Compare commits

..

1 Commits
1.0.8 ... main

Author SHA1 Message Date
242f979b18 wp-multi-toolkit.php aktualisiert 2025-05-06 05:55:27 +00:00

View File

@ -3,11 +3,12 @@
* Plugin Name: WP Multi Toolkit * Plugin Name: WP Multi Toolkit
* Plugin URI: https://git.viper.ipv64.net/M_Viper/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. * Description: Ein umfassendes Toolkit inklusive WP Multi Funktionen und Update-Management für zugehörige Plugins.
* Version: 1.0.8 * Version: 1.0.9
* Author: M_Viper * Author: M_Viper
* Author URI: https://m-viper.de * Author URI: https://m-viper.de
* Requires at least: 6.7.2 * Requires at least: 6.7.2
* Tested up to: 6.7.2 * Tested up to: 6.7.2
* Requires PHP: 7.4
* License: GPL2 * License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html * License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-multi-toolkit * Text Domain: wp-multi-toolkit
@ -104,9 +105,11 @@ defined('ABSPATH') or die('No direct access allowed.');
* Löscht ein Backup aus dem Backup-Verzeichnis. * Löscht ein Backup aus dem Backup-Verzeichnis.
*/ */
function wpmt_delete_backup() { 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')) { 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']); $backup_file = WPMT_BACKUP_DIR . sanitize_file_name($_POST['backup_file']);
if (file_exists($backup_file)) { if (file_exists($backup_file)) {
unlink($backup_file); unlink($backup_file);
echo '<div class="updated"><p>' . __('Backup erfolgreich gelöscht!', 'wp-multi-toolkit') . '</p></div>'; echo '<div class="updated"><p>' . __('Backup erfolgreich gelöscht!', 'wp-multi-toolkit') . '</p></div>';
@ -643,67 +646,89 @@ function wpmt_cookie_banner_settings_page() {
// DSGVO-konforme Cookie Banner Darstellung // DSGVO-konforme Cookie Banner Darstellung
function wpmt_cookie_banner() { function wpmt_cookie_banner() {
// Überprüfen, ob der Cookie-Banner aktiv ist if (get_option('wpmt_enable_cookie_banner', '1') !== '1' || isset($_COOKIE['wpmt_cookie_accepted'])) {
$enabled = get_option('wpmt_enable_cookie_banner', '1');
if ($enabled !== '1') {
return; return;
} }
// Überprüfen, ob der Benutzer schon zugestimmt hat
if( isset($_COOKIE['wpmt_cookie_accepted']) ) {
return; // Banner wird nicht angezeigt, wenn der Nutzer zugestimmt hat
}
// Banner-Inhalte aus den Optionen
$banner_text = get_option('wpmt_cookie_banner_text', __('Wir verwenden Cookies, um Ihnen das beste Erlebnis zu bieten.', 'wp-multi-toolkit')); $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')); $accept_text = get_option('wpmt_cookie_accept_text', __('Akzeptieren', 'wp-multi-toolkit'));
$decline_text = get_option('wpmt_cookie_decline_text', __('Ablehnen', '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', ''); $policy_url = get_option('wpmt_cookie_policy_url', '');
$impressum_url = get_option('wpmt_cookie_impressum_url', ''); $impressum_url = get_option('wpmt_cookie_impressum_url', '');
$banner_background_color = get_option('wpmt_cookie_banner_background_color', '#f0f0f0'); $banner_background_color = get_option('wpmt_cookie_banner_background_color', '#f0f0f0');
// Banner Style
$banner_style = 'position:fixed; bottom:0; left:0; width:100%; background:' . esc_attr($banner_background_color) . '; padding:10px; text-align:center; z-index:1000;'; $banner_style = 'position:fixed; bottom:0; left:0; width:100%; background:' . esc_attr($banner_background_color) . '; padding:10px; text-align:center; z-index:1000;';
// HTML für den Cookie-Banner
echo '<div style="' . $banner_style . '" id="cookie-banner">';
echo '<p>' . esc_html($banner_text) . ' <a href="' . esc_url($policy_url) . '">' . __('Mehr erfahren', 'wp-multi-toolkit') . '</a> | <a href="' . esc_url($impressum_url) . '">' . __('Impressum', 'wp-multi-toolkit') . '</a></p>';
echo '<button id="accept-cookies" class="button">' . esc_html($accept_text) . '</button>';
echo '<button id="decline-cookies" class="button">' . esc_html($decline_text) . '</button>';
echo '</div>';
// JavaScript zum Setzen des Cookies nach Zustimmung
?> ?>
<script type="text/javascript"> <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.getElementById('accept-cookies').addEventListener('click', function() {
document.cookie = "wpmt_cookie_accepted=true; path=/; max-age=" + (60 * 60 * 24 * 365); // 1 Jahr gültig document.cookie = "wpmt_cookie_accepted=true; path=/; max-age=" + (60 * 60 * 24 * 365);
document.getElementById('cookie-banner').style.display = 'none'; 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);
});
// Speichern der Zustimmung in der Datenbank function saveConsent(settings) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('POST', '<?php echo admin_url('admin-ajax.php'); ?>', true); xhr.open('POST', '<?php echo admin_url('admin-ajax.php'); ?>', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send('action=wpmt_save_cookie_consent&cookie_accepted=true'); xhr.send('action=wpmt_save_cookie_consent&cookie_accepted=' + encodeURIComponent(JSON.stringify(settings)));
}); }
document.getElementById('decline-cookies').addEventListener('click', function() {
document.getElementById('cookie-banner').style.display = 'none';
});
</script> </script>
<?php <?php
} }
add_action('wp_footer', 'wpmt_cookie_banner'); add_action('wp_footer', 'wpmt_cookie_banner');
// AJAX-Aktion für das Speichern der Zustimmung // 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() { function wpmt_save_cookie_consent() {
if (isset($_POST['cookie_accepted']) && $_POST['cookie_accepted'] === 'true') { if (isset($_POST['cookie_accepted']) && $_POST['cookie_accepted'] === 'true') {
global $wpdb; global $wpdb;
// Speichern der Zustimmung in der Datenbank
$wpdb->insert( $wpdb->insert(
$wpdb->prefix . 'wpmt_cookie_consent', $wpdb->prefix . 'wpmt_cookie_consent',
array( array(
'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_ip' => anonymize_ip($_SERVER['REMOTE_ADDR']),
'consent_given' => 1, 'consent_given' => 1,
'timestamp' => current_time('mysql') 'timestamp' => current_time('mysql')
) )
@ -998,7 +1023,6 @@ add_action('admin_menu', 'add_support_ticket_page');
/* /*
* Virtueller Assistent als Submenü * Virtueller Assistent als Submenü
*/ */
defined('ABSPATH') or die('No direct access allowed.'); defined('ABSPATH') or die('No direct access allowed.');
/** /**
@ -1029,7 +1053,7 @@ function wpmt_virtual_assistant_page() {
}, $keywords)); }, $keywords));
?> ?>
<div class="wrap"> <div class="wrap animate-fade-in">
<h1><?php _e('WP Multi Virtueller Assistent', 'wp-multi-toolkit'); ?></h1> <h1><?php _e('WP Multi Virtueller Assistent', 'wp-multi-toolkit'); ?></h1>
<div class="wpmt-assistant-container"> <div class="wpmt-assistant-container">
<div class="wpmt-assistant-header"> <div class="wpmt-assistant-header">
@ -1064,13 +1088,13 @@ function wpmt_virtual_assistant_page() {
$('#assistant-chat-messages').empty(); $('#assistant-chat-messages').empty();
if (chatHistory.length === 0) { if (chatHistory.length === 0) {
$('#assistant-chat-messages').append( $('#assistant-chat-messages').append(
'<div class="wpmt-message assistant"><?php printf(__('Hi %s! Stell mir einfach eine Frage, und ich lege los! 🚀', 'wp-multi-toolkit'), esc_js($user_name)); ?></div>' '<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 { } else {
chatHistory.forEach(function(item) { chatHistory.forEach(function(item) {
$('#assistant-chat-messages').append( $('#assistant-chat-messages').append(
'<div class="wpmt-message user">' + item.question + '</div>' + '<div class="wpmt-message user animate-slide-in-right">' + item.question + '</div>' +
'<div class="wpmt-message assistant">' + item.response + '</div>' '<div class="wpmt-message assistant animate-slide-in-left">' + item.response + '</div>'
); );
}); });
} }
@ -1092,8 +1116,8 @@ function wpmt_virtual_assistant_page() {
// Füge die Frage und den "Tippen"-Hinweis hinzu // Füge die Frage und den "Tippen"-Hinweis hinzu
$('#assistant-chat-messages').append( $('#assistant-chat-messages').append(
'<div class="wpmt-message user">' + question + '</div>' + '<div class="wpmt-message user animate-slide-in-right">' + question + '</div>' +
'<div class="wpmt-message assistant wpmt-typing"><?php _e('Ich tippe gerade...', 'wp-multi-toolkit'); ?></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(); scrollToBottom();
@ -1111,7 +1135,7 @@ function wpmt_virtual_assistant_page() {
$('.wpmt-typing').remove(); $('.wpmt-typing').remove();
if (response.success) { if (response.success) {
$('#assistant-chat-messages').append( $('#assistant-chat-messages').append(
'<div class="wpmt-message assistant">' + response.data.response + '</div>' '<div class="wpmt-message assistant animate-slide-in-left">' + response.data.response + '</div>'
); );
chatHistory.push({ chatHistory.push({
question: question, question: question,
@ -1122,7 +1146,7 @@ function wpmt_virtual_assistant_page() {
lastQuestion = question; lastQuestion = question;
} else { } else {
$('#assistant-chat-messages').append( $('#assistant-chat-messages').append(
'<div class="wpmt-message assistant"><?php _e('Ups, etwas ist schiefgelaufen. Versuche es nochmal! 😓', 'wp-multi-toolkit'); ?></div>' '<div class="wpmt-message assistant animate-slide-in-left"><?php _e('Ups, etwas ist schiefgelaufen. Versuche es nochmal! 😓', 'wp-multi-toolkit'); ?></div>'
); );
} }
scrollToBottom(); scrollToBottom();
@ -1130,7 +1154,7 @@ function wpmt_virtual_assistant_page() {
error: function() { error: function() {
$('.wpmt-typing').remove(); $('.wpmt-typing').remove();
$('#assistant-chat-messages').append( $('#assistant-chat-messages').append(
'<div class="wpmt-message assistant"><?php _e('Oh nein, meine Verbindung ist abgebrochen! 😵 Überprüfe deine Internetverbindung und versuche es erneut.', 'wp-multi-toolkit'); ?></div>' '<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(); scrollToBottom();
} }
@ -1242,6 +1266,7 @@ function wpmt_virtual_assistant_page() {
max-width: 80%; max-width: 80%;
line-height: 1.5; line-height: 1.5;
word-wrap: break-word; word-wrap: break-word;
opacity: 0; /* Für Animation */
} }
.wpmt-message.user { .wpmt-message.user {
background: #0073aa; background: #0073aa;
@ -1329,6 +1354,42 @@ function wpmt_virtual_assistant_page() {
max-width: 90%; 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> </style>
<?php <?php
} }
@ -1902,11 +1963,11 @@ add_action('admin_enqueue_scripts', 'wpmt_enqueue_scripts');
add_action('admin_footer', 'wpmt_add_floating_toolbar'); add_action('admin_footer', 'wpmt_add_floating_toolbar');
/* /*
* Update Funktion * Update Funktion
*/ */
define('WPMT_PLUGIN_DIR', plugin_dir_path(__FILE__)); define('WPMT_PLUGIN_DIR', plugin_dir_path(__FILE__));
// Textdomain laden // Textdomain laden
@ -2298,6 +2359,11 @@ function wpmt_update_dashboard_widget_content() {
'file' => 'wp-multi-kategorie/wp-multi-kategorie.php', 'file' => 'wp-multi-kategorie/wp-multi-kategorie.php',
'name' => 'WP Multi Kategorie', 'name' => 'WP Multi Kategorie',
'repo' => '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'
) )
); );
@ -2514,24 +2580,22 @@ function wp_multi_toolkit_setup_menu() {
### Function: Get IP Address ### Function: Get IP Address
function wp_multi_ban_get_ip() { function wp_multi_ban_get_ip() {
$banned_options = get_option('wp_multi_ban_options', array('reverse_proxy' => 0)); $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) { 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) { 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])) { if (!empty($_SERVER[$key])) {
foreach (explode(',', $_SERVER[$key]) as $ip) { foreach (explode(',', $_SERVER[$key]) as $potential_ip) {
$ip = trim($ip); $potential_ip = trim($potential_ip);
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { if (filter_var($potential_ip, FILTER_VALIDATE_IP)) {
return esc_attr($ip); return $potential_ip;
} }
} }
} }
} }
} elseif (!empty($_SERVER['REMOTE_ADDR'])) { } elseif (!empty($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP)) {
$ip = $_SERVER['REMOTE_ADDR']; $ip = explode(',', $_SERVER['REMOTE_ADDR'])[0];
if (strpos($ip, ',') !== false) { return $ip;
$ip = explode(',', $ip)[0];
}
return esc_attr($ip);
} }
return ''; return '';