• Resolved ed4becky

    (@ed4becky)


    I understand from another thread that 3.1 will no longer call the activation hook when a plugin is upgraded.

    was wondering if someone could point me to a good example of calling upgrade code outside of the activation, so it is called the minimal number of times.

    My plugin has an internal version number I can use to check against, I’m just not sure of the best place to put the check against the version number and the call to the upgrade function

Viewing 1 replies (of 1 total)
  • Thread Starter ed4becky

    (@ed4becky)

    I ended up putting the check in the admin_init hook.

    function rootsPersonaUpgrade() {
      $currentVersion = get_option('rootsPersonaVersion');
      if(!isset($currentVersion) || empty($currentVersion)
    	|| $this->rootsPersonaVersion != $currentVersion) {
    	$installer = new rootsPersonaInstaller();
    	$installer->rootsPersonaUpgrade(ABSPATH . $this->plugin_dir,
    					$this->rootsPersonaVersion);
      }
    }

    then

    add_action( 'admin_init', array($rootsPersonaplugin, 'rootsPersonaUpgrade' ));

Viewing 1 replies (of 1 total)

The topic ‘Coding plugin for upgrade’ is closed to new replies.