[wp-trac] [WordPress Trac] #38902: get_admin_page_parent() returns empty string when a top level admin page has no children
WordPress Trac
noreply at wordpress.org
Tue Nov 22 06:45:04 UTC 2016
#38902: get_admin_page_parent() returns empty string when a top level admin page
has no children
----------------------------+-----------------------------
Reporter: Taeo | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 4.6.1
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
This is causing user_can_access_admin_page() to incorrectly return false
in some situations.
For example, I have a custom post type with a custom capability type. I
have a custom user role to which I've assigned the edit_ and edit_others_
primitive capabilities. This correctly gives users with this role access
to view and edit posts of this type.
However I needed these users to not be able to create new posts. I
discovered that the "Add New" links check for the create_posts capability
but create_posts is mapped to edit_posts by default. To get around this I
added a filter to add a separate create_posts capability which works
exactly as intended.
However, thats when I encountered the above bug. The
get_admin_page_parent() function now returns an empty string which in turn
causes isset( $_wp_menu_nopriv[$pagenow] ) on line 1717 of /wp-
admin/plugin.php to evaluate to true since $pagenow = edit.php and my user
does not have the default edit_posts capability - only the custom post
edit capability.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38902>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list