festive-seasons-pro.php aktualisiert

This commit is contained in:
2026-01-06 23:30:11 +00:00
parent af031542e9
commit 056cf4d287

View File

@@ -2,7 +2,7 @@
/*
Plugin Name: Festive Seasons Pro
Description: Zeigt saisonale Effekte (Schnee, Eier, Spinnen, Ballons, Feuerwerk) für feste Feiertage und individuelle Geburtstage an.
Version: 1.0
Version: 1.1
Author: M_Viper
*/
@@ -21,10 +21,44 @@ class Festive_Seasons_Pro {
add_action('wp_footer', [$this, 'render_music_consent']);
add_action('admin_menu', [$this, 'add_admin_menu_page']);
add_action('admin_init', [$this, 'register_settings']);
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
add_action('widgets_init', [$this, 'register_widget']);
add_shortcode('festive_event', [$this, 'render_shortcode']);
}
// Admin-Scripts laden
public function enqueue_admin_scripts($hook) {
// Nur auf der Plugin-Einstellungsseite laden
if ($hook !== 'settings_page_festive-seasons-pro') {
return;
}
// jQuery ist standardmäßig in WordPress verfügbar
wp_enqueue_script('jquery');
// Inline-Script für Event-Verwaltung
wp_add_inline_script('jquery', '
jQuery(document).ready(function($) {
// Neues Ereignis hinzufügen
$("#fsp-add-event").on("click", function() {
var index = $("#fsp-events-container .fsp-event-row").length;
var newRow = \'<div class="fsp-event-row" style="margin-bottom: 10px; display: flex; gap: 10px; align-items: center;">\' +
\'<input type="text" name="fsp_events[\' + index + \'][name]" placeholder="Name (z.B. Max)" style="width: 200px;" />\' +
\'<input type="text" name="fsp_events[\' + index + \'][date]" placeholder="Datum (TT-MM)" style="width: 100px;" />\' +
\'<input type="text" name="fsp_events[\' + index + \'][text]" placeholder="Text (z.B. wird 30!)" style="flex-grow: 1;" />\' +
\'<button type="button" class="button button-secondary fsp-remove-event">Entfernen</button>\' +
\'</div>\';
$("#fsp-events-container").append(newRow);
});
// Ereignis entfernen
$(document).on("click", ".fsp-remove-event", function() {
$(this).closest(".fsp-event-row").remove();
});
});
');
}
public function get_active_events() {
if (isset($_GET['fsp_test_date'])) {
$today = sanitize_text_field($_GET['fsp_test_date']);
@@ -56,7 +90,7 @@ class Festive_Seasons_Pro {
return [
'advent' => ['name' => 'Adventszeit', 'start' => "$year-12-01", 'end' => "$year-12-23", 'class' => 'festive-advent', 'effects' => ['snow']],
'christmas' => ['name' => 'Weihnachten', 'start' => "$year-12-24", 'end' => "$year-12-26", 'class' => 'festive-christmas', 'effects' => ['snow', 'music', 'star', 'santa']], // NEU: Santa-Animation
'christmas' => ['name' => 'Weihnachten', 'start' => "$year-12-24", 'end' => "$year-12-26", 'class' => 'festive-christmas', 'effects' => ['snow', 'music', 'star', 'santa']],
'newyear' => ['name' => 'Silvester', 'start' => "$year-12-31", 'end' => ($year + 1) . "-01-01", 'class' => 'festive-newyear', 'effects' => ['newyear_fireworks']],
'halloween' => ['name' => 'Halloween', 'start' => "$year-10-31", 'end' => "$year-10-31", 'class' => 'festive-halloween', 'effects' => ['spiders']],
'easter' => ['name' => 'Ostern', 'start' => date('Y-m-d', strtotime($easter_date . ' -1 day')), 'end' => date('Y-m-d', strtotime($easter_date)), 'class' => 'festive-easter', 'effects' => ['eggs']],
@@ -133,7 +167,7 @@ class Festive_Seasons_Pro {
case 'star':
wp_enqueue_script('fsp-star', plugin_dir_url(__FILE__) . 'assets/js/christmas-star.js', ['jquery'], '3.4', true);
break;
case 'santa': // NEU: Santa-Animation
case 'santa':
wp_enqueue_script('fsp-santa', plugin_dir_url(__FILE__) . 'assets/js/santa-sleigh.js', ['jquery'], '3.4', true);
break;
case 'newyear_fireworks':
@@ -250,12 +284,12 @@ jQuery(document).ready(function($) {
$events = get_option('fsp_events', []);
?>
<div class="wrap">
<h1>Festive Seasons Pro Einstellungen</h1>
<h1>🎉 Festive Seasons Pro Einstellungen</h1>
<form method="post" action="options.php">
<?php settings_fields('fsp_settings_group'); ?>
<?php do_settings_sections('fsp_settings_group'); ?>
<h2>Allgemeine Einstellungen</h2>
<h2>⚙️ Allgemeine Einstellungen</h2>
<table class="form-table" role="presentation">
<tr>
<th scope="row">Musik-Einwilligung</th>
@@ -267,7 +301,7 @@ jQuery(document).ready(function($) {
</tr>
</table>
<h2>Feste Feiertage</h2>
<h2>🎄 Feste Feiertage</h2>
<table class="form-table" role="presentation">
<?php foreach ($this->get_fixed_events() as $key => $event): ?>
<tr>
@@ -279,10 +313,11 @@ jQuery(document).ready(function($) {
<?php endforeach; ?>
</table>
<h2>Geburtstage & Jubiläe</h2>
<h2>🎂 Geburtstage & Jubiläen</h2>
<p>Hier können Sie beliebige Ereignisse hinzufügen. Das Datum wird im Format <strong>TT-MM</strong> (z.B. 24-12) oder <strong>JJJJ-MM-TT</strong> (z.B. 2024-05-10) angegeben.</p>
<div id="fsp-events-container">
<?php if (is_array($events)) : ?>
<div id="fsp-events-container" style="margin-bottom: 15px;">
<?php if (is_array($events) && !empty($events)) : ?>
<?php foreach ($events as $index => $event) : ?>
<div class="fsp-event-row" style="margin-bottom: 10px; display: flex; gap: 10px; align-items: center;">
<input type="text" name="fsp_events[<?php echo $index; ?>][name]" placeholder="Name (z.B. Max)" value="<?php echo esc_attr($event['name'] ?? ''); ?>" style="width: 200px;" />
@@ -293,24 +328,14 @@ jQuery(document).ready(function($) {
<?php endforeach; ?>
<?php endif; ?>
</div>
<button type="button" id="fsp-add-event" class="button button-primary">+ Neues Ereignis hinzufügen</button>
<button type="button" id="fsp-add-event" class="button button-primary" style="margin-bottom: 20px;">
<span class="dashicons dashicons-plus-alt" style="margin-top: 3px;"></span> Neues Ereignis hinzufügen
</button>
<?php submit_button(); ?>
<?php submit_button('Einstellungen speichern'); ?>
</form>
</div>
<script>
jQuery(document).ready(function($) {
$("#fsp-add-event").on("click", function() {
var index = $("#fsp-events-container .fsp-event-row").length;
var newRow = \'<div class="fsp-event-row" style="margin-bottom: 10px; display: flex; gap: 10px; align-items: center;"><input type="text" name="fsp_events[\' + index + \'][name]" placeholder="Name (z.B. Max)" style="width: 200px;" /><input type="text" name="fsp_events[\' + index + \'][date]" placeholder="Datum (TT-MM)" style="width: 100px;" /><input type="text" name="fsp_events[\' + index + \'][text]" placeholder="Text (z.B. wird 30!)" style="flex-grow: 1;" /><button type="button" class="button button-secondary fsp-remove-event">Entfernen</button></div>\';
$("#fsp-events-container").append(newRow);
});
$(document).on("click", ".fsp-remove-event", function() {
$(this).closest(".fsp-event-row").remove();
});
});
</script>
<?php
}
@@ -339,7 +364,7 @@ jQuery(document).ready(function($) {
$audio_url = plugin_dir_url(__FILE__) . 'assets/audio/xmas-jingle.mp3';
echo '<div id="fsp-music-consent" style="position:fixed;bottom:20px;right:20px;background:#fff;color:#333;padding:20px;border-radius:8px;z-index:99999;box-shadow:0 4px 15px rgba(0,0,0,0.2);display:none;max-width:300px;">
<p style="margin:0 0 15px 0;">Weihnachtsmusik abspielen?</p>
<p style="margin:0 0 15px 0;">🎵 Weihnachtsmusik abspielen?</p>
<button id="fsp-music-yes" style="background:#c0392b;color:#fff;border:none;padding:8px 15px;border-radius:5px;cursor:pointer;margin-right:10px;">Ja</button>
<button id="fsp-music-no" style="background:#bdc3c7;color:#333;border:none;padding:8px 15px;border-radius:5px;cursor:pointer;">Nein</button>
</div>
@@ -416,4 +441,4 @@ class FSP_Widget extends WP_Widget {
}
}
$festive_seasons_pro_instance = new Festive_Seasons_Pro();
$festive_seasons_pro_instance = new Festive_Seasons_Pro();