wp-multi.php aktualisiert
This commit is contained in:
parent
58aa3c7e78
commit
32dea5d00b
198
wp-multi.php
198
wp-multi.php
@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: WP Multi
|
* Plugin Name: WP Multi
|
||||||
* Plugin URI: https://git.viper.ipv64.net/M_Viper/wp-multi
|
* Plugin URI: https://git.viper.ipv64.net/M_Viper/wp-multi
|
||||||
* Description: Erweiterter Anti-Spam-Schutz mit Honeypot, Keyword-Filter, Link-Limit und mehr. Jetzt mit Statistik im Dashboard und HappyForms-Integration.
|
* Description: Erweiterter Anti-Spam-Schutz mit Honeypot, Keyword-Filter, Link-Limit und mehr. Jetzt mit Statistik im Dashboard und HappyForms-Integration.
|
||||||
* Version: 2.3
|
* Version: 2.4
|
||||||
* 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
|
||||||
@ -33,7 +33,7 @@ function wp_multi_alphabetical_index($atts) {
|
|||||||
// Hole alle Beiträge
|
// Hole alle Beiträge
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'post',
|
'post_type' => 'post',
|
||||||
'posts_per_page' => -1, // Alle Beiträge (wir filtern später nach Buchstabenbereich)
|
'posts_per_page' => -1,
|
||||||
'orderby' => 'title',
|
'orderby' => 'title',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
);
|
);
|
||||||
@ -866,6 +866,7 @@ function wp_multi_statistics_page() {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Einstellungen registrieren
|
// Einstellungen registrieren
|
||||||
function wp_multi_register_security_settings() {
|
function wp_multi_register_security_settings() {
|
||||||
register_setting('wp_multi_security_settings', 'wp_multi_honeypot_field');
|
register_setting('wp_multi_security_settings', 'wp_multi_honeypot_field');
|
||||||
@ -881,11 +882,58 @@ function wp_multi_register_security_settings() {
|
|||||||
add_settings_field('wp_multi_honeypot_error', 'Honey Pot Error Message', 'wp_multi_honeypot_error_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
add_settings_field('wp_multi_honeypot_error', 'Honey Pot Error Message', 'wp_multi_honeypot_error_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
||||||
add_settings_field('wp_multi_honeypot_widget', 'Disable Honeypot Test Widget', 'wp_multi_honeypot_widget_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
add_settings_field('wp_multi_honeypot_widget', 'Disable Honeypot Test Widget', 'wp_multi_honeypot_widget_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
||||||
add_settings_field('wp_multi_max_links', 'Maximale Links im Kommentar', 'wp_multi_max_links_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
add_settings_field('wp_multi_max_links', 'Maximale Links im Kommentar', 'wp_multi_max_links_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
||||||
add_settings_field('wp_multi_blocked_keywords', 'Blockierte Keywords', 'wp_multi_blocked_keywords_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
add_settings_field('wp_multi_blocked_keywords', 'Blockierte Schlüsselwörter', 'wp_multi_blocked_keywords_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
||||||
add_settings_field('wp_multi_blocked_ips', 'Blockierte IP-Adressen', 'wp_multi_blocked_ips_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
add_settings_field('wp_multi_blocked_ips', 'Blockierte IP-Adressen', 'wp_multi_blocked_ips_callback', 'wp-multi-security', 'wp_multi_honeypot_section');
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('admin_init', 'wp_multi_register_security_settings');
|
add_action('admin_init', 'wp_multi_register_security_settings');
|
||||||
|
|
||||||
|
function wp_multi_honeypot_field_callback() {
|
||||||
|
?>
|
||||||
|
<div class="wp-multi-honeypot-group">
|
||||||
|
<input type="text" id="wp_multi_honeypot_field" name="wp_multi_honeypot_field" value="<?php echo esc_attr(get_option('wp_multi_honeypot_field')); ?>">
|
||||||
|
<button type="button" onclick="generateHoneypotName()">Generieren</button>
|
||||||
|
</div>
|
||||||
|
<small>Verwenden Sie ein zufälliges Zeichenfolgen für das Honeypot-Feld.</small>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function wp_multi_honeypot_error_callback() {
|
||||||
|
?>
|
||||||
|
<input type="text" name="wp_multi_honeypot_error" value="<?php echo esc_attr(get_option('wp_multi_honeypot_error')); ?>">
|
||||||
|
<small>Die Nachricht, die angezeigt wird, wenn ein Honeypot ausgelöst wird.</small>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function wp_multi_honeypot_widget_callback() {
|
||||||
|
?>
|
||||||
|
<input type="checkbox" name="wp_multi_honeypot_widget" value="1" <?php checked(1, get_option('wp_multi_honeypot_widget'), true); ?>>
|
||||||
|
<small>Deaktivieren Sie das Honeypot-Test-Widget im Frontend.</small>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function wp_multi_max_links_callback() {
|
||||||
|
?>
|
||||||
|
<input type="number" name="wp_multi_max_links" value="<?php echo esc_attr(get_option('wp_multi_max_links')); ?>">
|
||||||
|
<small>Maximale Anzahl von Links, die in einem Kommentar erlaubt sind.</small>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function wp_multi_blocked_keywords_callback() {
|
||||||
|
?>
|
||||||
|
<input type="text" name="wp_multi_blocked_keywords" value="<?php echo esc_attr(get_option('wp_multi_blocked_keywords')); ?>">
|
||||||
|
<small>Schlüsselwörter, die blockiert werden sollen (durch Kommas getrennt).</small>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function wp_multi_blocked_ips_callback() {
|
||||||
|
?>
|
||||||
|
<textarea name="wp_multi_blocked_ips" rows="5"><?php echo esc_textarea(get_option('wp_multi_blocked_ips')); ?></textarea>
|
||||||
|
<small>Blockierte IP-Adressen (jede Adresse in einer neuen Zeile).</small>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2389,22 +2437,79 @@ function wp_multi_update_dashboard_widget() {
|
|||||||
}
|
}
|
||||||
add_action('wp_dashboard_setup', 'wp_multi_update_dashboard_widget');
|
add_action('wp_dashboard_setup', 'wp_multi_update_dashboard_widget');
|
||||||
|
|
||||||
// Callback-Funktion für das Widget
|
// Cron-Job registrieren
|
||||||
function wp_multi_update_dashboard_widget_content() {
|
function wp_multi_update_schedule_check() {
|
||||||
// Gitea API-URL und Token
|
if (!wp_next_scheduled('wp_multi_update_check_event')) {
|
||||||
|
// Registriere den Cron-Job, der alle 3 Minuten ausgeführt wird
|
||||||
|
wp_schedule_event(time(), 'three_minutes', 'wp_multi_update_check_event');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action('wp', 'wp_multi_update_schedule_check');
|
||||||
|
|
||||||
|
// Cron-Job für Update-Überprüfung
|
||||||
|
function wp_multi_update_check() {
|
||||||
|
// Gitea API-URL
|
||||||
$api_url = 'https://git.viper.ipv64.net/api/v1/repos/M_Viper/wp-multi/releases';
|
$api_url = 'https://git.viper.ipv64.net/api/v1/repos/M_Viper/wp-multi/releases';
|
||||||
$api_token = '9a8bfc571ec98af17bdfadf9e8495c6c330d8c7d';
|
|
||||||
|
|
||||||
// Die Version des Plugins aus den Metadaten der Plugin-Datei holen
|
// Die Version des Plugins aus den Metadaten der Plugin-Datei holen
|
||||||
$plugin_data = get_plugin_data( __FILE__ );
|
$plugin_data = get_plugin_data( __FILE__ );
|
||||||
$installed_version = $plugin_data['Version']; // Die installierte Version aus den Plugin-Metadaten
|
$installed_version = $plugin_data['Version']; // Die installierte Version aus den Plugin-Metadaten
|
||||||
|
|
||||||
// Gitea API-Anfrage für die neuesten Releases
|
// Hole die Einstellung, ob PreRelease-Versionen angezeigt werden sollen
|
||||||
$response = wp_remote_get($api_url, array(
|
$show_prereleases = get_option('wp_multi_update_show_prereleases', false);
|
||||||
'headers' => array(
|
|
||||||
'Authorization' => 'token ' . $api_token
|
// Gitea API-Anfrage für die neuesten Releases ohne Authentifizierung
|
||||||
)
|
$response = wp_remote_get($api_url);
|
||||||
));
|
|
||||||
|
if (is_wp_error($response)) {
|
||||||
|
return; // Fehler nicht weitergeben, aber nichts tun
|
||||||
|
}
|
||||||
|
|
||||||
|
// API-Antwort verarbeiten
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
$data = json_decode($body, true);
|
||||||
|
|
||||||
|
// Finde das neueste, gültige Release (nicht PreRelease, falls deaktiviert)
|
||||||
|
$valid_release = null;
|
||||||
|
foreach ($data as $release) {
|
||||||
|
// Wenn PreRelease deaktiviert ist, überspringe alle PreRelease-Versionen
|
||||||
|
if (!$show_prereleases && isset($release['prerelease']) && $release['prerelease']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($release['tag_name'])) {
|
||||||
|
$valid_release = $release;
|
||||||
|
break; // Nur das erste gültige Release verwenden
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($valid_release) {
|
||||||
|
$latest_version = $valid_release['tag_name'];
|
||||||
|
$release_notes = isset($valid_release['body']) ? $valid_release['body'] : '';
|
||||||
|
$is_prerelease = isset($valid_release['prerelease']) && $valid_release['prerelease'];
|
||||||
|
|
||||||
|
// Speichern von Release-Daten
|
||||||
|
update_option('wp_multi_update_latest_version', $latest_version);
|
||||||
|
update_option('wp_multi_update_release_notes', $release_notes);
|
||||||
|
update_option('wp_multi_update_is_prerelease', $is_prerelease);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action('wp_multi_update_check_event', 'wp_multi_update_check');
|
||||||
|
|
||||||
|
// Callback-Funktion für das Widget
|
||||||
|
function wp_multi_update_dashboard_widget_content() {
|
||||||
|
// Gitea API-URL
|
||||||
|
$api_url = 'https://git.viper.ipv64.net/api/v1/repos/M_Viper/wp-multi/releases';
|
||||||
|
|
||||||
|
// Die Version des Plugins aus den Metadaten der Plugin-Datei holen
|
||||||
|
$plugin_data = get_plugin_data( __FILE__ );
|
||||||
|
$installed_version = $plugin_data['Version']; // Die installierte Version aus den Plugin-Metadaten
|
||||||
|
|
||||||
|
// Hole die Einstellung, ob PreRelease-Versionen angezeigt werden sollen
|
||||||
|
$show_prereleases = get_option('wp_multi_update_show_prereleases', false);
|
||||||
|
|
||||||
|
// Gitea API-Anfrage für die neuesten Releases ohne Authentifizierung
|
||||||
|
$response = wp_remote_get($api_url);
|
||||||
|
|
||||||
if (is_wp_error($response)) {
|
if (is_wp_error($response)) {
|
||||||
echo 'Fehler beim Abrufen der Versionsinformationen von Gitea.';
|
echo 'Fehler beim Abrufen der Versionsinformationen von Gitea.';
|
||||||
@ -2414,11 +2519,27 @@ function wp_multi_update_dashboard_widget_content() {
|
|||||||
// API-Antwort verarbeiten
|
// API-Antwort verarbeiten
|
||||||
$body = wp_remote_retrieve_body($response);
|
$body = wp_remote_retrieve_body($response);
|
||||||
$data = json_decode($body, true);
|
$data = json_decode($body, true);
|
||||||
|
|
||||||
if (!empty($data) && isset($data[0]['tag_name'])) {
|
|
||||||
$latest_version = $data[0]['tag_name']; // Neuste Version von Gitea
|
|
||||||
|
|
||||||
// Vergleiche die installierte Version mit der neuesten Version
|
// Finde das neueste, gültige Release (nicht PreRelease, falls deaktiviert)
|
||||||
|
$valid_release = null;
|
||||||
|
foreach ($data as $release) {
|
||||||
|
// Wenn PreRelease deaktiviert ist, überspringe alle PreRelease-Versionen
|
||||||
|
if (!$show_prereleases && isset($release['prerelease']) && $release['prerelease']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($release['tag_name'])) {
|
||||||
|
$valid_release = $release;
|
||||||
|
break; // Nur das erste gültige Release verwenden
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($valid_release) {
|
||||||
|
$latest_version = $valid_release['tag_name'];
|
||||||
|
$release_notes = isset($valid_release['body']) ? $valid_release['body'] : '';
|
||||||
|
$is_prerelease = isset($valid_release['prerelease']) && $valid_release['prerelease'];
|
||||||
|
|
||||||
|
// Anzeige der Versionen und Text basierend auf PreRelease
|
||||||
if (version_compare($installed_version, $latest_version, '>=')) {
|
if (version_compare($installed_version, $latest_version, '>=')) {
|
||||||
// Wenn die installierte Version gleich oder neuer ist als die Version in Gitea
|
// Wenn die installierte Version gleich oder neuer ist als die Version in Gitea
|
||||||
echo '<p style="color: green;">Ihre Version ist aktuell. Version ' . $installed_version . ' ist die neueste Version.</p>';
|
echo '<p style="color: green;">Ihre Version ist aktuell. Version ' . $installed_version . ' ist die neueste Version.</p>';
|
||||||
@ -2427,13 +2548,54 @@ function wp_multi_update_dashboard_widget_content() {
|
|||||||
echo '<p style="color: red;">Es ist eine neue Version von WP Multi verfügbar! <strong>Version ' . $latest_version . '</strong> ist jetzt verfügbar.</p>';
|
echo '<p style="color: red;">Es ist eine neue Version von WP Multi verfügbar! <strong>Version ' . $latest_version . '</strong> ist jetzt verfügbar.</p>';
|
||||||
echo '<p>Aktuell installierte Version: <strong>' . $installed_version . '</strong></p>';
|
echo '<p>Aktuell installierte Version: <strong>' . $installed_version . '</strong></p>';
|
||||||
echo '<p>Neue Version auf Gitea: <strong>' . $latest_version . '</strong></p>';
|
echo '<p>Neue Version auf Gitea: <strong>' . $latest_version . '</strong></p>';
|
||||||
echo '<p><a href="' . esc_url($data[0]['assets'][0]['browser_download_url']) . '" class="button button-primary" target="_blank">Update herunterladen</a></p>';
|
|
||||||
|
// PreRelease in blauer Schrift anzeigen, wenn erlaubt und das Update ein PreRelease ist
|
||||||
|
if ($is_prerelease && $show_prereleases) {
|
||||||
|
echo '<p style="color: blue;">Dieses Update ist ein PreRelease.</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verfassen-Text anzeigen, falls verfügbar
|
||||||
|
if (!empty($release_notes)) {
|
||||||
|
echo '<p><strong>Information zum Update:</strong></p>';
|
||||||
|
echo '<p>' . nl2br(esc_html($release_notes)) . '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Button-Text anpassen je nachdem, ob es ein PreRelease ist
|
||||||
|
$button_text = $is_prerelease ? 'PreRelease herunterladen' : 'Update herunterladen';
|
||||||
|
$download_url = $valid_release['assets'][0]['browser_download_url'];
|
||||||
|
echo '<p><a href="' . esc_url($download_url) . '" class="button button-primary" target="_blank">' . esc_html($button_text) . '</a></p>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo 'Fehler beim Abrufen der neuesten Version von Gitea.';
|
echo 'Fehler beim Abrufen der neuesten Version von Gitea.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Benutzerdefinierte Intervalle für Cron hinzufügen
|
||||||
|
function wp_multi_update_custom_intervals($schedules) {
|
||||||
|
// 3 Minuten Intervall hinzufügen
|
||||||
|
$schedules['three_minutes'] = array(
|
||||||
|
'interval' => 180, // Alle 3 Minuten
|
||||||
|
'display' => __('Alle 3 Minuten'),
|
||||||
|
);
|
||||||
|
return $schedules;
|
||||||
|
}
|
||||||
|
add_filter('cron_schedules', 'wp_multi_update_custom_intervals');
|
||||||
|
|
||||||
|
// PreRelease Option in den Einstellungen hinzufügen
|
||||||
|
function wp_multi_update_register_settings() {
|
||||||
|
add_option('wp_multi_update_show_prereleases', false);
|
||||||
|
register_setting('general', 'wp_multi_update_show_prereleases');
|
||||||
|
add_settings_field('wp_multi_update_show_prereleases', 'Pre-Release-Versionen anzeigen', 'wp_multi_update_show_prereleases_field', 'general');
|
||||||
|
}
|
||||||
|
add_action('admin_init', 'wp_multi_update_register_settings');
|
||||||
|
|
||||||
|
// Einstellung für PreRelease-Versionen
|
||||||
|
function wp_multi_update_show_prereleases_field() {
|
||||||
|
$value = get_option('wp_multi_update_show_prereleases', false);
|
||||||
|
echo '<input type="checkbox" id="wp_multi_update_show_prereleases" name="wp_multi_update_show_prereleases" value="1" ' . checked(1, $value, false) . ' />';
|
||||||
|
echo '<p class="description" style="color: red;">Aktiviere diese Option, um Pre-Release-Versionen anzuzeigen, die noch nicht vollständig veröffentlicht wurden. Deaktiviere die Option, um nur stabile Versionen anzuzeigen.</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Notify Seite Discord & Telegram
|
* Notify Seite Discord & Telegram
|
||||||
|
Loading…
x
Reference in New Issue
Block a user