Conversation
|
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. |
There was a problem hiding this comment.
Pull request overview
This PR adds icon category support to the Icons API to enable grouping/discovery of icons by category, including exposing registered categories via a new REST endpoint.
Changes:
- Added an icon categories registry and public wrapper functions for registering/unregistering categories.
- Added a REST controller and route for
/wp/v2/icons/categories, and extended the icons REST schema to expose an iconcategory. - Added
categorymetadata across icon manifests and updated the PHP manifest generation script.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/icons/src/manifest.php | Adds category metadata to the public icon manifest entries. |
| packages/icons/src/manifest.json | Adds category metadata for all icons in the source manifest. |
| packages/icons/lib/generate-manifest-php.cjs | Emits category into the generated PHP manifest. |
| lib/load.php | Loads the new registry/controller and category APIs for the WP 7.1 compat layer. |
| lib/compat/wordpress-7.1/rest-api.php | Registers the new icon categories REST routes alongside icons routes. |
| lib/compat/wordpress-7.1/icon-categories.php | Adds register_icon_category()/unregister_icon_category() and registers core categories on init. |
| lib/compat/wordpress-7.1/class-gutenberg-rest-icons-controller-7-1.php | Extends icons REST output/schema to include category. |
| lib/compat/wordpress-7.1/class-gutenberg-rest-icons-categories-controller-7-1.php | New REST controller for listing registered icon categories. |
| lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php | Adds category support when registering icons from the manifest. |
| lib/compat/wordpress-7.1/class-gutenberg-icon-categories-registry-7-1.php | New singleton registry to manage icon categories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public function prepare_item_for_response( $item, $request ) { | ||
| $keys = array( | ||
| 'name' => 'name', | ||
| 'label' => 'label', | ||
| 'content' => 'content', | ||
| 'category' => 'category', | ||
| ); | ||
| $data = array(); | ||
| foreach ( $keys as $item_key => $rest_key ) { | ||
| if ( isset( $item[ $item_key ] ) ) { | ||
| $data[ $rest_key ] = $item[ $item_key ]; | ||
| } | ||
| } | ||
|
|
||
| $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; | ||
| $data = $this->add_additional_fields_to_object( $data, $request ); | ||
| $data = $this->filter_response_by_context( $data, $context ); | ||
| return rest_ensure_response( $data ); |
| 'label' => $icon_data['label'], | ||
| 'filePath' => $icons_directory . $icon_data['filePath'], | ||
| 'category' => ! empty( $icon_data['category'] ) && is_string( $icon_data['category'] ) | ||
| ? $icon_data['category'] | ||
| : null, | ||
| ) |
| function gutenberg_register_icons_controller_endpoints() { | ||
| $icons_controller = new Gutenberg_REST_Icons_Controller_7_1(); | ||
| $icons_controller->register_routes(); | ||
|
|
||
| $icon_categories_controller = new Gutenberg_REST_Icons_Categories_Controller_7_1(); | ||
| $icon_categories_controller->register_routes(); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Thanks for the PR! In my opinion, many consumers will want to register multiple icons as their collections. That is, they should be structured like this: Collections (e.g. Google Fonts, Font Awesome) > Categories (e.g. Allows, Social) > Icons Therefore, I think we need an API for registering collections, rather than an API for registering categories. Please refer to this updated section. |
What?
Closes #75715 (Category Support)
Adds icon category support to the Icons API so consumers can group icons (including brand/group-based sets).
Why?
Icon consumers need a consistent way to group and discover icons by category, similar to block pattern categories.
How?
Added a dedicated icon categories registry (
Gutenberg_Icon_Categories_Registry_7_1similar toWP_Block_Pattern_Categories_Registry)Added a REST controller for icon categories (Gutenberg_REST_Icons_Categories_Controller_7_1)
Endpoints
GET /wp-json/wp/v2/iconsGET /wp-json/wp/v2/icons/categoriesNotes / Current Scope
Testing Instructions
/wp-json/wp/v2/iconsand verify icons are returned with category./wp-json/wp/v2/icons/categoriesand verify category objects are returned.Screenshots or screencast
Screen.Recording.2026-03-16.at.10.40.34.AM.mov