Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 56c88eb4b3 |
@@ -372,6 +372,7 @@ class KGV_Termine_Plugin {
|
||||
$atts = shortcode_atts(array(
|
||||
'limit' => 0,
|
||||
'detail' => 1,
|
||||
'base_url' => '',
|
||||
), $atts, 'kgv_termine');
|
||||
|
||||
$detail_id = absint(get_query_var('kgv_termin'));
|
||||
@@ -379,7 +380,7 @@ class KGV_Termine_Plugin {
|
||||
$detail_id = absint(wp_unslash($_GET['kgv_termin']));
|
||||
}
|
||||
|
||||
$base_url = $this->get_current_page_url(false);
|
||||
$base_url = $this->resolve_termine_base_url($atts['base_url']);
|
||||
|
||||
if ($detail_id && (int) $atts['detail'] === 1) {
|
||||
return $this->render_detail_by_id($detail_id, $base_url);
|
||||
@@ -470,6 +471,7 @@ class KGV_Termine_Plugin {
|
||||
public function render_sidebar_shortcode($atts) {
|
||||
$atts = shortcode_atts(array(
|
||||
'limit' => 5,
|
||||
'base_url' => '',
|
||||
), $atts, 'kgv_termine_sidebar');
|
||||
|
||||
$rows = $this->get_frontend_rows(max(1, min(20, absint($atts['limit']))));
|
||||
@@ -478,7 +480,7 @@ public function render_sidebar_shortcode($atts) {
|
||||
return '<div class="kgv-sidebar-box">Keine Termine</div>';
|
||||
}
|
||||
|
||||
$base_url = $this->get_current_page_url(false);
|
||||
$base_url = $this->resolve_termine_base_url($atts['base_url']);
|
||||
|
||||
ob_start();
|
||||
echo '<div class="kgv-sidebar-box">';
|
||||
@@ -499,6 +501,58 @@ public function render_sidebar_shortcode($atts) {
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
private function resolve_termine_base_url($base_url = '') {
|
||||
if (!empty($base_url)) {
|
||||
$clean_url = esc_url_raw((string) $base_url);
|
||||
if ($clean_url) {
|
||||
return remove_query_arg(array_keys($_GET), $clean_url);
|
||||
}
|
||||
}
|
||||
|
||||
$shortcode_page_url = $this->find_termine_shortcode_page_url();
|
||||
if ($shortcode_page_url) {
|
||||
return $shortcode_page_url;
|
||||
}
|
||||
|
||||
return $this->get_current_page_url(false);
|
||||
}
|
||||
|
||||
private function find_termine_shortcode_page_url() {
|
||||
static $cached_url = null;
|
||||
|
||||
if (null !== $cached_url) {
|
||||
return $cached_url;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$like = '%' . $wpdb->esc_like('[kgv_termine') . '%';
|
||||
$post_id = (int) $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"SELECT ID
|
||||
FROM {$wpdb->posts}
|
||||
WHERE post_status = 'publish'
|
||||
AND post_type IN ('page', 'post')
|
||||
AND post_content LIKE %s
|
||||
ORDER BY CASE WHEN post_type = 'page' THEN 0 ELSE 1 END, ID ASC
|
||||
LIMIT 1",
|
||||
$like
|
||||
)
|
||||
);
|
||||
|
||||
if ($post_id) {
|
||||
$permalink = get_permalink($post_id);
|
||||
if ($permalink) {
|
||||
$cached_url = remove_query_arg(array_keys($_GET), $permalink);
|
||||
return $cached_url;
|
||||
}
|
||||
}
|
||||
|
||||
$cached_url = '';
|
||||
return $cached_url;
|
||||
}
|
||||
|
||||
private function get_current_page_url($with_query = true) {
|
||||
$page_url = '';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Description: Eigene Terminverwaltung mit separatem Admin-Interface, Frontend-Liste und Detailansicht per Shortcode.
|
||||
* Update URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Termine.git
|
||||
* Gitea Plugin URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Termine.git
|
||||
* Version: 1.0.5
|
||||
* Version: 1.0.6
|
||||
* Author: Ronny Grobel
|
||||
* Author URI: https://apex-project.de/
|
||||
* Text Domain: kgv-termine-admin
|
||||
|
||||
@@ -13,4 +13,4 @@ Funktionen:
|
||||
- Ausgabe der Termine im Frontend
|
||||
- einfache Pflege für Vereins- und Veranstaltungsseiten
|
||||
|
||||
Version: 1.0.2
|
||||
Version: 1.0.6
|
||||
|
||||
Reference in New Issue
Block a user