remove_submenu_page

Remove an admin submenu.

Description

(array|bool) remove_submenu_page( (string) $menu_slug, (string) $submenu_slug ); 

Returns (array|bool)

The removed submenu on success, false if not found.

Parameters (2)

0. $menu_slug (string)
The slug for the parent menu.
1. $submenu_slug (string)
The slug of the submenu.

Usage

  1. if ( !function_exists( 'remove_submenu_page' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/plugin.php'; 
  3.  
  4. // The slug for the parent menu. 
  5. $menu_slug = ''; 
  6.  
  7. // The slug of the submenu. 
  8. $submenu_slug = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = remove_submenu_page($menu_slug, $submenu_slug); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/plugin.php  
  1. function remove_submenu_page( $menu_slug, $submenu_slug ) { 
  2. global $submenu; 
  3.  
  4. if ( !isset( $submenu[$menu_slug] ) ) 
  5. return false; 
  6.  
  7. foreach ( $submenu[$menu_slug] as $i => $item ) { 
  8. if ( $submenu_slug == $item[2] ) { 
  9. unset( $submenu[$menu_slug][$i] ); 
  10. return $item; 
  11.  
  12. return false;