-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add conditional check to replace launch-site task with LYS task #1509
Merged
ilyasfoo
merged 5 commits into
master
from
update/1497-replace-launch-site-task-with-lys
Sep 6, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e6d06b5
Add conditional check to replace launch-site task with LYS task
ilyasfoo a7507f1
Changelog
ilyasfoo c695309
Merge add_tasks function with replace_tasks to consolidate logic and …
ilyasfoo 6e67ae3
Move logic around to simplify it more
ilyasfoo 27842c7
Merge remote-tracking branch 'origin/master' into update/1497-replace…
ilyasfoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,6 @@ private function __construct() { | |
// All plans. | ||
add_action( 'load-woocommerce_page_wc-settings', array( $this, 'redirect_store_details_onboarding' ) ); | ||
add_action( 'wp_ajax_launch_store', array( $this, 'handle_ajax_launch_endpoint' ) ); | ||
add_action( 'init', array( $this, 'add_tasks' ) ); | ||
add_filter( 'woocommerce_admin_experimental_onboarding_tasklists', [ $this, 'replace_tasks' ] ); | ||
add_filter( 'get_user_metadata', array( $this, 'override_user_meta_field' ), 10, 4 ); | ||
} | ||
|
@@ -86,14 +85,9 @@ public function handle_ajax_launch_endpoint() { | |
} | ||
|
||
/** | ||
* Add Setup Tasks. | ||
* Add and replace setup tasks. | ||
*/ | ||
public function add_tasks() { | ||
|
||
if ( ! class_exists( '\Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists' ) ) { | ||
return; | ||
} | ||
|
||
public function replace_tasks( $lists ) { | ||
/** | ||
* `ecommerce_custom_setup_tasks_enabled` filter. | ||
* | ||
|
@@ -104,27 +98,7 @@ public function add_tasks() { | |
* @param bool $status_enabled | ||
* @return bool | ||
*/ | ||
if ( ! (bool) apply_filters( 'ecommerce_custom_setup_tasks_enabled', true ) ) { | ||
return; | ||
} | ||
|
||
$tl = \Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists::instance(); | ||
require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/tasks/class-wc-calypso-task-add-domain.php'; | ||
require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/tasks/class-wc-calypso-task-launch-site.php'; | ||
|
||
$list = $tl::get_lists_by_ids( array( 'setup' ) ); | ||
$list = array_pop( $list ); | ||
|
||
$add_domain_task = new \Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\AddDomain( $list ); | ||
$launch_site_task = new \Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\LaunchSite( $list ); | ||
$tl::add_task( 'setup', $add_domain_task ); | ||
$tl::add_task( 'setup', $launch_site_task ); | ||
} | ||
|
||
/** | ||
* Replace setup tasks. | ||
*/ | ||
public function replace_tasks( $lists ) { | ||
$ecommerce_custom_setup_tasks_enabled = (bool) apply_filters( 'ecommerce_custom_setup_tasks_enabled', true ); | ||
if ( isset( $lists['setup'] ) ) { | ||
// Default product task index. | ||
$product_task_index = 2; | ||
|
@@ -142,7 +116,19 @@ public function replace_tasks( $lists ) { | |
unset( $lists['setup']->tasks[$index] ); | ||
break; | ||
case 'launch-your-store': | ||
if ( wc_calypso_bridge_is_trial_plan() ) { | ||
if ( $ecommerce_custom_setup_tasks_enabled ) { | ||
// Append add domain task before launch your store task. | ||
require_once __DIR__ . '/tasks/class-wc-calypso-task-add-domain.php'; | ||
$add_domain_task = array( new \Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\AddDomain( $lists['setup'] ) ); | ||
array_splice( $lists['setup']->tasks, $index, 0, $add_domain_task ); | ||
|
||
// Replace launch your store task with launch site task. | ||
if ( ! Features::is_enabled( 'launch-your-store' ) && ! wc_calypso_bridge_is_trial_plan() ) { | ||
require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/tasks/class-wc-calypso-task-launch-site.php'; | ||
$launch_site_task = new \Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\LaunchSite( $lists['setup'] ); | ||
$lists['setup']->tasks[$index + 1] = $launch_site_task; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
} else if ( wc_calypso_bridge_is_trial_plan() ) { | ||
// Don't show launch your store task for trial sites. | ||
unset( $lists['setup']->tasks[$index] ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entirely merged this function into
replace_tasks