傻大憨

为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是一个关注跨境电商、创业话题的网站。

买WordPress主题自己搭建网站需要注意些什么

在选择和购买WordPress主题时,有很多需要注意的地方,以确保自己的网站能够顺利搭建并正常运行。

专业的WooCommerce模板定制服务商

WooCommerce作为一款广受欢迎的WordPress电子商务插件,为众多商家提供了搭建在线商店的便捷途径。

wordpress为不同页面调用不同头部header文件代码

不同页面调用不同的顶部header文件

WooCommerce商城主题的安全性决定跨境电商之路能不能更稳 更远

WooCommerce以其开源、灵活、功能强大的特点,成为众多商家进军电商领域的首选工具。然而,在搭建WooCommerce商城的过程中,一个经常被忽视却至关重要的问题,就是WooCommerce商城主题的安全性。

海归创业者喜欢用WordPress搭建公司官网

随着全球化的推进和科技的飞速发展,越来越多的海归创业者选择回国发展,他们不仅带回了丰富的国际经验和资源,也带来… Continue reading 海归创业者喜欢用WordPress搭建公司官网

把WordPress网站文章时间格式改为“几分钟前”

刚才访问一个网站时,发现这个网站文章发布时间并不是直接显示为具体时间,而是显示为“几分钟前”,大半夜的,不可能那么多文章都是几分钟前发布的,于是找了一下相关的教程,发现要实现这个挺简单的。