From ee461f010a87d806d31367d047a0d20804a80dde Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 5 Dec 2023 13:37:52 +0000 Subject: [PATCH] Administration: Don't unnecessarily escape `none` or `div` in the admin menu. This matches a similar conditional in `wp-admin/menu-header.php`, where these values are handled as special cases and don't output the default menu image so that an icon could be added to `div.wp-menu-image` as CSS background. Follow-up to [9578], [21877], [26664]. Props andrewleap, ironprogrammer, azaozz. Fixes #58361. git-svn-id: https://develop.svn.wordpress.org/trunk@57159 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/menu.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/menu.php b/src/wp-admin/menu.php index 567af4ae40..71fd94b2e3 100644 --- a/src/wp-admin/menu.php +++ b/src/wp-admin/menu.php @@ -127,8 +127,11 @@ foreach ( array_merge( $builtin, $types ) as $ptype ) { $menu_icon = 'dashicons-admin-post'; if ( is_string( $ptype_obj->menu_icon ) ) { - // Special handling for data:image/svg+xml and Dashicons. - if ( str_starts_with( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' ) || str_starts_with( $ptype_obj->menu_icon, 'dashicons-' ) ) { + // Special handling for an empty div.wp-menu-image, data:image/svg+xml, and Dashicons. + if ( 'none' === $ptype_obj->menu_icon || 'div' === $ptype_obj->menu_icon + || str_starts_with( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' ) + || str_starts_with( $ptype_obj->menu_icon, 'dashicons-' ) + ) { $menu_icon = $ptype_obj->menu_icon; } else { $menu_icon = esc_url( $ptype_obj->menu_icon );