On this page
get_plugin_page_hookname( string $plugin_page, string $parent_page ): string
Gets the hook name for the administrative page of a plugin.
Parameters
$plugin_pagestring Required-
The slug name of the plugin page.
$parent_pagestring Required-
The slug name for the parent menu (or the file name of a standard WordPress admin page).
Return
string Hook name for the plugin page.
Source
File: wp-admin/includes/plugin.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| get_admin_page_parent() wp-admin/includes/plugin.php | Gets the parent file of the current admin page. |
Used By
| Used By | Description |
|---|---|
| get_plugin_page_hook() wp-admin/includes/plugin.php | Gets the hook attached to the administrative page of a plugin. |
| user_can_access_admin_page() wp-admin/includes/plugin.php | Determines whether the current user can access the current admin page. |
| add_menu_page() wp-admin/includes/plugin.php | Adds a top-level menu page. |
| add_submenu_page() wp-admin/includes/plugin.php | Adds a submenu page. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_plugin_page_hookname