Icons: Allow icons to ship to WordPress Core without exposing them in the Icon block - #82634
Icons: Allow icons to ship to WordPress Core without exposing them in the Icon block #82634fushar wants to merge 2 commits into
Conversation
🤖 PR meta 🤖📦 Bundle sizeSize Change: 0 B Total Size: 8.06 MB
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
|
dc2e30a to
6ded051
Compare
public manifest property402e768 to
a087ca3
Compare
Marks the icons that WordPress/wordpress-develop#12270 adds to Core's icon library as `"public": false`: they are shipped and registered for server-side use, but stay out of the icons REST API and so out of the Icon block. brush, dashboard, link, media, page, pin, plugins, post, sites, tool, update `wordpress` is the twelfth icon that Core PR needs. It is already flagged by #82634, which introduces the non-public state and uses it as its first consumer, so it is not repeated here. `false` rather than `true` because these are admin chrome, not post content. Promoting an icon later is trivial; demoting one is a breaking change.
`public` in `packages/icons/src/manifest.json` becomes a tri-state:
- omitted: the icon stays in the JS library and is not shipped to core
- `true`: shipped to core and exposed through the icons REST API, which
makes it selectable in the Icon block
- `false`: shipped to core and registered, but hidden from the REST API.
Reachable server-side via `wp_get_icon()`.
Until now `public` was a build-time filter only, so an icon could not be
shipped to core without also appearing in the Icon block. The flag is now
carried into `manifest.php` (emitted only when `false`, so today's
generated file is unchanged) and honoured by the registry and the icons
REST controller.
`bin/build-plugin-zip.sh` needed a matching fix: `jq select(.public)` is
falsy for `false`, so a non-public icon would have kept its manifest entry
while its SVG was pruned from the WordPress Core build.
No icon data changes here.
a087ca3 to
fb610a2
Compare
Marks the icons that WordPress/wordpress-develop#12270 adds to Core's icon library as `"public": false`: they are shipped and registered for server-side use, but stay out of the icons REST API and so out of the Icon block. brush, dashboard, link, media, page, pin, plugins, post, sites, tool, update `wordpress` is the twelfth icon that Core PR needs. It is already flagged by #82634, which introduces the non-public state and uses it as its first consumer, so it is not repeated here. `false` rather than `true` because these are admin chrome, not post content. Promoting an icon later is trivial; demoting one is a breaking change.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Marks the icons that WordPress/wordpress-develop#12270 adds to Core's icon library as `"public": false`: they are shipped and registered for server-side use, but stay out of the icons REST API and so out of the Icon block. brush, dashboard, link, media, page, pin, plugins, post, sites, tool, update `wordpress` is the twelfth icon that Core PR needs. It is already flagged by #82634, which introduces the non-public state and uses it as its first consumer, so it is not repeated here. `false` rather than `true` because these are admin chrome, not post content. Promoting an icon later is trivial; demoting one is a breaking change.
Marks the icons that WordPress/wordpress-develop#12270 adds to Core's icon library as `"public": false`: they are shipped and registered for server-side use, but stay out of the icons REST API and so out of the Icon block. brush, dashboard, link, media, page, pin, plugins, post, sites, tool, update `wordpress` is the twelfth icon that Core PR needs. It is already flagged by #82634, which introduces the non-public state and uses it as its first consumer, so it is not repeated here. `false` rather than `true` because these are admin chrome, not post content. Promoting an icon later is trivial; demoting one is a breaking change.
| cd packages/icons/src | ||
| non_public_icons=$(comm -13 \ | ||
| <(jq -r "map(select(.public) | .filePath)[]" manifest.json | sort) \ | ||
| <(jq -r "map(select(.public != null) | .filePath)[]" manifest.json | sort) \ |
There was a problem hiding this comment.
Do we need better validation here? A "public": "false" typo would keep the SVG in the core zip .
scruffian
left a comment
There was a problem hiding this comment.
This looks good. One minor comment but nothing that should stop this merging.
Part of #82723
What
This PR makes the
publicproperty inpackages/icons/src/manifest.jsona tri-state, so an icon can be shipped to WordPress Core without also becoming selectable in the Icon block.Its new meaning as follows:
publicwp_get_icon()truefalseThis PR also adds
public: falseto thecore/wordpressicon as a proof of concept.Why
This implements the suggested solution from #79451. With this, we can have the admin screens to show certain icons via
wp_get_icon(), without allowing such icons to be selectable in the Icon block, as some icons might not be useful to use in a post content.How
Build
packages/icons/lib/generate-manifest-php.cjsreadsmanifest.jsonand generatesmanifest.php. Previously it only generated icons that havepublic: true. Now:public: false.public: falseas well inmanifest.php.Registry (WP_Icons_Registry[_Gutenberg])
It now allows
publicas accepted property. As a back-compat, if a plugin / code already registers icons withoutpublicproperty, it will be treated astrue.REST controller (WP_REST_Icons_Controller[_Gutenberg])
It skips icons which have explicit
public: false, in bothget_items()andget_icon():get_items(): the GB side already overrides and reimplements the parent function, so thepublic: falsecheck is added on bothWP_REST_Icons_ControllerandWP_REST_Icons_Controller_Gutenberg.get_icon(): the GB side hasn't overridden it yet, so we add one inWP_REST_Icons_Controller_Gutenberg, call the parent function, and return 404 if it haspublic: false.Testing Instructions
See the testing instructions in: #79451.
Use of AI Tools
I used Claude Code Opus to write and review these changes, then checked and validated the changes myself.