How to get a slug name for a page without creating an admin page menu How to get a slug name for a page without creating an admin page menu wordpress wordpress

How to get a slug name for a page without creating an admin page menu


Example of how to create an invisible sub menu (it gets attached to the Dashboard, index.php) and the correspondent $hook_suffix.

The page can be accessed through http://example.com/wp-admin/index.php?page=sample_page_hidden.

add_action(  'admin_menu', 'admin_menu_so_11593510' );add_action( 'admin_enqueue_scripts', 'admin_enqueue_scripts_so_11593510' );function admin_menu_so_11593510() {    add_submenu_page(        null, // doesn't shows up in the menu, submenu is attached to "index.php"        'Test',         'Test',         'edit_pages',         'sample_page_hidden',         'menu_options_so_11593510'    );}function menu_options_so_11593510() { echo 'Hello!'; }function admin_enqueue_scripts_so_11593510( $hook_suffix ){    if ( 'dashboard_page_sample_page_hidden' == $hook_suffix ) {        wp_enqueue_script( 'swfobject' );    }}