Last active
August 29, 2015 14:10
-
-
Save dgmstuart/b232ec418f4724917b64 to your computer and use it in GitHub Desktop.
A class for detecting when the plugin has updated (WordPress)
This file contains 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 | |
// ... | |
register_activation_hook( __FILE__, array( "dxw_security_Update_Checker", 'record_version' )); | |
if (dxw_security_Update_Checker::updated() ) { | |
dxw_security_Cron::schedule_tasks(); | |
dxw_security_Update_Checker::record_version(); | |
} | |
// ... | |
?> |
This file contains 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 | |
defined('ABSPATH') OR exit; | |
class dxw_security_Update_Checker { | |
private static $version_key = "dxw_security_plugin_version"; | |
public static function updated() { | |
return self::previous_version() != self::current_version(); | |
} | |
public static function record_version() { | |
update_option(self::$version_key, self::current_version()); | |
} | |
private static function previous_version() { | |
return get_site_option(self::$version_key); | |
} | |
private static function current_version() { | |
// TODO: is this OK or should we use get_plugin_data? | |
return DXW_SECURITY_PLUGIN_VERSION; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment