mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-01 03:58:07 +08:00
Refactoring
This commit is contained in:
parent
f2bf358b3a
commit
d130ab7e5f
21 changed files with 62 additions and 56 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace MainWP\Child;
|
namespace MainWP\Child;
|
||||||
|
|
||||||
|
// phpcs:disable WordPress.WP.AlternativeFunctions -- to custom functions.
|
||||||
|
|
||||||
class MainWP_Backup {
|
class MainWP_Backup {
|
||||||
protected static $instance = null;
|
protected static $instance = null;
|
||||||
protected $excludeZip;
|
protected $excludeZip;
|
||||||
|
@ -138,11 +140,11 @@ class MainWP_Backup {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function m_zip_file( $files, $archive ) {
|
public function m_zip_file( $files, $archive ) {
|
||||||
$this->zip = new ZipArchive();
|
$this->zip = new \ZipArchive();
|
||||||
$this->zipArchiveFileCount = 0;
|
$this->zipArchiveFileCount = 0;
|
||||||
$this->zipArchiveSizeCount = 0;
|
$this->zipArchiveSizeCount = 0;
|
||||||
|
|
||||||
$zipRes = $this->zip->open( $archive, ZipArchive::CREATE );
|
$zipRes = $this->zip->open( $archive, \ZipArchive::CREATE );
|
||||||
if ( $zipRes ) {
|
if ( $zipRes ) {
|
||||||
foreach ( $files as $file ) {
|
foreach ( $files as $file ) {
|
||||||
$this->add_fileToZip( $file, basename( $file ) );
|
$this->add_fileToZip( $file, basename( $file ) );
|
||||||
|
@ -161,7 +163,7 @@ class MainWP_Backup {
|
||||||
public function m_zip_file_pcl( $files, $archive ) {
|
public function m_zip_file_pcl( $files, $archive ) {
|
||||||
// Zip this backup folder.
|
// Zip this backup folder.
|
||||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||||
$this->zip = new PclZip( $archive );
|
$this->zip = new \PclZip( $archive );
|
||||||
|
|
||||||
$error = false;
|
$error = false;
|
||||||
foreach ( $files as $file ) {
|
foreach ( $files as $file ) {
|
||||||
|
@ -180,7 +182,7 @@ class MainWP_Backup {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function check_zip_support() {
|
public function check_zip_support() {
|
||||||
return class_exists( 'ZipArchive' );
|
return class_exists( '\ZipArchive' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,11 +203,11 @@ class MainWP_Backup {
|
||||||
*/
|
*/
|
||||||
public function create_zip_full_backup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) {
|
public function create_zip_full_backup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp ) {
|
||||||
$this->excludeZip = $excludezip;
|
$this->excludeZip = $excludezip;
|
||||||
$this->zip = new ZipArchive();
|
$this->zip = new \ZipArchive();
|
||||||
$this->zipArchiveFileCount = 0;
|
$this->zipArchiveFileCount = 0;
|
||||||
$this->zipArchiveSizeCount = 0;
|
$this->zipArchiveSizeCount = 0;
|
||||||
$this->zipArchiveFileName = $filepath;
|
$this->zipArchiveFileName = $filepath;
|
||||||
$zipRes = $this->zip->open( $filepath, ZipArchive::CREATE );
|
$zipRes = $this->zip->open( $filepath, \ZipArchive::CREATE );
|
||||||
if ( $zipRes ) {
|
if ( $zipRes ) {
|
||||||
$nodes = glob( ABSPATH . '*' );
|
$nodes = glob( ABSPATH . '*' );
|
||||||
if ( ! $includeCoreFiles ) {
|
if ( ! $includeCoreFiles ) {
|
||||||
|
@ -442,7 +444,7 @@ class MainWP_Backup {
|
||||||
|
|
||||||
// Zip this backup folder.
|
// Zip this backup folder.
|
||||||
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
|
||||||
$this->zip = new PclZip( $filepath );
|
$this->zip = new \PclZip( $filepath );
|
||||||
$this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder );
|
$this->zip->create( $backupFolder, PCLZIP_OPT_REMOVE_PATH, $backupFolder );
|
||||||
if ( $addConfig ) {
|
if ( $addConfig ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
@ -614,7 +616,7 @@ class MainWP_Backup {
|
||||||
if ( function_exists( 'gc_collect_cycles' ) ) {
|
if ( function_exists( 'gc_collect_cycles' ) ) {
|
||||||
gc_collect_cycles();
|
gc_collect_cycles();
|
||||||
}
|
}
|
||||||
$this->zip = new ZipArchive();
|
$this->zip = new \ZipArchive();
|
||||||
$this->zip->open( $this->zipArchiveFileName );
|
$this->zip->open( $this->zipArchiveFileName );
|
||||||
$this->zipArchiveFileCount = 0;
|
$this->zipArchiveFileCount = 0;
|
||||||
$this->zipArchiveSizeCount = 0;
|
$this->zipArchiveSizeCount = 0;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/mainwpbuddy/
|
* Extension URL: https://mainwp.com/extension/mainwpbuddy/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_Back_Up_Buddy {
|
class MainWP_Child_Back_Up_Buddy {
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/backupwordpress/
|
* Extension URL: https://mainwp.com/extension/backupwordpress/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_Back_Up_WordPress {
|
class MainWP_Child_Back_Up_WordPress {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/backwpup/
|
* Extension URL: https://mainwp.com/extension/backwpup/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) {
|
if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) {
|
||||||
define( 'MAINWP_BACKWPUP_DEVELOPMENT', false );
|
define( 'MAINWP_BACKWPUP_DEVELOPMENT', false );
|
||||||
|
|
|
@ -206,7 +206,7 @@ class MainWP_Child_Install {
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ( $urls as $url ) {
|
foreach ( $urls as $url ) {
|
||||||
$installer = new WP_Upgrader();
|
$installer = new \WP_Upgrader();
|
||||||
$ssl_verify = true;
|
$ssl_verify = true;
|
||||||
// @see wp-admin/includes/class-wp-upgrader.php
|
// @see wp-admin/includes/class-wp-upgrader.php
|
||||||
if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) {
|
if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/ithemes-security/
|
* Extension URL: https://mainwp.com/extension/ithemes-security/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_IThemes_Security {
|
class MainWP_Child_IThemes_Security {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* The code is used for the MainWP Broken Links Checker Extension (Retired Extension)
|
* The code is used for the MainWP Broken Links Checker Extension (Retired Extension)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_Links_Checker {
|
class MainWP_Child_Links_Checker {
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/page-speed/
|
* Extension URL: https://mainwp.com/extension/page-speed/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_Pagespeed {
|
class MainWP_Child_Pagespeed {
|
||||||
|
|
||||||
|
|
|
@ -1074,7 +1074,7 @@ class MainWP_Child_Server_Information {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function get_zip_archive_enabled() {
|
protected static function get_zip_archive_enabled() {
|
||||||
return class_exists( 'ZipArchive' );
|
return class_exists( '\ZipArchive' );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function get_gzip_enabled() {
|
protected static function get_gzip_enabled() {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
* Extension URL: https://mainwp.com/extension/staging/
|
* Extension URL: https://mainwp.com/extension/staging/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_Staging {
|
class MainWP_Child_Staging {
|
||||||
|
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
|
@ -166,9 +166,7 @@ class MainWP_Child_Stats {
|
||||||
|
|
||||||
$information['dbsize'] = MainWP_Child_DB::get_size();
|
$information['dbsize'] = MainWP_Child_DB::get_size();
|
||||||
|
|
||||||
global $mainWPChild;
|
$max_his = MainWP_Connect::instance()->get_max_history();
|
||||||
$max_his = $mainWPChild->get_max_history();
|
|
||||||
|
|
||||||
$auths = get_option( 'mainwp_child_auth' );
|
$auths = get_option( 'mainwp_child_auth' );
|
||||||
$information['extauth'] = ( $auths && isset( $auths[ $max_his ] ) ? $auths[ $max_his ] : null );
|
$information['extauth'] = ( $auths && isset( $auths[ $max_his ] ) ? $auths[ $max_his ] : null );
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/time-capsule/
|
* Extension URL: https://mainwp.com/extension/time-capsule/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_Timecapsule {
|
class MainWP_Child_Timecapsule {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
|
@ -96,7 +96,7 @@ class MainWP_Child_Updates {
|
||||||
$slug = ( isset( $update['slug'] ) ? $update['slug'] : $update['Name'] );
|
$slug = ( isset( $update['slug'] ) ? $update['slug'] : $update['Name'] );
|
||||||
|
|
||||||
if ( isset( $update['url'] ) ) {
|
if ( isset( $update['url'] ) ) {
|
||||||
$installer = new WP_Upgrader();
|
$installer = new \WP_Upgrader();
|
||||||
$result = $installer->run(
|
$result = $installer->run(
|
||||||
array(
|
array(
|
||||||
'package' => $update['url'],
|
'package' => $update['url'],
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/woocommerce-status/
|
* Extension URL: https://mainwp.com/extension/woocommerce-status/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_WooCommerce_Status {
|
class MainWP_Child_WooCommerce_Status {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/wordfence/
|
* Extension URL: https://mainwp.com/extension/wordfence/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_Wordfence {
|
class MainWP_Child_Wordfence {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/rocket/
|
* Extension URL: https://mainwp.com/extension/rocket/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_WP_Rocket {
|
class MainWP_Child_WP_Rocket {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_Child_WPvivid_BackupRestore {
|
class MainWP_Child_WPvivid_BackupRestore {
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class MainWP_Child {
|
||||||
|
|
||||||
public $plugin_slug;
|
public $plugin_slug;
|
||||||
private $plugin_dir;
|
private $plugin_dir;
|
||||||
private $maxHistory = 5;
|
|
||||||
|
|
||||||
public static $brandingTitle = null;
|
public static $brandingTitle = null;
|
||||||
|
|
||||||
|
@ -756,10 +756,6 @@ class MainWP_Child {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_max_history() {
|
|
||||||
return $this->maxHistory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function parse_init() {
|
public function parse_init() {
|
||||||
|
|
||||||
if ( isset( $_REQUEST['cloneFunc'] ) ) {
|
if ( isset( $_REQUEST['cloneFunc'] ) ) {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace MainWP\Child;
|
namespace MainWP\Child;
|
||||||
|
|
||||||
|
// phpcs:disable WordPress.WP.AlternativeFunctions -- to custom functions.
|
||||||
|
|
||||||
class MainWP_Clone_Install {
|
class MainWP_Clone_Install {
|
||||||
protected $file;
|
protected $file;
|
||||||
public $config;
|
public $config;
|
||||||
|
@ -34,7 +36,7 @@ class MainWP_Clone_Install {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function check_zip_support() {
|
public function check_zip_support() {
|
||||||
return class_exists( 'ZipArchive' );
|
return class_exists( '\ZipArchive' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +62,7 @@ class MainWP_Clone_Install {
|
||||||
} elseif ( $this->check_zip_console() ) {
|
} elseif ( $this->check_zip_console() ) {
|
||||||
return false;
|
return false;
|
||||||
} elseif ( $this->check_zip_support() ) {
|
} elseif ( $this->check_zip_support() ) {
|
||||||
$zip = new ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$zipRes = $zip->open( $this->file );
|
$zipRes = $zip->open( $this->file );
|
||||||
if ( $zipRes ) {
|
if ( $zipRes ) {
|
||||||
$zip->deleteName( 'wp-config.php' );
|
$zip->deleteName( 'wp-config.php' );
|
||||||
|
@ -72,7 +74,7 @@ class MainWP_Clone_Install {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$zip = new PclZip( $this->file );
|
$zip = new \PclZip( $this->file );
|
||||||
$list = $zip->delete( PCLZIP_OPT_BY_NAME, 'wp-config.php' );
|
$list = $zip->delete( PCLZIP_OPT_BY_NAME, 'wp-config.php' );
|
||||||
$list2 = $zip->delete( PCLZIP_OPT_BY_NAME, 'clone' );
|
$list2 = $zip->delete( PCLZIP_OPT_BY_NAME, 'clone' );
|
||||||
if ( 0 === $list ) {
|
if ( 0 === $list ) {
|
||||||
|
@ -115,7 +117,7 @@ class MainWP_Clone_Install {
|
||||||
} elseif ( $this->check_zip_console() ) {
|
} elseif ( $this->check_zip_console() ) {
|
||||||
return false;
|
return false;
|
||||||
} elseif ( $this->check_zip_support() ) {
|
} elseif ( $this->check_zip_support() ) {
|
||||||
$zip = new ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$zipRes = $zip->open( $this->file );
|
$zipRes = $zip->open( $this->file );
|
||||||
if ( $zipRes ) {
|
if ( $zipRes ) {
|
||||||
$content = $zip->locateName( $file );
|
$content = $zip->locateName( $file );
|
||||||
|
@ -292,7 +294,7 @@ class MainWP_Clone_Install {
|
||||||
if ( $this->check_zip_console() ) {
|
if ( $this->check_zip_console() ) {
|
||||||
return false;
|
return false;
|
||||||
} elseif ( $this->check_zip_support() ) {
|
} elseif ( $this->check_zip_support() ) {
|
||||||
$zip = new ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$zipRes = $zip->open( $this->file );
|
$zipRes = $zip->open( $this->file );
|
||||||
if ( $zipRes ) {
|
if ( $zipRes ) {
|
||||||
$content = $zip->get_from_name( 'clone/config.txt' );
|
$content = $zip->get_from_name( 'clone/config.txt' );
|
||||||
|
@ -303,7 +305,7 @@ class MainWP_Clone_Install {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$zip = new PclZip( $this->file );
|
$zip = new \PclZip( $this->file );
|
||||||
$content = $zip->extract( PCLZIP_OPT_BY_NAME, 'clone/config.txt', PCLZIP_OPT_EXTRACT_AS_STRING );
|
$content = $zip->extract( PCLZIP_OPT_BY_NAME, 'clone/config.txt', PCLZIP_OPT_EXTRACT_AS_STRING );
|
||||||
if ( ! is_array( $content ) || ! isset( $content[0]['content'] ) ) {
|
if ( ! is_array( $content ) || ! isset( $content[0]['content'] ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -350,7 +352,7 @@ class MainWP_Clone_Install {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function extract_zip_backup() {
|
public function extract_zip_backup() {
|
||||||
$zip = new ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$zipRes = $zip->open( $this->file );
|
$zipRes = $zip->open( $this->file );
|
||||||
if ( $zipRes ) {
|
if ( $zipRes ) {
|
||||||
$zip->extract_to( ABSPATH );
|
$zip->extract_to( ABSPATH );
|
||||||
|
@ -379,7 +381,7 @@ class MainWP_Clone_Install {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function extract_zip_pcl_backup() {
|
public function extract_zip_pcl_backup() {
|
||||||
$zip = new PclZip( $this->file );
|
$zip = new \PclZip( $this->file );
|
||||||
if ( 0 === $zip->extract( PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER ) ) {
|
if ( 0 === $zip->extract( PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -611,7 +613,7 @@ class MainWP_Clone_Install {
|
||||||
if ( ! isset( $_REQUEST['f'] ) || ( '' === $_REQUEST['f'] ) ) {
|
if ( ! isset( $_REQUEST['f'] ) || ( '' === $_REQUEST['f'] ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( ! $this->is_valid_auth( $_REQUEST['key'] ) ) {
|
if ( ! MainWP_Connect::instance()->is_valid_auth( $_REQUEST['key'] ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,19 +727,4 @@ class MainWP_Clone_Install {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function is_valid_auth( $key ) {
|
|
||||||
$auths = get_option( 'mainwp_child_auth' );
|
|
||||||
if ( ! $auths ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for ( $i = 0; $i <= $this->maxHistory; $i ++ ) {
|
|
||||||
if ( isset( $auths[ $i ] ) && ( $auths[ $i ] === $key ) ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@ namespace MainWP\Child;
|
||||||
|
|
||||||
class MainWP_Connect {
|
class MainWP_Connect {
|
||||||
|
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
private $maxHistory = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method get_class_name()
|
* Method get_class_name()
|
||||||
|
@ -459,4 +460,24 @@ class MainWP_Connect {
|
||||||
MainWP_Helper::update_option( 'mainwp_child_auth', $auths, 'yes' );
|
MainWP_Helper::update_option( 'mainwp_child_auth', $auths, 'yes' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function is_valid_auth( $key ) {
|
||||||
|
$auths = get_option( 'mainwp_child_auth' );
|
||||||
|
if ( ! $auths ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for ( $i = 0; $i <= $this->maxHistory; $i ++ ) {
|
||||||
|
if ( isset( $auths[ $i ] ) && ( $auths[ $i ] === $key ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_max_history() {
|
||||||
|
return $this->maxHistory;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* Extension URL: https://mainwp.com/extension/wordpress-seo/
|
* Extension URL: https://mainwp.com/extension/wordpress-seo/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- use external code.
|
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
|
||||||
|
|
||||||
class MainWP_WordPress_SEO {
|
class MainWP_WordPress_SEO {
|
||||||
public static $instance = null;
|
public static $instance = null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue