Skip to content

Commit

Permalink
Administration: Don't unnecessarily escape none or div in the adm…
Browse files Browse the repository at this point in the history
…in 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
  • Loading branch information
SergeyBiryukov committed Dec 5, 2023
1 parent 7f0b940 commit ee461f0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/wp-admin/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,11 @@

$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 );
Expand Down

0 comments on commit ee461f0

Please sign in to comment.