619 lines
25 KiB
PHP
619 lines
25 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.2
|
|
* Author: M_Viper
|
|
* Author URI: https://m-viper.de
|
|
* Requires at least: 6.7.2
|
|
* Tested up to: 6.7.2
|
|
* 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.');
|
|
|
|
/*
|
|
* Gitea - Ticket - BUG - Report
|
|
*/
|
|
|
|
// Funktion zur Erstellung eines Support-Tickets
|
|
function send_support_ticket_to_server($plugin_name, $title, $description, $label = 'bug') {
|
|
$server_url = 'https://m-viper.de/gitea-issue-creator.php';
|
|
|
|
$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'>Es gab einen Fehler bei der Ticketübertragung: $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</span>';
|
|
} else {
|
|
return '<span class="error-message">Es gab einen Fehler: ' . esc_html($response_body) . '</span>';
|
|
}
|
|
}
|
|
|
|
// Formular für das Support-Ticket mit Design
|
|
function support_ticket_form() {
|
|
?>
|
|
<div class="wrap">
|
|
<h1 class="wp-multi-support-title">WP-Multi Support</h1>
|
|
<div class="support-form-container">
|
|
<form method="post" class="wp-multi-support-form">
|
|
<div class="form-group">
|
|
<label for="plugin_name">Wählen Sie das Plugin</label>
|
|
<select name="plugin_name" id="plugin_name" required>
|
|
<option value="wp-multi">WP Multi</option>
|
|
<option value="wp-multi-search">WP Multi Search</option>
|
|
<option value="wp-multi-toolkit">WP Multi Toolkit</option>
|
|
<option value="wp-multi-comment-notifications">WP Multi Comment Notifications</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="ticket_title">Ticket-Titel</label>
|
|
<input type="text" name="ticket_title" id="ticket_title" required placeholder="Geben Sie den Titel ein" />
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="ticket_description">Ticket-Beschreibung</label>
|
|
<textarea name="ticket_description" id="ticket_description" required placeholder="Beschreiben Sie Ihr Anliegen"></textarea>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="ticket_label">Kategorie</label>
|
|
<select name="ticket_label" id="ticket_label" required>
|
|
<option value="bug">Bug (Etwas funktioniert nicht)</option>
|
|
<option value="enhancement">Verbesserung (Neue Funktion)</option>
|
|
<option value="question">Frage (Mehr Infos benötigt)</option>
|
|
<option value="help wanted">Hilfe benötigt</option>
|
|
<option value="invalid">Ungültig (Etwas ist falsch)</option>
|
|
<option value="duplicate">Duplikat (Bereits vorhanden)</option>
|
|
<option value="wontfix">Wird nicht behoben</option>
|
|
</select>
|
|
</div>
|
|
|
|
<input type="submit" name="submit_ticket" value="Ticket absenden" 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
|
|
// CSS nur auf der Ticket-Seite (wp_multi_support) ausgeben
|
|
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
|
|
}
|
|
?>
|
|
<?php
|
|
}
|
|
|
|
// Menüseite hinzufügen
|
|
function add_support_ticket_page() {
|
|
add_menu_page(
|
|
'WP-Multi Support', // Seitentitel
|
|
'WP-Multi Support', // Menüname
|
|
'manage_options', // Berechtigung
|
|
'wp_multi_support', // Slug (angepasst für Konsistenz)
|
|
'support_ticket_form' // Funktion, die das Formular rendert
|
|
);
|
|
}
|
|
|
|
add_action('admin_menu', 'add_support_ticket_page');
|
|
|
|
/*
|
|
// ### 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');
|
|
|
|
// ### 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 mit nur Offline-Anzeige
|
|
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'
|
|
)
|
|
);
|
|
|
|
$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')
|
|
)
|
|
);
|
|
|
|
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');
|