From 824e5a33243a629c77d1f2df6985bace72822cfc Mon Sep 17 00:00:00 2001 From: M_Viper Date: Thu, 8 Jan 2026 15:09:12 +0000 Subject: [PATCH] =?UTF-8?q?mc-multiserver-gallery/includes/class-mc-galler?= =?UTF-8?q?y-shortcodes.php=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../includes/class-mc-gallery-shortcodes.php | 892 ------------------ 1 file changed, 892 deletions(-) delete mode 100644 mc-multiserver-gallery/includes/class-mc-gallery-shortcodes.php diff --git a/mc-multiserver-gallery/includes/class-mc-gallery-shortcodes.php b/mc-multiserver-gallery/includes/class-mc-gallery-shortcodes.php deleted file mode 100644 index 884466a..0000000 --- a/mc-multiserver-gallery/includes/class-mc-gallery-shortcodes.php +++ /dev/null @@ -1,892 +0,0 @@ - 0, - 'server_ids' => '', - 'thumb_h' => 0 - ], $atts); - - $thumb_h = intval($atts['thumb_h']) ?: MC_Gallery_Core::get_default_thumb_h(); - $show_date = get_option(MC_Gallery_Core::OPTION_SHOW_DATE, true); - - $server_ids_to_search = []; - - // Server IDs sammeln - if (!empty($atts['server_ids'])) { - $raw_ids = explode(',', $atts['server_ids']); - foreach ($raw_ids as $id) { - $int_id = intval(trim($id)); - if ($int_id > 0) $server_ids_to_search[] = $int_id; - } - } else if (!empty($atts['server_id'])) { - $server_ids_to_search[] = intval($atts['server_id']); - } else { - // Alle aktiven Server laden - $all_server_posts = get_posts([ - 'post_type' => 'mc_server', - 'meta_key' => 'mc_server_active', - 'meta_value' => 1, - 'numberposts' => -1 - ]); - foreach ($all_server_posts as $s) { - $server_ids_to_search[] = $s->ID; - } - } - - if (empty($server_ids_to_search)) { - return ''; - } - - // Parameter auslesen - $q_player = isset($_GET['player']) ? sanitize_text_field($_GET['player']) : ''; - $q_server = isset($_GET['server']) ? intval($_GET['server']) : 0; - $q_album = isset($_GET['album']) ? intval($_GET['album']) : 0; - - $current_url = remove_query_arg(['player', 'server', 'album']); - - // ============================== - // 1. FALL: Album-Ansicht (wenn ?album=ID) - // ============================== - if ($q_album) { - return self::shortcode_album_view(['album_id' => $q_album]); - } - - // ============================== - // 2. FALL: Spieler-Spezifische Ansicht - // ============================== - if ($q_player) { - - // Header erstellen - $out = ''; - return $out; - } - - // ============================== - // 3. FALL: Haupt-Übersicht (Kein Spieler gewählt) - // ============================== - - // Alle mc_gallery Posts laden - $galleries = get_posts([ - 'post_type' => 'mc_gallery', - 'posts_per_page' => -1, - 'meta_query' => [ - [ - 'key' => 'mc_server', - 'value' => $server_ids_to_search, - 'compare' => 'IN' - ] - ], - 'orderby' => 'date', - 'order' => 'DESC' - ]); - - if (empty($galleries)) { - return ''; - } - - $all_images = []; - $players_list = []; - $player_counts = []; - - foreach ($galleries as $gallery) { - $player = get_post_meta($gallery->ID, 'mc_player', true); - - if (!in_array($player, $players_list)) { - $players_list[] = $player; - $player_counts[$player] = 0; - } - - $images = get_posts([ - 'post_type' => 'attachment', - 'post_parent' => $gallery->ID, - 'posts_per_page' => -1, - 'post_mime_type' => 'image', - 'orderby' => 'date', - 'order' => 'DESC' - ]); - - foreach ($images as $img) { - $img->mc_player_name = $player; - $img->mc_upload_date = $img->post_date; - $img->mc_gallery_id = $gallery->ID; - $all_images[] = $img; - $player_counts[$player]++; - } - } - - usort($all_images, function($a, $b) { - return strtotime($b->mc_upload_date) - strtotime($a->mc_upload_date); - }); - - $out = ''; - return $out; - } - - public static function shortcode_player($atts) { - $atts = shortcode_atts([ - 'player' => '', - 'server_id' => 0, - 'thumb_h' => 0 - ], $atts); - - $player = sanitize_text_field($atts['player']); - $server_id = intval($atts['server_id']); - $thumb_h = intval($atts['thumb_h']) ?: MC_Gallery_Core::get_default_thumb_h(); - $show_date = get_option(MC_Gallery_Core::OPTION_SHOW_DATE, true); - - if (!$player || !$server_id) { - return '
❌ Invalid request.
'; - } - - $gallery = MC_Gallery_Helpers::find_or_create_gallery_post($player, $server_id); - if (!$gallery) { - return '
📁 Gallery not found.
'; - } - - $images = get_posts([ - 'post_type' => 'attachment', - 'post_parent' => $gallery->ID, - 'posts_per_page' => -1, - 'post_mime_type' => 'image', - 'orderby' => 'date', - 'order' => 'DESC' - ]); - - $albums = get_posts([ - 'post_type' => 'mc_album', - 'posts_per_page' => -1, - 'meta_key' => 'mc_gallery_id', - 'meta_value' => $gallery->ID, - 'orderby' => 'date', - 'order' => 'DESC' - ]); - - if (empty($images) && empty($albums)) { - return ''; - } - - $current_url = remove_query_arg(['player', 'server', 'album']); - - $out = ''; - - return $out; - } - - public static function shortcode_all_albums_overview($atts) { - $show_date = get_option(MC_Gallery_Core::OPTION_SHOW_DATE, true); - $current_url = remove_query_arg(['player', 'server', 'album']); - - $albums = get_posts([ - 'post_type' => 'mc_album', - 'posts_per_page' => -1, - 'orderby' => 'date', - 'order' => 'DESC' - ]); - - if (empty($albums)) { - return ''; - } - - $out = ''; - return $out; - } - - public static function shortcode_album_view($atts) { - $atts = shortcode_atts([ - 'album_id' => 0, - 'server_id' => 0 - ], $atts); - - $album_id = intval($atts['album_id']); - $album = get_post($album_id); - $show_date = get_option(MC_Gallery_Core::OPTION_SHOW_DATE, true); - - if (!$album || $album->post_type !== 'mc_album') { - return '
❌ Album not found.
'; - } - - $images = get_posts([ - 'post_type' => 'attachment', - 'posts_per_page' => -1, - 'post_mime_type' => 'image', - 'meta_key' => 'mc_album_id', - 'meta_value' => $album_id, - 'orderby' => 'date', - 'order' => 'DESC' - ]); - - $gallery_id = get_post_meta($album_id, 'mc_gallery_id', true); - $gallery = get_post($gallery_id); - $player = $gallery ? get_post_meta($gallery_id, 'mc_player', true) : ''; - - $current_url = remove_query_arg(['album']); - - $out = ''; - return $out; - } - - public static function shortcode_upload($atts) { - $atts = shortcode_atts(['show' => '0'], $atts); - $show_default = ($atts['show'] === '1'); - - ob_start(); - ?> -
- -
- - - - - - -