BUG: global $typenow forced to ‘post’ on edit.php admin pages
-
Greetings,
I am an author of a plugin that adds a sub-menu to the Posts dashboard menu.
add_submenu_page('edit.php', 'Re-order', 'Reorder', $capability, 're-order', 'print_order_page');
this sub-menu page is capability dependent and users can configure the plugin so as to give access to this page to roles other than an administrator.
The WP function
add_submenu_page
the proceeds hook the sub-menu page to the callback function. this hook is created by WP core and is associated with the current post type stored in theglobal $typenow
variable.For
post
, the hook is associated with the parent slugedit.php
and the$typenow=''
.For custom post types, the hook is associated with the parent slug
edit.php?post_type={$typenow}
.The Disable gutenberg inc/plugin-core.php file on line 177 forces the $typenow = ‘post’ on the edit.php page,
if ($pagenow === 'edit.php') { if (empty($typenow)) $typenow = 'post'; $post_type = $typenow; }
this causes WP to fail to detect that the current type is post, and therefore associates the current sub-menu hook with a custom post type, breaking the core functionality.
the above code is only called for amdin page requests from users have non-administrator roles.
- The topic ‘BUG: global $typenow forced to ‘post’ on edit.php admin pages’ is closed to new replies.