2478 lines
112 KiB
PHP
2478 lines
112 KiB
PHP
<?php
|
||
/*
|
||
* Plugin Name: WP Multi Toolkit
|
||
* Plugin URI: https://git.viper.ipv64.net/M_Viper/wp-multi-toolkit
|
||
* Description: Ein umfassendes Toolkit inklusive WP Multi Funktionen und Update-Management für zugehörige Plugins.
|
||
* Version: 1.0.7
|
||
* Author: M_Viper
|
||
* Author URI: https://m-viper.de
|
||
* Requires at least: 6.7.2
|
||
* Tested up to: 6.7.2
|
||
* License: GPL2
|
||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||
* Text Domain: wp-multi-toolkit
|
||
* Tags: toolkit, update-management, wp-multi, plugin-utility, wordpress, plugin-toolkit
|
||
* Support: [Microsoft Teams Support](https://teams.live.com/l/community/FEAzokphpZTJ2u6OgI)
|
||
* Support: [Telegram Support](https://t.me/M_Viper04)
|
||
*/
|
||
|
||
defined('ABSPATH') or die('No direct access allowed.');
|
||
|
||
|
||
/*
|
||
* DB Backup
|
||
*/
|
||
|
||
// Funktion zum Erstellen des Backups
|
||
function wpmt_create_database_backup() {
|
||
global $wpdb;
|
||
|
||
// Definiere den Dateinamen für das Backup
|
||
$backup_filename = 'wp-database-backup-' . date('Y-m-d_H-i-s') . '.sql';
|
||
|
||
// Spezifizieren des Speicherorts des Backups (im Uploads-Verzeichnis)
|
||
$upload_dir = wp_upload_dir();
|
||
$backup_file_path = $upload_dir['basedir'] . '/wpmt_backups/' . $backup_filename;
|
||
|
||
// Sicherstellen, dass der Backup-Ordner existiert
|
||
if (!file_exists($upload_dir['basedir'] . '/wpmt_backups')) {
|
||
wp_mkdir_p($upload_dir['basedir'] . '/wpmt_backups');
|
||
}
|
||
|
||
// Hole alle Tabellen der Datenbank
|
||
$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
|
||
if (empty($tables)) {
|
||
return new WP_Error('backup_error', 'Keine Tabellen in der Datenbank gefunden.');
|
||
}
|
||
|
||
// Öffne die Backup-Datei
|
||
$backup_file = fopen($backup_file_path, 'w');
|
||
if (!$backup_file) {
|
||
return new WP_Error('backup_error', 'Fehler beim Öffnen der Backup-Datei.');
|
||
}
|
||
|
||
// Schreibe die SQL-Dumps für jede Tabelle
|
||
foreach ($tables as $table) {
|
||
$table_name = $table[0];
|
||
|
||
// SQL-Dump für die Tabelle hinzufügen
|
||
fwrite($backup_file, "DROP TABLE IF EXISTS `$table_name`;\n");
|
||
|
||
// Struktur der Tabelle
|
||
$create_table_query = $wpdb->get_row("SHOW CREATE TABLE $table_name", ARRAY_N);
|
||
fwrite($backup_file, $create_table_query[1] . ";\n\n");
|
||
|
||
// Daten der Tabelle
|
||
$rows = $wpdb->get_results("SELECT * FROM $table_name", ARRAY_A);
|
||
foreach ($rows as $row) {
|
||
$columns = array_map(function ($col) use ($wpdb) {
|
||
return $wpdb->prepare('%s', $col);
|
||
}, array_values($row));
|
||
|
||
$columns_str = implode(", ", $columns);
|
||
fwrite($backup_file, "INSERT INTO `$table_name` VALUES ($columns_str);\n");
|
||
}
|
||
|
||
fwrite($backup_file, "\n\n");
|
||
}
|
||
|
||
// Datei schließen
|
||
fclose($backup_file);
|
||
|
||
// Gebe den Pfad zur herunterladbaren Datei zurück
|
||
return $backup_file_path;
|
||
}
|
||
|
||
// Neue Funktion zum Löschen von Backups
|
||
function wpmt_delete_backup() {
|
||
if (isset($_POST['wpmt_action']) && $_POST['wpmt_action'] == 'delete_backup' && isset($_POST['backup_file'])) {
|
||
$upload_dir = wp_upload_dir();
|
||
$backup_file = $upload_dir['basedir'] . '/wpmt_backups/' . sanitize_file_name($_POST['backup_file']);
|
||
|
||
if (file_exists($backup_file)) {
|
||
unlink($backup_file);
|
||
echo '<div class="updated"><p>' . __('Backup erfolgreich gelöscht!', 'wp-multi-toolkit') . '</p></div>';
|
||
} else {
|
||
echo '<div class="error"><p>' . __('Backup-Datei nicht gefunden.', 'wp-multi-toolkit') . '</p></div>';
|
||
}
|
||
}
|
||
}
|
||
|
||
// Funktion zur Anzeige der Backup-Seite und der Liste der Backups im Admin-Bereich
|
||
function wpmt_display_backup_page() {
|
||
$upload_dir = wp_upload_dir();
|
||
$backup_dir = $upload_dir['basedir'] . '/wpmt_backups';
|
||
|
||
// Hole eine Liste der Backups
|
||
$backups = glob($backup_dir . '/*.sql');
|
||
|
||
?>
|
||
<div class="wrap">
|
||
<h1><?php _e('Datenbank-Backup erstellen und verwalten', 'wp-multi-toolkit'); ?></h1>
|
||
|
||
|
||
<form method="post" action="">
|
||
<input type="hidden" name="wpmt_action" value="create_backup">
|
||
<p><input type="submit" class="button-primary" value="<?php _e('Datenbank-Backup erstellen', 'wp-multi-toolkit'); ?>" /></p>
|
||
</form>
|
||
|
||
<?php if ($backups): ?>
|
||
<h2><?php _e('Erstellte Backups:', 'wp-multi-toolkit'); ?></h2>
|
||
<table class="wp-list-table widefat fixed striped posts">
|
||
<thead>
|
||
<tr>
|
||
<th><?php _e('Backup-Datei', 'wp-multi-toolkit'); ?></th>
|
||
<th><?php _e('Aktionen', 'wp-multi-toolkit'); ?></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($backups as $backup): ?>
|
||
<tr>
|
||
<td><?php echo basename($backup); ?></td>
|
||
<td>
|
||
<a href="<?php echo esc_url(wp_upload_dir()['baseurl'] . '/wpmt_backups/' . basename($backup)); ?>" class="button" download><?php _e('Herunterladen', 'wp-multi-toolkit'); ?></a>
|
||
<form method="post" action="" style="display:inline;">
|
||
<input type="hidden" name="wpmt_action" value="delete_backup">
|
||
<input type="hidden" name="backup_file" value="<?php echo esc_attr(basename($backup)); ?>">
|
||
<input type="submit" class="button" value="<?php _e('Löschen', 'wp-multi-toolkit'); ?>" onclick="return confirm('<?php _e('Backup wirklich löschen?', 'wp-multi-toolkit'); ?>');">
|
||
</form>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
<?php else: ?>
|
||
<p><?php _e('Noch keine Backups vorhanden.', 'wp-multi-toolkit'); ?></p>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php
|
||
}
|
||
|
||
// Handle Backup- und Löschvorgänge
|
||
function wpmt_handle_backup_request() {
|
||
wpmt_delete_backup(); // Handle Löschvorgang
|
||
|
||
if (isset($_POST['wpmt_action']) && $_POST['wpmt_action'] == 'create_backup') {
|
||
$backup_path = wpmt_create_database_backup();
|
||
|
||
if (is_wp_error($backup_path)) {
|
||
echo '<div class="error"><p>' . $backup_path->get_error_message() . '</p></div>';
|
||
} else {
|
||
echo '<div class="updated"><p>' . __('Datenbank-Backup erfolgreich erstellt!', 'wp-multi-toolkit') . '</p></div>';
|
||
}
|
||
}
|
||
}
|
||
|
||
// Admin-Menüpunkt unter Tools/Werkzeuge hinzufügen
|
||
function wpmt_add_backup_menu() {
|
||
add_submenu_page(
|
||
'tools.php',
|
||
'WP-Multi DB-Backup',
|
||
'WP-Multi DB-Backup',
|
||
'manage_options',
|
||
'wpmt-database-backup',
|
||
'wpmt_display_backup_page'
|
||
);
|
||
}
|
||
add_action('admin_menu', 'wpmt_add_backup_menu');
|
||
|
||
// Sicherstellen, dass die Anfrage bearbeitet wird
|
||
add_action('admin_init', 'wpmt_handle_backup_request');
|
||
|
||
|
||
/*
|
||
* DB cleaner
|
||
*/
|
||
|
||
|
||
function wp_multi_db_cleaner_page() {
|
||
if (!current_user_can('manage_options')) return;
|
||
|
||
global $wpdb;
|
||
$db_tables = $wpdb->get_results("SHOW TABLES", ARRAY_N);
|
||
|
||
$core_protected_tables = [
|
||
$wpdb->prefix . 'posts',
|
||
$wpdb->prefix . 'postmeta',
|
||
$wpdb->prefix . 'users',
|
||
$wpdb->prefix . 'usermeta',
|
||
$wpdb->prefix . 'options',
|
||
$wpdb->prefix . 'comments',
|
||
$wpdb->prefix . 'commentmeta',
|
||
$wpdb->prefix . 'terms',
|
||
$wpdb->prefix . 'termmeta',
|
||
$wpdb->prefix . 'term_relationships',
|
||
$wpdb->prefix . 'term_taxonomy',
|
||
$wpdb->prefix . 'links',
|
||
];
|
||
|
||
$allow_system_tables = get_option('wp_multi_allow_system_tables', 'no') === 'yes';
|
||
|
||
if (isset($_POST['wp_multi_clean_submit']) && check_admin_referer('wp_multi_clean_action', 'wp_multi_clean_nonce')) {
|
||
// Option für die Systemtabellen sperre speichern
|
||
if (isset($_POST['allow_system_tables'])) {
|
||
update_option('wp_multi_allow_system_tables', 'yes');
|
||
} else {
|
||
update_option('wp_multi_allow_system_tables', 'no');
|
||
}
|
||
|
||
$results = wp_multi_clean_database($_POST['clean_options'] ?? [], $_POST['truncate_tables'] ?? [], $core_protected_tables, $allow_system_tables);
|
||
echo '<div class="notice notice-success"><p><strong>Datenbankbereinigung abgeschlossen:</strong></p><ul>';
|
||
foreach ($results as $r) echo '<li>' . esc_html($r) . '</li>';
|
||
echo '</ul></div>';
|
||
}
|
||
|
||
?>
|
||
<div class="wrap">
|
||
<h1>🧹 WP Multi Toolkit – Datenbank Cleaner</h1>
|
||
<p>Hier kannst du gezielt Inhalte aus deiner Datenbank löschen oder bereinigen.</p>
|
||
|
||
<form method="post">
|
||
<?php wp_nonce_field('wp_multi_clean_action', 'wp_multi_clean_nonce'); ?>
|
||
|
||
<h2>⚠️ Systemtabellen (Achtung!)</h2>
|
||
<label><input type="checkbox" name="allow_system_tables" <?php checked($allow_system_tables, true); ?>> Systemtabellen-Sperre aufheben (Achtung: Nur auf eigene Gefahr!)</label>
|
||
<p>Wenn du diese Option aktivierst, können Systemtabellen (z.B. Optionen, Beiträge) ebenfalls geleert werden. Sei vorsichtig und stelle sicher, dass du weißt, was du tust!</p>
|
||
|
||
<hr>
|
||
<h2>🔧 Standardbereinigung</h2>
|
||
<label><input type="checkbox" name="clean_options[]" value="revisions"> Alte Revisionen</label><br>
|
||
<label><input type="checkbox" name="clean_options[]" value="transients"> Abgelaufene Transienten</label><br>
|
||
<label><input type="checkbox" name="clean_options[]" value="options"> Verwaiste Optionen</label><br>
|
||
|
||
<hr>
|
||
<h2>🧱 Tabellen gezielt leeren</h2>
|
||
<p>Hier kannst du benutzerdefinierte oder Plugin-Tabellen auswählen, deren Inhalte gelöscht werden sollen. Systemtabellen sind aus Sicherheitsgründen deaktiviert, es sei denn, die Sperre wurde aufgehoben.</p>
|
||
<table class="widefat striped">
|
||
<thead>
|
||
<tr>
|
||
<th>Leeren?</th>
|
||
<th>Tabellenname</th>
|
||
<th>Einträge</th>
|
||
<th>Beschreibung</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($db_tables as $table):
|
||
$table_name = $table[0];
|
||
$short_name = str_replace($wpdb->prefix, '', $table_name);
|
||
$entry_count = $wpdb->get_var("SELECT COUNT(*) FROM `$table_name`");
|
||
$description = wp_multi_get_table_description($short_name);
|
||
$is_core = in_array($table_name, $core_protected_tables) && !$allow_system_tables;
|
||
?>
|
||
<tr>
|
||
<td>
|
||
<?php if (!$is_core): ?>
|
||
<input type="checkbox" name="truncate_tables[]" value="<?php echo esc_attr($table_name); ?>">
|
||
<?php else: ?>
|
||
🔒 (geschützt)
|
||
<?php endif; ?>
|
||
</td>
|
||
<td><code><?php echo esc_html($table_name); ?></code></td>
|
||
<td><?php echo esc_html($entry_count); ?></td>
|
||
<td><?php echo esc_html($description); ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
|
||
<br>
|
||
<input type="submit" name="wp_multi_clean_submit" class="button button-primary" value="Ausgewählte Bereinigungen durchführen">
|
||
</form>
|
||
</div>
|
||
<?php
|
||
}
|
||
|
||
function wp_multi_clean_database($options, $truncate_tables, $protected, $allow_system_tables) {
|
||
global $wpdb;
|
||
$results = [];
|
||
|
||
if (in_array('revisions', $options)) {
|
||
$deleted = $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type = 'revision'");
|
||
$results[] = "$deleted Revision(en) gelöscht.";
|
||
}
|
||
|
||
if (in_array('transients', $options)) {
|
||
$transients = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_%'");
|
||
$results[] = "$transients Transient(en) gelöscht.";
|
||
}
|
||
|
||
if (in_array('options', $options)) {
|
||
$orphaned = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_value = '' OR option_value IS NULL");
|
||
$results[] = "$orphaned verwaiste Option(en) gelöscht.";
|
||
}
|
||
|
||
foreach ($truncate_tables as $table) {
|
||
if (!$allow_system_tables && in_array($table, $protected)) {
|
||
$results[] = "Tabelle $table ist geschützt und wurde nicht geleert.";
|
||
} else {
|
||
$wpdb->query("TRUNCATE TABLE `$table`");
|
||
$results[] = "Tabelle $table geleert.";
|
||
}
|
||
}
|
||
|
||
if (empty($results)) {
|
||
$results[] = "Keine Aktionen durchgeführt.";
|
||
}
|
||
|
||
return $results;
|
||
}
|
||
|
||
function wp_multi_get_table_description($short_name) {
|
||
// Hier kannst du für jede Tabelle eine Beschreibung hinzufügen
|
||
$descriptions = [
|
||
'postmeta' => 'Meta-Daten zu Beiträgen',
|
||
'options' => 'Allgemeine Optionen',
|
||
// Weitere Tabellenbeschreibungen hier hinzufügen
|
||
];
|
||
|
||
return isset($descriptions[$short_name]) ? $descriptions[$short_name] : 'Keine Beschreibung verfügbar';
|
||
}
|
||
|
||
// Menüpunkt unter Werkzeuge hinzufügen
|
||
function wp_multi_toolkit_menu() {
|
||
add_submenu_page(
|
||
'tools.php', // Untermenü von Werkzeuge
|
||
'WP Multi DB cleaner', // Titel der Seite
|
||
'WP Multi DB cleaner', // Name des Menüpunkts
|
||
'manage_options', // Berechtigung
|
||
'wp-multi-toolkit', // Slug
|
||
'wp_multi_db_cleaner_page' // Funktion zum Anzeigen der Seite
|
||
);
|
||
}
|
||
add_action('admin_menu', 'wp_multi_toolkit_menu');
|
||
|
||
|
||
/*
|
||
* Cookie-Banner
|
||
*/
|
||
|
||
|
||
// Menü für das Cookie-Banner
|
||
function wpmt_cookie_banner_menu() {
|
||
add_options_page(
|
||
__('Cookie Banner Einstellungen', 'wp-multi-toolkit'),
|
||
__('Cookie Banner', 'wp-multi-toolkit'),
|
||
'manage_options',
|
||
'wpmt-cookie-banner',
|
||
'wpmt_cookie_banner_settings_page'
|
||
);
|
||
}
|
||
add_action('admin_menu', 'wpmt_cookie_banner_menu');
|
||
|
||
// Admin-Bereich für die Cookie-Einstellungen
|
||
function wpmt_cookie_banner_settings_page() {
|
||
// Speichern der Daten, wenn das Formular übermittelt wird
|
||
if(isset($_POST['wpmt_save_cookie_settings'])) {
|
||
update_option('wpmt_cookie_banner_text', sanitize_textarea_field($_POST['wpmt_cookie_banner_text']));
|
||
update_option('wpmt_cookie_accept_text', sanitize_text_field($_POST['wpmt_cookie_accept_text']));
|
||
update_option('wpmt_cookie_decline_text', sanitize_text_field($_POST['wpmt_cookie_decline_text']));
|
||
update_option('wpmt_cookie_policy_url', esc_url_raw($_POST['wpmt_cookie_policy_url']));
|
||
update_option('wpmt_cookie_impressum_url', esc_url_raw($_POST['wpmt_cookie_impressum_url']));
|
||
update_option('wpmt_cookie_banner_background_color', sanitize_hex_color($_POST['wpmt_cookie_banner_background_color']));
|
||
update_option('wpmt_cookie_type_necessary', isset($_POST['wpmt_cookie_type_necessary']) ? '1' : '0');
|
||
update_option('wpmt_cookie_type_preferences', isset($_POST['wpmt_cookie_type_preferences']) ? '1' : '0');
|
||
update_option('wpmt_cookie_type_statistics', isset($_POST['wpmt_cookie_type_statistics']) ? '1' : '0');
|
||
update_option('wpmt_cookie_type_marketing', isset($_POST['wpmt_cookie_type_marketing']) ? '1' : '0');
|
||
update_option('wpmt_content_blocking_enabled', isset($_POST['wpmt_content_blocking_enabled']) ? '1' : '0');
|
||
update_option('wpmt_enable_cookie_banner', isset($_POST['wpmt_enable_cookie_banner']) ? '1' : '0');
|
||
echo '<div class="notice notice-success is-dismissible"><p>' . __('Einstellungen gespeichert!', 'wp-multi-toolkit') . '</p></div>';
|
||
}
|
||
|
||
// Optionen aus der Datenbank abrufen
|
||
$cookie_banner_text = get_option('wpmt_cookie_banner_text', __('Wir verwenden Cookies, um Ihnen das beste Erlebnis zu bieten.', 'wp-multi-toolkit'));
|
||
$cookie_accept_text = get_option('wpmt_cookie_accept_text', __('Akzeptieren', 'wp-multi-toolkit'));
|
||
$cookie_decline_text = get_option('wpmt_cookie_decline_text', __('Ablehnen', 'wp-multi-toolkit'));
|
||
$cookie_policy_url = get_option('wpmt_cookie_policy_url', '');
|
||
$cookie_impressum_url = get_option('wpmt_cookie_impressum_url', '');
|
||
$cookie_banner_background_color = get_option('wpmt_cookie_banner_background_color', '#f0f0f0');
|
||
$cookie_type_necessary = get_option('wpmt_cookie_type_necessary', '1');
|
||
$cookie_type_preferences = get_option('wpmt_cookie_type_preferences', '0');
|
||
$cookie_type_statistics = get_option('wpmt_cookie_type_statistics', '0');
|
||
$cookie_type_marketing = get_option('wpmt_cookie_type_marketing', '0');
|
||
$content_blocking_enabled = get_option('wpmt_content_blocking_enabled', '0');
|
||
$enable_cookie_banner = get_option('wpmt_enable_cookie_banner', '1');
|
||
|
||
// HTML für Einstellungsseite
|
||
?>
|
||
<div class="wrap">
|
||
<h1><?php _e('Cookie Banner Einstellungen', 'wp-multi-toolkit'); ?></h1>
|
||
<form method="post">
|
||
<table class="form-table">
|
||
<tr valign="top">
|
||
<th scope="row"><?php _e('Cookie Banner aktivieren', 'wp-multi-toolkit'); ?></th>
|
||
<td><input type="checkbox" name="wpmt_enable_cookie_banner" value="1" <?php checked( $enable_cookie_banner, 1 ); ?> /></td>
|
||
</tr>
|
||
<tr valign="top">
|
||
<th scope="row"><?php _e('Cookie Banner Text', 'wp-multi-toolkit'); ?></th>
|
||
<td><textarea name="wpmt_cookie_banner_text" class="large-text"><?php echo esc_textarea( $cookie_banner_text ); ?></textarea></td>
|
||
</tr>
|
||
<tr valign="top">
|
||
<th scope="row"><?php _e('Akzeptieren Button Text', 'wp-multi-toolkit'); ?></th>
|
||
<td><input type="text" name="wpmt_cookie_accept_text" value="<?php echo esc_attr( $cookie_accept_text ); ?>" class="regular-text" /></td>
|
||
</tr>
|
||
<tr valign="top">
|
||
<th scope="row"><?php _e('Ablehnen Button Text', 'wp-multi-toolkit'); ?></th>
|
||
<td><input type="text" name="wpmt_cookie_decline_text" value="<?php echo esc_attr( $cookie_decline_text ); ?>" class="regular-text" /></td>
|
||
</tr>
|
||
<tr valign="top">
|
||
<th scope="row"><?php _e('Datenschutzerklärung URL', 'wp-multi-toolkit'); ?></th>
|
||
<td><input type="url" name="wpmt_cookie_policy_url" value="<?php echo esc_url( $cookie_policy_url ); ?>" class="regular-text" /></td>
|
||
</tr>
|
||
<tr valign="top">
|
||
<th scope="row"><?php _e('Impressum URL', 'wp-multi-toolkit'); ?></th>
|
||
<td><input type="url" name="wpmt_cookie_impressum_url" value="<?php echo esc_url( $cookie_impressum_url ); ?>" class="regular-text" /></td>
|
||
</tr>
|
||
<tr valign="top">
|
||
<th scope="row"><?php _e('Banner Hintergrundfarbe', 'wp-multi-toolkit'); ?></th>
|
||
<td><input type="color" name="wpmt_cookie_banner_background_color" value="<?php echo esc_attr( $cookie_banner_background_color ); ?>" /></td>
|
||
</tr>
|
||
<tr valign="top">
|
||
<th scope="row"><?php _e('Cookie-Typen', 'wp-multi-toolkit'); ?></th>
|
||
<td>
|
||
<label><input type="checkbox" name="wpmt_cookie_type_necessary" value="1" <?php checked( $cookie_type_necessary, 1 ); ?> /> <?php _e('Notwendig', 'wp-multi-toolkit'); ?></label><br />
|
||
<label><input type="checkbox" name="wpmt_cookie_type_preferences" value="1" <?php checked( $cookie_type_preferences, 1 ); ?> /> <?php _e('Präferenzen', 'wp-multi-toolkit'); ?></label><br />
|
||
<label><input type="checkbox" name="wpmt_cookie_type_statistics" value="1" <?php checked( $cookie_type_statistics, 1 ); ?> /> <?php _e('Statistiken', 'wp-multi-toolkit'); ?></label><br />
|
||
<label><input type="checkbox" name="wpmt_cookie_type_marketing" value="1" <?php checked( $cookie_type_marketing, 1 ); ?> /> <?php _e('Marketing', 'wp-multi-toolkit'); ?></label><br />
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<input type="hidden" name="wpmt_save_cookie_settings" value="1">
|
||
<?php submit_button(); ?>
|
||
</form>
|
||
</div>
|
||
<?php
|
||
}
|
||
|
||
// DSGVO-konforme Cookie Banner Darstellung
|
||
function wpmt_cookie_banner() {
|
||
// Überprüfen, ob der Cookie-Banner aktiv ist
|
||
$enabled = get_option('wpmt_enable_cookie_banner', '1');
|
||
if ($enabled !== '1') {
|
||
return;
|
||
}
|
||
|
||
// Überprüfen, ob der Benutzer schon zugestimmt hat
|
||
if( isset($_COOKIE['wpmt_cookie_accepted']) ) {
|
||
return; // Banner wird nicht angezeigt, wenn der Nutzer zugestimmt hat
|
||
}
|
||
|
||
// Banner-Inhalte aus den Optionen
|
||
$banner_text = get_option('wpmt_cookie_banner_text', __('Wir verwenden Cookies, um Ihnen das beste Erlebnis zu bieten.', 'wp-multi-toolkit'));
|
||
$accept_text = get_option('wpmt_cookie_accept_text', __('Akzeptieren', 'wp-multi-toolkit'));
|
||
$decline_text = get_option('wpmt_cookie_decline_text', __('Ablehnen', 'wp-multi-toolkit'));
|
||
$policy_url = get_option('wpmt_cookie_policy_url', '');
|
||
$impressum_url = get_option('wpmt_cookie_impressum_url', '');
|
||
$banner_background_color = get_option('wpmt_cookie_banner_background_color', '#f0f0f0');
|
||
|
||
// Banner Style
|
||
$banner_style = 'position:fixed; bottom:0; left:0; width:100%; background:' . esc_attr( $banner_background_color ) . '; padding:10px; text-align:center; z-index:1000;';
|
||
|
||
// HTML für den Cookie-Banner
|
||
echo '<div style="' . $banner_style . '" id="cookie-banner">';
|
||
echo '<p>' . esc_html($banner_text) . ' <a href="' . esc_url($policy_url) . '">' . __('Mehr erfahren', 'wp-multi-toolkit') . '</a> | <a href="' . esc_url($impressum_url) . '">' . __('Impressum', 'wp-multi-toolkit') . '</a></p>';
|
||
echo '<button id="accept-cookies" class="button">' . esc_html($accept_text) . '</button>';
|
||
echo '<button id="decline-cookies" class="button">' . esc_html($decline_text) . '</button>';
|
||
echo '</div>';
|
||
|
||
// JavaScript zum Setzen des Cookies nach Zustimmung
|
||
?>
|
||
<script type="text/javascript">
|
||
document.getElementById('accept-cookies').addEventListener('click', function() {
|
||
document.cookie = "wpmt_cookie_accepted=true; path=/; max-age=" + (60 * 60 * 24 * 365); // 1 Jahr gültig
|
||
document.getElementById('cookie-banner').style.display = 'none';
|
||
|
||
// Speichern der Zustimmung in der Datenbank
|
||
var xhr = new XMLHttpRequest();
|
||
xhr.open('POST', '<?php echo admin_url('admin-ajax.php'); ?>', true);
|
||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||
xhr.send('action=wpmt_save_cookie_consent&cookie_accepted=true');
|
||
});
|
||
|
||
document.getElementById('decline-cookies').addEventListener('click', function() {
|
||
document.getElementById('cookie-banner').style.display = 'none';
|
||
});
|
||
</script>
|
||
<?php
|
||
}
|
||
add_action('wp_footer', 'wpmt_cookie_banner');
|
||
|
||
// AJAX-Aktion für das Speichern der Zustimmung
|
||
function wpmt_save_cookie_consent() {
|
||
if (isset($_POST['cookie_accepted']) && $_POST['cookie_accepted'] === 'true') {
|
||
global $wpdb;
|
||
|
||
// Speichern der Zustimmung in der Datenbank
|
||
$wpdb->insert(
|
||
$wpdb->prefix . 'wpmt_cookie_consent',
|
||
array(
|
||
'user_ip' => $_SERVER['REMOTE_ADDR'],
|
||
'consent_given' => 1,
|
||
'timestamp' => current_time('mysql')
|
||
)
|
||
);
|
||
}
|
||
wp_die();
|
||
}
|
||
add_action('wp_ajax_wpmt_save_cookie_consent', 'wpmt_save_cookie_consent');
|
||
add_action('wp_ajax_nopriv_wpmt_save_cookie_consent', 'wpmt_save_cookie_consent');
|
||
|
||
// Tabelle für die Cookie-Zustimmung erstellen (bei Aktivierung des Plugins oder beim Laden des Plugins)
|
||
function wpmt_create_cookie_consent_table() {
|
||
global $wpdb;
|
||
|
||
$table_name = $wpdb->prefix . 'wpmt_cookie_consent';
|
||
|
||
// Prüfen, ob die Tabelle bereits existiert
|
||
if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") !== $table_name) {
|
||
// Tabelle erstellen
|
||
$charset_collate = $wpdb->get_charset_collate();
|
||
|
||
$sql = "CREATE TABLE $table_name (
|
||
id bigint(20) NOT NULL AUTO_INCREMENT,
|
||
user_ip varchar(255) NOT NULL,
|
||
consent_given tinyint(1) NOT NULL,
|
||
timestamp datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||
PRIMARY KEY (id)
|
||
) $charset_collate;";
|
||
|
||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
||
dbDelta($sql);
|
||
}
|
||
}
|
||
|
||
// Aufruf beim Laden des Plugins
|
||
add_action('plugins_loaded', 'wpmt_create_cookie_consent_table');
|
||
|
||
// Aufruf bei der Aktivierung des Plugins
|
||
register_activation_hook(__FILE__, 'wpmt_create_cookie_consent_table');
|
||
|
||
|
||
/*
|
||
* Backup Autoveröffentlichung
|
||
*/
|
||
|
||
|
||
// Funktion, um zukünftige Posts zu veröffentlichen
|
||
function pubMissedPosts() {
|
||
if (is_front_page() || is_single()) {
|
||
global $wpdb;
|
||
$now = gmdate('Y-m-d H:i:00');
|
||
|
||
// Überprüfe, ob benutzerdefinierte Beitragstypen vorhanden sind
|
||
$args = array(
|
||
'public' => true,
|
||
'_builtin' => false,
|
||
);
|
||
|
||
$output = 'names'; // names oder objects, names ist der Standard
|
||
$operator = 'and'; // 'and' oder 'or'
|
||
$post_types = get_post_types($args, $output, $operator);
|
||
|
||
if (count($post_types) === 0) {
|
||
$sql = "SELECT ID FROM $wpdb->posts WHERE post_type IN ('post', 'page') AND post_status = 'future' AND post_date_gmt < '$now'";
|
||
} else {
|
||
$str = implode('\',\'', $post_types);
|
||
$sql = "SELECT ID FROM $wpdb->posts WHERE post_type IN ('page', 'post', '$str') AND post_status = 'future' AND post_date_gmt < '$now'";
|
||
}
|
||
|
||
$resulto = $wpdb->get_results($sql);
|
||
if ($resulto) {
|
||
foreach ($resulto as $thisarr) {
|
||
wp_publish_post($thisarr->ID);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Die Funktion beim Laden der Seite aufrufen
|
||
add_action('wp_head', 'pubMissedPosts');
|
||
|
||
|
||
/*
|
||
* Gitea - Ticket - BUG - Report
|
||
*/
|
||
|
||
/**
|
||
* Sendet ein Support-Ticket an den Server und leitet es an das entsprechende Gitea-Repository weiter.
|
||
*
|
||
* @param string $plugin_name Der Name des Plugins (z. B. wp-multi, wp-multi-teamcard).
|
||
* @param string $title Der Titel des Tickets.
|
||
* @param string $description Die Beschreibung des Tickets.
|
||
* @param string $label Die Kategorie des Tickets (z. B. bug, enhancement).
|
||
* @return string Die Rückmeldung (Erfolg oder Fehler).
|
||
*/
|
||
function send_support_ticket_to_server($plugin_name, $title, $description, $label = 'bug') {
|
||
$server_url = 'https://m-viper.de/gitea-issue-creator.php';
|
||
|
||
// Daten für die Anfrage vorbereiten
|
||
$data = [
|
||
'plugin' => $plugin_name,
|
||
'title' => $title,
|
||
'description' => $description,
|
||
'label' => $label
|
||
];
|
||
|
||
$args = [
|
||
'method' => 'POST',
|
||
'body' => json_encode($data),
|
||
'headers' => [
|
||
'Content-Type' => 'application/json',
|
||
],
|
||
'timeout' => 45,
|
||
];
|
||
|
||
$response = wp_remote_post($server_url, $args);
|
||
|
||
if (is_wp_error($response)) {
|
||
$error_message = $response->get_error_message();
|
||
return '<span class="error-message">' . sprintf(__('Es gab einen Fehler bei der Ticketübertragung: %s', 'wp-multi-toolkit'), $error_message) . '</span>';
|
||
}
|
||
|
||
$response_body = wp_remote_retrieve_body($response);
|
||
$response_data = json_decode($response_body, true);
|
||
|
||
if (isset($response_data['message']) && $response_data['message'] === 'Issues erfolgreich erstellt') {
|
||
return '<span class="success-message">' . __('Issues erfolgreich erstellt', 'wp-multi-toolkit') . '</span>';
|
||
} else {
|
||
return '<span class="error-message">' . sprintf(__('Es gab einen Fehler: %s', 'wp-multi-toolkit'), esc_html($response_body)) . '</span>';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Rendert das Support-Ticket-Formular im Admin-Bereich.
|
||
*/
|
||
function support_ticket_form() {
|
||
?>
|
||
<div class="wrap">
|
||
<h1 class="wp-multi-support-title"><?php _e('WP-Multi Support', 'wp-multi-toolkit'); ?></h1>
|
||
<div class="support-form-container">
|
||
<form method="post" class="wp-multi-support-form">
|
||
<div class="form-group">
|
||
<label for="plugin_name"><?php _e('Wählen Sie das Plugin', 'wp-multi-toolkit'); ?></label>
|
||
<select name="plugin_name" id="plugin_name" required>
|
||
<option value="wp-multi"><?php _e('WP Multi', 'wp-multi-toolkit'); ?></option>
|
||
<option value="wp-multi-search"><?php _e('WP Multi Search', 'wp-multi-toolkit'); ?></option>
|
||
<option value="wp-multi-toolkit"><?php _e('WP Multi Toolkit', 'wp-multi-toolkit'); ?></option>
|
||
<option value="wp-multi-comment-notifications"><?php _e('WP Multi Comment Notifications', 'wp-multi-toolkit'); ?></option>
|
||
<option value="wp-multi-kategorie"><?php _e('WP Multi Kategorie', 'wp-multi-toolkit'); ?></option>
|
||
<option value="wp-multi-teamcard"><?php _e('WP Multi Team-Card', 'wp-multi-toolkit'); ?></option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="ticket_title"><?php _e('Ticket-Titel', 'wp-multi-toolkit'); ?></label>
|
||
<input type="text" name="ticket_title" id="ticket_title" required placeholder="<?php _e('Geben Sie den Titel ein', 'wp-multi-toolkit'); ?>" />
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="ticket_description"><?php _e('Ticket-Beschreibung', 'wp-multi-toolkit'); ?></label>
|
||
<textarea name="ticket_description" id="ticket_description" required placeholder="<?php _e('Beschreiben Sie Ihr Anliegen', 'wp-multi-toolkit'); ?>"></textarea>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label for="ticket_label"><?php _e('Kategorie', 'wp-multi-toolkit'); ?></label>
|
||
<select name="ticket_label" id="ticket_label" required>
|
||
<option value="bug"><?php _e('Bug (Etwas funktioniert nicht)', 'wp-multi-toolkit'); ?></option>
|
||
<option value="enhancement"><?php _e('Verbesserung (Neue Funktion)', 'wp-multi-toolkit'); ?></option>
|
||
<option value="question"><?php _e('Frage (Mehr Infos benötigt)', 'wp-multi-toolkit'); ?></option>
|
||
<option value="help wanted"><?php _e('Hilfe benötigt', 'wp-multi-toolkit'); ?></option>
|
||
<option value="invalid"><?php _e('Ungültig (Etwas ist falsch)', 'wp-multi-toolkit'); ?></option>
|
||
<option value="duplicate"><?php _e('Duplikat (Bereits vorhanden)', 'wp-multi-toolkit'); ?></option>
|
||
<option value="wontfix"><?php _e('Wird nicht behoben', 'wp-multi-toolkit'); ?></option>
|
||
</select>
|
||
</div>
|
||
|
||
<input type="submit" name="submit_ticket" value="<?php _e('Ticket absenden', 'wp-multi-toolkit'); ?>" class="submit-button" />
|
||
</form>
|
||
|
||
<?php
|
||
if (isset($_POST['submit_ticket'])) {
|
||
$plugin_name = sanitize_text_field($_POST['plugin_name']);
|
||
$title = sanitize_text_field($_POST['ticket_title']);
|
||
$description = sanitize_textarea_field($_POST['ticket_description']);
|
||
$label = sanitize_text_field($_POST['ticket_label']);
|
||
$result = send_support_ticket_to_server($plugin_name, $title, $description, $label);
|
||
echo '<div class="response-message">' . $result . '</div>';
|
||
}
|
||
?>
|
||
</div>
|
||
</div>
|
||
|
||
<?php
|
||
if (isset($_GET['page']) && $_GET['page'] === 'wp_multi_support') {
|
||
?>
|
||
<style>
|
||
.wp-multi-support-title {
|
||
font-size: 28px;
|
||
color: #23282d;
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.support-form-container {
|
||
background: #fff;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||
max-width: 600px;
|
||
margin: 0 auto;
|
||
}
|
||
|
||
.wp-multi-support-form .form-group {
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.wp-multi-support-form label {
|
||
display: block;
|
||
font-weight: bold;
|
||
margin-bottom: 5px;
|
||
color: #333;
|
||
}
|
||
|
||
.wp-multi-support-form input[type="text"],
|
||
.wp-multi-support-form textarea,
|
||
.wp-multi-support-form select {
|
||
width: 100%;
|
||
padding: 10px;
|
||
border: 1px solid #ddd;
|
||
border-radius: 4px;
|
||
box-sizing: border-box;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.wp-multi-support-form textarea {
|
||
height: 120px;
|
||
resize: vertical;
|
||
}
|
||
|
||
.wp-multi-support-form .submit-button {
|
||
background-color: #0073aa;
|
||
color: #fff;
|
||
padding: 10px 20px;
|
||
border: none;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
font-size: 16px;
|
||
transition: background-color 0.3s;
|
||
}
|
||
|
||
.wp-multi-support-form .submit-button:hover {
|
||
background-color: #005d82;
|
||
}
|
||
|
||
.response-message {
|
||
margin-top: 20px;
|
||
padding: 10px;
|
||
border-radius: 4px;
|
||
text-align: center;
|
||
}
|
||
|
||
.success-message {
|
||
color: #155724;
|
||
background-color: #d4edda;
|
||
border: 1px solid #c3e6cb;
|
||
}
|
||
|
||
.error-message {
|
||
color: #721c24;
|
||
background-color: #f8d7da;
|
||
border: 1px solid #f5c6cb;
|
||
}
|
||
</style>
|
||
<?php
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Fügt die Support-Ticket-Seite zum Admin-Menü hinzu.
|
||
*/
|
||
function add_support_ticket_page() {
|
||
add_menu_page(
|
||
__('WP-Multi Support', 'wp-multi-toolkit'),
|
||
__('WP-Multi Support', 'wp-multi-toolkit'),
|
||
'manage_options',
|
||
'wp_multi_support',
|
||
'support_ticket_form'
|
||
);
|
||
}
|
||
add_action('admin_menu', 'add_support_ticket_page');
|
||
|
||
|
||
/*
|
||
* Virtueller Assistent als Submenü
|
||
*/
|
||
|
||
|
||
function wpmt_virtual_assistant_page() {
|
||
if (!current_user_can('manage_options')) {
|
||
wp_die(__('Du hast nicht die Berechtigung, auf diese Seite zuzugreifen.', 'wp-multi-toolkit'));
|
||
}
|
||
|
||
$assistant_responses = apply_filters('wpmt_assistant_responses', array(
|
||
'default' => __('Entschuldigung, das verstehe ich nicht. Versuche es mit einer anderen Frage oder erstelle ein Support-Ticket unter WP-Multi Support!', 'wp-multi-toolkit')
|
||
));
|
||
|
||
// Stichwörter aus den Antworten extrahieren (ohne 'default')
|
||
$keywords = array_keys($assistant_responses);
|
||
unset($keywords[array_search('default', $keywords)]); // Entfernt 'default' aus der Liste
|
||
$keywords_list = implode(', ', $keywords);
|
||
|
||
?>
|
||
<div class="wrap">
|
||
<h1><?php _e('WP Multi Virtueller Assistent', 'wp-multi-toolkit'); ?></h1>
|
||
<div class="wpmt-assistant-container" style="background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); max-width: 600px; margin: 0 auto 20px;">
|
||
<img src="https://m-viper.de/img/bot.png" alt="<?php _e('Virtueller Assistent', 'wp-multi-toolkit'); ?>" style="max-width: 100px; display: block; margin: 0 auto 20px;">
|
||
<p><?php _e('Stelle mir eine Frage zu WP Multi Plugins!', 'wp-multi-toolkit'); ?></p>
|
||
<input type="text" id="assistant-input" style="width: 100%; padding: 10px; margin-bottom: 10px;" placeholder="<?php _e('z. B. Wie aktiviere ich Telegram?', 'wp-multi-toolkit'); ?>" />
|
||
<button id="assistant-submit" class="button button-primary"><?php _e('Frage stellen', 'wp-multi-toolkit'); ?></button>
|
||
<div id="assistant-response" style="margin-top: 20px; padding: 10px; border: 1px solid #ddd; min-height: 50px;"></div>
|
||
</div>
|
||
<div class="wpmt-keywords-container" style="background: #f9f9f9; padding: 15px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); max-width: 600px; margin: 0 auto;">
|
||
<h3 style="margin-top: 0; font-size: 16px;"><?php _e('Verfügbare Stichwörter', 'wp-multi-toolkit'); ?></h3>
|
||
<p style="font-size: 12px; color: #666;"><?php echo esc_html($keywords_list); ?></p>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
jQuery(document).ready(function($) {
|
||
// Funktion zum Senden der Frage
|
||
function submitQuestion() {
|
||
var question = $('#assistant-input').val().toLowerCase();
|
||
var responses = <?php echo json_encode($assistant_responses); ?>;
|
||
var response = responses['default'];
|
||
|
||
for (var key in responses) {
|
||
if (question.includes(key)) {
|
||
response = responses[key];
|
||
break;
|
||
}
|
||
}
|
||
|
||
$('#assistant-response').html(response);
|
||
$('#assistant-input').val(''); // Eingabefeld nach dem Senden leeren
|
||
}
|
||
|
||
// Button-Klick-Event
|
||
$('#assistant-submit').on('click', function() {
|
||
submitQuestion();
|
||
});
|
||
|
||
// Enter-Taste-Event
|
||
$('#assistant-input').on('keypress', function(e) {
|
||
if (e.which === 13) { // 13 ist der Keycode für Enter
|
||
e.preventDefault(); // Verhindert Standard-Formularverhalten
|
||
submitQuestion();
|
||
}
|
||
});
|
||
});
|
||
</script>
|
||
<style>
|
||
.wpmt-assistant-container {
|
||
background: #fff;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||
max-width: 600px;
|
||
margin: 0 auto 20px;
|
||
text-align: center;
|
||
}
|
||
#assistant-input {
|
||
width: 100%;
|
||
padding: 10px;
|
||
border: 1px solid #ddd;
|
||
border-radius: 4px;
|
||
box-sizing: border-box;
|
||
font-size: 14px;
|
||
}
|
||
#assistant-submit {
|
||
background-color: #0073aa;
|
||
color: #fff;
|
||
padding: 10px 20px;
|
||
border: none;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
font-size: 16px;
|
||
transition: background-color 0.3s;
|
||
}
|
||
#assistant-submit:hover {
|
||
background-color: #005d82;
|
||
}
|
||
.wpmt-keywords-container {
|
||
background: #f9f9f9;
|
||
padding: 15px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||
max-width: 600px;
|
||
margin: 0 auto;
|
||
text-align: left;
|
||
}
|
||
.wpmt-keywords-container h3 {
|
||
margin-top: 0;
|
||
font-size: 16px;
|
||
color: #333;
|
||
}
|
||
.wpmt-keywords-container p {
|
||
font-size: 12px;
|
||
color: #666;
|
||
margin: 0;
|
||
}
|
||
</style>
|
||
<?php
|
||
}
|
||
|
||
function wpmt_add_assistant_page() {
|
||
add_submenu_page(
|
||
'wp_multi_support',
|
||
__('Virtueller Assistent', 'wp-multi-toolkit'),
|
||
__('Virtueller Assistent', 'wp-multi-toolkit'),
|
||
'manage_options',
|
||
'wpmt_assistant',
|
||
'wpmt_virtual_assistant_page'
|
||
);
|
||
}
|
||
add_action('admin_menu', 'wpmt_add_assistant_page');
|
||
|
||
|
||
/*
|
||
* Antworten vordefinieren
|
||
*/
|
||
|
||
|
||
add_filter('wpmt_assistant_responses', function($responses) {
|
||
// WP Multi
|
||
$responses['statistik'] = __('Nutze den Shortcode [statistik_manager] oder gehe zu "WP Stat & Notice", um Statistiken wie Beitragsanzahl, Kommentare, Kategorien und Serien anzuzeigen.', 'wp-multi-toolkit');
|
||
$responses['telegram'] = __('Schickt Benachrichtigungen für neue Beiträge an Telegram. Konfiguriere dies unter "Notify > TG-Notify".', 'wp-multi-toolkit');
|
||
$responses['discord'] = __('Schickt Benachrichtigungen für neue Beiträge an Discord. Konfiguriere dies unter "Notify > DC-Notify".', 'wp-multi-toolkit');
|
||
$responses['admin links'] = __('Füge eigene Links (z. B. zu externen Seiten) im Adminpanel hinzu. Gehe zu "Werkzeuge > Admin-Link hinzufügen".', 'wp-multi-toolkit');
|
||
$responses['gast-autor'] = __('Gib Gastautoren unter "Benutzer > Gastautor (Übersicht)" ein. Sie werden in jedem Beitrag im Frontend angezeigt.', 'wp-multi-toolkit');
|
||
$responses['beitrag report'] = __('Unangemessene Beiträge melden und bearbeiten. Sieh die Liste unter "Gemeldete Beiträge".', 'wp-multi-toolkit');
|
||
$responses['textbox'] = __('Fügt eine Textbox mit vordefinierten Texten am Beitragsende hinzu. Texte können im Adminpanel hinterlegt werden.', 'wp-multi-toolkit');
|
||
$responses['banner'] = __('Stelle ein Informationsbanner unter "WP Stat & Notice" ein (Header oder Footer).', 'wp-multi-toolkit');
|
||
$responses['inhaltsverzeichnis'] = __('Nutze den Shortcode [alphabetical_index], um ein Inhaltsverzeichnis aller Beiträge zu erstellen.', 'wp-multi-toolkit');
|
||
$responses['lesezeichen'] = __('Gäste können Lesezeichen mit [add_bookmark] setzen und mit [display_bookmarks] anzeigen. Per Cookie gespeichert.', 'wp-multi-toolkit');
|
||
$responses['custom shortcode'] = __('Erstelle eigene Shortcodes und wähle sie unter "Beitrag erstellen" im Editor aus.', 'wp-multi-toolkit');
|
||
$responses['kommentar sperren'] = __('Sperre Benutzer für Kommentare unter "Benutzer sperren" (z. B. via Benutzername, IP, Mail).', 'wp-multi-toolkit');
|
||
$responses['filter'] = __('Verbiete Rufnummern, Mailadressen, URLs, IPs oder Schimpfwörter unter "Kommentare > Kommentar Filter". Verstöße werden mit * ersetzt.', 'wp-multi-toolkit');
|
||
$responses['analytics'] = __('Sieh die beliebtesten Beiträge (Views, Kommentare, Titel, ID, Zeitstempel) unter "Benutzer > Benutzer Analytics".', 'wp-multi-toolkit');
|
||
$responses['pinwand'] = __('Hinterlege Nachrichten für Backend-Nutzer unter "Pinnwand". Diese können erstellt, bearbeitet oder gelöscht werden.', 'wp-multi-toolkit');
|
||
$responses['brute force'] = __('Schutz vor Brute-Force: Loggt Fehlversuche und sperrt nach 5 Versuchen. Einstellungen unter "Sicherheit".', 'wp-multi-toolkit');
|
||
$responses['anti spam'] = __('Blockiert Spam und Bots. Konfiguriere dies unter "Sicherheit" mit Übersicht im Adminpanel.', 'wp-multi-toolkit');
|
||
$responses['auto tag'] = __('Fügt fehlende Tags automatisch hinzu. Verwalte verbotene Wörter unter "Beiträge > Automatische Tags".', 'wp-multi-toolkit');
|
||
$responses['login deaktivieren'] = __('Deaktiviere Logins im Profil unter "Benutzer > Alle Benutzer > Benutzer auswählen".', 'wp-multi-toolkit');
|
||
$responses['text copy'] = __('Schützt Texte vor Kopieren (Rechtsklick-Sperre). Aktiviere dies in den WP Multi-Einstellungen.', 'wp-multi-toolkit');
|
||
$responses['trash mail'] = __('Verbietet Trash-Mail-Adressen in Kommentaren. Die Liste wird vom Entwickler gepflegt.', 'wp-multi-toolkit');
|
||
|
||
// WP Multi Comment Notifications
|
||
$responses['kommentar benachrichtigung'] = __('Schickt Benachrichtigungen für neue Kommentare per Mail, Telegram oder Discord. Einstellungen unter "Kommentare > Kommentar Benachrichtigung".', 'wp-multi-toolkit');
|
||
|
||
// WP Multi Kategorie
|
||
$responses['kategorien ausblenden'] = __('Blende einzelne Kategorien unter "Beiträge > Kategorie Filter" aus.', 'wp-multi-toolkit');
|
||
|
||
// WP Multi Search
|
||
$responses['suchfunktion'] = __('Füge eine Suchfunktion (Allgemein, Gastautor, Titel) als Shortcode, Widget oder Menüeintrag hinzu. Einstellungen unter "Einstellung > WP-Multi Search".', 'wp-multi-toolkit');
|
||
|
||
// WP Multi Team-Card
|
||
$responses['teamcard'] = __('Mit dem WP Multi Team-Card Plugin kannst du Teammitglieder mit Name, Funktion, Zuständigkeit und Bild erstellen. Nutze den Shortcode [teamcards] für die Anzeige im Frontend.', 'wp-multi-toolkit');
|
||
$responses['teammitglied hinzufügen'] = __('Gehe zu "Team-Cards" im Admin-Menü, fülle die Felder (Name, Funktion, Zuständigkeit, Bild) aus und klicke auf "Teammitglied hinzufügen".', 'wp-multi-toolkit');
|
||
$responses['teamcard shortcode'] = __('Verwende den Shortcode [teamcards] in einem Beitrag oder einer Seite, um alle Teammitglieder anzuzeigen. Für eine bestimmte Kategorie nutze z. B. [teamcards kategorie="slug"].', 'wp-multi-toolkit');
|
||
$responses['teamcard kategorie'] = __('Erstelle Kategorien für Teammitglieder unter "Beiträge > Kategorien". Weise sie den Teammitgliedern zu, um sie mit dem Shortcode [teamcards kategorie="slug"] gefiltert anzuzeigen.', 'wp-multi-toolkit');
|
||
$responses['teamcard bild'] = __('Füge ein Bild für ein Teammitglied hinzu, indem du in der "Team-Cards"-Verwaltung auf "Bild auswählen" klickst. Das Bild wird im Frontend in der Teamkarte angezeigt.', 'wp-multi-toolkit');
|
||
$responses['teamcard löschen'] = __('Um ein Teammitglied zu löschen, gehe zu "Team-Cards", finde das Mitglied in der Liste und klicke auf "Löschen".', 'wp-multi-toolkit');
|
||
$responses['teamcard reihenfolge'] = __('Ändere die Reihenfolge der Teammitglieder, indem du die Zeilen in der "Team-Cards"-Tabelle per Drag-and-Drop verschiebst.', 'wp-multi-toolkit');
|
||
$responses['teamcard deinstallation'] = __('Beim Löschen des WP Multi Team-Card Plugins werden alle Teammitglieder, Kategorien und Bilder aus der Datenbank entfernt. Erstelle ein Backup, wenn du die Daten behalten möchtest.', 'wp-multi-toolkit');
|
||
$responses['teamcard updates'] = __('Prüfe Updates für das WP Multi Team-Card Plugin unter https://git.viper.ipv64.net/M_Viper/wp-multi-teamcard. Eine Benachrichtigung erscheint im Admin-Bereich, wenn eine neue Version verfügbar ist.', 'wp-multi-toolkit');
|
||
|
||
// WP Multi Toolkit
|
||
$responses['update management'] = __('Zeigt den Status der WP Multi Plugins und verfügbare Updates im Dashboard-Widget "Verfügbare Updates für WP Multi Toolkit".', 'wp-multi-toolkit');
|
||
$responses['support issues'] = __('Erstelle Support-Tickets unter "WP-Multi Support" für Antworten zu WP Multi Plugins.', 'wp-multi-toolkit');
|
||
$responses['dokumentation'] = __('Finde die Dokumentation unter "WP-Multi Support > Dokumentation" mit Links zu den Plugins.', 'wp-multi-toolkit');
|
||
$responses['virtueller assistent'] = __('Ich bin der virtuelle Assistent! Stelle mir Fragen zu WP Multi Plugins unter "WP-Multi Support > Virtueller Assistent".', 'wp-multi-toolkit');
|
||
$responses['toolbar'] = __('Die Schnellstart-Toolbar unten rechts bietet Zugriff auf Support, Updates, Dokumentation und mich!', 'wp-multi-toolkit');
|
||
$responses['wp multi plugins'] = __('Folgende Plugins gehören zur WP Multi-Reihe: <br> - <strong>WP Multi Toolkit</strong>: Schnittstelle für alle WP Multi Plugins.<br> - <strong>WP Multi</strong>: Hauptplugin mit vielen Funktionen.<br> - <strong>WP Multi Comment Notifications</strong>: Benachrichtigungen für Kommentare.<br> - <strong>WP Multi Search</strong>: Erweiterte Suchfunktion.<br> - <strong>WP Multi Kategorie</strong>: Kategoriefilter.', 'wp-multi-toolkit');
|
||
|
||
// Allgemeine Fragen und Antworten zu WP Multi Plugins
|
||
$responses['was sind wp multi plugins'] = __('Die WP Multi Plugins sind eine Sammlung von WordPress-Plugins, die erweiterte Funktionen für deine Website bieten. Dazu gehören Tools für Benachrichtigungen, Sicherheit, Statistiken, Kommentar-Management und mehr. Sieh dir die Liste unter "wp multi plugins" an!', 'wp-multi-toolkit');
|
||
$responses['wie installiere ich ein plugin'] = __('Gehe zu "Plugins > Neu hinzufügen" in deinem WordPress-Dashboard, lade die Plugin-Datei (z. B. von https://git.viper.ipv64.net/M_Viper) hoch und aktiviere es. Alternativ kannst du es manuell über FTP in den Ordner /wp-content/plugins/ hochladen und aktivieren.', 'wp-multi-toolkit');
|
||
$responses['wo finde ich updates'] = __('Updates für WP Multi Plugins findest du im Dashboard-Widget "Verfügbare Updates für WP Multi Toolkit" oder auf https://git.viper.ipv64.net/M_Viper. Lade die neueste Version herunter und aktualisiere das Plugin manuell.', 'wp-multi-toolkit');
|
||
$responses['wie erstelle ich ein support ticket'] = __('Gehe zu "WP-Multi Support" im Admin-Menü, wähle das Plugin, gib einen Titel und eine Beschreibung ein und sende das Ticket ab. Du erhältst eine Bestätigung, wenn es erfolgreich erstellt wurde.', 'wp-multi-toolkit');
|
||
$responses['welche voraussetzungen gibt es'] = __('Die WP Multi Plugins benötigen mindestens WordPress 6.7.2. Einige Funktionen (z. B. Telegram- oder Discord-Benachrichtigungen) erfordern API-Keys oder zusätzliche Konfiguration. Details findest du in der Dokumentation.', 'wp-multi-toolkit');
|
||
$responses['sind die plugins kostenlos'] = __('Ja, alle WP Multi Plugins sind kostenlos verfügbar unter https://git.viper.ipv64.net/M_Viper. Es gibt keine versteckten Kosten und es wird kein Geld angenommen.', 'wp-multi-toolkit');
|
||
$responses['wie deaktiviere ich ein plugin'] = __('Gehe zu "Plugins > Installierte Plugins" in deinem WordPress-Dashboard, suche das Plugin und klicke auf "Deaktivieren". Du kannst es danach löschen, wenn du es nicht mehr benötigst.', 'wp-multi-toolkit');
|
||
$responses['wo finde ich die dokumentation'] = __('Die Dokumentation ist unter "WP-Multi Support > Dokumentation" im Admin-Menü verfügbar. Sie enthält Details zu jedem Plugin und Links zu den Download-Seiten.', 'wp-multi-toolkit');
|
||
$responses['wer entwickelt die plugins'] = __('Die WP Multi Plugins werden von M_Viper entwickelt. Mehr Infos findest du auf https://m-viper.de oder im Repository https://git.viper.ipv64.net/M_Viper.', 'wp-multi-toolkit');
|
||
$responses['kann ich eigene funktionen hinzufügen'] = __('Ja, die Plugins sind Open Source. Du kannst den Code auf https://git.viper.ipv64.net/M_Viper anpassen. Für Vorschläge erstelle ein Support-Ticket mit der Kategorie "Verbesserung".', 'wp-multi-toolkit');
|
||
|
||
return $responses;
|
||
});
|
||
|
||
|
||
/*
|
||
* Schnellzugriff-Menü (Floating Toolbar)
|
||
*/
|
||
|
||
|
||
function wpmt_add_floating_toolbar() {
|
||
if (!current_user_can('manage_options') || !is_admin()) {
|
||
return;
|
||
}
|
||
?>
|
||
<div id="wpmt-floating-toolbar" style="position: fixed; bottom: 20px; right: 20px; z-index: 1000;">
|
||
<button id="wpmt-toolbar-toggle" style="background: #0073aa; color: #fff; border: none; padding: 5px; border-radius: 50%; cursor: pointer; width: 40px; height: 40px; overflow: hidden;">
|
||
<img src="https://m-viper.de/img/bot.png" alt="<?php _e('Toolbar öffnen/schließen', 'wp-multi-toolkit'); ?>" style="width: 100%; height: 100%; object-fit: cover;" id="toolbar-icon">
|
||
</button>
|
||
<div id="wpmt-toolbar-menu" style="display: none; position: absolute; bottom: 50px; right: 0; background: #fff; padding: 10px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.2);">
|
||
<a href="<?php echo admin_url('admin.php?page=wp_multi_support'); ?>" class="button" style="display: block; margin: 5px 0;"><?php _e('Support-Ticket', 'wp-multi-toolkit'); ?></a>
|
||
<a href="<?php echo admin_url('index.php'); ?>" class="button" style="display: block; margin: 5px 0;"><?php _e('Updates prüfen', 'wp-multi-toolkit'); ?></a>
|
||
<a href="<?php echo admin_url('admin.php?page=wpmt_docs'); ?>" class="button" style="display: block; margin: 5px 0;"><?php _e('Dokumentation', 'wp-multi-toolkit'); ?></a>
|
||
<a href="<?php echo admin_url('admin.php?page=wpmt_assistant'); ?>" class="button" style="display: block; margin: 5px 0;"><?php _e('Assistent', 'wp-multi-toolkit'); ?></a>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
jQuery(document).ready(function($) {
|
||
$('#wpmt-toolbar-toggle').on('click', function() {
|
||
$('#wpmt-toolbar-menu').toggle();
|
||
// Bild bleibt statisch, da nur ein Bild verwendet wird
|
||
});
|
||
});
|
||
</script>
|
||
<?php
|
||
}
|
||
add_action('admin_footer', 'wpmt_add_floating_toolbar');
|
||
|
||
|
||
/*
|
||
* Update Funktion
|
||
*/
|
||
|
||
|
||
define('WPMT_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||
|
||
// Textdomain laden
|
||
function wpmt_load_textdomain() {
|
||
load_plugin_textdomain('wp-multi-toolkit', false, dirname(plugin_basename(__FILE__)) . '/languages');
|
||
}
|
||
add_action('plugins_loaded', 'wpmt_load_textdomain');
|
||
|
||
// ### WP Multi Grundfunktionen ###
|
||
|
||
// Optionen-Seite für WP Multi
|
||
function wpmt_register_settings() {
|
||
register_setting('wpmt_options_group', 'wpmt_multi_settings', array(
|
||
'sanitize_callback' => 'wpmt_sanitize_settings'
|
||
));
|
||
add_settings_section('wpmt_main_section', __('WP Multi Einstellungen', 'wp-multi-toolkit'), null, 'wpmt_settings');
|
||
add_settings_field('wpmt_enable_multi', __('Multi-Funktion aktivieren', 'wp-multi-toolkit'), 'wpmt_enable_multi_callback', 'wpmt_settings', 'wpmt_main_section');
|
||
}
|
||
add_action('admin_init', 'wpmt_register_settings');
|
||
|
||
function wpmt_sanitize_settings($input) {
|
||
$new_input = array();
|
||
$new_input['enable_multi'] = isset($input['enable_multi']) ? 1 : 0;
|
||
return $new_input;
|
||
}
|
||
|
||
function wpmt_enable_multi_callback() {
|
||
$options = get_option('wpmt_multi_settings', array('enable_multi' => 0));
|
||
echo '<input type="checkbox" name="wpmt_multi_settings[enable_multi]" value="1" ' . checked(1, $options['enable_multi'], false) . ' />';
|
||
}
|
||
|
||
function wpmt_settings_page() {
|
||
?>
|
||
<div class="wrap">
|
||
<h1><?php echo esc_html__('WP Multi Toolkit Einstellungen', 'wp-multi-toolkit'); ?></h1>
|
||
<form method="post" action="options.php">
|
||
<?php
|
||
settings_fields('wpmt_options_group');
|
||
do_settings_sections('wpmt_settings');
|
||
submit_button();
|
||
?>
|
||
</form>
|
||
</div>
|
||
<?php
|
||
}
|
||
|
||
// Shortcode für Multi-Funktionalität
|
||
function wpmt_multi_shortcode($atts) {
|
||
$options = get_option('wpmt_multi_settings', array('enable_multi' => 0));
|
||
if ($options['enable_multi']) {
|
||
return '<p>' . __('Multi-Funktion ist aktiviert!', 'wp-multi-toolkit') . '</p>';
|
||
}
|
||
return '<p>' . __('Multi-Funktion ist deaktiviert.', 'wp-multi-toolkit') . '</p>';
|
||
}
|
||
add_shortcode('wpmt_multi', 'wpmt_multi_shortcode');
|
||
|
||
// ### Automatisierte Plugin-Dokumentation ###
|
||
|
||
/**
|
||
* Ruft die neueste Version eines Plugins aus der Gitea-API ab.
|
||
*
|
||
* @param string $repo_name Der Name des Gitea-Repositorys.
|
||
* @return string|null Die neueste Version oder null bei Fehlern.
|
||
*/
|
||
function wpmt_get_latest_plugin_version($repo_name) {
|
||
$api_url = "https://git.viper.ipv64.net/api/v1/repos/M_Viper/{$repo_name}/releases";
|
||
$response = wp_remote_get($api_url, array(
|
||
'timeout' => 10,
|
||
'headers' => array('Accept' => 'application/json')
|
||
));
|
||
|
||
if (is_wp_error($response)) {
|
||
return null;
|
||
}
|
||
|
||
$body = wp_remote_retrieve_body($response);
|
||
$releases = json_decode($body, true);
|
||
|
||
if (empty($releases) || !is_array($releases)) {
|
||
return null;
|
||
}
|
||
|
||
// Sortiere Releases nach Erstellungsdatum (neuestes zuerst)
|
||
usort($releases, function($a, $b) {
|
||
return strtotime($b['created_at']) - strtotime($a['created_at']);
|
||
});
|
||
|
||
return !empty($releases[0]['tag_name']) ? ltrim($releases[0]['tag_name'], 'v') : null;
|
||
}
|
||
|
||
function wpmt_generate_plugin_docs() {
|
||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||
|
||
$installed_plugins = get_plugins();
|
||
$wp_multi_plugins = array(
|
||
'wp-multi-toolkit' => array(
|
||
'file' => 'wp-multi-toolkit/wp-multi-toolkit.php',
|
||
'name' => 'WP Multi Toolkit',
|
||
'description' => __('Zentrales Toolkit für die WP Multi Plugin-Reihe mit Update-Management und Support-Funktionen.', 'wp-multi-toolkit'),
|
||
'repo' => 'wp-multi-toolkit'
|
||
),
|
||
'wp-multi' => array(
|
||
'file' => 'WP-Multi/wp-multi.php',
|
||
'name' => 'WP Multi',
|
||
'description' => __('Hauptplugin für Multi-Funktionen mit Shortcode-Unterstützung.', 'wp-multi-toolkit'),
|
||
'repo' => 'wp-multi'
|
||
),
|
||
'wp-multi-search' => array(
|
||
'file' => 'wp-multi-search/wp-multi-search.php',
|
||
'name' => 'WP Multi Search',
|
||
'description' => __('Erweiterte Suchfunktionen für WordPress.', 'wp-multi-toolkit'),
|
||
'repo' => 'WP-Multi-Search'
|
||
),
|
||
'wp-multi-comment-notifications' => array(
|
||
'file' => 'wp-multi-comment-notifications/wp-multi-comment-notifications.php',
|
||
'name' => 'WP Multi Comment Notifications',
|
||
'description' => __('Automatische Benachrichtigungen für neue Kommentare.', 'wp-multi-toolkit'),
|
||
'repo' => 'wp-multi-comment-notifications'
|
||
),
|
||
'wp-multi-kategorie' => array(
|
||
'file' => 'wp-multi-kategorie/wp-multi-kategorie.php',
|
||
'name' => 'WP Multi Kategorie',
|
||
'description' => __('Filtert und verwaltet Kategorien für Beiträge.', 'wp-multi-toolkit'),
|
||
'repo' => 'wp-multi-kategorie'
|
||
),
|
||
'wp-multi-teamcard' => array(
|
||
'file' => 'wp-multi-teamcards/wp-multi-team-card.php', // Korrekter Pfad, wie von dir bestätigt
|
||
'name' => 'WP Multi Team-Card',
|
||
'description' => __('Erstellt Teamkarten mit Name, Funktion, Zuständigkeit und Bild, die über den Shortcode [teamcards] angezeigt werden.', 'wp-multi-toolkit'),
|
||
'repo' => 'wp-multi-teamcard'
|
||
)
|
||
);
|
||
|
||
?>
|
||
<div class="wrap">
|
||
<h1><?php echo esc_html__('WP Multi Plugin-Dokumentation', 'wp-multi-toolkit'); ?></h1>
|
||
<p><?php echo esc_html__('Hier finden Sie eine Übersicht aller WP Multi Plugins, einschließlich Versionen und grundlegender Informationen.', 'wp-multi-toolkit'); ?></p>
|
||
|
||
<?php foreach ($wp_multi_plugins as $key => $plugin) : ?>
|
||
<div class="wpmt-docs-section">
|
||
<h2><?php echo esc_html($plugin['name']); ?></h2>
|
||
<?php
|
||
$is_installed = array_key_exists($plugin['file'], $installed_plugins);
|
||
if ($is_installed) {
|
||
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin['file']);
|
||
$is_active = is_plugin_active($plugin['file']);
|
||
$status_class = $is_active ? 'status-active' : 'status-inactive';
|
||
$installed_version = $plugin_data['Version'];
|
||
$latest_version = wpmt_get_latest_plugin_version($plugin['repo']);
|
||
$update_available = $latest_version && version_compare($latest_version, $installed_version, '>');
|
||
?>
|
||
<p><strong><?php echo esc_html__('Status', 'wp-multi-toolkit'); ?>:</strong> <span class="<?php echo esc_attr($status_class); ?>"><?php echo $is_active ? esc_html__('Aktiv', 'wp-multi-toolkit') : esc_html__('Inaktiv', 'wp-multi-toolkit'); ?></span></p>
|
||
<p><strong><?php echo esc_html__('Version', 'wp-multi-toolkit'); ?>:</strong>
|
||
<span class="<?php echo $update_available ? 'version-outdated' : ''; ?>"><?php echo esc_html($installed_version); ?></span>
|
||
<?php if ($update_available) : ?>
|
||
<span class="version-latest"><?php echo esc_html__('(Neue Version verfügbar: ', 'wp-multi-toolkit') . esc_html($latest_version) . ')'; ?></span>
|
||
<?php endif; ?>
|
||
</p>
|
||
<p><strong><?php echo esc_html__('Beschreibung', 'wp-multi-toolkit'); ?>:</strong> <?php echo esc_html($plugin_data['Description']); ?></p>
|
||
<p><strong><?php echo esc_html__('Plugin-URI', 'wp-multi-toolkit'); ?>:</strong> <a href="<?php echo esc_url($plugin_data['PluginURI']); ?>" target="_blank"><?php echo esc_url($plugin_data['PluginURI']); ?></a></p>
|
||
<?php if (!empty($plugin_data['RequiresWP'])) : ?>
|
||
<p><strong><?php echo esc_html__('Benötigt WordPress', 'wp-multi-toolkit'); ?>:</strong> <?php echo esc_html($plugin_data['RequiresWP']); ?></p>
|
||
<?php endif; ?>
|
||
<?php if (!empty($plugin_data['TestedWP'])) : ?>
|
||
<p><strong><?php echo esc_html__('Getestet bis WordPress', 'wp-multi-toolkit'); ?>:</strong> <?php echo esc_html($plugin_data['TestedWP']); ?></p>
|
||
<?php endif; ?>
|
||
<?php } else { ?>
|
||
<p><strong><?php echo esc_html__('Status', 'wp-multi-toolkit'); ?>:</strong> <span class="status-not-installed"><?php echo esc_html__('Nicht installiert', 'wp-multi-toolkit'); ?></span></p>
|
||
<p><strong><?php echo esc_html__('Beschreibung', 'wp-multi-toolkit'); ?>:</strong> <?php echo esc_html($plugin['description']); ?></p>
|
||
<p><strong><?php echo esc_html__('Download', 'wp-multi-toolkit'); ?>:</strong> <a href="https://git.viper.ipv64.net/M_Viper/<?php echo esc_attr($plugin['repo']); ?>/releases" target="_blank"><?php echo esc_html__('Download-Seite', 'wp-multi-toolkit'); ?></a></p>
|
||
<?php } ?>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
|
||
<style>
|
||
.wpmt-docs-section {
|
||
background: #fff;
|
||
padding: 20px;
|
||
margin-bottom: 20px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||
}
|
||
.wpmt-docs-section h2 {
|
||
margin-top: 0;
|
||
color: #23282d;
|
||
}
|
||
.wpmt-docs-section p {
|
||
margin: 5px 0;
|
||
}
|
||
.status-active {
|
||
color: #28a745; /* Grün für Aktiv */
|
||
font-weight: bold;
|
||
}
|
||
.status-inactive {
|
||
color: #dc3545; /* Rot für Inaktiv */
|
||
font-weight: bold;
|
||
}
|
||
.status-not-installed {
|
||
color: #dc3545; /* Rot für Nicht installiert */
|
||
font-weight: bold;
|
||
}
|
||
.version-outdated {
|
||
color: #dc3545; /* Rot für veraltete Version */
|
||
font-weight: bold;
|
||
}
|
||
.version-latest {
|
||
color: #28a745; /* Grün für neueste Version */
|
||
font-weight: bold;
|
||
}
|
||
</style>
|
||
<?php
|
||
}
|
||
|
||
// Menüseite für Dokumentation hinzufügen
|
||
function wpmt_add_docs_page() {
|
||
add_submenu_page(
|
||
'wp_multi_support',
|
||
__('WP Multi Dokumentation', 'wp-multi-toolkit'),
|
||
__('Dokumentation', 'wp-multi-toolkit'),
|
||
'manage_options',
|
||
'wpmt_docs',
|
||
'wpmt_generate_plugin_docs'
|
||
);
|
||
}
|
||
add_action('admin_menu', 'wpmt_add_docs_page');
|
||
|
||
// ### Update-Management ###
|
||
|
||
// Widget zum Admin-Dashboard hinzufügen
|
||
function wpmt_update_dashboard_widget() {
|
||
wp_add_dashboard_widget(
|
||
'wpmt_update_widget',
|
||
__('Verfügbare Updates für WP Multi Toolkit', 'wp-multi-toolkit'),
|
||
'wpmt_update_dashboard_widget_content',
|
||
null,
|
||
null,
|
||
'normal',
|
||
'high'
|
||
);
|
||
}
|
||
|
||
// Dashboard-Setup anpassen
|
||
function wpmt_force_widget_position() {
|
||
global $wp_meta_boxes;
|
||
|
||
if (isset($wp_meta_boxes['dashboard']['normal']['high']['wpmt_update_widget'])) {
|
||
$widget = $wp_meta_boxes['dashboard']['normal']['high']['wpmt_update_widget'];
|
||
unset($wp_meta_boxes['dashboard']['normal']['high']['wpmt_update_widget']);
|
||
$wp_meta_boxes['dashboard']['normal']['high'] = array('wpmt_update_widget' => $widget) + $wp_meta_boxes['dashboard']['normal']['high'];
|
||
}
|
||
}
|
||
add_action('wp_dashboard_setup', 'wpmt_update_dashboard_widget', 1);
|
||
add_action('wp_dashboard_setup', 'wpmt_force_widget_position', 999);
|
||
|
||
// Widget nicht ausblendbar machen
|
||
function wpmt_prevent_widget_hiding($widgets) {
|
||
$widgets['wpmt_update_widget'] = array(
|
||
'id' => 'wpmt_update_widget',
|
||
'title' => __('Verfügbare Updates für WP Multi Toolkit', 'wp-multi-toolkit'),
|
||
'callback' => 'wpmt_update_dashboard_widget_content'
|
||
);
|
||
return $widgets;
|
||
}
|
||
add_filter('dashboard_available_widgets', 'wpmt_prevent_widget_hiding');
|
||
|
||
// Benutzerdefiniertes Cron-Intervall hinzufügen
|
||
add_filter('cron_schedules', function ($schedules) {
|
||
$schedules['hourly'] = array(
|
||
'interval' => 3600,
|
||
'display' => __('Stündlich', 'wp-multi-toolkit'),
|
||
);
|
||
return $schedules;
|
||
});
|
||
|
||
// Cron-Job registrieren
|
||
function wpmt_update_schedule_check() {
|
||
if (!wp_next_scheduled('wpmt_update_check_event')) {
|
||
wp_schedule_event(time(), 'hourly', 'wpmt_update_check_event');
|
||
}
|
||
}
|
||
add_action('wp', 'wpmt_update_schedule_check');
|
||
|
||
// Hilfsfunktion zur Wiederverwendung der Gitea-API-Abfrage
|
||
function wpmt_fetch_latest_release($repo, $show_prereleases = false) {
|
||
$api_url = "https://git.viper.ipv64.net/api/v1/repos/M_Viper/{$repo}/releases";
|
||
$response = wp_remote_get($api_url, array('timeout' => 10));
|
||
|
||
if (is_wp_error($response)) {
|
||
error_log("WP Multi Toolkit Update Fehler für {$repo}: " . $response->get_error_message());
|
||
return false;
|
||
}
|
||
|
||
$body = wp_remote_retrieve_body($response);
|
||
$data = json_decode($body, true);
|
||
|
||
if (!is_array($data)) {
|
||
error_log("WP Multi Toolkit Update für {$repo}: Ungültige API-Antwort");
|
||
return false;
|
||
}
|
||
|
||
foreach ($data as $release) {
|
||
if (!$show_prereleases && isset($release['prerelease']) && $release['prerelease']) {
|
||
continue;
|
||
}
|
||
if (!empty($release['tag_name'])) {
|
||
return $release;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
// Cron-Job für Update-Überprüfung
|
||
function wpmt_update_check() {
|
||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||
|
||
$show_prereleases = get_option('wpmt_update_show_prereleases', false);
|
||
$installed_plugins = get_plugins();
|
||
$plugins_to_check = array(
|
||
'wp-multi-toolkit' => 'wp-multi-toolkit/wp-multi-toolkit.php',
|
||
'wp-multi' => 'WP-Multi/wp-multi.php',
|
||
'WP-Multi-Search' => 'wp-multi-search/wp-multi-search.php',
|
||
'wp-multi-comment-notifications' => 'wp-multi-comment-notifications/wp-multi-comment-notifications.php'
|
||
);
|
||
|
||
foreach ($plugins_to_check as $repo => $file) {
|
||
if (array_key_exists($file, $installed_plugins) && is_plugin_active($file)) {
|
||
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $file);
|
||
$installed_version = $plugin_data['Version'];
|
||
$valid_release = wpmt_fetch_latest_release($repo, $show_prereleases);
|
||
|
||
if ($valid_release) {
|
||
$latest_version = $valid_release['tag_name'];
|
||
$release_notes = $valid_release['body'] ?? '';
|
||
$is_prerelease = isset($release['prerelease']) && $release['prerelease'];
|
||
|
||
update_option("wpmt_update_latest_version_{$repo}", $latest_version);
|
||
update_option("wpmt_update_release_notes_{$repo}", $release_notes);
|
||
update_option("wpmt_update_is_prerelease_{$repo}", $is_prerelease);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
add_action('wpmt_update_check_event', 'wpmt_update_check');
|
||
|
||
// Funktion zur Überprüfung des Update-Server-Status
|
||
function wpmt_check_update_server_status() {
|
||
$update_server_url = 'https://git.viper.ipv64.net';
|
||
$response = wp_remote_head($update_server_url, array('timeout' => 5));
|
||
return !is_wp_error($response) && wp_remote_retrieve_response_code($response) == 200;
|
||
}
|
||
|
||
// Callback-Funktion für das Widget
|
||
function wpmt_update_dashboard_widget_content() {
|
||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||
|
||
$installed_plugins = get_plugins();
|
||
$show_prereleases = get_option('wpmt_update_show_prereleases', false);
|
||
|
||
// Update-Server-Status nur bei Offline anzeigen
|
||
$server_online = wpmt_check_update_server_status();
|
||
if (!$server_online) {
|
||
echo '<p style="text-align: center; color: red;">🔴 ' . __('Update Server offline', 'wp-multi-toolkit') . '</p>';
|
||
echo '<hr style="margin: 20px 0;">';
|
||
}
|
||
|
||
$plugins_to_check = array(
|
||
'wp-multi-toolkit' => array(
|
||
'file' => 'wp-multi-toolkit/wp-multi-toolkit.php',
|
||
'name' => 'WP Multi Toolkit',
|
||
'repo' => 'wp-multi-toolkit'
|
||
),
|
||
'wp-multi' => array(
|
||
'file' => 'WP-Multi/wp-multi.php',
|
||
'name' => 'WP Multi',
|
||
'repo' => 'wp-multi'
|
||
),
|
||
'WP-Multi-Search' => array(
|
||
'file' => 'wp-multi-search/wp-multi-search.php',
|
||
'name' => 'WP Multi Search',
|
||
'repo' => 'WP-Multi-Search'
|
||
),
|
||
'wp-multi-comment-notifications' => array(
|
||
'file' => 'wp-multi-comment-notifications/wp-multi-comment-notifications.php',
|
||
'name' => 'WP Multi Comment Notifications',
|
||
'repo' => 'wp-multi-comment-notifications'
|
||
),
|
||
'wp-multi-kategorie' => array(
|
||
'file' => 'wp-multi-kategorie/wp-multi-kategorie.php',
|
||
'name' => 'WP Multi Kategorie',
|
||
'repo' => 'wp-multi-kategorie'
|
||
)
|
||
);
|
||
|
||
$has_active_plugins = false;
|
||
foreach ($plugins_to_check as $key => $plugin) {
|
||
$is_installed = array_key_exists($plugin['file'], $installed_plugins);
|
||
$is_active = $is_installed && is_plugin_active($plugin['file']);
|
||
|
||
if ($is_installed && $is_active) {
|
||
$has_active_plugins = true;
|
||
$plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin['file']);
|
||
$installed_version = $plugin_data['Version'];
|
||
$valid_release = wpmt_fetch_latest_release($plugin['repo'], $show_prereleases);
|
||
|
||
echo '<h4>' . esc_html($plugin['name']) . '</h4>';
|
||
if ($valid_release === false) {
|
||
printf('<p>%s</p>', esc_html__('Fehler beim Abrufen der Versionsinformationen.', 'wp-multi-toolkit'));
|
||
} elseif ($valid_release) {
|
||
$latest_version = $valid_release['tag_name'];
|
||
$release_notes = $valid_release['body'] ?? '';
|
||
$is_prerelease = isset($valid_release['prerelease']) && $valid_release['prerelease'];
|
||
|
||
if (version_compare($installed_version, $latest_version, '>=')) {
|
||
printf(
|
||
'<p style="color: green;">%s</p>',
|
||
sprintf(
|
||
__('Ihre Version ist aktuell. Version %s ist die neueste Version.', 'wp-multi-toolkit'),
|
||
esc_html($installed_version)
|
||
)
|
||
);
|
||
} else {
|
||
printf(
|
||
'<p style="color: red;">%s</p>',
|
||
sprintf(
|
||
__('Es ist eine neue Version von %s verfügbar! <strong>Version %s</strong> ist jetzt verfügbar.', 'wp-multi-toolkit'),
|
||
esc_html($plugin['name']),
|
||
esc_html($latest_version)
|
||
)
|
||
);
|
||
printf(
|
||
'<p>%s: <strong>%s</strong></p>',
|
||
__('Aktuell installierte Version', 'wp-multi-toolkit'),
|
||
esc_html($installed_version)
|
||
);
|
||
printf(
|
||
'<p>%s: <strong>%s</strong></p>',
|
||
__('Neue Version auf Gitea', 'wp-multi-toolkit'),
|
||
esc_html($latest_version)
|
||
);
|
||
|
||
if ($is_prerelease && $show_prereleases) {
|
||
printf('<p style="color: blue;">%s</p>', __('Dieses Update ist ein PreRelease.', 'wp-multi-toolkit'));
|
||
}
|
||
|
||
if (!empty($release_notes)) {
|
||
printf(
|
||
'<p><strong>%s:</strong></p><p>%s</p>',
|
||
__('Information zum Update', 'wp-multi-toolkit'),
|
||
nl2br(esc_html($release_notes))
|
||
);
|
||
}
|
||
|
||
$button_text = $is_prerelease ? __('PreRelease herunterladen', 'wp-multi-toolkit') : __('Update herunterladen', 'wp-multi-toolkit');
|
||
$download_url = $valid_release['assets'][0]['browser_download_url'] ?? '#';
|
||
printf(
|
||
'<p><a href="%s" class="button button-primary">%s</a></p>',
|
||
esc_url($download_url),
|
||
esc_html($button_text)
|
||
);
|
||
}
|
||
} else {
|
||
printf('<p>%s</p>', esc_html__('Keine Versionsinformationen gefunden.', 'wp-multi-toolkit'));
|
||
}
|
||
}
|
||
}
|
||
|
||
if (!$has_active_plugins) {
|
||
echo '<p>' . __('Keine aktiven WP Multi Plugins gefunden.', 'wp-multi-toolkit') . '</p>';
|
||
}
|
||
|
||
// Optionale Plugins
|
||
$optional_plugins = array(
|
||
'wp-multi-toolkit' => array(
|
||
'file' => 'wp-multi-toolkit/wp-multi-toolkit.php',
|
||
'download_url' => 'https://git.viper.ipv64.net/M_Viper/wp-multi-toolkit/releases',
|
||
'description' => __('Kern-Toolkit für WP Multi Plugins.', 'wp-multi-toolkit')
|
||
),
|
||
'wp-multi' => array(
|
||
'file' => 'WP-Multi/wp-multi.php',
|
||
'download_url' => 'https://git.viper.ipv64.net/M_Viper/wp-multi/releases',
|
||
'description' => __('Hauptplugin für WP Multi Funktionen.', 'wp-multi-toolkit')
|
||
),
|
||
'WP-Multi-Search' => array(
|
||
'file' => 'wp-multi-search/wp-multi-search.php',
|
||
'download_url' => 'https://git.viper.ipv64.net/M_Viper/WP-Multi-Search/releases',
|
||
'description' => __('Erweiterte Suchfunktionen.', 'wp-multi-toolkit')
|
||
),
|
||
'wp-multi-comment-notifications' => array(
|
||
'file' => 'wp-multi-comment-notifications/wp-multi-comment-notifications.php',
|
||
'download_url' => 'https://git.viper.ipv64.net/M_Viper/wp-multi-comment-notifications/releases',
|
||
'description' => __('Kommentar-Benachrichtigungen.', 'wp-multi-toolkit')
|
||
),
|
||
'wp-multi-kategorie' => array(
|
||
'file' => 'wp-multi-kategorie/wp-multi-kategorie.php',
|
||
'download_url' => 'https://git.viper.ipv64.net/M_Viper/wp-multi-kategorie/releases',
|
||
'description' => __('Erweiterte Kategorie-Funktionen für WP Multi.', 'wp-multi-toolkit')
|
||
)
|
||
);
|
||
|
||
echo '<hr style="margin: 20px 0;"><h3>' . __('Optionale Plugins', 'wp-multi-toolkit') . '</h3>';
|
||
echo '<table style="width: 100%; border-collapse: collapse;">';
|
||
echo '<tr><th style="text-align: left; padding: 5px;">' . __('Plugin', 'wp-multi-toolkit') . '</th><th style="text-align: left; padding: 5px;">' . __('Beschreibung', 'wp-multi-toolkit') . '</th><th style="text-align: left; padding: 5px;">' . __('Status', 'wp-multi-toolkit') . '</th><th style="text-align: left; padding: 5px;">' . __('Aktion', 'wp-multi-toolkit') . '</th></tr>';
|
||
|
||
foreach ($optional_plugins as $key => $plugin) {
|
||
$is_installed = array_key_exists($plugin['file'], $installed_plugins);
|
||
$is_active = $is_installed && is_plugin_active($plugin['file']);
|
||
|
||
echo '<tr style="border-bottom: 1px solid #ddd;">';
|
||
echo '<td style="padding: 5px;"><strong>' . esc_html($plugins_to_check[$key]['name']) . '</strong></td>';
|
||
echo '<td style="padding: 5px;">' . esc_html($plugin['description']) . '</td>';
|
||
echo '<td style="padding: 5px;">';
|
||
if ($is_active) {
|
||
echo '<span style="color: green;">' . __('Aktiv', 'wp-multi-toolkit') . '</span>';
|
||
} elseif ($is_installed) {
|
||
echo '<span style="color: orange;">' . __('Inaktiv', 'wp-multi-toolkit') . '</span>';
|
||
} else {
|
||
echo '<span style="color: red;">' . __('Nicht installiert', 'wp-multi-toolkit') . '</span>';
|
||
}
|
||
echo '</td>';
|
||
echo '<td style="padding: 5px;">';
|
||
if ($is_active) {
|
||
echo '—';
|
||
} elseif ($is_installed) {
|
||
echo '<a href="' . esc_url(wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $plugin['file']), 'activate-plugin_' . $plugin['file'])) . '" class="button">' . __('Aktivieren', 'wp-multi-toolkit') . '</a>';
|
||
} else {
|
||
echo '<a href="' . esc_url($plugin['download_url']) . '" class="button button-primary" target="_blank">' . __('Herunterladen', 'wp-multi-toolkit') . '</a>';
|
||
}
|
||
echo '</td>';
|
||
echo '</tr>';
|
||
}
|
||
echo '</table>';
|
||
}
|
||
|
||
// Update-Einstellungen
|
||
function wpmt_update_general_settings() {
|
||
add_settings_section(
|
||
'wpmt_update_section',
|
||
__('WP Multi Toolkit Update Einstellungen', 'wp-multi-toolkit'),
|
||
null,
|
||
'general'
|
||
);
|
||
|
||
add_settings_field(
|
||
'wpmt_update_show_prereleases',
|
||
__('Pre-Releases anzeigen', 'wp-multi-toolkit'),
|
||
'wpmt_update_show_prereleases_callback',
|
||
'general',
|
||
'wpmt_update_section'
|
||
);
|
||
|
||
register_setting('general', 'wpmt_update_show_prereleases', array(
|
||
'type' => 'boolean',
|
||
'description' => __('Aktivieren, um Pre-Releases im Dashboard und in den Versionsinformationen anzuzeigen.', 'wp-multi-toolkit'),
|
||
'default' => 0,
|
||
));
|
||
}
|
||
add_action('admin_init', 'wpmt_update_general_settings');
|
||
|
||
// Callback-Funktion für das Anzeigen der Checkbox
|
||
function wpmt_update_show_prereleases_callback() {
|
||
$checked = get_option('wpmt_update_show_prereleases', false);
|
||
echo '<input type="checkbox" name="wpmt_update_show_prereleases" value="1" ' . checked(1, $checked, false) . '/>';
|
||
echo '<p style="color: red;"><small>' . __('Achtung: Pre-Releases sind Beta-Versionen und können Fehler enthalten. Verwenden Sie sie nur, wenn Sie Fehlerberichterstattung oder Tests durchführen möchten.', 'wp-multi-toolkit') . '</small></p>';
|
||
}
|
||
|
||
// Deinstallation
|
||
function wpmt_uninstall() {
|
||
$repos = array('wp-multi-toolkit', 'wp-multi', 'WP-Multi-Search', 'wp-multi-comment-notifications');
|
||
foreach ($repos as $repo) {
|
||
delete_option("wpmt_update_latest_version_{$repo}");
|
||
delete_option("wpmt_update_release_notes_{$repo}");
|
||
delete_option("wpmt_update_is_prerelease_{$repo}");
|
||
}
|
||
delete_option('wpmt_update_show_prereleases');
|
||
delete_option('wpmt_multi_settings');
|
||
wp_clear_scheduled_hook('wpmt_update_check_event');
|
||
}
|
||
register_uninstall_hook(__FILE__, 'wpmt_uninstall');
|
||
|
||
|
||
/*
|
||
* Ban Funktion
|
||
*/
|
||
|
||
|
||
// Add Admin Menu
|
||
add_action('admin_menu', 'wp_multi_toolkit_setup_menu');
|
||
function wp_multi_toolkit_setup_menu() {
|
||
if (!current_user_can('manage_options')) {
|
||
return;
|
||
}
|
||
add_submenu_page(
|
||
'users.php',
|
||
'WP Multi Ban',
|
||
'WP Multi Ban',
|
||
'manage_options',
|
||
'wp-multi-ban',
|
||
'wp_multi_ban_options_page'
|
||
);
|
||
}
|
||
|
||
// WP Multi Ban Functions
|
||
|
||
### Function: Get IP Address
|
||
function wp_multi_ban_get_ip() {
|
||
$banned_options = get_option('wp_multi_ban_options', array('reverse_proxy' => 0));
|
||
|
||
if (!empty($banned_options['reverse_proxy']) && intval($banned_options['reverse_proxy']) === 1) {
|
||
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
|
||
if (!empty($_SERVER[$key])) {
|
||
foreach (explode(',', $_SERVER[$key]) as $ip) {
|
||
$ip = trim($ip);
|
||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
|
||
return esc_attr($ip);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} elseif (!empty($_SERVER['REMOTE_ADDR'])) {
|
||
$ip = $_SERVER['REMOTE_ADDR'];
|
||
if (strpos($ip, ',') !== false) {
|
||
$ip = explode(',', $ip)[0];
|
||
}
|
||
return esc_attr($ip);
|
||
}
|
||
|
||
return '';
|
||
}
|
||
|
||
### Function: Preview Banned Message
|
||
add_action('wp_ajax_wp_multi_ban_admin', 'wp_multi_ban_preview_banned_message');
|
||
function wp_multi_ban_preview_banned_message() {
|
||
if (!current_user_can('manage_options')) {
|
||
wp_send_json_error('Zugriff verweigert');
|
||
}
|
||
|
||
$banned_stats = get_option('wp_multi_ban_stats', array('users' => array(), 'count' => 0));
|
||
$banned_message = stripslashes(get_option('wp_multi_ban_message', 'Ihr Zugriff auf %SITE_NAME% (%SITE_URL%) wurde gesperrt.'));
|
||
$banned_message = str_replace(
|
||
array(
|
||
'%SITE_NAME%',
|
||
'%SITE_URL%',
|
||
'%USER_ATTEMPTS_COUNT%',
|
||
'%USER_IP%',
|
||
'%USER_HOSTNAME%',
|
||
'%TOTAL_ATTEMPTS_COUNT%'
|
||
),
|
||
array(
|
||
esc_html(get_option('blogname')),
|
||
esc_url(get_option('siteurl')),
|
||
number_format_i18n($banned_stats['users'][wp_multi_ban_get_ip()] ?? 0),
|
||
esc_html(wp_multi_ban_get_ip()),
|
||
esc_html(@gethostbyaddr(wp_multi_ban_get_ip())),
|
||
number_format_i18n($banned_stats['count'] ?? 0)
|
||
),
|
||
$banned_message
|
||
);
|
||
|
||
wp_send_json_success(array('message' => $banned_message));
|
||
}
|
||
|
||
### Function: Print Out Banned Message
|
||
function wp_multi_ban_print_banned_message() {
|
||
$banned_ip = wp_multi_ban_get_ip();
|
||
$banned_stats = get_option('wp_multi_ban_stats', array('users' => array(), 'count' => 0));
|
||
$banned_stats['count'] = isset($banned_stats['count']) ? $banned_stats['count'] + 1 : 1;
|
||
$banned_stats['users'][$banned_ip] = isset($banned_stats['users'][$banned_ip]) ? $banned_stats['users'][$banned_ip] + 1 : 1;
|
||
update_option('wp_multi_ban_stats', $banned_stats);
|
||
$banned_message = stripslashes(get_option('wp_multi_ban_message', 'Ihr Zugriff auf %SITE_NAME% (%SITE_URL%) wurde gesperrt.'));
|
||
$banned_message = str_replace(
|
||
array(
|
||
'%SITE_NAME%',
|
||
'%SITE_URL%',
|
||
'%USER_ATTEMPTS_COUNT%',
|
||
'%USER_IP%',
|
||
'%USER_HOSTNAME%',
|
||
'%TOTAL_ATTEMPTS_COUNT%'
|
||
),
|
||
array(
|
||
esc_html(get_option('blogname')),
|
||
esc_url(get_option('siteurl')),
|
||
number_format_i18n($banned_stats['users'][$banned_ip] ?? 0),
|
||
esc_html($banned_ip),
|
||
esc_html(@gethostbyaddr($banned_ip)),
|
||
number_format_i18n($banned_stats['count'] ?? 0)
|
||
),
|
||
$banned_message
|
||
);
|
||
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Gesperrt</title></head><body>' . $banned_message . '</body></html>';
|
||
exit;
|
||
}
|
||
|
||
### Function: Process Banning
|
||
function wp_multi_ban_process_ban($banarray, $against) {
|
||
if (!empty($banarray) && !empty($against) && is_array($banarray)) {
|
||
foreach ($banarray as $cban) {
|
||
if (wp_multi_ban_preg_match_wildcard($cban, $against)) {
|
||
wp_multi_ban_print_banned_message();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
### Function: Process Banned IP Range
|
||
function wp_multi_ban_process_ban_ip_range($banned_ips_range) {
|
||
if (!empty($banned_ips_range) && is_array($banned_ips_range)) {
|
||
foreach ($banned_ips_range as $banned_ip_range) {
|
||
$range = explode('-', $banned_ip_range);
|
||
if (count($range) === 2) {
|
||
$range_start = trim($range[0]);
|
||
$range_end = trim($range[1]);
|
||
if (wp_multi_ban_check_ip_within_range(wp_multi_ban_get_ip(), $range_start, $range_end)) {
|
||
wp_multi_ban_print_banned_message();
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
### Function: Banned
|
||
add_action('init', 'wp_multi_ban_banned', 1);
|
||
function wp_multi_ban_banned() {
|
||
$ip = wp_multi_ban_get_ip();
|
||
if (empty($ip)) {
|
||
return;
|
||
}
|
||
$banned_ips = get_option('wp_multi_ban_ips', array());
|
||
$banned_ips_range = get_option('wp_multi_ban_ips_range', array());
|
||
$banned_hosts = get_option('wp_multi_ban_hosts', array());
|
||
$banned_referers = get_option('wp_multi_ban_referers', array());
|
||
$banned_user_agents = get_option('wp_multi_ban_user_agents', array());
|
||
$banned_exclude_ips = get_option('wp_multi_ban_exclude_ips', array());
|
||
|
||
if (is_array($banned_exclude_ips) && in_array($ip, $banned_exclude_ips)) {
|
||
return;
|
||
}
|
||
|
||
if (is_array($banned_ips)) {
|
||
wp_multi_ban_process_ban($banned_ips, $ip);
|
||
}
|
||
if (is_array($banned_ips_range)) {
|
||
wp_multi_ban_process_ban_ip_range($banned_ips_range);
|
||
}
|
||
if (is_array($banned_hosts)) {
|
||
wp_multi_ban_process_ban($banned_hosts, @gethostbyaddr($ip));
|
||
}
|
||
if (is_array($banned_referers) && !empty($_SERVER['HTTP_REFERER'])) {
|
||
wp_multi_ban_process_ban($banned_referers, $_SERVER['HTTP_REFERER']);
|
||
}
|
||
if (is_array($banned_user_agents) && !empty($_SERVER['HTTP_USER_AGENT'])) {
|
||
wp_multi_ban_process_ban($banned_user_agents, $_SERVER['HTTP_USER_AGENT']);
|
||
}
|
||
}
|
||
|
||
### Function: Check Whether IP Within A Given IP Range
|
||
function wp_multi_ban_check_ip_within_range($ip, $range_start, $range_end) {
|
||
$range_start = ip2long($range_start);
|
||
$range_end = ip2long($range_end);
|
||
$ip = ip2long($ip);
|
||
return ($ip !== false && $range_start !== false && $range_end !== false && $ip >= $range_start && $ip <= $range_end);
|
||
}
|
||
|
||
### Function: Wildcard Check
|
||
function wp_multi_ban_preg_match_wildcard($regex, $subject) {
|
||
if (empty($regex) || empty($subject)) {
|
||
return false;
|
||
}
|
||
$regex = preg_quote($regex, '#');
|
||
$regex = str_replace('\*', '.*', $regex);
|
||
return preg_match("#^$regex$#i", $subject) === 1;
|
||
}
|
||
|
||
### Function: Activate Ban Module
|
||
function wp_multi_ban_activate() {
|
||
$default_message = 'Ihr Zugriff auf %SITE_NAME% (%SITE_URL%) wurde gesperrt.' . "\n\n" .
|
||
'Details:' . "\n" .
|
||
'- Ihre IP: %USER_IP%' . "\n" .
|
||
'- Hostname: %USER_HOSTNAME%' . "\n" .
|
||
'- Ihre Versuche: %USER_ATTEMPTS_COUNT%' . "\n" .
|
||
'- Gesamtanzahl Sperrversuche: %TOTAL_ATTEMPTS_COUNT%' . "\n\n" .
|
||
'Bitte kontaktieren Sie den Support von %SITE_NAME%, falls Sie Fragen haben.';
|
||
add_option('wp_multi_ban_ips', array());
|
||
add_option('wp_multi_ban_hosts', array());
|
||
add_option('wp_multi_ban_stats', array('users' => array(), 'count' => 0));
|
||
add_option('wp_multi_ban_message', $default_message);
|
||
add_option('wp_multi_ban_referers', array());
|
||
add_option('wp_multi_ban_exclude_ips', array());
|
||
add_option('wp_multi_ban_ips_range', array());
|
||
add_option('wp_multi_ban_user_agents', array());
|
||
add_option('wp_multi_ban_options', array('reverse_proxy' => 0));
|
||
}
|
||
|
||
### Function: Admin Options Page
|
||
function wp_multi_ban_options_page() {
|
||
if (!current_user_can('manage_options')) {
|
||
wp_die('Zugriff verweigert');
|
||
}
|
||
|
||
$text = '';
|
||
if (!empty($_POST['Submit'])) {
|
||
check_admin_referer('wp_multi_ban_templates');
|
||
|
||
$banned_options = array('reverse_proxy' => isset($_POST['banned_option_reverse_proxy']) ? 1 : 0);
|
||
$banned_ips = array();
|
||
$banned_ips_range = array();
|
||
$banned_hosts = array();
|
||
$banned_referers = array();
|
||
$banned_user_agents = array();
|
||
$banned_exclude_ips = array();
|
||
$admin_ip = wp_multi_ban_get_ip();
|
||
$admin_login = trim(wp_get_current_user()->user_login);
|
||
|
||
if (!empty($_POST['banned_ips'])) {
|
||
foreach (explode("\n", trim($_POST['banned_ips'])) as $banned_ip) {
|
||
$banned_ip = trim($banned_ip);
|
||
if ($admin_login === 'admin' && $banned_ip === $admin_ip) {
|
||
$text .= '<div class="wp-ban-notice wp-ban-notice-warning">Diese IP \'' . esc_html($banned_ip) . '\' gehört dem Admin und wird nicht gesperrt.</div>';
|
||
} else {
|
||
$banned_ips[] = esc_html($banned_ip);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (!empty($_POST['banned_ips_range'])) {
|
||
foreach (explode("\n", trim($_POST['banned_ips_range'])) as $banned_ip_range) {
|
||
$range = explode('-', trim($banned_ip_range));
|
||
if (count($range) === 2 && $admin_login === 'admin' && wp_multi_ban_check_ip_within_range($admin_ip, trim($range[0]), trim($range[1]))) {
|
||
$text .= '<div class="wp-ban-notice wp-ban-notice-warning">Die Admin-IP \'' . esc_html($admin_ip) . '\' liegt in diesem Bereich und wird nicht gesperrt.</div>';
|
||
} else {
|
||
$banned_ips_range[] = esc_html(trim($banned_ip_range));
|
||
}
|
||
}
|
||
}
|
||
|
||
if (!empty($_POST['banned_hosts'])) {
|
||
foreach (explode("\n", trim($_POST['banned_hosts'])) as $banned_host) {
|
||
$banned_hosts[] = esc_html(trim($banned_host));
|
||
}
|
||
}
|
||
|
||
if (!empty($_POST['banned_referers'])) {
|
||
foreach (explode("\n", trim($_POST['banned_referers'])) as $banned_referer) {
|
||
$banned_referers[] = esc_html(trim($banned_referer));
|
||
}
|
||
}
|
||
|
||
if (!empty($_POST['banned_user_agents'])) {
|
||
foreach (explode("\n", trim($_POST['banned_user_agents'])) as $banned_user_agent) {
|
||
$banned_user_agents[] = esc_html(trim($banned_user_agent));
|
||
}
|
||
}
|
||
|
||
if (!empty($_POST['banned_exclude_ips'])) {
|
||
foreach (explode("\n", trim($_POST['banned_exclude_ips'])) as $banned_exclude_ip) {
|
||
$banned_exclude_ips[] = esc_html(trim($banned_exclude_ip));
|
||
}
|
||
}
|
||
|
||
$allowed_tags = wp_kses_allowed_html('post');
|
||
$allowed_tags['a'] = array('href' => true, 'title' => true);
|
||
$banned_message = !empty($_POST['banned_template_message']) ? wp_kses(trim($_POST['banned_template_message']), $allowed_tags) : '';
|
||
|
||
update_option('wp_multi_ban_options', $banned_options);
|
||
update_option('wp_multi_ban_ips', $banned_ips);
|
||
update_option('wp_multi_ban_ips_range', $banned_ips_range);
|
||
update_option('wp_multi_ban_hosts', $banned_hosts);
|
||
update_option('wp_multi_ban_referers', $banned_referers);
|
||
update_option('wp_multi_ban_user_agents', $banned_user_agents);
|
||
update_option('wp_multi_ban_exclude_ips', $banned_exclude_ips);
|
||
update_option('wp_multi_ban_message', $banned_message);
|
||
|
||
$text .= '<div class="wp-ban-notice wp-ban-notice-success">Einstellungen gespeichert.</div>';
|
||
}
|
||
|
||
if (!empty($_POST['do']) && $_POST['do'] === 'Sperrstatistiken zurücksetzen') {
|
||
check_admin_referer('wp_multi_ban_stats');
|
||
if (!empty($_POST['reset_ban_stats']) && $_POST['reset_ban_stats'] === 'yes') {
|
||
update_option('wp_multi_ban_stats', array('users' => array(), 'count' => 0));
|
||
$text .= '<div class="wp-ban-notice wp-ban-notice-success">Alle Sperrstatistiken zurückgesetzt.</div>';
|
||
} elseif (!empty($_POST['delete_ips'])) {
|
||
$banned_stats = get_option('wp_multi_ban_stats', array('users' => array(), 'count' => 0));
|
||
foreach ((array)$_POST['delete_ips'] as $delete_ip) {
|
||
unset($banned_stats['users'][$delete_ip]);
|
||
}
|
||
update_option('wp_multi_ban_stats', $banned_stats);
|
||
$text .= '<div class="wp-ban-notice wp-ban-notice-success">Ausgewählte IP-Statistiken zurückgesetzt.</div>';
|
||
}
|
||
}
|
||
|
||
$banned_ips = get_option('wp_multi_ban_ips', array());
|
||
$banned_ips_range = get_option('wp_multi_ban_ips_range', array());
|
||
$banned_hosts = get_option('wp_multi_ban_hosts', array());
|
||
$banned_referers = get_option('wp_multi_ban_referers', array());
|
||
$banned_user_agents = get_option('wp_multi_ban_user_agents', array());
|
||
$banned_exclude_ips = get_option('wp_multi_ban_exclude_ips', array());
|
||
$banned_stats = get_option('wp_multi_ban_stats', array('users' => array(), 'count' => 0));
|
||
$banned_options = get_option('wp_multi_ban_options', array('reverse_proxy' => 0));
|
||
|
||
$banned_ips_display = implode("\n", $banned_ips);
|
||
$banned_ips_range_display = implode("\n", $banned_ips_range);
|
||
$banned_hosts_display = implode("\n", $banned_hosts);
|
||
$banned_referers_display = implode("\n", $banned_referers);
|
||
$banned_user_agents_display = implode("\n", $banned_user_agents);
|
||
$banned_exclude_ips_display = implode("\n", $banned_exclude_ips);
|
||
?>
|
||
<style type="text/css">
|
||
.wp-ban-container {
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||
max-width: 1200px;
|
||
margin: 20px auto;
|
||
padding: 0 20px;
|
||
}
|
||
.wp-ban-container h2 {
|
||
font-size: 24px;
|
||
color: #2d3436;
|
||
margin: 0 0 20px;
|
||
font-weight: 600;
|
||
}
|
||
.wp-ban-grid {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 24px;
|
||
margin-bottom: 24px;
|
||
visibility: visible !important;
|
||
}
|
||
.wp-ban-card {
|
||
background: #ffffff;
|
||
border-radius: 12px;
|
||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
||
padding: 24px;
|
||
transition: transform 0.3s ease;
|
||
display: block;
|
||
}
|
||
.wp-ban-card:hover {
|
||
transform: translateY(-2px);
|
||
}
|
||
.wp-ban-card h3 {
|
||
font-size: 18px;
|
||
color: #2d3436;
|
||
margin: 0 0 16px;
|
||
font-weight: 500;
|
||
}
|
||
.wp-ban-notice {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 12px 16px;
|
||
border-radius: 8px;
|
||
margin-bottom: 20px;
|
||
font-size: 14px;
|
||
animation: fadeIn 0.5s ease;
|
||
}
|
||
.wp-ban-notice-success {
|
||
background: #e9f7ef;
|
||
border-left: 4px solid #2ecc71;
|
||
color: #2d3436;
|
||
}
|
||
.wp-ban-notice-warning {
|
||
background: #fef5e7;
|
||
border-left: 4px solid #f39c12;
|
||
color: #2d3436;
|
||
}
|
||
@keyframes fadeIn {
|
||
from { opacity: 0; transform: translateY(10px); }
|
||
to { opacity: 1; transform: translateY(0); }
|
||
}
|
||
.wp-ban-table {
|
||
width: 100%;
|
||
border-collapse: separate;
|
||
border-spacing: 0;
|
||
background: #ffffff;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
}
|
||
.wp-ban-table th, .wp-ban-table td {
|
||
padding: 14px;
|
||
text-align: left;
|
||
border-bottom: 1px solid #edf2f7;
|
||
}
|
||
.wp-ban-table th {
|
||
background: #f5f7fa;
|
||
font-weight: 600;
|
||
color: #2d3436;
|
||
font-size: 14px;
|
||
}
|
||
.wp-ban-table td {
|
||
color: #4a5568;
|
||
font-size: 14px;
|
||
}
|
||
.wp-ban-table tr:last-child td {
|
||
border-bottom: none;
|
||
}
|
||
.wp-ban-table tr:hover {
|
||
background: #f7fafc;
|
||
}
|
||
.wp-ban-form-group {
|
||
display: grid;
|
||
grid-template-columns: 1fr 2fr;
|
||
gap: 24px;
|
||
margin-bottom: 20px;
|
||
align-items: start;
|
||
}
|
||
.wp-ban-form-group label {
|
||
font-weight: 500;
|
||
color: #2d3436;
|
||
font-size: 14px;
|
||
line-height: 1.5;
|
||
}
|
||
.wp-ban-form-group label small {
|
||
display: block;
|
||
color: #718096;
|
||
font-size: 12px;
|
||
margin-top: 4px;
|
||
}
|
||
.wp-ban-form-group .input-container {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
}
|
||
.wp-ban-form-group textarea {
|
||
width: 100%;
|
||
padding: 12px;
|
||
border: 1px solid #e2e8f0;
|
||
border-radius: 8px;
|
||
font-size: 14px;
|
||
line-height: 1.5;
|
||
resize: vertical;
|
||
background: #ffffff;
|
||
transition: border-color 0.3s, box-shadow 0.3s;
|
||
}
|
||
.wp-ban-form-group textarea:focus {
|
||
border-color: #1e88e5;
|
||
box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
|
||
outline: none;
|
||
}
|
||
.wp-ban-form-group input[type="checkbox"] {
|
||
appearance: none;
|
||
width: 18px;
|
||
height: 18px;
|
||
border: 2px solid #e2e8f0;
|
||
border-radius: 4px;
|
||
background: #ffffff;
|
||
cursor: pointer;
|
||
transition: all 0.2s;
|
||
}
|
||
.wp-ban-form-group input[type="checkbox"]:checked {
|
||
background: #1e88e5;
|
||
border-color: #1e88e5;
|
||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd' /%3E%3C/svg%3E");
|
||
background-size: 12px;
|
||
background-position: center;
|
||
}
|
||
.wp-ban-button, .wp-ban-button-primary {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 10px 20px;
|
||
border-radius: 8px;
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
text-decoration: none;
|
||
cursor: pointer;
|
||
transition: all 0.3s ease;
|
||
}
|
||
.wp-ban-button {
|
||
background: #edf2f7;
|
||
color: #2d3436;
|
||
border: 1px solid #e2e8f0;
|
||
}
|
||
.wp-ban-button:hover {
|
||
background: #e2e8f0;
|
||
transform: translateY(-1px);
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||
}
|
||
.wp-ban-button-primary {
|
||
background: #1e88e5;
|
||
color: #ffffff;
|
||
border: none;
|
||
}
|
||
.wp-ban-button-primary:hover {
|
||
background: #1565c0;
|
||
transform: translateY(-1px);
|
||
box-shadow: 0 2px 8px rgba(30, 136, 229, 0.3);
|
||
}
|
||
#banned_preview_message {
|
||
margin-top: 12px;
|
||
padding: 16px;
|
||
background: #f7fafc;
|
||
border: 1px solid #e2e8f0;
|
||
border-radius: 8px;
|
||
font-size: 14px;
|
||
color: #4a5568;
|
||
white-space: pre-wrap;
|
||
display: none;
|
||
}
|
||
#banned_preview_message.show {
|
||
display: block;
|
||
}
|
||
.wp-ban-actions {
|
||
display: flex;
|
||
gap: 12px;
|
||
justify-content: center;
|
||
margin-top: 20px;
|
||
position: sticky;
|
||
bottom: 20px;
|
||
background: #ffffff;
|
||
padding: 12px 0;
|
||
border-radius: 8px;
|
||
}
|
||
.wp-ban-table input[type="checkbox"] {
|
||
margin: 0 auto;
|
||
display: block;
|
||
}
|
||
.wp-ban-table label {
|
||
font-size: 12px;
|
||
color: #718096;
|
||
margin-left: 8px;
|
||
}
|
||
@media (max-width: 768px) {
|
||
.wp-ban-container {
|
||
padding: 0 10px;
|
||
}
|
||
.wp-ban-grid {
|
||
grid-template-columns: 1fr;
|
||
gap: 16px;
|
||
}
|
||
.wp-ban-form-group {
|
||
grid-template-columns: 1fr;
|
||
gap: 16px;
|
||
}
|
||
.wp-ban-table {
|
||
display: block;
|
||
overflow-x: auto;
|
||
white-space: nowrap;
|
||
}
|
||
.wp-ban-table th, .wp-ban-table td {
|
||
min-width: 100px;
|
||
}
|
||
.wp-ban-actions {
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
}
|
||
}
|
||
</style>
|
||
<script type="text/javascript">
|
||
jQuery(document).ready(function($) {
|
||
// Ensure details card is visible on load
|
||
$('.wp-ban-grid').css('display', 'grid');
|
||
|
||
$('#show_button').on('click', function(e) {
|
||
e.preventDefault();
|
||
var $button = $(this);
|
||
var $messageEl = $('#banned_template_message');
|
||
var $previewEl = $('#banned_preview_message');
|
||
var $detailsGrid = $('.wp-ban-grid');
|
||
|
||
if ($previewEl.hasClass('show')) {
|
||
$button.val('Vorschau anzeigen');
|
||
$previewEl.removeClass('show').empty();
|
||
$messageEl.show();
|
||
$detailsGrid.css('display', 'grid'); // Ensure details are visible
|
||
console.log('Details Grid displayed');
|
||
} else {
|
||
$button.val('Nachricht bearbeiten');
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: '<?php echo admin_url('admin-ajax.php'); ?>',
|
||
data: {
|
||
action: 'wp_multi_ban_admin',
|
||
nonce: '<?php echo wp_create_nonce('wp_multi_ban_preview'); ?>'
|
||
},
|
||
cache: false,
|
||
success: function(response) {
|
||
if (response.success) {
|
||
$messageEl.hide();
|
||
$previewEl.html(response.data.message).addClass('show');
|
||
$detailsGrid.css('display', 'grid'); // Ensure details remain visible
|
||
console.log('Vorschau geladen, Details sichtbar');
|
||
} else {
|
||
console.error('Vorschau fehlgeschlagen:', response.data);
|
||
alert('Fehler beim Laden der Vorschau: ' + (response.data || 'Unbekannter Fehler'));
|
||
}
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error('AJAX-Fehler:', status, error);
|
||
alert('Fehler bei der AJAX-Anfrage. Bitte Konsole prüfen.');
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
$('#restore_default').on('click', function() {
|
||
$('#banned_template_message').val('Ihr Zugriff auf %SITE_NAME% (%SITE_URL%) wurde gesperrt.\n\nDetails:\n- Ihre IP: %USER_IP%\n- Hostname: %USER_HOSTNAME%\n- Ihre Versuche: %USER_ATTEMPTS_COUNT%\n- Gesamtanzahl Sperrversuche: %TOTAL_ATTEMPTS_COUNT%\n\nBitte kontaktieren Sie den Support von %SITE_NAME%, falls Sie Fragen haben.');
|
||
$('#banned_preview_message').removeClass('show').empty();
|
||
$('#banned_template_message').show();
|
||
$('#show_button').val('Vorschau anzeigen');
|
||
$('.wp-ban-grid').css('display', 'grid'); // Ensure details are visible
|
||
console.log('Standard wiederhergestellt, Details sichtbar');
|
||
});
|
||
|
||
$('#toggle_checkbox').on('click', function() {
|
||
$('input[name="delete_ips[]"]').prop('checked', this.checked);
|
||
});
|
||
});
|
||
</script>
|
||
<div class="wp-ban-container">
|
||
<h2>WP Multi Ban Optionen</h2>
|
||
<?php if (!empty($text)) { ?>
|
||
<div><?php echo $text; ?></div>
|
||
<?php } ?>
|
||
<div class="wp-ban-grid">
|
||
<div class="wp-ban-card wp-ban-details-card">
|
||
<h3>Ihre Details</h3>
|
||
<table class="wp-ban-table">
|
||
<thead>
|
||
<tr>
|
||
<th>Detail</th>
|
||
<th>Wert</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>IP</td>
|
||
<td><strong><?php echo esc_html(wp_multi_ban_get_ip()); ?></strong></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Hostname</td>
|
||
<td><strong><?php echo esc_html(@gethostbyaddr(wp_multi_ban_get_ip())); ?></strong></td>
|
||
</tr>
|
||
<tr>
|
||
<td>User Agent</td>
|
||
<td><strong><?php echo esc_html($_SERVER['HTTP_USER_AGENT'] ?? 'Unbekannt'); ?></strong></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Seiten-URL</td>
|
||
<td><strong><?php echo esc_url(get_option('home')); ?></strong></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="2">Bitte <strong>nicht</strong> sich selbst sperren.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div class="wp-ban-card">
|
||
<h3>Sperrstatistiken</h3>
|
||
<form method="post" action="">
|
||
<?php wp_nonce_field('wp_multi_ban_stats'); ?>
|
||
<table class="wp-ban-table">
|
||
<thead>
|
||
<tr>
|
||
<th>IP</th>
|
||
<th>Versuche</th>
|
||
<th>Auswählen</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php
|
||
if (!empty($banned_stats['users'])) {
|
||
$i = 0;
|
||
ksort($banned_stats['users']);
|
||
foreach ($banned_stats['users'] as $ip => $count) {
|
||
?>
|
||
<tr>
|
||
<td><?php echo esc_html($ip); ?></td>
|
||
<td><?php echo number_format_i18n($count); ?></td>
|
||
<td>
|
||
<input type="checkbox" name="delete_ips[]" value="<?php echo esc_attr($ip); ?>" id="ban-<?php echo $i; ?>" />
|
||
<label for="ban-<?php echo $i; ?>">Zurücksetzen</label>
|
||
</td>
|
||
</tr>
|
||
<?php
|
||
$i++;
|
||
}
|
||
} else {
|
||
?>
|
||
<tr>
|
||
<td colspan="3">Keine Sperrversuche</td>
|
||
</tr>
|
||
<?php
|
||
}
|
||
?>
|
||
<tr>
|
||
<td><strong>Gesamtversuche:</strong></td>
|
||
<td><strong><?php echo number_format_i18n($banned_stats['count'] ?? 0); ?></strong></td>
|
||
<td>
|
||
<input type="checkbox" id="reset_ban_stats" name="reset_ban_stats" value="yes" />
|
||
<label for="reset_ban_stats">Alle Statistiken zurücksetzen</label>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="wp-ban-actions">
|
||
<input type="submit" name="do" class="wp-ban-button-primary" value="Sperrstatistiken zurücksetzen" onclick="return confirm('Möchten Sie die Sperrstatistiken wirklich zurücksetzen? Diese Aktion kann nicht rückgängig gemacht werden.');" />
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<form method="post" action="">
|
||
<?php wp_nonce_field('wp_multi_ban_templates'); ?>
|
||
<div class="wp-ban-card">
|
||
<h3>Einstellungen</h3>
|
||
<div class="wp-ban-form-group">
|
||
<label for="banned_option_reverse_proxy">
|
||
Reverse-Proxy-Prüfung
|
||
<small>Aktivieren, wenn Ihre Website hinter einem Reverse-Proxy läuft.</small>
|
||
</label>
|
||
<div class="input-container">
|
||
<label>
|
||
<input type="checkbox" name="banned_option_reverse_proxy" id="banned_option_reverse_proxy" value="1" <?php checked($banned_options['reverse_proxy'], 1); ?> />
|
||
Ich verwende einen Reverse-Proxy.
|
||
</label>
|
||
</div>
|
||
</div>
|
||
<div class="wp-ban-form-group">
|
||
<label for="banned_ips">
|
||
Gesperrte IPs
|
||
<small>Verwenden Sie * für Platzhalter. Eine IP pro Zeile.<br>Beispiele: 192.168.1.100, 192.168.1.*, 192.168.*.*</small>
|
||
</label>
|
||
<div class="input-container">
|
||
<textarea id="banned_ips" name="banned_ips" rows="6"><?php echo esc_textarea($banned_ips_display); ?></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="wp-ban-form-group">
|
||
<label for="banned_ips_range">
|
||
Gesperrter IP-Bereich
|
||
<small>Format: Start-IP-End-IP. Eine pro Zeile.<br>Beispiel: 192.168.1.1-192.168.1.255</small>
|
||
</label>
|
||
<div class="input-container">
|
||
<textarea id="banned_ips_range" name="banned_ips_range" rows="6"><?php echo esc_textarea($banned_ips_range_display); ?></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="wp-ban-form-group">
|
||
<label for="banned_hosts">
|
||
Gesperrte Hostnamen
|
||
<small>Verwenden Sie * für Platzhalter. Einer pro Zeile.<br>Beispiele: *.sg, *.cn</small>
|
||
</label>
|
||
<div class="input-container">
|
||
<textarea id="banned_hosts" name="banned_hosts" rows="6"><?php echo esc_textarea($banned_hosts_display); ?></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="wp-ban-form-group">
|
||
<label for="banned_referers">
|
||
Gesperrte Referer
|
||
<small>Verwenden Sie * für Platzhalter. Einer pro Zeile.<br>Beispiel: http://*.blogspot.com</small>
|
||
</label>
|
||
<div class="input-container">
|
||
<textarea id="banned_referers" name="banned_referers" rows="6"><?php echo esc_textarea($banned_referers_display); ?></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="wp-ban-form-group">
|
||
<label for="banned_user_agents">
|
||
Gesperrte User Agents
|
||
<small>Verwenden Sie * für Platzhalter. Einer pro Zeile.<br>Beispiele: EmailSiphon*, LMQueueBot*</small>
|
||
</label>
|
||
<div class="input-container">
|
||
<textarea id="banned_user_agents" name="banned_user_agents" rows="6"><?php echo esc_textarea($banned_user_agents_display); ?></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="wp-ban-form-group">
|
||
<label for="banned_exclude_ips">
|
||
Ausgeschlossene IPs
|
||
<small>Diese IPs werden nicht gesperrt. Eine pro Zeile.<br>Beispiel: 192.168.1.100</small>
|
||
</label>
|
||
<div class="input-container">
|
||
<textarea id="banned_exclude_ips" name="banned_exclude_ips" rows="6"><?php echo esc_textarea($banned_exclude_ips_display); ?></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="wp-ban-form-group">
|
||
<label for="banned_template_message">
|
||
Sperrnachricht
|
||
<small>Variablen: %SITE_NAME%, %SITE_URL%, %USER_ATTEMPTS_COUNT%, %USER_IP%, %USER_HOSTNAME%, %TOTAL_ATTEMPTS_COUNT%</small>
|
||
</label>
|
||
<div class="input-container">
|
||
<textarea id="banned_template_message" name="banned_template_message" rows="6"><?php echo esc_textarea(stripslashes(get_option('wp_multi_ban_message', ''))); ?></textarea>
|
||
<div class="wp-ban-actions">
|
||
<input type="button" id="restore_default" class="wp-ban-button" value="Standard wiederherstellen" />
|
||
<input type="button" id="show_button" class="wp-ban-button" value="Vorschau anzeigen" />
|
||
</div>
|
||
<div id="banned_preview_message"></div>
|
||
</div>
|
||
</div>
|
||
<div class="wp-ban-actions">
|
||
<input type="submit" name="Submit" class="wp-ban-button-primary" value="Speichern" />
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<?php
|
||
}
|
||
|
||
// Activation Hook
|
||
register_activation_hook(__FILE__, 'wp_multi_toolkit_activate');
|
||
function wp_multi_toolkit_activate($network_wide = false) {
|
||
if (is_multisite() && $network_wide) {
|
||
foreach (get_sites() as $site) {
|
||
switch_to_blog($site->blog_id);
|
||
wp_multi_ban_activate();
|
||
restore_current_blog();
|
||
}
|
||
} else {
|
||
wp_multi_ban_activate();
|
||
}
|
||
}
|
||
|
||
// Uninstall Hook
|
||
register_uninstall_hook(__FILE__, 'wp_multi_toolkit_uninstall');
|
||
function wp_multi_toolkit_uninstall() {
|
||
$options = array(
|
||
'wp_multi_ban_ips',
|
||
'wp_multi_ban_hosts',
|
||
'wp_multi_ban_stats',
|
||
'wp_multi_ban_message',
|
||
'wp_multi_ban_referers',
|
||
'wp_multi_ban_exclude_ips',
|
||
'wp_multi_ban_ips_range',
|
||
'wp_multi_ban_user_agents',
|
||
'wp_multi_ban_options'
|
||
);
|
||
if (is_multisite()) {
|
||
foreach (get_sites() as $site) {
|
||
switch_to_blog($site->blog_id);
|
||
foreach ($options as $option) {
|
||
delete_option($option);
|
||
}
|
||
restore_current_blog();
|
||
}
|
||
} else {
|
||
foreach ($options as $option) {
|
||
delete_option($option);
|
||
}
|
||
}
|
||
}
|