mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-08-31 03:53:15 +08:00
parent
8474ecc2a3
commit
5422bc33f3
18 changed files with 991 additions and 1037 deletions
|
@ -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 .= '<div class="row-actions"><a title="' . __( 'View Backup Log', 'mainwp-child' ) . '" href="#" serial="' . $serial . '" class="mainwp_bb_view_log_lnk thickbox">' . __( 'View Log', 'mainwp-child' ) . '</a></div>';
|
||||
}
|
||||
|
||||
} // 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' ) . ' <span class="description">(hover for options)</span>',
|
||||
);
|
||||
|
||||
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 '</pre>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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( '<h3>' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '</h3><p class="description" style="max-width: 700px; display: inline-block;">' . __( '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' ) . '</p>', false, '', 'backupbuddy_live_snapshot_verify_uptodate' );
|
||||
$message = '<h3>' . __( 'Verifying everything is up to date before Snapshot', 'it-l10n-backupbuddy' ) . '</h3><p class="description" style="max-width: 700px; display: inline-block;">' . __( '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' ) . '</p>';
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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( '(<code title="' . __( 'Backups will be compressed and should be smaller than this.', 'mainwp-backupwordpress-extension' ) . '">%s</code>)', esc_attr( $schedule->get_formatted_site_size() ) );
|
||||
}
|
||||
|
@ -533,7 +532,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
<td>
|
||||
|
||||
<?php
|
||||
if (function_exists('hmbkp_is_path_accessible')) {
|
||||
if ( function_exists('hmbkp_is_path_accessible') ) {
|
||||
if ( hmbkp_is_path_accessible( hmbkp_path() ) ) {
|
||||
?>
|
||||
<a href="#"
|
||||
|
@ -541,8 +540,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
class="download-action"><?php esc_html_e( 'Download', 'backupwordpress' ); ?></a> |
|
||||
<?php
|
||||
};
|
||||
} elseif (function_exists('HM\BackUpWordPress\is_path_accessible') ) {
|
||||
if (HM\BackUpWordPress\is_path_accessible(HM\BackUpWordPress\Path::get_path())) {
|
||||
} elseif ( function_exists('HM\BackUpWordPress\is_path_accessible') ) {
|
||||
if ( HM\BackUpWordPress\is_path_accessible(HM\BackUpWordPress\Path::get_path()) ) {
|
||||
?>
|
||||
<a href="#"
|
||||
onclick="event.preventDefault(); mainwp_backupwp_download_backup('<?php echo $encoded_file; ?>', <?php echo esc_attr( $schedule->get_id() ); ?>, this);"
|
||||
|
@ -569,7 +568,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
$schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( urldecode( $schedule_id ) ) );
|
||||
|
||||
$new_version = true;
|
||||
if (method_exists($schedule, 'get_running_backup_filename' )) {
|
||||
if ( method_exists($schedule, 'get_running_backup_filename' ) ) {
|
||||
$new_version = false;
|
||||
$user_excludes = array_diff( $schedule->get_excludes(), $schedule->backup->default_excludes() );
|
||||
$root_dir = $schedule->backup->get_root();
|
||||
|
@ -626,7 +625,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<td>
|
||||
<?php
|
||||
if ($new_version) {
|
||||
if ( $new_version ) {
|
||||
$is_default_rule = ( in_array( $exclude, $excludes->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 {
|
|||
|
||||
<td>
|
||||
<?php
|
||||
if ($new_version) {
|
||||
if ( $new_version ) {
|
||||
if ( $is_unreadable ) {
|
||||
?>
|
||||
|
||||
|
@ -910,7 +908,7 @@ class MainWP_Child_Back_Up_Wordpress {
|
|||
|
||||
<?php
|
||||
else :
|
||||
if ($new_version) {
|
||||
if ( $new_version ) {
|
||||
$size = $site_size->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;
|
||||
}
|
||||
|
|
|
@ -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 <i>%s</i> saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' <a href="' . network_admin_url( 'admin.php' ) . '?page=backwpupjobs">' . __( 'Jobs overview', 'backwpup' ) . '</a> | <a href="' . $url['url'] . '">' . __( 'Run now', 'backwpup' ) . '</a>' );
|
||||
}
|
||||
} 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 {
|
||||
|
|
|
@ -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 .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\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') {
|
||||
<?php
|
||||
// hide update notice row
|
||||
if (in_array('mainwp-child/mainwp-child.php', $hide_slugs)) {
|
||||
if ( in_array('mainwp-child/mainwp-child.php', $hide_slugs) ) {
|
||||
?>
|
||||
var el = document.querySelector('tr#mainwp-child-update');
|
||||
if (typeof(el) !== 'undefined' && el !== null) {
|
||||
|
@ -1095,7 +1095,7 @@ class MainWP_Child_Branding {
|
|||
<?php
|
||||
}
|
||||
// hide update notice row
|
||||
if (in_array('mainwp-child-reports/mainwp-child-reports.php', $hide_slugs)) {
|
||||
if ( in_array('mainwp-child-reports/mainwp-child-reports.php', $hide_slugs) ) {
|
||||
?>
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <strong>WordPress permalinks</strong> 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( '<p>' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . '</p>' );
|
||||
}
|
||||
}
|
||||
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 <code>%1$s</code>.', '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 . '<br />';
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
</tr>
|
||||
<?php
|
||||
$all_plugins = get_plugins();
|
||||
foreach ( $all_plugins as $slug => $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 {
|
|||
<td><?php echo( self::filesize_compare( $currentVersion, $pVersion, $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
<?php } elseif ( $whatType == 'curlssl' ) { ?>
|
||||
<td><?php echo( self::curlssl_compare( $pVersion, $pCompare ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
<?php } elseif (( $pGetter == 'getMaxInputTime' || $pGetter == 'getMaxExecutionTime' ) && $currentVersion == -1) { ?>
|
||||
<?php } elseif ( ( $pGetter == 'getMaxInputTime' || $pGetter == 'getMaxExecutionTime' ) && $currentVersion == -1 ) { ?>
|
||||
<td><?php echo '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>'; ?></td>
|
||||
<?php } else { ?>
|
||||
<td><?php echo ( version_compare($currentVersion, $pVersion, $pCompare) || ( ( $pExtraCompare != null ) && version_compare($currentVersion, $pExtraVersion, $pExtraCompare) ) ? '<span class="mainwp-pass"><i class="fa fa-check-circle"></i> Pass</span>' : self::getWarningHTML( $errorType ) ); ?></td>
|
||||
|
@ -1065,8 +1065,8 @@ class MainWP_Child_Server_Information {
|
|||
<?php
|
||||
}
|
||||
|
||||
private static function getWarningHTML( $errorType = self::WARNING) {
|
||||
if (self::WARNING == $errorType) {
|
||||
private static function getWarningHTML( $errorType = self::WARNING ) {
|
||||
if ( self::WARNING == $errorType ) {
|
||||
return '<span class="mainwp-warning"><i class="fa fa-exclamation-circle"></i> Warning</span>';
|
||||
}
|
||||
return '<span class="mainwp-fail"><i class="fa fa-exclamation-circle"></i> Fail</span>';
|
||||
|
@ -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 {
|
|||
<table id="mainwp-table" class="wp-list-table widefat" cellspacing="0" style="border: 0">
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($details as $row) {
|
||||
foreach ( $details as $row ) {
|
||||
?>
|
||||
<tr>
|
||||
<th style="width: 20%"><strong><?php echo esc_html($row['title']); ?></strong></th>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="wptc_activity_log_load_more" action_id="' . esc_attr( $action_id ) . '" limit="' . esc_attr( $to_limit ) . '">Load more</a></td><td></td></tr>';
|
||||
}
|
||||
|
||||
|
@ -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 = '<table>';
|
||||
$detailed .= $this->get_activity_log($sub_records);
|
||||
if (isset($load_more) && $load_more) {
|
||||
if ( isset($load_more) && $load_more ) {
|
||||
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="mainwp_wptc_activity_log_load_more" action_id="' . $rec->action_id . '" limit="' . $limit . '">Load more</a></td><td></td></tr>';
|
||||
}
|
||||
$detailed .= '</table>';
|
||||
|
@ -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 .= '<td class="wptc-act-td">' . $user_tz_now . '</td><td class="wptc-act-td">' . $msg;
|
||||
if ($more_logs) {
|
||||
if ( $more_logs ) {
|
||||
$html .= "    <a class='wptc-show-more' action_id='" . round($rec->action_id) . "'>View details</a></td>";
|
||||
} else {
|
||||
$html .= '</td>';
|
||||
}
|
||||
$html .= '<td class="wptc-act-td"><a class="report_issue_wptc" id="' . $rec->id . '" href="#">Send report to plugin developer</a></td>';
|
||||
if ($more_logs) {
|
||||
if ( $more_logs ) {
|
||||
|
||||
$html .= "</tr><tr id='" . round($rec->action_id) . "' class='wptc-more-logs'><td colspan=3>" . $detailed . '</td>';
|
||||
} 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'] ) ) {
|
||||
|
|
|
@ -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'), '<a href="https://updraftplus.com/shop/migrator/">' . __('the migrator add-on', 'updraftplus') . '</a>'));
|
||||
} 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', '<a href="https://updraftplus.com/shop/migrator/">' . __('the migrator add-on', 'updraftplus') . '</a>')));
|
||||
|
@ -2748,59 +2747,58 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
$info['same_url'] = false;
|
||||
$warn[] = apply_filters('updraftplus_dbscan_urlchange', '<a href="https://updraftplus.com/shop/migrator/">' . __('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') . '</a>', $old_siteurl, $res);
|
||||
}
|
||||
if ( ! class_exists('UpdraftPlus_Addons_Migrator')) {
|
||||
if ( ! class_exists('UpdraftPlus_Addons_Migrator') ) {
|
||||
$warn[] .= '<strong><a href="' . apply_filters('updraftplus_com_link', 'https://updraftplus.com/faqs/tell-me-more-about-the-search-and-replace-site-location-in-the-database-option/') . '">' . __('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') . '</a></strong>';
|
||||
}
|
||||
}
|
||||
|
||||
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', '<a href="https://updraftplus.com/shop/migrator/">' . __('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') . '</a>', $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 '<strong>'.__('Old table prefix:', 'updraftplus').'</strong> '.htmlspecialchars($old_table_prefix).'<br>';
|
||||
} 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') . ' <a href="https://updraftplus.com/information-on-importing-a-single-site-wordpress-backup-into-a-wordpress-network-i-e-multisite/">' . __('Please read this link for important information on this process.', 'updraftplus') . '</a>';
|
||||
// }
|
||||
// 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') . ' <a href="https://codex.wordpress.org/Create_A_Network">' . __('If you want to restore a multisite backup, you should first set up your WordPress installation as a multisite.', 'updraftplus') . '</a>';
|
||||
}
|
||||
} 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[] = '<strong>' . __('Site information:', 'updraftplus') . '</strong> ' . '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') . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __('Go here for more information.', 'updraftplus') . '</a>' . ' <a target="_blank" href="https://updraftplus.com/faqs/implications-changing-tables-character-set/">' . __('Go here for more information.', 'updraftplus') . '</a>';
|
||||
$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 = '<label>' . __('Your chosen character set to use instead:', 'updraftplus') . '</label> ';
|
||||
$charset_select_html .= '<select name="updraft_restorer_charset" id="updraft_restorer_charset">';
|
||||
if (is_array($db_supported_character_sets)) {
|
||||
foreach ($db_supported_character_sets as $character_set) {
|
||||
if ( is_array($db_supported_character_sets) ) {
|
||||
foreach ( $db_supported_character_sets as $character_set ) {
|
||||
$charset_select_html .= '<option value="' . esc_attr($character_set) . '" ' . selected($character_set, $similar_type_charset, false) . '>' . esc_html($character_set) . '</option>';
|
||||
}
|
||||
}
|
||||
$charset_select_html .= '</select>';
|
||||
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 = '<label>' . __('Your chosen replacement collation', 'updraftplus') . ':</label>';
|
||||
$collate_select_html .= '<select name="updraft_restorer_collate" id="updraft_restorer_collate">';
|
||||
foreach ($db_supported_collations as $collate => $collate_info_obj) {
|
||||
foreach ( $db_supported_collations as $collate => $collate_info_obj ) {
|
||||
$option_other_attr = array();
|
||||
if ($db_charset_forbidden && isset($collate_info_obj->Charset)) {
|
||||
if ( $db_charset_forbidden && isset($collate_info_obj->Charset) ) {
|
||||
$option_other_attr[] = 'data-charset=' . esc_attr($collate_info_obj->Charset);
|
||||
if ($similar_type_charset != $collate_info_obj->Charset) {
|
||||
if ( $similar_type_charset != $collate_info_obj->Charset ) {
|
||||
$option_other_attr[] = 'style="display:none;"';
|
||||
}
|
||||
}
|
||||
|
@ -2977,7 +2974,7 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
|
||||
$info['addui'] = empty($info['addui']) ? $collate_select_html : $info['addui'] . '<br>' . $collate_select_html;
|
||||
|
||||
if ($db_charset_forbidden) {
|
||||
if ( $db_charset_forbidden ) {
|
||||
$collate_change_on_charset_selection_data = array(
|
||||
'db_supported_collations' => $db_supported_collations,
|
||||
'db_unsupported_collate_unique' => $db_unsupported_collate_unique,
|
||||
|
@ -3007,33 +3004,33 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
CREATE TABLE $wpdb->sitemeta (
|
||||
CREATE TABLE $wpdb->signups (
|
||||
*/
|
||||
if ( ! isset($skipped_tables)) {
|
||||
if ( ! isset($skipped_tables) ) {
|
||||
$skipped_tables = array();
|
||||
}
|
||||
$missing_tables = array();
|
||||
if ($old_table_prefix) {
|
||||
if ( ! $header_only) {
|
||||
foreach ($wanted_tables as $table) {
|
||||
if ( ! in_array($old_table_prefix . $table, $tables_found)) {
|
||||
if ( $old_table_prefix ) {
|
||||
if ( ! $header_only ) {
|
||||
foreach ( $wanted_tables as $table ) {
|
||||
if ( ! in_array($old_table_prefix . $table, $tables_found) ) {
|
||||
$missing_tables[] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($missing_tables as $key => $value) {
|
||||
if (in_array($old_table_prefix . $value, $skipped_tables)) {
|
||||
foreach ( $missing_tables as $key => $value ) {
|
||||
if ( in_array($old_table_prefix . $value, $skipped_tables) ) {
|
||||
unset($missing_tables[ $key ]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($missing_tables) > 0) {
|
||||
if ( count($missing_tables) > 0 ) {
|
||||
$warn[] = sprintf(__('This database backup is missing core WordPress tables: %s', 'updraftplus'), implode(', ', $missing_tables));
|
||||
}
|
||||
if (count($skipped_tables) > 0) {
|
||||
if ( count($skipped_tables) > 0 ) {
|
||||
$warn[] = sprintf(__('This database backup has the following WordPress tables excluded: %s', 'updraftplus'), implode(', ', $skipped_tables));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (empty($backup['meta_foreign'])) {
|
||||
if ( empty($backup['meta_foreign']) ) {
|
||||
$warn[] = __('UpdraftPlus was unable to find the table prefix when scanning the database backup.', 'updraftplus');
|
||||
}
|
||||
}
|
||||
|
@ -3198,14 +3195,14 @@ class MainWP_Child_Updraft_Plus_Backups {
|
|||
$date_label = $this->date_label( $pretty_date, $key, $backup, $jobdata, $non );
|
||||
|
||||
$service_title = '';
|
||||
if ( ! isset($backup['service'])) {
|
||||
if ( ! isset($backup['service']) ) {
|
||||
$backup['service'] = array();
|
||||
}
|
||||
if ( ! is_array($backup['service'])) {
|
||||
if ( ! is_array($backup['service']) ) {
|
||||
$backup['service'] = array( $backup['service'] );
|
||||
}
|
||||
foreach ($backup['service'] as $service) {
|
||||
if ('none' === $service || '' === $service || ( is_array($service) && ( empty($service) || array( 'none' ) === $service || array( '' ) === $service ) )) {
|
||||
foreach ( $backup['service'] as $service ) {
|
||||
if ( 'none' === $service || '' === $service || ( is_array($service) && ( empty($service) || array( 'none' ) === $service || array( '' ) === $service ) ) ) {
|
||||
// Do nothing
|
||||
} else {
|
||||
// $image_url = file_exists($image_folder.$service.'.png') ? $image_folder_url.$service.'.png' : $image_folder_url.'folder.png';
|
||||
|
@ -3232,9 +3229,9 @@ ENDHERE;
|
|||
|
||||
// Set a flag according to whether or not $backup['db'] ends in .crypt, then pick this up in the display of the decrypt field.
|
||||
$db = is_array( $backup['db'] ) ? $backup['db'][0] : $backup['db'];
|
||||
if ( class_exists( 'UpdraftPlus_Encryption')) {
|
||||
if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted')) {
|
||||
if (UpdraftPlus_Encryption::is_file_encrypted($db)) {
|
||||
if ( class_exists( 'UpdraftPlus_Encryption') ) {
|
||||
if ( method_exists('UpdraftPlus_Encryption', 'is_file_encrypted') ) {
|
||||
if ( UpdraftPlus_Encryption::is_file_encrypted($db) ) {
|
||||
$entities .= '/dbcrypted=1/';
|
||||
}
|
||||
}
|
||||
|
@ -3450,7 +3447,7 @@ ENDHERE;
|
|||
}
|
||||
|
||||
$fix_perfomance++;
|
||||
if ($fix_perfomance > 50) { // // to fix perfomance issue of response when too much backup files
|
||||
if ( $fix_perfomance > 50 ) { // // to fix perfomance issue of response when too much backup files
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -4030,7 +4027,7 @@ ENDHERE;
|
|||
|
||||
private function close_browser_connection( $txt = '' ) {
|
||||
|
||||
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
|
||||
if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true ) :
|
||||
$output = json_encode( $txt );
|
||||
else :
|
||||
$output = serialize( $txt );
|
||||
|
@ -4053,7 +4050,7 @@ ENDHERE;
|
|||
}
|
||||
|
||||
public function updraftplus_init() {
|
||||
if ( ! $this->is_plugin_installed) {
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4117,7 +4114,7 @@ ENDHERE;
|
|||
if ( isset( $_POST['mainwpsignature'] ) ) {
|
||||
return $value;
|
||||
}
|
||||
if ( ! MainWP_Helper::is_screen_with_update()) {
|
||||
if ( ! MainWP_Helper::is_screen_with_update() ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -4128,7 +4125,7 @@ ENDHERE;
|
|||
return $value;
|
||||
}
|
||||
|
||||
public function get_sync_data( $with_hist = false) {
|
||||
public function get_sync_data( $with_hist = false ) {
|
||||
$this->required_files();
|
||||
return $this->get_updraft_data( $with_hist );
|
||||
}
|
||||
|
|
|
@ -62,51 +62,49 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
return $information;
|
||||
}
|
||||
|
||||
function check_plugins( $force = false) {
|
||||
function check_plugins( $force = false ) {
|
||||
$result = array();
|
||||
$active_plugins = get_option('active_plugins');
|
||||
|
||||
if ( ! empty($active_plugins) ) {
|
||||
foreach ($active_plugins as $plug) {
|
||||
foreach ( $active_plugins as $plug ) {
|
||||
|
||||
$plugin_file = WP_CONTENT_DIR . '/plugins/' . $plug;
|
||||
$plugin_info = get_plugin_data($plugin_file);
|
||||
$plugin_version = isset($plugin_info['Version']) ? $plugin_info['Version'] : '';
|
||||
$string = explode('/', $plug);
|
||||
$plug_vuln = get_transient('mainwp_vulnche_trans_plug_' . $string[0]);
|
||||
if (false === $plug_vuln || $force) {
|
||||
if ( false === $plug_vuln || $force ) {
|
||||
$plug_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'plugins/' . $string[0]);
|
||||
set_transient('mainwp_vulnche_trans_plug_' . $string[0], $plug_vuln, 1 * DAY_IN_SECONDS);
|
||||
}
|
||||
if ($plug_vuln) {
|
||||
if ( $plug_vuln ) {
|
||||
$plug_vuln = json_decode($plug_vuln, true);
|
||||
$plug_vuln_filter = $plug_vuln;
|
||||
|
||||
foreach ($plug_vuln as $slug => $pl_data) {
|
||||
if (isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0) {
|
||||
foreach ( $plug_vuln as $slug => $pl_data ) {
|
||||
if ( isset($pl_data['vulnerabilities']) && count($pl_data['vulnerabilities']) > 0 ) {
|
||||
$plug_vulner_data = array();
|
||||
foreach ($pl_data['vulnerabilities'] as $vuln_data) {
|
||||
foreach ( $pl_data['vulnerabilities'] as $vuln_data ) {
|
||||
if ( isset($vuln_data['fixed_in']) && version_compare( $plugin_version, $vuln_data['fixed_in'] ) >= 0 ) {
|
||||
continue;
|
||||
}
|
||||
$plug_vulner_data[] = $vuln_data;
|
||||
}
|
||||
|
||||
if (count($plug_vulner_data) == 0) {
|
||||
if ( count($plug_vulner_data) == 0 ) {
|
||||
unset($plug_vuln_filter[ $slug ]);
|
||||
} else {
|
||||
$plug_vuln_filter[ $slug ]['vulnerabilities'] = $plug_vulner_data;
|
||||
$plug_vuln_filter[ $slug ]['detected_version'] = $plugin_version;
|
||||
$plug_vuln_filter[ $slug ]['plugin_slug'] = $plug;
|
||||
}
|
||||
|
||||
} else {
|
||||
unset($plug_vuln_filter[ $slug ]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (count($plug_vuln_filter) == 0) {
|
||||
if ( count($plug_vuln_filter) == 0 ) {
|
||||
continue;
|
||||
}
|
||||
$plug_vuln = json_encode($plug_vuln_filter);
|
||||
|
@ -120,17 +118,17 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
return $result;
|
||||
}
|
||||
|
||||
function check_wp( $force = false) {
|
||||
function check_wp( $force = false ) {
|
||||
$wp_vuln = get_transient('mainwp_vulnche_trans_wp_json');
|
||||
$wp_version = str_replace('.', '', get_bloginfo('version'));
|
||||
if (false === $wp_vuln || $force) {
|
||||
if ( false === $wp_vuln || $force ) {
|
||||
$wp_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'wordpresses/' . $wp_version);
|
||||
set_transient('mainwp_vulnche_trans_wp_json', $wp_vuln, 1 * DAY_IN_SECONDS);
|
||||
}
|
||||
return $wp_vuln;
|
||||
}
|
||||
|
||||
function check_themes( $force = false) {
|
||||
function check_themes( $force = false ) {
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/misc.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
|
@ -142,24 +140,24 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
}
|
||||
wp_reset_vars( array( 'theme', 'search' ) );
|
||||
$result = array();
|
||||
if ( ! empty($themes)) {
|
||||
foreach ($themes as $th) {
|
||||
if (empty($th['parent'])) {
|
||||
if ( ! empty($themes) ) {
|
||||
foreach ( $themes as $th ) {
|
||||
if ( empty($th['parent']) ) {
|
||||
$th_vuln = get_transient('mainwp_vulnche_trans_theme_' . $th['id']);
|
||||
if (false === $th_vuln || $force) {
|
||||
if ( false === $th_vuln || $force ) {
|
||||
$th_vuln = $this->vulnche_get_content( $this->wpvulndb_api . 'themes/' . $th['id']);
|
||||
set_transient('mainwp_vulnche_trans_theme_' . $th['id'], $th_vuln, 1 * DAY_IN_SECONDS);
|
||||
}
|
||||
|
||||
if ($th_vuln) {
|
||||
if ( $th_vuln ) {
|
||||
$th_vuln = json_decode($th_vuln, true);
|
||||
$th_vuln_filter = $th_vuln;
|
||||
foreach ($th_vuln as $slug => $th_data) {
|
||||
if (isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0) {
|
||||
foreach ( $th_vuln as $slug => $th_data ) {
|
||||
if ( isset($th_data['vulnerabilities']) && count($th_data['vulnerabilities']) > 0 ) {
|
||||
|
||||
$th_vulner_data = array();
|
||||
foreach ($th_data['vulnerabilities'] as $vuln_data) {
|
||||
if (empty($vuln_data)) {
|
||||
foreach ( $th_data['vulnerabilities'] as $vuln_data ) {
|
||||
if ( empty($vuln_data) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -170,7 +168,7 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
$th_vulner_data[] = $vuln_data;
|
||||
}
|
||||
|
||||
if (count($th_vulner_data) == 0) {
|
||||
if ( count($th_vulner_data) == 0 ) {
|
||||
unset($th_vuln_filter[ $slug ]);
|
||||
} else {
|
||||
$th_vuln_filter[ $slug ]['vulnerabilities'] = $th_vulner_data;
|
||||
|
@ -180,7 +178,7 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
}
|
||||
}
|
||||
|
||||
if (count($th_vuln_filter) == 0) {
|
||||
if ( count($th_vuln_filter) == 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -200,7 +198,7 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
}
|
||||
|
||||
|
||||
function vulnche_get_content ( $url ) {
|
||||
function vulnche_get_content( $url ) {
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
|
@ -214,14 +212,14 @@ class MainWP_Child_Vulnerability_Checker {
|
|||
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($ch);
|
||||
if ($output === false || $info != 200) {
|
||||
if ( $output === false || $info != 200 ) {
|
||||
$output = null;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
function get_random_user_agent () {
|
||||
function get_random_user_agent() {
|
||||
|
||||
$someUA = array(
|
||||
'Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.1b1) Gecko/20081007 Firefox/3.1b1',
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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);
|
||||
|
|
|
@ -4,7 +4,7 @@ if ( defined( 'MAINWP_DEBUG' ) && MAINWP_DEBUG === true ) {
|
|||
@ini_set( 'display_errors', true );
|
||||
@ini_set( 'display_startup_errors', true );
|
||||
} else {
|
||||
if (isset($_REQUEST['mainwpsignature'])) {
|
||||
if ( isset($_REQUEST['mainwpsignature']) ) {
|
||||
@ini_set( 'display_errors', false );
|
||||
@error_reporting( 0 );
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|||
// To fix verify nonce conflict #1
|
||||
// this is fake post field to fix some conflict of wp_verify_nonce()
|
||||
// just return false to unverify nonce, does not exit
|
||||
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' )) {
|
||||
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|||
// To fix verify nonce conflict #2
|
||||
// this is fake nonce to fix some conflict of wp_verify_nonce()
|
||||
// just return false to unverify nonce, does not exit
|
||||
if ($nonce == 'mainwp-bsm-unverify-nonce') {
|
||||
if ( $nonce == 'mainwp-bsm-unverify-nonce' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
|
|||
// To fix verify nonce conflict #3
|
||||
// this is fake post field to fix some conflict of wp_verify_nonce()
|
||||
// just return false to unverify nonce, does not exit
|
||||
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' )) {
|
||||
if ( isset($_POST[ $action ]) && ( $_POST[ $action ] == 'mainwp-bsm-unverify-nonce' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -211,10 +211,10 @@ class MainWP_Child {
|
|||
public function __construct( $plugin_file ) {
|
||||
$this->update();
|
||||
$this->load_all_options();
|
||||
$this->filterFunction = function( $a) {
|
||||
if ($a == null) {
|
||||
$this->filterFunction = function( $a ) {
|
||||
if ( $a == null ) {
|
||||
return false; }
|
||||
if (is_object($a) && property_exists($a, 'last_checked') && ! property_exists($a, 'checked')) {
|
||||
if ( is_object($a) && property_exists($a, 'last_checked') && ! property_exists($a, 'checked') ) {
|
||||
return false;
|
||||
}
|
||||
return $a;
|
||||
|
@ -321,7 +321,7 @@ class MainWP_Child {
|
|||
'mainwp_child_plugintheme_days_outdate',
|
||||
);
|
||||
$query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
|
||||
foreach ($options as $option) {
|
||||
foreach ( $options as $option ) {
|
||||
$query .= "'" . $option . "', ";
|
||||
}
|
||||
$query = substr($query, 0, strlen($query) - 2);
|
||||
|
@ -337,7 +337,7 @@ class MainWP_Child {
|
|||
$alloptions[ $o->option_name ] = $o->option_value;
|
||||
unset($options[ array_search($o->option_name, $options) ]);
|
||||
}
|
||||
foreach ($options as $option ) {
|
||||
foreach ( $options as $option ) {
|
||||
$notoptions[ $option ] = true;
|
||||
}
|
||||
if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
|
||||
|
@ -514,7 +514,6 @@ class MainWP_Child {
|
|||
}
|
||||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $convertBranding );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MainWP_Helper::update_option( 'mainwp_child_update_version', $this->update_version, 'yes' );
|
||||
|
@ -570,7 +569,7 @@ class MainWP_Child {
|
|||
|
||||
public function detect_premium_themesplugins_updates() {
|
||||
|
||||
if (isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] == 'yes') {
|
||||
if ( isset($_GET['_detect_plugins_updates']) && $_GET['_detect_plugins_updates'] == 'yes' ) {
|
||||
// to fix some premium plugins update notification
|
||||
$current = get_site_transient( 'update_plugins' );
|
||||
set_site_transient( 'update_plugins', $current );
|
||||
|
@ -584,7 +583,7 @@ class MainWP_Child {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_GET['_detect_themes_updates']) && $_GET['_detect_themes_updates'] == 'yes') {
|
||||
if ( isset($_GET['_detect_themes_updates']) && $_GET['_detect_themes_updates'] == 'yes' ) {
|
||||
add_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
|
||||
$themes = get_theme_updates();
|
||||
remove_filter( 'pre_site_transient_update_themes', $this->filterFunction, 99 );
|
||||
|
@ -603,7 +602,7 @@ class MainWP_Child {
|
|||
$_POST['list'] = $list;
|
||||
|
||||
$function = 'upgradeplugintheme';
|
||||
if (isset($this->callableFunctions[ $function ])) {
|
||||
if ( isset($this->callableFunctions[ $function ]) ) {
|
||||
call_user_func( array( $this, $this->callableFunctions[ $function ] ) );
|
||||
}
|
||||
// wp_destroy_current_session(); // to fix issue multi user session
|
||||
|
@ -766,7 +765,7 @@ class MainWP_Child {
|
|||
global $submenu;
|
||||
if ( isset( $submenu['options-general.php'] ) ) {
|
||||
foreach ( $submenu['options-general.php'] as $index => $item ) {
|
||||
if ( 'mainwp-reports-page' === $item[2] || 'mainwp-reports-settings' === $item[2]) {
|
||||
if ( 'mainwp-reports-page' === $item[2] || 'mainwp-reports-settings' === $item[2] ) {
|
||||
unset( $submenu['options-general.php'][ $index ] );
|
||||
}
|
||||
}
|
||||
|
@ -774,7 +773,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
function render_pages( $shownPage) {
|
||||
function render_pages( $shownPage ) {
|
||||
$shownPage = '';
|
||||
if ( isset($_GET['tab']) ) {
|
||||
$shownPage = $_GET['tab'];
|
||||
|
@ -788,14 +787,14 @@ class MainWP_Child {
|
|||
|
||||
$hide_style = 'style="display:none"';
|
||||
|
||||
if ($shownPage == '') {
|
||||
if ( $shownPage == '' ) {
|
||||
if ( ! $hide_settings ) {
|
||||
$shownPage = 'settings';
|
||||
} elseif ( ! $hide_restore) {
|
||||
} elseif ( ! $hide_restore ) {
|
||||
$shownPage = 'restore-clone';
|
||||
} elseif ( ! $hide_server_info) {
|
||||
} elseif ( ! $hide_server_info ) {
|
||||
$shownPage = 'server-info';
|
||||
} elseif ( ! $hide_connection_detail) {
|
||||
} elseif ( ! $hide_connection_detail ) {
|
||||
$shownPage = 'connection-detail';
|
||||
}
|
||||
}
|
||||
|
@ -829,13 +828,13 @@ class MainWP_Child {
|
|||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ! $hide_server_info ) { ?>
|
||||
<?php if ( ! $hide_server_info ) { ?>
|
||||
<div class="mainwp-child-setting-tab server-info" <?php echo ( 'server-info' !== $shownPage ) ? $hide_style : ''; ?>>
|
||||
<?php MainWP_Child_Server_Information::renderPage(); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ! $hide_connection_detail ) { ?>
|
||||
<?php if ( ! $hide_connection_detail ) { ?>
|
||||
<div class="mainwp-child-setting-tab connection-detail" <?php echo ( 'connection-detail' !== $shownPage ) ? $hide_style : ''; ?>>
|
||||
<?php MainWP_Child_Server_Information::renderConnectionDetails(); ?>
|
||||
</div>
|
||||
|
@ -847,12 +846,12 @@ class MainWP_Child {
|
|||
self::render_footer();
|
||||
}
|
||||
|
||||
public static function render_header( $shownPage, $subpage = true) {
|
||||
public static function render_header( $shownPage, $subpage = true ) {
|
||||
if ( isset($_GET['tab']) ) {
|
||||
$shownPage = $_GET['tab'];
|
||||
}
|
||||
|
||||
if (empty($shownPage)) {
|
||||
if ( empty($shownPage) ) {
|
||||
$shownPage = 'settings';
|
||||
}
|
||||
|
||||
|
@ -1012,7 +1011,7 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
function admin_head() {
|
||||
if (isset($_GET['page']) && $_GET['page'] == 'mainwp_child_tab') {
|
||||
if ( isset($_GET['page']) && $_GET['page'] == 'mainwp_child_tab' ) {
|
||||
?>
|
||||
<style type="text/css">
|
||||
.mainwp-postbox-actions-top {
|
||||
|
@ -1196,7 +1195,7 @@ class MainWP_Child {
|
|||
|
||||
if ( isset( $_POST['function'] ) && 'visitPermalink' === $_POST['function'] ) {
|
||||
|
||||
if (empty($auth_user)) {
|
||||
if ( empty($auth_user) ) {
|
||||
$auth_user = $_POST['user'];
|
||||
}
|
||||
|
||||
|
@ -1520,7 +1519,7 @@ class MainWP_Child {
|
|||
|
||||
if ( isset( $_POST['function'] ) && 'visitPermalink' === $_POST['function'] ) {
|
||||
|
||||
if (empty($auth_user)) {
|
||||
if ( empty($auth_user) ) {
|
||||
$auth_user = $_POST['user'];
|
||||
}
|
||||
|
||||
|
@ -1556,7 +1555,7 @@ class MainWP_Child {
|
|||
MainWP_Child_Links_Checker::Instance()->init();
|
||||
MainWP_Child_WPvivid_BackupRestore::Instance()->init();
|
||||
global $_wp_submenu_nopriv;
|
||||
if ($_wp_submenu_nopriv === null) {
|
||||
if ( $_wp_submenu_nopriv === null ) {
|
||||
$_wp_submenu_nopriv = array(); // fix warning
|
||||
}
|
||||
|
||||
|
@ -1574,7 +1573,7 @@ class MainWP_Child {
|
|||
define( 'DOING_CRON', true );
|
||||
self::fix_for_custom_themes();
|
||||
call_user_func( array( $this, $this->callableFunctionsNoAuth[ $_POST['function'] ] ) );
|
||||
} elseif (isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && ! isset($this->callableFunctions[ $_POST['function'] ]) && ! isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
||||
} elseif ( isset( $_POST['function'] ) && isset( $_POST['mainwpsignature'] ) && ! isset($this->callableFunctions[ $_POST['function'] ]) && ! isset( $this->callableFunctionsNoAuth[ $_POST['function'] ]) ) {
|
||||
MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) );
|
||||
}
|
||||
|
||||
|
@ -1637,7 +1636,7 @@ class MainWP_Child {
|
|||
$auth = hash_equals( md5( $func . $nonce . get_option( 'mainwp_child_nossl_key' ) ), base64_decode( $signature ) );
|
||||
} else {
|
||||
$auth = openssl_verify( $func . $nonce, base64_decode( $signature ), base64_decode( get_option( 'mainwp_child_pubkey' ) ) );
|
||||
if ($auth !== 1) {
|
||||
if ( $auth !== 1 ) {
|
||||
$auth = false;
|
||||
}
|
||||
}
|
||||
|
@ -1747,7 +1746,7 @@ class MainWP_Child {
|
|||
) );
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0) {
|
||||
if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0 ) {
|
||||
// retry
|
||||
add_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99, 2 );
|
||||
$ssl_verify = false;
|
||||
|
@ -1806,7 +1805,7 @@ class MainWP_Child {
|
|||
do_action( 'mainwp_child_installPluginTheme', $args );
|
||||
if ( isset( $_POST['activatePlugin'] ) && 'yes' === $_POST['activatePlugin'] ) {
|
||||
// to fix activate issue
|
||||
if ('quotes-collection/quotes-collection.php' == $args['slug']) {
|
||||
if ( 'quotes-collection/quotes-collection.php' == $args['slug'] ) {
|
||||
activate_plugin( $path . $fileName, '', false, true );
|
||||
} else {
|
||||
activate_plugin( $path . $fileName, '' /* false, true */ );
|
||||
|
@ -2039,8 +2038,8 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
// to fix: smart-manager-for-wp-e-commerce update
|
||||
if (in_array('smart-manager-for-wp-e-commerce/smart-manager.php', $plugins)) {
|
||||
if (file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php') && file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php')) {
|
||||
if ( in_array('smart-manager-for-wp-e-commerce/smart-manager.php', $plugins) ) {
|
||||
if ( file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php') && file_exists(plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php') ) {
|
||||
include_once plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/smart-manager.php';
|
||||
include_once plugin_dir_path( __FILE__ ) . '../../smart-manager-for-wp-e-commerce/pro/upgrade.php';
|
||||
}
|
||||
|
@ -2091,7 +2090,7 @@ class MainWP_Child {
|
|||
// try to fix if that is premiums update
|
||||
$api = apply_filters( 'plugins_api', false, 'plugin_information', array( 'slug' => $plugin ) );
|
||||
|
||||
if ( ! is_wp_error( $api ) && ! empty($api)) {
|
||||
if ( ! is_wp_error( $api ) && ! empty($api) ) {
|
||||
if ( isset($api->download_link) ) {
|
||||
$res = $upgrader->install($api->download_link);
|
||||
if ( ! is_wp_error( $res ) && ! ( is_null( $res ) ) ) {
|
||||
|
@ -2099,8 +2098,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {
|
||||
$information['upgrades'][ $plugin ] = true;
|
||||
// to fix logging update
|
||||
// if (isset($information['plugin_updates']) && isset($information['plugin_updates'][$plugin])) {
|
||||
|
@ -2119,7 +2117,7 @@ class MainWP_Child {
|
|||
$failed = false;
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
if ( $failed ) {
|
||||
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
|
||||
}
|
||||
}
|
||||
|
@ -2233,7 +2231,7 @@ class MainWP_Child {
|
|||
$failed = false;
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
if ( $failed ) {
|
||||
MainWP_Helper::error( __( 'Invalid request!', 'mainwp-child' ) );
|
||||
}
|
||||
|
||||
|
@ -2249,7 +2247,6 @@ class MainWP_Child {
|
|||
'hookFixOptimizePressThemeUpdate',
|
||||
), 99 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
remove_filter( 'pre_site_transient_update_themes', array( $this, 'set_cached_update_themes' ), 10 );
|
||||
|
@ -2366,7 +2363,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($pre == false) {
|
||||
if ( $pre == false ) {
|
||||
return $false;
|
||||
}
|
||||
|
||||
|
@ -2390,7 +2387,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($pre == false) {
|
||||
if ( $pre == false ) {
|
||||
return $false;
|
||||
}
|
||||
|
||||
|
@ -2504,13 +2501,13 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
$others = array();
|
||||
if ( isset( $_POST['featured_image_data'] ) && ! empty($_POST['featured_image_data'])) {
|
||||
if ( isset( $_POST['featured_image_data'] ) && ! empty($_POST['featured_image_data']) ) {
|
||||
$others['featured_image_data'] = unserialize(base64_decode( $_POST['featured_image_data'] ));
|
||||
}
|
||||
|
||||
$res = MainWP_Helper::createPost( $new_post, $post_custom, $post_category, $post_featured_image, $upload_dir, $post_tags, $others );
|
||||
|
||||
if (is_array($res) && isset($res['error'])) {
|
||||
if ( is_array($res) && isset($res['error']) ) {
|
||||
MainWP_Helper::error( $res['error'] );
|
||||
}
|
||||
|
||||
|
@ -2602,7 +2599,7 @@ class MainWP_Child {
|
|||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
function get_post_edit( $id) {
|
||||
function get_post_edit( $id ) {
|
||||
$post = get_post( $id );
|
||||
if ( $post ) {
|
||||
$categoryObjects = get_the_category( $post->ID );
|
||||
|
@ -2689,7 +2686,7 @@ class MainWP_Child {
|
|||
return false;
|
||||
}
|
||||
|
||||
function get_page_edit( $id) {
|
||||
function get_page_edit( $id ) {
|
||||
$post = get_post( $id );
|
||||
if ( $post ) {
|
||||
$post_custom = get_post_custom( $id );
|
||||
|
@ -2779,21 +2776,21 @@ class MainWP_Child {
|
|||
wp_update_user( $my_user );
|
||||
} elseif ( 'edit' === $action ) {
|
||||
$user_data = $this->get_user_to_edit($userId);
|
||||
if ( ! empty($user_data)) {
|
||||
if ( ! empty($user_data) ) {
|
||||
$information['user_data'] = $user_data;
|
||||
} else {
|
||||
$failed = true;
|
||||
}
|
||||
} elseif ( 'update_user' === $action ) {
|
||||
$my_user = $_POST['extra'];
|
||||
if (is_array($my_user)) {
|
||||
foreach ($my_user as $idx => $val) {
|
||||
if ($val === 'donotupdate' || ( empty($val) && $idx !== 'role' )) {
|
||||
if ( is_array($my_user) ) {
|
||||
foreach ( $my_user as $idx => $val ) {
|
||||
if ( $val === 'donotupdate' || ( empty($val) && $idx !== 'role' ) ) {
|
||||
unset($my_user[ $idx ]);
|
||||
}
|
||||
}
|
||||
$result = $this->edit_user( $userId, $my_user );
|
||||
if (is_array($result) && isset($result['error'])) {
|
||||
if ( is_array($result) && isset($result['error']) ) {
|
||||
$information['error'] = $result['error'];
|
||||
}
|
||||
} else {
|
||||
|
@ -2803,21 +2800,20 @@ class MainWP_Child {
|
|||
$failed = true;
|
||||
}
|
||||
|
||||
if ($failed) {
|
||||
if ( $failed ) {
|
||||
$information['status'] = 'FAIL';
|
||||
}
|
||||
|
||||
if ( ! isset( $information['status'] ) && ! isset($information['error']) ) {
|
||||
$information['status'] = 'SUCCESS';
|
||||
if ('update_user' === $action && isset($_POST['optimize']) && ! empty($_POST['optimize'])) {
|
||||
if ( 'update_user' === $action && isset($_POST['optimize']) && ! empty($_POST['optimize']) ) {
|
||||
$information['users'] = $this->get_all_users_int(500); // to fix
|
||||
}
|
||||
|
||||
}
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
function edit_user( $user_id, $data) {
|
||||
function edit_user( $user_id, $data ) {
|
||||
$wp_roles = wp_roles();
|
||||
$user = new stdClass();
|
||||
|
||||
|
@ -2882,7 +2878,7 @@ class MainWP_Child {
|
|||
if ( isset( $data['last_name'] ) ) {
|
||||
$user->last_name = sanitize_text_field( $data['last_name'] );
|
||||
}
|
||||
if ( isset( $data['nickname'] ) && ! empty($data['nickname'])) {
|
||||
if ( isset( $data['nickname'] ) && ! empty($data['nickname']) ) {
|
||||
$user->nickname = sanitize_text_field( $data['nickname'] );
|
||||
}
|
||||
if ( isset( $data['display_name'] ) ) {
|
||||
|
@ -2901,7 +2897,7 @@ class MainWP_Child {
|
|||
|
||||
do_action_ref_array( 'check_passwords', array( $user->user_login, &$pass1, &$pass2 ) );
|
||||
|
||||
if ( ! empty($pass1) || ! empty($pass2)) {
|
||||
if ( ! empty($pass1) || ! empty($pass2) ) {
|
||||
// Check for blank password when adding a user.
|
||||
if ( ! $update && empty( $pass1 ) ) {
|
||||
$errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter a password.' ), array( 'form-field' => 'pass1' ) );
|
||||
|
@ -2948,7 +2944,6 @@ class MainWP_Child {
|
|||
if ( is_string( $message ) ) {
|
||||
$error_str .= ' ' . esc_html( strip_tags( $message ) );
|
||||
}
|
||||
|
||||
}
|
||||
return array( 'error' => $error_str );
|
||||
}
|
||||
|
@ -2963,7 +2958,7 @@ class MainWP_Child {
|
|||
$profileuser = get_user_to_edit($user_id);
|
||||
|
||||
$edit_data = array();
|
||||
if (is_object($profileuser)) {
|
||||
if ( is_object($profileuser) ) {
|
||||
$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
|
||||
$user_role = reset( $user_roles );
|
||||
$edit_data['role'] = $user_role;
|
||||
|
@ -3097,7 +3092,7 @@ class MainWP_Child {
|
|||
$new_user = maybe_unserialize( base64_decode( $_POST['new_user'] ) );
|
||||
$send_password = $_POST['send_password'];
|
||||
// check role existed
|
||||
if (isset( $new_user['role'] )) {
|
||||
if ( isset( $new_user['role'] ) ) {
|
||||
if ( ! get_role( $new_user['role'] ) ) {
|
||||
$new_user['role'] = 'subscriber';
|
||||
}
|
||||
|
@ -3831,7 +3826,7 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
// to fix incorrect info
|
||||
if ( ! property_exists( $plugin_update, 'update' ) || ! property_exists( $plugin_update->update, 'new_version' ) || empty($plugin_update->update->new_version)) {
|
||||
if ( ! property_exists( $plugin_update, 'update' ) || ! property_exists( $plugin_update->update, 'new_version' ) || empty($plugin_update->update->new_version) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3846,7 +3841,7 @@ class MainWP_Child {
|
|||
// to fix premium plugs update
|
||||
$cached_plugins_update = get_site_transient( 'mainwp_update_plugins_cached' );
|
||||
if ( is_array( $cached_plugins_update ) && ( count( $cached_plugins_update ) > 0 ) ) {
|
||||
if ( ! isset($information['plugin_updates'])) {
|
||||
if ( ! isset($information['plugin_updates']) ) {
|
||||
$information['plugin_updates'] = array();
|
||||
}
|
||||
foreach ( $cached_plugins_update as $slug => $plugin_update ) {
|
||||
|
@ -3861,8 +3856,7 @@ class MainWP_Child {
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! isset( $information['plugin_updates'][ $slug ] ) ) {
|
||||
$information['plugin_updates'][ $slug ] = $plugin_update;
|
||||
|
@ -3895,7 +3889,7 @@ class MainWP_Child {
|
|||
// to fix premium themes update
|
||||
$cached_themes_update = get_site_transient( 'mainwp_update_themes_cached' );
|
||||
if ( is_array( $cached_themes_update ) && ( count( $cached_themes_update ) > 0 ) ) {
|
||||
if ( ! isset($information['theme_updates'])) {
|
||||
if ( ! isset($information['theme_updates']) ) {
|
||||
$information['theme_updates'] = array();
|
||||
}
|
||||
|
||||
|
@ -3914,7 +3908,7 @@ class MainWP_Child {
|
|||
$translation_updates = wp_get_translation_updates();
|
||||
if ( ! empty( $translation_updates ) ) {
|
||||
$information['translation_updates'] = array();
|
||||
foreach ($translation_updates as $translation_update) {
|
||||
foreach ( $translation_updates as $translation_update ) {
|
||||
$new_translation_update = array(
|
||||
'type' => $translation_update->type,
|
||||
'slug' => $translation_update->slug,
|
||||
|
@ -3944,16 +3938,16 @@ class MainWP_Child {
|
|||
|
||||
$recent_number = 5;
|
||||
|
||||
if (isset($_POST) && isset( $_POST['recent_number'] )) {
|
||||
if ( isset($_POST) && isset( $_POST['recent_number'] ) ) {
|
||||
$recent_number = $_POST['recent_number'];
|
||||
if ($recent_number != get_option('mainwp_child_recent_number', 5)) {
|
||||
if ( $recent_number != get_option('mainwp_child_recent_number', 5) ) {
|
||||
update_option( 'mainwp_child_recent_number', $recent_number );
|
||||
}
|
||||
} else {
|
||||
$recent_number = get_option('mainwp_child_recent_number', 5);
|
||||
}
|
||||
|
||||
if ($recent_number <= 0 || $recent_number > 30) {
|
||||
if ( $recent_number <= 0 || $recent_number > 30 ) {
|
||||
$recent_number = 5;
|
||||
}
|
||||
|
||||
|
@ -4019,7 +4013,7 @@ class MainWP_Child {
|
|||
$get_file_size = apply_filters('mainwp-child-get-total-size', true);
|
||||
if ( $get_file_size && isset( $_POST['cloneSites'] ) && ( '0' !== $_POST['cloneSites'] ) ) {
|
||||
$max_exe = ini_get( 'max_execution_time' ); // to fix issue of some hosts have limit of execution time
|
||||
if ($max_exe > 20) {
|
||||
if ( $max_exe > 20 ) {
|
||||
$information['totalsize'] = $this->getTotalFileSize();
|
||||
}
|
||||
}
|
||||
|
@ -4037,7 +4031,7 @@ class MainWP_Child {
|
|||
$information['users'] = $this->get_all_users_int(500); // to fix
|
||||
}
|
||||
|
||||
if (isset($_POST['primaryBackup']) && ! empty($_POST['primaryBackup'])) {
|
||||
if ( isset($_POST['primaryBackup']) && ! empty($_POST['primaryBackup']) ) {
|
||||
$primary_bk = $_POST['primaryBackup'];
|
||||
$information['primaryLasttimeBackup'] = MainWP_Helper::get_lasttime_backup($primary_bk);
|
||||
}
|
||||
|
@ -4054,9 +4048,9 @@ class MainWP_Child {
|
|||
$information['plugins_outdate_info'] = MainWP_Child_Plugins_Check::Instance()->get_plugins_outdate_info();
|
||||
$information['themes_outdate_info'] = MainWP_Child_Themes_Check::Instance()->get_themes_outdate_info();
|
||||
|
||||
if (isset( $_POST['user'] )) {
|
||||
if ( isset( $_POST['user'] ) ) {
|
||||
$user = get_user_by( 'login', $_POST['user'] );
|
||||
if ( $user && property_exists($user, 'ID') && $user->ID) {
|
||||
if ( $user && property_exists($user, 'ID') && $user->ID ) {
|
||||
$information['admin_nicename'] = $user->data->user_nicename;
|
||||
$information['admin_useremail'] = $user->data->user_email;
|
||||
}
|
||||
|
@ -4064,7 +4058,7 @@ class MainWP_Child {
|
|||
|
||||
try {
|
||||
do_action('mainwp_child_site_stats');
|
||||
} catch (Exception $e) {
|
||||
} catch ( Exception $e ) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -4083,7 +4077,7 @@ class MainWP_Child {
|
|||
|
||||
try {
|
||||
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
||||
} catch (Exception $e) {
|
||||
} catch ( Exception $e ) {
|
||||
// do not exit
|
||||
}
|
||||
}
|
||||
|
@ -4130,9 +4124,9 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($parse_page) {
|
||||
if ( $parse_page ) {
|
||||
// try to parse page
|
||||
if (empty($favi_url)) {
|
||||
if ( empty($favi_url) ) {
|
||||
$request = wp_remote_get( $site_url, array( 'timeout' => 50 ) );
|
||||
$favi = '';
|
||||
if ( is_array( $request ) && isset( $request['body'] ) ) {
|
||||
|
@ -4148,9 +4142,9 @@ class MainWP_Child {
|
|||
}
|
||||
|
||||
if ( ! empty( $favi ) ) {
|
||||
if ( false === strpos( $favi, 'http' )) {
|
||||
if (0 === strpos( $favi, '//' )) {
|
||||
if (0 === strpos( $site_url, 'https' )) {
|
||||
if ( false === strpos( $favi, 'http' ) ) {
|
||||
if ( 0 === strpos( $favi, '//' ) ) {
|
||||
if ( 0 === strpos( $site_url, 'https' ) ) {
|
||||
$favi_url = 'https:' . $favi;
|
||||
} else {
|
||||
$favi_url = 'http:' . $favi;
|
||||
|
@ -4295,15 +4289,15 @@ class MainWP_Child {
|
|||
*/
|
||||
|
||||
$wp_seo_enabled = false;
|
||||
if ( isset( $_POST['WPSEOEnabled'] ) && $_POST['WPSEOEnabled']) {
|
||||
if (is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count') && class_exists('WPSEO_Meta')) {
|
||||
if ( isset( $_POST['WPSEOEnabled'] ) && $_POST['WPSEOEnabled'] ) {
|
||||
if ( is_plugin_active('wordpress-seo/wp-seo.php') && class_exists('WPSEO_Link_Column_Count') && class_exists('WPSEO_Meta') ) {
|
||||
$wp_seo_enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
$posts = get_posts( $args );
|
||||
if ( is_array( $posts ) ) {
|
||||
if ($wp_seo_enabled) {
|
||||
if ( $wp_seo_enabled ) {
|
||||
$post_ids = array();
|
||||
foreach ( $posts as $post ) {
|
||||
$post_ids[] = $post->ID;
|
||||
|
@ -4326,7 +4320,7 @@ class MainWP_Child {
|
|||
$outPost['dts'] = strtotime( $post->post_modified_gmt );
|
||||
}
|
||||
|
||||
if ($post->post_status == 'future') {
|
||||
if ( $post->post_status == 'future' ) {
|
||||
$outPost['dts'] = strtotime( $post->post_date_gmt );
|
||||
}
|
||||
|
||||
|
@ -4366,7 +4360,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($wp_seo_enabled) {
|
||||
if ( $wp_seo_enabled ) {
|
||||
$post_id = $post->ID;
|
||||
$outPost['seo_data'] = array(
|
||||
'count_seo_links' => $link_count->get( $post_id, 'internal_link_count' ),
|
||||
|
@ -4577,23 +4571,23 @@ class MainWP_Child {
|
|||
} else {
|
||||
if ( isset( $_POST['keyword'] ) ) {
|
||||
$search_on = isset($_POST['search_on']) ? $_POST['search_on'] : '';
|
||||
if ($search_on == 'title') {
|
||||
if ( $search_on == 'title' ) {
|
||||
$this->posts_where_suffix .= " AND ( $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )";
|
||||
} elseif ($search_on == 'content') {
|
||||
} elseif ( $search_on == 'content' ) {
|
||||
$this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' )";
|
||||
} else {
|
||||
$this->posts_where_suffix .= " AND ($wpdb->posts.post_content LIKE '%" . $_POST['keyword'] . "%' OR $wpdb->posts.post_title LIKE '%" . $_POST['keyword'] . "%' )";
|
||||
}
|
||||
}
|
||||
if ( isset( $_POST['dtsstart'] ) && '' !== $_POST['dtsstart'] ) {
|
||||
if ($where_post_date) {
|
||||
if ( $where_post_date ) {
|
||||
$this->posts_where_suffix .= " AND $wpdb->posts.post_date > '" . $_POST['dtsstart'] . "'";
|
||||
} else {
|
||||
$this->posts_where_suffix .= " AND $wpdb->posts.post_modified > '" . $_POST['dtsstart'] . "'";
|
||||
}
|
||||
}
|
||||
if ( isset( $_POST['dtsstop'] ) && '' !== $_POST['dtsstop'] ) {
|
||||
if ($where_post_date) {
|
||||
if ( $where_post_date ) {
|
||||
$this->posts_where_suffix .= " AND $wpdb->posts.post_date < '" . $_POST['dtsstop'] . "'";
|
||||
} else {
|
||||
$this->posts_where_suffix .= " AND $wpdb->posts.post_modified < '" . $_POST['dtsstop'] . "'";
|
||||
|
@ -4690,9 +4684,9 @@ class MainWP_Child {
|
|||
$outComment['author_url'] = get_comment_author_url( $comment->comment_ID );
|
||||
$outComment['author_ip'] = get_comment_author_IP( $comment->comment_ID );
|
||||
$outComment['author_email'] = $email = apply_filters( 'comment_email', $comment->comment_author_email );
|
||||
// if ( ( ! empty( $outComment['author_email'] ) ) && ( '@' !== $outComment['author_email'] ) ) {
|
||||
// $outComment['author_email'] = '<a href="mailto:' . $outComment['author_email'] . '">' . $outComment['author_email'] . '</a>';
|
||||
// }
|
||||
// if ( ( ! empty( $outComment['author_email'] ) ) && ( '@' !== $outComment['author_email'] ) ) {
|
||||
// $outComment['author_email'] = '<a href="mailto:' . $outComment['author_email'] . '">' . $outComment['author_email'] . '</a>';
|
||||
// }
|
||||
$outComment['postId'] = $comment->comment_post_ID;
|
||||
$outComment['postName'] = $post->post_title;
|
||||
$outComment['comment_count'] = $post->comment_count;
|
||||
|
@ -4739,7 +4733,7 @@ class MainWP_Child {
|
|||
$theme_name = wp_get_theme()->get( 'Name' );
|
||||
$themes = explode( '||', $theme );
|
||||
|
||||
if (count($themes) == 1) {
|
||||
if ( count($themes) == 1 ) {
|
||||
$themeToDelete = current($themes);
|
||||
if ( $themeToDelete == $theme_name ) {
|
||||
$information['error'] = 'IsActivatedTheme';
|
||||
|
@ -4827,7 +4821,7 @@ class MainWP_Child {
|
|||
$thePlugin = get_plugin_data( $plugin );
|
||||
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
||||
// to fix activate issue
|
||||
if ('quotes-collection/quotes-collection.php' == $plugin) {
|
||||
if ( 'quotes-collection/quotes-collection.php' == $plugin ) {
|
||||
activate_plugin( $plugin, '', false, true );
|
||||
// do_action( 'activate_plugin', $plugin, null );
|
||||
} else {
|
||||
|
@ -4870,7 +4864,7 @@ class MainWP_Child {
|
|||
foreach ( $plugins as $idx => $plugin ) {
|
||||
if ( $plugin !== $this->plugin_slug ) {
|
||||
if ( isset( $all_plugins[ $plugin ] ) ) {
|
||||
if (is_plugin_active($plugin)) {
|
||||
if ( is_plugin_active($plugin) ) {
|
||||
$thePlugin = get_plugin_data( $plugin );
|
||||
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
||||
deactivate_plugins( $plugin );
|
||||
|
@ -4962,7 +4956,7 @@ class MainWP_Child {
|
|||
return $rslt;
|
||||
}
|
||||
|
||||
function get_all_users( $return = false) {
|
||||
function get_all_users( $return = false ) {
|
||||
$roles = explode( ',', $_POST['role'] );
|
||||
$allusers = array();
|
||||
if ( is_array( $roles ) ) {
|
||||
|
@ -4985,17 +4979,17 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $allusers;
|
||||
}
|
||||
MainWP_Helper::write( $allusers );
|
||||
}
|
||||
|
||||
function get_all_users_int( $number = false) {
|
||||
function get_all_users_int( $number = false ) {
|
||||
$allusers = array();
|
||||
|
||||
$params = array();
|
||||
if ($number) {
|
||||
if ( $number ) {
|
||||
$params['number'] = $number;
|
||||
}
|
||||
|
||||
|
@ -5027,10 +5021,10 @@ class MainWP_Child {
|
|||
$search_user_role = array();
|
||||
$check_users_role = false;
|
||||
|
||||
if (isset($_POST['role']) && ! empty($_POST['role'])) {
|
||||
if ( isset($_POST['role']) && ! empty($_POST['role']) ) {
|
||||
$check_users_role = true;
|
||||
$all_users_role = $this->get_all_users(true);
|
||||
foreach ($all_users_role as $user) {
|
||||
foreach ( $all_users_role as $user ) {
|
||||
$search_user_role[] = $user['id'];
|
||||
}
|
||||
unset($all_users_role);
|
||||
|
@ -5054,8 +5048,8 @@ class MainWP_Child {
|
|||
) );
|
||||
if ( ! empty( $user_query->results ) ) {
|
||||
foreach ( $user_query->results as $new_user ) {
|
||||
if ($check_users_role) {
|
||||
if ( ! in_array($new_user->ID, $search_user_role )) {
|
||||
if ( $check_users_role ) {
|
||||
if ( ! in_array($new_user->ID, $search_user_role ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -5110,7 +5104,7 @@ class MainWP_Child {
|
|||
|
||||
function activation() {
|
||||
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
|
||||
if ($mu_plugin_enabled) {
|
||||
if ( $mu_plugin_enabled ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5135,10 +5129,10 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
function deactivation( $deact = true) {
|
||||
function deactivation( $deact = true ) {
|
||||
|
||||
$mu_plugin_enabled = apply_filters('mainwp_child_mu_plugin_enabled', false);
|
||||
if ($mu_plugin_enabled) {
|
||||
if ( $mu_plugin_enabled ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5160,7 +5154,7 @@ class MainWP_Child {
|
|||
}
|
||||
}
|
||||
|
||||
if ($deact) {
|
||||
if ( $deact ) {
|
||||
do_action( 'mainwp_child_deactivation' );
|
||||
}
|
||||
}
|
||||
|
@ -5270,7 +5264,7 @@ class MainWP_Child {
|
|||
// to fix for window host, performance not good?
|
||||
if ( class_exists( 'RecursiveIteratorIterator' ) ) {
|
||||
$size = 0;
|
||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) {
|
||||
foreach ( new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file ) {
|
||||
$size += $file->getSize();
|
||||
}
|
||||
if ( $size && MainWP_Helper::ctype_digit( $size ) ) {
|
||||
|
|
|
@ -339,65 +339,63 @@ class MainWP_Client_Report {
|
|||
if ( ! is_array( $records ) ) {
|
||||
$records = array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// to fix invalid data, or skip records
|
||||
$skip_records = array();
|
||||
|
||||
// to fix for incorrect posts created logging
|
||||
// query created posts from WP posts data to simulate records logging for created posts
|
||||
if ( isset($_POST['direct_posts']) && !empty($_POST['direct_posts']) ) {
|
||||
|
||||
// to fix for incorrect posts created logging
|
||||
// query created posts from WP posts data to simulate records logging for created posts
|
||||
if ( isset($_POST['direct_posts']) && ! empty($_POST['direct_posts']) ) {
|
||||
$query_string = array(
|
||||
'post_type' => 'post',
|
||||
'date_query' => array(
|
||||
'column' => 'post_date',
|
||||
'after' => $args['date_from'],
|
||||
'before' => $args['date_to']
|
||||
),
|
||||
'post_status' => 'publish'
|
||||
);
|
||||
'post_type' => 'post',
|
||||
'date_query' => array(
|
||||
'column' => 'post_date',
|
||||
'after' => $args['date_from'],
|
||||
'before' => $args['date_to'],
|
||||
),
|
||||
'post_status' => 'publish',
|
||||
);
|
||||
|
||||
$records_created_posts = query_posts( $query_string );
|
||||
|
||||
if ($records_created_posts) {
|
||||
|
||||
for( $i = 0; $i < count($records); $i++ ) {
|
||||
$record = $records[$i];
|
||||
if ($record->connector == 'posts' && $record->context == 'post' && $record->action == 'created') {
|
||||
if (!in_array($record->ID, $skip_records)) {
|
||||
|
||||
if ( $records_created_posts ) {
|
||||
|
||||
for ( $i = 0; $i < count($records); $i++ ) {
|
||||
$record = $records[ $i ];
|
||||
if ( $record->connector == 'posts' && $record->context == 'post' && $record->action == 'created' ) {
|
||||
if ( ! in_array($record->ID, $skip_records) ) {
|
||||
$skip_records[] = $record->ID; // so avoid this created logging, will use logging query from posts data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$post_authors = array();
|
||||
|
||||
foreach( $records_created_posts as $_post){
|
||||
|
||||
foreach ( $records_created_posts as $_post ) {
|
||||
$au_id = $_post->post_author;
|
||||
if ( !isset($post_authors[$au_id]) ) {
|
||||
$au = get_user_by( 'id', $au_id );
|
||||
$post_authors[$au_id] = $au->display_name;
|
||||
if ( ! isset($post_authors[ $au_id ]) ) {
|
||||
$au = get_user_by( 'id', $au_id );
|
||||
$post_authors[ $au_id ] = $au->display_name;
|
||||
}
|
||||
$au_name = $post_authors[$au_id];
|
||||
|
||||
//simulate logging created posts record
|
||||
$stdObj = new stdClass;
|
||||
$stdObj->ID = 0; // simulate ID value
|
||||
$au_name = $post_authors[ $au_id ];
|
||||
|
||||
// simulate logging created posts record
|
||||
$stdObj = new stdClass();
|
||||
$stdObj->ID = 0; // simulate ID value
|
||||
$stdObj->connector = 'posts';
|
||||
$stdObj->context = 'post';
|
||||
$stdObj->action = 'created';
|
||||
$stdObj->created = $_post->post_date;
|
||||
$stdObj->meta = array(
|
||||
$stdObj->context = 'post';
|
||||
$stdObj->action = 'created';
|
||||
$stdObj->created = $_post->post_date;
|
||||
$stdObj->meta = array(
|
||||
'post_title' => array( $_post->post_title ),
|
||||
'user_meta' => array( $au_name )
|
||||
);
|
||||
|
||||
'user_meta' => array( $au_name ),
|
||||
);
|
||||
|
||||
$records[] = $stdObj;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $other_tokens['header'] ) && is_array( $other_tokens['header'] ) ) {
|
||||
$other_tokens_data['header'] = $this->get_other_tokens_data( $records, $other_tokens['header'], $skip_records);
|
||||
}
|
||||
|
@ -500,11 +498,11 @@ class MainWP_Client_Report {
|
|||
if ( ! in_array( $record->context, $comment_contexts ) ) {
|
||||
continue;
|
||||
}
|
||||
} else if ( 'post' === $context && 'created' === $action ) {
|
||||
} elseif ( 'post' === $context && 'created' === $action ) {
|
||||
if ( in_array($record->ID, $skip_records) ) {
|
||||
continue;
|
||||
}
|
||||
} else if ( $context == "menus") {
|
||||
} elseif ( $context == 'menus' ) {
|
||||
// ok, pass, don't check context
|
||||
} elseif ( $record->connector == 'editor' ) {
|
||||
// ok, pass, checked above
|
||||
|
@ -563,8 +561,8 @@ class MainWP_Client_Report {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$count ++;
|
||||
}
|
||||
|
@ -880,12 +878,12 @@ class MainWP_Client_Report {
|
|||
|
||||
if ( isset( $record->meta ) ) {
|
||||
$meta = $record->meta;
|
||||
|
||||
if ( isset( $meta[ $meta_key ] ) ) {
|
||||
|
||||
|
||||
if ( isset( $meta[ $meta_key ] ) ) {
|
||||
|
||||
$value = $meta[ $meta_key ];
|
||||
$value = ( $meta_key == 'user_meta' && isset($value[1]) ) ? $value[1] : current( $value ); // display name
|
||||
|
||||
$value = ( $meta_key == 'user_meta' && isset($value[1]) ) ? $value[1] : current( $value ); // display name
|
||||
|
||||
// to compatible with old meta data
|
||||
if ( 'author_meta' === $meta_key ) {
|
||||
$value = maybe_unserialize( $value );
|
||||
|
|
|
@ -3,25 +3,25 @@
|
|||
class MainWP_Helper {
|
||||
|
||||
static function write( $val ) {
|
||||
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
|
||||
if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true ) :
|
||||
$output = self::safe_json_encode( $val );
|
||||
else :
|
||||
$output = serialize( $val );
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
die( '<mainwp>' . base64_encode( $output ) . '</mainwp>');
|
||||
}
|
||||
|
||||
|
||||
public static function json_valid_check( $data ) {
|
||||
|
||||
if (is_array( $data )) {
|
||||
|
||||
if ( is_array( $data ) ) {
|
||||
$output = array();
|
||||
foreach ( $data as $key => $value) {
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( is_string( $key ) ) {
|
||||
$id = self::json_convert_string( $key );
|
||||
} else {
|
||||
$id = $key;
|
||||
}
|
||||
}
|
||||
if ( is_array( $value ) || is_object( $value ) ) {
|
||||
$output[ $id ] = self::json_valid_check( $value );
|
||||
} elseif ( is_string( $value ) ) {
|
||||
|
@ -30,9 +30,9 @@ class MainWP_Helper {
|
|||
$output[ $id ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ( is_object( $data ) ) {
|
||||
$output = new stdClass;
|
||||
$output = new stdClass();
|
||||
foreach ( $data as $key => $value ) {
|
||||
if ( is_string( $key ) ) {
|
||||
$id = self::json_convert_string( $key );
|
||||
|
@ -47,39 +47,39 @@ class MainWP_Helper {
|
|||
$output->$id = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (is_string( $data )) {
|
||||
}
|
||||
elseif ( is_string( $data ) ) {
|
||||
return self::json_convert_string( $data );
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function json_convert_string( $str ) {
|
||||
if ( function_exists( 'mb_convert_encoding' )) {
|
||||
$encoding = mb_detect_encoding( $str, mb_detect_order(), true );
|
||||
if ( $encoding ) {
|
||||
return mb_convert_encoding( $str, 'UTF-8', $encoding );
|
||||
} else {
|
||||
return mb_convert_encoding( $str, 'UTF-8', 'UTF-8' );
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function safe_json_encode( $value, $options = 0, $depth = 512) {
|
||||
$encoded = @json_encode($value, $options, $depth);
|
||||
if ($encoded === false && !empty( $value ) && json_last_error() == JSON_ERROR_UTF8 ) {
|
||||
$encoded = @json_encode(self::json_valid_check($value), $options, $depth);
|
||||
public function json_convert_string( $str ) {
|
||||
if ( function_exists( 'mb_convert_encoding' ) ) {
|
||||
$encoding = mb_detect_encoding( $str, mb_detect_order(), true );
|
||||
if ( $encoding ) {
|
||||
return mb_convert_encoding( $str, 'UTF-8', $encoding );
|
||||
} else {
|
||||
return mb_convert_encoding( $str, 'UTF-8', 'UTF-8' );
|
||||
}
|
||||
}
|
||||
return $encoded ;
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function safe_json_encode( $value, $options = 0, $depth = 512 ) {
|
||||
$encoded = @json_encode($value, $options, $depth);
|
||||
if ( $encoded === false && ! empty( $value ) && json_last_error() == JSON_ERROR_UTF8 ) {
|
||||
$encoded = @json_encode(self::json_valid_check($value), $options, $depth);
|
||||
}
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
static function close_connection( $val = null ) {
|
||||
|
||||
if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) :
|
||||
if ( isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true ) :
|
||||
$output = self::safe_json_encode( $val );
|
||||
else :
|
||||
$output = serialize( $val );
|
||||
|
@ -102,7 +102,7 @@ class MainWP_Helper {
|
|||
|
||||
static function error( $error, $code = null ) {
|
||||
$information['error'] = $error;
|
||||
if (null !== $code) {
|
||||
if ( null !== $code ) {
|
||||
$information['error_code'] = $code;
|
||||
}
|
||||
self::write( $information );
|
||||
|
@ -114,7 +114,7 @@ class MainWP_Helper {
|
|||
* CSSPARSER
|
||||
* Copyright (C) 2009 Peter Kröner
|
||||
*/
|
||||
public static function parse_css( $css) {
|
||||
public static function parse_css( $css ) {
|
||||
|
||||
// Remove CSS-Comments
|
||||
$css = preg_replace('/\/\*.*?\*\//ms', '', $css);
|
||||
|
@ -125,14 +125,14 @@ class MainWP_Helper {
|
|||
// Append the rest to $blocks
|
||||
array_push($blocks[0], preg_replace('/@.+?\}[^\}]*?\}/ms', '', $css));
|
||||
$ordered = array();
|
||||
for ($i = 0;$i < count($blocks[0]);$i++) {
|
||||
for ( $i = 0;$i < count($blocks[0]);$i++ ) {
|
||||
// If @media-block, strip declaration and parenthesis
|
||||
if (substr($blocks[0][ $i ], 0, 6) === '@media') {
|
||||
if ( substr($blocks[0][ $i ], 0, 6) === '@media' ) {
|
||||
$ordered_key = preg_replace('/^(@media[^\{]+)\{.*\}$/ms', '$1', $blocks[0][ $i ]);
|
||||
$ordered_value = preg_replace('/^@media[^\{]+\{(.*)\}$/ms', '$1', $blocks[0][ $i ]);
|
||||
}
|
||||
// Rule-blocks of the sort @import or @font-face
|
||||
elseif (substr($blocks[0][ $i ], 0, 1) === '@') {
|
||||
elseif ( substr($blocks[0][ $i ], 0, 1) === '@' ) {
|
||||
$ordered_key = $blocks[0][ $i ];
|
||||
$ordered_value = $blocks[0][ $i ];
|
||||
} else {
|
||||
|
@ -144,27 +144,27 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
// Beginning to rebuild new slim CSS-Array
|
||||
foreach ($ordered as $key => $val) {
|
||||
foreach ( $ordered as $key => $val ) {
|
||||
$new = array();
|
||||
for ($i = 0; $i < count($val); $i++) {
|
||||
for ( $i = 0; $i < count($val); $i++ ) {
|
||||
// Split selectors and rules and split properties and values
|
||||
$selector = trim($val[ $i ], " \r\n\t");
|
||||
|
||||
if ( ! empty($selector)) {
|
||||
if ( ! isset($new[ $selector ])) {
|
||||
if ( ! empty($selector) ) {
|
||||
if ( ! isset($new[ $selector ]) ) {
|
||||
$new[ $selector ] = array();
|
||||
}
|
||||
$rules = explode(';', $val[ ++$i ]);
|
||||
foreach ($rules as $rule) {
|
||||
foreach ( $rules as $rule ) {
|
||||
$rule = trim($rule, " \r\n\t");
|
||||
if ( ! empty($rule)) {
|
||||
if ( ! empty($rule) ) {
|
||||
$rule = array_reverse(explode(':', $rule));
|
||||
$property = trim(array_pop($rule), " \r\n\t");
|
||||
$value = implode(':', array_reverse($rule));
|
||||
|
||||
if ( ! isset($new[ $selector ][ $property ]) || ! preg_match('/!important/', $new[ $selector ][ $property ])) {
|
||||
if ( ! isset($new[ $selector ][ $property ]) || ! preg_match('/!important/', $new[ $selector ][ $property ]) ) {
|
||||
$new[ $selector ][ $property ] = $value;
|
||||
} elseif (preg_match('/!important/', $new[ $selector ][ $property ]) && preg_match('/!important/', $value)) {
|
||||
} elseif ( preg_match('/!important/', $new[ $selector ][ $property ]) && preg_match('/!important/', $value) ) {
|
||||
$new[ $selector ][ $property ] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -176,23 +176,23 @@ class MainWP_Helper {
|
|||
$parsed = $ordered;
|
||||
|
||||
$output = '';
|
||||
foreach ($parsed as $media => $content) {
|
||||
if (substr($media, 0, 6) === '@media') {
|
||||
foreach ( $parsed as $media => $content ) {
|
||||
if ( substr($media, 0, 6) === '@media' ) {
|
||||
$output .= $media . " {\n";
|
||||
$prefix = "\t";
|
||||
} else {
|
||||
$prefix = '';
|
||||
}
|
||||
|
||||
foreach ($content as $selector => $rules) {
|
||||
foreach ( $content as $selector => $rules ) {
|
||||
$output .= $prefix . $selector . " {\n";
|
||||
foreach ($rules as $property => $value) {
|
||||
foreach ( $rules as $property => $value ) {
|
||||
$output .= $prefix . "\t" . $property . ': ' . $value;
|
||||
$output .= ";\n";
|
||||
}
|
||||
$output .= $prefix . "}\n\n";
|
||||
}
|
||||
if (substr($media, 0, 6) === '@media') {
|
||||
if ( substr($media, 0, 6) === '@media' ) {
|
||||
$output .= "}\n\n";
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ class MainWP_Helper {
|
|||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . $filename; // Local name
|
||||
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
|
||||
|
||||
//$gen_unique_fn = true;
|
||||
// $gen_unique_fn = true;
|
||||
|
||||
// to fix issue re-create new attachment
|
||||
if ( $check_file_existed ) {
|
||||
|
@ -227,7 +227,7 @@ class MainWP_Helper {
|
|||
$result = self::get_maybe_existed_attached_id( $local_img_url );
|
||||
if ( is_array($result) ) { // found attachment
|
||||
$attach = current($result);
|
||||
if (is_object($attach)) {
|
||||
if ( is_object($attach) ) {
|
||||
if ( file_exists( $temporary_file ) ) {
|
||||
unlink( $temporary_file );
|
||||
}
|
||||
|
@ -238,13 +238,12 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else { // find in other path
|
||||
} else { // find in other path
|
||||
$result = self::get_maybe_existed_attached_id( $filename, false );
|
||||
|
||||
if ( is_array( $result ) ) { // found attachment
|
||||
$attach = current($result);
|
||||
if (is_object($attach)) {
|
||||
if ( is_object($attach) ) {
|
||||
$basedir = $upload_dir['basedir'];
|
||||
$baseurl = $upload_dir['baseurl'];
|
||||
$local_img_path = str_replace( $baseurl, $basedir, $attach->guid );
|
||||
|
@ -259,13 +258,13 @@ class MainWP_Helper {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// file exists, do not overwrite, generate unique file name
|
||||
// this may causing of issue incorrect source of image in post content
|
||||
if ( file_exists( $local_img_path ) ) {
|
||||
if ( file_exists( $local_img_path ) ) {
|
||||
$local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) );
|
||||
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
|
||||
}
|
||||
|
@ -470,12 +469,12 @@ class MainWP_Helper {
|
|||
|
||||
if ( isset( $post_custom['_mainwp_edit_post_id'] ) && $post_custom['_mainwp_edit_post_id'] ) {
|
||||
$edit_post_id = current($post_custom['_mainwp_edit_post_id']);
|
||||
} elseif (isset( $new_post['ID'] ) && $new_post['ID']) {
|
||||
} elseif ( isset( $new_post['ID'] ) && $new_post['ID'] ) {
|
||||
$edit_post_id = $new_post['ID'];
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/post.php';
|
||||
if ($edit_post_id) {
|
||||
if ( $edit_post_id ) {
|
||||
if ( $user_id = wp_check_post_lock( $edit_post_id ) ) {
|
||||
$user = get_userdata( $user_id );
|
||||
$error = sprintf( __( 'This content is currently locked. %s is currently editing.' ), $user->display_name );
|
||||
|
@ -544,9 +543,9 @@ class MainWP_Helper {
|
|||
$replaceAttachedIds = array();
|
||||
if ( isset( $_POST['post_gallery_images'] ) ) {
|
||||
$post_gallery_images = unserialize(base64_decode( $_POST['post_gallery_images'] ));
|
||||
if (is_array($post_gallery_images)) {
|
||||
foreach ($post_gallery_images as $gallery) {
|
||||
if (isset($gallery['src'])) {
|
||||
if ( is_array($post_gallery_images) ) {
|
||||
foreach ( $post_gallery_images as $gallery ) {
|
||||
if ( isset($gallery['src']) ) {
|
||||
try {
|
||||
$upload = self::uploadImage( $gallery['src'], $gallery ); // Upload image to WP
|
||||
if ( null !== $upload ) {
|
||||
|
@ -559,18 +558,18 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (count($replaceAttachedIds) > 0) {
|
||||
if ( count($replaceAttachedIds) > 0 ) {
|
||||
foreach ( $matches as $match ) {
|
||||
$idsToReplace = $match[1];
|
||||
$idsToReplaceWith = '';
|
||||
$originalIds = explode(',', $idsToReplace);
|
||||
foreach ($originalIds as $attached_id) {
|
||||
if ( ! empty($originalIds) && isset($replaceAttachedIds[ $attached_id ])) {
|
||||
foreach ( $originalIds as $attached_id ) {
|
||||
if ( ! empty($originalIds) && isset($replaceAttachedIds[ $attached_id ]) ) {
|
||||
$idsToReplaceWith .= $replaceAttachedIds[ $attached_id ] . ',';
|
||||
}
|
||||
}
|
||||
$idsToReplaceWith = rtrim($idsToReplaceWith, ',');
|
||||
if ( ! empty($idsToReplaceWith)) {
|
||||
if ( ! empty($idsToReplaceWith) ) {
|
||||
$new_post['post_content'] = str_replace( '"' . $idsToReplace . '"', '"' . $idsToReplaceWith . '"', $new_post['post_content'] );
|
||||
}
|
||||
}
|
||||
|
@ -702,11 +701,11 @@ class MainWP_Helper {
|
|||
|
||||
$post_to_only_existing_categories = false;
|
||||
|
||||
if (is_array($post_custom)) {
|
||||
if ( is_array($post_custom) ) {
|
||||
foreach ( $post_custom as $meta_key => $meta_values ) {
|
||||
if ( ! in_array( $meta_key, $not_allowed ) ) {
|
||||
foreach ( $meta_values as $meta_value ) {
|
||||
if (strpos($meta_key, '_mainwp_spinner_') === 0) {
|
||||
if ( strpos($meta_key, '_mainwp_spinner_') === 0 ) {
|
||||
continue; // not save
|
||||
}
|
||||
|
||||
|
@ -753,7 +752,6 @@ class MainWP_Helper {
|
|||
} catch ( Exception $e ) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,7 +784,7 @@ class MainWP_Helper {
|
|||
if ( null !== $upload ) {
|
||||
update_post_meta( $new_post_id, '_thumbnail_id', $upload['id'] ); // Add the thumbnail to the post!
|
||||
$featured_image_exist = true;
|
||||
if (isset($others['featured_image_data'])) {
|
||||
if ( isset($others['featured_image_data']) ) {
|
||||
$_image_data = $others['featured_image_data'];
|
||||
update_post_meta( $upload['id'], '_wp_attachment_image_alt', $_image_data['alt'] );
|
||||
wp_update_post( array(
|
||||
|
@ -870,7 +868,7 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
// unlock if edit post
|
||||
if ($edit_post_id) {
|
||||
if ( $edit_post_id ) {
|
||||
update_post_meta( $edit_post_id, '_edit_lock', '' );
|
||||
}
|
||||
|
||||
|
@ -1098,7 +1096,7 @@ class MainWP_Helper {
|
|||
// $agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
|
||||
$agent = 'Mozilla/5.0 (compatible; MainWP-Child/' . MainWP_Child::$version . '; +http://mainwp.com)';
|
||||
|
||||
if ( ! is_array( $postdata )) {
|
||||
if ( ! is_array( $postdata ) ) {
|
||||
$postdata = array();
|
||||
}
|
||||
|
||||
|
@ -1311,7 +1309,7 @@ class MainWP_Helper {
|
|||
static function update_lasttime_backup( $by, $time ) {
|
||||
$backup_by = array( 'backupbuddy', 'backupwordpress', 'backwpup', 'updraftplus', 'wptimecapsule' );
|
||||
|
||||
if ( ! in_array($by, $backup_by)) {
|
||||
if ( ! in_array($by, $backup_by) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1324,17 +1322,17 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
static function get_lasttime_backup( $by ) {
|
||||
if ($by == 'backupwp') { // to compatible
|
||||
if ( $by == 'backupwp' ) { // to compatible
|
||||
$by = 'backupwordpress';
|
||||
}
|
||||
switch ($by) {
|
||||
switch ( $by ) {
|
||||
case 'backupbuddy':
|
||||
if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' )) {
|
||||
if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'backupwordpress':
|
||||
if ( ! is_plugin_active( 'backupwordpress/backupwordpress.php' )) {
|
||||
if ( ! is_plugin_active( 'backupwordpress/backupwordpress.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -1344,12 +1342,12 @@ class MainWP_Helper {
|
|||
}
|
||||
break;
|
||||
case 'updraftplus':
|
||||
if ( ! is_plugin_active( 'updraftplus/updraftplus.php' )) {
|
||||
if ( ! is_plugin_active( 'updraftplus/updraftplus.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case 'wptimecapsule':
|
||||
if ( ! is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' )) {
|
||||
if ( ! is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) ) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -1523,7 +1521,7 @@ class MainWP_Helper {
|
|||
}
|
||||
|
||||
public static function sanitize_filename( $filename ) {
|
||||
if ( ! function_exists('mb_ereg_replace')) {
|
||||
if ( ! function_exists('mb_ereg_replace') ) {
|
||||
return sanitize_file_name($filename);
|
||||
}
|
||||
|
||||
|
@ -1608,10 +1606,10 @@ class MainWP_Helper {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (function_exists('get_current_screen')) {
|
||||
if ( function_exists('get_current_screen') ) {
|
||||
$screen = get_current_screen();
|
||||
if ( $screen ) {
|
||||
if ( $screen->base == 'update-core' && $screen->parent_file == 'index.php' ) {
|
||||
if ( $screen->base == 'update-core' && $screen->parent_file == 'index.php' ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1625,21 +1623,21 @@ class MainWP_Helper {
|
|||
|
||||
public static function check_files_exists( $files = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $name) {
|
||||
if ( ! file_exists( $name )) {
|
||||
if ( is_array($files) ) {
|
||||
foreach ( $files as $name ) {
|
||||
if ( ! file_exists( $name ) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( ! file_exists( $files )) {
|
||||
if ( ! file_exists( $files ) ) {
|
||||
$missing[] = $files;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty($missing)) {
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing file(s): ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1648,11 +1646,11 @@ class MainWP_Helper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_classes_exists( $classes = array(), $return = false) {
|
||||
public static function check_classes_exists( $classes = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($classes)) {
|
||||
foreach ($classes as $name) {
|
||||
if ( ! class_exists( $name )) {
|
||||
if ( is_array($classes) ) {
|
||||
foreach ( $classes as $name ) {
|
||||
if ( ! class_exists( $name ) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
|
@ -1664,7 +1662,7 @@ class MainWP_Helper {
|
|||
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing classes: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1673,25 +1671,24 @@ class MainWP_Helper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_methods( $object, $methods = array(), $return = false) {
|
||||
public static function check_methods( $object, $methods = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($methods)) {
|
||||
if ( is_array($methods) ) {
|
||||
$missing = array();
|
||||
foreach ($methods as $name) {
|
||||
foreach ( $methods as $name ) {
|
||||
if ( ! method_exists($object, $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} elseif ( ! empty($methods)) {
|
||||
} elseif ( ! empty($methods) ) {
|
||||
if ( ! method_exists($object, $methods) ) {
|
||||
$missing[] = $methods;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing method: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1701,24 +1698,23 @@ class MainWP_Helper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_properties( $object, $properties = array(), $return = false) {
|
||||
public static function check_properties( $object, $properties = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($properties)) {
|
||||
foreach ($properties as $name) {
|
||||
if ( is_array($properties) ) {
|
||||
foreach ( $properties as $name ) {
|
||||
if ( ! property_exists($object, $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} elseif ( ! empty($properties)) {
|
||||
} elseif ( ! empty($properties) ) {
|
||||
if ( ! property_exists($object, $properties) ) {
|
||||
$missing[] = $properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing properties: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1728,24 +1724,23 @@ class MainWP_Helper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function check_functions( $funcs = array(), $return = false) {
|
||||
public static function check_functions( $funcs = array(), $return = false ) {
|
||||
$missing = array();
|
||||
if (is_array($funcs)) {
|
||||
foreach ($funcs as $name) {
|
||||
if ( is_array($funcs) ) {
|
||||
foreach ( $funcs as $name ) {
|
||||
if ( ! function_exists( $name) ) {
|
||||
$missing[] = $name;
|
||||
}
|
||||
}
|
||||
} elseif ( ! empty($funcs)) {
|
||||
} elseif ( ! empty($funcs) ) {
|
||||
if ( ! function_exists($funcs) ) {
|
||||
$missing[] = $funcs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty($missing) ) {
|
||||
$message = 'Missing functions: ' . implode(',', $missing);
|
||||
if ($return) {
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
throw new Exception( $message );
|
||||
|
@ -1774,7 +1769,7 @@ class MainWP_Helper {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
|
||||
if ( isset($_POST['function']) && isset($_POST['mainwpsignature']) &&
|
||||
( isset($_POST['mwp_action']) || 'wordpress_seo' == $_POST['function'] ) // wordpress_seo for WordPress SEO
|
||||
) {
|
||||
register_shutdown_function( 'handle_shutdown' );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue