From e8bbca0a8a6f57c1673cbd83d91444a20a699bc2 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca <150562+mcsf@users.noreply.github.com> Date: Wed, 25 Feb 2026 17:18:18 +0000 Subject: [PATCH 1/3] WP_Icons_Registry: Make private methods & constants protected This will make it easier to iterate on WP_Icons_Registry in Gutenberg by allowing us to define derived classes (Gutenberg_Icons_Registry extends WP_Icons_Registry) and inherit any methods or constants that are untouched by referenced by the derived class. --- src/wp-includes/class-wp-icons-registry.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/class-wp-icons-registry.php b/src/wp-includes/class-wp-icons-registry.php index 32c4ad83bc396..2e306bec77e53 100644 --- a/src/wp-includes/class-wp-icons-registry.php +++ b/src/wp-includes/class-wp-icons-registry.php @@ -18,7 +18,7 @@ class WP_Icons_Registry { * * @var array[] */ - private $registered_icons = array(); + protected $registered_icons = array(); /** @@ -26,12 +26,12 @@ class WP_Icons_Registry { * * @var WP_Icons_Registry|null */ - private static $instance = null; + protected static $instance = null; /** * Constructor. * - * WP_Icons_Registry is a singleton class, so keep this private. + * WP_Icons_Registry is a singleton class, so keep this protected. * * For 7.0, the Icons Registry is closed for third-party icon registry, * serving only a subset of core icons. @@ -40,7 +40,7 @@ class WP_Icons_Registry { * SVG files and as entries in a single manifest file. On init, the * registry is loaded with those icons listed in the manifest. */ - private function __construct() { + protected function __construct() { $icons_directory = __DIR__ . '/icons/'; $icons_directory = trailingslashit( $icons_directory ); $manifest_path = $icons_directory . 'manifest.php'; @@ -101,7 +101,7 @@ private function __construct() { * } * @return bool True if the icon was registered with success and false otherwise. */ - private function register( $icon_name, $icon_properties ) { + protected function register( $icon_name, $icon_properties ) { if ( ! isset( $icon_name ) || ! is_string( $icon_name ) ) { _doing_it_wrong( __METHOD__, @@ -188,7 +188,7 @@ private function register( $icon_name, $icon_properties ) { * @param string $icon_content The icon SVG content to sanitize. * @return string The sanitized icon SVG content. */ - private function sanitize_icon_content( $icon_content ) { + protected function sanitize_icon_content( $icon_content ) { $allowed_tags = array( 'svg' => array( 'class' => true, @@ -223,7 +223,7 @@ private function sanitize_icon_content( $icon_content ) { * @param string $icon_name Icon name including namespace. * @return string|null The content of the icon, if found. */ - private function get_content( $icon_name ) { + protected function get_content( $icon_name ) { if ( ! isset( $this->registered_icons[ $icon_name ]['content'] ) ) { $content = file_get_contents( $this->registered_icons[ $icon_name ]['filePath'] From 40dba1d85963cba9b1567a888e5e4f082fcd94b6 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca <150562+mcsf@users.noreply.github.com> Date: Wed, 25 Feb 2026 17:28:03 +0000 Subject: [PATCH 2/3] WP_Icons_Registry: Add filter icons_registry_core_manifest This is so that the Gutenberg plugin can easily provide new core icons in between major WordPress releases. On the other hand, we will probably end up redefining whole methods on the Gutenberg side as we improve WP_Icons_Registry, so it may be moot to introduce a filter just for the manifest file. --- src/wp-includes/class-wp-icons-registry.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/class-wp-icons-registry.php b/src/wp-includes/class-wp-icons-registry.php index 2e306bec77e53..fa472b9abe007 100644 --- a/src/wp-includes/class-wp-icons-registry.php +++ b/src/wp-includes/class-wp-icons-registry.php @@ -44,6 +44,7 @@ protected function __construct() { $icons_directory = __DIR__ . '/icons/'; $icons_directory = trailingslashit( $icons_directory ); $manifest_path = $icons_directory . 'manifest.php'; + $manifest_path = apply_filters( 'icons_registry_core_manifest', $manifest_path ); if ( ! is_readable( $manifest_path ) ) { wp_trigger_error( From 6872a21494b26e2a895bc1da6fd4ba9cd550593a Mon Sep 17 00:00:00 2001 From: Miguel Fonseca <150562+mcsf@users.noreply.github.com> Date: Thu, 26 Feb 2026 10:46:51 +0000 Subject: [PATCH 3/3] Revert "WP_Icons_Registry: Add filter icons_registry_core_manifest" We can think about this later on. I don't want to expose things unnecessarily, but still wanted to show the concept. This reverts commit 40dba1d85963cba9b1567a888e5e4f082fcd94b6. --- src/wp-includes/class-wp-icons-registry.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wp-includes/class-wp-icons-registry.php b/src/wp-includes/class-wp-icons-registry.php index fa472b9abe007..2e306bec77e53 100644 --- a/src/wp-includes/class-wp-icons-registry.php +++ b/src/wp-includes/class-wp-icons-registry.php @@ -44,7 +44,6 @@ protected function __construct() { $icons_directory = __DIR__ . '/icons/'; $icons_directory = trailingslashit( $icons_directory ); $manifest_path = $icons_directory . 'manifest.php'; - $manifest_path = apply_filters( 'icons_registry_core_manifest', $manifest_path ); if ( ! is_readable( $manifest_path ) ) { wp_trigger_error(