diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index d4e12e4..b9fdfb0 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -30,11 +30,11 @@ class MainWP_Child_Back_Up_Buddy { public function __construct() { // To fix bug run dashboard on local machine // if ( is_plugin_active( 'backupbuddy/backupbuddy.php' )) { - if ( class_exists('pb_backupbuddy')) { + if ( class_exists('pb_backupbuddy') ) { $this->is_backupbuddy_installed = true; } - if ( ! $this->is_backupbuddy_installed) { + if ( ! $this->is_backupbuddy_installed ) { return; } @@ -61,7 +61,7 @@ class MainWP_Child_Back_Up_Buddy { return $value; } - if ( ! MainWP_Helper::is_screen_with_update()) { + if ( ! MainWP_Helper::is_screen_with_update() ) { return $value; } @@ -97,19 +97,19 @@ class MainWP_Child_Back_Up_Buddy { function do_site_stats() { - if (has_action('mainwp_child_reports_log')) { + if ( has_action('mainwp_child_reports_log') ) { do_action( 'mainwp_child_reports_log', 'backupbuddy'); } else { $this->do_reports_log('backupbuddy'); } } // ok - function do_reports_log( $ext = '') { - if ($ext !== 'backupbuddy') { + function do_reports_log( $ext = '' ) { + if ( $ext !== 'backupbuddy' ) { return; } - if ( ! $this->is_backupbuddy_installed) { + if ( ! $this->is_backupbuddy_installed ) { return; } @@ -123,7 +123,7 @@ class MainWP_Child_Back_Up_Buddy { } } - if (file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php')) { + if ( file_exists(pb_backupbuddy::plugin_path() . '/classes/fileoptions.php') ) { require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; } @@ -160,13 +160,13 @@ class MainWP_Child_Back_Up_Buddy { $backupType = ''; if ( isset( $backup['profile'] ) && isset( $backup['profile']['type'] ) ) { - if (true === MainWP_Helper::check_properties('pb_backupbuddy', 'format', true)) { - if (true === MainWP_Helper::check_methods(pb_backupbuddy::$format, array( 'prettify' ), true)) { + if ( true === MainWP_Helper::check_properties('pb_backupbuddy', 'format', true) ) { + if ( true === MainWP_Helper::check_methods(pb_backupbuddy::$format, array( 'prettify' ), true) ) { $backupType = pb_backupbuddy::$format->prettify( $backup['profile']['type'], $pretty_type ); } } } else { - if (true === MainWP_Helper::check_methods('backupbuddy_core', array( 'pretty_backup_type', 'getBackupTypeFromFile' ), true)) { + if ( true === MainWP_Helper::check_methods('backupbuddy_core', array( 'pretty_backup_type', 'getBackupTypeFromFile' ), true) ) { $backupType = backupbuddy_core::pretty_backup_type( backupbuddy_core::getBackupTypeFromFile( $backup['archive_file'] ) ); } } @@ -177,7 +177,7 @@ class MainWP_Child_Back_Up_Buddy { $finish_time = $backup['finish_time']; $message = 'BackupBuddy ' . $backupType . ' finished'; - if ( ! empty($finish_time)) { + if ( ! empty($finish_time) ) { do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time); } } @@ -189,23 +189,21 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_methods('backupbuddy_live_periodic', 'get_stats'); $state = backupbuddy_live_periodic::get_stats(); - if (is_array($state) && isset($state['stats'])) { + if ( is_array($state) && isset($state['stats']) ) { - if ( is_array($state['stats'] ) && isset( $state['stats']['last_remote_snapshot'] )) { - if (isset( $state['stats']['last_remote_snapshot_response'] )) { + if ( is_array($state['stats'] ) && isset( $state['stats']['last_remote_snapshot'] ) ) { + if ( isset( $state['stats']['last_remote_snapshot_response'] ) ) { $resp = $state['stats']['last_remote_snapshot_response']; - if ( isset( $resp['success'] ) && $resp['success']) { + if ( isset( $resp['success'] ) && $resp['success'] ) { $finish_time = $state['stats']['last_remote_snapshot']; $backupType = 'Live Backup to cloud'; $message = 'BackupBuddy ' . $backupType . ' finished'; - if ( ! empty($finish_time)) { + if ( ! empty($finish_time) ) { do_action( 'mainwp_reports_backupbuddy_backup', $message, $backupType, $finish_time); } - } } } - } } } catch ( Exception $e ) { @@ -384,7 +382,7 @@ class MainWP_Child_Back_Up_Buddy { $type = isset($_POST['type']) ? $_POST['type'] : ''; - if ($type !== 'general_settings' && $type !== 'advanced_settings' && $type !== 'all' ) { + if ( $type !== 'general_settings' && $type !== 'advanced_settings' && $type !== 'all' ) { return array( 'error' => __('Invalid data. Please check and try again.') ); } @@ -487,42 +485,42 @@ class MainWP_Child_Back_Up_Buddy { $save_settings = array(); - if (is_array($settings)) { - if ($type === 'all' || 'general_settings' === $type) { - foreach ($filter_general_settings as $field) { - if (isset($settings[ $field ])) { + if ( is_array($settings) ) { + if ( $type === 'all' || 'general_settings' === $type ) { + foreach ( $filter_general_settings as $field ) { + if ( isset($settings[ $field ]) ) { $save_settings[ $field ] = $settings[ $field ]; } } } - if ($type === 'all' || 'advanced_settings' === $type) { - foreach ($filter_advanced_settings as $field) { - if (isset($settings[ $field ])) { + if ( $type === 'all' || 'advanced_settings' === $type ) { + foreach ( $filter_advanced_settings as $field ) { + if ( isset($settings[ $field ]) ) { $save_settings[ $field ] = $settings[ $field ]; } } } } - if ( ! empty($save_settings)) { + if ( ! empty($save_settings) ) { $newOptions = pb_backupbuddy::$options; - foreach ($newOptions as $key => $val) { - if (isset($save_settings[ $key ])) { + foreach ( $newOptions as $key => $val ) { + if ( isset($save_settings[ $key ]) ) { $newOptions[ $key ] = $save_settings[ $key ]; } } - if (isset($newOptions['profiles']) && isset($newOptions['profiles'][0])) { - foreach ($filter_profile0_values as $field) { - if (isset($settings[ $field ])) { + if ( isset($newOptions['profiles']) && isset($newOptions['profiles'][0]) ) { + foreach ( $filter_profile0_values as $field ) { + if ( isset($settings[ $field ]) ) { $newOptions['profiles'][0][ $field ] = $settings[ $field ]; } } } - if ('general_settings' === $type || 'all' === $type ) { + if ( 'general_settings' === $type || 'all' === $type ) { $newOptions['importbuddy_pass_hash_confirm'] = ''; } @@ -616,7 +614,7 @@ class MainWP_Child_Back_Up_Buddy { $information['schedules_run_time'] = $this->get_schedules_run_time(); // to fix missing destination notice - if (isset(pb_backupbuddy::$options['remote_destinations'])) { // update + if ( isset(pb_backupbuddy::$options['remote_destinations']) ) { // update $information['remote_destinations'] = pb_backupbuddy::$options['remote_destinations']; } @@ -650,12 +648,12 @@ class MainWP_Child_Back_Up_Buddy { $schedule_id = intval($_POST['schedule_id']); $schedule = unserialize(base64_decode($_POST['data'])); - if ( ! is_array($schedule)) { + if ( ! is_array($schedule) ) { return array( 'error' => __( 'Invalid schedule data', 'mainwp-child' ) ); } $information = array(); // add new - if ( ! isset(pb_backupbuddy::$options['schedules'][ $schedule_id ])) { + if ( ! isset(pb_backupbuddy::$options['schedules'][ $schedule_id ]) ) { $next_index = pb_backupbuddy::$options['next_schedule_index']; pb_backupbuddy::$options['next_schedule_index']++; // This change will be saved in savesettings function below. pb_backupbuddy::$options['schedules'][ $schedule_id ] = $schedule; @@ -683,7 +681,7 @@ class MainWP_Child_Back_Up_Buddy { $profile_id = $_POST['profile_id']; $profile = unserialize(base64_decode($_POST['data'])); - if ( ! is_array($profile)) { + if ( ! is_array($profile) ) { return array( 'error' => __( 'Invalid profile data', 'mainwp-child' ) ); } @@ -698,7 +696,7 @@ class MainWP_Child_Back_Up_Buddy { function delete_profile() { $profile_id = $_POST['profile_id']; - if (isset(pb_backupbuddy::$options['profiles'][ $profile_id ])) { + if ( isset(pb_backupbuddy::$options['profiles'][ $profile_id ]) ) { unset(pb_backupbuddy::$options['profiles'][ $profile_id ]); } @@ -755,7 +753,7 @@ class MainWP_Child_Back_Up_Buddy { if ( isset( $data['syncBackupBuddy'] ) && $data['syncBackupBuddy'] ) { try { $information['syncBackupBuddy'] = $this->get_sync_data(); - } catch (Exception $e) { + } catch ( Exception $e ) { } } @@ -771,7 +769,7 @@ class MainWP_Child_Back_Up_Buddy { MainWP_Helper::check_methods('pb_backupbuddy', array( 'plugin_path' ) ); $plugin_path = pb_backupbuddy::plugin_path(); - if (file_exists($plugin_path . '/classes/core.php')) { + if ( file_exists($plugin_path . '/classes/core.php') ) { require_once $plugin_path . '/classes/core.php'; } } @@ -801,7 +799,7 @@ class MainWP_Child_Back_Up_Buddy { } return $data; - } catch (Exception $e) { + } catch ( Exception $e ) { // not exit here } @@ -872,7 +870,7 @@ class MainWP_Child_Back_Up_Buddy { function get_hash() { $callback_data = $_POST['callback_data']; $file = backupbuddy_core::getBackupDirectory() . $callback_data; - if (file_exists($file)) { + if ( file_exists($file) ) { return array( 'result' => 'SUCCESS', 'hash' => md5_file( $file ), @@ -992,7 +990,6 @@ class MainWP_Child_Back_Up_Buddy { continue; } - } else { // This is just like file within the root @@ -1000,7 +997,6 @@ class MainWP_Child_Back_Up_Buddy { $files[ $key ][0] = $unrooted_file; } - } return array( @@ -1342,7 +1338,6 @@ class MainWP_Child_Back_Up_Buddy { if ( file_exists( $sumLogFile ) ) { $integrity .= '
' . __( 'View Log', 'mainwp-child' ) . '
'; } - } // end if is_array( $backup_options ). // No integrity check for themes or plugins types. @@ -1361,7 +1356,6 @@ class MainWP_Child_Back_Up_Buddy { $backup_sort_dates[ basename( $file) ] = $modified_time; } // End foreach(). - } // End if. // Sort backup by date. @@ -1376,7 +1370,7 @@ class MainWP_Child_Back_Up_Buddy { return $sorted_backups; } // End backups_list(). - function get_recent_backup_list () { + function get_recent_backup_list() { $recentBackups_list = glob( backupbuddy_core::getLogDirectory() . 'fileoptions/*.txt' ); if ( ! is_array( $recentBackups_list ) ) { $recentBackups_list = array(); @@ -1484,15 +1478,15 @@ class MainWP_Child_Back_Up_Buddy { __('Status', 'mainwp-child' ) . ' (hover for options)', ); - function pb_backupbuddy_aasort ( &$array, $key) { + function pb_backupbuddy_aasort( &$array, $key ) { $sorter = array(); $ret = array(); reset($array); - foreach ($array as $ii => $va) { + foreach ( $array as $ii => $va ) { $sorter[ $ii ] = $va[ $key ]; } asort($sorter); - foreach ($sorter as $ii => $va) { + foreach ( $sorter as $ii => $va ) { $ret[ $ii ] = $array[ $ii ]; } $array = $ret; @@ -1509,10 +1503,10 @@ class MainWP_Child_Back_Up_Buddy { $schedule_ids = $_POST['schedule_ids']; $schedule_ids = explode(',', $schedule_ids); - if (empty($schedule_ids)) { + if ( empty($schedule_ids) ) { return array( 'error' => __( 'Empty schedule ids', 'mainwp-child' ) ); } - foreach ($schedule_ids as $sch_id) { + foreach ( $schedule_ids as $sch_id ) { if ( isset( pb_backupbuddy::$options['schedules'][ $sch_id ] ) ) { unset( pb_backupbuddy::$options['schedules'][ $sch_id ] ); } @@ -1862,7 +1856,6 @@ class MainWP_Child_Back_Up_Buddy { if ( $htaccess_creation_status === false ) { die( 'Error #344894545. Security Warning! Unable to create security file (.htaccess) in backups archive directory. This file prevents unauthorized downloading of backups should someone be able to guess the backup location and filenames. This is unlikely but for best security should be in place. Please verify permissions on the backups directory.' ); } - } else { header( 'Location: ' . $download_url ); } @@ -1872,7 +1865,7 @@ class MainWP_Child_Back_Up_Buddy { function create_backup() { $requested_profile = $_POST['profile_id']; - if ( ! isset(pb_backupbuddy::$options['profiles'][ $requested_profile ])) { + if ( ! isset(pb_backupbuddy::$options['profiles'][ $requested_profile ]) ) { return array( 'error' => 'Invalid Profile. Not found.' ); } @@ -1902,7 +1895,7 @@ class MainWP_Child_Back_Up_Buddy { require_once pb_backupbuddy::plugin_path() . '/classes/backup.php'; $newBackup = new pb_backupbuddy_backup(); $data = $_POST['data']; - if (is_array($data) && isset($data['serial_override'])) { + if ( is_array($data) && isset($data['serial_override']) ) { if ( $newBackup->start_backup_process( $data['profile_array'], $data['trigger'], @@ -1926,7 +1919,7 @@ class MainWP_Child_Back_Up_Buddy { function backup_status() { $data = $_POST['data']; $result = ''; - if (is_array($data) && isset($data['serial'])) { + if ( is_array($data) && isset($data['serial']) ) { ob_start(); backupbuddy_api::getBackupStatus( $data['serial'], $data['specialAction'], $data['initwaitretrycount'], $data['sqlFile'], $echo = true ); $result = ob_get_clean(); @@ -1949,18 +1942,18 @@ class MainWP_Child_Back_Up_Buddy { $data = isset($_POST['data']) ? $_POST['data'] : false; $destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : 0; - if (is_array($data) && isset($data['do_not_override'])) { + if ( is_array($data) && isset($data['do_not_override']) ) { - if (true == $data['do_not_override']) { - if (( $data['type'] == 's32' || $data['type'] == 's33' )) { + if ( true == $data['do_not_override'] ) { + if ( ( $data['type'] == 's32' || $data['type'] == 's33' ) ) { $not_override = array( 'accesskey', 'secretkey', 'bucket', 'region', ); - foreach ($not_override as $opt) { - if (isset($data[ $opt ])) { + foreach ( $not_override as $opt ) { + if ( isset($data[ $opt ]) ) { unset($data[ $opt ]); } } @@ -1970,8 +1963,8 @@ class MainWP_Child_Back_Up_Buddy { unset($data['do_not_override']); } - if (is_array($data)) { - if (isset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ])) { // update + if ( is_array($data) ) { + if ( isset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ]) ) { // update pb_backupbuddy::$options['remote_destinations'][ $destination_id ] = array_merge( pb_backupbuddy::$options['remote_destinations'][ $destination_id ], $data ); } else { // add new $data['token'] = pb_backupbuddy::$options['dropboxtemptoken']; @@ -1986,7 +1979,7 @@ class MainWP_Child_Back_Up_Buddy { function remote_list() { $information = array(); - if (isset(pb_backupbuddy::$options['remote_destinations'])) { // update + if ( isset(pb_backupbuddy::$options['remote_destinations']) ) { // update $information['remote_destinations'] = pb_backupbuddy::$options['remote_destinations']; } $information['result'] = 'SUCCESS'; @@ -1995,7 +1988,7 @@ class MainWP_Child_Back_Up_Buddy { function remote_delete() { $destination_id = isset($_POST['destination_id']) ? $_POST['destination_id'] : null; - if ($destination_id !== null) { + if ( $destination_id !== null ) { require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $delete_response = pb_backupbuddy_destinations::delete_destination( $destination_id, true ); @@ -2080,7 +2073,6 @@ class MainWP_Child_Back_Up_Buddy { $success_output = true; } } - } // end if Stash. pb_backupbuddy::status( 'details', 'Scheduling cron to send to this remote destination...' ); @@ -2124,7 +2116,7 @@ class MainWP_Child_Back_Up_Buddy { require_once pb_backupbuddy::plugin_path() . '/classes/housekeeping.php'; backupbuddy_housekeeping::run_periodic( 0 ); // 0 cleans up everything even if not very old. - } elseif ( 'delete_tempfiles_now' == $other_action) { + } elseif ( 'delete_tempfiles_now' == $other_action ) { $tempDir = backupbuddy_core::getTempDirectory(); $logDir = backupbuddy_core::getLogDirectory(); $message = 'Deleting all files contained within `' . $tempDir . '` and `' . $logDir . '`.'; @@ -2141,12 +2133,12 @@ class MainWP_Child_Back_Up_Buddy { } else { // Unlinked. $message = 'Cleared log file.'; } - } elseif ( 'reset_disalerts' == $other_action) { + } elseif ( 'reset_disalerts' == $other_action ) { pb_backupbuddy::$options['disalerts'] = array(); pb_backupbuddy::save(); $message = 'Dismissed alerts have been reset. They may now be visible again.'; - } elseif ( 'cancel_running_backups' == $other_action) { + } elseif ( 'cancel_running_backups' == $other_action ) { require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; $fileoptions_directory = backupbuddy_core::getLogDirectory() . 'fileoptions/'; @@ -2155,7 +2147,7 @@ class MainWP_Child_Back_Up_Buddy { $files = array(); } $cancelCount = 0; - for ($x = 0; $x <= 3; $x++) { // Try this a few times since there may be race conditions on an open file. + for ( $x = 0; $x <= 3; $x++ ) { // Try this a few times since there may be race conditions on an open file. foreach ( $files as $file ) { pb_backupbuddy::status( 'details', 'Fileoptions instance #383.' ); @@ -2260,7 +2252,6 @@ class MainWP_Child_Back_Up_Buddy { $scan = $scan['body']; set_transient( 'pb_backupbuddy_malwarescan', $scan, 60 * 60 * 1 ); // 1 hour cache. } - } $continue_2 = true; @@ -2276,7 +2267,6 @@ class MainWP_Child_Back_Up_Buddy { // print_r( $scan ); // echo ''; } - } pb_backupbuddy::$ui->end_metabox(); @@ -2609,9 +2599,7 @@ class MainWP_Child_Back_Up_Buddy { update_option( '_transient_doing_cron', 0 ); // Prevent cron-blocking for next item. spawn_cron( time() + 150 ); // Adds > 60 seconds to get around once per minute cron running limit. } - } - } // end if user and pass set. if ( 0 == count( $errors ) ) { @@ -2648,7 +2636,7 @@ class MainWP_Child_Back_Up_Buddy { $destination_settings['itxapi_token'] = $itxapi_token; pb_backupbuddy::$options['remote_destinations'][ $new_destination_id ] = $destination_settings; - if ($check_current && $destination_id != $new_destination_id) { + if ( $check_current && $destination_id != $new_destination_id ) { unset(pb_backupbuddy::$options['remote_destinations'][ $destination_id ]); } @@ -2669,8 +2657,8 @@ class MainWP_Child_Back_Up_Buddy { $liveDestinationID = $_POST['destination_id']; $return = array(); - if ($liveDestinationID) { - if (isset(pb_backupbuddy::$options['remote_destinations'][ $liveDestinationID ])) { + if ( $liveDestinationID ) { + if ( isset(pb_backupbuddy::$options['remote_destinations'][ $liveDestinationID ]) ) { // Clear destination settings. unset( pb_backupbuddy::$options['remote_destinations'][ $liveDestinationID ] ); pb_backupbuddy::save(); @@ -2685,7 +2673,7 @@ class MainWP_Child_Back_Up_Buddy { $error = 'Error: Empty destination id.'; } - if ( ! empty($error)) { + if ( ! empty($error) ) { $return['error'] = $error; } @@ -2710,14 +2698,12 @@ class MainWP_Child_Back_Up_Buddy { } else { $message = 'Log file cleared.'; } - } elseif ( 'create_snapshot' == $action ) { // < 100% backed up _OR_ ( we are on a step other than daily_init and the last_activity is more recent than the php runtime ) if ( true === backupbuddy_api::runLiveSnapshot() ) { // pb_backupbuddy::alert( '

' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '

' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '

', false, '', 'backupbuddy_live_snapshot_verify_uptodate' ); $message = '

' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '

' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '

'; require pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php'; } - } elseif ( 'pause_periodic' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = true ); $destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var. @@ -2831,7 +2817,6 @@ class MainWP_Child_Back_Up_Buddy { backupbuddy_core::pretty_backup_type( $backup_type ), ); } - } krsort( $backup_list_temp ); @@ -2952,10 +2937,8 @@ class MainWP_Child_Back_Up_Buddy { spawn_cron( time() + 150 ); // Adds > 60 seconds to get around once per minute cron running limit. } } - } } - } return array( 'result' => json_encode( $stats ) ); @@ -2963,7 +2946,7 @@ class MainWP_Child_Back_Up_Buddy { function save_license_settings() { $settings = $_POST['settings']; - if (is_array($settings) && isset($GLOBALS['ithemes-updater-settings'])) { + if ( is_array($settings) && isset($GLOBALS['ithemes-updater-settings']) ) { $GLOBALS['ithemes-updater-settings']->update_options( $settings ); return array( 'ok' => 1 ); } @@ -2973,7 +2956,7 @@ class MainWP_Child_Back_Up_Buddy { function load_products_license() { $packages = array(); $packages_name = array(); - if (isset($GLOBALS['ithemes_updater_path'])) { + if ( isset($GLOBALS['ithemes_updater_path']) ) { require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; @@ -2983,12 +2966,11 @@ class MainWP_Child_Back_Up_Buddy { $details = Ithemes_Updater_Packages::get_full_details(); $packages = isset($details['packages']) ? $details['packages'] : array(); - if (is_array($packages)) { + if ( is_array($packages) ) { foreach ( $packages as $path => $data ) { $packages_name[ $path ] = Ithemes_Updater_Functions::get_package_name( $data['package'] ); } } - } return array( 'ok' => 1, @@ -3004,7 +2986,7 @@ class MainWP_Child_Back_Up_Buddy { $packages = $_POST['packages']; $return = array( 'ok' => 1 ); - if (isset($GLOBALS['ithemes_updater_path'])) { + if ( isset($GLOBALS['ithemes_updater_path']) ) { require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; @@ -3066,7 +3048,6 @@ class MainWP_Child_Back_Up_Buddy { } $return['soft_errors'] = $soft_errors; } - } return $return; } @@ -3079,7 +3060,7 @@ class MainWP_Child_Back_Up_Buddy { $return = array( 'ok' => 1 ); - if (isset($GLOBALS['ithemes_updater_path'])) { + if ( isset($GLOBALS['ithemes_updater_path']) ) { require_once $GLOBALS['ithemes_updater_path'] . '/functions.php'; require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; @@ -3134,7 +3115,6 @@ class MainWP_Child_Back_Up_Buddy { $return['errors'] = $errors; } - } return $return; } diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index 3dd3133..5612759 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -43,7 +43,7 @@ class MainWP_Child_Back_Up_Wordpress { return; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -67,7 +67,7 @@ class MainWP_Child_Back_Up_Wordpress { return $value; } - if ( ! MainWP_Helper::is_screen_with_update()) { + if ( ! MainWP_Helper::is_screen_with_update() ) { return $value; } if ( isset( $value->response['backupwordpress/backupwordpress.php'] ) ) { @@ -155,7 +155,7 @@ class MainWP_Child_Back_Up_Wordpress { if ( isset( $data['syncBackUpWordPress'] ) && $data['syncBackUpWordPress'] ) { try { $information['syncBackUpWordPress'] = $this->get_sync_data(); - } catch (Exception $e) { + } catch ( Exception $e ) { } } @@ -171,7 +171,7 @@ class MainWP_Child_Back_Up_Wordpress { $schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules(); $backups_time = array(); - if (is_array($schedules) && count($schedules)) { + if ( is_array($schedules) && count($schedules) ) { $check = current($schedules); MainWP_Helper::check_methods($check, array( 'get_backups' ) ); @@ -194,7 +194,7 @@ class MainWP_Child_Back_Up_Wordpress { } function do_site_stats() { - if (has_action('mainwp_child_reports_log')) { + if ( has_action('mainwp_child_reports_log') ) { do_action( 'mainwp_child_reports_log', 'backupwordpress'); } else { $this->do_reports_log('backupwordpress'); @@ -202,11 +202,11 @@ class MainWP_Child_Back_Up_Wordpress { } // ok - public function do_reports_log( $ext = '') { + public function do_reports_log( $ext = '' ) { if ( $ext !== 'backupwordpress' ) { return; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -217,11 +217,11 @@ class MainWP_Child_Back_Up_Wordpress { // Refresh the schedules from the database to make sure we have the latest changes HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules(); $schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules(); - if (is_array($schedules) && count($schedules) > 0) { + if ( is_array($schedules) && count($schedules) > 0 ) { $check = current($schedules); MainWP_Helper::check_methods($check, array( 'get_backups', 'get_type' )); - foreach ($schedules as $schedule) { + foreach ( $schedules as $schedule ) { foreach ( $schedule->get_backups() as $file ) { $backup_type = $schedule->get_type(); $message = 'BackupWordpres backup ' . $backup_type . ' finished'; @@ -236,7 +236,7 @@ class MainWP_Child_Back_Up_Wordpress { } } } - } catch (Exception $e) { + } catch ( Exception $e ) { } } @@ -268,7 +268,7 @@ class MainWP_Child_Back_Up_Wordpress { $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) ); // Delete the running backup - if (method_exists($schedule, 'get_running_backup_filename' )) { + if ( method_exists($schedule, 'get_running_backup_filename' ) ) { if ( $schedule->get_running_backup_filename() && file_exists( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ) ) { unlink( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ); } @@ -284,12 +284,11 @@ class MainWP_Child_Back_Up_Wordpress { if ( file_exists( $status->get_status_filepath() ) ) { unlink( $status->get_status_filepath() ); } - } HM\BackUpWordPress\Path::get_instance()->cleanup(); - if ($status === null) { + if ( $status === null ) { $information['scheduleStatus'] = $schedule->get_status(); } else { $information['scheduleStatus'] = $status->get_status(); @@ -304,7 +303,7 @@ class MainWP_Child_Back_Up_Wordpress { $schedule_id = $this->check_schedule(); $schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) ); - if (method_exists($schedule, 'get_running_backup_filename' )) { + if ( method_exists($schedule, 'get_running_backup_filename' ) ) { $information['scheduleStatus'] = $schedule->get_status(); } else { $status = $schedule->get_status(); @@ -318,9 +317,9 @@ class MainWP_Child_Back_Up_Wordpress { function run_schedule() { $schedule_id = $this->check_schedule(); - if (function_exists('hmbkp_run_schedule_async')) { + if ( function_exists('hmbkp_run_schedule_async') ) { hmbkp_run_schedule_async($schedule_id); - } elseif (function_exists('\HM\BackUpWordPress\run_schedule_async')) { + } elseif ( function_exists('\HM\BackUpWordPress\run_schedule_async') ) { HM\BackUpWordPress\Path::get_instance()->cleanup(); // Fixes an issue on servers which only allow a single session per client session_write_close(); @@ -361,7 +360,7 @@ class MainWP_Child_Back_Up_Wordpress { 'started_ago' => human_time_diff( $started_ago ), ); - if (method_exists($schedule, 'get_running_backup_filename' )) { + if ( method_exists($schedule, 'get_running_backup_filename' ) ) { $out['scheduleStatus'] = $schedule->get_status(); } else { $status = $schedule->get_status(); @@ -389,7 +388,7 @@ class MainWP_Child_Back_Up_Wordpress { 'scheduleStatus' => $schedule->get_status(), 'started_ago' => human_time_diff( $started_ago ), ); - if (method_exists($schedule, 'get_running_backup_filename' )) { + if ( method_exists($schedule, 'get_running_backup_filename' ) ) { $send_back_schedules['scheduleStatus'] = $schedule->get_status(); } else { $status = $schedule->get_status(); @@ -399,7 +398,7 @@ class MainWP_Child_Back_Up_Wordpress { } } - if (function_exists('HM\BackUpWordPress\Backup::get_home_path')) { + if ( function_exists('HM\BackUpWordPress\Backup::get_home_path') ) { $backups_path = str_replace( HM\BackUpWordPress\Backup::get_home_path(), '', hmbkp_path() ); } else { $backups_path = str_replace( HM\BackUpWordPress\Path::get_home_path(), '', HM\BackUpWordPress\Path::get_path() ); @@ -433,7 +432,7 @@ class MainWP_Child_Back_Up_Wordpress { 'count' => count( $schedule->get_backups() ), 'file_size_text' => $this->hmbkp_get_site_size_text( $schedule ), ); - if (method_exists($schedule, 'get_running_backup_filename' )) { + if ( method_exists($schedule, 'get_running_backup_filename' ) ) { $ret['scheduleStatus'] = $schedule->get_status(); } else { $status = $schedule->get_status(); @@ -497,7 +496,7 @@ class MainWP_Child_Back_Up_Wordpress { function hmbkp_get_site_size_text( HM\BackUpWordPress\Scheduled_Backup $schedule ) { - if (method_exists($schedule, 'is_site_size_cached')) { + if ( method_exists($schedule, 'is_site_size_cached') ) { if ( ( 'database' === $schedule->get_type() ) || $schedule->is_site_size_cached() ) { return sprintf( '(%s)', esc_attr( $schedule->get_formatted_site_size() ) ); } @@ -533,7 +532,7 @@ class MainWP_Child_Back_Up_Wordpress { | get_excludes(), $schedule->backup->default_excludes() ); $root_dir = $schedule->backup->get_root(); @@ -626,7 +625,7 @@ class MainWP_Child_Back_Up_Wordpress { get_default_excludes() ) ) || ( HM\BackUpWordPress\Path::get_path() === trailingslashit( HM\BackUpWordPress\Path::get_root() ) . untrailingslashit( $exclude ) ); } else { $is_default_rule = ( in_array( $exclude, $schedule->backup->default_excludes() ) ) || ( hmbkp_path() === untrailingslashit( $exclude ) ); @@ -679,16 +678,15 @@ class MainWP_Child_Back_Up_Wordpress { } // Kick off a recursive filesize scan - if ($new_version) { + if ( $new_version ) { $site_size = new HM\BackUpWordPress\Site_Size(); $exclude_string = implode( '|', $excludes->get_excludes_for_regex() ); - if (function_exists('HM\BackUpWordPress\list_directory_by_total_filesize')) { + if ( function_exists('HM\BackUpWordPress\list_directory_by_total_filesize') ) { $files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes ); } - } else { $files = $schedule->list_directory_by_total_filesize( $directory ); $exclude_string = $schedule->backup->exclude_string( 'regex' ); @@ -758,7 +756,7 @@ class MainWP_Child_Back_Up_Wordpress { $root = new SplFileInfo( $root_dir ); - if ($new_version) { + if ( $new_version ) { $size = $site_size->filesize( $root ); } else { $size = $schedule->filesize( $root, true ); @@ -817,7 +815,7 @@ class MainWP_Child_Back_Up_Wordpress { $is_excluded = $is_unreadable = false; // Check if the file is excluded - if ($new_version) { + if ( $new_version ) { if ( $exclude_string && preg_match( '(' . $exclude_string . ')', str_ireplace( trailingslashit( $root_dir ), '', wp_normalize_path( $file->getPathname() ) ) ) ) { $is_excluded = true; } @@ -855,7 +853,7 @@ class MainWP_Child_Back_Up_Wordpress { @@ -910,7 +908,7 @@ class MainWP_Child_Back_Up_Wordpress { filesize( $file ); } else { $size = $schedule->filesize( $file ); @@ -1079,7 +1077,7 @@ class MainWP_Child_Back_Up_Wordpress { $excludes = $schedule->get_excludes(); $exclude_rule_to_remove = stripslashes( sanitize_text_field( $_POST['remove_rule'] ) ); - if (method_exists($excludes, 'get_user_excludes')) { + if ( method_exists($excludes, 'get_user_excludes') ) { $schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) ); } else { $schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) ); @@ -1109,19 +1107,19 @@ class MainWP_Child_Back_Up_Wordpress { $exclude_paths = urldecode( $_POST['exclude_paths'] ); $exclude_paths = explode("\n", $exclude_paths); - if (is_array($exclude_paths) && count($exclude_paths) > 0) { + if ( is_array($exclude_paths) && count($exclude_paths) > 0 ) { foreach ( $exclude_paths as $excl_rule ) { $excl_rule = trim($excl_rule); $excl_rule = trim($excl_rule, '/'); - if (empty($excl_rule)) { + if ( empty($excl_rule) ) { continue; } $exclude_rule = ABSPATH . $excl_rule; $path = realpath($exclude_rule); // If it exist - if ($path !== false) { + if ( $path !== false ) { $schedule->set_excludes( $exclude_rule, true ); $schedule->save(); } @@ -1131,17 +1129,17 @@ class MainWP_Child_Back_Up_Wordpress { $un_exclude_paths = urldecode( $_POST['un_exclude_paths'] ); $un_exclude_paths = explode("\n", $un_exclude_paths); - if (is_array($un_exclude_paths) && count(get_user_excludes) > 0) { + if ( is_array($un_exclude_paths) && count(get_user_excludes) > 0 ) { foreach ( $un_exclude_paths as $exclude_rule_to_remove ) { $exclude_rule_to_remove = trim($exclude_rule_to_remove); $exclude_rule_to_remove = trim($exclude_rule_to_remove, '/'); - if (empty($exclude_rule_to_remove)) { + if ( empty($exclude_rule_to_remove) ) { continue; } $excludes = $schedule->get_excludes(); - if (method_exists($excludes, 'get_user_excludes')) { + if ( method_exists($excludes, 'get_user_excludes') ) { $schedule->set_excludes( array_diff( $excludes->get_user_excludes(), (array) $exclude_rule_to_remove ) ); } else { $schedule->set_excludes( array_diff( $excludes, $exclude_rule_to_remove ) ); @@ -1221,7 +1219,7 @@ class MainWP_Child_Back_Up_Wordpress { } $out = array(); - foreach ($schedules as $sch_id => $sch) { + foreach ( $schedules as $sch_id => $sch ) { if ( empty($sch_id) || ! isset( $sch['options'] ) || ! is_array( $sch['options'] ) ) { continue; } diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index ff0e126..2b738b7 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -91,7 +91,7 @@ class MainWP_Child_Back_WP_Up { $this->is_backwpup_installed = true; } - if ($this->is_backwpup_installed) { + if ( $this->is_backwpup_installed ) { MainWP_Helper::check_classes_exists('BackWPup'); MainWP_Helper::check_methods('get_instance'); BackWPup::get_instance(); @@ -100,7 +100,7 @@ class MainWP_Child_Back_WP_Up { add_action( 'admin_init', array( $this, 'init_download_backup' ) ); add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } - } catch ( Exception $e) { + } catch ( Exception $e ) { // do not exit() $this->is_backwpup_installed = false; } @@ -218,7 +218,7 @@ class MainWP_Child_Back_WP_Up { public function init() { - if ( ! $this->is_backwpup_installed) { + if ( ! $this->is_backwpup_installed ) { return; } @@ -231,18 +231,18 @@ class MainWP_Child_Back_WP_Up { } function do_site_stats() { - if (has_action('mainwp_child_reports_log')) { + if ( has_action('mainwp_child_reports_log') ) { do_action( 'mainwp_child_reports_log', 'backwpup'); } else { $this->do_reports_log('backwpup'); } } // ok - public function do_reports_log( $ext = '') { + public function do_reports_log( $ext = '' ) { if ( $ext !== 'backwpup' ) { return; } - if ( ! $this->is_backwpup_installed) { + if ( ! $this->is_backwpup_installed ) { return; } @@ -273,11 +273,11 @@ class MainWP_Child_Back_WP_Up { $log_items = array(); foreach ( $logfiles as $mtime => $logfile ) { $meta = BackWPup_Job::read_logheader( $log_folder . '/' . $logfile ); - if ( ! isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged) { + if ( ! isset($meta['logtime']) || $meta['logtime'] < $lasttime_logged ) { continue; } - if (isset($meta['errors']) && ! empty($meta['errors'])) { + if ( isset($meta['errors']) && ! empty($meta['errors']) ) { continue; // do not logging backups have errors } @@ -296,21 +296,21 @@ class MainWP_Child_Back_WP_Up { $new_lasttime_logged = $lasttime_logged; - foreach ($log_items as $log) { + foreach ( $log_items as $log ) { $backup_time = $log['logtime']; - if ($backup_time < $lasttime_logged) { + if ( $backup_time < $lasttime_logged ) { // small than last backup time then skip continue; } $job_job_types = explode('+', $log['type']); $backup_type = ''; - foreach ($job_job_types as $typeid) { - if (isset( $job_types[ $typeid ] )) { + foreach ( $job_job_types as $typeid ) { + if ( isset( $job_types[ $typeid ] ) ) { $backup_type .= ' + ' . $job_types[ $typeid ]; } } - if (empty($backup_type)) { + if ( empty($backup_type) ) { continue; } else { $backup_type = ltrim($backup_type, ' + '); @@ -318,16 +318,16 @@ class MainWP_Child_Back_WP_Up { $message = 'BackWPup backup finished (' . $backup_type . ')'; do_action( 'mainwp_reports_backwpup_backup', $message, $backup_type, $backup_time ); - if ($new_lasttime_logged < $backup_time) { + if ( $new_lasttime_logged < $backup_time ) { $new_lasttime_logged = $backup_time; } } - if ($new_lasttime_logged > $lasttime_logged ) { + if ( $new_lasttime_logged > $lasttime_logged ) { MainWP_Helper::update_lasttime_backup( 'backwpup', $new_lasttime_logged ); // to support backup before update feature } } - } catch (Exception $ex) { + } catch ( Exception $ex ) { } } @@ -340,7 +340,7 @@ class MainWP_Child_Back_WP_Up { $information['syncBackwpupData'] = array( 'lastbackup' => $lastbackup, ); - } catch (Exception $e) { + } catch ( Exception $e ) { } } @@ -366,7 +366,7 @@ class MainWP_Child_Back_WP_Up { } $dest_class = BackWPup::get_destination( $dest ); - if ($dest_class && method_exists($dest_class, 'file_get_list')) { + if ( $dest_class && method_exists($dest_class, 'file_get_list') ) { $can_do_dest = $dest_class->file_get_list( $jobid . '_' . $dest ); if ( ! empty( $can_do_dest ) ) { $jobdest[] = $jobid . '_' . $dest; @@ -778,7 +778,7 @@ class MainWP_Child_Back_WP_Up { ), $temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session( 'mainwp_download_backup' ) ); $temp_array['downloadurl_id'] = '/wp-admin/admin.php?page=backwpupbackups'; - if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches )) { + if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches ) ) { if ( ! empty( $matches[1] ) && is_numeric( $matches[1] ) ) { $temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1]; } @@ -808,7 +808,7 @@ class MainWP_Child_Back_WP_Up { } public function init_download_backup() { - if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'backwpupbackups' || ! isset( $_GET['download_click_id'] ) || empty( $_GET['download_click_id'] )) { + if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'backwpupbackups' || ! isset( $_GET['download_click_id'] ) || empty( $_GET['download_click_id'] ) ) { return; } ?> @@ -1255,7 +1255,7 @@ class MainWP_Child_Back_WP_Up { $return['tables'] = $tables_temp; } - if (isset($settings['job_id'])) { + if ( isset($settings['job_id']) ) { $return['dbdumpexclude'] = BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' ); } return array( @@ -1438,9 +1438,9 @@ class MainWP_Child_Back_WP_Up { update_site_option( 'backwpup_messages', array() ); - if (isset($settings['value']['backupdir']) && empty($settings['value']['backupdir'])) { + if ( isset($settings['value']['backupdir']) && empty($settings['value']['backupdir']) ) { $backupdir = BackWPup_Option::get( (int) $job_id, 'backupdir' ); - if ( ! empty($backupdir)) { + if ( ! empty($backupdir) ) { $settings['value']['backupdir'] = $backupdir; } } @@ -1449,7 +1449,7 @@ class MainWP_Child_Back_WP_Up { $_POST[ $key ] = $val; } - if ($settings['tab'] == 'jobtype-FILE') { + if ( $settings['tab'] == 'jobtype-FILE' ) { // to fix $this->edit_form_post_save($settings['value'], $job_id); // saved message @@ -1458,7 +1458,7 @@ class MainWP_Child_Back_WP_Up { $url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id ); BackWPup_Admin::message( sprintf( __( 'Changes for job %s saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' ' . __( 'Jobs overview', 'backwpup' ) . ' | ' . __( 'Run now', 'backwpup' ) . '' ); } - } elseif ($settings['tab'] == 'dest-DROPBOX') { + } elseif ( $settings['tab'] == 'dest-DROPBOX' ) { unset($settings['value']); // do not save dropbox settings BackWPup_Page_Editjob::save_post_form( $settings['tab'], $job_id ); } else { diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index db15879..64d1b95 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -50,7 +50,7 @@ class MainWP_Child_Branding { $opts['branding_preserve_title'] = ''; if ( ! $cancelled_branding ) { - if (isset($opts['branding_header'])) { + if ( isset($opts['branding_header']) ) { $branding_header = $opts['branding_header']; if ( is_array( $branding_header ) && isset( $branding_header['name'] ) && ! empty( $branding_header['name'] ) ) { $opts['branding_preserve_title'] = stripslashes( $branding_header['name'] ); @@ -64,9 +64,9 @@ class MainWP_Child_Branding { function get_extra_options() { $extra = array(); - if (is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings'])) { + if ( is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings']) ) { $extra = $this->child_branding_options['extra_settings']; - if ( ! is_array($extra)) { + if ( ! is_array($extra) ) { $extra = array(); } } @@ -145,8 +145,8 @@ class MainWP_Child_Branding { 'branding_ext_enabled', ); - foreach ($brandingOptions_empty as $opt) { - if (isset($this->child_branding_options[ $opt ])) { + foreach ( $brandingOptions_empty as $opt ) { + if ( isset($this->child_branding_options[ $opt ]) ) { $this->child_branding_options[ $opt ] = ''; } } @@ -389,10 +389,10 @@ class MainWP_Child_Branding { $extra_setting = $this->get_extra_options(); // to hide updates notice - if (is_admin()) { + if ( is_admin() ) { // back end add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) ); - } elseif (is_user_logged_in()) { + } elseif ( is_user_logged_in() ) { // front end add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' )); } @@ -417,7 +417,7 @@ class MainWP_Child_Branding { add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 ); - if ( 'T' === $opts['disable_change']) { + if ( 'T' === $opts['disable_change'] ) { // Disable the WordPress plugin update notifications remove_action('load-update-core.php', 'wp_update_plugins'); @@ -425,14 +425,14 @@ class MainWP_Child_Branding { // Disable the WordPress theme update notifications remove_action('load-update-core.php', 'wp_update_themes'); - add_filter('pre_site_transient_update_themes', ( $func = function( $a) { + add_filter('pre_site_transient_update_themes', ( $func = function( $a ) { return null; } )); // Disable the WordPress core update notifications add_action('after_setup_theme', 'remove_core_updates'); function remove_core_updates() { - add_action('init', ( $func = function( $a) { + add_action('init', ( $func = function( $a ) { remove_action( 'wp_version_check', 'wp_version_check' ); } ), 2); add_filter('pre_option_update_core', '__return_null'); @@ -814,7 +814,7 @@ class MainWP_Child_Branding { if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) { global $current_user; $headers .= "Content-Type: text/html;charset=utf-8\r\n"; - if ( ! empty($from)) { + if ( ! empty($from) ) { $headers .= 'From: "' . $from . '" <' . $from . ">\r\n"; } $mail .= "

Support Email from: " . site_url() . "

\r\n\r\n"; @@ -963,7 +963,7 @@ class MainWP_Child_Branding { public function is_branding() { $opts = $this->child_branding_options; - if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y') { + if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) { return false; } @@ -1005,30 +1005,30 @@ class MainWP_Child_Branding { $hide_slugs = apply_filters('mainwp_child_hide_update_notice', array()); - if ( ! is_array($hide_slugs)) { + if ( ! is_array($hide_slugs) ) { $hide_slugs = array(); } - if (count($hide_slugs) == 0) { + if ( count($hide_slugs) == 0 ) { return; } - if ( ! function_exists('get_plugin_updates')) { + if ( ! function_exists('get_plugin_updates') ) { include_once ABSPATH . '/wp-admin/includes/update.php'; } $count_hide = 0; $updates = get_plugin_updates(); - if (is_array($updates)) { - foreach ($updates as $slug => $data) { - if (in_array($slug, $hide_slugs)) { + if ( is_array($updates) ) { + foreach ( $updates as $slug => $data ) { + if ( in_array($slug, $hide_slugs) ) { $count_hide++; } } } - if ( $count_hide == 0) { + if ( $count_hide == 0 ) { return; } // js for front end @@ -1058,22 +1058,22 @@ class MainWP_Child_Branding { $hide_slugs = apply_filters('mainwp_child_hide_update_notice', array()); - if ( ! is_array($hide_slugs)) { + if ( ! is_array($hide_slugs) ) { $hide_slugs = array(); } $count_hide = 0; $updates = get_plugin_updates(); - if (is_array($updates)) { - foreach ($updates as $slug => $data) { - if (in_array($slug, $hide_slugs)) { + if ( is_array($updates) ) { + foreach ( $updates as $slug => $data ) { + if ( in_array($slug, $hide_slugs) ) { $count_hide++; } } } - if ( $count_hide == 0) { + if ( $count_hide == 0 ) { return; } @@ -1086,7 +1086,7 @@ class MainWP_Child_Branding { if (typeof(pagenow) !== 'undefined' && pagenow == 'plugins') { var el = document.querySelector('tr#mainwp-child-update'); if (typeof(el) !== 'undefined' && el !== null) { @@ -1095,7 +1095,7 @@ class MainWP_Child_Branding { var el = document.querySelector('tr#mainwp-child-reports-update'); if (typeof(el) !== 'undefined' && el !== null) { @@ -1185,7 +1185,7 @@ class MainWP_Child_Branding { return $value; } - if ( ! MainWP_Helper::is_screen_with_update()) { + if ( ! MainWP_Helper::is_screen_with_update() ) { return $value; } diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index 1495785..b9ecf2e 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -33,7 +33,7 @@ class MainWP_Child_iThemes_Security { $this->is_plugin_installed = true; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -46,7 +46,7 @@ class MainWP_Child_iThemes_Security { $information['syncIThemeData'] = array( 'users_and_roles' => $this->get_available_admin_users_and_roles(), ); - } catch (Exception $e) { + } catch ( Exception $e ) { error_log($e->getMessage()); } } @@ -55,7 +55,7 @@ class MainWP_Child_iThemes_Security { public function action() { $information = array(); - if ( ! class_exists( 'ITSEC_Core' ) || ! class_exists('ITSEC_Modules')) { + if ( ! class_exists( 'ITSEC_Core' ) || ! class_exists('ITSEC_Modules') ) { $information['error'] = 'NO_ITHEME'; MainWP_Helper::write( $information ); } @@ -131,7 +131,7 @@ class MainWP_Child_iThemes_Security { } public function ithemes_init() { - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -211,14 +211,14 @@ class MainWP_Child_iThemes_Security { $update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); - foreach ($update_settings as $module => $settings) { + foreach ( $update_settings as $module => $settings ) { $do_not_save = false; - if (in_array($module, $_itsec_modules)) { - if ($module == 'wordpress-salts') { + if ( in_array($module, $_itsec_modules) ) { + if ( $module == 'wordpress-salts' ) { $settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update - } elseif ($module == 'global') { + } elseif ( $module == 'global' ) { $keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' ); - foreach ($keep_olds as $key) { + foreach ( $keep_olds as $key ) { $settings[ $key ] = ITSEC_Modules::get_setting( $module, $key ); // not update } @@ -226,18 +226,17 @@ class MainWP_Child_iThemes_Security { $settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); } else { $result = $this->validate_directory('log_location', $settings['log_location']); - if ($result !== true) { + if ( $result !== true ) { $errors[] = $result; $settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); // no change } } - - } elseif ($module == 'backup') { + } elseif ( $module == 'backup' ) { if ( ! isset($settings['location']) || empty($settings['location']) ) { $settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); } else { $result = $this->validate_directory('location', $settings['location']); - if ($result !== true) { + if ( $result !== true ) { $errors[] = $result; $settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); // no change } @@ -246,8 +245,8 @@ class MainWP_Child_iThemes_Security { $settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' ); } - } elseif ($module == 'hide-backend') { - if (isset($settings['enabled']) && ! empty($settings['enabled'])) { + } elseif ( $module == 'hide-backend' ) { + if ( isset($settings['enabled']) && ! empty($settings['enabled']) ) { $permalink_structure = get_option( 'permalink_structure', false ); if ( empty( $permalink_structure ) && ! is_multisite() ) { $errors[] = __( 'You must change WordPress permalinks to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' ); @@ -255,11 +254,11 @@ class MainWP_Child_iThemes_Security { $do_not_save = true; } } - } elseif ($module == 'network-brute-force') { + } elseif ( $module == 'network-brute-force' ) { if ( isset( $settings['email'] ) ) { $result = $this->activate_api_key($settings); - if ($result === false) { + if ( $result === false ) { $nbf_settings = $settings; $errors[] = 'Error: Active iThemes Network Brute Force Protection Api Key'; } else { @@ -268,7 +267,7 @@ class MainWP_Child_iThemes_Security { } else { $previous_settings = ITSEC_Modules::get_settings( $module ); // update 'enable_ban' field only - if (isset($settings['enable_ban'])) { + if ( isset($settings['enable_ban']) ) { $previous_settings['enable_ban'] = $settings['enable_ban']; $nbf_settings = $previous_settings; } else { @@ -277,16 +276,16 @@ class MainWP_Child_iThemes_Security { } } $settings = $nbf_settings; - } elseif ($module == 'notification-center') { + } elseif ( $module == 'notification-center' ) { $current_settings = ITSEC_Modules::get_settings( $module ); - if (isset($settings['notifications'])) { + if ( isset($settings['notifications']) ) { $update_fields = array( 'schedule', 'enabled', 'subject' ); - if (isset($_POST['is_individual']) && $_POST['is_individual']) { + if ( isset($_POST['is_individual']) && $_POST['is_individual'] ) { $update_fields = array_merge($update_fields, array( 'user_list', 'email_list' )); } - foreach ($settings['notifications'] as $key => $val) { - foreach ($update_fields as $field) { - if (isset($val[ $field ])) { + foreach ( $settings['notifications'] as $key => $val ) { + foreach ( $update_fields as $field ) { + if ( isset($val[ $field ]) ) { $current_settings['notifications'][ $key ][ $field ] = $val[ $field ]; } } @@ -306,7 +305,7 @@ class MainWP_Child_iThemes_Security { if ( isset( $update_settings['itsec_active_modules'] ) ) { $current_val = get_site_option( 'itsec_active_modules', array() ); - foreach ($update_settings['itsec_active_modules'] as $mod => $val) { + foreach ( $update_settings['itsec_active_modules'] as $mod => $val ) { $current_val[ $mod ] = $val; } update_site_option( 'itsec_active_modules', $current_val ); @@ -336,17 +335,17 @@ class MainWP_Child_iThemes_Security { 'site_status' => $values, ); - if ($require_permalinks) { + if ( $require_permalinks ) { $return['require_permalinks'] = 1; } $return['nbf_settings'] = $nbf_settings; - if ( ! empty($errors)) { + if ( ! empty($errors) ) { $return['extra_message'] = $errors; } - if ($updated) { + if ( $updated ) { $return['result'] = 'success'; } else { $return['error'] = __('Not Updated', 'mainwp-child' ); @@ -358,7 +357,7 @@ class MainWP_Child_iThemes_Security { public static function activate_network_brute_force() { $data = maybe_unserialize( base64_decode( $_POST['data'] ) ); $information = array(); - if (is_array($data)) { + if ( is_array($data) ) { $settings = ITSEC_Modules::get_settings( 'network-brute-force' ); $settings['email'] = $data['email']; $settings['updates_optin'] = $data['updates_optin']; @@ -372,14 +371,14 @@ class MainWP_Child_iThemes_Security { // ITSEC_Response::set_response( '

' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '

' ); } } - if ($nbf_settings !== null) { + if ( $nbf_settings !== null ) { $information['nbf_settings'] = $nbf_settings; $information['result'] = 'success'; } return $information; } - private function validate_directory( $name, $folder) { + private function validate_directory( $name, $folder ) { require_once ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php'; $error = null; if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) { @@ -402,7 +401,7 @@ class MainWP_Child_iThemes_Security { } } - private function activate_api_key( $settings) { + private function activate_api_key( $settings ) { global $mainwp_itsec_modules_path; require_once $mainwp_itsec_modules_path . 'ipcheck/utilities.php'; @@ -521,7 +520,7 @@ class MainWP_Child_iThemes_Security { $str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type %1$s.', 'better-wp-security' ), gettype( $result ) ); } - if ( ! empty($str_error)) { + if ( ! empty($str_error) ) { $return['error'] = $str_error; } @@ -548,7 +547,7 @@ class MainWP_Child_iThemes_Security { $last_generated = ITSEC_Core::get_current_time_gmt(); ITSEC_Modules::set_setting( 'wordpress-salts', 'last_generated', $last_generated ); } - if ( ! empty($str_error)) { + if ( ! empty($str_error) ) { $return['error'] = $str_error; } return $return; @@ -679,7 +678,7 @@ class MainWP_Child_iThemes_Security { require_once $mainwp_itsec_modules_path . 'file-change/scanner.php'; } $result = ITSEC_File_Change_Scanner::run_scan( false ); - if ($result === false || $result === true || $result === -1) { + if ( $result === false || $result === true || $result === -1 ) { $return['result'] = 'success'; $return['scan_result'] = $result; } @@ -690,7 +689,7 @@ class MainWP_Child_iThemes_Security { $settings = $_POST['settings']; - if ( ! is_array($settings)) { + if ( ! is_array($settings) ) { $settings = array(); } @@ -706,11 +705,11 @@ class MainWP_Child_iThemes_Security { $username_exists = username_exists( 'admin' ); $user_id_exists = ITSEC_Lib::user_id_exists( 1 ); $msg = ''; - if ( strlen( $new_username ) >= 1) { + if ( strlen( $new_username ) >= 1 ) { global $current_user; if ( ! $username_exists ) { $msg = __( 'Admin user already changes.', 'mainwp-child' ); - } elseif ($current_user->user_login == 'admin') { + } elseif ( $current_user->user_login == 'admin' ) { $return['result'] = 'CHILD_ADMIN'; return $return; } @@ -886,8 +885,8 @@ class MainWP_Child_iThemes_Security { if ( isset( $_POST['change_prefix'] ) && 'yes' === $_POST['change_prefix'] ) { $result = ITSEC_Database_Prefix_Utility::change_database_prefix(); $return = $result['errors']; - if (is_array($result['errors'])) { - foreach ($result['errors'] as $error) { + if ( is_array($result['errors']) ) { + foreach ( $result['errors'] as $error ) { $arr_errors = ITSEC_Response::get_error_strings( $error ); foreach ( $arr_errors as $er ) { $str_error .= $er . '
'; @@ -1111,12 +1110,12 @@ class MainWP_Child_iThemes_Security { $active_modules = $_POST['active_modules']; - if ( ! is_array($active_modules)) { + if ( ! is_array($active_modules) ) { $active_modules = array(); } $current_val = get_site_option( 'itsec_active_modules', array() ); - foreach ($active_modules as $mod => $val) { + foreach ( $active_modules as $mod => $val ) { $current_val[ $mod ] = $val; } diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php index e5c42f0..f3a03f0 100644 --- a/class/class-mainwp-child-links-checker.php +++ b/class/class-mainwp-child-links-checker.php @@ -82,7 +82,7 @@ class MainWP_Child_Links_Checker { } } MainWP_Helper::write( $information ); - } catch (Exception $e) { + } catch ( Exception $e ) { MainWP_Helper::write( array( 'error' => $e->getMessage() ) ); } } @@ -212,7 +212,7 @@ class MainWP_Child_Links_Checker { if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) { try { $information['syncBrokenLinksCheckerData'] = $this->get_sync_data(); - } catch (Exception $e) { + } catch ( Exception $e ) { } } @@ -223,7 +223,7 @@ class MainWP_Child_Links_Checker { function get_sync_data( $strategy = '' ) { $information = array(); $data = $this->get_count_links(); - if (is_array($data)) { + if ( is_array($data) ) { $information['data'] = $data; } return $information; @@ -231,7 +231,7 @@ class MainWP_Child_Links_Checker { function get_links_data() { - if ( ! defined('BLC_DIRECTORY')) { + if ( ! defined('BLC_DIRECTORY') ) { return; } @@ -259,7 +259,7 @@ class MainWP_Child_Links_Checker { 'max_results' => $max_results, ); - if (empty($offset)) { + if ( empty($offset) ) { $first_sync = true; } else { $params['offset'] = $offset; @@ -268,18 +268,18 @@ class MainWP_Child_Links_Checker { $link_data = $this->links_checker_data($params); $total_sync = 0; - if ($offset) { + if ( $offset ) { $total_sync = $offset; } $total_sync += ( is_array($link_data) ? count($link_data) : 0 ); $information = array( 'links_data' => $link_data ); - if ($first_sync) { + if ( $first_sync ) { $information['data'] = $this->get_count_links(); } - if ($total > $offset + $max_results ) { + if ( $total > $offset + $max_results ) { $information['sync_offset'] = $offset + $max_results; } else { $information['last_sync'] = 1; @@ -292,7 +292,7 @@ class MainWP_Child_Links_Checker { } function get_count_links() { - if ( ! defined('BLC_DIRECTORY')) { + if ( ! defined('BLC_DIRECTORY') ) { return; } @@ -320,7 +320,7 @@ class MainWP_Child_Links_Checker { return $data; } - function links_checker_data( $params) { + function links_checker_data( $params ) { MainWP_Helper::check_functions('blc_get_links'); MainWP_Helper::check_classes_exists('blcLink'); @@ -404,8 +404,8 @@ class MainWP_Child_Links_Checker { /** @var blcContainer $container */ if ( ! empty( $container ) /* && ($container instanceof blcAnyPostContainer) */ ) { - if (true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true )) { - if (true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true )) { + if ( true === MainWP_Helper::check_properties($first_instance, array( 'container_field' ), true ) ) { + if ( true === MainWP_Helper::check_properties($container, array( 'container_type', 'container_id' ), true ) ) { $extra_info['container_type'] = $container->container_type; $extra_info['container_id'] = $container->container_id; $extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field ); @@ -659,7 +659,7 @@ class MainWP_Child_Links_Checker { $image = 'font-awesome/font-awesome-comment-alt.png'; } - if (true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object' ), true )) { + if ( true !== MainWP_Helper::check_methods($container, array( 'get_wrapped_object' ), true ) ) { return false; } diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php index f258161..d252053 100644 --- a/class/class-mainwp-child-pagespeed.php +++ b/class/class-mainwp-child-pagespeed.php @@ -34,7 +34,7 @@ class MainWP_Child_Pagespeed { $this->is_plugin_installed = true; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -76,7 +76,7 @@ class MainWP_Child_Pagespeed { } public function init() { - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -127,9 +127,9 @@ class MainWP_Child_Pagespeed { public function hide_menu() { global $submenu; - if (isset($submenu['tools.php'])) { - foreach ($submenu['tools.php'] as $key => $menu) { - if ($menu[2] == 'google-pagespeed-insights') { + if ( isset($submenu['tools.php']) ) { + foreach ( $submenu['tools.php'] as $key => $menu ) { + if ( $menu[2] == 'google-pagespeed-insights' ) { unset($submenu['tools.php'][ $key ]); break; } @@ -257,19 +257,19 @@ class MainWP_Child_Pagespeed { function check_pages() { - if (isset($_POST['force_recheck']) && ! empty($_POST['force_recheck'])) { + if ( isset($_POST['force_recheck']) && ! empty($_POST['force_recheck']) ) { $recheck = true; } else { $recheck = false; } $information = $this->do_check_pages($recheck); - if (isset($information['checked_pages']) && $information['checked_pages']) { + if ( isset($information['checked_pages']) && $information['checked_pages'] ) { $information['result'] = 'SUCCESS'; } return $information; } - function do_check_pages( $forceRecheck = false) { + function do_check_pages( $forceRecheck = false ) { $information = array(); if ( defined( 'GPI_DIRECTORY' ) ) { $checkstatus = apply_filters( 'gpi_check_status', false ); @@ -288,7 +288,7 @@ class MainWP_Child_Pagespeed { if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) { try { $information['syncPageSpeedData'] = $this->get_sync_data(); - } catch (Exception $e) { + } catch ( Exception $e ) { } } @@ -438,37 +438,37 @@ class MainWP_Child_Pagespeed { ); } - static function get_filter_options( $restrict_type = 'all') { + static function get_filter_options( $restrict_type = 'all' ) { $types = array(); $gpi_options = get_option('gpagespeedi_options'); $typestocheck = array(); - if ($gpi_options['check_pages']) { - if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages') { + if ( $gpi_options['check_pages'] ) { + if ( $restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'pages' ) { $typestocheck[] = 'type = %s'; $types[1][] = 'page'; } } - if ($gpi_options['check_posts']) { - if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts') { + if ( $gpi_options['check_posts'] ) { + if ( $restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'posts' ) { $typestocheck[] = 'type = %s'; $types[1][] = 'post'; } } - if ($gpi_options['check_categories']) { - if ($restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories') { + if ( $gpi_options['check_categories'] ) { + if ( $restrict_type == 'all' || $restrict_type == 'ignored' || $restrict_type == 'categories' ) { $typestocheck[] = 'type = %s'; $types[1][] = 'category'; } } - if ($gpi_options['cpt_whitelist']) { - if ($restrict_type == 'all' || $restrict_type == 'ignored' || stristr($restrict_type, 'gpi_custom_posts')) { + if ( $gpi_options['cpt_whitelist'] ) { + if ( $restrict_type == 'all' || $restrict_type == 'ignored' || stristr($restrict_type, 'gpi_custom_posts') ) { $cpt_whitelist_arr = false; - if ( ! empty($gpi_options['cpt_whitelist'])) { + if ( ! empty($gpi_options['cpt_whitelist']) ) { $cpt_whitelist_arr = unserialize($gpi_options['cpt_whitelist']); } $args = array( @@ -476,19 +476,19 @@ class MainWP_Child_Pagespeed { '_builtin' => false, ); $custom_post_types = get_post_types($args, 'names', 'and'); - if ($restrict_type != 'gpi_custom_posts' && $restrict_type != 'all' && $restrict_type != 'ignored') { + if ( $restrict_type != 'gpi_custom_posts' && $restrict_type != 'all' && $restrict_type != 'ignored' ) { $restrict_type = str_replace('gpi_custom_posts-', '', $restrict_type); - foreach ($custom_post_types as $post_type) { - if ($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) { - if ($post_type == $restrict_type) { + foreach ( $custom_post_types as $post_type ) { + if ( $cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr) ) { + if ( $post_type == $restrict_type ) { $typestocheck[] = 'type = %s'; $types[1][] = $custom_post_types[ $post_type ]; } } } } else { - foreach ($custom_post_types as $post_type) { - if ($cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr)) { + foreach ( $custom_post_types as $post_type ) { + if ( $cpt_whitelist_arr && in_array($post_type, $cpt_whitelist_arr) ) { $typestocheck[] = 'type = %s'; $types[1][] = $custom_post_types[ $post_type ]; } @@ -516,13 +516,13 @@ class MainWP_Child_Pagespeed { } } - if ( ! empty($typestocheck)) { + if ( ! empty($typestocheck) ) { $types[0] = ''; - foreach ($typestocheck as $type) { - if ( ! is_array($type)) { + foreach ( $typestocheck as $type ) { + if ( ! is_array($type) ) { $types[0] .= $type . ' OR '; } else { - foreach ($type as $custom_post_type) { + foreach ( $type as $custom_post_type ) { $types[0] .= 'type = %s OR '; $types[1][] = $custom_post_type; } diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php index 94ac0c1..5b7ec61 100644 --- a/class/class-mainwp-child-server-information.php +++ b/class/class-mainwp-child-server-information.php @@ -19,7 +19,7 @@ class MainWP_Child_Server_Information { } if ( $_POST['what'] == 'warning' ) { - if (isset($_POST['warnings'])) { + if ( isset($_POST['warnings']) ) { $warnings = intval($_POST['warnings']); } else { $warnings = self::getWarnings(); @@ -31,7 +31,7 @@ class MainWP_Child_Server_Information { } public static function showWarnings() { - if ( stristr( $_SERVER['REQUEST_URI'], 'mainwp_child_tab' ) || stristr( $_SERVER['REQUEST_URI'], 'mainwp-reports-page' ) || stristr( $_SERVER['REQUEST_URI'], 'mainwp-reports-settings' )) { + if ( stristr( $_SERVER['REQUEST_URI'], 'mainwp_child_tab' ) || stristr( $_SERVER['REQUEST_URI'], 'mainwp-reports-page' ) || stristr( $_SERVER['REQUEST_URI'], 'mainwp-reports-settings' ) ) { return; } @@ -822,12 +822,12 @@ class MainWP_Child_Server_Information { $plugin) { + foreach ( $all_plugins as $slug => $plugin ) { if ( $slug == 'mainwp-child/mainwp-child.php' || $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) { if ( $isBranding ) { if ( $slug == 'mainwp-child/mainwp-child.php' ) { $plugin['Name'] = esc_html( stripslashes( $branding_title ) ); - } elseif ($slug == 'mainwp-child-reports/mainwp-child-reports.php') { + } elseif ( $slug == 'mainwp-child-reports/mainwp-child-reports.php' ) { $plugin['Name'] = esc_html( stripslashes( $branding_title ) ) . ' reports'; } } @@ -967,7 +967,7 @@ class MainWP_Child_Server_Information { protected static function checkDirectoryMainWPDirectory( $write = true ) { $branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); - if ($branding_title == '') { + if ( $branding_title == '' ) { $branding_title = 'MainWP'; } @@ -1056,7 +1056,7 @@ class MainWP_Child_Server_Information { Pass' : self::getWarningHTML( $errorType ) ); ?> Pass' : self::getWarningHTML( $errorType ) ); ?> - + Pass'; ?> Pass' : self::getWarningHTML( $errorType ) ); ?> @@ -1065,8 +1065,8 @@ class MainWP_Child_Server_Information { Warning'; } return ' Fail'; @@ -1090,10 +1090,10 @@ class MainWP_Child_Server_Information { return version_compare( $value1, $value2, $operator ); } - protected static function check( $pCompare, $pVersion, $pGetter, $pExtraCompare = null, $pExtraVersion = null, $sizeCompare = false) { + protected static function check( $pCompare, $pVersion, $pGetter, $pExtraCompare = null, $pExtraVersion = null, $sizeCompare = false ) { $currentVersion = call_user_func( array( 'MainWP_Child_Server_Information', $pGetter ) ); - if ($sizeCompare) { + if ( $sizeCompare ) { return self::filesize_compare( $currentVersion, $pVersion, $pCompare ); } else { return ( version_compare( $currentVersion, $pVersion, $pCompare ) || ( ( null !== $pExtraCompare ) && version_compare( $currentVersion, $pExtraVersion, $pExtraCompare ) ) ); @@ -1482,7 +1482,7 @@ class MainWP_Child_Server_Information { if ( empty( $lines ) ) { $branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); - if ($branding_title == '') { + if ( $branding_title == '' ) { $branding_title = 'MainWP'; } $msg = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.'; @@ -1628,7 +1628,7 @@ class MainWP_Child_Server_Information { public static function renderConnectionDetails() { $branding_title = MainWP_Child_Branding::Instance()->get_branding_title(); - if ($branding_title == '') { + if ( $branding_title == '' ) { $branding_title = 'MainWP'; } @@ -1679,7 +1679,7 @@ class MainWP_Child_Server_Information { diff --git a/class/class-mainwp-child-skeleton-key.php b/class/class-mainwp-child-skeleton-key.php index 9905902..eac1022 100644 --- a/class/class-mainwp-child-skeleton-key.php +++ b/class/class-mainwp-child-skeleton-key.php @@ -195,7 +195,7 @@ class MainWP_Child_Skeleton_Key { public function save_settings() { $settings = isset($_POST['settings']) ? $_POST['settings'] : array(); - if ( ! is_array($settings) || empty($settings)) { + if ( ! is_array($settings) || empty($settings) ) { return array( 'error' => 'Invalid data. Please check and try again.' ); } @@ -231,8 +231,8 @@ class MainWP_Child_Skeleton_Key { } $updated = false; - foreach ($settings as $option => $value) { - if (in_array($option, $whitelist_general)) { + foreach ( $settings as $option => $value ) { + if ( in_array($option, $whitelist_general) ) { if ( ! is_array( $value ) ) { $value = trim( $value ); } @@ -242,7 +242,7 @@ class MainWP_Child_Skeleton_Key { } } - if ( ! $updated) { + if ( ! $updated ) { return false; } diff --git a/class/class-mainwp-child-staging.php b/class/class-mainwp-child-staging.php index b5ae160..82fd60c 100644 --- a/class/class-mainwp-child-staging.php +++ b/class/class-mainwp-child-staging.php @@ -30,13 +30,13 @@ class MainWP_Child_Staging { public function __construct() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; - if ( is_plugin_active( 'wp-staging/wp-staging.php' ) && defined('WPSTG_PLUGIN_DIR')) { + if ( is_plugin_active( 'wp-staging/wp-staging.php' ) && defined('WPSTG_PLUGIN_DIR') ) { $this->is_plugin_installed = true; } elseif ( is_plugin_active( 'wp-staging-pro/wp-staging-pro.php' ) ) { $this->is_plugin_installed = true; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -49,7 +49,7 @@ class MainWP_Child_Staging { return; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -65,7 +65,7 @@ class MainWP_Child_Staging { if ( isset( $data['syncWPStaging'] ) && $data['syncWPStaging'] ) { try { $information['syncWPStaging'] = $this->get_sync_data(); - } catch (Exception $e) { + } catch ( Exception $e ) { // do not exit } } @@ -77,17 +77,17 @@ class MainWP_Child_Staging { } public function action() { - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { MainWP_Helper::write( array( 'error' => 'Please install WP Staging plugin on child website' ) ); } - if ( ! class_exists( 'WPStaging\WPStaging' )) { + if ( ! class_exists( 'WPStaging\WPStaging' ) ) { require_once WPSTG_PLUGIN_DIR . 'apps/Core/WPStaging.php'; } \WPStaging\WPStaging::getInstance(); $information = array(); - if (get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y') { + if ( get_option( 'mainwp_wp_staging_ext_enabled' ) !== 'Y' ) { MainWP_Helper::update_option( 'mainwp_wp_staging_ext_enabled', 'Y', 'yes' ); } @@ -176,8 +176,8 @@ class MainWP_Child_Staging { ); $save_fields = array(); - foreach ($filters as $field) { - if (isset($settings[ $field ])) { + foreach ( $filters as $field ) { + if ( isset($settings[ $field ]) ) { $save_fields[ $field ] = $settings[ $field ]; } } @@ -378,8 +378,8 @@ class MainWP_Child_Staging { } // from wp-staging plugin - public function formatSize( $bytes, $precision = 2) { - if ( (float) $bytes < 1) { + public function formatSize( $bytes, $precision = 2 ) { + if ( (float) $bytes < 1 ) { return ''; } @@ -423,7 +423,7 @@ class MainWP_Child_Staging { return $value; } - if ( ! MainWP_Helper::is_screen_with_update()) { + if ( ! MainWP_Helper::is_screen_with_update() ) { return $value; } diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index d8d833f..924792a 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -27,11 +27,11 @@ class MainWP_Child_Timecapsule { public function __construct() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; - if ( is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) && defined('WPTC_CLASSES_DIR')) { + if ( is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) && defined('WPTC_CLASSES_DIR') ) { $this->is_plugin_installed = true; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -40,7 +40,7 @@ class MainWP_Child_Timecapsule { public function init() { - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -60,13 +60,13 @@ class MainWP_Child_Timecapsule { public function action() { - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { MainWP_Helper::write( array( 'error' => 'Please install WP Time Capsule plugin on child website' ) ); } try { $this->require_files(); - } catch ( Exception $e) { + } catch ( Exception $e ) { $error = $e->getMessage(); MainWP_Helper::write( array( 'error' => $error ) ); } @@ -80,7 +80,7 @@ class MainWP_Child_Timecapsule { if ( isset( $_POST['mwp_action'] ) ) { - if (( + if ( ( $_POST['mwp_action'] == 'save_settings' || $_POST['mwp_action'] == 'get_staging_details_wptc' || $_POST['mwp_action'] == 'progress_wptc' @@ -243,7 +243,7 @@ class MainWP_Child_Timecapsule { public function syncOthersData( $information, $data = array() ) { if ( isset( $data['syncWPTimeCapsule'] ) && $data['syncWPTimeCapsule'] ) { $information['syncWPTimeCapsule'] = $this->get_sync_data(); - if (get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y') { + if ( get_option( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) { MainWP_Helper::update_option( 'mainwp_time_capsule_ext_enabled', 'Y', 'yes' ); } } @@ -270,9 +270,9 @@ class MainWP_Child_Timecapsule { $all_backups = $this->getBackups(); $backups_count = 0; - if (is_array($all_backups)) { + if ( is_array($all_backups) ) { $formatted_backups = array(); - foreach ($all_backups as $key => $value) { + foreach ( $all_backups as $key => $value ) { $value_array = (array) $value; $formatted_backups[ $value_array['backupID'] ][] = $value_array; } @@ -289,14 +289,14 @@ class MainWP_Child_Timecapsule { 'backups_count' => $backups_count, ); return $return; - } catch ( Exception $e) { + } catch ( Exception $e ) { // do not exit here } return false; } protected function getBackups( $last_time = false ) { - if (empty($last_time)) { + if ( empty($last_time) ) { $last_time = strtotime(date('Y-m-d', strtotime(date('Y-m-01')))); } global $wpdb; @@ -318,7 +318,7 @@ class MainWP_Child_Timecapsule { } public function exclude_file_list() { - if ( ! isset($_POST['data'])) { + if ( ! isset($_POST['data']) ) { wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['category']; @@ -331,7 +331,7 @@ class MainWP_Child_Timecapsule { $config = WPTC_Factory::get('config'); global $wpdb; - if ( ! $config->get_option('in_progress')) { + if ( ! $config->get_option('in_progress') ) { spawn_cron(); } @@ -346,13 +346,13 @@ class MainWP_Child_Timecapsule { $return_array['is_staging_running'] = apply_filters('is_any_staging_process_going_on', ''); $cron_status = $config->get_option('wptc_own_cron_status'); - if ( ! empty($cron_status)) { + if ( ! empty($cron_status) ) { $return_array['wptc_own_cron_status'] = unserialize($cron_status); $return_array['wptc_own_cron_status_notified'] = (int) $config->get_option('wptc_own_cron_status_notified'); } $start_backups_failed_server = $config->get_option('start_backups_failed_server'); - if ( ! empty($start_backups_failed_server)) { + if ( ! empty($start_backups_failed_server) ) { $return_array['start_backups_failed_server'] = unserialize($start_backups_failed_server); $config->set_option('start_backups_failed_server', false); } @@ -368,7 +368,7 @@ class MainWP_Child_Timecapsule { $processed_files = WPTC_Factory::get('processed-files'); $last_backup_time = $config->get_option('last_backup_time'); - if ( ! empty($last_backup_time)) { + 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); @@ -385,10 +385,10 @@ class MainWP_Child_Timecapsule { wptc_own_cron_status(); $status = array(); $cron_status = $config->get_option('wptc_own_cron_status'); - if ( ! empty($cron_status)) { + if ( ! empty($cron_status) ) { $cron_status = unserialize($cron_status); - if ($cron_status['status'] == 'success') { + if ( $cron_status['status'] == 'success' ) { $status['status'] = 'success'; } else { $status['status'] = 'failed'; @@ -416,7 +416,7 @@ class MainWP_Child_Timecapsule { function start_restore_tc_callback_wptc() { - if (apply_filters('is_restore_to_staging_wptc', '')) { + if ( apply_filters('is_restore_to_staging_wptc', '') ) { $request = apply_filters('get_restore_to_staging_request_wptc', ''); } else { $request = $_POST['data']; @@ -455,9 +455,9 @@ class MainWP_Child_Timecapsule { function prepare_items() { global $wpdb; - if (isset($_POST['type'])) { + if ( isset($_POST['type']) ) { $type = $_POST['type']; - switch ($type) { + switch ( $type ) { case 'backups': $query = 'SELECT * FROM ' . $wpdb->base_prefix . "wptc_activity_log WHERE type LIKE '%backup%' AND show_user = 1 GROUP BY action_id"; break; @@ -490,7 +490,7 @@ class MainWP_Child_Timecapsule { // Parameters that are going to be used to order the result $orderby = ! empty($_POST['orderby']) ? mysql_real_escape_string($_POST['orderby']) : 'id'; $order = ! empty($_POST['order']) ? mysql_real_escape_string($_POST['order']) : 'DESC'; - if ( ! empty($orderby) & ! empty($order)) { + if ( ! empty($orderby) & ! empty($order) ) { $query .= ' ORDER BY ' . $orderby . ' ' . $order;} /* @@ -501,12 +501,12 @@ class MainWP_Child_Timecapsule { $perpage = 20; // Which page is this? $paged = ! empty($_POST['paged']) ? $_POST['paged'] : ''; - if (empty($paged) || ! is_numeric($paged) || $paged <= 0) { + if ( empty($paged) || ! is_numeric($paged) || $paged <= 0 ) { $paged = 1;} //Page Number // How many pages do we have in total? $totalpages = ceil($totalitems / $perpage); // Total number of pages // adjust the query to take pagination into account - if ( ! empty($paged) && ! empty($perpage)) { + if ( ! empty($paged) && ! empty($perpage) ) { $offset = ( $paged - 1 ) * $perpage; $query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage; } @@ -521,13 +521,13 @@ class MainWP_Child_Timecapsule { function lazy_load_activity_log_wptc() { - if ( ! isset($_POST['data'])) { + if ( ! isset($_POST['data']) ) { return false; } $data = $_POST['data']; - if ( ! isset($data['action_id']) || ! isset($data['limit'])) { + if ( ! isset($data['action_id']) || ! isset($data['limit']) ) { return false; } global $wpdb; @@ -544,13 +544,13 @@ class MainWP_Child_Timecapsule { $sub_records = $wpdb->get_results($sql); $row_count = count($sub_records); - if ($row_count == $current_limit) { + if ( $row_count == $current_limit ) { $load_more = true; } $detailed = $this->get_activity_log($sub_records); - if (isset($load_more) && $load_more) { + if ( isset($load_more) && $load_more ) { $detailed .= ''; } @@ -560,10 +560,10 @@ class MainWP_Child_Timecapsule { } - function get_display_rows( $records) { + function get_display_rows( $records ) { global $wpdb; // Get the records registered in the prepare_items method - if ( ! is_array($records)) { + if ( ! is_array($records) ) { return ''; } @@ -572,26 +572,26 @@ class MainWP_Child_Timecapsule { // Get the columns registered in the get_columns and get_sortable_columns methods // $columns = $this->get_columns(); $timezone = WPTC_Factory::get('config')->get_option('wptc_timezone'); - if (count($records) > 0) { + if ( count($records) > 0 ) { - foreach ($records as $key => $rec) { + foreach ( $records as $key => $rec ) { $html = ''; $more_logs = false; $load_more = false; - if ($rec->action_id != '') { + if ( $rec->action_id != '' ) { $sql = 'SELECT * FROM ' . $wpdb->base_prefix . 'wptc_activity_log WHERE action_id=' . $rec->action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT 0 , ' . $limit; $sub_records = $wpdb->get_results($sql); $row_count = count($sub_records); - if ($row_count == $limit) { + if ( $row_count == $limit ) { $load_more = true; } - if ($row_count > 0) { + if ( $row_count > 0 ) { $more_logs = true; $detailed = '
Load more
'; $detailed .= $this->get_activity_log($sub_records); - if (isset($load_more) && $load_more) { + if ( isset($load_more) && $load_more ) { $detailed .= ''; } $detailed .= '
Load more
'; @@ -608,29 +608,29 @@ class MainWP_Child_Timecapsule { // $user_tz_now = $user_tz->format("M d, Y @ g:i:s a"); $user_tz_now = date('M d, Y @ g:i:s a', $user_time); $msg = ''; - if ( ! ( strpos($rec->type, 'backup') === false )) { + if ( ! ( strpos($rec->type, 'backup') === false ) ) { // Backup process $msg = 'Backup Process'; - } elseif ( ! ( strpos($rec->type, 'restore') === false )) { + } elseif ( ! ( strpos($rec->type, 'restore') === false ) ) { // Restore Process $msg = 'Restore Process'; - } elseif ( ! ( strpos($rec->type, 'staging') === false )) { + } elseif ( ! ( strpos($rec->type, 'staging') === false ) ) { // Restore Process $msg = 'Staging Process'; } else { - if ($row_count < 2) { + if ( $row_count < 2 ) { $more_logs = false; } $msg = $Ldata['msg']; } $html .= '' . $user_tz_now . '' . $msg; - if ($more_logs) { + if ( $more_logs ) { $html .= "    View details"; } else { $html .= ''; } $html .= 'Send report to plugin developer'; - if ($more_logs) { + if ( $more_logs ) { $html .= "" . $detailed . ''; } else { @@ -641,19 +641,18 @@ class MainWP_Child_Timecapsule { $display_rows[ $key ] = $html; } - } return $display_rows; } - function get_activity_log( $sub_records) { - if (count($sub_records) < 1) { + function get_activity_log( $sub_records ) { + if ( count($sub_records) < 1 ) { return false; } $detailed = ''; $timezone = WPTC_Factory::get('config')->get_option('wptc_timezone'); - foreach ($sub_records as $srec) { + foreach ( $sub_records as $srec ) { $Moredata = unserialize($srec->log_data); $user_tmz = new DateTime('@' . $Moredata['log_time'], new DateTimeZone(date_default_timezone_get())); $user_tmz->setTimeZone(new DateTimeZone($timezone)); @@ -665,7 +664,7 @@ class MainWP_Child_Timecapsule { function clear_wptc_logs() { global $wpdb; - if ($wpdb->query('TRUNCATE TABLE `' . $wpdb->base_prefix . 'wptc_activity_log`')) { + if ( $wpdb->query('TRUNCATE TABLE `' . $wpdb->base_prefix . 'wptc_activity_log`') ) { $result = 'yes'; } else { $result = 'no'; @@ -691,7 +690,7 @@ class MainWP_Child_Timecapsule { public function exclude_table_list() { - if ( ! isset($_POST['data'])) { + if ( ! isset($_POST['data']) ) { wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['data']['category']; @@ -701,7 +700,7 @@ class MainWP_Child_Timecapsule { } function do_site_stats() { - if (has_action('mainwp_child_reports_log')) { + if ( has_action('mainwp_child_reports_log') ) { do_action( 'mainwp_child_reports_log', 'wptimecapsule'); } else { $this->do_reports_log('wptimecapsule'); @@ -709,13 +708,13 @@ class MainWP_Child_Timecapsule { } // ok - public function do_reports_log( $ext = '') { + public function do_reports_log( $ext = '' ) { if ( $ext !== 'wptimecapsule' ) { return; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -728,41 +727,40 @@ class MainWP_Child_Timecapsule { $backup_time = $config->get_option('last_backup_time'); - if ( ! empty($backup_time)) { + if ( ! empty($backup_time) ) { MainWP_Helper::update_lasttime_backup( 'wptimecapsule', $backup_time ); // to support backup before update feature } $last_time = time() - 24 * 7 * 2 * 60 * 60; // 2 weeks ago $lasttime_logged = MainWP_Helper::get_lasttime_backup('wptimecapsule'); - if (empty($lasttime_logged)) { + if ( empty($lasttime_logged) ) { $last_time = time() - 24 * 7 * 8 * 60 * 60; // 8 weeks ago } $all_last_backups = $this->getBackups( $last_time ); - if (is_array($all_last_backups)) { + if ( is_array($all_last_backups) ) { $formatted_backups = array(); - foreach ($all_last_backups as $key => $value) { + foreach ( $all_last_backups as $key => $value ) { $value_array = (array) $value; $formatted_backups[ $value_array['backupID'] ][] = $value_array; } $message = 'WP Time Capsule backup finished'; $backup_type = 'WP Time Capsule backup'; - if (count($formatted_backups) > 0) { - foreach ($formatted_backups as $key => $value) { + if ( count($formatted_backups) > 0 ) { + foreach ( $formatted_backups as $key => $value ) { $backup_time = $key; do_action( 'mainwp_reports_wptimecapsule_backup', $message, $backup_type, $backup_time ); } } } - - } catch (Exception $e) { + } catch ( Exception $e ) { } } public function include_table_list() { - if ( ! isset($_POST['data'])) { + if ( ! isset($_POST['data']) ) { wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['data']['category']; @@ -773,7 +771,7 @@ class MainWP_Child_Timecapsule { public function include_table_structure_only() { - if ( ! isset($_POST['data'])) { + if ( ! isset($_POST['data']) ) { wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } @@ -785,7 +783,7 @@ class MainWP_Child_Timecapsule { public function include_file_list() { - if ( ! isset($_POST['data'])) { + if ( ! isset($_POST['data']) ) { wptc_die_with_json_encode( array( 'status' => 'no data found' ) ); } $category = $_POST['category']; @@ -805,7 +803,7 @@ class MainWP_Child_Timecapsule { private function process_wptc_login() { $options_helper = new Wptc_Options_Helper(); - if ($options_helper->get_is_user_logged_in()) { + if ( $options_helper->get_is_user_logged_in() ) { return array( 'result' => 'is_user_logged_in', 'sync_data' => $this->get_sync_data(), @@ -815,7 +813,7 @@ class MainWP_Child_Timecapsule { $email = $_POST['acc_email']; $pwd = $_POST['acc_pwd']; - if (empty( $email ) || empty($pwd)) { + if ( empty( $email ) || empty($pwd) ) { return array( 'error' => 'Username and password cannot be empty' ); } @@ -839,7 +837,7 @@ class MainWP_Child_Timecapsule { $is_user_logged_in = $options->get_option('is_user_logged_in'); - if ( ! $is_user_logged_in) { + if ( ! $is_user_logged_in ) { return array( 'error' => 'Login failed.' ); } return array( @@ -853,7 +851,7 @@ class MainWP_Child_Timecapsule { $backup_before_auto_update_settings = WPTC_Pro_Factory::get('Wptc_Backup_Before_Auto_Update_Settings'); $plugins = $backup_before_auto_update_settings->get_installed_plugins(); - if ($plugins) { + if ( $plugins ) { return array( 'results' => $plugins ); } return array( 'results' => array() ); @@ -864,7 +862,7 @@ class MainWP_Child_Timecapsule { $backup_before_auto_update_settings = WPTC_Pro_Factory::get('Wptc_Backup_Before_Auto_Update_Settings'); $plugins = $backup_before_auto_update_settings->get_installed_themes(); - if ($plugins) { + if ( $plugins ) { return array( 'results' => $plugins ); } return array( 'results' => array() ); @@ -886,7 +884,7 @@ class MainWP_Child_Timecapsule { function start_fresh_staging_wptc() { $staging = WPTC_Pro_Factory::get('Wptc_Staging'); - if (empty($_POST['path'])) { + if ( empty($_POST['path']) ) { wptc_die_with_json_encode( array( 'status' => 'error', 'msg' => 'path is missing', @@ -950,7 +948,7 @@ class MainWP_Child_Timecapsule { public function init_restore() { - if (empty($_POST)) { + if ( empty($_POST) ) { return ( array( 'error' => 'Backup id is empty !' ) ); } $restore_to_staging = WPTC_Base_Factory::get('Wptc_Restore_To_Staging'); @@ -984,7 +982,7 @@ class MainWP_Child_Timecapsule { $config->set_option('user_excluded_extenstions', $data['user_excluded_extenstions']); $config->set_option('user_excluded_files_more_than_size_settings', $data['user_excluded_files_more_than_size_settings']); - if ( ! empty($data['backup_slot'])) { + if ( ! empty($data['backup_slot']) ) { $config->set_option('old_backup_slot', $config->get_option('backup_slot')); $config->set_option('backup_slot', $data['backup_slot']); } @@ -995,7 +993,7 @@ class MainWP_Child_Timecapsule { $config->set_option('schedule_time_str', $data['schedule_time_str']); if ( ! empty($data['schedule_time_str']) && ! empty($data['wptc_timezone']) ) { - if (function_exists('wptc_modify_schedule_backup')) { + if ( function_exists('wptc_modify_schedule_backup') ) { wptc_modify_schedule_backup(); } } @@ -1024,14 +1022,14 @@ class MainWP_Child_Timecapsule { $current['update_settings']['themes']['status'] = $new['update_settings']['themes']['status']; $current['update_settings']['plugins']['status'] = $new['update_settings']['plugins']['status']; - if ( ! $is_general) { - if (isset($new['update_settings']['plugins']['included'])) { + if ( ! $is_general ) { + if ( isset($new['update_settings']['plugins']['included']) ) { $current['update_settings']['plugins']['included'] = $new['update_settings']['plugins']['included']; } else { $current['update_settings']['plugins']['included'] = array(); } - if (isset($new['update_settings']['themes']['included'])) { + if ( isset($new['update_settings']['themes']['included']) ) { $current['update_settings']['themes']['included'] = $new['update_settings']['themes']['included']; } else { $current['update_settings']['themes']['included'] = array(); @@ -1050,12 +1048,12 @@ class MainWP_Child_Timecapsule { $current['themes']['status'] = $new['themes']['status']; $current['plugins']['status'] = $new['plugins']['status']; - if ( ! $is_general) { + if ( ! $is_general ) { $vulns_plugins_included = ! empty($new['plugins']['vulns_plugins_included']) ? $new['plugins']['vulns_plugins_included'] : array(); $plugin_include_array = array(); - if ( ! empty($vulns_plugins_included)) { + if ( ! empty($vulns_plugins_included) ) { $plugin_include_array = explode(',', $vulns_plugins_included); $plugin_include_array = ! empty($plugin_include_array) ? $plugin_include_array : array(); } @@ -1072,7 +1070,7 @@ class MainWP_Child_Timecapsule { $themes_include_array = array(); - if ( ! empty($vulns_themes_included)) { + if ( ! empty($vulns_themes_included) ) { $themes_include_array = explode(',', $vulns_themes_included); } @@ -1090,7 +1088,7 @@ class MainWP_Child_Timecapsule { $config->set_option('internal_staging_deep_link_limit', $data['internal_staging_deep_link_limit']); $config->set_option('internal_staging_enable_admin_login', $data['internal_staging_enable_admin_login']); $config->set_option('staging_is_reset_permalink', $data['staging_is_reset_permalink']); - if ( ! $is_general) { + if ( ! $is_general ) { $config->set_option('staging_login_custom_link', $data['staging_login_custom_link']); } $saved = true; @@ -1103,7 +1101,7 @@ class MainWP_Child_Timecapsule { return array( 'result' => 'ok' ); } - private function filter_plugins( $included_plugins) { + private function filter_plugins( $included_plugins ) { $app_functions = WPTC_Base_Factory::get('Wptc_App_Functions'); $plugins_data = $app_functions->get_all_plugins_data($specific = true, $attr = 'slug'); $not_included_plugin = array_diff($plugins_data, $included_plugins); @@ -1113,7 +1111,7 @@ class MainWP_Child_Timecapsule { } - private function filter_themes( $included_themes) { + private function filter_themes( $included_themes ) { $app_functions = WPTC_Base_Factory::get('Wptc_App_Functions'); $themes_data = $app_functions->get_all_themes_data($specific = true, $attr = 'slug'); $not_included_theme = array_diff($themes_data, $included_themes); @@ -1281,7 +1279,7 @@ class MainWP_Child_Timecapsule { if ( isset( $_POST['mainwpsignature'] ) ) { return $value; } - if ( ! MainWP_Helper::is_screen_with_update()) { + if ( ! MainWP_Helper::is_screen_with_update() ) { return $value; } if ( isset( $value->response['wp-time-capsule/wp-time-capsule.php'] ) ) { diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index 3da4ced..1e19d87 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -28,11 +28,11 @@ class MainWP_Child_Updraft_Plus_Backups { public function __construct() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; - if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR')) { + if ( is_plugin_active( 'updraftplus/updraftplus.php' ) && defined('UPDRAFTPLUS_DIR') ) { $this->is_plugin_installed = true; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -40,14 +40,14 @@ class MainWP_Child_Updraft_Plus_Backups { add_filter('updraftplus_save_last_backup', array( __CLASS__, 'hookUpdraftplusSaveLastBackup' )); } - public static function hookUpdraftplusSaveLastBackup( $last_backup) { - if ( ! is_array($last_backup)) { + public static function hookUpdraftplusSaveLastBackup( $last_backup ) { + if ( ! is_array($last_backup) ) { return $last_backup; } - if (isset($last_backup['backup_time'])) { + if ( isset($last_backup['backup_time']) ) { $backup_time = $last_backup['backup_time']; - if ($last_backup['success']) { + if ( $last_backup['success'] ) { MainWP_Helper::update_lasttime_backup('updraftplus', $backup_time); } } @@ -70,7 +70,7 @@ class MainWP_Child_Updraft_Plus_Backups { $information['sync_Updraftvault_quota_text'] = $this->connected_html(); } } - } catch (Exception $e) { + } catch ( Exception $e ) { } @@ -162,7 +162,7 @@ class MainWP_Child_Updraft_Plus_Backups { $information = $this->vault_disconnect(); break; } - } catch (Exception $e) { + } catch ( Exception $e ) { $information = array( 'error' => $e->getMessage() ); } } @@ -412,7 +412,7 @@ class MainWP_Child_Updraft_Plus_Backups { } function required_files() { - if (defined('UPDRAFTPLUS_DIR')) { + if ( defined('UPDRAFTPLUS_DIR') ) { if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) { require_once UPDRAFTPLUS_DIR . '/class-updraftplus.php'; } @@ -434,14 +434,14 @@ class MainWP_Child_Updraft_Plus_Backups { foreach ( $keys_filter as $key ) { if ( isset( $settings[ $key ] ) ) { $settings_key = null; - if ( 'updraft_dropbox' === $key && is_array($settings[ $key ])) { + if ( 'updraft_dropbox' === $key && is_array($settings[ $key ]) ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dropbox' ); - if ( ! is_array($opts)) { + if ( ! is_array($opts) ) { $opts = array(); } - if (is_array($opts) && isset($opts['settings'])) { + if ( is_array($opts) && isset($opts['settings']) ) { $settings_key = key($opts['settings']); - if (isset($settings['is_general']) && ! empty($settings['is_general'])) { + if ( isset($settings['is_general']) && ! empty($settings['is_general']) ) { $opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } else { // $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey']; @@ -449,7 +449,7 @@ class MainWP_Child_Updraft_Plus_Backups { $opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } } else { - if (isset($settings['is_general']) && ! empty($settings['is_general'])) { + if ( isset($settings['is_general']) && ! empty($settings['is_general']) ) { $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']); } else { // $opts['appkey'] = $settings[ $key ]['appkey']; @@ -524,18 +524,18 @@ class MainWP_Child_Updraft_Plus_Backups { UpdraftPlus_Options::update_updraft_option( $key, $value ); } elseif ( 'updraft_s3' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3' ); - if ( ! is_array($opts)) { + if ( ! is_array($opts) ) { $opts = array(); } - if (is_array($opts) && isset($opts['settings'])) { + if ( is_array($opts) && isset($opts['settings']) ) { $settings_key = key($opts['settings']); $opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey']; $opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey']; $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']); - if ( ! empty($opts['settings'][ $settings_key ]['path']) && '/' == substr($opts['settings'][ $settings_key ]['path'], 0, 1)) { + if ( ! empty($opts['settings'][ $settings_key ]['path']) && '/' == substr($opts['settings'][ $settings_key ]['path'], 0, 1) ) { $opts['settings'][ $settings_key ]['path'] = substr($opts['settings'][ $settings_key ]['path'], 1); } - if (isset($settings[ $key ]['rrs'])) { // premium settings + if ( isset($settings[ $key ]['rrs']) ) { // premium settings $opts['settings'][ $settings_key ]['rrs'] = $settings[ $key ]['rrs']; $opts['settings'][ $settings_key ]['server_side_encryption'] = $settings[ $key ]['server_side_encryption']; } @@ -543,10 +543,10 @@ class MainWP_Child_Updraft_Plus_Backups { $opts['accesskey'] = $settings[ $key ]['accesskey']; $opts['secretkey'] = $settings[ $key ]['secretkey']; $opts['path'] = $this->replace_tokens($settings[ $key ]['path']); - if ( ! empty($opts['path']) && '/' == substr($opts['path'], 0, 1)) { + if ( ! empty($opts['path']) && '/' == substr($opts['path'], 0, 1) ) { $opts['path'] = substr($opts['path'], 1); } - if (isset($settings[ $key ]['rrs'])) { // premium settings + if ( isset($settings[ $key ]['rrs']) ) { // premium settings $opts['rrs'] = $settings[ $key ]['rrs']; $opts['server_side_encryption'] = $settings[ $key ]['server_side_encryption']; } @@ -555,10 +555,10 @@ class MainWP_Child_Updraft_Plus_Backups { UpdraftPlus_Options::update_updraft_option( $key, $opts ); } elseif ( 'updraft_s3generic' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_s3generic' ); - if ( ! is_array($opts)) { + if ( ! is_array($opts) ) { $opts = array(); } - if (is_array($opts) && isset($opts['settings'])) { + if ( is_array($opts) && isset($opts['settings']) ) { $settings_key = key($opts['settings']); $opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint']; $opts['settings'][ $settings_key ]['accesskey'] = $settings[ $key ]['accesskey']; @@ -574,10 +574,10 @@ class MainWP_Child_Updraft_Plus_Backups { UpdraftPlus_Options::update_updraft_option( $key, $opts ); } elseif ( 'updraft_dreamobjects' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_dreamobjects' ); - if ( ! is_array($opts)) { + if ( ! is_array($opts) ) { $opts = array(); } - if (is_array($opts) && isset($opts['settings'])) { + if ( is_array($opts) && isset($opts['settings']) ) { $settings_key = key($opts['settings']); $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']); $opts['settings'][ $settings_key ]['endpoint'] = $settings[ $key ]['endpoint']; @@ -588,10 +588,10 @@ class MainWP_Child_Updraft_Plus_Backups { UpdraftPlus_Options::update_updraft_option( $key, $opts ); } elseif ( 'updraft_ftp' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_ftp' ); - if ( ! is_array($opts)) { + if ( ! is_array($opts) ) { $opts = array(); } - if (is_array($opts) && isset($opts['settings'])) { + if ( is_array($opts) && isset($opts['settings']) ) { $settings_key = key($opts['settings']); if ( isset( $settings[ $key ]['path'] ) ) { $opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host']; @@ -613,10 +613,10 @@ class MainWP_Child_Updraft_Plus_Backups { UpdraftPlus_Options::update_updraft_option( $key, $opts ); } elseif ( 'updraft_sftp_settings' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_sftp' ); - if ( ! is_array($opts)) { + if ( ! is_array($opts) ) { $opts = array(); } - if (is_array($opts) && isset($opts['settings'])) { + if ( is_array($opts) && isset($opts['settings']) ) { $settings_key = key($opts['settings']); if ( isset( $settings[ $key ]['path'] ) ) { $opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host']; @@ -639,24 +639,23 @@ class MainWP_Child_Updraft_Plus_Backups { } } UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts ); - } elseif ('updraft_webdav_settings' == $key) { + } elseif ( 'updraft_webdav_settings' == $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_webdav' ); - if ( ! is_array($opts)) { + if ( ! is_array($opts) ) { $opts = array(); } - if (is_array($opts) && isset($opts['settings'])) { + if ( is_array($opts) && isset($opts['settings']) ) { $settings_key = key($opts['settings']); $opts['settings'][ $settings_key ]['url'] = $this->replace_tokens( $settings[ $key ]['url'] ); UpdraftPlus_Options::update_updraft_option( 'updraft_webdav', $opts ); } - - } elseif ( 'updraft_backblaze' === $key ) { + } elseif ( 'updraft_backblaze' === $key ) { $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_backblaze' ); - if ( ! is_array($opts)) { + if ( ! is_array($opts) ) { $opts = array(); - } - if (is_array($opts) && isset($opts['settings'])) { + } + if ( is_array($opts) && isset($opts['settings']) ) { $settings_key = key($opts['settings']); $opts['settings'][ $settings_key ]['account_id'] = $settings[ $key ]['account_id']; $opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key']; @@ -669,7 +668,7 @@ class MainWP_Child_Updraft_Plus_Backups { $opts['settings'][ $settings_key ]['bucket_name'] = $bname; $opts['settings'][ $settings_key ]['backup_path'] = $bpath; UpdraftPlus_Options::update_updraft_option( $key, $opts ); - } + } } else { UpdraftPlus_Options::update_updraft_option( $key, $settings[ $key ] ); } @@ -677,7 +676,7 @@ class MainWP_Child_Updraft_Plus_Backups { } } - if ( ! isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings'])) { + if ( ! isset($settings['do_not_save_remote_settings']) || empty($settings['do_not_save_remote_settings']) ) { UpdraftPlus_Options::update_updraft_option( 'updraft_service', $settings['updraft_service'] ); } @@ -709,15 +708,15 @@ class MainWP_Child_Updraft_Plus_Backups { return $out; } - function replace_tokens( $str = '') { - if (stripos($str, '%sitename%') !== false) { + function replace_tokens( $str = '' ) { + if ( stripos($str, '%sitename%') !== false ) { $replace_token = get_bloginfo( 'name' ); $replace_token = sanitize_file_name($replace_token); $replace_token = strtolower($replace_token); $str = str_ireplace('%sitename%', $replace_token, $str); } - if (stripos($str, '%siteurl%') !== false) { + if ( stripos($str, '%siteurl%') !== false ) { $replace_token = get_bloginfo( 'url' ); $replace_token = preg_replace('/^https?:\/\//i', '', $replace_token); $replace_token = sanitize_file_name($replace_token); @@ -728,7 +727,7 @@ class MainWP_Child_Updraft_Plus_Backups { function addons_connect() { if ( ! defined( 'UDADDONS2_SLUG' ) ) { - if (is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php')) { + if ( is_file(UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php') ) { require_once UPDRAFTPLUS_DIR . '/udaddons/updraftplus-addons.php'; } if ( ! defined( 'UDADDONS2_SLUG' ) ) { @@ -942,7 +941,7 @@ class MainWP_Child_Updraft_Plus_Backups { ); } - private function cb_get_name_base_type( $a) { + private function cb_get_name_base_type( $a ) { return $a[0]; } @@ -1189,7 +1188,7 @@ class MainWP_Child_Updraft_Plus_Backups { // UNIX timestamp $next_scheduled_backup = wp_next_scheduled('updraft_backup'); - if ($next_scheduled_backup) { + if ( $next_scheduled_backup ) { // Convert to GMT $next_scheduled_backup_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup); // Convert to blog time zone @@ -1201,8 +1200,8 @@ class MainWP_Child_Updraft_Plus_Backups { } $next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database'); - if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database', UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) { - if (isset($files_not_scheduled)) { + if ( UpdraftPlus_Options::get_updraft_option('updraft_interval_database', UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval') ) { + if ( isset($files_not_scheduled) ) { $next_scheduled_backup_database = $next_scheduled_backup; $database_not_scheduled = true; } else { @@ -1210,7 +1209,7 @@ class MainWP_Child_Updraft_Plus_Backups { $next_scheduled_backup_database_same_time = true; } } else { - if ($next_scheduled_backup_database) { + if ( $next_scheduled_backup_database ) { // Convert to GMT $next_scheduled_backup_database_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup_database); // Convert to blog time zone @@ -1271,9 +1270,9 @@ class MainWP_Child_Updraft_Plus_Backups { private function deleteset() { global $updraftplus; - if (method_exists($updraftplus, 'get_backup_history')) { + if ( method_exists($updraftplus, 'get_backup_history') ) { $backups = $updraftplus->get_backup_history(); - } elseif (class_exists('UpdraftPlus_Backup_History')) { + } elseif ( class_exists('UpdraftPlus_Backup_History') ) { $backups = UpdraftPlus_Backup_History::get_history(); } $timestamp = $_POST['backup_timestamp']; @@ -1499,9 +1498,9 @@ class MainWP_Child_Updraft_Plus_Backups { $updraftplus->jobdata_set( 'job_time_ms', $updraftplus->job_time_ms ); // Retrieve the information from our backup history - if (method_exists($updraftplus, 'get_backup_history')) { + if ( method_exists($updraftplus, 'get_backup_history') ) { $backup_history = $updraftplus->get_backup_history(); - } elseif (class_exists('UpdraftPlus_Backup_History')) { + } elseif ( class_exists('UpdraftPlus_Backup_History') ) { $backup_history = UpdraftPlus_Backup_History::get_history(); } @@ -1659,9 +1658,9 @@ class MainWP_Child_Updraft_Plus_Backups { public function restore_alldownloaded() { global $updraftplus; - if (method_exists($updraftplus, 'get_backup_history')) { + if ( method_exists($updraftplus, 'get_backup_history') ) { $backups = $updraftplus->get_backup_history(); - } elseif (class_exists('UpdraftPlus_Backup_History')) { + } elseif ( class_exists('UpdraftPlus_Backup_History') ) { $backups = UpdraftPlus_Backup_History::get_history(); } @@ -1700,7 +1699,7 @@ class MainWP_Child_Updraft_Plus_Backups { if ( isset( $elements['db'] ) ) { // Analyse the header of the database file + display results - if ( class_exists( 'UpdraftPlus_Encryption' )) { + if ( class_exists( 'UpdraftPlus_Encryption' ) ) { list ( $mess2, $warn2, $err2, $info ) = $updraftplus->analyse_db_file( $timestamp, $res ); } else { list ( $mess2, $warn2, $err2, $info ) = $this->analyse_db_file_old( $timestamp, $res ); @@ -2378,9 +2377,9 @@ class MainWP_Child_Updraft_Plus_Backups { // This attempts to raise the maximum packet size. This can't be done within the session, only globally. Therefore, it has to be done before the session starts; in our case, during the pre-analysis. $updraftplus->get_max_packet_size(); - if (method_exists($updraftplus, 'get_backup_history')) { + if ( method_exists($updraftplus, 'get_backup_history') ) { $backup = $updraftplus->get_backup_history($timestamp); - } elseif (class_exists('UpdraftPlus_Backup_History')) { + } elseif ( class_exists('UpdraftPlus_Backup_History') ) { $backup = UpdraftPlus_Backup_History::get_history($timestamp); } @@ -2597,7 +2596,7 @@ class MainWP_Child_Updraft_Plus_Backups { } - public function analyse_db_file( $timestamp, $res, $db_file = false, $header_only = false) { + public function analyse_db_file( $timestamp, $res, $db_file = false, $header_only = false ) { global $updraftplus; $mess = array(); @@ -2609,29 +2608,29 @@ class MainWP_Child_Updraft_Plus_Backups { $updraft_dir = $updraftplus->backups_dir_location(); - if (false === $db_file) { + if ( false === $db_file ) { // This attempts to raise the maximum packet size. This can't be done within the session, only globally. Therefore, it has to be done before the session starts; in our case, during the pre-analysis. $updraftplus->get_max_packet_size(); $backup = UpdraftPlus_Backup_History::get_history($timestamp); - if ( ! isset($backup['nonce']) || ! isset($backup['db'])) { + if ( ! isset($backup['nonce']) || ! isset($backup['db']) ) { return array( $mess, $warn, $err, $info ); } $db_file = ( is_string($backup['db']) ) ? $updraft_dir . '/' . $backup['db'] : $updraft_dir . '/' . $backup['db'][0]; } - if ( ! is_readable($db_file)) { + if ( ! is_readable($db_file) ) { return array( $mess, $warn, $err, $info ); } // Encrypted - decrypt it - if (UpdraftPlus_Encryption::is_file_encrypted($db_file)) { + if ( UpdraftPlus_Encryption::is_file_encrypted($db_file) ) { $encryption = empty($res['updraft_encryptionphrase']) ? UpdraftPlus_Options::get_updraft_option('updraft_encryptionphrase') : $res['updraft_encryptionphrase']; - if ( ! $encryption) { - if (class_exists('UpdraftPlus_Addon_MoreDatabase')) { + if ( ! $encryption ) { + if ( class_exists('UpdraftPlus_Addon_MoreDatabase') ) { $err[] = sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The database file is encrypted, but you have no encryption key entered.', 'updraftplus')); } else { $err[] = sprintf(__('Error: %s', 'updraftplus'), __('Decryption failed. The database file is encrypted.', 'updraftplus')); @@ -2641,7 +2640,7 @@ class MainWP_Child_Updraft_Plus_Backups { $decrypted_file = UpdraftPlus_Encryption::decrypt($db_file, $encryption); - if (is_array($decrypted_file)) { + if ( is_array($decrypted_file) ) { $db_file = $decrypted_file['fullpath']; } else { $err[] = __('Decryption failed. The most likely cause is that you used the wrong key.', 'updraftplus'); @@ -2650,7 +2649,7 @@ class MainWP_Child_Updraft_Plus_Backups { } // Even the empty schema when gzipped comes to 1565 bytes; a blank WP 3.6 install at 5158. But we go low, in case someone wants to share single tables. - if (filesize($db_file) < 1000) { + if ( filesize($db_file) < 1000 ) { $err[] = sprintf(__('The database is too small to be a valid WordPress database (size: %s Kb).', 'updraftplus'), round(filesize($db_file) / 1024, 1)); return array( $mess, $warn, $err, $info ); } @@ -2658,7 +2657,7 @@ class MainWP_Child_Updraft_Plus_Backups { $is_plain = ( '.gz' == substr($db_file, -3, 3) ) ? false : true; $dbhandle = ( $is_plain ) ? fopen($db_file, 'r') : $this->gzopen_for_read($db_file, $warn, $err); - if ( ! is_resource($dbhandle)) { + if ( ! is_resource($dbhandle) ) { $err[] = __('Failed to open database file.', 'updraftplus'); return array( $mess, $warn, $err, $info ); } @@ -2706,35 +2705,35 @@ class MainWP_Child_Updraft_Plus_Backups { $db_collates_found = array(); $db_supported_charset_related_to_unsupported_collation = false; $db_supported_charsets_related_to_unsupported_collations = array(); - while (( ( $is_plain && ! feof($dbhandle) ) || ( ! $is_plain && ! gzeof($dbhandle) ) ) && ( $line < 100 || ( ! $header_only && count($wanted_tables) > 0 ) || ( ( microtime(true) - $charset_scan_start_time ) < $db_charset_collate_scan_timeout && ! empty($db_supported_character_sets) ) )) { + while ( ( ( $is_plain && ! feof($dbhandle) ) || ( ! $is_plain && ! gzeof($dbhandle) ) ) && ( $line < 100 || ( ! $header_only && count($wanted_tables) > 0 ) || ( ( microtime(true) - $charset_scan_start_time ) < $db_charset_collate_scan_timeout && ! empty($db_supported_character_sets) ) ) ) { $line++; // Up to 1MB $buffer = ( $is_plain ) ? rtrim(fgets($dbhandle, 1048576)) : rtrim(gzgets($dbhandle, 1048576)); // Comments are what we are interested in - if (substr($buffer, 0, 1) == '#') { + if ( substr($buffer, 0, 1) == '#' ) { $processing_create = false; - if ('' == $old_siteurl && preg_match('/^\# Backup of: (http(.*))$/', $buffer, $matches)) { + if ( '' == $old_siteurl && preg_match('/^\# Backup of: (http(.*))$/', $buffer, $matches) ) { $old_siteurl = untrailingslashit($matches[1]); $mess[] = __('Backup of:', 'updraftplus') . ' ' . htmlspecialchars($old_siteurl) . ( ( ! empty($old_wp_version) ) ? ' ' . sprintf(__('(version: %s)', 'updraftplus'), $old_wp_version) : '' ); // Check for should-be migration - if (untrailingslashit(site_url()) != $old_siteurl) { - if ( ! $migration_warning) { + if ( untrailingslashit(site_url()) != $old_siteurl ) { + if ( ! $migration_warning ) { $migration_warning = true; $info['migration'] = true; // && !class_exists('UpdraftPlus_Addons_Migrator') - if (UpdraftPlus_Manipulation_Functions::normalise_url($old_siteurl) == UpdraftPlus_Manipulation_Functions::normalise_url(site_url())) { + if ( UpdraftPlus_Manipulation_Functions::normalise_url($old_siteurl) == UpdraftPlus_Manipulation_Functions::normalise_url(site_url()) ) { // Same site migration with only http/https difference $info['same_url'] = false; $old_siteurl_parsed = parse_url($old_siteurl); $actual_siteurl_parsed = parse_url(site_url()); - if (( stripos($old_siteurl_parsed['host'], 'www.') === 0 && stripos($actual_siteurl_parsed['host'], 'www.') !== 0 ) || ( stripos($old_siteurl_parsed['host'], 'www.') !== 0 && stripos($actual_siteurl_parsed['host'], 'www.') === 0 )) { + if ( ( stripos($old_siteurl_parsed['host'], 'www.') === 0 && stripos($actual_siteurl_parsed['host'], 'www.') !== 0 ) || ( stripos($old_siteurl_parsed['host'], 'www.') !== 0 && stripos($actual_siteurl_parsed['host'], 'www.') === 0 ) ) { $powarn = sprintf(__('The website address in the backup set (%1$s) is slightly different from that of the site now (%2$s). This is not expected to be a problem for restoring the site, as long as visits to the former address still reach the site.', 'updraftplus'), $old_siteurl, site_url()) . ' '; } else { $powarn = ''; } - if (( 'https' == $old_siteurl_parsed['scheme'] && 'http' == $actual_siteurl_parsed['scheme'] ) || ( 'http' == $old_siteurl_parsed['scheme'] && 'https' == $actual_siteurl_parsed['scheme'] )) { + if ( ( 'https' == $old_siteurl_parsed['scheme'] && 'http' == $actual_siteurl_parsed['scheme'] ) || ( 'http' == $old_siteurl_parsed['scheme'] && 'https' == $actual_siteurl_parsed['scheme'] ) ) { $powarn .= sprintf(__('This backup set is of this site, but at the time of the backup you were using %1$s, whereas the site now uses %2$s.', 'updraftplus'), $old_siteurl_parsed['scheme'], $actual_siteurl_parsed['scheme']); - if ('https' == $old_siteurl_parsed['scheme']) { + if ( 'https' == $old_siteurl_parsed['scheme'] ) { $powarn .= ' ' . apply_filters('updraftplus_https_to_http_additional_warning', sprintf(__('This restoration will work if you still have an SSL certificate (i.e. can use https) to access the site. Otherwise, you will want to use %s to search/replace the site address so that the site can be visited without https.', 'updraftplus'), '' . __('the migrator add-on', 'updraftplus') . '')); } else { $powarn .= ' ' . apply_filters('updraftplus_http_to_https_additional_warning', sprintf(__('As long as your web hosting allows http (i.e. non-SSL access) or will forward requests to https (which is almost always the case), this is no problem. If that is not yet set up, then you should set it up, or use %s so that the non-https links are automatically replaced.', 'updraftplus'), apply_filters('updraftplus_migrator_addon_link', '' . __('the migrator add-on', 'updraftplus') . ''))); @@ -2748,59 +2747,58 @@ class MainWP_Child_Updraft_Plus_Backups { $info['same_url'] = false; $warn[] = apply_filters('updraftplus_dbscan_urlchange', '' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '', $old_siteurl, $res); } - if ( ! class_exists('UpdraftPlus_Addons_Migrator')) { + if ( ! class_exists('UpdraftPlus_Addons_Migrator') ) { $warn[] .= '' . __('You can search and replace your database (for migrating a website to a new location/URL) with the Migrator add-on - follow this link for more information', 'updraftplus') . ''; } } - if ($updraftplus->mod_rewrite_unavailable(false)) { + if ( $updraftplus->mod_rewrite_unavailable(false) ) { $warn[] = sprintf(__('You are using the %1$s webserver, but do not seem to have the %2$s module loaded.', 'updraftplus'), 'Apache', 'mod_rewrite') . ' ' . sprintf(__('You should enable %1$s to make any pretty permalinks (e.g. %2$s) work', 'updraftplus'), 'mod_rewrite', 'http://example.com/my-page/'); } - } else { // For exactly same URL site restoration $info['same_url'] = true; } - } elseif ('' == $old_home && preg_match('/^\# Home URL: (http(.*))$/', $buffer, $matches)) { + } elseif ( '' == $old_home && preg_match('/^\# Home URL: (http(.*))$/', $buffer, $matches) ) { $old_home = untrailingslashit($matches[1]); // Check for should-be migration - if ( ! $migration_warning && home_url() != $old_home) { + if ( ! $migration_warning && home_url() != $old_home ) { $migration_warning = true; $powarn = apply_filters('updraftplus_dbscan_urlchange', '' . __('This backup set is from a different site - this is not a restoration, but a migration. You need the Migrator add-on in order to make this work.', 'updraftplus') . '', $old_home, $res); - if ( ! empty($powarn)) { + if ( ! empty($powarn) ) { $warn[] = $powarn; } } - } elseif ( ! isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches)) { + } elseif ( ! isset($info['created_by_version']) && preg_match('/^\# Created by UpdraftPlus version ([\d\.]+)/', $buffer, $matches) ) { $info['created_by_version'] = trim($matches[1]); - } elseif ('' == $old_wp_version && preg_match('/^\# WordPress Version: ([0-9]+(\.[0-9]+)+)(-[-a-z0-9]+,)?(.*)$/', $buffer, $matches)) { + } elseif ( '' == $old_wp_version && preg_match('/^\# WordPress Version: ([0-9]+(\.[0-9]+)+)(-[-a-z0-9]+,)?(.*)$/', $buffer, $matches) ) { $old_wp_version = $matches[1]; - if ( ! empty($matches[3])) { + if ( ! empty($matches[3]) ) { $old_wp_version .= substr($matches[3], 0, strlen($matches[3]) - 1); } - if (version_compare($old_wp_version, $wp_version, '>')) { + if ( version_compare($old_wp_version, $wp_version, '>') ) { // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); $warn[] = sprintf(__('You are importing from a newer version of WordPress (%1$s) into an older one (%2$s). There are no guarantees that WordPress can handle this.', 'updraftplus'), $old_wp_version, $wp_version); } - if (preg_match('/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches) && preg_match('/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches)) { + if ( preg_match('/running on PHP ([0-9]+\.[0-9]+)(\s|\.)/', $matches[4], $nmatches) && preg_match('/^([0-9]+\.[0-9]+)(\s|\.)/', PHP_VERSION, $cmatches) ) { $old_php_version = $nmatches[1]; $current_php_version = $cmatches[1]; - if (version_compare($old_php_version, $current_php_version, '>')) { + if ( version_compare($old_php_version, $current_php_version, '>') ) { // $mess[] = sprintf(__('%s version: %s', 'updraftplus'), 'WordPress', $old_wp_version); $warn[] = sprintf(__('The site in this backup was running on a webserver with version %1$s of %2$s. ', 'updraftplus'), $old_php_version, 'PHP') . ' ' . sprintf(__('This is significantly newer than the server which you are now restoring onto (version %s).', 'updraftplus'), PHP_VERSION) . ' ' . sprintf(__('You should only proceed if you cannot update the current server and are confident (or willing to risk) that your plugins/themes/etc. are compatible with the older %s version.', 'updraftplus'), 'PHP') . ' ' . sprintf(__('Any support requests to do with %s should be raised with your web hosting company.', 'updraftplus'), 'PHP'); } } - } elseif ('' == $old_table_prefix && ( preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches) )) { + } elseif ( '' == $old_table_prefix && ( preg_match('/^\# Table prefix: (\S+)$/', $buffer, $matches) || preg_match('/^-- Table prefix: (\S+)$/i', $buffer, $matches) ) ) { $old_table_prefix = $matches[1]; // echo ''.__('Old table prefix:', 'updraftplus').' '.htmlspecialchars($old_table_prefix).'
'; - } elseif (empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches)) { + } elseif ( empty($info['label']) && preg_match('/^\# Label: (.*)$/', $buffer, $matches) ) { $info['label'] = $matches[1]; $mess[] = __('Backup label:', 'updraftplus') . ' ' . htmlspecialchars($info['label']); - } elseif ($gathering_siteinfo && preg_match('/^\# Site info: (\S+)$/', $buffer, $matches)) { - if ('end' == $matches[1]) { + } elseif ( $gathering_siteinfo && preg_match('/^\# Site info: (\S+)$/', $buffer, $matches) ) { + if ( 'end' == $matches[1] ) { $gathering_siteinfo = false; // Sanity checks - if (isset($old_siteinfo['multisite']) && ! $old_siteinfo['multisite'] && is_multisite()) { + if ( isset($old_siteinfo['multisite']) && ! $old_siteinfo['multisite'] && is_multisite() ) { // Just need to check that you're crazy // if (!defined('UPDRAFTPLUS_EXPERIMENTAL_IMPORTINTOMULTISITE') || !UPDRAFTPLUS_EXPERIMENTAL_IMPORTINTOMULTISITE) { // $err[] = sprintf(__('Error: %s', 'updraftplus'), __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus')); @@ -2809,165 +2807,164 @@ class MainWP_Child_Updraft_Plus_Backups { $warn[] = __('You are running on WordPress multisite - but your backup is not of a multisite site.', 'updraftplus') . ' ' . __('It will be imported as a new site.', 'updraftplus') . ' ' . __('Please read this link for important information on this process.', 'updraftplus') . ''; // } // Got the needed code? - if ( ! class_exists('UpdraftPlusAddOn_MultiSite') || ! class_exists('UpdraftPlus_Addons_Migrator')) { + if ( ! class_exists('UpdraftPlusAddOn_MultiSite') || ! class_exists('UpdraftPlus_Addons_Migrator') ) { $err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('To import an ordinary WordPress site into a multisite installation requires %s.', 'updraftplus'), 'UpdraftPlus Premium')); return array( $mess, $warn, $err, $info ); } - } elseif (isset($old_siteinfo['multisite']) && $old_siteinfo['multisite'] && ! is_multisite()) { + } elseif ( isset($old_siteinfo['multisite']) && $old_siteinfo['multisite'] && ! is_multisite() ) { $warn[] = __('Warning:', 'updraftplus') . ' ' . __('Your backup is of a WordPress multisite install; but this site is not. Only the first site of the network will be accessible.', 'updraftplus') . ' ' . __('If you want to restore a multisite backup, you should first set up your WordPress installation as a multisite.', 'updraftplus') . ''; } - } elseif (preg_match('/^([^=]+)=(.*)$/', $matches[1], $kvmatches)) { + } elseif ( preg_match('/^([^=]+)=(.*)$/', $matches[1], $kvmatches) ) { $key = $kvmatches[1]; $val = $kvmatches[2]; - if ('multisite' == $key) { + if ( 'multisite' == $key ) { $info['multisite'] = $val ? true : false; - if ($val) { + if ( $val ) { $mess[] = '' . __('Site information:', 'updraftplus') . ' ' . 'backup is of a WordPress Network'; } } $old_siteinfo[ $key ] = $val; } - } elseif (preg_match('/^\# Skipped tables: (.*)$/', $buffer, $matches)) { + } elseif ( preg_match('/^\# Skipped tables: (.*)$/', $buffer, $matches) ) { $skipped_tables = explode(',', $matches[1]); } - - } elseif (preg_match('/^\s*create table \`?([^\`\(]*)\`?\s*\(/i', $buffer, $matches)) { + } elseif ( preg_match('/^\s*create table \`?([^\`\(]*)\`?\s*\(/i', $buffer, $matches) ) { $table = $matches[1]; $tables_found[] = $table; - if ($old_table_prefix) { + if ( $old_table_prefix ) { // Remove prefix $table = UpdraftPlus_Manipulation_Functions::str_replace_once($old_table_prefix, '', $table); - if (in_array($table, $wanted_tables)) { + if ( in_array($table, $wanted_tables) ) { $wanted_tables = array_diff($wanted_tables, array( $table )); } } - if (';' != substr($buffer, -1, 1)) { + if ( ';' != substr($buffer, -1, 1) ) { $processing_create = true; $db_supported_charset_related_to_unsupported_collation = true; } - } elseif ($processing_create) { - if ( ! empty($db_supported_collations)) { - if (preg_match('/ COLLATE=([^\s;]+)/i', $buffer, $collate_match)) { + } elseif ( $processing_create ) { + if ( ! empty($db_supported_collations) ) { + if ( preg_match('/ COLLATE=([^\s;]+)/i', $buffer, $collate_match) ) { $db_collates_found[] = $collate_match[1]; - if ( ! isset($db_supported_collations[ $collate_match[1] ])) { + if ( ! isset($db_supported_collations[ $collate_match[1] ]) ) { $db_supported_charset_related_to_unsupported_collation = true; } } - if (preg_match('/ COLLATE ([a-zA-Z0-9._-]+),/i', $buffer, $collate_match)) { + if ( preg_match('/ COLLATE ([a-zA-Z0-9._-]+),/i', $buffer, $collate_match) ) { $db_collates_found[] = $collate_match[1]; - if ( ! isset($db_supported_collations[ $collate_match[1] ])) { + if ( ! isset($db_supported_collations[ $collate_match[1] ]) ) { $db_supported_charset_related_to_unsupported_collation = true; } } - if (preg_match('/ COLLATE ([a-zA-Z0-9._-]+) /i', $buffer, $collate_match)) { + if ( preg_match('/ COLLATE ([a-zA-Z0-9._-]+) /i', $buffer, $collate_match) ) { $db_collates_found[] = $collate_match[1]; - if ( ! isset($db_supported_collations[ $collate_match[1] ])) { + if ( ! isset($db_supported_collations[ $collate_match[1] ]) ) { $db_supported_charset_related_to_unsupported_collation = true; } } } - if ( ! empty($db_supported_character_sets)) { - if (preg_match('/ CHARSET=([^\s;]+)/i', $buffer, $charset_match)) { + if ( ! empty($db_supported_character_sets) ) { + if ( preg_match('/ CHARSET=([^\s;]+)/i', $buffer, $charset_match) ) { $db_charsets_found[] = $charset_match[1]; - if ($db_supported_charset_related_to_unsupported_collation && ! in_array($charset_match[1], $db_supported_charsets_related_to_unsupported_collations)) { + if ( $db_supported_charset_related_to_unsupported_collation && ! in_array($charset_match[1], $db_supported_charsets_related_to_unsupported_collations) ) { $db_supported_charsets_related_to_unsupported_collations[] = $charset_match[1]; } } } - if (';' == substr($buffer, -1, 1)) { + if ( ';' == substr($buffer, -1, 1) ) { $processing_create = false; $db_supported_charset_related_to_unsupported_collation = false; } static $mysql_version_warned = false; - if ( ! $mysql_version_warned && version_compare($db_version, '5.2.0', '<') && preg_match('/(CHARSET|COLLATE)[= ]utf8mb4/', $buffer)) { + if ( ! $mysql_version_warned && version_compare($db_version, '5.2.0', '<') && preg_match('/(CHARSET|COLLATE)[= ]utf8mb4/', $buffer) ) { $mysql_version_warned = true; $err[] = sprintf(__('Error: %s', 'updraftplus'), sprintf(__('The database backup uses MySQL features not available in the old MySQL version (%s) that this site is running on.', 'updraftplus'), $db_version) . ' ' . __('You must upgrade MySQL to be able to use this database.', 'updraftplus')); } } } - if ($is_plain) { + if ( $is_plain ) { @fclose($dbhandle); } else { @gzclose($dbhandle); } - if ( ! empty($db_supported_character_sets)) { + if ( ! empty($db_supported_character_sets) ) { $db_charsets_found_unique = array_unique($db_charsets_found); $db_unsupported_charset = array(); $db_charset_forbidden = false; - foreach ($db_charsets_found_unique as $db_charset) { - if ( ! isset($db_supported_character_sets[ $db_charset ])) { + foreach ( $db_charsets_found_unique as $db_charset ) { + if ( ! isset($db_supported_character_sets[ $db_charset ]) ) { $db_unsupported_charset[] = $db_charset; $db_charset_forbidden = true; } } - if ($db_charset_forbidden) { + if ( $db_charset_forbidden ) { $db_unsupported_charset_unique = array_unique($db_unsupported_charset); $warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the character set (%s) which you are trying to import.", "The database server that this WordPress site is running on doesn't support the character sets (%s) which you are trying to import.", count($db_unsupported_charset_unique), 'updraftplus'), implode(', ', $db_unsupported_charset_unique)) . ' ' . __('You can choose another suitable character set instead and continue with the restoration at your own risk.', 'updraftplus') . ' ' . __('Go here for more information.', 'updraftplus') . '' . ' ' . __('Go here for more information.', 'updraftplus') . ''; $db_supported_character_sets = array_keys($db_supported_character_sets); $similar_type_charset = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_charset_unique, $db_supported_character_sets, true); - if (empty($similar_type_charset)) { + if ( empty($similar_type_charset) ) { $row = $GLOBALS['wpdb']->get_row('show variables like "character_set_database"'); $similar_type_charset = ( null !== $row ) ? $row->Value : ''; } - if (empty($similar_type_charset) && ! empty($db_supported_character_sets[0])) { + if ( empty($similar_type_charset) && ! empty($db_supported_character_sets[0]) ) { $similar_type_charset = $db_supported_character_sets[0]; } $charset_select_html = ' '; $charset_select_html .= ''; - if (empty($info['addui'])) { + if ( empty($info['addui']) ) { $info['addui'] = ''; } $info['addui'] .= $charset_select_html; } } - if ( ! empty($db_supported_collations)) { + if ( ! empty($db_supported_collations) ) { $db_collates_found_unique = array_unique($db_collates_found); $db_unsupported_collate = array(); $db_collate_forbidden = false; - foreach ($db_collates_found_unique as $db_collate) { - if ( ! isset($db_supported_collations[ $db_collate ])) { + foreach ( $db_collates_found_unique as $db_collate ) { + if ( ! isset($db_supported_collations[ $db_collate ]) ) { $db_unsupported_collate[] = $db_collate; $db_collate_forbidden = true; } } - if ($db_collate_forbidden) { + if ( $db_collate_forbidden ) { $db_unsupported_collate_unique = array_unique($db_unsupported_collate); $warn[] = sprintf(_n("The database server that this WordPress site is running on doesn't support the collation (%s) used in the database which you are trying to import.", "The database server that this WordPress site is running on doesn't support multiple collations (%s) used in the database which you are trying to import.", count($db_unsupported_collate_unique), 'updraftplus'), implode(', ', $db_unsupported_collate_unique)) . ' ' . __('You can choose another suitable collation instead and continue with the restoration (at your own risk).', 'updraftplus'); $similar_type_collate = ''; - if ($db_charset_forbidden && ! empty($similar_type_charset)) { + if ( $db_charset_forbidden && ! empty($similar_type_charset) ) { $similar_type_collate = $updraftplus->get_similar_collate_related_to_charset($db_supported_collations, $db_unsupported_collate_unique, $similar_type_charset); } - if (empty($similar_type_collate) && ! empty($db_supported_charsets_related_to_unsupported_collations)) { + if ( empty($similar_type_collate) && ! empty($db_supported_charsets_related_to_unsupported_collations) ) { $db_supported_collations_related_to_charset = array(); - foreach ($db_supported_collations as $db_supported_collation => $db_supported_collations_info_obj) { - if (isset($db_supported_collations_info_obj->Charset) && in_array($db_supported_collations_info_obj->Charset, $db_supported_charsets_related_to_unsupported_collations)) { + foreach ( $db_supported_collations as $db_supported_collation => $db_supported_collations_info_obj ) { + if ( isset($db_supported_collations_info_obj->Charset) && in_array($db_supported_collations_info_obj->Charset, $db_supported_charsets_related_to_unsupported_collations) ) { $db_supported_collations_related_to_charset[] = $db_supported_collation; } } - if ( ! empty($db_supported_collations_related_to_charset)) { + if ( ! empty($db_supported_collations_related_to_charset) ) { $similar_type_collate = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_collate_unique, $db_supported_collations_related_to_charset, false); } } - if (empty($similar_type_collate)) { + if ( empty($similar_type_collate) ) { $similar_type_collate = $updraftplus->get_similar_collate_based_on_ocuurence_count($db_collates_found, $db_supported_collations, $db_supported_charsets_related_to_unsupported_collations); } - if (empty($similar_type_collate)) { + if ( empty($similar_type_collate) ) { $similar_type_collate = UpdraftPlus_Manipulation_Functions::get_matching_str_from_array_elems($db_unsupported_collate_unique, array_keys($db_supported_collations), false); } $collate_select_html = ''; $collate_select_html .= '", ); - } elseif ($cacheType == 'php') { + } elseif ( $cacheType == 'php' ) { wfConfig::set('cacheType', 'php'); return array( 'ok' => 1, 'heading' => 'Wordfence Basic Caching Enabled', 'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.

", ); - } elseif ($cacheType == 'falcon') { - if ($noEditHtaccess != '1') { + } elseif ( $cacheType == 'falcon' ) { + if ( $noEditHtaccess != '1' ) { $err = wfCache::addHtaccessCode('add'); - if ($err) { + if ( $err ) { return array( 'ok' => 1, 'heading' => 'Wordfence could not edit .htaccess', @@ -2172,18 +2170,18 @@ SQL } public static function checkFalconHtaccess() { - if (wfUtils::isNginx()) { + if ( wfUtils::isNginx() ) { return array( 'nginx' => 1 ); } $file = wfCache::getHtaccessPath(); - if ( ! $file) { + if ( ! $file ) { return array( 'err' => 'We could not find your .htaccess file to modify it.', 'code' => wfCache::getHtaccessCode(), ); } $fh = @fopen($file, 'r+'); - if ( ! $fh) { + if ( ! $fh ) { $err = error_get_last(); return array( 'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'], @@ -2198,15 +2196,15 @@ SQL } public static function checkHtaccess() { - if (wfUtils::isNginx()) { + if ( wfUtils::isNginx() ) { return array( 'nginx' => 1 ); } $file = wfCache::getHtaccessPath(); - if ( ! $file) { + if ( ! $file ) { return array( 'err' => 'We could not find your .htaccess file to modify it.' ); } $fh = @fopen($file, 'r+'); - if ( ! $fh) { + if ( ! $fh ) { $err = error_get_last(); return array( 'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'] ); } @@ -2236,15 +2234,15 @@ SQL public static function saveCacheOptions() { $changed = false; - if ($_POST['allowHTTPSCaching'] != wfConfig::get('allowHTTPSCaching', false)) { + if ( $_POST['allowHTTPSCaching'] != wfConfig::get('allowHTTPSCaching', false) ) { $changed = true; } wfConfig::set('allowHTTPSCaching', $_POST['allowHTTPSCaching'] == '1' ? 1 : 0); // wfConfig::set('addCacheComment', $_POST['addCacheComment'] == 1 ? '1' : 0); wfConfig::set('clearCacheSched', $_POST['clearCacheSched'] == 1 ? '1' : 0); - if ($changed && wfConfig::get('cacheType', false) == 'falcon') { + if ( $changed && wfConfig::get('cacheType', false) == 'falcon' ) { $err = wfCache::addHtaccessCode('add'); - if ($err) { + if ( $err ) { return array( 'updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err, 'code' => wfCache::getHtaccessCode(), @@ -2257,7 +2255,7 @@ SQL public static function clearPageCache() { $stats = wfCache::clearPageCache(); - if ($stats['error']) { + if ( $stats['error'] ) { $body = 'A total of ' . $stats['totalErrors'] . ' errors occurred while trying to clear your cache. The last error was: ' . $stats['error']; return array( 'ok' => 1, @@ -2266,7 +2264,7 @@ SQL ); } $body = 'A total of ' . $stats['filesDeleted'] . ' files were deleted and ' . $stats['dirsDeleted'] . ' directories were removed. We cleared a total of ' . $stats['totalData'] . 'KB of data in the cache.'; - if ($stats['totalErrors'] > 0) { + if ( $stats['totalErrors'] > 0 ) { $body .= ' A total of ' . $stats['totalErrors'] . ' errors were encountered. This probably means that we could not remove some of the files or directories in the cache. Please use your CPanel or file manager to remove the rest of the files in the directory: ' . WP_CONTENT_DIR . '/wfcache/'; } return array( @@ -2278,7 +2276,7 @@ SQL public static function getCacheStats() { $s = wfCache::getCacheStats(); - if ($s['files'] == 0) { + if ( $s['files'] == 0 ) { return array( 'ok' => 1, 'heading' => 'Cache Stats', @@ -2288,26 +2286,26 @@ SQL $body = 'Total files in cache: ' . $s['files'] . '
Total directories in cache: ' . $s['dirs'] . '
Total data: ' . $s['data'] . 'KB'; - if ($s['compressedFiles'] > 0) { + if ( $s['compressedFiles'] > 0 ) { $body .= '
Files: ' . $s['uncompressedFiles'] . '
Data: ' . $s['uncompressedKBytes'] . 'KB' . '
Compressed files: ' . $s['compressedFiles'] . '
Compressed data: ' . $s['compressedKBytes'] . 'KB'; } - if ($s['largestFile'] > 0) { + if ( $s['largestFile'] > 0 ) { $body .= '
Largest file: ' . $s['largestFile'] . 'KB'; } - if ($s['oldestFile'] !== false) { + if ( $s['oldestFile'] !== false ) { $body .= '
Oldest file in cache created '; - if (time() - $s['oldestFile'] < 300) { + if ( time() - $s['oldestFile'] < 300 ) { $body .= ( time() - $s['oldestFile'] ) . ' seconds ago'; } else { $body .= human_time_diff($s['oldestFile']) . ' ago.'; } } - if ($s['newestFile'] !== false) { + if ( $s['newestFile'] !== false ) { $body .= '
Newest file in cache created '; - if (time() - $s['newestFile'] < 300) { + if ( time() - $s['newestFile'] < 300 ) { $body .= ( time() - $s['newestFile'] ) . ' seconds ago'; } else { $body .= human_time_diff($s['newestFile']) . ' ago.'; @@ -2323,12 +2321,12 @@ SQL public static function addCacheExclusion() { $ex = wfConfig::get('cacheExclusions', false); - if ($ex) { + if ( $ex ) { $ex = unserialize($ex); } else { $ex = array(); } - if (isset($_POST['cacheExclusions'])) { + if ( isset($_POST['cacheExclusions']) ) { $ex = $_POST['cacheExclusions']; } else { $ex[] = array( @@ -2339,8 +2337,8 @@ SQL } wfConfig::set('cacheExclusions', serialize($ex)); wfCache::scheduleCacheClear(); - if (wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType'])) { - if (wfCache::addHtaccessCode('add')) { // rewrites htaccess rules + if ( wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType']) ) { + if ( wfCache::addHtaccessCode('add') ) { // rewrites htaccess rules return array( 'errorMsg' => 'We added the rule you requested but could not modify your .htaccess file. Please delete this rule, check the permissions on your .htaccess file and then try again.', 'ex' => $ex, @@ -2355,7 +2353,7 @@ SQL public static function loadCacheExclusions() { $ex = wfConfig::get('cacheExclusions', false); - if ( ! $ex) { + if ( ! $ex ) { return array( 'ex' => false ); } $ex = unserialize($ex); @@ -2368,15 +2366,15 @@ SQL public static function removeCacheExclusion() { $id = $_POST['id']; $ex = wfConfig::get('cacheExclusions', false); - if ( ! $ex) { + if ( ! $ex ) { return array( 'ok' => 1 ); } $ex = unserialize($ex); $rewriteHtaccess = false; $removed = false; - for ($i = 0; $i < sizeof($ex); $i++) { - if ( (string) $ex[ $i ]['id'] == (string) $id) { - if (wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[ $i ]['pt'])) { + for ( $i = 0; $i < sizeof($ex); $i++ ) { + if ( (string) $ex[ $i ]['id'] == (string) $id ) { + if ( wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $ex[ $i ]['pt']) ) { $rewriteHtaccess = true; } array_splice($ex, $i, 1); @@ -2385,13 +2383,13 @@ SQL } } $return = array( 'ex' => $ex ); - if ( ! $removed) { + if ( ! $removed ) { $return['error'] = 'Not found the cache exclusion.'; return $return; } wfConfig::set('cacheExclusions', serialize($ex)); - if ($rewriteHtaccess && wfCache::addHtaccessCode('add')) { // rewrites htaccess rules + if ( $rewriteHtaccess && wfCache::addHtaccessCode('add') ) { // rewrites htaccess rules $return['errorMsg'] = "We removed that rule but could not rewrite your .htaccess file. You're going to have to manually remove this rule from your .htaccess file. Please reload this page now."; return $return; } @@ -2421,17 +2419,17 @@ SQL
getResults() as $title => $tests) : + foreach ( $diagnostic->getResults() as $title => $tests ) : $key = sanitize_key('wf-diagnostics-' . $title); $hasFailingTest = false; - foreach ($tests['results'] as $result) { - if ( ! $result['test']) { + foreach ( $tests['results'] as $result ) { + if ( ! $result['test'] ) { $hasFailingTest = true; break; } } - if ($inEmail) : + if ( $inEmail ) : ?> @@ -2440,7 +2438,7 @@ SQL - + - + - + @@ -2779,18 +2777,18 @@ SQL ), ); - foreach ($wordPressValues as $settingName => $settingData) : + foreach ( $wordPressValues as $settingName => $settingData ) : $escapedName = esc_html($settingName); $escapedDescription = ''; $escapedValue = '(not set)'; - if (is_array($settingData)) { + if ( is_array($settingData) ) { $escapedDescription = esc_html($settingData['description']); - if (isset($settingData['value'])) { + if ( isset($settingData['value']) ) { $escapedValue = esc_html($settingData['value']); } } else { $escapedDescription = esc_html($settingData); - if (defined($settingName)) { + if ( defined($settingName) ) { $escapedValue = esc_html(constant($settingName)); } } @@ -2821,17 +2819,17 @@ SQL
@@ -2454,7 +2452,7 @@ SQL ?> - +
@@ -2484,7 +2482,7 @@ SQL
    - +
  • @@ -2497,7 +2495,7 @@ SQL )) ?>
    - +
    @@ -2514,13 +2512,13 @@ SQL $howGet = wfConfig::get('howGetIPs', false); list($currentIP, $currentServerVarForIP) = wfUtils::getIPAndServerVariable(); $howGetHasErrors = false; - foreach (array( + foreach ( array( 'REMOTE_ADDR' => 'REMOTE_ADDR', 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', 'HTTP_X_REAL_IP' => 'X-Real-IP', 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', - ) as $variable => $label) { - if ( ! ( $currentServerVarForIP && $currentServerVarForIP === $variable ) && $howGet === $variable) { + ) as $variable => $label ) { + if ( ! ( $currentServerVarForIP && $currentServerVarForIP === $variable ) && $howGet === $variable ) { $howGetHasErrors = true; break; } @@ -2552,37 +2550,37 @@ SQL 'REMOTE_ADDR', 'HTTP_CF_CONNECTING_IP' => 'CF-Connecting-IP', 'HTTP_X_REAL_IP' => 'X-Real-IP', 'HTTP_X_FORWARDED_FOR' => 'X-Forwarded-For', - ) as $variable => $label) : + ) as $variable => $label ) : ?>
$i) { - foreach ($trustedProxies as $proxy) { - if ( ! empty($proxy)) { - if (wfUtils::subnetContainsIP($proxy, $i) && $index < count($items) - 1) { + foreach ( $items as $index => $i ) { + foreach ( $trustedProxies as $proxy ) { + if ( ! empty($proxy) ) { + if ( wfUtils::subnetContainsIP($proxy, $i) && $index < count($items) - 1 ) { $output = esc_html($i) . ', ' . $output; continue 2; } } } - if ( ! $markedSelectedAddress) { + if ( ! $markedSelectedAddress ) { $output = '' . esc_html($i) . ', ' . $output; $markedSelectedAddress = true; } else { @@ -2597,9 +2595,9 @@ SQL } ?> In use Configured, but not valid
> - $pluginData) : ?> + $pluginData ) : ?> - + - + @@ -2856,13 +2854,13 @@ SQL
- + - Version Network Activated Active Inactive
> - + - $pluginData) : ?> + $pluginData ) : ?> @@ -2895,14 +2893,14 @@ SQL
- + - Version
> - + - $themeData) : ?> + $themeData ) : ?> - get_stylesheet()) : ?> + get_stylesheet() ) : ?> @@ -2939,10 +2937,10 @@ SQL $values) { - if (is_array($values)) { - foreach ($values as $cron_job => $v) { - if (is_numeric($timestamp)) { + foreach ( $cron as $timestamp => $values ) { + if ( is_array($values) ) { + foreach ( $values as $cron_job => $v ) { + if ( is_numeric($timestamp) ) { ?> @@ -2965,12 +2963,12 @@ SQL // This must be done this way because MySQL with InnoDB tables does a full regeneration of all metadata if we don't. That takes a long time with a large table count. $tables = $wfdb->querySelect('SELECT SQL_CALC_FOUND_ROWS TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() ORDER BY TABLE_NAME ASC LIMIT 250'); $total = $wfdb->querySingle('SELECT FOUND_ROWS()'); - foreach ($tables as &$t) { + foreach ( $tables as &$t ) { $t = "'" . esc_sql($t['TABLE_NAME']) . "'"; } unset($t); $q = $wfdb->querySelect('SHOW TABLE STATUS WHERE Name IN (' . implode(',', $tables) . ')'); - if ($q) : + if ( $q ) : $databaseCols = count($q[0]); ?>
@@ -2993,7 +2991,7 @@ SQL $val = wfUtils::array_first($q); ?>
- $tval) : ?> + $tval ) : ?> @@ -3001,16 +2999,16 @@ SQL - $tval) : ?> + $tval ) : ?> = 250) { + if ( $count >= 250 ) { ?> @@ -3052,14 +3050,14 @@ SQL $readable) : + foreach ( $errorLogs as $log => $readable ) : ?> @@ -3147,8 +3145,8 @@ SQL public static function save_debugging_config() { $settings = $_POST['settings']; - foreach (self::$diagnosticParams as $param) { - if (isset($settings[ $param ])) { + foreach ( self::$diagnosticParams as $param ) { + if ( isset($settings[ $param ]) ) { wfConfig::set( $param, $settings[ $param ] ); } } diff --git a/class/class-mainwp-child-wp-rocket.php b/class/class-mainwp-child-wp-rocket.php index f0bf896..4858664 100644 --- a/class/class-mainwp-child-wp-rocket.php +++ b/class/class-mainwp-child-wp-rocket.php @@ -140,7 +140,7 @@ class MainWP_Child_WP_Rocket { try { $data = array( 'rocket_boxes' => get_user_meta( $GLOBALS['current_user']->ID, 'rocket_boxes', true ) ); $information['syncWPRocketData'] = $data; - } catch (Exception $e) { + } catch ( Exception $e ) { } } return $information; @@ -192,7 +192,7 @@ class MainWP_Child_WP_Rocket { return $value; } - if ( ! MainWP_Helper::is_screen_with_update()) { + if ( ! MainWP_Helper::is_screen_with_update() ) { return $value; } @@ -286,7 +286,7 @@ class MainWP_Child_WP_Rocket { $information = $this->do_admin_post_rocket_purge_opcache(); break; } - } catch (Exception $e) { + } catch ( Exception $e ) { $information = array( 'error' => $e->getMessage() ); } } @@ -331,11 +331,11 @@ class MainWP_Child_WP_Rocket { rocket_clean_minify(); // Remove cache busting files. - if ( function_exists( 'rocket_clean_cache_busting' )) { + if ( function_exists( 'rocket_clean_cache_busting' ) ) { rocket_clean_cache_busting(); } - if ( ! function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH')) { + if ( ! function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH') ) { require_once WP_ROCKET_ADMIN_PATH . 'admin.php'; } @@ -413,7 +413,7 @@ class MainWP_Child_WP_Rocket { update_option( WP_ROCKET_SLUG, $options ); - if (isset($_POST['do_database_optimization']) && ! empty($_POST['do_database_optimization'])) { + if ( isset($_POST['do_database_optimization']) && ! empty($_POST['do_database_optimization']) ) { $this->optimize_database(); } diff --git a/class/class-mainwp-child-wpvivid-backuprestore.php b/class/class-mainwp-child-wpvivid-backuprestore.php index 0a3dc8d..d8047cc 100644 --- a/class/class-mainwp-child-wpvivid-backuprestore.php +++ b/class/class-mainwp-child-wpvivid-backuprestore.php @@ -15,11 +15,11 @@ class MainWP_Child_WPvivid_BackupRestore { public function __construct() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; - if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR')) { + if ( is_plugin_active( 'wpvivid-backuprestore/wpvivid-backuprestore.php' ) && defined('WPVIVID_PLUGIN_DIR') ) { $this->is_plugin_installed = true; } - if ( ! $this->is_plugin_installed) { + if ( ! $this->is_plugin_installed ) { return; } @@ -33,7 +33,7 @@ class MainWP_Child_WPvivid_BackupRestore { function syncOthersData( $information, $data = array() ) { try { - if ( isset( $data['syncWPvividData'] )) { + if ( isset( $data['syncWPvividData'] ) ) { $information['syncWPvividData'] = 1; $data = WPvivid_Setting::get_sync_data(); $information['syncWPvividSettingData'] = $data['setting']; @@ -41,8 +41,7 @@ class MainWP_Child_WPvivid_BackupRestore { $information['syncWPvividScheduleData'] = $data['schedule']; $information['syncWPvividSetting'] = $data; } - - } catch (Exception $e) { + } catch ( Exception $e ) { } @@ -58,7 +57,7 @@ class MainWP_Child_WPvivid_BackupRestore { if ( isset( $_POST['mwp_action'] ) ) { try { - switch ($_POST['mwp_action']) { + switch ( $_POST['mwp_action'] ) { case 'prepare_backup': $information = $this->prepare_backup(); break; @@ -123,7 +122,7 @@ class MainWP_Child_WPvivid_BackupRestore { $information = $this->post_mainwp_data($_POST); break; } - } catch (Exception $e) { + } catch ( Exception $e ) { $information = array( 'error' => $e->getMessage() ); } @@ -131,7 +130,7 @@ class MainWP_Child_WPvivid_BackupRestore { } } - public function post_mainwp_data( $data) { + public function post_mainwp_data( $data ) { global $wpvivid_plugin; $ret = $wpvivid_plugin->wpvivid_handle_mainwp_action($data); diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php index f9ce8bf..b4dad79 100644 --- a/class/class-mainwp-clone-install.php +++ b/class/class-mainwp-clone-install.php @@ -673,7 +673,7 @@ class MainWP_Clone_Install { $data = $_tmp; unset( $_tmp ); - } elseif (is_serialized_string($data) && is_serialized($data)) { + } elseif ( is_serialized_string($data) && is_serialized($data) ) { // TODO: apply solution like phpmyadmin project have! if ( ( $data = @unserialize( $data ) ) !== false ) { $data = str_replace( $from, $to, $data ); diff --git a/class/class-mainwp-clone.php b/class/class-mainwp-clone.php index 07c9760..ee48063 100644 --- a/class/class-mainwp-clone.php +++ b/class/class-mainwp-clone.php @@ -518,7 +518,7 @@ class MainWP_Clone { var child_security_nonces = []; getSecurityNonces(); - foreach ($security_nonces as $k => $v) { + foreach ( $security_nonces as $k => $v ) { echo 'child_security_nonces[' . "'" . $k . "'" . '] = ' . "'" . $v . "';\n"; } ?> diff --git a/class/class-mainwp-custom-post-type.php b/class/class-mainwp-custom-post-type.php index 9c2f488..ea64a23 100755 --- a/class/class-mainwp-custom-post-type.php +++ b/class/class-mainwp-custom-post-type.php @@ -69,9 +69,9 @@ class MainWP_Custom_Post_Type { } $edit_id = ( isset($_POST['post_id']) && ! empty($_POST['post_id']) ) ? $_POST['post_id'] : 0; $return = $this->_insert_post($data, $edit_id, $parent_id = 0); - if (isset($return['success']) && $return['success'] == 1) { - if (isset($data['product_variation']) && is_array($data['product_variation'])) { - foreach ($data['product_variation'] as $product_variation) { + if ( isset($return['success']) && $return['success'] == 1 ) { + 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']); } } @@ -84,7 +84,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 ) { @@ -215,7 +215,7 @@ class MainWP_Custom_Post_Type { $data_insert['post_content'] = $this->_search_images( $data_insert['post_content'], $data['extras']['upload_dir'], $check_image_existed ); - if ( ! empty($parent_id)) { + if ( ! empty($parent_id) ) { $data_insert['post_parent'] = $parent_id; // for product variation } $post_id = wp_insert_post( $data_insert, true ); diff --git a/class/class-mainwp-debug.php b/class/class-mainwp-debug.php index bb963b8..8fa1904 100644 --- a/class/class-mainwp-debug.php +++ b/class/class-mainwp-debug.php @@ -4,7 +4,7 @@ class MainWP_Debug { /** * @param $mainwpChild MainWP_Child */ - public static function process( &$mainwpChild) { + public static function process( &$mainwpChild ) { if ( ! isset( $_GET['mainwpdebug'] ) || ! defined( 'MAINWP_DEBUG' ) || ( MAINWP_DEBUG !== true ) ) { return; } diff --git a/class/class-mainwp-keyword-links.php b/class/class-mainwp-keyword-links.php index 24136b1..0541522 100644 --- a/class/class-mainwp-keyword-links.php +++ b/class/class-mainwp-keyword-links.php @@ -387,7 +387,7 @@ class MainWP_Keyword_Links { return $content; } - private function usort_callback_func( $a, $b) { + private function usort_callback_func( $a, $b ) { return strlen($a) < strlen($b); } diff --git a/class/class-mainwp-wordpress-seo.php b/class/class-mainwp-wordpress-seo.php index cf667b0..73c0a7d 100644 --- a/class/class-mainwp-wordpress-seo.php +++ b/class/class-mainwp-wordpress-seo.php @@ -77,8 +77,7 @@ class MainWP_Wordpress_SEO { if ( file_exists( $temporary_file ) ) { unlink( $temporary_file ); } - - } elseif ( isset( $_POST['settings'] ) ) { + } elseif ( isset( $_POST['settings'] ) ) { try { $settings = base64_decode( $_POST['settings'] ); // @codingStandardsIgnoreLine @@ -104,9 +103,9 @@ class MainWP_Wordpress_SEO { } else { throw new Exception( __( 'Settings could not be imported:', 'wordpress-seo' ) ); } - } catch ( Exception $e ) { + } catch ( Exception $e ) { $information['error'] = $e->getMessage(); - } + } } MainWP_Helper::write( $information );
Version Active Inactive
and more
No log files found.