Make WordPress Core

Opened 4 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#66087 closed enhancement (fixed)

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

Reported by: fushar Owned by: mcsf
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 (7)

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


4 weeks 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.

#2 @mcsf
3 weeks ago

  • Owner set to mcsf
  • Resolution → fixed
  • Status new → closed

In 63625:

Icons: Add public property to hide registered icons from REST API.

Expand the signature of WP_Icons_Registry::register and wp_register_icon to accept an optional boolean property, public, which controls whether a given icon should be exposed in the REST API. It defaults to true.

An icon registered with public set to false will nevertheless remain accessible to wp_get_icon and other direct consumers of WP_Icons_Registry.

Developed in: ​https://github.com/WordPress/gutenberg/pull/82634
Developed in: ​https://github.com/WordPress/wordpress-develop/pull/13453

Props fushar.

Fixes #66087.

This ticket was mentioned in ​PR #13633 on ​WordPress/wordpress-develop by ​@wildworks.


2 weeks ago
#3

Moves icon visibility from the icon level to the collection level.

wp_register_icon_collection() now accepts a public property (default true), and the icons / icon collections REST controllers hide non-public collections and every icon in them. Those icons remain available to server-side code via wp_get_icon().

Backports ​https://github.com/WordPress/gutenberg/pull/83277 to core. See that PR for the rationale.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Porting the Gutenberg implementation and tests to core; reviewed and edited by me.

#4 @wildworks
2 weeks ago

Reopening this ticket as the public property needs to be moved from the icon-level to the collection-level.

See ​https://github.com/WordPress/gutenberg/pull/83261#issuecomment-5758936393 for more details.

#5 @wildworks
2 weeks ago

  • Resolution fixed
  • Status closed → reopened

​@wildworks commented on ​PR #13633:


2 weeks ago
#6

Closing: this has been folded into #13625, since the two changes cannot really be reviewed apart. The commit is preserved there.

#7 @wildworks
2 weeks ago

  • Resolution → fixed
  • Status reopened → closed

Reopening this ticket as the public property needs to be moved from the icon-level to the collection-level.

See ​https://github.com/WordPress/gutenberg/pull/83261#issuecomment-5758936393 for more details.

Since I have decided to address this issue in #66114, I am re-closing this ticket.

Last edited 2 weeks ago by wildworks (previous) (diff)
Note: See TracTickets for help on using tickets.