Use wc filter to get status tabs for tools category (https://github.com/woocommerce/woocommerce-admin/pull/6525)

* Use wc filter to get status tabs for tools category

* Add testing instructions and changelog entry

* Handle PR feedback
This commit is contained in:
Joshua T Flowers 2021-03-09 17:41:54 -05:00 committed by GitHub
parent f1bac7d787
commit f0e1e924c8
3 changed files with 57 additions and 42 deletions

View File

@ -2,6 +2,18 @@
## Unreleased
### Use wc filter to get status tabs for tools category #6525
1. Register a new tab via the filter.
```
add_filter( 'woocommerce_admin_status_tabs', function ( array $tabs ) {
$tabs['my-tools-page'] = __( 'My Tools Page', 'your-text-domain' );
return $tabs;
} );
```
2. Enable the new navigation.
3. Make sure the menu item for the registered tab is shown under `Tools`.
### Add Guards to "Deactivate Plugin" Note Handlers #6532
#### Test incompatible WooCommerce version

View File

@ -75,6 +75,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
== Unreleased ==
- Dev: Use wc filter to get status tabs for tools category #6525
- Tweak: Remove mobile activity panel toggle #6539
- Dev: Add nav header component tests #6509
- Add: Add legacy report items to new navigation #6507

View File

@ -224,49 +224,9 @@ class CoreMenu {
'menuId' => 'secondary',
'order' => 10,
),
// Tools category.
array(
'parent' => 'woocommerce-tools',
'title' => __( 'System status', 'woocommerce-admin' ),
'capability' => 'manage_woocommerce',
'id' => 'tools-system-status',
'url' => 'wc-status',
'order' => 20,
),
array(
'parent' => 'woocommerce-tools',
'title' => __( 'Import / Export', 'woocommerce-admin' ),
'capability' => 'import',
'id' => 'tools-import-export',
'url' => 'import.php',
'migrate' => false,
'order' => 10,
),
array(
'parent' => 'woocommerce-tools',
'title' => __( 'Utilities', 'woocommerce-admin' ),
'capability' => 'manage_woocommerce',
'id' => 'tools-utilities',
'url' => 'admin.php?page=wc-status&tab=tools',
'order' => 30,
),
array(
'parent' => 'woocommerce-tools',
'title' => __( 'Logs', 'woocommerce-admin' ),
'capability' => 'manage_woocommerce',
'id' => 'tools-logs',
'url' => 'admin.php?page=wc-status&tab=logs',
'order' => 40,
),
array(
'parent' => 'woocommerce-tools',
'title' => __( 'Scheduled Actions', 'woocommerce-admin' ),
'capability' => 'manage_woocommerce',
'id' => 'tools-scheduled_actions',
'url' => 'admin.php?page=wc-status&tab=action-scheduler',
'order' => 50,
),
),
// Tools category.
self::get_tool_items(),
// WooCommerce Admin items.
$wca_items,
// Settings category.
@ -276,6 +236,47 @@ class CoreMenu {
);
}
/**
* Get items for tools category.
*
* @returna array
*/
public static function get_tool_items() {
$tabs = array(
'status' => __( 'System status', 'woocommerce-admin' ),
'tools' => __( 'Utilities', 'woocommerce-admin' ),
'logs' => __( 'Logs', 'woocommerce-admin' ),
);
$tabs = apply_filters( 'woocommerce_admin_status_tabs', $tabs );
$order = 1;
$items = array(
array(
'parent' => 'woocommerce-tools',
'title' => __( 'Import / Export', 'woocommerce-admin' ),
'capability' => 'import',
'id' => 'tools-import-export',
'url' => 'import.php',
'migrate' => false,
'order' => 0,
),
);
foreach ( $tabs as $key => $tab ) {
$items[] = array(
'parent' => 'woocommerce-tools',
'title' => $tab,
'capability' => 'manage_woocommerce',
'id' => 'tools-' . $key,
'url' => 'wc-status&tab=' . $key,
'order' => $order,
);
$order++;
}
return $items;
}
/**
* Get legacy report items.
*
@ -386,6 +387,7 @@ class CoreMenu {
'woocommerce',
'wc-reports',
'wc-settings',
'wc-status',
);
return apply_filters( 'woocommerce_navigation_core_excluded_items', $excluded_items );