From 49dfee8c0e384abac5d92022f57e26733e76b2f0 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 21:23:56 +0900 Subject: [PATCH 01/10] Icons: Move REST API visibility from icons to collections --- ...wp-icon-collections-registry-gutenberg.php | 87 +++++++++++++ lib/class-wp-icons-registry-gutenberg.php | 18 +-- ...-icon-collections-controller-gutenberg.php | 61 +++++++++ ...ass-wp-rest-icons-controller-gutenberg.php | 21 ++-- lib/compat/wordpress-7.1/icons.php | 8 +- lib/compat/wordpress-7.1/rest-api.php | 9 -- lib/icons.php | 4 - lib/load.php | 2 + lib/rest-api.php | 9 ++ packages/icons/CHANGELOG.md | 2 - packages/icons/README.md | 8 +- packages/icons/lib/generate-manifest-php.cjs | 11 +- packages/icons/src/manifest.json | 33 ++--- packages/icons/src/manifest.php | 55 -------- ...lass-wp-icon-collections-registry-test.php | 110 ++++++++++++++++ phpunit/class-wp-icon-test.php | 34 +++++ ...class-wp-icons-registry-gutenberg-test.php | 6 +- .../class-wp-rest-icon-controller-test.php | 118 ++++++++++++++++-- 18 files changed, 453 insertions(+), 143 deletions(-) create mode 100644 lib/class-wp-icon-collections-registry-gutenberg.php create mode 100644 lib/class-wp-rest-icon-collections-controller-gutenberg.php diff --git a/lib/class-wp-icon-collections-registry-gutenberg.php b/lib/class-wp-icon-collections-registry-gutenberg.php new file mode 100644 index 00000000000000..8b3fe293f5171b --- /dev/null +++ b/lib/class-wp-icon-collections-registry-gutenberg.php @@ -0,0 +1,87 @@ +registered_collections[ $collection_slug ]['public'] = $public; + return true; + } + + /** + * Returns the shared registry instance, preserving existing collections. + * + * @return WP_Icon_Collections_Registry_Gutenberg The shared registry instance. + */ + public static function get_instance() { + if ( ! self::$instance instanceof self ) { + $original_registry = self::$instance; + $gutenberg_registry = new self(); + + if ( null !== $original_registry ) { + foreach ( $original_registry->get_all_registered() as $collection ) { + $slug = $collection['slug']; + unset( $collection['slug'] ); + $gutenberg_registry->register( $slug, $collection ); + } + } + + self::$instance = $gutenberg_registry; + } + + return self::$instance; + } +} + +/** + * Upgrades the shared collection registry before default collections are registered. + */ +function gutenberg_override_wp_icon_collections_registry() { + WP_Icon_Collections_Registry_Gutenberg::get_instance(); +} +add_action( 'init', 'gutenberg_override_wp_icon_collections_registry', -1 ); diff --git a/lib/class-wp-icons-registry-gutenberg.php b/lib/class-wp-icons-registry-gutenberg.php index baae1cec20dc60..39b2794ff83481 100644 --- a/lib/class-wp-icons-registry-gutenberg.php +++ b/lib/class-wp-icons-registry-gutenberg.php @@ -112,10 +112,6 @@ protected function __construct() {} * If not provided, the content will be retrieved from the `file_path` if set. * If both `content` and `file_path` are not set, the icon will not be registered. * @type string $file_path Optional. The full path to the file containing the icon content. - * @type bool $public Optional. Whether the icon is exposed through the REST API, and - * therefore selectable in the editor's Icon block. Non-public icons - * stay available to server-side code via {@see wp_get_icon()}. - * Default true. * } * @return bool True if the icon was registered with success and false otherwise. */ @@ -158,7 +154,7 @@ public function register( $icon_name, $icon_properties ) { return false; } - $allowed_keys = array_fill_keys( array( 'label', 'content', 'file_path', 'public' ), 1 ); + $allowed_keys = array_fill_keys( array( 'label', 'content', 'file_path' ), 1 ); foreach ( array_keys( $icon_properties ) as $key ) { if ( ! array_key_exists( $key, $allowed_keys ) ) { _doing_it_wrong( @@ -196,15 +192,6 @@ public function register( $icon_name, $icon_properties ) { return false; } - if ( isset( $icon_properties['public'] ) && ! is_bool( $icon_properties['public'] ) ) { - _doing_it_wrong( - __METHOD__, - __( 'Icon public property must be a boolean.', 'gutenberg' ), - '7.2.0' - ); - return false; - } - if ( ( ! isset( $icon_properties['content'] ) && ! isset( $icon_properties['file_path'] ) ) || ( isset( $icon_properties['content'] ) && isset( $icon_properties['file_path'] ) ) @@ -397,9 +384,6 @@ public static function get_instance() { } else { continue; } - if ( isset( $icon['public'] ) ) { - $icon_properties['public'] = $icon['public']; - } $gutenberg_registry->register( $icon['name'], $icon_properties ); } } diff --git a/lib/class-wp-rest-icon-collections-controller-gutenberg.php b/lib/class-wp-rest-icon-collections-controller-gutenberg.php new file mode 100644 index 00000000000000..2c749e3cf80f64 --- /dev/null +++ b/lib/class-wp-rest-icon-collections-controller-gutenberg.php @@ -0,0 +1,61 @@ +get_all_registered(); + foreach ( $collections as $collection ) { + if ( ! $collection['public'] ) { + continue; + } + $prepared_collection = $this->prepare_item_for_response( $collection, $request ); + $response[] = $this->prepare_response_for_collection( $prepared_collection ); + } + return rest_ensure_response( $response ); + } + + /** + * Retrieves a specific public icon collection. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. + */ + public function get_item( $request ) { + $collection = WP_Icon_Collections_Registry::get_instance()->get_registered( $request['slug'] ); + + if ( null !== $collection && ! $collection['public'] ) { + return new WP_Error( + 'rest_icon_collection_not_found', + sprintf( + /* translators: %s: Icon collection slug. */ + __( 'Icon collection not found: "%s".', 'gutenberg' ), + $request['slug'] + ), + array( 'status' => 404 ) + ); + } + + return parent::get_item( $request ); + } +} diff --git a/lib/class-wp-rest-icons-controller-gutenberg.php b/lib/class-wp-rest-icons-controller-gutenberg.php index 8ef4035921065a..faa9ae5791b127 100644 --- a/lib/class-wp-rest-icons-controller-gutenberg.php +++ b/lib/class-wp-rest-icons-controller-gutenberg.php @@ -97,9 +97,11 @@ public function get_collection_params() { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function get_items( $request ) { - $collection = $request->get_param( 'collection' ); + $collection = $request->get_param( 'collection' ); + $collections_registry = WP_Icon_Collections_Registry::get_instance(); + $registered_collection = null !== $collection ? $collections_registry->get_registered( $collection ) : null; - if ( null !== $collection && ! WP_Icon_Collections_Registry::get_instance()->is_registered( $collection ) ) { + if ( null !== $collection && ( null === $registered_collection || ! $registered_collection['public'] ) ) { return new WP_Error( 'rest_icon_collection_not_found', sprintf( @@ -116,10 +118,11 @@ public function get_items( $request ) { $icons = WP_Icons_Registry::get_instance()->get_registered_icons( $search ); foreach ( $icons as $icon ) { - if ( false === ( $icon['public'] ?? true ) ) { + if ( null !== $collection && ( ! isset( $icon['collection'] ) || $icon['collection'] !== $collection ) ) { continue; } - if ( null !== $collection && ( ! isset( $icon['collection'] ) || $icon['collection'] !== $collection ) ) { + $icon_collection = $collections_registry->get_registered( $icon['collection'] ); + if ( null === $icon_collection || ! $icon_collection['public'] ) { continue; } $prepared_icon = $this->prepare_item_for_response( $icon, $request ); @@ -132,8 +135,7 @@ public function get_items( $request ) { /** * Retrieves a specific icon from the registry. * - * Icons registered as non-public are reported as not found. Icons registered - * without an explicit `public` property are public. + * Icons belonging to non-public collections are reported as not found. * * @param string $name Icon name. * @return array|WP_Error Icon data on success, or WP_Error object on failure. @@ -141,7 +143,12 @@ public function get_items( $request ) { public function get_icon( $name ) { $icon = parent::get_icon( $name ); - if ( ! is_wp_error( $icon ) && false === ( $icon['public'] ?? true ) ) { + if ( is_wp_error( $icon ) ) { + return $icon; + } + + $collection = WP_Icon_Collections_Registry::get_instance()->get_registered( $icon['collection'] ); + if ( null === $collection || ! $collection['public'] ) { return new WP_Error( 'rest_icon_not_found', sprintf( diff --git a/lib/compat/wordpress-7.1/icons.php b/lib/compat/wordpress-7.1/icons.php index 8eec638e3ee23b..4e4f5ad6c2a91e 100644 --- a/lib/compat/wordpress-7.1/icons.php +++ b/lib/compat/wordpress-7.1/icons.php @@ -15,6 +15,10 @@ * * @type string $label Required. A human-readable label for the icon collection. * @type string $description Optional. A human-readable description for the icon collection. + * @type bool $public Optional. Whether the collection and its icons are exposed through + * the REST API and selectable in the editor's Icon block. Icons in + * non-public collections remain available via {@see wp_get_icon()}. + * Default true. * } * @return bool True if the icon collection was registered successfully, else false. */ @@ -52,10 +56,6 @@ function wp_unregister_icon_collection( $slug ) { * If not provided, the content will be retrieved from the `file_path` if set. * If both `content` and `file_path` are not set, the icon will not be registered. * @type string $file_path Optional. The full path to the file containing the icon content. - * @type bool $public Optional. Whether the icon is exposed through the REST API, and - * therefore selectable in the editor's Icon block. Non-public icons - * stay available to server-side code via {@see wp_get_icon()}. - * Default true. * } * @return bool True if the icon was registered successfully, else false. */ diff --git a/lib/compat/wordpress-7.1/rest-api.php b/lib/compat/wordpress-7.1/rest-api.php index 3b9b0671fe12b9..bd7acf7f608075 100644 --- a/lib/compat/wordpress-7.1/rest-api.php +++ b/lib/compat/wordpress-7.1/rest-api.php @@ -79,15 +79,6 @@ function gutenberg_allow_null_modified_wp_template_field() { } add_action( 'rest_api_init', 'gutenberg_allow_null_modified_wp_template_field' ); -/** - * Registers the Icon Collections Registry REST API routes. - */ -function gutenberg_register_icon_collections_controller_endpoints() { - $icon_collections_controller = new WP_REST_Icon_Collections_Controller(); - $icon_collections_controller->register_routes(); -} -add_action( 'rest_api_init', 'gutenberg_register_icon_collections_controller_endpoints' ); - /** * Overrides the REST controller for the attachment post type to add support * for filtering by multiple media types. diff --git a/lib/icons.php b/lib/icons.php index 03d1db97496874..6732ea0907ce36 100644 --- a/lib/icons.php +++ b/lib/icons.php @@ -69,10 +69,6 @@ function gutenberg_register_default_icons() { 'file_path' => $icons_directory . $icon_data['filePath'], ); - if ( isset( $icon_data['public'] ) ) { - $icon_args['public'] = $icon_data['public']; - } - wp_register_icon( 'core/' . $icon_name, $icon_args ); } } diff --git a/lib/load.php b/lib/load.php index c629b223f815f5..ef00a8477f2391 100644 --- a/lib/load.php +++ b/lib/load.php @@ -77,6 +77,8 @@ function gutenberg_is_experiment_enabled( $name ) { // Plugin specific code. require_once __DIR__ . '/class-wp-rest-global-styles-controller-gutenberg.php'; require_once __DIR__ . '/class-wp-rest-edit-site-export-controller-gutenberg.php'; + require_once __DIR__ . '/class-wp-icon-collections-registry-gutenberg.php'; + require_once __DIR__ . '/class-wp-rest-icon-collections-controller-gutenberg.php'; require_once __DIR__ . '/class-wp-icons-registry-gutenberg.php'; require_once __DIR__ . '/class-wp-rest-icons-controller-gutenberg.php'; require_once __DIR__ . '/rest-api.php'; diff --git a/lib/rest-api.php b/lib/rest-api.php index 529cff55cbc271..e8d95b9cb16d8b 100644 --- a/lib/rest-api.php +++ b/lib/rest-api.php @@ -45,3 +45,12 @@ function gutenberg_register_icon_controller_endpoints() { $icons_controller->register_routes(); } add_action( 'rest_api_init', 'gutenberg_register_icon_controller_endpoints' ); + +/** + * Registers the Icon Collections Registry REST API routes. + */ +function gutenberg_register_icon_collections_controller_endpoints() { + $icon_collections_controller = new WP_REST_Icon_Collections_Controller_Gutenberg(); + $icon_collections_controller->register_routes(); +} +add_action( 'rest_api_init', 'gutenberg_register_icon_collections_controller_endpoints' ); diff --git a/packages/icons/CHANGELOG.md b/packages/icons/CHANGELOG.md index 9cdebbf36222aa..64e84413a35e5a 100644 --- a/packages/icons/CHANGELOG.md +++ b/packages/icons/CHANGELOG.md @@ -9,8 +9,6 @@ ### Enhancements - Redraw a further 236 icons as stroke-based for variable stroke-width support, following the convention introduced in [#78808](https://github.com/WordPress/gutenberg/pull/78808), and refine the already stroke-based `image` and `commentAuthorAvatar` drawings. Most retain their original footprint; the table icons, `capturePhoto`, and `image` are slightly smaller, and several drawings in the final batch change by design. ([#82540](https://github.com/WordPress/gutenberg/pull/82540), [#82754](https://github.com/WordPress/gutenberg/pull/82754)) -- `manifest.json`: The `public` property is now a tri-state. Omitting it keeps an icon in the JS library only; `true` ships it to WordPress Core and exposes it through the icons REST API, making it selectable in the Icon block; `false` ships it and registers it in the `core` collection for server-side use via `wp_get_icon()`, while hiding it from the REST API and the Icon block. ([#82634](https://github.com/WordPress/gutenberg/pull/82634)) -- The `brush`, `dashboard`, `link`, `media`, `page`, `pin`, `plugins`, `sites`, `tool`, `update` and `wordpress` icons now ship to WordPress Core as non-public icons: they are registered in the `core` collection and stay available to server-side code via `wp_get_icon()`, but are not exposed through the icons REST API and are not selectable in the Icon block. ([#82634](https://github.com/WordPress/gutenberg/pull/82634), [#79451](https://github.com/WordPress/gutenberg/pull/79451)) ### Bug Fixes diff --git a/packages/icons/README.md b/packages/icons/README.md index ef49eb1d050c5a..c8a2c439d0b13a 100644 --- a/packages/icons/README.md +++ b/packages/icons/README.md @@ -50,10 +50,10 @@ To add a new icon to the library, follow these steps: - `slug`: The icon identifier (should match the SVG filename without the `.svg` extension) - `label`: The human-readable label for the icon. Use Title Case (for example, `My New Icon`). - `filePath`: The relative path to the SVG file (e.g., `library/my-new-icon.svg`) - - `public` (optional): Controls whether the icon is shipped to WordPress core, and if so how far it is exposed. **Important**: Once an icon ships, removing it is difficult, so carefully consider this field before setting it. - - Omit the field to keep the icon in the JS library only. It is not shipped to core. - - `true` ships the icon to core and exposes it through the SVG Icons API, which makes it selectable in the Icon block. - - `false` ships the icon to core and registers it for server-side use through `wp_get_icon()`, but hides it from the REST API and the Icon block. Use this for icons that belong to the admin UI rather than to post content, such as admin menu icons. + - `public` (optional): Set to `true` to ship the icon to WordPress Core and register it in the `core` collection. Omit it or set it to `false` to keep the icon in the JS library only. **Important**: Once an icon ships to WordPress Core, removing it is difficult, so carefully consider this field before setting it. + + This manifest property controls which icons ship to WordPress Core. REST API visibility is configured for the whole collection through the `public` argument of `wp_register_icon_collection()`, which defaults to `true`. Icons in non-public collections remain available to server-side code through `wp_get_icon()` but are not exposed through the REST API or selectable in the Icon block. + 4. **Do not edit `manifest.php`**: The `manifest.php` file is automatically generated from `manifest.json` by the build script. Do not edit it manually, as your changes will be overwritten when the build runs. After adding your icon, run `npm run build` to generate the TypeScript files and update `manifest.php`. diff --git a/packages/icons/lib/generate-manifest-php.cjs b/packages/icons/lib/generate-manifest-php.cjs index 5c940462c80e7e..8b33091f6f0b59 100644 --- a/packages/icons/lib/generate-manifest-php.cjs +++ b/packages/icons/lib/generate-manifest-php.cjs @@ -43,12 +43,9 @@ function generatePHPArray( manifest ) { const label = escapePHPString( item.label ); const filePath = escapePHPString( item.filePath ); - const publicEntry = - item.public === false ? "\n\t\t'public' => false," : ''; - return `${ key } => array( 'label' => _x( '${ label }', 'icon label', 'gutenberg' ), - 'filePath' => '${ filePath }',${ publicEntry } + 'filePath' => '${ filePath }', ),`; } ); @@ -59,14 +56,12 @@ ${ phpEntries.join( '\n' ) } /** * Generates manifest.php from manifest.json. - * Only includes icons which have the `public` key set. + * Only includes icons which have `public` set to true. */ async function generateManifestPHP() { const manifestJson = await readFile( MANIFEST_JSON_PATH, 'utf8' ); const manifest = JSON.parse( manifestJson ); - const includedIcons = manifest.filter( - ( item ) => typeof item.public === 'boolean' - ); + const includedIcons = manifest.filter( ( item ) => item.public === true ); const phpHeader = ` _x( 'Block Table', 'icon label', 'gutenberg' ), 'filePath' => 'library/block-table.svg', ), - 'brush' => array( - 'label' => _x( 'Brush', 'icon label', 'gutenberg' ), - 'filePath' => 'library/brush.svg', - 'public' => false, - ), 'calendar' => array( 'label' => _x( 'Calendar', 'icon label', 'gutenberg' ), 'filePath' => 'library/calendar.svg', @@ -146,11 +141,6 @@ 'label' => _x( 'Create', 'icon label', 'gutenberg' ), 'filePath' => 'library/create.svg', ), - 'dashboard' => array( - 'label' => _x( 'Dashboard', 'icon label', 'gutenberg' ), - 'filePath' => 'library/dashboard.svg', - 'public' => false, - ), 'desktop' => array( 'label' => _x( 'Desktop', 'icon label', 'gutenberg' ), 'filePath' => 'library/desktop.svg', @@ -219,20 +209,10 @@ 'label' => _x( 'Language', 'icon label', 'gutenberg' ), 'filePath' => 'library/language.svg', ), - 'link' => array( - 'label' => _x( 'Link', 'icon label', 'gutenberg' ), - 'filePath' => 'library/link.svg', - 'public' => false, - ), 'map-marker' => array( 'label' => _x( 'Map Marker', 'icon label', 'gutenberg' ), 'filePath' => 'library/map-marker.svg', ), - 'media' => array( - 'label' => _x( 'Media', 'icon label', 'gutenberg' ), - 'filePath' => 'library/media.svg', - 'public' => false, - ), 'menu' => array( 'label' => _x( 'Menu', 'icon label', 'gutenberg' ), 'filePath' => 'library/menu.svg', @@ -253,11 +233,6 @@ 'label' => _x( 'Next', 'icon label', 'gutenberg' ), 'filePath' => 'library/next.svg', ), - 'page' => array( - 'label' => _x( 'Page', 'icon label', 'gutenberg' ), - 'filePath' => 'library/page.svg', - 'public' => false, - ), 'paragraph' => array( 'label' => _x( 'Paragraph', 'icon label', 'gutenberg' ), 'filePath' => 'library/paragraph.svg', @@ -274,16 +249,6 @@ 'label' => _x( 'People', 'icon label', 'gutenberg' ), 'filePath' => 'library/people.svg', ), - 'pin' => array( - 'label' => _x( 'Pin', 'icon label', 'gutenberg' ), - 'filePath' => 'library/pin.svg', - 'public' => false, - ), - 'plugins' => array( - 'label' => _x( 'Plugins', 'icon label', 'gutenberg' ), - 'filePath' => 'library/plugins.svg', - 'public' => false, - ), 'plus' => array( 'label' => _x( 'Plus', 'icon label', 'gutenberg' ), 'filePath' => 'library/plus.svg', @@ -340,11 +305,6 @@ 'label' => _x( 'Shuffle', 'icon label', 'gutenberg' ), 'filePath' => 'library/shuffle.svg', ), - 'sites' => array( - 'label' => _x( 'Sites', 'icon label', 'gutenberg' ), - 'filePath' => 'library/sites.svg', - 'public' => false, - ), 'star-empty' => array( 'label' => _x( 'Star Empty', 'icon label', 'gutenberg' ), 'filePath' => 'library/star-empty.svg', @@ -389,16 +349,6 @@ 'label' => _x( 'Tip', 'icon label', 'gutenberg' ), 'filePath' => 'library/tip.svg', ), - 'tool' => array( - 'label' => _x( 'Tool', 'icon label', 'gutenberg' ), - 'filePath' => 'library/tool.svg', - 'public' => false, - ), - 'update' => array( - 'label' => _x( 'Update', 'icon label', 'gutenberg' ), - 'filePath' => 'library/update.svg', - 'public' => false, - ), 'upload' => array( 'label' => _x( 'Upload', 'icon label', 'gutenberg' ), 'filePath' => 'library/upload.svg', @@ -407,9 +357,4 @@ 'label' => _x( 'Verse', 'icon label', 'gutenberg' ), 'filePath' => 'library/verse.svg', ), - 'wordpress' => array( - 'label' => _x( 'WordPress', 'icon label', 'gutenberg' ), - 'filePath' => 'library/wordpress.svg', - 'public' => false, - ), ); diff --git a/phpunit/class-wp-icon-collections-registry-test.php b/phpunit/class-wp-icon-collections-registry-test.php index ad8e7be5bf1d8c..2b8b96340ee68b 100644 --- a/phpunit/class-wp-icon-collections-registry-test.php +++ b/phpunit/class-wp-icon-collections-registry-test.php @@ -88,6 +88,116 @@ public function test_register_collection( $slug ) { $this->assertTrue( $this->collections->is_registered( $slug ) ); } + /** + * Should register collections as public by default. + */ + public function test_register_collection_defaults_to_public() { + $this->collections->register( 'my-collection', array( 'label' => 'My Collection' ) ); + + $this->assertTrue( $this->collections->get_registered( 'my-collection' )['public'] ); + } + + /** + * Should preserve explicitly configured collection visibility. + * + * @dataProvider data_boolean_public_properties + * + * @param bool $is_public Whether the collection is public. + */ + public function test_register_collection_accepts_boolean_public_property( $is_public ) { + $result = $this->collections->register( + 'my-collection', + array( + 'label' => 'My Collection', + 'public' => $is_public, + ) + ); + + $this->assertTrue( $result ); + $this->assertSame( $is_public, $this->collections->get_registered( 'my-collection' )['public'] ); + } + + /** + * Provides supported collection visibility values. + * + * @return array[] + */ + public function data_boolean_public_properties() { + return array( + 'public collection' => array( true ), + 'non-public collection' => array( false ), + ); + } + + /** + * Should reject collection visibility values that are not booleans. + * + * @dataProvider data_non_boolean_public_properties + * @expectedIncorrectUsage WP_Icon_Collections_Registry_Gutenberg::register + * + * @param mixed $is_public Invalid collection visibility value. + */ + public function test_register_collection_rejects_non_boolean_public_property( $is_public ) { + $result = $this->collections->register( + 'my-collection', + array( + 'label' => 'My Collection', + 'public' => $is_public, + ) + ); + + $this->assertFalse( $result ); + $this->assertFalse( $this->collections->is_registered( 'my-collection' ) ); + } + + /** + * Provides unsupported collection visibility values. + * + * @return array[] + */ + public function data_non_boolean_public_properties() { + return array( + 'null' => array( null ), + 'string' => array( 'false' ), + 'integer' => array( 0 ), + 'array' => array( array() ), + ); + } + + /** + * Should preserve collections registered before the shared registry is upgraded. + */ + public function test_get_instance_preserves_existing_collections_in_shared_registry() { + $instance_property = new ReflectionProperty( WP_Icon_Collections_Registry::class, 'instance' ); + if ( PHP_VERSION_ID < 80100 ) { + $instance_property->setAccessible( true ); + } + + $original_registry = $instance_property->getValue(); + + try { + $instance_property->setValue( null, null ); + $registry = WP_Icon_Collections_Registry::get_instance(); + $registry->register( + 'my-collection', + array( + 'label' => 'My Collection', + 'description' => 'Registered before the upgrade.', + ) + ); + + $upgraded_registry = WP_Icon_Collections_Registry_Gutenberg::get_instance(); + + $this->assertSame( $upgraded_registry, WP_Icon_Collections_Registry::get_instance() ); + $this->assertSame( + array_merge( $registry->get_registered( 'my-collection' ), array( 'public' => true ) ), + $upgraded_registry->get_registered( 'my-collection' ) + ); + } finally { + $instance_property->setValue( null, $original_registry ); + } + } + /** * Data provider for invalid collection slug candidates. * diff --git a/phpunit/class-wp-icon-test.php b/phpunit/class-wp-icon-test.php index d3ab2a64ec31fb..d6eefccc4cc884 100644 --- a/phpunit/class-wp-icon-test.php +++ b/phpunit/class-wp-icon-test.php @@ -20,6 +20,26 @@ public function set_up() { if ( empty( WP_Icons_Registry_Gutenberg::get_instance()->get_registered_icons() ) ) { gutenberg_register_default_icons(); } + + wp_register_icon_collection( + 'test-private', + array( + 'label' => 'Private Collection', + 'public' => false, + ) + ); + wp_register_icon( + 'test-private/visibility-icon', + array( + 'label' => 'Visibility Icon', + 'content' => '', + ) + ); + } + + public function tear_down() { + wp_unregister_icon_collection( 'test-private' ); + parent::tear_down(); } public function test_wp_get_icon_returns_svg_for_known_icon() { @@ -28,6 +48,20 @@ public function test_wp_get_icon_returns_svg_for_known_icon() { $this->assertStringContainsString( '', $output ); } + public function test_wp_get_icon_returns_svg_for_non_public_collection() { + $output = wp_get_icon( 'test-private/visibility-icon' ); + $this->assertStringStartsWith( 'assertStringContainsString( '', $output ); + } + + public function test_get_registered_icon_returns_icon_from_non_public_collection() { + $icon = WP_Icons_Registry_Gutenberg::get_instance()->get_registered_icon( 'test-private/visibility-icon' ); + + $this->assertSame( 'test-private/visibility-icon', $icon['name'] ); + $this->assertStringStartsWith( 'assertArrayNotHasKey( 'public', $icon ); + } + public function test_wp_get_icon_returns_empty_string_for_unknown_icon() { $output = wp_get_icon( 'this-icon-does-not-exist' ); $this->assertSame( '', $output ); diff --git a/phpunit/class-wp-icons-registry-gutenberg-test.php b/phpunit/class-wp-icons-registry-gutenberg-test.php index 9941071ed9aaa2..47a2b46b71aaf1 100644 --- a/phpunit/class-wp-icons-registry-gutenberg-test.php +++ b/phpunit/class-wp-icons-registry-gutenberg-test.php @@ -498,17 +498,17 @@ public function test_register_icon_without_content_or_file_path() { } /** - * Should fail to register an icon whose `public` property is not a boolean. + * Should reject visibility configured on an icon instead of its collection. * * @expectedIncorrectUsage WP_Icons_Registry_Gutenberg::register */ - public function test_register_icon_rejects_non_boolean_public_property() { + public function test_register_icon_rejects_public_property() { $result = $this->registry->register( 'test-collection/invalid-visibility', array( 'label' => 'Icon', 'content' => '', - 'public' => 'yes', + 'public' => false, ) ); diff --git a/phpunit/class-wp-rest-icon-controller-test.php b/phpunit/class-wp-rest-icon-controller-test.php index 52b6281f63dfd6..d10916e92430d1 100644 --- a/phpunit/class-wp-rest-icon-controller-test.php +++ b/phpunit/class-wp-rest-icon-controller-test.php @@ -37,6 +37,33 @@ public function set_up() { if ( empty( WP_Icons_Registry_Gutenberg::get_instance()->get_registered_icons() ) ) { gutenberg_register_default_icons(); } + + $collections = array( + 'test-public' => true, + 'test-private' => false, + ); + foreach ( $collections as $slug => $is_public ) { + wp_register_icon_collection( + $slug, + array( + 'label' => $slug, + 'public' => $is_public, + ) + ); + wp_register_icon( + $slug . '/visibility-icon', + array( + 'label' => 'Visibility Icon', + 'content' => '', + ) + ); + } + } + + public function tear_down() { + wp_unregister_icon_collection( 'test-public' ); + wp_unregister_icon_collection( 'test-private' ); + parent::tear_down(); } /** @@ -292,30 +319,105 @@ public function test_get_item_requires_authentication() { } /** - * Test that icons registered as non-public are omitted from the collection. + * Test that icons in non-public collections are omitted from lists and search results. + * + * @dataProvider data_icon_visibility_searches + * + * @param string $search Icon search term. */ - public function test_get_items_omits_non_public_icons() { + public function test_get_items_omits_non_public_collections( $search ) { wp_set_current_user( self::$editor_id ); - $request = new WP_REST_Request( 'GET', '/wp/v2/icons' ); + $request = new WP_REST_Request( 'GET', '/wp/v2/icons' ); + $request->set_param( 'search', $search ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $names = wp_list_pluck( $response->get_data(), 'name' ); - $this->assertContains( 'core/plus', $names ); - $this->assertNotContains( 'core/wordpress', $names ); + $this->assertContains( 'test-public/visibility-icon', $names ); + $this->assertNotContains( 'test-private/visibility-icon', $names ); + } + + /** + * Provides icon searches that match both public and non-public collections. + * + * @return array[] + */ + public function data_icon_visibility_searches() { + return array( + 'all icons' => array( '' ), + 'search icons' => array( 'visibility' ), + ); } /** - * Test that an icon registered as non-public is not readable by name. + * Test that an icon in a non-public collection is not readable by name. */ - public function test_get_item_returns_404_for_non_public_icon() { + public function test_get_item_returns_404_for_non_public_collection() { wp_set_current_user( self::$editor_id ); - $request = new WP_REST_Request( 'GET', '/wp/v2/icons/core/wordpress' ); + $request = new WP_REST_Request( 'GET', '/wp/v2/icons/test-private/visibility-icon' ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_icon_not_found', $response, 404 ); } + + /** + * Test that non-public collections cannot be requested by URL or query parameter. + * + * @dataProvider data_non_public_collection_requests + * + * @param string $route REST API route. + * @param array $query REST API query parameters. + */ + public function test_get_collection_icons_returns_404_for_non_public_collection( $route, $query ) { + wp_set_current_user( self::$editor_id ); + + $request = new WP_REST_Request( 'GET', $route ); + $request->set_query_params( $query ); + $response = rest_get_server()->dispatch( $request ); + + $this->assertErrorResponse( 'rest_icon_collection_not_found', $response, 404 ); + } + + /** + * Provides requests scoped to a non-public collection. + * + * @return array[] + */ + public function data_non_public_collection_requests() { + return array( + 'collection route' => array( '/wp/v2/icons/test-private', array() ), + 'collection query' => array( '/wp/v2/icons', array( 'collection' => 'test-private' ) ), + ); + } + + /** + * Test that non-public collections are omitted from the collection list. + */ + public function test_get_collections_omits_non_public_collections() { + wp_set_current_user( self::$editor_id ); + + $request = new WP_REST_Request( 'GET', '/wp/v2/icon-collections' ); + $response = rest_get_server()->dispatch( $request ); + + $this->assertSame( 200, $response->get_status() ); + + $slugs = wp_list_pluck( $response->get_data(), 'slug' ); + $this->assertContains( 'test-public', $slugs ); + $this->assertNotContains( 'test-private', $slugs ); + } + + /** + * Test that non-public collections are not readable by slug. + */ + public function test_get_collection_returns_404_for_non_public_collection() { + wp_set_current_user( self::$editor_id ); + + $request = new WP_REST_Request( 'GET', '/wp/v2/icon-collections/test-private' ); + $response = rest_get_server()->dispatch( $request ); + + $this->assertErrorResponse( 'rest_icon_collection_not_found', $response, 404 ); + } } From 15b94864934ee39a3fcd62103495f0a22844a3cc Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 21:43:38 +0900 Subject: [PATCH 02/10] Icons: Preserve changelog history and document collection visibility --- packages/icons/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/icons/CHANGELOG.md b/packages/icons/CHANGELOG.md index 64e84413a35e5a..88fdf2a9109bf6 100644 --- a/packages/icons/CHANGELOG.md +++ b/packages/icons/CHANGELOG.md @@ -9,6 +9,9 @@ ### Enhancements - Redraw a further 236 icons as stroke-based for variable stroke-width support, following the convention introduced in [#78808](https://github.com/WordPress/gutenberg/pull/78808), and refine the already stroke-based `image` and `commentAuthorAvatar` drawings. Most retain their original footprint; the table icons, `capturePhoto`, and `image` are slightly smaller, and several drawings in the final batch change by design. ([#82540](https://github.com/WordPress/gutenberg/pull/82540), [#82754](https://github.com/WordPress/gutenberg/pull/82754)) +- `manifest.json`: The `public` property is now a tri-state. Omitting it keeps an icon in the JS library only; `true` ships it to WordPress Core and exposes it through the icons REST API, making it selectable in the Icon block; `false` ships it and registers it in the `core` collection for server-side use via `wp_get_icon()`, while hiding it from the REST API and the Icon block. ([#82634](https://github.com/WordPress/gutenberg/pull/82634)) +- The `brush`, `dashboard`, `link`, `media`, `page`, `pin`, `plugins`, `sites`, `tool`, `update` and `wordpress` icons now ship to WordPress Core as non-public icons: they are registered in the `core` collection and stay available to server-side code via `wp_get_icon()`, but are not exposed through the icons REST API and are not selectable in the Icon block. ([#82634](https://github.com/WordPress/gutenberg/pull/82634), [#79451](https://github.com/WordPress/gutenberg/pull/79451)) +- Move the icon registry's `public` property from individual icons to collections and restore PHP manifest generation to include only icons with `public: true` ([#83277](https://github.com/WordPress/gutenberg/pull/83277)). ### Bug Fixes From 62b3d5c82fa01551bfa3062e2d28384be632f2c3 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 21:49:33 +0900 Subject: [PATCH 03/10] Icons: Simplify manifest public property documentation --- packages/icons/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/icons/README.md b/packages/icons/README.md index c8a2c439d0b13a..2f4dc87ecb5389 100644 --- a/packages/icons/README.md +++ b/packages/icons/README.md @@ -50,7 +50,7 @@ To add a new icon to the library, follow these steps: - `slug`: The icon identifier (should match the SVG filename without the `.svg` extension) - `label`: The human-readable label for the icon. Use Title Case (for example, `My New Icon`). - `filePath`: The relative path to the SVG file (e.g., `library/my-new-icon.svg`) - - `public` (optional): Set to `true` to ship the icon to WordPress Core and register it in the `core` collection. Omit it or set it to `false` to keep the icon in the JS library only. **Important**: Once an icon ships to WordPress Core, removing it is difficult, so carefully consider this field before setting it. + - `public` (optional): Set to `true` to ship the icon to WordPress Core and register it in the `core` collection. Omit it to keep the icon in the JS library only. **Important**: Once an icon ships to WordPress Core, removing it is difficult, so carefully consider this field before setting it. This manifest property controls which icons ship to WordPress Core. REST API visibility is configured for the whole collection through the `public` argument of `wp_register_icon_collection()`, which defaults to `true`. Icons in non-public collections remain available to server-side code through `wp_get_icon()` but are not exposed through the REST API or selectable in the Icon block. From f9a27a9e24d6c81e1cb962875cbc0f8a6139f6ef Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 21:51:03 +0900 Subject: [PATCH 04/10] Icons: Remove collection visibility details from the README --- packages/icons/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/icons/README.md b/packages/icons/README.md index 2f4dc87ecb5389..4209a53cf78153 100644 --- a/packages/icons/README.md +++ b/packages/icons/README.md @@ -52,8 +52,6 @@ To add a new icon to the library, follow these steps: - `filePath`: The relative path to the SVG file (e.g., `library/my-new-icon.svg`) - `public` (optional): Set to `true` to ship the icon to WordPress Core and register it in the `core` collection. Omit it to keep the icon in the JS library only. **Important**: Once an icon ships to WordPress Core, removing it is difficult, so carefully consider this field before setting it. - This manifest property controls which icons ship to WordPress Core. REST API visibility is configured for the whole collection through the `public` argument of `wp_register_icon_collection()`, which defaults to `true`. Icons in non-public collections remain available to server-side code through `wp_get_icon()` but are not exposed through the REST API or selectable in the Icon block. - 4. **Do not edit `manifest.php`**: The `manifest.php` file is automatically generated from `manifest.json` by the build script. Do not edit it manually, as your changes will be overwritten when the build runs. After adding your icon, run `npm run build` to generate the TypeScript files and update `manifest.php`. From 9e1603f8cf6f018691bc3b941f56414ed4e47225 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 21:53:49 +0900 Subject: [PATCH 05/10] Icons: Clarify the public manifest field in the changelog --- packages/icons/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/icons/CHANGELOG.md b/packages/icons/CHANGELOG.md index 88fdf2a9109bf6..bc0a4361c53441 100644 --- a/packages/icons/CHANGELOG.md +++ b/packages/icons/CHANGELOG.md @@ -11,7 +11,7 @@ - Redraw a further 236 icons as stroke-based for variable stroke-width support, following the convention introduced in [#78808](https://github.com/WordPress/gutenberg/pull/78808), and refine the already stroke-based `image` and `commentAuthorAvatar` drawings. Most retain their original footprint; the table icons, `capturePhoto`, and `image` are slightly smaller, and several drawings in the final batch change by design. ([#82540](https://github.com/WordPress/gutenberg/pull/82540), [#82754](https://github.com/WordPress/gutenberg/pull/82754)) - `manifest.json`: The `public` property is now a tri-state. Omitting it keeps an icon in the JS library only; `true` ships it to WordPress Core and exposes it through the icons REST API, making it selectable in the Icon block; `false` ships it and registers it in the `core` collection for server-side use via `wp_get_icon()`, while hiding it from the REST API and the Icon block. ([#82634](https://github.com/WordPress/gutenberg/pull/82634)) - The `brush`, `dashboard`, `link`, `media`, `page`, `pin`, `plugins`, `sites`, `tool`, `update` and `wordpress` icons now ship to WordPress Core as non-public icons: they are registered in the `core` collection and stay available to server-side code via `wp_get_icon()`, but are not exposed through the icons REST API and are not selectable in the Icon block. ([#82634](https://github.com/WordPress/gutenberg/pull/82634), [#79451](https://github.com/WordPress/gutenberg/pull/79451)) -- Move the icon registry's `public` property from individual icons to collections and restore PHP manifest generation to include only icons with `public: true` ([#83277](https://github.com/WordPress/gutenberg/pull/83277)). +- `manifest.json`: The `public` field now only controls whether an icon ships to WordPress Core ([#83277](https://github.com/WordPress/gutenberg/pull/83277)). ### Bug Fixes From bd0d8ec11010fd5741b9c95928ef34df2d246eb7 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 21:57:21 +0900 Subject: [PATCH 06/10] Icons: Move new visibility tests to the end of their classes --- ...lass-wp-icon-collections-registry-test.php | 216 +++++++++--------- phpunit/class-wp-icon-test.php | 28 +-- 2 files changed, 122 insertions(+), 122 deletions(-) diff --git a/phpunit/class-wp-icon-collections-registry-test.php b/phpunit/class-wp-icon-collections-registry-test.php index 2b8b96340ee68b..e830a8b6dc93fd 100644 --- a/phpunit/class-wp-icon-collections-registry-test.php +++ b/phpunit/class-wp-icon-collections-registry-test.php @@ -88,6 +88,114 @@ public function test_register_collection( $slug ) { $this->assertTrue( $this->collections->is_registered( $slug ) ); } + /** + * Data provider for invalid collection slug candidates. + * + * @return array[] + */ + public function data_invalid_collection_slugs() { + return array( + 'non-string slug' => array( 1 ), + 'contains slash' => array( 'plugin/icons' ), + 'uppercase characters' => array( 'Plugin' ), + 'underscore at the start' => array( '_my-plugin' ), + 'underscore at the end' => array( 'my-plugin_' ), + 'hyphen at the start' => array( '-my-plugin' ), + 'hyphen at the end' => array( 'my-plugin-' ), + ); + } + + /** + * Should fail to register a collection with an invalid slug. + * + * @dataProvider data_invalid_collection_slugs + * @expectedIncorrectUsage WP_Icon_Collections_Registry::register + * + * @param mixed $slug Invalid slug candidate. + */ + public function test_register_rejects_invalid_slug( $slug ) { + $result = $this->collections->register( $slug, array( 'label' => 'X' ) ); + $this->assertFalse( $result ); + } + + /** + * Should fail to register the same collection twice. + * + * @expectedIncorrectUsage WP_Icon_Collections_Registry::register + */ + public function test_register_twice_fails() { + $this->assertTrue( $this->collections->register( 'my-collection', array( 'label' => 'A' ) ) ); + $this->assertFalse( $this->collections->register( 'my-collection', array( 'label' => 'A' ) ) ); + } + + /** + * Should fail to register a collection with an unknown property. + * + * @expectedIncorrectUsage WP_Icon_Collections_Registry::register + */ + public function test_register_rejects_unknown_property() { + $result = $this->collections->register( + 'my-collection', + array( + 'label' => 'A', + 'bogus' => 'nope', + ) + ); + $this->assertFalse( $result ); + } + + /** + * Unregistering a collection should cascade and remove all icons + * belonging to it, while leaving icons from other collections intact. + */ + public function test_unregister_collection_cascades_to_icons() { + $this->collections->register( 'plugin-a', array( 'label' => 'A' ) ); + $this->collections->register( 'plugin-b', array( 'label' => 'B' ) ); + + $icons = WP_Icons_Registry_Gutenberg::get_instance(); + $this->register_icon( + 'plugin-a/alpha', + array( + 'label' => 'Alpha', + 'content' => '', + ) + ); + $this->register_icon( + 'plugin-a/beta', + array( + 'label' => 'Beta', + 'content' => '', + ) + ); + $this->register_icon( + 'plugin-b/gamma', + array( + 'label' => 'Gamma', + 'content' => '', + ) + ); + + $this->assertTrue( $icons->is_registered( 'plugin-a/alpha' ) ); + $this->assertTrue( $icons->is_registered( 'plugin-a/beta' ) ); + + $this->assertTrue( $this->collections->unregister( 'plugin-a' ) ); + + $this->assertFalse( $icons->is_registered( 'plugin-a/alpha' ) ); + $this->assertFalse( $icons->is_registered( 'plugin-a/beta' ) ); + $this->assertTrue( $icons->is_registered( 'plugin-b/gamma' ) ); + + $icons->unregister( 'plugin-b/gamma' ); + } + + /** + * Should fail to unregister a collection that was never registered. + * + * @expectedIncorrectUsage WP_Icon_Collections_Registry::unregister + */ + public function test_unregister_unknown_collection() { + $this->assertFalse( $this->collections->unregister( 'ghost' ) ); + } + /** * Should register collections as public by default. */ @@ -197,112 +305,4 @@ public function test_get_instance_preserves_existing_collections_in_shared_regis $instance_property->setValue( null, $original_registry ); } } - - /** - * Data provider for invalid collection slug candidates. - * - * @return array[] - */ - public function data_invalid_collection_slugs() { - return array( - 'non-string slug' => array( 1 ), - 'contains slash' => array( 'plugin/icons' ), - 'uppercase characters' => array( 'Plugin' ), - 'underscore at the start' => array( '_my-plugin' ), - 'underscore at the end' => array( 'my-plugin_' ), - 'hyphen at the start' => array( '-my-plugin' ), - 'hyphen at the end' => array( 'my-plugin-' ), - ); - } - - /** - * Should fail to register a collection with an invalid slug. - * - * @dataProvider data_invalid_collection_slugs - * @expectedIncorrectUsage WP_Icon_Collections_Registry::register - * - * @param mixed $slug Invalid slug candidate. - */ - public function test_register_rejects_invalid_slug( $slug ) { - $result = $this->collections->register( $slug, array( 'label' => 'X' ) ); - $this->assertFalse( $result ); - } - - /** - * Should fail to register the same collection twice. - * - * @expectedIncorrectUsage WP_Icon_Collections_Registry::register - */ - public function test_register_twice_fails() { - $this->assertTrue( $this->collections->register( 'my-collection', array( 'label' => 'A' ) ) ); - $this->assertFalse( $this->collections->register( 'my-collection', array( 'label' => 'A' ) ) ); - } - - /** - * Should fail to register a collection with an unknown property. - * - * @expectedIncorrectUsage WP_Icon_Collections_Registry::register - */ - public function test_register_rejects_unknown_property() { - $result = $this->collections->register( - 'my-collection', - array( - 'label' => 'A', - 'bogus' => 'nope', - ) - ); - $this->assertFalse( $result ); - } - - /** - * Unregistering a collection should cascade and remove all icons - * belonging to it, while leaving icons from other collections intact. - */ - public function test_unregister_collection_cascades_to_icons() { - $this->collections->register( 'plugin-a', array( 'label' => 'A' ) ); - $this->collections->register( 'plugin-b', array( 'label' => 'B' ) ); - - $icons = WP_Icons_Registry_Gutenberg::get_instance(); - $this->register_icon( - 'plugin-a/alpha', - array( - 'label' => 'Alpha', - 'content' => '', - ) - ); - $this->register_icon( - 'plugin-a/beta', - array( - 'label' => 'Beta', - 'content' => '', - ) - ); - $this->register_icon( - 'plugin-b/gamma', - array( - 'label' => 'Gamma', - 'content' => '', - ) - ); - - $this->assertTrue( $icons->is_registered( 'plugin-a/alpha' ) ); - $this->assertTrue( $icons->is_registered( 'plugin-a/beta' ) ); - - $this->assertTrue( $this->collections->unregister( 'plugin-a' ) ); - - $this->assertFalse( $icons->is_registered( 'plugin-a/alpha' ) ); - $this->assertFalse( $icons->is_registered( 'plugin-a/beta' ) ); - $this->assertTrue( $icons->is_registered( 'plugin-b/gamma' ) ); - - $icons->unregister( 'plugin-b/gamma' ); - } - - /** - * Should fail to unregister a collection that was never registered. - * - * @expectedIncorrectUsage WP_Icon_Collections_Registry::unregister - */ - public function test_unregister_unknown_collection() { - $this->assertFalse( $this->collections->unregister( 'ghost' ) ); - } } diff --git a/phpunit/class-wp-icon-test.php b/phpunit/class-wp-icon-test.php index d6eefccc4cc884..28285e4d391eeb 100644 --- a/phpunit/class-wp-icon-test.php +++ b/phpunit/class-wp-icon-test.php @@ -48,20 +48,6 @@ public function test_wp_get_icon_returns_svg_for_known_icon() { $this->assertStringContainsString( '', $output ); } - public function test_wp_get_icon_returns_svg_for_non_public_collection() { - $output = wp_get_icon( 'test-private/visibility-icon' ); - $this->assertStringStartsWith( 'assertStringContainsString( '', $output ); - } - - public function test_get_registered_icon_returns_icon_from_non_public_collection() { - $icon = WP_Icons_Registry_Gutenberg::get_instance()->get_registered_icon( 'test-private/visibility-icon' ); - - $this->assertSame( 'test-private/visibility-icon', $icon['name'] ); - $this->assertStringStartsWith( 'assertArrayNotHasKey( 'public', $icon ); - } - public function test_wp_get_icon_returns_empty_string_for_unknown_icon() { $output = wp_get_icon( 'this-icon-does-not-exist' ); $this->assertSame( '', $output ); @@ -133,4 +119,18 @@ public function test_wp_get_icon_escapes_attributes() { $output = wp_get_icon( 'core/plus', array( 'class' => '">' ) ); $this->assertStringNotContainsString( '