diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index 8a0cb02..9b56af0 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -601,11 +601,13 @@ class MainWP_Backup { } public function create_backup_db( $filepath_prefix, $archiveExt = false, &$archiver = null ) { + // phpcs:disable $timeout = 20 * 60 * 60; set_time_limit( $timeout ); ini_set( 'max_execution_time', $timeout ); $mem = '512M'; ini_set( 'memory_limit', $mem ); + // phpcs:enable /** @var $wpdb wpdb */ global $wpdb; @@ -630,7 +632,7 @@ class MainWP_Backup { $table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_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 ) { $i = 0; diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index 699c104..dc81ca1 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -12,9 +12,8 @@ * Extension URL: https://mainwp.com/extension/mainwpbuddy/ */ -namespace MainWP\Child; - class MainWP_Child_Back_Up_Buddy { + public static $instance = null; public $plugin_translate = 'mainwp-child'; public $is_backupbuddy_installed = false; @@ -36,7 +35,7 @@ class MainWP_Child_Back_Up_Buddy { 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( 'mainwp_child_site_stats', array( $this, 'do_site_stats' ) ); @@ -215,7 +214,7 @@ class MainWP_Child_Back_Up_Buddy { public function action() { $information = array(); 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' ) ) { @@ -368,7 +367,7 @@ class MainWP_Child_Back_Up_Buddy { 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'] ) ) { $finish_time = $getOverview['lastBackupStats']['finish']; $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; MainWP_Helper::update_lasttime_backup( 'backupbuddy', $finish_time ); // support Require Backup Before Update feature. } else { diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index cb7b743..31a8773 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -31,7 +31,7 @@ class MainWP_Child_Back_Up_WordPress { if ( is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) { $this->is_plugin_installed = true; 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(); if ( ! self::is_activated() ) { $information['error'] = 'NO_BACKUPWORDPRESS'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } if ( isset( $_POST['mwp_action'] ) ) { @@ -128,7 +128,7 @@ class MainWP_Child_Back_Up_WordPress { 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'] : ''; if ( empty( $schedule_id ) ) { $information = array( 'error' => 'Empty schedule id' ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } else { $schedule_id = sanitize_text_field( rawurldecode( $schedule_id ) ); HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules(); if ( ! HM\BackUpWordPress\Schedules::get_instance()->get_schedule( $schedule_id ) ) { $information = array( 'result' => 'NOTFOUND' ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } } diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index d445edc..c52cfb4 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -13,8 +13,6 @@ * Extension URL: https://mainwp.com/extension/backwpup/ */ -namespace MainWP\Child; - if ( ! defined( 'MAINWP_BACKWPUP_DEVELOPMENT' ) ) { 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'; } - 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_path2; $this->is_backwpup_installed = true; $this->is_backwpup_pro = true; } 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'; - MainWP_Helper::check_files_exists( array( $file_path ) ); + mainwp_child_helper()->check_files_exists( array( $file_path ) ); require_once $file_path; $this->is_backwpup_installed = true; } if ( $this->is_backwpup_installed ) { - MainWP_Helper::check_classes_exists( 'BackWPup' ); - MainWP_Helper::check_methods( 'get_instance' ); - BackWPup::get_instance(); + mainwp_child_helper()->check_classes_exists( '\BackWPup' ); + mainwp_child_helper()->check_methods( 'get_instance' ); + \BackWPup::get_instance(); 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 ) { $this->is_backwpup_installed = false; @@ -104,7 +102,7 @@ class MainWP_Child_Back_WP_Up { public function action() { 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; } @@ -114,11 +112,11 @@ class MainWP_Child_Back_WP_Up { $error = error_get_last(); $info = self::$information; 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 ) ) { - MainWP_Helper::write( self::$information ); + mainwp_child_helper()->write( self::$information ); } 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 { - MainWP_Helper::check_classes_exists( array( 'BackWPup_File', 'BackWPup_Job' ) ); - MainWP_Helper::check_methods( 'BackWPup_File', array( 'get_absolute_path' ) ); - MainWP_Helper::check_methods( 'BackWPup_Job', array( 'read_logheader' ) ); + mainwp_child_helper()->check_classes_exists( array( '\BackWPup_File', '\BackWPup_Job' ) ); + mainwp_child_helper()->check_methods( '\BackWPup_File', array( 'get_absolute_path' ) ); + 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 = BackWPup_File::get_absolute_path( $log_folder ); + $log_folder = \BackWPup_File::get_absolute_path( $log_folder ); $log_folder = untrailingslashit( $log_folder ); $logfiles = array(); @@ -268,7 +266,7 @@ class MainWP_Child_Back_WP_Up { $log_items = array(); 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 ) { continue; } @@ -319,7 +317,7 @@ class MainWP_Child_Back_WP_Up { } 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 ) { @@ -330,7 +328,7 @@ class MainWP_Child_Back_WP_Up { public function sync_others_data( $information, $data = array() ) { if ( isset( $data['syncBackwpupData'] ) && $data['syncBackwpupData'] ) { try { - $lastbackup = MainWP_Helper::get_lasttime_backup( 'backwpup' ); + $lastbackup = mainwp_child_helper()->get_lasttime_backup( 'backwpup' ); $information['syncBackwpupData'] = array( 'lastbackup' => $lastbackup, ); @@ -342,24 +340,24 @@ class MainWP_Child_Back_WP_Up { } public function get_destinations_list() { - MainWP_Helper::check_classes_exists( array( 'BackWPup', 'BackWPup_Option' ) ); - MainWP_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_classes_exists( array( '\BackWPup', '\BackWPup_Option' ) ); + mainwp_child_helper()->check_methods( '\BackWPup', array( 'get_registered_destinations', 'get_destination' ) ); + mainwp_child_helper()->check_methods( '\BackWPup_Option', array( 'get_job_ids', 'get' ) ); $jobdest = array(); - $jobids = BackWPup_Option::get_job_ids(); - $destinations = BackWPup::get_registered_destinations(); + $jobids = \BackWPup_Option::get_job_ids(); + $destinations = \BackWPup::get_registered_destinations(); foreach ( $jobids as $jobid ) { - if ( BackWPup_Option::get( $jobid, 'backuptype' ) === 'sync' ) { + if ( \BackWPup_Option::get( $jobid, 'backuptype' ) === 'sync' ) { continue; } - $dests = BackWPup_Option::get( $jobid, 'destinations' ); + $dests = \BackWPup_Option::get( $jobid, 'destinations' ); foreach ( $dests as $dest ) { if ( ! $destinations[ $dest ]['class'] ) { continue; } - $dest_class = BackWPup::get_destination( $dest ); + $dest_class = \BackWPup::get_destination( $dest ); if ( $dest_class && method_exists( $dest_class, 'file_get_list' ) ) { $can_do_dest = $dest_class->file_get_list( $jobid . '_' . $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' : ''; - 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 ); } @@ -415,11 +413,11 @@ class MainWP_Child_Back_WP_Up { echo ''; echo ''; echo ''; - echo ''; - if ( ! class_exists( 'BackWPup_Pro', false ) ) { - echo ''; + echo ''; + if ( ! class_exists( '\BackWPup_Pro', false ) ) { + echo ''; } else { - echo ''; + echo ''; } echo ''; @@ -434,7 +432,7 @@ class MainWP_Child_Back_WP_Up { echo ''; echo ''; echo ''; echo ''; - echo ''; // phpcs:ignore -- local time + echo ''; // phpcs:ignore -- local time. echo ''; echo ' - + 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; } @@ -275,7 +275,7 @@ class MainWP_Child_WP_Rocket { $information = array( 'error' => $e->getMessage() ); } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function set_showhide() { diff --git a/class/class-mainwp-child-wpvivid-backuprestore.php b/class/class-mainwp-child-wpvivid-backuprestore.php index b7102d3..c835829 100644 --- a/class/class-mainwp-child-wpvivid-backuprestore.php +++ b/class/class-mainwp-child-wpvivid-backuprestore.php @@ -25,7 +25,7 @@ class MainWP_Child_WPvivid_BackupRestore { 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(); } @@ -54,7 +54,7 @@ class MainWP_Child_WPvivid_BackupRestore { $information = array(); if ( ! $this->is_plugin_installed ) { $information['error'] = 'NO_WPVIVIDBACKUP'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } if ( isset( $_POST['mwp_action'] ) ) { @@ -128,7 +128,7 @@ class MainWP_Child_WPvivid_BackupRestore { $information = array( 'error' => $e->getMessage() ); } - MainWP_Helper::write($information); + mainwp_child_helper()->write($information); } } diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index d6971f5..4f5fd93 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -2,6 +2,7 @@ namespace MainWP\Child; +// phpcs:disable if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) { error_reporting( E_ALL ); ini_set( 'display_errors', true ); @@ -12,6 +13,7 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) { error_reporting( 0 ); } } +// phpcs:enable require_once ABSPATH . '/wp-admin/includes/file.php'; require_once ABSPATH . '/wp-admin/includes/plugin.php'; @@ -478,7 +480,7 @@ class MainWP_Child { $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. for ( $i = 0; $i < $this->maxHistory; $i ++ ) { if ( ! isset( $auths[ $i + 1 ] ) ) { @@ -580,11 +582,14 @@ class MainWP_Child { 'branding' => ( null === self::$brandingTitle ) ? 'MainWP' : self::$brandingTitle, '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(); - $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 ) ) { $all_subpages = array(); @@ -1089,7 +1094,7 @@ class MainWP_Child { } unlink( $result[0] ); - MainWP_Helper::write( array( 'result' => 'ok' ) ); + mainwp_child_helper()->write( array( 'result' => 'ok' ) ); } elseif ( 'createCloneBackupPoll' === $_POST['cloneFunc'] ) { $dirs = MainWP_Helper::get_mainwp_dir( 'backup' ); $backupdir = $dirs[0]; @@ -1105,7 +1110,7 @@ class MainWP_Child { return; } - MainWP_Helper::write( array( 'size' => filesize( $archiveFile ) ) ); + mainwp_child_helper()->write( array( 'size' => filesize( $archiveFile ) ) ); } elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) { MainWP_Helper::end_session(); @@ -1182,7 +1187,7 @@ class MainWP_Child { closedir( $fh ); $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_Back_Up_WordPress::instance()->init(); MainWP_Child_WP_Rocket::instance()->init(); - MainWP_Child_Back_WP_Up::instance()->init(); - MainWP_Child_Back_Up_Buddy::instance(); + \MainWP_Child_Back_WP_Up::instance()->init(); + \MainWP_Child_Back_Up_Buddy::instance(); MainWP_Child_Wordfence::instance()->wordfence_init(); MainWP_Child_Timecapsule::instance()->init(); MainWP_Child_Staging::instance()->init(); @@ -1645,8 +1650,10 @@ class MainWP_Child { } } - if ( ! empty( $fileName ) ) { - do_action( 'mainwp_child_installPluginTheme', $args ); + if ( ! empty( $fileName ) ) { + do_action_deprecated( 'mainwp_child_installPluginTheme', array( $args ), '4.0.7.1', 'mainwp_child_install_plugin_theme' ); + do_action( 'mainwp_child_install_plugin_theme', $args ); + if ( isset( $_POST['activatePlugin'] ) && 'yes' === $_POST['activatePlugin'] ) { // to fix activate issue. if ( 'quotes-collection/quotes-collection.php' == $args['slug'] ) { @@ -1658,13 +1665,14 @@ class MainWP_Child { } } else { $args['type'] = 'theme'; - $args['slug'] = $result['destination_name']; - do_action( 'mainwp_child_installPluginTheme', $args ); + $args['slug'] = $result['destination_name']; + do_action_deprecated( 'mainwp_child_installPluginTheme', array( $args ), '4.0.7.1', 'mainwp_child_install_plugin_theme' ); + do_action( 'mainwp_child_install_plugin_theme', $args ); } } $information['installation'] = 'SUCCESS'; $information['destination_name'] = $result['destination_name']; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } // This will upgrade WP! @@ -1752,7 +1760,7 @@ class MainWP_Child { remove_filter( 'pre_transient_update_core', $this->filterFunction, 99 ); } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function upgrade_translation() { @@ -1804,7 +1812,7 @@ class MainWP_Child { } $information['sync'] = $this->get_site_stats( array(), false ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function upgrade_plugin_theme() { @@ -2120,7 +2128,7 @@ class MainWP_Child { } } $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 ) { @@ -2303,7 +2311,7 @@ class MainWP_Child { do_action( 'mainwp_child_after_newpost', $res ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function post_action() { @@ -2379,7 +2387,7 @@ class MainWP_Child { $information['status'] = 'SUCCESS'; } $information['my_post'] = $my_post; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function get_post_edit( $id ) { @@ -2590,7 +2598,7 @@ class MainWP_Child { $information['users'] = $this->get_all_users_int( 500 ); } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function edit_user( $user_id, $data ) { @@ -2808,7 +2816,7 @@ class MainWP_Child { if ( ! isset( $information['status'] ) ) { $information['status'] = 'SUCCESS'; } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } 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; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function new_user() { @@ -2899,7 +2907,7 @@ class MainWP_Child { wp_mail( $user_email, sprintf( __( '[%s] Your username and password' ), $blogname ), $message, '' ); } $information['added'] = true; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function cloneinfo() { @@ -2910,7 +2918,7 @@ class MainWP_Child { $information['site_url'] = get_option( 'site_url' ); $information['home'] = get_option( 'home' ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function backup_poll() { @@ -2935,10 +2943,10 @@ class MainWP_Child { } } 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 { $backupFile = 'dbBackup-' . $fileNameUID . '-*.sql'; @@ -2946,14 +2954,14 @@ class MainWP_Child { $backupdir = $dirs[0]; $result = glob( $backupdir . $backupFile . '*' ); if ( 0 === count( $result ) ) { - MainWP_Helper::write( array() ); + mainwp_child_helper()->write( array() ); } $size = 0; foreach ( $result as $f ) { $size += filesize( $f ); } - MainWP_Helper::write( array( 'size' => $size ) ); + mainwp_child_helper()->write( array( 'size' => $size ) ); exit(); } } @@ -2976,12 +2984,12 @@ class MainWP_Child { if ( $wp_filesystem->is_file( $pidFile ) ) { $time = $wp_filesystem->mtime( $pidFile ); - $minutes = date( 'i', time() ); - $seconds = date( 's', time() ); - - $file_minutes = date( 'i', $time ); - $file_seconds = date( 's', $time ); + $minutes = date( 'i', time() ); // phpcs:ignore -- local time. + $seconds = date( 's', time() ); // phpcs:ignore -- local time. + $file_minutes = date( 'i', $time ); // phpcs:ignore -- local time. + $file_seconds = date( 's', $time ); // phpcs:ignore -- local time. + $minuteDiff = $minutes - $file_minutes; if ( 59 === $minuteDiff ) { $minuteDiff = 1; @@ -3004,13 +3012,14 @@ class MainWP_Child { $information['status'] = 'invalid'; } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function backup( $pWrite = true ) { + $timeout = 20 * 60 * 60; set_time_limit( $timeout ); - ini_set( 'max_execution_time', $timeout ); + ini_set( 'max_execution_time', $timeout ); // phpcs:ignore MainWP_Helper::end_session(); // Cleanup pid files! @@ -3153,7 +3162,7 @@ class MainWP_Child { } if ( $pWrite ) { - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } return $information; @@ -3266,7 +3275,7 @@ class MainWP_Child { if ( $sync ) { $information['sync'] = $this->get_site_stats( array(), false ); } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function do_security_un_fix() { @@ -3321,7 +3330,7 @@ class MainWP_Child { $information['sync'] = $this->get_site_stats( array(), false ); } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function get_security_stats() { @@ -3338,7 +3347,7 @@ class MainWP_Child { $information['admin'] = ( MainWP_Security::admin_user_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() { @@ -3427,7 +3436,7 @@ class MainWP_Child { $timeout = 3 * 60 * 60; set_time_limit( $timeout ); - ini_set( 'max_execution_time', $timeout ); + ini_set( 'max_execution_time', $timeout ); //phpcs:ignore -- to custom // Check for new versions. if ( null !== $this->filterFunction ) { @@ -3709,7 +3718,10 @@ class MainWP_Child { $categories[] = $cat->name; } $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'] ) ) { $max_exe = ini_get( 'max_execution_time' ); if ( $max_exe > 20 ) { @@ -3775,14 +3787,16 @@ class MainWP_Child { } 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 ) { // ok! } } if ( $exit ) { - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } return $information; @@ -3794,7 +3808,7 @@ class MainWP_Child { if ( ! empty( $url ) ) { $information['faviIconUrl'] = $url; } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function get_favicon( $parse_page = false ) { @@ -4089,7 +4103,7 @@ class MainWP_Child { public function get_terms() { $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' ); - MainWP_Helper::write( $rslt ); + mainwp_child_helper()->write( $rslt ); } 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() { @@ -4142,7 +4156,7 @@ class MainWP_Child { } $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() { @@ -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')"; $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() { @@ -4207,13 +4221,13 @@ class MainWP_Child { $information['count'] = $count; } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function get_next_time_to_post() { $post_type = $_POST['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; } @@ -4246,10 +4260,10 @@ class MainWP_Child { $information['next_post_id'] = $next_post->ID; } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } catch ( \Exception $e ) { $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 ); $this->posts_where_suffix = ''; - MainWP_Helper::write( $rslt ); + mainwp_child_helper()->write( $rslt ); } public function comments_clauses( $clauses ) { @@ -4371,7 +4385,7 @@ class MainWP_Child { $rslt = $this->get_recent_comments( explode( ',', $_POST['status'] ), $maxComments ); $this->comments_and_clauses = ''; - MainWP_Helper::write( $rslt ); + mainwp_child_helper()->write( $rslt ); } public function get_recent_comments( $pAllowedStatuses, $pCount ) { @@ -4445,7 +4459,7 @@ class MainWP_Child { $themeToDelete = current( $themes ); if ( $themeToDelete == $theme_name ) { $information['error'] = 'IsActivatedTheme'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); return; } } @@ -4473,7 +4487,7 @@ class MainWP_Child { $information['status'] = 'SUCCESS'; } $information['sync'] = $this->get_site_stats( array(), false ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function get_all_themes() { @@ -4482,7 +4496,7 @@ class MainWP_Child { $filter = isset( $_POST['filter'] ) ? $_POST['filter'] : true; $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 = '' ) { @@ -4593,7 +4607,7 @@ class MainWP_Child { $information['status'] = 'SUCCESS'; } $information['sync'] = $this->get_site_stats( array(), false ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function get_all_plugins() { @@ -4602,7 +4616,7 @@ class MainWP_Child { $filter = isset( $_POST['filter'] ) ? $_POST['filter'] : true; $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 = '' ) { @@ -4685,7 +4699,7 @@ class MainWP_Child { if ( $return ) { return $allusers; } - MainWP_Helper::write( $allusers ); + mainwp_child_helper()->write( $allusers ); } 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. @@ -4792,7 +4806,7 @@ class MainWP_Child { $information['version'] = self::$version; $information['wpversion'] = $wp_version; $information['wpe'] = MainWP_Helper::is_wp_engine() ? 1 : 0; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } // Deactivating the plugin. @@ -4804,7 +4818,7 @@ class MainWP_Child { MainWP_Helper::error( 'Plugin still active' ); } $information['deactivated'] = true; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function activation() { @@ -4974,7 +4988,7 @@ class MainWP_Child { $output['htaccess'] = ob_get_contents(); ob_end_clean(); - MainWP_Helper::write( $output ); + mainwp_child_helper()->write( $output ); } public function maintenance_site() { @@ -4995,16 +5009,16 @@ class MainWP_Child { delete_option( 'mainwp_maintenance_opt_alert_404_email' ); } $information['result'] = 'SUCCESS'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); return; } elseif ( 'clear_settings' === $_POST['action'] ) { delete_option( 'mainwp_maintenance_opt_alert_404' ); delete_option( 'mainwp_maintenance_opt_alert_404_email' ); $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']; @@ -5097,18 +5111,18 @@ class MainWP_Child { do_action( 'mainwp_reports_maintenance', $message, $log_time, $details, $result ); } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function maintenance_optimize() { global $wpdb, $table_prefix; $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 ) ) { while ( $row = MainWP_Child_DB::fetch_array( $result ) ) { if ( strpos( $row['Name'], $table_prefix ) !== false ) { $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'; } // 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 = '
404 alert
' . '
TIME: ' . $time . '
' . @@ -5210,7 +5224,7 @@ class MainWP_Child { $information = array( 'status' => 'FAIL' ); if ( 'run_snippet' === $action || 'save_snippet' === $action ) { if ( ! isset( $_POST['code'] ) ) { - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } } $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 = '' ) { @@ -5316,7 +5330,7 @@ class MainWP_Child { $information = array(); if ( empty( $file_url ) || empty( $path ) ) { - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); return; } @@ -5338,7 +5352,7 @@ class MainWP_Child { if ( ! file_exists( $dir ) ) { if ( false === mkdir( $dir, 0777, true ) ) { $information['error'] = 'ERRORCREATEDIR'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); return; } @@ -5352,7 +5366,7 @@ class MainWP_Child { } catch ( \Exception $e ) { $information['error'] = $e->getMessage(); } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function wordpress_seo() { @@ -5395,7 +5409,7 @@ class MainWP_Child { public function backup_wp() { if ( ! version_compare( phpversion(), '5.3', '>=' ) ) { $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(); } @@ -5405,7 +5419,7 @@ class MainWP_Child { } 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 ); } - MainWP_Helper::write( array( 'result' => 'ok' ) ); + mainwp_child_helper()->write( array( 'result' => 'ok' ) ); } public function update_values() { $uniId = isset( $_POST['uniqueId'] ) ? $_POST['uniqueId'] : ''; 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 ) { @@ -5474,9 +5488,9 @@ class MainWP_Child { public function settings_tools() { if ( isset( $_POST['action'] ) ) { switch ( $_POST['action'] ) { - case 'force_destroy_sessions'; + case 'force_destroy_sessions': 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(); @@ -5484,17 +5498,17 @@ class MainWP_Child { $sessions = wp_get_all_sessions(); if ( empty( $sessions ) ) { - MainWP_Helper::write( array( 'success' => 1 ) ); + mainwp_child_helper()->write( array( 'success' => 1 ) ); } else { - MainWP_Helper::write( array( 'error' => __( 'Cannot destroy sessions', 'mainwp-child' ) ) ); + mainwp_child_helper()->write( array( 'error' => __( 'Cannot destroy sessions', 'mainwp-child' ) ) ); } break; default: - MainWP_Helper::write( array( 'error' => __( 'Invalid action', 'mainwp-child' ) ) ); + mainwp_child_helper()->write( array( 'error' => __( 'Invalid action', 'mainwp-child' ) ) ); } } 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() { - MainWP_Child_Back_Up_Buddy::instance()->action(); + \MainWP_Child_Back_Up_Buddy::instance()->action(); } public function vulner_checker() { @@ -5526,12 +5540,12 @@ class MainWP_Child { $post = $_POST; $information = array(); $information = apply_filters( 'mainwp_child_extra_execution', $information, $post ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function disconnect() { $this->deactivation( false ); - MainWP_Helper::write( array( 'result' => 'success' ) ); + mainwp_child_helper()->write( array( 'result' => 'success' ) ); } public static function fix_for_custom_themes() { diff --git a/class/class-mainwp-client-report.php b/class/class-mainwp-client-report.php index ddf45cf..f4b3e05 100644 --- a/class/class-mainwp-client-report.php +++ b/class/class-mainwp-client-report.php @@ -19,7 +19,7 @@ class MainWP_Client_Report { } 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' ) ); } @@ -47,13 +47,13 @@ class MainWP_Client_Report { public static function do_reports_log( $ext = '' ) { switch ( $ext ) { case 'backupbuddy': - MainWP_Child_Back_Up_Buddy::instance()->do_reports_log( $ext ); + \MainWP_Child_Back_Up_Buddy::instance()->do_reports_log( $ext ); break; case 'backupwordpress': MainWP_Child_Back_Up_WordPress::instance()->do_reports_log( $ext ); break; case 'backwpup': - MainWP_Child_Back_WP_Up::instance()->do_reports_log( $ext ); + \MainWP_Child_Back_WP_Up::instance()->do_reports_log( $ext ); break; case 'wordfence': MainWP_Child_Wordfence::instance()->do_reports_log( $ext ); @@ -70,7 +70,7 @@ class MainWP_Client_Report { if ( ! function_exists( 'wp_mainwp_stream_get_instance' ) ) { $information['error'] = __( 'No MainWP Child Reports plugin installed.', 'mainwp-child' ); - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } if ( isset( $_POST['mwp_action'] ) ) { @@ -89,7 +89,7 @@ class MainWP_Client_Report { break; } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function save_sucuri_stream() { @@ -313,11 +313,11 @@ class MainWP_Client_Report { $args['with-meta'] = 1; 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'] ) ) { - $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() ) { @@ -335,23 +335,25 @@ class MainWP_Client_Report { // fix invalid data, or skip records! $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. - if ( isset( $_POST['direct_posts'] ) && ! empty( $_POST['direct_posts'] ) ) { - $query_string = array( + if ( isset( $_POST['direct_posts'] ) && ! empty( $_POST['direct_posts'] ) ) { + + $args = array( 'post_type' => 'post', + 'post_status' => 'publish', 'date_query' => array( 'column' => 'post_date', 'after' => $args['date_from'], '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 ) { - + $count_records = count( $records ); for ( $i = 0; $i < $count_records; $i++ ) { $record = $records[ $i ]; diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php index b445226..436ed83 100644 --- a/class/class-mainwp-clone-install.php +++ b/class/class-mainwp-clone-install.php @@ -317,14 +317,6 @@ class MainWP_Clone_Install { return false; } - public function cleanUp() { - // Clean up! - $files = glob( '../dbBackup*.sql' ); - foreach ( $files as $file ) { - unlink( $file ); - } - } - public function get_config_contents() { if ( 'extracted' === $this->file ) { return file_get_contents( '../clone/config.txt' ); @@ -526,13 +518,13 @@ class MainWP_Clone_Install { $columns = array(); // 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 ) ) { $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. - $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 ); $row_count = $rows_result['count']; if ( 0 === $row_count ) { @@ -546,7 +538,7 @@ class MainWP_Clone_Install { $start = $page * $page_size; $end = $start + $page_size; // 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 ) { $report['errors'][] = MainWP_Child_DB::error(); } @@ -583,7 +575,7 @@ class MainWP_Clone_Install { if ( $upd && ! empty( $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 ) { $report['errors'][] = MainWP_Child_DB::error(); } else { diff --git a/class/class-mainwp-custom-post-type.php b/class/class-mainwp-custom-post-type.php index 5ed9f89..22e6b47 100755 --- a/class/class-mainwp-custom-post-type.php +++ b/class/class-mainwp-custom-post-type.php @@ -38,7 +38,7 @@ class MainWP_Custom_Post_Type { $information = array(); switch ( $_POST['action'] ) { case 'custom_post_type_import': - $information = $this->_import(); + $information = $this->import_custom_post(); break; default: @@ -51,7 +51,7 @@ class MainWP_Custom_Post_Type { exit(); } - private function _import() { + private function import_custom_post() { add_filter( 'http_request_host_is_external', '__return_true' ); 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 ) ); } $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( $data['product_variation'] ) && is_array( $data['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 */ - 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( '/(]+href=\"(.*?)\"[^>]*>)?(\/]*src=\"((.*?)(png|gif|jpg|jpeg))\")/ix', $post_content, $matches, PREG_SET_ORDER ); if ( $foundMatches > 0 ) { foreach ( $matches as $match ) { @@ -133,7 +133,7 @@ class MainWP_Custom_Post_Type { 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_post = $data['post']; $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'] ) ); } - $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 ) ) { $data_insert['post_parent'] = $parent_id; diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index d343965..3e1df3a 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -4,7 +4,16 @@ namespace MainWP\Child; 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'] ) : $output = self::safe_json_encode( $val ); else : @@ -437,7 +446,7 @@ class MainWP_Helper { 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'] ) { $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 = is_array( $random_date_to ) ? current( $random_date_to ) : 0; - $now = current_time( 'timestamp' ); + $now = time(); if ( empty( $random_date_from ) ) { $random_date_from = $now; @@ -579,7 +588,7 @@ class MainWP_Helper { } $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 ) { case 'g': $val *= 1024; + break; case 'm': $val *= 1024; + break; case 'k': $val *= 1024; + break; } return $val; @@ -1284,7 +1296,7 @@ class MainWP_Helper { return true; } - public static function get_lasttime_backup( $by ) { + public function get_lasttime_backup( $by ) { if ( 'backupwp' == $by ) { $by = 'backupwordpress'; @@ -1472,7 +1484,7 @@ class MainWP_Helper { // 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. - // Thanks @Å?ukasz Rysiak! + // Thanks @�?ukasz Rysiak! $filename = mb_ereg_replace( '([^\w\s\d\-_~,;:\[\]\(\).])', '', $filename ); // Remove any runs of periods (thanks falstro!). $filename = mb_ereg_replace( '([\.]{2,})', '', $filename ); @@ -1564,7 +1576,7 @@ class MainWP_Helper { 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(); if ( is_array( $files ) ) { foreach ( $files as $name ) { @@ -1589,7 +1601,7 @@ class MainWP_Helper { return true; } - public static function check_classes_exists( $classes = array(), $return = false ) { + public function check_classes_exists( $classes = array(), $return = false ) { $missing = array(); if ( is_array( $classes ) ) { foreach ( $classes as $name ) { @@ -1614,7 +1626,7 @@ class MainWP_Helper { return true; } - public static function check_methods( $object, $methods = array(), $return = false ) { + public function check_methods( $object, $methods = array(), $return = false ) { $missing = array(); if ( is_array( $methods ) ) { $missing = array(); diff --git a/class/class-mainwp-keyword-links.php b/class/class-mainwp-keyword-links.php index 6edf995..9bffc18 100644 --- a/class/class-mainwp-keyword-links.php +++ b/class/class-mainwp-keyword-links.php @@ -730,7 +730,7 @@ class MainWP_Keyword_Links { $result = $this->remove_keywords(); break; } - MainWP_Helper::write( $result ); + mainwp_child_helper()->write( $result ); } function remove_keywords() { diff --git a/class/class-mainwp-security.php b/class/class-mainwp-security.php index 83cf263..32ee819 100644 --- a/class/class-mainwp-security.php +++ b/class/class-mainwp-security.php @@ -152,8 +152,8 @@ class MainWP_Security { public static function remove_php_reporting( $force = false ) { if ( $force || self::get_security_option( 'php_reporting' ) ) { error_reporting( 0 ); - ini_set( 'display_errors', 'off' ); - ini_set( 'display_startup_errors', 0 ); + ini_set( 'display_errors', 'off' ); //phpcs:ignore -- to custom display errors + ini_set( 'display_startup_errors', 0 ); //phpcs:ignore -- to custom } } diff --git a/class/class-mainwp-wordpress-seo.php b/class/class-mainwp-wordpress-seo.php index 378e19b..8016cc4 100644 --- a/class/class-mainwp-wordpress-seo.php +++ b/class/class-mainwp-wordpress-seo.php @@ -40,7 +40,7 @@ class MainWP_Wordpress_SEO { public function action() { if ( ! class_exists( 'WPSEO_Admin' ) ) { $information['error'] = 'NO_WPSEO'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } $result = array(); switch ( $_POST['action'] ) { @@ -48,7 +48,7 @@ class MainWP_Wordpress_SEO { $information = $this->import_settings(); break; } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } 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 ) { diff --git a/class/class-tar-archiver.php b/class/class-tar-archiver.php index 027aed9..049bab1 100644 --- a/class/class-tar-archiver.php +++ b/class/class-tar-archiver.php @@ -693,7 +693,8 @@ class Tar_Archiver { $this->add_data( $block ); $i = 0; - while ( ( $line = substr( $content, $i ++ * 512, 512 ) ) != '' ) { + while ( ( $line = substr( $content, $i * 512, 512 ) ) != '' ) { + $i++; $this->add_data( pack( 'a512', $line ) ); } diff --git a/includes/functions.php b/includes/functions.php index af09cb0..270b46b 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -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(); + } +} \ No newline at end of file diff --git a/mainwp-child.php b/mainwp-child.php index a823dc8..9a26c3f 100644 --- a/mainwp-child.php +++ b/mainwp-child.php @@ -26,12 +26,11 @@ if ( ! defined( 'MAINWP_CHILD_URL' ) ) { function mainwp_child_autoload( $class_name ) { - if ( 0 !== strpos( $class_name, 'MainWP\Child' ) ) { - return; + if ( 0 === strpos( $class_name, 'MainWP\Child' ) ) { + // 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_' ) ) { return; }
' . __( 'Setting', 'mainwp-child' ) . '' . __( 'Value', 'mainwp-child' ) . '
' . __( 'Setting', 'mainwp-child' ) . '' . __( 'Value', 'mainwp-child' ) . '
' . __( 'WordPress version', 'mainwp-child' ) . '' . esc_html( BackWPup::get_plugin_data( 'wp_version' ) ) . '
' . __( 'BackWPup version', 'mainwp-child' ) . '' . esc_html( BackWPup::get_plugin_data( 'Version' ) ) . ' ' . __( 'Get pro.', 'mainwp-child' ) . '
' . __( 'WordPress version', 'mainwp-child' ) . '' . esc_html( \BackWPup::get_plugin_data( 'wp_version' ) ) . '
' . __( 'BackWPup version', 'mainwp-child' ) . '' . esc_html( \BackWPup::get_plugin_data( 'Version' ) ) . ' ' . __( 'Get pro.', 'mainwp-child' ) . '
' . __( 'BackWPup Pro version', 'mainwp-child' ) . '' . esc_html( BackWPup::get_plugin_data( 'Version' ) ) . '
' . __( 'BackWPup Pro version', 'mainwp-child' ) . '' . esc_html( \BackWPup::get_plugin_data( 'Version' ) ) . '
' . __( 'PHP version', 'mainwp-child' ) . '' . esc_html( PHP_VERSION ) . '
' . __( 'WP-Cron url:', 'mainwp-child' ) . '' . esc_html( site_url( 'wp-cron.php' ) ) . '
' . __( 'Server self connect:', 'mainwp-child' ) . ''; - $raw_response = BackWPup_Job::get_jobrun_url( 'test' ); + $raw_response =\BackWPup_Job::get_jobrun_url( 'test' ); $test_result = ''; 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() ) ); @@ -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 ) ) ); } $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'] ) ); } @@ -454,18 +452,18 @@ class MainWP_Child_Back_WP_Up { echo '
' . __( 'Temp folder:', 'mainwp-child' ) . ''; - 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' ) ) ); - } 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' ) ) ); + 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' ) ) ); + } 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' ) ) ); } else { - echo esc_html( BackWPup::get_plugin_data( 'TEMP' ) ); + echo esc_html( \BackWPup::get_plugin_data( 'TEMP' ) ); } echo '
' . __( 'Log folder:', 'mainwp-child' ) . ''; - $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 ) ) { 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 = BackWPup_File::get_absolute_path( $dir ); + $dir = \BackWPup_File::get_absolute_path( $dir ); foreach ( $_POST['settings']['logfile'] as $logfile ) { $logfile = basename( $logfile ); @@ -571,7 +569,7 @@ class MainWP_Child_Back_WP_Up { $job_id = (int) $_POST['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' ) ); } @@ -592,7 +590,7 @@ class MainWP_Child_Back_WP_Up { 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 ) ) { 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 = BackWPup_File::get_absolute_path( $log_folder ); + $log_folder = \BackWPup_File::get_absolute_path( $log_folder ); $log_file = $log_folder . basename( $_POST['settings']['logfile'] ); 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 ) { case 'logs': $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 ); 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 ); - $output = new BackWPup_Page_Logs(); + $output = new \BackWPup_Page_Logs(); $output->prepare_items(); break; case 'backups': update_user_option( get_current_user_id(), 'backwpupbackups_per_page', 99999999 ); - $output = new BackWPup_Page_Backups(); + $output = new \BackWPup_Page_Backups(); $output->items = array(); - $jobids = BackWPup_Option::get_job_ids(); + $jobids = \BackWPup_Option::get_job_ids(); if ( ! empty( $jobids ) ) { foreach ( $jobids as $jobid ) { - if ( BackWPup_Option::get( $jobid, 'backuptype' ) == 'sync' ) { + if ( \BackWPup_Option::get( $jobid, 'backuptype' ) == 'sync' ) { continue; } - $dests = BackWPup_Option::get( $jobid, 'destinations' ); + $dests = \Option::get( $jobid, 'destinations' ); foreach ( $dests as $dest ) { - $dest_class = BackWPup::get_destination( $dest ); + $dest_class = \BackWPup::get_destination( $dest ); if ( is_null( $dest_class ) ) { continue; } @@ -718,7 +716,7 @@ class MainWP_Child_Back_WP_Up { break; case 'jobs': - $output = new BackWPup_Page_Jobs(); + $output = new \BackWPup_Page_Jobs(); $output->prepare_items(); break; } @@ -728,15 +726,15 @@ class MainWP_Child_Back_WP_Up { foreach ( $output->items as $key => $val ) { $temp_array = array(); $temp_array['id'] = $val; - $temp_array['name'] = BackWPup_Option::get( $val, 'name' ); - $temp_array['type'] = BackWPup_Option::get( $val, 'type' ); - $temp_array['destinations'] = BackWPup_Option::get( $val, 'destinations' ); + $temp_array['name'] = \BackWPup_Option::get( $val, 'name' ); + $temp_array['type'] = \BackWPup_Option::get( $val, 'type' ); + $temp_array['destinations'] = \BackWPup_Option::get( $val, 'destinations' ); if ( $this->is_backwpup_pro ) { $temp_array['export'] = str_replace( '&', '&', 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 ) ); 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 ) ); @@ -746,11 +744,11 @@ class MainWP_Child_Back_WP_Up { } else { $temp_array['nextrun'] = __( 'Inactive', 'mainwp-child' ); } - if ( BackWPup_Option::get( $val, 'lastrun' ) ) { - $lastrun = BackWPup_Option::get( $val, 'lastrun' ); + if ( \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 ) ); - if ( BackWPup_Option::get( $val, 'lastruntime' ) ) { - $temp_array['lastrun'] .= ' ' . sprintf( __( 'Runtime: %d seconds', 'mainwp-child' ), 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' ) ); } } else { $temp_array['lastrun'] = __( 'not yet', 'mainwp-child' ); @@ -836,7 +834,7 @@ class MainWP_Child_Back_WP_Up { $dest = strtoupper( str_replace( 'download', '', $_GET['type'] ) ); if ( ! empty( $dest ) && strstr( $_GET['type'], 'download' ) ) { - $dest_class = BackWPup::get_destination( $dest ); + $dest_class = \BackWPup::get_destination( $dest ); if ( is_null( $dest_class ) ) { die( '-4' ); } @@ -913,7 +911,7 @@ class MainWP_Child_Back_WP_Up { remove_filter( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); ob_start(); - BackWPup_Page_Jobs::ajax_working(); + \BackWPup_Page_Jobs::ajax_working(); $output = ob_get_contents(); @@ -942,15 +940,15 @@ class MainWP_Child_Back_WP_Up { $this->wp_list_table_dependency(); ob_start(); - BackWPup_Page_Jobs::load(); + \BackWPup_Page_Jobs::load(); ob_end_clean(); $output = $this->check_backwpup_messages(); 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 { - $job_object = BackWPup_Job::get_working_data(); + $job_object = \BackWPup_Job::get_working_data(); if ( is_object( $job_object ) ) { return array( 'success' => 1, @@ -975,7 +973,7 @@ class MainWP_Child_Back_WP_Up { $this->wp_list_table_dependency(); ob_start(); - BackWPup_Page_Jobs::load(); + \BackWPup_Page_Jobs::load(); ob_end_clean(); $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'; } } protected function wizard_system_scan() { - if ( class_exists( 'BackWPup_Pro_Wizard_SystemTest' ) ) { + if ( class_exists( '\BackWPup_Pro_Wizard_SystemTest' ) ) { ob_start(); - $system_test = new BackWPup_Pro_Wizard_SystemTest(); + $system_test = new \BackWPup_Pro_Wizard_SystemTest(); $system_test->execute( null ); $output = ob_get_contents(); @@ -1063,8 +1061,8 @@ class MainWP_Child_Back_WP_Up { } } - if ( ! class_exists( 'Swift', false ) ) { - require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php'; + if ( ! class_exists( '\Swift', false ) ) { + require \BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php'; } 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 ) { $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 ) { - $exclude_dir_array[] = trailingslashit( str_replace( '\\', '/', realpath( BackWPup_File::get_upload_dir() ) ) ); + 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() ) ) ); } return array_unique( $exclude_dir_array ); @@ -1150,7 +1148,7 @@ class MainWP_Child_Back_WP_Up { 'content' => WP_CONTENT_DIR, 'plugin' => WP_PLUGIN_DIR, 'theme' => get_theme_root(), - 'upload' => BackWPup_File::get_upload_dir(), + 'upload' => \BackWPup_File::get_upload_dir(), ); foreach ( $folders as $key => $folder ) { @@ -1159,13 +1157,13 @@ class MainWP_Child_Back_WP_Up { if ( $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 ); if ( $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 ) ) ) { - $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( 'size' => $folder_size, 'name' => $file, @@ -1243,7 +1241,7 @@ class MainWP_Child_Back_WP_Up { } 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( 'success' => 1, @@ -1331,7 +1329,7 @@ class MainWP_Child_Back_WP_Up { $normalized && $to_exclude_parsed[ $key ] = $normalized; } 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 ); // Parse and save folders to include. @@ -1346,7 +1344,7 @@ class MainWP_Child_Back_WP_Up { $realpath && $to_include_parsed[ $key ] = $realpath; } 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 ); // Parse and save boolean fields. @@ -1362,7 +1360,7 @@ class MainWP_Child_Back_WP_Up { ); 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. $exclude_dirs_def = array( @@ -1389,7 +1387,7 @@ class MainWP_Child_Back_WP_Up { ); foreach ( $exclude_dirs_def as $key => $filter ) { $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' ) ); } - if ( ! class_exists( 'BackWPup' ) ) { + if ( ! class_exists( '\BackWPup' ) ) { 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'] ); } else { // generate jobid if not exists. - $newjobid = BackWPup_Option::get_job_ids(); + $newjobid = \BackWPup_Option::get_job_ids(); sort( $newjobid ); $job_id = end( $newjobid ) + 1; } @@ -1425,7 +1423,7 @@ class MainWP_Child_Back_WP_Up { update_site_option( 'backwpup_messages', array() ); 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 ) ) { $settings['value']['backupdir'] = $backupdir; } @@ -1437,16 +1435,16 @@ class MainWP_Child_Back_WP_Up { if ( 'jobtype-FILE' == $settings['tab'] ) { $this->edit_form_post_save( $settings['value'], $job_id ); - $messages = BackWPup_Admin::get_messages(); + $messages = \BackWPup_Admin::get_messages(); if ( empty( $messages['error'] ) ) { - $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id ); - BackWPup_Admin::message( sprintf( __( 'Changes for job %s saved.', 'mainwp-child' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' ' . __( 'Jobs overview', 'mainwp-child' ) . ' | ' . __( 'Run now', 'mainwp-child' ) . '' ); + $url = \BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id ); + \BackWPup_Admin::message( sprintf( __( 'Changes for job %s saved.', 'mainwp-child' ), \BackWPup_Option::get( $job_id, 'name' ) ) . ' ' . __( 'Jobs overview', 'mainwp-child' ) . ' | ' . __( 'Run now', 'mainwp-child' ) . '' ); } } elseif ( 'dest-DROPBOX' == $settings['tab'] ) { unset( $settings['value'] ); - BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id ); + \BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id ); } 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(); @@ -1459,26 +1457,26 @@ class MainWP_Child_Back_WP_Up { } 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'] ) ) { - 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'] ) { - BackWPup_Option::update( $job_id, 'dbdumpexclude', array() ); + \BackWPup_Option::update( $job_id, 'dbdumpexclude', array() ); } if ( isset( $settings['value']['dropboxtoken'] ) && isset( $settings['value']['dropboxroot'] ) ) { - BackWPup_Option::update( $job_id, 'dropboxtoken', $settings['value']['dropboxtoken'] ); - BackWPup_Option::update( $job_id, 'dropboxroot', $settings['value']['dropboxroot'] ); + \BackWPup_Option::update( $job_id, 'dropboxtoken', $settings['value']['dropboxtoken'] ); + \Option::update( $job_id, 'dropboxroot', $settings['value']['dropboxroot'] ); } $changes_array = array(); 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 ( isset( $this->exclusions[ $settings['tab'] ] ) ) { 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' ) ); } - if ( ! class_exists( 'BackWPup' ) ) { + if ( ! class_exists( '\BackWPup' ) ) { return array( 'error' => __( 'Install BackWPup on child website', 'mainwp-child' ) ); } @@ -1523,11 +1521,11 @@ class MainWP_Child_Back_WP_Up { $settings_views = 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(); - if ( class_exists( 'BackWPup_Pro' ) ) { - $pro_settings = BackWPup_Pro_Settings_APIKeys::get_instance(); + if ( class_exists( '\BackWPup_Pro' ) ) { + $pro_settings = \BackWPup_Pro_Settings_APIKeys::get_instance(); $pro_settings->save_form(); } diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index 1a3482f..8b36540 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -158,7 +158,7 @@ class MainWP_Child_Branding { $information = $this->update_branding(); break; } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function update_branding() { @@ -743,7 +743,7 @@ class MainWP_Child_Branding { $generator = ''; break; case 'export': - $generator = ''; //phpcs:ignore -- current local time + $generator = ''; //phpcs:ignore -- current local time. break; endswitch; diff --git a/class/class-mainwp-child-db.php b/class/class-mainwp-child-db.php index a62bc84..1a45aec 100644 --- a/class/class-mainwp-child-db.php +++ b/class/class-mainwp-child-db.php @@ -2,48 +2,50 @@ namespace MainWP\Child; + 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+). public static function use_mysqli() { /** @var $wpdb wpdb */ - if ( ! function_exists( 'mysqli_connect' ) ) { + if ( ! function_exists( '\mysqli_connect' ) ) { return false; } 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() ) { - return mysqli_query( $link, $query ); + return \mysqli_query( $link, $query ); } else { - return mysql_query( $query, $link ); + return \mysql_query( $query, $link ); } } public static function fetch_array( $result ) { if ( self::use_mysqli() ) { - return mysqli_fetch_array( $result, MYSQLI_ASSOC ); + return \mysqli_fetch_array( $result, MYSQLI_ASSOC ); } else { - return mysql_fetch_array( $result, MYSQL_ASSOC ); + return \mysql_fetch_array( $result, MYSQL_ASSOC ); } } public static function num_rows( $result ) { if ( self::use_mysqli() ) { - return mysqli_num_rows( $result ); + return \mysqli_num_rows( $result ); } else { - return mysql_num_rows( $result ); + return \mysql_num_rows( $result ); } } public static function connect( $host, $user, $pass ) { if ( self::use_mysqli() ) { - return mysqli_connect( $host, $user, $pass ); + return \mysqli_connect( $host, $user, $pass ); } else { - return mysql_connect( $host, $user, $pass ); + return \mysql_connect( $host, $user, $pass ); } } @@ -52,9 +54,9 @@ class MainWP_Child_DB { /** @var $wpdb wpdb */ global $wpdb; - return mysqli_select_db( $wpdb->dbh, $db ); + return \mysqli_select_db( $wpdb->dbh, $db ); } else { - return mysql_select_db( $db ); + return \mysql_select_db( $db ); } } @@ -63,9 +65,9 @@ class MainWP_Child_DB { /** @var $wpdb wpdb */ global $wpdb; - return mysqli_error( $wpdb->dbh ); + return \mysqli_error( $wpdb->dbh ); } else { - return mysql_error(); + return \mysql_error(); } } @@ -74,9 +76,9 @@ class MainWP_Child_DB { global $wpdb; if ( self::use_mysqli() ) { - return mysqli_real_escape_string( $wpdb->dbh, $value ); + return \mysqli_real_escape_string( $wpdb->dbh, $value ); } 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 */ global $wpdb; - $rows = self::_query( 'SHOW table STATUS', $wpdb->dbh ); + $rows = self::to_query( 'SHOW table STATUS', $wpdb->dbh ); $size = 0; while ( $row = self::fetch_array( $rows ) ) { $size += $row['Data_length']; diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index c32d045..8a46dbd 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -36,7 +36,7 @@ class MainWP_Child_IThemes_Security { 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() ) { @@ -56,7 +56,7 @@ class MainWP_Child_IThemes_Security { $information = array(); if ( ! class_exists( 'ITSEC_Core' ) || ! class_exists( 'ITSEC_Modules' ) ) { $information['error'] = 'NO_ITHEME'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } global $mainwp_itsec_modules_path; @@ -118,7 +118,7 @@ class MainWP_Child_IThemes_Security { break; } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function set_showhide() { diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php index d67019c..9b133f0 100644 --- a/class/class-mainwp-child-links-checker.php +++ b/class/class-mainwp-child-links-checker.php @@ -34,14 +34,14 @@ class MainWP_Child_Links_Checker { 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() { $information = array(); if ( ! defined( 'BLC_ACTIVE' ) || ! function_exists( 'blc_init' ) ) { $information['error'] = 'NO_BROKENLINKSCHECKER'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } blc_init(); @@ -78,9 +78,9 @@ class MainWP_Child_Links_Checker { break; } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } catch ( \Exception $e ) { - MainWP_Helper::write( array( 'error' => $e->getMessage() ) ); + mainwp_child_helper()->write( array( 'error' => $e->getMessage() ) ); } } diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php index 49bc284..fafd0e2 100644 --- a/class/class-mainwp-child-pagespeed.php +++ b/class/class-mainwp-child-pagespeed.php @@ -37,7 +37,7 @@ class MainWP_Child_Pagespeed { 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' ) ); } @@ -46,7 +46,7 @@ class MainWP_Child_Pagespeed { $information = array(); if ( ! defined( 'GPI_DIRECTORY' ) ) { $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'] ) ) { @@ -65,7 +65,7 @@ class MainWP_Child_Pagespeed { break; } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function child_deactivation() { diff --git a/class/class-mainwp-child-skeleton-key.php b/class/class-mainwp-child-skeleton-key.php index 11eb17e..3fd5632 100644 --- a/class/class-mainwp-child-skeleton-key.php +++ b/class/class-mainwp-child-skeleton-key.php @@ -19,7 +19,7 @@ class MainWP_Child_Skeleton_Key { function mainwp_skeleton_key_handle_fatal_error() { $error = error_get_last(); 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' ); } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); exit(); } diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php index d30849f..d5ef69b 100644 --- a/class/class-mainwp-child-staging.php +++ b/class/class-mainwp-child-staging.php @@ -38,7 +38,7 @@ class MainWP_Child_Staging { 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() { 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' ) ) { @@ -145,7 +145,7 @@ class MainWP_Child_Staging { break; } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function set_showhide() { diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index 081d01b..550f8fb 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -34,7 +34,7 @@ class MainWP_Child_Timecapsule { 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() { 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 { $this->require_files(); } catch ( \Exception $e ) { $error = $e->getMessage(); - MainWP_Helper::write( array( 'error' => $error ) ); + mainwp_child_helper()->write( array( 'error' => $error ) ); } $information = array(); @@ -80,7 +80,7 @@ class MainWP_Child_Timecapsule { 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 ) ) { - 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'] ) { @@ -209,7 +209,7 @@ class MainWP_Child_Timecapsule { 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 ) { 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; $all_backups = $wpdb->get_results( @@ -365,7 +365,7 @@ class MainWP_Child_Timecapsule { if ( ! empty( $last_backup_time ) ) { $user_time = $config->cnvt_UTC_to_usrTime( $last_backup_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; } else { $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 '; } - $orderby = ! empty( $_POST['orderby'] ) ? mysql_real_escape_string( $_POST['orderby'] ) : 'id'; - $order = ! empty( $_POST['order'] ) ? mysql_real_escape_string( $_POST['order'] ) : 'DESC'; + $orderby = ! empty( $_POST['orderby'] ) ? MainWP_Child_DB::real_escape_string( $_POST['orderby'] ) : 'id'; + $order = ! empty( $_POST['order'] ) ? MainWP_Child_DB::real_escape_string( $_POST['order'] ) : 'DESC'; if ( ! empty( $orderby ) & ! empty( $order ) ) { $query .= ' ORDER BY ' . $orderby . ' ' . $order; } @@ -583,7 +583,7 @@ class MainWP_Child_Timecapsule { $Ldata = unserialize( $rec->log_data ); $user_time = WPTC_Factory::get( 'config' )->cnvt_UTC_to_usrTime( $Ldata['log_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 = ''; if ( ! ( strpos( $rec->type, 'backup' ) === false ) ) { // Backup process. @@ -1174,7 +1174,7 @@ class MainWP_Child_Timecapsule { $now = localtime( time(), true ); echo '
' . __( 'Server Time', 'wp-time-capsule' ) . '' . esc_html( $now['tm_hour'] . ':' . $now['tm_min'] ) . '
' . __( 'Blog Time', 'wp-time-capsule' ) . '' . date( 'H:i', current_time( 'timestamp' ) ) . '
' . __( 'Blog Time', 'wp-time-capsule' ) . '' . date( 'H:i', current_time( 'timestamp' ) ) . '
' . __( 'Blog language', 'wp-time-capsule' ) . '' . get_bloginfo( 'language' ) . '
' . __( 'MySQL Client encoding', 'wp-time-capsule' ) . ''; echo defined( 'DB_CHARSET' ) ? DB_CHARSET : ''; diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index 300366b..37caa18 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -35,7 +35,7 @@ class MainWP_Child_Updraft_Plus_Backups { 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' ) ); } @@ -81,7 +81,7 @@ class MainWP_Child_Updraft_Plus_Backups { $information = array(); if ( ! $this->is_plugin_installed ) { $information['error'] = 'NO_UPDRAFTPLUS'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } $this->required_files(); @@ -92,7 +92,7 @@ class MainWP_Child_Updraft_Plus_Backups { } if ( empty( $updraftplus ) ) { $information['error'] = 'Error empty updraftplus'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } if ( isset( $_POST['mwp_action'] ) ) { @@ -163,7 +163,7 @@ class MainWP_Child_Updraft_Plus_Backups { $information = array( 'error' => $e->getMessage() ); } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function set_showhide() { diff --git a/class/class-mainwp-child-vulnerability-checker.php b/class/class-mainwp-child-vulnerability-checker.php index 9bdf2cd..b57a124 100644 --- a/class/class-mainwp-child-vulnerability-checker.php +++ b/class/class-mainwp-child-vulnerability-checker.php @@ -44,7 +44,7 @@ class MainWP_Child_Vulnerability_Checker { } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function vulner_recheck() { diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 39f7b45..3360306 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -35,7 +35,7 @@ class MainWP_Child_WooCommerce_Status { $information = array(); if ( ! class_exists( 'WooCommerce' ) || ! defined( 'WC_VERSION' ) ) { $information['error'] = 'NO_WOOCOMMERCE'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } $is_ver220 = $this->is_version_220(); @@ -52,7 +52,7 @@ class MainWP_Child_WooCommerce_Status { break; } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } public function is_version_220() { @@ -166,8 +166,8 @@ class MainWP_Child_WooCommerce_Status { $start_date = $_POST['start_date']; $end_date = $_POST['end_date']; - $start_date = date( 'Y-m-d H:i:s', $start_date ); - $end_date = date( 'Y-m-d H:i:s', $end_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 ); // phpcs:ignore -- local time. // Get sales. $sales = $wpdb->get_var( @@ -246,8 +246,8 @@ class MainWP_Child_WooCommerce_Status { public function sync_data_two() { // sync data for current month. - $start_date = date( 'Y-m-01 00:00:00', time() ); - $end_date = date( 'Y-m-d H:i:s', 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() ); // phpcs:ignore -- local time. $start_date = strtotime( $start_date ); $end_date = strtotime( $end_date ); @@ -278,8 +278,8 @@ class MainWP_Child_WooCommerce_Status { return false; } - $start_date = date( 'Y-m-d H:i:s', $start_date ); - $end_date = date( 'Y-m-d H:i:s', $end_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 ); // phpcs:ignore -- local time. $reports = new WC_Admin_Report(); // Sales. diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php index 24f1903..6626900 100644 --- a/class/class-mainwp-child-wordfence.php +++ b/class/class-mainwp-child-wordfence.php @@ -204,13 +204,13 @@ class MainWP_Child_Wordfence { public function action() { $information = array(); 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; } if ( ! class_exists( 'wordfence' ) || ! class_exists( 'wfScanEngine' ) ) { $information['error'] = 'NO_WORDFENCE'; - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } if ( isset( $_POST['mwp_action'] ) ) { @@ -424,7 +424,7 @@ class MainWP_Child_Wordfence { break; } } - MainWP_Helper::write( $information ); + mainwp_child_helper()->write( $information ); } @@ -677,7 +677,7 @@ class MainWP_Child_Wordfence { // fix prepare sql empty. $sql = sprintf( "SELECT * FROM {$table_wfStatus} WHERE ctime >= %d AND level = 1 AND type = 'info' AND msg LIKE ", $lastcheck ); $sql .= " 'Scan Complete.%';"; - $rows = MainWP_Child_DB::_query( $sql, $wpdb->dbh ); + $rows = MainWP_Child_DB::to_query( $sql, $wpdb->dbh ); $scan_time = array(); 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 .= " 'SUM_FINAL:Scan complete.%';"; - $sum_rows = MainWP_Child_DB::_query( $sql, $wpdb->dbh ); + $sum_rows = MainWP_Child_DB::to_query( $sql, $wpdb->dbh ); $result = ''; if ( $sum_rows ) { $sum_row = MainWP_Child_DB::fetch_array( $sum_rows ); @@ -2606,11 +2606,11 @@ SQL 'UPLOADS' => 'Custom upload folder location', 'TEMPLATEPATH' => array( '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( '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', 'WP_POST_REVISIONS' => array( @@ -2871,7 +2871,7 @@ SQL if ( is_numeric( $timestamp ) ) { ?>