[CodeFactor] Apply fixes

This commit is contained in:
codefactor-io 2020-03-26 15:29:54 +00:00
parent ac49ce16e7
commit 0d6d73e1a6
26 changed files with 1206 additions and 798 deletions

View file

@ -568,7 +568,10 @@ class MainWP_Child_Back_Up_Buddy {
}
function get_notifications() {
return array('result' => 'SUCCESS', 'notifications' => backupbuddy_core::getNotifications() );
return array(
'result' => 'SUCCESS',
'notifications' => backupbuddy_core::getNotifications(),
);
}
function get_schedules_run_time() {
@ -870,7 +873,10 @@ class MainWP_Child_Back_Up_Buddy {
$callback_data = $_POST['callback_data'];
$file = backupbuddy_core::getBackupDirectory() . $callback_data;
if (file_exists($file)) {
return array( 'result' =>'SUCCESS', 'hash' => md5_file( $file ) );
return array(
'result' =>'SUCCESS',
'hash' => md5_file( $file ),
);
} else {
return array( 'error' =>'Not found the file' );
}
@ -997,7 +1003,11 @@ class MainWP_Child_Back_Up_Buddy {
}
return array('result' => 'SUCCESS', 'files' => $files, 'message' => implode('<br/>', $alerts));
return array(
'result' => 'SUCCESS',
'files' => $files,
'message' => implode('<br/>', $alerts),
);
}
function exclude_tree() {
@ -1165,7 +1175,10 @@ class MainWP_Child_Back_Up_Buddy {
}
}
return array( 'result' => 'SUCCESS', 'file_content' => $file_content );
return array(
'result' => 'SUCCESS',
'file_content' => $file_content,
);
}
@ -1552,7 +1565,10 @@ class MainWP_Child_Back_Up_Buddy {
<?php
$html = ob_get_clean();
pb_backupbuddy::flush();
return array('result' => 'SUCCESS', 'html_log' => $html);
return array(
'result' => 'SUCCESS',
'html_log' => $html,
);
}
function view_detail() {
@ -1782,7 +1798,10 @@ class MainWP_Child_Back_Up_Buddy {
$html = ob_get_clean();
pb_backupbuddy::flush();
return array('result' => 'SUCCESS', 'html_detail' => $html);
return array(
'result' => 'SUCCESS',
'html_detail' => $html,
);
}
function reset_integrity() {
@ -1914,7 +1933,10 @@ class MainWP_Child_Back_Up_Buddy {
} else {
return array( 'error' => 'Invalid backup request.' );
}
return array('ok' => 1, 'result' => $result);
return array(
'ok' => 1,
'result' => $result,
);
}
function stop_backup() {
@ -2154,7 +2176,10 @@ class MainWP_Child_Back_Up_Buddy {
$message = 'Marked all timed out or running backups & transfers as officially cancelled (`' . $cancelCount . '` total found).';
}
return array('_error' => $error, '_message' => $message);
return array(
'_error' => $error,
'_message' => $message,
);
}
function malware_scan() {
@ -2562,7 +2587,10 @@ class MainWP_Child_Back_Up_Buddy {
if ( 0 == count( $errors ) ) {
pb_backupbuddy::save();
$data = pb_backupbuddy::$options['remote_destinations'][ $destination_id ];
return array( 'destination_id' => $destination_id, 'data' => $data);
return array(
'destination_id' => $destination_id,
'data' => $data,
);
} else {
return array( 'errors' => $errors );
}
@ -2694,7 +2722,11 @@ class MainWP_Child_Back_Up_Buddy {
$error = 'Error #1000. Invalid request.';
}
return array( 'ok' => 1, '_error' => $error, '_message' => $message );
return array(
'ok' => 1,
'_error' => $error,
'_message' => $message,
);
}
@ -2704,7 +2736,10 @@ class MainWP_Child_Back_Up_Buddy {
backupbuddy_live_troubleshooting::run();
$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() {
@ -2835,7 +2870,10 @@ class MainWP_Child_Back_Up_Buddy {
$msg = 'Failed to delete one or more files. Details: `' . $response . '`.';
}
return array( 'ok' => 1, 'msg' => $msg );
return array(
'ok' => 1,
'msg' => $msg,
);
}
function get_live_stats() {
@ -2922,7 +2960,11 @@ class MainWP_Child_Back_Up_Buddy {
}
}
return array('ok' => 1, 'packages' => $packages, 'packages_name' => $packages_name);
return array(
'ok' => 1,
'packages' => $packages,
'packages_name' => $packages_name,
);
}
function activate_package() {

View file

@ -537,7 +537,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() {
@ -606,11 +609,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() {
@ -640,7 +649,10 @@ class MainWP_Child_Back_WP_Up {
}
}
return array( 'success' => 1, 'response' => $output );
return array(
'success' => 1,
'response' => $output,
);
}
protected function tables() {
@ -666,7 +678,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();
@ -785,7 +800,10 @@ class MainWP_Child_Back_WP_Up {
}
}
return array( 'success' => 1, 'response' => $array );
return array(
'success' => 1,
'response' => $array,
);
}
public function init_download_backup() {
@ -902,7 +920,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() {
@ -938,7 +959,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'],
);
}
}
}
@ -960,7 +984,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'],
);
}
}
@ -993,7 +1020,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' );
}
@ -1092,7 +1122,10 @@ class MainWP_Child_Back_WP_Up {
}
}
return array( 'success' => 1, 'message' => $message );
return array(
'success' => 1,
'message' => $message,
);
}
protected function get_job_files() {
@ -1158,11 +1191,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() {
@ -1217,7 +1257,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() {
@ -1336,11 +1379,26 @@ class MainWP_Child_Back_WP_Up {
}
// 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();
@ -1514,7 +1572,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() {

View file

@ -268,7 +268,10 @@ class MainWP_Child_Branding {
try {
$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 ) ) {
@ -291,7 +294,10 @@ class MainWP_Child_Branding {
try {
$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 ) ) {
@ -364,7 +370,10 @@ class MainWP_Child_Branding {
$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 ) ) {

View file

@ -867,7 +867,11 @@ 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;
}
@ -1175,7 +1179,10 @@ class MainWP_Child_iThemes_Security {
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

View file

@ -1331,7 +1331,8 @@ class MainWP_Child_Server_Information {
$url = site_url( 'wp-cron.php' );
$query_args = array( 'mainwp_child_run' => 'test' );
$url = add_query_arg( $query_args, $url );
$args = array( 'blocking' => true,
$args = array(
'blocking' => true,
'sslverify' => apply_filters( 'https_local_ssl_verify', true ),
'timeout' => 15,
);

View file

@ -84,8 +84,14 @@ class MainWP_Child_Skeleton_Key {
$post_args['redirection'] = 5;
$post_args['decompress'] = false; // For gzinflate() data error bug
$post_args['cookies'] = array(
new WP_Http_Cookie( array( 'name' => $auth_cookie_name, 'value' => $auth_cookie ) ),
new WP_Http_Cookie( array( 'name' => LOGGED_IN_COOKIE, 'value' => $logged_in_cookie ) ),
new WP_Http_Cookie( array(
'name' => $auth_cookie_name,
'value' => $auth_cookie,
) ),
new WP_Http_Cookie( array(
'name' => LOGGED_IN_COOKIE,
'value' => $logged_in_cookie,
) ),
);
if ( isset( $args['get'] ) ) {

View file

@ -234,7 +234,13 @@ class MainWP_Child_Themes_Check {
$url = set_url_scheme( $url, 'https' );
}
$args = array( 'slug' => $theme, 'fields' => array( 'sections' => false, 'tags' => false ) );
$args = array(
'slug' => $theme,
'fields' => array(
'sections' => false,
'tags' => false,
),
);
$args = (object) $args;
$http_args = array(

View file

@ -509,7 +509,8 @@ function get_sibling_files_callback_wptc() {
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $perpage;
}
return array( 'items' => $wpdb->get_results($query),
return array(
'items' => $wpdb->get_results($query),
'totalitems' => $totalitems,
'perpage' => $perpage,
);
@ -838,7 +839,10 @@ function get_sibling_files_callback_wptc() {
if (!$is_user_logged_in) {
return array( 'error' => 'Login failed.' );
}
return array('result' => 'ok', 'sync_data' => $this->get_sync_data());
return array(
'result' => 'ok',
'sync_data' => $this->get_sync_data(),
);
}
function get_installed_plugins() {
@ -880,7 +884,10 @@ function get_sibling_files_callback_wptc() {
$staging = WPTC_Pro_Factory::get('Wptc_Staging');
if (empty($_POST['path'])) {
wptc_die_with_json_encode( array('status' => 'error', 'msg' => 'path is missing') );
wptc_die_with_json_encode( array(
'status' => 'error',
'msg' => 'path is missing',
) );
}
$staging->choose_action($_POST['path'], $reqeust_type = 'fresh');

View file

@ -245,12 +245,18 @@ class MainWP_Child_Updraft_Plus_Backups {
private function do_vault_connect() {
$vault_settings = UpdraftPlus_Options::get_updraft_option( 'updraft_updraftvault' );
if ( is_array( $vault_settings ) && !empty( $vault_settings['token'] ) && !empty( $vault_settings['email'] ) ) {
return array( 'connected' => true, 'html' => $this->connected_html() );
return array(
'connected' => true,
'html' => $this->connected_html(),
);
}
$connect = $this->vault_connect( $_REQUEST['email'], $_REQUEST['passwd'] );
if ( true === $connect ) {
$response = array( 'connected' => true, 'html' => $this->connected_html() );
$response = array(
'connected' => true,
'html' => $this->connected_html(),
);
} else {
$response = array(
'e' => __( 'An unknown error occurred when trying to connect to UpdraftPlus.Com', 'updraftplus' ),
@ -376,8 +382,10 @@ 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
@ -822,7 +830,10 @@ class MainWP_Child_Updraft_Plus_Backups {
}
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'] ) ) {
@ -920,7 +931,10 @@ class MainWP_Child_Updraft_Plus_Backups {
restore_error_handler();
return array( 'r' => $_POST['row'], 'm' => $ret . $ret_after );
return array(
'r' => $_POST['row'],
'm' => $ret . $ret_after,
);
}
private function cb_get_name_base_type( $a) {
@ -944,7 +958,10 @@ class MainWP_Child_Updraft_Plus_Backups {
// unfix for tic#22678
$this->close_browser_connection( $msg );
$options = array( 'nocloud' => $backupnow_nocloud, 'use_nonce' => $nonce );
$options = array(
'nocloud' => $backupnow_nocloud,
'use_nonce' => $nonce,
);
if ( ! empty( $_REQUEST['onlythisfileentity'] ) && is_string( $_REQUEST['onlythisfileentity'] ) ) {
// Something to see in the 'last log' field when it first appears, before the backup actually starts
$updraftplus->log( __( 'Start backup', 'updraftplus' ) );
@ -1073,7 +1090,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$last_backup_text = '<span style="color:blue;">' . __( 'No backup has been completed.', 'updraftplus' ) . '</span>';
}
return array( 'b' => $last_backup_text, 'lasttime_gmt' => $backup_time );
return array(
'b' => $last_backup_text,
'lasttime_gmt' => $backup_time,
);
}
private function get_updraft_data( $with_hist = true ) {
@ -1396,7 +1416,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$output = $noutput . $output;
}
return array( 'h' => $output, 'c' => count( $backup_history ) );
return array(
'h' => $output,
'c' => count( $backup_history ),
);
}
public function historystatus( $remotescan = null, $rescan = null ) {
@ -1641,7 +1664,11 @@ class MainWP_Child_Updraft_Plus_Backups {
$timestamp = (int) $_POST['timestamp'];
if ( ! isset( $backups[ $timestamp ] ) ) {
return array( 'm' => '', 'w' => '', 'e' => __( 'No such backup set exists', 'updraftplus' ) );
return array(
'm' => '',
'w' => '',
'e' => __( 'No such backup set exists', 'updraftplus' ),
);
}
@ -2237,7 +2264,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$output = ob_get_clean();
return array( 'o' => $output, 'd' => $deleted );
return array(
'o' => $output,
'd' => $deleted,
);
}
//deletes the -old directories that are created when a backup is restored.
@ -3859,7 +3889,10 @@ ENDHERE;
$args = $cron[ $time ]['updraft_backup_resume'][ $hook ]['args'];
wp_unschedule_event( $time, 'updraft_backup_resume', $args );
if ( ! $found_it ) {
return array( 'ok' => 'Y', 'm' => __( 'Job deleted', 'updraftplus' ) );
return array(
'ok' => 'Y',
'm' => __( 'Job deleted', 'updraftplus' ),
);
}
$found_it = 1;
}

View file

@ -55,7 +55,10 @@ class MainWP_Child_Vulnerability_Checker {
$result['plugin'] = $this->check_plugins($force);
$result['wp'] = $this->check_wp($force);
$result['theme'] = $this->check_themes($force);
$information = array( 'result' => $result, 'ok' => 1);
$information = array(
'result' => $result,
'ok' => 1,
);
return $information;
}

View file

@ -1004,7 +1004,11 @@ SQL
$bodyMsg = "We didn't $verb2 anything and no errors were found.";
}
return array( 'ok' => 1, 'bulkHeading' => $headMsg, 'bulkBody' => $bodyMsg );
return array(
'ok' => 1,
'bulkHeading' => $headMsg,
'bulkBody' => $bodyMsg,
);
} else {
return array( 'errorMsg' => 'Invalid bulk operation selected' );
}
@ -1357,7 +1361,10 @@ SQL
$api = new wfAPI($apiKey, wfUtils::getWPVersion());
try {
$keyType = wfAPI::KEY_TYPE_FREE;
$keyData = $api->call('ping_api_key', array(), array('supportHash' => wfConfig::get('supportHash', ''), 'whitelistHash' => wfConfig::get('whitelistHash', '')));
$keyData = $api->call('ping_api_key', array(), array(
'supportHash' => wfConfig::get('supportHash', ''),
'whitelistHash' => wfConfig::get('whitelistHash', ''),
));
if (isset($keyData['_isPaidKey'])) {
$keyType = wfConfig::get('keyType');
}
@ -1899,7 +1906,10 @@ SQL
$res[ $ip ] = wfUtils::reverseLookup( $ip );
}
return array( 'ok' => 1, 'ips' => $res );
return array(
'ok' => 1,
'ips' => $res,
);
}
@ -2030,7 +2040,10 @@ SQL
$results = $wfLog->getThrottledIPs();
}
return array( 'ok' => 1, 'results' => $results );
return array(
'ok' => 1,
'results' => $results,
);
}
public function downgrade_license() {
@ -2112,7 +2125,11 @@ SQL
if($cacheType == 'php' || $cacheType == 'falcon'){
$err = wfCache::cacheDirectoryTest();
if($err){
return array('ok' => 1, 'heading' => 'Could not write to cache directory', 'body' => "To enable caching, Wordfence needs to be able to create and write to the /wp-content/wfcache/ directory. We did some tests that indicate this is not possible. You need to manually create the /wp-content/wfcache/ directory and make it writable by Wordfence. The error we encountered was during our tests was: $err");
return array(
'ok' => 1,
'heading' => 'Could not write to cache directory',
'body' => "To enable caching, Wordfence needs to be able to create and write to the /wp-content/wfcache/ directory. We did some tests that indicate this is not possible. You need to manually create the /wp-content/wfcache/ directory and make it writable by Wordfence. The error we encountered was during our tests was: $err",
);
}
}
@ -2126,20 +2143,36 @@ SQL
}
if($cacheType == 'disable'){
wfConfig::set('cacheType', false);
return array('ok' => 1, 'heading' => 'Caching successfully disabled.', 'body' => "{$htMsg}Caching has been disabled on your system.<br /><br /><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>");
return array(
'ok' => 1,
'heading' => 'Caching successfully disabled.',
'body' => "{$htMsg}Caching has been disabled on your system.<br /><br /><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>",
);
} elseif($cacheType == 'php'){
wfConfig::set('cacheType', 'php');
return array('ok' => 1, 'heading' => 'Wordfence Basic Caching Enabled', 'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.<br /><br /><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>");
return array(
'ok' => 1,
'heading' => 'Wordfence Basic Caching Enabled',
'body' => "{$htMsg}Wordfence basic caching has been enabled on your system.<br /><br /><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>",
);
} elseif($cacheType == 'falcon'){
if($noEditHtaccess != '1'){
$err = wfCache::addHtaccessCode('add');
if($err){
return array('ok' => 1, 'heading' => 'Wordfence could not edit .htaccess', 'body' => 'Wordfence could not edit your .htaccess code. The error was: ' . $err);
return array(
'ok' => 1,
'heading' => 'Wordfence could not edit .htaccess',
'body' => 'Wordfence could not edit your .htaccess code. The error was: ' . $err,
);
}
}
wfConfig::set('cacheType', 'falcon');
wfCache::scheduleUpdateBlockedIPs(); //Runs every 5 mins until we change cachetype
return array('ok' => 1, 'heading' => 'Wordfence Falcon Engine Activated!', 'body' => "Wordfence Falcon Engine has been activated on your system. You will see this icon appear on the Wordfence admin pages as long as Falcon is active indicating your site is running in high performance mode:<div class='wfFalconImage'></div><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>");
return array(
'ok' => 1,
'heading' => 'Wordfence Falcon Engine Activated!',
'body' => "Wordfence Falcon Engine has been activated on your system. You will see this icon appear on the Wordfence admin pages as long as Falcon is active indicating your site is running in high performance mode:<div class='wfFalconImage'></div><center><input type='button' name='wfReload' value='Click here now to refresh this page' onclick='window.location.reload(true);' /></center>",
);
}
return array( 'errorMsg' => 'An error occurred.' );
}
@ -2150,15 +2183,24 @@ SQL
}
$file = wfCache::getHtaccessPath();
if(! $file){
return array('err' => 'We could not find your .htaccess file to modify it.', 'code' => wfCache::getHtaccessCode() );
return array(
'err' => 'We could not find your .htaccess file to modify it.',
'code' => wfCache::getHtaccessCode(),
);
}
$fh = @fopen($file, 'r+');
if(! $fh){
$err = error_get_last();
return array('err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'], 'code' => wfCache::getHtaccessCode() );
return array(
'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'],
'code' => wfCache::getHtaccessCode(),
);
}
$download_url = admin_url( 'admin-ajax.php' ) . '?action=mainwp_wordfence_download_htaccess&_wpnonce=' . MainWP_Helper::create_nonce_without_session( 'mainwp_download_htaccess' );
return array( 'ok' => 1, 'download_url' => $download_url );
return array(
'ok' => 1,
'download_url' => $download_url,
);
}
public static function checkHtaccess() {
@ -2209,7 +2251,10 @@ SQL
if($changed && wfConfig::get('cacheType', false) == 'falcon'){
$err = wfCache::addHtaccessCode('add');
if($err){
return array('updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err, 'code' => wfCache::getHtaccessCode() );
return array(
'updateErr' => 'Wordfence could not edit your .htaccess file. The error was: ' . $err,
'code' => wfCache::getHtaccessCode(),
);
}
}
wfCache::scheduleCacheClear();
@ -2220,19 +2265,31 @@ SQL
$stats = wfCache::clearPageCache();
if($stats['error']){
$body = 'A total of ' . $stats['totalErrors'] . ' errors occurred while trying to clear your cache. The last error was: ' . $stats['error'];
return array('ok' => 1, 'heading' => 'Error occurred while clearing cache', 'body' => $body );
return array(
'ok' => 1,
'heading' => 'Error occurred while clearing cache',
'body' => $body,
);
}
$body = 'A total of ' . $stats['filesDeleted'] . ' files were deleted and ' . $stats['dirsDeleted'] . ' directories were removed. We cleared a total of ' . $stats['totalData'] . 'KB of data in the cache.';
if($stats['totalErrors'] > 0){
$body .= ' A total of ' . $stats['totalErrors'] . ' errors were encountered. This probably means that we could not remove some of the files or directories in the cache. Please use your CPanel or file manager to remove the rest of the files in the directory: ' . WP_CONTENT_DIR . '/wfcache/';
}
return array('ok' => 1, 'heading' => 'Page Cache Cleared', 'body' => $body );
return array(
'ok' => 1,
'heading' => 'Page Cache Cleared',
'body' => $body,
);
}
public static function getCacheStats() {
$s = wfCache::getCacheStats();
if($s['files'] == 0){
return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => 'The cache is currently empty. It may be disabled or it may have been recently cleared.');
return array(
'ok' => 1,
'heading' => 'Cache Stats',
'body' => 'The cache is currently empty. It may be disabled or it may have been recently cleared.',
);
}
$body = 'Total files in cache: ' . $s['files'] .
'<br />Total directories in cache: ' . $s['dirs'] .
@ -2263,7 +2320,11 @@ SQL
}
}
return array('ok' => 1, 'heading' => 'Cache Stats', 'body' => $body);
return array(
'ok' => 1,
'heading' => 'Cache Stats',
'body' => $body,
);
}
public static function addCacheExclusion() {
@ -2286,10 +2347,16 @@ SQL
wfCache::scheduleCacheClear();
if(wfConfig::get('cacheType', false) == 'falcon' && preg_match('/^(?:uac|uaeq|cc)$/', $_POST['patternType'])){
if(wfCache::addHtaccessCode('add')){ //rewrites htaccess rules
return array('errorMsg' => 'We added the rule you requested but could not modify your .htaccess file. Please delete this rule, check the permissions on your .htaccess file and then try again.', 'ex' => $ex);
return array(
'errorMsg' => 'We added the rule you requested but could not modify your .htaccess file. Please delete this rule, check the permissions on your .htaccess file and then try again.',
'ex' => $ex,
);
}
}
return array('ok' => 1, 'ex' => $ex);
return array(
'ok' => 1,
'ex' => $ex,
);
}
public static function loadCacheExclusions() {
@ -2298,7 +2365,10 @@ SQL
return array( 'ex' => false );
}
$ex = unserialize($ex);
return array('ok' => 1, 'ex' => $ex);
return array(
'ok' => 1,
'ex' => $ex,
);
}
public static function removeCacheExclusion() {
@ -2567,56 +2637,152 @@ SQL
require ABSPATH . 'wp-includes/version.php';
$postRevisions = ( defined('WP_POST_REVISIONS') ? WP_POST_REVISIONS : true );
$wordPressValues = array(
'WordPress Version' => array('description' => '', 'value' => $wp_version),
'WP_DEBUG' => array('description' => 'WordPress debug mode', 'value' => (defined('WP_DEBUG') && WP_DEBUG ? 'On' : 'Off')),
'WP_DEBUG_LOG' => array('description' => 'WordPress error logging override', 'value' => defined('WP_DEBUG_LOG') ? (WP_DEBUG_LOG ? 'Enabled' : 'Disabled') : '(not set)'),
'WP_DEBUG_DISPLAY' => array('description' => 'WordPress error display override', 'value' => defined('WP_DEBUG_DISPLAY') ? (WP_DEBUG_LOG ? 'Enabled' : 'Disabled') : '(not set)'),
'SCRIPT_DEBUG' => array('description' => 'WordPress script debug mode', 'value' => (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'On' : 'Off')),
'SAVEQUERIES' => array('description' => 'WordPress query debug mode', 'value' => (defined('SAVEQUERIES') && SAVEQUERIES ? 'On' : 'Off')),
'WordPress Version' => array(
'description' => '',
'value' => $wp_version,
),
'WP_DEBUG' => array(
'description' => 'WordPress debug mode',
'value' => ( defined('WP_DEBUG') && WP_DEBUG ? 'On' : 'Off' ),
),
'WP_DEBUG_LOG' => array(
'description' => 'WordPress error logging override',
'value' => defined('WP_DEBUG_LOG') ? ( WP_DEBUG_LOG ? 'Enabled' : 'Disabled' ) : '(not set)',
),
'WP_DEBUG_DISPLAY' => array(
'description' => 'WordPress error display override',
'value' => defined('WP_DEBUG_DISPLAY') ? ( WP_DEBUG_LOG ? 'Enabled' : 'Disabled' ) : '(not set)',
),
'SCRIPT_DEBUG' => array(
'description' => 'WordPress script debug mode',
'value' => ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'On' : 'Off' ),
),
'SAVEQUERIES' => array(
'description' => 'WordPress query debug mode',
'value' => ( defined('SAVEQUERIES') && SAVEQUERIES ? 'On' : 'Off' ),
),
'DB_CHARSET' => 'Database character set',
'DB_COLLATE' => 'Database collation',
'WP_SITEURL' => 'Explicitly set site URL',
'WP_HOME' => 'Explicitly set blog URL',
'WP_CONTENT_DIR' => array('description' => '"wp-content" folder is in default location', 'value' => (realpath(WP_CONTENT_DIR) === realpath(ABSPATH . 'wp-content') ? 'Yes' : 'No')),
'WP_CONTENT_DIR' => array(
'description' => '"wp-content" folder is in default location',
'value' => ( realpath(WP_CONTENT_DIR) === realpath(ABSPATH . 'wp-content') ? 'Yes' : 'No' ),
),
'WP_CONTENT_URL' => 'URL to the "wp-content" folder',
'WP_PLUGIN_DIR' => array('description' => '"plugins" folder is in default location', 'value' => (realpath(WP_PLUGIN_DIR) === realpath(ABSPATH . 'wp-content/plugins') ? 'Yes' : 'No')),
'WP_LANG_DIR' => array('description' => '"languages" folder is in default location', 'value' => (realpath(WP_LANG_DIR) === realpath(ABSPATH . 'wp-content/languages') ? 'Yes' : 'No')),
'WP_PLUGIN_DIR' => array(
'description' => '"plugins" folder is in default location',
'value' => ( realpath(WP_PLUGIN_DIR) === realpath(ABSPATH . 'wp-content/plugins') ? 'Yes' : 'No' ),
),
'WP_LANG_DIR' => array(
'description' => '"languages" folder is in default location',
'value' => ( realpath(WP_LANG_DIR) === realpath(ABSPATH . 'wp-content/languages') ? 'Yes' : 'No' ),
),
'WPLANG' => 'Language choice',
'UPLOADS' => 'Custom upload folder location',
'TEMPLATEPATH' => array('description' => 'Theme template folder override', 'value' => (defined('TEMPLATEPATH') && realpath(get_template_directory()) !== realpath(TEMPLATEPATH) ? 'Overridden' : '(not set)')),
'STYLESHEETPATH' => array('description' => 'Theme stylesheet folder override', 'value' => (defined('STYLESHEETPATH') && realpath(get_stylesheet_directory()) !== realpath(STYLESHEETPATH) ? 'Overridden' : '(not set)')),
'TEMPLATEPATH' => array(
'description' => 'Theme template folder override',
'value' => ( defined('TEMPLATEPATH') && realpath(get_template_directory()) !== realpath(TEMPLATEPATH) ? 'Overridden' : '(not set)' ),
),
'STYLESHEETPATH' => array(
'description' => 'Theme stylesheet folder override',
'value' => ( defined('STYLESHEETPATH') && realpath(get_stylesheet_directory()) !== realpath(STYLESHEETPATH) ? 'Overridden' : '(not set)' ),
),
'AUTOSAVE_INTERVAL' => 'Post editing automatic saving interval',
'WP_POST_REVISIONS' => array('description' => 'Post revisions saved by WordPress', 'value' => is_numeric($postRevisions) ? $postRevisions : ($postRevisions ? 'Unlimited' : 'None')),
'WP_POST_REVISIONS' => array(
'description' => 'Post revisions saved by WordPress',
'value' => is_numeric($postRevisions) ? $postRevisions : ( $postRevisions ? 'Unlimited' : 'None' ),
),
'COOKIE_DOMAIN' => 'WordPress cookie domain',
'COOKIEPATH' => 'WordPress cookie path',
'SITECOOKIEPATH' => 'WordPress site cookie path',
'ADMIN_COOKIE_PATH' => 'WordPress admin cookie path',
'PLUGINS_COOKIE_PATH' => 'WordPress plugins cookie path',
'WP_ALLOW_MULTISITE' => array('description' => 'Multisite/network ability enabled', 'value' => (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ? 'Yes' : 'No')),
'WP_ALLOW_MULTISITE' => array(
'description' => 'Multisite/network ability enabled',
'value' => ( defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE ? 'Yes' : 'No' ),
),
'NOBLOGREDIRECT' => 'URL redirected to if the visitor tries to access a nonexistent blog',
'CONCATENATE_SCRIPTS' => array('description' => 'Concatenate JavaScript files', 'value' => (defined('CONCATENATE_SCRIPTS') && CONCATENATE_SCRIPTS ? 'Yes' : 'No')),
'CONCATENATE_SCRIPTS' => array(
'description' => 'Concatenate JavaScript files',
'value' => ( defined('CONCATENATE_SCRIPTS') && CONCATENATE_SCRIPTS ? 'Yes' : 'No' ),
),
'WP_MEMORY_LIMIT' => 'WordPress memory limit',
'WP_MAX_MEMORY_LIMIT' => 'Administrative memory limit',
'WP_CACHE' => array('description' => 'Built-in caching', 'value' => (defined('WP_CACHE') && WP_CACHE ? 'Enabled' : 'Disabled')),
'CUSTOM_USER_TABLE' => array('description' => 'Custom "users" table', 'value' => (defined('CUSTOM_USER_TABLE') ? 'Set' : '(not set)')),
'CUSTOM_USER_META_TABLE' => array('description' => 'Custom "usermeta" table', 'value' => (defined('CUSTOM_USER_META_TABLE') ? 'Set' : '(not set)')),
'FS_CHMOD_DIR' => array('description' => 'Overridden permissions for a new folder', 'value' => defined('FS_CHMOD_DIR') ? decoct(FS_CHMOD_DIR) : '(not set)'),
'FS_CHMOD_FILE' => array('description' => 'Overridden permissions for a new file', 'value' => defined('FS_CHMOD_FILE') ? decoct(FS_CHMOD_FILE) : '(not set)'),
'ALTERNATE_WP_CRON' => array('description' => 'Alternate WP cron', 'value' => (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ? 'Enabled' : 'Disabled')),
'DISABLE_WP_CRON' => array('description' => 'WP cron status', 'value' => (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'Disabled' : 'Enabled')),
'WP_CACHE' => array(
'description' => 'Built-in caching',
'value' => ( defined('WP_CACHE') && WP_CACHE ? 'Enabled' : 'Disabled' ),
),
'CUSTOM_USER_TABLE' => array(
'description' => 'Custom "users" table',
'value' => ( defined('CUSTOM_USER_TABLE') ? 'Set' : '(not set)' ),
),
'CUSTOM_USER_META_TABLE' => array(
'description' => 'Custom "usermeta" table',
'value' => ( defined('CUSTOM_USER_META_TABLE') ? 'Set' : '(not set)' ),
),
'FS_CHMOD_DIR' => array(
'description' => 'Overridden permissions for a new folder',
'value' => defined('FS_CHMOD_DIR') ? decoct(FS_CHMOD_DIR) : '(not set)',
),
'FS_CHMOD_FILE' => array(
'description' => 'Overridden permissions for a new file',
'value' => defined('FS_CHMOD_FILE') ? decoct(FS_CHMOD_FILE) : '(not set)',
),
'ALTERNATE_WP_CRON' => array(
'description' => 'Alternate WP cron',
'value' => ( defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ? 'Enabled' : 'Disabled' ),
),
'DISABLE_WP_CRON' => array(
'description' => 'WP cron status',
'value' => ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'Disabled' : 'Enabled' ),
),
'WP_CRON_LOCK_TIMEOUT' => 'Cron running frequency lock',
'EMPTY_TRASH_DAYS' => array('description' => 'Interval the trash is automatically emptied at in days', 'value' => (EMPTY_TRASH_DAYS > 0 ? EMPTY_TRASH_DAYS : 'Never')),
'WP_ALLOW_REPAIR' => array('description' => 'Automatic database repair', 'value' => (defined('WP_ALLOW_REPAIR') && WP_ALLOW_REPAIR ? 'Enabled' : 'Disabled')),
'DO_NOT_UPGRADE_GLOBAL_TABLES' => array('description' => 'Do not upgrade global tables', 'value' => (defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && DO_NOT_UPGRADE_GLOBAL_TABLES ? 'Yes' : 'No')),
'DISALLOW_FILE_EDIT' => array('description' => 'Disallow plugin/theme editing', 'value' => (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ? 'Yes' : 'No')),
'DISALLOW_FILE_MODS' => array('description' => 'Disallow plugin/theme update and installation', 'value' => (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ? 'Yes' : 'No')),
'IMAGE_EDIT_OVERWRITE' => array('description' => 'Overwrite image edits when restoring the original', 'value' => (defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ? 'Yes' : 'No')),
'FORCE_SSL_ADMIN' => array('description' => 'Force SSL for administrative logins', 'value' => (defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'Yes' : 'No')),
'WP_HTTP_BLOCK_EXTERNAL' => array('description' => 'Block external URL requests', 'value' => (defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL ? 'Yes' : 'No')),
'EMPTY_TRASH_DAYS' => array(
'description' => 'Interval the trash is automatically emptied at in days',
'value' => ( EMPTY_TRASH_DAYS > 0 ? EMPTY_TRASH_DAYS : 'Never' ),
),
'WP_ALLOW_REPAIR' => array(
'description' => 'Automatic database repair',
'value' => ( defined('WP_ALLOW_REPAIR') && WP_ALLOW_REPAIR ? 'Enabled' : 'Disabled' ),
),
'DO_NOT_UPGRADE_GLOBAL_TABLES' => array(
'description' => 'Do not upgrade global tables',
'value' => ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') && DO_NOT_UPGRADE_GLOBAL_TABLES ? 'Yes' : 'No' ),
),
'DISALLOW_FILE_EDIT' => array(
'description' => 'Disallow plugin/theme editing',
'value' => ( defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ? 'Yes' : 'No' ),
),
'DISALLOW_FILE_MODS' => array(
'description' => 'Disallow plugin/theme update and installation',
'value' => ( defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ? 'Yes' : 'No' ),
),
'IMAGE_EDIT_OVERWRITE' => array(
'description' => 'Overwrite image edits when restoring the original',
'value' => ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ? 'Yes' : 'No' ),
),
'FORCE_SSL_ADMIN' => array(
'description' => 'Force SSL for administrative logins',
'value' => ( defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'Yes' : 'No' ),
),
'WP_HTTP_BLOCK_EXTERNAL' => array(
'description' => 'Block external URL requests',
'value' => ( defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL ? 'Yes' : 'No' ),
),
'WP_ACCESSIBLE_HOSTS' => 'Whitelisted hosts',
'WP_AUTO_UPDATE_CORE' => array('description' => 'Automatic WP Core updates', 'value' => defined('WP_AUTO_UPDATE_CORE') ? (is_bool(WP_AUTO_UPDATE_CORE) ? (WP_AUTO_UPDATE_CORE ? 'Everything' : 'None') : WP_AUTO_UPDATE_CORE) : 'Default'),
'WP_PROXY_HOST' => array('description' => 'Hostname for a proxy server', 'value' => defined('WP_PROXY_HOST') ? WP_PROXY_HOST : '(not set)'),
'WP_PROXY_PORT' => array('description' => 'Port for a proxy server', 'value' => defined('WP_PROXY_PORT') ? WP_PROXY_PORT : '(not set)'),
'WP_AUTO_UPDATE_CORE' => array(
'description' => 'Automatic WP Core updates',
'value' => defined('WP_AUTO_UPDATE_CORE') ? ( is_bool(WP_AUTO_UPDATE_CORE) ? ( WP_AUTO_UPDATE_CORE ? 'Everything' : 'None' ) : WP_AUTO_UPDATE_CORE ) : 'Default',
),
'WP_PROXY_HOST' => array(
'description' => 'Hostname for a proxy server',
'value' => defined('WP_PROXY_HOST') ? WP_PROXY_HOST : '(not set)',
),
'WP_PROXY_PORT' => array(
'description' => 'Port for a proxy server',
'value' => defined('WP_PROXY_PORT') ? WP_PROXY_PORT : '(not set)',
),
);
foreach ($wordPressValues as $settingName => $settingData):
@ -2959,7 +3125,10 @@ SQL
<?php
$html = ob_get_clean();
return array('ok' => 1, 'html' => $html);
return array(
'ok' => 1,
'html' => $html,
);
}
public static function updateWAFRules() {
@ -2968,7 +3137,10 @@ SQL
$event->fire();
$isPaid = (bool) wfConfig::get('isPaid', 0);
//return self::_getWAFData();
return array('ok' => 1, 'isPaid' => $isPaid );
return array(
'ok' => 1,
'isPaid' => $isPaid,
);
}
public static function updateWAFRules_New() {

View file

@ -374,7 +374,8 @@ class MainWP_Child_WP_Rocket {
}
function generate_critical_css() {
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber',
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Subscriber\Optimization\Critical_CSS_Subscriber',
'WP_Rocket\Optimization\CSS\Critical_CSS',
'WP_Rocket\Optimization\CSS\Critical_CSS_Generation',
'WP_Rocket\Admin\Options',
@ -421,7 +422,8 @@ class MainWP_Child_WP_Rocket {
function optimize_database() {
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization',
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Admin\Database\Optimization',
'WP_Rocket\Admin\Database\Optimization_Process',
'WP_Rocket\Admin\Options',
'WP_Rocket\Admin\Options_Data',
@ -446,7 +448,8 @@ class MainWP_Child_WP_Rocket {
function get_optimize_info() {
MainWP_Helper::check_classes_exists( array( 'WP_Rocket\Admin\Database\Optimization',
MainWP_Helper::check_classes_exists( array(
'WP_Rocket\Admin\Database\Optimization',
'WP_Rocket\Admin\Database\Optimization_Process',
));
@ -471,7 +474,10 @@ class MainWP_Child_WP_Rocket {
function load_existing_settings() {
$options = get_option( WP_ROCKET_SLUG );
return array('result' => 'SUCCESS', 'options' => $options);
return array(
'result' => 'SUCCESS',
'options' => $options,
);
}
}

View file

@ -1746,7 +1746,10 @@ class MainWP_Child {
remove_filter( 'http_request_args', array( &$this, 'noSSLFilterFunction' ), 99 );
}
$args = array( 'success' => 1, 'action' => 'install' );
$args = array(
'success' => 1,
'action' => 'install',
);
if ( 'plugin' === $_POST['type'] ) {
$path = $result['destination'];
$fileName = '';
@ -2508,13 +2511,17 @@ class MainWP_Child {
} else {
if ( 'future' == $post_current->post_status ) {
wp_publish_post( $postId ); // to fix: fail when publish future page
wp_update_post(array('ID' => $postId,
wp_update_post(array(
'ID' => $postId,
'post_date' => current_time( 'mysql', false ),
'post_date_gmt' => current_time( 'mysql', true ),
));
} else {
// to fix error post slug
wp_update_post(array('ID' => $postId, 'post_status' => 'publish' ));
wp_update_post(array(
'ID' => $postId,
'post_status' => 'publish',
));
}
}
} elseif ( 'update' === $action ) {
@ -3039,7 +3046,10 @@ class MainWP_Child {
$user = get_user_by( 'login', $_POST['user'] );
require_once ABSPATH . WPINC . '/registration.php';
$id = wp_update_user( array( 'ID' => $user->ID, 'user_pass' => $new_password['user_pass'] ) );
$id = wp_update_user( array(
'ID' => $user->ID,
'user_pass' => $new_password['user_pass'],
) );
if ( $id !== $user->ID ) {
if ( is_wp_error( $id ) ) {
MainWP_Helper::error( $id->get_error_message() );
@ -3876,10 +3886,12 @@ class MainWP_Child {
$information['translation_updates'] = array();
foreach ($translation_updates as $translation_update)
{
$new_translation_update = array('type' => $translation_update->type,
$new_translation_update = array(
'type' => $translation_update->type,
'slug' => $translation_update->slug,
'language' => $translation_update->language,
'version' => $translation_update->version, );
'version' => $translation_update->version,
);
if ( 'plugin' === $translation_update->type ) {
$all_plugins = get_plugins();
foreach ( $all_plugins as $file => $plugin ) {
@ -3965,7 +3977,11 @@ class MainWP_Child {
//Directory listings!
$information['directories'] = $this->scanDir( ABSPATH, 3 );
$cats = get_categories( array( 'hide_empty' => 0, 'hierarchical' => true, 'number' => 300 ) );
$cats = get_categories( array(
'hide_empty' => 0,
'hierarchical' => true,
'number' => 300,
) );
$categories = array();
foreach ( $cats as $cat ) {
$categories[] = $cat->name;
@ -4709,7 +4725,10 @@ class MainWP_Child {
if ( null !== $theTheme && '' !== $theTheme ) {
$tmp['theme'] = $theTheme['Template'];
if ( true === $themeUpgrader->delete_old_theme( null, null, null, $tmp ) ) {
$args = array( 'action' => 'delete', 'Name' => $theTheme['Name'] );
$args = array(
'action' => 'delete',
'Name' => $theTheme['Name'],
);
do_action( 'mainwp_child_theme_action', $args );
}
}
@ -4830,7 +4849,10 @@ class MainWP_Child {
}
$tmp['plugin'] = $plugin;
if ( true === $pluginUpgrader->delete_old_plugin( null, null, null, $tmp ) ) {
$args = array( 'action' => 'delete', 'Name' => $all_plugins[ $plugin ]['Name'] );
$args = array(
'action' => 'delete',
'Name' => $all_plugins[ $plugin ]['Name'],
);
do_action( 'mainwp_child_plugin_action', $args );
}
}

View file

@ -1226,7 +1226,10 @@ class MainWP_Clone {
MainWP_Helper::update_option( 'mainwp_temp_clone_plugins', $result['plugins'] );
MainWP_Helper::update_option( 'mainwp_temp_clone_themes', $result['themes'] );
$output = array( 'url' => $result['backup'], 'size' => round( $result['size'] / 1024, 0 ) );
$output = array(
'url' => $result['backup'],
'size' => round( $result['size'] / 1024, 0 ),
);
} catch ( Exception $e ) {
$output = array( 'error' => $e->getMessage() );
}
@ -1320,7 +1323,11 @@ class MainWP_Clone {
$filename = $backupdir . $filename;
$response = wp_remote_get( $url, array( 'timeout' => 300000, 'stream' => true, 'filename' => $filename ) );
$response = wp_remote_get( $url, array(
'timeout' => 300000,
'stream' => true,
'filename' => $filename,
) );
if ( is_wp_error( $response ) ) {
unlink( $filename );

View file

@ -337,6 +337,9 @@ class MainWP_Custom_Post_Type {
}
}
return array( 'success' => 1, 'post_id' => $post_id );
return array(
'success' => 1,
'post_id' => $post_id,
);
}
}

View file

@ -188,7 +188,10 @@ class MainWP_Helper {
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
return array( 'id' => $attach->ID, 'url' => $local_img_url );
return array(
'id' => $attach->ID,
'url' => $local_img_url,
);
}
}
}
@ -207,7 +210,10 @@ class MainWP_Helper {
if ( file_exists( $temporary_file ) ) {
unlink( $temporary_file );
}
return array( 'id' => $attach->ID, 'url' => $attach->guid );
return array(
'id' => $attach->ID,
'url' => $attach->guid,
);
}
}
}
@ -244,7 +250,10 @@ class MainWP_Helper {
if ( isset( $img_data['alt'] ) && !empty( $img_data['alt'] ) ) {
update_post_meta( $attach_id, '_wp_attachment_image_alt', $img_data['alt'] );
}
return array( 'id' => $attach_id, 'url' => $local_img_url );
return array(
'id' => $attach_id,
'url' => $local_img_url,
);
}
}
if ( file_exists( $temporary_file ) ) {
@ -591,7 +600,10 @@ class MainWP_Helper {
}
if ( !$edit_post_id ) {
wp_update_post( array( 'ID' => $new_post_id, 'post_status' => $post_status ) );
wp_update_post( array(
'ID' => $new_post_id,
'post_status' => $post_status,
) );
}
if ( ! empty( $terms ) ) {
@ -732,7 +744,8 @@ class MainWP_Helper {
if (isset($others['featured_image_data'])) {
$_image_data = $others['featured_image_data'];
update_post_meta( $upload['id'], '_wp_attachment_image_alt', $_image_data['alt'] );
wp_update_post( array( 'ID' => $upload['id'],
wp_update_post( array(
'ID' => $upload['id'],
'post_excerpt' => $_image_data['caption'],
'post_content' => $_image_data['description'],
'post_title' => $_image_data['title'],
@ -767,14 +780,20 @@ class MainWP_Helper {
if ( count( $random_post_authors ) > 0 ) {
shuffle( $random_post_authors );
$key = array_rand( $random_post_authors );
wp_update_post( array( 'ID' => $new_post_id, 'post_author' => $random_post_authors[ $key ] ) );
wp_update_post( array(
'ID' => $new_post_id,
'post_author' => $random_post_authors[ $key ],
) );
}
}
$random_category = isset( $post_custom['_saved_draft_random_category'] ) ? $post_custom['_saved_draft_random_category'] : false;
$random_category = is_array( $random_category ) ? current( $random_category ) : null;
if ( ! empty( $random_category ) ) {
$cats = get_categories( array( 'type' => 'post', 'hide_empty' => 0 ) );
$cats = get_categories( array(
'type' => 'post',
'hide_empty' => 0,
) );
$random_cats = array();
if ( is_array( $cats ) ) {
foreach ( $cats as $cat ) {
@ -793,7 +812,10 @@ class MainWP_Helper {
// to support custom post author
$custom_post_author = apply_filters('mainwp_create_post_custom_author', false, $new_post_id);
if ( !empty( $custom_post_author ) ) {
wp_update_post( array( 'ID' => $new_post_id, 'post_author' => $custom_post_author ) );
wp_update_post( array(
'ID' => $new_post_id,
'post_author' => $custom_post_author,
) );
}
// MainWP Robot