diff --git a/class/class-mainwp-api-manager-key.php b/class/class-mainwp-api-manager-key.php index 5ff3db344..8ae4e8ff3 100644 --- a/class/class-mainwp-api-manager-key.php +++ b/class/class-mainwp-api-manager-key.php @@ -264,11 +264,13 @@ public function get_purchased_software( $args ) { MainWP_Api_Manager::instance()->get_upgrade_url() . '?mainwp-api=am-software-api', array( 'body' => $args, - 'timeout' => 50, + 'timeout' => 200, 'sslverify' => self::$apisslverify, ) ); + MainWP_Logger::instance()->debug( 'Get purchased softwares: ' . MainWP_Utility::value_to_string( $request ) ); + if ( is_wp_error( $request ) || 200 != wp_remote_retrieve_response_code( $request ) ) { // Request failed. return false; diff --git a/class/class-mainwp-api-manager-plugin-update.php b/class/class-mainwp-api-manager-plugin-update.php index 21180223a..5f32d332f 100644 --- a/class/class-mainwp-api-manager-plugin-update.php +++ b/class/class-mainwp-api-manager-plugin-update.php @@ -171,7 +171,7 @@ public function plugin_information( $args, $bulk_check = false ) { $target_url = $this->create_upgrade_api_url( $args, $bulk_check ); $default = array( - 'timeout' => 50, + 'timeout' => 150, 'sslverify' => 1, ); diff --git a/class/class-mainwp-db-client.php b/class/class-mainwp-db-client.php index bf9b9c2d7..a42f46b12 100644 --- a/class/class-mainwp-db-client.php +++ b/class/class-mainwp-db-client.php @@ -1112,25 +1112,57 @@ public function get_client_fields( $general = true, $client_id = 0, $field_name_ return false; } + $gene_results = array(); + + if ( $general ) { + // to fix: missing general fields for client without client fields values. + $gene_sql = 'SELECT f.* FROM ' . $this->table_name( 'wp_clients_fields' ) . ' f WHERE f.client_id = 0 ORDER BY f.field_name '; + $gene_results = $this->wpdb->get_results( $gene_sql ); + } + if ( $client_id ) { // get fields values of client. - $sql = 'SELECT f.*,v.value_client_id, v.field_value as field_value FROM ' . $this->table_name( 'wp_clients_fields' ) . ' f LEFT JOIN ' . + $sql = 'SELECT f.*, v.field_value as field_value FROM ' . $this->table_name( 'wp_clients_fields' ) . ' f LEFT JOIN ' . $this->table_name( 'wp_clients_field_values' ) . ' v ON f.field_id = v.field_id WHERE ' . $where . ' ORDER BY f.field_name '; } else { $sql = 'SELECT f.* FROM ' . $this->table_name( 'wp_clients_fields' ) . ' f WHERE ' . $where . ' ORDER BY f.field_name '; // value_client_id to compatible result. } + $results = $this->wpdb->get_results( $sql ); + + $fields_list = array(); if ( $field_name_index ) { - $results = $this->wpdb->get_results( $sql ); - $fields_list = array(); if ( $results ) { foreach ( $results as $item ) { $fields_list[ $item->field_name ] = $item; } } - return $fields_list; + if ( $gene_results ) { + foreach ( $gene_results as $gene_item ) { + if ( ! isset( $fields_list[ $gene_item->field_name ] ) ) { + $gene_item->field_value = ''; + $fields_list[ $gene_item->field_name ] = $gene_item; + } + } + } } else { - return $this->wpdb->get_results( $sql ); + $check_list = array(); + if ( $results ) { + foreach ( $results as $item ) { + $check_list[ $item->field_name ] = true; + $fields_list[] = $item; + } + } + if ( $gene_results ) { + foreach ( $gene_results as $gene_item ) { + if ( ! isset( $check_list[ $gene_item->field_name ] ) ) { + $check_list[ $gene_item->field_name ] = true; + $gene_item->field_value = ''; + $fields_list[] = $gene_item; + } + } + } } + return $fields_list; } /** diff --git a/class/class-mainwp-db.php b/class/class-mainwp-db.php index 8338aa998..6fc522eb9 100644 --- a/class/class-mainwp-db.php +++ b/class/class-mainwp-db.php @@ -274,6 +274,8 @@ public function get_website_options_array( &$website, $options ) { } else { $get_options[] = $option; } + } else { + $get_options[] = $option; } } diff --git a/class/class-mainwp-system-utility.php b/class/class-mainwp-system-utility.php index fdabc7c65..ca0884426 100644 --- a/class/class-mainwp-system-utility.php +++ b/class/class-mainwp-system-utility.php @@ -692,18 +692,18 @@ public static function get_child_response( $data ) { } if ( isset( $resp['notices'] ) ) { - $notices = array(); if ( is_string( $resp['notices'] ) ) { - $notices = MainWP_Utility::esc_content( $resp['notices'] ); + $resp['notices'] = MainWP_Utility::esc_content( $resp['notices'] ); } elseif ( is_array( $resp['notices'] ) ) { + $notices = array(); foreach ( $resp['notices'] as $noti ) { - if ( is_string( $noti ) ) { + if ( ! empty( $noti ) && is_string( $noti ) ) { $notices[] = MainWP_Utility::esc_content( $noti ); } } - } - if ( ! empty( $notices ) ) { - $resp['notices'] = $notices; + if ( ! empty( $notices ) ) { + $resp['notices'] = implode( ' || ', $notices ); + } } } } diff --git a/class/class-mainwp-system.php b/class/class-mainwp-system.php index ce09589f8..cfbe9a2f3 100644 --- a/class/class-mainwp-system.php +++ b/class/class-mainwp-system.php @@ -126,7 +126,7 @@ public function __construct( $mainwp_plugin_file ) { if ( is_admin() ) { include_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'plugin.php'; - $pluginData = get_plugin_data( $mainwp_plugin_file ); + $pluginData = get_plugin_data( $mainwp_plugin_file, true, false ); // to fix issue of user language setting. $this->current_version = $pluginData['Version']; $currentVersion = get_option( 'mainwp_plugin_version' ); @@ -165,7 +165,7 @@ public function __construct( $mainwp_plugin_file ) { $systemHandler = MainWP_System_Handler::instance(); - add_action( 'init', array( &$this, 'localization' ) ); + add_action( 'plugins_loaded', array( &$this, 'localization' ) ); add_filter( 'site_transient_update_plugins', array( $systemHandler, 'check_update_custom' ) ); add_filter( 'pre_set_site_transient_update_plugins', array( $systemHandler, 'pre_check_update_custom' ) ); add_filter( 'plugins_api', array( $systemHandler, 'plugins_api_info' ), 10, 3 ); diff --git a/class/class-mainwp-ui.php b/class/class-mainwp-ui.php index 5b6907c14..fee2d236a 100644 --- a/class/class-mainwp-ui.php +++ b/class/class-mainwp-ui.php @@ -1130,23 +1130,32 @@ public static function gen_groups_sites_selection() { * * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count() */ - public static function render_header_actions() { + public static function render_header_actions() { //phpcs:ignore -- complex method. $sites_count = MainWP_DB::instance()->get_websites_count(); $website_id = ''; $sidebar_pages = array( 'ManageGroups', 'PostBulkManage', 'PostBulkAdd', 'PageBulkManage', 'PageBulkAdd', 'ThemesManage', 'ThemesInstall', 'ThemesAutoUpdate', 'PluginsManage', 'PluginsInstall', 'PluginsAutoUpdate', 'UserBulkManage', 'UserBulkAdd', 'UpdateAdminPasswords', 'Extensions' ); $sidebar_pages = apply_filters( 'mainwp_sidbar_pages', $sidebar_pages ); // deprecated filter. $sidebar_pages = apply_filters( 'mainwp_sidebar_pages', $sidebar_pages ); ob_start(); - if ( isset( $_GET['dashboard'] ) ) : - $id = intval( $_GET['dashboard'] ); + if ( isset( $_GET['dashboard'] ) || isset( $_GET['id'] ) || isset( $_GET['updateid'] ) || isset( $_GET['emailsettingsid'] ) || isset( $_GET['scanid'] ) ) : + if ( isset( $_GET['dashboard'] ) ) { + $id = intval( $_GET['dashboard'] ); + } elseif ( isset( $_GET['id'] ) ) { + $id = intval( $_GET['id'] ); + } elseif ( isset( $_GET['updateid'] ) ) { + $id = intval( $_GET['updateid'] ); + } elseif ( isset( $_GET['emailsettingsid'] ) ) { + $id = intval( $_GET['emailsettingsid'] ); + } elseif ( isset( $_GET['scanid'] ) ) { + $id = intval( $_GET['scanid'] ); + } + $website = MainWP_DB::instance()->get_website_by_id( $id ); if ( '' != $website->sync_errors ) : ?> - + diff --git a/pages/page-mainwp-updates-handler.php b/pages/page-mainwp-updates-handler.php index ac4dacb32..a726583ed 100644 --- a/pages/page-mainwp-updates-handler.php +++ b/pages/page-mainwp-updates-handler.php @@ -658,6 +658,7 @@ public static function upgrade_plugin_theme_translation( $id, $type, $list ) { } $result = self::update_plugin_theme_translation( $website, $type, $list ); if ( is_array( $result ) ) { + $undefined = true; if ( isset( $result['upgrades'] ) ) { $tmp = array(); if ( isset( $result['upgrades'] ) ) { @@ -669,8 +670,13 @@ public static function upgrade_plugin_theme_translation( $id, $type, $list ) { } elseif ( isset( $result['error'] ) ) { throw new MainWP_Exception( 'WPERROR', esc_html( $result['error'] ) ); } elseif ( isset( $result['notices'] ) ) { - throw new MainWP_Exception( $result['notices'], '', 'MAINWP_NOTICE' ); - } else { + $noti = $result['notices']; + if ( ! empty( $noti ) && is_string( $noti ) ) { + throw new MainWP_Exception( $noti, '', 'MAINWP_NOTICE' ); + } + } + + if ( $undefined ) { throw new MainWP_Exception( 'ERROR', esc_html__( 'Invalid response retured from the child site. Please try again.', 'mainwp' ) ); } } diff --git a/widgets/widget-mainwp-clients.php b/widgets/widget-mainwp-clients.php index eace1bcc7..8e887bf24 100644 --- a/widgets/widget-mainwp-clients.php +++ b/widgets/widget-mainwp-clients.php @@ -99,19 +99,23 @@ private static function render_clients( $clients ) { get_wp_client_contact_by( 'contact_id', $client['primary_contact_id'] ); - ?> + if ( $contact ) { + ?> contact_name ); ?> contact_role ) && '' != $contact->contact_role ) ? ' - ' . esc_html( $contact->contact_role ) : ''; ?>
- contact_email ) && '' != $contact->contact_email ) : ?> + contact_email ) && '' != $contact->contact_email ) : ?> contact_email ); ?>
- contact_phone ) && '' != $contact->contact_phone ) : ?> + contact_phone ) && '' != $contact->contact_phone ) : ?> contact_phone ); ?> -