diff --git a/img/screenshot.png b/img/screenshot.png new file mode 100644 index 0000000..4decb4f Binary files /dev/null and b/img/screenshot.png differ diff --git a/includes/admin-banner.php b/includes/admin-banner.php new file mode 100644 index 0000000..3075122 --- /dev/null +++ b/includes/admin-banner.php @@ -0,0 +1,108 @@ + 0 && (time() - $ts) < (WP_MULTI_BANNER_DAYS * DAY_IN_SECONDS); + } + + // Admin-Banner als Notice mit Blauem Hintergrund (#0073aa) + function wp_multi_add_warning_banner() { + // Nach dem Schließen für WP_MULTI_BANNER_DAYS Tage nicht mehr anzeigen + if (wp_multi_banner_is_dismissed()) { + return; + } + + // Verwende printf für bessere Lesbarkeit und Übersetzbarkeit + printf( + '
', + esc_attr(wp_create_nonce('wp_multi_dismiss_banner')), + esc_html__('Danke, dass du WP Multi verwendest!', 'wp-multi'), + esc_html__('Dein Feedback hilft uns, das Plugin ständig zu verbessern. Wenn du Fehler entdeckst oder Verbesserungsvorschläge hast, besuche bitte unsere', 'wp-multi'), + 'https://git.viper.ipv64.net/M_Viper/wp-multi', + esc_html__('Gitea-Seite', 'wp-multi'), + esc_html__('und teile uns deine Ideen mit!', 'wp-multi'), + esc_html__('Support', 'wp-multi'), + esc_html__('Bei Fragen oder Supportanfragen kannst du uns über', 'wp-multi'), + 'https://discord.com/invite/FdRs4BRd8D', + esc_html__('Discord', 'wp-multi'), + esc_html__('oder', 'wp-multi'), + 'https://t.me/M_Viper04', + esc_html__('Telegram', 'wp-multi'), + esc_html__('erreichen.', 'wp-multi') + ); + + // Beim Klick auf das X den Schließ-Zeitpunkt speichern (per AJAX) + ?> + + sprintf( + '%s', + esc_url('https://discord.com/invite/FdRs4BRd8D'), + esc_html__('Discord Support', 'wp-multi') + ), + 'support_telegram' => sprintf( + '%s', + esc_url('https://t.me/M_Viper04'), + esc_html__('Telegram Support', 'wp-multi') + ), + ); + $links = array_merge($links, $new_links); + } + return $links; + } + add_filter('plugin_row_meta', 'wp_multi_plugin_row_meta', 10, 2); + + diff --git a/includes/admin-menu.php b/includes/admin-menu.php new file mode 100644 index 0000000..e16522e --- /dev/null +++ b/includes/admin-menu.php @@ -0,0 +1,88 @@ + 20, // Maximale Beiträge pro Seite + ), $atts, 'alphabetical_index'); + + // Hole alle Beiträge + $args = array( + 'post_type' => 'post', + 'posts_per_page' => -1, + 'orderby' => 'title', + 'order' => 'ASC', + ); + + $posts = get_posts($args); + + // Beiträge nach Anfangsbuchstaben gruppieren + $alphabet = range('A', 'Z'); + $posts_by_letter = array(); + + foreach ($posts as $post) { + $first_letter = strtoupper(substr($post->post_title, 0, 1)); + if (in_array($first_letter, $alphabet)) { + $posts_by_letter[$first_letter][] = $post; + } + } + + // Holen des aktuellen Buchstabens aus der URL + $letter = isset($_GET['letter']) ? strtoupper($_GET['letter']) : ''; // Der Buchstabe aus der URL + + // Bestimme, welche Beiträge angezeigt werden + $posts_in_letter = []; + if ($letter && isset($posts_by_letter[$letter])) { + $posts_in_letter = $posts_by_letter[$letter]; + } + + // Teile die Beiträge in zwei Hälften für die Boxen + $halfway = ceil(count($posts_in_letter) / 2); // Rundet die Hälfte auf + $first_half = array_slice($posts_in_letter, 0, $halfway); // Erste Hälfte der Beiträge + $second_half = array_slice($posts_in_letter, $halfway); // Zweite Hälfte der Beiträge + + // Ausgabe + ob_start(); + ?> + +' . esc_html__('Die Analytics-Tabelle existiert nicht. Bitte aktiviere das Plugin erneut.', 'wp-multi') . '
| + | + | + | + | + |
|---|---|---|---|---|
| user_id); ?> | +action); ?> | ++ post_id) { + $post_title = get_the_title($row->post_id); + echo esc_html($post_title ?: __('Kein Titel verfügbar', 'wp-multi')); + } else { + echo esc_html__('Kein Beitrag', 'wp-multi'); + } + ?> + | +post_id ?: '-'); ?> | +timestamp); ?> | +
' . __('Konfiguriere die Sicherheitseinstellungen für den Brute-Force-Schutz deiner Website. Aktiviere oder deaktiviere die wöchentliche Zusammenfassung der fehlgeschlagenen Anmeldeversuche.', 'wp-multi') . '
'; +} + +// Callback für das Settings Field +function wp_multi_summary_enabled_callback() { + $summary_enabled = get_option('wp_multi_summary_enabled', 1); + ?> + /> + + + + + + prefix . 'blocked_ips'; + + $five_days_ago = date('Y-m-d H:i:s', strtotime('-5 days')); + $per_page = 50; + $page = max(1, isset($_GET['paged']) ? intval($_GET['paged']) : 1); + $offset = ($page - 1) * $per_page; + + $blocked_ips = $wpdb->get_results( + $wpdb->prepare( + "SELECT * FROM $table_name WHERE last_attempt >= %s ORDER BY last_attempt DESC LIMIT %d OFFSET %d", + $five_days_ago, + $per_page, + $offset + ) + ); + + $total_ips = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE last_attempt >= %s", $five_days_ago)); + $total_pages = ceil($total_ips / $per_page); + + wpmt_admin_page_open( + __('Blockierte IPs', 'wp-multi'), + __('Vom Brute-Force-Schutz erfasste IP-Adressen der letzten 5 Tage', 'wp-multi') + ); + + wpmt_admin_card_open(); + if (empty($blocked_ips)) { + wpmt_admin_notice('info', __('Keine blockierten IPs gefunden.', 'wp-multi')); + } else { + ?> +| + | + | + | + | + |
|---|---|---|---|---|
| id); ?> | +ip); ?> | +attempts); ?> | +last_attempt); ?> | ++ + + + | +
' . esc_html__('Lege fest, welche Inhalte in Kommentaren automatisch durch * ersetzt werden, statt den ganzen Kommentar zu blockieren.', 'wp-multi') . '
'; +} + +function wp_multi_filter_phone_callback() { + ?> + > + + > + + > + + > + + > + + "]+#i', 'wp_multi_mask_match', $content); + } + + if (get_option('wp_multi_filter_ip', 0)) { + $content = preg_replace_callback('/\b(?:\d{1,3}\.){3}\d{1,3}\b/', 'wp_multi_mask_match', $content); + } + + if (get_option('wp_multi_filter_swearwords', 0)) { + foreach (wp_multi_get_bad_words_patterns() as $pattern) { + $content = preg_replace_callback($pattern, 'wp_multi_mask_match', $content); + } + } + + return $content; +} + + + + + + + + diff --git a/includes/copy-protection.php b/includes/copy-protection.php new file mode 100644 index 0000000..f389e57 --- /dev/null +++ b/includes/copy-protection.php @@ -0,0 +1,63 @@ +window.open("' . esc_url($page['url']) . '", "_blank");'; + echo '' . __('Die externe Seite wird in einem neuen Fenster geöffnet.', 'wp-stat-notice') . '
'; + echo '' . esc_html__('Seite manuell öffnen', 'wp-stat-notice') . '
'; + } else { + echo '' . __('Dies ist eine benutzerdefinierte Seite im Admin-Bereich.', 'wp-stat-notice') . '
'; + } + wpmt_admin_card_close(); + wpmt_admin_page_close(); + return; + } + } + + wpmt_admin_page_open(__('Benutzerdefinierte Seite', 'wp-stat-notice')); + wpmt_admin_notice('error', __('Seite nicht gefunden.', 'wp-stat-notice')); + wpmt_admin_page_close(); +} + +// Funktion zum Hinzufügen und Verwalten benutzerdefinierter Seiten +function wp_stat_notice_add_custom_page_form() { + $dashicons = [ + 'dashicons-admin-links', 'dashicons-admin-site', 'dashicons-admin-home', + 'dashicons-admin-plugins', 'dashicons-admin-users', 'dashicons-analytics', + 'dashicons-archive', 'dashicons-book', 'dashicons-calendar', + 'dashicons-camera', 'dashicons-cart', 'dashicons-cloud', + 'dashicons-clipboard', 'dashicons-clock', 'dashicons-cloud-upload', + 'dashicons-email', 'dashicons-heart', 'dashicons-laptop', + 'dashicons-lock', 'dashicons-phone', 'dashicons-rss', + 'dashicons-search', 'dashicons-settings', 'dashicons-share', + 'dashicons-tag', 'dashicons-thumbs-up', 'dashicons-welcome-learn-more', + 'dashicons-welcome-write-blog' + ]; + + ?> +' . __('Titel und Slug sind erforderlich.', 'wp-stat-notice') . '
' . __('Dieser Slug wird bereits verwendet.', 'wp-stat-notice') . '
' . __('Benutzerdefinierte Seite wurde hinzugefügt!', 'wp-stat-notice') . '
| ' . __('Titel', 'wp-stat-notice') . ' | ' . __('URL', 'wp-stat-notice') . ' | ' . __('Slug', 'wp-stat-notice') . ' | ' . __('Aktionen', 'wp-stat-notice') . ' |
|---|---|---|---|
| ' . esc_html($page['title']) . ' | '; + echo '' . esc_html($page['url'] ?: '-') . ' | '; + echo '' . esc_html($page['slug']) . ' | '; + $delete_url = wp_nonce_url(admin_url('admin.php?page=wp-stat-notice-custom-page&delete=' . $index), 'wp_stat_notice_delete_page_' . $index); + echo '' . __('Bearbeiten', 'wp-stat-notice') . ' | '; + echo '' . __('Löschen', 'wp-stat-notice') . ' | '; + echo '
' . __('Titel und Slug sind erforderlich.', 'wp-stat-notice') . '
' . __('Seite erfolgreich bearbeitet!', 'wp-stat-notice') . '
' . __('Seite wurde gelöscht.', 'wp-stat-notice') . '
' . __('Autor:', 'wp-multi') . ' ' . esc_html($author_name); + if ($selected_second_custom_text !== '' && isset($second_custom_texts_array[$selected_second_custom_text])) { + $output .= ' | ' . esc_html($second_custom_texts_array[$selected_second_custom_text]); + } + $output .= '
'; + if ($selected_custom_text !== '' && isset($custom_texts_array[$selected_custom_text])) { + $output .= '' . esc_html($custom_texts_array[$selected_custom_text]) . '
'; + } + $output .= '| + | + ID, 'disable_login', true), 1 ); ?> /> + Markiere diese Option, um den Login des Benutzers zu deaktivieren. + | +
|---|
| + + + + + + + | ++ + + + + + + | +
|---|---|
| guest_author); ?> | +post_count); ?> | +
%s
%s
Keine neuen Nachrichten.
'; + } +} + + diff --git a/includes/notify-dashboard.php b/includes/notify-dashboard.php new file mode 100644 index 0000000..15d32fc --- /dev/null +++ b/includes/notify-dashboard.php @@ -0,0 +1,38 @@ +Telegram Nachrichten gesendet: ' . esc_html($telegram_message_count) . ''; + echo 'Discord Nachrichten gesendet: ' . esc_html($discord_message_count) . '
'; +} + + diff --git a/includes/notify-discord.php b/includes/notify-discord.php new file mode 100644 index 0000000..1ae6ba3 --- /dev/null +++ b/includes/notify-discord.php @@ -0,0 +1,182 @@ + + + post_author)); + $content = get_post_field('post_content', $ID); + $excerpt = wp_trim_words($content, 60, '...'); + $role_id = get_option('wp_multi_discord_role_id'); + $mention_role = (!empty($role_id) && is_numeric($role_id)) ? "<@&" . esc_attr($role_id) . ">" : ''; + $footer_text = get_option('wp_multi_discord_footer_text'); + $footer = !empty($footer_text) ? str_replace( + ['{post_title}', '{post_author}', '{post_url}'], + [$post_title, $post_author, $post_url], + $footer_text + ) : ''; + + $message_template = get_option('wp_multi_discord_message_template', 'Beitrag "{post_title}" von {post_author} | Link: {post_url}'); + $message = str_replace( + ['{post_title}', '{post_author}', '{post_url}'], + [$post_title, $post_author, $post_url], + $message_template + ); + $message .= "\n\n" . $excerpt . "\n\n" . $footer; + + $data = json_encode([ + 'username' => $bot_name, + 'avatar_url' => $avatar_url, + 'content' => $mention_role . "\n" . $message + ]); + + $response = wp_remote_post($webhook_url, [ + 'method' => 'POST', + 'body' => $data, + 'headers' => ['Content-Type' => 'application/json'] + ]); + + if (!is_wp_error($response)) { + wp_multi_increment_discord_message_count(); + } else { + error_log('Discord Webhook Fehler: ' . $response->get_error_message()); + } +} +add_action('publish_post', 'wp_multi_send_discord_notification', 10, 2); + +// Funktion zum Erhöhen des Discord-Nachrichtenzählers +function wp_multi_increment_discord_message_count() { + $current_count = get_option('wp_multi_discord_message_count', 0); + update_option('wp_multi_discord_message_count', $current_count + 1); +} + +// Funktion, um die Checkbox in der Sidebar des Beitrag Editors hinzuzufügen +function wp_multi_add_checkbox_to_sidebar() { + global $post; + wp_nonce_field('wp_multi_checkbox_nonce', 'wp_multi_checkbox_nonce_field'); + $value = get_post_meta($post->ID, '_wp_multi_checkbox', true); + ?> +Kanal ohne Thema: -1001234567890
'; + echo 'Kanal mit Thema: -1001234567890_123
'; +} +function tg_notify_custom_message_callback() { + $value = get_option('tg_notify_custom_message', ''); + echo ''; + echo 'Verfügbare Variablen: {title}, {author}, {link}
'; +} + +// Checkbox beim Beitrag hinzufügen +function tg_notify_add_meta_box() { + add_meta_box( + 'tg_notify_meta_box', + __('Telegram Benachrichtigung', 'wp-stat-notice'), + 'tg_notify_meta_box_callback', + 'post', + 'side', + 'high' + ); +} +add_action('add_meta_boxes', 'tg_notify_add_meta_box'); + +function tg_notify_meta_box_callback($post) { + $value = get_post_meta($post->ID, '_tg_notify_send', true); + + // Standardmäßig auf 1 setzen, wenn der Beitrag neu ist + if (empty($value) && get_post_status($post->ID) !== 'publish') { + $value = 1; + } + + wp_nonce_field('tg_notify_meta_box', 'tg_notify_meta_box_nonce'); + echo ''; +} + +function tg_notify_save_post($post_id) { + // Sicherheitsprüfungen + if (!isset($_POST['tg_notify_meta_box_nonce']) || !wp_verify_nonce($_POST['tg_notify_meta_box_nonce'], 'tg_notify_meta_box')) return; + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; + if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) return; + if (!current_user_can('edit_post', $post_id)) return; + + // Prüfen, ob der Beitrag wirklich veröffentlicht wurde + if (get_post_status($post_id) !== 'publish') return; + + // Prüfen, ob die Nachricht bereits gesendet wurde + $already_sent = get_post_meta($post_id, '_tg_notify_sent', true); + if ($already_sent) return; + + $send_notification = isset($_POST['tg_notify_send']) ? 1 : 0; + update_post_meta($post_id, '_tg_notify_send', $send_notification); + + if ($send_notification) { + tg_notify_send_telegram_message($post_id); + update_post_meta($post_id, '_tg_notify_sent', 1); + } +} + + +add_action('save_post', 'tg_notify_save_post'); + +function tg_notify_send_telegram_message($post_id) { + $bot_token = get_option('tg_notify_bot_token'); + $chat_ids = explode("\n", get_option('tg_notify_chat_ids')); + $message_template = get_option('tg_notify_custom_message'); + + $post = get_post($post_id); + // Überprüfen, ob der Beitrag von einem Gast-Author stammt + $author_name = get_the_author_meta('display_name', $post->post_author); + if (empty($author_name)) { + // Falls kein Name vorhanden ist (Gast-Author), den Gast-Namen verwenden oder einen Platzhalter setzen + $author_name = 'Gast-Author'; + } + + // Nachricht formatieren + $message = str_replace( + ['{title}', '{author}', '{link}'], + [$post->post_title, $author_name, get_permalink($post_id)], + $message_template + ); + + foreach ($chat_ids as $chat_id) { + $chat_id = trim($chat_id); + if (!empty($chat_id)) { + // Überprüfen, ob die ID das Thema enthält (Format: -1001234567890_123) + if (strpos($chat_id, '_') !== false) { + // Kanal-ID und Themen-ID trennen + list($channel_id, $topic_id) = explode('_', $chat_id); + $chat_id = $channel_id; + + // Telegram API-Anfrage senden + $url = "https://api.telegram.org/bot$bot_token/sendMessage"; + $args = [ + 'body' => json_encode([ + 'chat_id' => $chat_id, + 'text' => $message, + 'parse_mode' => 'HTML', + 'reply_to_message_id' => $topic_id + ]), + 'headers' => ['Content-Type' => 'application/json'], + 'method' => 'POST', + ]; + + // API-Request senden und Fehlerprotokollierung + $response = wp_remote_post($url, $args); + if (is_wp_error($response)) { + $error_message = $response->get_error_message(); + error_log("Telegram Fehler: $error_message"); + } else { + // Erhöhe den Telegram-Nachrichtenzähler + tg_notify_increment_telegram_message_count(); + } + } else { + // Normaler Kanal ohne Thema + $url = "https://api.telegram.org/bot$bot_token/sendMessage"; + $args = [ + 'body' => json_encode([ + 'chat_id' => $chat_id, + 'text' => $message, + 'parse_mode' => 'HTML' + ]), + 'headers' => ['Content-Type' => 'application/json'], + 'method' => 'POST', + ]; + + // API-Request senden und Fehlerprotokollierung + $response = wp_remote_post($url, $args); + if (is_wp_error($response)) { + $error_message = $response->get_error_message(); + error_log("Telegram Fehler: $error_message"); + } else { + // Erhöhe den Telegram-Nachrichtenzähler + tg_notify_increment_telegram_message_count(); + } + } + } + } +} + +function tg_notify_increment_telegram_message_count() { + $current_count = get_option('wp_multi_telegram_message_count', 0); + update_option('wp_multi_telegram_message_count', $current_count + 1); +} + + diff --git a/includes/notify.php b/includes/notify.php new file mode 100644 index 0000000..1c0cbc3 --- /dev/null +++ b/includes/notify.php @@ -0,0 +1,59 @@ +'; + + wpmt_admin_card_open(__('Discord', 'wp-multi')); + ?> + +Es gibt keine gemeldeten Beiträge.
'; + return; + } + + // Tabelle mit den letzten 10 gemeldeten Beiträgen anzeigen + echo '| Beitrag | Datum | Grund |
|---|---|---|
| ' . esc_html($post->post_title) . ' | '; + echo '' . esc_html($report->report_date) . ' | '; + echo '' . esc_html($report->reason) . ' | '; + echo '
| + | + | + | + | + | + |
|---|---|---|---|---|---|
| post_title) : '—'; ?> | +report_date); ?> | +name); ?> | +reason); ?> | +status); ?> | ++ + + + | +
| + | + | + |
|---|---|---|
[shortcode_name); ?>] |
+ shortcode_content, 15)); ?> | ++ |
Keine Shortcodes vorhanden.
'; + } +} + + // JavaScript für Meta-Box einbinden (Classic Editor: fügt den gewählten Shortcode ein) +function wp_multi_enqueue_admin_scripts($hook) { + if ('post.php' === $hook || 'post-new.php' === $hook) { + wp_enqueue_script('wp-multi-shortcode', plugin_dir_url(WP_MULTI_FILE) . 'js/classic-editor-shortcodes.js', array('jquery'), '1.0', true); + } +} +add_action('admin_enqueue_scripts', 'wp_multi_enqueue_admin_scripts'); + +// Funktion zum Registrieren des TinyMCE Plugins +function wp_multi_add_shortcode_button() { + add_filter('mce_external_plugins', 'wp_multi_register_tinymce_plugin'); + add_filter('mce_buttons', 'wp_multi_add_tinymce_button'); +} +add_action('admin_head', 'wp_multi_add_shortcode_button'); + +// Plugin für TinyMCE registrieren (angepasster Pfad zum JS-File) +function wp_multi_register_tinymce_plugin($plugins) { + $plugins['wp_multi_shortcodes'] = plugin_dir_url(WP_MULTI_FILE) . 'js/tinymce-shortcodes.js'; + return $plugins; +} + +// Button zur TinyMCE Toolbar hinzufügen +function wp_multi_add_tinymce_button($buttons) { + array_push($buttons, 'wp_multi_shortcodes'); + return $buttons; +} + +// Shortcodes aus der Datenbank für das JavaScript bereitstellen +function wp_multi_localize_shortcodes() { + global $wpdb; + $shortcodes = $wpdb->get_results("SELECT shortcode_name FROM {$wpdb->prefix}wp_multi_shortcodes", ARRAY_A); + + // Shortcodes als JSON an das JS-File übergeben + wp_enqueue_script('wp-multi-tinymce', plugin_dir_url(WP_MULTI_FILE) . 'js/tinymce-shortcodes.js', array('jquery'), null, true); + wp_localize_script('wp-multi-tinymce', 'wpMultiShortcodes', $shortcodes); +} +add_action('admin_enqueue_scripts', 'wp_multi_localize_shortcodes'); + + diff --git a/includes/statistik-manager.php b/includes/statistik-manager.php new file mode 100644 index 0000000..1528919 --- /dev/null +++ b/includes/statistik-manager.php @@ -0,0 +1,510 @@ + + + publish; + + // Kommentare + $comments_count = wp_count_comments()->total_comments; + + // Kategorien + $selected_categories = get_option('statistik_manager_selected_categories', []); + $categories_count = 0; + + if (!empty($selected_categories)) { + $categories_count = count($selected_categories); + } else { + // Alle Kategorien zählen, wenn keine ausgewählt wurden + $categories_count = wp_count_terms('category'); + } + + // Serien (angenommen, Serien sind benutzerdefinierte Taxonomie) + $series_count = 0; + if (taxonomy_exists('series')) { + $count = wp_count_terms('series'); + $series_count = is_wp_error($count) ? 0 : (int) $count; + } + + // Eröffnungsdatum + $opening_date = get_option('statistik_manager_opening_date', ''); + + return [ + 'posts_count' => $posts_count, + 'comments_count' => $comments_count, + 'categories_count' => $categories_count, + 'series_count' => $series_count, + 'opening_date' => $opening_date + ]; +} + + // Banner-Funktion + function statistik_manager_display_banner($position) { + if (!get_option('statistik_manager_banner_enabled', 1)) { + return; + } + + $banner_text = get_option('statistik_manager_banner_text', 'Willkommen auf unserer Webseite!'); + $banner_color = get_option('statistik_manager_banner_color', '#0073aa'); + $banner_position = get_option('statistik_manager_banner_position', 'top'); + $font_size = get_option('statistik_manager_banner_font_size', 'medium'); + $banner_icon = get_option('statistik_manager_banner_icon', 'fas fa-info-circle'); // Standard-Icon + $show_icon = get_option('statistik_manager_show_icon', 1); // Option zur Aktivierung des Icons + + // Schriftgröße je nach Auswahl setzen + switch ($font_size) { + case 'small': + $font_size_css = '14px'; + break; + case 'medium': + $font_size_css = '18px'; + break; + case 'large': + $font_size_css = '24px'; + break; + default: + $font_size_css = '18px'; + } + + if ($banner_position !== $position) { + return; + } + + // Standard-Styles für das Banner + $style = "background-color: " . esc_attr($banner_color) . "; + color: #fff; + text-align: center; + padding: 10px; + width: 100%; + height: 50px; /* Feste Höhe */ + line-height: 30px; /* Zentrierte Schrift */ + z-index: 9999; + position: fixed; + top: 0; + left: 0;"; + + $text_style = "font-size: " . esc_attr($font_size_css) . ";"; + $icon_style = "font-size: 24px; margin-right: 8px;"; // Feste Größe für Icon + + echo ''; + } + + // Funktion für das Banner im Header (nach ) + function statistik_manager_display_banner_header() { + add_action('wp_body_open', function() { + statistik_manager_display_banner('top'); + }); + } + + // Falls `wp_body_open` nicht unterstützt wird, als Fallback `wp_footer` nutzen + function statistik_manager_display_banner_header_fallback() { + add_action('wp_footer', function() { + statistik_manager_display_banner('top'); + }, 5); + } + + // Funktion für das Banner im Footer + function statistik_manager_display_banner_footer() { + add_action('wp_footer', function() { + statistik_manager_display_banner('bottom'); + }, 10); + } + + // Banner laden (Header mit Fallback) + if (function_exists('wp_body_open')) { + statistik_manager_display_banner_header(); + } else { + statistik_manager_display_banner_header_fallback(); + } + + // Fix: Admin-Leiste (Wenn Admin angemeldet ist, Banner nach unten verschieben) + function statistik_manager_admin_bar_fix() { + if (is_admin_bar_showing()) { + echo ''; + } else { + echo ''; + } + } + add_action('wp_head', 'statistik_manager_admin_bar_fix'); + +// Shortcode für die Anzeige der Statistiken +function statistik_manager_shortcode() { + $statistics = statistik_manager_get_statistics(); + $webseitenname = get_bloginfo('name'); + + $output = 'Beiträge: ' . esc_html($statistics['posts_count']) . '
Kommentare: ' . esc_html($statistics['comments_count']) . '
Kategorien: ' . esc_html($statistics['categories_count']) . '
Serien: ' . esc_html($statistics['series_count']) . '
' . sprintf(__('%s wurde am %s eröffnet.', 'statistik-manager'), esc_html($webseitenname), esc_html($formatted_date)) . '
'; + $output .= '[statistik_manager] an der gewünschten Stelle in einem Beitrag oder einer Seite ein.[display_bookmarks] listet die gespeicherten Lesezeichen der Besucher auf.[add_bookmark] erhalten Besucher ein Formular zum Speichern eines Lesezeichens.git.viper.ipv64.net'); ?>
+ '; + + wpmt_admin_page_close(); +} + +// Optionen registrieren +function statistik_manager_register_settings() { + register_setting('statistik_manager_settings_group', 'statistik_manager_show_posts'); + register_setting('statistik_manager_settings_group', 'statistik_manager_show_comments'); + register_setting('statistik_manager_settings_group', 'statistik_manager_show_categories'); + register_setting('statistik_manager_settings_group', 'statistik_manager_show_series'); + register_setting('statistik_manager_settings_group', 'statistik_manager_selected_categories'); + register_setting('statistik_manager_settings_group', 'statistik_manager_opening_date'); + register_setting('statistik_manager_settings_group', 'statistik_manager_banner_text'); + register_setting('statistik_manager_settings_group', 'statistik_manager_banner_color', [ + 'sanitize_callback' => 'sanitize_hex_color', + ]); + register_setting('statistik_manager_settings_group', 'statistik_manager_banner_position'); + register_setting('statistik_manager_settings_group', 'statistik_manager_banner_enabled'); + register_setting('statistik_manager_settings_group', 'statistik_manager_banner_icon', [ + 'sanitize_callback' => function($value) { + // Icon-Wert besteht aus mehreren space-getrennten CSS-Klassen (z. B. "fas fa-bell") + $classes = array_map('sanitize_html_class', explode(' ', (string) $value)); + return implode(' ', array_filter($classes)); + }, + ]); + register_setting('statistik_manager_settings_group', 'statistik_manager_show_icon'); + register_setting('statistik_manager_settings_group', 'statistik_manager_banner_font_size'); + +} +add_action('admin_init', 'statistik_manager_register_settings'); + +// Standardwerte setzen +function statistik_manager_set_default_options() { + if (get_option('statistik_manager_show_posts') === false) { + update_option('statistik_manager_show_posts', 1); + } + if (get_option('statistik_manager_show_comments') === false) { + update_option('statistik_manager_show_comments', 1); + } + if (get_option('statistik_manager_show_categories') === false) { + update_option('statistik_manager_show_categories', 1); + } + if (get_option('statistik_manager_show_series') === false) { + update_option('statistik_manager_show_series', 1); + } + if (get_option('statistik_manager_selected_categories') === false) { + update_option('statistik_manager_selected_categories', []); + } + if (get_option('statistik_manager_banner_enabled') === false) { + update_option('statistik_manager_banner_enabled', 1); + } + if (get_option('statistik_manager_banner_font_size') === false) { + update_option('statistik_manager_banner_font_size', 'medium'); +} + +} +add_action('admin_init', 'statistik_manager_set_default_options'); \ No newline at end of file diff --git a/includes/update-check.php b/includes/update-check.php new file mode 100644 index 0000000..d8356af --- /dev/null +++ b/includes/update-check.php @@ -0,0 +1,142 @@ + 10, + 'headers' => array('Accept' => 'application/json'), + )); + + if (is_wp_error($response)) { + // Kurz erneut versuchen statt für 12 Stunden zu sperren + set_transient(WP_MULTI_UPDATE_CACHE_KEY, false, HOUR_IN_SECONDS); + return false; + } + + $body = wp_remote_retrieve_body($response); + $releases = json_decode($body, true); + + if (empty($releases) || !is_array($releases)) { + set_transient(WP_MULTI_UPDATE_CACHE_KEY, false, HOUR_IN_SECONDS); + return false; + } + + usort($releases, function ($a, $b) { + $a_date = !empty($a['created_at']) ? $a['created_at'] : ''; + $b_date = !empty($b['created_at']) ? $b['created_at'] : ''; + return strtotime($b_date) - strtotime($a_date); + }); + + $latest = false; + foreach ($releases as $release) { + if (!empty($release['prerelease'])) { + continue; + } + if (!empty($release['tag_name'])) { + // Nur Download-URLs auf dem erwarteten Host akzeptieren + $html_url = !empty($release['html_url']) ? $release['html_url'] : ''; + $release_host = $html_url ? wp_parse_url($html_url, PHP_URL_HOST) : ''; + $latest = array( + 'version' => ltrim($release['tag_name'], 'v'), + 'url' => ($release_host === WP_MULTI_UPDATE_HOST) + ? esc_url_raw($html_url) + : 'https://' . WP_MULTI_UPDATE_HOST . '/M_Viper/' . WP_MULTI_UPDATE_REPO . '/releases', + ); + break; + } + } + + set_transient(WP_MULTI_UPDATE_CACHE_KEY, $latest, 12 * HOUR_IN_SECONDS); + return $latest; +} + +// Liest die installierte Version aus dem Plugin-Header +function wp_multi_get_installed_version() { + if (!function_exists('get_plugin_data')) { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + } + $data = get_plugin_data(WP_MULTI_FILE, false, false); + return !empty($data['Version']) ? $data['Version'] : '0'; +} + +// Dashboard-Widget registrieren +function wp_multi_add_update_dashboard_widget() { + wp_add_dashboard_widget( + 'wp_multi_update_widget', + __('WP Multi - Update-Status', 'wp-multi'), + 'wp_multi_update_dashboard_widget_content' + ); +} +add_action('wp_dashboard_setup', 'wp_multi_add_update_dashboard_widget'); + +// Zeigt im Dashboard-Widget an, ob WP Multi aktuell ist oder ein Update verfügbar ist +function wp_multi_update_dashboard_widget_content() { + $installed_version = wp_multi_get_installed_version(); + $latest = wp_multi_get_latest_release(); + + echo '' . esc_html__('Installierte Version:', 'wp-multi') . ' ' . esc_html($installed_version) . '
'; + + if (!$latest || empty($latest['version'])) { + echo '' . esc_html__('Der Update-Server konnte nicht erreicht werden.', 'wp-multi') . '
'; + return; + } + + if (version_compare($latest['version'], $installed_version, '>')) { + echo '' . esc_html__('Update verfügbar:', 'wp-multi') . ' ' . esc_html($latest['version']) . '
'; + echo '' . esc_html__('Update herunterladen', 'wp-multi') . '
'; + } else { + echo '' . esc_html__('WP Multi ist aktuell.', 'wp-multi') . '
'; + } +} + +// Admin-Hinweis anzeigen, wenn ein Update verfügbar ist +function wp_multi_update_admin_notice() { + if (!current_user_can('manage_options') || !is_admin()) { + return; + } + + $installed_version = wp_multi_get_installed_version(); + $latest = wp_multi_get_latest_release(); + + if (!$latest || empty($latest['version'])) { + return; + } + + if (version_compare($latest['version'], $installed_version, '>')) { + printf( + '%1$s %3$s
- - - - -
-%s %s %s %s
- - ', - esc_html__('Danke, dass du WP Multi verwendest!', 'wp-multi'), - esc_html__('Dein Feedback hilft uns, das Plugin ständig zu verbessern. Wenn du Fehler entdeckst oder Verbesserungsvorschläge hast, besuche bitte unsere', 'wp-multi'), - 'https://git.viper.ipv64.net/M_Viper/wp-multi', - esc_html__('Gitea-Seite', 'wp-multi'), - esc_html__('und teile uns deine Ideen mit!', 'wp-multi'), - esc_html__('Support', 'wp-multi'), - esc_html__('Bei Fragen oder Supportanfragen kannst du uns über', 'wp-multi'), - 'https://teams.live.com/l/community/FEAzokphpZTJ2u6OgI', - esc_html__('Microsoft Teams', 'wp-multi'), - esc_html__('oder', 'wp-multi'), - 'https://t.me/M_Viper04', - esc_html__('Telegram', 'wp-multi'), - esc_html__('erreichen.', 'wp-multi') - ); - } - add_action('admin_notices', 'wp_multi_add_warning_banner'); - - // Support-Links in der Plugin-Übersicht anzeigen - function wp_multi_plugin_row_meta($links, $file) { - if ($file === plugin_basename(__FILE__)) { - $new_links = array( - 'support_teams' => sprintf( - '%s', - esc_url('https://teams.live.com/l/community/FEAzokphpZTJ2u6OgI'), - esc_html__('Microsoft Teams Support', 'wp-multi') - ), - 'support_telegram' => sprintf( - '%s', - esc_url('https://t.me/M_Viper04'), - esc_html__('Telegram Support', 'wp-multi') - ), - ); - $links = array_merge($links, $new_links); - } - return $links; - } - add_filter('plugin_row_meta', 'wp_multi_plugin_row_meta', 10, 2); - - -/* -* Index Verzeichnis [alphabetical_index] -*/ - - -// Shortcode zum Erstellen des Indexes -function wp_multi_alphabetical_index($atts) { - // Definiere die Argumente für den Shortcode - $atts = shortcode_atts(array( - 'posts_per_page' => 20, // Maximale Beiträge pro Seite - ), $atts, 'alphabetical_index'); - - // Hole alle Beiträge - $args = array( - 'post_type' => 'post', - 'posts_per_page' => -1, - 'orderby' => 'title', - 'order' => 'ASC', - ); - - $posts = get_posts($args); - - // Beiträge nach Anfangsbuchstaben gruppieren - $alphabet = range('A', 'Z'); - $posts_by_letter = array(); - - foreach ($posts as $post) { - $first_letter = strtoupper(substr($post->post_title, 0, 1)); - if (in_array($first_letter, $alphabet)) { - $posts_by_letter[$first_letter][] = $post; - } - } - - // Holen des aktuellen Buchstabens aus der URL - $letter = isset($_GET['letter']) ? strtoupper($_GET['letter']) : ''; // Der Buchstabe aus der URL - - // Bestimme, welche Beiträge angezeigt werden - $posts_in_letter = []; - if ($letter && isset($posts_by_letter[$letter])) { - $posts_in_letter = $posts_by_letter[$letter]; - } - - // Teile die Beiträge in zwei Hälften für die Boxen - $halfway = ceil(count($posts_in_letter) / 2); // Rundet die Hälfte auf - $first_half = array_slice($posts_in_letter, 0, $halfway); // Erste Hälfte der Beiträge - $second_half = array_slice($posts_in_letter, $halfway); // Zweite Hälfte der Beiträge - - // Ausgabe - ob_start(); - ?> - -| - | - ID, 'disable_login', true), 1 ); ?> /> - Markiere diese Option, um den Login des Benutzers zu deaktivieren. - | -
|---|
-
- | Statistik | -Wert | -
|---|---|
| Blockierte Kommentare | -- |
| Aktivierte Honeypot-Felder | -- |
| Spammer-IP-Adressen | -- |
| Spam-Einreichungen | -- |
Keine Spammer-IP-Adressen gefunden.
- -| - | - | - | - | - |
|---|---|---|---|---|
| id); ?> | -ip); ?> | -attempts); ?> | -last_attempt); ?> | -- - - - | -
Keine Nachrichten vorhanden.
'; - } - ?> - -Nachricht wurde erfolgreich erstellt.
'; - echo ""; // Seite neu laden - } -} - -// Menüeintrag im Adminbereich hinzufügen -function wp_multi_add_message_board_menu() { - add_menu_page( - 'Pinwand', // Seitentitel - 'Pinwand', // Menüeintrag - 'manage_options', // Berechtigung - 'message-board', // Slug - 'wp_multi_add_message_board', // Callback - 'dashicons-bell', // Icon - 6 // Position im Menü - ); -} -add_action('admin_menu', 'wp_multi_add_message_board_menu'); - -// Funktion zum Abrufen der vollständigen Nachricht -function wp_multi_get_message() { - if (isset($_POST['message_id'])) { - global $wpdb; - $table_name = $wpdb->prefix . 'message_board'; - $message_id = intval($_POST['message_id']); - $message = $wpdb->get_row("SELECT * FROM $table_name WHERE id = $message_id"); - - if ($message) { - // Datum im gewünschten Format (DD-MM-JJJJ HH:MM:SS) - $formatted_date = date('d-m-Y H:i:s', strtotime($message->created_at)); - - echo json_encode([ - 'created_at' => $formatted_date, - 'message' => nl2br(esc_textarea($message->message)), - 'user' => get_userdata($message->user_id)->user_login - ]); - } - } - wp_die(); -} - -add_action('wp_ajax_wp_multi_get_message', 'wp_multi_get_message'); - -// Funktion zum Löschen einer Nachricht -function wp_multi_delete_message() { - if (isset($_POST['message_id'])) { - global $wpdb; - $table_name = $wpdb->prefix . 'message_board'; - $message_id = intval($_POST['message_id']); - $wpdb->delete($table_name, array('id' => $message_id)); - - echo 'success'; - } - wp_die(); -} -add_action('wp_ajax_wp_multi_delete_message', 'wp_multi_delete_message'); - -// Funktion zum Deaktivieren der Pinwand bei der Deinstallation -function wp_multi_delete_message_board_table() { - global $wpdb; - $table_name = $wpdb->prefix . 'message_board'; - $wpdb->query("DROP TABLE IF EXISTS $table_name"); -} -register_deactivation_hook(__FILE__, 'wp_multi_delete_message_board_table'); - -// Funktion, um das Dashboard-Widget zu registrieren -function wp_multi_dashboard_widget() { - wp_add_dashboard_widget( - 'wp_multi_pinwand_widget', // Widget-ID - 'Pinwand Übersicht', // Widget-Titel - 'wp_multi_dashboard_widget_content' // Callback-Funktion - ); -} -add_action('wp_dashboard_setup', 'wp_multi_dashboard_widget'); - -// Callback-Funktion, die den Inhalt des Widgets erstellt -function wp_multi_dashboard_widget_content() { - global $wpdb; - $table_name = $wpdb->prefix . 'message_board'; - $messages = $wpdb->get_results("SELECT * FROM $table_name ORDER BY created_at DESC LIMIT 5"); // Zeige die neuesten 5 Nachrichten an - - if ($messages) { - echo 'Keine neuen Nachrichten.
'; - } -} - - -/* - * Benutzer-Analytics mit verbesserten Sicherheits-, Performance- und Benutzerfreundlichkeits-Features - */ - - -define('WP_MULTI_ANALYTICS_TABLE', $wpdb->prefix . 'wp_multi_user_analytics'); - -/** - * Erstellt die Datenbanktabelle für Benutzer-Analytics. - */ -function wp_multi_create_analytics_table() { - global $wpdb; - $table_name = WP_MULTI_ANALYTICS_TABLE; - $charset_collate = $wpdb->get_charset_collate(); - - $sql = "CREATE TABLE $table_name ( - id mediumint(9) NOT NULL AUTO_INCREMENT, - user_id bigint(20) NOT NULL, - action varchar(255) NOT NULL, - post_id bigint(20) DEFAULT NULL, - timestamp datetime DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (id), - INDEX idx_timestamp (timestamp), - INDEX idx_action (action) - ) $charset_collate;"; - - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; - dbDelta($sql); -} -register_activation_hook(__FILE__, 'wp_multi_create_analytics_table'); - -/** - * Verfolgt Benutzerinteraktionen (Kommentare und Beitragsaufrufe). - * - * @param int $user_id Benutzer-ID. - * @param string $action Aktion (z. B. 'view', 'comment'). - * @param int $post_id Beitrag-ID (optional). - * @return bool Erfolg der Operation. - */ -function wp_multi_track_user_activity($user_id, $action, $post_id = null) { - global $wpdb; - $table_name = WP_MULTI_ANALYTICS_TABLE; - - $user_id = absint($user_id); - $action = sanitize_text_field($action); - $post_id = $post_id ? absint($post_id) : null; - - if ($action === 'view' && is_single()) { - $post_id = get_the_ID(); - } - - if (!$user_id || !$action) { - return false; - } - - return $wpdb->insert( - $table_name, - array( - 'user_id' => $user_id, - 'action' => $action, - 'post_id' => $post_id, - ), - array('%d', '%s', '%d') - ); -} - -/** - * Verfolgt Kommentar-Aktivitäten. - * - * @param int $comment_id Kommentar-ID. - */ -function wp_multi_comment_activity($comment_id) { - $comment = get_comment($comment_id); - $user_id = absint($comment->user_id); - if ($user_id) { - wp_multi_track_user_activity($user_id, 'comment', $comment->comment_post_ID); - } -} -add_action('comment_post', 'wp_multi_comment_activity'); - -/** - * Verfolgt Beitragsaufrufe. - */ -function wp_multi_post_view_activity() { - if (is_single() && is_user_logged_in()) { - $user_id = get_current_user_id(); - $post_id = get_the_ID(); - wp_multi_track_user_activity($user_id, 'view', $post_id); - } -} -add_action('wp_head', 'wp_multi_post_view_activity'); - -/** - * Ruft rohe Analytics-Daten aus der Datenbank ab. - * - * @param string $date_query Datum für die Abfrage. - * @return array Rohe Analytics-Daten. - */ -function wp_multi_fetch_raw_analytics($date_query = 'CURDATE() - INTERVAL 7 DAY') { - global $wpdb; - return $wpdb->get_results( - $wpdb->prepare( - "SELECT DATE(timestamp) AS date, action, post_id, COUNT(*) AS count, user_id, timestamp - FROM " . WP_MULTI_ANALYTICS_TABLE . " - WHERE timestamp >= %s - GROUP BY date, action, post_id, user_id, timestamp - ORDER BY date ASC", - date('Y-m-d H:i:s', strtotime($date_query)) - ) - ); -} - -/** - * Verarbeitet rohe Analytics-Daten für Diagramm und Tabelle. - * - * @param array $results Rohe Analytics-Daten. - * @return array Verarbeitete Daten. - */ -function wp_multi_process_analytics_data($results) { - $dates = []; - $comment_counts = []; - $view_counts = []; - - foreach ($results as $result) { - $date = $result->date; - if (!in_array($date, $dates)) { - $dates[] = $date; - } - if ($result->action === 'comment') { - $comment_counts[$date] = ($comment_counts[$date] ?? 0) + $result->count; - } elseif ($result->action === 'view') { - $view_counts[$date] = ($view_counts[$date] ?? 0) + $result->count; - } - } - - $all_dates = []; - $datasets = ['comments' => [], 'views' => []]; - - for ($i = 6; $i >= 0; $i--) { - $date = date('Y-m-d', strtotime("-$i day")); - $all_dates[] = $date; - $datasets['comments'][] = $comment_counts[$date] ?? 0; - $datasets['views'][] = $view_counts[$date] ?? 0; - } - - return [ - 'dates' => array_reverse($all_dates), - 'datasets' => [ - [ - 'label' => __('Kommentare', 'wp-multi'), - 'data' => array_reverse($datasets['comments']), - 'borderColor' => 'rgba(75, 192, 192, 1)', - 'borderWidth' => 1, - 'fill' => false, - ], - [ - 'label' => __('Beitragsaufrufe', 'wp-multi'), - 'data' => array_reverse($datasets['views']), - 'borderColor' => 'rgba(153, 102, 255, 1)', - 'borderWidth' => 1, - 'fill' => false, - ] - ], - 'data' => $results - ]; -} - -/** - * Ruft Analytics-Daten mit Caching ab. - * - * @param string $date_query Datum für die Abfrage. - * @return array Analytics-Daten. - */ -function wp_multi_get_analytics_data($date_query = 'CURDATE() - INTERVAL 7 DAY') { - $cache_key = 'wp_multi_analytics_data_' . md5($date_query); - $cached_data = get_transient($cache_key); - - if ($cached_data !== false) { - return $cached_data; - } - - $results = wp_multi_fetch_raw_analytics($date_query); - $data = wp_multi_process_analytics_data($results); - - set_transient($cache_key, $data, HOUR_IN_SECONDS); - return $data; -} - -/** - * Zeigt die Benutzer-Analytics-Seite im Admin-Bereich an. - */ -function wp_multi_display_user_analytics() { - global $wpdb; - - if (!$wpdb->get_var("SHOW TABLES LIKE '" . WP_MULTI_ANALYTICS_TABLE . "'")) { - echo '' . esc_html__('Die Analytics-Tabelle existiert nicht. Bitte aktiviere das Plugin erneut.', 'wp-multi') . '
-
- | - | - | - | - | - |
|---|---|---|---|---|
| user_id); ?> | -action); ?> | -- post_id) { - $post_title = get_the_title($row->post_id); - echo esc_html($post_title ?: __('Kein Titel verfügbar', 'wp-multi')); - } else { - echo esc_html__('Kein Beitrag', 'wp-multi'); - } - ?> - | -post_id ?: '-'); ?> | -timestamp); ?> | -
Benutzer wurde gesperrt!
Fehler beim Sperren des Benutzers!
Benutzer wurde gelöscht!
Fehler beim Löschen des Benutzers!
| Benutzername | -E-Mail-Adresse | -IP-Adresse | -Aktionen | -
|---|---|---|---|
| username); ?> | -email); ?> | -ip_address); ?> | -- Löschen - | -
| Keine gesperrten Benutzer gefunden. | -|||
Keine Shortcodes vorhanden.
'; - } -} - - // JavaScript für Meta-Box einbinden -function wp_multi_enqueue_admin_scripts($hook) { - if ('post.php' === $hook || 'post-new.php' === $hook) { - wp_enqueue_script('wp-multi-shortcode', plugin_dir_url(__FILE__) . 'js/editor-shortcode.js', array('jquery'), null, true); - } -} -add_action('admin_enqueue_scripts', 'wp_multi_enqueue_admin_scripts'); - -// Funktion zum Registrieren des TinyMCE Plugins -function wp_multi_add_shortcode_button() { - add_filter('mce_external_plugins', 'wp_multi_register_tinymce_plugin'); - add_filter('mce_buttons', 'wp_multi_add_tinymce_button'); -} -add_action('admin_head', 'wp_multi_add_shortcode_button'); - -// Plugin für TinyMCE registrieren (angepasster Pfad zum JS-File) -function wp_multi_register_tinymce_plugin($plugins) { - $plugins['wp_multi_shortcodes'] = plugin_dir_url(__FILE__) . 'js/tinymce-shortcodes.js'; - return $plugins; -} - -// Button zur TinyMCE Toolbar hinzufügen -function wp_multi_add_tinymce_button($buttons) { - array_push($buttons, 'wp_multi_shortcodes'); - return $buttons; -} - -// Shortcodes aus der Datenbank für das JavaScript bereitstellen -function wp_multi_localize_shortcodes() { - global $wpdb; - $shortcodes = $wpdb->get_results("SELECT shortcode_name FROM {$wpdb->prefix}wp_multi_shortcodes", ARRAY_A); - - // Shortcodes als JSON an das JS-File übergeben - wp_enqueue_script('wp-multi-tinymce', plugin_dir_url(__FILE__) . 'js/tinymce-shortcodes.js', array('jquery'), null, true); - wp_localize_script('wp-multi-tinymce', 'wpMultiShortcodes', $shortcodes); -} -add_action('admin_enqueue_scripts', 'wp_multi_localize_shortcodes'); - - -/* -* Notify Seite Discord & Telegram -*/ - - -// Übergeordnetes Menü "Notify" erstellen -function wp_multi_menu() { - // Menüpunkt für "Notify" - add_menu_page( - 'Notify', - 'Notify', - 'manage_options', - 'wp-multi-notify', - 'wp_multi_notify_page', - 'dashicons-bell', - 100 - ); - - // Untermenüpunkt für DC-Notify - add_submenu_page( - 'wp-multi-notify', - 'DC-Notify Einstellungen', - 'DC-Notify', - 'manage_options', - 'wp-multi', - 'wp_multi_settings_page' - ); - - // Untermenüpunkt für TG-Notify - add_submenu_page( - 'wp-multi-notify', - 'TG-Notify Einstellungen', - 'TG-Notify', - 'manage_options', - 'tg-notify', - 'tg_notify_page' - ); -} -add_action('admin_menu', 'wp_multi_menu'); - -// Callback-Funktion für die Hauptseite Notify -function wp_multi_notify_page() { - ?> -
- Kanal ohne Thema: -1001234567890
'; - echo 'Kanal mit Thema: -1001234567890_123
'; -} -function tg_notify_custom_message_callback() { - $value = get_option('tg_notify_custom_message', ''); - echo ''; - echo 'Verfügbare Variablen: {title}, {author}, {link}
'; -} - -// Checkbox beim Beitrag hinzufügen -function tg_notify_add_meta_box() { - add_meta_box( - 'tg_notify_meta_box', - __('Telegram Benachrichtigung', 'wp-stat-notice'), - 'tg_notify_meta_box_callback', - 'post', - 'side', - 'high' - ); -} -add_action('add_meta_boxes', 'tg_notify_add_meta_box'); - -function tg_notify_meta_box_callback($post) { - $value = get_post_meta($post->ID, '_tg_notify_send', true); - - // Standardmäßig auf 1 setzen, wenn der Beitrag neu ist - if (empty($value) && get_post_status($post->ID) !== 'publish') { - $value = 1; - } - - wp_nonce_field('tg_notify_meta_box', 'tg_notify_meta_box_nonce'); - echo ''; -} - -function tg_notify_save_post($post_id) { - // Sicherheitsprüfungen - if (!isset($_POST['tg_notify_meta_box_nonce']) || !wp_verify_nonce($_POST['tg_notify_meta_box_nonce'], 'tg_notify_meta_box')) return; - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; - if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) return; - if (!current_user_can('edit_post', $post_id)) return; - - // Prüfen, ob der Beitrag wirklich veröffentlicht wurde - if (get_post_status($post_id) !== 'publish') return; - - // Prüfen, ob die Nachricht bereits gesendet wurde - $already_sent = get_post_meta($post_id, '_tg_notify_sent', true); - if ($already_sent) return; - - $send_notification = isset($_POST['tg_notify_send']) ? 1 : 0; - update_post_meta($post_id, '_tg_notify_send', $send_notification); - - if ($send_notification) { - tg_notify_send_telegram_message($post_id); - update_post_meta($post_id, '_tg_notify_sent', 1); - } -} - - -add_action('save_post', 'tg_notify_save_post'); - -function tg_notify_send_telegram_message($post_id) { - $bot_token = get_option('tg_notify_bot_token'); - $chat_ids = explode("\n", get_option('tg_notify_chat_ids')); - $message_template = get_option('tg_notify_custom_message'); - - $post = get_post($post_id); - // Überprüfen, ob der Beitrag von einem Gast-Author stammt - $author_name = get_the_author_meta('display_name', $post->post_author); - if (empty($author_name)) { - // Falls kein Name vorhanden ist (Gast-Author), den Gast-Namen verwenden oder einen Platzhalter setzen - $author_name = 'Gast-Author'; - } - - // Nachricht formatieren - $message = str_replace( - ['{title}', '{author}', '{link}'], - [$post->post_title, $author_name, get_permalink($post_id)], - $message_template - ); - - foreach ($chat_ids as $chat_id) { - $chat_id = trim($chat_id); - if (!empty($chat_id)) { - // Überprüfen, ob die ID das Thema enthält (Format: -1001234567890_123) - if (strpos($chat_id, '_') !== false) { - // Kanal-ID und Themen-ID trennen - list($channel_id, $topic_id) = explode('_', $chat_id); - $chat_id = $channel_id; - - // Telegram API-Anfrage senden - $url = "https://api.telegram.org/bot$bot_token/sendMessage"; - $args = [ - 'body' => json_encode([ - 'chat_id' => $chat_id, - 'text' => $message, - 'parse_mode' => 'HTML', - 'reply_to_message_id' => $topic_id - ]), - 'headers' => ['Content-Type' => 'application/json'], - 'method' => 'POST', - ]; - - // API-Request senden und Fehlerprotokollierung - $response = wp_remote_post($url, $args); - if (is_wp_error($response)) { - $error_message = $response->get_error_message(); - error_log("Telegram Fehler: $error_message"); - } else { - // Erhöhe den Telegram-Nachrichtenzähler - tg_notify_increment_telegram_message_count(); - error_log('Telegram Antwort: ' . print_r($response, true)); - } - } else { - // Normaler Kanal ohne Thema - $url = "https://api.telegram.org/bot$bot_token/sendMessage"; - $args = [ - 'body' => json_encode([ - 'chat_id' => $chat_id, - 'text' => $message, - 'parse_mode' => 'HTML' - ]), - 'headers' => ['Content-Type' => 'application/json'], - 'method' => 'POST', - ]; - - // API-Request senden und Fehlerprotokollierung - $response = wp_remote_post($url, $args); - if (is_wp_error($response)) { - $error_message = $response->get_error_message(); - error_log("Telegram Fehler: $error_message"); - } else { - // Erhöhe den Telegram-Nachrichtenzähler - tg_notify_increment_telegram_message_count(); - error_log('Telegram Antwort: ' . print_r($response, true)); - } - } - } - } -} - -function tg_notify_increment_telegram_message_count() { - $current_count = get_option('wp_multi_telegram_message_count', 0); - update_option('wp_multi_telegram_message_count', $current_count + 1); -} - - -/* -* Admin-Dashboard Nachrichten sende Zähler -*/ - - -// Admin Dashboard Widget für Telegram und Discord Nachrichten Zähler -function wp_multi_add_dashboard_widgets() { - wp_add_dashboard_widget( - 'wp_multi_dashboard_widget', - 'Telegram & Discord Nachrichten Zähler', - 'wp_multi_display_dashboard_widget' - ); -} -add_action('wp_dashboard_setup', 'wp_multi_add_dashboard_widgets'); - -// Callback-Funktion, die den Inhalt des Widgets anzeigt -function wp_multi_display_dashboard_widget() { - // Telegram-Nachrichtenzähler - $telegram_message_count = get_option('wp_multi_telegram_message_count', 0); - // Discord-Nachrichtenzähler - $discord_message_count = get_option('wp_multi_discord_message_count', 0); - - // Ausgabe der Zähler - echo 'Telegram Nachrichten gesendet: ' . esc_html($telegram_message_count) . '
'; - echo 'Discord Nachrichten gesendet: ' . esc_html($discord_message_count) . '
'; -} - - -/* -* Gast Autoren -*/ - -// Gast-Autor Eingabefeld in der Sidebar im Admin-Bereich hinzufügen -function wp_multi_add_guest_author_field() { - add_meta_box( - 'guest_author_meta_box', - __('Gast-Autor', 'wp-multi'), - 'wp_multi_guest_author_field', - ['post', 'page', 'dein_custom_post_type'], - 'side', - 'high' - ); -} -add_action('add_meta_boxes', 'wp_multi_add_guest_author_field'); - -// Callback-Funktion, die das Eingabefeld anzeigt -function wp_multi_guest_author_field($post) { - $guest_author = get_post_meta($post->ID, '_guest_author', true); - ?> - - - ID, '_guest_author', true); - if (!empty($guest_author)) { - $author_name = $guest_author; - } - } - } - return $author_name; -} -add_filter('the_author', 'wp_multi_display_guest_author'); - -// Anzeige des Gast-Autors in der Beitragsübersicht (Backend) -function wp_multi_add_guest_author_column($columns) { - if (isset($columns['author'])) { - $columns['guest_author'] = __('Gast-Autor', 'wp-multi'); - } - return $columns; -} -add_filter('manage_posts_columns', 'wp_multi_add_guest_author_column'); - -function wp_multi_display_guest_author_column($column_name, $post_id) { - if ($column_name == 'guest_author') { - $guest_author = get_post_meta($post_id, '_guest_author', true); - echo !empty($guest_author) ? esc_html($guest_author) : __('Kein Gast-Autor', 'wp-multi'); - } -} -add_action('manage_posts_custom_column', 'wp_multi_display_guest_author_column', 10, 2); - -// Admin-Menü für die Gast-Autor-Übersicht unter Benutzer hinzufügen -function wp_multi_add_guest_author_page() { - add_submenu_page( - 'users.php', - __('Gast-Autor Übersicht', 'wp-multi'), - __('Gast-Autoren', 'wp-multi'), - 'manage_options', - 'guest_author_overview', - 'wp_multi_guest_author_overview_page' - ); -} -add_action('admin_menu', 'wp_multi_add_guest_author_page'); - -// Callback-Funktion für die Gast-Autor-Übersicht -function wp_multi_guest_author_overview_page() { - // Sortierparameter aus URL lesen - $orderby = isset($_GET['orderby']) ? sanitize_key($_GET['orderby']) : 'guest_author'; - $order = isset($_GET['order']) && in_array(strtoupper($_GET['order']), ['ASC', 'DESC']) ? strtoupper($_GET['order']) : 'ASC'; - - // Gültige Sortierfelder - $valid_orderby = ['guest_author' => 'pm.meta_value', 'posts' => 'post_count']; - $sql_orderby = isset($valid_orderby[$orderby]) ? $valid_orderby[$orderby] : 'pm.meta_value'; - $sql_order = $order; - - // Basis-URL für Sortier-Links - $base_url = add_query_arg(['page' => 'guest_author_overview'], admin_url('users.php')); - - ?> -| - - - - - - - | -- - - - - - - | -
|---|---|
| guest_author); ?> | -post_count); ?> | -' . __('Keine Gast-Autoren gefunden.', 'wp-multi') . ' | '; - } - ?> - -
' . __('Autor:', 'wp-multi') . ' ' . esc_html($author_name); - if ($selected_second_custom_text !== '' && isset($second_custom_texts_array[$selected_second_custom_text])) { - $output .= ' | ' . esc_html($second_custom_texts_array[$selected_second_custom_text]); - } - $output .= '
'; - if ($selected_custom_text !== '' && isset($custom_texts_array[$selected_custom_text])) { - $output .= '' . esc_html($custom_texts_array[$selected_custom_text]) . '
'; - } - $output .= '' . __('Keine benutzerdefinierten Seiten gefunden.', 'wp-stat-notice') . '
'; - return; - } - - foreach ($custom_pages as $page) { - if ($page['slug'] === $current_slug) { - if (isset($page['url']) && filter_var($page['url'], FILTER_VALIDATE_URL)) { - // Externe URL in neuem Fenster öffnen - echo ''; - echo '' . __('Die externe Seite wird in einem neuen Fenster geöffnet.', 'wp-stat-notice') . '
' . __('Dies ist eine benutzerdefinierte Seite im Admin-Bereich.', 'wp-stat-notice') . '
' . __('Seite nicht gefunden.', 'wp-stat-notice') . '
' . __('Titel und Slug sind erforderlich.', 'wp-stat-notice') . '
' . __('Dieser Slug wird bereits verwendet.', 'wp-stat-notice') . '
' . __('Benutzerdefinierte Seite wurde hinzugefügt!', 'wp-stat-notice') . '
| ' . __('Titel', 'wp-stat-notice') . ' | ' . __('URL', 'wp-stat-notice') . ' | ' . __('Slug', 'wp-stat-notice') . ' | ' . __('Aktionen', 'wp-stat-notice') . ' |
|---|---|---|---|
| ' . esc_html($page['title']) . ' | '; - echo '' . esc_html($page['url'] ?: '-') . ' | '; - echo '' . esc_html($page['slug']) . ' | '; - echo '' . __('Bearbeiten', 'wp-stat-notice') . ' | '; - echo '' . __('Löschen', 'wp-stat-notice') . ' | '; - echo '
' . __('Titel und Slug sind erforderlich.', 'wp-stat-notice') . '
'; - } else { - $custom_pages[$edit_index] = ['title' => $title, 'url' => $url, 'slug' => $slug, 'icon' => $icon]; - update_option('wp_stat_notice_custom_pages', $custom_pages); - echo '' . __('Seite erfolgreich bearbeitet!', 'wp-stat-notice') . '
' . __('Seite wurde gelöscht.', 'wp-stat-notice') . '
Es gibt keine gemeldeten Beiträge.
'; - return; - } - - // Tabelle mit den letzten 10 gemeldeten Beiträgen anzeigen - echo '| Beitrag | Datum | Grund |
|---|---|---|
| ' . esc_html($post->post_title) . ' | '; - echo '' . esc_html($report->report_date) . ' | '; - echo '' . esc_html($report->reason) . ' | '; - echo '
| Beitrag | -Datum | -Name | -Grund | -Status | -Aktionen | -
|---|---|---|---|---|---|
| post_title); ?> | -report_date); ?> | -name); ?> | -reason); ?> | -status); ?> | -- Report Löschen | - Unpublish | - Beitrag Löschen - | -
Beiträge: ' . $statistics['posts_count'] . '
Kommentare: ' . $statistics['comments_count'] . '
Kategorien: ' . $statistics['categories_count'] . '
Serien: ' . $statistics['series_count'] . '
' . sprintf(__('%s wurde am %s eröffnet.', 'statistik-manager'), esc_html($webseitenname), esc_html($formatted_date)) . '
'; - $output .= '
- Verwenden Sie den Statistik Manager, um eine benutzerdefinierte Statistik Box auf Ihrer Website anzuzeigen und wichtige Statistiken zu verfolgen. Hier ist eine kurze Anleitung:
-[statistik_manager].Die Statistik Box wird an der Stelle angezeigt, an der der Shortcode eingefügt wurde. Alle Statistiken und Inhalte können jederzeit über die Plugin-Einstellungen angepasst werden.
-Bei Fragen oder Problemen können Sie sich jederzeit an uns wenden!
- -Zusätzlich zur Anzeige von Statistiken können Sie auch eine benutzerdefinierte Liste von Lesezeichen für Ihre Gäste verwalten. Hier sind die wichtigen Schritte:
-[display_bookmarks].[add_bookmark] verwenden, der ein Formular zum Speichern eines Lesezeichens anzeigt.Wenn Sie Fragen oder Probleme haben, wenden Sie sich an uns!
-+ + + + +
+