WC_Admin_Menus::hide_submenu_page()publicWC 1.0

Hide the submenu page based on slug and return the item that was hidden.

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

Method of the class: WC_Admin_Menus{}

No Hooks.

Return

false|Array.

Usage

$WC_Admin_Menus = new WC_Admin_Menus();
$WC_Admin_Menus->hide_submenu_page( $menu_slug, $submenu_slug );
$menu_slug(string) (required)
The parent menu slug.
$submenu_slug(string) (required)
The submenu slug that should be hidden.

WC_Admin_Menus::hide_submenu_page() code WC 8.9.0

public function hide_submenu_page( $menu_slug, $submenu_slug ) {
	global $submenu;

	if ( ! isset( $submenu[ $menu_slug ] ) ) {
		return false;
	}

	foreach ( $submenu[ $menu_slug ] as $i => $item ) {
		if ( $submenu_slug !== $item[2] ) {
			continue;
		}

		$this->hide_submenu_element( $i, $menu_slug, $item );

		return $item;
	}

	return false;
}