获取Wordpress中所有可用的管理页面 [英] Get all available admin pages in 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.
您还需要考虑用户的权限。请参阅
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屋!