Navigation: Update PHP registration (https://github.com/woocommerce/woocommerce-admin/pull/5255)
* UPdate to new registration API * conditionally add path to Overview * add comment * change to is_top_level
This commit is contained in:
parent
90cad8c945
commit
a4e8f6996c
|
@ -112,15 +112,19 @@ class Analytics {
|
|||
* Registers report pages.
|
||||
*/
|
||||
public function register_pages() {
|
||||
$report_pages = array(
|
||||
array(
|
||||
$overview_page = array(
|
||||
'id' => 'woocommerce-analytics',
|
||||
'title' => __( 'Analytics', 'woocommerce-admin' ),
|
||||
'path' => '/analytics/overview',
|
||||
'path' => '/analytics/overview',
|
||||
'icon' => 'dashicons-chart-bar',
|
||||
'position' => 56, // After WooCommerce & Product menu items.
|
||||
),
|
||||
);
|
||||
if ( class_exists( '\Automattic\WooCommerce\Navigation\Menu' ) ) {
|
||||
unset( $overview_page['path'] );
|
||||
}
|
||||
|
||||
$report_pages = array(
|
||||
$overview_page,
|
||||
array(
|
||||
'id' => 'woocommerce-analytics-overview',
|
||||
'title' => __( 'Overview', 'woocommerce-admin' ),
|
||||
|
|
|
@ -439,14 +439,19 @@ class PageController {
|
|||
);
|
||||
|
||||
if ( method_exists( '\Automattic\WooCommerce\Navigation\Menu', 'add_category' ) ) {
|
||||
\Automattic\WooCommerce\Navigation\Menu::add_category(
|
||||
array(
|
||||
$category_options = array(
|
||||
'id' => $options['id'],
|
||||
'title' => $options['title'],
|
||||
'capability' => $options['capability'],
|
||||
'url' => $options['path'],
|
||||
)
|
||||
'is_top_level' => true,
|
||||
);
|
||||
|
||||
// If there is no path option, remove url because its a parent category item.
|
||||
if ( 'wc-admin&path=' === $options['path'] ) {
|
||||
unset( $category_options['url'] );
|
||||
}
|
||||
\Automattic\WooCommerce\Navigation\Menu::add_category( $category_options );
|
||||
}
|
||||
} else {
|
||||
$parent_path = $this->get_path_from_id( $options['parent'] );
|
||||
|
@ -461,6 +466,7 @@ class PageController {
|
|||
);
|
||||
|
||||
if ( method_exists( '\Automattic\WooCommerce\Navigation\Menu', 'add_item' ) ) {
|
||||
$top_level_ids = array( 'woocommerce-home', 'woocommerce-analytics-customers' );
|
||||
\Automattic\WooCommerce\Navigation\Menu::add_item(
|
||||
array(
|
||||
'id' => $options['id'],
|
||||
|
@ -468,6 +474,7 @@ class PageController {
|
|||
'title' => $options['title'],
|
||||
'capability' => $options['capability'],
|
||||
'url' => $options['path'],
|
||||
'is_top_level' => in_array( $options['id'], $top_level_ids, true ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue