• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

関数リファレンス/add object page

提供: WordPress Codex 日本語版
移動先: 案内検索

説明

トップレベルメニューの追加。

Add a top level menu page at the 'object' level. This new menu will appear in the group including the default WordPress Posts, Media, Links, Pages and Comments.

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(), but checks (and increments) the $_wp_last_object_menu global variable to add the menu item to the last position in the menu items. So, if $_wp_last_object_menu has already been incremented to 25, this call to add_object_page() will send 26 in the $position argument to the add_menu_page() function.

使い方

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

パラメータ

$page_title
文字列) (必須) メニューが選択された場合テキストがページのタイトルタグに表示されます。
初期値: なし
$menu_title
文字列) (必須) メニュー用の画面上の名のテキスト。
初期値: なし
$capability
文字列) (必須) The capability required for this menu to be displayed to the user. User levels are deprecated and should not be used here!
初期値: なし
$menu_slug
文字列) (必須) 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.
初期値: なし
$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
文字列) (オプション) 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.
初期値:

戻り値

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

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.

ソースファイル

add_object_page()wp-admin/includes/plugin.phpにあります。


外部リソース

関連

管理メニュー: add_menu_page(), remove_menu_page(), add_submenu_page() /en, remove_submenu_page() /en, add_dashboard_page() /en, add_posts_page() /en, add_media_page() /en, add_links_page() /en, add_pages_page() /en, add_comments_page() /en, add_theme_page() /en, add_plugins_page() /en, add_users_page() /en, add_management_page() /en, add_options_page()


関数リファレンステンプレートタグ目次もご覧ください。


このページ「関数リファレンス/add object page」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

最新英語版: WordPress Codex » Function Reference/add object page最新版との差分