get_plugin_page_hookname

The WordPress Core get plugin page hookname function.

Description

get_plugin_page_hookname( (string) $plugin_page, (string) $parent_page ); 

Parameters (2)

0. $plugin_page (string)
The plugin page.
1. $parent_page (string)
The parent page.

Usage

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

Defined (1)

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

/wp-admin/includes/plugin.php  
  1. function get_plugin_page_hookname( $plugin_page, $parent_page ) { 
  2. global $admin_page_hooks; 
  3.  
  4. $parent = get_admin_page_parent( $parent_page ); 
  5.  
  6. $page_type = 'admin'; 
  7. if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_page] ) ) { 
  8. if ( isset( $admin_page_hooks[$plugin_page] ) ) { 
  9. $page_type = 'toplevel'; 
  10. } elseif ( isset( $admin_page_hooks[$parent] )) { 
  11. $page_type = $admin_page_hooks[$parent]; 
  12. } elseif ( isset( $admin_page_hooks[$parent] ) ) { 
  13. $page_type = $admin_page_hooks[$parent]; 
  14.  
  15. $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); 
  16.  
  17. return $page_type . '_page_' . $plugin_name;