From f62e160d0b0e8cd21d0828df8406fcf205d0dcef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Blanco?= Date: Wed, 16 Oct 2024 14:38:33 -0300 Subject: [PATCH] Post migration tasklist: Add/ssl provisioned task (#39776) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add SSL provisioned task * changelog * check for slug ending to enable/disable the task * add . to domain check * add a better way to get the url * remove is_visible_callback, since it defaults to true and add default check for task completion --------- Co-authored-by: Andrés Blanco --- .../changelog/add-ssl-provisioned-task | 4 +++ .../launchpad/launchpad-task-definitions.php | 28 +++++++++++++++++++ .../src/features/launchpad/launchpad.php | 1 + 3 files changed, 33 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-ssl-provisioned-task diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-ssl-provisioned-task b/projects/packages/jetpack-mu-wpcom/changelog/add-ssl-provisioned-task new file mode 100644 index 0000000000000..6a120468bd1ad --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/add-ssl-provisioned-task @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +adding a WPCOM task diff --git a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php index d1e2fb1b392f4..352d3d2932d7d 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php @@ -852,6 +852,17 @@ function wpcom_launchpad_get_task_definitions() { 'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed', 'is_visible_callback' => '__return_true', ), + 'check_ssl_status' => array( + 'get_title' => function () { + return __( 'Provision SSL certificate', 'jetpack-mu-wpcom' ); + }, + 'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed', + 'is_disabled_callback' => 'wpcom_launchpad_is_primary_domain_wpcom', + 'get_calypso_path' => function ( $task, $default, $data ) { + $domain = $data['site_slug_encoded']; + return '/domains/manage/' . $domain . '/edit/' . $domain; + }, + ), ); $extended_task_definitions = apply_filters( 'wpcom_launchpad_extended_task_definitions', array() ); @@ -2803,3 +2814,20 @@ function wpcom_launchpad_get_latest_draft_id() { return $cached_draft_id; } + +/** + * Checks if the current site primary domain is a WPCOM domain. + * + * @return bool Will return true if the primary domain is a WPCOM domain. + */ +function wpcom_launchpad_is_primary_domain_wpcom() { + if ( ! ( new Automattic\Jetpack\Status\Host() )->is_wpcom_platform() ) { + return false; + } + + $url = home_url(); + $host = wp_parse_url( $url, PHP_URL_HOST ); + + // If site_slug ends with .wpcomstaging.com return true + return str_ends_with( $host, '.wpcomstaging.com' ); +} diff --git a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad.php b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad.php index d8e2ceb64e2e5..8c4a999899b69 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad.php @@ -325,6 +325,7 @@ function wpcom_launchpad_get_task_list_definitions() { 'review_plugins', 'connect_migration_domain', 'domain_dns_mapped', + 'check_ssl_status', ), ), );