function wp_stream_update_142($db_version, $current_version) { // If $db_version if 1.4.1 then we need to run all updates again. Otherwise. We skip this update. if (version_compare($db_version, '1.4.1', '=')) { $versions = WP_Stream_Install::db_update_versions(); foreach ($versions as $version) { // Further updates will apply themselves on their on. if ('1.4.2' === $version) { break; } $function = 'wp_stream_update_' . str_ireplace('.', '', $version); if (function_exists($function)) { $db_success = call_user_func($function, $db_version, $current_version); if ($current_version !== $db_success) { return $db_success; } } } } return $current_version; }
/** * Installation / Upgrade checks * * @action register_activation_hook * @return void */ public static function install() { // Install plugin tables require_once WP_STREAM_INC_DIR . 'install.php'; $update = WP_Stream_Install::get_instance(); }
/** * Check db version, create/update table schema accordingly * If database update required admin notice will be given * on the plugin update screen * * @return null */ private static function check() { if (defined('DOING_AJAX') && DOING_AJAX) { return; } if (empty(self::$db_version)) { self::install(self::$current); } elseif (self::$db_version !== self::$current) { if (!isset($_REQUEST['wp_stream_update'])) { self::$update_required = true; $update_args = array('type' => 'auto'); self::$success_db = self::update(self::$db_version, self::$current, $update_args); } elseif ('update_and_continue' === $_REQUEST['wp_stream_update']) { $update_args = array('type' => 'user'); self::$success_db = self::update(self::$db_version, self::$current, $update_args); } // We need to check if there is a manual update needed between the current and last db version. $versions = self::db_update_versions(); if (version_compare(end($versions), self::$db_version, '>')) { add_action('all_admin_notices', array(__CLASS__, 'update_notice_hook')); } else { self::update_db_option(); } } }