Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#18853 closed defect (bug) (fixed)

Menus Admin Screen Doesn't Accept Body Classes

Reported by: johnonolan's profile JohnONolan Owned by: dd32's profile dd32
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.3
Component: Administration Keywords: has-patch
Focuses: Cc:


This is going to be a hazy bug report, because it's at the outer limits of my technical ability, but:

Using this code

function my_admin_body_class( $classes ) {
	if ( is_admin() ) {
		$classes .= 'extra-class';
	return $classes;
add_filter('admin_body_class', 'my_admin_body_class');

I can add a class of "extra-class" to the admin body tag on every single page... except Appearance > Menus. Where the class doesn't get inserted at all.

I'm seeing this both in 3.2 and latest trunk. Apologies if this is something I'm doing wrong... like I say - outer limits.

Attachments (3)

18853.patch (613 bytes) - added by SergeyBiryukov 13 years ago.
18853.2.patch (731 bytes) - added by johnbillion 13 years ago.
18853.3.patch (1.2 KB) - added by SergeyBiryukov 13 years ago.
Fixes admin_body_class on Widgets screen as well

Download all attachments as: .zip

Change History (10)

#1 @johnbillion
13 years ago

Confirmed. The culprit is lines 435-440 in wp-admin/nav-menus.php which is treating admin_body_class as an action instead of a filter and not returning anything.

#2 @johnbillion
13 years ago

  • Keywords has-patch added; needs-patch removed

Damnit, beaten by Sergey ;-)

#3 @SergeyBiryukov
13 years ago

Same for Widgets screen in the accessibility mode:

A workaround could be calling the function with a later priority and with a whitespace in the string:

function my_admin_body_class( $classes ) {
	if ( is_admin() ) {
		$classes .= ' extra-class';
	return $classes;
add_filter('admin_body_class', 'my_admin_body_class', 11);

#4 @dd32
13 years ago

  • Milestone changed from Awaiting Review to 3.3

Geeze, SergeyBiryukov even beats me these days!

I've just gone through checking this whilst you guys were busy posting, Widgets and Menu's are the only location which overwrites, menu uses add_action rather than add_filter and iframe's don't get the admin_body_class filter at all (and are missing the wp-admin class too)

#5 @dd32
13 years ago

(no need to patch the iframe code btw, I've got it changed already!)

#6 @JohnONolan
13 years ago

You guys are all insanely quick. Also - I'm glad I'm not a complete moron after all. Well, you know, at least in this context.

13 years ago

Fixes admin_body_class on Widgets screen as well

#7 @dd32
13 years ago

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

In [18882]:

Fix admin_body_class filter for Menu's and Widgets pages, Include the filter in Iframe's. Props SergeyBiryukov & johnbillion. Fixes #18853

Note: See TracTickets for help on using tickets.