傻大憨

为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插件。你可以根据自己的需求扩展和定制插件的功能。请参考WordPress官方文档以获取更多关于插件开发的详细信息和钩子函数的用法。

wordpress做企业官网有什么优势

使用WordPress作为企业官网是一个明智的选择,具有许多优势和潜力。

wordpress禁止多地同时登录

wordpress禁止用户在不同地点同时登录,管理员除外。

如何在wordpress顶部header.php中引用css/bootstrap.css文件

在 WordPress 的 header.php 文件中引用 CSS 文件(如 bootstrap.css)是实现主题样式化的一种常见方式。以下是具体的步骤和代码示例

WordPress外贸建站服务的高效应用与管理

  在竞争激烈的国际市场,WordPress外贸建站服务不仅仅是一个网站的搭建,更是业务提升的关键。本文将分享… Continue reading WordPress外贸建站服务的高效应用与管理

WordPress外贸建站平台优势与特点一览

  在众多建站平台中,WordPress一直以其强大的功能和灵活性而备受欢迎。特别是在外贸行业,选择一个适合的… Continue reading WordPress外贸建站平台优势与特点一览