Refactoring

This commit is contained in:
thanghv 2020-05-20 20:15:29 +07:00
parent a63b447496
commit cb60afea0d
30 changed files with 351 additions and 402 deletions

View file

@ -12,6 +12,7 @@
* Extension URL: https://mainwp.com/extension/mainwpbuddy/ * Extension URL: https://mainwp.com/extension/mainwpbuddy/
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable -- third party credit. // phpcs:disable -- third party credit.
class MainWP_Child_Back_Up_Buddy { class MainWP_Child_Back_Up_Buddy {
@ -60,7 +61,7 @@ class MainWP_Child_Back_Up_Buddy {
return $value; return $value;
} }
if ( ! MainWP_Helper::is_screen_with_update() ) { if ( ! MainWP_Helper::is_updates_screen() ) {
return $value; return $value;
} }
@ -216,7 +217,7 @@ class MainWP_Child_Back_Up_Buddy {
public function action() { public function action() {
$information = array(); $information = array();
if ( ! $this->is_backupbuddy_installed ) { if ( ! $this->is_backupbuddy_installed ) {
mainwp_child_helper()->write( array( 'error' => __( 'Please install the BackupBuddy plugin on the child site.', $this->plugin_translate ) ) ); MainWP_Helper::write( array( 'error' => __( 'Please install the BackupBuddy plugin on the child site.', $this->plugin_translate ) ) );
} }
if ( ! class_exists( 'backupbuddy_core' ) ) { if ( ! class_exists( 'backupbuddy_core' ) ) {
@ -369,7 +370,7 @@ class MainWP_Child_Back_Up_Buddy {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -791,7 +792,7 @@ class MainWP_Child_Back_Up_Buddy {
$time = $this->localize_time( $finish_time ); $time = $this->localize_time( $finish_time );
$data['lastBackupStats'] = date( 'M j - g:i A', $time ); // phpcs:ignore -- local time. $data['lastBackupStats'] = date( 'M j - g:i A', $time ); // phpcs:ignore -- local time.
$data['lasttime_backup'] = $finish_time; $data['lasttime_backup'] = $finish_time;
mainwp_child_helper()->update_lasttime_backup( 'backupbuddy', $finish_time ); // support Require Backup Before Update feature. MainWP_Helper::instance()->update_lasttime_backup( 'backupbuddy', $finish_time ); // support Require Backup Before Update feature.
} else { } else {
$data['lastBackupStats'] = 'Unknown'; $data['lastBackupStats'] = 'Unknown';
} }
@ -1264,7 +1265,7 @@ class MainWP_Child_Back_Up_Buddy {
// Calculate main row string. // Calculate main row string.
if ( 'default' == $type ) { // Default backup listing. if ( 'default' == $type ) { // Default backup listing.
$download_url = '/wp-admin/admin-ajax.php?action=mainwp_backupbuddy_download_archive&backupbuddy_backup=' . basename( $file ) . '&_wpnonce=' . mainwp_child_helper()->create_nonce_without_session( 'mainwp_download_backup' ); $download_url = '/wp-admin/admin-ajax.php?action=mainwp_backupbuddy_download_archive&backupbuddy_backup=' . basename( $file ) . '&_wpnonce=' . MainWP_Helper::instance()->create_nonce_without_session( 'mainwp_download_backup' );
$main_string = '<a href="#" download-url="' . $download_url . '"class="backupbuddyFileTitle mwp_bb_download_backup_lnk" title="' . basename( $file ) . '">' . $modified . ' (' . $time_ago . ')</a>'; $main_string = '<a href="#" download-url="' . $download_url . '"class="backupbuddyFileTitle mwp_bb_download_backup_lnk" title="' . basename( $file ) . '">' . $modified . ' (' . $time_ago . ')</a>';
} elseif ( 'migrate' == $type ) { // Migration backup listing. } elseif ( 'migrate' == $type ) { // Migration backup listing.
$main_string = '<a class="pb_backupbuddy_hoveraction_migrate backupbuddyFileTitle" rel="' . basename( $file ) . '" href="' . pb_backupbuddy::page_url() . '&migrate=' . basename( $file ) . '&value=' . basename( $file ) . '" title="' . basename( $file ) . '">' . $modified . ' (' . $time_ago . ')</a>'; $main_string = '<a class="pb_backupbuddy_hoveraction_migrate backupbuddyFileTitle" rel="' . basename( $file ) . '" href="' . pb_backupbuddy::page_url() . '&migrate=' . basename( $file ) . '&value=' . basename( $file ) . '" title="' . basename( $file ) . '">' . $modified . ' (' . $time_ago . ')</a>';
@ -1760,7 +1761,7 @@ class MainWP_Child_Back_Up_Buddy {
die( '-1' ); die( '-1' );
} }
if ( ! mainwp_child_helper()->verify_nonce_without_session( $_GET['_wpnonce'], 'mainwp_download_backup' ) ) { if ( ! MainWP_Helper::instance()->verify_nonce_without_session( $_GET['_wpnonce'], 'mainwp_download_backup' ) ) {
die( '-2' ); die( '-2' );
} }

View file

@ -13,6 +13,8 @@
* Extension URL: https://mainwp.com/extension/backupwordpress/ * Extension URL: https://mainwp.com/extension/backupwordpress/
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -65,7 +67,7 @@ class MainWP_Child_Back_Up_WordPress {
return $value; return $value;
} }
if ( ! MainWP_Helper::is_screen_with_update() ) { if ( ! MainWP_Helper::is_updates_screen() ) {
return $value; return $value;
} }
if ( isset( $value->response['backupwordpress/backupwordpress.php'] ) ) { if ( isset( $value->response['backupwordpress/backupwordpress.php'] ) ) {
@ -79,7 +81,7 @@ class MainWP_Child_Back_Up_WordPress {
$information = array(); $information = array();
if ( ! self::is_activated() ) { if ( ! self::is_activated() ) {
$information['error'] = 'NO_BACKUPWORDPRESS'; $information['error'] = 'NO_BACKUPWORDPRESS';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) { switch ( $_POST['mwp_action'] ) {
@ -127,7 +129,7 @@ class MainWP_Child_Back_Up_WordPress {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -135,13 +137,13 @@ class MainWP_Child_Back_Up_WordPress {
$schedule_id = ( isset( $_POST['schedule_id'] ) && ! empty( $_POST['schedule_id'] ) ) ? $_POST['schedule_id'] : ''; $schedule_id = ( isset( $_POST['schedule_id'] ) && ! empty( $_POST['schedule_id'] ) ) ? $_POST['schedule_id'] : '';
if ( empty( $schedule_id ) ) { if ( empty( $schedule_id ) ) {
$information = array( 'error' => 'Empty schedule id' ); $information = array( 'error' => 'Empty schedule id' );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} else { } else {
$schedule_id = sanitize_text_field( rawurldecode( $schedule_id ) ); $schedule_id = sanitize_text_field( rawurldecode( $schedule_id ) );
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules(); HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
if ( ! HM\BackUpWordPress\Schedules::get_instance()->get_schedule( $schedule_id ) ) { if ( ! HM\BackUpWordPress\Schedules::get_instance()->get_schedule( $schedule_id ) ) {
$information = array( 'result' => 'NOTFOUND' ); $information = array( 'result' => 'NOTFOUND' );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
} }
@ -225,7 +227,7 @@ class MainWP_Child_Back_Up_WordPress {
$date = filemtime( $file ); $date = filemtime( $file );
if ( ! empty( $date ) ) { if ( ! empty( $date ) ) {
do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date ); do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date );
mainwp_child_helper()->update_lasttime_backup( 'backupwordpress', $date ); // to support backup before update feature. MainWP_Helper::instance()->update_lasttime_backup( 'backupwordpress', $date ); // to support backup before update feature.
} }
} }
} }

View file

@ -15,6 +15,8 @@
// phpcs:disable -- third party credit. // phpcs:disable -- third party credit.
use MainWP\Child\MainWP_Helper;
if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) { if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) {
define( 'MAINWP_BACKWPUP_DEVELOPMENT', false ); define( 'MAINWP_BACKWPUP_DEVELOPMENT', false );
} }
@ -77,21 +79,21 @@ class MainWP_Child_Back_WP_Up {
$file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php'; $file_path2 = plugin_dir_path( __FILE__ ) . '../../backwpup-pro/inc/pro/class-pro.php';
} }
mainwp_child_helper()->check_files_exists( array( $file_path1, $file_path2 ) ); MainWP_Helper::instance()->check_files_exists( array( $file_path1, $file_path2 ) );
require_once $file_path1; require_once $file_path1;
require_once $file_path2; require_once $file_path2;
$this->is_backwpup_installed = true; $this->is_backwpup_installed = true;
$this->is_backwpup_pro = true; $this->is_backwpup_pro = true;
} elseif ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) { } elseif ( is_plugin_active( 'backwpup/backwpup.php' ) && file_exists( plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php' ) ) {
$file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php'; $file_path = plugin_dir_path( __FILE__ ) . '../../backwpup/backwpup.php';
mainwp_child_helper()->check_files_exists( array( $file_path ) ); MainWP_Helper::instance()->check_files_exists( array( $file_path ) );
require_once $file_path; require_once $file_path;
$this->is_backwpup_installed = true; $this->is_backwpup_installed = true;
} }
if ( $this->is_backwpup_installed ) { if ( $this->is_backwpup_installed ) {
mainwp_child_helper()->check_classes_exists( '\BackWPup' ); MainWP_Helper::instance()->check_classes_exists( '\BackWPup' );
mainwp_child_helper()->check_methods( 'get_instance' ); MainWP_Helper::instance()->check_methods( 'get_instance' );
\BackWPup::get_instance(); \BackWPup::get_instance();
add_action( 'admin_init', array( $this, 'init_download_backup' ) ); add_action( 'admin_init', array( $this, 'init_download_backup' ) );
@ -104,7 +106,7 @@ class MainWP_Child_Back_WP_Up {
public function action() { public function action() {
if ( ! $this->is_backwpup_installed ) { if ( ! $this->is_backwpup_installed ) {
mainwp_child_helper()->write( array( 'error' => __( 'Please install BackWPup plugin on child website', 'mainwp-child' ) ) ); MainWP_Helper::write( array( 'error' => __( 'Please install BackWPup plugin on child website', 'mainwp-child' ) ) );
return; return;
} }
@ -112,11 +114,11 @@ class MainWP_Child_Back_WP_Up {
$error = error_get_last(); $error = error_get_last();
$info = self::$information; $info = self::$information;
if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) { if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) {
mainwp_child_helper()->write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
} elseif ( ! empty( $info ) ) { } elseif ( ! empty( $info ) ) {
mainwp_child_helper()->write( self::$information ); MainWP_Helper::write( self::$information );
} else { } else {
mainwp_child_helper()->write( array( 'error' => 'Missing information array inside fatal_error' ) ); MainWP_Helper::write( array( 'error' => 'Missing information array inside fatal_error' ) );
} }
} }
@ -242,11 +244,11 @@ class MainWP_Child_Back_WP_Up {
try { try {
mainwp_child_helper()->check_classes_exists( array( '\BackWPup_File', '\BackWPup_Job' ) ); MainWP_Helper::instance()->check_classes_exists( array( '\BackWPup_File', '\BackWPup_Job' ) );
mainwp_child_helper()->check_methods( '\BackWPup_File', array( 'get_absolute_path' ) ); MainWP_Helper::instance()->check_methods( '\BackWPup_File', array( 'get_absolute_path' ) );
mainwp_child_helper()->check_methods( '\BackWPup_Job', array( 'read_logheader' ) ); MainWP_Helper::instance()->check_methods( '\BackWPup_Job', array( 'read_logheader' ) );
$lasttime_logged = mainwp_child_helper()->get_lasttime_backup( 'backwpup' ); $lasttime_logged = MainWP_Helper::instance()->get_lasttime_backup( 'backwpup' );
$log_folder = get_site_option( 'backwpup_cfg_logfolder' ); $log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = \BackWPup_File::get_absolute_path( $log_folder ); $log_folder = \BackWPup_File::get_absolute_path( $log_folder );
@ -317,7 +319,7 @@ class MainWP_Child_Back_WP_Up {
} }
if ( $new_lasttime_logged > $lasttime_logged ) { if ( $new_lasttime_logged > $lasttime_logged ) {
mainwp_child_helper()->update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature. MainWP_Helper::instance()->update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature.
} }
} }
} catch ( \Exception $ex ) { } catch ( \Exception $ex ) {
@ -328,7 +330,7 @@ class MainWP_Child_Back_WP_Up {
public function sync_others_data( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) { if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) {
try { try {
$lastbackup = mainwp_child_helper()->get_lasttime_backup( 'backwpup' ); $lastbackup = MainWP_Helper::instance()->get_lasttime_backup( 'backwpup' );
$information['syncBackwpupData'] = array( $information['syncBackwpupData'] = array(
'lastbackup' => $lastbackup, 'lastbackup' => $lastbackup,
); );
@ -340,9 +342,9 @@ class MainWP_Child_Back_WP_Up {
} }
public function get_destinations_list() { public function get_destinations_list() {
mainwp_child_helper()->check_classes_exists( array( '\BackWPup', '\BackWPup_Option' ) ); MainWP_Helper::instance()->check_classes_exists( array( '\BackWPup', '\BackWPup_Option' ) );
mainwp_child_helper()->check_methods( '\BackWPup', array( 'get_registered_destinations', 'get_destination' ) ); MainWP_Helper::instance()->check_methods( '\BackWPup', array( 'get_registered_destinations', 'get_destination' ) );
mainwp_child_helper()->check_methods( '\BackWPup_Option', array( 'get_job_ids', 'get' ) ); MainWP_Helper::instance()->check_methods( '\BackWPup_Option', array( 'get_job_ids', 'get' ) );
$jobdest = array(); $jobdest = array();
$jobids = \BackWPup_Option::get_job_ids(); $jobids = \BackWPup_Option::get_job_ids();
@ -401,7 +403,7 @@ class MainWP_Child_Back_WP_Up {
$hide = isset( $_POST['show_hide'] ) && ( '1' === $_POST['show_hide'] ) ? 'hide' : ''; $hide = isset( $_POST['show_hide'] ) && ( '1' === $_POST['show_hide'] ) ? 'hide' : '';
mainwp_child_helper()->update_option( 'mainwp_backwpup_hide_plugin', $hide, 'yes' ); MainWP_Helper::instance()->update_option( 'mainwp_backwpup_hide_plugin', $hide, 'yes' );
return array( 'success' => 1 ); return array( 'success' => 1 );
} }

View file

@ -124,7 +124,7 @@ class MainWP_Child_Branding {
$information = $this->update_branding(); $information = $this->update_branding();
break; break;
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function update_branding() { public function update_branding() {
@ -1121,7 +1121,7 @@ class MainWP_Child_Branding {
return $value; return $value;
} }
if ( ! MainWP_Helper::is_screen_with_update() ) { if ( ! MainWP_Helper::is_updates_screen() ) {
return $value; return $value;
} }

View file

@ -191,7 +191,7 @@ class MainWP_Child_Callable {
) )
); );
} }
mainwp_child_helper()->write( $ids ); MainWP_Helper::write( $ids );
} }
public function theme_action() { public function theme_action() {
@ -250,12 +250,12 @@ class MainWP_Child_Callable {
$maint_options = $_POST['options']; $maint_options = $_POST['options'];
if ( ! is_array( $maint_options ) ) { if ( ! is_array( $maint_options ) ) {
mainwp_child_helper()->write( array( 'status' => 'FAIL' ) ); // exit. MainWP_Helper::write( array( 'status' => 'FAIL' ) ); // exit.
} }
$max_revisions = isset( $_POST['revisions'] ) ? intval( $_POST['revisions'] ) : 0; $max_revisions = isset( $_POST['revisions'] ) ? intval( $_POST['revisions'] ) : 0;
$information = $this->maintenance_db( $maint_options, $max_revisions ); $information = $this->maintenance_db( $maint_options, $max_revisions );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
private function maintenance_db( $maint_options, $max_revisions ) { private function maintenance_db( $maint_options, $max_revisions ) {
@ -387,17 +387,17 @@ class MainWP_Child_Callable {
delete_option( 'mainwp_maintenance_opt_alert_404_email' ); delete_option( 'mainwp_maintenance_opt_alert_404_email' );
} }
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
return; return;
} elseif ( 'clear_settings' === $action ) { } elseif ( 'clear_settings' === $action ) {
delete_option( 'mainwp_maintenance_opt_alert_404' ); delete_option( 'mainwp_maintenance_opt_alert_404' );
delete_option( 'mainwp_maintenance_opt_alert_404_email' ); delete_option( 'mainwp_maintenance_opt_alert_404_email' );
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function new_post() { public function new_post() {
@ -424,7 +424,7 @@ class MainWP_Child_Callable {
$information['site_url'] = get_option( 'site_url' ); $information['site_url'] = get_option( 'site_url' );
$information['home'] = get_option( 'home' ); $information['home'] = get_option( 'home' );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function backup_poll() { public function backup_poll() {
@ -449,10 +449,10 @@ class MainWP_Child_Callable {
} }
} }
if ( false === $archiveFile ) { if ( false === $archiveFile ) {
mainwp_child_helper()->write( array() ); MainWP_Helper::write( array() );
} }
mainwp_child_helper()->write( array( 'size' => filesize( $archiveFile ) ) ); MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) );
} else { } else {
$backupFile = 'dbBackup-' . $fileNameUID . '-*.sql'; $backupFile = 'dbBackup-' . $fileNameUID . '-*.sql';
@ -460,14 +460,14 @@ class MainWP_Child_Callable {
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$result = glob( $backupdir . $backupFile . '*' ); $result = glob( $backupdir . $backupFile . '*' );
if ( 0 === count( $result ) ) { if ( 0 === count( $result ) ) {
mainwp_child_helper()->write( array() ); MainWP_Helper::write( array() );
} }
$size = 0; $size = 0;
foreach ( $result as $f ) { foreach ( $result as $f ) {
$size += filesize( $f ); $size += filesize( $f );
} }
mainwp_child_helper()->write( array( 'size' => $size ) ); MainWP_Helper::write( array( 'size' => $size ) );
exit(); exit();
} }
} }
@ -518,7 +518,7 @@ class MainWP_Child_Callable {
$information['status'] = 'invalid'; $information['status'] = 'invalid';
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function backup( $pWrite = true ) { public function backup( $pWrite = true ) {
@ -580,7 +580,7 @@ class MainWP_Child_Callable {
} }
if ( $pWrite ) { if ( $pWrite ) {
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
return $information; return $information;
@ -717,7 +717,7 @@ class MainWP_Child_Callable {
if ( ! empty( $url ) ) { if ( ! empty( $url ) ) {
$information['faviIconUrl'] = $url; $information['faviIconUrl'] = $url;
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function get_favicon( $parse_page = false ) { public function get_favicon( $parse_page = false ) {
@ -808,7 +808,7 @@ class MainWP_Child_Callable {
$information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' ); $information['admin'] = ( MainWP_Security::admin_user_ok() ? 'Y' : 'N' );
$information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' ); $information['readme'] = ( MainWP_Security::remove_readme_ok() ? 'Y' : 'N' );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -886,7 +886,7 @@ class MainWP_Child_Callable {
if ( $sync ) { if ( $sync ) {
$information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false ); $information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false );
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function do_security_un_fix() { public function do_security_un_fix() {
@ -941,7 +941,7 @@ class MainWP_Child_Callable {
$information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false ); $information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false );
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function settings_tools() { public function settings_tools() {
@ -949,7 +949,7 @@ class MainWP_Child_Callable {
switch ( $_POST['action'] ) { switch ( $_POST['action'] ) {
case 'force_destroy_sessions': case 'force_destroy_sessions':
if ( 0 === get_current_user_id() ) { if ( 0 === get_current_user_id() ) {
mainwp_child_helper()->write( array( 'error' => __( 'Cannot get user_id', 'mainwp-child' ) ) ); MainWP_Helper::write( array( 'error' => __( 'Cannot get user_id', 'mainwp-child' ) ) );
} }
wp_destroy_all_sessions(); wp_destroy_all_sessions();
@ -957,17 +957,17 @@ class MainWP_Child_Callable {
$sessions = wp_get_all_sessions(); $sessions = wp_get_all_sessions();
if ( empty( $sessions ) ) { if ( empty( $sessions ) ) {
mainwp_child_helper()->write( array( 'success' => 1 ) ); MainWP_Helper::write( array( 'success' => 1 ) );
} else { } else {
mainwp_child_helper()->write( array( 'error' => __( 'Cannot destroy sessions', 'mainwp-child' ) ) ); MainWP_Helper::write( array( 'error' => __( 'Cannot destroy sessions', 'mainwp-child' ) ) );
} }
break; break;
default: default:
mainwp_child_helper()->write( array( 'error' => __( 'Invalid action', 'mainwp-child' ) ) ); MainWP_Helper::write( array( 'error' => __( 'Invalid action', 'mainwp-child' ) ) );
} }
} else { } else {
mainwp_child_helper()->write( array( 'error' => __( 'Missing action', 'mainwp-child' ) ) ); MainWP_Helper::write( array( 'error' => __( 'Missing action', 'mainwp-child' ) ) );
} }
} }
@ -999,7 +999,7 @@ class MainWP_Child_Callable {
$post = $_POST; $post = $_POST;
$information = array(); $information = array();
$information = apply_filters( 'mainwp_child_extra_execution', $information, $post ); $information = apply_filters( 'mainwp_child_extra_execution', $information, $post );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -1010,7 +1010,7 @@ class MainWP_Child_Callable {
$information = array(); $information = array();
if ( empty( $file_url ) || empty( $path ) ) { if ( empty( $file_url ) || empty( $path ) ) {
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
return; return;
} }
@ -1032,7 +1032,7 @@ class MainWP_Child_Callable {
if ( ! file_exists( $dir ) ) { if ( ! file_exists( $dir ) ) {
if ( false === mkdir( $dir, 0777, true ) ) { if ( false === mkdir( $dir, 0777, true ) ) {
$information['error'] = 'ERRORCREATEDIR'; $information['error'] = 'ERRORCREATEDIR';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
return; return;
} }
@ -1046,7 +1046,7 @@ class MainWP_Child_Callable {
} catch ( \Exception $e ) { } catch ( \Exception $e ) {
$information['error'] = $e->getMessage(); $information['error'] = $e->getMessage();
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -1131,7 +1131,7 @@ class MainWP_Child_Callable {
public function backup_wp() { public function backup_wp() {
if ( ! version_compare( phpversion(), '5.3', '>=' ) ) { if ( ! version_compare( phpversion(), '5.3', '>=' ) ) {
$error = sprintf( __( 'PHP Version %s is unsupported.', 'mainwp-child' ), phpversion() ); $error = sprintf( __( 'PHP Version %s is unsupported.', 'mainwp-child' ), phpversion() );
mainwp_child_helper()->write( array( 'error' => $error ) ); MainWP_Helper::write( array( 'error' => $error ) );
} }
\MainWP_Child_Back_Up_WordPress::instance()->action(); \MainWP_Child_Back_Up_WordPress::instance()->action();
} }
@ -1155,14 +1155,14 @@ class MainWP_Child_Callable {
unlink( $backupdir . $file ); unlink( $backupdir . $file );
} }
mainwp_child_helper()->write( array( 'result' => 'ok' ) ); MainWP_Helper::write( array( 'result' => 'ok' ) );
} }
public function update_child_values() { public function update_child_values() {
$uniId = isset( $_POST['uniqueId'] ) ? $_POST['uniqueId'] : ''; $uniId = isset( $_POST['uniqueId'] ) ? $_POST['uniqueId'] : '';
MainWP_Helper::update_option( 'mainwp_child_uniqueId', $uniId ); MainWP_Helper::update_option( 'mainwp_child_uniqueId', $uniId );
mainwp_child_helper()->write( array( 'result' => 'ok' ) ); MainWP_Helper::write( array( 'result' => 'ok' ) );
} }
@ -1189,7 +1189,7 @@ class MainWP_Child_Callable {
if ( 'run_snippet' === $action || 'save_snippet' === $action ) { if ( 'run_snippet' === $action || 'save_snippet' === $action ) {
if ( ! isset( $_POST['code'] ) ) { if ( ! isset( $_POST['code'] ) ) {
mainwp_child_helper()->write( array( 'status' => 'FAIL' ) ); MainWP_Helper::write( array( 'status' => 'FAIL' ) );
} }
} }
@ -1208,7 +1208,7 @@ class MainWP_Child_Callable {
$information = array( 'status' => 'FAIL' ); $information = array( 'status' => 'FAIL' );
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
private function snippet_save_snippet( $slug, $type, $code, $snippets ) { private function snippet_save_snippet( $slug, $type, $code, $snippets ) {
@ -1275,7 +1275,7 @@ class MainWP_Child_Callable {
public function disconnect() { public function disconnect() {
global $mainWPChild; global $mainWPChild;
$mainWPChild->deactivation( false ); $mainWPChild->deactivation( false );
mainwp_child_helper()->write( array( 'result' => 'success' ) ); MainWP_Helper::write( array( 'result' => 'success' ) );
} }
@ -1289,7 +1289,7 @@ class MainWP_Child_Callable {
MainWP_Helper::error( 'Plugin still active' ); MainWP_Helper::error( 'Plugin still active' );
} }
$information['deactivated'] = true; $information['deactivated'] = true;
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
} }

View file

@ -95,7 +95,7 @@ class MainWP_Child_Install {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
$information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false ); $information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
private function delete_plugins( $plugins ) { private function delete_plugins( $plugins ) {
@ -177,7 +177,7 @@ class MainWP_Child_Install {
$themeToDelete = current( $themes ); $themeToDelete = current( $themes );
if ( $themeToDelete == $theme_name ) { if ( $themeToDelete == $theme_name ) {
$information['error'] = 'IsActivatedTheme'; $information['error'] = 'IsActivatedTheme';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
return; return;
} }
} }
@ -206,7 +206,7 @@ class MainWP_Child_Install {
} }
$information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false ); $information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -222,13 +222,8 @@ class MainWP_Child_Install {
if ( ! isset( $_POST['type'] ) || ! isset( $_POST['url'] ) || ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) || '' === $_POST['url'] ) { if ( ! isset( $_POST['type'] ) || ! isset( $_POST['url'] ) || ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) || '' === $_POST['url'] ) {
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) ); MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
} }
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
include_once ABSPATH . '/wp-admin/includes/screen.php'; $this->require_files();
}
include_once ABSPATH . '/wp-admin/includes/template.php';
include_once ABSPATH . '/wp-admin/includes/misc.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . '/wp-admin/includes/plugin.php';
$urlgot = json_decode( stripslashes( $_POST['url'] ) ); $urlgot = json_decode( stripslashes( $_POST['url'] ) );
@ -263,7 +258,7 @@ class MainWP_Child_Install {
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0 ) { if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0 ) {
$ssl_verify = false; $ssl_verify = false;
$result = $this->try_install_one_more( $url, $installer ); $result = $this->try_second_install( $url, $installer );
} }
} }
@ -271,56 +266,70 @@ class MainWP_Child_Install {
if ( false == $ssl_verify ) { if ( false == $ssl_verify ) {
remove_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'no_ssl_filter_function' ), 99 ); remove_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'no_ssl_filter_function' ), 99 );
} }
$this->after_installed( $result );
$args = array(
'success' => 1,
'action' => 'install',
);
if ( 'plugin' === $_POST['type'] ) {
$path = $result['destination'];
$fileName = '';
wp_cache_set( 'plugins', array(), 'plugins' );
foreach ( $result['source_files'] as $srcFile ) {
if ( is_dir( $path . $srcFile ) ) {
continue;
}
$thePlugin = get_plugin_data( $path . $srcFile );
if ( null !== $thePlugin && '' !== $thePlugin && '' !== $thePlugin['Name'] ) {
$args['type'] = 'plugin';
$args['Name'] = $thePlugin['Name'];
$args['Version'] = $thePlugin['Version'];
$args['slug'] = $result['destination_name'] . '/' . $srcFile;
$fileName = $srcFile;
break;
}
}
if ( ! empty( $fileName ) ) {
do_action_deprecated( 'mainwp_child_installPluginTheme', array( $args ), '4.0.7.1', 'mainwp_child_install_plugin_theme' );
do_action( 'mainwp_child_install_plugin_theme', $args );
if ( isset( $_POST['activatePlugin'] ) && 'yes' === $_POST['activatePlugin'] ) {
// to fix activate issue.
if ( 'quotes-collection/quotes-collection.php' == $args['slug'] ) {
activate_plugin( $path . $fileName, '', false, true );
} else {
activate_plugin( $path . $fileName, '' );
}
}
}
} else {
$args['type'] = 'theme';
$args['slug'] = $result['destination_name'];
do_action_deprecated( 'mainwp_child_installPluginTheme', array( $args ), '4.0.7.1', 'mainwp_child_install_plugin_theme' );
do_action( 'mainwp_child_install_plugin_theme', $args );
}
} }
$information['installation'] = 'SUCCESS'; $information['installation'] = 'SUCCESS';
$information['destination_name'] = $result['destination_name']; $information['destination_name'] = $result['destination_name'];
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
private function try_install_one_more( $url, $installer ) { private function require_files() {
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
include_once ABSPATH . '/wp-admin/includes/screen.php';
}
include_once ABSPATH . '/wp-admin/includes/template.php';
include_once ABSPATH . '/wp-admin/includes/misc.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
include_once ABSPATH . '/wp-admin/includes/plugin.php';
}
private function after_installed( $result ) {
$args = array(
'success' => 1,
'action' => 'install',
);
if ( 'plugin' === $_POST['type'] ) {
$path = $result['destination'];
$fileName = '';
wp_cache_set( 'plugins', array(), 'plugins' );
foreach ( $result['source_files'] as $srcFile ) {
if ( is_dir( $path . $srcFile ) ) {
continue;
}
$thePlugin = get_plugin_data( $path . $srcFile );
if ( null !== $thePlugin && '' !== $thePlugin && '' !== $thePlugin['Name'] ) {
$args['type'] = 'plugin';
$args['Name'] = $thePlugin['Name'];
$args['Version'] = $thePlugin['Version'];
$args['slug'] = $result['destination_name'] . '/' . $srcFile;
$fileName = $srcFile;
break;
}
}
if ( ! empty( $fileName ) ) {
do_action_deprecated( 'mainwp_child_installPluginTheme', array( $args ), '4.0.7.1', 'mainwp_child_install_plugin_theme' );
do_action( 'mainwp_child_install_plugin_theme', $args );
if ( isset( $_POST['activatePlugin'] ) && 'yes' === $_POST['activatePlugin'] ) {
// to fix activate issue.
if ( 'quotes-collection/quotes-collection.php' == $args['slug'] ) {
activate_plugin( $path . $fileName, '', false, true );
} else {
activate_plugin( $path . $fileName, '' );
}
}
}
} else {
$args['type'] = 'theme';
$args['slug'] = $result['destination_name'];
do_action_deprecated( 'mainwp_child_installPluginTheme', array( $args ), '4.0.7.1', 'mainwp_child_install_plugin_theme' );
do_action( 'mainwp_child_install_plugin_theme', $args );
}
}
private function try_second_install( $url, $installer ) {
add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'no_ssl_filter_function' ), 99, 2 ); add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'no_ssl_filter_function' ), 99, 2 );
$result = $installer->run( $result = $installer->run(
array( array(

View file

@ -13,6 +13,8 @@
* Extension URL: https://mainwp.com/extension/ithemes-security/ * Extension URL: https://mainwp.com/extension/ithemes-security/
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable -- third party credit code. // phpcs:disable -- third party credit code.
class MainWP_Child_IThemes_Security { class MainWP_Child_IThemes_Security {
@ -56,7 +58,7 @@ class MainWP_Child_IThemes_Security {
$information = array(); $information = array();
if ( ! class_exists( 'ITSEC_Core' ) || ! class_exists( 'ITSEC_Modules' ) ) { if ( ! class_exists( 'ITSEC_Core' ) || ! class_exists( 'ITSEC_Modules' ) ) {
$information['error'] = 'NO_ITHEME'; $information['error'] = 'NO_ITHEME';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
global $mainwp_itsec_modules_path; global $mainwp_itsec_modules_path;
@ -118,7 +120,7 @@ class MainWP_Child_IThemes_Security {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function set_showhide() { public function set_showhide() {

View file

@ -9,6 +9,8 @@
* 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)
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -41,7 +43,7 @@ class MainWP_Child_Links_Checker {
$information = array(); $information = array();
if ( ! defined( 'BLC_ACTIVE' ) || ! function_exists( 'blc_init' ) ) { if ( ! defined( 'BLC_ACTIVE' ) || ! function_exists( 'blc_init' ) ) {
$information['error'] = 'NO_BROKENLINKSCHECKER'; $information['error'] = 'NO_BROKENLINKSCHECKER';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
blc_init(); blc_init();
@ -78,9 +80,9 @@ class MainWP_Child_Links_Checker {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} catch ( \Exception $e ) { } catch ( \Exception $e ) {
mainwp_child_helper()->write( array( 'error' => $e->getMessage() ) ); MainWP_Helper::write( array( 'error' => $e->getMessage() ) );
} }
} }

View file

@ -12,6 +12,8 @@
* Extension URL: https://mainwp.com/extension/page-speed/ * Extension URL: https://mainwp.com/extension/page-speed/
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -46,7 +48,7 @@ class MainWP_Child_Pagespeed {
$information = array(); $information = array();
if ( ! defined( 'GPI_DIRECTORY' ) ) { if ( ! defined( 'GPI_DIRECTORY' ) ) {
$information['error'] = 'Please install Google Pagespeed Insights plugin on child website'; $information['error'] = 'Please install Google Pagespeed Insights plugin on child website';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -65,7 +67,7 @@ class MainWP_Child_Pagespeed {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function child_deactivation() { public function child_deactivation() {

View file

@ -255,7 +255,7 @@ class MainWP_Child_Posts {
$rslt = $this->get_recent_posts( explode( ',', $_POST['status'] ), $maxPages, $type, $extra ); $rslt = $this->get_recent_posts( explode( ',', $_POST['status'] ), $maxPages, $type, $extra );
$this->posts_where_suffix = ''; $this->posts_where_suffix = '';
mainwp_child_helper()->write( $rslt ); MainWP_Helper::write( $rslt );
} }
public function new_post() { public function new_post() {
@ -288,7 +288,7 @@ class MainWP_Child_Posts {
do_action( 'mainwp_child_after_newpost', $res ); do_action( 'mainwp_child_after_newpost', $res );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function post_action() { public function post_action() {
@ -364,7 +364,7 @@ class MainWP_Child_Posts {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
$information['my_post'] = $my_post; $information['my_post'] = $my_post;
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function get_post_edit( $id ) { public function get_post_edit( $id ) {
@ -542,7 +542,7 @@ class MainWP_Child_Posts {
if ( ! isset( $information['status'] ) ) { if ( ! isset( $information['status'] ) ) {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function comment_bulk_action() { public function comment_bulk_action() {
@ -571,7 +571,7 @@ class MainWP_Child_Posts {
} }
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -618,7 +618,7 @@ class MainWP_Child_Posts {
$rslt = $this->get_recent_comments( explode( ',', $_POST['status'] ), $maxComments ); $rslt = $this->get_recent_comments( explode( ',', $_POST['status'] ), $maxComments );
$this->comments_and_clauses = ''; $this->comments_and_clauses = '';
mainwp_child_helper()->write( $rslt ); MainWP_Helper::write( $rslt );
} }
public function get_recent_comments( $pAllowedStatuses, $pCount ) { public function get_recent_comments( $pAllowedStatuses, $pCount ) {
@ -666,10 +666,10 @@ class MainWP_Child_Posts {
* *
* Runs before creating or updating a post via MainWP dashboard. * Runs before creating or updating a post via MainWP dashboard.
* *
* @param array $new_post Post data array. * @param array $new_post <EFBFBD> Post data array.
* @param array $post_custom Post custom meta data. * @param array $post_custom <EFBFBD> Post custom meta data.
* @param string $post_category Post categories. * @param string $post_category <EFBFBD> Post categories.
* @param string $post_tags Post tags. * @param string $post_tags <EFBFBD> Post tags.
*/ */
do_action( 'mainwp_before_post_update', $new_post, $post_custom, $post_category, $post_tags ); do_action( 'mainwp_before_post_update', $new_post, $post_custom, $post_category, $post_tags );
$edit_post_id = 0; $edit_post_id = 0;

View file

@ -56,7 +56,7 @@ class MainWP_Child_Skeleton_Key {
function mainwp_skeleton_key_handle_fatal_error() { function mainwp_skeleton_key_handle_fatal_error() {
$error = error_get_last(); $error = error_get_last();
if ( isset( $error['type'] ) && in_array( $error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) { if ( isset( $error['type'] ) && in_array( $error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) {
mainwp_child_helper()->write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
} }
} }
@ -73,7 +73,7 @@ class MainWP_Child_Skeleton_Key {
$information = array( 'error' => 'Unknown action' ); $information = array( 'error' => 'Unknown action' );
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
exit(); exit();
} }

View file

@ -12,6 +12,9 @@
* Extension URL: https://mainwp.com/extension/staging/ * Extension URL: https://mainwp.com/extension/staging/
*/ */
use MainWP\Child\MainWP_Child_Callable;
use MainWP\Child\MainWP_Helper;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code. // phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to use external code.
class MainWP_Child_Staging { class MainWP_Child_Staging {
@ -76,7 +79,7 @@ class MainWP_Child_Staging {
public function action() { // phpcs:ignore -- ignore complex method notice. public function action() { // phpcs:ignore -- ignore complex method notice.
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
mainwp_child_helper()->write( array( 'error' => __( 'Please install WP Staging plugin on child website', 'mainwp-child' ) ) ); MainWP_Helper::write( array( 'error' => __( 'Please install WP Staging plugin on child website', 'mainwp-child' ) ) );
} }
if ( ! class_exists( 'WPStaging\WPStaging' ) ) { if ( ! class_exists( 'WPStaging\WPStaging' ) ) {
@ -145,7 +148,7 @@ class MainWP_Child_Staging {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function set_showhide() { public function set_showhide() {
@ -412,7 +415,7 @@ class MainWP_Child_Staging {
return $value; return $value;
} }
if ( ! MainWP_Helper::is_screen_with_update() ) { if ( ! MainWP_Helper::is_updates_screen() ) {
return $value; return $value;
} }

View file

@ -52,7 +52,7 @@ class MainWP_Child_Stats {
$information['version'] = MainWP_Child::$version; $information['version'] = MainWP_Child::$version;
$information['wpversion'] = $wp_version; $information['wpversion'] = $wp_version;
$information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0; $information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0;
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -141,7 +141,7 @@ class MainWP_Child_Stats {
if ( isset( $_POST['primaryBackup'] ) && ! empty( $_POST['primaryBackup'] ) ) { if ( isset( $_POST['primaryBackup'] ) && ! empty( $_POST['primaryBackup'] ) ) {
$primary_bk = $_POST['primaryBackup']; $primary_bk = $_POST['primaryBackup'];
$information['primaryLasttimeBackup'] = mainwp_child_helper()->get_lasttime_backup( $primary_bk ); $information['primaryLasttimeBackup'] = MainWP_Helper::instance()->get_lasttime_backup( $primary_bk );
} }
$last_post = wp_get_recent_posts( array( 'numberposts' => absint( '1' ) ) ); $last_post = wp_get_recent_posts( array( 'numberposts' => absint( '1' ) ) );
@ -175,7 +175,7 @@ class MainWP_Child_Stats {
} }
if ( $exit ) { if ( $exit ) {
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
return $information; return $information;
@ -656,7 +656,7 @@ class MainWP_Child_Stats {
$filter = isset( $_POST['filter'] ) ? $_POST['filter'] : true; $filter = isset( $_POST['filter'] ) ? $_POST['filter'] : true;
$rslt = $this->get_all_themes_int( $filter, $keyword, $status ); $rslt = $this->get_all_themes_int( $filter, $keyword, $status );
mainwp_child_helper()->write( $rslt ); MainWP_Helper::write( $rslt );
} }
public function get_all_themes_int( $filter, $keyword = '', $status = '' ) { public function get_all_themes_int( $filter, $keyword = '', $status = '' ) {
@ -697,7 +697,7 @@ class MainWP_Child_Stats {
$filter = isset( $_POST['filter'] ) ? $_POST['filter'] : true; $filter = isset( $_POST['filter'] ) ? $_POST['filter'] : true;
$rslt = $this->get_all_plugins_int( $filter, $keyword, $status ); $rslt = $this->get_all_plugins_int( $filter, $keyword, $status );
mainwp_child_helper()->write( $rslt ); MainWP_Helper::write( $rslt );
} }
public function get_all_plugins_int( $filter, $keyword = '', $status = '' ) { public function get_all_plugins_int( $filter, $keyword = '', $status = '' ) {

View file

@ -11,6 +11,9 @@
* Extension URL: https://mainwp.com/extension/time-capsule/ * Extension URL: https://mainwp.com/extension/time-capsule/
*/ */
use MainWP\Child\MainWP_Helper;
use MainWP\Child\MainWP_Child_DB;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -60,14 +63,14 @@ class MainWP_Child_Timecapsule {
public function action() { // phpcs:ignore -- ignore complex method notice. public function action() { // phpcs:ignore -- ignore complex method notice.
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
mainwp_child_helper()->write( array( 'error' => 'Please install WP Time Capsule plugin on child website' ) ); MainWP_Helper::write( array( 'error' => 'Please install WP Time Capsule plugin on child website' ) );
} }
try { try {
$this->require_files(); $this->require_files();
} catch ( \Exception $e ) { } catch ( \Exception $e ) {
$error = $e->getMessage(); $error = $e->getMessage();
mainwp_child_helper()->write( array( 'error' => $error ) ); MainWP_Helper::write( array( 'error' => $error ) );
} }
$information = array(); $information = array();
@ -80,7 +83,7 @@ class MainWP_Child_Timecapsule {
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
if ( ( 'save_settings' == $_POST['mwp_action'] || 'get_staging_details_wptc' == $_POST['mwp_action'] || 'progress_wptc' == $_POST['mwp_action'] ) && ( ! $is_user_logged_in || ! $privileges_wptc ) ) { if ( ( 'save_settings' == $_POST['mwp_action'] || 'get_staging_details_wptc' == $_POST['mwp_action'] || 'progress_wptc' == $_POST['mwp_action'] ) && ( ! $is_user_logged_in || ! $privileges_wptc ) ) {
mainwp_child_helper()->write( array( 'error' => 'You are not login to your WP Time Capsule account.' ) ); MainWP_Helper::write( array( 'error' => 'You are not login to your WP Time Capsule account.' ) );
} }
switch ( $_POST['mwp_action'] ) { switch ( $_POST['mwp_action'] ) {
@ -209,7 +212,7 @@ class MainWP_Child_Timecapsule {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -699,11 +702,11 @@ class MainWP_Child_Timecapsule {
$backup_time = $config->get_option( 'last_backup_time' ); $backup_time = $config->get_option( 'last_backup_time' );
if ( ! empty( $backup_time ) ) { if ( ! empty( $backup_time ) ) {
mainwp_child_helper()->update_lasttime_backup( 'wptimecapsule', $backup_time ); MainWP_Helper::instance()->update_lasttime_backup( 'wptimecapsule', $backup_time );
} }
$last_time = time() - 24 * 7 * 2 * 60 * 60; $last_time = time() - 24 * 7 * 2 * 60 * 60;
$lasttime_logged = mainwp_child_helper()->get_lasttime_backup( 'wptimecapsule' ); $lasttime_logged = MainWP_Helper::instance()->get_lasttime_backup( 'wptimecapsule' );
if ( empty( $lasttime_logged ) ) { if ( empty( $lasttime_logged ) ) {
$last_time = time() - 24 * 7 * 8 * 60 * 60; $last_time = time() - 24 * 7 * 8 * 60 * 60;
} }
@ -1264,7 +1267,7 @@ class MainWP_Child_Timecapsule {
if ( isset( $_POST['mainwpsignature'] ) ) { if ( isset( $_POST['mainwpsignature'] ) ) {
return $value; return $value;
} }
if ( ! MainWP_Helper::is_screen_with_update() ) { if ( ! MainWP_Helper::is_updates_screen() ) {
return $value; return $value;
} }
if ( isset( $value->response['wp-time-capsule/wp-time-capsule.php'] ) ) { if ( isset( $value->response['wp-time-capsule/wp-time-capsule.php'] ) ) {

View file

@ -68,7 +68,7 @@ class MainWP_Child_Updates {
} }
$information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false ); $information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
private function include_updates() { private function include_updates() {
@ -562,7 +562,7 @@ class MainWP_Child_Updates {
remove_filter( 'pre_transient_update_core', $this->filterFunction, 99 ); remove_filter( 'pre_transient_update_core', $this->filterFunction, 99 );
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
private function do_upgrade_wp( &$information ) { private function do_upgrade_wp( &$information ) {
@ -668,7 +668,7 @@ class MainWP_Child_Updates {
$information['upgrades'] = array(); // to fix error message when translations updated. $information['upgrades'] = array(); // to fix error message when translations updated.
} }
$information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false ); $information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
} }

View file

@ -12,6 +12,8 @@
* Extension URL: https://mainwp.com/extension/updraftplus/ * Extension URL: https://mainwp.com/extension/updraftplus/
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable -- Third party credit. // phpcs:disable -- Third party credit.
class MainWP_Child_Updraft_Plus_Backups { class MainWP_Child_Updraft_Plus_Backups {
@ -47,7 +49,7 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( isset( $last_backup['backup_time'] ) ) { if ( isset( $last_backup['backup_time'] ) ) {
$backup_time = $last_backup['backup_time']; $backup_time = $last_backup['backup_time'];
if ( $last_backup['success'] ) { if ( $last_backup['success'] ) {
mainwp_child_helper()->update_lasttime_backup( 'updraftplus', $backup_time ); MainWP_Helper::instance()->update_lasttime_backup( 'updraftplus', $backup_time );
} }
} }
return $last_backup; return $last_backup;
@ -81,7 +83,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$information = array(); $information = array();
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
$information['error'] = 'NO_UPDRAFTPLUS'; $information['error'] = 'NO_UPDRAFTPLUS';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
$this->required_files(); $this->required_files();
@ -92,7 +94,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} }
if ( empty( $updraftplus ) ) { if ( empty( $updraftplus ) ) {
$information['error'] = 'Error empty updraftplus'; $information['error'] = 'Error empty updraftplus';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -163,7 +165,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$information = array( 'error' => $e->getMessage() ); $information = array( 'error' => $e->getMessage() );
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function set_showhide() { public function set_showhide() {
@ -3567,7 +3569,7 @@ ENDHERE;
if ( isset( $_POST['mainwpsignature'] ) ) { if ( isset( $_POST['mainwpsignature'] ) ) {
return $value; return $value;
} }
if ( ! MainWP_Helper::is_screen_with_update() ) { if ( ! MainWP_Helper::is_updates_screen() ) {
return $value; return $value;
} }

View file

@ -86,7 +86,7 @@ class MainWP_Child_Users {
$information['users'] = $this->get_all_users_int( 500 ); $information['users'] = $this->get_all_users_int( 500 );
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -147,7 +147,7 @@ class MainWP_Child_Users {
if ( $return ) { if ( $return ) {
return $allusers; return $allusers;
} }
mainwp_child_helper()->write( $allusers ); MainWP_Helper::write( $allusers );
} }
@ -210,7 +210,7 @@ class MainWP_Child_Users {
} }
} }
mainwp_child_helper()->write( $allusers ); MainWP_Helper::write( $allusers );
} }
@ -424,7 +424,7 @@ class MainWP_Child_Users {
} }
$information['added'] = true; $information['added'] = true;
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function new_user() { public function new_user() {
@ -462,7 +462,7 @@ class MainWP_Child_Users {
wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), $blogname ), $message, '' ); wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), $blogname ), $message, '' );
} }
$information['added'] = true; $information['added'] = true;
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }

View file

@ -44,7 +44,7 @@ class MainWP_Child_Vulnerability_Checker {
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function vulner_recheck() { public function vulner_recheck() {

View file

@ -11,6 +11,9 @@
* Extension URL: https://mainwp.com/extension/woocommerce-status/ * Extension URL: https://mainwp.com/extension/woocommerce-status/
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -35,7 +38,7 @@ class MainWP_Child_WooCommerce_Status {
$information = array(); $information = array();
if ( ! class_exists( 'WooCommerce' ) || ! defined( 'WC_VERSION' ) ) { if ( ! class_exists( 'WooCommerce' ) || ! defined( 'WC_VERSION' ) ) {
$information['error'] = 'NO_WOOCOMMERCE'; $information['error'] = 'NO_WOOCOMMERCE';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
$is_ver220 = $this->is_version_220(); $is_ver220 = $this->is_version_220();
@ -52,7 +55,7 @@ class MainWP_Child_WooCommerce_Status {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function is_version_220() { public function is_version_220() {

View file

@ -11,6 +11,9 @@
* Extension URL: https://mainwp.com/extension/wordfence/ * Extension URL: https://mainwp.com/extension/wordfence/
*/ */
use MainWP\Child\MainWP_Helper;
use MainWP\Child\MainWP_Child_DB;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -204,13 +207,13 @@ class MainWP_Child_Wordfence {
public function action() { // phpcs:ignore -- not quite complex method public function action() { // phpcs:ignore -- not quite complex method
$information = array(); $information = array();
if ( ! $this->is_wordfence_installed ) { if ( ! $this->is_wordfence_installed ) {
mainwp_child_helper()->write( array( 'error' => __( 'Please install the Wordfence plugin on the child site.', $this->plugin_translate ) ) ); MainWP_Helper::write( array( 'error' => __( 'Please install the Wordfence plugin on the child site.', $this->plugin_translate ) ) );
return; return;
} }
if ( ! class_exists( 'wordfence' ) || ! class_exists( 'wfScanEngine' ) ) { if ( ! class_exists( 'wordfence' ) || ! class_exists( 'wfScanEngine' ) ) {
$information['error'] = 'NO_WORDFENCE'; $information['error'] = 'NO_WORDFENCE';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -424,7 +427,7 @@ class MainWP_Child_Wordfence {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
@ -2129,7 +2132,7 @@ SQL
'code' => wfCache::getHtaccessCode(), 'code' => wfCache::getHtaccessCode(),
); );
} }
$download_url = admin_url( 'admin-ajax.php' ) . '?action=mainwp_wordfence_download_htaccess&_wpnonce=' . mainwp_child_helper()->create_nonce_without_session( 'mainwp_download_htaccess' ); $download_url = admin_url( 'admin-ajax.php' ) . '?action=mainwp_wordfence_download_htaccess&_wpnonce=' . MainWP_Helper::instance()->create_nonce_without_session( 'mainwp_download_htaccess' );
return array( return array(
'ok' => 1, 'ok' => 1,
'download_url' => $download_url, 'download_url' => $download_url,
@ -2157,7 +2160,7 @@ SQL
die( '-1' ); die( '-1' );
} }
if ( ! mainwp_child_helper()->verify_nonce_without_session( $_GET['_wpnonce'], 'mainwp_download_htaccess' ) ) { if ( ! MainWP_Helper::instance()->verify_nonce_without_session( $_GET['_wpnonce'], 'mainwp_download_htaccess' ) ) {
die( '-2' ); die( '-2' );
} }

View file

@ -12,6 +12,8 @@
* Extension URL: https://mainwp.com/extension/rocket/ * Extension URL: https://mainwp.com/extension/rocket/
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -210,7 +212,7 @@ class MainWP_Child_WP_Rocket {
return $value; return $value;
} }
if ( ! MainWP_Helper::is_screen_with_update() ) { if ( ! MainWP_Helper::is_updates_screen() ) {
return $value; return $value;
} }
@ -259,7 +261,7 @@ class MainWP_Child_WP_Rocket {
public function action() { public function action() {
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
mainwp_child_helper()->write( array( 'error' => __( 'Please install WP Rocket plugin on child website', $this->plugin_translate ) ) ); MainWP_Helper::write( array( 'error' => __( 'Please install WP Rocket plugin on child website', $this->plugin_translate ) ) );
return; return;
} }
@ -303,7 +305,7 @@ class MainWP_Child_WP_Rocket {
$information = array( 'error' => $e->getMessage() ); $information = array( 'error' => $e->getMessage() );
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function set_showhide() { public function set_showhide() {

View file

@ -1,5 +1,8 @@
<?php <?php
use MainWP\Child\MainWP_Helper;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -54,7 +57,7 @@ class MainWP_Child_WPvivid_BackupRestore {
$information = array(); $information = array();
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
$information['error'] = 'NO_WPVIVIDBACKUP'; $information['error'] = 'NO_WPVIVIDBACKUP';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -128,7 +131,7 @@ class MainWP_Child_WPvivid_BackupRestore {
$information = array( 'error' => $e->getMessage() ); $information = array( 'error' => $e->getMessage() );
} }
mainwp_child_helper()->write($information); MainWP_Helper::write($information);
} }
} }

View file

@ -150,99 +150,6 @@ class MainWP_Child {
return; return;
} }
if ( false === $update_version ) {
$options = array(
'mainwp_child_legacy',
'mainwp_child_auth',
'mainwp_child_uniqueId',
'mainwp_child_htaccess_set',
'mainwp_child_fix_htaccess',
'mainwp_child_pubkey',
'mainwp_child_server',
'mainwp_child_nonce',
'mainwp_child_nossl',
'mainwp_child_nossl_key',
'mainwp_child_remove_wp_version',
'mainwp_child_remove_rsd',
'mainwp_child_remove_wlw',
'mainwp_child_remove_core_updates',
'mainwp_child_remove_plugin_updates',
'mainwp_child_remove_theme_updates',
'mainwp_child_remove_php_reporting',
'mainwp_child_remove_scripts_version',
'mainwp_child_remove_styles_version',
'mainwp_child_remove_readme',
'mainwp_child_clone_sites',
'mainwp_child_pluginDir',
'mainwp_premium_updates',
'mainwp_child_activated_once',
'mainwp_maintenance_opt_alert_404',
'mainwp_maintenance_opt_alert_404_email',
'mainwp_ext_code_snippets',
'mainwp_ext_snippets_enabled',
'mainwp_temp_clone_plugins',
'mainwp_temp_clone_themes',
'mainwp_child_click_data',
'mainwp_child_clone_from_server_last_folder',
'mainwp_child_clone_permalink',
'mainwp_child_restore_permalink',
'mainwp_keyword_links_htaccess_set',
'mainwp_kwl_options',
'mainwp_kwl_keyword_links',
'mainwp_kwl_click_statistic_data',
'mainwp_kwl_statistic_data_',
'mainwp_kwl_enable_statistic',
'mainwpKeywordLinks',
);
foreach ( $options as $option ) {
MainWP_Helper::fix_option( $option );
}
} elseif ( ( '1.0' === $update_version ) || ( '1.1' === $update_version ) ) {
$options = array(
'mainwp_child_pubkey',
'mainwp_child_update_version',
'mainwp_child_auth',
'mainwp_child_clone_permalink',
'mainwp_child_restore_permalink',
'mainwp_ext_snippets_enabled',
'mainwp_child_fix_htaccess',
'mainwp_child_pluginDir',
'mainwp_child_htaccess_set',
'mainwp_child_nossl',
'mainwp_updraftplus_ext_enabled',
'mainwpKeywordLinks',
'mainwp_keyword_links_htaccess_set',
'mainwp_pagespeed_ext_enabled',
'mainwp_linkschecker_ext_enabled',
'mainwp_maintenance_opt_alert_404',
);
foreach ( $options as $option ) {
MainWP_Helper::fix_option( $option, 'yes' );
}
if ( ! is_array( get_option( 'mainwp_security' ) ) ) {
$securityOptions = array(
'wp_version' => 'mainwp_child_remove_wp_version',
'rsd' => 'mainwp_child_remove_rsd',
'wlw' => 'mainwp_child_remove_wlw',
'core_updates' => 'mainwp_child_remove_core_updates',
'plugin_updates' => 'mainwp_child_remove_plugin_updates',
'theme_updates' => 'mainwp_child_remove_theme_updates',
'php_reporting' => 'mainwp_child_remove_php_reporting',
'scripts_version' => 'mainwp_child_remove_scripts_version',
'styles_version' => 'mainwp_child_remove_styles_version',
'readme' => 'mainwp_child_remove_readme',
);
$security = array();
foreach ( $securityOptions as $option => $old ) {
$value = get_option( $old );
$security[ $option ] = ( 'T' === $value );
}
MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' );
}
}
MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' ); MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' );
} }

View file

@ -70,7 +70,7 @@ class MainWP_Client_Report {
if ( ! function_exists( 'wp_mainwp_stream_get_instance' ) ) { if ( ! function_exists( 'wp_mainwp_stream_get_instance' ) ) {
$information['error'] = __( 'No MainWP Child Reports plugin installed.', 'mainwp-child' ); $information['error'] = __( 'No MainWP Child Reports plugin installed.', 'mainwp-child' );
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -89,7 +89,7 @@ class MainWP_Client_Report {
break; break;
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function save_sucuri_stream() { public function save_sucuri_stream() {
@ -958,7 +958,7 @@ class MainWP_Client_Report {
return $value; return $value;
} }
if ( ! MainWP_Helper::is_screen_with_update() ) { if ( ! MainWP_Helper::is_updates_screen() ) {
return $value; return $value;
} }

View file

@ -629,7 +629,7 @@ class MainWP_Clone_Install {
} }
unlink( $result[0] ); unlink( $result[0] );
mainwp_child_helper()->write( array( 'result' => 'ok' ) ); MainWP_Helper::write( array( 'result' => 'ok' ) );
} elseif ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) { } elseif ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) {
$dirs = MainWP_Helper::get_mainwp_dir( 'backup' ); $dirs = MainWP_Helper::get_mainwp_dir( 'backup' );
$backupdir = $dirs[0]; $backupdir = $dirs[0];
@ -645,7 +645,7 @@ class MainWP_Clone_Install {
return; return;
} }
mainwp_child_helper()->write( array( 'size' => filesize( $archiveFile ) ) ); MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) );
} elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) { } elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) {
$this->create_clone_backup(); $this->create_clone_backup();
} }
@ -726,6 +726,6 @@ class MainWP_Clone_Install {
} }
closedir( $fh ); closedir( $fh );
$information['themes'] = $themes; $information['themes'] = $themes;
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
} }

View file

@ -206,14 +206,8 @@ class MainWP_Connect {
} }
$signature = rawurldecode( isset( $_REQUEST['mainwpsignature'] ) ? $_REQUEST['mainwpsignature'] : '' ); $signature = rawurldecode( isset( $_REQUEST['mainwpsignature'] ) ? $_REQUEST['mainwpsignature'] : '' );
$file = '';
if ( isset( $_REQUEST['f'] ) ) { $file = $this->get_request_files();
$file = $_REQUEST['f'];
} elseif ( isset( $_REQUEST['file'] ) ) {
$file = $_REQUEST['file'];
} elseif ( isset( $_REQUEST['fdl'] ) ) {
$file = $_REQUEST['fdl'];
}
$auth = self::instance()->auth( $signature, rawurldecode( ( isset( $_REQUEST['where'] ) ? $_REQUEST['where'] : $file ) ), isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '', isset( $_REQUEST['nossl'] ) ? $_REQUEST['nossl'] : 0 ); $auth = self::instance()->auth( $signature, rawurldecode( ( isset( $_REQUEST['where'] ) ? $_REQUEST['where'] : $file ) ), isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '', isset( $_REQUEST['nossl'] ) ? $_REQUEST['nossl'] : 0 );
@ -238,6 +232,22 @@ class MainWP_Connect {
} }
} }
} }
$this->check_redirects();
}
private function get_request_files() {
$file = '';
if ( isset( $_REQUEST['f'] ) ) {
$file = $_REQUEST['f'];
} elseif ( isset( $_REQUEST['file'] ) ) {
$file = $_REQUEST['file'];
} elseif ( isset( $_REQUEST['fdl'] ) ) {
$file = $_REQUEST['fdl'];
}
return $file;
}
private function check_redirects() {
if ( isset( $_REQUEST['fdl'] ) ) { if ( isset( $_REQUEST['fdl'] ) ) {
if ( stristr( $_REQUEST['fdl'], '..' ) ) { if ( stristr( $_REQUEST['fdl'], '..' ) ) {
return; return;
@ -254,7 +264,7 @@ class MainWP_Connect {
} }
private function open_location_redirect( $open_location ) { private function open_location_redirect( $open_location ) {
$_vars = MainWP_Helper::parse_query( $open_location ); $_vars = self::parse_query( $open_location );
$_path = wp_parse_url( $open_location, PHP_URL_PATH ); $_path = wp_parse_url( $open_location, PHP_URL_PATH );
if ( isset( $_vars['_mwpNoneName'] ) && isset( $_vars['_mwpNoneValue'] ) ) { if ( isset( $_vars['_mwpNoneName'] ) && isset( $_vars['_mwpNoneValue'] ) ) {
$_vars[ $_vars['_mwpNoneName'] ] = wp_create_nonce( $_vars['_mwpNoneValue'] ); $_vars[ $_vars['_mwpNoneName'] ] = wp_create_nonce( $_vars['_mwpNoneValue'] );
@ -275,6 +285,23 @@ class MainWP_Connect {
exit(); exit();
} }
public static function parse_query( $var ) {
$var = wp_parse_url( $var, PHP_URL_QUERY );
$var = html_entity_decode( $var );
$var = explode( '&', $var );
$arr = array();
foreach ( $var as $val ) {
$x = explode( '=', $val );
$arr[ $x[0] ] = $x[1];
}
unset( $val, $x, $var );
return $arr;
}
private function where_redirect() { private function where_redirect() {
$where = isset( $_REQUEST['where'] ) ? $_REQUEST['where'] : ''; $where = isset( $_REQUEST['where'] ) ? $_REQUEST['where'] : '';
if ( isset( $_POST['f'] ) || isset( $_POST['file'] ) ) { if ( isset( $_POST['f'] ) || isset( $_POST['file'] ) ) {

View file

@ -26,7 +26,7 @@ class MainWP_Helper {
return self::$instance; return self::$instance;
} }
public function write( $val ) { public static function write( $val ) {
if ( isset( $_REQUEST['json_result'] ) && true == $_REQUEST['json_result'] ) : if ( isset( $_REQUEST['json_result'] ) && true == $_REQUEST['json_result'] ) :
$output = wp_json_encode( $val ); $output = wp_json_encode( $val );
else : else :
@ -64,7 +64,7 @@ class MainWP_Helper {
if ( null !== $code ) { if ( null !== $code ) {
$information['error_code'] = $code; $information['error_code'] = $code;
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
/** /**
@ -378,14 +378,6 @@ class MainWP_Helper {
return $url; return $url;
} }
public static function clean( $string ) {
$string = trim( $string );
$string = htmlentities( $string, ENT_QUOTES );
$string = str_replace( "\n", '<br>', $string );
$string = stripslashes( $string );
return $string;
}
public static function end_session() { public static function end_session() {
session_write_close(); session_write_close();
ob_end_flush(); ob_end_flush();
@ -488,66 +480,6 @@ class MainWP_Helper {
return date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $timestamp ); return date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $timestamp );
} }
public static function format_email( $to, $body ) {
return '<br>
<div>
<br>
<div style="background:#ffffff;padding:0 1.618em;font:13px/20px Helvetica,Arial,Sans-serif;padding-bottom:50px!important">
<div style="width:600px;background:#fff;margin-left:auto;margin-right:auto;margin-top:10px;margin-bottom:25px;padding:0!important;border:10px Solid #fff;border-radius:10px;overflow:hidden">
<div style="display: block; width: 100% ; background-image: url(https://mainwp.com/wp-content/uploads/2013/02/debut_light.png) ; background-repeat: repeat; border-bottom: 2px Solid #7fb100 ; overflow: hidden;">
<div style="display: block; width: 95% ; margin-left: auto ; margin-right: auto ; padding: .5em 0 ;">
<div style="float: left;"><a href="https://mainwp.com"><img src="https://mainwp.com/wp-content/uploads/2013/07/MainWP-Logo-1000-300x62.png" alt="MainWP" height="30"/></a></div>
<div style="float: right; margin-top: .6em ;">
<span style="display: inline-block; margin-right: .8em;"><a href="https://mainwp.com/mainwp-extensions/" style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;">Extensions</a></span>
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="https://mainwp.com/forum">Support</a></span>
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="https://docs.mainwp.com">Documentation</a></span>
<span style="display: inline-block; margin-right: .5em;" class="mainwp-memebers-area"><a href="https://mainwp.com/member/login/index" style="padding: .6em .5em ; border-radius: 50px ; -moz-border-radius: 50px ; -webkit-border-radius: 50px ; background: #1c1d1b; border: 1px Solid #000; color: #fff !important; font-size: .9em !important; font-weight: normal ; -webkit-box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, .1); box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, .1);">Members Area</a></span>
</div><div style="clear: both;"></div>
</div>
</div>
<div>
<p>Hello MainWP User!<br></p>
' . $body . '
<div></div>
<br />
<div>MainWP</div>
<div><a href="https://www.MainWP.com" target="_blank">www.MainWP.com</a></div>
<p></p>
</div>
<div style="display: block; width: 100% ; background: #1c1d1b;">
<div style="display: block; width: 95% ; margin-left: auto ; margin-right: auto ; padding: .5em 0 ;">
<div style="padding: .5em 0 ; float: left;"><p style="color: #fff; font-family: Helvetica, Sans; font-size: 12px ;">© 2013 MainWP. All Rights Reserved.</p></div>
<div style="float: right;"><a href="https://mainwp.com"><img src="https://mainwp.com/wp-content/uploads/2013/07/MainWP-Icon-300.png" height="45"/></a></div><div style="clear: both;"></div>
</div>
</div>
</div>
<center>
<br><br><br><br><br><br>
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color:#ffffff;border-top:1px solid #e5e5e5">
<tbody><tr>
<td align="center" valign="top" style="padding-top:20px;padding-bottom:20px">
<table border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td align="center" valign="top" style="color:#606060;font-family:Helvetica,Arial,sans-serif;font-size:11px;line-height:150%;padding-right:20px;padding-bottom:5px;padding-left:20px;text-align:center">
This email is sent from your MainWP Dashboard.
<br>
If you do not wish to receive these notices please re-check your preferences in the MainWP Settings page.
<br>
<br>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</center>
</div>
</div>
<br>';
}
public static function update_option( $option_name, $option_value, $autoload = 'no' ) { public static function update_option( $option_name, $option_value, $autoload = 'no' ) {
$success = add_option( $option_name, $option_value, '', $autoload ); $success = add_option( $option_name, $option_value, '', $autoload );
@ -558,16 +490,6 @@ class MainWP_Helper {
return $success; return $success;
} }
public static function fix_option( $option_name, $autoload = 'no' ) {
global $wpdb;
if ( $autoload != $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option_name ) ) ) {
$option_value = get_option( $option_name );
delete_option( $option_name );
add_option( $option_name, $option_value, '', $autoload );
}
}
public function update_lasttime_backup( $by, $time ) { public function update_lasttime_backup( $by, $time ) {
$backup_by = array( 'backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule' ); $backup_by = array( 'backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule' );
if ( ! in_array( $by, $backup_by ) ) { if ( ! in_array( $by, $backup_by ) ) {
@ -698,22 +620,6 @@ class MainWP_Helper {
return preg_match( '/' . $pPrefix . '(.*).(zip|tar|tar.gz|tar.bz2)' . $pSuffix . '$/', $pFileName ); return preg_match( '/' . $pPrefix . '(.*).(zip|tar|tar.gz|tar.bz2)' . $pSuffix . '$/', $pFileName );
} }
public static function parse_query( $var ) {
$var = wp_parse_url( $var, PHP_URL_QUERY );
$var = html_entity_decode( $var );
$var = explode( '&', $var );
$arr = array();
foreach ( $var as $val ) {
$x = explode( '=', $val );
$arr[ $x[0] ] = $x[1];
}
unset( $val, $x, $var );
return $arr;
}
public static function sanitize_filename( $filename ) { public static function sanitize_filename( $filename ) {
if ( ! function_exists( 'mb_ereg_replace' ) ) { if ( ! function_exists( 'mb_ereg_replace' ) ) {
return sanitize_file_name( $filename ); return sanitize_file_name( $filename );
@ -753,7 +659,7 @@ class MainWP_Helper {
return function_exists( 'openssl_verify' ); return function_exists( 'openssl_verify' );
} }
public static function is_screen_with_update() { public static function is_updates_screen() {
if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
return false; return false;

View file

@ -735,7 +735,7 @@ class MainWP_Keyword_Links {
$result = $this->remove_keywords(); $result = $this->remove_keywords();
break; break;
} }
mainwp_child_helper()->write( $result ); MainWP_Helper::write( $result );
} }
function remove_keywords() { function remove_keywords() {

View file

@ -111,43 +111,43 @@ class MainWP_Utility {
// referrer. // referrer.
if ( isset( $_SERVER['HTTP_REFERER'] ) ) { if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
$referer = MainWP_Helper::clean( $_SERVER['HTTP_REFERER'] ); $referer = self::clean( $_SERVER['HTTP_REFERER'] );
} else { } else {
$referer = 'undefined'; $referer = 'undefined';
} }
$protocol = isset( $_SERVER['HTTPS'] ) && strcasecmp( $_SERVER['HTTPS'], 'off' ) ? 'https://' : 'http://'; $protocol = isset( $_SERVER['HTTPS'] ) && strcasecmp( $_SERVER['HTTPS'], 'off' ) ? 'https://' : 'http://';
// request URI. // request URI.
if ( isset( $_SERVER['REQUEST_URI'] ) && isset( $_SERVER['HTTP_HOST'] ) ) { if ( isset( $_SERVER['REQUEST_URI'] ) && isset( $_SERVER['HTTP_HOST'] ) ) {
$request = MainWP_Helper::clean( $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); $request = self::clean( $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
} else { } else {
$request = 'undefined'; $request = 'undefined';
} }
// query string. // query string.
if ( isset( $_SERVER['QUERY_STRING'] ) ) { if ( isset( $_SERVER['QUERY_STRING'] ) ) {
$string = MainWP_Helper::clean( $_SERVER['QUERY_STRING'] ); $string = self::clean( $_SERVER['QUERY_STRING'] );
} else { } else {
$string = 'undefined'; $string = 'undefined';
} }
// IP address. // IP address.
if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
$address = MainWP_Helper::clean( $_SERVER['REMOTE_ADDR'] ); $address = self::clean( $_SERVER['REMOTE_ADDR'] );
} else { } else {
$address = 'undefined'; $address = 'undefined';
} }
// user agent. // user agent.
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
$agent = MainWP_Helper::clean( $_SERVER['HTTP_USER_AGENT'] ); $agent = self::clean( $_SERVER['HTTP_USER_AGENT'] );
} else { } else {
$agent = 'undefined'; $agent = 'undefined';
} }
// identity. // identity.
if ( isset( $_SERVER['REMOTE_IDENT'] ) ) { if ( isset( $_SERVER['REMOTE_IDENT'] ) ) {
$remote = MainWP_Helper::clean( $_SERVER['REMOTE_IDENT'] ); $remote = self::clean( $_SERVER['REMOTE_IDENT'] );
} else { } else {
$remote = 'undefined'; $remote = 'undefined';
} }
// log time. // log time.
$time = MainWP_Helper::clean( date( 'F jS Y, h:ia', time() ) ); // phpcs:ignore -- local time. $time = self::clean( date( 'F jS Y, h:ia', time() ) ); // phpcs:ignore -- local time.
$mail = '<div>404 alert</div><div></div>' . $mail = '<div>404 alert</div><div></div>' .
'<div>TIME: ' . $time . '</div>' . '<div>TIME: ' . $time . '</div>' .
@ -161,13 +161,81 @@ class MainWP_Utility {
wp_mail( wp_mail(
$email, $email,
'MainWP - 404 Alert: ' . $blog, 'MainWP - 404 Alert: ' . $blog,
MainWP_Helper::format_email( $email, $mail ), self::format_email( $email, $mail ),
array( array(
'content-type: text/html', 'content-type: text/html',
) )
); );
} }
public static function clean( $string ) {
$string = trim( $string );
$string = htmlentities( $string, ENT_QUOTES );
$string = str_replace( "\n", '<br>', $string );
$string = stripslashes( $string );
return $string;
}
public static function format_email( $to_email, $body ) {
return '<br>
<div>
<br>
<div style="background:#ffffff;padding:0 1.618em;font:13px/20px Helvetica,Arial,Sans-serif;padding-bottom:50px!important">
<div style="width:600px;background:#fff;margin-left:auto;margin-right:auto;margin-top:10px;margin-bottom:25px;padding:0!important;border:10px Solid #fff;border-radius:10px;overflow:hidden">
<div style="display: block; width: 100% ; background-image: url(https://mainwp.com/wp-content/uploads/2013/02/debut_light.png) ; background-repeat: repeat; border-bottom: 2px Solid #7fb100 ; overflow: hidden;">
<div style="display: block; width: 95% ; margin-left: auto ; margin-right: auto ; padding: .5em 0 ;">
<div style="float: left;"><a href="https://mainwp.com"><img src="https://mainwp.com/wp-content/uploads/2013/07/MainWP-Logo-1000-300x62.png" alt="MainWP" height="30"/></a></div>
<div style="float: right; margin-top: .6em ;">
<span style="display: inline-block; margin-right: .8em;"><a href="https://mainwp.com/mainwp-extensions/" style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;">Extensions</a></span>
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="https://mainwp.com/forum">Support</a></span>
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="https://docs.mainwp.com">Documentation</a></span>
<span style="display: inline-block; margin-right: .5em;" class="mainwp-memebers-area"><a href="https://mainwp.com/member/login/index" style="padding: .6em .5em ; border-radius: 50px ; -moz-border-radius: 50px ; -webkit-border-radius: 50px ; background: #1c1d1b; border: 1px Solid #000; color: #fff !important; font-size: .9em !important; font-weight: normal ; -webkit-box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, .1); box-shadow: 0px 0px 0px 5px rgba(0, 0, 0, .1);">Members Area</a></span>
</div><div style="clear: both;"></div>
</div>
</div>
<div>
<p>Hello MainWP User!<br></p>
' . $body . '
<div></div>
<br />
<div>MainWP</div>
<div><a href="https://www.MainWP.com" target="_blank">www.MainWP.com</a></div>
<p></p>
</div>
<div style="display: block; width: 100% ; background: #1c1d1b;">
<div style="display: block; width: 95% ; margin-left: auto ; margin-right: auto ; padding: .5em 0 ;">
<div style="padding: .5em 0 ; float: left;"><p style="color: #fff; font-family: Helvetica, Sans; font-size: 12px ;">© 2013 MainWP. All Rights Reserved.</p></div>
<div style="float: right;"><a href="https://mainwp.com"><img src="https://mainwp.com/wp-content/uploads/2013/07/MainWP-Icon-300.png" height="45"/></a></div><div style="clear: both;"></div>
</div>
</div>
</div>
<center>
<br><br><br><br><br><br>
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color:#ffffff;border-top:1px solid #e5e5e5">
<tbody><tr>
<td align="center" valign="top" style="padding-top:20px;padding-bottom:20px">
<table border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td align="center" valign="top" style="color:#606060;font-family:Helvetica,Arial,sans-serif;font-size:11px;line-height:150%;padding-right:20px;padding-bottom:5px;padding-left:20px;text-align:center">
This email is sent from your MainWP Dashboard.
<br>
If you do not wish to receive these notices please re-check your preferences in the MainWP Settings page.
<br>
<br>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</center>
</div>
</div>
<br>';
}
/** /**
* Handle fatal error for requests from the dashboard * Handle fatal error for requests from the dashboard
@ -181,7 +249,7 @@ class MainWP_Utility {
// handle fatal errors and compile errors. // handle fatal errors and compile errors.
$error = error_get_last(); $error = error_get_last();
if ( isset( $error['type'] ) && isset( $error['message'] ) && ( E_ERROR === $error['type'] || E_COMPILE_ERROR === $error['type'] ) ) { if ( isset( $error['type'] ) && isset( $error['message'] ) && ( E_ERROR === $error['type'] || E_COMPILE_ERROR === $error['type'] ) ) {
mainwp_child_helper()->write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
} }
} }

View file

@ -12,6 +12,8 @@
* Extension URL: https://mainwp.com/extension/wordpress-seo/ * Extension URL: https://mainwp.com/extension/wordpress-seo/
*/ */
use MainWP\Child\MainWP_Helper;
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- root namespace to 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 {
@ -40,7 +42,7 @@ class MainWP_WordPress_SEO {
public function action() { public function action() {
if ( ! class_exists( 'WPSEO_Admin' ) ) { if ( ! class_exists( 'WPSEO_Admin' ) ) {
$information['error'] = 'NO_WPSEO'; $information['error'] = 'NO_WPSEO';
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
$result = array(); $result = array();
switch ( $_POST['action'] ) { switch ( $_POST['action'] ) {
@ -48,7 +50,7 @@ class MainWP_WordPress_SEO {
$information = $this->import_settings(); $information = $this->import_settings();
break; break;
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function import_settings() { public function import_settings() {
@ -106,7 +108,7 @@ class MainWP_WordPress_SEO {
} }
} }
mainwp_child_helper()->write( $information ); MainWP_Helper::write( $information );
} }
public function import_seo_settings( $file ) { public function import_seo_settings( $file ) {