diff --git a/composer.lock b/composer.lock index 8e5f6ffe..7acff367 100644 --- a/composer.lock +++ b/composer.lock @@ -4,15 +4,15 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ad59edcb88854390229c2fb6b289b87e", + "content-hash": "6ca195c641ea78696fb27cff0c3f213a", "packages": [ { "name": "automattic/jetpack-mu-wpcom", - "version": "5.8.2-alpha.1704910968", + "version": "5.8.2-alpha.1704984367", "dist": { "type": "path", "url": "/tmp/jetpack-build/Automattic/jetpack-mu-wpcom", - "reference": "30d7bd04f783e912868d64258b18f89ad3ebb3d0" + "reference": "184e40f9ac18957e1481aeed2c20483b04c00227" }, "require": { "php": ">=7.0" @@ -81,7 +81,7 @@ "dist": { "type": "path", "url": "/tmp/jetpack-build/Automattic/jetpack-changelogger", - "reference": "c3274e13e6b338b0820b2fefc728e7d75438b8bc" + "reference": "af68c8ebc46824378f5ea2203bb9bbaf772eb73e" }, "require": { "php": ">=7.0", diff --git a/vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md b/vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md index 8f8ebbe9..b7aac7cb 100644 --- a/vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md +++ b/vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md @@ -11,6 +11,7 @@ This is an alpha version! The changes listed here are not final. ### Added - Add the completion logic for the `front_page_updated` task +- Add the Verify Domain Email task ### Removed - Removes the `Set up your Professional Email` task diff --git a/vendor/automattic/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php b/vendor/automattic/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php index 2b77c2c5..0ed80c3c 100644 --- a/vendor/automattic/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php +++ b/vendor/automattic/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php @@ -627,6 +627,16 @@ function wpcom_launchpad_get_task_definitions() { return site_url( '/wp-admin/admin.php?page=sensei' ); }, ), + 'verify_domain_email' => array( + 'get_title' => function () { + return __( 'Verify the email address for your domains', 'jetpack-mu-wpcom' ); + }, + 'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed', + 'is_visible_callback' => 'wpcom_launchpad_is_verify_domain_email_visible', + 'get_calypso_path' => function ( $task, $default, $data ) { + return '/domains/manage/' . $data['site_slug_encoded']; + }, + ), ); $extended_task_definitions = apply_filters( 'wpcom_launchpad_extended_task_definitions', array() ); @@ -974,6 +984,101 @@ function wpcom_launchpad_is_sensei_setup_visible() { return is_plugin_active( 'sensei-lms/sensei-lms.php' ); } +/** + * Determines whether or not the verify domain email task should be visible. + * + * @return bool True if the verify domain email task should be visible. + */ +function wpcom_launchpad_is_verify_domain_email_visible() { + // If the task is complete, we should show it and prevent the logic below + // to be executed. + if ( wpcom_is_checklist_task_complete( 'verify_domain_email' ) ) { + return true; + } + + $domains_pending_icann_verification = array(); + + // For Atomic sites we need to get the domain list from + // the public API. + $is_atomic_site = ( new Automattic\Jetpack\Status\Host() )->is_woa_site(); + if ( $is_atomic_site ) { + $domains = wpcom_request_domains_list(); + + if ( is_wp_error( $domains ) ) { + // logs the erro + return false; + } + + $domains_pending_icann_verification = array_filter( + $domains, + function ( $domain ) { + return $domain->is_pending_icann_verification; + } + ); + + return ! empty( $domains_pending_icann_verification ); + } else { + if ( ! class_exists( 'Domain_Management' ) ) { + return false; + } + + $domains = \Domain_Management::get_paid_domains_with_icann_verification_status(); + + $domains_pending_icann_verification = array_filter( + $domains, + function ( $domain ) { + return isset( $domain['is_pending_icann_verification'] ) && $domain['is_pending_icann_verification']; + } + ); + } + + return ! empty( $domains_pending_icann_verification ); +} + +/** + * Make a request to the WordPress.com API to get the domain list for the current site. + * + * @return array|WP_Error Array of domains and their verification status or WP_Error if the request fails. + */ +function wpcom_request_domains_list() { + $site_id = \Jetpack_Options::get_option( 'id' ); + $request_path = sprintf( '/sites/%d/domains', $site_id ); + $wpcom_request = Automattic\Jetpack\Connection\Client::wpcom_json_api_request_as_blog( + $request_path, + '1.2', + array( + 'method' => 'GET', + 'headers' => array( + 'content-type' => 'application/json', + 'X-Forwarded-For' => ( new Automattic\Jetpack\Status\Visitor() )->get_ip( true ), + ), + ), + null, + 'rest' + ); + + $response_code = wp_remote_retrieve_response_code( $wpcom_request ); + if ( 200 !== $response_code ) { + return new \WP_Error( + 'failed_to_fetch_data', + esc_html__( 'Unable to fetch the requested data.', 'jetpack-mu-wpcom' ), + array( 'status' => $response_code ) + ); + } + + $body = wp_remote_retrieve_body( $wpcom_request ); + $decoded_body = json_decode( $body ); + + if ( ! isset( $decoded_body->domains ) ) { + return new \WP_Error( + 'failed_to_fetch_data', + esc_html__( 'Unable to fetch the requested data.', 'jetpack-mu-wpcom' ) + ); + } + + return $decoded_body->domains; +} + /** * Identify whether we can retrieve newsletter subscriber counts in * the current environment. diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index fe57f0ae..dde66a89 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2,12 +2,12 @@ "packages": [ { "name": "automattic/jetpack-mu-wpcom", - "version": "5.8.2-alpha.1704910968", - "version_normalized": "5.8.2.0-alpha1704910968", + "version": "5.8.2-alpha.1704984367", + "version_normalized": "5.8.2.0-alpha1704984367", "dist": { "type": "path", "url": "/tmp/jetpack-build/Automattic/jetpack-mu-wpcom", - "reference": "30d7bd04f783e912868d64258b18f89ad3ebb3d0" + "reference": "184e40f9ac18957e1481aeed2c20483b04c00227" }, "require": { "php": ">=7.0" diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 50915b50..a2d396d7 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -11,9 +11,9 @@ ), 'versions' => array( 'automattic/jetpack-mu-wpcom' => array( - 'pretty_version' => '5.8.2-alpha.1704910968', - 'version' => '5.8.2.0-alpha1704910968', - 'reference' => '30d7bd04f783e912868d64258b18f89ad3ebb3d0', + 'pretty_version' => '5.8.2-alpha.1704984367', + 'version' => '5.8.2.0-alpha1704984367', + 'reference' => '184e40f9ac18957e1481aeed2c20483b04c00227', 'type' => 'jetpack-library', 'install_path' => __DIR__ . '/../automattic/jetpack-mu-wpcom', 'aliases' => array(),