Commit realizado el 12:13:52 08-04-2024
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* Plugin: Rank Math - Version Control
|
||||
* URL: https://rankmath.com/wordpress/plugin/seo-suite/
|
||||
* Name: version-control.css
|
||||
*/.rank-math-rollback-form .loading-indicator-text{line-height:2}.rank-math-rollback-form iframe,.rank-math-rollback-form a[target="_parent"]{display:none}.rank-math-rollback-form .rollback-version-label{color:#FF9800;font-weight:500}.rank-math-rollback-form th,.rank-math-rollback-form td{padding:10px 5px 10px 0}.rank-math-rollback-form .update-link{margin-left:4px}.rank-math-rollback-form span.warning,.rank-math-beta-optin-form span.warning{text-transform:uppercase;color:#F44336}.rank-math-beta-optin-form th,.rank-math-beta-optin-form td,.rank-math-auto-update-form th,.rank-math-auto-update-form td{vertical-align:middle;padding:0 10px 0 0}.rank-math-beta-optin-form .cmb-row,.rank-math-auto-update-form .cmb-row{border-bottom:none}.rank-math-rollback-status>.wrap{background:#fff;padding:10px 20px;border:1px solid #ddd}.rank-math-rollback-status>.wrap>h1{font-size:22px;font-weight:bold}.rank-math-tools-wrap tr.cmb-row.cmb-type-switch th,.rank-math-tools-wrap tr.cmb-row.cmb-type-switch td{padding:20px 0 !important}
|
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var r,n={n:function(r){var o=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(o,{a:o}),o},d:function(r,o){for(var t in o)n.o(o,t)&&!n.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:o[t]})},o:function(r,n){return Object.prototype.hasOwnProperty.call(r,n)}},o=jQuery;(r=n.n(o)())((function(){r(".rank-math-rollback-form").on("submit",(function(){if(!confirm(rankMath.rollbackConfirm.replace("%s",r("#rm_rollback_version").val())))return!1;r("#rm-rollback-button").prop("disabled",!0),r(".rollback-loading-indicator").removeClass("hidden")}));var n=r("#rm-rollback-button");r("#rm_rollback_version").on("change",(function(){n.text(n.data("buttonlabel").replace("%s",r(this).val()))})).trigger("change")}))}();
|
@@ -0,0 +1,347 @@
|
||||
<?php
|
||||
/**
|
||||
* The Beta Opt-in functionality.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Version_Control
|
||||
*/
|
||||
|
||||
namespace RankMath;
|
||||
|
||||
use RankMath\Traits\Hooker;
|
||||
use RankMath\Helpers\Str;
|
||||
use RankMath\Helpers\Param;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Beta_Optin class.
|
||||
*/
|
||||
class Beta_Optin {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Beta changelog URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const BETA_CHANGELOG_URL = 'https://rankmath.com/changelog/beta/';
|
||||
|
||||
/**
|
||||
* Placeholder for opening tag inserted with JS.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const NOTICE_START_MARKER = '▷';
|
||||
|
||||
/**
|
||||
* Placeholder for closing tag inserted with JS.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const NOTICE_END_MARKER = '◁';
|
||||
|
||||
/**
|
||||
* Holds the fetched trunk version in memory to avoid fetching multiple times.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $trunk_version = false;
|
||||
|
||||
/**
|
||||
* Actions and filters.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function hooks() {
|
||||
$this->filter( 'site_transient_update_plugins', 'transient_update_plugins' );
|
||||
$this->action( 'in_plugin_update_message-seo-by-rank-math/rank-math.php', 'plugin_update_message', 10, 2 );
|
||||
$this->action( 'install_plugins_pre_plugin-information', 'beta_plugin_information' );
|
||||
$this->action( 'admin_footer', 'beta_changelog_link_js' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace plugin info popup for beta versions.
|
||||
*/
|
||||
public function beta_plugin_information() {
|
||||
if ( 'seo-by-rank-math' !== Param::request( 'plugin' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$transient = get_site_transient( 'update_plugins' );
|
||||
if ( self::has_beta_update( $transient ) ) {
|
||||
// No-js fallback.
|
||||
echo '<html><head></head><body style="margin: 0;"><iframe src="' . esc_attr( self::BETA_CHANGELOG_URL ) . '" style="width: 100%; height: 100%;"></body></html>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Rank Math update is a beta update in the transient.
|
||||
*
|
||||
* @param mixed $transient Transient value.
|
||||
* @return boolean If it is a beta update or not.
|
||||
*/
|
||||
public static function has_beta_update( $transient ) {
|
||||
return (
|
||||
is_object( $transient )
|
||||
&& ! empty( $transient->response )
|
||||
&& ! empty( $transient->response['seo-by-rank-math/rank-math.php'] )
|
||||
&& ! empty( $transient->response['seo-by-rank-math/rank-math.php']->is_beta )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available versions of Rank Math.
|
||||
*
|
||||
* @param boolean $beta Include beta versions.
|
||||
*
|
||||
* @return array List of versions and download URLs.
|
||||
*/
|
||||
public static function get_available_versions( $beta = false ) {
|
||||
$versions = [];
|
||||
$plugin_info = Version_Control::get_plugin_info();
|
||||
|
||||
foreach ( (array) $plugin_info['versions'] as $version => $url ) {
|
||||
if ( ! self::is_eligible_version( $version, $beta ) ) {
|
||||
continue;
|
||||
}
|
||||
$versions[ $version ] = $url;
|
||||
}
|
||||
|
||||
uksort( $versions, 'version_compare' );
|
||||
|
||||
return $versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if version should be in the dropdown.
|
||||
*
|
||||
* @param string $version Version number.
|
||||
* @param boolean $beta If beta versions should be included or not.
|
||||
*
|
||||
* @return boolean If version should be in the dropdown.
|
||||
*/
|
||||
public static function is_eligible_version( $version, $beta ) {
|
||||
if ( 'trunk' === $version ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $beta && Str::contains( 'beta', $version ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get latest version available.
|
||||
*
|
||||
* @return string Latest version number.
|
||||
*/
|
||||
public static function get_latest_version() {
|
||||
$plugin_info = Version_Control::get_plugin_info();
|
||||
return $plugin_info['version'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get latest beta version available.
|
||||
*
|
||||
* @return string Latest beta version number.
|
||||
*/
|
||||
public function get_latest_beta_version() {
|
||||
$version = get_transient( 'rank_math_trunk_version' );
|
||||
if ( ! $version || $this->is_check_requested() ) {
|
||||
$version = $this->fetch_trunk_version();
|
||||
}
|
||||
|
||||
$beta = 0;
|
||||
if ( Str::contains( 'beta', $version ) ) {
|
||||
$beta = $version;
|
||||
}
|
||||
|
||||
return $beta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch latest plugin file from public SVN and get version number.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch_trunk_version() {
|
||||
if ( false !== $this->trunk_version ) {
|
||||
return $this->trunk_version;
|
||||
}
|
||||
|
||||
$this->trunk_version = 0;
|
||||
|
||||
$response = wp_remote_get( 'https://plugins.svn.wordpress.org/seo-by-rank-math/trunk/rank-math.php' );
|
||||
if ( ! is_array( $response ) || is_wp_error( $response ) ) {
|
||||
return $this->trunk_version;
|
||||
}
|
||||
|
||||
$plugin_file = wp_remote_retrieve_body( $response );
|
||||
|
||||
preg_match( '/Version:\s+([0-9a-zA-Z.-]+)\s*$/m', $plugin_file, $matches );
|
||||
if ( empty( $matches[1] ) ) {
|
||||
return $this->trunk_version;
|
||||
}
|
||||
|
||||
$this->trunk_version = $matches[1];
|
||||
set_transient( 'rank_math_trunk_version', $this->trunk_version, ( 12 * HOUR_IN_SECONDS ) );
|
||||
return $this->trunk_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject beta in the `update_plugins` transient to be able to update to it.
|
||||
*
|
||||
* @param mixed $value Original value.
|
||||
*
|
||||
* @return mixed New value.
|
||||
*/
|
||||
public function transient_update_plugins( $value ) {
|
||||
$beta_version = $this->get_latest_beta_version();
|
||||
$new_version = isset( $value->response['seo-by-rank-math/rank-math.php'] ) && ! empty( $value->response['seo-by-rank-math/rank-math.php']->new_version ) ? $value->response['seo-by-rank-math/rank-math.php']->new_version : 0;
|
||||
|
||||
if ( ! $beta_version ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ( version_compare( $beta_version, rank_math()->version, '>' ) && version_compare( $beta_version, $new_version, '>' ) ) {
|
||||
$value = $this->inject_beta( $value, $beta_version );
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject beta update in the transient value.
|
||||
*
|
||||
* @param mixed $value Transient value.
|
||||
* @param string $beta_version Beta version number.
|
||||
*
|
||||
* @return mixed New transient value.
|
||||
*/
|
||||
public function inject_beta( $value, $beta_version ) {
|
||||
if ( empty( $value ) ) {
|
||||
$value = new \stdClass();
|
||||
}
|
||||
|
||||
if ( empty( $value->response ) ) {
|
||||
$value->response = [];
|
||||
}
|
||||
|
||||
$value->response['seo-by-rank-math/rank-math.php'] = new \stdClass();
|
||||
|
||||
$plugin_data = Version_Control::get_plugin_data( $beta_version, 'https://downloads.wordpress.org/plugin/seo-by-rank-math.zip' );
|
||||
foreach ( $plugin_data as $prop_key => $prop_value ) {
|
||||
$value->response['seo-by-rank-math/rank-math.php']->{$prop_key} = $prop_value;
|
||||
}
|
||||
|
||||
$value->response['seo-by-rank-math/rank-math.php']->is_beta = true;
|
||||
$value->response['seo-by-rank-math/rank-math.php']->upgrade_notice = self::NOTICE_START_MARKER . ' ' . __( 'This update will install a beta version of Rank Math.', 'rank-math' ) . ' ' . self::NOTICE_END_MARKER;
|
||||
|
||||
if ( empty( $value->no_update ) ) {
|
||||
$value->no_update = [];
|
||||
}
|
||||
|
||||
unset( $value->no_update['seo-by-rank-math/rank-math.php'] );
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add warning about beta version in the update notice.
|
||||
*
|
||||
* @param array $plugin_data An array of plugin metadata.
|
||||
* @param array $response An array of metadata about the available plugin update.
|
||||
* @return void
|
||||
*/
|
||||
public function plugin_update_message( $plugin_data, $response ) {
|
||||
if ( empty( $plugin_data['is_beta'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'</p><p class="rank-math-beta-update-notice">%s',
|
||||
esc_html__( 'This update will install a beta version of Rank Math.', 'rank-math' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Javascript to open beta changelog link in a new tab instead of the modal.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function beta_changelog_link_js() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
$applicable_screens = [
|
||||
'update-core',
|
||||
'plugins',
|
||||
'update-core-network',
|
||||
'plugins-network',
|
||||
];
|
||||
|
||||
if ( empty( $screen->base ) || ! in_array( $screen->base, $applicable_screens, true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$transient = get_site_transient( 'update_plugins' );
|
||||
if ( ! self::has_beta_update( $transient ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
// Change our link.
|
||||
$('.open-plugin-details-modal').each( function( index, element ) {
|
||||
if ( element.href.indexOf( 'plugin=seo-by-rank-math§ion=changelog' ) !== -1 ) {
|
||||
// Found our link.
|
||||
$( element )
|
||||
.removeClass( 'open-plugin-details-modal thickbox' )
|
||||
.attr( 'href', '<?php echo esc_js( self::BETA_CHANGELOG_URL ); ?>' )
|
||||
.attr( 'target', '_blank' );
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
// Change our notice.
|
||||
<?php if ( 'update-core' === $screen->base || 'update-core-network' === $screen->base ) { ?>
|
||||
$('td.plugin-title').each( function( index, element ) {
|
||||
var contents = $( element ).html();
|
||||
if ( contents.indexOf( '<?php echo esc_js( html_entity_decode( self::NOTICE_START_MARKER ) ); ?>' ) !== -1 && contents.indexOf( '<?php echo esc_js( html_entity_decode( self::NOTICE_END_MARKER ) ); ?>' ) !== -1 ) {
|
||||
contents = contents
|
||||
.replace( '<?php echo esc_js( html_entity_decode( self::NOTICE_START_MARKER ) ); ?>', '</p><div class="update-message notice inline notice-warning notice-alt rank-math-beta-update-notice"><p>' )
|
||||
.replace( '<?php echo esc_js( html_entity_decode( self::NOTICE_END_MARKER ) ); ?>', '</p></div><p style="display: none;">' );
|
||||
|
||||
$( element ).html( contents );
|
||||
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
<?php } ?>
|
||||
} );
|
||||
</script>
|
||||
<style>
|
||||
.update-message.rank-math-beta-update-notice {
|
||||
font-weight: bold;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.update-message.rank-math-beta-update-notice > p:before {
|
||||
content: "\f534";
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* If user requested check with force-check parameter.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_check_requested() {
|
||||
return (bool) Param::get( 'force-check' );
|
||||
}
|
||||
}
|
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* The Version Rollback Class.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Version_Control
|
||||
*/
|
||||
|
||||
namespace RankMath;
|
||||
|
||||
use RankMath\Traits\Hooker;
|
||||
use RankMath\Helpers\Param;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Rollback_Version class.
|
||||
*/
|
||||
class Rollback_Version {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Rollback version option key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const ROLLBACK_VERSION_OPTION = 'rank_math_rollback_version';
|
||||
|
||||
/**
|
||||
* Check if currently installed version is a rollback version.
|
||||
*
|
||||
* @return boolean Whether it is rollback or not.
|
||||
*/
|
||||
public static function is_rollback_version() {
|
||||
$is_rollback = boolval( get_option( self::ROLLBACK_VERSION_OPTION, false ) );
|
||||
if ( ! $is_rollback ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$current_version = rank_math()->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 '<div class="rank-math-rollback-status">';
|
||||
$upgrader->upgrade( $plugin );
|
||||
echo '</div>';
|
||||
remove_filter( 'pre_site_transient_update_plugins', [ $this, 'pre_transient_update_plugins' ], 20 );
|
||||
remove_filter( 'gettext', [ $this, 'change_updater_strings' ], 20 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject old version in the `update_plugins` transient for downgrading.
|
||||
*
|
||||
* @param boolean $false False. Pass truthy value to short-circuit the get_site_transient().
|
||||
* @return object New `update_plugins` data object.
|
||||
*/
|
||||
public function pre_transient_update_plugins( $false ) {
|
||||
$versions = Beta_Optin::get_available_versions( true );
|
||||
$selected = Param::post( 'rm_rollback_version' );
|
||||
$package = $versions[ $selected ];
|
||||
$data = new \stdClass();
|
||||
$data->response = [];
|
||||
$data->response['seo-by-rank-math/rank-math.php'] = new \stdClass();
|
||||
|
||||
$plugin_data = Version_Control::get_plugin_data( $selected, $package );
|
||||
foreach ( $plugin_data as $prop_key => $prop_value ) {
|
||||
$data->response['seo-by-rank-math/rank-math.php']->{$prop_key} = $prop_value;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooked to gettext filter to change strings in the Updater for the rollback process.
|
||||
*
|
||||
* @param string $translation Translated text.
|
||||
* @param string $text Original text.
|
||||
* @param string $domain Text-domain.
|
||||
*
|
||||
* @return string New translated text.
|
||||
*/
|
||||
public function change_updater_strings( $translation, $text, $domain ) {
|
||||
if ( 'Plugin updated successfully.' === $text ) {
|
||||
return __( 'Plugin rollback successful.', 'rank-math' );
|
||||
}
|
||||
|
||||
if ( 'Installing the latest version…' === $text ) {
|
||||
return __( 'Installing the rollback version…', 'rank-math' );
|
||||
}
|
||||
|
||||
return $translation;
|
||||
}
|
||||
}
|
@@ -0,0 +1,356 @@
|
||||
<?php
|
||||
/**
|
||||
* The Version Control internal module.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Version_Control
|
||||
*/
|
||||
|
||||
namespace RankMath;
|
||||
|
||||
use RankMath\Helper;
|
||||
use RankMath\Helpers\Param;
|
||||
use RankMath\Traits\Hooker;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Version_Control class.
|
||||
*/
|
||||
class Version_Control {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Module ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id = '';
|
||||
|
||||
/**
|
||||
* Module directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $directory = '';
|
||||
|
||||
/**
|
||||
* Plugin info transient key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TRANSIENT = 'rank_math_wporg_plugin_info';
|
||||
|
||||
/**
|
||||
* WordPress.org plugins API URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const API_URL = 'https://api.wordpress.org/plugins/info/1.0/seo-by-rank-math.json';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
if ( Helper::is_heartbeat() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Helper::is_rest() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$directory = dirname( __FILE__ );
|
||||
$this->config(
|
||||
[
|
||||
'id' => 'status',
|
||||
'directory' => $directory,
|
||||
]
|
||||
);
|
||||
|
||||
$this->hooks();
|
||||
|
||||
$this->maybe_save_beta_optin();
|
||||
$this->maybe_save_auto_update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change beta_optin setting.
|
||||
*
|
||||
* @return bool Change successful.
|
||||
*/
|
||||
public function maybe_save_beta_optin() {
|
||||
if ( ! Param::post( 'beta_optin' ) || ! Param::post( '_wpnonce' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'rank-math-beta-optin' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sanitize input.
|
||||
$new_value = Param::post( 'beta_optin' ) === 'on' ? 'on' : 'off';
|
||||
|
||||
$settings = get_option( 'rank-math-options-general', [] );
|
||||
$settings['beta_optin'] = $new_value;
|
||||
rank_math()->settings->set( 'general', 'beta_optin', 'on' === $new_value ? true : false );
|
||||
update_option( 'rank-math-options-general', $settings );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change enable_auto_update setting.
|
||||
*
|
||||
* @return bool Change successful.
|
||||
*/
|
||||
public function maybe_save_auto_update() {
|
||||
if ( ! ( Param::post( 'enable_auto_update' ) || Param::post( 'enable_update_notification_email' ) ) && ! Param::post( '_wpnonce' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'rank-math-auto-update' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( Param::post( 'enable_auto_update' ) ) {
|
||||
$new_value = Param::post( 'enable_auto_update' ) === 'on' ? 'on' : 'off';
|
||||
Helper::toggle_auto_update_setting( $new_value );
|
||||
}
|
||||
|
||||
if ( Param::post( 'enable_update_notification_email' ) ) {
|
||||
$enable_notifications = Param::post( 'enable_update_notification_email' ) === 'on' ? 'on' : 'off';
|
||||
$settings = get_option( 'rank-math-options-general', [] );
|
||||
|
||||
$settings['update_notification_email'] = $enable_notifications;
|
||||
rank_math()->settings->set( 'general', 'update_notification_email', 'on' === $enable_notifications ? true : false );
|
||||
update_option( 'rank-math-options-general', $settings );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register version control hooks.
|
||||
*/
|
||||
public function hooks() {
|
||||
if ( Helper::get_settings( 'general.beta_optin' ) ) {
|
||||
$beta_optin = new Beta_Optin();
|
||||
$beta_optin->hooks();
|
||||
}
|
||||
|
||||
if (
|
||||
Helper::is_advanced_mode() && (
|
||||
! Helper::is_plugin_active_for_network() ||
|
||||
current_user_can( 'setup_network' )
|
||||
)
|
||||
) {
|
||||
$this->filter( 'rank_math/tools/pages', 'add_status_page' );
|
||||
$this->filter( 'rank_math/tools/default_tab', 'change_default_tab' );
|
||||
}
|
||||
|
||||
$this->filter( 'rank_math/admin/dashboard_view', 'network_admin_view', 10, 2 );
|
||||
$this->filter( 'rank_math/admin/dashboard_nav_links', 'network_admin_dashboard_tabs' );
|
||||
$this->action( 'admin_enqueue_scripts', 'enqueue', 20 );
|
||||
|
||||
if ( $this->should_add_json() ) {
|
||||
/* translators: Placeholder is version number. */
|
||||
Helper::add_json( 'rollbackConfirm', esc_html__( 'Are you sure you want to install version %s?', 'rank-math' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if JSON for confirmation l10n needs to be added.
|
||||
*
|
||||
* @return bool Whether the data needs to be added.
|
||||
*/
|
||||
private function should_add_json() {
|
||||
if ( ! is_admin() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( is_network_admin() && Helper::is_plugin_active_for_network() ) {
|
||||
return Param::get( 'page' ) === 'rank-math';
|
||||
}
|
||||
|
||||
return Param::get( 'page' ) === 'rank-math-status';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if assets should be enqueued on current admin page.
|
||||
*
|
||||
* @param string $hook Page hook name.
|
||||
* @return bool Whether we should proceed with the enqueue functions.
|
||||
*/
|
||||
private function should_enqueue( $hook ) {
|
||||
if ( is_network_admin() && Helper::is_plugin_active_for_network() ) {
|
||||
return 'toplevel_page_rank-math' === $hook;
|
||||
}
|
||||
|
||||
return 'rank-math_page_rank-math-status' === $hook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace Admin_Helper::get_view() output for the network admin tab.
|
||||
*
|
||||
* @param string $file File path.
|
||||
* @param string $view Requested view.
|
||||
* @return string New file path.
|
||||
*/
|
||||
public function network_admin_view( $file, $view ) {
|
||||
if ( 'version_control' === Param::get( 'view' ) && is_network_admin() && Helper::is_plugin_active_for_network() ) {
|
||||
return dirname( __FILE__ ) . '/display.php';
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter top nav links in the dashboard.
|
||||
*
|
||||
* @param array $nav_links Nav links.
|
||||
* @return array New nav links.
|
||||
*/
|
||||
public function network_admin_dashboard_tabs( $nav_links ) {
|
||||
if ( ! is_network_admin() ) {
|
||||
return $nav_links;
|
||||
}
|
||||
|
||||
if ( empty( $nav_links ) ) {
|
||||
$nav_links = [
|
||||
'help' => [
|
||||
'id' => 'help',
|
||||
'url' => '',
|
||||
'args' => '',
|
||||
'cap' => 'manage_options',
|
||||
'title' => esc_html__( 'Dashboard', 'rank-math' ),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$nav_links['version_control'] = [
|
||||
'id' => 'version_control',
|
||||
'url' => '',
|
||||
'args' => 'view=version_control',
|
||||
'cap' => 'manage_options',
|
||||
'title' => esc_html__( 'Version Control', 'rank-math' ),
|
||||
];
|
||||
return $nav_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add subpage to Status & Tools screen.
|
||||
*
|
||||
* @param array $pages Pages.
|
||||
* @return array New pages.
|
||||
*/
|
||||
public function add_status_page( $pages ) {
|
||||
$pages['version_control'] = [
|
||||
'url' => 'status',
|
||||
'args' => 'view=version_control',
|
||||
'cap' => 'install_plugins',
|
||||
'title' => __( 'Version Control', 'rank-math' ),
|
||||
'class' => '\\RankMath\\Version_Control',
|
||||
];
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change default tab on the Status & Tools screen.
|
||||
*
|
||||
* @param string $default Default tab.
|
||||
* @return string New default tab.
|
||||
*/
|
||||
public function change_default_tab( $default ) {
|
||||
if ( is_multisite() && ! current_user_can( 'setup_network' ) ) {
|
||||
return $default;
|
||||
}
|
||||
return 'version_control';
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue CSS & JS.
|
||||
*
|
||||
* @param string $hook Page hook name.
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue( $hook ) {
|
||||
if ( ! $this->should_enqueue( $hook ) ) {
|
||||
return;
|
||||
}
|
||||
$uri = untrailingslashit( plugin_dir_url( __FILE__ ) );
|
||||
wp_enqueue_style( 'rank-math-cmb2' );
|
||||
wp_enqueue_style( 'rank-math-version-control', $uri . '/assets/css/version-control.css', [], rank_math()->version );
|
||||
wp_enqueue_script( 'rank-math-version-control', $uri . '/assets/js/version-control.js', [ 'jquery' ], rank_math()->version, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rank Math plugin information.
|
||||
*
|
||||
* @return mixed Plugin information array or false on fail.
|
||||
*/
|
||||
public static function get_plugin_info() {
|
||||
$cache = get_transient( self::TRANSIENT );
|
||||
if ( $cache ) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$request = wp_remote_get( self::API_URL, [ 'timeout' => 20 ] );
|
||||
if ( ! is_wp_error( $request ) && is_array( $request ) ) {
|
||||
$response = json_decode( $request['body'], true );
|
||||
set_transient( self::TRANSIENT, $response, ( 12 * HOUR_IN_SECONDS ) );
|
||||
return $response;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin data to use in the `update_plugins` transient.
|
||||
*
|
||||
* @param string $version New version.
|
||||
* @param string $package New version download URL.
|
||||
* @return array An array of plugin metadata.
|
||||
*/
|
||||
public static function get_plugin_data( $version, $package ) {
|
||||
return [
|
||||
'id' => 'w.org/plugins/seo-by-rank-math',
|
||||
'slug' => 'seo-by-rank-math',
|
||||
'plugin' => 'seo-by-rank-math/rank-math.php',
|
||||
'new_version' => $version,
|
||||
'url' => 'https://wordpress.org/plugins/seo-by-rank-math/',
|
||||
'package' => $package,
|
||||
'icons' =>
|
||||
[
|
||||
'2x' => 'https://ps.w.org/seo-by-rank-math/assets/icon-256x256.png?rev=2034417',
|
||||
'1x' => 'https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=2034417',
|
||||
'svg' => 'https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=2034417',
|
||||
],
|
||||
'banners' =>
|
||||
[
|
||||
'2x' => 'https://ps.w.org/seo-by-rank-math/assets/banner-1544x500.png?rev=2034417',
|
||||
'1x' => 'https://ps.w.org/seo-by-rank-math/assets/banner-772x250.png?rev=2034417',
|
||||
],
|
||||
'banners_rtl' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Display forms.
|
||||
*/
|
||||
public function display() {
|
||||
$directory = dirname( __FILE__ );
|
||||
include_once $directory . '/display.php';
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Load variables and include view files.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Version_Control
|
||||
*/
|
||||
|
||||
namespace RankMath;
|
||||
|
||||
use RankMath\Helper;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( Rollback_Version::should_rollback() ) {
|
||||
$rollback = new Rollback_Version();
|
||||
$rollback->rollback();
|
||||
return;
|
||||
}
|
||||
|
||||
$directory = dirname( __FILE__ );
|
||||
$beta_optin = boolval( Helper::get_settings( 'general.beta_optin' ) );
|
||||
$update_notification = boolval( Helper::get_settings( 'general.update_notification_email' ) );
|
||||
$auto_update = boolval( Helper::get_auto_update_setting() );
|
||||
$versions = array_reverse( array_keys( Beta_Optin::get_available_versions( $beta_optin ) ) );
|
||||
$current_version = rank_math()->version;
|
||||
$latest_version = Beta_Optin::get_latest_version();
|
||||
array_splice( $versions, 10 );
|
||||
|
||||
require_once $directory . '/views/version-control-panel.php';
|
||||
require_once $directory . '/views/beta-optin-panel.php';
|
||||
require_once $directory . '/views/auto-update-panel.php';
|
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden.
|
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Auto Updater view in Version Control Tab.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Version_Control
|
||||
*/
|
||||
|
||||
use RankMath\Helper;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
?>
|
||||
<form id="cmb2-metabox-rank-math-auto-update" class="rank-math-auto-update-form cmb2-form rank-math-box" action="" method="post">
|
||||
|
||||
<header>
|
||||
<h3><?php esc_html_e( 'Auto Update', 'rank-math' ); ?></h3>
|
||||
</header>
|
||||
|
||||
<?php if ( Helper::is_plugin_update_disabled() ) : ?>
|
||||
<p><?php esc_html_e( 'You cannot turn on auto-updates to automatically update to stable versions of Rank Math as soon as they are released, because site wide plugins auto-update option is disabled on your site.', 'rank-math' ); ?></p>
|
||||
|
||||
<hr/>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! Helper::is_plugin_update_disabled() ) : ?>
|
||||
<p><?php esc_html_e( 'Turn on auto-updates to automatically update to stable versions of Rank Math as soon as they are released. The beta versions will never install automatically.', 'rank-math' ); ?></p>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr class="cmb-row cmb-type-switch">
|
||||
<th scope="row"><label><?php esc_html_e( 'Auto Update Plugin', 'rank-math' ); ?></label></th>
|
||||
<td>
|
||||
<label class="cmb2-toggle">
|
||||
<input type="hidden" name="enable_auto_update" id="enable_auto_update_hidden" value="off">
|
||||
<input type="checkbox" class="regular-text" name="enable_auto_update" id="enable_auto_update" value="on" <?php checked( $auto_update ); ?>>
|
||||
<span class="cmb2-slider">
|
||||
<svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg>
|
||||
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg>
|
||||
</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<div id="control_update_notification_email">
|
||||
<p><?php esc_html_e( 'When auto-updates are turned off, you can enable update notifications, to send an email to the site administrator when an update is available for Rank Math.', 'rank-math' ); ?></p>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr class="cmb-row cmb-type-switch">
|
||||
<th scope="row"><label><?php esc_html_e( 'Update Notification Email', 'rank-math' ); ?></label></th>
|
||||
<td>
|
||||
<label class="cmb2-toggle">
|
||||
<input type="hidden" name="enable_update_notification_email" id="enable_update_notification_email_hidden" value="off">
|
||||
<input type="checkbox" class="regular-text" name="enable_update_notification_email" id="enable_update_notification_email" value="on" <?php checked( $update_notification ); ?>>
|
||||
<span class="cmb2-slider">
|
||||
<svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg>
|
||||
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg>
|
||||
</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php if ( ! Helper::is_plugin_update_disabled() ) : ?>
|
||||
<?php if ( get_option( 'rank_math_rollback_version', false ) ) { ?>
|
||||
<div class="notice notice-alt notice-warning info inline" style="border: none;">
|
||||
<p>
|
||||
<?php esc_html_e( 'Rank Math will not auto-update because you have rolled back to a previous version. Update to the latest version manually to make this option work again.', 'rank-math' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<footer>
|
||||
<?php wp_nonce_field( 'rank-math-auto-update' ); ?>
|
||||
<button type="submit" class="button button-primary button-xlarge"><?php esc_html_e( 'Save Changes', 'rank-math' ); ?></button>
|
||||
</footer>
|
||||
|
||||
</form>
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Beta Opt-in view in Version Control Tab.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Version_Control
|
||||
*/
|
||||
|
||||
use RankMath\Helper;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
?>
|
||||
|
||||
<form id="cmb2-metabox-rank-math-beta-optin" class="rank-math-beta-optin-form cmb2-form rank-math-box" action="" method="post">
|
||||
|
||||
<header>
|
||||
<h3><?php esc_html_e( 'Beta Opt-in', 'rank-math' ); ?></h3>
|
||||
</header>
|
||||
|
||||
<?php if ( Helper::is_plugin_update_disabled() ) : ?>
|
||||
<p><?php esc_html_e( 'You cannot turn on the Beta Tester feature because site wide plugins auto-update option is disabled on your site.', 'rank-math' ); ?></p>
|
||||
|
||||
</form>
|
||||
<?php return; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<p><?php esc_html_e( 'You can take part in shaping Rank Math by test-driving the newest features and letting us know what you think. Turn on the Beta Tester feature to get notified about new beta releases. The beta version will not install automatically and you always have the option to ignore it.', 'rank-math' ); ?></p>
|
||||
<?php // translators: Warning. ?>
|
||||
<p class="description warning"><strong><?php printf( esc_html__( '%s It is not recommended to use the beta version on live production sites.', 'rank-math' ), '<span class="warning">' . esc_html__( 'Warning: ', 'rank-math' ) . '</span>' ); ?></strong></p>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr class="cmb-row cmb-type-switch">
|
||||
<th scope="row"><label><?php esc_html_e( 'Beta Tester', 'rank-math' ); ?></label></th>
|
||||
<td>
|
||||
<label class="cmb2-toggle">
|
||||
<input type="hidden" name="beta_optin" id="beta_optin_hidden" value="off">
|
||||
<input type="checkbox" class="regular-text" name="beta_optin" id="beta_optin" value="on" <?php checked( $beta_optin ); ?>>
|
||||
<span class="cmb2-slider">
|
||||
<svg width="3" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 6" class="toggle_on" role="img" aria-hidden="true" focusable="false"><path d="M0 0h2v6H0z"></path></svg>
|
||||
<svg width="8" height="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 6 6" class="toggle_off" role="img" aria-hidden="true" focusable="false"><path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path></svg>
|
||||
</span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<footer>
|
||||
<?php wp_nonce_field( 'rank-math-beta-optin' ); ?>
|
||||
<button type="submit" class="button button-primary button-xlarge"><?php esc_html_e( 'Save Changes', 'rank-math' ); ?></button>
|
||||
</footer>
|
||||
|
||||
</form>
|
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden.
|
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* The Version Control View.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Version_Control
|
||||
*/
|
||||
|
||||
namespace RankMath;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
?>
|
||||
<form class="rank-math-rollback-form cmb2-form rank-math-box" action="" method="post">
|
||||
|
||||
<header>
|
||||
<h3><?php esc_html_e( 'Rollback to Previous Version', 'rank-math' ); ?></h3>
|
||||
</header>
|
||||
|
||||
<p><?php esc_html_e( 'If you are facing issues after an update, you can reinstall a previous version with this tool.', 'rank-math' ); ?></p>
|
||||
<?php // translators: placeholder is the word "warning". ?>
|
||||
<p class="description warning"><strong><?php printf( esc_html__( '%s Previous versions may not be secure or stable. Proceed with caution and always create a backup.', 'rank-math' ), '<span class="warning">' . esc_html__( 'Warning: ', 'rank-math' ) . '</span>' ); ?></strong></p>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e( 'Your Version', 'rank-math' ); ?></label></th>
|
||||
<td>
|
||||
<strong>
|
||||
<?php echo esc_html( $current_version ); ?>
|
||||
</strong>
|
||||
<?php if ( Rollback_Version::is_rollback_version() ) { ?>
|
||||
<?php // Translators: placeholder is "Rolled Back Version:". ?>
|
||||
<br><?php printf( esc_html__( '%s Auto updates will not work, please update the plugin manually.', 'rank-math' ), '<span class="rollback-version-label">' . esc_html__( 'Rolled Back Version: ', 'rank-math' ) . '</span>' ); ?>
|
||||
<?php } ?>
|
||||
<?php if ( $current_version === $latest_version ) { ?>
|
||||
<p class="description"><?php esc_html_e( 'You are using the latest version of the plugin.', 'rank-math' ); ?></p>
|
||||
<?php } else { ?>
|
||||
<p class="description"><?php esc_html_e( 'This is the version you are using on this site.', 'rank-math' ); ?></p>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( $current_version !== $latest_version ) { ?>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e( 'Latest Stable Version', 'rank-math' ); ?></label></th>
|
||||
<td>
|
||||
<strong><?php echo esc_html( $latest_version ); ?></strong>
|
||||
<?php if ( ! Helper::is_plugin_update_disabled() && version_compare( $current_version, $latest_version, '<' ) ) { ?>
|
||||
<a href="<?php echo esc_url( self_admin_url( 'update-core.php' ) ); ?>" class="update-link"><?php esc_html_e( 'Update Now', 'rank-math' ); ?></a>
|
||||
<?php } ?>
|
||||
<p class="description"><?php esc_html_e( 'This is the latest version of the plugin.', 'rank-math' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e( 'Rollback Version', 'rank-math' ); ?></label></th>
|
||||
<td>
|
||||
<select class="cmb2_select" name="rm_rollback_version" id="rm_rollback_version">
|
||||
<?php foreach ( $versions as $version ) { ?>
|
||||
<option value="<?php echo esc_attr( $version ); ?>" <?php disabled( ( $version === $current_version ) ); ?>>
|
||||
<?php echo esc_html( $version ); ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<p class="description"><?php esc_html_e( 'Roll back to this version.', 'rank-math' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<footer>
|
||||
<?php wp_nonce_field( 'rank-math-rollback' ); ?>
|
||||
<?php // translators: Version number. ?>
|
||||
<button type="submit" class="button button-primary button-xlarge" id="rm-rollback-button" data-buttonlabel="<?php esc_attr_e( 'Install Version %s', 'rank-math' ); ?>"><?php esc_html_e( 'Install Selected Version', 'rank-math' ); ?></button>
|
||||
<div class="alignright hidden rollback-loading-indicator">
|
||||
<span class="loading-indicator-text"><?php esc_html_e( 'Reinstalling, please wait...', 'rank-math' ); ?></span>
|
||||
<span class="spinner is-active"></span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</form>
|
Reference in New Issue
Block a user