WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#16204 reviewing enhancement

Add hooks to enable access to pages in the admin when the menu layout has been changed by plugin

Reported by: mikeschinkel Owned by: westi
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch
Focuses: Cc:

Description

This patch and ticket is a follow on to tickets #16048 and #16050 and indirectly related to this discussion on hackers: http://lists.automattic.com/pipermail/wp-hackers/2011-January/037129.html

This patch simply adds the following hooks, all within /wp-admin/includes/plugin.php.

  • menu_page_url
  • admin_page_parent
  • admin_page_title
  • plugin_page_hookname
  • user_can_access_admin_page

The patch does not attempt to unravel the many early exits of the various functions instead it simply redundantly adds the hooks at each exit point. As such it's backward compatibility can be reviewed simply by viewing the code.

The use-case for this patch is when the menus are not exactly in the format expected by WordPress (but instead desired by the client) it can sometimes take hours of trial and error to get the permissions to allow users access to the menus they should be allowed access to.

For example, if the first submenu page for a menu page is removed from the menu, even when it makes logical sense to the user WordPress currently does not allow that menu option to be viewed. These hooks would give plugin developers the ability to modify the menus and still enable users access to the pages they need access to.

Attachments (1)

admin-includes-plugin-hooks.diff (7.8 KB) - added by mikeschinkel 3 years ago.
Add hooks menu_page_url, admin_page_parent, admin_page_title, plugin_page_hookname and user_can_access_admin_page to /wp-admin/includes/plugin.php.

Download all attachments as: .zip

Change History (6)

mikeschinkel3 years ago

Add hooks menu_page_url, admin_page_parent, admin_page_title, plugin_page_hookname and user_can_access_admin_page to /wp-admin/includes/plugin.php.

comment:1 westi3 years ago

  • Owner set to westi
  • Status changed from new to reviewing

Before adding loads of extra hooks like this we should fully understand the use-case and how this isn't supported fully by the new menu removal apis

comment:2 mikeschinkel3 years ago

I've described the various issues I'm having with admin menus hgere:

To further elaborate the security on admin menus is somehow coupled directly to the values in either the $menu or $submenu arrays which is problematic when the client does not want a submenu page to duplicate the menu page. Honestly I battled with it for over 8 hours and at the end I still wasn't sure exactly what it was doing which is why I can't give you a more specific answer:

http://mikeschinkel.com/websnaps/skitched-20110114-050852.png

I just know that the admin menu is extremely difficult to get to work the way the clients want it and all I'm asking for are hooks so that I can make it work.

I thought hooks were the things we were supposed to ask for when we needed something, so we could make it "plugin territory?"

comment:3 mikeschinkel3 years ago

@westi - Maybe the way you can understand the requirement is to build the above menu yourself and see how close to impossible it is? Be sure to implement a special submenu option that needs to be highlight when loading a customized edit.php page and also whenb loading apost.php page, and make it so that security doesn't keep you from loading those pages. Make it happen without needing to use output buffering and without hacking core and I'll withdraw the request for these hooks and the ones on tickets #16048 and #16050.

comment:4 mikeschinkel3 years ago

I just reread what I wrote and realized I should make something clear; they above was not meant to be snarky but instead simply matter-of-fact.

comment:5 mikeschinkel3 years ago

A point to be considered; if only one hook here added it could handle most needs, and that would be a hook for: 'user_can_access_admin_page'.

Note: See TracTickets for help on using tickets.