Fixed: CodeFactor issues

This commit is contained in:
Bogdan Rapaić 2020-04-22 20:05:24 +02:00 committed by GitHub
parent d6e53806ad
commit 25ea8e91b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 98 additions and 95 deletions

View file

@ -1818,17 +1818,7 @@ class MainWP_Child_Back_Up_Buddy {
$profile_array = pb_backupbuddy::$options['profiles'][ $requested_profile ]; $profile_array = pb_backupbuddy::$options['profiles'][ $requested_profile ];
$serial_override = pb_backupbuddy::random_string( 10 ); $serial_override = pb_backupbuddy::random_string( 10 );
if ( $newBackup->start_backup_process( if ( true !== $newBackup->start_backup_process( $profile_array, 'manual', array(), isset( $_POST['post_backup_steps'] ) && is_array( $_POST['post_backup_steps'] ) ? $_POST['post_backup_steps'] : array(), '', $serial_override, '', '', '' ) ) {
$profile_array,
'manual',
array(),
isset( $_POST['post_backup_steps'] ) && is_array( $_POST['post_backup_steps'] ) ? $_POST['post_backup_steps'] : array(),
'',
$serial_override,
'',
'',
''
) !== true ) {
return array( 'error' => __( 'Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'mainwp-child' ) ); return array( 'error' => __( 'Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'mainwp-child' ) );
} }
return array( 'result' => 'SUCCESS' ); return array( 'result' => 'SUCCESS' );
@ -2233,7 +2223,7 @@ class MainWP_Child_Back_Up_Buddy {
} }
if ( ! empty( $scan['MALWARE'] ) && ( 'E' != $scan['MALWARE'] ) ) { if ( ! empty( $scan['MALWARE'] ) && ( 'E' != $scan['MALWARE'] ) ) {
echo '<table><tr><td><i class="fa fa-exclamation-circle fa-5x" style="color: red"></i></td><td><h1>', __('Warning: Possible Malware Detected!', 'mainwp-child' ), '</h1>', __( 'See details below.', 'mainwp-child' ), '</td></tr></table>'; echo '<table><tr><td><i class="fa fa-exclamation-circle fa-5x" style="color: red"></i></td><td><h1>', __( 'Warning: Possible Malware Detected!', 'mainwp-child' ), '</h1>', __( 'See details below.', 'mainwp-child' ), '</td></tr></table>';
} }
?> ?>
<div class="postbox-container" style="width: 100%; min-width: 750px;"> <div class="postbox-container" style="width: 100%; min-width: 750px;">

View file

@ -761,13 +761,17 @@ class MainWP_Child_Back_WP_Up {
$without_dupes = array(); $without_dupes = array();
foreach ( $output->items as $key ) { foreach ( $output->items as $key ) {
$temp_array = $key; $temp_array = $key;
$temp_array['downloadurl'] = str_replace( array( $temp_array['downloadurl'] = str_replace(
'&amp;', array(
network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=', '&amp;',
), array( network_admin_url( 'admin.php' ) . '?page=backwpupbackups&action=',
'&', ),
admin_url( 'admin-ajax.php' ) . '?action=mainwp_backwpup_download_backup&type=', array(
), $temp_array['downloadurl'] . '&_wpnonce=' . $this->create_nonce_without_session( 'mainwp_download_backup' ) ); '&',
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'; $temp_array['downloadurl_id'] = '/wp-admin/admin.php?page=backwpupbackups';
if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches ) ) { if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches ) ) {
@ -1157,14 +1161,9 @@ class MainWP_Child_Back_WP_Up {
$dir = @opendir( $main_folder_name ); $dir = @opendir( $main_folder_name );
if ( $dir ) { if ( $dir ) {
while ( ( $file = readdir( $dir ) ) !== false ) { while ( false !== ( $file = readdir( $dir ) ) ) {
if ( ! in_array( $file, array( if ( ! in_array( $file, array( '.', '..', ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) ) {
'.', $folder_size = ' (' . size_format( BackWPup_File::get_folder_size( $main_folder_name . '/' . $file ), 2 ) . ')';
'..',
) ) && 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 ) . ')';
$return_temp[] = array( $return_temp[] = array(
'size' => $folder_size, 'size' => $folder_size,
'name' => $file, 'name' => $file,
@ -1346,7 +1345,7 @@ class MainWP_Child_Back_WP_Up {
} }
sort( $to_include_parsed ); sort( $to_include_parsed );
BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) ); BackWPup_Option::update( $id, 'dirinclude', implode( ',', $to_include_parsed ) );
unset( $include_input, $include_list, $to_include, $to_include_parsed, $normalized, $realpath ); unset( $include_input, $include_list, $to_include, $to_include_parsed, $normalized, $realpath );
// Parse and save boolean fields. // Parse and save boolean fields.
$boolean_fields_def = array( $boolean_fields_def = array(

View file

@ -776,17 +776,20 @@ class MainWP_Child_iThemes_Security {
$wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' ); $wpdb->query( 'DELETE FROM `' . $wpdb->users . '` WHERE ID = 1;' );
$wpdb->insert( $wpdb->users, array( $wpdb->insert(
'user_login' => $user_login, $wpdb->users,
'user_pass' => $user_object->user_pass, array(
'user_nicename' => $user_object->user_nicename, 'user_login' => $user_login,
'user_email' => $user_object->user_email, 'user_pass' => $user_object->user_pass,
'user_url' => $user_object->user_url, 'user_nicename' => $user_object->user_nicename,
'user_registered' => $user_object->user_registered, 'user_email' => $user_object->user_email,
'user_activation_key' => $user_object->user_activation_key, 'user_url' => $user_object->user_url,
'user_status' => $user_object->user_status, 'user_registered' => $user_object->user_registered,
'display_name' => $user_object->display_name, '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 ) ) { if ( is_multisite() && null !== $username && validate_username( $new_user ) ) {

View file

@ -182,7 +182,7 @@ class MainWP_Child_Staging {
public function get_overview() { public function get_overview() {
$return = array( $return = array(
'availableClones' => get_option( 'wpstg_existing_clones_beta', array()), 'availableClones' => get_option( 'wpstg_existing_clones_beta', array() ),
); );
return $return; return $return;
} }

View file

@ -69,43 +69,51 @@ class MainWP_Child_WooCommerce_Status {
$reports = new WC_Admin_Report(); $reports = new WC_Admin_Report();
// Get sales. // Get sales.
$sales = $wpdb->get_var( $wpdb->prepare( $sales = $wpdb->get_var(
"SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts $wpdb->prepare(
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
LEFT JOIN {$wpdb->terms} AS term USING( term_id ) LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id LEFT JOIN {$wpdb->terms} AS term USING( term_id )
WHERE posts.post_type = 'shop_order' LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
AND posts.post_status = 'publish' WHERE posts.post_type = 'shop_order'
AND tax.taxonomy = 'shop_order_status' AND posts.post_status = 'publish'
AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) AND tax.taxonomy = 'shop_order_status'
AND postmeta.meta_key = '_order_total' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' )
AND posts.post_date >= %s AND postmeta.meta_key = '_order_total'
AND posts.post_date <= %s AND posts.post_date >= %s
", date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date ) ) ); AND posts.post_date <= %s",
date( 'Y-m-01', $start_date ),
date( 'Y-m-d H:i:s', $end_date )
)
);
// Get top seller. // Get top seller.
$top_seller = $wpdb->get_row( $wpdb->prepare( $top_seller = $wpdb->get_row(
"SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id $wpdb->prepare(
FROM {$wpdb->posts} as posts "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
LEFT JOIN {$wpdb->terms} AS term USING( term_id ) LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
LEFT JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id LEFT JOIN {$wpdb->terms} AS term USING( term_id )
LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id LEFT JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id
LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id
WHERE posts.post_type = 'shop_order' LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id
AND posts.post_status = 'publish' WHERE posts.post_type = 'shop_order'
AND tax.taxonomy = 'shop_order_status' AND posts.post_status = 'publish'
AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) AND tax.taxonomy = 'shop_order_status'
AND order_item_meta.meta_key = '_qty' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' )
AND order_item_meta_2.meta_key = '_product_id' AND order_item_meta.meta_key = '_qty'
AND posts.post_date >= %s AND order_item_meta_2.meta_key = '_product_id'
AND posts.post_date <= %s AND posts.post_date >= %s
GROUP BY product_id AND posts.post_date <= %s
ORDER BY qty DESC GROUP BY product_id
LIMIT 1 ORDER BY qty DESC
", date( 'Y-m-01', $start_date ), date( 'Y-m-d H:i:s', $end_date )) ); LIMIT 1",
date( 'Y-m-01', $start_date ),
date( 'Y-m-d H:i:s', $end_date )
)
);
if ( ! empty( $top_seller ) ) { if ( ! empty( $top_seller ) ) {
$top_seller->name = get_the_title( $top_seller->product_id ); $top_seller->name = get_the_title( $top_seller->product_id );
@ -160,7 +168,7 @@ class MainWP_Child_WooCommerce_Status {
$end_date = date( 'Y-m-d H:i:s', $end_date ); $end_date = date( 'Y-m-d H:i:s', $end_date );
// Get sales. // Get sales.
$sales = $wpdb->get_var(\ $sales = $wpdb->get_var(
"SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id ) LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
@ -172,8 +180,8 @@ class MainWP_Child_WooCommerce_Status {
AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' )
AND postmeta.meta_key = '_order_total' AND postmeta.meta_key = '_order_total'
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s')
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s')"
" ); );
// Get top seller. // Get top seller.
$top_seller = $wpdb->get_row( $top_seller = $wpdb->get_row(
@ -191,12 +199,12 @@ class MainWP_Child_WooCommerce_Status {
AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' )
AND order_item_meta.meta_key = '_qty' AND order_item_meta.meta_key = '_qty'
AND order_item_meta_2.meta_key = '_product_id' AND order_item_meta_2.meta_key = '_product_id'
AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') AND posts.post_date >= STR_TO_DATE(" . $wpdb->prepare( '%s', $start_date ) . ", '%Y-%m-%d %H:%i:%s' )
AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') AND posts.post_date <= STR_TO_DATE(" . $wpdb->prepare( '%s', $end_date ) . ", '%Y-%m-%d %H:%i:%s' )
GROUP BY product_id GROUP BY product_id
ORDER BY qty DESC ORDER BY qty DESC
LIMIT 1 LIMIT 1"
" ); );
if ( ! empty( $top_seller ) ) { if ( ! empty( $top_seller ) ) {
$top_seller->name = get_the_title( $top_seller->product_id ); $top_seller->name = get_the_title( $top_seller->product_id );
@ -279,8 +287,8 @@ class MainWP_Child_WooCommerce_Status {
$query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'reports' ) ) . "' ) "; $query['where'] = "WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'reports' ) ) . "' ) ";
$query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) "; $query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) ";
$query['where'] .= "AND postmeta.meta_key = '_order_total' "; $query['where'] .= "AND postmeta.meta_key = '_order_total' ";
$query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare('%s', $start_date) . ", '%Y-%m-%d %H:%i:%s') "; $query['where'] .= 'AND posts.post_date >= STR_TO_DATE(' . $wpdb->prepare( '%s', $start_date ) . ", '%Y-%m-%d %H:%i:%s' ) ";
$query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare('%s', $end_date) . ", '%Y-%m-%d %H:%i:%s') "; $query['where'] .= 'AND posts.post_date <= STR_TO_DATE(' . $wpdb->prepare( '%s', $end_date ) . ", '%Y-%m-%d %H:%i:%s' ) ";
$sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) ); $sales = $wpdb->get_var( implode( ' ', apply_filters( 'woocommerce_dashboard_status_widget_sales_query', $query ) ) );

View file

@ -310,7 +310,7 @@ class MainWP_Child_WP_Rocket {
if ( function_exists( 'rocket_clean_cache_busting' ) ) { if ( function_exists( 'rocket_clean_cache_busting' ) ) {
rocket_clean_cache_busting(); rocket_clean_cache_busting();
} }
if ( ! function_exists( 'rocket_dismiss_boxes' ) && defined('WP_ROCKET_ADMIN_PATH') ) { if ( ! function_exists( 'rocket_dismiss_boxes' ) && defined( 'WP_ROCKET_ADMIN_PATH' ) ) {
require_once WP_ROCKET_ADMIN_PATH . 'admin.php'; require_once WP_ROCKET_ADMIN_PATH . 'admin.php';
} }
include_once ABSPATH . '/wp-admin/includes/template.php'; include_once ABSPATH . '/wp-admin/includes/template.php';
@ -328,10 +328,10 @@ class MainWP_Child_WP_Rocket {
public function preload_cache() { public function preload_cache() {
MainWP_Helper::check_functions( array( 'run_rocket_sitemap_preload', 'run_rocket_bot' ) ); MainWP_Helper::check_functions( array( 'run_rocket_sitemap_preload', 'run_rocket_bot' ) );
MainWP_Helper::check_classes_exists('WP_Rocket\Preload\Full_Process'); MainWP_Helper::check_classes_exists( 'WP_Rocket\Preload\Full_Process' );
$preload_process = new WP_Rocket\Preload\Full_Process(); $preload_process = new WP_Rocket\Preload\Full_Process();
MainWP_Helper::check_methods($preload_process, array( 'is_process_running' )); MainWP_Helper::check_methods( $preload_process, array( 'is_process_running' ) );
if ( $preload_process->is_process_running() ) { if ( $preload_process->is_process_running() ) {
return array( 'result' => 'RUNNING' ); return array( 'result' => 'RUNNING' );

View file

@ -1198,12 +1198,15 @@ class MainWP_Clone {
MainWP_Helper::endSession(); MainWP_Helper::endSession();
// Send request to the childsite! // Send request to the childsite!
$result = MainWP_Helper::fetchUrl( $url, array( $result = MainWP_Helper::fetchUrl(
'cloneFunc' => 'createCloneBackupPoll', $url,
'key' => $key, array(
'f' => $rand, 'cloneFunc' => 'createCloneBackupPoll',
'json_result' => true, 'key' => $key,
) ); 'f' => $rand,
'json_result' => true,
)
);
if ( ! isset( $result['size'] ) ) { if ( ! isset( $result['size'] ) ) {
throw new Exception( __( 'Invalid response', 'mainwp-child' ) ); throw new Exception( __( 'Invalid response', 'mainwp-child' ) );
@ -1314,7 +1317,7 @@ class MainWP_Clone {
public function cloneBackupDownloadPoll() { public function cloneBackupDownloadPoll() {
try { try {
$this->secure_request('mainwp-child_clone_backupdownloadpoll'); $this->secure_request( 'mainwp-child_clone_backupdownloadpoll' );
MainWP_Helper::endSession(); MainWP_Helper::endSession();
@ -1341,7 +1344,7 @@ class MainWP_Clone {
public function cloneBackupExtract() { public function cloneBackupExtract() {
try { try {
$this->secure_request('mainwp-child_clone_backupextract'); $this->secure_request( 'mainwp-child_clone_backupextract' );
MainWP_Helper::endSession(); MainWP_Helper::endSession();