Skip to content

Icons: Add a manifest containing icons metadata#74943

Merged
mcsf merged 15 commits intotrunkfrom
add/icons-library-manifest
Jan 26, 2026
Merged

Icons: Add a manifest containing icons metadata#74943
mcsf merged 15 commits intotrunkfrom
add/icons-library-manifest

Conversation

@mcsf
Copy link
Copy Markdown
Contributor

@mcsf mcsf commented Jan 26, 2026

What?

Related: Icons registration API and REST endpoint (#72215)
Related: Icon block (#71227)

Adds a file to the Icons package listing all the core icons along with their labels:

'add-card' => array(
	'label'    => _x( 'Add Card', 'icon label', 'gutenberg' ),
	'filePath' => 'library/add-card.svg',
),

// ...

'wordpress' => array(
	'label'    => _x( 'WordPress', 'icon label', 'gutenberg' ),
	'filePath' => 'library/wordpress.svg',
),

Why?

To allow core icons to have metadata. For now, it's only labels, but it could support categories, etc., in order to support the needs of the Icon block. This would allow WP_Icons_Registry::register, a method currently proposed in #72215, to register icons based on that manifest and have all that metadata available.

How?

  • Generated packages/icons/src/manifest.php from the available SVG icons and capitalised their labels automatically (and a manual correction for "WordPress" 😉).
  • Added a step to the package's generate-library script called validate-manifest.
    • This doesn't actually validate the PHP file, because invoking php (whether natively or as npm run env run cli php) in the middle of an NPM/Node call tree feels overkill.
    • Instead, it assumes that the manifest is valid PHP and scans it for text patterns to run some fast heuristics:
      • All the SVG files present in packages/icons/src/library/*.svg are listed in the manifest
      • All the entries in the manifest point to a valid SVG file in packages/icons/src/library/*.svg

Alternatives

  • Instead of PHP, it could be manifest.json, but this would require more infrastructure work to make it translatable. Most likely, it would include patching wp i18n's JsonSchemaExtractor. This seems a bit too much.
  • Actually parse the PHP file in order to really validate it. Right now I'd rather have something imperfect but fast, but we can change later on if people feel very strongly about this.

Testing Instructions

Run npm run -w packages/icons build, then verify:

  • No change in behaviour, i.e. files index.ts and *.tsx under packages/icons/src/library/ are correctly generated
  • No errors, in particular none from the validation of the manifest

Verify that errors are raised after tampering with / renaming SVG files or with entries in the manifest.

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

Labels

[Package] Icons /packages/icons [Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants