Opened 8 years ago
Last modified 8 years ago
#39351 new defect (bug)
Passing 'none' to menu_icon of custom post type displays broken image in admin menu
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | minor | Version: | |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description
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.
Attachments (1)
Change History (9)
#3
@
8 years ago
4 month and not a single reaction although I have provided a patch is strange. Can someone please comment on this issue? What can I do to get the bug fixed?
#4
@
8 years ago
menu.patch Applies cleanly.
#5
@
8 years ago
- Milestone changed from Awaiting Review to 4.8
- Severity changed from major to minor
- Version 4.7 deleted
Moving to the milestone for consideration.
Note that the patch would need to be cleaned up a bit as we do not write multi-line comments like this. Also, backward compatibility needs to be considered.
Fix for custom post type menu_icon with value 'none' or 'div'