为wordpress后台添加一个自定义页面

非插件线代码方式实现为wordpress后台添加一个自定义页面

参数如下:

$page_title (string) – The text to be displayed in the title tags of the page when the menu is selected.
$menu_title (string) – The text to be used for the menu.
$capability (string) – The capability required for this menu to be displayed to the user.
$menu_slug (string) – The unique slug name to refer to this menu.
$callback (callable, optional) – The function to be called to output the content for this page. Default: ”
$position (int, optional) – The position in the menu order this item should appear. Default: null

将下面代码添加到functions.php中即可实现

function my_plugin_menu() {
    add_dashboard_page('My Custom Dashboard', 'Custom Dashboard', 'read', 'wodepress-custom-dashboard', 'wodepress_custom_dashboard_output');
}
add_action('admin_menu', 'my_plugin_menu');

function wodepress_custom_dashboard_output() {
    echo 'Welcome to My Custom Dashboard!';
}

所有登陆后台的用户可见

function my_plugin_menu() {
    add_dashboard_page('My Custom Dashboard', 'Custom Dashboard', 'edit_posts', 'wodepress-custom-dashboard', 'wodepress_custom_dashboard_output');
}
add_action('admin_menu', 'my_plugin_menu');

function wodepress_custom_dashboard_output() {
    echo 'Welcome to My Custom Dashboard!';
}

拥有编辑权限的用户可见

原文

https://www.wowsoho.com/news/6009.html

相关推荐

  1. wordpress后台添加一个定义页面

    2024-03-23 20:24:04       21 阅读
  2. wordpress特定分类目录下的内容添加定义字段

    2024-03-23 20:24:04       19 阅读
  3. wpf 定义控件添加滚动条

    2024-03-23 20:24:04       34 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-23 20:24:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-23 20:24:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-23 20:24:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-23 20:24:04       20 阅读

热门阅读

  1. Linux ld链接器

    2024-03-23 20:24:04       17 阅读
  2. server2016datacenter改正式版

    2024-03-23 20:24:04       18 阅读
  3. 苍穹外卖Day3碰到的元注解

    2024-03-23 20:24:04       16 阅读
  4. Eureka注册中心

    2024-03-23 20:24:04       19 阅读
  5. C语言经典面试题目(二十)

    2024-03-23 20:24:04       19 阅读
  6. python之exec与eval

    2024-03-23 20:24:04       23 阅读
  7. Acwing 104. 货仓选址

    2024-03-23 20:24:04       16 阅读
  8. MySQL 中的事务和存储引擎

    2024-03-23 20:24:04       14 阅读
  9. 基于单片机的机电控制实训平台设计

    2024-03-23 20:24:04       21 阅读