[wp-trac] [WordPress Trac] #55539: add_menu_page no longer renders base64 encoded SVG icon
WordPress Trac
noreply at wordpress.org
Thu Apr 7 12:32:06 UTC 2022
#55539: add_menu_page no longer renders base64 encoded SVG icon
------------------------------+-----------------------------
Reporter: KProvance | Owner: SergeyBiryukov
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.0
Component: Administration | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch commit | Focuses: administration
------------------------------+-----------------------------
Changes (by mukesh27):
* keywords: has-patch => has-patch commit
* owner: (none) => SergeyBiryukov
* status: new => assigned
Comment:
Hi there!
Thank you for the ticket and patch.
PR looks fine to me.
**Testing for Trunk version**
1. Add the below code in theme function.php
{{{#!php
<?php
function register_menu_with_custom_svg_icon() {
//The icon in Base64 format
$icon_base64 =
'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI2LjEuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxhZ2VyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAyMCAyMCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMjAgMjA7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5zdDB7c3Ryb2tlOiNFMDEwMTA7c3Ryb2tlLXdpZHRoOjI7fQo8L3N0eWxlPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMCwyaDIwIE0wLDEwaDIwIE0wLDE4aDIwIi8+Cjwvc3ZnPgo=';
//The icon in the data URI scheme
$icon_data_uri = 'data:image/svg+xml;base64,' . $icon_base64;
add_menu_page(
'Example',
'Example',
'manage_options',
'example',
'',
$icon_data_uri,
);
}
add_action( 'admin_menu', 'register_menu_with_custom_svg_icon' );
}}}
2. Icon is not visible for menu item.
3. Apply PR
4. Icon shows fine.
''Note: We have to add comment so other committer or contributor do not
change it again.''
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55539#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list