WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#6422 closed defect (bug) (fixed)

Admin Menu bug

Reported by: Denis-de-Bernardy Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.5
Component: Administration Keywords:
Focuses: Cc:

Description

I suspect this one will be a bit tricky... :)

If you create a theme with a file name that is included in the submenu already, then the menu no longer works as expected.

To reproduce: Create a theme with a file called widgets.php, include that file from the functions.php, and from that file, register an admin screen using:

add_submenu_page(
	'themes.php',
	__('Whatever'),
	__('Whatever'),
	'switch_themes',
	basename(__FILE__),
	'foobar'
	);

Upon doing so, wp-admin/widgets.php is no longer available -- that menu item points to themes.php?page=widgets.php instead.

I'm guessing this also works with plugins. I also vaguely recall a weird bug reported by Ozh that might be related to this one.

Change History (6)

comment:1 mrmist5 years ago

  • Keywords reporter-feedback added

I couldn't reproduce this accurately. Is it still a problem?

comment:2 Denis-de-Bernardy5 years ago

  • Keywords reporter-feedback removed

It is.

In function.php:

include dirname(__FILE__) . '/widgets.php';

In the theme's widgets.php file:

<?php
function foo() {
	add_submenu_page(
		'themes.php',
		__('Whatever'),
		__('Whatever'),
		'switch_themes',
		basename(__FILE__),
		'bar'
		);
}

function bar() {
	echo 'bar';
}

add_action('admin_menu', 'foo');
?>

Browse Appearance / Widgets -> It no longer is available.

Fixing it will likely be complex, as I'm guessing one would need to mess around with the way the menu and submenu global arrays are keyed.

comment:4 DD325 years ago

You know the simple way to solve this? Get people to stop using filenames for the 5th param and instead use a string, It looks prettier & Its guaranteed to work. but hmm.. Probably is related to #6478

comment:5 Denis-de-Bernardy5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

This seems fixed by Ryan's patches in #6478

comment:6 mtekk5 years ago

  • Milestone changed from 2.9 to 2.8
Note: See TracTickets for help on using tickets.