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 '
🚫 Keine aktiven Server gefunden.
';
- }
-
- // 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 = '';
- $out .= '';
-
- // Alle Galerien für diesen Spieler laden
- $all_galleries = get_posts([
- 'post_type' => 'mc_gallery',
- 'posts_per_page' => -1,
- 'meta_query' => [
- [
- 'key' => 'mc_server',
- 'value' => $server_ids_to_search,
- 'compare' => 'IN'
- ]
- ]
- ]);
-
- // Filter nach Spielername
- $player_galleries = [];
- $player_gallery_ids = [];
- foreach ($all_galleries as $gal) {
- $p = get_post_meta($gal->ID, 'mc_player', true);
- if ($p === $q_player) {
- $player_galleries[] = $gal;
- $player_gallery_ids[] = $gal->ID;
- }
- }
-
- // ALBEN dieses Spielers laden
- $albums = [];
- if (!empty($player_gallery_ids)) {
- $albums = get_posts([
- 'post_type' => 'mc_album',
- 'posts_per_page' => -1,
- 'meta_key' => 'mc_gallery_id',
- 'value' => $player_gallery_ids,
- 'compare' => 'IN',
- 'orderby' => 'date',
- 'order' => 'DESC'
- ]);
- }
-
- // --- HTML Alben ---
- if (!empty($albums)) {
- $out .= '
';
- $out .= '
📁 Alben ('.count($albums).')
';
- $out .= '
';
-
- foreach ($albums as $album) {
- $album_images = get_posts([
- 'post_type' => 'attachment',
- 'posts_per_page' => 1,
- 'post_mime_type' => 'image',
- 'post_parent' => get_post_meta($album->ID, 'mc_gallery_id', true),
- 'orderby' => 'date',
- 'order' => 'DESC'
- ]);
-
- $cover_url = '';
- if (!empty($album_images)) {
- $cover_array = wp_get_attachment_image_src($album_images[0]->ID, 'medium');
- $cover_url = $cover_array ? $cover_array[0] : '';
- }
-
- $album_count = get_post_meta($album->ID, 'mc_image_count', true) ?: 0;
- $album_link = add_query_arg(['album' => $album->ID], $current_url);
-
- $out .= '
';
- if ($cover_url) {
- $out .= '';
- } else {
- $out .= '📁
';
- }
- $out .= '';
- $out .= '
'.esc_html($album->post_title).'
';
- $out .= ''.$album_count.' Images';
- $out .= '';
- $out .= '';
- }
-
- $out .= '
';
- $out .= '
';
- }
-
- // Alle Bilder des Spielers laden
- $all_images = get_posts([
- 'post_type' => 'attachment',
- 'post_parent' => $player_gallery_ids,
- 'posts_per_page' => -1,
- 'post_mime_type' => 'image',
- 'orderby' => 'date',
- 'order' => 'DESC'
- ]);
-
- // BILDER FILTER: Nur Bilder, die in einem Album sind
- $images_linked_to_albums = [];
- foreach ($all_images as $img) {
- $album_id = get_post_meta($img->ID, 'mc_album_id', true);
- // Prüfen ob Album ID existiert und nicht 0 ist
- if (!empty($album_id) && $album_id > 0) {
- $images_linked_to_albums[] = $img;
- }
- }
-
- // --- HTML Bilder (NUR VERKNÜPFTE) ---
- if (!empty($images_linked_to_albums)) {
- $out .= '
';
- $out .= '
🖼️ Alle Bilder ('.count($images_linked_to_albums).')
';
- $out .= '
';
-
- foreach ($images_linked_to_albums as $img) {
- $full = wp_get_attachment_url($img->ID);
- $upload_date = date_i18n('d.m.Y', strtotime($img->post_date));
-
- $album_id = get_post_meta($img->ID, 'mc_album_id', true);
- $album_name = '';
- if ($album_id) {
- $album_post = get_post($album_id);
- if ($album_post) {
- $album_name = $album_post->post_title;
- }
- }
-
- $metadata = wp_get_attachment_metadata($img->ID);
- $width = isset($metadata['width']) ? $metadata['width'] : 0;
- $height = isset($metadata['height']) ? $metadata['height'] : 0;
- $aspect_ratio = ($width && $height) ? ($width / $height) : 1;
-
- $resize_pct = intval(get_option(MC_Gallery_Core::OPTION_RESIZE_PCT, 100));
- if ($resize_pct < 100 && isset($metadata['sizes']['mc-optimized'])) {
- $upload_dir = wp_upload_dir();
- $file_path = dirname($metadata['file']) . '/' . $metadata['sizes']['mc-optimized']['file'];
- $thumb = $upload_dir['baseurl'] . '/' . $file_path;
- } else {
- $thumb_array = wp_get_attachment_image_src($img->ID, 'medium');
- $thumb = $thumb_array ? $thumb_array[0] : $full;
- }
-
- $data_date_attr = $show_date ? 'data-date="'.esc_attr($upload_date).'"' : '';
- $views = get_post_meta($img->ID, 'mc_views', true) ?: 0;
-
- $out .= '
';
- $out .= '';
- $out .= '
👁️ '.$views.'
';
- if ($show_date) {
- $out .= '
'.$upload_date.'
';
- }
- $out .= '
.')
';
- $out .= '
';
- $out .= '
';
- $out .= '
'.esc_html($q_player).'
';
- if ($album_name) {
- $out .= '
📁 '.esc_html($album_name).'
';
- }
- $out .= '
';
- $out .= '
';
- $out .= '
';
- $out .= '';
- }
-
- $out .= '
';
- $out .= '
';
- }
-
- $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 '🎮 No galleries on selected servers yet.
';
- }
-
- $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 = '';
-
- // Filter Bar
- if (!empty($players_list)) {
- $active_all = empty($q_player) ? 'mc-tag-active' : '';
-
- $out .= '
';
- $out .= '';
- $out .= '
';
- }
-
- // Bilder Grid (Gemischt - Alle Bilder, auch unverknüpfte)
- if (!empty($all_images)) {
- $out .= '
';
-
- foreach ($all_images as $img) {
- $full = wp_get_attachment_url($img->ID);
- $player_name = esc_html($img->mc_player_name);
- $upload_date = date_i18n('d.m.Y', strtotime($img->mc_upload_date));
-
- $album_id = get_post_meta($img->ID, 'mc_album_id', true);
- $album_name = '';
- if ($album_id) {
- $album_post = get_post($album_id);
- if ($album_post) {
- $album_name = $album_post->post_title;
- }
- }
-
- $metadata = wp_get_attachment_metadata($img->ID);
- $width = isset($metadata['width']) ? $metadata['width'] : 0;
- $height = isset($metadata['height']) ? $metadata['height'] : 0;
- $aspect_ratio = ($width && $height) ? ($width / $height) : 1;
-
- $resize_pct = intval(get_option(MC_Gallery_Core::OPTION_RESIZE_PCT, 100));
-
- if ($resize_pct < 100 && isset($metadata['sizes']['mc-optimized'])) {
- $upload_dir = wp_upload_dir();
- $file_path = dirname($metadata['file']) . '/' . $metadata['sizes']['mc-optimized']['file'];
- $thumb = $upload_dir['baseurl'] . '/' . $file_path;
- } else {
- $thumb_array = wp_get_attachment_image_src($img->ID, 'medium');
- $thumb = $thumb_array ? $thumb_array[0] : $full;
- }
-
- $data_date_attr = $show_date ? 'data-date="'.esc_attr($upload_date).'"' : '';
- $views = get_post_meta($img->ID, 'mc_views', true) ?: 0;
-
- $out .= '
';
- $out .= '';
- $out .= '
👁️ '.$views.'
';
- if ($show_date) {
- $out .= '
'.$upload_date.'
';
- }
- $out .= '
.')
';
- $out .= '
';
- $out .= '
';
- $out .= '
'.$player_name.'
';
- if ($album_name) {
- $out .= '
📁 '.esc_html($album_name).'
';
- }
- $out .= '
';
- $out .= '
';
- $out .= '
';
- $out .= '';
- }
-
- $out .= '
';
- } else {
- $out .= '
🔍 Keine Bilder gefunden für den ausgewählten Filter.
';
- }
-
- $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 '
-
- 📷 '.esc_html($player).' has not uploaded any images yet.
-
-
';
- }
-
- $current_url = remove_query_arg(['player', 'server', 'album']);
-
- $out = '';
- $out .= '';
-
- if (!empty($albums)) {
- $out .= '
';
- $out .= '
📁 Albums ('.count($albums).')
';
- $out .= '
';
-
- foreach ($albums as $album) {
- $album_images = get_posts([
- 'post_type' => 'attachment',
- 'posts_per_page' => 1,
- 'post_mime_type' => 'image',
- 'post_parent' => get_post_meta($album->ID, 'mc_gallery_id', true),
- 'orderby' => 'date',
- 'order' => 'DESC'
- ]);
-
- $cover_url = '';
- if (!empty($album_images)) {
- $cover_array = wp_get_attachment_image_src($album_images[0]->ID, 'medium');
- $cover_url = $cover_array ? $cover_array[0] : '';
- }
-
- $album_count = get_post_meta($album->ID, 'mc_image_count', true) ?: 0;
- $album_link = add_query_arg(['album' => $album->ID], $current_url);
-
- $out .= '
';
- if ($cover_url) {
- $out .= '';
- } else {
- $out .= '📁
';
- }
- $out .= '';
- $out .= '
'.esc_html($album->post_title).'
';
- $out .= ''.$album_count.' Images';
- $out .= '';
- $out .= '';
- }
-
- $out .= '
';
- $out .= '
';
- }
-
- if (!empty($images)) {
- $out .= '
';
- $out .= '
🖼️ Alle Bilder ('.count($images).')
';
- $out .= '
';
-
- foreach ($images as $img) {
- $full = wp_get_attachment_url($img->ID);
- $upload_date = date_i18n('d.m.Y', strtotime($img->post_date));
-
- $metadata = wp_get_attachment_metadata($img->ID);
- $width = isset($metadata['width']) ? $metadata['width'] : 0;
- $height = isset($metadata['height']) ? $metadata['height'] : 0;
- $aspect_ratio = ($width && $height) ? ($width / $height) : 1;
-
- $resize_pct = intval(get_option(MC_Gallery_Core::OPTION_RESIZE_PCT, 100));
- if ($resize_pct < 100 && isset($metadata['sizes']['mc-optimized'])) {
- $upload_dir = wp_upload_dir();
- $file_path = dirname($metadata['file']) . '/' . $metadata['sizes']['mc-optimized']['file'];
- $thumb = $upload_dir['baseurl'] . '/' . $file_path;
- } else {
- $thumb_array = wp_get_attachment_image_src($img->ID, 'medium');
- $thumb = $thumb_array ? $thumb_array[0] : $full;
- }
-
- $data_date_attr = $show_date ? 'data-date="'.esc_attr($upload_date).'"' : '';
- $views = get_post_meta($img->ID, 'mc_views', true) ?: 0;
-
- $out .= '
';
- $out .= '';
- $out .= '
👁️ '.$views.'
';
- if ($show_date) {
- $out .= '
'.$upload_date.'
';
- }
- $out .= '
.')
';
- $out .= '
';
- $out .= '
';
- $out .= '
'.esc_html($player).'
';
- $out .= '
';
- $out .= '
';
- $out .= '
';
- $out .= '';
- }
-
- $out .= '
';
- $out .= '
';
- }
-
- $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 '📁 Es wurden noch keine Alben erstellt.
';
- }
-
- $out = '';
- $out .= '';
-
- $out .= '
';
-
- foreach ($albums as $album) {
- $album_count = get_post_meta($album->ID, 'mc_image_count', true) ?: 0;
-
- $cover_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'
- ]);
-
- $cover_url = '';
- if (!empty($cover_images)) {
- $cover_array = wp_get_attachment_image_src($cover_images[0]->ID, 'medium');
- $cover_url = $cover_array ? $cover_array[0] : '';
- }
-
- $album_link = add_query_arg(['album' => $album->ID], $current_url);
-
- $gallery_id = get_post_meta($album->ID, 'mc_gallery_id', true);
- $player_name = '';
- if ($gallery_id) {
- $player_name = get_post_meta($gallery_id, 'mc_player', true);
- }
-
- $out .= '
';
- if ($cover_url) {
- $out .= '';
- } else {
- $out .= '📁
';
- }
- $out .= '';
- $out .= '
'.esc_html($album->post_title).'
';
- $out .= ''.$album_count.' Images';
- if ($player_name) {
- $out .= 'by '.esc_html($player_name).'';
- }
- $out .= '';
- $out .= '';
- }
-
- $out .= '
';
- $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 = '';
- $out .= '';
-
- if (!empty($images)) {
- $out .= '
';
-
- foreach ($images as $img) {
- $full = wp_get_attachment_url($img->ID);
- $upload_date = date_i18n('d.m.Y', strtotime($img->post_date));
-
- $metadata = wp_get_attachment_metadata($img->ID);
- $width = isset($metadata['width']) ? $metadata['width'] : 0;
- $height = isset($metadata['height']) ? $metadata['height'] : 0;
- $aspect_ratio = ($width && $height) ? ($width / $height) : 1;
-
- $thumb_array = wp_get_attachment_image_src($img->ID, 'medium');
- $thumb = $thumb_array ? $thumb_array[0] : $full;
-
- $data_date_attr = $show_date ? 'data-date="'.esc_attr($upload_date).'"' : '';
- $views = get_post_meta($img->ID, 'mc_views', true) ?: 0;
-
- $out .= '
';
- $out .= '';
- $out .= '
👁️ '.$views.'
';
- if ($show_date) {
- $out .= '
'.$upload_date.'
';
- }
- $out .= '
.')
';
- $out .= '
';
- $out .= '';
- }
-
- $out .= '
';
- } else {
- $out .= '
📷 This album contains no images yet.
';
- }
-
- $out .= '
';
- return $out;
- }
-
- public static function shortcode_upload($atts) {
- $atts = shortcode_atts(['show' => '0'], $atts);
- $show_default = ($atts['show'] === '1');
-
- ob_start();
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 🎮 Gehe auf den Server und führe den folgenden Befehl aus:
-
-
-
- Waiting...
-
-
-
-
- 💡 Gib im Chat ein: /verify [dein-token]
-
-
-
-
-
-
-
-
-
-
- ✓ Session aktiv
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Keine Bilder gewählt
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-