version; $latest_version = Beta_Optin::get_latest_version(); if ( $current_version === $latest_version ) { delete_option( self::ROLLBACK_VERSION_OPTION ); return false; } return true; } /** * Check if we should roll back in this request or not. */ public static function should_rollback() { if ( ! Param::post( 'rm_rollback_version' ) ) { return false; } if ( ! current_user_can( 'update_plugins' ) ) { return false; } if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'rank-math-rollback' ) ) { return false; } return true; } /** * Reinstall previous version. * * @return boolean Whether the installation was successful. */ public function rollback() { $title = __( 'Rollback Plugin', 'rank-math' ); $parent_file = 'plugins.php'; $submenu_file = 'plugins.php'; $new_version = Param::post( 'rm_rollback_version' ); wp_enqueue_script( 'updates' ); $plugin = 'seo-by-rank-math/rank-math.php'; $nonce = 'upgrade-plugin_' . $plugin; $url = 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $plugin ); if ( ! class_exists( '\Plugin_Upgrader' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; } update_option( self::ROLLBACK_VERSION_OPTION, $new_version ); // Downgrade version number if necessary. if ( version_compare( rank_math()->version, $new_version, '>' ) ) { update_option( 'rank_math_version', $new_version ); } add_filter( 'pre_site_transient_update_plugins', [ $this, 'pre_transient_update_plugins' ], 20 ); add_filter( 'gettext', [ $this, 'change_updater_strings' ], 20, 3 ); $upgrader = new \Plugin_Upgrader( new \Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) ); echo '