WC_Admin_Menus
in package
WC_Admin_Menus Class.
Table of Contents
- HIDE_CSS_CLASS = 'hide-if-js'
- The CSS classes used to hide the submenu items in navigation.
- __construct() : mixed
- Hook in tabs.
- add_nav_menu_meta_boxes() : void
- Add custom nav meta box.
- addons_menu() : void
- Addons menu item.
- addons_my_subscriptions() : void
- Registers the wc-addons page within the WooCommerce menu.
- addons_page() : void
- Init the addons page.
- admin_bar_menus() : void
- Add the "Visit Store" link in admin bar main menu.
- admin_menu() : void
- Add menu items.
- attributes_page() : void
- Init the attributes page.
- can_view_woocommerce_menu_item() : bool
- Check if the user can access the top-level WooCommerce item.
- custom_menu_order() : bool
- Custom menu order.
- filter_default_nav_menu_hidden_meta_boxes() : mixed
- Filter the default hidden meta boxes for the Appearance > Menus screen.
- hide_submenu_element() : void
- Apply the hide-if-js CSS class to a submenu item.
- hide_submenu_page() : false|array<string|int, mixed>
- Hide the submenu page based on slug and return the item that was hidden.
- menu_highlight() : void
- Highlights the correct top level admin menu item for post type add screens.
- menu_order() : array<string|int, mixed>
- Reorder the WC menu items in admin.
- menu_order_count() : void
- Adds the order processing count to the menu.
- nav_menu_links() : void
- Output menu links.
- orders_menu() : void
- Link to the order admin list table from the main WooCommerce menu.
- register_default_nav_menu_meta_boxes_filter() : void
- Ensure the Product Categories, Product Tags, and Brands meta boxes are visible by default on the Appearance > Menus screen.
- reports_menu() : void
- Add menu item.
- reports_page() : void
- Init the reports page.
- save_settings() : void
- Handle saving of settings.
- set_screen_option() : bool|int
- Validate screen options on update.
- settings_menu() : void
- Add menu item.
- settings_page() : void
- Init the settings page.
- settings_page_init() : void
- Loads gateways and shipping methods into memory for use within settings.
- status_menu() : void
- Add menu item.
- status_page() : void
- Init the status page.
Constants
HIDE_CSS_CLASS
The CSS classes used to hide the submenu items in navigation.
public
string
HIDE_CSS_CLASS
= 'hide-if-js'
Methods
__construct()
Hook in tabs.
public
__construct() : mixed
Return values
mixed —add_nav_menu_meta_boxes()
Add custom nav meta box.
public
add_nav_menu_meta_boxes() : void
Adapted from http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/.
Return values
void —addons_menu()
Addons menu item.
public
addons_menu() : void
Tags
Return values
void —addons_my_subscriptions()
Registers the wc-addons page within the WooCommerce menu.
public
addons_my_subscriptions() : void
Temporary measure till we convert the whole page to React.
Return values
void —addons_page()
Init the addons page.
public
addons_page() : void
Return values
void —admin_bar_menus()
Add the "Visit Store" link in admin bar main menu.
public
admin_bar_menus(WP_Admin_Bar $wp_admin_bar) : void
Parameters
- $wp_admin_bar : WP_Admin_Bar
-
Admin bar instance.
Tags
Return values
void —admin_menu()
Add menu items.
public
admin_menu() : void
Return values
void —attributes_page()
Init the attributes page.
public
attributes_page() : void
Return values
void —can_view_woocommerce_menu_item()
Check if the user can access the top-level WooCommerce item.
public
static can_view_woocommerce_menu_item() : bool
Return values
bool —custom_menu_order()
Custom menu order.
public
custom_menu_order(bool $enabled) : bool
Parameters
- $enabled : bool
-
Whether custom menu ordering is already enabled.
Return values
bool —filter_default_nav_menu_hidden_meta_boxes()
Filter the default hidden meta boxes for the Appearance > Menus screen.
public
filter_default_nav_menu_hidden_meta_boxes(mixed $result, string $option, WP_User $user) : mixed
Only applies when the user has no saved preference for the nav-menus screen. Returns a list of every registered nav-menus meta box except the four core visible boxes, the "WooCommerce endpoints" box, and the WC taxonomy boxes. Product Brands is visible only when its taxonomy exists.
Parameters
- $result : mixed
-
Value for the user's option, or false if not set.
- $option : string
-
Name of the option being retrieved.
- $user : WP_User
-
WP_User object of the user whose option is being retrieved.
Tags
Return values
mixed — The filtered option value.hide_submenu_element()
Apply the hide-if-js CSS class to a submenu item.
public
hide_submenu_element(int $index, string $parent_slug, array<string|int, mixed> $item) : void
Borrowed from Jetpack's Base_Admin_Menu class.
Parameters
- $index : int
-
The position of a submenu item in the submenu array.
- $parent_slug : string
-
The parent slug.
- $item : array<string|int, mixed>
-
The submenu item.
Return values
void —hide_submenu_page()
Hide the submenu page based on slug and return the item that was hidden.
public
hide_submenu_page(string $menu_slug, string $submenu_slug) : false|array<string|int, mixed>
Borrowed from Jetpack's Base_Admin_Menu class.
Instead of actually removing the submenu item, a safer approach is to hide it and filter it in the API response. In this manner we'll avoid breaking third-party plugins depending on items that no longer exist.
A false|array value is returned to be consistent with remove_submenu_page() function
Parameters
- $menu_slug : string
-
The parent menu slug.
- $submenu_slug : string
-
The submenu slug that should be hidden.
Return values
false|array<string|int, mixed> —menu_highlight()
Highlights the correct top level admin menu item for post type add screens.
public
menu_highlight() : void
Return values
void —menu_order()
Reorder the WC menu items in admin.
public
menu_order(int $menu_order) : array<string|int, mixed>
Parameters
- $menu_order : int
-
Menu order.
Return values
array<string|int, mixed> —menu_order_count()
Adds the order processing count to the menu.
public
menu_order_count() : void
Return values
void —nav_menu_links()
Output menu links.
public
nav_menu_links() : void
Return values
void —orders_menu()
Link to the order admin list table from the main WooCommerce menu.
public
orders_menu() : void
Return values
void —register_default_nav_menu_meta_boxes_filter()
Ensure the Product Categories, Product Tags, and Brands meta boxes are visible by default on the Appearance > Menus screen.
public
register_default_nav_menu_meta_boxes_filter() : void
WordPress's wp_initial_nav_menu_meta_boxes() hides every box except page, post, custom-links, and category on a user's first visit. We intercept the empty user option and return a hidden list that excludes the WC taxonomy boxes, so WP's existing-user guard short-circuits and leaves them visible.
The computed list is persisted to user meta on that first read, mirroring core's wp_initial_nav_menu_meta_boxes(). This keeps the snapshot stable across the multiple reads in a single page load and, crucially, across later requests: boxes registered by plugins installed after the first visit stay visible, matching vanilla WordPress instead of defaulting to hidden on every recompute. As in core, only the current user's snapshot is persisted, so reads on behalf of another user never overwrite that user's own first-visit snapshot.
Tags
Return values
void —reports_menu()
Add menu item.
public
reports_menu() : void
Return values
void —reports_page()
Init the reports page.
public
reports_page() : void
Return values
void —save_settings()
Handle saving of settings.
public
save_settings() : void
Return values
void —set_screen_option()
Validate screen options on update.
public
set_screen_option(bool|int $status, string $option, int $value) : bool|int
Parameters
- $status : bool|int
-
Screen option value. Default false to skip.
- $option : string
-
The option name.
- $value : int
-
The number of rows to use.
Return values
bool|int —settings_menu()
Add menu item.
public
settings_menu() : void
Return values
void —settings_page()
Init the settings page.
public
settings_page() : void
Return values
void —settings_page_init()
Loads gateways and shipping methods into memory for use within settings.
public
settings_page_init() : void
Return values
void —status_menu()
Add menu item.
public
status_menu() : void
Return values
void —status_page()
Init the status page.
public
status_page() : void
