add_menu_page [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Add a top level 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_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) {
global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
$menu_slug = plugin_basename( $menu_slug );
$admin_page_hooks[$menu_slug] = sanitize_title( $menu_title );
$hookname = get_plugin_page_hookname( $menu_slug, '' );
if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) )
add_action( $hookname, $function );
if ( empty($icon_url) )
$icon_url = esc_url( admin_url( 'images/generic.png' ) );
elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') )
$icon_url = 'https://' . substr($icon_url, 7);
$new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
if ( null === $position )
$menu[] = $new_menu;
else
$menu[$position] = $new_menu;
$_registered_pages[$hookname] = true;
// No parent as top level
$_parent_pages[$menu_slug] = false;
return $hookname;
}
?>
Examples [ wp-snippets.com ]
Top Google Search Results
- Function Reference/add menu page « WordPress Codex
Description. Add a top level menu page. Specifically, creates a new top level menu section in the admin menu sidebar and registers a hook to callback your ...
codex.wordpress.org - Administration Menus « WordPress Codex
<?php add_menu_page( $page_title, $menu_title, $capability, $menu_slug, ... Technically, as in the add_menu_page function, the function parameter is ...
codex.wordpress.org - add_menu_page, add_submenu_page
Jul 23, 2010 ... The add_menu_page and add_submenu_page functions are used to ... perform using add_menu_page and add_submenu_page including - ...
shibashake.com - php - WordPress and Call to undefined function add_menu_page ...
I don't know how your code looks but this is how I just tested and it worked: add_action('admin_menu', 'my_menu'); function my_menu() ...
stackoverflow.com
User discussions [ wordpress.org ]
- docarzt on "Problem with 'add_menu_page'"
- Chip Bennett on "Problem with 'add_menu_page'"
- docarzt on "Problem with 'add_menu_page'"
- EpicKris on "If add_menu_page"
- EpicKris on "If add_menu_page"
- EpicKris on "If add_menu_page"
- mayaboys on "duplicate add_submenu_page"
- oqeysites on "[Plugin: Ozh' Admin Drop Down Menu] Other plugin not working at Editor level"
- oqeysites on "[Plugin: Ozh' Admin Drop Down Menu] Other plugin not working at Editor level"
- oqeysites on "[Plugin: Ozh' Admin Drop Down Menu] Other plugin not working at Editor level"