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. *