diff --git a/wp-ingame-shop/wp-ingame-shop.php b/wp-ingame-shop/wp-ingame-shop.php index 5918131..066e818 100644 --- a/wp-ingame-shop/wp-ingame-shop.php +++ b/wp-ingame-shop/wp-ingame-shop.php @@ -1,27 +1,227 @@ 'Cache erfolgreich geleert!']); + } + + // Prüfe auf Updates (läuft im Admin-Hintergrund) + public static function check_for_update() { + $update_data = get_transient(self::$transient_name); + + if (false === $update_data) { + $response = wp_remote_get(self::$api_url, ['timeout' => 10]); + + if (is_wp_error($response)) { + return; // Fehler beim Abrufen, nichts tun + } + + $body = wp_remote_retrieve_body($response); + $data = json_decode($body); + + if (isset($data->tag_name) && isset($data->html_url)) { + // Entferne 'v' vom Tag (z.B. v2.1.3 -> 2.1.3) + $remote_version = ltrim($data->tag_name, 'v'); + + $update_data = [ + 'new_version' => $remote_version, + 'url' => self::$update_url, + 'package_url' => isset($data->assets[0]->browser_download_url) ? $data->assets[0]->browser_download_url : '', + 'changelog' => isset($data->body) ? substr($data->body, 0, 200) . '...' : '' + ]; + + // Speichere für 12 Stunden + set_transient(self::$transient_name, $update_data, 12 * HOUR_IN_SECONDS); + } + } + } + + // Zeige Admin Notice wenn Update verfügbar + public static function show_update_notice() { + $update_data = get_transient(self::$transient_name); + if ($update_data && version_compare(WIS_VERSION, $update_data['new_version'], '<')) { + ?> +
+

+ 🚀 WP Ingame Shop Pro Update verfügbar!
+ Neue Version: (Du hast )
+ Hier im Git Repository ansehen oder unten im Widget Details prüfen. +

+
+ $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}wis_items WHERE status = 'publish'"), + 'orders' => $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}wis_orders WHERE status = 'completed'"), + 'pending' => $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}wis_orders WHERE status IN ('pending', 'claimed')"), + 'revenue' => $wpdb->get_var("SELECT SUM(price) FROM {$wpdb->prefix}wis_orders WHERE status = 'completed'"), + ]; + $currency = get_option('wis_currency_name', 'Coins'); + + // Update Status bestimmen + $update_html = '✅ Aktuell (v' . WIS_VERSION . ')'; + if ($update_data && version_compare(WIS_VERSION, $update_data['new_version'], '<')) { + $update_html = '⚠️ Update verfügbar!'; + } + + ?> + + +
+
+ + Items +
+
+ + Bestellungen +
+
+ + Offen +
+
+ + Umsatz () +
+
+ +

+ Status: +

+ + +
+ Neue Version
+ Updates ansehen +
+ + +
+ Bestellungen ansehen + + +
+ + +