File tree Expand file tree Collapse file tree
packages/block-library/src/icon Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ function render_block_core_icon( $attributes ) {
1919 return ;
2020 }
2121
22+ // Non-public icons are not available in the editor, so do not render them either.
23+ $ registered_icon = WP_Icons_Registry::get_instance ()->get_registered_icon ( $ attributes ['icon ' ] );
24+ if ( false === ( $ registered_icon ['public ' ] ?? true ) ) {
25+ return ;
26+ }
27+
2228 // Text color and background color.
2329 $ color_styles = array ();
2430
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ public function set_up() {
3131 if ( ! WP_Icon_Collections_Registry::get_instance ()->is_registered ( 'core ' ) ) {
3232 gutenberg_register_default_icon_collections ();
3333 }
34- if ( empty ( WP_Icons_Registry ::get_instance ()->get_registered_icons () ) ) {
34+ if ( empty ( WP_Icons_Registry_Gutenberg ::get_instance ()->get_registered_icons () ) ) {
3535 gutenberg_register_default_icons ();
3636 }
3737 }
@@ -42,6 +42,11 @@ public function tear_down() {
4242 parent ::tear_down ();
4343 }
4444
45+ public function test_does_not_render_non_public_icon () {
46+ $ this ->assertNotEmpty ( wp_get_icon ( 'core/wordpress ' ) );
47+ $ this ->assertEmpty ( gutenberg_render_block_core_icon ( array ( 'icon ' => 'core/wordpress ' ) ) );
48+ }
49+
4550 public function test_preserves_intrinsic_svg_style_when_applying_block_styles () {
4651 $ output = gutenberg_render_block_core_icon (
4752 array (
You can’t perform that action at this time.
0 commit comments