Skip to content

Icons Registry: Don't expose "internal" icons#75526

Merged
mcsf merged 8 commits intotrunkfrom
update/hide-icons-from-library
Feb 16, 2026
Merged

Icons Registry: Don't expose "internal" icons#75526
mcsf merged 8 commits intotrunkfrom
update/hide-icons-from-library

Conversation

@mcsf
Copy link
Copy Markdown
Contributor

@mcsf mcsf commented Feb 13, 2026

What?

Follow-up of #72215

Follow @jasmussen's recommendation to try to distinguish icons meant for internal use only and those we'd like to expose to consumers such as the Icon block (#71227), i.e. those icons that users are more likely to want to use in the front end:

icons-public-private

How?

  • In the icons manifest, introduce an optional array property public
  • In the icons registry, ignore any manifest entry that doesn't have 'public' => true

Why not simply remove them from the manifest?

We can, but by keeping them (and adding this property) we can keep our validate-collection script, which helps us ensure that the manifest and the SVG files never go out of sync. This seems like a better tradeoff.

Testing Instructions

(outdated) To properly visualise the icons grid, apply the following patch — which is a modified version of @t-hamano's snippet from #75273 — then, in a fresh post editor, insert block "Icon List Test".

(outdated snippet)
diff --git a/lib/experimental/class-wp-icons-registry.php b/lib/experimental/class-wp-icons-registry.php
index aefd83f718c..7ce27c23eca 100644
--- a/lib/experimental/class-wp-icons-registry.php
+++ b/lib/experimental/class-wp-icons-registry.php
@@ -63,8 +63,10 @@ if ( ! class_exists( 'WP_Icons_Registry' ) ) {
 					continue;
 				}
 
+				$tail = $status !== '' ? '--ignored' : '';
+
 				$this->register(
-					'core/' . $icon_name,
+					'core/' . $icon_name . $tail,
 					array(
 						'label'    => $icon_data['label'],
 						'filePath' => $icons_directory . $icon_data['filePath'],
diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js
index f891ec38c0a..422b141db18 100644
--- a/packages/block-library/src/index.js
+++ b/packages/block-library/src/index.js
@@ -446,3 +446,55 @@ export const __experimentalRegisterExperimentalCoreBlocks =
 		: undefined;
 
 export { privateApis } from './private-apis';
+
+wp.blocks.registerBlockType( 'test/icon-list', {
+	apiVersion: 3,
+	title: 'Icon List Test',
+	edit: class Edit extends wp.element.Component {
+		constructor( props ) {
+			super( props );
+			this.state = { icons: [] };
+		}
+		componentDidMount() {
+			wp.apiFetch( { path: '/wp/v2/icons' } ).then( ( data ) => {
+				this.setState( {
+					icons: Array.isArray( data ) ? data : [],
+				} );
+			} );
+		}
+		render() {
+			return wp.element.createElement(
+				'div',
+				{},
+				wp.element.createElement(
+					'div',
+					{
+						style: {
+							display: 'grid',
+							gridTemplateColumns:
+								'repeat(21, minmax(32px, 1fr))',
+							gap: '4px',
+							padding: 0,
+						},
+					},
+					this.state.icons.map( ( icon ) =>
+						wp.element.createElement( 'div', {
+							key: icon.name,
+							style: {
+								width: 32,
+								height: 32,
+								opacity: icon.name.endsWith( '--ignored' )
+									? 0.3
+									: 1,
+							},
+							title: icon.name,
+							dangerouslySetInnerHTML: {
+								__html: icon.content || '',
+							},
+						} )
+					)
+				)
+			);
+		}
+	},
+} );

To view the full set, including disabled icons, comment out the statement continue; in WP_Icons_Registry::__construct where it ignores hidden/disabled icons.

Screenshots or screencast

Comparison of expected and actual grid:

Screenshot 2026-02-13 at 15 08 30

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Icon Affects the Icon block [Package] Icons /packages/icons [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants