wp-multi-team-card.php aktualisiert
This commit is contained in:
parent
7f09b4896d
commit
193119cc2d
@ -24,6 +24,57 @@ if (version_compare(PHP_VERSION, '7.2', '<')) {
|
|||||||
die('This plugin requires PHP 7.2 or higher.');
|
die('This plugin requires PHP 7.2 or higher.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the current version of the plugin from the plugin header dynamically
|
||||||
|
function get_current_plugin_version() {
|
||||||
|
// Get the plugin data
|
||||||
|
$plugin_data = get_plugin_data(__FILE__);
|
||||||
|
return $plugin_data['Version']; // Return the version from the plugin header
|
||||||
|
}
|
||||||
|
|
||||||
|
$gitea_api_url = 'https://git.viper.ipv64.net/api/v1/repos/M_Viper/wp-multi-teamcard/releases/latest'; // Gitea API URL
|
||||||
|
|
||||||
|
function check_for_new_release() {
|
||||||
|
global $gitea_api_url;
|
||||||
|
|
||||||
|
// Get the current version dynamically from the plugin header
|
||||||
|
$current_version = get_current_plugin_version();
|
||||||
|
|
||||||
|
// Fetch the latest release data from Gitea
|
||||||
|
$response = wp_remote_get($gitea_api_url);
|
||||||
|
|
||||||
|
// Check if there was an error with the API request
|
||||||
|
if (is_wp_error($response)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = wp_remote_retrieve_body($response);
|
||||||
|
$release_data = json_decode($body);
|
||||||
|
|
||||||
|
// If release data is valid
|
||||||
|
if (isset($release_data->tag_name)) {
|
||||||
|
$latest_version = $release_data->tag_name;
|
||||||
|
|
||||||
|
// If the latest version differs from the current version, show the banner
|
||||||
|
if ($latest_version !== $current_version) {
|
||||||
|
// Display the banner in the admin area
|
||||||
|
add_action('admin_notices', function() use ($latest_version) {
|
||||||
|
echo '<div class="notice notice-info is-dismissible">
|
||||||
|
<p><strong>⚠️ Neue Version von WP Multi Teamcard verfügbar:</strong> Version ' . esc_html($latest_version) . ' ist jetzt auf Gitea verfügbar. <a href="https://git.viper.ipv64.net/M_Viper/wp-multi-teamcard/releases" target="_blank">Hier klicken, um die neue Version herunterzuladen. ⚠️</a></p>
|
||||||
|
</div>';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook into the admin init to check for updates
|
||||||
|
add_action('admin_init', 'check_for_new_release');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CPT registrieren
|
// CPT registrieren
|
||||||
function teamcard_register_post_type() {
|
function teamcard_register_post_type() {
|
||||||
register_post_type('teamcard', [
|
register_post_type('teamcard', [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user