mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-06 11:10:43 +08:00
Fixed:CodeFactor issues
This commit is contained in:
parent
22ded195ad
commit
975b8405ab
8 changed files with 16 additions and 18 deletions
|
@ -667,7 +667,7 @@ class MainWP_Backup {
|
||||||
$this->zipArchiveFileCount ++;
|
$this->zipArchiveFileCount ++;
|
||||||
|
|
||||||
$this->testContent = file_get_contents( $path );
|
$this->testContent = file_get_contents( $path );
|
||||||
if ( $this->testContent === false ) {
|
if ( false === $this->testContent ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$added = $this->zip->addFromString( $zipEntryName, $this->testContent );
|
$added = $this->zip->addFromString( $zipEntryName, $this->testContent );
|
||||||
|
@ -747,7 +747,7 @@ class MainWP_Backup {
|
||||||
// @codingStandardsIgnoreEnd
|
// @codingStandardsIgnoreEnd
|
||||||
$query = $table_insert;
|
$query = $table_insert;
|
||||||
foreach ( $row as $value ) {
|
foreach ( $row as $value ) {
|
||||||
if ( $value === null ) {
|
if ( null === $value ) {
|
||||||
$query .= 'NULL, ';
|
$query .= 'NULL, ';
|
||||||
} else {
|
} else {
|
||||||
$query .= '"' . MainWP_Child_DB::real_escape_string( $value ) . '", ';
|
$query .= '"' . MainWP_Child_DB::real_escape_string( $value ) . '", ';
|
||||||
|
|
|
@ -849,7 +849,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
|
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
|
||||||
pb_backupbuddy::status( 'details', 'Fileoptions instance #24.' );
|
pb_backupbuddy::status( 'details', 'Fileoptions instance #24.' );
|
||||||
$backup_options = new pb_backupbuddy_fileoptions( backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' );
|
$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 ) {
|
if ( true === $result ) {
|
||||||
$backup_options->options['integrity']['comment'] = $note;
|
$backup_options->options['integrity']['comment'] = $note;
|
||||||
$backup_options->save();
|
$backup_options->save();
|
||||||
|
@ -1839,7 +1839,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
isset( $data['export_plugins'] ) ? $data['export_plugins'] : '',
|
isset( $data['export_plugins'] ) ? $data['export_plugins'] : '',
|
||||||
$data['direction'],
|
$data['direction'],
|
||||||
isset( $data['deployDestination'] ) ? $data['deployDestination'] : ''
|
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' ) );
|
return array( 'error' => __( 'Fatal Error #4344443: Backup failure. Please see any errors listed in the Status Log for details.', 'mainwp-child' ) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2200,7 +2200,7 @@ class MainWP_Child_Back_Up_Buddy {
|
||||||
}
|
}
|
||||||
pb_backupbuddy::$ui->end_metabox();
|
pb_backupbuddy::$ui->end_metabox();
|
||||||
|
|
||||||
if ( $continue_2 === true ) {
|
if ( true === $continue_2 ) {
|
||||||
function lined_array( $array ) {
|
function lined_array( $array ) {
|
||||||
if ( is_array( $array ) ) {
|
if ( is_array( $array ) ) {
|
||||||
foreach ( $array as $array_key => $array_item ) {
|
foreach ( $array as $array_key => $array_item ) {
|
||||||
|
|
|
@ -1340,7 +1340,7 @@ class MainWP_Child_Back_WP_Up {
|
||||||
foreach ( $to_include as $key => $value ) {
|
foreach ( $to_include as $key => $value ) {
|
||||||
$normalized = trailingslashit( wp_normalize_path( trim( $value ) ) );
|
$normalized = trailingslashit( wp_normalize_path( trim( $value ) ) );
|
||||||
$normalized && $normalized = filter_var( $normalized, FILTER_SANITIZE_URL );
|
$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;
|
$realpath && $to_include_parsed[ $key ] = $realpath;
|
||||||
}
|
}
|
||||||
sort( $to_include_parsed );
|
sort( $to_include_parsed );
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class MainWP_Child_DB {
|
class MainWP_Child_DB {
|
||||||
// Support old & new versions of WordPress (3.9+)
|
// Support old & new versions of WordPress (3.9+).
|
||||||
public static function use_mysqli() {
|
public static function use_mysqli() {
|
||||||
/** @var $wpdb wpdb */
|
/** @var $wpdb wpdb */
|
||||||
if ( ! function_exists( 'mysqli_connect' ) ) {
|
if ( ! function_exists( 'mysqli_connect' ) ) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ class MainWP_Child_Staging {
|
||||||
|
|
||||||
public function action() {
|
public function action() {
|
||||||
if ( ! $this->is_plugin_installed ) {
|
if ( ! $this->is_plugin_installed ) {
|
||||||
MainWP_Helper::write( array( 'error' => __( 'Please install WP Staging plugin on child website', 'mainwp-child' ) ) );
|
MainWP_Helper::write( array( 'error' => __( 'Please install WP Staging plugin on child website', 'mainwp-child' ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! class_exists( 'WPStaging\WPStaging' ) ) {
|
if ( ! class_exists( 'WPStaging\WPStaging' ) ) {
|
||||||
|
|
|
@ -550,7 +550,6 @@ class MainWP_Child_Timecapsule {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$limit = WPTC_Factory::get( 'config' )->get_option( 'activity_log_lazy_load_limit' );
|
$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.
|
// 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' );
|
$timezone = WPTC_Factory::get( 'config' )->get_option( 'wptc_timezone' );
|
||||||
if ( count( $records ) > 0 ) {
|
if ( count( $records ) > 0 ) {
|
||||||
|
|
||||||
|
|
|
@ -179,8 +179,8 @@ class MainWP_Child_WooCommerce_Status {
|
||||||
AND tax.taxonomy = 'shop_order_status'
|
AND tax.taxonomy = 'shop_order_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.
|
||||||
|
@ -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 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.meta_key = '_qty' ";
|
||||||
$query['where'] .= "AND order_item_meta_2.meta_key = '_product_id' ";
|
$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', $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') ";
|
||||||
$query['groupby'] = 'GROUP BY product_id';
|
$query['groupby'] = 'GROUP BY product_id';
|
||||||
$query['orderby'] = 'ORDER BY qty DESC';
|
$query['orderby'] = 'ORDER BY qty DESC';
|
||||||
$query['limits'] = 'LIMIT 1';
|
$query['limits'] = 'LIMIT 1';
|
||||||
|
|
|
@ -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
|
// 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.
|
// So users can upgrade older versions too.
|
||||||
// 3rd option: 'wp_update_core'
|
// 3rd option: 'wp_update_core'.
|
||||||
|
|
||||||
if ( ! is_wp_error( $upgrade ) ) {
|
if ( ! is_wp_error( $upgrade ) ) {
|
||||||
$information['upgrade'] = 'SUCCESS';
|
$information['upgrade'] = 'SUCCESS';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1881,7 +1880,8 @@ class MainWP_Child {
|
||||||
|
|
||||||
$result = count( $language_updates ) == 0 ? false : $upgrader->bulk_upgrade( $language_updates );
|
$result = count( $language_updates ) == 0 ? false : $upgrader->bulk_upgrade( $language_updates );
|
||||||
if ( ! empty( $result ) ) {
|
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 ] ) ) {
|
if ( empty( $result[ $i ] ) || is_wp_error( $result[ $i ] ) ) {
|
||||||
$information['upgrades'][ $language_updates[ $i ]->slug ] = false;
|
$information['upgrades'][ $language_updates[ $i ]->slug ] = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -3861,7 +3861,7 @@ class MainWP_Child {
|
||||||
try {
|
try {
|
||||||
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
$information = apply_filters( 'mainwp-site-sync-others-data', $information, $othersData );
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
// do not exit!
|
// ok!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4741,7 +4741,6 @@ class MainWP_Child {
|
||||||
if ( is_array( $roles ) ) {
|
if ( is_array( $roles ) ) {
|
||||||
foreach ( $roles as $role ) {
|
foreach ( $roles as $role ) {
|
||||||
$new_users = get_users( 'role=' . $role );
|
$new_users = get_users( 'role=' . $role );
|
||||||
// $allusers[$role] = array();
|
|
||||||
foreach ( $new_users as $new_user ) {
|
foreach ( $new_users as $new_user ) {
|
||||||
$usr = array();
|
$usr = array();
|
||||||
$usr['id'] = $new_user->ID;
|
$usr['id'] = $new_user->ID;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue