get_plugin_page_hookname() – Gets the hook name for the administrative page of a plugin.

You appear to be a bot. Output may be restricted

Description

Gets the hook name for the administrative page of a plugin.

Usage

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

Parameters

$plugin_page
( string ) required – The slug name of the plugin page.
$parent_page
( string ) required – The slug name for the parent menu (or the file name of a standard WordPress admin page).

Returns

string Hook name for the plugin page.

Source

File name: wordpress/wp-admin/includes/plugin.php
Lines:

1 to 20 of 20
function get_plugin_page_hookname( $plugin_page, $parent_page ) {
  global $admin_page_hooks;

  $parent = get_admin_page_parent( $parent_page );

  $page_type = 'admin';
  if ( empty( $parent_page ) || 'admin.php' === $parent_page || isset( $admin_page_hooks[ $plugin_page ] ) ) {
    if ( isset( $admin_page_hooks[ $plugin_page ] ) ) {
      $page_type = 'toplevel';
    } elseif ( isset( $admin_page_hooks[ $parent ] ) ) {
      $page_type = $admin_page_hooks[ $parent ];
    }
  } elseif ( isset( $admin_page_hooks[ $parent ] ) ) {
    $page_type = $admin_page_hooks[ $parent ];
  }

  $plugin_name = preg_replace( '!\.php!', '', $plugin_page );

  return $page_type . '_page_' . $plugin_name;
}
 

 View on GitHub View on Trac