From d6c23c086e10311d5bc001ff8cd59d9847de4860 Mon Sep 17 00:00:00 2001
From: M_Viper
Date: Tue, 10 Feb 2026 22:27:05 +0000
Subject: [PATCH] Upload mc-multiserver-gallery-pro.php via GUI
---
mc-multiserver-gallery-pro.php | 112 ++++++++++++++++++++++++++++++++-
1 file changed, 110 insertions(+), 2 deletions(-)
diff --git a/mc-multiserver-gallery-pro.php b/mc-multiserver-gallery-pro.php
index a0d5338..787c4b4 100644
--- a/mc-multiserver-gallery-pro.php
+++ b/mc-multiserver-gallery-pro.php
@@ -2,7 +2,7 @@
/*
Plugin Name: MC MultiServer Gallery PRO
Description: Professionelle Minecraft-Galerie mit Ingame-Verification, modernem UI, Lightbox und AJAX-Upload (multi-server fähig).
-Version: 2.5.2
+Version: 2.5.3
Author: M_Viper
Text Domain: mc-multiserver-gallery-pro
Domain Path: /languages
@@ -88,4 +88,112 @@ if (class_exists('MC_Gallery_Core')) {
}
if (class_exists('MC_Gallery_Shortcodes')) {
add_action('plugins_loaded', ['MC_Gallery_Shortcodes', 'init']);
-}
\ No newline at end of file
+}
+
+/* ================= SIDEBAR WIDGET: BILD DES TAGES ================= */
+class MC_Daily_Image_Widget extends WP_Widget {
+
+ public function __construct() {
+ parent::__construct(
+ 'mc_daily_image_widget',
+ 'MC Bild des Tages',
+ array( 'description' => 'Zeigt jeden Tag ein anderes, zufälliges Bild aus allen MC Galerien an.' )
+ );
+ }
+
+ // Frontend-Ausgabe
+ public function widget( $args, $instance ) {
+ $title = ! empty( $instance['title'] ) ? $instance['title'] : 'Bild des Tages';
+
+ echo $args['before_widget'];
+ if ( ! empty( $title ) ) {
+ echo $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title'];
+ }
+
+ // 1. Eindeutiger Key für heute (z.B. mc_daily_image_2023-10-27)
+ $today_key = 'mc_daily_image_' . date('Y-m-d');
+
+ // 2. Prüfen, ob wir heute schon ein Bild ausgewählt haben
+ $image_id = get_transient( $today_key );
+
+ // Falls kein Bild für heute im Cache ist:
+ if ( false === $image_id ) {
+
+ // Alle MC Galerien finden
+ $galleries = get_posts([
+ 'post_type' => 'mc_gallery',
+ 'numberposts' => -1,
+ 'fields' => 'ids',
+ 'post_status' => 'publish'
+ ]);
+
+ if ( ! empty( $galleries ) ) {
+ // Ein zufälliges Bild aus diesen Galerien holen
+ $random_image = get_posts([
+ 'post_type' => 'attachment',
+ 'post_mime_type' => 'image',
+ 'post_parent__in'=> $galleries,
+ 'numberposts' => 1,
+ 'orderby' => 'rand', // Zufällig wählen
+ 'suppress_filters' => false
+ ]);
+
+ if ( ! empty( $random_image ) ) {
+ $image_id = $random_image[0]->ID;
+ // Das Bild für 24 Stunden (bis morgen) speichern
+ set_transient( $today_key, $image_id, DAY_IN_SECONDS );
+ }
+ }
+ }
+
+ // 3. Bild anzeigen (wird aus Cache oder neu geladen)
+ if ( $image_id && wp_attachment_is_image( $image_id ) ) {
+
+ $img_src = wp_get_attachment_image_src( $image_id, 'medium' );
+ $full_src = wp_get_attachment_image_src( $image_id, 'full' );
+
+ if ( $img_src ) {
+ ?>
+
+ Keine Bilder verfügbar.
';
+ }
+
+ echo $args['after_widget'];
+ }
+
+ // Backend Formular
+ public function form( $instance ) {
+ $title = ! empty( $instance['title'] ) ? $instance['title'] : 'Bild des Tages';
+ ?>
+
+ Titel:
+
+
+
+ Dieses Widget wählt einmal pro Tag (um 00:00 Uhr) ein zufälliges Bild aus allen Spieler-Galerien aus und zeigt es an. Der Bildtext ist ausgeblendet.
+
+