get_admin_page_parent

The WordPress Core get admin page parent function.

Description

get_admin_page_parent( (string) $parent = '' ); 

Parameters (1)

0. $parent — Optional. (string) => ''
The parent.

Usage

  1. if ( !function_exists( 'get_admin_page_parent' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/plugin.php'; 
  3.  
  4. // The parent. 
  5. $parent = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_admin_page_parent($parent); 
  9.  

Defined (1)

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

/wp-admin/includes/plugin.php  
  1. function get_admin_page_parent( $parent = '' ) { 
  2. global $parent_file, $menu, $submenu, $pagenow, $typenow,  
  3. $plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv; 
  4.  
  5. if ( !empty ( $parent ) && 'admin.php' != $parent ) { 
  6. if ( isset( $_wp_real_parent_file[$parent] ) ) 
  7. $parent = $_wp_real_parent_file[$parent]; 
  8. return $parent; 
  9.  
  10. if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) { 
  11. foreach ( (array)$menu as $parent_menu ) { 
  12. if ( $parent_menu[2] == $plugin_page ) { 
  13. $parent_file = $plugin_page; 
  14. if ( isset( $_wp_real_parent_file[$parent_file] ) ) 
  15. $parent_file = $_wp_real_parent_file[$parent_file]; 
  16. return $parent_file; 
  17. if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) { 
  18. $parent_file = $plugin_page; 
  19. if ( isset( $_wp_real_parent_file[$parent_file] ) ) 
  20. $parent_file = $_wp_real_parent_file[$parent_file]; 
  21. return $parent_file; 
  22.  
  23. if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) { 
  24. $parent_file = $pagenow; 
  25. if ( isset( $_wp_real_parent_file[$parent_file] ) ) 
  26. $parent_file = $_wp_real_parent_file[$parent_file]; 
  27. return $parent_file; 
  28.  
  29. foreach (array_keys( (array)$submenu ) as $parent) { 
  30. foreach ( $submenu[$parent] as $submenu_array ) { 
  31. if ( isset( $_wp_real_parent_file[$parent] ) ) 
  32. $parent = $_wp_real_parent_file[$parent]; 
  33. if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) { 
  34. $parent_file = $parent; 
  35. return $parent; 
  36. } elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) { 
  37. $parent_file = $parent; 
  38. return $parent; 
  39. } elseif ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) { 
  40. $parent_file = $parent; 
  41. return $parent; 
  42.  
  43. if ( empty($parent_file) ) 
  44. $parent_file = ''; 
  45. return '';