PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/scripts/block-library/icon.php +27 -6 23.6.2 → 24.1.0 View file →
@@ -18,8 +18,17 @@
18 18 if ( empty( $attributes['icon'] ) ) {
19 19 return;
20 20 }
21 21
22 + // Icons in non-public collections 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 ( null !== $registered_icon ) {
25 + $icon_collection = WP_Icon_Collections_Registry::get_instance()->get_registered( $registered_icon['collection'] );
26 + if ( null !== $icon_collection && ! $icon_collection['public'] ) {
27 + return;
28 + }
29 + }
30 +
22 31 // Text color and background color.
23 32 $color_styles = array();
24 33
25 34 $preset_text_color = array_key_exists( 'textColor', $attributes ) ? "var:preset|color|{$attributes['textColor']}" : null;
@@ -95,9 +104,19 @@
95 104
96 105 $processor = new WP_HTML_Tag_Processor( $svg );
97 106 if ( $processor->next_tag( 'svg' ) ) {
98 107 if ( ! empty( $styles['css'] ) ) {
99 - $processor->set_attribute( 'style', $styles['css'] );
108 + // Merge with the SVG's intrinsic style (e.g. `fill: none` on
109 + // stroke-based icons) so it is preserved. The block styles come last
110 + // so they win on any conflicting property.
111 + $existing_style = $processor->get_attribute( 'style' );
112 + $trimmed_style = is_string( $existing_style )
113 + ? rtrim( trim( $existing_style ), ';' )
114 + : '';
115 + $merged_style = '' !== $trimmed_style
116 + ? $trimmed_style . '; ' . $styles['css']
117 + : $styles['css'];
118 + $processor->set_attribute( 'style', $merged_style );
100 119 }
101 120
102 121 // Apply flip classes to the SVG.
103 122 $flip_horizontal = $attributes['flipHorizontal'] ?? false;
@@ -114,13 +133,15 @@
114 133
115 134 if ( $rotation ) {
116 135 $current_style = $processor->get_attribute( 'style' ) ?? '';
117 136 $rotation_css = 'rotate: ' . $rotation . 'deg;';
118 - if ( $current_style ) {
119 - $processor->set_attribute( 'style', $current_style . ' ' . $rotation_css );
120 - } else {
121 - $processor->set_attribute( 'style', $rotation_css );
122 - }
137 + $trimmed_style = is_string( $current_style )
138 + ? rtrim( trim( $current_style ), ';' )
139 + : '';
140 + $merged_style = '' !== $trimmed_style
141 + ? $trimmed_style . '; ' . $rotation_css
142 + : $rotation_css;
143 + $processor->set_attribute( 'style', $merged_style );
123 144 }
124 145
125 146 $svg = $processor->get_updated_html();
126 147 }