Last active
July 29, 2022 08:03
-
-
Save mikeott/c804fdaa61de0bd4bfd8f6aac77111a7 to your computer and use it in GitHub Desktop.
WordPress: Compare local and remote plugin versions (WordPress)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php function my_current_plugin_version() { | |
$plugin_data = get_plugin_data( __FILE__ ); | |
return $plugin_data['Version']; | |
} | |
function my_remote_plugin_version() { | |
$str = file_get_contents('https://rocketapps.com.au/files/open-graphite-pro/open-graphite-pro/info.json'); | |
$json = json_decode($str, true); | |
return $json['version']; | |
} | |
if(my_remote_plugin_version() > my_current_plugin_version()) { | |
// New plugin is available | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment