Conversation
Merge the core icon store (`root/icon` REST entity registered by
`wp_register_icon`) into `useIcons`/`useIcon` on top of the internal
`registerIcons` store. Each core record is flattened to the picker's
`{ source, name, label, iconSet }` shape and deduped by `iconSet` + name,
with the internal store winning on a collision.
Feature-detected by entity presence, so WordPress below 7.1 (where the
`root/icon` entity is absent) falls back to the internal store alone. The
picker UI is untouched: it already consumes the flattened list.
|
🎉 A new testing version of this package has been published to NPM. You can install it with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
<IconPicker>,<Icon>, and<IconPickerToolbarButton>now read the WordPress 7.1 core icon store in addition to the internalregisterIconsstore.useIcons/useIconmerge icons fromgetEntityRecords('root', 'icon')on top of the internal store. Each core record is flattened to the picker's{ source, name, label, iconSet }shape — the<collection>/prefix is stripped from the name and the collection becomes theiconSet. The list is deduped byiconSet+name, with the internal store winning on a collision so an explicitregisterIconsentry overrides a core-registered icon of the same name.The read is feature-detected by entity presence: on WordPress below 7.1 the
root/iconentity is absent, so the hooks fall back to the internal store alone. The picker UI is unchanged — it already consumes the flattened list.registerIconsis documented as legacy on WordPress 7.1+ in favor ofwp_register_icon(), which comes with kses sanitization and REST exposure.Closes #411.
Verification
Tested in the editor on WordPress 7.1:
getEntityRecords('root', 'icon')returns the core collection (88 icons) in the expected record shape.core/arrow-down-left) is reachable through the picker search and renders the core store's SVG.