From ed5aba24033716f2e79ef0e60b957fc8c4148972 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 16:27:30 +0900 Subject: [PATCH 01/13] Icons: Add a core-admin collection for the admin interface Register a `core-admin` icon collection alongside `core`, holding the icons the admin bar and admin menu render, so that unregistering `core` cannot take them away from the dashboard. Icons opt in through a new `admin` property in the icons manifest and are always registered as non-public there. Since the collection is exposed by the icon collections endpoint but holds no public icon, the Icon block no longer offers a tab for a collection without a single icon. Co-Authored-By: Claude --- lib/icons.php | 22 +++++-- .../icon/components/custom-inserter/index.jsx | 62 ++++++++++--------- packages/icons/README.md | 1 + packages/icons/lib/generate-manifest-php.cjs | 8 ++- packages/icons/lib/validate-collection.cjs | 22 ++++--- packages/icons/src/manifest.json | 60 ++++++++++++------ packages/icons/src/manifest.php | 20 ++++++ 7 files changed, 127 insertions(+), 68 deletions(-) diff --git a/lib/icons.php b/lib/icons.php index 03d1db97496874..79395025a1d743 100644 --- a/lib/icons.php +++ b/lib/icons.php @@ -1,6 +1,6 @@ __( 'Core icon collection.', 'gutenberg' ), ) ); + wp_register_icon_collection( + 'core-admin', + array( + 'label' => __( 'WordPress Admin', 'gutenberg' ), + 'description' => __( 'Icon collection used by the WordPress admin interface.', 'gutenberg' ), + ) + ); } $default_icon_collections_priority = has_action( 'init', '_wp_register_default_icon_collections' ); @@ -26,7 +33,7 @@ function gutenberg_register_default_icon_collections() { add_action( 'init', 'gutenberg_register_default_icon_collections', 0 ); /** - * Registers the default core icons from the Gutenberg manifest. + * Registers the default core and core-admin icons from the Gutenberg manifest. */ function gutenberg_register_default_icons() { $icons_directory = gutenberg_dir_path() . 'packages/icons/src'; @@ -41,9 +48,9 @@ function gutenberg_register_default_icons() { return; } - $collection = include $manifest_path; + $manifest = include $manifest_path; - if ( empty( $collection ) ) { + if ( empty( $manifest ) ) { wp_trigger_error( __FUNCTION__, __( 'Core icon collection manifest is empty or invalid.', 'gutenberg' ) @@ -51,7 +58,7 @@ function gutenberg_register_default_icons() { return; } - foreach ( $collection as $icon_name => $icon_data ) { + foreach ( $manifest as $icon_name => $icon_data ) { if ( empty( $icon_data['filePath'] ) || ! is_string( $icon_data['filePath'] ) @@ -74,6 +81,11 @@ function gutenberg_register_default_icons() { } wp_register_icon( 'core/' . $icon_name, $icon_args ); + + if ( ! empty( $icon_data['admin'] ) ) { + $icon_args['public'] = false; + wp_register_icon( 'core-admin/' . $icon_name, $icon_args ); + } } } diff --git a/packages/block-library/src/icon/components/custom-inserter/index.jsx b/packages/block-library/src/icon/components/custom-inserter/index.jsx index 86d74f834d4f99..116a439f86c1cc 100644 --- a/packages/block-library/src/icon/components/custom-inserter/index.jsx +++ b/packages/block-library/src/icon/components/custom-inserter/index.jsx @@ -8,21 +8,39 @@ import { store as coreDataStore } from '@wordpress/core-data'; import IconGrid from './icon-grid'; import { normalizeSearchInput } from '../../../utils/search-patterns'; +const ALL_ICONS_QUERY = {}; + export default function CustomInserterModal( { onClose, value, onChange } ) { const [ searchInput, setSearchInput ] = useState( '' ); const [ currentCollection, setCurrentCollection ] = useState( null ); const debouncedSetSearchInput = useDebounce( setSearchInput, 300 ); - const collections = useSelect( - ( select ) => - select( coreDataStore ).getEntityRecords( - 'root', - 'iconCollection' - ), + const { allCollections, icons, hasResolvedIcons } = useSelect( + ( select ) => { + const { getEntityRecords, hasFinishedResolution } = + select( coreDataStore ); + return { + allCollections: getEntityRecords( 'root', 'iconCollection' ), + icons: getEntityRecords( 'root', 'icon', ALL_ICONS_QUERY ), + hasResolvedIcons: hasFinishedResolution( 'getEntityRecords', [ + 'root', + 'icon', + ALL_ICONS_QUERY, + ] ), + }; + }, [] ); + const collections = useMemo( () => { + if ( ! allCollections || ! icons ) { + return null; + } + const populated = new Set( icons.map( ( icon ) => icon.collection ) ); + return allCollections.filter( ( { slug } ) => populated.has( slug ) ); + }, [ allCollections, icons ] ); + // Default to the collection the selected icon belongs to, otherwise the // first collection. const selectedCollection = value?.split( '/' )[ 0 ]; @@ -33,34 +51,18 @@ export default function CustomInserterModal( { onClose, value, onChange } ) { : collections?.[ 0 ]?.slug ) ?? null; - const { icons, hasResolvedIcons } = useSelect( - ( select ) => { - if ( collectionSlug === null ) { - return { icons: null, hasResolvedIcons: false }; - } - const query = - collectionSlug === '' ? {} : { collection: collectionSlug }; - const { getEntityRecords, hasFinishedResolution } = - select( coreDataStore ); - return { - icons: getEntityRecords( 'root', 'icon', query ), - hasResolvedIcons: hasFinishedResolution( 'getEntityRecords', [ - 'root', - 'icon', - query, - ] ), - }; - }, - [ collectionSlug ] - ); - const filteredIcons = useMemo( () => { if ( ! icons ) { return []; } + + const scopedIcons = collectionSlug + ? icons.filter( ( icon ) => icon.collection === collectionSlug ) + : icons; + if ( searchInput ) { const input = normalizeSearchInput( searchInput ); - return icons.filter( ( icon ) => { + return scopedIcons.filter( ( icon ) => { const iconName = normalizeSearchInput( icon.name ); const iconLabel = normalizeSearchInput( icon.label ); @@ -70,8 +72,8 @@ export default function CustomInserterModal( { onClose, value, onChange } ) { } ); } - return icons; - }, [ searchInput, icons ] ); + return scopedIcons; + }, [ searchInput, icons, collectionSlug ] ); return ( false," : ''; + const adminEntry = + item.admin === true ? "\n\t\t'admin' => true," : ''; return `${ key } => array( 'label' => _x( '${ label }', 'icon label', 'gutenberg' ), - 'filePath' => '${ filePath }',${ publicEntry } + 'filePath' => '${ filePath }',${ publicEntry }${ adminEntry } ),`; } ); @@ -59,13 +61,13 @@ ${ phpEntries.join( '\n' ) } /** * Generates manifest.php from manifest.json. - * Only includes icons which have the `public` key set. + * Only includes icons which have the `public` or `admin` key set. */ 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' + ( item ) => typeof item.public === 'boolean' || item.admin === true ); const phpHeader = ` _x( 'Brush', 'icon label', 'gutenberg' ), 'filePath' => 'library/brush.svg', 'public' => false, + 'admin' => true, ), 'calendar' => array( 'label' => _x( 'Calendar', 'icon label', 'gutenberg' ), @@ -109,6 +110,7 @@ 'chevron-left' => array( 'label' => _x( 'Chevron Left', 'icon label', 'gutenberg' ), 'filePath' => 'library/chevron-left.svg', + 'admin' => true, ), 'chevron-left-small' => array( 'label' => _x( 'Chevron Left Small', 'icon label', 'gutenberg' ), @@ -137,6 +139,7 @@ 'comment' => array( 'label' => _x( 'Comment', 'icon label', 'gutenberg' ), 'filePath' => 'library/comment.svg', + 'admin' => true, ), 'cover' => array( 'label' => _x( 'Cover', 'icon label', 'gutenberg' ), @@ -150,6 +153,7 @@ 'label' => _x( 'Dashboard', 'icon label', 'gutenberg' ), 'filePath' => 'library/dashboard.svg', 'public' => false, + 'admin' => true, ), 'desktop' => array( 'label' => _x( 'Desktop', 'icon label', 'gutenberg' ), @@ -202,6 +206,7 @@ 'home' => array( 'label' => _x( 'Home', 'icon label', 'gutenberg' ), 'filePath' => 'library/home.svg', + 'admin' => true, ), 'image' => array( 'label' => _x( 'Image', 'icon label', 'gutenberg' ), @@ -223,6 +228,7 @@ 'label' => _x( 'Link', 'icon label', 'gutenberg' ), 'filePath' => 'library/link.svg', 'public' => false, + 'admin' => true, ), 'map-marker' => array( 'label' => _x( 'Map Marker', 'icon label', 'gutenberg' ), @@ -232,10 +238,12 @@ 'label' => _x( 'Media', 'icon label', 'gutenberg' ), 'filePath' => 'library/media.svg', 'public' => false, + 'admin' => true, ), 'menu' => array( 'label' => _x( 'Menu', 'icon label', 'gutenberg' ), 'filePath' => 'library/menu.svg', + 'admin' => true, ), 'mobile' => array( 'label' => _x( 'Mobile', 'icon label', 'gutenberg' ), @@ -257,6 +265,7 @@ 'label' => _x( 'Page', 'icon label', 'gutenberg' ), 'filePath' => 'library/page.svg', 'public' => false, + 'admin' => true, ), 'paragraph' => array( 'label' => _x( 'Paragraph', 'icon label', 'gutenberg' ), @@ -269,24 +278,29 @@ 'pencil' => array( 'label' => _x( 'Pencil', 'icon label', 'gutenberg' ), 'filePath' => 'library/pencil.svg', + 'admin' => true, ), 'people' => array( 'label' => _x( 'People', 'icon label', 'gutenberg' ), 'filePath' => 'library/people.svg', + 'admin' => true, ), 'pin' => array( 'label' => _x( 'Pin', 'icon label', 'gutenberg' ), 'filePath' => 'library/pin.svg', 'public' => false, + 'admin' => true, ), 'plugins' => array( 'label' => _x( 'Plugins', 'icon label', 'gutenberg' ), 'filePath' => 'library/plugins.svg', 'public' => false, + 'admin' => true, ), 'plus' => array( 'label' => _x( 'Plus', 'icon label', 'gutenberg' ), 'filePath' => 'library/plus.svg', + 'admin' => true, ), 'plus-circle' => array( 'label' => _x( 'Plus Circle', 'icon label', 'gutenberg' ), @@ -319,10 +333,12 @@ 'search' => array( 'label' => _x( 'Search', 'icon label', 'gutenberg' ), 'filePath' => 'library/search.svg', + 'admin' => true, ), 'settings' => array( 'label' => _x( 'Settings', 'icon label', 'gutenberg' ), 'filePath' => 'library/settings.svg', + 'admin' => true, ), 'shadow' => array( 'label' => _x( 'Shadow', 'icon label', 'gutenberg' ), @@ -344,6 +360,7 @@ 'label' => _x( 'Sites', 'icon label', 'gutenberg' ), 'filePath' => 'library/sites.svg', 'public' => false, + 'admin' => true, ), 'star-empty' => array( 'label' => _x( 'Star Empty', 'icon label', 'gutenberg' ), @@ -393,11 +410,13 @@ 'label' => _x( 'Tool', 'icon label', 'gutenberg' ), 'filePath' => 'library/tool.svg', 'public' => false, + 'admin' => true, ), 'update' => array( 'label' => _x( 'Update', 'icon label', 'gutenberg' ), 'filePath' => 'library/update.svg', 'public' => false, + 'admin' => true, ), 'upload' => array( 'label' => _x( 'Upload', 'icon label', 'gutenberg' ), @@ -411,5 +430,6 @@ 'label' => _x( 'WordPress', 'icon label', 'gutenberg' ), 'filePath' => 'library/wordpress.svg', 'public' => false, + 'admin' => true, ), ); From 194fb41d21d74bb35197ba8b1057c287bd2d0076 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 16:28:36 +0900 Subject: [PATCH 02/13] Icons: Add a CHANGELOG entry for the admin manifest property Co-Authored-By: Claude --- packages/icons/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/icons/CHANGELOG.md b/packages/icons/CHANGELOG.md index 9cdebbf36222aa..f5d1179828c120 100644 --- a/packages/icons/CHANGELOG.md +++ b/packages/icons/CHANGELOG.md @@ -11,6 +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)) +- `manifest.json`: New `admin` property, set on the icons the WordPress admin interface renders. It additionally registers the icon in the `core-admin` collection, always as a non-public icon there, so that unregistering `core` cannot take it away from the admin interface. ([#83261](https://github.com/WordPress/gutenberg/pull/83261)) ### Bug Fixes From 6bc70d97634431fc9b5085a30ce0e646410dbffb Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 21 Sep 2026 17:07:09 +0900 Subject: [PATCH 03/13] Icons: Add a backport changelog entry for the core-admin collection Co-Authored-By: Claude Opus 5 (1M context) --- backport-changelog/7.2/13625.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 backport-changelog/7.2/13625.md diff --git a/backport-changelog/7.2/13625.md b/backport-changelog/7.2/13625.md new file mode 100644 index 00000000000000..d32c56f48ce265 --- /dev/null +++ b/backport-changelog/7.2/13625.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/13625 + +* https://github.com/WordPress/gutenberg/pull/83261 From b6e59dfe5ffae48366e5a33d5ae4788e739f53b6 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 22 Sep 2026 19:36:03 +0900 Subject: [PATCH 04/13] Icons: Keep the manifest variable named $collection The merge renamed it to $manifest, which only widened the PR diff without changing behaviour. Co-Authored-By: Claude --- lib/icons.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/icons.php b/lib/icons.php index 8d56df49468681..21fdc88dc7c748 100644 --- a/lib/icons.php +++ b/lib/icons.php @@ -49,9 +49,9 @@ function gutenberg_register_default_icons() { return; } - $manifest = include $manifest_path; + $collection = include $manifest_path; - if ( empty( $manifest ) ) { + if ( empty( $collection ) ) { wp_trigger_error( __FUNCTION__, __( 'Core icon collection manifest is empty or invalid.', 'gutenberg' ) @@ -59,7 +59,7 @@ function gutenberg_register_default_icons() { return; } - foreach ( $manifest as $icon_name => $icon_data ) { + foreach ( $collection as $icon_name => $icon_data ) { if ( empty( $icon_data['filePath'] ) || ! is_string( $icon_data['filePath'] ) From d4f6c95aa0d84335890c7f85f2440e440c4a4bdd Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 22 Sep 2026 19:38:13 +0900 Subject: [PATCH 05/13] Icons: Shorten the core-admin collection changelog entry Drop the list of affected icon names and the REST API/Icon block restatement, which "not public" already implies. Co-Authored-By: Claude --- 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 beddd43d69b966..a519b901dee37b 100644 --- a/packages/icons/CHANGELOG.md +++ b/packages/icons/CHANGELOG.md @@ -12,7 +12,7 @@ - `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)) - `manifest.json`: The `public` field now only controls whether an icon ships to WordPress Core ([#83277](https://github.com/WordPress/gutenberg/pull/83277)). -- `manifest.json`: New `admin` property, set on the icons the WordPress admin interface renders (`brush`, `chevron-left`, `comment`, `dashboard`, `home`, `link`, `media`, `menu`, `page`, `pencil`, `people`, `pin`, `plugins`, `plus`, `search`, `settings`, `sites`, `tool`, `update` and `wordpress`). It ships the icon to WordPress Core and registers it in the new `core-admin` collection, which is not public, so the icon is not exposed through the icons REST API or selectable in the Icon block, and unregistering `core` cannot take it away from the admin interface. ([#83261](https://github.com/WordPress/gutenberg/pull/83261), [#79451](https://github.com/WordPress/gutenberg/pull/79451)) +- `manifest.json`: New `admin` property, set on the icons the WordPress admin interface renders. It ships the icon to WordPress Core and registers it in the new `core-admin` collection, which is not public, so unregistering `core` cannot take the icon away from the admin interface. ([#83261](https://github.com/WordPress/gutenberg/pull/83261), [#79451](https://github.com/WordPress/gutenberg/pull/79451)) ### Bug Fixes From c18b5497d01395c8d0e04315f18349d436040b03 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 22 Sep 2026 19:39:19 +0900 Subject: [PATCH 06/13] Icons: Drop the collection visibility clause from the changelog entry Co-Authored-By: Claude --- 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 a519b901dee37b..f5b82ad97cae6c 100644 --- a/packages/icons/CHANGELOG.md +++ b/packages/icons/CHANGELOG.md @@ -12,7 +12,7 @@ - `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)) - `manifest.json`: The `public` field now only controls whether an icon ships to WordPress Core ([#83277](https://github.com/WordPress/gutenberg/pull/83277)). -- `manifest.json`: New `admin` property, set on the icons the WordPress admin interface renders. It ships the icon to WordPress Core and registers it in the new `core-admin` collection, which is not public, so unregistering `core` cannot take the icon away from the admin interface. ([#83261](https://github.com/WordPress/gutenberg/pull/83261), [#79451](https://github.com/WordPress/gutenberg/pull/79451)) +- `manifest.json`: New `admin` property, set on the icons the WordPress admin interface renders. It ships the icon to WordPress Core and registers it in the new `core-admin` collection. ([#83261](https://github.com/WordPress/gutenberg/pull/83261), [#79451](https://github.com/WordPress/gutenberg/pull/79451)) ### Bug Fixes From a6b49b62b1f64f69e76cb82c4eec89aa9fd0ab2f Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 22 Sep 2026 20:55:03 +0900 Subject: [PATCH 07/13] Icons: Rebuild both default collections in test set_up so core-admin is not registered twice Co-Authored-By: Claude --- phpunit/blocks/render-block-icon-test.php | 18 +++++++++++++----- phpunit/class-wp-icon-test.php | 18 +++++++++++------- phpunit/class-wp-rest-icon-controller-test.php | 18 +++++++++++------- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/phpunit/blocks/render-block-icon-test.php b/phpunit/blocks/render-block-icon-test.php index 77bf89980d844f..8992ae312af35b 100644 --- a/phpunit/blocks/render-block-icon-test.php +++ b/phpunit/blocks/render-block-icon-test.php @@ -28,12 +28,20 @@ public function set_up() { 'attrs' => array(), ); - if ( ! WP_Icon_Collections_Registry::get_instance()->is_registered( 'core' ) ) { - gutenberg_register_default_icon_collections(); - } - if ( empty( WP_Icons_Registry_Gutenberg::get_instance()->get_registered_icons() ) ) { - gutenberg_register_default_icons(); + /* + * Other suites reset the `WP_Icons_Registry` singleton, wiping the collections and + * icons that `init` only registers once. Replay the registration so order-dependent + * tests pass. `gutenberg_register_default_icon_collections()` registers every default + * collection at once, so drop whatever survived rather than topping up. + */ + $collections_registry = WP_Icon_Collections_Registry::get_instance(); + foreach ( array( 'core', 'core-admin' ) as $collection_slug ) { + if ( $collections_registry->is_registered( $collection_slug ) ) { + $collections_registry->unregister( $collection_slug ); + } } + gutenberg_register_default_icon_collections(); + gutenberg_register_default_icons(); } public function tear_down() { diff --git a/phpunit/class-wp-icon-test.php b/phpunit/class-wp-icon-test.php index d3ab2a64ec31fb..274804b1844266 100644 --- a/phpunit/class-wp-icon-test.php +++ b/phpunit/class-wp-icon-test.php @@ -11,15 +11,19 @@ public function set_up() { parent::set_up(); /* - * Other suites reset the `WP_Icons_Registry` singleton, wiping the core icons that - * `init` only registers once. Re-register them when empty so order-dependent tests pass. + * Other suites reset the `WP_Icons_Registry` singleton, wiping the collections and + * icons that `init` only registers once. Replay the registration so order-dependent + * tests pass. `gutenberg_register_default_icon_collections()` registers every default + * collection at once, so drop whatever survived rather than topping up. */ - if ( ! WP_Icon_Collections_Registry::get_instance()->is_registered( 'core' ) ) { - gutenberg_register_default_icon_collections(); - } - if ( empty( WP_Icons_Registry_Gutenberg::get_instance()->get_registered_icons() ) ) { - gutenberg_register_default_icons(); + $collections_registry = WP_Icon_Collections_Registry::get_instance(); + foreach ( array( 'core', 'core-admin' ) as $collection_slug ) { + if ( $collections_registry->is_registered( $collection_slug ) ) { + $collections_registry->unregister( $collection_slug ); + } } + gutenberg_register_default_icon_collections(); + gutenberg_register_default_icons(); } public function test_wp_get_icon_returns_svg_for_known_icon() { diff --git a/phpunit/class-wp-rest-icon-controller-test.php b/phpunit/class-wp-rest-icon-controller-test.php index d10916e92430d1..cd9db70f7ca517 100644 --- a/phpunit/class-wp-rest-icon-controller-test.php +++ b/phpunit/class-wp-rest-icon-controller-test.php @@ -28,15 +28,19 @@ public function set_up() { parent::set_up(); /* - * Other suites reset the `WP_Icons_Registry` singleton, wiping the core icons that - * `init` only registers once. Re-register them when empty so order-dependent tests pass. + * Other suites reset the `WP_Icons_Registry` singleton, wiping the collections and + * icons that `init` only registers once. Replay the registration so order-dependent + * tests pass. `gutenberg_register_default_icon_collections()` registers every default + * collection at once, so drop whatever survived rather than topping up. */ - if ( ! WP_Icon_Collections_Registry::get_instance()->is_registered( 'core' ) ) { - gutenberg_register_default_icon_collections(); - } - if ( empty( WP_Icons_Registry_Gutenberg::get_instance()->get_registered_icons() ) ) { - gutenberg_register_default_icons(); + $collections_registry = WP_Icon_Collections_Registry::get_instance(); + foreach ( array( 'core', 'core-admin' ) as $collection_slug ) { + if ( $collections_registry->is_registered( $collection_slug ) ) { + $collections_registry->unregister( $collection_slug ); + } } + gutenberg_register_default_icon_collections(); + gutenberg_register_default_icons(); $collections = array( 'test-public' => true, From 4f91c5ed8e7bb06d705006a97a09e54c546302a7 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 22 Sep 2026 20:57:00 +0900 Subject: [PATCH 08/13] Icons: Skip core-admin icons when replaying an existing registry so the plugin manifest wins Co-Authored-By: Claude --- lib/class-wp-icons-registry-gutenberg.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/class-wp-icons-registry-gutenberg.php b/lib/class-wp-icons-registry-gutenberg.php index 39b2794ff83481..9bd3784a1ce97a 100644 --- a/lib/class-wp-icons-registry-gutenberg.php +++ b/lib/class-wp-icons-registry-gutenberg.php @@ -364,7 +364,7 @@ public function get_registered_icons( $search = '' ) { * The base `$instance` slot is intentionally not redefined, so both * `WP_Icons_Registry::get_instance()` (used by core) and this method share * one instance. An existing base registry is upgraded, replaying any - * non-`core/` icons so they are not lost. + * non-`core/` and non-`core-admin/` icons so they are not lost. */ public static function get_instance() { if ( ! self::$instance instanceof self ) { @@ -373,7 +373,7 @@ public static function get_instance() { if ( null !== $original_registry ) { foreach ( $original_registry->get_registered_icons() as $icon ) { - if ( str_starts_with( $icon['name'], 'core/' ) ) { + if ( str_starts_with( $icon['name'], 'core/' ) || str_starts_with( $icon['name'], 'core-admin/' ) ) { continue; } $icon_properties = array( 'label' => $icon['label'] ); From 320a3b480b86280deacc63f971c318fcd8657a31 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 22 Sep 2026 20:59:02 +0900 Subject: [PATCH 09/13] Icons: Keep admin-only icon SVGs in the Core build so their manifest entries resolve Co-Authored-By: Claude --- tools/release/build-plugin-zip.mts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/release/build-plugin-zip.mts b/tools/release/build-plugin-zip.mts index 303322fb2bf360..4016406125d75d 100644 --- a/tools/release/build-plugin-zip.mts +++ b/tools/release/build-plugin-zip.mts @@ -141,8 +141,8 @@ async function resetRepository(): Promise< void > { /** * Deletes the icons WordPress Core does not ship. An icon ships when its - * manifest entry carries a `public` property, whether that property is `true` - * or `false`. + * manifest entry sets `public` or `admin` to `true`, matching the entries + * `generateManifestPHP()` writes to `manifest.php`. * * This runs after the build so that icon collection validation still sees the * full library. @@ -150,14 +150,16 @@ async function resetRepository(): Promise< void > { function prunePrivateIcons(): void { status( 'Pruning non-public icons for WordPress Core... ✂️' ); - const manifest: { filePath: string; public?: boolean }[] = JSON.parse( + const manifest: { + filePath: string; + public?: boolean; + admin?: boolean; + }[] = JSON.parse( fs.readFileSync( path.join( ICONS_DIR, 'manifest.json' ), 'utf8' ) ); const shipped = new Set( manifest - .filter( - ( icon ) => icon.public !== undefined && icon.public !== null - ) + .filter( ( icon ) => icon.public === true || icon.admin === true ) .map( ( icon ) => icon.filePath ) ); From ef83a1a970db4d97793747bce5502334b4055fd3 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 22 Sep 2026 21:09:12 +0900 Subject: [PATCH 10/13] Icons: Cover the visibility of the default icon collections with tests Co-Authored-By: Claude --- phpunit/class-wp-icon-test.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/phpunit/class-wp-icon-test.php b/phpunit/class-wp-icon-test.php index 274804b1844266..495d3712cc2855 100644 --- a/phpunit/class-wp-icon-test.php +++ b/phpunit/class-wp-icon-test.php @@ -103,4 +103,21 @@ public function test_wp_get_icon_escapes_attributes() { $output = wp_get_icon( 'core/plus', array( 'class' => '">' ) ); $this->assertStringNotContainsString( '