add_submenu_page [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Add a sub menu page
This function takes a capability which will be used to determine whether or not a page is included in the menu.
The function which is hooked in to handle the output of the page must check that the user has the required capability as well.
Source
<?php
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
global $submenu;
global $menu;
global $_wp_real_parent_file;
global $_wp_submenu_nopriv;
global $_registered_pages;
global $_parent_pages;
$menu_slug = plugin_basename( $menu_slug );
$parent_slug = plugin_basename( $parent_slug);
if ( isset( $_wp_real_parent_file[$parent_slug] ) )
$parent_slug = $_wp_real_parent_file[$parent_slug];
if ( !current_user_can( $capability ) ) {
$_wp_submenu_nopriv[$parent_slug][$menu_slug] = true;
return false;
}
// If the parent doesn't already have a submenu, add a link to the parent
// as the first item in the submenu. If the submenu file is the same as the
// parent file someone is trying to link back to the parent manually. In
// this case, don't automatically add a link back to avoid duplication.
if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) {
foreach ( (array)$menu as $parent_menu ) {
if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) )
$submenu[$parent_slug][] = $parent_menu;
}
}
$submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title );
$hookname = get_plugin_page_hookname( $menu_slug, $parent_slug);
if (!empty ( $function ) && !empty ( $hookname ))
add_action( $hookname, $function );
$_registered_pages[$hookname] = true;
// backwards-compatibility for plugins using add_management page. See wp-admin/admin.php for redirect from edit.php to tools.php
if ( 'tools.php' == $parent_slug )
$_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true;
// No parent as top level
$_parent_pages[$menu_slug] = $parent_slug;
return $hookname;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/add submenu page « WordPress Codex
Description. Add a sub menu page. This function takes a capability which will be used to determine whether or not a page is included in the menu. The function ...
codex.wordpress.org - Administration Menus « WordPress Codex
5.2.1 Using add_submenu_page .... The duplicate link title can be avoided by calling the add_submenu_page function the first time with the parent_slug and ...
codex.wordpress.org - add_menu_page, add_submenu_page
add_menu_page, add_submenu_page. by ShibaShake on Jul 23, 2010. The add_menu_page and add_submenu_page functions are used to add menu and ...
shibashake.com - Current class on admin menu using add_submenu_page()
Feb 19, 2011 ... I have also added a couple of sections within the menu using add_submenu_page(). It appears that WordPress (running 3.05) is not correctly ...
wordpress.stackexchange.com
Gebruikersdiscussies [ wordpress.org ]
- EpicKris on "If add_menu_page"
- EpicKris on "If add_menu_page"
- EpicKris on "If add_menu_page"
- CaspervdH on "Making my own module"
- Tammy Hart on "Moving Taxonomy UI to another main menu"
- sam_benne on "Moving Taxonomy UI to another main menu"
- Tammy Hart on "Moving Taxonomy UI to another main menu"
- Tammy Hart on "Moving Taxonomy UI to another main menu"
- mayaboys on "duplicate add_submenu_page"
- oqeysites on "[Plugin: Ozh' Admin Drop Down Menu] Other plugin not working at Editor level"