From 4e3df319a6119b4da5164687504cc57aacc2d935 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Mon, 11 May 2020 13:33:45 +0000 Subject: [PATCH] [CodeFactor] Apply fixes to commit 673fe6f [ci skip] [skip ci] --- class/class-mainwp-child-branding.php | 2 +- class/class-mainwp-child-install.php | 11 +++-- class/class-mainwp-child-plugins-check.php | 2 +- class/class-mainwp-child-updates.php | 47 +++++++++++----------- class/class-mainwp-child.php | 26 ++++++------ class/class-mainwp-helper.php | 22 +++++----- class/class-mainwp-security.php | 4 +- class/class-mainwp-wordpress-seo.php | 2 +- 8 files changed, 57 insertions(+), 59 deletions(-) diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index 752b6f4..c36c75c 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -315,7 +315,7 @@ class MainWP_Child_Branding { public static function upload_image( $img_url ) { include_once ABSPATH . 'wp-admin/includes/file.php'; - + add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'reject_unsafe_urls' ), 99, 2 ); $temporary_file = download_url( $img_url ); remove_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'reject_unsafe_urls' ), 99, 2 ); diff --git a/class/class-mainwp-child-install.php b/class/class-mainwp-child-install.php index f79a678..6a17f62 100644 --- a/class/class-mainwp-child-install.php +++ b/class/class-mainwp-child-install.php @@ -3,10 +3,10 @@ namespace MainWP\Child; class MainWP_Child_Install { - + protected static $instance = null; - - + + /** * Method get_class_name() * @@ -19,9 +19,8 @@ class MainWP_Child_Install { } public function __construct() { - } - + public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); @@ -34,7 +33,7 @@ class MainWP_Child_Install { * Functions to support core functionality */ public function install_plugin_theme() { - + MainWP_Helper::check_wp_filesystem(); if ( ! isset( $_POST['type'] ) || ! isset( $_POST['url'] ) || ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) || '' === $_POST['url'] ) { diff --git a/class/class-mainwp-child-plugins-check.php b/class/class-mainwp-child-plugins-check.php index 1770672..6996738 100644 --- a/class/class-mainwp-child-plugins-check.php +++ b/class/class-mainwp-child-plugins-check.php @@ -127,7 +127,7 @@ class MainWP_Child_Plugins_Check { return $plugins_outdate; } - + public static function may_outdate_number_change() { if ( isset( $_POST['numberdaysOutdatePluginTheme'] ) ) { $days_outdate = get_option( 'mainwp_child_plugintheme_days_outdate', 365 ); diff --git a/class/class-mainwp-child-updates.php b/class/class-mainwp-child-updates.php index 243b98d..082ada2 100644 --- a/class/class-mainwp-child-updates.php +++ b/class/class-mainwp-child-updates.php @@ -3,12 +3,12 @@ namespace MainWP\Child; class MainWP_Child_Updates { - + protected static $instance = null; - - private $filterFunction = null; - - + + private $filterFunction = null; + + /** * Method get_class_name() * @@ -30,7 +30,7 @@ class MainWP_Child_Updates { return $a; }; } - + public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); @@ -354,8 +354,8 @@ class MainWP_Child_Updates { $information['sync'] = $this->get_site_stats( array(), false ); mainwp_child_helper()->write( $information ); } - - + + public function hook_fix_optimize_press_theme_update( $transient ) { if ( ! defined( 'OP_FUNC' ) ) { return $transient; @@ -388,7 +388,7 @@ class MainWP_Child_Updates { return $transient; } - + public function set_cached_update_plugins( $false = false, $_transient_data = null ) { if ( ! is_object( $_transient_data ) ) { @@ -412,8 +412,8 @@ class MainWP_Child_Updates { return $_transient_data; } - - + + public function set_cached_update_themes( $false = false, $_transient_data = null ) { if ( ! is_object( $_transient_data ) ) { @@ -437,7 +437,7 @@ class MainWP_Child_Updates { return $_transient_data; } - + public function detect_premium_themesplugins_updates() { if ( isset( $_GET['_detect_plugins_updates'] ) && 'yes' == $_GET['_detect_plugins_updates'] ) { @@ -461,32 +461,31 @@ class MainWP_Child_Updates { } $type = isset( $_GET['_request_update_premiums_type'] ) ? $_GET['_request_update_premiums_type'] : ''; - + if ( 'plugin' == $type || 'theme' == $type ) { $list = isset( $_GET['list'] ) ? $_GET['list'] : ''; if ( ! empty( $list ) ) { // to call function upgrade_plugin_theme(). $_POST['type'] = $type; $_POST['list'] = $list; - + global $mainWPChild; $callable = $mainWPChild->get_callable_functions(); - + $function = 'upgradeplugintheme'; if ( isset( $callable [ $function ] ) ) { call_user_func( array( $this, $callable [ $function ] ) ); } - } } } - - + + /** * Functions to support core functionality */ public function install_plugin_theme() { - + MainWP_Helper::check_wp_filesystem(); if ( ! isset( $_POST['type'] ) || ! isset( $_POST['url'] ) || ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) || '' === $_POST['url'] ) { @@ -610,13 +609,13 @@ class MainWP_Child_Updates { mainwp_child_helper()->write( $information ); } - - + + // This will upgrade WP! public function upgrade_wp() { - global $wp_version; + global $wp_version; MainWP_Helper::get_wp_filesystem(); - + $information = array(); include_once ABSPATH . '/wp-admin/includes/update.php'; @@ -750,5 +749,5 @@ class MainWP_Child_Updates { $information['sync'] = $this->get_site_stats( array(), false ); mainwp_child_helper()->write( $information ); - } + } } diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index 0be942d..029aea8 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -486,7 +486,7 @@ class MainWP_Child { public function get_callable_functions() { return $this->callableFunctions; } - + public function admin_menu() { $branding_opts = MainWP_Child_Branding::instance()->get_branding_options(); $is_hide = isset( $branding_opts['hide'] ) ? $branding_opts['hide'] : ''; @@ -1496,16 +1496,16 @@ class MainWP_Child { /** - * Functions to support core functionality - */ + * Functions to support core functionality + */ public function install_plugin_theme() { MainWP_Child_Install::get_instance()->install_plugin_theme(); } - + public function upgrade_wp() { MainWP_Child_Updates::get_instance()->upgrade_wp(); } - + public function upgrade_translation() { MainWP_Child_Updates::get_instance()->upgrade_translation(); } @@ -2965,9 +2965,9 @@ class MainWP_Child { $recent_number = 5; } - $information['recent_posts'] = $this->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash', 'future' ), $recent_number ); - $information['recent_pages'] = $this->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash', 'future' ), $recent_number, 'page' ); - $information['securityIssues'] = MainWP_Security::get_stats_security();; + $information['recent_posts'] = $this->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash', 'future' ), $recent_number ); + $information['recent_pages'] = $this->get_recent_posts( array( 'publish', 'draft', 'pending', 'trash', 'future' ), $recent_number, 'page' ); + $information['securityIssues'] = MainWP_Security::get_stats_security(); // Directory listings! $information['directories'] = $this->scan_dir( ABSPATH, 3 ); @@ -3607,11 +3607,11 @@ class MainWP_Child { include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; - + global $wp_filesystem; - + MainWP_Helper::check_wp_filesystem(); - + if ( empty( $wp_filesystem ) ) { $wp_filesystem = new WP_Filesystem_Direct( null ); } @@ -3737,9 +3737,9 @@ class MainWP_Child { include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; - global $wp_filesystem; + global $wp_filesystem; MainWP_Helper::check_wp_filesystem(); - + if ( null === $wp_filesystem ) { $wp_filesystem = new WP_Filesystem_Direct( null ); } diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index 65c27ac..29edf70 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -16,7 +16,7 @@ class MainWP_Helper { public static function get_class_name() { return __CLASS__; } - + public static function instance() { if ( null === self::$instance ) { self::$instance = new self(); @@ -225,7 +225,7 @@ class MainWP_Helper { if ( ! is_array( $img_data ) ) { $img_data = array(); } - + include_once ABSPATH . 'wp-admin/includes/file.php'; $upload_dir = wp_upload_dir(); add_filter( 'http_request_args', array( self::get_class_name(), 'reject_unsafe_urls' ), 99, 2 ); @@ -1002,29 +1002,29 @@ class MainWP_Helper { return $init; } - - public static function check_wp_filesystem() { - - self::get_wp_filesystem(); + + public static function check_wp_filesystem() { + + self::get_wp_filesystem(); global $wp_filesystem; if ( empty( $wp_filesystem ) ) { - MainWP_Helper::error( $this->FTP_ERROR ); + self::error( $this->FTP_ERROR ); } elseif ( is_wp_error( $wp_filesystem->errors ) ) { $errorCodes = $wp_filesystem->errors->get_error_codes(); if ( ! empty( $errorCodes ) ) { - MainWP_Helper::error( __( 'WordPress Filesystem error: ', 'mainwp-child' ) . $wp_filesystem->errors->get_error_message() ); + self::error( __( 'WordPress Filesystem error: ', 'mainwp-child' ) . $wp_filesystem->errors->get_error_message() ); } } return $wp_filesystem; } - + public static function no_ssl_filter_function( $r, $url ) { $r['sslverify'] = false; return $r; } - + public static function reject_unsafe_urls( $r, $url ) { $r['reject_unsafe_urls'] = false; if ( isset( $_POST['wpadmin_user'] ) && ! empty( $_POST['wpadmin_user'] ) && isset( $_POST['wpadmin_passwd'] ) && ! empty( $_POST['wpadmin_passwd'] ) ) { @@ -1033,7 +1033,7 @@ class MainWP_Helper { } return $r; } - + public static function starts_with( $haystack, $needle ) { return ! strncmp( $haystack, $needle, strlen( $needle ) ); } diff --git a/class/class-mainwp-security.php b/class/class-mainwp-security.php index c366c1a..db53b74 100644 --- a/class/class-mainwp-security.php +++ b/class/class-mainwp-security.php @@ -299,10 +299,10 @@ class MainWP_Security { } if ( ! self::remove_readme_ok() ) { $securityIssuess ++; - } + } return $securityIssuess; } - + public static function update_security_option( $key, $value ) { $security = get_option( 'mainwp_security' ); if ( ! empty( $key ) ) { diff --git a/class/class-mainwp-wordpress-seo.php b/class/class-mainwp-wordpress-seo.php index 31c7161..f6d9b55 100644 --- a/class/class-mainwp-wordpress-seo.php +++ b/class/class-mainwp-wordpress-seo.php @@ -55,7 +55,7 @@ class MainWP_WordPress_SEO { if ( isset( $_POST['file_url'] ) ) { $file_url = base64_decode( $_POST['file_url'] ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for begin reasons. $temporary_file = ''; - + try { include_once ABSPATH . 'wp-admin/includes/file.php'; add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'reject_unsafe_urls' ), 99, 2 );