傻大憨

为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!';
}

拥有编辑权限的用户可见

Published
Categorized as 建站知识 Tagged ,

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

WooCommerce定制开发的优势和使用盗版模板的风险

为什么说建WooCommerce独立站时一定要定制,不要用模板,即使用模板,也要找模板的开发者购买,千万不要用盗版模板,盗版模板危害极大。

wordpress建站必备的函数大全

wordpress主题二次开发时常用到的函数

wordpress移除wp_head不常用代码

把不常用的代码移除,让wordpress快起来,想要非一样的感觉,可以试试。

WordPress外贸整站源码解析与应用技巧分享

  开源软件的魅力在于它的灵活性和可定制性。WordPress作为一款广受欢迎的开源建站工具,在外贸领域也有着… Continue reading WordPress外贸整站源码解析与应用技巧分享

WordPress外贸网站建设的核心要素与实战案例

  在全球数字化时代,WordPress外贸网站成为企业拓展国际市场的重要工具。本文将深入探讨成功建设Word… Continue reading WordPress外贸网站建设的核心要素与实战案例

WordPress外贸建站教程分享

  在数字化时代,拥有一个强大的在线存在对于外贸业务至关重要。WordPress作为一个强大且用户友好的建站平… Continue reading WordPress外贸建站教程分享