protected function update_plugin($when = '') { if (!$this->bridge->is_admin()) { return; } $current_version = $this->plugin_ver; $db_version = $this->bridge->get_option($this->plugin_key . '_version'); if (!$db_version || version_compare($db_version, $current_version, '<')) { if ('pre_init' == $when) { $action_hook = $this->plugin_key . '_upgrade'; $this->upgrade_plugin($db_version, $current_version); } else { $action_hook = $this->plugin_key . '_init_upgrade'; $this->init_upgrade_plugin($db_version, $current_version); } // fire an action when plugin updates itself $this->bridge->do_action($action_hook, $db_version, $current_version); // only mark as upgraded when this is init update if ('init' == $when) { $this->bridge->update_option($this->plugin_key . '_version', $current_version); } } }