Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
add_comments_page() - 将子菜单页添加到评论主菜单 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / add_comments_page()

add_comments_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $callback = '', int $position = null )

将子菜单页添加到评论主菜单


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "d369e5096771b4ef95be960ff7c1c3db" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "5d38607a8b13d4a544b0e14fd6bf9118" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

addmore...

menu_page 菜单页more...


描述

这个函数接受一个能力(capability),它将被用来确定一个页面是否包括在菜单中。

用于处理页面输出的函数必须检查用户是否具有所需的能力。


参数

$page_title

(string)(必填) 选中菜单时要在页面标题标签中显示的文本。

$menu_title

(string)(必填) 要用于菜单的文本。

$capability

(string)(必填) 向用户显示此菜单所需的能力。

$menu_slug

(string)(必填) 用于引用此菜单的slug名称(对于此菜单应是唯一的)。

$callback

(callable)(可选) 要调用以输出此页面内容的函数。

默认值: ''

$position

(int)(可选) 此项应出现在菜单顺序中的位置。

默认值: null


返回

(string|false) 返回结果页面的hook_suffix,如果用户不具备所需的能力则返回false。



源码

查看源码 官方文档


更新日志

版本描述
5.3.0添加了$position参数。
2.7.0开始引入

使用示例

  • 示例1

    在评论菜单下添加管理页面

    add_action('admin_menu', 'wpdocs_my_plugin_menu');
    
    function wpdocs_my_plugin_menu() {
        add_comments_page( __( 'My Plugin Comments', 'textdomain' ), __( 'My Plugin Comments', 'textdomain' ), 'read', 'my-unique-identifier', 'my_plugin_function' );
    }