Function Reference/add submenu page
Description
Add a sub menu page.
NOTE: If you're running into the "You do not have sufficient permissions to access this page."message in a wp_die() screen, then you've hooked too early. The hook you should use is admin_menu.
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.
This function should normally be hooked in with one of the the admin_menu actions depending on the menu where the sub menu is to appear:
admin_menu
The normal, or site, administration menu
user_admin_menu
The user administration menu
network_admin_menu
The network administration menu
Usage
<?php add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); ?>
Parameters
Return values
Notes
add_submenu_page()
, such as the $page_title. Typically, these will work: get_admin_page_parent()
get_admin_page_title()
, or simply global $title
global $plugin_page
Example
add_action('admin_menu', 'register_my_custom_submenu_page');
function register_my_custom_submenu_page() {
add_submenu_page( 'tools.php', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' );
}
function my_custom_submenu_page_callback() {
echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
echo '<h2>My Custom Submenu Page</h2>';
echo '</div>';
}
To hide your submenu link from a top level menu item to which it belongs you would instead do,
add_action('admin_menu', 'register_my_custom_submenu_page');
function register_my_custom_submenu_page() {
add_submenu_page(
null //or 'options.php'
, 'My Custom Submenu Page'
, 'My Custom Submenu Page'
, 'manage_options'
, 'my-custom-submenu-page'
, 'my_custom_submenu_page_callback'
);
}
If you are attempting to add a sub menu page to a menu page created via
add_menu_page()
the first sub_menu_page will duplicate your add_menu_page()
. If you want a sub_menu_page in this scenario, you should first create a duplicate of your add_menu_page() and then add your sub_menu_page() second:
add_menu_page('My Custom Page', 'My Custom Page', 'manage_options', 'my-top-level-slug');
add_submenu_page( 'my-top-level-slug', 'My Custom Page', 'My Custom Page', 'manage_options', 'my-top-level-slug');
add_submenu_page( 'my-top-level-slug', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-secondary-slug');
Change Log
Source File
add_submenu_page() is located in
wp-admin/includes/plugin.php
.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.