Make WordPress Core

Opened 6 hours ago

Last modified 6 hours ago

#66087 new enhancement

Icons: Allow registering icons that are hidden from the REST API

Reported by: fushar Owned by:
Priority: normal Milestone: 7.2
Component: REST API Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

To support replacing Dashicons with SVG icons in admin screens via #65089, we need a way to register an icon which is available via wp_get_icon() but not available via REST API and not exposed in the Icon block.

The current consensus of the approach has been discussed here: https://github.com/WordPress/gutenberg/pull/79451#issuecomment-4797981729. In short, we propose to allow a new property public when registering an icon via wp_register_icon().

Here's a summary of the behavior:

Registered with Registry / wp_get_icon() REST API / Icon block
public omitted or true yes yes
public: false yes no

This Trac ticket is also tracking Core backport for the Gutenberg-side changes here: https://github.com/WordPress/gutenberg/pull/82634.

Change History (1)

This ticket was mentioned in PR #13453 on WordPress/wordpress-develop by @fushar.


6 hours ago
#1

  • Keywords has-patch has-unit-tests added

Trac ticket: https://core.trac.wordpress.org/ticket/66087.
Backport from https://github.com/WordPress/gutenberg/pull/82634.

## What

This PR allows an optional boolean public property to icon registration via wp_register_icon().

Icons registered with public: false will still be available through wp_get_icon(), but the REST API will not return them, so they aren't exposed in the Icon block.

As a back-compatibility, if we don't provide a public property, the default is true and the behavior will be the same as the existing behavior.

Here's a summary of the behavior:

Registered with Registry /wp_get_icon() REST API / Icon block
public omitted or true yes yes
public: false yes no

## Use of AI Tools

Used Claude Opus to generate the backported changes from the linked Gutenberg PR, then checked the changes myself.

Note: See TracTickets for help on using tickets.