From 975b8405abba1f7ba6594705b359be6d4b4da312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 23 Apr 2020 16:42:30 +0200 Subject: [PATCH] Fixed:CodeFactor issues --- class/class-mainwp-backup.php | 4 ++-- class/class-mainwp-child-back-up-buddy.php | 6 +++--- class/class-mainwp-child-back-wp-up.php | 2 +- class/class-mainwp-child-db.php | 2 +- class/class-mainwp-child-staging.php | 2 +- class/class-mainwp-child-timecapsule.php | 1 - class/class-mainwp-child-woocommerce-status.php | 8 ++++---- class/class-mainwp-child.php | 9 ++++----- 8 files changed, 16 insertions(+), 18 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index 07c43f9..c6475b4 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -667,7 +667,7 @@ class MainWP_Backup { $this->zipArchiveFileCount ++; $this->testContent = file_get_contents( $path ); - if ( $this->testContent === false ) { + if ( false === $this->testContent ) { return false; } $added = $this->zip->addFromString( $zipEntryName, $this->testContent ); @@ -747,7 +747,7 @@ class MainWP_Backup { // @codingStandardsIgnoreEnd $query = $table_insert; foreach ( $row as $value ) { - if ( $value === null ) { + if ( null === $value ) { $query .= 'NULL, '; } else { $query .= '"' . MainWP_Child_DB::real_escape_string( $value ) . '", '; diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index b842792..6ed7d64 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -849,7 +849,7 @@ class MainWP_Child_Back_Up_Buddy { require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status( 'details', 'Fileoptions instance #24.' ); $backup_options = new pb_backupbuddy_fileoptions( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' ); - $result = $backup_options->is_ok(); + $result = $backup_options->is_ok(); if ( true === $result ) { $backup_options->options['integrity']['comment'] = $note; $backup_options->save(); @@ -1839,7 +1839,7 @@ class MainWP_Child_Back_Up_Buddy { isset( $data['export_plugins'] ) ? $data['export_plugins'] : '', $data['direction'], isset( $data['deployDestination'] ) ? $data['deployDestination'] : '' - ) !== true ) { + ) !== true ) { return array( 'error' => __( 'Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'mainwp-child' ) ); } } else { @@ -2200,7 +2200,7 @@ class MainWP_Child_Back_Up_Buddy { } pb_backupbuddy::$ui->end_metabox(); - if ( $continue_2 === true ) { + if ( true === $continue_2 ) { function lined_array( $array ) { if ( is_array( $array ) ) { foreach ( $array as $array_key => $array_item ) { diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index 9785e89..bbf7a2a 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -1340,7 +1340,7 @@ class MainWP_Child_Back_WP_Up { foreach ( $to_include as $key => $value ) { $normalized = trailingslashit( wp_normalize_path( trim( $value ) ) ); $normalized && $normalized = filter_var( $normalized, FILTER_SANITIZE_URL ); - $realpath = $normalized && $normalized !== '/' ? realpath( $normalized ) : false; + $realpath = $normalized && '/' !== $normalized ? realpath( $normalized ) : false; $realpath && $to_include_parsed[ $key ] = $realpath; } sort( $to_include_parsed ); diff --git a/class/class-mainwp-child-db.php b/class/class-mainwp-child-db.php index bf5bb9e..00c4c9e 100644 --- a/class/class-mainwp-child-db.php +++ b/class/class-mainwp-child-db.php @@ -1,7 +1,7 @@ is_plugin_installed ) { - MainWP_Helper::write( array( 'error' => __( 'Please install WP Staging plugin on child website', 'mainwp-child' ) ) ); + MainWP_Helper::write( array( 'error' => __( 'Please install WP Staging plugin on child website', 'mainwp-child' ) ) ); } if ( ! class_exists( 'WPStaging\WPStaging' ) ) { diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index 27cf78f..dcf299c 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -550,7 +550,6 @@ class MainWP_Child_Timecapsule { $i = 0; $limit = WPTC_Factory::get( 'config' )->get_option( 'activity_log_lazy_load_limit' ); // Get the columns registered in the get_columns and get_sortable_columns methods. - // $columns = $this->get_columns(); $timezone = WPTC_Factory::get( 'config' )->get_option( 'wptc_timezone' ); if ( count( $records ) > 0 ) { diff --git a/class/class-mainwp-child-woocommerce-status.php b/class/class-mainwp-child-woocommerce-status.php index 727320c..c471c4f 100644 --- a/class/class-mainwp-child-woocommerce-status.php +++ b/class/class-mainwp-child-woocommerce-status.php @@ -179,8 +179,8 @@ class MainWP_Child_WooCommerce_Status { AND tax.taxonomy = 'shop_order_status' AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) 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', $end_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')" ); // Get top seller. @@ -302,8 +302,8 @@ class MainWP_Child_WooCommerce_Status { $query['where'] .= "AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' ) "; $query['where'] .= "AND order_item_meta.meta_key = '_qty' "; $query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' "; - $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', $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['groupby'] = 'GROUP BY product_id'; $query['orderby'] = 'ORDER BY qty DESC'; $query['limits'] = 'LIMIT 1'; diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index 9156cec..824b3d4 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -1821,8 +1821,7 @@ class MainWP_Child { } // If this does not work - add code from /wp-admin/includes/class-wp-upgrader.php in the newer versions // So users can upgrade older versions too. - // 3rd option: 'wp_update_core' - + // 3rd option: 'wp_update_core'. if ( ! is_wp_error( $upgrade ) ) { $information['upgrade'] = 'SUCCESS'; } else { @@ -1881,7 +1880,8 @@ class MainWP_Child { $result = count( $language_updates ) == 0 ? false : $upgrader->bulk_upgrade( $language_updates ); if ( ! empty( $result ) ) { - for ( $i = 0; $i < count( $result ); $i++ ) { + $count_result = count( $result ); + for ( $i = 0; $i < $count_result; $i++ ) { if ( empty( $result[ $i ] ) || is_wp_error( $result[ $i ] ) ) { $information['upgrades'][ $language_updates[ $i ]->slug ] = false; } else { @@ -3861,7 +3861,7 @@ class MainWP_Child { try { $information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData ); } catch ( Exception $e ) { - // do not exit! + // ok! } } @@ -4741,7 +4741,6 @@ class MainWP_Child { if ( is_array( $roles ) ) { foreach ( $roles as $role ) { $new_users = get_users( 'role=' . $role ); - // $allusers[$role] = array(); foreach ( $new_users as $new_user ) { $usr = array(); $usr['id'] = $new_user->ID;