3405 lines
159 KiB
PHP
3405 lines
159 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.9
|
||
* Author: M_Viper
|
||
* Author URI: https://m-viper.de
|
||
* Requires at least: 6.7.2
|
||
* Tested up to: 6.7.2
|
||
* Requires PHP: 7.4
|
||
* 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
|
||
*/
|
||
|
||
defined('ABSPATH') or die('No direct access allowed.');
|
||
|
||
// Konstanten für wiederkehrende Pfade
|
||
define('WPMT_BACKUP_DIR', wp_upload_dir()['basedir'] . '/wpmt_backups/');
|
||
define('WPMT_BACKUP_URL', wp_upload_dir()['baseurl'] . '/wpmt_backups/');
|
||
|
||
/**
|
||
* Erstellt ein Backup der WordPress-Datenbank und speichert es als SQL-Datei.
|
||
*
|
||
* @return string|WP_Error Der Pfad zur Backup-Datei oder ein WP_Error-Objekt bei Fehlern.
|
||
*/
|
||
function wpmt_create_database_backup() {
|
||
global $wpdb;
|
||
|
||
// Dateinamen für das Backup definieren
|
||
$backup_filename = 'wp-database-backup-' . date('Y-m-d_H-i-s') . '.sql';
|
||
$backup_file_path = WPMT_BACKUP_DIR . $backup_filename;
|
||
|
||
// Sicherstellen, dass der Backup-Ordner existiert und beschreibbar ist
|
||
if (!is_writable(wp_upload_dir()['basedir'])) {
|
||
return new WP_Error('backup_error', __('Upload-Verzeichnis ist nicht beschreibbar.', 'wp-multi-toolkit'));
|
||
}
|
||
|
||
if (!file_exists(WPMT_BACKUP_DIR)) {
|
||
if (!wp_mkdir_p(WPMT_BACKUP_DIR)) {
|
||
return new WP_Error('backup_error', __('Backup-Ordner konnte nicht erstellt werden.', 'wp-multi-toolkit'));
|
||
}
|
||
}
|
||
|
||
// 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.', 'wp-multi-toolkit'));
|
||
}
|
||
|
||
// Öffne die Backup-Datei
|
||
$backup_file = fopen($backup_file_path, 'w');
|
||
if (!$backup_file) {
|
||
return new WP_Error('backup_error', __('Backup-Datei konnte nicht geöffnet werden.', 'wp-multi-toolkit'));
|
||
}
|
||
|
||
// 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 (mit SQL-Injection-Schutz)
|
||
$create_table_query = $wpdb->get_row($wpdb->prepare('SHOW CREATE TABLE %s', $table_name), ARRAY_N);
|
||
if ($create_table_query) {
|
||
fwrite($backup_file, $create_table_query[1] . ";\n\n");
|
||
}
|
||
|
||
// Daten der Tabelle in Batches holen (Performance-Optimierung)
|
||
$offset = 0;
|
||
$batch_size = 1000;
|
||
while ($rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM `$table_name` LIMIT %d, %d", $offset, $batch_size), 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");
|
||
}
|
||
$offset += $batch_size;
|
||
}
|
||
|
||
fwrite($backup_file, "\n\n");
|
||
}
|
||
|
||
// Datei schließen
|
||
fclose($backup_file);
|
||
|
||
return $backup_file_path;
|
||
}
|
||
|
||
/**
|
||
* Löscht ein Backup aus dem Backup-Verzeichnis.
|
||
*/
|
||
function wpmt_delete_backup() {
|
||
if (!current_user_can('manage_options')) {
|
||
wp_die(__('Du hast nicht die Berechtigung, diese Aktion auszuführen.', 'wp-multi-toolkit'));
|
||
}
|
||
if (isset($_POST['wpmt_action']) && $_POST['wpmt_action'] === 'delete_backup' && isset($_POST['backup_file']) && check_admin_referer('wpmt_delete_backup_nonce')) {
|
||
$backup_file = WPMT_BACKUP_DIR . 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>';
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Plant automatische Backups via Cron-Job.
|
||
*/
|
||
function wpmt_schedule_backup() {
|
||
$schedule = get_option('wpmt_backup_schedule', 'none');
|
||
$hook = 'wpmt_scheduled_backup';
|
||
|
||
// Entferne bestehende Cron-Jobs, um Duplikate zu vermeiden
|
||
wp_clear_scheduled_hook($hook);
|
||
|
||
// Plane neuen Cron-Job, wenn aktiviert
|
||
if ($schedule !== 'none' && !wp_next_scheduled($hook)) {
|
||
wp_schedule_event(time(), $schedule, $hook);
|
||
}
|
||
}
|
||
add_action('wp', 'wpmt_schedule_backup');
|
||
|
||
/**
|
||
* Führt das geplante Backup aus und sendet optional eine E-Mail-Benachrichtigung.
|
||
*/
|
||
function wpmt_create_scheduled_backup() {
|
||
$backup_path = wpmt_create_database_backup();
|
||
if (!is_wp_error($backup_path)) {
|
||
// Sende E-Mail-Benachrichtigung, wenn aktiviert
|
||
$send_email = get_option('wpmt_backup_email_notification', 0);
|
||
if ($send_email) {
|
||
$admin_email = get_option('admin_email');
|
||
$subject = __('Datenbank-Backup erstellt', 'wp-multi-toolkit');
|
||
$message = __('Ein neues Backup wurde erstellt: ', 'wp-multi-toolkit') . $backup_path;
|
||
wp_mail($admin_email, $subject, $message);
|
||
}
|
||
} else {
|
||
// Optional: Fehler in Log schreiben
|
||
error_log('WP Multi Toolkit: Geplantes Backup fehlgeschlagen: ' . $backup_path->get_error_message());
|
||
}
|
||
}
|
||
add_action('wpmt_scheduled_backup', 'wpmt_create_scheduled_backup');
|
||
|
||
/**
|
||
* Exportiert die Backup-Einstellungen als JSON-Datei.
|
||
*/
|
||
function wpmt_export_backup_settings() {
|
||
if (isset($_POST['wpmt_export_backup_settings']) && check_admin_referer('wpmt_export_backup_settings')) {
|
||
$settings = array(
|
||
'wpmt_backup_schedule' => get_option('wpmt_backup_schedule', 'none'),
|
||
'wpmt_backup_email_notification' => get_option('wpmt_backup_email_notification', 0),
|
||
);
|
||
header('Content-Type: application/json');
|
||
header('Content-Disposition: attachment; filename="wpmt_backup_settings.json"');
|
||
echo json_encode($settings, JSON_PRETTY_PRINT);
|
||
exit;
|
||
}
|
||
}
|
||
add_action('admin_init', 'wpmt_export_backup_settings');
|
||
|
||
/**
|
||
* Importiert Backup-Einstellungen aus einer JSON-Datei.
|
||
*/
|
||
function wpmt_import_backup_settings() {
|
||
if (isset($_POST['wpmt_import_backup_settings']) && check_admin_referer('wpmt_import_backup_settings') && isset($_FILES['wpmt_backup_settings_file'])) {
|
||
$file = $_FILES['wpmt_backup_settings_file']['tmp_name'];
|
||
$settings = json_decode(file_get_contents($file), true);
|
||
|
||
if (is_array($settings)) {
|
||
$valid_schedules = array('none', 'hourly', 'twicedaily', 'daily', 'weekly');
|
||
update_option('wpmt_backup_schedule', in_array($settings['wpmt_backup_schedule'], $valid_schedules) ? $settings['wpmt_backup_schedule'] : 'none');
|
||
update_option('wpmt_backup_email_notification', isset($settings['wpmt_backup_email_notification']) ? (int) $settings['wpmt_backup_email_notification'] : 0);
|
||
echo '<div class="notice notice-success"><p>' . __('Einstellungen erfolgreich importiert!', 'wp-multi-toolkit') . '</p></div>';
|
||
|
||
// Cron-Job aktualisieren
|
||
wpmt_schedule_backup();
|
||
} else {
|
||
echo '<div class="notice notice-error"><p>' . __('Ungültige Datei.', 'wp-multi-toolkit') . '</p></div>';
|
||
}
|
||
}
|
||
}
|
||
add_action('admin_init', 'wpmt_import_backup_settings');
|
||
|
||
/**
|
||
* Anzeige der Backup-Seite mit Liste der Backups und Verlinkung zur Einstellungsseite.
|
||
*/
|
||
function wpmt_display_backup_page() {
|
||
$backup_dir = WPMT_BACKUP_DIR;
|
||
$backups = glob($backup_dir . '/*.sql');
|
||
|
||
?>
|
||
<div class="wrap">
|
||
<h1><?php _e('Datenbank-Backup erstellen und verwalten', 'wp-multi-toolkit'); ?></h1>
|
||
<p><a href="<?php echo admin_url('tools.php?page=wpmt-backup-settings'); ?>" class="button"><?php _e('Backup-Einstellungen', 'wp-multi-toolkit'); ?></a></p>
|
||
|
||
<form method="post" action="">
|
||
<?php wp_nonce_field('wpmt_create_backup_nonce'); ?>
|
||
<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 esc_html(basename($backup)); ?></td>
|
||
<td>
|
||
<a href="<?php echo esc_url(WPMT_BACKUP_URL . basename($backup)); ?>" class="button" download><?php _e('Herunterladen', 'wp-multi-toolkit'); ?></a>
|
||
<form method="post" action="" style="display:inline;">
|
||
<?php wp_nonce_field('wpmt_delete_backup_nonce'); ?>
|
||
<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
|
||
}
|
||
|
||
/**
|
||
* Anzeige der Backup-Einstellungsseite für automatische Backups und Export/Import.
|
||
*/
|
||
function wpmt_display_backup_settings_page() {
|
||
?>
|
||
<div class="wrap">
|
||
<h1><?php _e('Backup-Einstellungen', 'wp-multi-toolkit'); ?></h1>
|
||
<form method="post" action="options.php">
|
||
<?php
|
||
settings_fields('wpmt_backup_settings');
|
||
do_settings_sections('wpmt_backup_settings');
|
||
submit_button();
|
||
?>
|
||
</form>
|
||
|
||
<h2><?php _e('Einstellungen exportieren/importieren', 'wp-multi-toolkit'); ?></h2>
|
||
<form method="post">
|
||
<?php wp_nonce_field('wpmt_export_backup_settings'); ?>
|
||
<input type="hidden" name="wpmt_export_backup_settings" value="1">
|
||
<p><input type="submit" class="button" value="<?php _e('Einstellungen exportieren', 'wp-multi-toolkit'); ?>"></p>
|
||
</form>
|
||
<form method="post" enctype="multipart/form-data">
|
||
<?php wp_nonce_field('wpmt_import_backup_settings'); ?>
|
||
<input type="hidden" name="wpmt_import_backup_settings" value="1">
|
||
<p><input type="file" name="wpmt_backup_settings_file" accept=".json"></p>
|
||
<p><input type="submit" class="button" value="<?php _e('Einstellungen importieren', 'wp-multi-toolkit'); ?>"></p>
|
||
</form>
|
||
</div>
|
||
<?php
|
||
}
|
||
|
||
/**
|
||
* Registriert die Backup-Einstellungen für die Einstellungsseite.
|
||
*/
|
||
function wpmt_register_backup_settings() {
|
||
register_setting('wpmt_backup_settings', 'wpmt_backup_schedule', array(
|
||
'sanitize_callback' => function($value) {
|
||
$valid_schedules = array('none', 'hourly', 'twicedaily', 'daily', 'weekly');
|
||
return in_array($value, $valid_schedules) ? $value : 'none';
|
||
}
|
||
));
|
||
register_setting('wpmt_backup_settings', 'wpmt_backup_email_notification', array(
|
||
'sanitize_callback' => 'absint'
|
||
));
|
||
|
||
add_settings_section(
|
||
'wpmt_backup_main_section',
|
||
__('Automatische Backup-Einstellungen', 'wp-multi-toolkit'),
|
||
function() {
|
||
echo '<p>' . __('Konfigurieren Sie automatische Backups und Benachrichtigungen.', 'wp-multi-toolkit') . '</p>';
|
||
},
|
||
'wpmt_backup_settings'
|
||
);
|
||
|
||
add_settings_field(
|
||
'wpmt_backup_schedule',
|
||
__('Backup-Zeitplan', 'wp-multi-toolkit'),
|
||
function() {
|
||
$schedule = get_option('wpmt_backup_schedule', 'none');
|
||
?>
|
||
<select name="wpmt_backup_schedule">
|
||
<option value="none" <?php selected($schedule, 'none'); ?>><?php _e('Deaktiviert', 'wp-multi-toolkit'); ?></option>
|
||
<option value="hourly" <?php selected($schedule, 'hourly'); ?>><?php _e('Stündlich', 'wp-multi-toolkit'); ?></option>
|
||
<option value="twicedaily" <?php selected($schedule, 'twicedaily'); ?>><?php _e('Zweimal täglich', 'wp-multi-toolkit'); ?></option>
|
||
<option value="daily" <?php selected($schedule, 'daily'); ?>><?php _e('Täglich', 'wp-multi-toolkit'); ?></option>
|
||
<option value="weekly" <?php selected($schedule, 'weekly'); ?>><?php _e('Wöchentlich', 'wp-multi-toolkit'); ?></option>
|
||
</select>
|
||
<?php
|
||
},
|
||
'wpmt_backup_settings',
|
||
'wpmt_backup_main_section'
|
||
);
|
||
|
||
add_settings_field(
|
||
'wpmt_backup_email_notification',
|
||
__('E-Mail-Benachrichtigung', 'wp-multi-toolkit'),
|
||
function() {
|
||
$email_notification = get_option('wpmt_backup_email_notification', 0);
|
||
?>
|
||
<input type="checkbox" name="wpmt_backup_email_notification" value="1" <?php checked($email_notification, 1); ?>>
|
||
<label><?php _e('E-Mail senden, wenn ein Backup erstellt wurde', 'wp-multi-toolkit'); ?></label>
|
||
<?php
|
||
},
|
||
'wpmt_backup_settings',
|
||
'wpmt_backup_main_section'
|
||
);
|
||
}
|
||
add_action('admin_init', 'wpmt_register_backup_settings');
|
||
|
||
/**
|
||
* Handhabt 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' && check_admin_referer('wpmt_create_backup_nonce')) {
|
||
$backup_path = wpmt_create_database_backup();
|
||
|
||
if (is_wp_error($backup_path)) {
|
||
echo '<div class="error"><p>' . esc_html($backup_path->get_error_message()) . '</p></div>';
|
||
} else {
|
||
echo '<div class="updated"><p>' . __('Datenbank-Backup erfolgreich erstellt!', 'wp-multi-toolkit') . '</p></div>';
|
||
}
|
||
}
|
||
}
|
||
add_action('admin_init', 'wpmt_handle_backup_request');
|
||
|
||
/**
|
||
* Fügt die Backup-Menüpunkte zum Admin-Menü hinzu.
|
||
*/
|
||
function wpmt_add_backup_menu() {
|
||
add_submenu_page(
|
||
'tools.php',
|
||
__('WP-Multi DB-Backup', 'wp-multi-toolkit'),
|
||
__('WP-Multi DB-Backup', 'wp-multi-toolkit'),
|
||
'manage_options',
|
||
'wpmt-database-backup',
|
||
'wpmt_display_backup_page'
|
||
);
|
||
|
||
add_submenu_page(
|
||
'tools.php',
|
||
__('WP-Multi Backup-Einstellungen', 'wp-multi-toolkit'),
|
||
__('Backup-Einstellungen', 'wp-multi-toolkit'),
|
||
'manage_options',
|
||
'wpmt-backup-settings',
|
||
'wpmt_display_backup_settings_page'
|
||
);
|
||
}
|
||
add_action('admin_menu', 'wpmt_add_backup_menu');
|
||
|
||
|
||
/*
|
||
* 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() {
|
||
if (get_option('wpmt_enable_cookie_banner', '1') !== '1' || isset($_COOKIE['wpmt_cookie_accepted'])) {
|
||
return;
|
||
}
|
||
|
||
$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'));
|
||
$settings_text = __('Einstellungen', '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 = 'position:fixed; bottom:0; left:0; width:100%; background:' . esc_attr($banner_background_color) . '; padding:10px; text-align:center; z-index:1000;';
|
||
?>
|
||
<div style="<?php echo $banner_style; ?>" id="cookie-banner">
|
||
<p><?php echo esc_html($banner_text); ?> <a href="<?php echo esc_url($policy_url); ?>"><?php _e('Mehr erfahren', 'wp-multi-toolkit'); ?></a> | <a href="<?php echo esc_url($impressum_url); ?>"><?php _e('Impressum', 'wp-multi-toolkit'); ?></a></p>
|
||
<button id="accept-cookies" class="button"><?php echo esc_html($accept_text); ?></button>
|
||
<button id="decline-cookies" class="button"><?php echo esc_html($decline_text); ?></button>
|
||
<button id="settings-cookies" class="button"><?php echo esc_html($settings_text); ?></button>
|
||
</div>
|
||
<div id="cookie-settings" style="display:none; position:fixed; bottom:0; left:0; width:100%; background:#fff; padding:20px; z-index:1001;">
|
||
<h3><?php _e('Cookie-Einstellungen', 'wp-multi-toolkit'); ?></h3>
|
||
<label><input type="checkbox" name="cookie_necessary" checked disabled> <?php _e('Notwendig', 'wp-multi-toolkit'); ?></label><br>
|
||
<label><input type="checkbox" name="cookie_preferences"> <?php _e('Präferenzen', 'wp-multi-toolkit'); ?></label><br>
|
||
<label><input type="checkbox" name="cookie_statistics"> <?php _e('Statistiken', 'wp-multi-toolkit'); ?></label><br>
|
||
<label><input type="checkbox" name="cookie_marketing"> <?php _e('Marketing', 'wp-multi-toolkit'); ?></label><br>
|
||
<button id="save-cookie-settings" class="button button-primary"><?php _e('Speichern', 'wp-multi-toolkit'); ?></button>
|
||
</div>
|
||
<script>
|
||
document.getElementById('accept-cookies').addEventListener('click', function() {
|
||
document.cookie = "wpmt_cookie_accepted=true; path=/; max-age=" + (60 * 60 * 24 * 365);
|
||
document.getElementById('cookie-banner').style.display = 'none';
|
||
saveConsent(true);
|
||
});
|
||
document.getElementById('decline-cookies').addEventListener('click', function() {
|
||
document.getElementById('cookie-banner').style.display = 'none';
|
||
saveConsent(false);
|
||
});
|
||
document.getElementById('settings-cookies').addEventListener('click', function() {
|
||
document.getElementById('cookie-settings').style.display = 'block';
|
||
});
|
||
document.getElementById('save-cookie-settings').addEventListener('click', function() {
|
||
var settings = {
|
||
necessary: true,
|
||
preferences: document.querySelector('[name="cookie_preferences"]').checked,
|
||
statistics: document.querySelector('[name="cookie_statistics"]').checked,
|
||
marketing: document.querySelector('[name="cookie_marketing"]').checked
|
||
};
|
||
document.cookie = "wpmt_cookie_accepted=" + JSON.stringify(settings) + "; path=/; max-age=" + (60 * 60 * 24 * 365);
|
||
document.getElementById('cookie-banner').style.display = 'none';
|
||
document.getElementById('cookie-settings').style.display = 'none';
|
||
saveConsent(settings);
|
||
});
|
||
|
||
function saveConsent(settings) {
|
||
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=' + encodeURIComponent(JSON.stringify(settings)));
|
||
}
|
||
</script>
|
||
<?php
|
||
}
|
||
add_action('wp_footer', 'wpmt_cookie_banner');
|
||
|
||
// AJAX-Aktion für das Speichern der Zustimmung
|
||
function anonymize_ip($ip) {
|
||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||
$parts = explode('.', $ip);
|
||
return implode('.', array_slice($parts, 0, 2)) . '.0.0';
|
||
} elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||
return bin2hex(inet_pton($ip) & pack('H*', 'ffffffffffffffff0000000000000000'));
|
||
}
|
||
return $ip;
|
||
}
|
||
|
||
function wpmt_save_cookie_consent() {
|
||
if (isset($_POST['cookie_accepted']) && $_POST['cookie_accepted'] === 'true') {
|
||
global $wpdb;
|
||
$wpdb->insert(
|
||
$wpdb->prefix . 'wpmt_cookie_consent',
|
||
array(
|
||
'user_ip' => anonymize_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ü
|
||
*/
|
||
defined('ABSPATH') or die('No direct access allowed.');
|
||
|
||
/**
|
||
* Anzeige der virtuellen Assistenten-Seite
|
||
*/
|
||
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'));
|
||
}
|
||
|
||
$current_user = wp_get_current_user();
|
||
$user_name = $current_user->display_name ?: __('Freund', 'wp-multi-toolkit');
|
||
|
||
$assistant_responses = apply_filters('wpmt_assistant_responses', array(
|
||
'default' => sprintf(
|
||
__('Ups, das habe ich nicht ganz verstanden, %s! 😅 Versuche es mit einer anderen Formulierung oder schau in die <a href="%s" class="wpmt-action">Dokumentation</a>. Alternativ kannst du ein <a href="%s" class="wpmt-action">Support-Ticket</a> erstellen, und wir helfen dir weiter!', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs'),
|
||
admin_url('admin.php?page=wp_multi_support')
|
||
)
|
||
));
|
||
|
||
// Stichwörter für Autovervollständigung und Anzeige
|
||
$keywords = array_keys($assistant_responses);
|
||
unset($keywords[array_search('default', $keywords)]);
|
||
$keywords_list = implode(', ', array_map(function($key) {
|
||
return ucfirst(str_replace('-', ' ', $key));
|
||
}, $keywords));
|
||
|
||
?>
|
||
<div class="wrap animate-fade-in">
|
||
<h1><?php _e('WP Multi Virtueller Assistent', 'wp-multi-toolkit'); ?></h1>
|
||
<div class="wpmt-assistant-container">
|
||
<div class="wpmt-assistant-header">
|
||
<img src="https://m-viper.de/img/bot.png" alt="<?php _e('Virtueller Assistent', 'wp-multi-toolkit'); ?>" class="wpmt-assistant-avatar">
|
||
<h2><?php printf(__('Hallo %s, ich bin dein WP Multi Assistent!', 'wp-multi-toolkit'), esc_html($user_name)); ?></h2>
|
||
<p><?php _e('Frag mich alles über die WP Multi Plugins – ich erkläre dir alles Schritt für Schritt! 😊', 'wp-multi-toolkit'); ?></p>
|
||
</div>
|
||
<div class="wpmt-assistant-chat">
|
||
<div id="assistant-chat-messages" class="wpmt-assistant-messages"></div>
|
||
</div>
|
||
<div class="wpmt-assistant-input-container">
|
||
<input type="text" id="assistant-input" placeholder="<?php _e('z. B. Wie richte ich Telegram ein?', 'wp-multi-toolkit'); ?>" autocomplete="off" />
|
||
<button id="assistant-submit" class="button button-primary"><?php _e('Senden', 'wp-multi-toolkit'); ?></button>
|
||
<button id="assistant-clear" class="button"><?php _e('Chatverlauf löschen', 'wp-multi-toolkit'); ?></button>
|
||
</div>
|
||
</div>
|
||
<div class="wpmt-keywords-container">
|
||
<h3><?php _e('Themen, zu denen ich dir helfen kann', 'wp-multi-toolkit'); ?></h3>
|
||
<p><?php echo esc_html($keywords_list); ?></p>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
jQuery(document).ready(function($) {
|
||
var responses = <?php echo json_encode($assistant_responses); ?>;
|
||
var keywords = <?php echo json_encode($keywords); ?>;
|
||
var chatHistory = JSON.parse(localStorage.getItem('wpmt_assistant_chat') || '[]');
|
||
var lastQuestion = '';
|
||
|
||
// Nachrichten anzeigen
|
||
function updateChat() {
|
||
$('#assistant-chat-messages').empty();
|
||
if (chatHistory.length === 0) {
|
||
$('#assistant-chat-messages').append(
|
||
'<div class="wpmt-message assistant animate-slide-in-left"><?php printf(__('Hi %s! Stell mir einfach eine Frage, und ich lege los! 🚀', 'wp-multi-toolkit'), esc_js($user_name)); ?></div>'
|
||
);
|
||
} else {
|
||
chatHistory.forEach(function(item) {
|
||
$('#assistant-chat-messages').append(
|
||
'<div class="wpmt-message user animate-slide-in-right">' + item.question + '</div>' +
|
||
'<div class="wpmt-message assistant animate-slide-in-left">' + item.response + '</div>'
|
||
);
|
||
});
|
||
}
|
||
scrollToBottom();
|
||
}
|
||
updateChat();
|
||
|
||
// Funktion zum Scrollen zur letzten Nachricht
|
||
function scrollToBottom() {
|
||
var $chatMessages = $('#assistant-chat-messages');
|
||
$chatMessages.animate({
|
||
scrollTop: $chatMessages[0].scrollHeight
|
||
}, 300);
|
||
}
|
||
|
||
// AJAX-Request für Antworten
|
||
function submitQuestion(question, selectedKeyword = null) {
|
||
if (!question) return;
|
||
|
||
// Füge die Frage und den "Tippen"-Hinweis hinzu
|
||
$('#assistant-chat-messages').append(
|
||
'<div class="wpmt-message user animate-slide-in-right">' + question + '</div>' +
|
||
'<div class="wpmt-message assistant wpmt-typing animate-slide-in-left"><?php _e('Ich tippe gerade', 'wp-multi-toolkit'); ?><span class="typing-dots">...</span></div>'
|
||
);
|
||
scrollToBottom();
|
||
|
||
$.ajax({
|
||
url: '<?php echo admin_url('admin-ajax.php'); ?>',
|
||
type: 'POST',
|
||
data: {
|
||
action: 'wpmt_assistant_query',
|
||
question: question,
|
||
last_question: lastQuestion,
|
||
selected_keyword: selectedKeyword,
|
||
nonce: '<?php echo wp_create_nonce('wpmt_assistant_nonce'); ?>'
|
||
},
|
||
success: function(response) {
|
||
$('.wpmt-typing').remove();
|
||
if (response.success) {
|
||
$('#assistant-chat-messages').append(
|
||
'<div class="wpmt-message assistant animate-slide-in-left">' + response.data.response + '</div>'
|
||
);
|
||
chatHistory.push({
|
||
question: question,
|
||
response: response.data.response
|
||
});
|
||
if (chatHistory.length > 20) chatHistory.shift();
|
||
localStorage.setItem('wpmt_assistant_chat', JSON.stringify(chatHistory));
|
||
lastQuestion = question;
|
||
} else {
|
||
$('#assistant-chat-messages').append(
|
||
'<div class="wpmt-message assistant animate-slide-in-left"><?php _e('Ups, etwas ist schiefgelaufen. Versuche es nochmal! 😓', 'wp-multi-toolkit'); ?></div>'
|
||
);
|
||
}
|
||
scrollToBottom();
|
||
},
|
||
error: function() {
|
||
$('.wpmt-typing').remove();
|
||
$('#assistant-chat-messages').append(
|
||
'<div class="wpmt-message assistant animate-slide-in-left"><?php _e('Oh nein, meine Verbindung ist abgebrochen! 😵 Überprüfe deine Internetverbindung und versuche es erneut.', 'wp-multi-toolkit'); ?></div>'
|
||
);
|
||
scrollToBottom();
|
||
}
|
||
});
|
||
}
|
||
|
||
// Button-Klick
|
||
$('#assistant-submit').on('click', function() {
|
||
var question = $('#assistant-input').val().trim();
|
||
if (question) {
|
||
submitQuestion(question);
|
||
$('#assistant-input').val('');
|
||
}
|
||
});
|
||
|
||
// Enter-Taste
|
||
$('#assistant-input').on('keypress', function(e) {
|
||
if (e.which === 13) {
|
||
e.preventDefault();
|
||
$('#assistant-submit').trigger('click');
|
||
}
|
||
});
|
||
|
||
// Chatverlauf löschen
|
||
$('#assistant-clear').on('click', function() {
|
||
if (confirm('<?php _e('Möchtest du den Chatverlauf wirklich löschen?', 'wp-multi-toolkit'); ?>')) {
|
||
chatHistory = [];
|
||
localStorage.setItem('wpmt_assistant_chat', JSON.stringify(chatHistory));
|
||
updateChat();
|
||
}
|
||
});
|
||
|
||
// Antwort bewerten
|
||
$(document).on('click', '.wpmt-rate-response', function() {
|
||
var message = $(this).closest('.wpmt-message').html();
|
||
var rating = $(this).data('rating');
|
||
$.post('<?php echo admin_url('admin-ajax.php'); ?>', {
|
||
action: 'wpmt_assistant_feedback',
|
||
message: message,
|
||
rating: rating,
|
||
nonce: '<?php echo wp_create_nonce('wpmt_assistant_nonce'); ?>'
|
||
}, function() {
|
||
alert('<?php _e('Danke für deine Bewertung!', 'wp-multi-toolkit'); ?>');
|
||
});
|
||
});
|
||
|
||
// Schnellaktionen
|
||
$(document).on('click', '.wpmt-action', function(e) {
|
||
e.preventDefault();
|
||
var url = $(this).attr('href');
|
||
if (url) window.location.href = url;
|
||
});
|
||
|
||
// Klick auf Stichwort-Vorschlag
|
||
$(document).on('click', '.wpmt-keyword-suggestion', function(e) {
|
||
e.preventDefault();
|
||
var keyword = $(this).data('keyword');
|
||
var question = '<?php _e('Informationen zu ', 'wp-multi-toolkit'); ?>' + keyword;
|
||
submitQuestion(question, keyword);
|
||
});
|
||
});
|
||
</script>
|
||
|
||
<style>
|
||
.wpmt-assistant-container {
|
||
background: #fff;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||
max-width: 700px;
|
||
margin: 20px auto;
|
||
}
|
||
.wpmt-assistant-header {
|
||
text-align: center;
|
||
margin-bottom: 20px;
|
||
}
|
||
.wpmt-assistant-avatar {
|
||
max-width: 80px;
|
||
border-radius: 50%;
|
||
margin-bottom: 10px;
|
||
}
|
||
.wpmt-assistant-header h2 {
|
||
font-size: 24px;
|
||
margin: 10px 0;
|
||
color: #333;
|
||
}
|
||
.wpmt-assistant-header p {
|
||
font-size: 16px;
|
||
color: #666;
|
||
}
|
||
.wpmt-assistant-chat {
|
||
background: #f9f9f9;
|
||
border: 1px solid #ddd;
|
||
border-radius: 8px;
|
||
padding: 15px;
|
||
margin-bottom: 15px;
|
||
}
|
||
.wpmt-assistant-messages {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
max-height: 400px;
|
||
overflow-y: auto;
|
||
padding-right: 10px;
|
||
}
|
||
.wpmt-message {
|
||
padding: 10px 15px;
|
||
border-radius: 8px;
|
||
max-width: 80%;
|
||
line-height: 1.5;
|
||
word-wrap: break-word;
|
||
opacity: 0; /* Für Animation */
|
||
}
|
||
.wpmt-message.user {
|
||
background: #0073aa;
|
||
color: #fff;
|
||
align-self: flex-end;
|
||
border-bottom-right-radius: 0;
|
||
}
|
||
.wpmt-message.assistant {
|
||
background: #fff;
|
||
border: 1px solid #ddd;
|
||
align-self: flex-start;
|
||
border-bottom-left-radius: 0;
|
||
}
|
||
.wpmt-message.wpmt-typing {
|
||
font-style: italic;
|
||
color: #0073aa;
|
||
}
|
||
.wpmt-assistant-input-container {
|
||
display: flex;
|
||
gap: 10px;
|
||
flex-wrap: wrap;
|
||
}
|
||
#assistant-input {
|
||
flex: 1;
|
||
padding: 10px;
|
||
border: 1px solid #ddd;
|
||
border-radius: 4px;
|
||
font-size: 14px;
|
||
}
|
||
#assistant-submit, #assistant-clear {
|
||
padding: 10px 20px;
|
||
border-radius: 4px;
|
||
font-size: 14px;
|
||
}
|
||
.wpmt-action, .wpmt-rate-response {
|
||
color: #0073aa;
|
||
text-decoration: none;
|
||
margin-right: 10px;
|
||
cursor: pointer;
|
||
}
|
||
.wpmt-action:hover, .wpmt-rate-response:hover {
|
||
color: #005d82;
|
||
text-decoration: underline;
|
||
}
|
||
.wpmt-keyword-suggestion {
|
||
display: inline-block;
|
||
padding: 8px 15px;
|
||
margin: 5px;
|
||
background: #0073aa;
|
||
color: #fff;
|
||
border-radius: 4px;
|
||
text-decoration: none;
|
||
cursor: pointer;
|
||
}
|
||
.wpmt-keyword-suggestion:hover {
|
||
background: #005d82;
|
||
}
|
||
.wpmt-keywords-container {
|
||
background: #f9f9f9;
|
||
padding: 15px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
||
max-width: 700px;
|
||
margin: 20px auto;
|
||
text-align: left;
|
||
}
|
||
.wpmt-keywords-container h3 {
|
||
font-size: 16px;
|
||
margin: 0 0 10px;
|
||
}
|
||
.wpmt-keywords-container p {
|
||
font-size: 12px;
|
||
color: #666;
|
||
margin: 0;
|
||
word-wrap: break-word;
|
||
}
|
||
@media (max-width: 600px) {
|
||
.wpmt-assistant-input-container {
|
||
flex-direction: column;
|
||
}
|
||
#assistant-submit, #assistant-clear {
|
||
width: 100%;
|
||
}
|
||
.wpmt-message {
|
||
max-width: 90%;
|
||
}
|
||
}
|
||
|
||
/* Animationen */
|
||
@keyframes fadeIn {
|
||
from { opacity: 0; }
|
||
to { opacity: 1; }
|
||
}
|
||
@keyframes slideInLeft {
|
||
from { transform: translateX(-20px); opacity: 0; }
|
||
to { transform: translateX(0); opacity: 1; }
|
||
}
|
||
@keyframes slideInRight {
|
||
from { transform: translateX(20px); opacity: 0; }
|
||
to { transform: translateX(0); opacity: 1; }
|
||
}
|
||
@keyframes typingDots {
|
||
0% { content: '.'; }
|
||
33% { content: '..'; }
|
||
66% { content: '...'; }
|
||
100% { content: '.'; }
|
||
}
|
||
.animate-fade-in {
|
||
animation: fadeIn 0.5s ease forwards;
|
||
}
|
||
.animate-slide-in-left {
|
||
animation: slideInLeft 0.5s ease forwards;
|
||
}
|
||
.animate-slide-in-right {
|
||
animation: slideInRight 0.5s ease forwards;
|
||
}
|
||
.wpmt-typing .typing-dots::after {
|
||
content: '...';
|
||
display: inline-block;
|
||
width: 1.5em;
|
||
text-align: left;
|
||
animation: typingDots 1.5s infinite;
|
||
}
|
||
</style>
|
||
<?php
|
||
}
|
||
|
||
/**
|
||
* Normalisiert Text für die Stichwortsuche
|
||
*/
|
||
function wpmt_normalize_text($text) {
|
||
$text = strtolower(trim($text));
|
||
$text = str_replace(['ä', 'ö', 'ü', 'ß'], ['ae', 'oe', 'ue', 'ss'], $text);
|
||
$text = preg_replace('/[\-_.,;:!?]/', ' ', $text);
|
||
$text = preg_replace('/\s+/', ' ', $text);
|
||
return $text;
|
||
}
|
||
|
||
/**
|
||
* Berechnet die Levenshtein-Distanz für Tippfehler-Toleranz
|
||
*/
|
||
function wpmt_levenshtein_match($input, $keywords, $max_distance = 4) {
|
||
$input = wpmt_normalize_text($input);
|
||
$best_match = false;
|
||
$min_distance = 999;
|
||
foreach ($keywords as $key => $synonyms) {
|
||
foreach ($synonyms as $synonym) {
|
||
$distance = levenshtein($input, wpmt_normalize_text($synonym));
|
||
if ($distance < $min_distance && $distance <= $max_distance) {
|
||
$min_distance = $distance;
|
||
$best_match = $key;
|
||
}
|
||
}
|
||
}
|
||
return $best_match;
|
||
}
|
||
|
||
/**
|
||
* AJAX-Handler für Assistenten-Anfragen
|
||
*/
|
||
function wpmt_assistant_query() {
|
||
check_ajax_referer('wpmt_assistant_nonce', 'nonce');
|
||
|
||
$question = isset($_POST['question']) ? sanitize_text_field($_POST['question']) : '';
|
||
$last_question = isset($_POST['last_question']) ? sanitize_text_field($_POST['last_question']) : '';
|
||
$selected_keyword = isset($_POST['selected_keyword']) ? sanitize_text_field($_POST['selected_keyword']) : '';
|
||
|
||
if (empty($question)) {
|
||
wp_send_json_error(__('Bitte gib eine Frage ein, um weiterzumachen!', 'wp-multi-toolkit'));
|
||
}
|
||
|
||
$current_user = wp_get_current_user();
|
||
$user_name = $current_user->display_name ?: __('Freund', 'wp-multi-toolkit');
|
||
|
||
$responses = apply_filters('wpmt_assistant_responses', array(
|
||
'default' => sprintf(
|
||
__('Ups, das habe ich nicht ganz verstanden, %s! 😅 Versuche es mit einer anderen Formulierung oder schau in die <a href="%s" class="wpmt-action">Dokumentation</a>. Alternativ kannst du ein <a href="%s" class="wpmt-action">Support-Ticket</a> erstellen, und wir helfen dir weiter!', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs'),
|
||
admin_url('admin.php?page=wp_multi_support')
|
||
)
|
||
));
|
||
|
||
$keyword_synonyms = apply_filters('wpmt_assistant_keyword_synonyms', array(
|
||
'statistik' => ['statistik', 'statistiken', 'stats', 'daten', 'bericht'],
|
||
'telegram' => ['telegram', 'telegarm', 'tg', 'tele', 'benachrichtigung telegram'],
|
||
'discord' => ['discord', 'discrod', 'dc', 'discord benachrichtigung'],
|
||
'admin links' => ['admin links', 'admin-links', 'adminlinks', 'links', 'menü links'],
|
||
'gast-autor' => ['gast-autor', 'gastautor', 'guest author', 'gast', 'autor'],
|
||
'beitrag report' => ['beitrag report', 'beitrag-report', 'report', 'melden', 'gemeldete beiträge'],
|
||
'textbox' => ['textbox', 'text-box', 'textfeld', 'text am beitrag'],
|
||
'banner' => ['banner', 'werbung', 'anzeige', 'header banner', 'footer banner'],
|
||
'inhaltsverzeichnis' => ['inhaltsverzeichnis', 'inhalt', 'index', 'verzeichnis', 'alphabetische liste'],
|
||
'lesezeichen' => ['lesezeichen', 'bookmark', 'favoriten', 'speichern', 'merken'],
|
||
'custom shortcode' => ['custom shortcode', 'shortcode', 'eigener shortcode', 'shortcodes'],
|
||
'kommentar sperren' => ['kommentar sperren', 'kommentarsperre', 'blockieren', 'sperren', 'nutzer blockieren'],
|
||
'filter' => ['filter', 'kommentarfilter', 'filtern', 'kommentare filtern'],
|
||
'analytics' => ['analytics', 'analyse', 'benutzer analytics', 'datenanalyse'],
|
||
'pinwand' => ['pinwand', 'notiz', 'pinnwand', 'team notizen'],
|
||
'brute force' => ['brute force', 'bruteforce', 'sicherheit', 'login schutz'],
|
||
'anti spam' => ['anti spam', 'antispam', 'spam', 'spam schutz'],
|
||
'auto tag' => ['auto tag', 'autotag', 'tags', 'automatische tags'],
|
||
'login deaktivieren' => ['login deaktivieren', 'login-deaktivieren', 'login', 'zugang sperren'],
|
||
'text copy' => ['text copy', 'text-copy', 'kopierschutz', 'rechtsklick sperre'],
|
||
'trash mail' => ['trash mail', 'trash-mail', 'spam mail', 'wegwerf email'],
|
||
'kommentar benachrichtigung' => ['kommentar benachrichtigung', 'kommentar-benachrichtigung', 'benachrichtigung', 'comment', 'kommentar alarm'],
|
||
'kategorien ausblenden' => ['kategorien ausblenden', 'kategorie-ausblenden', 'kategorien', 'ausblenden', 'kategorie filter'],
|
||
'suchfunktion' => ['suchfunktion', 'suche', 'search', 'wp multi search'],
|
||
'teamcard' => ['teamcard', 'team-card', 'teamkarte', 'team', 'teamkarten'],
|
||
'teammitglied hinzufügen' => ['teammitglied hinzufügen', 'teammitglied-hinzufügen', 'mitglied', 'hinzufügen', 'teammitglied'],
|
||
'teamcard shortcode' => ['teamcard shortcode', 'teamcard-shortcode', 'shortcode', 'teamkarten shortcode'],
|
||
'teamcard kategorie' => ['teamcard kategorie', 'teamcard-kategorie', 'kategorie', 'team kategorie'],
|
||
'teamcard bild' => ['teamcard bild', 'teamcard-bild', 'bild', 'team foto'],
|
||
'teamcard löschen' => ['teamcard löschen', 'teamcard-löschen', 'löschen', 'teammitglied entfernen'],
|
||
'teamcard reihenfolge' => ['teamcard reihenfolge', 'teamcard-reihenfolge', 'reihenfolge', 'team sortieren'],
|
||
'teamcard deinstallation' => ['teamcard deinstallation', 'teamcard-deinstallation', 'deinstallieren', 'teamcard entfernen'],
|
||
'teamcard updates' => ['teamcard updates', 'teamcard-updates', 'updates', 'teamcard aktualisierung'],
|
||
'update management' => ['update management', 'update-management', 'updates', 'plugin updates'],
|
||
'support issues' => ['support issues', 'support-issues', 'support', 'ticket', 'hilfe'],
|
||
'dokumentation' => ['dokumentation', 'doku', 'docs', 'anleitung', 'dokumentaton'],
|
||
'virtueller assistent' => ['virtueller assistent', 'assistent', 'virtuell', 'chatbot'],
|
||
'toolbar' => ['toolbar', 'werkzeugleiste', 'schnellstart', 'quickbar'],
|
||
'wp multi plugins' => ['wp multi plugins', 'wp-multi-plugins', 'plugins', 'wp multi'],
|
||
'was sind wp multi plugins' => ['was sind wp multi plugins', 'wp multi plugins', 'plugins', 'wp multi erklärung'],
|
||
'wie installiere ich ein plugin' => ['wie installiere ich ein plugin', 'plugin installieren', 'installation', 'plugin setup', 'install plugin'],
|
||
'wo finde ich updates' => ['wo finde ich updates', 'updates finden', 'aktualisierungen', 'plugin updates', 'update suchen'],
|
||
'wie erstelle ich ein support ticket' => ['wie erstelle ich ein support ticket', 'support ticket', 'ticket', 'support anfrage', 'ticket erstellen'],
|
||
'welche voraussetzungen gibt es' => ['welche voraussetzungen gibt es', 'voraussetzungen', 'anforderungen', 'systemanforderungen', 'plugin voraussetzungen'],
|
||
'sind die plugins kostenlos' => ['sind die plugins kostenlos', 'kostenlos', 'gratis', 'plugin kosten', 'free plugins'],
|
||
'wie deaktiviere ich ein plugin' => ['wie deaktiviere ich ein plugin', 'plugin deaktivieren', 'deaktivieren', 'plugin ausschalten', 'disable plugin'],
|
||
'wo finde ich die dokumentation' => ['wo finde ich die dokumentation', 'dokumentation finden', 'doku', 'anleitung finden', 'doku suchen'],
|
||
'wer entwickelt die plugins' => ['wer entwickelt die plugins', 'entwickler', 'm_viper', 'plugin entwickler', 'wer macht plugins'],
|
||
'kann ich eigene funktionen hinzufügen' => ['kann ich eigene funktionen hinzufügen', 'eigene funktionen', 'anpassen', 'erweitern', 'custom functions'],
|
||
'wie richte ich wp multi ein' => ['wie richte ich wp multi ein', 'wp multi einrichten', 'setup wp multi', 'installation wp multi', 'wp multi installieren'],
|
||
'was ist wordpress' => ['was ist wordpress', 'wordpress', 'wordpress erklärung', 'cms wordpress', 'wordpress info'],
|
||
'wie sichere ich meine website' => ['wie sichere ich meine website', 'website sichern', 'sicherheit', 'backup', 'sichere website'],
|
||
'wie verbessere ich die performance' => ['wie verbessere ich die performance', 'performance', 'geschwindigkeit', 'optimierung', 'website schneller'],
|
||
'wie kontaktiere ich den support' => ['wie kontaktiere ich den support', 'support kontakt', 'hilfe kontakt', 'support team', 'support anfragen'],
|
||
'welche plugins sind kompatibel' => ['welche plugins sind kompatibel', 'kompatibilität', 'plugin kompatibel', 'kompatible plugins', 'plugin kompatibilität'],
|
||
'wie teste ich ein plugin' => ['wie teste ich ein plugin', 'plugin testen', 'test plugin', 'plugin ausprobieren', 'plugin prüfen']
|
||
));
|
||
|
||
$normalized_question = wpmt_normalize_text($question);
|
||
$response = $responses['default'];
|
||
$matched_keywords = [];
|
||
|
||
// Wenn ein spezifisches Stichwort ausgewählt wurde
|
||
if ($selected_keyword && isset($responses[$selected_keyword])) {
|
||
$response = $responses[$selected_keyword];
|
||
} else {
|
||
// Suche nach allen passenden Stichwörtern
|
||
foreach ($keyword_synonyms as $key => $synonyms) {
|
||
if ($key === 'default') continue;
|
||
foreach ($synonyms as $synonym) {
|
||
if (strpos($normalized_question, wpmt_normalize_text($synonym)) !== false) {
|
||
$matched_keywords[] = $key;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
// Falls kein Treffer, suche nach Tippfehlern
|
||
if (empty($matched_keywords)) {
|
||
$matched_keyword = wpmt_levenshtein_match($normalized_question, $keyword_synonyms);
|
||
if ($matched_keyword && isset($responses[$matched_keyword])) {
|
||
$matched_keywords[] = $matched_keyword;
|
||
}
|
||
}
|
||
|
||
// Wenn genau ein Stichwort gefunden wurde
|
||
if (count($matched_keywords) === 1) {
|
||
$response = $responses[$matched_keywords[0]];
|
||
if ($matched_keywords[0] === $matched_keyword) {
|
||
$response = sprintf(
|
||
__('Meintest du vielleicht „%s“, %s? Hier ist die Antwort: ', 'wp-multi-toolkit'),
|
||
esc_html(str_replace('-', ' ', $matched_keywords[0])),
|
||
esc_html($user_name)
|
||
) . $response;
|
||
}
|
||
}
|
||
// Wenn mehrere Stichwörter gefunden wurden
|
||
elseif (count($matched_keywords) > 1) {
|
||
$response = sprintf(
|
||
__('Mehrere Themen passen zu deiner Frage, %s! 😊 Wähle eines aus: ', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$response .= '<div class="wpmt-keyword-suggestions">';
|
||
foreach ($matched_keywords as $key) {
|
||
$response .= sprintf(
|
||
'<a href="#" class="wpmt-keyword-suggestion" data-keyword="%s">%s</a>',
|
||
esc_attr($key),
|
||
esc_html(ucfirst(str_replace('-', ' ', $key)))
|
||
);
|
||
}
|
||
$response .= '</div>';
|
||
}
|
||
// Wenn kein Treffer, Vorschläge machen
|
||
else {
|
||
$suggestions = [];
|
||
$words = explode(' ', $normalized_question);
|
||
foreach ($words as $word) {
|
||
foreach ($keyword_synonyms as $key => $synonyms) {
|
||
foreach ($synonyms as $synonym) {
|
||
if (levenshtein($word, wpmt_normalize_text($synonym)) <= 4 && !in_array($key, $suggestions)) {
|
||
$suggestions[] = $key;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (!empty($suggestions)) {
|
||
$response .= sprintf(
|
||
__('Keine direkte Antwort gefunden, %s. 🙁 Vielleicht passen diese Themen: <strong>%s</strong>.', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
implode(', ', array_map(function($key) { return ucfirst(str_replace('-', ' ', $key)); }, $suggestions))
|
||
);
|
||
}
|
||
}
|
||
}
|
||
|
||
// Antwort mit Bewertungsoptionen
|
||
$allowed_html = array(
|
||
'a' => array('href' => true, 'class' => true, 'data-keyword' => true),
|
||
'code' => array(),
|
||
'strong' => array(),
|
||
'div' => array('class' => true),
|
||
'ul' => array(),
|
||
'li' => array()
|
||
);
|
||
$formatted_response = wp_kses($response, $allowed_html) . '<div class="wpmt-response-actions">';
|
||
$formatted_response .= '<a href="#" class="wpmt-rate-response" data-rating="helpful">' . __('Hilfreich', 'wp-multi-toolkit') . '</a>';
|
||
$formatted_response .= '<a href="#" class="wpmt-rate-response" data-rating="not_helpful">' . __('Nicht hilfreich', 'wp-multi-toolkit') . '</a>';
|
||
$formatted_response .= '</div>';
|
||
|
||
wp_send_json_success(array('response' => $formatted_response));
|
||
}
|
||
add_action('wp_ajax_wpmt_assistant_query', 'wpmt_assistant_query');
|
||
|
||
/**
|
||
* AJAX-Handler für Feedback
|
||
*/
|
||
function wpmt_assistant_feedback() {
|
||
check_ajax_referer('wpmt_assistant_nonce', 'nonce');
|
||
|
||
$message = isset($_POST['message']) ? wp_kses_post($_POST['message']) : '';
|
||
$rating = isset($_POST['rating']) ? sanitize_text_field($_POST['rating']) : '';
|
||
|
||
$feedback_log = get_option('wpmt_assistant_feedback', array());
|
||
$feedback_log[] = array(
|
||
'message' => $message,
|
||
'rating' => $rating,
|
||
'timestamp' => current_time('mysql')
|
||
);
|
||
update_option('wpmt_assistant_feedback', $feedback_log);
|
||
|
||
wp_send_json_success();
|
||
}
|
||
add_action('wp_ajax_wpmt_assistant_feedback', 'wpmt_assistant_feedback');
|
||
|
||
/**
|
||
* Registriert die Assistenten-Seite im Admin-Menü
|
||
*/
|
||
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) {
|
||
$current_user = wp_get_current_user();
|
||
$user_name = $current_user->display_name ?: __('Freund', 'wp-multi-toolkit');
|
||
|
||
// WP Multi
|
||
$responses['statistik'] = sprintf(
|
||
__('Hey %s, willst du die Statistiken deiner Website im Blick haben? 📊 Füge den Shortcode <code>[statistik_manager]</code> in einen Beitrag oder eine Seite ein, um sie anzuzeigen. Oder gehe zu <strong>WP Stat & Notice</strong>, um Details wie Beitragsanzahl, Kommentare oder Kategorien zu sehen. Tipp: Aktiviere Benachrichtigungen für wichtige Updates! Bereit, deine Daten zu checken? 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['telegram'] = sprintf(
|
||
__('Telegram-Benachrichtigungen einrichten, %s? Super einfach! 🔔 Gehe zu <strong>Notify > TG-Notify</strong>, erstelle einen Bot über BotFather und folge den Schritten, um ihn zu konfigurieren. Neue Beiträge oder Kommentare landen direkt in deinem Chat. <a href="%s" class="wpmt-action">Jetzt einrichten</a>. Tipp: Teste den Bot mit einer Probemitteilung! Alles klar? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=tg-notify')
|
||
);
|
||
$responses['discord'] = sprintf(
|
||
__('Discord-Benachrichtigungen für deine Community, %s? 😄 Gehe zu <strong>Notify > DC-Notify</strong>, erstelle einen Webhook in deinem Discord-Server und füge ihn in den Einstellungen ein. Neue Beiträge werden automatisch gepostet. <a href="%s" class="wpmt-action">Los geht’s!</a> Tipp: Nutze einen separaten Kanal für Benachrichtigungen! Bereit? 🌟', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wp-multi')
|
||
);
|
||
$responses['admin links'] = sprintf(
|
||
__('Eigene Admin-Links hinzufügen, %s? Perfekt für schnellen Zugriff! 🔧 Gehe zu <strong>Werkzeuge > Admin-Link hinzufügen</strong>, gib Namen und URL ein (z. B. für externe Tools) und speichere. Deine Links erscheinen im Admin-Menü. Tipp: Gruppiere Links für bessere Übersicht! Alles organisiert? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['gast-autor'] = sprintf(
|
||
__('Gastautoren auf deiner Seite, %s? 😊 Gehe zu <strong>Benutzer > Gastautor (Übersicht)</strong>, füge Autoren hinzu und weise ihnen Beiträge zu. Ihre Namen erscheinen automatisch im Frontend. Tipp: Füge eine kurze Bio hinzu, um sie vorzustellen! Einfach, oder? ✨', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['beitrag report'] = sprintf(
|
||
__('Probleme mit Beiträgen, %s? 🧹 Unter <strong>Gemeldete Beiträge</strong> kannst du unangemessene Inhalte prüfen, bearbeiten oder löschen. So bleibt deine Seite sauber! Brauchst du Hilfe? Erstelle ein <a href="%s" class="wpmt-action">Support-Ticket</a>. Alles unter Kontrolle? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wp_multi_support')
|
||
);
|
||
$responses['textbox'] = sprintf(
|
||
__('Eine Textbox am Beitragsende, %s? Ideal für Hinweise oder Werbung! ✨ Gehe zu <strong>WP Multi > Textbox</strong>, füge deinen Text ein und passe das Design an. Die Box erscheint automatisch unter Beiträgen. Tipp: Nutze auffällige Farben für mehr Aufmerksamkeit! Bereit? 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['banner'] = sprintf(
|
||
__('Ein schickes Banner, %s? 🎨 Gehe zu <strong>WP Stat & Notice</strong>, lade ein Bild hoch und wähle Header oder Footer. Perfekt, um Neuigkeiten zu präsentieren! Tipp: Verwende Bilder mit hohem Kontrast für bessere Sichtbarkeit. Los geht’s! 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['inhaltsverzeichnis'] = sprintf(
|
||
__('Ein Inhaltsverzeichnis für deine Beiträge, %s? 🚀 Nutze den Shortcode <code>[alphabetical_index]</code>, um alle Beiträge übersichtlich aufzulisten. Ideal für Blogs mit vielen Inhalten! Tipp: Kombiniere es mit Kategoriefiltern für mehr Struktur. Alles klar? 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['lesezeichen'] = sprintf(
|
||
__('Lesezeichen für deine Besucher, %s? 😎 Mit <code>[add_bookmark]</code> können Nutzer Beiträge speichern, und <code>[display_bookmarks]</code> zeigt ihre Liste. Alles per Cookie – keine Datenbank nötig! Tipp: Füge die Shortcodes in eine Sidebar für schnellen Zugriff! Cool, oder? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['custom shortcode'] = sprintf(
|
||
__('Eigene Shortcodes erstellen, %s? Super flexibel! 😉 Gehe zu <strong>WP Multi > Shortcodes</strong>, lege deinen Shortcode an und füge ihn im Editor ein. Ideal für wiederkehrende Inhalte! Tipp: Dokumentiere deine Shortcodes für spätere Änderungen. Bereit zum Codieren? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['kommentar sperren'] = sprintf(
|
||
__('Bestimmte Nutzer blockieren, %s? 🛡️ Gehe zu <strong>Benutzer sperren</strong>, gib Benutzername, IP oder E-Mail ein und speichere. So bleibt die Kommentarspalte sauber! Tipp: Überprüfe die Sperrliste regelmäßig, um sie aktuell zu halten. Alles sicher? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['filter'] = sprintf(
|
||
__('Kommentare filtern, %s? 😊 Gehe zu <strong>Kommentare > Kommentar Filter</strong> und verbiete URLs, Schimpfwörter oder Telefonnummern. Verstöße werden mit * ersetzt. Tipp: Teste die Filter mit einem Probekommentar, um sicherzugehen! Deine Community wird’s lieben! 🌟', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['analytics'] = sprintf(
|
||
__('Datenanalyse für deine Beiträge, %s? 📊 Unter <strong>Benutzer > Benutzer Analytics</strong> siehst du Views, Kommentare, Top-Beiträge und mehr. Perfekt, um Inhalte zu optimieren! Tipp: Exportiere die Daten für langfristige Analysen. Bereit, ein Profi zu werden? 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['pinwand'] = sprintf(
|
||
__('Nachrichten für dein Team, %s? 📌 Unter <strong>Pinnwand</strong> kannst du Notizen für Admins oder Redakteure hinterlegen. Erstelle, bearbeite oder lösche sie jederzeit. Tipp: Nutze die Pinnwand für wichtige To-Dos! Alles organisiert? 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['brute force'] = sprintf(
|
||
__('Sicherheit zuerst, %s! 🛡️ Der Brute-Force-Schutz protokolliert Fehlversuche und sperrt nach 5 Versuchen. Einstellungen findest du unter <strong>Sicherheit</strong>. Tipp: Aktiviere Benachrichtigungen, um verdächtige Aktivitäten zu überwachen! Alles sicher? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['anti spam'] = sprintf(
|
||
__('Spam loswerden, %s? 😒 Aktiviere den Anti-Spam-Schutz unter <strong>Sicherheit</strong>, um Bots zu blockieren. Spam-Kommentare werden automatisch gefiltert. Tipp: Kombiniere es mit Kommentarfiltern für doppelten Schutz! Bereit? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['auto tag'] = sprintf(
|
||
__('Automatische Tags, %s? ⏳ Gehe zu <strong>Beiträge > Automatische Tags</strong>, füge fehlende Tags hinzu oder verbiete Wörter. Spart Zeit! Tipp: Überprüfe die Tags regelmäßig, um sie an deine Inhalte anzupassen. Alles klar? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['login deaktivieren'] = sprintf(
|
||
__('Logins deaktivieren, %s? 🔒 Gehe zu <strong>Benutzer > Alle Benutzer</strong>, wähle einen Benutzer und schalte den Login ab. Ideal für temporäre Sperren. Tipp: Notiere dir, wen du deaktiviert hast! Alles unter Kontrolle? 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['text copy'] = sprintf(
|
||
__('Inhalte schützen, %s? 🛡️ Aktiviere die Rechtsklick-Sperre unter <strong>WP Multi-Einstellungen</strong>, um Texte vor Kopieren zu sichern. Perfekt für Blogs! Tipp: Füge einen Hinweis hinzu, warum Kopieren deaktiviert ist. Bereit? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['trash mail'] = sprintf(
|
||
__('Kein Bock auf Spam-Mails, %s? 😊 Wir blockieren Trash-Mails in Kommentaren automatisch. Die Liste wird vom Entwickler gepflegt – du musst nichts tun! Tipp: Aktiviere Anti-Spam für extra Schutz! Alles sauber? 🌟', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
|
||
// WP Multi Comment Notifications
|
||
$responses['kommentar benachrichtigung'] = sprintf(
|
||
__('Immer über neue Kommentare informiert, %s? 🔔 Gehe zu <strong>Kommentare > Kommentar Benachrichtigung</strong> und richte E-Mail, Telegram oder Discord ein. Tipp: Filtere Benachrichtigungen, um nur wichtige zu erhalten! Nie wieder etwas verpassen! 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
|
||
// WP Multi Kategorie
|
||
$responses['kategorien ausblenden'] = sprintf(
|
||
__('Kategorien ausblenden, %s? 🗂️ Gehe zu <strong>Beiträge > Kategorie Filter</strong> und wähle, was im Frontend nicht angezeigt werden soll. Ideal für eine saubere Seite! Tipp: Teste Änderungen in der Vorschau! Alles organisiert? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
|
||
// WP Multi Search
|
||
$responses['suchfunktion'] = sprintf(
|
||
__('Eine starke Suche, %s? 🔍 Füge WP Multi Search über Shortcode, Widget oder Menü hinzu. Einstellungen findest du unter <strong>Einstellung > WP-Multi Search</strong>. Tipp: Aktiviere Autovervollständigung für bessere Ergebnisse! Bereit, alles zu finden? 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
|
||
// WP Multi Team-Card
|
||
$responses['teamcard'] = sprintf(
|
||
__('Dein Team präsentieren, %s? 🌟 Mit WP Multi Team-Card erstellst du professionelle Teamkarten mit Namen, Funktionen und Bildern. Nutze <code>[teamcards]</code> im Frontend. <a href="%s" class="wpmt-action">Jetzt ausprobieren</a> und dein Team ins Rampenlicht stellen! 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=teamcard_management')
|
||
);
|
||
$responses['teammitglied hinzufügen'] = sprintf(
|
||
__('Ein neues Teammitglied, %s? 😄 Gehe zu <strong>Team-Cards</strong>, gib Name, Funktion, Zuständigkeit und Bild ein und klicke auf <strong>Hinzufügen</strong>. Tipp: Wähle hochauflösende Bilder für beste Darstellung! Bereit fürs Update? ✨', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['teamcard shortcode'] = sprintf(
|
||
__('Teamkarten anzeigen, %s? 🚀 Nutze <code>[teamcards]</code> für alle Mitglieder oder <code>[teamcards kategorie="slug"]</code> für eine Kategorie. Füge den Shortcode in Beiträge ein. Tipp: Teste verschiedene Layouts! Alles klar? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['teamcard kategorie'] = sprintf(
|
||
__('Kategorien für Teamkarten, %s? 🗂️ Erstelle sie unter <strong>Beiträge > Kategorien</strong> und weise sie Mitgliedern zu. Zeige sie mit <code>[teamcards kategorie="slug"]</code>. Tipp: Sortiere Teams nach Abteilungen! Alles organisiert? 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['teamcard bild'] = sprintf(
|
||
__('Ein Bild für ein Teammitglied, %s? 😊 In <strong>Team-Cards</strong> klickst du auf <strong>Bild auswählen</strong> und lädst ein Foto hoch. Es erscheint in der Teamkarte. Tipp: Nutze quadratische Bilder für einheitliches Design! Bereit? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['teamcard löschen'] = sprintf(
|
||
__('Ein Teammitglied entfernen, %s? 🗑️ Gehe zu <strong>Team-Cards</strong>, finde das Mitglied und klicke auf <strong>Löschen</strong>. Tipp: Sichere Daten vor dem Löschen! Schnell erledigt? 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['teamcard reihenfolge'] = sprintf(
|
||
__('Reihenfolge der Teamkarten ändern, %s? 😎 In <strong>Team-Cards</strong> verschiebst du Mitglieder per Drag-and-Drop. Tipp: Speichere nach dem Sortieren, um Änderungen zu sichern! Alles sortiert? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['teamcard deinstallation'] = sprintf(
|
||
__('Team-Card deinstallieren, %s? ⚠️ Achtung: Alle Teammitglieder und Bilder werden gelöscht. Sichere Daten mit einem Backup! Mehr Infos: <a href="%s" class="wpmt-action">Mehr Infos</a>. Alles klar? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
'https://git.viper.ipv64.net/M_Viper/wp-multi-teamcard'
|
||
);
|
||
$responses['teamcard updates'] = sprintf(
|
||
__('Updates für Team-Card, %s? 🚀 Schau auf <a href="%s" class="wpmt-action">git.viper.ipv64.net</a> für die neueste Version. Updates werden auch im Admin-Bereich angezeigt. Tipp: Lies die Changelogs für neue Features! Bleib up to date! 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
'https://git.viper.ipv64.net/M_Viper/wp-multi-teamcard'
|
||
);
|
||
|
||
// WP Multi Toolkit
|
||
$responses['update management'] = sprintf(
|
||
__('Updates im Griff, %s? 🌟 Im Dashboard-Widget <strong>Verfügbare Updates für WP Multi Toolkit</strong> siehst du den Status aller Plugins. Lade neue Versionen herunter und installiere sie. <a href="%s" class="wpmt-action">Jetzt prüfen</a>. Tipp: Sichere deine Seite vor Updates! Bereit? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('index.php')
|
||
);
|
||
$responses['support issues'] = sprintf(
|
||
__('Hilfe nötig, %s? 😊 Erstelle ein Support-Ticket unter <strong>WP-Multi Support</strong>. Beschreibe dein Problem genau, und wir melden uns schnell! <a href="%s" class="wpmt-action">Ticket erstellen</a>. Tipp: Screenshots helfen uns, schneller zu reagieren! Bereit? 🌟', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wp_multi_support')
|
||
);
|
||
$responses['dokumentation'] = sprintf(
|
||
__('Alles über WP Multi erfahren, %s? 📚 Die Dokumentation findest du unter <strong>WP-Multi Support > Dokumentation</strong>. Dort gibt’s Anleitungen und FAQs. <a href="%s" class="wpmt-action">Dokumentation ansehen</a>. Tipp: Nutze die Suche in der Doku! Bereit? 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs')
|
||
);
|
||
$responses['virtueller assistent'] = sprintf(
|
||
__('Das bin ich, %s! 😄 Dein virtueller Assistent für alle WP Multi Fragen. Stelle mir deine Fragen unter <strong>WP-Multi Support > Virtueller Assistent</strong>. Tipp: Frag nach spezifischen Features, ich kenne sie alle! Wie kann ich dir helfen? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['toolbar'] = sprintf(
|
||
__('Die Schnellstart-Toolbar, %s? 🚀 Unten rechts findest du Support, Updates, Dokumentation und mich – alles in einem Klick! Tipp: Halte die Toolbar aktiviert für schnellen Zugriff! Praktisch, oder? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['wp multi plugins'] = sprintf(
|
||
__('Neugierig auf WP Multi Plugins, %s? 🌟 Hier die Übersicht:<ul><li><strong>WP Multi Toolkit</strong>: Zentrale für alle Plugins.</li><li><strong>WP Multi</strong>: Viele Funktionen.</li><li><strong>WP Multi Comment Notifications</strong>: Kommentar-Benachrichtigungen.</li><li><strong>WP Multi Search</strong>: Smarte Suche.</li><li><strong>WP Multi Kategorie</strong>: Kategoriefilter.</li><li><strong>WP Multi Team-Cards</strong>: Teamkarten.</li></ul>Mehr in der <a href="%s" class="wpmt-action">Dokumentation</a>! 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs')
|
||
);
|
||
|
||
// Allgemeine Fragen und Antworten
|
||
$responses['was sind wp multi plugins'] = sprintf(
|
||
__('WP Multi Plugins, %s? 🚀 Eine Sammlung cooler Tools für deine Website! Von Statistiken über Sicherheit bis Benachrichtigungen – alles dabei. Schau unter <strong>wp multi plugins</strong> oder auf <a href="%s" class="wpmt-action">git.viper.ipv64.net</a>. Bereit, deine Seite zu boosten? 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
'https://git.viper.ipv64.net/M_Viper'
|
||
);
|
||
$responses['wie installiere ich ein plugin'] = sprintf(
|
||
__('Ein Plugin installieren, %s? 😊 Gehe zu <strong>Plugins > Neu hinzufügen</strong>, lade die Datei von <a href="%s" class="wpmt-action">git.viper.ipv64.net</a> hoch und aktiviere es. Oder per FTP in <code>/wp-content/plugins/</code>. Tipp: Lies die Doku für Details! Los geht’s! 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
'https://git.viper.ipv64.net/M_Viper'
|
||
);
|
||
$responses['wo finde ich updates'] = sprintf(
|
||
__('Updates, %s? 🌟 Im Dashboard-Widget <strong>Verfügbare Updates für WP Multi Toolkit</strong> oder auf <a href="%s" class="wpmt-action">git.viper.ipv64.net</a>. Lade die neue Version hoch! Tipp: Sichere deine Seite vor Updates! Bleib frisch! 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
'https://git.viper.ipv64.net/M_Viper'
|
||
);
|
||
$responses['wie erstelle ich ein support ticket'] = sprintf(
|
||
__('Ein Support-Ticket, %s? 😊 Gehe zu <strong>WP-Multi Support</strong>, wähle das Plugin, gib Titel und Beschreibung ein und sende es ab. <a href="%s" class="wpmt-action">Jetzt erstellen</a>. Tipp: Füge Screenshots hinzu! Wir helfen schnell! 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wp_multi_support')
|
||
);
|
||
$responses['welche voraussetzungen gibt es'] = sprintf(
|
||
__('Voraussetzungen, %s? 📋 Mindestens WordPress 6.7.2 und PHP 7.4. Für Telegram/Discord brauchst du API-Keys. Details in der <a href="%s" class="wpmt-action">Dokumentation</a>. Tipp: Prüfe deine Server-Einstellungen! Bereit? 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs')
|
||
);
|
||
$responses['sind die plugins kostenlos'] = sprintf(
|
||
__('Kostenlos, %s? 😄 Ja, alle WP Multi Plugins sind gratis auf <a href="%s" class="wpmt-action">git.viper.ipv64.net</a>! Tipp: Spende dem Entwickler einen Kaffee, wenn sie dir gefallen! Bereit? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
'https://git.viper.ipv64.net/M_Viper'
|
||
);
|
||
$responses['wie deaktiviere ich ein plugin'] = sprintf(
|
||
__('Plugin deaktivieren, %s? 😎 Gehe zu <strong>Plugins > Installierte Plugins</strong>, klicke auf <strong>Deaktivieren</strong> oder <strong>Löschen</strong>. Tipp: Deaktiviere vor Updates, um Konflikte zu vermeiden! Alles klar? 🌟', 'wp-multi-toolkit'),
|
||
esc_html($user_name)
|
||
);
|
||
$responses['wo finde ich die dokumentation'] = sprintf(
|
||
__('Dokumentation, %s? 📚 Unter <strong>WP-Multi Support > Dokumentation</strong> findest du Anleitungen und FAQs. <a href="%s" class="wpmt-action">Jetzt ansehen</a>. Tipp: Nutze die Suche in der Doku! Bereit? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs')
|
||
);
|
||
$responses['wer entwickelt die plugins'] = sprintf(
|
||
__('Wer entwickelt sie, %s? 😊 M_Viper, ein WordPress-Fan! Besuche <a href="%s" class="wpmt-action">m-viper.de</a> oder <a href="%s" class="wpmt-action">git.viper.ipv64.net</a>. Tipp: Folge M_Viper für News! Cool, oder? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
'https://m-viper.de',
|
||
'https://git.viper.ipv64.net/M_Viper'
|
||
);
|
||
$responses['kann ich eigene funktionen hinzufügen'] = sprintf(
|
||
__('Eigene Funktionen, %s? 🌟 Die Plugins sind Open Source! Schau den Code auf <a href="%s" class="wpmt-action">git.viper.ipv64.net</a> an. Ideen? Erstelle ein Ticket mit <strong>Verbesserung</strong>! Tipp: Teste in einer Staging-Umgebung! Bereit? 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
'https://git.viper.ipv64.net/M_Viper'
|
||
);
|
||
|
||
// Neue allgemeine Antworten
|
||
$responses['wie richte ich wp multi ein'] = sprintf(
|
||
__('WP Multi einrichten, %s? 🚀 Nach der Installation gehe zu <strong>WP-Multi Support</strong> und aktiviere die Plugins. Folge der Anleitung in der <a href="%s" class="wpmt-action">Dokumentation</a>. Tipp: Prüfe, ob deine WordPress-Version aktuell ist! Bereit? 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs')
|
||
);
|
||
$responses['was ist wordpress'] = sprintf(
|
||
__('WordPress, %s? 📝 Ein kostenloses CMS für Websites, Blogs oder Shops – ohne Programmierkenntnisse! WP Multi Plugins machen es noch besser. Mehr in der <a href="%s" class="wpmt-action">Dokumentation</a>. Neugierig? 😊', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs')
|
||
);
|
||
$responses['wie sichere ich meine website'] = sprintf(
|
||
__('Website sichern, %s? 🛡️ Nutze WP Multi Features wie Brute-Force-Schutz und Anti-Spam unter <strong>Sicherheit</strong>. Erstelle Backups (z. B. mit UpdraftPlus) und aktiviere die Rechtsklick-Sperre. Mehr in der <a href="%s" class="wpmt-action">Dokumentation</a>. Alles sicher? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs')
|
||
);
|
||
$responses['wie verbessere ich die performance'] = sprintf(
|
||
__('Performance boosten, %s? ⚡ Nutze WP Multi Search für schnelle Suchen und Caching-Plugins wie WP Super Cache. Optimiere Bilder und prüfe Ladezeiten unter <strong>Benutzer > Benutzer Analytics</strong>. Mehr in der <a href="%s" class="wpmt-action">Dokumentation</a>. Bereit für Speed? 😎', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs')
|
||
);
|
||
$responses['wie kontaktiere ich den support'] = sprintf(
|
||
__('Support kontaktieren, %s? 😊 Erstelle ein Ticket unter <strong>WP-Multi Support</strong> (<a href="%s" class="wpmt-action">Ticket erstellen</a>) oder besuche <a href="%s" class="wpmt-action">m-viper.de</a>. Tipp: Beschreibe dein Problem genau! Bereit? 🌟', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wp_multi_support'),
|
||
'https://m-viper.de'
|
||
);
|
||
$responses['welche plugins sind kompatibel'] = sprintf(
|
||
__('Kompatible Plugins, %s? 🌟 WP Multi Plugins passen zu den meisten WordPress-Plugins, wenn sie die Standards einhalten. Teste in einer Staging-Umgebung. Probleme? Schau in die <a href="%s" class="wpmt-action">Dokumentation</a> oder erstelle ein <a href="%s" class="wpmt-action">Support-Ticket</a>! Alles klar? 😄', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs'),
|
||
admin_url('admin.php?page=wp_multi_support')
|
||
);
|
||
$responses['wie teste ich ein plugin'] = sprintf(
|
||
__('Plugin testen, %s? 😊 Installiere es in einer Staging-Umgebung oder lokal. Aktiviere es, teste Funktionen und prüfe Kompatibilität. Probleme? Schau in die <a href="%s" class="wpmt-action">Dokumentation</a> oder kontaktiere den <a href="%s" class="wpmt-action">Support</a>. Tipp: Deaktiviere andere Plugins, um Konflikte zu finden! Bereit? 🚀', 'wp-multi-toolkit'),
|
||
esc_html($user_name),
|
||
admin_url('admin.php?page=wpmt_docs'),
|
||
admin_url('admin.php?page=wp_multi_support')
|
||
);
|
||
|
||
return $responses;
|
||
});
|
||
|
||
/**
|
||
* Sicherstellen, dass jQuery geladen wird
|
||
*/
|
||
function wpmt_enqueue_scripts() {
|
||
wp_enqueue_script('jquery');
|
||
}
|
||
add_action('admin_enqueue_scripts', 'wpmt_enqueue_scripts');
|
||
|
||
|
||
/*
|
||
* 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',
|
||
'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'
|
||
),
|
||
'wp-multi-teamcard' => array(
|
||
'file' => 'wp-multi-teamcards/wp-multi-team-card.php',
|
||
'name' => 'WP Multi Team-Card',
|
||
'repo' => 'wp-multi-teamcard'
|
||
)
|
||
);
|
||
|
||
$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));
|
||
$ip = '';
|
||
|
||
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 $potential_ip) {
|
||
$potential_ip = trim($potential_ip);
|
||
if (filter_var($potential_ip, FILTER_VALIDATE_IP)) {
|
||
return $potential_ip;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} elseif (!empty($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP)) {
|
||
$ip = explode(',', $_SERVER['REMOTE_ADDR'])[0];
|
||
return $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);
|
||
}
|
||
}
|
||
}
|