国产三级农村妇女在线,国产精品毛片a∨一区二区三区,国产乱子伦视频大全,国产精品色拉拉,国产欧美日韩一区二区三区,

首頁(yè) > 技術(shù) > cms教程

WordPress功能函數(shù)add_management_page()

cms教程 2022-10-26 09:23:35

WordPress功能函數(shù)add_management_page(),在工具主菜單中添加子菜單頁(yè)。

用法:

add_management_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', int $position = null )

描述:

該函數(shù)具有一種功能,用于確定菜單中是否包含某個(gè)頁(yè)面。

用于處理頁(yè)面輸出的函數(shù)也必須檢查用戶(hù)是否具備所需的功能。

參數(shù):

$page_title

(string) (必需) 選中菜單時(shí)要在頁(yè)面標(biāo)題標(biāo)簽中顯示的文本。

$menu_title

(string) (必需) 要用于菜單的文本。

$capability

(string) (必需) 向用戶(hù)顯示該菜單所需的功能。

$menu_slug

(string) (必需) 用來(lái)引用這個(gè)菜單的名稱(chēng)(對(duì)于這個(gè)菜單應(yīng)該是唯一的)。

$function

(callable) (可選) 用于輸出此頁(yè)面內(nèi)容的函數(shù)。

默認(rèn)值: ''

$position

(int) (可選) The position in the menu order this item should appear.

默認(rèn)值: null

返回

(string|false) 結(jié)果頁(yè)面的hook_suffix,如果用戶(hù)不具備所需的能力,則為false。

更多信息:

例子:

add_management_page('Custom permalinkks ', 'Custom permalinkks ', 'manage_options', 'my-unique-identifier', 'custom_permalinks_options_page');

注:

如果你正在運(yùn)行?你沒(méi)有足夠的權(quán)限訪問(wèn)這個(gè)頁(yè)面?!皐p_die()”屏幕中的消息,那么你太早上鉤了。你應(yīng)該使用的鉤子是' admin_menu '。

來(lái)源:

文件: wp-admin/includes/plugin.php

function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {

return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );

}

更新日志:

WordPress功能函數(shù)add_management_page() (https://www.wpzt.net/) WordPress開(kāi)發(fā)教程 第1張
用戶(hù)貢獻(xiàn)的筆記

(由David Brumbaugh貢獻(xiàn)- 5年前)

使用實(shí)例添加工具頁(yè)面。

class MyWPTool {

function __construct() {

add_action( 'admin_menu', array( $this, 'admin_menu' ) );

}

function admin_menu() {

$hook = add_management_page( 'My WP Tool Page', 'My WP Tool', 'install_plugins', 'mywptool', array( $this, 'admin_page' ), '' );

add_action( "load-$hook", array( $this, 'admin_page_load' ) );

}

function admin_page_load() {

// ...

}

function admin_page() {

// ...

}

}

(由jakubd貢獻(xiàn)- 2年前)

// Example

add_action ('admin_menu', function () {

add_management_page('Some page title', 'Title in the menu', 'install_plugins', 'some_unique_string', 'my_custom_page_render_function', '');

});

function my_custom_page_render_function()

{

echo 'This is content of the page';

}

TAg

加載中~

本網(wǎng)站LOGO受版權(quán)及商標(biāo)保護(hù),版權(quán)登記號(hào):國(guó)作登字-2022-F-10126915,未經(jīng)湖南木星科技官方許可,嚴(yán)禁使用。
Copyright ? 2012-2022 湖南木星科技有限公司(木星網(wǎng))版權(quán)所有
轉(zhuǎn)載內(nèi)容版權(quán)歸作者及來(lái)源網(wǎng)站所有,本站原創(chuàng)內(nèi)容轉(zhuǎn)載請(qǐng)注明來(lái)源,商業(yè)媒體及紙媒請(qǐng)先聯(lián)系:aishangyiwan@126.com

工信部備案號(hào):湘ICP備19012813號(hào)-5