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

Apply fixes from CodeFactor
This commit is contained in:
Thang Hoang Van 2020-05-20 17:00:16 +07:00 committed by GitHub
commit dad5f282c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 26 deletions

View file

@ -113,9 +113,8 @@ class MainWP_Child_Install {
} }
} }
} }
} }
public function theme_action() { public function theme_action() {
$action = $_POST['action']; $action = $_POST['action'];
@ -234,7 +233,7 @@ class MainWP_Child_Install {
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0 ) { if ( true == $ssl_verify && strpos( $url, 'https://' ) === 0 ) {
$ssl_verify = false; $ssl_verify = false;
$result = $this->try_install_one_more( $url, $installer ); $result = $this->try_install_one_more( $url, $installer );
} }
} }
@ -249,7 +248,7 @@ class MainWP_Child_Install {
); );
if ( 'plugin' === $_POST['type'] ) { if ( 'plugin' === $_POST['type'] ) {
$path = $result['destination']; $path = $result['destination'];
$fileName = ''; $fileName = '';
wp_cache_set( 'plugins', array(), 'plugins' ); wp_cache_set( 'plugins', array(), 'plugins' );
foreach ( $result['source_files'] as $srcFile ) { foreach ( $result['source_files'] as $srcFile ) {
if ( is_dir( $path . $srcFile ) ) { if ( is_dir( $path . $srcFile ) ) {
@ -290,10 +289,10 @@ class MainWP_Child_Install {
$information['destination_name'] = $result['destination_name']; $information['destination_name'] = $result['destination_name'];
mainwp_child_helper()->write( $information ); mainwp_child_helper()->write( $information );
} }
private function try_install_one_more( $url, $installer ) { private function try_install_one_more( $url, $installer ) {
add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'no_ssl_filter_function' ), 99, 2 ); add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'no_ssl_filter_function' ), 99, 2 );
$result = $installer->run( $result = $installer->run(
array( array(
'package' => $url, 'package' => $url,
'destination' => ( 'plugin' === $_POST['type'] ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/themes' ), 'destination' => ( 'plugin' === $_POST['type'] ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/themes' ),
@ -311,6 +310,6 @@ class MainWP_Child_Install {
MainWP_Helper::error( implode( ', ', $error ), $err_code ); MainWP_Helper::error( implode( ', ', $error ), $err_code );
} }
} }
return $result; return $result;
} }
} }

View file

@ -245,17 +245,17 @@ class MainWP_Connect {
MainWP_Utility::instance()->upload_file( $_REQUEST['fdl'], isset( $_REQUEST['foffset'] ) ? $_REQUEST['foffset'] : 0 ); MainWP_Utility::instance()->upload_file( $_REQUEST['fdl'], isset( $_REQUEST['foffset'] ) ? $_REQUEST['foffset'] : 0 );
exit; exit;
} }
// to support open not wp-admin url. // to support open not wp-admin url.
if ( isset( $_REQUEST['open_location'] ) ) { if ( isset( $_REQUEST['open_location'] ) ) {
$open_location = base64_decode( $_REQUEST['open_location'] ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for begin reasons. $open_location = base64_decode( $_REQUEST['open_location'] ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for begin reasons.
$this->open_location_redirect( $open_location ); $this->open_location_redirect( $open_location );
} }
$this->where_redirect(); $this->where_redirect();
} }
private function open_location_redirect( $open_location ) { private function open_location_redirect( $open_location ) {
$_vars = MainWP_Helper::parse_query( $open_location ); $_vars = MainWP_Helper::parse_query( $open_location );
$_path = wp_parse_url( $open_location, PHP_URL_PATH ); $_path = wp_parse_url( $open_location, PHP_URL_PATH );
if ( isset( $_vars['_mwpNoneName'] ) && isset( $_vars['_mwpNoneValue'] ) ) { if ( isset( $_vars['_mwpNoneName'] ) && isset( $_vars['_mwpNoneValue'] ) ) {
$_vars[ $_vars['_mwpNoneName'] ] = wp_create_nonce( $_vars['_mwpNoneValue'] ); $_vars[ $_vars['_mwpNoneName'] ] = wp_create_nonce( $_vars['_mwpNoneValue'] );
unset( $_vars['_mwpNoneName'] ); unset( $_vars['_mwpNoneName'] );
@ -274,8 +274,8 @@ class MainWP_Connect {
wp_safe_redirect( site_url() . $open_location ); wp_safe_redirect( site_url() . $open_location );
exit(); exit();
} }
private function where_redirect() { private function where_redirect() {
$where = isset( $_REQUEST['where'] ) ? $_REQUEST['where'] : ''; $where = isset( $_REQUEST['where'] ) ? $_REQUEST['where'] : '';
if ( isset( $_POST['f'] ) || isset( $_POST['file'] ) ) { if ( isset( $_POST['f'] ) || isset( $_POST['file'] ) ) {
$file = ''; $file = '';
@ -293,9 +293,9 @@ class MainWP_Connect {
$_SESSION['size'] = $_POST['size']; $_SESSION['size'] = $_POST['size'];
} }
wp_safe_redirect( admin_url( $where ) ); wp_safe_redirect( admin_url( $where ) );
exit(); exit();
} }
public function check_login() { public function check_login() {
// to login requires 'mainwpsignature'. // to login requires 'mainwpsignature'.

View file

@ -306,11 +306,12 @@ class MainWP_Custom_Post_Type {
return array( 'error' => __( 'Product SKU must be unique', $this->plugin_translate ) ); return array( 'error' => __( 'Product SKU must be unique', $this->plugin_translate ) );
} }
} }
if ( '_product_image_gallery' == $key['meta_key'] ) { if ( '_product_image_gallery' == $key['meta_key'] ) {
if ( isset( $data['extras']['woocommerce']['product_images'] ) ) { if ( isset( $data['extras']['woocommerce']['product_images'] ) ) {
$ret = $this->upload_postmeta_image( $data['extras']['woocommerce']['product_images'], $meta_value, $check_image_existed ); $ret = $this->upload_postmeta_image( $data['extras']['woocommerce']['product_images'], $meta_value, $check_image_existed );
if ( true !== $ret ) if ( true !== $ret ) {
return $ret; return $ret;
}
} else { } else {
continue; continue;
} }
@ -343,8 +344,8 @@ class MainWP_Custom_Post_Type {
} }
return true; return true;
} }
private function upload_postmeta_image( $product_images, &$meta_value, $check_image_existed ){ private function upload_postmeta_image( $product_images, &$meta_value, $check_image_existed ) {
$product_image_gallery = array(); $product_image_gallery = array();
foreach ( $product_images as $product_image ) { foreach ( $product_images as $product_image ) {
try { try {

View file

@ -105,16 +105,16 @@ class MainWP_Pages {
// if preserve branding and do not hide menus. // if preserve branding and do not hide menus.
if ( ( ! $remove_all_child_menu && 'T' !== $is_hide ) || $cancelled_branding ) { if ( ( ! $remove_all_child_menu && 'T' !== $is_hide ) || $cancelled_branding ) {
$branding_header = isset( $branding_opts['branding_header'] ) ? $branding_opts['branding_header'] : array(); $branding_header = isset( $branding_opts['branding_header'] ) ? $branding_opts['branding_header'] : array();
if ( ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) && ! $cancelled_branding ) { if ( ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) && ! $cancelled_branding ) {
self::$brandingTitle = stripslashes( $branding_header['name'] ); self::$brandingTitle = stripslashes( $branding_header['name'] );
$child_menu_title = stripslashes( $branding_header['name'] ); $child_menu_title = stripslashes( $branding_header['name'] );
$child_page_title = $child_menu_title . ' Settings'; $child_page_title = $child_menu_title . ' Settings';
} else { } else {
$child_menu_title = 'MainWP Child'; $child_menu_title = 'MainWP Child';
$child_page_title = 'MainWPSettings'; $child_page_title = 'MainWPSettings';
} }
$this->init_pages( $branding_header ); $this->init_pages( $branding_header );
} }
} }
@ -177,7 +177,7 @@ class MainWP_Pages {
} }
} }
} }
public function plugin_row_meta( $plugin_meta, $plugin_file ) { public function plugin_row_meta( $plugin_meta, $plugin_file ) {
global $mainWPChild; global $mainWPChild;
if ( $mainWPChild->plugin_slug !== $plugin_file ) { if ( $mainWPChild->plugin_slug !== $plugin_file ) {