WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#8596 closed defect (bug) (duplicate)

Submenu highlighting in ACP By URI/Query to highlight correctly for some plugins

Reported by: ixiter Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

When a plugin creates an own Menu with own SubMenus in the ACP, and uses links with the same filename but different parameters for the SubMenu entries, the highlighting for the "current" page fails for these SubMenus.
You can reproduce this bug with the statpress plugin. Submenus will not be highlighted. Always and only the "Overview" Submenu is highlighted!

In wp-admin/menu-header.php the "current" status of an item is just chosen from plugin name and plugin filename. The filename is taken from the page parameter from the URI. Other parameters are ignored. This causes the bug.
My patch compares the URI Parameters with $sub_item[2], if there is more than one parameter, instead of the filename only. That way also additional parameters with same filenames are recognized and teh SubMenus are highlighted correctly.

File wp-admin/menu-header.php
FIND: (Lines 97 and 98)

if ( !current_user_can($sub_item[1]) )
continue;

INSERT AFTER:

$params = substr($_SERVER['QUERY_STRING'], 5); // remove the 'page='

FIND: (Line 110)

} else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($item[2]) || ($item[2] == $self))) || (!isset($plugin_page) && $self == $sub_item[2]) ) {

REPLACE WITH:

} else if ( (isset($plugin_page) && ($params == '' && $plugin_page == $sub_item[2] || $params != '' && $params == $sub_item[2]) && (!file_exists($item[2]) || ($item[2] == $self))) || (!isset($plugin_page) && $self == $sub_item[2]) ){

Change History (1)

comment:1 @ryan7 years ago

  • Milestone 2.8 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #8597

Note: See TracTickets for help on using tickets.