1 Commits
1.0.0 ... 1.0.1

Author SHA1 Message Date
76b3fd0a9f pulsecast.php aktualisiert 2026-02-11 19:40:12 +00:00

View File

@@ -3,13 +3,115 @@
* Plugin Name: PulseCast * Plugin Name: PulseCast
* Plugin URI: https://git.viper.ipv64.net/M_Viper/PulseCast/ * Plugin URI: https://git.viper.ipv64.net/M_Viper/PulseCast/
* Description: Sende Broadcasts (sofort oder geplant) an deine StatusAPI direkt aus dem WordPress-Backend. Scheduler serverseitig (StatusAPI) bevorzugt. * Description: Sende Broadcasts (sofort oder geplant) an deine StatusAPI direkt aus dem WordPress-Backend. Scheduler serverseitig (StatusAPI) bevorzugt.
* Version: 1.0.0 * Version: 1.0.1
* Author: M_Viper * Author: M_Viper
* Author URI: https://m-viper.de * Author URI: https://m-viper.de
*/ */
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
/**
* PulseCast - Update-Notice (Gitea Releases)
* Zeigt eine Admin-Notice, wenn eine neue Version auf Gitea verfügbar ist.
*/
// Plugin-Version aus Header lesen
function pulsecast_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 (Button "Jetzt neu prüfen")
function pulsecast_clear_update_cache() {
if (isset($_GET['pulsecast_clear_cache']) && current_user_can('manage_options')) {
check_admin_referer('pulsecast_clear_cache_action');
delete_transient('pulsecast_latest_release');
wp_redirect(admin_url('plugins.php'));
exit;
}
}
add_action('admin_init', 'pulsecast_clear_update_cache');
// Neueste Release-Infos von Gitea holen
function pulsecast_get_latest_release_info($force_refresh = false) {
$transient_key = 'pulsecast_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/PulseCast/releases/latest',
array('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((string)$data['tag_name'], 'vV');
$release_info = array(
'version' => $tag,
'download_url' => $data['zipball_url'] ?? '',
'notes' => $data['body'] ?? '',
'published_at' => $data['published_at'] ?? '',
);
// Cache für 6 Stunden
set_transient($transient_key, $release_info, 6 * HOUR_IN_SECONDS);
} else {
set_transient($transient_key, array(), HOUR_IN_SECONDS);
}
} else {
set_transient($transient_key, array(), HOUR_IN_SECONDS);
}
}
return $release_info;
}
// Admin-Notice anzeigen, wenn Update verfügbar
function pulsecast_show_update_notice() {
if (!current_user_can('manage_options')) return;
$current_version = pulsecast_get_plugin_version();
$latest_release = pulsecast_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?pulsecast_clear_cache=1'), 'pulsecast_clear_cache_action');
?>
<div class="notice notice-warning is-dismissible">
<h3>PulseCast 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" rel="noreferrer noopener">
Update herunterladen
</a>
<a href="https://git.viper.ipv64.net/M_Viper/PulseCast/releases" class="button" target="_blank" rel="noreferrer noopener">
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', 'pulsecast_show_update_notice');
class PulseCast { class PulseCast {
const OPTION_KEY = 'pulsecast_settings'; const OPTION_KEY = 'pulsecast_settings';