Adding basic support for tasks badge to woo navigation

This commit is contained in:
Joel T 2022-04-12 16:59:18 -07:00
parent 18e0af4c29
commit 3a443234ea
2 changed files with 7 additions and 5 deletions

View File

@ -10,6 +10,7 @@ namespace Automattic\WooCommerce\Admin\Features\Navigation;
use Automattic\WooCommerce\Admin\Features\Features; use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Admin\Features\Navigation\Menu; use Automattic\WooCommerce\Admin\Features\Navigation\Menu;
use Automattic\WooCommerce\Admin\Features\Navigation\Screen; use Automattic\WooCommerce\Admin\Features\Navigation\Screen;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists;
/** /**
* CoreMenu class. Handles registering Core menu items. * CoreMenu class. Handles registering Core menu items.
@ -196,6 +197,7 @@ class CoreMenu {
'url' => \Automattic\WooCommerce\Internal\Admin\Homescreen::MENU_SLUG, 'url' => \Automattic\WooCommerce\Internal\Admin\Homescreen::MENU_SLUG,
'order' => 0, 'order' => 0,
'matchExpression' => 'page=wc-admin((?!path=).)*$', 'matchExpression' => 'page=wc-admin((?!path=).)*$',
'badge' => TaskLists::setup_tasks_remaining(),
); );
} }

View File

@ -468,13 +468,13 @@ class TaskLists {
* @return number * @return number
*/ */
public static function setup_tasks_remaining () { public static function setup_tasks_remaining () {
if(!Features::is_enabled( 'tasklist-setup-experiment-1' )) { if( ! Features::is_enabled( 'tasklist-setup-experiment-1' )) {
return; return;
} }
$setup_list = self::get_list('setup_experiment_1'); $setup_list = self::get_list( 'setup_experiment_1' );
if($setup_list->is_hidden() || $setup_list->is_complete()) { if( $setup_list->is_hidden() || $setup_list->is_complete() ) {
return; return;
} }
@ -487,7 +487,7 @@ class TaskLists {
) )
); );
return count($remaining_tasks); return count( $remaining_tasks );
} }
/** /**
@ -498,7 +498,7 @@ class TaskLists {
$tasks_count = self::setup_tasks_remaining(); $tasks_count = self::setup_tasks_remaining();
if(!$tasks_count) { if( !$tasks_count ) {
return; return;
} }