此功能具有一項(xiàng)功能,該功能將用于確定菜單中是否包含頁(yè)面。連接到處理頁(yè)面輸出的功能必須檢查用戶是否也具有所需的功能。
函數(shù)介紹:
add_options_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', int $position = null )
參數(shù)詳解:
$ page_title
(字符串)?(必需)?選擇菜單時(shí)在頁(yè)面標(biāo)題標(biāo)簽中顯示的文本。
$ menu_title
(字符串)?(必需)?用于菜單的文本。
$capability
(字符串)(必需)?此菜單需要顯示給用戶的功能。
$menu_slug
(string)(必需)?引用此菜單所用的子文件名(此菜單應(yīng)該唯一)。
$function
(callable)?(可選)?將被調(diào)用以輸出此頁(yè)面內(nèi)容的函數(shù)。
Default value: ”
$position
(int)?(可選)?應(yīng)在菜單項(xiàng)中顯示此項(xiàng)目的位置。
Default value: null
Return?
(string|false)?結(jié)果頁(yè)面的hook_suffix,如果用戶沒(méi)有所需的功能,則返回false。
例子:
面向?qū)ο蟮倪x項(xiàng)頁(yè)面助手/視圖
/**
* Class for registering a new settings page under Settings.
*/
class WPDocs_Options_Page {
/**
* Constructor.
*/
function __construct() {
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
}
/**
* Registers a new settings page under Settings.
*/
function admin_menu() {
add_options_page(
__( 'Page Title', 'textdomain' ),
__( 'Circle Tree Login', 'textdomain' ),
'manage_options',
'options_page_slug',
array(
$this,
'settings_page'
)
);
}
/**
* Settings page display callback.
*/
function settings_page() {
echo __( 'This is the page content', 'textdomain' );
}
}
new WPDocs_Options_Page;
其他:
如果您需要將子菜單頁(yè)面添加到外觀主菜單中,您可以參考這篇wordpress函數(shù)文章:
用在實(shí)際開(kāi)發(fā)中,您可以看看這款插件是如何使用的: