From 11d39206620d33a88294f1da6a85f1dacb14598b Mon Sep 17 00:00:00 2001 From: nelsonec87 Date: Tue, 16 Apr 2024 21:24:40 +0200 Subject: [PATCH] Fix/launch task completion (#36839) * Adds a complete callback to the launch site task * changelog * Fixed phpdoc * Added explicit blog id * persist task completion status * fixing linting * fixing changelogger validity --- .../changelog/fix-launch-task-completion | 4 ++++ .../launchpad/launchpad-task-definitions.php | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/fix-launch-task-completion diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-launch-task-completion b/projects/packages/jetpack-mu-wpcom/changelog/fix-launch-task-completion new file mode 100644 index 0000000000000..94b17a3db98e9 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/fix-launch-task-completion @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Added completed callback for site_launched 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 0ac94e3382c41..c4c4a7c2838d0 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 @@ -154,6 +154,7 @@ function wpcom_launchpad_get_task_definitions() { return __( 'Launch your site', 'jetpack-mu-wpcom' ); }, 'isLaunchTask' => true, + 'is_complete_callback' => 'wpcom_launchpad_is_site_launched', 'add_listener_callback' => 'wpcom_launchpad_add_site_launch_listener', ), 'verify_email' => array( @@ -736,6 +737,29 @@ function wpcom_launchpad_get_task_definitions() { return array_merge( $extended_task_definitions, $task_definitions ); } +/** + * Returns true if the current site is launched. + * + * @param array $task The task object. + * @param bool $is_complete The current task status. + * + * @return boolean + */ +function wpcom_launchpad_is_site_launched( $task, $is_complete ) { + if ( $is_complete ) { + return true; + } + + $launch_status = get_blog_option( get_current_blog_id(), 'launch-status' ); + + if ( 'launched' === $launch_status ) { + wpcom_mark_launchpad_task_complete( 'site_launched' ); + return true; + } else { + return false; + } +} + /** * Record completion event in Tracks if we're running on WP.com. *