diff --git a/.gitattributes b/.gitattributes
index a810b8d..8f35e6b 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -4,9 +4,8 @@ bin export-ignore
composer.* export-ignore
tests export-ignore
.gitattributes export-ignore
-.phpcs.xml.dist export-ignore
+phpcs.xml export-ignore
.travis.yml export-ignore
LICENSE.md export-ignore
LICENSE.txt export-ignore
README.md export-ignore
-phpunit.xml.dist export-ignore
diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist
deleted file mode 100644
index 067d574..0000000
--- a/.phpcs.xml.dist
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
'; - //print_r( $scan ); - //echo ''; + // echo '
'; + // print_r( $scan ); + // echo ''; } } @@ -2276,31 +2286,30 @@ class MainWP_Child_Back_Up_Buddy { $array_item ) { + foreach ( $array as $array_key => $array_item ) { if ( is_array( $array_item ) ) { - $array[$array_key] = lined_array( $array_item ); + $array[ $array_key ] = lined_array( $array_item ); } } - //return implode( '
', __('Warning: Possible Malware Detected!', 'it-l10n-backupbuddy' ), '',__('See details below.', 'it-l10n-backupbuddy' ), ' |
' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '
', false, '', 'backupbuddy_live_snapshot_verify_uptodate' ); + // pb_backupbuddy::alert( '' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '
', false, '', 'backupbuddy_live_snapshot_verify_uptodate' ); $message = '' . __( 'Please wait while we verify your backup is completely up to date before we create the Snapshot. This may take a few minutes...', 'it-l10n-backupbuddy' ) . '
'; - require( pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php' ); + require pb_backupbuddy::plugin_path() . '/destinations/live/_manual_snapshot.php'; } - } else if ( 'pause_periodic' == $action ) { + } elseif ( 'pause_periodic' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = true ); - $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. - //pb_backupbuddy::disalert( '', __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ) ); + $destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var. + // pb_backupbuddy::disalert( '', __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live File Backup paused. It may take a moment for current processes to finish.', 'it-l10n-backupbuddy' ); - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. - } else if ( 'resume_periodic' == $action ) { + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. + } elseif ( 'resume_periodic' == $action ) { $launchNowText = ' ' . __( 'Unpaused but not running now.', 'it-l10n-backupbuddy' ); - $start_run = false; + $start_run = false; if ( '1' != pb_backupbuddy::_GET( 'skip_run_live_now' ) ) { $launchNowText = ''; - $start_run = true; + $start_run = true; } backupbuddy_api::setLiveStatus( $pause_continuous = '', $pause_periodic = false, $start_run ); - //pb_backupbuddy::disalert( '', __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText ); + // pb_backupbuddy::disalert( '', __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText ); $message = __( 'Live File Backup has resumed.', 'it-l10n-backupbuddy' ) . $launchNowText; - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. - } else if ( 'pause_continuous' == $action ) { + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. + } elseif ( 'pause_continuous' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = true, $pause_periodic = '' ); - $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. - //pb_backupbuddy::disalert( '', __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ) ); + $destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var. + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. + // pb_backupbuddy::disalert( '', __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live Database Backup paused.', 'it-l10n-backupbuddy' ); - } else if ( 'resume_continuous' == $action ) { + } elseif ( 'resume_continuous' == $action ) { backupbuddy_api::setLiveStatus( $pause_continuous = false, $pause_periodic = '' ); - $destination = pb_backupbuddy::$options['remote_destinations'][$destination_id]; // Update local var. - include( pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php' ); // Recalculate stats. - //pb_backupbuddy::disalert( '', __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ) ); + $destination = pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; // Update local var. + include pb_backupbuddy::plugin_path() . '/destinations/live/_stats.php'; // Recalculate stats. + // pb_backupbuddy::disalert( '', __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ) ); $message = __( 'Live Database Backup resumed.', 'it-l10n-backupbuddy' ); } else { $error = 'Error #1000. Invalid request.'; } - return array( 'ok' => 1, '_error' => $error, '_message' => $message ); + return array( + 'ok' => 1, + '_error' => $error, + '_message' => $message, + ); } function download_troubleshooting() { - require( pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php' ); + require pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php'; backupbuddy_live_troubleshooting::run(); - $output = "**File best viewed with wordwrap OFF**\n\n" . print_r( backupbuddy_live_troubleshooting::get_raw_results(), true ); + $output = "**File best viewed with wordwrap OFF**\n\n" . print_r( backupbuddy_live_troubleshooting::get_raw_results(), true ); $backup_prefix = backupbuddy_core::backup_prefix(); - return array( 'output' => $output, 'backup_prefix' => $backup_prefix ); + return array( + 'output' => $output, + 'backup_prefix' => $backup_prefix, + ); } function get_live_backups() { $destination_id = $_POST['destination_id']; // Load required files. - require_once( pb_backupbuddy::plugin_path() . '/destinations/s32/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/s32/init.php'; if ( ! isset( pb_backupbuddy::$options['remote_destinations'][ $destination_id ] ) ) { return array( 'error' => 'Error #9828332: Destination not found with id `' . htmlentities( $destination_id ) . '`.' ); } - require_once( pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php' ); + require_once pb_backupbuddy::plugin_path() . '/destinations/stash2/init.php'; $settings = &pb_backupbuddy::$options['remote_destinations'][ $destination_id ]; $settings = pb_backupbuddy_destination_stash2::_formatSettings( $settings ); @@ -2678,43 +2788,43 @@ class MainWP_Child_Back_Up_Buddy { if ( 'live' == $destination['type'] ) { $remotePath = 'snapshot-';// . backupbuddy_core::backup_prefix(); - $site_only = true; + $site_only = true; } else { // Get list of files for this site. $remotePath = 'backup-';// . backupbuddy_core::backup_prefix(); - $site_only = true; + $site_only = true; } - $files = pb_backupbuddy_destination_stash2::listFiles( $settings, '', $site_only ); //2nd param was $remotePath. + $files = pb_backupbuddy_destination_stash2::listFiles( $settings, '', $site_only ); // 2nd param was $remotePath. if ( ! is_array( $files ) ) { return array( 'error' => 'Error #892329c: ' . $files ); } $backup_list_temp = array(); - foreach( (array)$files as $file ) { + foreach ( (array) $files as $file ) { if ( ( '' != $remotePath ) && ( ! backupbuddy_core::startsWith( basename( $file['filename'] ), $remotePath ) ) ) { // Only show backups for this site unless set to show all. continue; } $last_modified = $file['uploaded_timestamp']; - $size = (double) $file['size']; - $backup_type = backupbuddy_core::getBackupTypeFromFile( $file['filename'], $quiet = false, $skip_fileoptions = true ); + $size = (float) $file['size']; + $backup_type = backupbuddy_core::getBackupTypeFromFile( $file['filename'], $quiet = false, $skip_fileoptions = true ); // Generate array of table rows. - while( isset( $backup_list_temp[$last_modified] ) ) { // Avoid collisions. + while ( isset( $backup_list_temp[ $last_modified ] ) ) { // Avoid collisions. $last_modified += 0.1; } if ( 'live' == $destination['type'] ) { - $backup_list_temp[$last_modified] = array( + $backup_list_temp[ $last_modified ] = array( array( base64_encode( $file['url'] ), '' . pb_backupbuddy::$format->date( pb_backupbuddy::$format->localize_time( $last_modified ) ) . ' (' . pb_backupbuddy::$format->time_ago( $last_modified ) . ' ago)
-
/
-
+ foreach ( $parents as $directory_basename ) {
+ ?>
@@ -793,7 +811,8 @@ class MainWP_Child_Back_Up_Wordpress {
|
- $file ) {
+ $file ) {
$is_excluded = $is_unreadable = false;
@@ -811,7 +830,8 @@ class MainWP_Child_Back_Up_Wordpress {
// Skip unreadable files
if ( ! @realpath( $file->getPathname() ) || ! $file->isReadable() ) {
$is_unreadable = true;
- } ?>
+ }
+ ?>
|||||||||
---|---|---|---|---|---|---|---|---|---|
+ if ( $is_unreadable ) {
+ ?>
getBasename() ); ?>
@@ -852,9 +873,11 @@ class MainWP_Child_Back_Up_Wordpress {
onclick="event.preventDefault(); mainwp_backupwp_directory_browse('getPathname()) ); ?>', this)">getBasename() ); ?>
-
+ if ( $is_unreadable ) {
+ ?>
getBasename() ); ?>
@@ -864,14 +887,16 @@ class MainWP_Child_Back_Up_Wordpress {
getBasename() ); ?>
- isDir() ) {
- //echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
+ isDir() ) {
+ // echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) );
?>
getBasename() ); ?>
-
@@ -897,7 +922,8 @@ class MainWP_Child_Back_Up_Wordpress {
if ( ! $size ) {
$size = '0 B';
- } ?>
+ }
+ ?>
@@ -918,7 +944,8 @@ class MainWP_Child_Back_Up_Wordpress {
| |||||||||
' . __( 'Loaded PHP Extensions:', 'backwpup' ) . ' | ';
$extensions = get_loaded_extensions();
sort( $extensions );
@@ -532,7 +538,10 @@ class MainWP_Child_Back_WP_Up {
ob_end_clean();
- return array( 'success' => 1, 'response' => $output );
+ return array(
+ 'success' => 1,
+ 'response' => $output,
+ );
}
protected function delete_log() {
@@ -601,11 +610,17 @@ class MainWP_Child_Back_WP_Up {
if ( is_array( $file ) && $file['file'] == $backupfile ) {
$dest_class->file_delete( $dest, $backupfile );
- return array( 'success' => 1, 'response' => 'DELETED' );
+ return array(
+ 'success' => 1,
+ 'response' => 'DELETED',
+ );
}
}
- return array( 'success' => 1, 'response' => 'Not found' );
+ return array(
+ 'success' => 1,
+ 'response' => 'Not found',
+ );
}
protected function view_log() {
@@ -615,7 +630,7 @@ class MainWP_Child_Back_WP_Up {
$log_folder = get_site_option( 'backwpup_cfg_logfolder' );
$log_folder = BackWPup_File::get_absolute_path( $log_folder );
- $log_file = $log_folder . basename( $_POST['settings']['logfile'] );
+ $log_file = $log_folder . basename( $_POST['settings']['logfile'] );
if ( ! is_readable( $log_file ) && ! is_readable( $log_file . '.gz' ) && ! is_readable( $log_file . '.bz2' ) ) {
$output = __( 'Log file doesn\'t exists', $this->plugin_translate );
@@ -635,7 +650,10 @@ class MainWP_Child_Back_WP_Up {
}
}
- return array( 'success' => 1, 'response' => $output );
+ return array(
+ 'success' => 1,
+ 'response' => $output,
+ );
}
protected function tables() {
@@ -661,7 +679,10 @@ class MainWP_Child_Back_WP_Up {
$log_folder = untrailingslashit( $log_folder );
if ( ! is_dir( $log_folder ) ) {
- return array( 'success' => 1, 'response' => $array );
+ return array(
+ 'success' => 1,
+ 'response' => $array,
+ );
}
update_user_option( get_current_user_id(), 'backwpuplogs_per_page', 99999999 );
$output = new BackWPup_Page_Logs();
@@ -687,13 +708,13 @@ class MainWP_Child_Back_WP_Up {
if ( is_null($dest_class) ) {
continue;
}
- $items = $dest_class->file_get_list( $jobid . '_' . $dest );
+ $items = $dest_class->file_get_list( $jobid . '_' . $dest );
if ( ! empty( $items ) ) {
foreach ( $items as $item ) {
- $temp_single_item = $item;
- $temp_single_item['dest'] = $jobid . '_' . $dest;
- $temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item[ 'time' ], TRUE ), date_i18n( get_option( 'time_format' ), $temp_single_item[ 'time' ], TRUE ) );
- $output->items[] = $temp_single_item;
+ $temp_single_item = $item;
+ $temp_single_item['dest'] = $jobid . '_' . $dest;
+ $temp_single_item['timeloc'] = sprintf( __( '%1$s at %2$s', 'backwpup' ), date_i18n( get_option( 'date_format' ), $temp_single_item['time'], true ), date_i18n( get_option( 'time_format' ), $temp_single_item['time'], true ) );
+ $output->items[] = $temp_single_item;
}
}
}
@@ -744,7 +765,7 @@ class MainWP_Child_Back_WP_Up {
$temp_array['website_id'] = $website_id;
$array[] = $temp_array;
}
- } else if ( $type == 'backups' ) {
+ } elseif ( $type == 'backups' ) {
$without_dupes = array();
foreach ( $output->items as $key ) {
$temp_array = $key;
@@ -755,18 +776,18 @@ class MainWP_Child_Back_WP_Up {
'&',
admin_url( 'admin-ajax.php' ) . '?action=mainwp_backwpup_download_backup&type=',
), $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 ( !empty( $matches[1] ) && is_numeric( $matches[1] ) ) {
- $temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1];
- }
- error_log('did match' . print_r($matches, true));
+ if ( ! empty( $matches[1] ) && is_numeric( $matches[1] ) ) {
+ $temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1];
+ }
+ error_log('did match' . print_r($matches, true));
} else {
error_log('not match');
}
-
- $temp_array['website_id'] = $website_id;
+
+ $temp_array['website_id'] = $website_id;
if ( ! isset( $without_dupes[ $temp_array['file'] ] ) ) {
$array[] = $temp_array;
@@ -780,11 +801,14 @@ class MainWP_Child_Back_WP_Up {
}
}
- return array( 'success' => 1, 'response' => $array );
+ return array(
+ 'success' => 1,
+ 'response' => $array,
+ );
}
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;
}
?>
@@ -798,8 +822,8 @@ class MainWP_Child_Back_WP_Up {
verify_nonce_without_session( $_GET['_wpnonce'], 'mainwp_download_backup' ) ) {
die( '-3' );
}
-
+
$dest = strtoupper( str_replace( 'download', '', $_GET['type'] ) );
if ( ! empty( $dest ) && strstr( $_GET['type'], 'download' ) ) {
$dest_class = BackWPup::get_destination( $dest );
if ( is_null( $dest_class ) ) {
die( '-4' );
- }
+ }
$dest_class->file_download( (int) $_GET['jobid'], $_GET['file'] );
} else {
die( '-5' );
- }
+ }
die();
- }
+ }
protected function create_nonce_without_session( $action = - 1 ) {
$user = wp_get_current_user();
@@ -897,7 +921,10 @@ class MainWP_Child_Back_WP_Up {
ob_end_clean();
- return array( 'success' => 1, 'response' => $output );
+ return array(
+ 'success' => 1,
+ 'response' => $output,
+ );
}
protected function backup_now() {
@@ -933,7 +960,10 @@ class MainWP_Child_Back_WP_Up {
'logfile' => basename( $job_object->logfile ),
);
} else {
- return array( 'success' => 1, 'response' => $output['message'] );
+ return array(
+ 'success' => 1,
+ 'response' => $output['message'],
+ );
}
}
}
@@ -955,7 +985,10 @@ class MainWP_Child_Back_WP_Up {
if ( isset( $output['error'] ) ) {
return array( 'error' => 'Cannot abort: ' . $output['error'] );
} else {
- return array( 'success' => 1, 'response' => $output['message'] );
+ return array(
+ 'success' => 1,
+ 'response' => $output['message'],
+ );
}
}
@@ -969,12 +1002,11 @@ class MainWP_Child_Back_WP_Up {
if ( ! function_exists( 'add_screen_option' ) ) {
function add_screen_option( $option, $args = array() ) {
-
}
}
if ( ! class_exists( 'WP_List_Table' ) ) {
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
}
@@ -989,7 +1021,10 @@ class MainWP_Child_Back_WP_Up {
ob_end_clean();
- return array( 'success' => 1, 'response' => $output );
+ return array(
+ 'success' => 1,
+ 'response' => $output,
+ );
} else {
return array( 'error' => 'Missing BackWPup_Pro_Wizard_SystemTest' );
}
@@ -1014,7 +1049,7 @@ class MainWP_Child_Back_WP_Up {
// From BackWPup_Destination_Email::edit_ajax
if ( $emailmethod ) {
- //do so if i'm the wp_mail to get the settings
+ // do so if i'm the wp_mail to get the settings
global $phpmailer;
// (Re)create it, if it's gone missing
if ( ! is_object( $phpmailer ) || ! $phpmailer instanceof PHPMailer ) {
@@ -1022,10 +1057,10 @@ class MainWP_Child_Back_WP_Up {
require_once ABSPATH . WPINC . '/class-smtp.php';
$phpmailer = new PHPMailer( true );
}
- //only if PHPMailer really used
+ // only if PHPMailer really used
if ( is_object( $phpmailer ) ) {
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
- //get settings from PHPMailer
+ // get settings from PHPMailer
$emailmethod = $phpmailer->Mailer;
$emailsendmail = $phpmailer->Sendmail;
$emailhost = $phpmailer->Host;
@@ -1036,7 +1071,7 @@ class MainWP_Child_Back_WP_Up {
}
}
- //Generate mail with Swift Mailer
+ // Generate mail with Swift Mailer
if ( ! class_exists( 'Swift', false ) ) {
require BackWPup::get_plugin_data( 'plugindir' ) . '/vendor/SwiftMailer/swift_required.php';
}
@@ -1088,7 +1123,10 @@ class MainWP_Child_Back_WP_Up {
}
}
- return array( 'success' => 1, 'message' => $message );
+ return array(
+ 'success' => 1,
+ 'message' => $message,
+ );
}
protected function get_job_files() {
@@ -1137,9 +1175,9 @@ class MainWP_Child_Back_WP_Up {
if ( $dir = @opendir( $main_folder_name ) ) {
while ( ( $file = readdir( $dir ) ) !== false ) {
if ( ! in_array( $file, array(
- '.',
- '..',
- ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) )
+ '.',
+ '..',
+ ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) )
) {
$folder_size = ' (' . size_format( BackWPup_File::get_folder_size( $main_folder_name . '/' . $file ), 2 ) . ')';
@@ -1154,11 +1192,18 @@ class MainWP_Child_Back_WP_Up {
@closedir( $dir );
}
- $return[ $key ] = array( 'size' => $main_folder_size, 'name' => $folder, 'folders' => $return_temp );
+ $return[ $key ] = array(
+ 'size' => $main_folder_size,
+ 'name' => $folder,
+ 'folders' => $return_temp,
+ );
}
}
- return array( 'success' => 1, 'folders' => $return );
+ return array(
+ 'success' => 1,
+ 'folders' => $return,
+ );
}
protected function get_child_tables() {
@@ -1213,7 +1258,10 @@ class MainWP_Child_Back_WP_Up {
if (isset($settings['job_id'])) {
$return['dbdumpexclude'] = BackWPup_Option::get( $settings['job_id'], 'dbdumpexclude' );
}
- return array( 'success' => 1, 'return' => $return );
+ return array(
+ 'success' => 1,
+ 'return' => $return,
+ );
}
protected function insert_or_update_jobs_global() {
@@ -1287,29 +1335,29 @@ class MainWP_Child_Back_WP_Up {
// From BackWPup_JobType_File::edit_form_post_save with some tweaks
public function edit_form_post_save( $post_data, $id ) {
// Parse and save files to exclude
- $exclude_input = $post_data['fileexclude'];
- $to_exclude_list = $exclude_input ? str_replace( array( "\r\n", "\r" ), ',', $exclude_input ) : array();
+ $exclude_input = $post_data['fileexclude'];
+ $to_exclude_list = $exclude_input ? str_replace( array( "\r\n", "\r" ), ',', $exclude_input ) : array();
$to_exclude_list and $to_exclude_list = sanitize_text_field( stripslashes( $to_exclude_list ) );
- $to_exclude = $to_exclude_list ? explode( ',', $to_exclude_list ) : array();
- $to_exclude_parsed = array();
+ $to_exclude = $to_exclude_list ? explode( ',', $to_exclude_list ) : array();
+ $to_exclude_parsed = array();
foreach ( $to_exclude as $key => $value ) {
- $normalized = wp_normalize_path( trim( $value ) );
- $normalized and $to_exclude_parsed[$key] = $normalized;
+ $normalized = wp_normalize_path( trim( $value ) );
+ $normalized and $to_exclude_parsed[ $key ] = $normalized;
}
sort( $to_exclude_parsed );
BackWPup_Option::update( $id, 'fileexclude', implode( ',', $to_exclude_parsed ) );
unset( $exclude_input, $to_exclude_list, $to_exclude, $to_exclude_parsed, $normalized );
// Parse and save folders to include
- $include_input = $post_data['dirinclude'];
- $include_list = $include_input ? str_replace( array( "\r\n", "\r" ), ',', $include_input ) : array();
- $to_include = $include_list ? explode( ',', $include_list ) : array();
+ $include_input = $post_data['dirinclude'];
+ $include_list = $include_input ? str_replace( array( "\r\n", "\r" ), ',', $include_input ) : array();
+ $to_include = $include_list ? explode( ',', $include_list ) : array();
$to_include_parsed = array();
foreach ( $to_include as $key => $value ) {
- $normalized = trailingslashit( wp_normalize_path( trim( $value ) ) );
- $normalized and $normalized = filter_var( $normalized, FILTER_SANITIZE_URL );
- $realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false;
- $realpath and $to_include_parsed[$key] = $realpath;
+ $normalized = trailingslashit( wp_normalize_path( trim( $value ) ) );
+ $normalized and $normalized = filter_var( $normalized, FILTER_SANITIZE_URL );
+ $realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false;
+ $realpath and $to_include_parsed[ $key ] = $realpath;
}
sort( $to_include_parsed );
BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) );
@@ -1327,19 +1375,34 @@ class MainWP_Child_Back_WP_Up {
'backupuploads' => FILTER_VALIDATE_BOOLEAN,
);
- foreach( $boolean_fields_def as $key => $value ) {
- BackWPup_Option::update( $id, $key, ! empty( $post_data[$key] ) );
+ foreach ( $boolean_fields_def as $key => $value ) {
+ BackWPup_Option::update( $id, $key, ! empty( $post_data[ $key ] ) );
}
// Parse and save directories to exclude
$exclude_dirs_def = array(
- 'backuprootexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
- 'backuppluginsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
- 'backupcontentexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
- 'backupthemesexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
- 'backupuploadsexcludedirs' => array( 'filter' => FILTER_SANITIZE_URL, 'flags' => FILTER_FORCE_ARRAY ),
+ 'backuprootexcludedirs' => array(
+ 'filter' => FILTER_SANITIZE_URL,
+ 'flags' => FILTER_FORCE_ARRAY,
+ ),
+ 'backuppluginsexcludedirs' => array(
+ 'filter' => FILTER_SANITIZE_URL,
+ 'flags' => FILTER_FORCE_ARRAY,
+ ),
+ 'backupcontentexcludedirs' => array(
+ 'filter' => FILTER_SANITIZE_URL,
+ 'flags' => FILTER_FORCE_ARRAY,
+ ),
+ 'backupthemesexcludedirs' => array(
+ 'filter' => FILTER_SANITIZE_URL,
+ 'flags' => FILTER_FORCE_ARRAY,
+ ),
+ 'backupuploadsexcludedirs' => array(
+ 'filter' => FILTER_SANITIZE_URL,
+ 'flags' => FILTER_FORCE_ARRAY,
+ ),
);
- foreach( $exclude_dirs_def as $key => $filter ) {
- $value = ! empty( $post_data[$key] ) && is_array( $post_data[$key] ) ? $post_data[$key] : array();
+ foreach ( $exclude_dirs_def as $key => $filter ) {
+ $value = ! empty( $post_data[ $key ] ) && is_array( $post_data[ $key ] ) ? $post_data[ $key ] : array();
BackWPup_Option::update( $id, $key, $value );
}
}
@@ -1367,7 +1430,7 @@ class MainWP_Child_Back_WP_Up {
if ( $settings['job_id'] > 0 ) {
$job_id = intval( $settings['job_id'] );
} else {
- //generate jobid if not exists
+ // generate jobid if not exists
$newjobid = BackWPup_Option::get_job_ids();
sort( $newjobid );
$job_id = end( $newjobid ) + 1;
@@ -1376,8 +1439,8 @@ class MainWP_Child_Back_WP_Up {
update_site_option( 'backwpup_messages', array() );
if (isset($settings['value']['backupdir']) && empty($settings['value']['backupdir'])) {
- $backupdir = BackWPup_Option::get( (int)$job_id, 'backupdir' );
- if (!empty($backupdir)) {
+ $backupdir = BackWPup_Option::get( (int) $job_id, 'backupdir' );
+ if ( ! empty($backupdir)) {
$settings['value']['backupdir'] = $backupdir;
}
}
@@ -1389,13 +1452,13 @@ class MainWP_Child_Back_WP_Up {
if ($settings['tab'] == 'jobtype-FILE') {
// to fix
$this->edit_form_post_save($settings['value'], $job_id);
- //saved message
+ // saved message
$messages = BackWPup_Admin::get_messages();
if ( empty( $messages['error'] ) ) {
$url = BackWPup_Job::get_jobrun_url( 'runnowlink', $job_id );
BackWPup_Admin::message( sprintf( __( 'Changes for job %s saved.', 'backwpup' ), BackWPup_Option::get( $job_id, 'name' ) ) . ' ' . __( 'Jobs overview', 'backwpup' ) . ' | ' . __( 'Run now', 'backwpup' ) . '' );
}
- } else if ($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 {
@@ -1437,7 +1500,7 @@ class MainWP_Child_Back_WP_Up {
if ( ! in_array( $key, $this->exclusions[ $settings['tab'] ] ) && strcmp( $temp_value, $val ) != 0 ) {
$changes_array[ $key ] = $temp_value;
}
- } else if ( strcmp( $temp_value, $val ) != 0 ) {
+ } elseif ( strcmp( $temp_value, $val ) != 0 ) {
$changes_array[ $key ] = $temp_value;
}
}
@@ -1473,7 +1536,7 @@ class MainWP_Child_Back_WP_Up {
update_site_option( 'backwpup_messages', array() );
- $settings_views = array();
+ $settings_views = array();
$settings_updaters = array();
$backwpup = new BackWPup_Page_Settings($settings_views, $settings_updaters);
@@ -1510,7 +1573,11 @@ class MainWP_Child_Back_WP_Up {
}
}
- return array( 'success' => 1, 'changes' => $changes_array, 'message' => $return['message'] );
+ return array(
+ 'success' => 1,
+ 'changes' => $changes_array,
+ 'message' => $return['message'],
+ );
}
protected function check_backwpup_messages() {
@@ -1519,12 +1586,11 @@ class MainWP_Child_Back_WP_Up {
if ( isset( $message['error'] ) ) {
return array( 'error' => implode( ', ', $message['error'] ) );
- } else if ( isset( $message['updated'] ) ) {
+ } elseif ( isset( $message['updated'] ) ) {
return array( 'message' => $message['updated'] );
} else {
return array( 'error' => 'Generic error' );
}
-
}
}
diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php
index 0b560de..db15879 100644
--- a/class/class-mainwp-child-branding.php
+++ b/class/class-mainwp-child-branding.php
@@ -7,10 +7,10 @@ class MainWP_Child_Branding {
public $child_branding_options = null;
static function Instance() {
- if ( null === MainWP_Child_Branding::$instance ) {
- MainWP_Child_Branding::$instance = new MainWP_Child_Branding();
+ if ( null === self::$instance ) {
+ self::$instance = new MainWP_Child_Branding();
}
- return MainWP_Child_Branding::$instance;
+ return self::$instance;
}
public function __construct() {
@@ -20,11 +20,11 @@ class MainWP_Child_Branding {
$this->child_branding_options = $this->init_options();
}
- function init_options(){
+ function init_options() {
$opts = get_option( 'mainwp_child_branding_settings' );
- if ( !is_array( $opts ) ) {
+ if ( ! is_array( $opts ) ) {
// compatible with old code
$opts = array();
@@ -33,20 +33,20 @@ class MainWP_Child_Branding {
$label = stripslashes( $label );
}
- $opts['contact_label'] = $label;
- $opts['extra_settings'] = get_option( 'mainwp_branding_extra_settings' );
+ $opts['contact_label'] = $label;
+ $opts['extra_settings'] = get_option( 'mainwp_branding_extra_settings' );
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $opts );
}
- if ( !isset($opts['contact_label']) || empty($opts['contact_label']) ) {
+ if ( ! isset($opts['contact_label']) || empty($opts['contact_label']) ) {
$opts['contact_label'] = 'Contact Support';
}
- $disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
- $preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
+ $disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
+ $preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
$cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
- $opts['cancelled_branding'] = $cancelled_branding;
+ $opts['cancelled_branding'] = $cancelled_branding;
$opts['branding_preserve_title'] = '';
if ( ! $cancelled_branding ) {
@@ -56,9 +56,9 @@ class MainWP_Child_Branding {
$opts['branding_preserve_title'] = stripslashes( $branding_header['name'] );
}
}
- }
-
- $opts = apply_filters( 'mainwp_child_branding_init_options', $opts );
+ }
+
+ $opts = apply_filters( 'mainwp_child_branding_init_options', $opts );
return $opts;
}
@@ -66,8 +66,9 @@ class MainWP_Child_Branding {
$extra = array();
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();
+ }
}
return $extra;
@@ -109,7 +110,7 @@ class MainWP_Child_Branding {
'mainwp_branding_remove_wp_tools',
'mainwp_branding_remove_wp_setting',
'mainwp_branding_remove_permalink',
- //'mainwp_branding_plugin_header', // don't remove header
+ // 'mainwp_branding_plugin_header', // don't remove header
'mainwp_branding_button_contact_label',
'mainwp_branding_send_email_message',
'mainwp_branding_message_return_sender',
@@ -135,7 +136,7 @@ class MainWP_Child_Branding {
'remove_wp_tools',
'remove_wp_setting',
'remove_permalink',
- //'branding_header', // don't remove header
+ // 'branding_header', // don't remove header
'contact_label',
'email_message',
'message_return_sender',
@@ -144,13 +145,12 @@ class MainWP_Child_Branding {
'branding_ext_enabled',
);
- foreach($brandingOptions_empty as $opt) {
- if (isset($this->child_branding_options[$opt])) {
- $this->child_branding_options[$opt] = '';
+ foreach ($brandingOptions_empty as $opt) {
+ if (isset($this->child_branding_options[ $opt ])) {
+ $this->child_branding_options[ $opt ] = '';
}
}
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
-
}
@@ -171,10 +171,10 @@ class MainWP_Child_Branding {
return $information;
}
- $current_settings = $this->child_branding_options;
+ $current_settings = $this->child_branding_options;
$current_extra_setting = $this->child_branding_options['extra_settings'];
- //MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
+ // MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
$current_settings['branding_ext_enabled'] = 'Y';
$header = array(
@@ -187,41 +187,41 @@ class MainWP_Child_Branding {
MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' ); // to compatible with old version of child report plugin
MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' ); // to compatible
-// MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
-// MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
-// MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
-// MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
-// MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
-// MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
-// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
-// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
-// MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
-// MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
-// MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
-// MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
-// MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
-// if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
-// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
-// }
+ // MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
+ // MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
+ // MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
+ // MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
+ // MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
+ // MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
+ // MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
+ // if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
+ // }
- $current_settings['preserve_branding'] = $settings['child_preserve_branding'];
- $current_settings['branding_header'] = $header;
- $current_settings['support_email'] = $settings['child_support_email'];
- $current_settings['support_message'] = $settings['child_support_message'];
- $current_settings['remove_restore'] = $settings['child_remove_restore'];
- $current_settings['remove_setting'] = $settings['child_remove_setting'];
- $current_settings['remove_server_info'] = $settings['child_remove_server_info'];
- $current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0 ;
- $current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
- $current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
- $current_settings['remove_permalink'] = $settings['child_remove_permalink'];
- $current_settings['contact_label'] = $settings['child_button_contact_label'];
- $current_settings['email_message'] = $settings['child_send_email_message'];
- $current_settings['return_sender'] = $settings['child_message_return_sender'];
- $current_settings['submit_button_title'] = $settings['child_submit_button_title'];
+ $current_settings['preserve_branding'] = $settings['child_preserve_branding'];
+ $current_settings['branding_header'] = $header;
+ $current_settings['support_email'] = $settings['child_support_email'];
+ $current_settings['support_message'] = $settings['child_support_message'];
+ $current_settings['remove_restore'] = $settings['child_remove_restore'];
+ $current_settings['remove_setting'] = $settings['child_remove_setting'];
+ $current_settings['remove_server_info'] = $settings['child_remove_server_info'];
+ $current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0;
+ $current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
+ $current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
+ $current_settings['remove_permalink'] = $settings['child_remove_permalink'];
+ $current_settings['contact_label'] = $settings['child_button_contact_label'];
+ $current_settings['email_message'] = $settings['child_send_email_message'];
+ $current_settings['return_sender'] = $settings['child_message_return_sender'];
+ $current_settings['submit_button_title'] = $settings['child_submit_button_title'];
if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
- $current_settings['disable_wp_branding'] = $settings['child_disable_wp_branding'];
+ $current_settings['disable_wp_branding'] = $settings['child_disable_wp_branding'];
}
$extra_setting = array(
@@ -233,8 +233,8 @@ class MainWP_Child_Branding {
'remove_widget_activity' => $settings['child_remove_widget_activity'],
'remove_widget_quick' => $settings['child_remove_widget_quick'],
'remove_widget_news' => $settings['child_remove_widget_news'],
- 'login_image_link' => $settings['child_login_image_link'],
- 'login_image_title' => $settings['child_login_image_title'],
+ 'login_image_link' => $settings['child_login_image_link'],
+ 'login_image_title' => $settings['child_login_image_title'],
'site_generator' => $settings['child_site_generator'],
'generator_link' => $settings['child_generator_link'],
'admin_css' => $settings['child_admin_css'],
@@ -266,9 +266,12 @@ class MainWP_Child_Branding {
$extra_setting['login_image'] = array();
} else {
try {
- $upload = $this->uploadImage( $settings['child_login_image_url'] ); //Upload image to WP
+ $upload = $this->uploadImage( $settings['child_login_image_url'] ); // Upload image to WP
if ( null !== $upload ) {
- $extra_setting['login_image'] = array( 'path' => $upload['path'], 'url' => $upload['url'] );
+ $extra_setting['login_image'] = array(
+ 'path' => $upload['path'],
+ 'url' => $upload['url'],
+ );
if ( isset( $current_extra_setting['login_image']['path'] ) ) {
$old_file = $current_extra_setting['login_image']['path'];
if ( ! empty( $old_file ) && file_exists( $old_file ) ) {
@@ -280,7 +283,7 @@ class MainWP_Child_Branding {
$information['error']['login_image'] = $e->getMessage();
}
}
- } else if ( isset( $current_extra_setting['login_image'] ) ) {
+ } elseif ( isset( $current_extra_setting['login_image'] ) ) {
$extra_setting['login_image'] = $current_extra_setting['login_image'];
}
@@ -289,9 +292,12 @@ class MainWP_Child_Branding {
$extra_setting['favico_image'] = array();
} else {
try {
- $upload = $this->uploadImage( $settings['child_favico_image_url'] ); //Upload image to WP
+ $upload = $this->uploadImage( $settings['child_favico_image_url'] ); // Upload image to WP
if ( null !== $upload ) {
- $extra_setting['favico_image'] = array( 'path' => $upload['path'], 'url' => $upload['url'] );
+ $extra_setting['favico_image'] = array(
+ 'path' => $upload['path'],
+ 'url' => $upload['url'],
+ );
if ( isset( $current_extra_setting['favico_image']['path'] ) ) {
$old_file = $current_extra_setting['favico_image']['path'];
if ( ! empty( $old_file ) && file_exists( $old_file ) ) {
@@ -303,11 +309,11 @@ class MainWP_Child_Branding {
$information['error']['favico_image'] = $e->getMessage();
}
}
- } else if ( isset( $current_extra_setting['favico_image'] ) ) {
+ } elseif ( isset( $current_extra_setting['favico_image'] ) ) {
$extra_setting['favico_image'] = $current_extra_setting['favico_image'];
}
- //MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
+ // MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
$current_settings['extra_settings'] = $extra_setting;
// keep it to compatible with old version of child reports plugin
@@ -316,28 +322,28 @@ class MainWP_Child_Branding {
} else {
MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' );
}
-//
-// if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
-// MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
-// } else {
-// MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
-// }
+ //
+ // if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
+ // MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
+ // } else {
+ // MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
+ // }
-// if ( $settings['child_disable_change'] ) {
-// MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
-// } else {
-// MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
-// }
+ // if ( $settings['child_disable_change'] ) {
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
+ // } else {
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
+ // }
-// if ( $settings['child_disable_switching_theme'] ) {
-// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
-// } else {
-// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
-// }
+ // if ( $settings['child_disable_switching_theme'] ) {
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
+ // } else {
+ // MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
+ // }
- $current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
- $current_settings['show_support'] = ( $settings['child_show_support_button'] && !empty($settings['child_support_email']) ) ? 'T' : '';
- $current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
+ $current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
+ $current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : '';
+ $current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
$current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : '';
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $current_settings );
@@ -348,10 +354,10 @@ class MainWP_Child_Branding {
}
static function uploadImage( $img_url ) {
- include_once( ABSPATH . 'wp-admin/includes/file.php' ); //Contains download_url
+ include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
global $mainWPChild;
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
- //Download $img_url
+ // Download $img_url
$temporary_file = download_url( $img_url );
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
@@ -359,12 +365,15 @@ class MainWP_Child_Branding {
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
} else {
$upload_dir = wp_upload_dir();
- $local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); //Local name
+ $local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); // Local name
$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 );
$moved = @rename( $temporary_file, $local_img_path );
if ( $moved ) {
- return array( 'path' => $local_img_path, 'url' => $local_img_url );
+ return array(
+ 'path' => $local_img_path,
+ 'url' => $local_img_url,
+ );
}
}
if ( file_exists( $temporary_file ) ) {
@@ -383,7 +392,7 @@ class MainWP_Child_Branding {
if (is_admin()) {
// back end
add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) );
- } else if (is_user_logged_in()) {
+ } elseif (is_user_logged_in()) {
// front end
add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' ));
}
@@ -402,7 +411,7 @@ class MainWP_Child_Branding {
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
}
- if ( !isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
+ if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
return;
}
@@ -410,29 +419,32 @@ class MainWP_Child_Branding {
if ( 'T' === $opts['disable_change']) {
- // Disable the wordpress plugin update notifications
+ // Disable the WordPress plugin update notifications
remove_action('load-update-core.php', 'wp_update_plugins');
add_filter('pre_site_transient_update_plugins', '__return_null');
- // Disable the wordpress theme update notifications
+ // 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){ return null;} ));
+ add_filter('pre_site_transient_update_themes', ( $func = function( $a) {
+ return null;
+ } ));
- // Disable the wordpress core update notifications
+ // Disable the WordPress core update notifications
add_action('after_setup_theme', 'remove_core_updates');
function remove_core_updates() {
- add_action('init', ( $func = function($a){ remove_action( 'wp_version_check', 'wp_version_check' );} ), 2);
+ add_action('init', ( $func = function( $a) {
+ remove_action( 'wp_version_check', 'wp_version_check' );
+ } ), 2);
add_filter('pre_option_update_core', '__return_null');
add_filter('pre_site_transient_update_core', '__return_null');
}
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
- add_action( 'admin_menu', array($this, 'branding_redirect' ), 9);
+ add_action( 'admin_menu', array( $this, 'branding_redirect' ), 9);
}
// to fix
- add_action( 'admin_menu', array( &$this, 'admin_menu' ) );//
- if ( !isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
+ add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); if ( ! isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
// branding site generator
@@ -448,13 +460,13 @@ class MainWP_Child_Branding {
add_filter( 'login_headertext', array( &$this, 'custom_login_headertitle' ) );
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
- //remove_filter( 'update_footer', 'core_update_footer' );
+ // remove_filter( 'update_footer', 'core_update_footer' );
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
}
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
- add_action( 'admin_init', array($this, 'admin_init'));
+ add_action( 'admin_init', array( $this, 'admin_init' ));
}
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
@@ -470,9 +482,8 @@ class MainWP_Child_Branding {
// to fix conflict with other plugin
function admin_menu() {
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
- if ( $allow_contact ) {
- ; // ok
- } else if ( !current_user_can( 'administrator' ) ) {
+ if ( $allow_contact ) {; // ok
+ } elseif ( ! current_user_can( 'administrator' ) ) {
return false;
}
@@ -500,7 +511,6 @@ class MainWP_Child_Branding {
add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
}
}
-
}
function remove_default_post_metaboxes() {
@@ -630,7 +640,8 @@ class MainWP_Child_Branding {
el.parentElement.innerHTML = '';
}
});
-
+ child_branding_options['support_email'];
- $sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) );
- $from = trim($_POST['mainwp_branding_contact_send_from']);
- $subject = !empty( $sub ) ? $sub : "MainWP - Support Contact";
+ $sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) );
+ $from = trim($_POST['mainwp_branding_contact_send_from']);
+ $subject = ! empty( $sub ) ? $sub : 'MainWP - Support Contact';
$content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) );
- $mail = $headers = '';
+ $mail = $headers = '';
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))
- $headers .= "From: \"" . $from . "\" <" . $from . ">\r\n";
+ if ( ! empty($from)) {
+ $headers .= 'From: "' . $from . '" <' . $from . ">\r\n";
+ }
$mail .= " Support Email from: " . site_url() . " \r\n\r\n"; - $mail .= "Sent from WordPress page: " . ( ! empty( $_POST["mainwp_branding_send_from_page"] ) ? "" . esc_url( $_POST["mainwp_branding_send_from_page"] ) . " \r\n\r\n" : "" ); - $mail .= "Client Email: " . $current_user->user_email . " \r\n\r\n"; + $mail .= 'Sent from WordPress page: ' . ( ! empty( $_POST['mainwp_branding_send_from_page'] ) ? "" . esc_url( $_POST['mainwp_branding_send_from_page'] ) . " \r\n\r\n" : '' ); + $mail .= 'Client Email: ' . $current_user->user_email . " \r\n\r\n"; $mail .= "Support Text: \r\n\r\n"; - $mail .= "" . $content . " \r\n\r\n"; + $mail .= '' . $content . " \r\n\r\n"; - if ( @wp_mail( $email, $subject, $mail, $headers ) ) { - ; + if ( @wp_mail( $email, $subject, $mail, $headers ) ) {; } return true; @@ -860,7 +871,8 @@ class MainWP_Child_Branding { } ?> + user_email : ''; + $from_email = $current_user ? $current_user->user_email : ''; ?> - 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; } - $is_hide = isset( $opts['hide'] ) ? $opts['hide'] : ''; + $is_hide = isset( $opts['hide'] ) ? $opts['hide'] : ''; $cancelled_branding = $opts['cancelled_branding']; - $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : ''; + $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : ''; if ( $cancelled_branding ) { return false; @@ -966,7 +978,7 @@ class MainWP_Child_Branding { if ( 'T' === $is_hide ) { return true; } - if ( is_array( $branding_header ) && !empty( $branding_header['name'] ) ) { + if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) { return true; } return false; @@ -985,30 +997,31 @@ class MainWP_Child_Branding { } public function save_branding_options( $name, $val ) { - $this->child_branding_options[$name] = $val; + $this->child_branding_options[ $name ] = $val; MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options ); } public function after_admin_bar_render() { - $hide_slugs = apply_filters('mainwp_child_hide_update_notice' , array()); + $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) { return; } - if (!function_exists('get_plugin_updates')) { - include_once( ABSPATH . '/wp-admin/includes/update.php' ); + 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) { + foreach ($updates as $slug => $data) { if (in_array($slug, $hide_slugs)) { $count_hide++; } @@ -1037,22 +1050,23 @@ class MainWP_Child_Branding { $adminBarUpdates.textContent = itemCount; } }); - + $data) { + foreach ($updates as $slug => $data) { if (in_array($slug, $hide_slugs)) { $count_hide++; } @@ -1115,7 +1129,8 @@ class MainWP_Child_Branding { }); } }); - + child_branding_options; if ( is_array($opts) ) { - $is_hide = isset( $opts['hide'] ) ? $opts['hide'] : ''; + $is_hide = isset( $opts['hide'] ) ? $opts['hide'] : ''; $cancelled_branding = $opts['cancelled_branding']; - $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : ''; + $branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : ''; if ( $cancelled_branding ) { return $plugins; @@ -1170,7 +1185,7 @@ class MainWP_Child_Branding { return $value; } - if (! MainWP_Helper::is_screen_with_update()) { + if ( ! MainWP_Helper::is_screen_with_update()) { return $value; } diff --git a/class/class-mainwp-child-db.php b/class/class-mainwp-child-db.php index e83e493..bf5bb9e 100644 --- a/class/class-mainwp-child-db.php +++ b/class/class-mainwp-child-db.php @@ -1,7 +1,7 @@ dbh ); + $rows = self::_query( 'SHOW table STATUS', $wpdb->dbh ); $size = 0; - while ( $row = MainWP_Child_DB::fetch_array( $rows ) ) { + while ( $row = self::fetch_array( $rows ) ) { $size += $row['Data_length']; } diff --git a/class/class-mainwp-child-ithemes-security.php b/class/class-mainwp-child-ithemes-security.php index ba421d3..1495785 100644 --- a/class/class-mainwp-child-ithemes-security.php +++ b/class/class-mainwp-child-ithemes-security.php @@ -16,36 +16,37 @@ */ class MainWP_Child_iThemes_Security { - public static $instance = null; + public static $instance = null; public $is_plugin_installed = false; static function Instance() { - if ( null === MainWP_Child_iThemes_Security::$instance ) { - MainWP_Child_iThemes_Security::$instance = new MainWP_Child_iThemes_Security(); + if ( null === self::$instance ) { + self::$instance = new MainWP_Child_iThemes_Security(); } - return MainWP_Child_iThemes_Security::$instance; + return self::$instance; } public function __construct() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'better-wp-security/better-wp-security.php') || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) { $this->is_plugin_installed = true; } - if (!$this->is_plugin_installed) + if ( ! $this->is_plugin_installed) { return; + } add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 ); } // ok function syncOthersData( $information, $data = array() ) { if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) { - try{ + try { $information['syncIThemeData'] = array( - 'users_and_roles' => $this->get_available_admin_users_and_roles() + 'users_and_roles' => $this->get_available_admin_users_and_roles(), ); - } catch(Exception $e) { + } catch (Exception $e) { error_log($e->getMessage()); } } @@ -54,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 ); } @@ -63,7 +64,6 @@ class MainWP_Child_iThemes_Security { $mainwp_itsec_modules_path = ITSEC_Core::get_core_dir() . '/modules/'; - if ( isset( $_POST['mwp_action'] ) ) { switch ( $_POST['mwp_action'] ) { case 'set_showhide': @@ -131,15 +131,16 @@ class MainWP_Child_iThemes_Security { } public function ithemes_init() { - if (!$this->is_plugin_installed) + if ( ! $this->is_plugin_installed) { return; + } if ( get_option( 'mainwp_ithemes_hide_plugin' ) === 'hide' ) { add_filter( 'all_plugins', array( $this, 'all_plugins' ) ); add_action( 'admin_menu', array( $this, 'remove_menu' ) ); add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'admin_head', array( &$this, 'custom_admin_css' ) ); - if ( isset($_GET['page']) && ($_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check') ) { + if ( isset($_GET['page']) && ( $_GET['page'] == 'itsec' || $_GET['page'] == 'itsec-security-check' ) ) { wp_redirect( get_option( 'siteurl' ) . '/wp-admin/index.php' ); exit(); } @@ -178,7 +179,7 @@ class MainWP_Child_iThemes_Security { function save_settings() { if ( ! class_exists( 'ITSEC_Lib' ) ) { - require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' ); + require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; } $_itsec_modules = array( @@ -193,73 +194,74 @@ class MainWP_Child_iThemes_Security { '404-detection', 'network-brute-force', 'ssl', - //'strong-passwords', + // 'strong-passwords', 'password-requirements', 'system-tweaks', 'wordpress-tweaks', 'multisite-tweaks', 'notification-center', - //'salts', - //'content-directory', + // 'salts', + // 'content-directory', ); $require_permalinks = false; - $updated = false; - $errors = array(); - $nbf_settings = array(); + $updated = false; + $errors = array(); + $nbf_settings = array(); - $update_settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); + $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') { $settings['last_generated'] = ITSEC_Modules::get_setting( $module, 'last_generated' ); // not update - } else if ($module == 'global') { - $keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check' , 'nginx_file' ); - foreach($keep_olds as $key) { - $settings[$key] = ITSEC_Modules::get_setting( $module, $key ); // not update + } elseif ($module == 'global') { + $keep_olds = array( 'did_upgrade', 'log_info', 'show_new_dashboard_notice', 'show_security_check', 'nginx_file' ); + foreach ($keep_olds as $key) { + $settings[ $key ] = ITSEC_Modules::get_setting( $module, $key ); // not update } - if (!isset($settings['log_location']) || empty($settings['log_location']) ) { + if ( ! isset($settings['log_location']) || empty($settings['log_location']) ) { $settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); } else { $result = $this->validate_directory('log_location', $settings['log_location']); if ($result !== true) { - $errors[] = $result; + $errors[] = $result; $settings['log_location'] = ITSEC_Modules::get_setting( $module, 'log_location' ); // no change } } - } else if ($module == 'backup') { - if (!isset($settings['location']) || empty($settings['location']) ) { + } 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) { - $errors[] = $result; + $errors[] = $result; $settings['location'] = ITSEC_Modules::get_setting( $module, 'location' ); // no change } } - if (!isset($settings['exclude']) ) { - $settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' );; + if ( ! isset($settings['exclude']) ) { + $settings['exclude'] = ITSEC_Modules::get_setting( $module, 'exclude' ); + } - } else if ($module == 'hide-backend') { - if (isset($settings['enabled']) && !empty($settings['enabled'])) { + } elseif ($module == 'hide-backend') { + if (isset($settings['enabled']) && ! empty($settings['enabled'])) { $permalink_structure = get_option( 'permalink_structure', false ); if ( empty( $permalink_structure ) && ! is_multisite() ) { - $errors[] = __( 'You must change WordPress permalinks to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' ); + $errors[] = __( 'You must change WordPress permalinks to a setting other than "Plain" in order to use "Hide Backend" feature.', 'better-wp-security' ); $require_permalinks = true; - $do_not_save = true; + $do_not_save = true; } } - } else if ($module == 'network-brute-force') { + } elseif ($module == 'network-brute-force') { if ( isset( $settings['email'] ) ) { $result = $this->activate_api_key($settings); if ($result === false) { $nbf_settings = $settings; - $errors[] = 'Error: Active iThemes Network Brute Force Protection Api Key'; + $errors[] = 'Error: Active iThemes Network Brute Force Protection Api Key'; } else { $nbf_settings = $result; } @@ -268,36 +270,36 @@ class MainWP_Child_iThemes_Security { // update 'enable_ban' field only if (isset($settings['enable_ban'])) { $previous_settings['enable_ban'] = $settings['enable_ban']; - $nbf_settings = $previous_settings; + $nbf_settings = $previous_settings; } else { - $do_not_save = true; + $do_not_save = true; $nbf_settings = $previous_settings; } } $settings = $nbf_settings; - } else if ($module == 'notification-center') { + } elseif ($module == 'notification-center') { $current_settings = ITSEC_Modules::get_settings( $module ); if (isset($settings['notifications'])) { - $update_fields = array( 'schedule', 'enabled', 'subject'); + $update_fields = array( 'schedule', 'enabled', 'subject' ); if (isset($_POST['is_individual']) && $_POST['is_individual']) { - $update_fields = array_merge($update_fields, array('user_list', 'email_list')); + $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])) { - $current_settings['notifications'][$key][$field] = $val[$field]; + if (isset($val[ $field ])) { + $current_settings['notifications'][ $key ][ $field ] = $val[ $field ]; } } } - $updated = true; + $updated = true; ITSEC_Modules::set_settings( $module, $current_settings ); } continue; } - if ( !$do_not_save ) { + if ( ! $do_not_save ) { ITSEC_Modules::set_settings( $module, $settings ); - $updated = true; + $updated = true; } } } @@ -305,33 +307,33 @@ 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) { - $current_val[$mod] = $val; + $current_val[ $mod ] = $val; } update_site_option( 'itsec_active_modules', $current_val ); } - require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' ); + require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php'; $values = array( 'permalink_structure' => get_option( 'permalink_structure' ), 'is_multisite' => is_multisite() ? 1 : 0, 'users_can_register' => get_site_option( 'users_can_register' ) ? 1 : 0, 'server_nginx' => ( ITSEC_Lib::get_server() === 'nginx' ) ? 1 : 0, - 'has_ssl' => ITSEC_Lib::get_ssl_support_probability(), - 'jquery_version' => ITSEC_Modules::get_setting( 'wordpress-tweaks', 'jquery_version' ), - 'server_rules' => ITSEC_Lib_Config_File::get_server_config(), - 'config_rules' => ITSEC_Lib_Config_File::get_wp_config(), + 'has_ssl' => ITSEC_Lib::get_ssl_support_probability(), + 'jquery_version' => ITSEC_Modules::get_setting( 'wordpress-tweaks', 'jquery_version' ), + 'server_rules' => ITSEC_Lib_Config_File::get_server_config(), + 'config_rules' => ITSEC_Lib_Config_File::get_wp_config(), 'lockouts_host' => $this->get_lockouts( 'host', true ), 'lockouts_user' => $this->get_lockouts( 'user', true ), 'lockouts_username' => $this->get_lockouts( 'username', true ), - 'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ), - 'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ), - 'excludable_tables' => $this->get_excludable_tables(), - 'users_and_roles' => $this->get_available_admin_users_and_roles() + 'default_log_location' => ITSEC_Modules::get_default( 'global', 'log_location' ), + 'default_location' => ITSEC_Modules::get_default( 'backup', 'location' ), + 'excludable_tables' => $this->get_excludable_tables(), + 'users_and_roles' => $this->get_available_admin_users_and_roles(), ); $return = array( - 'site_status' => $values + 'site_status' => $values, ); if ($require_permalinks) { @@ -340,44 +342,45 @@ class MainWP_Child_iThemes_Security { $return['nbf_settings'] = $nbf_settings; - if (!empty($errors)) { + if ( ! empty($errors)) { $return['extra_message'] = $errors; } - if ($updated) + if ($updated) { $return['result'] = 'success'; - else + } else { $return['error'] = __('Not Updated', 'mainwp-child' ); + } return $return; } public static function activate_network_brute_force() { - $data = maybe_unserialize( base64_decode( $_POST['data'] ) ); + $data = maybe_unserialize( base64_decode( $_POST['data'] ) ); $information = array(); if (is_array($data)) { - $settings = ITSEC_Modules::get_settings( 'network-brute-force' ); - $settings['email'] = $data['email']; + $settings = ITSEC_Modules::get_settings( 'network-brute-force' ); + $settings['email'] = $data['email']; $settings['updates_optin'] = $data['updates_optin']; - $settings['api_nag'] = false; - $results = ITSEC_Modules::set_settings( 'network-brute-force', $settings ); + $settings['api_nag'] = false; + $results = ITSEC_Modules::set_settings( 'network-brute-force', $settings ); if ( is_wp_error( $results ) ) { $information['error'] = 'Error: Active iThemes Network Brute Force Protection Api Key'; - } else if ( $results['saved'] ) { + } elseif ( $results['saved'] ) { ITSEC_Modules::activate( 'network-brute-force' ); $nbf_settings = ITSEC_Modules::get_settings( 'network-brute-force' ); -// ITSEC_Response::set_response( '' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . ' ' ); + // ITSEC_Response::set_response( '' . __( 'Your site is now using Network Brute Force Protection.', 'better-wp-security' ) . ' ' ); } } if ($nbf_settings !== null) { $information['nbf_settings'] = $nbf_settings; - $information['result'] = 'success'; + $information['result'] = 'success'; } return $information; } - private function validate_directory($name, $folder) { - require_once( ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php' ); + 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 ) ) { $result = ITSEC_Lib_Directory::create( $folder ); @@ -399,24 +402,24 @@ 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' ); + require_once $mainwp_itsec_modules_path . 'ipcheck/utilities.php'; $key = ITSEC_Network_Brute_Force_Utilities::get_api_key( $settings['email'], $settings['updates_optin'] ); if ( is_wp_error( $key ) ) { return false; -// $this->set_can_save( false ); -// $this->add_error( $key ); + // $this->set_can_save( false ); + // $this->add_error( $key ); } else { $secret = ITSEC_Network_Brute_Force_Utilities::activate_api_key( $key ); if ( is_wp_error( $secret ) ) { return false; -// $this->set_can_save( false ); -// $this->add_error( $secret ); + // $this->set_can_save( false ); + // $this->add_error( $secret ); } else { - $settings['api_key'] = $key; + $settings['api_key'] = $key; $settings['api_secret'] = $secret; $settings['api_nag'] = false; @@ -483,7 +486,6 @@ class MainWP_Child_iThemes_Security { return $response; } - } function whitelist_release() { @@ -496,15 +498,15 @@ class MainWP_Child_iThemes_Security { global $itsec_backup, $mainwp_itsec_modules_path; if ( ! isset( $itsec_backup ) ) { - require_once ( $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php' ); + require_once $mainwp_itsec_modules_path . 'backup/class-itsec-backup.php'; $itsec_backup = new ITSEC_Backup(); $itsec_backup->run(); } - $return = array(); + $return = array(); $str_error = ''; - $result = $itsec_backup->do_backup( true ); + $result = $itsec_backup->do_backup( true ); if ( is_wp_error( $result ) ) { $errors = ITSEC_Response::get_error_strings( $result ); @@ -512,14 +514,14 @@ class MainWP_Child_iThemes_Security { foreach ( $errors as $error ) { $str_error .= $error . ''; } - } else if ( is_string( $result ) ) { - $return['result'] = 'success'; + } elseif ( is_string( $result ) ) { + $return['result'] = 'success'; $return['message'] = $result; } else { - $str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type %1$s .', 'better-wp-security' ), gettype( $result ) ) ;
+ $str_error = sprintf( __( 'The backup request returned an unexpected response. It returned a response of type %1$s .', 'better-wp-security' ), gettype( $result ) );
}
- if (!empty($str_error)) {
+ if ( ! empty($str_error)) {
$return['error'] = $str_error;
}
@@ -530,9 +532,9 @@ class MainWP_Child_iThemes_Security {
private function wordpress_salts() {
global $mainwp_itsec_modules_path;
if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) {
- require( $mainwp_itsec_modules_path . 'salts/utilities.php' );
+ require $mainwp_itsec_modules_path . 'salts/utilities.php';
}
- $result = ITSEC_WordPress_Salts_Utilities::generate_new_salts();
+ $result = ITSEC_WordPress_Salts_Utilities::generate_new_salts();
$str_error = '';
if ( is_wp_error( $result ) ) {
$errors = ITSEC_Response::get_error_strings( $result );
@@ -541,19 +543,19 @@ class MainWP_Child_iThemes_Security {
$str_error .= $error . ''; } } else { - $return['result'] = 'success'; - $return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-security' ) ; - $last_generated = ITSEC_Core::get_current_time_gmt(); + $return['result'] = 'success'; + $return['message'] = __( 'The WordPress salts were successfully regenerated.', 'better-wp-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; } private function file_permissions() { - require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' ); + require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php'; $wp_upload_dir = ITSEC_Core::get_wp_upload_dir(); @@ -584,7 +586,7 @@ class MainWP_Child_iThemes_Security { ), array( WP_PLUGIN_DIR, - 0755 + 0755, ), array( $wp_upload_dir['basedir'], @@ -600,7 +602,6 @@ class MainWP_Child_iThemes_Security { ), ); - $rows = array(); foreach ( $path_data as $path ) { @@ -619,7 +620,7 @@ class MainWP_Child_iThemes_Security { $row[] = sprintf( '%o', $suggested_permissions ); $permissions = fileperms( $path ) & 0777; - $row[] = sprintf( '%o', $permissions ); + $row[] = sprintf( '%o', $permissions ); if ( ! $permissions || $permissions != $suggested_permissions ) { $row[] = __( 'WARNING', 'better-wp-security' ); @@ -632,10 +633,9 @@ class MainWP_Child_iThemes_Security { $rows[] = $row; } - $class = 'entry-row'; - ob_start(); - ?> + ob_start(); + ?> - $html); + return array( 'html' => $html ); } public function file_change() { global $mainwp_itsec_modules_path; if ( ! class_exists( 'ITSEC_File_Change_Scanner' ) ) { - require_once( $mainwp_itsec_modules_path . 'file-change/scanner.php' ); + 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) { - $return['result'] = 'success'; + $return['result'] = 'success'; $return['scan_result'] = $result; } return $return; @@ -690,17 +690,17 @@ class MainWP_Child_iThemes_Security { $settings = $_POST['settings']; - if (!is_array($settings)) + if ( ! is_array($settings)) { $settings = array(); + } - $new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : ''; - $change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false; + $new_username = isset( $settings['new_username'] ) ? $settings['new_username'] : ''; + $change_id = isset( $settings['change_id'] ) && $settings['change_id'] ? true : false; - - //load utility functions + // load utility functions if ( ! class_exists( 'ITSEC_Lib' ) ) { global $itsec_globals; - require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' ); + require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php'; } $username_exists = username_exists( 'admin' ); @@ -710,13 +710,12 @@ class MainWP_Child_iThemes_Security { global $current_user; if ( ! $username_exists ) { $msg = __( 'Admin user already changes.', 'mainwp-child' ); - } else if ($current_user->user_login == 'admin') { + } elseif ($current_user->user_login == 'admin') { $return['result'] = 'CHILD_ADMIN'; return $return; } } - if ( true === $change_id && ! $user_id_exists ) { if ( ! empty( $msg ) ) { $msg .= ' '; @@ -724,16 +723,16 @@ class MainWP_Child_iThemes_Security { $msg .= __( 'Admin user ID already changes.', 'mainwp-child' ); } -// if ( $change_id ) { -// $user = get_user_by( 'login', $new_username ); -// if ( $user && 1 === (int) $user->ID ) { -// $return['result'] = 'CHILD_ADMIN'; -// return $return; -// } -// } + // if ( $change_id ) { + // $user = get_user_by( 'login', $new_username ); + // if ( $user && 1 === (int) $user->ID ) { + // $return['result'] = 'CHILD_ADMIN'; + // return $return; + // } + // } $admin_success = true; - $return = array(); + $return = array(); if ( strlen( $new_username ) >= 1 && $username_exists ) { $admin_success = $this->change_admin_user( $new_username, $change_id ); @@ -756,95 +755,94 @@ class MainWP_Child_iThemes_Security { $itsec_files = ITSEC_Core::get_itsec_files(); // do not need to check this - //if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running + // if ( $itsec_files->get_file_lock( 'admin_user' ) ) { //make sure it isn't already running - //sanitize the username + // sanitize the username $new_user = sanitize_text_field( $username ); - //Get the full user object + // Get the full user object $user_object = get_user_by( 'id', '1' ); - if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { //there is a valid username to change + if ( null !== $username && validate_username( $new_user ) && false === username_exists( $new_user ) ) { // there is a valid username to change - if ( true === $id ) { //we're changing the id too so we'll set the username + if ( true === $id ) { // we're changing the id too so we'll set the username - $user_login = $new_user; + $user_login = $new_user; - } else { // we're only changing the username + } else { // we're only changing the username - //query main user table - $wpdb->query( "UPDATE `" . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" ); + // query main user table + $wpdb->query( 'UPDATE `' . $wpdb->users . "` SET user_login = '" . esc_sql( $new_user ) . "' WHERE user_login='admin';" ); - if ( is_multisite() ) { //process sitemeta if we're in a multi-site situation - - $oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" ); - $newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->sitemeta . "` SET meta_value = %s WHERE meta_key = 'site_admins'", $newAdmins ) ); - } - - wp_clear_auth_cookie(); - $itsec_files->release_file_lock( 'admin_user' ); - - return true; - - } - } elseif ( null !== $username ) { //username didn't validate - - $itsec_files->release_file_lock( 'admin_user' ); - - return false; - - } else { //only changing the id - - $user_login = $user_object->user_login; - - } - - if ( true === $id ) { //change the user id - - $wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' ); - - $wpdb->insert( $wpdb->users, array( - 'user_login' => $user_login, - 'user_pass' => $user_object->user_pass, - 'user_nicename' => $user_object->user_nicename, - 'user_email' => $user_object->user_email, - 'user_url' => $user_object->user_url, - 'user_registered' => $user_object->user_registered, - 'user_activation_key' => $user_object->user_activation_key, - 'user_status' => $user_object->user_status, - 'display_name' => $user_object->display_name, - ) ); - - if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { //process sitemeta if we're in a multi-site situation + if ( is_multisite() ) { // process sitemeta if we're in a multi-site situation $oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" ); $newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins ); - $wpdb->query( 'UPDATE `' . $wpdb->sitemeta . "` SET meta_value = '" . esc_sql( $newAdmins ) . "' WHERE meta_key = 'site_admins'" ); - + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->sitemeta . "` SET meta_value = %s WHERE meta_key = 'site_admins'", $newAdmins ) ); } - $new_user = $wpdb->insert_id; - - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->posts . "` SET post_author = %s WHERE post_author = 1;", $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->usermeta . "` SET user_id = %s WHERE user_id = 1;", $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->comments . "` SET user_id = %s WHERE user_id = 1;", $new_user ) ); - $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->links . "` SET link_owner = %s WHERE link_owner = 1;", $new_user ) ); - wp_clear_auth_cookie(); $itsec_files->release_file_lock( 'admin_user' ); return true; } - //} + } elseif ( null !== $username ) { // username didn't validate + + $itsec_files->release_file_lock( 'admin_user' ); + + return false; + + } else { // only changing the id + + $user_login = $user_object->user_login; + + } + + if ( true === $id ) { // change the user id + + $wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' ); + + $wpdb->insert( $wpdb->users, array( + 'user_login' => $user_login, + 'user_pass' => $user_object->user_pass, + 'user_nicename' => $user_object->user_nicename, + 'user_email' => $user_object->user_email, + 'user_url' => $user_object->user_url, + 'user_registered' => $user_object->user_registered, + 'user_activation_key' => $user_object->user_activation_key, + 'user_status' => $user_object->user_status, + 'display_name' => $user_object->display_name, + ) ); + + if ( is_multisite() && null !== $username && validate_username( $new_user ) ) { // process sitemeta if we're in a multi-site situation + + $oldAdmins = $wpdb->get_var( 'SELECT meta_value FROM `' . $wpdb->sitemeta . "` WHERE meta_key = 'site_admins'" ); + $newAdmins = str_replace( '5:"admin"', strlen( $new_user ) . ':"' . esc_sql( $new_user ) . '"', $oldAdmins ); + $wpdb->query( 'UPDATE `' . $wpdb->sitemeta . "` SET meta_value = '" . esc_sql( $newAdmins ) . "' WHERE meta_key = 'site_admins'" ); + + } + + $new_user = $wpdb->insert_id; + + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->posts . '` SET post_author = %s WHERE post_author = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->usermeta . '` SET user_id = %s WHERE user_id = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->comments . '` SET user_id = %s WHERE user_id = 1;', $new_user ) ); + $wpdb->query( $wpdb->prepare( 'UPDATE `' . $wpdb->links . '` SET link_owner = %s WHERE link_owner = 1;', $new_user ) ); + + wp_clear_auth_cookie(); + $itsec_files->release_file_lock( 'admin_user' ); + + return true; + + } + // } return false; - } public function build_wpconfig_rules( $rules_array, $input = null ) { - //Get the rules from the database if input wasn't sent + // Get the rules from the database if input wasn't sent if ( null === $input ) { return $rules_array; } @@ -869,18 +867,21 @@ class MainWP_Child_iThemes_Security { 'rule' => "define( 'WP_CONTENT_DIR', '" . $new_dir . "' );", ); - $rules_array[] = array( 'type' => 'wpconfig', 'name' => 'Content Directory', 'rules' => $rules ); + $rules_array[] = array( + 'type' => 'wpconfig', + 'name' => 'Content Directory', + 'rules' => $rules, + ); return $rules_array; - } public function change_database_prefix() { global $mainwp_itsec_modules_path; - require_once( $mainwp_itsec_modules_path . 'database-prefix/utility.php' ); + require_once $mainwp_itsec_modules_path . 'database-prefix/utility.php'; $str_error = ''; - $return = array(); + $return = array(); if ( isset( $_POST['change_prefix'] ) && 'yes' === $_POST['change_prefix'] ) { $result = ITSEC_Database_Prefix_Utility::change_database_prefix(); @@ -899,7 +900,7 @@ class MainWP_Child_iThemes_Security { if ( false === $result['new_prefix'] ) { $return['error'] = $str_error; } else { - $return['result'] = 'success'; + $return['result'] = 'success'; $return['message'] = sprintf( __( 'The database table prefix was successfully changed to %1$s .', 'better-wp-security' ), $result['new_prefix'] );
}
@@ -913,7 +914,7 @@ class MainWP_Child_iThemes_Security {
$settings = array();
}
$settings['reset'] = true;
- $return = array();
+ $return = array();
if ( update_site_option( 'itsec_ipcheck', $settings ) ) {
$return['result'] = 'success';
} else {
@@ -926,7 +927,7 @@ class MainWP_Child_iThemes_Security {
public function reset_api_key() {
$defaults = ITSEC_Modules::get_defaults( 'network-brute-force' );
- $results = ITSEC_Modules::set_settings( 'network-brute-force', $defaults );
+ $results = ITSEC_Modules::set_settings( 'network-brute-force', $defaults );
ITSEC_Response::set_response( $results['saved'] );
ITSEC_Response::add_errors( $results['errors'] );
@@ -934,9 +935,9 @@ class MainWP_Child_iThemes_Security {
$information = array();
if ( $results['saved'] ) {
- $information['result'] = 'success';
+ $information['result'] = 'success';
$information['nbf_settings'] = ITSEC_Modules::get_settings( 'network-brute-force');
- } else if ( empty( $results['errors'] ) ) {
+ } elseif ( empty( $results['errors'] ) ) {
$information['error_reset_api'] = 1;
}
return $information;
@@ -946,15 +947,15 @@ class MainWP_Child_iThemes_Security {
global $mainwp_itsec_modules_path;
if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) {
- require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' );
- require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' );
+ require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php';
+ require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php';
}
$response = array();
if ( ! ITSEC_Core::current_user_can_manage() ) {
$response['error'] = 'The currently logged in user does not have sufficient permissions to run this scan.';
} else {
- $results = ITSEC_Malware_Scanner::scan();
+ $results = ITSEC_Malware_Scanner::scan();
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
}
@@ -965,11 +966,11 @@ class MainWP_Child_iThemes_Security {
global $mainwp_itsec_modules_path;
if ( ! class_exists( 'ITSEC_Malware_Scanner' ) ) {
- require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php' );
- require_once( $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php' );
+ require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scanner.php';
+ require_once $mainwp_itsec_modules_path . 'malware/class-itsec-malware-scan-results-template.php';
}
- $response = array();
- $results= ITSEC_Malware_Scanner::scan();
+ $response = array();
+ $results = ITSEC_Malware_Scanner::scan();
$response['html'] = ITSEC_Malware_Scan_Results_Template::get_html( $results, true );
return $response;
}
@@ -1068,7 +1069,7 @@ class MainWP_Child_iThemes_Security {
global $wpdb;
if ( ! class_exists( 'ITSEC_Lib' ) ) {
- require( ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php' );
+ require ITSEC_Core::get_core_dir() . '/core/class-itsec-lib.php';
}
$lockout_ids = $_POST['lockout_ids'];
@@ -1095,7 +1096,7 @@ class MainWP_Child_iThemes_Security {
if ( ! is_multisite() ) {
if ( ! function_exists( 'add_settings_error' ) ) {
- require_once( ABSPATH . '/wp-admin/includes/template.php' );
+ require_once ABSPATH . '/wp-admin/includes/template.php';
}
add_settings_error( 'itsec', esc_attr( 'settings_updated' ), $message, $type );
@@ -1110,30 +1111,30 @@ 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) {
- $current_val[$mod] = $val;
+ $current_val[ $mod ] = $val;
}
update_site_option( 'itsec_active_modules', $current_val );
- return array('result' => 'success');
-
+ return array( 'result' => 'success' );
}
- private function reload_backup_exclude( ) {
+ private function reload_backup_exclude() {
return array(
- 'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
+ 'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
'excludable_tables' => $this->get_excludable_tables(),
- 'result' => 'success'
+ 'result' => 'success',
);
}
- private function get_excludable_tables( ) {
+ private function get_excludable_tables() {
global $wpdb;
- $all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' );
+ $all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' );
$ignored_tables = array(
'commentmeta',
'comments',
@@ -1154,7 +1155,7 @@ class MainWP_Child_iThemes_Security {
$query = $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->base_prefix}%" );
}
- $tables = $wpdb->get_results( $query, ARRAY_N );
+ $tables = $wpdb->get_results( $query, ARRAY_N );
$excludes = array();
foreach ( $tables as $table ) {
@@ -1164,21 +1165,24 @@ class MainWP_Child_iThemes_Security {
continue;
}
- $excludes[$short_table] = $table[0];
+ $excludes[ $short_table ] = $table[0];
}
- return $excludes ;
+ return $excludes;
}
private function security_site() {
global $mainwp_itsec_modules_path;
- require_once( $mainwp_itsec_modules_path . 'security-check/scanner.php' );
- require_once( $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php' );
+ require_once $mainwp_itsec_modules_path . 'security-check/scanner.php';
+ require_once $mainwp_itsec_modules_path . 'security-check/feedback-renderer.php';
$results = ITSEC_Security_Check_Scanner::get_results();
ob_start();
ITSEC_Security_Check_Feedback_Renderer::render( $results );
$response = ob_get_clean();
- return array('result' => 'success' , 'response' => $response);
+ return array(
+ 'result' => 'success',
+ 'response' => $response,
+ );
}
// source from itheme plugin
@@ -1195,7 +1199,7 @@ class MainWP_Child_iThemes_Security {
foreach ( $roles->roles as $role => $details ) {
if ( isset( $details['capabilities']['manage_options'] ) && ( true === $details['capabilities']['manage_options'] ) ) {
- $available_roles["role:$role"] = translate_user_role( $details['name'] );
+ $available_roles[ "role:$role" ] = translate_user_role( $details['name'] );
$users = get_users( array( 'role' => $role ) );
diff --git a/class/class-mainwp-child-links-checker.php b/class/class-mainwp-child-links-checker.php
index c91e756..e5c42f0 100644
--- a/class/class-mainwp-child-links-checker.php
+++ b/class/class-mainwp-child-links-checker.php
@@ -15,28 +15,28 @@
class MainWP_Child_Links_Checker {
- public static $instance = null;
+ public static $instance = null;
public $is_plugin_installed = false;
static function Instance() {
- if ( null === MainWP_Child_Links_Checker::$instance ) {
- MainWP_Child_Links_Checker::$instance = new MainWP_Child_Links_Checker();
+ if ( null === self::$instance ) {
+ self::$instance = new MainWP_Child_Links_Checker();
}
- return MainWP_Child_Links_Checker::$instance;
+ return self::$instance;
}
public function __construct() {
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'broken-link-checker/broken-link-checker.php' ) ) {
$this->is_plugin_installed = true;
}
- if ( !$this->is_plugin_installed )
+ if ( ! $this->is_plugin_installed ) {
return;
+ }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
-
}
public function action() {
@@ -82,8 +82,8 @@ class MainWP_Child_Links_Checker {
}
}
MainWP_Helper::write( $information );
- } catch(Exception $e) {
- MainWP_Helper::write( array('error' => $e->getMessage()) );
+ } catch (Exception $e) {
+ MainWP_Helper::write( array( 'error' => $e->getMessage() ) );
}
}
@@ -114,8 +114,8 @@ class MainWP_Child_Links_Checker {
}
function save_settings() {
- $information = array();
- $check_threshold = intval( $_POST['check_threshold'] );
+ $information = array();
+ $check_threshold = intval( $_POST['check_threshold'] );
if ( $check_threshold > 0 ) {
$conf = blc_get_configuration();
$conf->options['check_threshold'] = $check_threshold;
@@ -137,13 +137,13 @@ class MainWP_Child_Links_Checker {
global $wpdb;
/** @var wpdb $wpdb */
- //Delete all discovered instances
+ // Delete all discovered instances
$wpdb->query( "TRUNCATE {$wpdb->prefix}blc_instances" );
- //Delete all discovered links
+ // Delete all discovered links
$wpdb->query( "TRUNCATE {$wpdb->prefix}blc_links" );
- //Mark all posts, custom fields and bookmarks for processing.
+ // Mark all posts, custom fields and bookmarks for processing.
blc_resynch( true );
}
@@ -158,18 +158,18 @@ class MainWP_Child_Links_Checker {
}
blc_init();
- //Get the container type matching the type of the deleted post
+ // Get the container type matching the type of the deleted post
$post = get_post( $post_id );
if ( ! $post ) {
return;
}
- //Get the associated container object
+ // Get the associated container object
$post_container = blcContainerHelper::get_container( array( $post->post_type, intval( $post_id ) ) );
if ( $post_container ) {
- //Delete it
+ // Delete it
$post_container->delete();
- //Clean up any dangling links
+ // Clean up any dangling links
blc_cleanup_links();
}
}
@@ -210,9 +210,9 @@ class MainWP_Child_Links_Checker {
// ok
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncBrokenLinksCheckerData'] ) && $data['syncBrokenLinksCheckerData'] ) {
- try{
+ try {
$information['syncBrokenLinksCheckerData'] = $this->get_sync_data();
- } catch(Exception $e) {
+ } catch (Exception $e) {
}
}
@@ -223,14 +223,17 @@ 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;
}
function get_links_data() {
- if (!defined('BLC_DIRECTORY')) return;
+ if ( ! defined('BLC_DIRECTORY')) {
+ return;
+ }
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
@@ -242,20 +245,19 @@ class MainWP_Child_Links_Checker {
MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
- $blc_link_query = blcLinkQuery::getInstance();
+ $blc_link_query = blcLinkQuery::getInstance();
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
- $total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
-
+ $total = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
$max_results = isset($_POST['max_results']) ? intval($_POST['max_results']) : 50;
- $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
+ $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0;
- $params = array(
- array( 'load_instances' => true ),
- 'max_results' => $max_results
- );
+ $params = array(
+ array( 'load_instances' => true ),
+ 'max_results' => $max_results,
+ );
if (empty($offset)) {
$first_sync = true;
@@ -266,12 +268,12 @@ 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);
+ $total_sync += ( is_array($link_data) ? count($link_data) : 0 );
- $information = array('links_data' => $link_data);
+ $information = array( 'links_data' => $link_data );
if ($first_sync) {
$information['data'] = $this->get_count_links();
@@ -280,9 +282,9 @@ class MainWP_Child_Links_Checker {
if ($total > $offset + $max_results ) {
$information['sync_offset'] = $offset + $max_results;
} else {
- $information['last_sync'] = 1;
+ $information['last_sync'] = 1;
$information['total_sync'] = $total_sync;
- $information['data'] = $this->get_count_links();
+ $information['data'] = $this->get_count_links();
}
$information['result'] = 'success';
@@ -290,7 +292,9 @@ class MainWP_Child_Links_Checker {
}
function get_count_links() {
- if (!defined('BLC_DIRECTORY')) return;
+ if ( ! defined('BLC_DIRECTORY')) {
+ return;
+ }
$file_path1 = BLC_DIRECTORY . '/includes/link-query.php';
$file_path2 = BLC_DIRECTORY . '/includes/modules.php';
@@ -303,25 +307,25 @@ class MainWP_Child_Links_Checker {
MainWP_Helper::check_classes_exists('blcLinkQuery');
MainWP_Helper::check_methods('blcLinkQuery', 'getInstance');
- $data = array();
- $blc_link_query = blcLinkQuery::getInstance();
+ $data = array();
+ $blc_link_query = blcLinkQuery::getInstance();
MainWP_Helper::check_methods($blc_link_query, 'get_filter_links');
- $data['broken'] = $blc_link_query->get_filter_links( 'broken', array( 'count_only' => true ) );
- $data['redirects'] = $blc_link_query->get_filter_links( 'redirects', array( 'count_only' => true ) );
- $data['dismissed'] = $blc_link_query->get_filter_links( 'dismissed', array( 'count_only' => true ) );
+ $data['broken'] = $blc_link_query->get_filter_links( 'broken', array( 'count_only' => true ) );
+ $data['redirects'] = $blc_link_query->get_filter_links( 'redirects', array( 'count_only' => true ) );
+ $data['dismissed'] = $blc_link_query->get_filter_links( 'dismissed', array( 'count_only' => true ) );
$data['warning'] = $blc_link_query->get_filter_links( 'warning', array( 'count_only' => true ) );
- $data['all'] = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
+ $data['all'] = $blc_link_query->get_filter_links( 'all', array( 'count_only' => true ) );
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');
- $links = blc_get_links( $params );
+ $links = blc_get_links( $params );
$filter_fields = array(
'link_id',
@@ -341,13 +345,13 @@ class MainWP_Child_Links_Checker {
'last_success',
'may_recheck',
'false_positive',
- //'result_hash',
+ // 'result_hash',
'dismissed',
'status_text',
'status_code',
- 'log'
+ 'log',
);
- $return = array();
+ $return = array();
$blc_option = get_option( 'wsblc_options' );
@@ -370,7 +374,7 @@ class MainWP_Child_Links_Checker {
$days_broken = 0;
if ( $link->broken ) {
- //Add a highlight to broken links that appear to be permanently broken
+ // Add a highlight to broken links that appear to be permanently broken
$days_broken = intval( ( time() - $link->first_failure ) / ( 3600 * 24 ) );
if ( $days_broken >= $blc_option['failure_duration_threshold'] ) {
$extra_info['permanently_broken'] = 1;
@@ -380,7 +384,7 @@ class MainWP_Child_Links_Checker {
}
}
$extra_info['days_broken'] = $days_broken;
- $instances = false;
+ $instances = false;
$get_link = new blcLink( intval( $link->link_id ) );
if ( $get_link->valid() ) {
@@ -389,13 +393,13 @@ class MainWP_Child_Links_Checker {
}
if ( ! empty( $instances ) ) {
- $first_instance = reset( $instances );
+ $first_instance = reset( $instances );
- MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable') );
+ MainWP_Helper::check_methods($first_instance, array( 'ui_get_link_text', 'get_container', 'is_link_text_editable', 'is_url_editable' ) );
- $new_link->link_text = $first_instance->ui_get_link_text();
+ $new_link->link_text = $first_instance->ui_get_link_text();
$extra_info['count_instance'] = count( $instances );
- $container = $first_instance->get_container();
+ $container = $first_instance->get_container();
/** @var blcContainer $container */
@@ -403,8 +407,8 @@ class MainWP_Child_Links_Checker {
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 );
+ $extra_info['container_id'] = $container->container_id;
+ $extra_info['source_data'] = $this->ui_get_source( $container, $first_instance->container_field );
}
}
}
@@ -429,27 +433,26 @@ class MainWP_Child_Links_Checker {
$link_texts = $can_edit_text ? $editable_link_texts : $non_editable_link_texts;
$data_link_text = '';
if ( count( $link_texts ) === 1 ) {
- //All instances have the same text - use it.
+ // All instances have the same text - use it.
$link_text = key( $link_texts );
$data_link_text = esc_attr( $link_text );
}
$extra_info['data_link_text'] = $data_link_text;
- $extra_info['can_edit_url'] = $can_edit_url;
- $extra_info['can_edit_text'] = $can_edit_text;
+ $extra_info['can_edit_url'] = $can_edit_url;
+ $extra_info['can_edit_text'] = $can_edit_text;
} else {
- $new_link->link_text = '';
+ $new_link->link_text = '';
$extra_info['count_instance'] = 0;
}
$new_link->extra_info = base64_encode(serialize($extra_info));
- $new_link->synced = 1;
- $return[] = $new_link;
+ $new_link->synced = 1;
+ $return[] = $new_link;
}
} else {
return array();
}
return $return;
-
}
function edit_link() {
@@ -459,14 +462,14 @@ class MainWP_Child_Links_Checker {
return $information;
}
- //Load the link
+ // Load the link
$link = new blcLink( intval( $_POST['link_id'] ) );
if ( ! $link->valid() ) {
$information['error'] = 'NOTFOUNDLINK'; // Oops, I can't find the link
return $information;
}
- //Validate the new URL.
+ // Validate the new URL.
$new_url = stripslashes( $_POST['new_url'] );
$parsed = @parse_url( $new_url );
if ( ! $parsed ) {
@@ -479,7 +482,7 @@ class MainWP_Child_Links_Checker {
$new_text = null;
}
if ( ! empty( $new_text ) && ! current_user_can( 'unfiltered_html' ) ) {
- $new_text = stripslashes( wp_filter_post_kses( addslashes( $new_text ) ) ); //wp_filter_post_kses expects slashed data.
+ $new_text = stripslashes( wp_filter_post_kses( addslashes( $new_text ) ) ); // wp_filter_post_kses expects slashed data.
}
$rez = $link->edit( $new_url, $new_text );
@@ -512,7 +515,7 @@ class MainWP_Child_Links_Checker {
'ui_link_text' => isset( $new_text ) ? $ui_link_text : null,
'errors' => array(),
);
- //url, status text, status code, link text, editable link text
+ // url, status text, status code, link text, editable link text
foreach ( $rez['errors'] as $error ) {
/** @var $error WP_Error */
@@ -532,7 +535,7 @@ class MainWP_Child_Links_Checker {
}
if ( isset( $_POST['link_id'] ) ) {
- //Load the link
+ // Load the link
$link = new blcLink( intval( $_POST['link_id'] ) );
if ( ! $link->valid() ) {
@@ -540,7 +543,7 @@ class MainWP_Child_Links_Checker {
return $information;
}
- //Try and unlink it
+ // Try and unlink it
$rez = $link->unlink();
if ( false === $rez ) {
@@ -577,7 +580,7 @@ class MainWP_Child_Links_Checker {
}
if ( isset( $_POST['link_id'] ) ) {
- //Load the link
+ // Load the link
$link = new blcLink( intval( $_POST['link_id'] ) );
if ( ! $link->valid() ) {
@@ -587,7 +590,7 @@ class MainWP_Child_Links_Checker {
$link->dismissed = $dismiss;
- //Save the changes
+ // Save the changes
if ( $link->save() ) {
$information = 'OK';
} else {
@@ -610,7 +613,7 @@ class MainWP_Child_Links_Checker {
return $information;
}
if ( isset( $_POST['link_id'] ) ) {
- //Load the link
+ // Load the link
$link = new blcLink( intval( $_POST['link_id'] ) );
if ( ! $link->valid() ) {
@@ -618,13 +621,13 @@ class MainWP_Child_Links_Checker {
return $information;
}
- //Make it appear "not broken"
+ // Make it appear "not broken"
$link->broken = false;
$link->false_positive = true;
$link->last_check_attempt = time();
$link->log = __( 'This link was manually marked as working by the user.', 'mainwp-child' );
- //Save the changes
+ // Save the changes
if ( $link->save() ) {
$information['status'] = 'OK';
$information['last_check_attempt'] = $link->last_check_attempt;
@@ -641,7 +644,7 @@ class MainWP_Child_Links_Checker {
function ui_get_source( $container, $container_field = '' ) {
if ( 'comment' === $container->container_type ) {
return $this->ui_get_source_comment( $container, $container_field );
- } else if ( $container instanceof blcAnyPostContainer ) {
+ } elseif ( $container instanceof blcAnyPostContainer ) {
return $this->ui_get_source_post( $container, $container_field );
}
@@ -649,19 +652,20 @@ class MainWP_Child_Links_Checker {
}
function ui_get_source_comment( $container, $container_field = '' ) {
- //Display a comment icon.
+ // Display a comment icon.
if ( 'comment_author_url' === $container_field ) {
$image = 'font-awesome/font-awesome-user.png';
} else {
$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;
+ }
$comment = $container->get_wrapped_object();
- //Display a small text sample from the comment
+ // Display a small text sample from the comment
$text_sample = strip_tags( $comment->comment_content );
$text_sample = blcUtility::truncate( $text_sample, 65 );
@@ -680,7 +684,7 @@ class MainWP_Child_Links_Checker {
function ui_get_source_post( $container, $container_field = '' ) {
return array(
'post_title' => get_the_title( $container->container_id ),
- 'post_status' => get_post_status($container->container_id),
+ 'post_status' => get_post_status($container->container_id),
'container_anypost' => true,
);
}
diff --git a/class/class-mainwp-child-pagespeed.php b/class/class-mainwp-child-pagespeed.php
index 43ccd2f..f258161 100644
--- a/class/class-mainwp-child-pagespeed.php
+++ b/class/class-mainwp-child-pagespeed.php
@@ -17,25 +17,26 @@
class MainWP_Child_Pagespeed {
- public static $instance = null;
+ public static $instance = null;
public $is_plugin_installed = false;
static function Instance() {
- if ( null === MainWP_Child_Pagespeed::$instance ) {
- MainWP_Child_Pagespeed::$instance = new MainWP_Child_Pagespeed();
+ if ( null === self::$instance ) {
+ self::$instance = new MainWP_Child_Pagespeed();
}
- return MainWP_Child_Pagespeed::$instance;
+ return self::$instance;
}
public function __construct() {
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'google-pagespeed-insights/google-pagespeed-insights.php' ) ) {
$this->is_plugin_installed = true;
}
- if (!$this->is_plugin_installed)
+ if ( ! $this->is_plugin_installed) {
return;
+ }
add_filter( 'mainwp-site-sync-others-data', array( $this, 'syncOthersData' ), 10, 2 );
@@ -60,7 +61,7 @@ class MainWP_Child_Pagespeed {
case 'sync_data':
$information = $this->get_sync_data();
break;
- case "check_pages":
+ case 'check_pages':
$information = $this->check_pages();
break;
}
@@ -75,12 +76,13 @@ class MainWP_Child_Pagespeed {
}
public function init() {
- if (!$this->is_plugin_installed)
+ if ( ! $this->is_plugin_installed) {
return;
+ }
if ( get_option( 'mainwp_pagespeed_hide_plugin' ) === 'hide' ) {
add_filter( 'all_plugins', array( $this, 'hide_plugin' ) );
- add_action('admin_menu', array($this, 'hide_menu'), 999);
+ add_action('admin_menu', array( $this, 'hide_menu' ), 999);
}
$this->init_cron();
}
@@ -126,9 +128,9 @@ class MainWP_Child_Pagespeed {
public function hide_menu() {
global $submenu;
if (isset($submenu['tools.php'])) {
- foreach($submenu['tools.php'] as $key => $menu) {
+ foreach ($submenu['tools.php'] as $key => $menu) {
if ($menu[2] == 'google-pagespeed-insights') {
- unset($submenu['tools.php'][$key]);
+ unset($submenu['tools.php'][ $key ]);
break;
}
}
@@ -157,7 +159,7 @@ class MainWP_Child_Pagespeed {
function save_settings() {
$current_values = get_option( 'gpagespeedi_options' );
- $checkstatus = apply_filters( 'gpi_check_status', false );
+ $checkstatus = apply_filters( 'gpi_check_status', false );
if ( $checkstatus ) {
return array( 'result' => 'RUNNING' );
}
@@ -214,9 +216,9 @@ class MainWP_Child_Pagespeed {
if ( isset( $settings['check_report'] ) ) {
if ( is_array( $settings['check_report'] ) ) {
- $current_values['check_pages'] = in_array( 'page', $settings['check_report'] ) ? true : false;
- $current_values['check_posts'] = in_array( 'post', $settings['check_report'] ) ? true : false;
- $current_values['check_categories'] = in_array( 'category', $settings['check_report'] ) ? true : false;
+ $current_values['check_pages'] = in_array( 'page', $settings['check_report'] ) ? true : false;
+ $current_values['check_posts'] = in_array( 'post', $settings['check_report'] ) ? true : false;
+ $current_values['check_categories'] = in_array( 'category', $settings['check_report'] ) ? true : false;
$current_values['check_custom_urls'] = in_array( 'custom_urls', $settings['check_report'] ) ? true : false;
} else {
$current_values['check_pages'] = $current_values['check_posts'] = $current_values['check_categories'] = $current_values['check_custom_urls'] = false;
@@ -238,24 +240,24 @@ class MainWP_Child_Pagespeed {
$result = $this->get_sync_data( $strategy );
-// if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
-// if ( 'recheck_all_pages' === $_POST['doaction'] ) {
-// $recheck = true;
-// } else {
-// $recheck = false;
-// }
-//
-//
-// if ($this->do_check_pages($recheck))
-// $information['checked_pages'] = 1;
-// }
+ // if ( isset( $_POST['doaction'] ) && ( 'check_new_pages' === $_POST['doaction'] || 'recheck_all_pages' === $_POST['doaction'] ) ) {
+ // if ( 'recheck_all_pages' === $_POST['doaction'] ) {
+ // $recheck = true;
+ // } else {
+ // $recheck = false;
+ // }
+ //
+ //
+ // if ($this->do_check_pages($recheck))
+ // $information['checked_pages'] = 1;
+ // }
$information['data'] = $result['data'];
return $information;
}
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;
@@ -267,14 +269,14 @@ class MainWP_Child_Pagespeed {
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 );
if ( $checkstatus ) {
$information['error'] = __( 'The API is busy checking other pages, please try again later.', 'gpagespeedi' );
} else {
- //do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
+ // do_action( 'googlepagespeedinsightsworker', array(), $forceRecheck );
do_action( 'run_gpi', $forceRecheck ); // to fix
$information['checked_pages'] = 1;
}
@@ -284,9 +286,9 @@ class MainWP_Child_Pagespeed {
public function syncOthersData( $information, $data = array() ) {
if ( isset( $data['syncPageSpeedData'] ) && $data['syncPageSpeedData'] ) {
- try{
+ try {
$information['syncPageSpeedData'] = $this->get_sync_data();
- } catch(Exception $e) {
+ } catch (Exception $e) {
}
}
@@ -299,7 +301,7 @@ class MainWP_Child_Pagespeed {
}
$current_values = get_option( 'gpagespeedi_options' );
- $checkstatus = apply_filters( 'gpi_check_status', false );
+ $checkstatus = apply_filters( 'gpi_check_status', false );
if ( $checkstatus ) {
return array( 'result' => 'RUNNING' );
}
@@ -309,16 +311,16 @@ class MainWP_Child_Pagespeed {
$data = array( 'bad_api_key' => $bad_key );
if ( 'both' === $strategy || 'desktop' === $strategy ) {
- $result = self::cal_pagespeed_data( 'desktop' );
- if ( !empty($result) && is_array($result) ) {
+ $result = self::cal_pagespeed_data( 'desktop' );
+ if ( ! empty($result) && is_array($result) ) {
$data['desktop_score'] = $result['average_score'];
$data['desktop_total_pages'] = $result['total_pages'];
$data['desktop_last_modified'] = $result['last_modified'];
}
}
if ( 'both' === $strategy || 'mobile' === $strategy ) {
- $result = self::cal_pagespeed_data( 'mobile' );
- if ( !empty($result) && is_array($result) ) {
+ $result = self::cal_pagespeed_data( 'mobile' );
+ if ( ! empty($result) && is_array($result) ) {
$data['mobile_score'] = $result['average_score'];
$data['mobile_total_pages'] = $result['total_pages'];
$data['mobile_last_modified'] = $result['last_modified'];
@@ -340,9 +342,8 @@ class MainWP_Child_Pagespeed {
return false;
}
- $score_column = $strategy . '_score';
- //$page_stats_column = $strategy . '_page_stats';
-
+ $score_column = $strategy . '_score';
+ // $page_stats_column = $strategy . '_page_stats';
$data_typestocheck = self::get_filter_options( 'all' );
@@ -399,9 +400,9 @@ class MainWP_Child_Pagespeed {
// Not Null check for Report List scores
switch ( $strategy ) {
- // case 'both':
- // $nullcheck = 'desktop_score IS NOT NULL AND mobile_score IS NOT NULL';
- // break;
+ // case 'both':
+ // $nullcheck = 'desktop_score IS NOT NULL AND mobile_score IS NOT NULL';
+ // break;
case 'mobile':
$nullcheck = 'mobile_score IS NOT NULL';
@@ -437,61 +438,59 @@ 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');
+ $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";
+ $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";
+ $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";
+ $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(
+ $args = array(
'public' => true,
- '_builtin' => false
+ '_builtin' => false,
);
- $custom_post_types = get_post_types($args,'names','and');
- if($restrict_type != 'gpi_custom_posts' && $restrict_type != 'all' && $restrict_type != 'ignored') {
+ $custom_post_types = get_post_types($args, 'names', 'and');
+ 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];
+ $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];
+ $types[1][] = $custom_post_types[ $post_type ];
}
}
}
@@ -501,7 +500,7 @@ class MainWP_Child_Pagespeed {
if ( $gpi_options['check_custom_urls'] ) {
global $wpdb;
- $gpi_custom_urls = $wpdb->prefix . 'gpi_custom_urls';
+ $gpi_custom_urls = $wpdb->prefix . 'gpi_custom_urls';
$custom_url_types = $wpdb->get_col(
"
SELECT DISTINCT type
@@ -512,21 +511,19 @@ class MainWP_Child_Pagespeed {
if ( ! empty( $custom_url_types ) ) {
foreach ( $custom_url_types as $custom_url_type ) {
$typestocheck[] = 'type = %s';
- $types[1][] = $custom_url_type;
+ $types[1][] = $custom_url_type;
}
}
}
- 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)
- {
- $types[0] .= 'type = %s OR ';
+ foreach ($type as $custom_post_type) {
+ $types[0] .= 'type = %s OR ';
$types[1][] = $custom_post_type;
}
}
diff --git a/class/class-mainwp-child-plugins-check.php b/class/class-mainwp-child-plugins-check.php
index c0d52a0..98aaed8 100644
--- a/class/class-mainwp-child-plugins-check.php
+++ b/class/class-mainwp-child-plugins-check.php
@@ -29,11 +29,11 @@ class MainWP_Child_Plugins_Check {
private $option_name_last_daily_run = 'mainwp_child_plugin_last_daily_run';
public static function Instance() {
- if ( null === MainWP_Child_Plugins_Check::$instance ) {
- MainWP_Child_Plugins_Check::$instance = new MainWP_Child_Plugins_Check();
+ if ( null === self::$instance ) {
+ self::$instance = new MainWP_Child_Plugins_Check();
}
- return MainWP_Child_Plugins_Check::$instance;
+ return self::$instance;
}
public function __construct() {
@@ -45,7 +45,7 @@ class MainWP_Child_Plugins_Check {
add_action( $this->cron_name_watcher, array( $this, 'perform_watchdog' ) );
- //add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
+ // add_filter( 'plugin_row_meta', array( $this, 'change_plugin_row_meta' ), 10, 4 );
add_filter( 'plugins_api_args', array( $this, 'modify_plugin_api_search_query' ), 10, 2 );
@@ -97,7 +97,7 @@ class MainWP_Child_Plugins_Check {
$last_run = new \DateTime( '@' . $last_run );
}
- //Get now
+ // Get now
$now = new \DateTime();
if ( false === $last_run || (int) $now->diff( $last_run )->format( '%h' ) >= 24 ) {
@@ -112,14 +112,13 @@ class MainWP_Child_Plugins_Check {
}
public function schedule_watchdog() {
- //For testing
- //$this->cleanup_deactivation();
+ // For testing
+ // $this->cleanup_deactivation();
- //Schedule a global watching cron just in case both other crons get killed
+ // Schedule a global watching cron just in case both other crons get killed
if ( ! wp_next_scheduled( $this->cron_name_watcher ) ) {
wp_schedule_event( time(), 'hourly', $this->cron_name_watcher );
}
-
}
public function get_plugins_outdate_info() {
@@ -143,44 +142,38 @@ class MainWP_Child_Plugins_Check {
}
return $plugins_outdate;
-
}
// for testing
public function change_plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) {
- //Grab our previously stored array of known last modified dates
- //Requires WP 2.8.0
+ // Grab our previously stored array of known last modified dates
+ // Requires WP 2.8.0
$plugin_info = get_transient( $this->tran_name_plugin_timestamps );
- //Sanity check the response
- if( false === $plugin_info || ! is_array( $plugin_info ) && 0 === count( $plugin_info ) )
- {
+ // Sanity check the response
+ if ( false === $plugin_info || ! is_array( $plugin_info ) && 0 === count( $plugin_info ) ) {
return $plugin_meta;
}
- //See if this specific plugin is in the known list
- if( array_key_exists( $plugin_file, $plugin_info ) )
- {
- //Get now
- $now = new \DateTime();
+ // See if this specific plugin is in the known list
+ if ( array_key_exists( $plugin_file, $plugin_info ) ) {
+ // Get now
+ $now = new \DateTime();
$last_updated = $plugin_info[ $plugin_file ]['last_updated'];
- //Last updated is stored as timestamp, get a real date
+ // Last updated is stored as timestamp, get a real date
$plugin_last_updated_date = new \DateTime( '@' . $last_updated );
- //Compute days between now and plugin last updated
+ // Compute days between now and plugin last updated
$diff_in_days = $now->diff( $plugin_last_updated_date )->format( '%a' );
- //Customizable number of days for tolerance
+ // Customizable number of days for tolerance
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
- //If we're outside the window for tolerance show a message
- if( $diff_in_days > $tolerance_in_days )
- {
+ // If we're outside the window for tolerance show a message
+ if ( $diff_in_days > $tolerance_in_days ) {
$plugin_meta[] = sprintf( 'This plugin has not been updated by the author in %1$d days!', $diff_in_days );
- }
- else
- {
+ } else {
$plugin_meta[] = sprintf( 'This plugin was last updated by the author in %1$d days ago.', $diff_in_days );
}
}
@@ -193,17 +186,17 @@ class MainWP_Child_Plugins_Check {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
- //Get our previous results
+ // Get our previous results
$responses = get_transient( $this->tran_name_plugin_timestamps );
if ( false === $responses || ! is_array( $responses ) ) {
$responses = array();
}
- //Get our previous cache of plugins for batching
+ // Get our previous cache of plugins for batching
$all_plugins = get_transient( $this->tran_name_plugins_to_batch );
- //If there wasn't a previous cache
+ // If there wasn't a previous cache
if ( false === $all_plugins || ! is_array( $all_plugins ) ) {
$plugins = get_plugins();
if ( is_array( $plugins ) ) {
@@ -222,29 +215,29 @@ class MainWP_Child_Plugins_Check {
}
$avoid_plugins = array( 'sitepress-multilingual-cms/sitepress.php' );
- //Grab a small number of plugins to scan
- $plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) );
+ // Grab a small number of plugins to scan
+ $plugins_to_scan = array_splice( $all_plugins, 0, apply_filters( 'mainwp_child_plugin_health_check_max_plugins_to_batch', 10 ) );
$tolerance_in_days = get_option( 'mainwp_child_plugintheme_days_outdate', 365 );
- //Loop through each known plugin
+ // Loop through each known plugin
foreach ( $plugins_to_scan as $slug => $v ) {
if ( in_array( $slug, $avoid_plugins ) ) {
continue;
}
- //Try to get the raw information for this plugin
+ // Try to get the raw information for this plugin
$body = $this->try_get_response_body( $slug, false );
- //We couldn't get any information, skip this plugin
+ // We couldn't get any information, skip this plugin
if ( false === $body ) {
continue;
}
- //Deserialize the response
+ // Deserialize the response
$obj = maybe_unserialize( $body );
$now = new \DateTime();
- //Sanity check that deserialization worked and that our property exists
+ // Sanity check that deserialization worked and that our property exists
if ( false !== $obj && is_object( $obj ) && property_exists( $obj, 'last_updated' ) ) {
if ( version_compare( $v['Version'], $obj->version, '>' ) ) {
continue;
@@ -266,7 +259,7 @@ class MainWP_Child_Plugins_Check {
define( 'DAY_IN_SECONDS', 24 * 60 * 60 );
}
- //Store the master response for usage in the plugin table
+ // Store the master response for usage in the plugin table
set_transient( $this->tran_name_plugin_timestamps, $responses, DAY_IN_SECONDS );
if ( 0 === count( $all_plugins ) ) {
@@ -278,26 +271,26 @@ class MainWP_Child_Plugins_Check {
}
private function try_get_response_body( $plugin, $second_pass ) {
- //Some of this code is lifted from class-wp-upgrader
+ // Some of this code is lifted from class-wp-upgrader
- //Get the WordPress current version to be polite in the API call
- include( ABSPATH . WPINC . '/version.php' );
+ // Get the WordPress current version to be polite in the API call
+ include ABSPATH . WPINC . '/version.php';
global $wp_version;
- //General options to be passed to wp_remote_get
+ // General options to be passed to wp_remote_get
$options = array(
- 'timeout' => 60 * 60, //HOUR_IN_SECONDS
+ 'timeout' => 60 * 60, // HOUR_IN_SECONDS
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
);
- //The URL for the endpoint
+ // The URL for the endpoint
$url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
- //If we support SSL
- //Requires WP 3.2.0
+ // If we support SSL
+ // Requires WP 3.2.0
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
- //Requires WP 3.4.0
+ // Requires WP 3.4.0
$url = set_url_scheme( $url, 'https' );
}
@@ -306,27 +299,27 @@ class MainWP_Child_Plugins_Check {
$plugin_dir = dirname( $plugin );
}
- //Try to get the response (usually the SSL version)
- //Requires WP 2.7.0
+ // Try to get the response (usually the SSL version)
+ // Requires WP 2.7.0
$raw_response = wp_remote_get( $url . $plugin_dir, $options );
- //If we don't have an error and we received a valid response code
- //Requires WP 2.7.0
+ // If we don't have an error and we received a valid response code
+ // Requires WP 2.7.0
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
- //Get the actual body
- //Requires WP 2.7.0
+ // Get the actual body
+ // Requires WP 2.7.0
$body = wp_remote_retrieve_body( $raw_response );
- //Make sure that it isn't empty and also not an empty serialized object
+ // Make sure that it isn't empty and also not an empty serialized object
if ( '' !== $body && 'N;' !== $body ) {
- //If valid, return that
+ // If valid, return that
return $body;
}
}
- //The above valid
- //If we previously tried an SSL version try without SSL
- //Code below same as above block
+ // The above valid
+ // If we previously tried an SSL version try without SSL
+ // Code below same as above block
if ( $ssl ) {
$raw_response = wp_remote_get( $http_url . $plugin, $options );
if ( ! is_wp_error( $raw_response ) && 200 === (int) wp_remote_retrieve_response_code( $raw_response ) ) {
@@ -337,22 +330,22 @@ class MainWP_Child_Plugins_Check {
}
}
- //The above failed
- //If we're on a second pass already then there's nothing left to do but bail
+ // The above failed
+ // If we're on a second pass already then there's nothing left to do but bail
if ( true === $second_pass ) {
return false;
}
- //We're still on the first pass, try to get just the name of the directory of the plugin
+ // We're still on the first pass, try to get just the name of the directory of the plugin
$parts = explode( '/', $plugin );
- //Sanity check that we have two parts, a directory and a file name
+ // Sanity check that we have two parts, a directory and a file name
if ( 2 === count( $parts ) ) {
- //Try this entire function using just the directory name
+ // Try this entire function using just the directory name
return $this->try_get_response_body( $parts[0], true );
}
- //Everything above failed, bail
+ // Everything above failed, bail
return false;
}
}
diff --git a/class/class-mainwp-child-robot.php b/class/class-mainwp-child-robot.php
index d48f416..2c01e66 100644
--- a/class/class-mainwp-child-robot.php
+++ b/class/class-mainwp-child-robot.php
@@ -4,11 +4,11 @@ class MainWP_Child_Robot {
public static $instance = null;
static function Instance() {
- if ( null === MainWP_Child_Robot::$instance ) {
- MainWP_Child_Robot::$instance = new MainWP_Child_Robot();
+ if ( null === self::$instance ) {
+ self::$instance = new MainWP_Child_Robot();
}
- return MainWP_Child_Robot::$instance;
+ return self::$instance;
}
public function wpr_insertcomments( $postid, $comments ) {
@@ -23,12 +23,12 @@ class MainWP_Child_Robot {
$comment_author = $comment['author'];
$comment_author_url = '';
$comment_content = '';
- $comment_content .= $comment['content'];
- $comment_type = '';
- $user_ID = '';
- $comment_approved = 1;
- $commentdata = compact( 'comment_post_ID', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID', 'comment_approved' );
- $comment_id = wp_insert_comment( $commentdata );
+ $comment_content .= $comment['content'];
+ $comment_type = '';
+ $user_ID = '';
+ $comment_approved = 1;
+ $commentdata = compact( 'comment_post_ID', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID', 'comment_approved' );
+ $comment_id = wp_insert_comment( $commentdata );
}
}
}
diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php
index 344a5e7..94ac0c1 100644
--- a/class/class-mainwp-child-server-information.php
+++ b/class/class-mainwp-child-server-information.php
@@ -2,7 +2,7 @@
class MainWP_Child_Server_Information {
const WARNING = 1;
- const ERROR = 2;
+ const ERROR = 2;
public static function init() {
add_action( 'wp_ajax_mainwp-child_dismiss_warnings', array(
@@ -19,10 +19,11 @@ class MainWP_Child_Server_Information {
}
if ( $_POST['what'] == 'warning' ) {
- if (isset($_POST['warnings']))
- $warnings = intval($_POST['warnings']);
- else
- $warnings = self::getWarnings();
+ if (isset($_POST['warnings'])) {
+ $warnings = intval($_POST['warnings']);
+ } else {
+ $warnings = self::getWarnings();
+ }
$dismissWarnings['warnings'] = $warnings;
}
MainWP_Helper::update_option( 'mainwp_child_dismiss_warnings', $dismissWarnings );
@@ -34,7 +35,7 @@ class MainWP_Child_Server_Information {
return;
}
- $warnings = self::getWarnings();
+ $warnings = self::getWarnings();
$dismissWarnings = get_option( 'mainwp_child_dismiss_warnings' );
if ( ! is_array( $dismissWarnings ) ) {
@@ -473,12 +474,17 @@ class MainWP_Child_Server_Information {
-
+
+
+
+
+
@@ -509,7 +515,7 @@ class MainWP_Child_Server_Information {
if ( ! self::check( '>=', '10000', 'getOutputBufferSize' ) ) {
$i ++;
}
- // if (!self::check('=', true, 'getSSLSupport')) $i++;
+ // if (!self::check('=', true, 'getSSLSupport')) $i++;
if ( ! self::checkDirectoryMainWPDirectory( false ) ) {
$i ++;
@@ -538,10 +544,10 @@ class MainWP_Child_Server_Information {
public static function render() {
$branding_title = MainWP_Child_Branding::Instance()->get_branding_title();
- $isBranding = true;
+ $isBranding = true;
if ( $branding_title == '' ) {
$branding_title = 'MainWP Child';
- $isBranding = false;
+ $isBranding = false;
}
?>
@@ -573,7 +579,7 @@ class MainWP_Child_Server_Information {
| ||||||||
@@ -583,8 +589,9 @@ class MainWP_Child_Server_Information { | |||||||||
- | |||||||||
- | |||||||||
- | |||||||||
- | |||||||||
+ | Pass' : self::getWarningHTML( $errorType ) ); ?> | - +Pass' : self::getWarningHTML( $errorType ) ); ?> | - +Pass'; ?> | -Pass' : self::getWarningHTML( $errorType )); ?> | +Pass' : self::getWarningHTML( $errorType ) ); ?> | Warning'; } @@ -1124,9 +1134,9 @@ class MainWP_Child_Server_Information { protected static function getSSLWarning() { $conf = array( 'private_key_bits' => 2048 ); - $str = ''; + $str = ''; if ( function_exists( 'openssl_pkey_new' ) ) { - $res = @openssl_pkey_new( $conf ); + $res = @openssl_pkey_new( $conf ); @openssl_pkey_export( $res, $privkey ); $str = openssl_error_string(); @@ -1170,7 +1180,10 @@ class MainWP_Child_Server_Information { } protected static function getArchitecture() { - echo esc_html( PHP_INT_SIZE * 8 ) ?> bit + bit + 'test'); - $url = add_query_arg( $query_args, $url ); - $args = array( 'blocking' => TRUE, - 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), - 'timeout' => 15 + $url = site_url( 'wp-cron.php' ); + $query_args = array( 'mainwp_child_run' => 'test' ); + $url = add_query_arg( $query_args, $url ); + $args = array( + 'blocking' => true, + 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), + 'timeout' => 15, ); - $response = wp_remote_post( $url, $args ); + $response = wp_remote_post( $url, $args ); $test_result = ''; if ( is_wp_error( $response ) ) { - $test_result .= sprintf( __( 'The HTTP response test get an error "%s"','mainwp-child' ), $response->get_error_message() ); + $test_result .= sprintf( __( 'The HTTP response test get an error "%s"', 'mainwp-child' ), $response->get_error_message() ); } $response_code = wp_remote_retrieve_response_code( $response ); - if ( $response_code < 200 && $response_code > 204 ) { - $test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)','mainwp-child' ), wp_remote_retrieve_response_code( $response ) ); + if ( $response_code < 200 && $response_code > 204 ) { + $test_result .= sprintf( __( 'The HTTP response test get a false http status (%s)', 'mainwp-child' ), wp_remote_retrieve_response_code( $response ) ); } else { $response_body = wp_remote_retrieve_body( $response ); - if ( FALSE === strstr( $response_body, 'MainWP Test' ) ) { - $test_result .= sprintf( __( 'Not expected HTTP response body: %s','mainwp-child' ), esc_attr( strip_tags( $response_body ) ) ); + if ( false === strstr( $response_body, 'MainWP Test' ) ) { + $test_result .= sprintf( __( 'Not expected HTTP response body: %s', 'mainwp-child' ), esc_attr( strip_tags( $response_body ) ) ); } } if ( empty( $test_result ) ) { _e( 'Response Test O.K.', 'mainwp-child' ); - } else + } else { echo $test_result; + } } @@ -1411,7 +1426,6 @@ class MainWP_Child_Server_Information { } return $bytes; - } @@ -1472,7 +1486,7 @@ class MainWP_Child_Server_Information { $branding_title = 'MainWP'; } $msg = esc_html( stripslashes( $branding_title ) ) . ' is unable to find your error logs, please contact your host for server error logs.'; - echo '||||
' . $msg . ' | |||||||||
' . $msg . ' | |||||||||
{$time} | {$error} |
Load more | ||
Load more |
'; - $ret .= __( 'This site is connected to UpdraftPlus Vault.', 'updraftplus' ).' '.__( "Well done - there's nothing more needed to set up.", 'updraftplus' ).'
'.__( 'Vault owner', 'updraftplus' ).': ' . htmlspecialchars( $vault_settings['email'] ); + $ret .= __( 'This site is connected to UpdraftPlus Vault.', 'updraftplus' ) . ' ' . __( "Well done - there's nothing more needed to set up.", 'updraftplus' ) . '
' . __( 'Vault owner', 'updraftplus' ) . ': ' . htmlspecialchars( $vault_settings['email'] );
$ret .= '
' . __( 'Quota:', 'updraftplus' ) . ' ';
- if ( !isset( $vault_settings['quota'] ) || !is_numeric( $vault_settings['quota'] ) || ( $vault_settings['quota'] < 0 ) ) {
+ if ( ! isset( $vault_settings['quota'] ) || ! is_numeric( $vault_settings['quota'] ) || ( $vault_settings['quota'] < 0 ) ) {
$ret .= __( 'Unknown', 'updraftplus' );
} else {
$quota_via_transient = get_transient( 'updraftvault_quota_text' );
@@ -297,23 +306,25 @@ class MainWP_Child_Updraft_Plus_Backups {
$vault_mothership = 'https://vault.updraftplus.com/plugin-info/';
// Use SSL to prevent snooping
- $result = wp_remote_post( $vault_mothership.'/?udm_action=vault_connect',
+ $result = wp_remote_post( $vault_mothership . '/?udm_action=vault_connect',
array(
'timeout' => 20,
- 'body' => array(
- 'e' => $email,
- 'p' => base64_encode( $password ),
+ 'body' => array(
+ 'e' => $email,
+ 'p' => base64_encode( $password ),
'sid' => $updraftplus->siteid(),
- 'su' => base64_encode( home_url() )
- )
+ 'su' => base64_encode( home_url() ),
+ ),
)
);
- if ( is_wp_error( $result ) || ( false === $result ) ) return $result;
+ if ( is_wp_error( $result ) || ( false === $result ) ) {
+ return $result;
+ }
$response = json_decode( $result['body'], true );
- if ( !is_array( $response ) || !isset( $response['mothership'] ) || !isset( $response['loggedin'] ) ) {
+ if ( ! is_array( $response ) || ! isset( $response['mothership'] ) || ! isset( $response['loggedin'] ) ) {
if ( preg_match( '/has banned your IP address \(([\.:0-9a-f]+)\)/', $result['body'], $matches ) ) {
return new WP_Error( 'banned_ip', sprintf( __( "UpdraftPlus.com has responded with 'Access Denied'.", 'updraftplus' ) . '
' . __( "It appears that your web server's IP Address (%s) is blocked.", 'updraftplus' ) . ' ' . __( 'This most likely means that you share a webserver with a hacked website that has been used in previous attacks.', 'updraftplus' ) . '
' . __( 'To remove the block, please go here.', 'updraftplus' ) . ' ', $matches[1] ) );
} else {
@@ -323,25 +334,28 @@ class MainWP_Child_Updraft_Plus_Backups {
switch ( $response['loggedin'] ) {
case 'connected':
- if ( !empty( $response['token'] ) ) {
+ if ( ! empty( $response['token'] ) ) {
// Store it
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
- if ( !is_array( $vault_settings ) ) $vault_settings = array();
+ if ( ! is_array( $vault_settings ) ) {
+ $vault_settings = array();
+ }
$vault_settings['email'] = $email;
$vault_settings['token'] = (string) $response['token'];
$vault_settings['quota'] = -1;
unset( $vault_settings['last_config'] );
- if ( isset($response['quota'] ) ) $vault_settings['quota'] = $response['quota'];
+ if ( isset($response['quota'] ) ) {
+ $vault_settings['quota'] = $response['quota'];
+ }
UpdraftPlus_Options::update_updraft_option( 'updraft_updraftvault', $vault_settings );
- } elseif ( isset( $response['quota'] ) && !$response['quota'] ) {
+ } elseif ( isset( $response['quota'] ) && ! $response['quota'] ) {
return new WP_Error( 'no_quota', __( 'You do not currently have any UpdraftPlus Vault quota', 'updraftplus' ) );
} else {
return new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
}
break;
case 'authfailed':
-
- if ( !empty( $response['authproblem'] ) ) {
+ if ( ! empty( $response['authproblem'] ) ) {
if ( 'invalidpassword' == $response['authproblem'] ) {
$authfail_error = new WP_Error( 'authfailed', __( 'Your email address was valid, but your password was not recognised by UpdraftPlus.Com.', 'updraftplus' ) . ' ' . __( 'If you have forgotten your password, then go here to change your password on updraftplus.com.', 'updraftplus' ) . '' );
return $authfail_error;
@@ -371,24 +385,28 @@ class MainWP_Child_Updraft_Plus_Backups {
delete_transient( 'udvault_last_config' );
delete_transient( 'updraftvault_quota_text' );
- MainWP_Helper::close_connection( array( 'disconnected' => 1,
- 'html' => $this->connected_html() )
+ MainWP_Helper::close_connection( array(
+ 'disconnected' => 1,
+ 'html' => $this->connected_html(),
+ )
);
// If $_POST['reset_hash'] is set, then we were alerted by updraftplus.com - no need to notify back
if ( is_array( $vault_settings ) && isset( $vault_settings['email'] ) && empty( $_POST['reset_hash'] ) ) {
$post_body = array(
- 'e' => (string) $vault_settings['email'],
+ 'e' => (string) $vault_settings['email'],
'sid' => $updraftplus->siteid(),
- 'su' => base64_encode( home_url() )
+ 'su' => base64_encode( home_url() ),
);
- if ( !empty( $vault_settings['token'] ) ) $post_body['token'] = (string) $vault_settings['token'];
+ if ( ! empty( $vault_settings['token'] ) ) {
+ $post_body['token'] = (string) $vault_settings['token'];
+ }
// Use SSL to prevent snooping
- wp_remote_post( $vault_mothership.'/?udm_action=vault_disconnect', array(
+ wp_remote_post( $vault_mothership . '/?udm_action=vault_disconnect', array(
'timeout' => 20,
- 'body' => $post_body,
+ 'body' => $post_body,
));
}
}
@@ -396,11 +414,11 @@ class MainWP_Child_Updraft_Plus_Backups {
function required_files() {
if (defined('UPDRAFTPLUS_DIR')) {
if ( ! class_exists( 'UpdraftPlus' ) && file_exists( UPDRAFTPLUS_DIR . '/class-updraftplus.php') ) {
- require_once( UPDRAFTPLUS_DIR . '/class-updraftplus.php' );
+ require_once UPDRAFTPLUS_DIR . '/class-updraftplus.php';
}
- if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
- require_once( UPDRAFTPLUS_DIR . '/options.php' );
+ if ( ! class_exists( 'UpdraftPlus_Options' ) && file_exists( UPDRAFTPLUS_DIR . '/options.php' ) ) {
+ require_once UPDRAFTPLUS_DIR . '/options.php';
}
}
}
@@ -418,83 +436,84 @@ class MainWP_Child_Updraft_Plus_Backups {
$settings_key = null;
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'])){
- $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
+ 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'];
-// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
- $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
+ // $opts['settings'][$settings_key]['appkey'] = $settings[ $key ]['appkey'];
+ // $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
+ $opts['settings'][ $settings_key ]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
- } else {
- if (isset($settings['is_general']) && !empty($settings['is_general'])){
+ } else {
+ if (isset($settings['is_general']) && ! empty($settings['is_general'])) {
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
} else {
-// $opts['appkey'] = $settings[ $key ]['appkey'];
-// $opts['secret'] = $settings[ $key ]['secret'];
+ // $opts['appkey'] = $settings[ $key ]['appkey'];
+ // $opts['secret'] = $settings[ $key ]['secret'];
$opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
}
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
- } else if ( 'updraft_googledrive' === $key ) {
+ } elseif ( 'updraft_googledrive' === $key ) {
// do not saving from dashboard
-// $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' );
-// if (!is_array($opts))
-// $opts = array();
-// if(is_array($opts) && isset($opts['settings'])) {
-// $settings_key = key($opts['settings']);
-//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
-//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
-// $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
-// } else {
-//// $opts['clientid'] = $settings[ $key ]['clientid'];
-//// $opts['secret'] = $settings[ $key ]['secret'];
-// $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
-// }
-// UpdraftPlus_Options::update_updraft_option( $key, $opts );
- } else if ( 'updraft_googlecloud' === $key ) {
+ // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_googledrive' );
+ // if (!is_array($opts))
+ // $opts = array();
+ // if(is_array($opts) && isset($opts['settings'])) {
+ // $settings_key = key($opts['settings']);
+ // $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
+ // $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
+ // $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
+ // } else {
+ // $opts['clientid'] = $settings[ $key ]['clientid'];
+ // $opts['secret'] = $settings[ $key ]['secret'];
+ // $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
+ // }
+ // UpdraftPlus_Options::update_updraft_option( $key, $opts );
+ } elseif ( 'updraft_googlecloud' === $key ) {
// do not saving from dashboard
-// $opts = UpdraftPlus_Options::get_updraft_option( $key );
-// if (!is_array($opts))
-// $opts = array();
-// if(is_array($opts) && isset($opts['settings'])) {
-// $settings_key = key($opts['settings']);
-//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
-//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
-//// $opts['settings'][$settings_key]['project_id'] = $settings[ $key ]['project_id'];
-//// $opts['settings'][$settings_key]['bucket_path'] = $settings[ $key ]['bucket_path'];
-// $opts['settings'][$settings_key]['storage_class'] = $settings[ $key ]['storage_class'];
-// $opts['settings'][$settings_key]['bucket_location'] = $settings[ $key ]['bucket_location'];
-// } else {
-//// $opts['clientid'] = $settings[ $key ]['clientid'];
-//// $opts['secret'] = $settings[ $key ]['secret'];
-//// $opts['project_id'] = $settings[ $key ]['project_id'];
-//// $opts['bucket_path'] = $settings[ $key ]['bucket_path'];
-// $opts['storage_class'] = $settings[ $key ]['storage_class'];
-// $opts['bucket_location'] = $settings[ $key ]['bucket_location'];
-// }
-// UpdraftPlus_Options::update_updraft_option( $key, $opts );
- } else if ( 'updraft_onedrive' === $key ) {
+ // $opts = UpdraftPlus_Options::get_updraft_option( $key );
+ // if (!is_array($opts))
+ // $opts = array();
+ // if(is_array($opts) && isset($opts['settings'])) {
+ // $settings_key = key($opts['settings']);
+ // $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
+ // $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
+ // $opts['settings'][$settings_key]['project_id'] = $settings[ $key ]['project_id'];
+ // $opts['settings'][$settings_key]['bucket_path'] = $settings[ $key ]['bucket_path'];
+ // $opts['settings'][$settings_key]['storage_class'] = $settings[ $key ]['storage_class'];
+ // $opts['settings'][$settings_key]['bucket_location'] = $settings[ $key ]['bucket_location'];
+ // } else {
+ // $opts['clientid'] = $settings[ $key ]['clientid'];
+ // $opts['secret'] = $settings[ $key ]['secret'];
+ // $opts['project_id'] = $settings[ $key ]['project_id'];
+ // $opts['bucket_path'] = $settings[ $key ]['bucket_path'];
+ // $opts['storage_class'] = $settings[ $key ]['storage_class'];
+ // $opts['bucket_location'] = $settings[ $key ]['bucket_location'];
+ // }
+ // UpdraftPlus_Options::update_updraft_option( $key, $opts );
+ } elseif ( 'updraft_onedrive' === $key ) {
// do not saving from dashboard
-// $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' );
-// if (!is_array($opts))
-// $opts = array();
-// if(is_array($opts) && isset($opts['settings'])) {
-// $settings_key = key($opts['settings']);
-//// $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
-//// $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
-// $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
-// } else {
-//// $opts['clientid'] = $settings[ $key ]['clientid'];
-//// $opts['secret'] = $settings[ $key ]['secret'];
-// $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
-// }
-//
-// UpdraftPlus_Options::update_updraft_option( $key, $opts );
- } else if ( 'updraft_email' === $key ) {
+ // $opts = UpdraftPlus_Options::get_updraft_option( 'updraft_onedrive' );
+ // if (!is_array($opts))
+ // $opts = array();
+ // if(is_array($opts) && isset($opts['settings'])) {
+ // $settings_key = key($opts['settings']);
+ // $opts['settings'][$settings_key]['clientid'] = $settings[ $key ]['clientid'];
+ // $opts['settings'][$settings_key]['secret'] = $settings[ $key ]['secret'];
+ // $opts['settings'][$settings_key]['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
+ // } else {
+ // $opts['clientid'] = $settings[ $key ]['clientid'];
+ // $opts['secret'] = $settings[ $key ]['secret'];
+ // $opts['folder'] = $this->replace_tokens($settings[ $key ]['folder']);
+ // }
+ //
+ // UpdraftPlus_Options::update_updraft_option( $key, $opts );
+ } elseif ( 'updraft_email' === $key ) {
$value = $settings[ $key ];
// free version
if ( ! is_array( $value ) ) {
@@ -503,105 +522,110 @@ class MainWP_Child_Updraft_Plus_Backups {
}
}
UpdraftPlus_Options::update_updraft_option( $key, $value );
- } else if ( 'updraft_s3' === $key ) {
+ } 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'])) {
- $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)) {
- $opts['settings'][$settings_key]['path'] = substr($opts['settings'][$settings_key]['path'], 1);
+ }
+ 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)) {
+ $opts['settings'][ $settings_key ]['path'] = substr($opts['settings'][ $settings_key ]['path'], 1);
}
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'];
+ $opts['settings'][ $settings_key ]['rrs'] = $settings[ $key ]['rrs'];
+ $opts['settings'][ $settings_key ]['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
}
} else {
$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)) {
+ $opts['secretkey'] = $settings[ $key ]['secretkey'];
+ $opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
+ if ( ! empty($opts['path']) && '/' == substr($opts['path'], 0, 1)) {
$opts['path'] = substr($opts['path'], 1);
}
if (isset($settings[ $key ]['rrs'])) { // premium settings
- $opts['rrs'] = $settings[ $key ]['rrs'];
- $opts['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
+ $opts['rrs'] = $settings[ $key ]['rrs'];
+ $opts['server_side_encryption'] = $settings[ $key ]['server_side_encryption'];
}
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
- } else if ( 'updraft_s3generic' === $key ) {
+ } 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'])) {
- $settings_key = key($opts['settings']);
- $opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
- $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 (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'];
+ $opts['settings'][ $settings_key ]['secretkey'] = $settings[ $key ]['secretkey'];
+ $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens($settings[ $key ]['path']);
} else {
- $opts['endpoint'] = $settings[ $key ]['endpoint'];
- $opts['accesskey'] = $settings[ $key ]['accesskey'];
- $opts['secretkey'] = $settings[ $key ]['secretkey'];
- $opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
+ $opts['endpoint'] = $settings[ $key ]['endpoint'];
+ $opts['accesskey'] = $settings[ $key ]['accesskey'];
+ $opts['secretkey'] = $settings[ $key ]['secretkey'];
+ $opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
- } else if ( 'updraft_dreamobjects' === $key ) {
+ } 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'])) {
- $settings_key = key($opts['settings']);
- $opts['settings'][$settings_key]['path'] = $this->replace_tokens($settings[ $key ]['path']);
- $opts['settings'][$settings_key]['endpoint'] = $settings[ $key ]['endpoint'];
+ }
+ 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'];
} else {
- $opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
- $opts['endpoint'] = $settings[ $key ]['endpoint'];
+ $opts['path'] = $this->replace_tokens($settings[ $key ]['path']);
+ $opts['endpoint'] = $settings[ $key ]['endpoint'];
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
- } else if ( 'updraft_ftp' === $key ) {
+ } 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'];
- $opts['settings'][$settings_key]['user'] = $settings[ $key ]['user'];
- $opts['settings'][$settings_key]['pass'] = $settings[ $key ]['pass'];
- $opts['settings'][$settings_key]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
- $opts['settings'][$settings_key]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
+ $opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host'];
+ $opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user'];
+ $opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass'];
+ $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
+ $opts['settings'][ $settings_key ]['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
}
} else {
if ( isset( $settings[ $key ]['path'] ) ) {
- $opts['host'] = $settings[ $key ]['host'];
- $opts['user'] = $settings[ $key ]['user'];
- $opts['pass'] = $settings[ $key ]['pass'];
- $opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
+ $opts['host'] = $settings[ $key ]['host'];
+ $opts['user'] = $settings[ $key ]['user'];
+ $opts['pass'] = $settings[ $key ]['pass'];
+ $opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
$opts['passive'] = isset($settings[ $key ]['passive']) ? $settings[ $key ]['passive'] : 0;
}
}
UpdraftPlus_Options::update_updraft_option( $key, $opts );
- } else if ( 'updraft_sftp_settings' === $key ) {
+ } 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'];
- $opts['settings'][$settings_key]['port'] = $settings[ $key ]['port'];
- $opts['settings'][$settings_key]['user'] = $settings[ $key ]['user'];
- $opts['settings'][$settings_key]['pass'] = $settings[ $key ]['pass'];
- $opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
- $opts['settings'][$settings_key]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
- $opts['settings'][$settings_key]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
+ $opts['settings'][ $settings_key ]['host'] = $settings[ $key ]['host'];
+ $opts['settings'][ $settings_key ]['port'] = $settings[ $key ]['port'];
+ $opts['settings'][ $settings_key ]['user'] = $settings[ $key ]['user'];
+ $opts['settings'][ $settings_key ]['pass'] = $settings[ $key ]['pass'];
+ $opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key'];
+ $opts['settings'][ $settings_key ]['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
+ $opts['settings'][ $settings_key ]['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
}
} else {
if ( isset( $settings[ $key ]['path'] ) ) {
@@ -609,39 +633,41 @@ class MainWP_Child_Updraft_Plus_Backups {
$opts['port'] = $settings[ $key ]['port'];
$opts['user'] = $settings[ $key ]['user'];
$opts['pass'] = $settings[ $key ]['pass'];
- $opts['key'] = $settings[ $key ]['key'];
+ $opts['key'] = $settings[ $key ]['key'];
$opts['path'] = $this->replace_tokens( $settings[ $key ]['path'] );
- $opts['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
+ $opts['scp'] = isset($settings[ $key ]['scp']) ? $settings[ $key ]['scp'] : 0;
}
}
UpdraftPlus_Options::update_updraft_option( 'updraft_sftp', $opts );
- } else if ('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'])) {
- $settings_key = key($opts['settings']);
- $opts['settings'][$settings_key]['url'] = $this->replace_tokens( $settings[ $key ]['url'] );
+ 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 );
}
- } else if ( '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'])) {
- $settings_key = key($opts['settings']);
- $opts['settings'][$settings_key]['account_id'] = $settings[ $key ]['account_id'];
- $opts['settings'][$settings_key]['key'] = $settings[ $key ]['key'];
+ $settings_key = key($opts['settings']);
+ $opts['settings'][ $settings_key ]['account_id'] = $settings[ $key ]['account_id'];
+ $opts['settings'][ $settings_key ]['key'] = $settings[ $key ]['key'];
$bname = $this->replace_tokens( $settings[ $key ]['bucket_name'] );
$bpath = $this->replace_tokens( $settings[ $key ]['backup_path'] );
$bname = str_replace('.', '-', $bname);
$bpath = str_replace('.', '-', $bpath);
$bname = str_replace('_', '', $bname); // to fix strange character
$bpath = str_replace('_', '', $bpath);
- $opts['settings'][$settings_key]['bucket_name'] = $bname;
- $opts['settings'][$settings_key]['backup_path'] = $bpath;
+ $opts['settings'][ $settings_key ]['bucket_name'] = $bname;
+ $opts['settings'][ $settings_key ]['backup_path'] = $bpath;
UpdraftPlus_Options::update_updraft_option( $key, $opts );
}
} else {
@@ -651,12 +677,10 @@ 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'] );
}
-
global $updraftplus;
if ( isset( $settings['updraft_interval'] ) ) {
// fix for premium version
@@ -685,26 +709,28 @@ class MainWP_Child_Updraft_Plus_Backups {
return $out;
}
- function replace_tokens($str = '') {
+ 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);
+ $str = str_ireplace('%sitename%', $replace_token, $str);
}
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);
- $str = str_ireplace("%siteurl%", $replace_token, $str);
+ $str = str_ireplace('%siteurl%', $replace_token, $str);
}
return $str;
}
function addons_connect() {
if ( ! defined( 'UDADDONS2_SLUG' ) ) {
- if (is_file(UPDRAFTPLUS_DIR.'/udaddons/updraftplus-addons.php')) require_once(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' ) ) {
return array( 'error' => 'NO_PREMIUM' );
}
@@ -747,7 +773,7 @@ class MainWP_Child_Updraft_Plus_Backups {
// Funnelling through here a) allows for future flexibility and b) allows us to migrate elegantly from the previous non-MU-friendly setup
public function addons2_get_option( $option ) {
$val = get_site_option( $option );
- # On multisite, migrate options into the site options
+ // On multisite, migrate options into the site options
if ( false === $val && is_multisite() ) {
$blog_id = get_current_blog_id();
if ( $blog_id > 1 ) {
@@ -759,7 +785,7 @@ class MainWP_Child_Updraft_Plus_Backups {
return $val;
}
}
- # $val is still false
+ // $val is still false
switch_to_blog( 1 );
$val = get_option( $option );
if ( false !== $val ) {
@@ -777,7 +803,7 @@ class MainWP_Child_Updraft_Plus_Backups {
}
public function options_validate( $input ) {
- # See: http://codex.wordpress.org/Function_Reference/add_settings_error
+ // See: http://codex.wordpress.org/Function_Reference/add_settings_error
// When the options are re-saved, clear any previous cache of the connection status
$ehash = substr( md5( $input['email'] ), 0, 23 );
@@ -804,12 +830,15 @@ class MainWP_Child_Updraft_Plus_Backups {
if ( ! class_exists( 'UpdraftPlus_WPDB_OtherDB_Test' ) ) {
if ( file_exists( UPDRAFTPLUS_DIR . '/addons/moredatabase.php' ) ) {
- require_once( UPDRAFTPLUS_DIR . '/addons/moredatabase.php' );
+ require_once UPDRAFTPLUS_DIR . '/addons/moredatabase.php';
}
}
if ( ! class_exists( 'UpdraftPlus_WPDB_OtherDB_Test' ) ) {
- return array( 'r' => $_POST['row'], 'm' => 'Error: Require premium UpdraftPlus plugin.' );
+ return array(
+ 'r' => $_POST['row'],
+ 'm' => 'Error: Require premium UpdraftPlus plugin.',
+ );
}
if ( empty( $_POST['user_db'] ) ) {
@@ -842,7 +871,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$wpdb_obj = new UpdraftPlus_WPDB_OtherDB_Test( $_POST['user_db'], $_POST['pass'], $_POST['name'], $_POST['host'] );
if ( ! empty( $wpdb_obj->error ) ) {
$failed = true;
- $ret .= '
'; + $ret .= '
'; $dbinfo['user'] . '@' . $dbinfo['host'] . '/' . $dbinfo['name'] . ' : ' . __( 'database connection attempt failed', 'updraftplus' ) . '
'; if ( is_wp_error( $wpdb_obj->error ) || is_string( $wpdb_obj->error ) ) { $ret .= ''; @@ -1805,17 +1844,16 @@ class MainWP_Child_Updraft_Plus_Backups { $updraftplus->log_wp_error( $backup_success ); $updraftplus->log( 'Restore failed' ); $updraftplus->list_errors(); - //echo ''.__('Actions','updraftplus').': '.__('Return to UpdraftPlus Configuration','updraftplus').''; + // echo ''.__('Actions','updraftplus').': '.__('Return to UpdraftPlus Configuration','updraftplus').''; } elseif ( false === $backup_success ) { - # This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information" + // This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information" } $output = ob_get_clean(); return array( 'o' => $output ); - } // not used @@ -1825,7 +1863,7 @@ class MainWP_Child_Updraft_Plus_Backups { @set_time_limit( 900 ); global $wp_filesystem, $updraftplus; -// $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' ); + // $backup_history = UpdraftPlus_Options::get_updraft_option( 'updraft_backup_history' ); $backup_history = UpdraftPlus_Backup_History::get_history(); if ( ! is_array( $backup_history[ $timestamp ] ) ) { echo wp_kses_post( '
' . esc_html__( 'This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus' ) . " $timestamp
'.__('Follow this link to download the log file for this restoration.', 'updraftplus').'
'; + // echo ''.__('Follow this link to download the log file for this restoration.', 'updraftplus').'
'; - # TODO: Automatic purging of old log files - # TODO: Provide option to auto-email the log file + // TODO: Automatic purging of old log files + // TODO: Provide option to auto-email the log file - //if we make it this far then WP_Filesystem has been instantiated and is functional (tested with ftpext, what about suPHP and other situations where direct may work?) + // if we make it this far then WP_Filesystem has been instantiated and is functional (tested with ftpext, what about suPHP and other situations where direct may work?) echo '$type: " ); esc_html_e( 'Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.', 'updraftplus' ); - #TODO - #$updraftplus->log_e('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.'); + // TODO + // $updraftplus->log_e('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.'); echo '
'; continue; } @@ -1997,7 +2035,7 @@ class MainWP_Child_Updraft_Plus_Backups { foreach ( $files as $ind => $file ) { $fullpath = $updraft_dir . $file; - echo sprintf( esc_html__( 'Looking for %s archive: file name: %s', 'updraftplus' ), esc_html( $type ), esc_html( htmlspecialchars( $file ) ) ) . '', esc_html__( 'Old directory removal failed for some reason. You may want to do this manually.', 'updraftplus' ) . '
'; -// $rawbackup = "" . esc_attr( print_r( $backup, true ) ); + // if ( ! empty( $non ) ) { + // $jd = $updraftplus->jobdata_getarray( $non ); + // if ( ! empty( $jd ) && is_array( $jd ) ) { + // $rawbackup .= '
' . esc_attr( print_r( $jd, true ) ); + // } + // } + // $rawbackup .= '
'; - - // to fix - $rawbackup = '' ; //$updraftplus_admin->raw_backup_info($backup_history, $key, $non); + // to fix + $rawbackup = ''; // $updraftplus_admin->raw_backup_info($backup_history, $key, $non); $jobdata = $updraftplus->jobdata_getarray( $non ); @@ -3144,21 +3198,24 @@ class MainWP_Child_Updraft_Plus_Backups { $date_label = $this->date_label( $pretty_date, $key, $backup, $jobdata, $non ); $service_title = ''; - if (!isset($backup['service'])) $backup['service'] = array(); - if (!is_array($backup['service'])) $backup['service'] = array($backup['service']); + if ( ! isset($backup['service'])) { + $backup['service'] = array(); + } + 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))) { + 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'; + // $image_url = file_exists($image_folder.$service.'.png') ? $image_folder_url.$service.'.png' : $image_folder_url.'folder.png'; - $remote_storage = ('remotesend' === $service) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[$service]; + $remote_storage = ( 'remotesend' === $service ) ? __('remote site', 'updraftplus') : $updraftplus->backup_methods[ $service ]; $service_title = '" . esc_attr( print_r( $backup, true ) ); -// if ( ! empty( $non ) ) { -// $jd = $updraftplus->jobdata_getarray( $non ); -// if ( ! empty( $jd ) && is_array( $jd ) ) { -// $rawbackup .= '
' . esc_attr( print_r( $jd, true ) ); -// } -// } -// $rawbackup .= '
'.__('(None)', 'updraftplus').'
'; + // if (0 == $found_jobs) $ret .= ''.__('(None)', 'updraftplus').'
'; return $ret; } @@ -3648,7 +3707,7 @@ ENDHERE; return ''; } - #if (!is_array($jobdata)) $jobdata = array(); + // if (!is_array($jobdata)) $jobdata = array(); if ( ! isset( $jobdata['backup_time'] ) ) { return ''; } @@ -3660,11 +3719,11 @@ ENDHERE; $jobstatus = empty( $jobdata['jobstatus'] ) ? 'unknown' : $jobdata['jobstatus']; $stage = 0; switch ( $jobstatus ) { - # Stage 0 + // Stage 0 case 'begun': $curstage = __( 'Backup begun', 'updraftplus' ); break; - # Stage 1 + // Stage 1 case 'filescreating': $stage = 1; $curstage = __( 'Creating file backup zips', 'updraftplus' ); @@ -3685,17 +3744,17 @@ ENDHERE; $curstage = __( 'Created file backup zips', 'updraftplus' ); break; - # Stage 4 + // Stage 4 case 'clouduploading': $stage = 4; $curstage = __( 'Uploading files to remote storage', 'updraftplus' ); if ( isset( $jobdata['uploading_substatus']['t'] ) && isset( $jobdata['uploading_substatus']['i'] ) ) { - $t = max( (int) $jobdata['uploading_substatus']['t'], 1 ); - $i = min( $jobdata['uploading_substatus']['i'] / $t, 1 ); - $p = min( $jobdata['uploading_substatus']['p'], 1 ); - $pd = $i + $p / $t; - $stage = 4 + $pd; - $curstage .= ' ' . sprintf( __( '(%s%%, file %s of %s)', 'updraftplus' ), floor( 100 * $pd ), $jobdata['uploading_substatus']['i'] + 1, $t ); + $t = max( (int) $jobdata['uploading_substatus']['t'], 1 ); + $i = min( $jobdata['uploading_substatus']['i'] / $t, 1 ); + $p = min( $jobdata['uploading_substatus']['p'], 1 ); + $pd = $i + $p / $t; + $stage = 4 + $pd; + $curstage .= ' ' . sprintf( __( '(%1$s%%, file %2$s of %3$s)', 'updraftplus' ), floor( 100 * $pd ), $jobdata['uploading_substatus']['i'] + 1, $t ); } break; case 'pruning': @@ -3706,14 +3765,13 @@ ENDHERE; $stage = - 1; $curstage = __( 'Waiting until scheduled time to retry because of errors', 'updraftplus' ); break; - # Stage 6 + // Stage 6 case 'finished': $stage = 6; $curstage = __( 'Backup finished', 'updraftplus' ); break; default: - - # Database creation and encryption occupies the space from 2 to 4. Databases are created then encrypted, then the next databae is created/encrypted, etc. + // Database creation and encryption occupies the space from 2 to 4. Databases are created then encrypted, then the next databae is created/encrypted, etc. if ( 'dbcreated' === substr( $jobstatus, 0, 9 ) ) { $jobstatus = 'dbcreated'; $whichdb = substr( $jobstatus, 9 ); @@ -3743,7 +3801,7 @@ ENDHERE; $curstage .= ' (' . sprintf( __( 'table: %s', 'updraftplus' ), $jobdata['dbcreating_substatus']['t'] ) . ')'; if ( ! empty( $jobdata['dbcreating_substatus']['i'] ) && ! empty( $jobdata['dbcreating_substatus']['a'] ) ) { $substage = max( 0.001, ( $jobdata['dbcreating_substatus']['i'] / max( $jobdata['dbcreating_substatus']['a'], 1 ) ) ); - $stage += $substage * $perdbspace * 0.5; + $stage += $substage * $perdbspace * 0.5; } } } elseif ( 'dbencrypting' === substr( $jobstatus, 0, 12 ) ) { @@ -3786,7 +3844,7 @@ ENDHERE; } $next_res_after = (int) $time - time(); - $next_res_txt = ( $is_oneshot ) ? '' : ' - ' . sprintf( __( 'next resumption: %d (after %ss)', 'updraftplus' ), $next_resumption, $next_res_after ) . ' '; + $next_res_txt = ( $is_oneshot ) ? '' : ' - ' . sprintf( __( 'next resumption: %1$d (after %2$ss)', 'updraftplus' ), $next_resumption, $next_res_after ) . ' '; $last_activity_txt = ( $last_checkin_ago >= 0 ) ? ' - ' . sprintf( __( 'last activity: %ss ago', 'updraftplus' ), floor( $last_checkin_ago ) ) . ' ' : ''; if ( ( $last_checkin_ago < 50 && $next_res_after > 30 ) || $is_oneshot ) { @@ -3823,7 +3881,6 @@ ENDHERE; $ret .= '