mc-multiserver-gallery-pro.php aktualisiert

This commit is contained in:
2026-02-11 19:22:57 +00:00
parent d6c23c086e
commit 92ecb0e719

View File

@@ -2,7 +2,7 @@
/* /*
Plugin Name: MC MultiServer Gallery PRO Plugin Name: MC MultiServer Gallery PRO
Description: Professionelle Minecraft-Galerie mit Ingame-Verification, modernem UI, Lightbox und AJAX-Upload (multi-server fähig). Description: Professionelle Minecraft-Galerie mit Ingame-Verification, modernem UI, Lightbox und AJAX-Upload (multi-server fähig).
Version: 2.5.3 Version: 2.5.4
Author: M_Viper Author: M_Viper
Text Domain: mc-multiserver-gallery-pro Text Domain: mc-multiserver-gallery-pro
Domain Path: /languages Domain Path: /languages
@@ -10,6 +10,113 @@ Domain Path: /languages
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
// ===========================================
// MC GALLERY PRO - UPDATE NOTICE SYSTEM
// ===========================================
// Plugin-Version aus Header lesen (NICHT aus Konstante)
function mc_gallery_get_plugin_version() {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugin_data = get_plugin_data( __FILE__ );
return $plugin_data['Version'] ?? '0.0.0';
}
// Cache manuell leeren
function mc_gallery_clear_update_cache() {
if ( isset($_GET['mc_gallery_clear_cache']) && current_user_can('manage_options') ) {
check_admin_referer('mc_gallery_clear_cache_action');
delete_transient('mc_gallery_latest_release');
wp_redirect( admin_url('plugins.php') );
exit;
}
}
add_action('admin_init', 'mc_gallery_clear_update_cache');
// Neueste Release-Infos von Gitea holen
function mc_gallery_get_latest_release_info( $force_refresh = false ) {
$transient_key = 'mc_gallery_latest_release';
if ( $force_refresh ) {
delete_transient( $transient_key );
}
$release_info = get_transient( $transient_key );
if ( false === $release_info ) {
$response = wp_remote_get(
'https://git.viper.ipv64.net/api/v1/repos/M_Viper/Wordpress-MC-Gallery/releases/latest',
['timeout' => 10]
);
if ( ! is_wp_error($response) && 200 === wp_remote_retrieve_response_code($response) ) {
$body = wp_remote_retrieve_body($response);
$data = json_decode($body, true);
if ( $data && isset($data['tag_name']) ) {
$tag = ltrim( $data['tag_name'], 'vV' );
$release_info = [
'version' => $tag,
'download_url' => $data['zipball_url'] ?? '',
'notes' => $data['body'] ?? '',
'published_at' => $data['published_at'] ?? '',
];
set_transient( $transient_key, $release_info, 6 * HOUR_IN_SECONDS );
} else {
set_transient( $transient_key, [], HOUR_IN_SECONDS );
}
} else {
set_transient( $transient_key, [], HOUR_IN_SECONDS );
}
}
return $release_info;
}
// Admin-Update-Hinweis anzeigen
function mc_gallery_show_update_notice() {
if ( ! current_user_can('manage_options') ) {
return;
}
$current_version = mc_gallery_get_plugin_version();
$latest_release = mc_gallery_get_latest_release_info();
if ( ! empty($latest_release['version']) && version_compare($current_version, $latest_release['version'], '<') ) {
$refresh_url = wp_nonce_url(
admin_url('plugins.php?mc_gallery_clear_cache=1'),
'mc_gallery_clear_cache_action'
);
?>
<div class="notice notice-warning is-dismissible">
<h3>MC MultiServer Gallery PRO Update verfügbar</h3>
<p>
Installiert: <strong><?php echo esc_html($current_version); ?></strong><br>
Neueste Version: <strong><?php echo esc_html($latest_release['version']); ?></strong>
</p>
<p>
<a href="<?php echo esc_url($latest_release['download_url']); ?>" class="button button-primary" target="_blank">
Update herunterladen
</a>
<a href="https://git.viper.ipv64.net/M_Viper/Wordpress-MC-Gallery/releases" class="button" target="_blank">
Release Notes
</a>
<a href="<?php echo esc_url($refresh_url); ?>" class="button">
Jetzt neu prüfen
</a>
</p>
</div>
<?php
}
}
add_action('admin_notices', 'mc_gallery_show_update_notice');
if (version_compare(PHP_VERSION, '7.0', '<')) { if (version_compare(PHP_VERSION, '7.0', '<')) {
if (is_admin()) { if (is_admin()) {
add_action('admin_notices', function() { add_action('admin_notices', function() {