Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
242f979b18 |
@ -3,11 +3,12 @@
|
||||
* 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.8
|
||||
* 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
|
||||
@ -104,9 +105,11 @@ defined('ABSPATH') or die('No direct access allowed.');
|
||||
* 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>';
|
||||
@ -114,7 +117,7 @@ defined('ABSPATH') or die('No direct access allowed.');
|
||||
echo '<div class="error"><p>' . __('Backup-Datei nicht gefunden.', 'wp-multi-toolkit') . '</p></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plant automatische Backups via Cron-Job.
|
||||
@ -643,67 +646,89 @@ function wpmt_cookie_banner_settings_page() {
|
||||
|
||||
// DSGVO-konforme Cookie Banner Darstellung
|
||||
function wpmt_cookie_banner() {
|
||||
// Überprüfen, ob der Cookie-Banner aktiv ist
|
||||
$enabled = get_option('wpmt_enable_cookie_banner', '1');
|
||||
if ($enabled !== '1') {
|
||||
if (get_option('wpmt_enable_cookie_banner', '1') !== '1' || isset($_COOKIE['wpmt_cookie_accepted'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Überprüfen, ob der Benutzer schon zugestimmt hat
|
||||
if( isset($_COOKIE['wpmt_cookie_accepted']) ) {
|
||||
return; // Banner wird nicht angezeigt, wenn der Nutzer zugestimmt hat
|
||||
}
|
||||
|
||||
// Banner-Inhalte aus den Optionen
|
||||
$banner_text = get_option('wpmt_cookie_banner_text', __('Wir verwenden Cookies, um Ihnen das beste Erlebnis zu bieten.', 'wp-multi-toolkit'));
|
||||
$accept_text = get_option('wpmt_cookie_accept_text', __('Akzeptieren', 'wp-multi-toolkit'));
|
||||
$decline_text = get_option('wpmt_cookie_decline_text', __('Ablehnen', 'wp-multi-toolkit'));
|
||||
$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
|
||||
$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
|
||||
$banner_style = 'position:fixed; bottom:0; left:0; width:100%; background:' . esc_attr($banner_background_color) . '; padding:10px; text-align:center; z-index:1000;';
|
||||
?>
|
||||
<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.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';
|
||||
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();
|
||||
xhr.open('POST', '<?php echo admin_url('admin-ajax.php'); ?>', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
xhr.send('action=wpmt_save_cookie_consent&cookie_accepted=true');
|
||||
});
|
||||
|
||||
document.getElementById('decline-cookies').addEventListener('click', function() {
|
||||
document.getElementById('cookie-banner').style.display = 'none';
|
||||
});
|
||||
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;
|
||||
|
||||
// Speichern der Zustimmung in der Datenbank
|
||||
$wpdb->insert(
|
||||
$wpdb->prefix . 'wpmt_cookie_consent',
|
||||
array(
|
||||
'user_ip' => $_SERVER['REMOTE_ADDR'],
|
||||
'user_ip' => anonymize_ip($_SERVER['REMOTE_ADDR']),
|
||||
'consent_given' => 1,
|
||||
'timestamp' => current_time('mysql')
|
||||
)
|
||||
@ -998,7 +1023,6 @@ add_action('admin_menu', 'add_support_ticket_page');
|
||||
/*
|
||||
* Virtueller Assistent als Submenü
|
||||
*/
|
||||
|
||||
defined('ABSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
@ -1029,7 +1053,7 @@ function wpmt_virtual_assistant_page() {
|
||||
}, $keywords));
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<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">
|
||||
@ -1064,13 +1088,13 @@ function wpmt_virtual_assistant_page() {
|
||||
$('#assistant-chat-messages').empty();
|
||||
if (chatHistory.length === 0) {
|
||||
$('#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 {
|
||||
chatHistory.forEach(function(item) {
|
||||
$('#assistant-chat-messages').append(
|
||||
'<div class="wpmt-message user">' + item.question + '</div>' +
|
||||
'<div class="wpmt-message assistant">' + item.response + '</div>'
|
||||
'<div class="wpmt-message user animate-slide-in-right">' + item.question + '</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
|
||||
$('#assistant-chat-messages').append(
|
||||
'<div class="wpmt-message user">' + question + '</div>' +
|
||||
'<div class="wpmt-message assistant wpmt-typing"><?php _e('Ich tippe gerade...', 'wp-multi-toolkit'); ?></div>'
|
||||
'<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();
|
||||
|
||||
@ -1111,7 +1135,7 @@ function wpmt_virtual_assistant_page() {
|
||||
$('.wpmt-typing').remove();
|
||||
if (response.success) {
|
||||
$('#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({
|
||||
question: question,
|
||||
@ -1122,7 +1146,7 @@ function wpmt_virtual_assistant_page() {
|
||||
lastQuestion = question;
|
||||
} else {
|
||||
$('#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();
|
||||
@ -1130,7 +1154,7 @@ function wpmt_virtual_assistant_page() {
|
||||
error: function() {
|
||||
$('.wpmt-typing').remove();
|
||||
$('#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();
|
||||
}
|
||||
@ -1242,6 +1266,7 @@ function wpmt_virtual_assistant_page() {
|
||||
max-width: 80%;
|
||||
line-height: 1.5;
|
||||
word-wrap: break-word;
|
||||
opacity: 0; /* Für Animation */
|
||||
}
|
||||
.wpmt-message.user {
|
||||
background: #0073aa;
|
||||
@ -1329,6 +1354,42 @@ function wpmt_virtual_assistant_page() {
|
||||
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
|
||||
}
|
||||
@ -1579,10 +1640,10 @@ function wpmt_add_assistant_page() {
|
||||
}
|
||||
add_action('admin_menu', 'wpmt_add_assistant_page');
|
||||
|
||||
/**
|
||||
/**
|
||||
* Antworten vordefinieren
|
||||
*/
|
||||
add_filter('wpmt_assistant_responses', function($responses) {
|
||||
add_filter('wpmt_assistant_responses', function($responses) {
|
||||
$current_user = wp_get_current_user();
|
||||
$user_name = $current_user->display_name ?: __('Freund', 'wp-multi-toolkit');
|
||||
|
||||
@ -1857,15 +1918,15 @@ add_filter('wpmt_assistant_responses', function($responses) {
|
||||
);
|
||||
|
||||
return $responses;
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sicherstellen, dass jQuery geladen wird
|
||||
*/
|
||||
function wpmt_enqueue_scripts() {
|
||||
function wpmt_enqueue_scripts() {
|
||||
wp_enqueue_script('jquery');
|
||||
}
|
||||
add_action('admin_enqueue_scripts', 'wpmt_enqueue_scripts');
|
||||
}
|
||||
add_action('admin_enqueue_scripts', 'wpmt_enqueue_scripts');
|
||||
|
||||
|
||||
/*
|
||||
@ -1902,11 +1963,11 @@ add_action('admin_enqueue_scripts', 'wpmt_enqueue_scripts');
|
||||
add_action('admin_footer', 'wpmt_add_floating_toolbar');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Update Funktion
|
||||
*/
|
||||
|
||||
|
||||
define('WPMT_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||
|
||||
// Textdomain laden
|
||||
@ -2298,6 +2359,11 @@ function wpmt_update_dashboard_widget_content() {
|
||||
'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'
|
||||
)
|
||||
);
|
||||
|
||||
@ -2514,24 +2580,22 @@ function wp_multi_toolkit_setup_menu() {
|
||||
### 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 $ip) {
|
||||
$ip = trim($ip);
|
||||
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
|
||||
return esc_attr($ip);
|
||||
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'])) {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
if (strpos($ip, ',') !== false) {
|
||||
$ip = explode(',', $ip)[0];
|
||||
}
|
||||
return esc_attr($ip);
|
||||
} elseif (!empty($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP)) {
|
||||
$ip = explode(',', $_SERVER['REMOTE_ADDR'])[0];
|
||||
return $ip;
|
||||
}
|
||||
|
||||
return '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user