From a44fafe9b8df4f860156314d094bc1ffbbfda75e Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 13 Mar 2026 00:53:10 +0900 Subject: [PATCH 01/14] Icons: Override WP_Icons_Registry singleton with Gutenberg icons registry --- .../class-gutenberg-icons-registry-7-1.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php index e827056064e7b1..bbd9a8226d5968 100644 --- a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php +++ b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php @@ -87,3 +87,16 @@ public static function get_instance() { return self::$instance; } } + +/** + * Forces Gutenberg_Icons_Registry_7_1 instantiation and overrides WP_Icons_Registry + * so that all code using WP_Icons_Registry::get_instance() receives the Gutenberg + * registry. + */ +function gutenberg_override_wp_icons_registry_7_1() { + $reflection = new ReflectionClass( WP_Icons_Registry::class ); + $property = $reflection->getProperty( 'instance' ); + $property->setAccessible( true ); + $property->setValue( null, Gutenberg_Icons_Registry_7_1::get_instance() ); +} +add_action( 'init', 'gutenberg_override_wp_icons_registry_7_1' ); From b61083927364b524b0598db72d9ae8101abcf7c6 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 13 Mar 2026 01:21:05 +0900 Subject: [PATCH 02/14] Remove Gutenberg_REST_Icons_Controller_7_1 --- .../class-gutenberg-icons-registry-7-1.php | 7 ++ ...ss-gutenberg-rest-icons-controller-7-1.php | 82 ------------------- lib/compat/wordpress-7.1/rest-api.php | 16 ---- lib/load.php | 1 - 4 files changed, 7 insertions(+), 99 deletions(-) delete mode 100644 lib/compat/wordpress-7.1/class-gutenberg-rest-icons-controller-7-1.php delete mode 100644 lib/compat/wordpress-7.1/rest-api.php diff --git a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php index bbd9a8226d5968..d8114cfc81eb59 100644 --- a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php +++ b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php @@ -50,6 +50,13 @@ protected function __construct() { } } + public function get_registered_icon( $icon_name ) { + return array( + 'name' => $icon_name, + 'content' => 'Rendered via Gutenberg_Icons_Registry_7_1 class.', + ); + } + /** * Modified to also search in icon labels */ diff --git a/lib/compat/wordpress-7.1/class-gutenberg-rest-icons-controller-7-1.php b/lib/compat/wordpress-7.1/class-gutenberg-rest-icons-controller-7-1.php deleted file mode 100644 index 17793de625afcf..00000000000000 --- a/lib/compat/wordpress-7.1/class-gutenberg-rest-icons-controller-7-1.php +++ /dev/null @@ -1,82 +0,0 @@ -namespace, - '/' . $this->rest_base, - array( - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_items' ), - 'permission_callback' => array( $this, 'get_items_permissions_check' ), - 'args' => $this->get_collection_params(), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ), - true // Override the core route. - ); - - register_rest_route( - $this->namespace, - '/' . $this->rest_base . '/(?P[a-z][a-z0-9-]*/[a-z][a-z0-9-]*)', - array( - 'args' => array( - 'name' => array( - 'description' => __( 'Icon name.', 'gutenberg' ), - 'type' => 'string', - ), - ), - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_item' ), - 'permission_callback' => array( $this, 'get_item_permissions_check' ), - 'args' => array( - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), - ), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ), - true // Override the core route. - ); - } - - /** - * Modified to call Gutenberg_Icons_Registry_7_1 - */ - public function get_items( $request ) { - $response = array(); - $search = $request->get_param( 'search' ); - $icons = Gutenberg_Icons_Registry_7_1::get_instance()->get_registered_icons( $search ); - foreach ( $icons as $icon ) { - $prepared_icon = $this->prepare_item_for_response( $icon, $request ); - $response[] = $this->prepare_response_for_collection( $prepared_icon ); - } - return rest_ensure_response( $response ); - } - - /** - * Modified to call Gutenberg_Icons_Registry_7_1 - */ - public function get_icon( $name ) { - $registry = Gutenberg_Icons_Registry_7_1::get_instance(); - $icon = $registry->get_registered_icon( $name ); - - if ( null === $icon ) { - return new WP_Error( - 'rest_icon_not_found', - sprintf( - // translators: %s is the name of any user-provided name - __( 'Icon not found: "%s".', 'gutenberg' ), - $name - ), - array( 'status' => 404 ) - ); - } - - return $icon; - } -} diff --git a/lib/compat/wordpress-7.1/rest-api.php b/lib/compat/wordpress-7.1/rest-api.php deleted file mode 100644 index 4d7ceaba5cd85f..00000000000000 --- a/lib/compat/wordpress-7.1/rest-api.php +++ /dev/null @@ -1,16 +0,0 @@ -register_routes(); -} -add_action( 'rest_api_init', 'gutenberg_register_icons_controller_endpoints', PHP_INT_MAX ); diff --git a/lib/load.php b/lib/load.php index b17ac1cf58a7af..3bde0bcaeee510 100644 --- a/lib/load.php +++ b/lib/load.php @@ -80,7 +80,6 @@ function gutenberg_is_experiment_enabled( $name ) { // WordPress 7.1 compat. require __DIR__ . '/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php'; - require __DIR__ . '/compat/wordpress-7.1/class-gutenberg-rest-icons-controller-7-1.php'; require __DIR__ . '/compat/wordpress-7.1/rest-api.php'; // Plugin specific code. From 55892ed03608a1c9c564adb5e9a92af6e6976dec Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 13 Mar 2026 01:28:13 +0900 Subject: [PATCH 03/14] Remove require statement --- lib/load.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/load.php b/lib/load.php index 3bde0bcaeee510..bb3e26b73e6482 100644 --- a/lib/load.php +++ b/lib/load.php @@ -80,7 +80,6 @@ function gutenberg_is_experiment_enabled( $name ) { // WordPress 7.1 compat. require __DIR__ . '/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php'; - require __DIR__ . '/compat/wordpress-7.1/rest-api.php'; // Plugin specific code. require_once __DIR__ . '/class-wp-rest-global-styles-controller-gutenberg.php'; From 78ec29f92c51ea205c57dd1f2bb0a033970c657c Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 13 Mar 2026 01:34:34 +0900 Subject: [PATCH 04/14] Remove temp code --- .../wordpress-7.1/class-gutenberg-icons-registry-7-1.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php index d8114cfc81eb59..bbd9a8226d5968 100644 --- a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php +++ b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php @@ -50,13 +50,6 @@ protected function __construct() { } } - public function get_registered_icon( $icon_name ) { - return array( - 'name' => $icon_name, - 'content' => 'Rendered via Gutenberg_Icons_Registry_7_1 class.', - ); - } - /** * Modified to also search in icon labels */ From d0daaf6b077a2013464a554005d45b55699e7747 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 13 Mar 2026 01:45:13 +0900 Subject: [PATCH 05/14] Update comment --- lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php index bbd9a8226d5968..f792bde4b4af2a 100644 --- a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php +++ b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php @@ -90,7 +90,7 @@ public static function get_instance() { /** * Forces Gutenberg_Icons_Registry_7_1 instantiation and overrides WP_Icons_Registry - * so that all code using WP_Icons_Registry::get_instance() receives the Gutenberg + * so that all code using WP_Icons_Registry::{method_name}() receives the Gutenberg * registry. */ function gutenberg_override_wp_icons_registry_7_1() { From 491c9fbeaad539959078724d435d973e417ca096 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 13 Mar 2026 10:32:52 +0900 Subject: [PATCH 06/14] Replay pre-registered non-core icons --- .../class-gutenberg-icons-registry-7-1.php | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php index f792bde4b4af2a..9fb30ecd60103d 100644 --- a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php +++ b/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php @@ -97,6 +97,29 @@ function gutenberg_override_wp_icons_registry_7_1() { $reflection = new ReflectionClass( WP_Icons_Registry::class ); $property = $reflection->getProperty( 'instance' ); $property->setAccessible( true ); - $property->setValue( null, Gutenberg_Icons_Registry_7_1::get_instance() ); + $original_registry = $property->getValue( null ); + $gutenberg_registry = Gutenberg_Icons_Registry_7_1::get_instance(); + + // If the original registry was already instantiated, replay any icons outside + // the `core/` namespace onto the Gutenberg registry so they are not lost. + if ( null !== $original_registry ) { + $register_method = new ReflectionMethod( Gutenberg_Icons_Registry_7_1::class, 'register' ); + $register_method->setAccessible( true ); + foreach ( $original_registry->get_registered_icons() as $icon ) { + if ( strpos( $icon['name'], 'core/' ) === 0 ) { + continue; + } + $icon_properties = array( 'label' => $icon['label'] ); + if ( ! empty( $icon['content'] ) ) { + $icon_properties['content'] = $icon['content']; + } elseif ( ! empty( $icon['filePath'] ) ) { + $icon_properties['filePath'] = $icon['filePath']; + } else { + continue; + } + $register_method->invoke( $gutenberg_registry, $icon['name'], $icon_properties ); + } + } + $property->setValue( null, $gutenberg_registry ); } -add_action( 'init', 'gutenberg_override_wp_icons_registry_7_1' ); +add_action( 'init', 'gutenberg_override_wp_icons_registry_7_1', 1 ); From 7d47012172bf146665d55d984fb7657a25ad9f0d Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 13 Mar 2026 19:11:59 +0900 Subject: [PATCH 07/14] Create registry and REST API controller for Gutenberg --- ... => class-wp-icons-registry-gutenberg.php} | 12 +++++----- ...ass-wp-rest-icons-controller-gutenberg.php | 22 +++++++++++++++++++ lib/load.php | 5 ++--- lib/rest-api.php | 4 ++-- 4 files changed, 32 insertions(+), 11 deletions(-) rename lib/{compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php => class-wp-icons-registry-gutenberg.php} (87%) create mode 100644 lib/class-wp-rest-icons-controller-gutenberg.php diff --git a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php b/lib/class-wp-icons-registry-gutenberg.php similarity index 87% rename from lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php rename to lib/class-wp-icons-registry-gutenberg.php index 9fb30ecd60103d..e361ab3372d4d5 100644 --- a/lib/compat/wordpress-7.1/class-gutenberg-icons-registry-7-1.php +++ b/lib/class-wp-icons-registry-gutenberg.php @@ -1,6 +1,6 @@ getProperty( 'instance' ); $property->setAccessible( true ); $original_registry = $property->getValue( null ); - $gutenberg_registry = Gutenberg_Icons_Registry_7_1::get_instance(); + $gutenberg_registry = WP_Icons_Registry_Gutenberg::get_instance(); // If the original registry was already instantiated, replay any icons outside // the `core/` namespace onto the Gutenberg registry so they are not lost. if ( null !== $original_registry ) { - $register_method = new ReflectionMethod( Gutenberg_Icons_Registry_7_1::class, 'register' ); + $register_method = new ReflectionMethod( WP_Icons_Registry_Gutenberg::class, 'register' ); $register_method->setAccessible( true ); foreach ( $original_registry->get_registered_icons() as $icon ) { if ( strpos( $icon['name'], 'core/' ) === 0 ) { @@ -122,4 +122,4 @@ function gutenberg_override_wp_icons_registry_7_1() { } $property->setValue( null, $gutenberg_registry ); } -add_action( 'init', 'gutenberg_override_wp_icons_registry_7_1', 1 ); +add_action( 'init', 'gutenberg_override_wp_icons_registry', 1 ); diff --git a/lib/class-wp-rest-icons-controller-gutenberg.php b/lib/class-wp-rest-icons-controller-gutenberg.php new file mode 100644 index 00000000000000..4d266101dc8374 --- /dev/null +++ b/lib/class-wp-rest-icons-controller-gutenberg.php @@ -0,0 +1,22 @@ +register_routes(); + $icons_controller = new WP_REST_Icons_Controller_Gutenberg(); + $icons_controller->register_routes(); } add_action( 'rest_api_init', 'gutenberg_register_icon_controller_endpoints' ); From 196e4b30f66f778dad721958f47fbc0134fa95fd Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Fri, 13 Mar 2026 19:13:19 +0900 Subject: [PATCH 08/14] WP_REST_Icons_Controller_Gutenberg: Remove unnecessary ABSPATH check --- lib/class-wp-rest-icons-controller-gutenberg.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/class-wp-rest-icons-controller-gutenberg.php b/lib/class-wp-rest-icons-controller-gutenberg.php index 4d266101dc8374..e20c5a39e19645 100644 --- a/lib/class-wp-rest-icons-controller-gutenberg.php +++ b/lib/class-wp-rest-icons-controller-gutenberg.php @@ -9,10 +9,6 @@ * @subpackage REST_API */ -if ( ! defined( 'ABSPATH' ) ) { - die( 'Silence is golden.' ); -} - /** * Gutenberg Icons REST API Controller. * From c56e31c27ac9281c67de8adae7c33eaffabb4436 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Thu, 19 Mar 2026 18:45:01 +0900 Subject: [PATCH 09/14] Fix misplaced files --- .../class-gutenberg-rest-view-config-controller-7-1.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/{ => compat/wordpress-7.1}/class-gutenberg-rest-view-config-controller-7-1.php (100%) diff --git a/lib/class-gutenberg-rest-view-config-controller-7-1.php b/lib/compat/wordpress-7.1/class-gutenberg-rest-view-config-controller-7-1.php similarity index 100% rename from lib/class-gutenberg-rest-view-config-controller-7-1.php rename to lib/compat/wordpress-7.1/class-gutenberg-rest-view-config-controller-7-1.php From b30292f3735a634957fc6562ba4eacfe0f7b1850 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 31 Mar 2026 18:27:34 +0900 Subject: [PATCH 10/14] Restore code that was accidentally deleted --- lib/compat/wordpress-7.1/rest-api.php | 16 ++++++++++++++++ lib/load.php | 1 + 2 files changed, 17 insertions(+) create mode 100644 lib/compat/wordpress-7.1/rest-api.php diff --git a/lib/compat/wordpress-7.1/rest-api.php b/lib/compat/wordpress-7.1/rest-api.php new file mode 100644 index 00000000000000..da8acb5309f22e --- /dev/null +++ b/lib/compat/wordpress-7.1/rest-api.php @@ -0,0 +1,16 @@ +register_routes(); +} +add_action( 'rest_api_init', 'gutenberg_register_view_config_controller_endpoints', PHP_INT_MAX ); diff --git a/lib/load.php b/lib/load.php index 601b612e03fdc2..f899d34e071d19 100644 --- a/lib/load.php +++ b/lib/load.php @@ -81,6 +81,7 @@ function gutenberg_is_experiment_enabled( $name ) { // WordPress 7.1 compat. require __DIR__ . '/compat/wordpress-7.1/class-gutenberg-rest-view-config-controller-7-1.php'; + require __DIR__ . '/compat/wordpress-7.1/rest-api.php'; // Plugin specific code. require_once __DIR__ . '/class-wp-rest-global-styles-controller-gutenberg.php'; From 55b6070d4efe1b3a5fb5ba2169fa70f12ee3c9f8 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 1 Apr 2026 12:07:41 +0900 Subject: [PATCH 11/14] Update unit test --- ...> class-wp-icons-registry-gutenberg-test.php} | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename phpunit/experimental/{class-gutenberg-icons-registry-7-1-test.php => class-wp-icons-registry-gutenberg-test.php} (83%) diff --git a/phpunit/experimental/class-gutenberg-icons-registry-7-1-test.php b/phpunit/experimental/class-wp-icons-registry-gutenberg-test.php similarity index 83% rename from phpunit/experimental/class-gutenberg-icons-registry-7-1-test.php rename to phpunit/experimental/class-wp-icons-registry-gutenberg-test.php index 89696277f4720a..68f60b730ff8bc 100644 --- a/phpunit/experimental/class-gutenberg-icons-registry-7-1-test.php +++ b/phpunit/experimental/class-wp-icons-registry-gutenberg-test.php @@ -1,25 +1,25 @@ registry = Gutenberg_Icons_Registry_7_1::get_instance(); + $this->registry = WP_Icons_Registry_Gutenberg::get_instance(); } public function tear_down() { - $instance_property = new ReflectionProperty( Gutenberg_Icons_Registry_7_1::class, 'instance' ); + $instance_property = new ReflectionProperty( WP_Icons_Registry_Gutenberg::class, 'instance' ); /* * ReflectionProperty::setAccessible is: @@ -38,7 +38,7 @@ public function tear_down() { } /** - * Invokes Gutenberg_Icons_Registry_7_1::register despite it being private + * Invokes WP_Icons_Registry_Gutenberg::register despite it being private * * @param string $icon_name Icon name including namespace. * @param array $icon_properties Icon properties (label, content, filePath). @@ -92,7 +92,7 @@ public function data_invalid_icon_names() { /** * Should fail to re-register the same icon. * - * @expectedIncorrectUsage Gutenberg_Icons_Registry_7_1::register + * @expectedIncorrectUsage WP_Icons_Registry_Gutenberg::register */ public function test_register_icon_twice() { $name = 'test-plugin/duplicate'; @@ -111,7 +111,7 @@ public function test_register_icon_twice() { * Should fail to register icon with invalid names. * * @dataProvider data_invalid_icon_names - * @expectedIncorrectUsage Gutenberg_Icons_Registry_7_1::register + * @expectedIncorrectUsage WP_Icons_Registry_Gutenberg::register */ public function test_register_invalid_name() { foreach ( $this->data_invalid_icon_names() as $name ) { From 14fe750d6fa4d4e5d98c755d54c4a8f5f6adda1a Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 1 Apr 2026 12:10:46 +0900 Subject: [PATCH 12/14] Fix PHPCS warning --- lib/class-wp-icons-registry-gutenberg.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/class-wp-icons-registry-gutenberg.php b/lib/class-wp-icons-registry-gutenberg.php index 376f05d41cfdc9..7d652034ae97d0 100644 --- a/lib/class-wp-icons-registry-gutenberg.php +++ b/lib/class-wp-icons-registry-gutenberg.php @@ -78,7 +78,7 @@ protected function register( $icon_name, $icon_properties ) { if ( preg_match( '/[A-Z]/', $icon_name ) ) { _doing_it_wrong( __METHOD__, - __( 'Icon names must not contain uppercase characters.' ), + __( 'Icon names must not contain uppercase characters.', 'gutenberg' ), '7.1.0' ); return false; @@ -97,7 +97,7 @@ protected function register( $icon_name, $icon_properties ) { if ( $this->is_registered( $icon_name ) ) { _doing_it_wrong( __METHOD__, - __( 'Icon is already registered.' ), + __( 'Icon is already registered.', 'gutenberg' ), '7.1.0' ); return false; From a3027c66556a173f7d5bd2d6701d4a42feeb187f Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 1 Apr 2026 12:17:52 +0900 Subject: [PATCH 13/14] Fix PHPCS warning take 2 --- lib/class-wp-icons-registry-gutenberg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-wp-icons-registry-gutenberg.php b/lib/class-wp-icons-registry-gutenberg.php index 7d652034ae97d0..271859ebce1393 100644 --- a/lib/class-wp-icons-registry-gutenberg.php +++ b/lib/class-wp-icons-registry-gutenberg.php @@ -88,7 +88,7 @@ protected function register( $icon_name, $icon_properties ) { if ( ! preg_match( $name_matcher, $icon_name ) ) { _doing_it_wrong( __METHOD__, - __( 'Icon names must contain a namespace prefix. Example: my-plugin/my-custom-icon' ), + __( 'Icon names must contain a namespace prefix. Example: my-plugin/my-custom-icon', 'gutenberg' ), '7.1.0' ); return false; From 60bafaa2d3dfd77a92509dfca9c5492c28f456c3 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 8 Apr 2026 15:57:03 +0900 Subject: [PATCH 14/14] Add PHP version check --- lib/class-wp-icons-registry-gutenberg.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/class-wp-icons-registry-gutenberg.php b/lib/class-wp-icons-registry-gutenberg.php index 271859ebce1393..c652bcfb924e2d 100644 --- a/lib/class-wp-icons-registry-gutenberg.php +++ b/lib/class-wp-icons-registry-gutenberg.php @@ -217,7 +217,15 @@ public static function get_instance() { function gutenberg_override_wp_icons_registry() { $reflection = new ReflectionClass( WP_Icons_Registry::class ); $property = $reflection->getProperty( 'instance' ); - $property->setAccessible( true ); + /* + * ReflectionProperty::setAccessible is: + * - redundant as of 8.1.0, which made all properties accessible + * - deprecated as of 8.5.0 + * - needed until 8.1.0, as property `instance` is private + */ + if ( PHP_VERSION_ID < 80100 ) { + $property->setAccessible( true ); + } $original_registry = $property->getValue( null ); $gutenberg_registry = WP_Icons_Registry_Gutenberg::get_instance(); @@ -225,7 +233,15 @@ function gutenberg_override_wp_icons_registry() { // the `core/` namespace onto the Gutenberg registry so they are not lost. if ( null !== $original_registry ) { $register_method = new ReflectionMethod( WP_Icons_Registry_Gutenberg::class, 'register' ); - $register_method->setAccessible( true ); + /* + * ReflectionMethod::setAccessible is: + * - redundant as of 8.1.0, which made all properties accessible + * - deprecated as of 8.5.0 + * - needed until 8.1.0, as property `instance` is private + */ + if ( PHP_VERSION_ID < 80100 ) { + $register_method->setAccessible( true ); + } foreach ( $original_registry->get_registered_icons() as $icon ) { if ( strpos( $icon['name'], 'core/' ) === 0 ) { continue;