Skip to content

Icons: Support keyword-based search in the icons registry - #13672

Closed
n8finch wants to merge 10 commits into
WordPress:trunkfrom
n8finch:backport/pr-82367
Closed

n8finch wants to merge 10 commits into
WordPress:trunkfrom
n8finch:backport/pr-82367

Conversation

@n8finch

@n8finch n8finch commented Sep 22, 2026 •

Copy link
Copy Markdown

Backports WordPress/gutenberg#82367.

Registered icons can now carry an optional keywords property, and icon search matches against it in addition to the icon's name and label. Previously an icon could only be found by its namespaced name or its human-readable label, so an icon whose common name differs from its label (for example core/menu, widely known as a "hamburger" menu) was undiscoverable in the editor's icon picker unless the user happened to guess the label.

This follows the same pattern as the label search added in [62551] for #64847.

Changes

WP_Icons_Registry

  • register() accepts an optional keywords property. It must be an array of strings; anything else triggers _doing_it_wrong() and the icon is not registered. Accepted keywords are passed through sanitize_text_field().
  • New protected icon_matches_search() encapsulates the match, testing the search term case-insensitively against the icon's name, label, and keywords.
  • get_registered_icons() delegates to it, replacing the inlined name/label comparison.

REST API (WP_REST_Icons_Controller)

  • keywords is added to the item schema as a read-only array of strings.
  • The field is always present in a response, defaulting to an empty array for icons registered without keywords, so clients that filter locally do not have to special-case its absence.

Core icon manifest

  • _wp_register_default_icons() passes a manifest entry's keywords through to wp_register_icon().
  • src/wp-includes/assets/icon-library-manifest.php is regenerated from the Gutenberg branch, adding localized keywords to all 88 core icons. Keywords use the icon keyword translation context, matching the existing icon label context.

Testing instructions

Automated:

npm run test:php -- --test-suffix wpIconsRegistry.php,wpRestIconsController.php tests/phpunit/tests/icons

Eight new test methods cover registration with and without keywords, rejection of non-string and non-array values (seven data-provided cases), case-insensitive keyword matching, keyword search through the REST endpoint, and the empty-array default. The full icons group passes: 131 tests, 518 assertions.

Manual testing requires the update to Gutenberg plugin: WordPress/gutenberg#82367

Trac ticket: https://core.trac.wordpress.org/ticket/66158

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Diagnosing failures in the initial backport commits, regenerating the icon manifest from the Gutenberg branch, correcting the REST controller's keywords handling, removing a test that covered a plugin-only code path with no Core equivalent, and aligning docblocks with the Inline Documentation Standards. I reviewed every change, ran the test suite, and take responsibility for the result.


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.

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props n8finch, wildworks.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@n8finch n8finch changed the title Backport/pr 82367 Backport PR #82367 Sep 22, 2026
@n8finch n8finch changed the title Backport PR #82367 Editor: Sync Gutenberg PR 82367 Sep 23, 2026
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@t-hamano t-hamano changed the title Editor: Sync Gutenberg PR 82367 Icons: Support keyword-based search in the icons registry Sep 23, 2026
Co-Authored-By: Claude <noreply@anthropic.com>

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I believe the Gutenberg implementation has been correctly backported to core. In 3596cc0, I added the ticket number to the test, which is standard practice when adding unit tests to core.

Comment thread src/wp-includes/class-wp-icons-registry.php Outdated
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
@t-hamano

Copy link
Copy Markdown
Contributor

I re-tested this PR and confirmed that all the feedback from the Gutenberg PR (WordPress/gutenberg#76481) has been properly backported here 👍

wporg-sync pushed a commit that referenced this pull request Sep 29, 2026
Registered icons can now define optional search keywords, and icon search in the registry and the REST API matches them as well as the icon's name and label.

Developed in: #13672

Props n8finch, tayyiba66, wildworks.
Fixes #66158.


git-svn-id: https://develop.svn.wordpress.org/trunk@63999 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 63999
GitHub commit: 3ffb1df

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Sep 29, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Sep 29, 2026
Registered icons can now define optional search keywords, and icon search in the registry and the REST API matches them as well as the icon's name and label.

Developed in: WordPress/wordpress-develop#13672

Props n8finch, tayyiba66, wildworks.
Fixes #66158.

Built from https://develop.svn.wordpress.org/trunk@63999


git-svn-id: http://core.svn.wordpress.org/trunk@63162 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.

2 participants