Skip to content

feat(icon-picker): read the WordPress 7.1 core icon store - #414

Open
s3rgiosan wants to merge 2 commits into
developfrom
feature/411-core-icon-store
Open

s3rgiosan wants to merge 2 commits into
developfrom
feature/411-core-icon-store

Conversation

@s3rgiosan

Copy link
Copy Markdown
Member

Description

<IconPicker>, <Icon>, and <IconPickerToolbarButton> now read the WordPress 7.1 core icon store in addition to the internal registerIcons store.

useIcons / useIcon merge icons from getEntityRecords('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 the iconSet. The list is deduped by iconSet + name, with the internal store winning on a collision so an explicit registerIcons entry overrides a core-registered icon of the same name.

The read is feature-detected by entity presence: on WordPress below 7.1 the root/icon entity is absent, so the hooks fall back to the internal store alone. The picker UI is unchanged — it already consumes the flattened list.

registerIcons is documented as legacy on WordPress 7.1+ in favor of wp_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.
  • Merged list = 200 internal + 88 core, no collisions → 288.
  • A core-only icon (core/arrow-down-left) is reachable through the picker search and renders the core store's SVG.
  • Unit tests cover the mapping, prefix stripping, merge/dedup, and feature detection (WP < 7.1 and resolving states).

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.
@github-actions

Copy link
Copy Markdown

🎉 A new testing version of this package has been published to NPM. You can install it with npm install @10up/block-components@testing-414

@cypress

cypress Bot commented Sep 10, 2026

Copy link
Copy Markdown

10up Block Components    Run #1082

Run Properties:  status check failed Failed #1082  •  git commit 93f2344ff2: docs(register-icons): mark registerIcons as legacy on WP 7.1+
Project 10up Block Components
Branch Review feature/411-core-icon-store
Run status status check failed Failed #1082
Run duration 13m 24s
Commit git commit 93f2344ff2: docs(register-icons): mark registerIcons as legacy on WP 7.1+
Committer Sérgio Santos
View all properties for this run ↗︎

Test results
Tests that failed  Failures 12
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 23
Tests that passed  Passing 0
View all changes introduced in this branch ↗︎

Tests for review

Failed  ColorSettings.spec.js • 1 failed test

View Output

Test Artifacts
ColorSettings > Allows the user to pick the block and displays it Test Replay Screenshots
Failed  Counter.spec.js • 1 failed test

View Output

Test Artifacts
Counter > Allows the user to pick the block and displays it Test Replay Screenshots
Failed  IconPicker.spec.js • 1 failed test

View Output

Test Artifacts
IconPicker > allows the user to use the post picker to change an icon and displays it Test Replay Screenshots
Failed  Image.spec.js • 1 failed test

View Output

Test Artifacts
Image > allows the user to pick an image from the media library and displays it inline Test Replay Screenshots
Failed  Link.spec.js • 1 failed test

View Output

Test Artifacts
Link > allows the editor to pick a link directly inline Test Replay Screenshots

The first 5 failed specs are shown, see all 11 specs in Cypress Cloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IconPicker: support the WordPress 7.1 core icon store (wp/v2/icons)

1 participant