Codex

Function Reference/add object page

Contents

描述

在“对象”层上添加一个最高级别的菜单页,新的菜单将出现在wordpress默认和文章,多媒体,链接,页面,评论一起的级别里

Specifically, creates a new top level menu section in the admin menu sidebar and registers a hook to callback your function for outputting the page content when the linked menu page is requested. Returns the $hookname.

This essentially does the exact same thing as add_menu_page() in case you're wondering.

Usage

<?php
add_object_page
$page_title$menu_title$capability$menu_slug$function$icon_url$position );
?>

Parameters

$page_title
(string) (required) The text to be displayed in the title tags of the page when the menu is selected
Default: None
$menu_title
(string) (required) The on-screen name text for the menu
Default: None
$capability
(string) (required) The capability required for this menu to be displayed to the user. User levels are deprecated and should not be used here!
Default: None
$menu_slug
(string) (required) The slug name to refer to this menu by (should be unique for this menu). Prior to Version 3.0 this was called the file (or handle) parameter. If the function parameter is omitted, the menu_slug should be the PHP file that handles the display of the menu page content.
Default: None
$function
The function that displays the page content for the menu page. Technically, the function parameter is optional, but if it is not supplied, then WordPress will basically assume that including the PHP file will generate the administration screen, without calling a function. Most plugin authors choose to put the page-generating code in a function within their main plugin file.:In the event that the function parameter is specified, it is possible to use any string for the file parameter. This allows usage of pages such as ?page=my_super_plugin_page instead of ?page=my-super-plugin/admin-options.php.
The function must be referenced in one of two ways:
  1. if the function is a member of a class within the plugin it should be referenced as array( $this, 'function_name' )
  2. in all other cases, using the function name itself is sufficient
$icon_url
(string) (optional) The url to the icon to be used for this menu. This parameter is optional. Icons should be fairly small, around 20 x 20 pixels (?). You can use the WP_CONTENT_URL constant to help point to an image contained in your plugin folder.
Default:
$position
(integer) (optional) The position in the menu order this menu should appear. By default, if this parameter is omitted, the menu will appear at the bottom of the menu structure. The higher the number, the lower its position in the menu.
Default: bottom of menu structure

Return Values

string 
$hookname used internally to track menu page callbacks for outputting the page inside the global $menu array

Notes

This function takes a 'capability' (see Roles and Capabilities) 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 File

add_object_page() is located in wp-admin/includes/plugin.php.

Related

Administration Menus: add_menu_page(), remove_menu_page(), add_submenu_page(), remove_submenu_page(), add_dashboard_page(), add_posts_page(), add_media_page(), add_links_page(), add_pages_page(), add_comments_page(), add_theme_page(), add_plugins_page(), add_users_page(), add_management_page(), add_options_page()