Skip to content

Commit dfbab3d

Browse files
committed
v1.1
1 parent c18ee1d commit dfbab3d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

lgsl-wordpress-plugin/lgsl-wordpress-plugin.php

+27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,33 @@
1313
exit; // Exit if accessed directly.
1414
}
1515

16+
// Add a function to check for plugin updates
17+
function lgsl_check_for_plugin_update() {
18+
$current_version = '1.0';
19+
$remote_version_info_url = 'https://github.com/wahke/lgsl-wordpress-plugin/raw/main/lgsl-version.json'; // Replace with the URL to your version file
20+
21+
$response = wp_remote_get($remote_version_info_url);
22+
if (is_wp_error($response)) {
23+
return;
24+
}
25+
26+
$response_body = wp_remote_retrieve_body($response);
27+
$version_info = json_decode($response_body, true);
28+
29+
if (isset($version_info['version']) && version_compare($current_version, $version_info['version'], '<')) {
30+
add_action('admin_notices', 'lgsl_update_notification');
31+
}
32+
}
33+
add_action('admin_init', 'lgsl_check_for_plugin_update');
34+
35+
function lgsl_update_notification() {
36+
$update_url = 'https://your-update-server.com/lgsl-latest.zip'; // Replace with the URL to your update file
37+
echo '<div class="notice notice-warning is-dismissible">
38+
<p>Es ist eine neue Version des LGSL WordPress Plugins verfügbar. <a href="' . esc_url($update_url) . '">Jetzt aktualisieren</a>.</p>
39+
</div>';
40+
}
41+
42+
1643
// Activation hook to set default options and redirect to setup
1744
function lgsl_activate_plugin() {
1845
// Set default options on activation

0 commit comments

Comments
 (0)