Make WordPress Core

Opened 4 months ago

Last modified 4 months ago

#58361 new defect (bug)

Passing 'none' as 'menu_icon' to 'register_post_type' is not working correctly

Reported by: andrewleap's profile andrewleap Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 6.2.1
Component: Administration Keywords: reporter-feedback
Focuses: Cc:

Description

The resultant menu item contains:

<img src="http://none" alt="">

This is presumably because

$menu_icon = esc_url( $ptype_obj->menu_icon );

was wrapped in esc_url in wp-admin/menu.php at some point, so it can no longer be correctly compared in wp-admin/menu-header.php with

 'none' === $item[6] || 'div' === $item[6] 

Attachments (2)

58361.diff (817 bytes) - added by andrewleap 4 months ago.
patch
58361.2.diff (823 bytes) - added by andrewleap 4 months ago.
forked from correct version

Download all attachments as: .zip

Change History (4)

@andrewleap
4 months ago

patch

@andrewleap
4 months ago

forked from correct version

This ticket was mentioned in Slack in #core-test by ironprogrammer. View the logs.


4 months ago

#2 @ironprogrammer
4 months ago

  • Keywords reporter-feedback added

Thanks for the report, @andrewleap, and welcome back to Trac!

register_post_type() expects that menu_icon is a URL, Dashicon, or base64-encoded SVG. Please see https://developer.wordpress.org/reference/functions/register_post_type/#menu_icon. Is your intent to not display any icon at all for the menu?

Background

esc_url( $ptype_obj->menu_icon ) has existed since https://core.trac.wordpress.org/browser/trunk/wp-admin/menu.php?rev=14097#L119, and provided a way to add a menu icon by URL.

Looking deeper into the intent behind wp-admin/menu-header.php's check for none or div (see r21877), it seems these values were to be assigned internally by wp-admin/menu.php in the case that menu_icon was null. That behavior has since evolved to display the default posts icon.

Note: See TracTickets for help on using tickets.