当サイト、Codex 日本語版は今後積極的な更新は行わない予定です。後継となる新ユーザーマニュアルは、https://ja.wordpress.org/support/ にあります。
万が一、当サイトで重大な問題を発見した際などは、フォーラムWordSlack #docs チャンネルでお知らせください。</p>

関数リファレンス/remove submenu page

提供: WordPress Codex 日本語版
< 関数リファレンス
2018年8月26日 (日) 22:35時点におけるNorando (トーク | 投稿記録)による版 (en:Function Reference/remove submenu page 21:39, 23 August 2018‎ Bookchiq 版)

(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Description

Remove an admin submenu.

Depending on when this function is called, it may not prevent users from accessing the screen for the removed submenu directly (see ticket #18850). Removing a menu does not replace the need to filter a user's permissions as appropriate.

Usage

<?php remove_submenu_page( $menu_slug, $submenu_slug ); ?>

Parameters

$menu_slug
string) (必須) The slug for the parent menu
初期値: なし
$submenu_slug
string) (必須) The slug of the submenu
初期値: なし

Return Values

(array|boolean) 
The removed submenu on success, false if not found.

Examples

Removes the Widgets submenu page.

function wpcodex_adjust_the_wp_menu() {
	$page = remove_submenu_page( 'themes.php', 'widgets.php' );
	// $page[0] is the menu title
	// $page[1] is the minimum level or capability required
	// $page[2] is the URL to the item's file
}
add_action( 'admin_menu', 'wpcodex_adjust_the_wp_menu', 999 );

In the above example, the value of $page would have been:

array(3) { [0]=> string(7) "Widgets" [1]=> string(18) "edit_theme_options" [2]=> string(11) "widgets.php" }

To remove a settings page for plugins that use a slug like /wp-admin/options-general.php?page=certain-plugin-settings use this code:

add_action( 'admin_menu', 'nstrm_remove_admin_submenus', 999 );
function nstrm_remove_admin_submenus() {
	remove_submenu_page( 'options-general.php', 'certain-plugin-settings' );
}

Remove custom post type submenu pages. The secret is in converting the second argument `&` to `&amp;`.

Notes

  • Uses global: (array) $submenu
  • In order to remove the theme-editor.php submenu of themes.php (and others) in more recent versions of WordPress, you need to bind to the admin_menu hook with a very high priority (about 110, depending on the submenus to remove). Don't use admin_init as previously stated here, hence it will break wp-admin/admin-ajax.php.

Change Log

Since: 3.1.0

Source File

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

Related

管理メニュー: 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()


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


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