[wp-trac] [WordPress Trac] #39351: Passing 'none' to menu_icon of custom post type displays broken image in admin menu

WordPress Trac noreply at wordpress.org
Tue Dec 20 22:39:44 UTC 2016


#39351: Passing 'none' to menu_icon of custom post type displays broken image in
admin menu
-------------------------------+-----------------------------
 Reporter:  mensmaximus        |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  4.7
 Severity:  normal             |   Keywords:
  Focuses:  administration     |
-------------------------------+-----------------------------
 According to the inline documentation of class WP_Post_Type you have to
 pass 'none' for the menu_icon parameter to leave div.wp-menu-image empty
 to be able to add an icon via CSS.

 However passing none (or div) as menu_icon while registering a post type
 result in a broken image because instead of 'none' you get 'http://none'.

 The following condition in line 120 of menu-header.php does not match:

 {{{
 if ( 'none' === $item[6] || 'div' === $item[6] ) {
         $img = '<br />';
 }
 }}}

 The conditional statement in line 103 of /wp-admin/menu.php url escapes
 any value of menu_icon that is neither a dashicons class nor a svg data:


 {{{
 if ( 0 === strpos( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,' )
 || 0 === strpos( $ptype_obj->menu_icon, 'dashicons-' ) ) {
                 $menu_icon = $ptype_obj->menu_icon;
 } else {
                 $menu_icon = esc_url( $ptype_obj->menu_icon );
 }
 }}}

 To make 'none' and 'div' (deprecated) work as documented either the first
 condition has to be extended or an additional elseif statement has to be
 included. I have opted for the second statement for better readability and
 documentation.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39351>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list