获取Wordpress中所有可用的管理页面 [英] Get all available admin pages in Wordpress

查看:81
本文介绍了获取Wordpress中所有可用的管理页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Wordpress中创建一个包含所有可用管理页面的下拉列表:

I need to create a dropdown with all available admin pages in Wordpress:

Dashboard -> /wp-admin/index.php
Posts -> /wp-admin/edit.php
Media -> /wp-admin/upload.php
...
etc
...

我可以手动完成,但是我想获取具有一阶菜单的特定插件链接:

I can do it manually but I would like get the specific plugins links that have first order menu:

My plugin -> /wp-admin/admin.php?page=my-plugin


推荐答案

该信息存储在全局 $ menu $ submenu 变量中(尽管仅在以下位置可用)

That information is stored in the global $menu and $submenu variables (though they're only available in the admin screens, of course).

看看 menu-header.php中的_wp_menu_output函数,以了解WordPress如何使用它们。

Have a look at the _wp_menu_output function in menu-header.php to see how WordPress uses them.

您还需要考虑用户的权限。请参阅current_user_can 函数的用法。 header.php#L36 rel = nofollow> _ wp_menu_output 。

You'll need to consider the user's permissions too. See the usages of the current_user_can function in _wp_menu_output.

这篇关于获取Wordpress中所有可用的管理页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆