3 Commits

3 changed files with 99 additions and 15 deletions

View File

@@ -372,6 +372,7 @@ class KGV_Termine_Plugin {
$atts = shortcode_atts(array( $atts = shortcode_atts(array(
'limit' => 0, 'limit' => 0,
'detail' => 1, 'detail' => 1,
'base_url' => '',
), $atts, 'kgv_termine'); ), $atts, 'kgv_termine');
$detail_id = absint(get_query_var('kgv_termin')); $detail_id = absint(get_query_var('kgv_termin'));
@@ -379,7 +380,7 @@ class KGV_Termine_Plugin {
$detail_id = absint(wp_unslash($_GET['kgv_termin'])); $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) { if ($detail_id && (int) $atts['detail'] === 1) {
return $this->render_detail_by_id($detail_id, $base_url); return $this->render_detail_by_id($detail_id, $base_url);
@@ -470,6 +471,7 @@ class KGV_Termine_Plugin {
public function render_sidebar_shortcode($atts) { public function render_sidebar_shortcode($atts) {
$atts = shortcode_atts(array( $atts = shortcode_atts(array(
'limit' => 5, 'limit' => 5,
'base_url' => '',
), $atts, 'kgv_termine_sidebar'); ), $atts, 'kgv_termine_sidebar');
$rows = $this->get_frontend_rows(max(1, min(20, absint($atts['limit'])))); $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>'; 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(); ob_start();
echo '<div class="kgv-sidebar-box">'; echo '<div class="kgv-sidebar-box">';
@@ -499,6 +501,58 @@ public function render_sidebar_shortcode($atts) {
return ob_get_clean(); 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) { private function get_current_page_url($with_query = true) {
$page_url = ''; $page_url = '';

View File

@@ -5,10 +5,11 @@
* Description: Eigene Terminverwaltung mit separatem Admin-Interface, Frontend-Liste und Detailansicht per Shortcode. * 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 * 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 * Gitea Plugin URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Termine.git
* Version: 1.0.4 * Version: 1.0.6
* Author: Ronny Grobel * Author: Ronny Grobel
* Author URI: https://apex-project.de/ * Author URI: https://apex-project.de/
* Text Domain: kgv-termine-admin * Text Domain: kgv-termine-admin
* Requires Plugins: KGV-Updater
*/ */
if (!defined('ABSPATH')) { if (!defined('ABSPATH')) {

View File

@@ -1,16 +1,45 @@
KGV Termine WordPress Plugin === KGV Termine ===
Contributors: ronnygrobel
Tags: events, termine, kalender, verein, shortcode
Requires at least: 6.0
Tested up to: 6.8
Stable tag: 1.0.6
Requires PHP: 7.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Beschreibung: Terminverwaltung mit Frontend-Liste, Detailansicht und Sidebar-Shortcode.
KGV Termine ist ein WordPress-Plugin zur Verwaltung und Anzeige von Terminen im Vereinsumfeld.
Installation: == Description ==
1. Plugin in den Ordner `wp-content/plugins/` hochladen
2. In WordPress unter `Plugins` aktivieren
3. Die Termine anschließend im Backend verwalten
Funktionen: KGV Termine verwaltet Vereins- und Veranstaltungsdaten im Backend und gibt sie im Frontend ueber Shortcodes aus.
- Terminverwaltung im WordPress-Backend
- Ausgabe der Termine im Frontend
- einfache Pflege für Vereins- und Veranstaltungsseiten
Version: 1.0.2 = Features =
* Terminverwaltung im WordPress-Backend
* Frontend-Liste und Detailansicht
* Sidebar-Ausgabe naechster Termine
* Flexible Shortcodes fuer Uebersicht und Details
== Installation ==
1. Plugin in `wp-content/plugins/KGV-Termine/` hochladen.
2. Plugin aktivieren.
3. Termine im Backend anlegen.
4. Shortcodes auf Seiten einbinden.
== Frequently Asked Questions ==
= Wie gebe ich die Terminliste aus? =
Mit `[kgv_termine]`.
= Gibt es eine Sidebar-Ausgabe? =
Ja, mit `[kgv_termine_sidebar]`.
== Changelog ==
= 1.0.6 =
* Detail-Link-Logik verbessert, damit Termin-Links auch ausserhalb der Terminseite korrekt funktionieren.
* WordPress-Readme auf Standardformat umgestellt.