Skip to content

Commit

Permalink
Launchpad Checklist API: Update free flow task definitions (#30146)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeyip authored Apr 18, 2023
1 parent 3c5fae8 commit b7ea653
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

SLaunchpad Checklist API: add task definitions for the Launchpad free flow
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ function get_checklist_definitions() {
);
}

/**
* Determines whether or not design selected task is enabled
*
* @return boolean True if design selected task is enabled
*/
function can_update_design_selected_task() {
$site_intent = get_option( 'site_intent' );
return $site_intent === 'free' || $site_intent === 'build' || $site_intent === 'write';
}

/**
* Determines whether or not domain upsell task is completed
*
* @return boolean True if domain upsell task is completed
*/
function is_domain_upsell_completed() {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
if ( class_exists( '\WPCOM_Store_API' ) ) {
$plan = \WPCOM_Store_API::get_current_plan( \get_current_blog_id() );
return ! $plan['is_free'] || get_checklist_task( 'domain_upsell_deferred' );
}
}

return get_checklist_task( 'domain_upsell_deferred' );
}

/**
* Returns the subtitle for the plan selected task
*
Expand All @@ -84,13 +110,12 @@ function get_plan_selected_subtitle() {
}

/**
* Determines whether or not design selected task is enabled
* Returns the badge text for the plan selected task
*
* @return boolean True if design selected task is enabled
* @return string Badge text
*/
function can_update_design_selected_task() {
$site_intent = get_option( 'site_intent' );
return $site_intent === 'free' || $site_intent === 'build' || $site_intent === 'write';
function get_domain_upsell_badge_text() {
return is_domain_upsell_completed() ? '' : __( 'Upgrade plan', 'jetpack-mu-wpcom' );
}

/**
Expand Down Expand Up @@ -185,6 +210,7 @@ function get_task_definitions() {
'setup_free'
=> array(
'id' => 'setup_free',
'title' => __( 'Personalize your site', 'jetpack-mu-wpcom' ),
'completed' => true,
'disabled' => false,
),
Expand Down Expand Up @@ -219,9 +245,11 @@ function get_task_definitions() {
),
'domain_upsell'
=> array(
'id' => 'domain_upsell',
'completed' => false,
'disabled' => false,
'id' => 'domain_upsell',
'title' => __( 'Choose a domain', 'jetpack-mu-wpcom' ),
'completed' => is_domain_upsell_completed(),
'disabled' => false,
'badge_text' => get_domain_upsell_badge_text(),
),
'verify_email'
=> array(
Expand Down

0 comments on commit b7ea653

Please sign in to comment.