Make WordPress Core


Ignore:
Timestamp:
07/15/2026 04:25:35 AM (2 months ago)
Author:
wildworks
Message:

Icons: Add APIs for collection and icon registration

Introduces a set of public APIs for registering icon collections and individual icons, allowing themes and plugins to register icons for consistent use across the block editor and the wider WordPress admin.

  • Add the WP_Icon_Collections_Registry class, a singleton that manages the registration of icon collections. Each collection groups a set of icons under a namespace and is exposed through the REST API via the new WP_REST_Icon_Collections_Controller.
  • Update the WP_Icons_Registry class to allow registering custom icons through public register() and unregister() methods, surfaced through WP_REST_Icons_Controller.
  • Add four wrapper functions in icons.php: wp_register_icon_collection() and wp_unregister_icon_collection() for collections, and wp_register_icon() and wp_unregister_icon() for individual icons.
  • Register the default collections and icons through _wp_register_default_icon_collections() and _wp_register_default_icons(), both hooked to the init action.

Props mcsf, tyxla, wildworks.
See #64847.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/functions.php

    r61824 r62748  
    377377
    378378/**
     379 * After the init action has been run once, trying to re-register icon collections and icons
     380 * can cause errors. To avoid this, unhook the icon registration functions.
     381 *
     382 * @since 7.1.0
     383 */
     384function _unhook_icon_registration() {
     385        remove_action( 'init', '_wp_register_default_icon_collections', 0 );
     386        remove_action( 'init', '_wp_register_default_icons' );
     387}
     388tests_add_filter( 'init', '_unhook_icon_registration', 1000 );
     389
     390/**
    379391 * After the init action has been run once, trying to re-register connector settings can cause
    380392 * duplicate registrations. To avoid this, unhook the connector registration functions.
Note: See TracChangeset for help on using the changeset viewer.