Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // This must be in the same file as your main plugin file which WordPress uses to determine plugin name, plugin version etc.
- global $sMyUniquePluginBaseFile;
- $sMyUniquePluginBaseFile = plugin_basename( __FILE__ );
- add_filter( 'auto_update_plugin', 'onWpAutoUpdatePlugin', 100, 2 );
- /**
- * @param boolean $fUpdate
- * @param object $oPluginInfo
- * @return bool
- */
- function onWpAutoUpdatePlugin( $fUpdate, $oPluginInfo ) {
- // Only supports WordPress 3.8.2+
- if ( !is_object( $oPluginInfo ) || !isset( $oPluginInfo->new_version ) || !isset( $oPluginInfo->plugin ) ) { // WP 3.8.2+
- return $fUpdate;
- }
- // Verify that this is MY plugin
- global $sMyUniquePluginBaseFile;
- if ( $oPluginInfo->plugin === $sMyUniquePluginBaseFile ) {
- // You need logic in here that determines that this plugin update is MINOR.
- // e.g.
- $sCurrentVersion = getCurrentPluginMajorVersionNumber();
- $sUpdateVersion = getNewUpdateMajorVersionNumber( $oPluginInfo->new_version );
- // We only return true (i.e. update) only if the major versions are UNCHANGED - so it must be a minor version update
- return ( $sCurrentVersion === $sUpdateVersion );
- }
- return $fUpdate;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement