Admin: replace dashicons in admin bar and sidebar with @wordpress/icons#12270
Admin: replace dashicons in admin bar and sidebar with @wordpress/icons#12270fushar wants to merge 7 commits into
Conversation
Introduce a procedural wrapper around `WP_Icons_Registry` so themes and plugins can render any registered core icon as an inline SVG from PHP, mirroring the React `<Icon>` component. This bridges the gap for PHP contexts that otherwise depend on the deprecated dashicons font. `wp_get_icon()` looks up the icon content via the registry and uses `WP_HTML_Tag_Processor` to apply configurable `size` and `class` attributes, plus accessibility handling: a `label` produces `role="img"` and `aria-label`, while its absence marks the icon `aria-hidden="true"`. The function lives in a new `icons.php`, following the established registry-class-plus-procedural-API pairing used by connectors.php and abilities.php. Props ... Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The test file only covers wp_get_icon(); the_wp_icon() does not exist. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Align wp_get_icon() with the latest changes from the Gutenberg side (WordPress/gutenberg#78332): - Only set width/height when size is numeric, using absint(), so passing null leaves the SVG's intrinsic dimensions untouched. - Drop the fixed 'wp-icon' class and split the class argument on whitespace to support multiple space-separated class names. - Toggle accessibility attributes both ways: when a label is given, set role/aria-label and remove aria-hidden/focusable; otherwise set aria-hidden/focusable and remove role/aria-label. Update the unit tests accordingly. Co-Authored-By: Claude <noreply@anthropic.com>
|
Hi there! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
95e9293 to
9272a78
Compare
ec0faf9 to
6ec651a
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @1178653+wordpress-develop-pr-bot[bot]@users.noreply.github.com. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
cc-ing (maybe) interested parties :) @t-hamano @jasmussen @tyxla @scruffian @lucasmendes-design |
| // The value is base64-encoded data, so esc_attr() is used here instead of esc_url(). | ||
| $img_style = ' style="background-image:url(\'' . esc_attr( $item[6] ) . '\')"'; | ||
| $img_class = ' svg'; | ||
| } elseif ( str_starts_with( $item[6], 'core/' ) ) { |
There was a problem hiding this comment.
I am not 100% sure if this condition is sufficient to output the SVG icon from the registry. Open to alternatives 😬
|
These all appear to be solid like-for-like replacements, though I feel least supportive of the |
|
@jeffpaul Thanks for checking!
Yep, as noted in the PR description, I'm not sure about this as well.
You mean
But my worry is that the icon slug is not related to "site" at all. I would expect there is something like Another idea is to use this icon, to represent a "site switcher":
|
|
A few things from my end as I'm looking at this work:
|
|
@fushar yes the |


Trac ticket: https://core.trac.wordpress.org/ticket/65089
Warning
This PR is stacked on top of #12010. Please only review my commit: 6ec651a
Also, some icons were not already public, so they need to be made public, maybe as separate Gutenberg PR. See related: WordPress/gutenberg#79102.
This PR replaces the dashicons usage in admin bar and menu (sidebar) with
@wordpress/icons, via the newly-introducedwp_get_icon()function, which outputs an inline SVG to be rendered.New icon mapping
Admin bar
dashicons-wordpresscore/wordpressdashicons-menu-altcore/menudashicons-admin-multisitecore/griddashicons-dashboardcore/dashboarddashicons-admin-homecore/homeCustomize
dashicons-admin-appearancedashicons-admin-customizercore/brushdashicons-editcore/pencildashicons-pluscore/plusdashicons-admin-commentscore/commentdashicons-updatecore/updateCommand Palette
dashicons-searchcore/searchdashicons-admin-userscore/peopleAdmin menu (left sidebar)
For simplicity, only showing new items not present in the admin bar above.
dashicons-admin-postcore/postdashicons-admin-mediacore/mediadashicons-admin-linkscore/linkdashicons-admin-pagecore/pagedashicons-admin-pluginscore/pluginsdashicons-admin-toolscore/tooldashicons-admin-settingscore/settingsdashicons-admin-collapsecore/chevron-leftOpen questions
My Sitesicon. The closest thing that I think fits is thecore/gridicon (see screenshot below). Open to alternatives.Screenshots
WP Admin
WP Admin - Multisite
Frontend
Before
After
Mobile
Before
After
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.8
Used for: code generation, with my supervision.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.