109 lines
4.7 KiB
PHP
109 lines
4.7 KiB
PHP
<?php
|
||
/**
|
||
* WP Multi – Modul: Admin-Panel-Banner & Plugin-Links
|
||
*
|
||
* Automatisch aus wp-multi.php ausgelagert. Wird über den Loader in
|
||
* wp-multi.php eingebunden (nur wenn das WP Multi Toolkit aktiv ist).
|
||
*/
|
||
|
||
if (!defined('ABSPATH')) { exit; }
|
||
|
||
/*
|
||
* Admin - Panel Banner
|
||
*/
|
||
|
||
|
||
// Anzahl Tage, die das Banner nach dem Schließen ausgeblendet bleibt
|
||
if (!defined('WP_MULTI_BANNER_DAYS')) {
|
||
define('WP_MULTI_BANNER_DAYS', 7);
|
||
}
|
||
|
||
// Prüft, ob das Banner für den aktuellen Benutzer noch ausgeblendet ist
|
||
function wp_multi_banner_is_dismissed() {
|
||
$ts = (int) get_user_meta(get_current_user_id(), 'wp_multi_banner_dismissed', true);
|
||
return $ts > 0 && (time() - $ts) < (WP_MULTI_BANNER_DAYS * DAY_IN_SECONDS);
|
||
}
|
||
|
||
// Admin-Banner als Notice mit Blauem Hintergrund (#0073aa)
|
||
function wp_multi_add_warning_banner() {
|
||
// Nach dem Schließen für WP_MULTI_BANNER_DAYS Tage nicht mehr anzeigen
|
||
if (wp_multi_banner_is_dismissed()) {
|
||
return;
|
||
}
|
||
|
||
// Verwende printf für bessere Lesbarkeit und Übersetzbarkeit
|
||
printf(
|
||
'<div class="notice notice-warning is-dismissible wp-multi-feedback-notice" data-wpm-nonce="%s" style="background-color: #0073aa; color: white; border-left: 4px solid #005177;">
|
||
<p><strong>%s</strong> %s <a href="%s" target="_blank" style="color: #FFDD00; text-decoration: none;">%s</a> %s</p>
|
||
<p><strong>%s:</strong> %s <a href="%s" target="_blank" style="color: #FFDD00; text-decoration: none;">%s</a> %s <a href="%s" target="_blank" style="color: #FFDD00; text-decoration: none;">%s</a> %s</p>
|
||
</div>',
|
||
esc_attr(wp_create_nonce('wp_multi_dismiss_banner')),
|
||
esc_html__('Danke, dass du WP Multi verwendest!', 'wp-multi'),
|
||
esc_html__('Dein Feedback hilft uns, das Plugin ständig zu verbessern. Wenn du Fehler entdeckst oder Verbesserungsvorschläge hast, besuche bitte unsere', 'wp-multi'),
|
||
'https://git.viper.ipv64.net/M_Viper/wp-multi',
|
||
esc_html__('Gitea-Seite', 'wp-multi'),
|
||
esc_html__('und teile uns deine Ideen mit!', 'wp-multi'),
|
||
esc_html__('Support', 'wp-multi'),
|
||
esc_html__('Bei Fragen oder Supportanfragen kannst du uns über', 'wp-multi'),
|
||
'https://discord.com/invite/FdRs4BRd8D',
|
||
esc_html__('Discord', 'wp-multi'),
|
||
esc_html__('oder', 'wp-multi'),
|
||
'https://t.me/M_Viper04',
|
||
esc_html__('Telegram', 'wp-multi'),
|
||
esc_html__('erreichen.', 'wp-multi')
|
||
);
|
||
|
||
// Beim Klick auf das X den Schließ-Zeitpunkt speichern (per AJAX)
|
||
?>
|
||
<script>
|
||
(function () {
|
||
var notice = document.querySelector('.wp-multi-feedback-notice');
|
||
if (!notice || typeof ajaxurl === 'undefined') { return; }
|
||
notice.addEventListener('click', function (e) {
|
||
if (e.target && e.target.classList.contains('notice-dismiss')) {
|
||
var body = 'action=wp_multi_dismiss_banner&nonce=' + encodeURIComponent(notice.getAttribute('data-wpm-nonce'));
|
||
fetch(ajaxurl, {
|
||
method: 'POST',
|
||
credentials: 'same-origin',
|
||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||
body: body
|
||
});
|
||
}
|
||
});
|
||
})();
|
||
</script>
|
||
<?php
|
||
}
|
||
add_action('admin_notices', 'wp_multi_add_warning_banner');
|
||
|
||
// AJAX: Schließ-Zeitpunkt des Banners für den aktuellen Benutzer merken
|
||
function wp_multi_dismiss_banner() {
|
||
check_ajax_referer('wp_multi_dismiss_banner', 'nonce');
|
||
update_user_meta(get_current_user_id(), 'wp_multi_banner_dismissed', time());
|
||
wp_send_json_success();
|
||
}
|
||
add_action('wp_ajax_wp_multi_dismiss_banner', 'wp_multi_dismiss_banner');
|
||
|
||
// Support-Links in der Plugin-Übersicht anzeigen
|
||
function wp_multi_plugin_row_meta($links, $file) {
|
||
if ($file === plugin_basename(WP_MULTI_FILE)) {
|
||
$new_links = array(
|
||
'support_teams' => sprintf(
|
||
'<a href="%s" target="_blank" style="color: rgb(255, 0, 0);">%s</a>',
|
||
esc_url('https://discord.com/invite/FdRs4BRd8D'),
|
||
esc_html__('Discord Support', 'wp-multi')
|
||
),
|
||
'support_telegram' => sprintf(
|
||
'<a href="%s" target="_blank" style="color: rgb(255, 0, 0);">%s</a>',
|
||
esc_url('https://t.me/M_Viper04'),
|
||
esc_html__('Telegram Support', 'wp-multi')
|
||
),
|
||
);
|
||
$links = array_merge($links, $new_links);
|
||
}
|
||
return $links;
|
||
}
|
||
add_filter('plugin_row_meta', 'wp_multi_plugin_row_meta', 10, 2);
|
||
|
||
|