Refactoring

This commit is contained in:
thanghv 2020-05-07 19:34:36 +07:00
parent ebda5deb4c
commit 148109d980
29 changed files with 366 additions and 329 deletions

View file

@ -601,11 +601,13 @@ class MainWP_Backup {
} }
public function create_backup_db( $filepath_prefix, $archiveExt = false, &$archiver = null ) { public function create_backup_db( $filepath_prefix, $archiveExt = false, &$archiver = null ) {
// phpcs:disable
$timeout = 20 * 60 * 60; $timeout = 20 * 60 * 60;
set_time_limit( $timeout ); set_time_limit( $timeout );
ini_set( 'max_execution_time', $timeout ); ini_set( 'max_execution_time', $timeout );
$mem = '512M'; $mem = '512M';
ini_set( 'memory_limit', $mem ); ini_set( 'memory_limit', $mem );
// phpcs:enable
/** @var $wpdb wpdb */ /** @var $wpdb wpdb */
global $wpdb; global $wpdb;
@ -630,7 +632,7 @@ class MainWP_Backup {
$table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); $table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N );
fwrite( $fh, "\n" . $table_create[1] . ";\n\n" ); fwrite( $fh, "\n" . $table_create[1] . ";\n\n" );
$rows = MainWP_Child_DB::_query( 'SELECT * FROM ' . $table, $wpdb->dbh ); $rows = MainWP_Child_DB::to_query( 'SELECT * FROM ' . $table, $wpdb->dbh );
if ( $rows ) { if ( $rows ) {
$i = 0; $i = 0;

View file

@ -12,9 +12,8 @@
* Extension URL: https://mainwp.com/extension/mainwpbuddy/ * Extension URL: https://mainwp.com/extension/mainwpbuddy/
*/ */
namespace MainWP\Child;
class MainWP_Child_Back_Up_Buddy { class MainWP_Child_Back_Up_Buddy {
public static $instance = null; public static $instance = null;
public $plugin_translate = 'mainwp-child'; public $plugin_translate = 'mainwp-child';
public $is_backupbuddy_installed = false; public $is_backupbuddy_installed = false;
@ -36,7 +35,7 @@ class MainWP_Child_Back_Up_Buddy {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) ); add_action( 'wp_ajax_mainwp_backupbuddy_download_archive', array( $this, 'download_archive' ) );
add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); add_action( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) );
@ -215,7 +214,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_Helper::write( array( 'error' => __( 'Please install the BackupBuddy plugin on the child site.', $this->plugin_translate ) ) ); mainwp_child_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' ) ) {
@ -368,7 +367,7 @@ class MainWP_Child_Back_Up_Buddy {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
@ -788,7 +787,7 @@ class MainWP_Child_Back_Up_Buddy {
if ( isset( $getOverview['lastBackupStats']['finish'] ) ) { if ( isset( $getOverview['lastBackupStats']['finish'] ) ) {
$finish_time = $getOverview['lastBackupStats']['finish']; $finish_time = $getOverview['lastBackupStats']['finish'];
$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_Helper::update_lasttime_backup( 'backupbuddy', $finish_time ); // support Require Backup Before Update feature. MainWP_Helper::update_lasttime_backup( 'backupbuddy', $finish_time ); // support Require Backup Before Update feature.
} else { } else {

View file

@ -31,7 +31,7 @@ class MainWP_Child_Back_Up_WordPress {
if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) { if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
$this->is_plugin_installed = true; $this->is_plugin_installed = true;
if ( version_compare( phpversion(), '5.3', '>=' ) ) { if ( version_compare( phpversion(), '5.3', '>=' ) ) {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
} }
} }
} }
@ -79,7 +79,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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -128,7 +128,7 @@ class MainWP_Child_Back_Up_WordPress {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
@ -136,13 +136,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_Helper::write( $information ); mainwp_child_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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
} }

View file

@ -13,8 +13,6 @@
* Extension URL: https://mainwp.com/extension/backwpup/ * Extension URL: https://mainwp.com/extension/backwpup/
*/ */
namespace MainWP\Child;
if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) { if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) {
define( 'MAINWP_BACKWPUP_DEVELOPMENT', false ); define( 'MAINWP_BACKWPUP_DEVELOPMENT', false );
} }
@ -77,25 +75,25 @@ 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_Helper::check_files_exists( array( $file_path1, $file_path2 ) ); mainwp_child_helper()->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_Helper::check_files_exists( array( $file_path ) ); mainwp_child_helper()->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_Helper::check_classes_exists( 'BackWPup' ); mainwp_child_helper()->check_classes_exists( '\BackWPup' );
MainWP_Helper::check_methods( 'get_instance' ); mainwp_child_helper()->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' ) );
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
} }
} catch ( \Exception $e ) { } catch ( \Exception $e ) {
$this->is_backwpup_installed = false; $this->is_backwpup_installed = false;
@ -104,7 +102,7 @@ class MainWP_Child_Back_WP_Up {
public function action() { public function action() {
if ( ! $this->is_backwpup_installed ) { if ( ! $this->is_backwpup_installed ) {
MainWP_Helper::write( array( 'error' => __( 'Please install BackWPup plugin on child website', 'mainwp-child' ) ) ); mainwp_child_helper()->write( array( 'error' => __( 'Please install BackWPup plugin on child website', 'mainwp-child' ) ) );
return; return;
} }
@ -114,11 +112,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_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); mainwp_child_helper()->write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
} elseif ( ! empty( $info ) ) { } elseif ( ! empty( $info ) ) {
MainWP_Helper::write( self::$information ); mainwp_child_helper()->write( self::$information );
} else { } else {
MainWP_Helper::write( array( 'error' => 'Missing information array inside fatal_error' ) ); mainwp_child_helper()->write( array( 'error' => 'Missing information array inside fatal_error' ) );
} }
} }
@ -244,14 +242,14 @@ class MainWP_Child_Back_WP_Up {
try { try {
MainWP_Helper::check_classes_exists( array( 'BackWPup_File', 'BackWPup_Job' ) ); mainwp_child_helper()->check_classes_exists( array( '\BackWPup_File', '\BackWPup_Job' ) );
MainWP_Helper::check_methods( 'BackWPup_File', array( 'get_absolute_path' ) ); mainwp_child_helper()->check_methods( '\BackWPup_File', array( 'get_absolute_path' ) );
MainWP_Helper::check_methods( 'BackWPup_Job', array( 'read_logheader' ) ); mainwp_child_helper()->check_methods( '\BackWPup_Job', array( 'read_logheader' ) );
$lasttime_logged = MainWP_Helper::get_lasttime_backup( 'backwpup' ); $lasttime_logged = mainwp_child_helper()->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 );
$log_folder = untrailingslashit( $log_folder ); $log_folder = untrailingslashit( $log_folder );
$logfiles = array(); $logfiles = array();
@ -268,7 +266,7 @@ class MainWP_Child_Back_WP_Up {
$log_items = array(); $log_items = array();
foreach ( $logfiles as $mtime => $logfile ) { foreach ( $logfiles as $mtime => $logfile ) {
$meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile ); $meta = \BackWPup_Job::read_logheader( $log_folder . '/' . $logfile );
if ( ! isset( $meta['logtime'] ) || $meta['logtime'] < $lasttime_logged ) { if ( ! isset( $meta['logtime'] ) || $meta['logtime'] < $lasttime_logged ) {
continue; continue;
} }
@ -319,7 +317,7 @@ class MainWP_Child_Back_WP_Up {
} }
if ( $new_lasttime_logged > $lasttime_logged ) { if ( $new_lasttime_logged > $lasttime_logged ) {
MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature. mainwp_child_helper()->update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature.
} }
} }
} catch ( \Exception $ex ) { } catch ( \Exception $ex ) {
@ -330,7 +328,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_Helper::get_lasttime_backup( 'backwpup' ); $lastbackup = mainwp_child_helper()->get_lasttime_backup( 'backwpup' );
$information['syncBackwpupData'] = array( $information['syncBackwpupData'] = array(
'lastbackup' => $lastbackup, 'lastbackup' => $lastbackup,
); );
@ -342,24 +340,24 @@ class MainWP_Child_Back_WP_Up {
} }
public function get_destinations_list() { public function get_destinations_list() {
MainWP_Helper::check_classes_exists( array( 'BackWPup', 'BackWPup_Option' ) ); mainwp_child_helper()->check_classes_exists( array( '\BackWPup', '\BackWPup_Option' ) );
MainWP_Helper::check_methods( 'BackWPup', array( 'get_registered_destinations', 'get_destination' ) ); mainwp_child_helper()->check_methods( '\BackWPup', array( 'get_registered_destinations', 'get_destination' ) );
MainWP_Helper::check_methods( 'BackWPup_Option', array( 'get_job_ids', 'get' ) ); mainwp_child_helper()->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();
$destinations = BackWPup::get_registered_destinations(); $destinations = \BackWPup::get_registered_destinations();
foreach ( $jobids as $jobid ) { foreach ( $jobids as $jobid ) {
if ( BackWPup_Option::get( $jobid, 'backuptype' ) === 'sync' ) { if ( \BackWPup_Option::get( $jobid, 'backuptype' ) === 'sync' ) {
continue; continue;
} }
$dests = BackWPup_Option::get( $jobid, 'destinations' ); $dests = \BackWPup_Option::get( $jobid, 'destinations' );
foreach ( $dests as $dest ) { foreach ( $dests as $dest ) {
if ( ! $destinations[ $dest ]['class'] ) { if ( ! $destinations[ $dest ]['class'] ) {
continue; continue;
} }
$dest_class = BackWPup::get_destination( $dest ); $dest_class = \BackWPup::get_destination( $dest );
if ( $dest_class && method_exists( $dest_class, 'file_get_list' ) ) { if ( $dest_class && method_exists( $dest_class, 'file_get_list' ) ) {
$can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest ); $can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest );
if ( ! empty( $can_do_dest ) ) { if ( ! empty( $can_do_dest ) ) {
@ -403,7 +401,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_Helper::update_option( 'mainwp_backwpup_hide_plugin', $hide, 'yes' ); mainwp_child_helper()->update_option( 'mainwp_backwpup_hide_plugin', $hide, 'yes' );
return array( 'success' => 1 ); return array( 'success' => 1 );
} }
@ -415,11 +413,11 @@ class MainWP_Child_Back_WP_Up {
echo '<table class="wp-list-table widefat fixed" cellspacing="0" style="width: 85%;margin-left:auto;;margin-right:auto;">'; echo '<table class="wp-list-table widefat fixed" cellspacing="0" style="width: 85%;margin-left:auto;;margin-right:auto;">';
echo '<thead><tr><th width="35%">' . __( 'Setting', 'mainwp-child' ) . '</th><th>' . __( 'Value', 'mainwp-child' ) . '</th></tr></thead>'; echo '<thead><tr><th width="35%">' . __( 'Setting', 'mainwp-child' ) . '</th><th>' . __( 'Value', 'mainwp-child' ) . '</th></tr></thead>';
echo '<tfoot><tr><th>' . __( 'Setting', 'mainwp-child' ) . '</th><th>' . __( 'Value', 'mainwp-child' ) . '</th></tr></tfoot>'; echo '<tfoot><tr><th>' . __( 'Setting', 'mainwp-child' ) . '</th><th>' . __( 'Value', 'mainwp-child' ) . '</th></tr></tfoot>';
echo '<tr title="&gt;=3.2"><td>' . __( 'WordPress version', 'mainwp-child' ) . '</td><td>' . esc_html( BackWPup::get_plugin_data( 'wp_version' ) ) . '</td></tr>'; echo '<tr title="&gt;=3.2"><td>' . __( 'WordPress version', 'mainwp-child' ) . '</td><td>' . esc_html( \BackWPup::get_plugin_data( 'wp_version' ) ) . '</td></tr>';
if ( ! class_exists( 'BackWPup_Pro', false ) ) { if ( ! class_exists( '\BackWPup_Pro', false ) ) {
echo '<tr title=""><td>' . __( 'BackWPup version', 'mainwp-child' ) . '</td><td>' . esc_html( BackWPup::get_plugin_data( 'Version' ) ) . ' <a href="' . esc_url( translate( BackWPup::get_plugin_data( 'pluginuri' ), 'backwpup' ) ) . '">' . __( 'Get pro.', 'mainwp-child' ) . '</a></td></tr>'; echo '<tr title=""><td>' . __( 'BackWPup version', 'mainwp-child' ) . '</td><td>' . esc_html( \BackWPup::get_plugin_data( 'Version' ) ) . ' <a href="' . esc_url( translate( \BackWPup::get_plugin_data( 'pluginuri' ), 'backwpup' ) ) . '">' . __( 'Get pro.', 'mainwp-child' ) . '</a></td></tr>';
} else { } else {
echo '<tr title=""><td>' . __( 'BackWPup Pro version', 'mainwp-child' ) . '</td><td>' . esc_html( BackWPup::get_plugin_data( 'Version' ) ) . '</td></tr>'; echo '<tr title=""><td>' . __( 'BackWPup Pro version', 'mainwp-child' ) . '</td><td>' . esc_html( \BackWPup::get_plugin_data( 'Version' ) ) . '</td></tr>';
} }
echo '<tr title="&gt;=5.3.3"><td>' . __( 'PHP version', 'mainwp-child' ) . '</td><td>' . esc_html( PHP_VERSION ) . '</td></tr>'; echo '<tr title="&gt;=5.3.3"><td>' . __( 'PHP version', 'mainwp-child' ) . '</td><td>' . esc_html( PHP_VERSION ) . '</td></tr>';
@ -434,7 +432,7 @@ class MainWP_Child_Back_WP_Up {
echo '<tr title=""><td>' . __( 'WP-Cron url:', 'mainwp-child' ) . '</td><td>' . esc_html( site_url( 'wp-cron.php' ) ) . '</td></tr>'; echo '<tr title=""><td>' . __( 'WP-Cron url:', 'mainwp-child' ) . '</td><td>' . esc_html( site_url( 'wp-cron.php' ) ) . '</td></tr>';
echo '<tr><td>' . __( 'Server self connect:', 'mainwp-child' ) . '</td><td>'; echo '<tr><td>' . __( 'Server self connect:', 'mainwp-child' ) . '</td><td>';
$raw_response = BackWPup_Job::get_jobrun_url( 'test' ); $raw_response =\BackWPup_Job::get_jobrun_url( 'test' );
$test_result = ''; $test_result = '';
if ( is_wp_error( $raw_response ) ) { if ( is_wp_error( $raw_response ) ) {
$test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), esc_html( $raw_response->get_error_message() ) ); $test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), esc_html( $raw_response->get_error_message() ) );
@ -442,7 +440,7 @@ class MainWP_Child_Back_WP_Up {
$test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)', 'mainwp-child' ), esc_html( wp_remote_retrieve_response_code( $raw_response ) ) ); $test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)', 'mainwp-child' ), esc_html( wp_remote_retrieve_response_code( $raw_response ) ) );
} }
$headers = wp_remote_retrieve_headers( $raw_response ); $headers = wp_remote_retrieve_headers( $raw_response );
if ( isset( $headers['x-backwpup-ver'] ) && BackWPup::get_plugin_data( 'version' ) !== $headers['x-backwpup-ver'] ) { if ( isset( $headers['x-backwpup-ver'] ) && \BackWPup::get_plugin_data( 'version' ) !== $headers['x-backwpup-ver'] ) {
$test_result .= sprintf( __( 'The BackWPup HTTP response header returns a false value: "%s"', 'mainwp-child' ), esc_html( $headers['x-backwpup-ver'] ) ); $test_result .= sprintf( __( 'The BackWPup HTTP response header returns a false value: "%s"', 'mainwp-child' ), esc_html( $headers['x-backwpup-ver'] ) );
} }
@ -454,18 +452,18 @@ class MainWP_Child_Back_WP_Up {
echo '</td></tr>'; echo '</td></tr>';
echo '<tr><td>' . __( 'Temp folder:', 'mainwp-child' ) . '</td><td>'; echo '<tr><td>' . __( 'Temp folder:', 'mainwp-child' ) . '</td><td>';
if ( ! is_dir( BackWPup::get_plugin_data( 'TEMP' ) ) ) { if ( ! is_dir( \BackWPup::get_plugin_data( 'TEMP' ) ) ) {
echo sprintf( __( 'Temp folder %s doesn\'t exist.', 'mainwp-child' ), esc_html( BackWPup::get_plugin_data( 'TEMP' ) ) ); echo sprintf( __( 'Temp folder %s doesn\'t exist.', 'mainwp-child' ), esc_html( \BackWPup::get_plugin_data( 'TEMP' ) ) );
} elseif ( ! is_writable( BackWPup::get_plugin_data( 'TEMP' ) ) ) { } elseif ( ! is_writable( \BackWPup::get_plugin_data( 'TEMP' ) ) ) {
echo sprintf( __( 'Temporary folder %s is not writable.', 'mainwp-child' ), esc_html( BackWPup::get_plugin_data( 'TEMP' ) ) ); echo sprintf( __( 'Temporary folder %s is not writable.', 'mainwp-child' ), esc_html( \BackWPup::get_plugin_data( 'TEMP' ) ) );
} else { } else {
echo esc_html( BackWPup::get_plugin_data( 'TEMP' ) ); echo esc_html( \BackWPup::get_plugin_data( 'TEMP' ) );
} }
echo '</td></tr>'; echo '</td></tr>';
echo '<tr><td>' . __( 'Log folder:', 'mainwp-child' ) . '</td><td>'; echo '<tr><td>' . __( 'Log folder:', 'mainwp-child' ) . '</td><td>';
$log_folder = BackWPup_File::get_absolute_path( get_site_option( 'backwpup_cfg_logfolder' ) ); $log_folder = \BackWPup_File::get_absolute_path( get_site_option( 'backwpup_cfg_logfolder' ) );
if ( ! is_dir( $log_folder ) ) { if ( ! is_dir( $log_folder ) ) {
echo sprintf( __( 'Logs folder %s not exist.', 'mainwp-child' ), esc_html( $log_folder ) ); echo sprintf( __( 'Logs folder %s not exist.', 'mainwp-child' ), esc_html( $log_folder ) );
@ -544,7 +542,7 @@ class MainWP_Child_Back_WP_Up {
} }
$dir = get_site_option( 'backwpup_cfg_logfolder' ); $dir = get_site_option( 'backwpup_cfg_logfolder' );
$dir = BackWPup_File::get_absolute_path( $dir ); $dir = \BackWPup_File::get_absolute_path( $dir );
foreach ( $_POST['settings']['logfile'] as $logfile ) { foreach ( $_POST['settings']['logfile'] as $logfile ) {
$logfile = basename( $logfile ); $logfile = basename( $logfile );
@ -571,7 +569,7 @@ class MainWP_Child_Back_WP_Up {
$job_id = (int) $_POST['job_id']; $job_id = (int) $_POST['job_id'];
wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => $job_id ) ); wp_clear_scheduled_hook( 'backwpup_cron', array( 'id' => $job_id ) );
if ( ! BackWPup_Option::delete_job( $job_id ) ) { if ( ! \BackWPup_Option::delete_job( $job_id ) ) {
return array( 'error' => __( 'Cannot delete job', 'mainwp-child' ) ); return array( 'error' => __( 'Cannot delete job', 'mainwp-child' ) );
} }
@ -592,7 +590,7 @@ class MainWP_Child_Back_WP_Up {
list( $dest_id, $dest_name ) = explode( '_', $dest ); list( $dest_id, $dest_name ) = explode( '_', $dest );
$dest_class = BackWPup::get_destination( $dest_name ); $dest_class = \BackWPup::get_destination( $dest_name );
if ( is_null( $dest_class ) ) { if ( is_null( $dest_class ) ) {
return array( 'error' => __( 'Invalid dest class.', 'mainwp-child' ) ); return array( 'error' => __( 'Invalid dest class.', 'mainwp-child' ) );
@ -623,7 +621,7 @@ class MainWP_Child_Back_WP_Up {
} }
$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 );
$log_file = $log_folder . basename( $_POST['settings']['logfile'] ); $log_file = $log_folder . basename( $_POST['settings']['logfile'] );
if ( ! is_readable( $log_file ) && ! is_readable( $log_file . '.gz' ) && ! is_readable( $log_file . '.bz2' ) ) { if ( ! is_readable( $log_file ) && ! is_readable( $log_file . '.gz' ) && ! is_readable( $log_file . '.bz2' ) ) {
@ -669,7 +667,7 @@ class MainWP_Child_Back_WP_Up {
switch ( $type ) { switch ( $type ) {
case 'logs': case 'logs':
$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 );
$log_folder = untrailingslashit( $log_folder ); $log_folder = untrailingslashit( $log_folder );
if ( ! is_dir( $log_folder ) ) { if ( ! is_dir( $log_folder ) ) {
@ -679,26 +677,26 @@ class MainWP_Child_Back_WP_Up {
); );
} }
update_user_option( get_current_user_id(), 'backwpuplogs_per_page', 99999999 ); update_user_option( get_current_user_id(), 'backwpuplogs_per_page', 99999999 );
$output = new BackWPup_Page_Logs(); $output = new \BackWPup_Page_Logs();
$output->prepare_items(); $output->prepare_items();
break; break;
case 'backups': case 'backups':
update_user_option( get_current_user_id(), 'backwpupbackups_per_page', 99999999 ); update_user_option( get_current_user_id(), 'backwpupbackups_per_page', 99999999 );
$output = new BackWPup_Page_Backups(); $output = new \BackWPup_Page_Backups();
$output->items = array(); $output->items = array();
$jobids = BackWPup_Option::get_job_ids(); $jobids = \BackWPup_Option::get_job_ids();
if ( ! empty( $jobids ) ) { if ( ! empty( $jobids ) ) {
foreach ( $jobids as $jobid ) { foreach ( $jobids as $jobid ) {
if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'sync' ) { if ( \BackWPup_Option::get( $jobid, 'backuptype' ) == 'sync' ) {
continue; continue;
} }
$dests = BackWPup_Option::get( $jobid, 'destinations' ); $dests = \Option::get( $jobid, 'destinations' );
foreach ( $dests as $dest ) { foreach ( $dests as $dest ) {
$dest_class = BackWPup::get_destination( $dest ); $dest_class = \BackWPup::get_destination( $dest );
if ( is_null( $dest_class ) ) { if ( is_null( $dest_class ) ) {
continue; continue;
} }
@ -718,7 +716,7 @@ class MainWP_Child_Back_WP_Up {
break; break;
case 'jobs': case 'jobs':
$output = new BackWPup_Page_Jobs(); $output = new \BackWPup_Page_Jobs();
$output->prepare_items(); $output->prepare_items();
break; break;
} }
@ -728,15 +726,15 @@ class MainWP_Child_Back_WP_Up {
foreach ( $output->items as $key => $val ) { foreach ( $output->items as $key => $val ) {
$temp_array = array(); $temp_array = array();
$temp_array['id'] = $val; $temp_array['id'] = $val;
$temp_array['name'] = BackWPup_Option::get( $val, 'name' ); $temp_array['name'] = \BackWPup_Option::get( $val, 'name' );
$temp_array['type'] = BackWPup_Option::get( $val, 'type' ); $temp_array['type'] = \BackWPup_Option::get( $val, 'type' );
$temp_array['destinations'] = BackWPup_Option::get( $val, 'destinations' ); $temp_array['destinations'] = \BackWPup_Option::get( $val, 'destinations' );
if ( $this->is_backwpup_pro ) { if ( $this->is_backwpup_pro ) {
$temp_array['export'] = str_replace( '&amp;', '&', wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupjobs&action=export&jobs[]=' . $val, 'bulk-jobs' ) ); $temp_array['export'] = str_replace( '&amp;', '&', wp_nonce_url( network_admin_url( 'admin.php' ) . '?page=backwpupjobs&action=export&jobs[]=' . $val, 'bulk-jobs' ) );
} }
if ( BackWPup_Option::get( $val, 'activetype' ) == 'wpcron' ) { if ( \BackWPup_Option::get( $val, 'activetype' ) == 'wpcron' ) {
$nextrun = wp_next_scheduled( 'backwpup_cron', array( 'id' => $val ) ); $nextrun = wp_next_scheduled( 'backwpup_cron', array( 'id' => $val ) );
if ( $nextrun + ( get_option( 'gmt_offset' ) * 3600 ) ) { if ( $nextrun + ( get_option( 'gmt_offset' ) * 3600 ) ) {
$temp_array['nextrun'] = sprintf( __( '%1$s at %2$s by WP-Cron', 'mainwp-child' ), date_i18n( get_option( 'date_format' ), $nextrun, true ), date_i18n( get_option( 'time_format' ), $nextrun, true ) ); $temp_array['nextrun'] = sprintf( __( '%1$s at %2$s by WP-Cron', 'mainwp-child' ), date_i18n( get_option( 'date_format' ), $nextrun, true ), date_i18n( get_option( 'time_format' ), $nextrun, true ) );
@ -746,11 +744,11 @@ class MainWP_Child_Back_WP_Up {
} else { } else {
$temp_array['nextrun'] = __( 'Inactive', 'mainwp-child' ); $temp_array['nextrun'] = __( 'Inactive', 'mainwp-child' );
} }
if ( BackWPup_Option::get( $val, 'lastrun' ) ) { if ( \BackWPup_Option::get( $val, 'lastrun' ) ) {
$lastrun = BackWPup_Option::get( $val, 'lastrun' ); $lastrun = \BackWPup_Option::get( $val, 'lastrun' );
$temp_array['lastrun'] = sprintf( __( '%1$s at %2$s', 'mainwp-child' ), date_i18n( get_option( 'date_format' ), $lastrun, true ), date_i18n( get_option( 'time_format' ), $lastrun, true ) ); $temp_array['lastrun'] = sprintf( __( '%1$s at %2$s', 'mainwp-child' ), date_i18n( get_option( 'date_format' ), $lastrun, true ), date_i18n( get_option( 'time_format' ), $lastrun, true ) );
if ( BackWPup_Option::get( $val, 'lastruntime' ) ) { if ( \BackWPup_Option::get( $val, 'lastruntime' ) ) {
$temp_array['lastrun'] .= ' ' . sprintf( __( 'Runtime: %d seconds', 'mainwp-child' ), BackWPup_Option::get( $val, 'lastruntime' ) ); $temp_array['lastrun'] .= ' ' . sprintf( __( 'Runtime: %d seconds', 'mainwp-child' ), \BackWPup_Option::get( $val, 'lastruntime' ) );
} }
} else { } else {
$temp_array['lastrun'] = __( 'not yet', 'mainwp-child' ); $temp_array['lastrun'] = __( 'not yet', 'mainwp-child' );
@ -836,7 +834,7 @@ class MainWP_Child_Back_WP_Up {
$dest = strtoupper( str_replace( 'download', '', $_GET['type'] ) ); $dest = strtoupper( str_replace( 'download', '', $_GET['type'] ) );
if ( ! empty( $dest ) && strstr( $_GET['type'], 'download' ) ) { if ( ! empty( $dest ) && strstr( $_GET['type'], 'download' ) ) {
$dest_class = BackWPup::get_destination( $dest ); $dest_class = \BackWPup::get_destination( $dest );
if ( is_null( $dest_class ) ) { if ( is_null( $dest_class ) ) {
die( '-4' ); die( '-4' );
} }
@ -913,7 +911,7 @@ class MainWP_Child_Back_WP_Up {
remove_filter( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); remove_filter( 'wp_die_ajax_handler', '_ajax_wp_die_handler' );
ob_start(); ob_start();
BackWPup_Page_Jobs::ajax_working(); \BackWPup_Page_Jobs::ajax_working();
$output = ob_get_contents(); $output = ob_get_contents();
@ -942,15 +940,15 @@ class MainWP_Child_Back_WP_Up {
$this->wp_list_table_dependency(); $this->wp_list_table_dependency();
ob_start(); ob_start();
BackWPup_Page_Jobs::load(); \BackWPup_Page_Jobs::load();
ob_end_clean(); ob_end_clean();
$output = $this->check_backwpup_messages(); $output = $this->check_backwpup_messages();
if ( isset( $output['error'] ) ) { if ( isset( $output['error'] ) ) {
return array( 'error' => 'BackWPup_Page_Jobs::load fail: ' . $output['error'] ); return array( 'error' => '\BackWPup_Page_Jobs::load fail: ' . $output['error'] );
} else { } else {
$job_object = BackWPup_Job::get_working_data(); $job_object = \BackWPup_Job::get_working_data();
if ( is_object( $job_object ) ) { if ( is_object( $job_object ) ) {
return array( return array(
'success' => 1, 'success' => 1,
@ -975,7 +973,7 @@ class MainWP_Child_Back_WP_Up {
$this->wp_list_table_dependency(); $this->wp_list_table_dependency();
ob_start(); ob_start();
BackWPup_Page_Jobs::load(); \BackWPup_Page_Jobs::load();
ob_end_clean(); ob_end_clean();
$output = $this->check_backwpup_messages(); $output = $this->check_backwpup_messages();
@ -1003,16 +1001,16 @@ class MainWP_Child_Back_WP_Up {
} }
} }
if ( ! class_exists( 'WP_List_Table' ) ) { if ( ! class_exists( '\WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
} }
} }
protected function wizard_system_scan() { protected function wizard_system_scan() {
if ( class_exists( 'BackWPup_Pro_Wizard_SystemTest' ) ) { if ( class_exists( '\BackWPup_Pro_Wizard_SystemTest' ) ) {
ob_start(); ob_start();
$system_test = new BackWPup_Pro_Wizard_SystemTest(); $system_test = new \BackWPup_Pro_Wizard_SystemTest();
$system_test->execute( null ); $system_test->execute( null );
$output = ob_get_contents(); $output = ob_get_contents();
@ -1063,8 +1061,8 @@ class MainWP_Child_Back_WP_Up {
} }
} }
if ( ! class_exists( 'Swift', false ) ) { if ( ! class_exists( '\Swift', false ) ) {
require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php'; require \BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php';
} }
if ( function_exists( 'mb_internal_encoding' ) && ( (int) ini_get( 'mbstring.func_overload' ) ) & 2 ) { if ( function_exists( 'mb_internal_encoding' ) && ( (int) ini_get( 'mbstring.func_overload' ) ) & 2 ) {
@ -1136,8 +1134,8 @@ class MainWP_Child_Back_WP_Up {
if ( false !== strpos( trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ) != $folder ) { if ( false !== strpos( trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ) != $folder ) {
$exclude_dir_array[] = trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) ); $exclude_dir_array[] = trailingslashit( str_replace( '\\', '/', realpath( get_theme_root() ) ) );
} }
if ( false !== strpos( trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) ) != $folder ) { if ( false !== strpos( trailingslashit( str_replace( '\\', '/', realpath( \BackWPup_File::get_upload_dir() ) ) ), $folder ) && trailingslashit( str_replace( '\\', '/', realpath( \BackWPup_File::get_upload_dir() ) ) ) != $folder ) {
$exclude_dir_array[] = trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) ); $exclude_dir_array[] = trailingslashit( str_replace( '\\', '/', realpath( \BackWPup_File::get_upload_dir() ) ) );
} }
return array_unique( $exclude_dir_array ); return array_unique( $exclude_dir_array );
@ -1150,7 +1148,7 @@ class MainWP_Child_Back_WP_Up {
'content' => WP_CONTENT_DIR, 'content' => WP_CONTENT_DIR,
'plugin' => WP_PLUGIN_DIR, 'plugin' => WP_PLUGIN_DIR,
'theme' => get_theme_root(), 'theme' => get_theme_root(),
'upload' => BackWPup_File::get_upload_dir(), 'upload' => \BackWPup_File::get_upload_dir(),
); );
foreach ( $folders as $key => $folder ) { foreach ( $folders as $key => $folder ) {
@ -1159,13 +1157,13 @@ class MainWP_Child_Back_WP_Up {
if ( $main_folder_name ) { if ( $main_folder_name ) {
$main_folder_name = untrailingslashit( str_replace( '\\', '/', $main_folder_name ) ); $main_folder_name = untrailingslashit( str_replace( '\\', '/', $main_folder_name ) );
$main_folder_size = '(' . size_format( BackWPup_File::get_folder_size( $main_folder_name, false ), 2 ) . ')'; $main_folder_size = '(' . size_format( \BackWPup_File::get_folder_size( $main_folder_name, false ), 2 ) . ')';
$dir = opendir( $main_folder_name ); $dir = opendir( $main_folder_name );
if ( $dir ) { if ( $dir ) {
while ( false !== ( $file = readdir( $dir ) ) ) { while ( false !== ( $file = readdir( $dir ) ) ) {
if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) ) { if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) ) {
$folder_size = ' (' . size_format( BackWPup_File::get_folder_size( $main_folder_name . '/' . $file ), 2 ) . ')'; $folder_size = ' (' . size_format( \BackWPup_File::get_folder_size( $main_folder_name . '/' . $file ), 2 ) . ')';
$return_temp[] = array( $return_temp[] = array(
'size' => $folder_size, 'size' => $folder_size,
'name' => $file, 'name' => $file,
@ -1243,7 +1241,7 @@ class MainWP_Child_Back_WP_Up {
} }
if ( isset( $settings['job_id'] ) ) { if ( isset( $settings['job_id'] ) ) {
$return['dbdumpexclude'] = BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' ); $return['dbdumpexclude'] = \BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' );
} }
return array( return array(
'success' => 1, 'success' => 1,
@ -1331,7 +1329,7 @@ class MainWP_Child_Back_WP_Up {
$normalized && $to_exclude_parsed[ $key ] = $normalized; $normalized && $to_exclude_parsed[ $key ] = $normalized;
} }
sort( $to_exclude_parsed ); sort( $to_exclude_parsed );
BackWPup_Option::update( $id, 'fileexclude', implode( ',', $to_exclude_parsed ) ); \BackWPup_Option::update( $id, 'fileexclude', implode( ',', $to_exclude_parsed ) );
unset( $exclude_input, $to_exclude_list, $to_exclude, $to_exclude_parsed, $normalized ); unset( $exclude_input, $to_exclude_list, $to_exclude, $to_exclude_parsed, $normalized );
// Parse and save folders to include. // Parse and save folders to include.
@ -1346,7 +1344,7 @@ class MainWP_Child_Back_WP_Up {
$realpath && $to_include_parsed[ $key ] = $realpath; $realpath && $to_include_parsed[ $key ] = $realpath;
} }
sort( $to_include_parsed ); sort( $to_include_parsed );
BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) ); \BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) );
unset( $include_input, $include_list, $to_include, $to_include_parsed, $normalized, $realpath ); unset( $include_input, $include_list, $to_include, $to_include_parsed, $normalized, $realpath );
// Parse and save boolean fields. // Parse and save boolean fields.
@ -1362,7 +1360,7 @@ class MainWP_Child_Back_WP_Up {
); );
foreach ( $boolean_fields_def as $key => $value ) { foreach ( $boolean_fields_def as $key => $value ) {
BackWPup_Option::update( $id, $key, ! empty( $post_data[ $key ] ) ); \BackWPup_Option::update( $id, $key, ! empty( $post_data[ $key ] ) );
} }
// Parse and save directories to exclude. // Parse and save directories to exclude.
$exclude_dirs_def = array( $exclude_dirs_def = array(
@ -1389,7 +1387,7 @@ class MainWP_Child_Back_WP_Up {
); );
foreach ( $exclude_dirs_def as $key => $filter ) { foreach ( $exclude_dirs_def as $key => $filter ) {
$value = ! empty( $post_data[ $key ] ) && is_array( $post_data[ $key ] ) ? $post_data[ $key ] : array(); $value = ! empty( $post_data[ $key ] ) && is_array( $post_data[ $key ] ) ? $post_data[ $key ] : array();
BackWPup_Option::update( $id, $key, $value ); \BackWPup_Option::update( $id, $key, $value );
} }
} }
@ -1409,7 +1407,7 @@ class MainWP_Child_Back_WP_Up {
return array( 'error' => __( 'Missing job_id', 'mainwp-child' ) ); return array( 'error' => __( 'Missing job_id', 'mainwp-child' ) );
} }
if ( ! class_exists( 'BackWPup' ) ) { if ( ! class_exists( '\BackWPup' ) ) {
return array( 'error' => __( 'Install BackWPup on child website', 'mainwp-child' ) ); return array( 'error' => __( 'Install BackWPup on child website', 'mainwp-child' ) );
} }
@ -1417,7 +1415,7 @@ class MainWP_Child_Back_WP_Up {
$job_id = intval( $settings['job_id'] ); $job_id = intval( $settings['job_id'] );
} else { } else {
// generate jobid if not exists. // generate jobid if not exists.
$newjobid = BackWPup_Option::get_job_ids(); $newjobid = \BackWPup_Option::get_job_ids();
sort( $newjobid ); sort( $newjobid );
$job_id = end( $newjobid ) + 1; $job_id = end( $newjobid ) + 1;
} }
@ -1425,7 +1423,7 @@ class MainWP_Child_Back_WP_Up {
update_site_option( 'backwpup_messages', array() ); update_site_option( 'backwpup_messages', array() );
if ( isset( $settings['value']['backupdir'] ) && empty( $settings['value']['backupdir'] ) ) { if ( isset( $settings['value']['backupdir'] ) && empty( $settings['value']['backupdir'] ) ) {
$backupdir = BackWPup_Option::get( (int) $job_id, 'backupdir' ); $backupdir = \BackWPup_Option::get( (int) $job_id, 'backupdir' );
if ( ! empty( $backupdir ) ) { if ( ! empty( $backupdir ) ) {
$settings['value']['backupdir'] = $backupdir; $settings['value']['backupdir'] = $backupdir;
} }
@ -1437,16 +1435,16 @@ class MainWP_Child_Back_WP_Up {
if ( 'jobtype-FILE' == $settings['tab'] ) { if ( 'jobtype-FILE' == $settings['tab'] ) {
$this->edit_form_post_save( $settings['value'], $job_id ); $this->edit_form_post_save( $settings['value'], $job_id );
$messages = BackWPup_Admin::get_messages(); $messages = \BackWPup_Admin::get_messages();
if ( empty( $messages['error'] ) ) { if ( empty( $messages['error'] ) ) {
$url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id ); $url = \BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id );
BackWPup_Admin::message( sprintf( __( 'Changes for job <i>%s</i> saved.', 'mainwp-child' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'mainwp-child' ) . '</a> | <a href="' . $url['url'] . '">' . __( 'Run now', 'mainwp-child' ) . '</a>' ); \BackWPup_Admin::message( sprintf( __( 'Changes for job <i>%s</i> saved.', 'mainwp-child' ), \BackWPup_Option::get( $job_id, 'name' ) ) . ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'mainwp-child' ) . '</a> | <a href="' . $url['url'] . '">' . __( 'Run now', 'mainwp-child' ) . '</a>' );
} }
} elseif ( 'dest-DROPBOX' == $settings['tab'] ) { } elseif ( 'dest-DROPBOX' == $settings['tab'] ) {
unset( $settings['value'] ); unset( $settings['value'] );
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id ); \BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
} else { } else {
BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id ); \BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id );
} }
$return = $this->check_backwpup_messages(); $return = $this->check_backwpup_messages();
@ -1459,26 +1457,26 @@ class MainWP_Child_Back_WP_Up {
} }
if ( isset( $settings['value']['sugarrefreshtoken'] ) ) { if ( isset( $settings['value']['sugarrefreshtoken'] ) ) {
BackWPup_Option::update( $job_id, 'sugarrefreshtoken', $settings['value']['sugarrefreshtoken'] ); \BackWPup_Option::update( $job_id, 'sugarrefreshtoken', $settings['value']['sugarrefreshtoken'] );
} }
if ( isset( $settings['value']['gdriverefreshtoken'] ) ) { if ( isset( $settings['value']['gdriverefreshtoken'] ) ) {
BackWPup_Option::update( $job_id, 'gdriverefreshtoken', $settings['value']['gdriverefreshtoken'] ); \BackWPup_Option::update( $job_id, 'gdriverefreshtoken', $settings['value']['gdriverefreshtoken'] );
} }
if ( isset( $settings['value']['dbdumpspecialsetalltables'] ) && $settings['value']['dbdumpspecialsetalltables'] ) { if ( isset( $settings['value']['dbdumpspecialsetalltables'] ) && $settings['value']['dbdumpspecialsetalltables'] ) {
BackWPup_Option::update( $job_id, 'dbdumpexclude', array() ); \BackWPup_Option::update( $job_id, 'dbdumpexclude', array() );
} }
if ( isset( $settings['value']['dropboxtoken'] ) && isset( $settings['value']['dropboxroot'] ) ) { if ( isset( $settings['value']['dropboxtoken'] ) && isset( $settings['value']['dropboxroot'] ) ) {
BackWPup_Option::update( $job_id, 'dropboxtoken', $settings['value']['dropboxtoken'] ); \BackWPup_Option::update( $job_id, 'dropboxtoken', $settings['value']['dropboxtoken'] );
BackWPup_Option::update( $job_id, 'dropboxroot', $settings['value']['dropboxroot'] ); \Option::update( $job_id, 'dropboxroot', $settings['value']['dropboxroot'] );
} }
$changes_array = array(); $changes_array = array();
foreach ( $settings['value'] as $key => $val ) { foreach ( $settings['value'] as $key => $val ) {
$temp_value = BackWPup_Option::get( $job_id, $key ); $temp_value = \BackWPup_Option::get( $job_id, $key );
if ( is_string( $temp_value ) ) { if ( is_string( $temp_value ) ) {
if ( isset( $this->exclusions[ $settings['tab'] ] ) ) { if ( isset( $this->exclusions[ $settings['tab'] ] ) ) {
if ( ! in_array( $key, $this->exclusions[ $settings['tab'] ] ) && strcmp( $temp_value, $val ) != 0 ) { if ( ! in_array( $key, $this->exclusions[ $settings['tab'] ] ) && strcmp( $temp_value, $val ) != 0 ) {
@ -1506,7 +1504,7 @@ class MainWP_Child_Back_WP_Up {
return array( 'error' => __( 'Missing array settings', 'mainwp-child' ) ); return array( 'error' => __( 'Missing array settings', 'mainwp-child' ) );
} }
if ( ! class_exists( 'BackWPup' ) ) { if ( ! class_exists( '\BackWPup' ) ) {
return array( 'error' => __( 'Install BackWPup on child website', 'mainwp-child' ) ); return array( 'error' => __( 'Install BackWPup on child website', 'mainwp-child' ) );
} }
@ -1523,11 +1521,11 @@ class MainWP_Child_Back_WP_Up {
$settings_views = array(); $settings_views = array();
$settings_updaters = array(); $settings_updaters = array();
$backwpup = new BackWPup_Page_Settings( $settings_views, $settings_updaters ); $backwpup = new \BackWPup_Page_Settings( $settings_views, $settings_updaters );
$backwpup->save_post_form(); $backwpup->save_post_form();
if ( class_exists( 'BackWPup_Pro' ) ) { if ( class_exists( '\BackWPup_Pro' ) ) {
$pro_settings = BackWPup_Pro_Settings_APIKeys::get_instance(); $pro_settings = \BackWPup_Pro_Settings_APIKeys::get_instance();
$pro_settings->save_form(); $pro_settings->save_form();
} }

View file

@ -158,7 +158,7 @@ class MainWP_Child_Branding {
$information = $this->update_branding(); $information = $this->update_branding();
break; break;
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function update_branding() { public function update_branding() {
@ -743,7 +743,7 @@ class MainWP_Child_Branding {
$generator = '<!-- generator="' . $extra_setting['site_generator'] . '" -->'; $generator = '<!-- generator="' . $extra_setting['site_generator'] . '" -->';
break; break;
case 'export': case 'export':
$generator = '<!-- generator="' . $extra_setting['site_generator'] . '" created="' . date( 'Y-m-d H:i' ) . '" -->'; //phpcs:ignore -- current local time $generator = '<!-- generator="' . $extra_setting['site_generator'] . '" created="' . date( 'Y-m-d H:i' ) . '" -->'; //phpcs:ignore -- current local time.
break; break;
endswitch; endswitch;

View file

@ -2,48 +2,50 @@
namespace MainWP\Child; namespace MainWP\Child;
class MainWP_Child_DB { class MainWP_Child_DB {
// phpcs:disable WordPress.DB.RestrictedFunctions, WordPress.DB.PreparedSQL.NotPrepared -- unprepared SQL ok, accessing the database directly to custom database functions.
// Support old & new versions of WordPress (3.9+). // Support old & new versions of WordPress (3.9+).
public static function use_mysqli() { public static function use_mysqli() {
/** @var $wpdb wpdb */ /** @var $wpdb wpdb */
if ( ! function_exists( 'mysqli_connect' ) ) { if ( ! function_exists( '\mysqli_connect' ) ) {
return false; return false;
} }
global $wpdb; global $wpdb;
return ( $wpdb->dbh instanceof mysqli ); return ( $wpdb->dbh instanceof \mysqli );
} }
public static function _query( $query, $link ) { public static function to_query( $query, $link ) {
if ( self::use_mysqli() ) { if ( self::use_mysqli() ) {
return mysqli_query( $link, $query ); return \mysqli_query( $link, $query );
} else { } else {
return mysql_query( $query, $link ); return \mysql_query( $query, $link );
} }
} }
public static function fetch_array( $result ) { public static function fetch_array( $result ) {
if ( self::use_mysqli() ) { if ( self::use_mysqli() ) {
return mysqli_fetch_array( $result, MYSQLI_ASSOC ); return \mysqli_fetch_array( $result, MYSQLI_ASSOC );
} else { } else {
return mysql_fetch_array( $result, MYSQL_ASSOC ); return \mysql_fetch_array( $result, MYSQL_ASSOC );
} }
} }
public static function num_rows( $result ) { public static function num_rows( $result ) {
if ( self::use_mysqli() ) { if ( self::use_mysqli() ) {
return mysqli_num_rows( $result ); return \mysqli_num_rows( $result );
} else { } else {
return mysql_num_rows( $result ); return \mysql_num_rows( $result );
} }
} }
public static function connect( $host, $user, $pass ) { public static function connect( $host, $user, $pass ) {
if ( self::use_mysqli() ) { if ( self::use_mysqli() ) {
return mysqli_connect( $host, $user, $pass ); return \mysqli_connect( $host, $user, $pass );
} else { } else {
return mysql_connect( $host, $user, $pass ); return \mysql_connect( $host, $user, $pass );
} }
} }
@ -52,9 +54,9 @@ class MainWP_Child_DB {
/** @var $wpdb wpdb */ /** @var $wpdb wpdb */
global $wpdb; global $wpdb;
return mysqli_select_db( $wpdb->dbh, $db ); return \mysqli_select_db( $wpdb->dbh, $db );
} else { } else {
return mysql_select_db( $db ); return \mysql_select_db( $db );
} }
} }
@ -63,9 +65,9 @@ class MainWP_Child_DB {
/** @var $wpdb wpdb */ /** @var $wpdb wpdb */
global $wpdb; global $wpdb;
return mysqli_error( $wpdb->dbh ); return \mysqli_error( $wpdb->dbh );
} else { } else {
return mysql_error(); return \mysql_error();
} }
} }
@ -74,9 +76,9 @@ class MainWP_Child_DB {
global $wpdb; global $wpdb;
if ( self::use_mysqli() ) { if ( self::use_mysqli() ) {
return mysqli_real_escape_string( $wpdb->dbh, $value ); return \mysqli_real_escape_string( $wpdb->dbh, $value );
} else { } else {
return mysql_real_escape_string( $value, $wpdb->dbh ); return \mysql_real_escape_string( $value, $wpdb->dbh );
} }
} }
@ -92,7 +94,7 @@ class MainWP_Child_DB {
/** @var $wpdb wpdb */ /** @var $wpdb wpdb */
global $wpdb; global $wpdb;
$rows = self::_query( 'SHOW table STATUS', $wpdb->dbh ); $rows = self::to_query( 'SHOW table STATUS', $wpdb->dbh );
$size = 0; $size = 0;
while ( $row = self::fetch_array( $rows ) ) { while ( $row = self::fetch_array( $rows ) ) {
$size += $row['Data_length']; $size += $row['Data_length'];

View file

@ -36,7 +36,7 @@ class MainWP_Child_IThemes_Security {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
} }
public function sync_others_data( $information, $data = array() ) { public function sync_others_data( $information, $data = array() ) {
@ -56,7 +56,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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
global $mainwp_itsec_modules_path; global $mainwp_itsec_modules_path;
@ -118,7 +118,7 @@ class MainWP_Child_IThemes_Security {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function set_showhide() { public function set_showhide() {

View file

@ -34,14 +34,14 @@ class MainWP_Child_Links_Checker {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
} }
public function action() { public function action() {
$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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
blc_init(); blc_init();
@ -78,9 +78,9 @@ class MainWP_Child_Links_Checker {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} catch ( \Exception $e ) { } catch ( \Exception $e ) {
MainWP_Helper::write( array( 'error' => $e->getMessage() ) ); mainwp_child_helper()->write( array( 'error' => $e->getMessage() ) );
} }
} }

View file

@ -37,7 +37,7 @@ class MainWP_Child_Pagespeed {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) ); add_action( 'mainwp_child_deactivation', array( $this, 'child_deactivation' ) );
} }
@ -46,7 +46,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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -65,7 +65,7 @@ class MainWP_Child_Pagespeed {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function child_deactivation() { public function child_deactivation() {

View file

@ -19,7 +19,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_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) ); mainwp_child_helper()->write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
} }
} }
@ -36,7 +36,7 @@ class MainWP_Child_Skeleton_Key {
$information = array( 'error' => 'Unknown action' ); $information = array( 'error' => 'Unknown action' );
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
exit(); exit();
} }

View file

@ -38,7 +38,7 @@ class MainWP_Child_Staging {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
} }
@ -76,7 +76,7 @@ class MainWP_Child_Staging {
public function action() { public function action() {
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
MainWP_Helper::write( array( 'error' => __( 'Please install WP Staging plugin on child website', 'mainwp-child' ) ) ); mainwp_child_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 +145,7 @@ class MainWP_Child_Staging {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function set_showhide() { public function set_showhide() {

View file

@ -34,7 +34,7 @@ class MainWP_Child_Timecapsule {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
} }
@ -60,14 +60,14 @@ class MainWP_Child_Timecapsule {
public function action() { public function action() {
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
MainWP_Helper::write( array( 'error' => 'Please install WP Time Capsule plugin on child website' ) ); mainwp_child_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_Helper::write( array( 'error' => $error ) ); mainwp_child_helper()->write( array( 'error' => $error ) );
} }
$information = array(); $information = array();
@ -80,7 +80,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_Helper::write( array( 'error' => 'You are not login to your WP Time Capsule account.' ) ); mainwp_child_helper()->write( array( 'error' => 'You are not login to your WP Time Capsule account.' ) );
} }
switch ( $_POST['mwp_action'] ) { switch ( $_POST['mwp_action'] ) {
@ -209,7 +209,7 @@ class MainWP_Child_Timecapsule {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
@ -289,7 +289,7 @@ class MainWP_Child_Timecapsule {
protected function get_backups( $last_time = false ) { protected function get_backups( $last_time = false ) {
if ( empty( $last_time ) ) { if ( empty( $last_time ) ) {
$last_time = strtotime( date( 'Y-m-d', strtotime( date( 'Y-m-01' ) ) ) ); // phpcs:ignore -- local time $last_time = strtotime( date( 'Y-m-d', strtotime( date( 'Y-m-01' ) ) ) ); // phpcs:ignore -- local time.
} }
global $wpdb; global $wpdb;
$all_backups = $wpdb->get_results( $all_backups = $wpdb->get_results(
@ -365,7 +365,7 @@ class MainWP_Child_Timecapsule {
if ( ! empty( $last_backup_time ) ) { if ( ! empty( $last_backup_time ) ) {
$user_time = $config->cnvt_UTC_to_usrTime( $last_backup_time ); $user_time = $config->cnvt_UTC_to_usrTime( $last_backup_time );
$processed_files->modify_schedule_backup_time( $user_time ); $processed_files->modify_schedule_backup_time( $user_time );
$formatted_date = date( 'M d @ g:i a', $user_time ); $formatted_date = date( 'M d @ g:i a', $user_time ); // phpcs:ignore -- local time.
$return_array['last_backup_time'] = $formatted_date; $return_array['last_backup_time'] = $formatted_date;
} else { } else {
$return_array['last_backup_time'] = 'No Backup Taken'; $return_array['last_backup_time'] = 'No Backup Taken';
@ -477,8 +477,8 @@ class MainWP_Child_Timecapsule {
$query = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log WHERE show_user = 1 GROUP BY action_id '; $query = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log WHERE show_user = 1 GROUP BY action_id ';
} }
$orderby = ! empty( $_POST['orderby'] ) ? mysql_real_escape_string( $_POST['orderby'] ) : 'id'; $orderby = ! empty( $_POST['orderby'] ) ? MainWP_Child_DB::real_escape_string( $_POST['orderby'] ) : 'id';
$order = ! empty( $_POST['order'] ) ? mysql_real_escape_string( $_POST['order'] ) : 'DESC'; $order = ! empty( $_POST['order'] ) ? MainWP_Child_DB::real_escape_string( $_POST['order'] ) : 'DESC';
if ( ! empty( $orderby ) & ! empty( $order ) ) { if ( ! empty( $orderby ) & ! empty( $order ) ) {
$query .= ' ORDER BY ' . $orderby . ' ' . $order; $query .= ' ORDER BY ' . $orderby . ' ' . $order;
} }
@ -583,7 +583,7 @@ class MainWP_Child_Timecapsule {
$Ldata = unserialize( $rec->log_data ); $Ldata = unserialize( $rec->log_data );
$user_time = WPTC_Factory::get( 'config' )->cnvt_UTC_to_usrTime( $Ldata['log_time'] ); $user_time = WPTC_Factory::get( 'config' )->cnvt_UTC_to_usrTime( $Ldata['log_time'] );
WPTC_Factory::get( 'processed-files' )->modify_schedule_backup_time( $user_time ); WPTC_Factory::get( 'processed-files' )->modify_schedule_backup_time( $user_time );
$user_tz_now = date( 'M d, Y @ g:i:s a', $user_time ); $user_tz_now = date( 'M d, Y @ g:i:s a', $user_time ); // phpcs:ignore -- local time.
$msg = ''; $msg = '';
if ( ! ( strpos( $rec->type, 'backup' ) === false ) ) { if ( ! ( strpos( $rec->type, 'backup' ) === false ) ) {
// Backup process. // Backup process.
@ -1174,7 +1174,7 @@ class MainWP_Child_Timecapsule {
$now = localtime( time(), true ); $now = localtime( time(), true );
echo '<tr title=""><td>' . __( 'Server Time', 'wp-time-capsule' ) . '</td><td>' . esc_html( $now['tm_hour'] . ':' . $now['tm_min'] ) . '</td></tr>'; echo '<tr title=""><td>' . __( 'Server Time', 'wp-time-capsule' ) . '</td><td>' . esc_html( $now['tm_hour'] . ':' . $now['tm_min'] ) . '</td></tr>';
echo '<tr title=""><td>' . __( 'Blog Time', 'wp-time-capsule' ) . '</td><td>' . date( 'H:i', current_time( 'timestamp' ) ) . '</td></tr>'; // phpcs:ignore -- local time echo '<tr title=""><td>' . __( 'Blog Time', 'wp-time-capsule' ) . '</td><td>' . date( 'H:i', current_time( 'timestamp' ) ) . '</td></tr>'; // phpcs:ignore -- local time.
echo '<tr title="WPLANG"><td>' . __( 'Blog language', 'wp-time-capsule' ) . '</td><td>' . get_bloginfo( 'language' ) . '</td></tr>'; echo '<tr title="WPLANG"><td>' . __( 'Blog language', 'wp-time-capsule' ) . '</td><td>' . get_bloginfo( 'language' ) . '</td></tr>';
echo '<tr title="utf8"><td>' . __( 'MySQL Client encoding', 'wp-time-capsule' ) . '</td><td>'; echo '<tr title="utf8"><td>' . __( 'MySQL Client encoding', 'wp-time-capsule' ) . '</td><td>';
echo defined( 'DB_CHARSET' ) ? DB_CHARSET : ''; echo defined( 'DB_CHARSET' ) ? DB_CHARSET : '';

View file

@ -35,7 +35,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
add_filter( 'updraftplus_save_last_backup', array( __CLASS__, 'hook_updraft_plus_save_last_backup' ) ); add_filter( 'updraftplus_save_last_backup', array( __CLASS__, 'hook_updraft_plus_save_last_backup' ) );
} }
@ -81,7 +81,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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
$this->required_files(); $this->required_files();
@ -92,7 +92,7 @@ class MainWP_Child_Updraft_Plus_Backups {
} }
if ( empty( $updraftplus ) ) { if ( empty( $updraftplus ) ) {
$information['error'] = 'Error empty updraftplus'; $information['error'] = 'Error empty updraftplus';
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -163,7 +163,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$information = array( 'error' => $e->getMessage() ); $information = array( 'error' => $e->getMessage() );
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function set_showhide() { public function set_showhide() {

View file

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

View file

@ -35,7 +35,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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
$is_ver220 = $this->is_version_220(); $is_ver220 = $this->is_version_220();
@ -52,7 +52,7 @@ class MainWP_Child_WooCommerce_Status {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function is_version_220() { public function is_version_220() {
@ -166,8 +166,8 @@ class MainWP_Child_WooCommerce_Status {
$start_date = $_POST['start_date']; $start_date = $_POST['start_date'];
$end_date = $_POST['end_date']; $end_date = $_POST['end_date'];
$start_date = date( 'Y-m-d H:i:s', $start_date ); $start_date = date( 'Y-m-d H:i:s', $start_date ); // phpcs:ignore -- local time.
$end_date = date( 'Y-m-d H:i:s', $end_date ); $end_date = date( 'Y-m-d H:i:s', $end_date ); // phpcs:ignore -- local time.
// Get sales. // Get sales.
$sales = $wpdb->get_var( $sales = $wpdb->get_var(
@ -246,8 +246,8 @@ class MainWP_Child_WooCommerce_Status {
public function sync_data_two() { public function sync_data_two() {
// sync data for current month. // sync data for current month.
$start_date = date( 'Y-m-01 00:00:00', time() ); $start_date = date( 'Y-m-01 00:00:00', time() ); // phpcs:ignore -- local time.
$end_date = date( 'Y-m-d H:i:s', time() ); $end_date = date( 'Y-m-d H:i:s', time() ); // phpcs:ignore -- local time.
$start_date = strtotime( $start_date ); $start_date = strtotime( $start_date );
$end_date = strtotime( $end_date ); $end_date = strtotime( $end_date );
@ -278,8 +278,8 @@ class MainWP_Child_WooCommerce_Status {
return false; return false;
} }
$start_date = date( 'Y-m-d H:i:s', $start_date ); $start_date = date( 'Y-m-d H:i:s', $start_date ); // phpcs:ignore -- local time.
$end_date = date( 'Y-m-d H:i:s', $end_date ); $end_date = date( 'Y-m-d H:i:s', $end_date ); // phpcs:ignore -- local time.
$reports = new WC_Admin_Report(); $reports = new WC_Admin_Report();
// Sales. // Sales.

View file

@ -204,13 +204,13 @@ class MainWP_Child_Wordfence {
public function action() { public function action() {
$information = array(); $information = array();
if ( ! $this->is_wordfence_installed ) { if ( ! $this->is_wordfence_installed ) {
MainWP_Helper::write( array( 'error' => __( 'Please install the Wordfence plugin on the child site.', $this->plugin_translate ) ) ); mainwp_child_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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -424,7 +424,7 @@ class MainWP_Child_Wordfence {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
@ -677,7 +677,7 @@ class MainWP_Child_Wordfence {
// fix prepare sql empty. // fix prepare sql empty.
$sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime >= %d AND level = 1 AND type = 'info' AND msg LIKE ", $lastcheck ); $sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime >= %d AND level = 1 AND type = 'info' AND msg LIKE ", $lastcheck );
$sql .= " 'Scan Complete.%';"; $sql .= " 'Scan Complete.%';";
$rows = MainWP_Child_DB::_query( $sql, $wpdb->dbh ); $rows = MainWP_Child_DB::to_query( $sql, $wpdb->dbh );
$scan_time = array(); $scan_time = array();
if ( $rows ) { if ( $rows ) {
@ -692,7 +692,7 @@ class MainWP_Child_Wordfence {
$sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime > %d AND ctime < %d AND level = 10 AND type = 'info' AND msg LIKE ", $ctime, $ctime + 100 ); // to get nearest SUM_FINAL msg. $sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime > %d AND ctime < %d AND level = 10 AND type = 'info' AND msg LIKE ", $ctime, $ctime + 100 ); // to get nearest SUM_FINAL msg.
$sql .= " 'SUM_FINAL:Scan complete.%';"; $sql .= " 'SUM_FINAL:Scan complete.%';";
$sum_rows = MainWP_Child_DB::_query( $sql, $wpdb->dbh ); $sum_rows = MainWP_Child_DB::to_query( $sql, $wpdb->dbh );
$result = ''; $result = '';
if ( $sum_rows ) { if ( $sum_rows ) {
$sum_row = MainWP_Child_DB::fetch_array( $sum_rows ); $sum_row = MainWP_Child_DB::fetch_array( $sum_rows );
@ -2606,11 +2606,11 @@ SQL
'UPLOADS' => 'Custom upload folder location', 'UPLOADS' => 'Custom upload folder location',
'TEMPLATEPATH' => array( 'TEMPLATEPATH' => array(
'description' => 'Theme template folder override', 'description' => 'Theme template folder override',
'value' => ( defined( 'TEMPLATEPATH' ) && realpath( get_template_directory() ) !== realpath( TEMPLATEPATH ) ? 'Overridden' : '(not set)' ), 'value' => ( defined( 'TEMPLATEPATH' ) && realpath( get_template_directory() ) !== realpath( TEMPLATEPATH ) ? 'Overridden' : '(not set)' ), //phpcs:ignore -- use to check defined
), ),
'STYLESHEETPATH' => array( 'STYLESHEETPATH' => array(
'description' => 'Theme stylesheet folder override', 'description' => 'Theme stylesheet folder override',
'value' => ( defined( 'STYLESHEETPATH' ) && realpath( get_stylesheet_directory() ) !== realpath( STYLESHEETPATH ) ? 'Overridden' : '(not set)' ), 'value' => ( defined( 'STYLESHEETPATH' ) && realpath( get_stylesheet_directory() ) !== realpath( STYLESHEETPATH ) ? 'Overridden' : '(not set)' ), //phpcs:ignore -- use to check defined
), ),
'AUTOSAVE_INTERVAL' => 'Post editing automatic saving interval', 'AUTOSAVE_INTERVAL' => 'Post editing automatic saving interval',
'WP_POST_REVISIONS' => array( 'WP_POST_REVISIONS' => array(
@ -2871,7 +2871,7 @@ SQL
if ( is_numeric( $timestamp ) ) { if ( is_numeric( $timestamp ) ) {
?> ?>
<tr> <tr>
<td colspan="<?php echo $cols - 1; ?>"><?php echo esc_html( date( 'r', $timestamp ) ); ?></td> <td colspan="<?php echo $cols - 1; ?>"><?php echo esc_html( date( 'r', $timestamp ) ); // phpcs:ignore -- local time. ?></td>
<td><?php echo esc_html( $cron_job ); ?></td> <td><?php echo esc_html( $cron_job ); ?></td>
</tr> </tr>
<?php <?php

View file

@ -37,7 +37,7 @@ class MainWP_Child_WP_Rocket {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
if ( 'hide' === get_option( 'mainwp_wprocket_hide_plugin' ) ) { if ( 'hide' === get_option( 'mainwp_wprocket_hide_plugin' ) ) {
add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); add_filter( 'all_plugins', array( $this, 'all_plugins' ) );
@ -231,7 +231,7 @@ class MainWP_Child_WP_Rocket {
public function action() { public function action() {
if ( ! $this->is_plugin_installed ) { if ( ! $this->is_plugin_installed ) {
MainWP_Helper::write( array( 'error' => __( 'Please install WP Rocket plugin on child website', $this->plugin_translate ) ) ); mainwp_child_helper()->write( array( 'error' => __( 'Please install WP Rocket plugin on child website', $this->plugin_translate ) ) );
return; return;
} }
@ -275,7 +275,7 @@ class MainWP_Child_WP_Rocket {
$information = array( 'error' => $e->getMessage() ); $information = array( 'error' => $e->getMessage() );
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function set_showhide() { public function set_showhide() {

View file

@ -25,7 +25,7 @@ class MainWP_Child_WPvivid_BackupRestore {
return; return;
} }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
$this->public_intetface = new WPvivid_Public_Interface(); $this->public_intetface = new WPvivid_Public_Interface();
} }
@ -54,7 +54,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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -128,7 +128,7 @@ class MainWP_Child_WPvivid_BackupRestore {
$information = array( 'error' => $e->getMessage() ); $information = array( 'error' => $e->getMessage() );
} }
MainWP_Helper::write($information); mainwp_child_helper()->write($information);
} }
} }

View file

@ -2,6 +2,7 @@
namespace MainWP\Child; namespace MainWP\Child;
// phpcs:disable
if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) { if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) {
error_reporting( E_ALL ); error_reporting( E_ALL );
ini_set( 'display_errors', true ); ini_set( 'display_errors', true );
@ -12,6 +13,7 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) {
error_reporting( 0 ); error_reporting( 0 );
} }
} }
// phpcs:enable
require_once ABSPATH . '/wp-admin/includes/file.php'; require_once ABSPATH . '/wp-admin/includes/file.php';
require_once ABSPATH . '/wp-admin/includes/plugin.php'; require_once ABSPATH . '/wp-admin/includes/plugin.php';
@ -478,7 +480,7 @@ class MainWP_Child {
$auths = array(); $auths = array();
} }
if ( ! isset( $auths['last'] ) || $auths['last'] < mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) ) ) { if ( ! isset( $auths['last'] ) || $auths['last'] < mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) ) ) { // phpcs:ignore -- local time.
// Generate code for today. // Generate code for today.
for ( $i = 0; $i < $this->maxHistory; $i ++ ) { for ( $i = 0; $i < $this->maxHistory; $i ++ ) {
if ( ! isset( $auths[ $i + 1 ] ) ) { if ( ! isset( $auths[ $i + 1 ] ) ) {
@ -580,11 +582,14 @@ class MainWP_Child {
'branding' => ( null === self::$brandingTitle ) ? 'MainWP' : self::$brandingTitle, 'branding' => ( null === self::$brandingTitle ) ? 'MainWP' : self::$brandingTitle,
'parent_menu' => $settingsPage, 'parent_menu' => $settingsPage,
); );
do_action( 'mainwp-child-subpages', $subpageargs );
do_action_deprecated( 'mainwp-child-subpages', array( $subpageargs ), '4.0.7.1', 'mainwp_child_subpages' );
do_action( 'mainwp_child_subpages', $subpageargs );
$sub_pages = array(); $sub_pages = array();
$all_subpages = apply_filters( 'mainwp-child-init-subpages', array() ); $all_subpages = apply_filters_deprecated( 'mainwp-child-init-subpages', array( array() ), '4.0.7.1', 'mainwp_child_init_subpages' );
$all_subpages = apply_filters( 'mainwp_child_init_subpages', $all_subpages );
if ( ! is_array( $all_subpages ) ) { if ( ! is_array( $all_subpages ) ) {
$all_subpages = array(); $all_subpages = array();
@ -1089,7 +1094,7 @@ class MainWP_Child {
} }
unlink( $result[0] ); unlink( $result[0] );
MainWP_Helper::write( array( 'result' => 'ok' ) ); mainwp_child_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];
@ -1105,7 +1110,7 @@ class MainWP_Child {
return; return;
} }
MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) ); mainwp_child_helper()->write( array( 'size' => filesize( $archiveFile ) ) );
} elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) { } elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) {
MainWP_Helper::end_session(); MainWP_Helper::end_session();
@ -1182,7 +1187,7 @@ class MainWP_Child {
closedir( $fh ); closedir( $fh );
$information['themes'] = $themes; $information['themes'] = $themes;
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
} }
@ -1394,8 +1399,8 @@ class MainWP_Child {
MainWP_Child_Updraft_Plus_Backups::instance()->updraftplus_init(); MainWP_Child_Updraft_Plus_Backups::instance()->updraftplus_init();
MainWP_Child_Back_Up_WordPress::instance()->init(); MainWP_Child_Back_Up_WordPress::instance()->init();
MainWP_Child_WP_Rocket::instance()->init(); MainWP_Child_WP_Rocket::instance()->init();
MainWP_Child_Back_WP_Up::instance()->init(); \MainWP_Child_Back_WP_Up::instance()->init();
MainWP_Child_Back_Up_Buddy::instance(); \MainWP_Child_Back_Up_Buddy::instance();
MainWP_Child_Wordfence::instance()->wordfence_init(); MainWP_Child_Wordfence::instance()->wordfence_init();
MainWP_Child_Timecapsule::instance()->init(); MainWP_Child_Timecapsule::instance()->init();
MainWP_Child_Staging::instance()->init(); MainWP_Child_Staging::instance()->init();
@ -1645,8 +1650,10 @@ class MainWP_Child {
} }
} }
if ( ! empty( $fileName ) ) { if ( ! empty( $fileName ) ) {
do_action( 'mainwp_child_installPluginTheme', $args ); 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'] ) { if ( isset( $_POST['activatePlugin'] ) && 'yes' === $_POST['activatePlugin'] ) {
// to fix activate issue. // to fix activate issue.
if ( 'quotes-collection/quotes-collection.php' == $args['slug'] ) { if ( 'quotes-collection/quotes-collection.php' == $args['slug'] ) {
@ -1658,13 +1665,14 @@ class MainWP_Child {
} }
} else { } else {
$args['type'] = 'theme'; $args['type'] = 'theme';
$args['slug'] = $result['destination_name']; $args['slug'] = $result['destination_name'];
do_action( 'mainwp_child_installPluginTheme', $args ); 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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
// This will upgrade WP! // This will upgrade WP!
@ -1752,7 +1760,7 @@ class MainWP_Child {
remove_filter( 'pre_transient_update_core', $this->filterFunction, 99 ); remove_filter( 'pre_transient_update_core', $this->filterFunction, 99 );
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function upgrade_translation() { public function upgrade_translation() {
@ -1804,7 +1812,7 @@ class MainWP_Child {
} }
$information['sync'] = $this->get_site_stats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function upgrade_plugin_theme() { public function upgrade_plugin_theme() {
@ -2120,7 +2128,7 @@ class MainWP_Child {
} }
} }
$information['sync'] = $this->get_site_stats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function set_cached_update_plugins( $false = false, $_transient_data = null ) { public function set_cached_update_plugins( $false = false, $_transient_data = null ) {
@ -2303,7 +2311,7 @@ class MainWP_Child {
do_action( 'mainwp_child_after_newpost', $res ); do_action( 'mainwp_child_after_newpost', $res );
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function post_action() { public function post_action() {
@ -2379,7 +2387,7 @@ class MainWP_Child {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
$information['my_post'] = $my_post; $information['my_post'] = $my_post;
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function get_post_edit( $id ) { public function get_post_edit( $id ) {
@ -2590,7 +2598,7 @@ class MainWP_Child {
$information['users'] = $this->get_all_users_int( 500 ); $information['users'] = $this->get_all_users_int( 500 );
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function edit_user( $user_id, $data ) { public function edit_user( $user_id, $data ) {
@ -2808,7 +2816,7 @@ class MainWP_Child {
if ( ! isset( $information['status'] ) ) { if ( ! isset( $information['status'] ) ) {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function comment_bulk_action() { public function comment_bulk_action() {
@ -2837,7 +2845,7 @@ class MainWP_Child {
} }
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
@ -2861,7 +2869,7 @@ class MainWP_Child {
} }
$information['added'] = true; $information['added'] = true;
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function new_user() { public function new_user() {
@ -2899,7 +2907,7 @@ class MainWP_Child {
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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function cloneinfo() { public function cloneinfo() {
@ -2910,7 +2918,7 @@ class MainWP_Child {
$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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function backup_poll() { public function backup_poll() {
@ -2935,10 +2943,10 @@ class MainWP_Child {
} }
} }
if ( false === $archiveFile ) { if ( false === $archiveFile ) {
MainWP_Helper::write( array() ); mainwp_child_helper()->write( array() );
} }
MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) ); mainwp_child_helper()->write( array( 'size' => filesize( $archiveFile ) ) );
} else { } else {
$backupFile = 'dbBackup-' . $fileNameUID . '-*.sql'; $backupFile = 'dbBackup-' . $fileNameUID . '-*.sql';
@ -2946,14 +2954,14 @@ class MainWP_Child {
$backupdir = $dirs[0]; $backupdir = $dirs[0];
$result = glob( $backupdir . $backupFile . '*' ); $result = glob( $backupdir . $backupFile . '*' );
if ( 0 === count( $result ) ) { if ( 0 === count( $result ) ) {
MainWP_Helper::write( array() ); mainwp_child_helper()->write( array() );
} }
$size = 0; $size = 0;
foreach ( $result as $f ) { foreach ( $result as $f ) {
$size += filesize( $f ); $size += filesize( $f );
} }
MainWP_Helper::write( array( 'size' => $size ) ); mainwp_child_helper()->write( array( 'size' => $size ) );
exit(); exit();
} }
} }
@ -2976,12 +2984,12 @@ class MainWP_Child {
if ( $wp_filesystem->is_file( $pidFile ) ) { if ( $wp_filesystem->is_file( $pidFile ) ) {
$time = $wp_filesystem->mtime( $pidFile ); $time = $wp_filesystem->mtime( $pidFile );
$minutes = date( 'i', time() ); $minutes = date( 'i', time() ); // phpcs:ignore -- local time.
$seconds = date( 's', time() ); $seconds = date( 's', time() ); // phpcs:ignore -- local time.
$file_minutes = date( 'i', $time );
$file_seconds = date( 's', $time );
$file_minutes = date( 'i', $time ); // phpcs:ignore -- local time.
$file_seconds = date( 's', $time ); // phpcs:ignore -- local time.
$minuteDiff = $minutes - $file_minutes; $minuteDiff = $minutes - $file_minutes;
if ( 59 === $minuteDiff ) { if ( 59 === $minuteDiff ) {
$minuteDiff = 1; $minuteDiff = 1;
@ -3004,13 +3012,14 @@ class MainWP_Child {
$information['status'] = 'invalid'; $information['status'] = 'invalid';
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function backup( $pWrite = true ) { public function backup( $pWrite = true ) {
$timeout = 20 * 60 * 60; $timeout = 20 * 60 * 60;
set_time_limit( $timeout ); set_time_limit( $timeout );
ini_set( 'max_execution_time', $timeout ); ini_set( 'max_execution_time', $timeout ); // phpcs:ignore
MainWP_Helper::end_session(); MainWP_Helper::end_session();
// Cleanup pid files! // Cleanup pid files!
@ -3153,7 +3162,7 @@ class MainWP_Child {
} }
if ( $pWrite ) { if ( $pWrite ) {
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
return $information; return $information;
@ -3266,7 +3275,7 @@ class MainWP_Child {
if ( $sync ) { if ( $sync ) {
$information['sync'] = $this->get_site_stats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function do_security_un_fix() { public function do_security_un_fix() {
@ -3321,7 +3330,7 @@ class MainWP_Child {
$information['sync'] = $this->get_site_stats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function get_security_stats() { public function get_security_stats() {
@ -3338,7 +3347,7 @@ class MainWP_Child {
$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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function update_external_settings() { public function update_external_settings() {
@ -3427,7 +3436,7 @@ class MainWP_Child {
$timeout = 3 * 60 * 60; $timeout = 3 * 60 * 60;
set_time_limit( $timeout ); set_time_limit( $timeout );
ini_set( 'max_execution_time', $timeout ); ini_set( 'max_execution_time', $timeout ); //phpcs:ignore -- to custom
// Check for new versions. // Check for new versions.
if ( null !== $this->filterFunction ) { if ( null !== $this->filterFunction ) {
@ -3709,7 +3718,10 @@ class MainWP_Child {
$categories[] = $cat->name; $categories[] = $cat->name;
} }
$information['categories'] = $categories; $information['categories'] = $categories;
$get_file_size = apply_filters( 'mainwp-child-get-total-size', true );
$get_file_size = apply_filters_deprecated( 'mainwp-child-get-total-size', array( true ), '4.0.7.1', 'mainwp_child_get_total_size' );
$get_file_size = apply_filters( 'mainwp_child_get_total_size', $get_file_size );
if ( $get_file_size && isset( $_POST['cloneSites'] ) && ( '0' !== $_POST['cloneSites'] ) ) { if ( $get_file_size && isset( $_POST['cloneSites'] ) && ( '0' !== $_POST['cloneSites'] ) ) {
$max_exe = ini_get( 'max_execution_time' ); $max_exe = ini_get( 'max_execution_time' );
if ( $max_exe > 20 ) { if ( $max_exe > 20 ) {
@ -3775,14 +3787,16 @@ class MainWP_Child {
} }
try { try {
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData ); $information = apply_filters_deprecated( 'mainwp-site-sync-others-data', array( $information, $othersData ), '4.0.7.1', 'mainwp_site_sync_others_data' );
$information = apply_filters( 'mainwp_site_sync_others_data', $information, $othersData );
} catch ( \Exception $e ) { } catch ( \Exception $e ) {
// ok! // ok!
} }
} }
if ( $exit ) { if ( $exit ) {
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
return $information; return $information;
@ -3794,7 +3808,7 @@ class MainWP_Child {
if ( ! empty( $url ) ) { if ( ! empty( $url ) ) {
$information['faviIconUrl'] = $url; $information['faviIconUrl'] = $url;
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function get_favicon( $parse_page = false ) { public function get_favicon( $parse_page = false ) {
@ -4089,7 +4103,7 @@ class MainWP_Child {
public function get_terms() { public function get_terms() {
$taxonomy = base64_decode( $_POST['taxonomy'] ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. $taxonomy = base64_decode( $_POST['taxonomy'] ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
$rslt = get_terms( taxonomy_exists( $taxonomy ) ? $taxonomy : 'category', 'hide_empty=0' ); $rslt = get_terms( taxonomy_exists( $taxonomy ) ? $taxonomy : 'category', 'hide_empty=0' );
MainWP_Helper::write( $rslt ); mainwp_child_helper()->write( $rslt );
} }
public function set_terms() { public function set_terms() {
@ -4119,7 +4133,7 @@ class MainWP_Child {
) )
); );
} }
MainWP_Helper::write( $ids ); mainwp_child_helper()->write( $ids );
} }
public function get_post_meta() { public function get_post_meta() {
@ -4142,7 +4156,7 @@ class MainWP_Child {
} }
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM %s WHERE 1 = 1 $where ", $wpdb->postmeta ) ); $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM %s WHERE 1 = 1 $where ", $wpdb->postmeta ) );
MainWP_Helper::write( $results ); mainwp_child_helper()->write( $results );
} }
public function get_total_ezine_post() { public function get_total_ezine_post() {
@ -4159,7 +4173,7 @@ class MainWP_Child {
} }
$where .= " ( p.post_status='publish' OR p.post_status='future' OR p.post_status='draft' ) AND (pm.meta_key='_ezine_keyword' AND pm.meta_value='$keyword_meta')"; $where .= " ( p.post_status='publish' OR p.post_status='future' OR p.post_status='draft' ) AND (pm.meta_key='_ezine_keyword' AND pm.meta_value='$keyword_meta')";
$total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p JOIN $wpdb->postmeta pm ON p.ID=pm.post_id $where " ); $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p JOIN $wpdb->postmeta pm ON p.ID=pm.post_id $where " );
MainWP_Helper::write( $total ); mainwp_child_helper()->write( $total );
} }
public function cancel_scheduled_post() { public function cancel_scheduled_post() {
@ -4207,13 +4221,13 @@ class MainWP_Child {
$information['count'] = $count; $information['count'] = $count;
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function get_next_time_to_post() { public function get_next_time_to_post() {
$post_type = $_POST['post_type']; $post_type = $_POST['post_type'];
if ( 'post' !== $post_type && 'page' !== $post_type ) { if ( 'post' !== $post_type && 'page' !== $post_type ) {
MainWP_Helper::write( array( 'error' => 'Data error.' ) ); mainwp_child_helper()->write( array( 'error' => 'Data error.' ) );
return; return;
} }
@ -4246,10 +4260,10 @@ class MainWP_Child {
$information['next_post_id'] = $next_post->ID; $information['next_post_id'] = $next_post->ID;
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} catch ( \Exception $e ) { } catch ( \Exception $e ) {
$information['error'] = $e->getMessage(); $information['error'] = $e->getMessage();
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
} }
@ -4325,7 +4339,7 @@ class MainWP_Child {
$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_Helper::write( $rslt ); mainwp_child_helper()->write( $rslt );
} }
public function comments_clauses( $clauses ) { public function comments_clauses( $clauses ) {
@ -4371,7 +4385,7 @@ class MainWP_Child {
$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_Helper::write( $rslt ); mainwp_child_helper()->write( $rslt );
} }
public function get_recent_comments( $pAllowedStatuses, $pCount ) { public function get_recent_comments( $pAllowedStatuses, $pCount ) {
@ -4445,7 +4459,7 @@ class MainWP_Child {
$themeToDelete = current( $themes ); $themeToDelete = current( $themes );
if ( $themeToDelete == $theme_name ) { if ( $themeToDelete == $theme_name ) {
$information['error'] = 'IsActivatedTheme'; $information['error'] = 'IsActivatedTheme';
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
return; return;
} }
} }
@ -4473,7 +4487,7 @@ class MainWP_Child {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
$information['sync'] = $this->get_site_stats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function get_all_themes() { public function get_all_themes() {
@ -4482,7 +4496,7 @@ class MainWP_Child {
$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_Helper::write( $rslt ); mainwp_child_helper()->write( $rslt );
} }
public function get_all_themes_int( $filter, $keyword = '', $status = '' ) { public function get_all_themes_int( $filter, $keyword = '', $status = '' ) {
@ -4593,7 +4607,7 @@ class MainWP_Child {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
$information['sync'] = $this->get_site_stats( array(), false ); $information['sync'] = $this->get_site_stats( array(), false );
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function get_all_plugins() { public function get_all_plugins() {
@ -4602,7 +4616,7 @@ class MainWP_Child {
$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_Helper::write( $rslt ); mainwp_child_helper()->write( $rslt );
} }
public function get_all_plugins_int( $filter, $keyword = '', $status = '' ) { public function get_all_plugins_int( $filter, $keyword = '', $status = '' ) {
@ -4685,7 +4699,7 @@ class MainWP_Child {
if ( $return ) { if ( $return ) {
return $allusers; return $allusers;
} }
MainWP_Helper::write( $allusers ); mainwp_child_helper()->write( $allusers );
} }
public function get_all_users_int( $number = false ) { public function get_all_users_int( $number = false ) {
@ -4778,7 +4792,7 @@ class MainWP_Child {
} }
} }
MainWP_Helper::write( $allusers ); mainwp_child_helper()->write( $allusers );
} }
// Show stats without login - only allowed while no account is added yet. // Show stats without login - only allowed while no account is added yet.
@ -4792,7 +4806,7 @@ class MainWP_Child {
$information['version'] = self::$version; $information['version'] = self::$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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
// Deactivating the plugin. // Deactivating the plugin.
@ -4804,7 +4818,7 @@ class MainWP_Child {
MainWP_Helper::error( 'Plugin still active' ); MainWP_Helper::error( 'Plugin still active' );
} }
$information['deactivated'] = true; $information['deactivated'] = true;
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function activation() { public function activation() {
@ -4974,7 +4988,7 @@ class MainWP_Child {
$output['htaccess'] = ob_get_contents(); $output['htaccess'] = ob_get_contents();
ob_end_clean(); ob_end_clean();
MainWP_Helper::write( $output ); mainwp_child_helper()->write( $output );
} }
public function maintenance_site() { public function maintenance_site() {
@ -4995,16 +5009,16 @@ class MainWP_Child {
delete_option( 'mainwp_maintenance_opt_alert_404_email' ); delete_option( 'mainwp_maintenance_opt_alert_404_email' );
} }
$information['result'] = 'SUCCESS'; $information['result'] = 'SUCCESS';
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
return; return;
} elseif ( 'clear_settings' === $_POST['action'] ) { } elseif ( 'clear_settings' === $_POST['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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
$maint_options = $_POST['options']; $maint_options = $_POST['options'];
@ -5097,18 +5111,18 @@ class MainWP_Child {
do_action( 'mainwp_reports_maintenance', $message, $log_time, $details, $result ); do_action( 'mainwp_reports_maintenance', $message, $log_time, $details, $result );
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function maintenance_optimize() { public function maintenance_optimize() {
global $wpdb, $table_prefix; global $wpdb, $table_prefix;
$sql = 'SHOW TABLE STATUS FROM `' . DB_NAME . '`'; $sql = 'SHOW TABLE STATUS FROM `' . DB_NAME . '`';
$result = MainWP_Child_DB::_query( $sql, $wpdb->dbh ); $result = MainWP_Child_DB::to_query( $sql, $wpdb->dbh );
if ( MainWP_Child_DB::num_rows( $result ) && MainWP_Child_DB::is_result( $result ) ) { if ( MainWP_Child_DB::num_rows( $result ) && MainWP_Child_DB::is_result( $result ) ) {
while ( $row = MainWP_Child_DB::fetch_array( $result ) ) { while ( $row = MainWP_Child_DB::fetch_array( $result ) ) {
if ( strpos( $row['Name'], $table_prefix ) !== false ) { if ( strpos( $row['Name'], $table_prefix ) !== false ) {
$sql = 'OPTIMIZE TABLE ' . $row['Name']; $sql = 'OPTIMIZE TABLE ' . $row['Name'];
MainWP_Child_DB::_query( $sql, $wpdb->dbh ); MainWP_Child_DB::to_query( $sql, $wpdb->dbh );
} }
} }
} }
@ -5176,7 +5190,7 @@ class MainWP_Child {
$remote = 'undefined'; $remote = 'undefined';
} }
// log time. // log time.
$time = MainWP_Helper::clean( date( 'F jS Y, h:ia', time() ) ); $time = MainWP_Helper::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>' .
@ -5210,7 +5224,7 @@ class MainWP_Child {
$information = array( 'status' => 'FAIL' ); $information = array( 'status' => 'FAIL' );
if ( 'run_snippet' === $action || 'save_snippet' === $action ) { if ( 'run_snippet' === $action || 'save_snippet' === $action ) {
if ( ! isset( $_POST['code'] ) ) { if ( ! isset( $_POST['code'] ) ) {
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
} }
$code = stripslashes( $_POST['code'] ); $code = stripslashes( $_POST['code'] );
@ -5259,7 +5273,7 @@ class MainWP_Child {
} }
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function snippet_update_wp_config( $action, $slug, $code = '' ) { public function snippet_update_wp_config( $action, $slug, $code = '' ) {
@ -5316,7 +5330,7 @@ class MainWP_Child {
$information = array(); $information = array();
if ( empty( $file_url ) || empty( $path ) ) { if ( empty( $file_url ) || empty( $path ) ) {
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
return; return;
} }
@ -5338,7 +5352,7 @@ class MainWP_Child {
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_Helper::write( $information ); mainwp_child_helper()->write( $information );
return; return;
} }
@ -5352,7 +5366,7 @@ class MainWP_Child {
} catch ( \Exception $e ) { } catch ( \Exception $e ) {
$information['error'] = $e->getMessage(); $information['error'] = $e->getMessage();
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function wordpress_seo() { public function wordpress_seo() {
@ -5395,7 +5409,7 @@ class MainWP_Child {
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_Helper::write( array( 'error' => $error ) ); mainwp_child_helper()->write( array( 'error' => $error ) );
} }
MainWP_Child_Back_Up_WordPress::instance()->action(); MainWP_Child_Back_Up_WordPress::instance()->action();
} }
@ -5405,7 +5419,7 @@ class MainWP_Child {
} }
public function backwpup() { public function backwpup() {
MainWP_Child_Back_WP_Up::instance()->action(); \MainWP_Child_Back_WP_Up::instance()->action();
} }
@ -5419,13 +5433,13 @@ class MainWP_Child {
unlink( $backupdir . $file ); unlink( $backupdir . $file );
} }
MainWP_Helper::write( array( 'result' => 'ok' ) ); mainwp_child_helper()->write( array( 'result' => 'ok' ) );
} }
public function update_values() { public function update_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_Helper::write( array( 'result' => 'ok' ) ); mainwp_child_helper()->write( array( 'result' => 'ok' ) );
} }
public function upload_file( $file, $offset = 0 ) { public function upload_file( $file, $offset = 0 ) {
@ -5474,9 +5488,9 @@ class MainWP_Child {
public function settings_tools() { public function settings_tools() {
if ( isset( $_POST['action'] ) ) { if ( isset( $_POST['action'] ) ) {
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_Helper::write( array( 'error' => __( 'Cannot get user_id', 'mainwp-child' ) ) ); mainwp_child_helper()->write( array( 'error' => __( 'Cannot get user_id', 'mainwp-child' ) ) );
} }
wp_destroy_all_sessions(); wp_destroy_all_sessions();
@ -5484,17 +5498,17 @@ class MainWP_Child {
$sessions = wp_get_all_sessions(); $sessions = wp_get_all_sessions();
if ( empty( $sessions ) ) { if ( empty( $sessions ) ) {
MainWP_Helper::write( array( 'success' => 1 ) ); mainwp_child_helper()->write( array( 'success' => 1 ) );
} else { } else {
MainWP_Helper::write( array( 'error' => __( 'Cannot destroy sessions', 'mainwp-child' ) ) ); mainwp_child_helper()->write( array( 'error' => __( 'Cannot destroy sessions', 'mainwp-child' ) ) );
} }
break; break;
default: default:
MainWP_Helper::write( array( 'error' => __( 'Invalid action', 'mainwp-child' ) ) ); mainwp_child_helper()->write( array( 'error' => __( 'Invalid action', 'mainwp-child' ) ) );
} }
} else { } else {
MainWP_Helper::write( array( 'error' => __( 'Missing action', 'mainwp-child' ) ) ); mainwp_child_helper()->write( array( 'error' => __( 'Missing action', 'mainwp-child' ) ) );
} }
} }
@ -5507,7 +5521,7 @@ class MainWP_Child {
} }
public function backup_buddy() { public function backup_buddy() {
MainWP_Child_Back_Up_Buddy::instance()->action(); \MainWP_Child_Back_Up_Buddy::instance()->action();
} }
public function vulner_checker() { public function vulner_checker() {
@ -5526,12 +5540,12 @@ class MainWP_Child {
$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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function disconnect() { public function disconnect() {
$this->deactivation( false ); $this->deactivation( false );
MainWP_Helper::write( array( 'result' => 'success' ) ); mainwp_child_helper()->write( array( 'result' => 'success' ) );
} }
public static function fix_for_custom_themes() { public static function fix_for_custom_themes() {

View file

@ -19,7 +19,7 @@ class MainWP_Client_Report {
} }
public function init() { public function init() {
add_filter( 'mainwp-site-sync-others-data', array( $this, 'sync_others_data' ), 10, 2 ); add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) ); add_action( 'mainwp_child_log', array( 'MainWP_Client_Report', 'do_reports_log' ) );
} }
@ -47,13 +47,13 @@ class MainWP_Client_Report {
public static function do_reports_log( $ext = '' ) { public static function do_reports_log( $ext = '' ) {
switch ( $ext ) { switch ( $ext ) {
case 'backupbuddy': case 'backupbuddy':
MainWP_Child_Back_Up_Buddy::instance()->do_reports_log( $ext ); \MainWP_Child_Back_Up_Buddy::instance()->do_reports_log( $ext );
break; break;
case 'backupwordpress': case 'backupwordpress':
MainWP_Child_Back_Up_WordPress::instance()->do_reports_log( $ext ); MainWP_Child_Back_Up_WordPress::instance()->do_reports_log( $ext );
break; break;
case 'backwpup': case 'backwpup':
MainWP_Child_Back_WP_Up::instance()->do_reports_log( $ext ); \MainWP_Child_Back_WP_Up::instance()->do_reports_log( $ext );
break; break;
case 'wordfence': case 'wordfence':
MainWP_Child_Wordfence::instance()->do_reports_log( $ext ); MainWP_Child_Wordfence::instance()->do_reports_log( $ext );
@ -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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
if ( isset( $_POST['mwp_action'] ) ) { if ( isset( $_POST['mwp_action'] ) ) {
@ -89,7 +89,7 @@ class MainWP_Client_Report {
break; break;
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function save_sucuri_stream() { public function save_sucuri_stream() {
@ -313,11 +313,11 @@ class MainWP_Client_Report {
$args['with-meta'] = 1; $args['with-meta'] = 1;
if ( isset( $args['date_from'] ) ) { if ( isset( $args['date_from'] ) ) {
$args['date_from'] = date( 'Y-m-d', $args['date_from'] ); $args['date_from'] = date( 'Y-m-d', $args['date_from'] ); // phpcs:ignore -- local time.
} }
if ( isset( $args['date_to'] ) ) { if ( isset( $args['date_to'] ) ) {
$args['date_to'] = date( 'Y-m-d', $args['date_to'] ); $args['date_to'] = date( 'Y-m-d', $args['date_to'] ); // phpcs:ignore -- local time.
} }
if ( MainWP_Child_Branding::instance()->is_branding() ) { if ( MainWP_Child_Branding::instance()->is_branding() ) {
@ -335,23 +335,25 @@ class MainWP_Client_Report {
// fix invalid data, or skip records! // fix invalid data, or skip records!
$skip_records = array(); $skip_records = array();
// fix for incorrect posts created logging! // fix for incorrect posts created logs!
// query created posts from WP posts data to simulate records logging for created posts. // query created posts from WP posts data to simulate records logging for created posts.
if ( isset( $_POST['direct_posts'] ) && ! empty( $_POST['direct_posts'] ) ) { if ( isset( $_POST['direct_posts'] ) && ! empty( $_POST['direct_posts'] ) ) {
$query_string = array(
$args = array(
'post_type' => 'post', 'post_type' => 'post',
'post_status' => 'publish',
'date_query' => array( 'date_query' => array(
'column' => 'post_date', 'column' => 'post_date',
'after' => $args['date_from'], 'after' => $args['date_from'],
'before' => $args['date_to'], 'before' => $args['date_to'],
), ),
'post_status' => 'publish',
); );
$records_created_posts = query_posts( $query_string ); $result = new \WP_Query( $args );
$records_created_posts = $result->posts;
if ( $records_created_posts ) { if ( $records_created_posts ) {
$count_records = count( $records ); $count_records = count( $records );
for ( $i = 0; $i < $count_records; $i++ ) { for ( $i = 0; $i < $count_records; $i++ ) {
$record = $records[ $i ]; $record = $records[ $i ];

View file

@ -317,14 +317,6 @@ class MainWP_Clone_Install {
return false; return false;
} }
public function cleanUp() {
// Clean up!
$files = glob( '../dbBackup*.sql' );
foreach ( $files as $file ) {
unlink( $file );
}
}
public function get_config_contents() { public function get_config_contents() {
if ( 'extracted' === $this->file ) { if ( 'extracted' === $this->file ) {
return file_get_contents( '../clone/config.txt' ); return file_get_contents( '../clone/config.txt' );
@ -526,13 +518,13 @@ class MainWP_Clone_Install {
$columns = array(); $columns = array();
// Get a list of columns in this table. // Get a list of columns in this table.
$fields = MainWP_Child_DB::_query( 'DESCRIBE ' . $table, $connection ); $fields = MainWP_Child_DB::to_query( 'DESCRIBE ' . $table, $connection );
while ( $column = MainWP_Child_DB::fetch_array( $fields ) ) { while ( $column = MainWP_Child_DB::fetch_array( $fields ) ) {
$columns[ $column['Field'] ] = 'PRI' === $column['Key'] ? true : false; $columns[ $column['Field'] ] = 'PRI' === $column['Key'] ? true : false;
} }
// Count the number of rows we have in the table if large we'll split into blocks, This is a mod from Simon Wheatley. // Count the number of rows we have in the table if large we'll split into blocks, This is a mod from Simon Wheatley.
$row_count = MainWP_Child_DB::_query( 'SELECT COUNT(*) as count FROM ' . $table, $connection ); $row_count = MainWP_Child_DB::to_query( 'SELECT COUNT(*) as count FROM ' . $table, $connection );
$rows_result = MainWP_Child_DB::fetch_array( $row_count ); $rows_result = MainWP_Child_DB::fetch_array( $row_count );
$row_count = $rows_result['count']; $row_count = $rows_result['count'];
if ( 0 === $row_count ) { if ( 0 === $row_count ) {
@ -546,7 +538,7 @@ class MainWP_Clone_Install {
$start = $page * $page_size; $start = $page * $page_size;
$end = $start + $page_size; $end = $start + $page_size;
// Grab the content of the table. // Grab the content of the table.
$data = MainWP_Child_DB::_query( sprintf( 'SELECT * FROM %s LIMIT %d, %d', $table, $start, $end ), $connection ); $data = MainWP_Child_DB::to_query( sprintf( 'SELECT * FROM %s LIMIT %d, %d', $table, $start, $end ), $connection );
if ( ! $data ) { if ( ! $data ) {
$report['errors'][] = MainWP_Child_DB::error(); $report['errors'][] = MainWP_Child_DB::error();
} }
@ -583,7 +575,7 @@ class MainWP_Clone_Install {
if ( $upd && ! empty( $where_sql ) ) { if ( $upd && ! empty( $where_sql ) ) {
$sql = 'UPDATE ' . $table . ' SET ' . implode( ', ', $update_sql ) . ' WHERE ' . implode( ' AND ', array_filter( $where_sql ) ); $sql = 'UPDATE ' . $table . ' SET ' . implode( ', ', $update_sql ) . ' WHERE ' . implode( ' AND ', array_filter( $where_sql ) );
$result = MainWP_Child_DB::_query( $sql, $connection ); $result = MainWP_Child_DB::to_query( $sql, $connection );
if ( ! $result ) { if ( ! $result ) {
$report['errors'][] = MainWP_Child_DB::error(); $report['errors'][] = MainWP_Child_DB::error();
} else { } else {

View file

@ -38,7 +38,7 @@ class MainWP_Custom_Post_Type {
$information = array(); $information = array();
switch ( $_POST['action'] ) { switch ( $_POST['action'] ) {
case 'custom_post_type_import': case 'custom_post_type_import':
$information = $this->_import(); $information = $this->import_custom_post();
break; break;
default: default:
@ -51,7 +51,7 @@ class MainWP_Custom_Post_Type {
exit(); exit();
} }
private function _import() { private function import_custom_post() {
add_filter( 'http_request_host_is_external', '__return_true' ); add_filter( 'http_request_host_is_external', '__return_true' );
if ( ! isset( $_POST['data'] ) || strlen( $_POST['data'] ) < 2 ) { if ( ! isset( $_POST['data'] ) || strlen( $_POST['data'] ) < 2 ) {
@ -66,11 +66,11 @@ class MainWP_Custom_Post_Type {
return array( 'error' => __( 'Cannot decode data', $this->plugin_translate ) ); return array( 'error' => __( 'Cannot decode data', $this->plugin_translate ) );
} }
$edit_id = ( isset( $_POST['post_id'] ) && ! empty( $_POST['post_id'] ) ) ? $_POST['post_id'] : 0; $edit_id = ( isset( $_POST['post_id'] ) && ! empty( $_POST['post_id'] ) ) ? $_POST['post_id'] : 0;
$return = $this->_insert_post( $data, $edit_id, $parent_id = 0 ); $return = $this->insert_post( $data, $edit_id, $parent_id = 0 );
if ( isset( $return['success'] ) && 1 == $return['success'] ) { if ( isset( $return['success'] ) && 1 == $return['success'] ) {
if ( isset( $data['product_variation'] ) && is_array( $data['product_variation'] ) ) { if ( isset( $data['product_variation'] ) && is_array( $data['product_variation'] ) ) {
foreach ( $data['product_variation'] as $product_variation ) { foreach ( $data['product_variation'] as $product_variation ) {
$return_variantion = $this->_insert_post( $product_variation, 0, $return['post_id'] ); $return_variantion = $this->insert_post( $product_variation, 0, $return['post_id'] );
} }
} }
} }
@ -82,7 +82,7 @@ class MainWP_Custom_Post_Type {
/** /**
* Search image inside post content and upload it to child * Search image inside post content and upload it to child
*/ */
private function _search_images( $post_content, $upload_dir, $check_image = false ) { private function search_images( $post_content, $upload_dir, $check_image = false ) {
$foundMatches = preg_match_all( '/(<a[^>]+href=\"(.*?)\"[^>]*>)?(<img[^>\/]*src=\"((.*?)(png|gif|jpg|jpeg))\")/ix', $post_content, $matches, PREG_SET_ORDER ); $foundMatches = preg_match_all( '/(<a[^>]+href=\"(.*?)\"[^>]*>)?(<img[^>\/]*src=\"((.*?)(png|gif|jpg|jpeg))\")/ix', $post_content, $matches, PREG_SET_ORDER );
if ( $foundMatches > 0 ) { if ( $foundMatches > 0 ) {
foreach ( $matches as $match ) { foreach ( $matches as $match ) {
@ -133,7 +133,7 @@ class MainWP_Custom_Post_Type {
return $post_content; return $post_content;
} }
private function _insert_post( $data, $edit_id, $parent_id = 0 ) { private function insert_post( $data, $edit_id, $parent_id = 0 ) {
$data_insert = array(); $data_insert = array();
$data_post = $data['post']; $data_post = $data['post'];
$data_insert['post_author'] = get_current_user_id(); $data_insert['post_author'] = get_current_user_id();
@ -205,7 +205,7 @@ class MainWP_Custom_Post_Type {
wp_delete_object_term_relationships( $old_post_id, get_object_taxonomies( $data_insert['post_type'] ) ); wp_delete_object_term_relationships( $old_post_id, get_object_taxonomies( $data_insert['post_type'] ) );
} }
$data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'], $check_image_existed ); $data_insert['post_content'] = $this->search_images( $data_insert['post_content'], $data['extras']['upload_dir'], $check_image_existed );
if ( ! empty( $parent_id ) ) { if ( ! empty( $parent_id ) ) {
$data_insert['post_parent'] = $parent_id; $data_insert['post_parent'] = $parent_id;

View file

@ -4,7 +4,16 @@ namespace MainWP\Child;
class MainWP_Helper { class MainWP_Helper {
public static function write( $val ) { public static $instance = null;
public static function instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
public function write( $val ) {
if ( isset( $_REQUEST['json_result'] ) && true == $_REQUEST['json_result'] ) : if ( isset( $_REQUEST['json_result'] ) && true == $_REQUEST['json_result'] ) :
$output = self::safe_json_encode( $val ); $output = self::safe_json_encode( $val );
else : else :
@ -437,7 +446,7 @@ class MainWP_Helper {
if ( $is_post_plus ) { if ( $is_post_plus ) {
if ( isset( $new_post['post_date_gmt'] ) && ! empty( $new_post['post_date_gmt'] ) && '0000-00-00 00:00:00' != $new_post['post_date_gmt'] ) { if ( isset( $new_post['post_date_gmt'] ) && ! empty( $new_post['post_date_gmt'] ) && '0000-00-00 00:00:00' != $new_post['post_date_gmt'] ) {
$post_date_timestamp = strtotime( $new_post['post_date_gmt'] ) + get_option( 'gmt_offset' ) * 60 * 60; $post_date_timestamp = strtotime( $new_post['post_date_gmt'] ) + get_option( 'gmt_offset' ) * 60 * 60;
$new_post['post_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp ); $new_post['post_date'] = date( 'Y-m-d H:i:s', $post_date_timestamp ); // phpcs:ignore -- local time.
} }
} }
@ -558,7 +567,7 @@ class MainWP_Helper {
$random_date_to = isset( $post_custom['_saved_draft_publish_date_to'] ) ? $post_custom['_saved_draft_publish_date_to'] : 0; $random_date_to = isset( $post_custom['_saved_draft_publish_date_to'] ) ? $post_custom['_saved_draft_publish_date_to'] : 0;
$random_date_to = is_array( $random_date_to ) ? current( $random_date_to ) : 0; $random_date_to = is_array( $random_date_to ) ? current( $random_date_to ) : 0;
$now = current_time( 'timestamp' ); $now = time();
if ( empty( $random_date_from ) ) { if ( empty( $random_date_from ) ) {
$random_date_from = $now; $random_date_from = $now;
@ -579,7 +588,7 @@ class MainWP_Helper {
} }
$random_timestamp = wp_rand( $random_date_from, $random_date_to ); $random_timestamp = wp_rand( $random_date_from, $random_date_to );
$new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp ); $new_post['post_date'] = date( 'Y-m-d H:i:s', $random_timestamp ); // phpcs:ignore -- local time.
} }
} }
@ -1114,10 +1123,13 @@ class MainWP_Helper {
switch ( $last ) { switch ( $last ) {
case 'g': case 'g':
$val *= 1024; $val *= 1024;
break;
case 'm': case 'm':
$val *= 1024; $val *= 1024;
break;
case 'k': case 'k':
$val *= 1024; $val *= 1024;
break;
} }
return $val; return $val;
@ -1284,7 +1296,7 @@ class MainWP_Helper {
return true; return true;
} }
public static function get_lasttime_backup( $by ) { public function get_lasttime_backup( $by ) {
if ( 'backupwp' == $by ) { if ( 'backupwp' == $by ) {
$by = 'backupwordpress'; $by = 'backupwordpress';
@ -1472,7 +1484,7 @@ class MainWP_Helper {
// Remove anything which isn't a word, whitespace, number or any of the following caracters -_~,;:[](). // Remove anything which isn't a word, whitespace, number or any of the following caracters -_~,;:[]().
// If you don't need to handle multi-byte characters you can use preg_replace rather than mb_ereg_replace. // If you don't need to handle multi-byte characters you can use preg_replace rather than mb_ereg_replace.
// Thanks @Å?ukasz Rysiak! // Thanks @<EFBFBD>?ukasz Rysiak!
$filename = mb_ereg_replace( '([^\w\s\d\-_~,;:\[\]\(\).])', '', $filename ); $filename = mb_ereg_replace( '([^\w\s\d\-_~,;:\[\]\(\).])', '', $filename );
// Remove any runs of periods (thanks falstro!). // Remove any runs of periods (thanks falstro!).
$filename = mb_ereg_replace( '([\.]{2,})', '', $filename ); $filename = mb_ereg_replace( '([\.]{2,})', '', $filename );
@ -1564,7 +1576,7 @@ class MainWP_Helper {
return function_exists( 'is_wpe' ) && is_wpe(); return function_exists( 'is_wpe' ) && is_wpe();
} }
public static function check_files_exists( $files = array(), $return = false ) { public function check_files_exists( $files = array(), $return = false ) {
$missing = array(); $missing = array();
if ( is_array( $files ) ) { if ( is_array( $files ) ) {
foreach ( $files as $name ) { foreach ( $files as $name ) {
@ -1589,7 +1601,7 @@ class MainWP_Helper {
return true; return true;
} }
public static function check_classes_exists( $classes = array(), $return = false ) { public function check_classes_exists( $classes = array(), $return = false ) {
$missing = array(); $missing = array();
if ( is_array( $classes ) ) { if ( is_array( $classes ) ) {
foreach ( $classes as $name ) { foreach ( $classes as $name ) {
@ -1614,7 +1626,7 @@ class MainWP_Helper {
return true; return true;
} }
public static function check_methods( $object, $methods = array(), $return = false ) { public function check_methods( $object, $methods = array(), $return = false ) {
$missing = array(); $missing = array();
if ( is_array( $methods ) ) { if ( is_array( $methods ) ) {
$missing = array(); $missing = array();

View file

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

View file

@ -152,8 +152,8 @@ class MainWP_Security {
public static function remove_php_reporting( $force = false ) { public static function remove_php_reporting( $force = false ) {
if ( $force || self::get_security_option( 'php_reporting' ) ) { if ( $force || self::get_security_option( 'php_reporting' ) ) {
error_reporting( 0 ); error_reporting( 0 );
ini_set( 'display_errors', 'off' ); ini_set( 'display_errors', 'off' ); //phpcs:ignore -- to custom display errors
ini_set( 'display_startup_errors', 0 ); ini_set( 'display_startup_errors', 0 ); //phpcs:ignore -- to custom
} }
} }

View file

@ -40,7 +40,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_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
$result = array(); $result = array();
switch ( $_POST['action'] ) { switch ( $_POST['action'] ) {
@ -48,7 +48,7 @@ class MainWP_Wordpress_SEO {
$information = $this->import_settings(); $information = $this->import_settings();
break; break;
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function import_settings() { public function import_settings() {
@ -106,7 +106,7 @@ class MainWP_Wordpress_SEO {
} }
} }
MainWP_Helper::write( $information ); mainwp_child_helper()->write( $information );
} }
public function import_seo_settings( $file ) { public function import_seo_settings( $file ) {

View file

@ -693,7 +693,8 @@ class Tar_Archiver {
$this->add_data( $block ); $this->add_data( $block );
$i = 0; $i = 0;
while ( ( $line = substr( $content, $i ++ * 512, 512 ) ) != '' ) { while ( ( $line = substr( $content, $i * 512, 512 ) ) != '' ) {
$i++;
$this->add_data( pack( 'a512', $line ) ); $this->add_data( pack( 'a512', $line ) );
} }

View file

@ -102,3 +102,19 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
} }
} }
} }
if ( ! function_exists( 'mainwp_child_helper' ) ) {
/**
* Method mainwp_child_helper()
*
* Get MainWP Child helper instance.
*
* @return mixed MainWP\Child\MainWP_Helper
*
*/
function mainwp_child_helper() {
return MainWP\Child\MainWP_Helper::instance();
}
}

View file

@ -26,12 +26,11 @@ if ( ! defined( 'MAINWP_CHILD_URL' ) ) {
function mainwp_child_autoload( $class_name ) { function mainwp_child_autoload( $class_name ) {
if ( 0 !== strpos( $class_name, 'MainWP\Child' ) ) { if ( 0 === strpos( $class_name, 'MainWP\Child' ) ) {
return; // trip the namespace prefix: MainWP\Child\ .
$class_name = substr( $class_name, 13 );
} }
// trip the namespace prefix: MainWP\Child\ .
$class_name = substr( $class_name, 13 );
if ( 0 !== strpos( $class_name, 'MainWP_' ) ) { if ( 0 !== strpos( $class_name, 'MainWP_' ) ) {
return; return;
} }