[CodeFactor] Apply fixes to commit acdfa23

[ci skip] [skip ci]
This commit is contained in:
codefactor-io 2020-05-07 16:27:57 +00:00
parent acdfa23a81
commit 584d90bc3c
6 changed files with 20 additions and 20 deletions

View file

@ -777,7 +777,7 @@ class MainWP_Child_Back_WP_Up {
if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches ) ) { if ( preg_match( '/.*&jobid=([^&]+)&.*/is', $temp_array['downloadurl'], $matches ) ) {
if ( ! empty( $matches[1] ) && is_numeric( $matches[1] ) ) { if ( ! empty( $matches[1] ) && is_numeric( $matches[1] ) ) {
$temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1]; $temp_array['downloadurl_id'] .= '&download_click_id=' . $matches[1];
} }
} }
$temp_array['website_id'] = $website_id; $temp_array['website_id'] = $website_id;
@ -1316,15 +1316,15 @@ class MainWP_Child_Back_WP_Up {
// From BackWPup_JobType_File::edit_form_post_save with some tweaks. // From BackWPup_JobType_File::edit_form_post_save with some tweaks.
public function edit_form_post_save( $post_data, $id ) { public function edit_form_post_save( $post_data, $id ) {
// Parse and save files to exclude. // Parse and save files to exclude.
$exclude_input = $post_data['fileexclude']; $exclude_input = $post_data['fileexclude'];
$to_exclude_list = $exclude_input ? str_replace( array( "\r\n", "\r" ), ',', $exclude_input ) : array(); $to_exclude_list = $exclude_input ? str_replace( array( "\r\n", "\r" ), ',', $exclude_input ) : array();
if ( $to_exclude_list ) { if ( $to_exclude_list ) {
$to_exclude_list = sanitize_text_field( stripslashes( $to_exclude_list ) ); $to_exclude_list = sanitize_text_field( stripslashes( $to_exclude_list ) );
} }
$to_exclude = $to_exclude_list ? explode( ',', $to_exclude_list ) : array(); $to_exclude = $to_exclude_list ? explode( ',', $to_exclude_list ) : array();
$to_exclude_parsed = array(); $to_exclude_parsed = array();
foreach ( $to_exclude as $key => $value ) { foreach ( $to_exclude as $key => $value ) {
$normalized = wp_normalize_path( trim( $value ) ); $normalized = wp_normalize_path( trim( $value ) );
if ( $normalized ) { if ( $normalized ) {
$to_exclude_parsed[ $key ] = $normalized; $to_exclude_parsed[ $key ] = $normalized;
} }
@ -1339,11 +1339,11 @@ class MainWP_Child_Back_WP_Up {
$to_include = $include_list ? explode( ',', $include_list ) : array(); $to_include = $include_list ? explode( ',', $include_list ) : array();
$to_include_parsed = array(); $to_include_parsed = array();
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 ) ) );
if ( $normalized ) { if ( $normalized ) {
$normalized = filter_var( $normalized, FILTER_SANITIZE_URL ); $normalized = filter_var( $normalized, FILTER_SANITIZE_URL );
} }
$realpath = $normalized && '/' !== $normalized ? realpath( $normalized ) : false; $realpath = $normalized && '/' !== $normalized ? realpath( $normalized ) : false;
if ( $realpath ) { if ( $realpath ) {
$to_include_parsed[ $key ] = $realpath; $to_include_parsed[ $key ] = $realpath;
} }

View file

@ -344,7 +344,7 @@ class MainWP_Child_Branding {
public function branding_init() { public function branding_init() {
$extra_setting = $this->get_extra_options(); $extra_setting = $this->get_extra_options();
if ( is_admin() ) { if ( is_admin() ) {
@ -375,7 +375,7 @@ class MainWP_Child_Branding {
add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 ); add_filter( 'map_meta_cap', array( $this, 'branding_map_meta_cap' ), 10, 5 );
if ( 'T' === $opts['disable_change'] ) { if ( 'T' === $opts['disable_change'] ) {
// Disable the WordPress plugin update notifications. // Disable the WordPress plugin update notifications.
remove_action( 'load-update-core.php', 'wp_update_plugins' ); remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', '__return_null' ); add_filter( 'pre_site_transient_update_plugins', '__return_null' );
@ -386,7 +386,7 @@ class MainWP_Child_Branding {
'pre_site_transient_update_themes', 'pre_site_transient_update_themes',
function( $a ) { function( $a ) {
return null; return null;
} }
); );
// Disable the WordPress core update notifications. // Disable the WordPress core update notifications.

View file

@ -15,7 +15,7 @@ class MainWP_Child_Skeleton_Key {
} }
public function action() { public function action() {
function mainwp_skeleton_key_handle_fatal_error() { function mainwp_skeleton_key_handle_fatal_error() {
$error = error_get_last(); $error = error_get_last();
if ( isset( $error['type'] ) && in_array( $error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) { if ( isset( $error['type'] ) && in_array( $error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) {

View file

@ -51,7 +51,7 @@ class MainWP_Child {
'get_all_users' => 'get_all_users', 'get_all_users' => 'get_all_users',
'user_action' => 'user_action', 'user_action' => 'user_action',
'search_users' => 'search_users', 'search_users' => 'search_users',
'insert_comment' => 'insert_comment', 'insert_comment' => 'insert_comment',
'cancel_scheduled_post' => 'cancel_scheduled_post', 'cancel_scheduled_post' => 'cancel_scheduled_post',
'serverInformation' => 'server_information', 'serverInformation' => 'server_information',
'maintenance_site' => 'maintenance_site', 'maintenance_site' => 'maintenance_site',
@ -4136,7 +4136,7 @@ class MainWP_Child {
$information['status'] = 'SUCCESS'; $information['status'] = 'SUCCESS';
} }
} elseif ( $cancel_all ) { } elseif ( $cancel_all ) {
$post_type = $_POST['post_type']; $post_type = $_POST['post_type'];
$posts = $wpdb->get_results( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p JOIN $wpdb->postmeta pm ON p.ID=pm.post_id WHERE p.post_status='future' AND p.post_type = %s AND pm.meta_key = '_is_auto_generate_content' AND pm.meta_value = 'yes' ", $post_type ) ); $posts = $wpdb->get_results( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p JOIN $wpdb->postmeta pm ON p.ID=pm.post_id WHERE p.post_status='future' AND p.post_type = %s AND pm.meta_key = '_is_auto_generate_content' AND pm.meta_value = 'yes' ", $post_type ) );
$count = 0; $count = 0;
if ( is_array( $posts ) ) { if ( is_array( $posts ) ) {

View file

@ -15,7 +15,7 @@ class MainWP_Custom_Post_Type {
return self::$instance; return self::$instance;
} }
public function action() { public function action() {
function mainwp_custom_post_type_handle_fatal_error() { function mainwp_custom_post_type_handle_fatal_error() {
$error = error_get_last(); $error = error_get_last();
if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) { if ( isset( $error['type'] ) && E_ERROR === $error['type'] && isset( $error['message'] ) ) {

View file

@ -1343,7 +1343,7 @@ class MainWP_Helper {
public static function get_revisions( $max_revisions ) { public static function get_revisions( $max_revisions ) {
global $wpdb; global $wpdb;
return $wpdb->get_results( $wpdb->prepare( " SELECT `post_parent`, COUNT(*) cnt FROM $wpdb->posts WHERE `post_type` = 'revision' GROUP BY `post_parent` HAVING COUNT(*) > %d " , $max_revisions ) ); return $wpdb->get_results( $wpdb->prepare( " SELECT `post_parent`, COUNT(*) cnt FROM $wpdb->posts WHERE `post_type` = 'revision' GROUP BY `post_parent` HAVING COUNT(*) > %d ", $max_revisions ) );
} }
public static function delete_revisions( $results, $max_revisions ) { public static function delete_revisions( $results, $max_revisions ) {
@ -1356,16 +1356,16 @@ class MainWP_Helper {
$results_length = count( $results ); $results_length = count( $results );
for ( $i = 0; $i < $results_length; $i ++ ) { for ( $i = 0; $i < $results_length; $i ++ ) {
$number_to_delete = $results[ $i ]->cnt - $max_revisions; $number_to_delete = $results[ $i ]->cnt - $max_revisions;
$count_deleted += $number_to_delete; $count_deleted += $number_to_delete;
$results_posts = $wpdb->get_results( $wpdb->prepare( "SELECT `ID`, `post_modified` FROM $wpdb->posts WHERE `post_parent`= %d AND `post_type`='revision' ORDER BY `post_modified` ASC", $results[ $i ]->post_parent ) ); $results_posts = $wpdb->get_results( $wpdb->prepare( "SELECT `ID`, `post_modified` FROM $wpdb->posts WHERE `post_parent`= %d AND `post_type`='revision' ORDER BY `post_modified` ASC", $results[ $i ]->post_parent ) );
$delete_ids = array(); $delete_ids = array();
if ( is_array( $results_posts ) && count( $results_posts ) > 0 ) { if ( is_array( $results_posts ) && count( $results_posts ) > 0 ) {
for ( $j = 0; $j < $number_to_delete; $j ++ ) { for ( $j = 0; $j < $number_to_delete; $j ++ ) {
$delete_ids[] = $results_posts[ $j ]->ID; $delete_ids[] = $results_posts[ $j ]->ID;
} }
} }
if ( count( $delete_ids ) > 0 ) { if ( count( $delete_ids ) > 0 ) {
$sql_delete = " DELETE FROM $wpdb->posts WHERE `ID` IN (" . implode( ',', $delete_ids ) . ")"; // phpcs:ignore -- safe $sql_delete = " DELETE FROM $wpdb->posts WHERE `ID` IN (" . implode( ',', $delete_ids ) . ")"; // phpcs:ignore -- safe
$wpdb->get_results( $sql_delete ); // phpcs:ignore -- safe $wpdb->get_results( $sql_delete ); // phpcs:ignore -- safe
} }