Merge pull request #144 from mainwp/bogdan01-cf-autofix

Apply fixes from CodeFactor
This commit is contained in:
Thang Hoang Van 2020-05-15 01:11:26 +07:00 committed by GitHub
commit aaf1fa3333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 44 additions and 45 deletions

View file

@ -91,7 +91,7 @@ class MainWP_Backup {
$this->timeout = 20 * 60 * 60;
$mem = '512M';
MainWP_Helper::set_limit( $this->timeout, $mem );
if ( null !== $this->archiver ) {
$success = $this->archiver->create_full_backup( $filepath, $excludes, $addConfig, $includeCoreFiles, $excludezip, $excludenonwp, $append );
} elseif ( $this->check_zip_support() ) {
@ -113,7 +113,7 @@ class MainWP_Backup {
$this->timeout = 20 * 60 * 60;
$mem = '512M';
MainWP_Helper::set_limit( $this->timeout, $mem );
if ( ! is_array( $files ) ) {
$files = array( $files );
}
@ -622,11 +622,11 @@ class MainWP_Backup {
}
public function create_backup_db( $filepath_prefix, $archiveExt = false, &$archiver = null ) {
$timeout = 20 * 60 * 60;
$mem = '512M';
$mem = '512M';
MainWP_Helper::set_limit( $timeout, $mem );
/** @var $wpdb wpdb */
global $wpdb;

View file

@ -99,15 +99,15 @@ class MainWP_Child_Callable {
}
public function init_call_functions( $auth = false ) {
$callable = false;
$callable = false;
$callable_no_auth = false;
$call_func = false;
$call_func = false;
// check to execute mainwp child's callable functions.
if ( isset( $_POST['function'] ) ) {
$call_func = $_POST['function'];
$callable = $this->is_callable_function( $call_func ); // check callable func.
$callable_no_auth = $this->is_callable_function_no_auth( $call_func ); // check callable no auth func.
if ( isset( $_POST['function'] ) ) {
$call_func = $_POST['function'];
$callable = $this->is_callable_function( $call_func ); // check callable func.
$callable_no_auth = $this->is_callable_function_no_auth( $call_func ); // check callable no auth func.
}
// Call the function required.
@ -580,9 +580,9 @@ class MainWP_Child_Callable {
public function backup( $pWrite = true ) {
$timeout = 20 * 60 * 60;
$timeout = 20 * 60 * 60;
MainWP_Helper::set_limit( $timeout );
MainWP_Helper::end_session();
// Cleanup pid files!

View file

@ -86,7 +86,7 @@ class MainWP_Child_Stats {
include_once ABSPATH . '/wp-admin/includes/update.php';
$timeout = 3 * 60 * 60;
MainWP_Helper::set_limit( $timeout );
MainWP_Helper::set_limit( $timeout );
// Check for new versions.
$information['wp_updates'] = $this->stats_wp_update();

View file

@ -158,7 +158,7 @@ class MainWP_Child_WP_Rocket {
}
}
/**
* Credit to the : wp-filters-extras
*/

View file

@ -36,12 +36,12 @@ class MainWP_Child {
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
add_action( 'init', array( &$this, 'check_login' ), 1 );
add_action( 'init', array( &$this, 'parse_init' ), 9999 );
add_action( 'init', array( &$this, 'parse_init' ), 9999 );
add_action( 'init', array( &$this, 'localization' ), 33 );
add_action( 'admin_init', array( &$this, 'admin_init' ) );
add_action( 'pre_current_active_plugins', array( MainWP_Child_Updates::get_instance(), 'detect_premium_themesplugins_updates' ) ); // to support detect premium plugins update.
add_action( 'core_upgrade_preamble', array( MainWP_Child_Updates::get_instance(), 'detect_premium_themesplugins_updates' ) ); // to support detect premium themes.
MainWP_Pages::get_instance()->init();
if ( is_admin() ) {
@ -57,7 +57,7 @@ class MainWP_Child {
MainWP_Child_Plugins_Check::instance();
MainWP_Child_Themes_Check::instance();
MainWP_Utility::instance()->run_saved_snippets();
if ( ! get_option( 'mainwp_child_pubkey' ) ) {
MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' );
}
@ -348,14 +348,14 @@ class MainWP_Child {
// auth here.
$auth = MainWP_Connect::instance()->auth( isset( $_POST['mainwpsignature'] ) ? $_POST['mainwpsignature'] : '', isset( $_POST['function'] ) ? $_POST['function'] : '', isset( $_POST['nonce'] ) ? $_POST['nonce'] : '', isset( $_POST['nossl'] ) ? $_POST['nossl'] : 0 );
// parse auth, if it is not correct actions then exit with message or return.
if ( ! MainWP_Connect::instance()->parse_init_auth( $auth ) ) {
return;
}
$this->parse_init_extensions();
global $_wp_submenu_nopriv;
if ( null === $_wp_submenu_nopriv ) {
$_wp_submenu_nopriv = array(); // phpcs:ignore -- to fix warning.
@ -370,13 +370,13 @@ class MainWP_Child {
public function check_login() {
MainWP_Connect::instance()->check_login();
}
public function admin_init() {
if ( MainWP_Helper::is_admin() && is_admin() ) {
MainWP_Clone::get()->init_ajax();
}
}
private function parse_init_extensions() {
// Handle fatal errors for those init if needed.
MainWP_Child_Branding::instance()->branding_init();

View file

@ -91,7 +91,7 @@ class MainWP_Connect {
public function parse_init_auth( $auth = false ) {
if ( ! $auth && isset( $_POST['mainwpsignature'] ) ) { // with 'mainwpsignature' then need to callable functions.
MainWP_Helper::error( __( 'Authentication failed! Please deactivate & re-activate the MainWP Child plugin on this site and try again.', 'mainwp-child' ) );
}
@ -116,7 +116,7 @@ class MainWP_Connect {
if ( $this->check_login_as( $_POST['alt_user'] ) ) {
$auth_user = $_POST['alt_user'];
// get alternative admin user.
$user = get_user_by( 'login', $auth_user );
$user = get_user_by( 'login', $auth_user );
}
}

View file

@ -1014,8 +1014,8 @@ class MainWP_Helper {
error_log( $msg ); // phpcs:ignore -- debug mode only.
}
}
public static function set_limit( $timeout, $mem = false ){
public static function set_limit( $timeout, $mem = false ) {
// phpcs:disable
if ( ! empty( $mem ) ) {
ini_set( 'memory_limit', $mem );

View file

@ -3,14 +3,14 @@
namespace MainWP\Child;
class MainWP_Pages {
protected static $instance = null;
public static $subPages;
public static $subPagesLoaded = false;
public static $brandingTitle = null;
/**
* Method get_class_name()
*
@ -23,9 +23,8 @@ class MainWP_Pages {
}
public function __construct() {
}
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
@ -33,15 +32,15 @@ class MainWP_Pages {
return self::$instance;
}
public function init(){
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
add_action( 'admin_head', array( &$this, 'admin_head' ) );
public function init() {
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
add_action( 'admin_head', array( &$this, 'admin_head' ) );
add_action( 'admin_notices', array( &$this, 'admin_notice' ) );
add_filter( 'plugin_row_meta', array( &$this, 'plugin_row_meta' ), 10, 2 );
}
public function admin_notice() {
// Admin Notice...
if ( ! get_option( 'mainwp_child_pubkey' ) && MainWP_Helper::is_admin() && is_admin() ) {
@ -67,7 +66,7 @@ class MainWP_Pages {
}
MainWP_Child_Server_Information::show_warnings();
}
public function admin_menu() {
$branding_opts = MainWP_Child_Branding::instance()->get_branding_options();
$is_hide = isset( $branding_opts['hide'] ) ? $branding_opts['hide'] : '';
@ -173,7 +172,7 @@ class MainWP_Pages {
}
}
}
public function plugin_row_meta( $plugin_meta, $plugin_file ) {
global $mainWPChild;
if ( $mainWPChild->plugin_slug !== $plugin_file ) {
@ -489,5 +488,5 @@ class MainWP_Pages {
<?php
}
}

View file

@ -142,7 +142,7 @@ class MainWP_Utility {
);
}
/**
* Handle fatal error for requests from the dashboard
* mwp_action requests
@ -163,7 +163,7 @@ class MainWP_Utility {
register_shutdown_function( 'handle_shutdown' );
}
}
public function cron_active() {
if ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) {
return;
@ -229,7 +229,7 @@ class MainWP_Utility {
return fclose( $handle );
}
// $check_file_existed: to support checking if file existed.
// $parent_id: optional.
public static function upload_image( $img_url, $img_data = array(), $check_file_existed = false, $parent_id = 0 ) {