-
Notifications
You must be signed in to change notification settings - Fork 4.8k
SVG Icon API: Iteration for WordPress 7.1 #75715
Copy link
Copy link
Open
Labels
[Block] IconAffects the Icon blockAffects the Icon block[Feature] IconsRelated to Icon registration API and Icon REST APIRelated to Icon registration API and Icon REST API[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] IterationScoped iteration of an effort from a tracking issue or overview issue ideally for a major release.Scoped iteration of an effort from a tracking issue or overview issue ideally for a major release.
Metadata
Metadata
Assignees
Labels
[Block] IconAffects the Icon blockAffects the Icon block[Feature] IconsRelated to Icon registration API and Icon REST APIRelated to Icon registration API and Icon REST API[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] IterationScoped iteration of an effort from a tracking issue or overview issue ideally for a major release.Scoped iteration of an effort from a tracking issue or overview issue ideally for a major release.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Important Issues and PRs:
We have stabilized three core features and shipped them in 7.0 Beta1:
WP_Icons_Registryclass: The singleton class that loads core SVG icons from a manifest file, stores them, and exposes methods to check registration and retrieve icon data and content. There is currently no way to register a custom icon.WP_REST_Icons_Controller: The REST API controller that exposes the icon registry overwp/v2/icons, letting the editor list icons and fetch a single icon by name.core/icon): The core block that retrieves a list of icons from the endpoint and lists them in a modal. The selected icon name is saved as an attribute, and the content is rendered server-side via the icon registry.To make the Icon API more robust and extensible, I believe the following features are necessary:
Icon registry enhancements
register_icon()functionunregister_icon()functioncore-iconstheme support: This is similar to thecore-block-patternstheme support: if this support is disabled, all core icons will not be registered.sanitize_svg()instead.Icons Registry: improve SVG sanitizer #75550
core/. If we allow custom icon registration in the future, we will need to strictly check that the icon name follows the{namespace/icon-name}format.Icons: Enforce strict name validation in
registermethod #76079REST API enhancements
searchparameter, but only thenamefield is referenced. We could also reference thelabelfield and an optionalkeywordsfield. Icons API: Support searching in labels; extend classes post-7.0 work #75878Category SupportSimilar to block patterns, it should be possible to support categories: consumers will want to group icon sets based on their own brand.Create a registry likeWP_Icon_Categories_RegistryCreate an endpoint likeWP_REST_Icons_Categories_ControllerCreate public APIs:register_icon_category()functionunregister_icon_category()functionCollection Support
Similar to Font Library, it should be possible to support collection: consumers will want to group icon sets based on their own brand.
WP_Icon_Colloections_RegistryWP_REST_Icons_Colloections_Controllerwp_register_icon_collection()functionwp_unregister_icon_collection()function_wp_register_default_icon_collectionsfunctionCreate Icon Picker Modal component
DataViewPicker. (ref) Perhaps it should be possible to add a component likeIconPickerModalto the@wordpress/block-editorpackage and load it from a block. This icon picker should be useful for blocks other than the Icon block as well.DataViewsPickerbased UIIconPickerModalinto block-editor for reusability #76787Icon block enhancements
Customizable icon support for other blocks
Some icons render their own hard-coded SVG content or symbols. Make those icons selectable via the Icon API.
+symbol)Inline SVG icon (Inline format)