Skip to content

Instantly share code, notes, and snippets.

@mikeott
Last active July 29, 2022 08:03
Show Gist options
  • Save mikeott/c804fdaa61de0bd4bfd8f6aac77111a7 to your computer and use it in GitHub Desktop.
Save mikeott/c804fdaa61de0bd4bfd8f6aac77111a7 to your computer and use it in GitHub Desktop.
WordPress: Compare local and remote plugin versions (WordPress)
<?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