diff --git a/class/class-mainwp-child-callable.php b/class/class-mainwp-child-callable.php index 4d48d15..dcd2a99 100644 --- a/class/class-mainwp-child-callable.php +++ b/class/class-mainwp-child-callable.php @@ -97,7 +97,7 @@ class MainWP_Child_Callable { } return self::$instance; } - + public function init_call_functions( $auth ) { $callable = false; $func_auth = false; @@ -135,7 +135,7 @@ class MainWP_Child_Callable { MainWP_Helper::error( __( 'Required version has not been detected. Please, make sure that you are using the latest version of the MainWP Child plugin on your site.', 'mainwp-child' ) ); } } - + public function is_callable_function( $func ) { if ( isset( $this->callableFunctions[ $func ] ) ) { return true; @@ -1108,7 +1108,7 @@ class MainWP_Child_Callable { mainwp_child_helper()->write( $information ); } - + public function uploader_upload_file( $file_url, $path, $file_name ) { // to fix uploader extension rename htaccess file issue. if ( '.htaccess' != $file_name && '.htpasswd' != $file_name ) { @@ -1149,7 +1149,7 @@ class MainWP_Child_Callable { return array( 'path' => $full_file_name ); } - + public function wordpress_seo() { \MainWP_WordPress_SEO::instance()->action(); } diff --git a/class/class-mainwp-child-stats.php b/class/class-mainwp-child-stats.php index cb45faf..91398c9 100644 --- a/class/class-mainwp-child-stats.php +++ b/class/class-mainwp-child-stats.php @@ -39,10 +39,9 @@ class MainWP_Child_Stats { } /** - * + * * Show stats without login - only allowed while no account is added yet. - * - */ + */ public function get_site_stats_no_auth( $information = array() ) { if ( get_option( 'mainwp_child_pubkey' ) ) { $hint = '
' . __( 'Hint: Go to the child site, deactivate and reactivate the MainWP Child plugin and try again.', 'mainwp-child' ); @@ -529,7 +528,7 @@ class MainWP_Child_Stats { if ( isset( $_POST['pluginDir'] ) ) { if ( get_option( 'mainwp_child_pluginDir' ) !== $_POST['pluginDir'] ) { - MainWP_Helper::update_option( 'mainwp_child_pluginDir', $_POST['pluginDir'], 'yes' ); + MainWP_Helper::update_option( 'mainwp_child_pluginDir', $_POST['pluginDir'], 'yes' ); } } elseif ( false !== get_option( 'mainwp_child_pluginDir' ) ) { MainWP_Helper::update_option( 'mainwp_child_pluginDir', false, 'yes' ); diff --git a/class/class-mainwp-child.php b/class/class-mainwp-child.php index 9541f42..0b1bc77 100644 --- a/class/class-mainwp-child.php +++ b/class/class-mainwp-child.php @@ -57,7 +57,7 @@ class MainWP_Child { MainWP_Connect::instance()->check_other_auth(); - $this->init_extensions(); + $this->init_extensions(); if ( ! get_option( 'mainwp_child_pubkey' ) ) { MainWP_Child_Branding::instance()->save_branding_options( 'branding_disconnected', 'yes' ); @@ -808,9 +808,10 @@ class MainWP_Child { } // if auth connect are not valid then exit or return. - if ( ! MainWP_Connect::instance()->parse_init_auth() ) + if ( ! MainWP_Connect::instance()->parse_init_auth() ) { return; - + } + $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 ); if ( ! $auth && isset( $_POST['mainwpsignature'] ) ) { @@ -887,15 +888,15 @@ class MainWP_Child { } MainWP_Child_Callable::get_instance()->init_call_functions( $auth ); - + MainWP_Keyword_Links::instance()->parse_init_keyword_links(); } - + public function check_login() { MainWP_Connect::instance()->check_login(); } - private function init_extensions() { + private function init_extensions() { MainWP_Clone::get()->init(); MainWP_Child_Server_Information::init(); MainWP_Client_Report::instance()->init(); @@ -903,7 +904,7 @@ class MainWP_Child { MainWP_Child_Themes_Check::instance(); MainWP_Utility::instance()->run_saved_snippets(); } - + private function parse_init_extensions() { // Handle fatal errors for those init if needed. \MainWP_Child_IThemes_Security::instance()->ithemes_init(); diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php index 160ce7c..b749677 100644 --- a/class/class-mainwp-clone-install.php +++ b/class/class-mainwp-clone-install.php @@ -724,8 +724,8 @@ class MainWP_Clone_Install { } return true; } - - + + public function is_valid_auth( $key ) { $auths = get_option( 'mainwp_child_auth' ); if ( ! $auths ) { diff --git a/class/class-mainwp-connect.php b/class/class-mainwp-connect.php index 34d62b0..90e26df 100644 --- a/class/class-mainwp-connect.php +++ b/class/class-mainwp-connect.php @@ -3,7 +3,7 @@ namespace MainWP\Child; class MainWP_Connect { - + public static $instance = null; /** @@ -23,7 +23,7 @@ class MainWP_Connect { } return self::$instance; } - + // This will register the current wp - thus generating the public key etc. public function register_site() { global $current_user; @@ -88,11 +88,11 @@ class MainWP_Connect { MainWP_Child_Stats::get_instance()->get_site_stats( $information ); } - + public function parse_init_auth() { - + $auth = $this->auth( isset( $_POST['mainwpsignature'] ) ? $_POST['mainwpsignature'] : '', isset( $_POST['function'] ) ? $_POST['function'] : '', isset( $_POST['nonce'] ) ? $_POST['nonce'] : '', isset( $_POST['nossl'] ) ? $_POST['nossl'] : 0 ); - + if ( ! $auth && isset( $_POST['mainwpsignature'] ) ) { MainWP_Helper::error( __( 'Authentication failed! Please deactivate & re-activate the MainWP Child plugin on this site and try again.', 'mainwp-child' ) ); } @@ -157,11 +157,11 @@ class MainWP_Connect { die(); } } - + return true; } - - + + public function auth( $signature, $func, $nonce, $pNossl ) { if ( empty( $signature ) || ! isset( $func ) || ( ! get_option( 'mainwp_child_pubkey' ) && ! get_option( 'mainwp_child_nossl_key' ) ) ) { $auth = false; @@ -182,7 +182,7 @@ class MainWP_Connect { return $auth; } - + public function parse_login_required() { global $current_user; @@ -191,7 +191,7 @@ class MainWP_Connect { $username = rawurldecode( $_REQUEST['user'] ); if ( isset( $_REQUEST['alt_user'] ) && ! empty( $_REQUEST['alt_user'] ) ) { - $alter_login_required = MainWP_Connect::instance()->check_login_as( $_REQUEST['alt_user'] ); + $alter_login_required = self::instance()->check_login_as( $_REQUEST['alt_user'] ); if ( $alter_login_required ) { $username = rawurldecode( $_REQUEST['alt_user'] ); } @@ -214,8 +214,8 @@ class MainWP_Connect { $file = $_REQUEST['fdl']; } - $auth = MainWP_Connect::instance()->auth( $signature, rawurldecode( ( isset( $_REQUEST['where'] ) ? $_REQUEST['where'] : $file ) ), isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '', isset( $_REQUEST['nossl'] ) ? $_REQUEST['nossl'] : 0 ); - + $auth = self::instance()->auth( $signature, rawurldecode( ( isset( $_REQUEST['where'] ) ? $_REQUEST['where'] : $file ) ), isset( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '', isset( $_REQUEST['nossl'] ) ? $_REQUEST['nossl'] : 0 ); + if ( ! $auth ) { return; } @@ -293,7 +293,7 @@ class MainWP_Connect { exit(); } - + public function check_login() { if ( ! isset( $_POST['mainwpsignature'] ) || empty( $_POST['mainwpsignature'] ) ) { @@ -370,14 +370,12 @@ class MainWP_Connect { } } } - + /** - * + * * Check to support login by alternative admin. * Return false will login by connected admin user. * Return true will try to login as alternative user. - * - * */ public function check_login_as( $alter_login ) { @@ -434,8 +432,8 @@ class MainWP_Connect { return false; } - - + + public function check_other_auth() { $auths = get_option( 'mainwp_child_auth' ); diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index 6f7e69f..98d3e7e 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -177,10 +177,11 @@ class MainWP_Helper { $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path ); // to fix issue re-create new attachment. - if ( $check_file_existed ) { - $result = self::check_media_file_existed( $upload_dir, $filename, $temporary_file, $local_img_path, $local_img_url ); - if ( ! empty( $result ) ) + if ( $check_file_existed ) { + $result = self::check_media_file_existed( $upload_dir, $filename, $temporary_file, $local_img_path, $local_img_url ); + if ( ! empty( $result ) ) { return $result; + } } // file exists, do not overwrite, generate unique file name. @@ -192,18 +193,17 @@ class MainWP_Helper { $moved = rename( $temporary_file, $local_img_path ); if ( $moved ) { - return self::insert_attachment_media( $img_data, $img_url, $parent_id, $local_img_path, $local_img_url ); + return self::insert_attachment_media( $img_data, $img_url, $parent_id, $local_img_path, $local_img_url ); } - } - + if ( file_exists( $temporary_file ) ) { unlink( $temporary_file ); } return null; } - - private static function check_media_file_existed( $upload_dir, $filename, $temporary_file, &$local_img_path, $local_img_url ){ + + private static function check_media_file_existed( $upload_dir, $filename, $temporary_file, &$local_img_path, $local_img_url ) { if ( file_exists( $local_img_path ) ) { if ( filesize( $local_img_path ) == filesize( $temporary_file ) ) { $result = self::get_maybe_existed_attached_id( $local_img_url ); @@ -241,9 +241,9 @@ class MainWP_Helper { } } } - - private static function insert_attachment_media( $img_data, $img_url, $parent_id, $local_img_path, $local_img_url ){ - + + private static function insert_attachment_media( $img_data, $img_url, $parent_id, $local_img_path, $local_img_url ) { + $wp_filetype = wp_check_filetype( basename( $img_url ), null ); // Get the filetype to set the mimetype. $attachment = array( 'post_mime_type' => $wp_filetype['type'], diff --git a/class/class-mainwp-utility.php b/class/class-mainwp-utility.php index fc54903..3411155 100644 --- a/class/class-mainwp-utility.php +++ b/class/class-mainwp-utility.php @@ -5,7 +5,7 @@ namespace MainWP\Child; // phpcs:disable WordPress.WP.AlternativeFunctions -- to custom. class MainWP_Utility { - + public static $instance = null; /** @@ -25,12 +25,12 @@ class MainWP_Utility { } return self::$instance; } - - + + public function run_saved_snippets() { - + if ( isset( $_POST['action'] ) && isset( $_POST['mainwpsignature'] ) ) { - $action = $_POST['action']; + $action = $_POST['action']; if ( 'run_snippet' === $action || 'save_snippet' === $action || 'delete_snippet' === $action ) { return; // do not run saved snippets if in do action snippet. } @@ -45,7 +45,7 @@ class MainWP_Utility { } } } - + public static function fix_for_custom_themes() { if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { include_once ABSPATH . '/wp-admin/includes/screen.php'; @@ -54,12 +54,11 @@ class MainWP_Utility { et_register_updates_component(); } } - + /** - * + * * To support maintenance alert - * - */ + */ public function maintenance_alert() { if ( ! is_404() ) { return; @@ -142,7 +141,7 @@ class MainWP_Utility { ) ); } - + public function cron_active() { if ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) { return; @@ -160,12 +159,11 @@ class MainWP_Utility { } die( '' ); } - - + + /** - * + * * To support upload backup files. - * */ public function upload_file( $file, $offset = 0 ) { $dirs = MainWP_Helper::get_mainwp_dir( 'backup' ); @@ -209,5 +207,5 @@ class MainWP_Utility { return fclose( $handle ); } - + }