[CodeFactor] Apply fixes to commit bca98c3

[ci skip] [skip ci]
This commit is contained in:
codefactor-io 2020-05-05 13:19:34 +00:00
parent bca98c3a1a
commit 0c562742f7
12 changed files with 60 additions and 57 deletions

View file

@ -792,7 +792,7 @@ class MainWP_Backup {
foreach ( $db_files as $db_file ) { foreach ( $db_files as $db_file ) {
unlink( $db_file ); unlink( $db_file );
} }
} }
} }
return ( false !== $archiveExt ? array( 'filepath' => $archivefilePath ) : $db_files ); return ( false !== $archiveExt ? array( 'filepath' => $archivefilePath ) : $db_files );

View file

@ -153,9 +153,9 @@ class MainWP_Child_Back_Up_Buddy {
$check_finished = false; $check_finished = false;
if ( ( $backup['finish_time'] >= $backup['start_time'] ) && ( 0 != $backup['start_time'] ) ) { if ( ( $backup['finish_time'] >= $backup['start_time'] ) && ( 0 != $backup['start_time'] ) ) {
$check_finished = true; $check_finished = true;
} }
if ( ! $check_finished ) { if ( ! $check_finished ) {
continue; continue;
} }

View file

@ -448,7 +448,7 @@ class MainWP_Child_Branding {
// prevent conflicts with other plugins. // prevent conflicts with other plugins.
public function admin_menu() { public function admin_menu() {
$enable_contact = apply_filters( 'mainwp_branding_role_cap_enable_contact_form', false ); $enable_contact = apply_filters( 'mainwp_branding_role_cap_enable_contact_form', false );
if ( ! $enable_contact && ! current_user_can( 'administrator' ) ) { if ( ! $enable_contact && ! current_user_can( 'administrator' ) ) {
return false; return false;
} }

View file

@ -326,8 +326,8 @@ class MainWP_Child_Updraft_Plus_Backups {
return new WP_Error( 'unknown_response', sprintf( __( 'UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus' ), $result['body'] ) ); return new WP_Error( 'unknown_response', sprintf( __( 'UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus' ), $result['body'] ) );
} }
} }
$return = false; $return = false;
switch ( $response['loggedin'] ) { switch ( $response['loggedin'] ) {
case 'connected': case 'connected':
if ( ! empty( $response['token'] ) ) { if ( ! empty( $response['token'] ) ) {
@ -367,7 +367,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$return = new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) ); $return = new WP_Error( 'unknown_response', __( 'UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus' ) );
break; break;
} }
return $return; return $return;
} }
@ -431,10 +431,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$updated = false; $updated = false;
if ( is_array( $settings ) ) { if ( is_array( $settings ) ) {
if ( class_exists( 'UpdraftPlus_Options' ) ) { if ( class_exists( 'UpdraftPlus_Options' ) ) {
foreach ( $keys_filter as $key ) { foreach ( $keys_filter as $key ) {
if ( 'updraft_googledrive' === $key || 'updraft_googlecloud' === $key || 'updraft_onedrive' === $key ) { if ( 'updraft_googledrive' === $key || 'updraft_googlecloud' === $key || 'updraft_onedrive' === $key ) {
continue; // skip continue; // skip
} }
if ( isset( $settings[ $key ] ) ) { if ( isset( $settings[ $key ] ) ) {
$settings_key = null; $settings_key = null;
if ( 'updraft_dropbox' === $key && is_array( $settings[ $key ] ) ) { if ( 'updraft_dropbox' === $key && is_array( $settings[ $key ] ) ) {
@ -1289,7 +1289,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$remote_obj = new $objname(); $remote_obj = new $objname();
$deleted = $remote_obj->delete( $files ); $deleted = $remote_obj->delete( $files );
} }
if ( -1 !== $deleted && false !== $deleted ) { if ( -1 !== $deleted && false !== $deleted ) {
$remote_deleted = $remote_deleted + count( $files ); $remote_deleted = $remote_deleted + count( $files );
} }
@ -1768,7 +1768,7 @@ class MainWP_Child_Updraft_Plus_Backups {
$updraftplus->log( 'Restore failed' ); $updraftplus->log( 'Restore failed' );
$updraftplus->list_errors(); $updraftplus->list_errors();
} }
$output = ob_get_clean(); $output = ob_get_clean();
@ -3045,10 +3045,10 @@ class MainWP_Child_Updraft_Plus_Backups {
$backup['service'] = array( $backup['service'] ); $backup['service'] = array( $backup['service'] );
} }
foreach ( $backup['service'] as $service ) { foreach ( $backup['service'] as $service ) {
$emptyCheck = ( 'none' === $service || '' === $service || ( is_array( $service ) && ( empty( $service ) || array( 'none' ) === $service || array( '' ) === $service ) ) ); $emptyCheck = ( 'none' === $service || '' === $service || ( is_array( $service ) && ( empty( $service ) || array( 'none' ) === $service || array( '' ) === $service ) ) );
if ( ! empty( $emptyCheck ) ) { if ( ! empty( $emptyCheck ) ) {
$remote_storage = ( 'remotesend' === $service ) ? __( 'remote site', 'updraftplus' ) : $updraftplus->backup_methods[ $service ]; $remote_storage = ( 'remotesend' === $service ) ? __( 'remote site', 'updraftplus' ) : $updraftplus->backup_methods[ $service ];
$service_title = '<br>' . esc_attr( sprintf( __( 'Remote storage: %s', 'updraftplus' ), $remote_storage ) ); $service_title = '<br>' . esc_attr( sprintf( __( 'Remote storage: %s', 'updraftplus' ), $remote_storage ) );
} }
} }

View file

@ -1402,7 +1402,7 @@ class MainWP_Child {
MainWP_Child_Pagespeed::Instance()->init(); MainWP_Child_Pagespeed::Instance()->init();
MainWP_Child_Links_Checker::Instance()->init(); MainWP_Child_Links_Checker::Instance()->init();
MainWP_Child_WPvivid_BackupRestore::Instance()->init(); MainWP_Child_WPvivid_BackupRestore::Instance()->init();
global $_wp_submenu_nopriv; global $_wp_submenu_nopriv;
if ( null === $_wp_submenu_nopriv ) { if ( null === $_wp_submenu_nopriv ) {
$_wp_submenu_nopriv = array(); // phpcs:ignore -- to fix warning. $_wp_submenu_nopriv = array(); // phpcs:ignore -- to fix warning.
@ -4302,9 +4302,10 @@ class MainWP_Child {
} }
$maxPages = 50; $maxPages = 50;
if ( defined( 'MAINWP_CHILD_NR_OF_PAGES' ) ) if ( defined( 'MAINWP_CHILD_NR_OF_PAGES' ) ) {
$maxPages = MAINWP_CHILD_NR_OF_PAGES; $maxPages = MAINWP_CHILD_NR_OF_PAGES;
}
if ( isset( $_POST['maxRecords'] ) ) { if ( isset( $_POST['maxRecords'] ) ) {
$maxPages = $_POST['maxRecords']; $maxPages = $_POST['maxRecords'];
} }
@ -4352,10 +4353,11 @@ class MainWP_Child {
} }
} }
$maxComments = 50; $maxComments = 50;
if ( defined( 'MAINWP_CHILD_NR_OF_COMMENTS' ) ) if ( defined( 'MAINWP_CHILD_NR_OF_COMMENTS' ) ) {
$maxComments = MAINWP_CHILD_NR_OF_COMMENTS; // to compatible. $maxComments = MAINWP_CHILD_NR_OF_COMMENTS; // to compatible.
}
if ( isset( $_POST['maxRecords'] ) ) { if ( isset( $_POST['maxRecords'] ) ) {
$maxComments = $_POST['maxRecords']; $maxComments = $_POST['maxRecords'];
} }
@ -5182,7 +5184,7 @@ class MainWP_Child {
'<div>QUERY STRING: ' . $string . '</div>' . '<div>QUERY STRING: ' . $string . '</div>' .
'<div>REMOTE ADDRESS: ' . $address . '</div>' . '<div>REMOTE ADDRESS: ' . $address . '</div>' .
'<div>REMOTE IDENTITY: ' . $remote . '</div>' . '<div>REMOTE IDENTITY: ' . $remote . '</div>' .
'<div>USER AGENT: ' . $agent . '</div>'; '<div>USER AGENT: ' . $agent . '</div>';
wp_mail( wp_mail(
$email, $email,
'MainWP - 404 Alert: ' . $blog, 'MainWP - 404 Alert: ' . $blog,

View file

@ -614,7 +614,7 @@ class MainWP_Client_Report {
$loop_count = 0; $loop_count = 0;
foreach ( $records as $record ) { foreach ( $records as $record ) {
if ( in_array( $record->ID, $skip_records ) ) { if ( in_array( $record->ID, $skip_records ) ) {
continue; continue;
} }
@ -628,13 +628,13 @@ class MainWP_Client_Report {
} }
$valid_context = false; $valid_context = false;
if ( 'comments' == $context ) { if ( 'comments' == $context ) {
$comment_contexts = array( 'post', 'page' ); $comment_contexts = array( 'post', 'page' );
if ( ! in_array( $record->context, $comment_contexts ) ) { if ( ! in_array( $record->context, $comment_contexts ) ) {
continue; continue;
} }
$valid_context = true; $valid_context = true;
} elseif ( 'menus' == $context ) { } elseif ( 'menus' == $context ) {
$valid_context = true; // ok, pass, don't check context. $valid_context = true; // ok, pass, don't check context.
} elseif ( 'editor' == $record->connector ) { } elseif ( 'editor' == $record->connector ) {
@ -642,10 +642,10 @@ class MainWP_Client_Report {
} elseif ( 'media' == $connector && 'media' == $record->connector ) { } elseif ( 'media' == $connector && 'media' == $record->connector ) {
$valid_context = true; // ok, pass, do not check context. $valid_context = true; // ok, pass, do not check context.
} elseif ( 'widgets' == $connector && 'widgets' == $record->connector ) { } elseif ( 'widgets' == $connector && 'widgets' == $record->connector ) {
$valid_context = true; // ok, pass, don't check context. $valid_context = true; // ok, pass, don't check context.
} }
if ( ! $valid_context || strtolower( $record->context ) !== $context ) { if ( ! $valid_context || strtolower( $record->context ) !== $context ) {
continue; continue;
} }

View file

@ -373,7 +373,7 @@ class MainWP_Clone_Install {
return $content; return $content;
} else { } else {
if ( $this->checkZipConsole() ) { if ( $this->checkZipConsole() ) {
return false; return false;
} elseif ( $this->checkZipSupport() ) { } elseif ( $this->checkZipSupport() ) {

View file

@ -17,7 +17,7 @@ class MainWP_Clone {
return __CLASS__; return __CLASS__;
} }
public static function get() { public static function get() {
if ( null === self::$instance ) { if ( null === self::$instance ) {
self::$instance = new MainWP_Clone(); self::$instance = new MainWP_Clone();
@ -90,9 +90,9 @@ class MainWP_Clone {
} }
public function init() { public function init() {
add_action( 'check_admin_referer', array( MainWP_Clone::get_class_name(), 'permalinkChanged' ) ); add_action( 'check_admin_referer', array( self::get_class_name(), 'permalinkChanged' ) );
if ( get_option( 'mainwp_child_clone_permalink' ) || get_option( 'mainwp_child_restore_permalink' ) ) { if ( get_option( 'mainwp_child_clone_permalink' ) || get_option( 'mainwp_child_restore_permalink' ) ) {
add_action( 'admin_notices', array( MainWP_Clone::get_class_name(), 'permalinkAdminNotice' ) ); add_action( 'admin_notices', array( self::get_class_name(), 'permalinkAdminNotice' ) );
} }
} }
@ -130,7 +130,7 @@ class MainWP_Clone {
} }
$uploadedfile = $_FILES['file']; $uploadedfile = $_FILES['file'];
$upload_overrides = array( 'test_form' => false ); $upload_overrides = array( 'test_form' => false );
add_filter( 'upload_mimes', array( MainWP_Clone::get_class_name(), 'upload_mimes' ) ); add_filter( 'upload_mimes', array( self::get_class_name(), 'upload_mimes' ) );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if ( $movefile ) { if ( $movefile ) {
$uploadFile = str_replace( ABSPATH, '', $movefile['file'] ); $uploadFile = str_replace( ABSPATH, '', $movefile['file'] );

View file

@ -414,7 +414,7 @@ class MainWP_Helper {
// Set up a new post (adding addition information). // Set up a new post (adding addition information).
$post_author = isset( $new_post['post_author'] ) ? $new_post['post_author'] : $current_uid; $post_author = isset( $new_post['post_author'] ) ? $new_post['post_author'] : $current_uid;
if ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) { if ( isset( $new_post['custom_post_author'] ) && ! empty( $new_post['custom_post_author'] ) ) {
$_author = get_user_by( 'login', $new_post['custom_post_author'] ); $_author = get_user_by( 'login', $new_post['custom_post_author'] );
if ( ! empty( $_author ) ) { if ( ! empty( $_author ) ) {
@ -428,7 +428,7 @@ class MainWP_Helper {
$post_author = ! empty( $post_author ) ? $post_author : $current_uid; $post_author = ! empty( $post_author ) ? $post_author : $current_uid;
$new_post['post_author'] = $post_author; $new_post['post_author'] = $post_author;
$terms = isset( $new_post['_ezin_post_category'] ) ? $new_post['_ezin_post_category'] : false; $terms = isset( $new_post['_ezin_post_category'] ) ? $new_post['_ezin_post_category'] : false;
unset( $new_post['_ezin_post_category'] ); unset( $new_post['_ezin_post_category'] );
$is_post_plus = isset( $post_custom['_mainwp_post_plus'] ) ? true : false; $is_post_plus = isset( $post_custom['_mainwp_post_plus'] ) ? true : false;
@ -665,7 +665,7 @@ class MainWP_Helper {
$not_allowed[] = '_saved_draft_random_publish_date'; $not_allowed[] = '_saved_draft_random_publish_date';
$not_allowed[] = '_saved_draft_publish_date_from'; $not_allowed[] = '_saved_draft_publish_date_from';
$not_allowed[] = '_saved_draft_publish_date_to'; $not_allowed[] = '_saved_draft_publish_date_to';
$not_allowed[] = '_post_to_only_existing_categories'; $not_allowed[] = '_post_to_only_existing_categories';
$not_allowed[] = '_mainwp_edit_post_site_id'; $not_allowed[] = '_mainwp_edit_post_site_id';
$not_allowed[] = '_mainwp_edit_post_id'; $not_allowed[] = '_mainwp_edit_post_id';
$not_allowed[] = '_edit_post_status'; $not_allowed[] = '_edit_post_status';
@ -1031,7 +1031,7 @@ class MainWP_Helper {
public static function clean( $string ) { public static function clean( $string ) {
$string = trim( $string ); $string = trim( $string );
$string = htmlentities( $string, ENT_QUOTES ); $string = htmlentities( $string, ENT_QUOTES );
$string = str_replace( "\n", '<br>', $string ); $string = str_replace( "\n", '<br>', $string );
$string = stripslashes( $string ); $string = stripslashes( $string );
return $string; return $string;
} }
@ -1285,12 +1285,12 @@ class MainWP_Helper {
} }
public static function get_lasttime_backup( $by ) { public static function get_lasttime_backup( $by ) {
if ( 'backupwp' == $by ) { if ( 'backupwp' == $by ) {
$by = 'backupwordpress'; $by = 'backupwordpress';
} }
$activated = true; $activated = true;
switch ( $by ) { switch ( $by ) {
case 'backupbuddy': case 'backupbuddy':
if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' ) ) { if ( ! is_plugin_active( 'backupbuddy/backupbuddy.php' ) && ! is_plugin_active( 'Backupbuddy/backupbuddy.php' ) ) {
@ -1321,12 +1321,12 @@ class MainWP_Helper {
$activated = false; $activated = false;
break; break;
} }
if ( ! $activated ) if ( ! $activated ) {
return 0; return 0;
}
return get_option( 'mainwp_lasttime_backup_' . $by, 0 ); return get_option( 'mainwp_lasttime_backup_' . $by, 0 );
} }
@ -1732,12 +1732,12 @@ class MainWP_Helper {
/** /**
* Method execute_snippet() * Method execute_snippet()
* *
* Execute snippet code * Execute snippet code
* *
* @param string $code The code * * @param string $code The code *
* *
* @return array result * @return array result
*/ */
public static function execute_snippet( $code ) { public static function execute_snippet( $code ) {
ob_start(); ob_start();
@ -1755,5 +1755,5 @@ class MainWP_Helper {
} }
return $return; return $return;
} }
} }

View file

@ -3,7 +3,7 @@
namespace MainWP\Child; namespace MainWP\Child;
class MainWP_Security { class MainWP_Security {
/** /**
* Method get_class_name() * Method get_class_name()
* *
@ -14,7 +14,7 @@ class MainWP_Security {
public static function get_class_name() { public static function get_class_name() {
return __CLASS__; return __CLASS__;
} }
public static function fixAll() { public static function fixAll() {
self::remove_wp_version(); self::remove_wp_version();
self::remove_rsd(); self::remove_rsd();

View file

@ -101,4 +101,4 @@ if ( isset( $_GET['skeleton_keyuse_nonce_key'] ) && isset( $_GET['skeleton_keyus
endif; endif;
} }
} }
} }

View file

@ -25,16 +25,17 @@ if ( ! defined( 'MAINWP_CHILD_URL' ) ) {
} }
function mainwp_child_autoload( $class_name ) { function mainwp_child_autoload( $class_name ) {
if ( 0 !== strpos( $class_name, 'MainWP\Child' ) ) if ( 0 !== strpos( $class_name, 'MainWP\Child' ) ) {
return; return;
}
// trip the namespace prefix: MainWP\Child\ . // trip the namespace prefix: MainWP\Child\ .
$class_name = substr( $class_name, 13 ); $class_name = substr( $class_name, 13 );
if ( 0 !== strpos( $class_name, 'MainWP_' ) ) { if ( 0 !== strpos( $class_name, 'MainWP_' ) ) {
return; return;
} }
$autoload_dir = \trailingslashit( dirname( __FILE__ ) . '/class' ); $autoload_dir = \trailingslashit( dirname( __FILE__ ) . '/class' );
$autoload_path = sprintf( '%sclass-%s.php', $autoload_dir, strtolower( str_replace( '_', '-', $class_name ) ) ); $autoload_path = sprintf( '%sclass-%s.php', $autoload_dir, strtolower( str_replace( '_', '-', $class_name ) ) );