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 | lib/block-supports/typography.php +23 -6 23.1.0 → 24.1.0 View file →
@@ -30,8 +30,9 @@
30 30 $has_text_columns_support = $typography_supports['textColumns'] ?? false;
31 31 $has_text_decoration_support = $typography_supports['__experimentalTextDecoration'] ?? false;
32 32 $has_text_transform_support = $typography_supports['__experimentalTextTransform'] ?? false;
33 33 $has_text_indent_support = $typography_supports['textIndent'] ?? false;
34 + $has_text_shadow_support = $typography_supports['textShadow'] ?? false;
34 35 $has_writing_mode_support = $typography_supports['__experimentalWritingMode'] ?? false;
35 36
36 37 $has_typography_support = $has_font_family_support
37 38 || $has_font_size_support
@@ -43,8 +44,9 @@
43 44 || $has_text_columns_support
44 45 || $has_text_decoration_support
45 46 || $has_text_transform_support
46 47 || $has_text_indent_support
48 + || $has_text_shadow_support
47 49 || $has_writing_mode_support;
48 50
49 51 if ( ! $block_type->attributes ) {
50 52 $block_type->attributes = array();
@@ -66,8 +68,14 @@
66 68 $block_type->attributes['fontFamily'] = array(
67 69 'type' => 'string',
68 70 );
69 71 }
72 +
73 + if ( $has_text_shadow_support && ! array_key_exists( 'textShadow', $block_type->attributes ) ) {
74 + $block_type->attributes['textShadow'] = array(
75 + 'type' => 'string',
76 + );
77 + }
70 78 }
71 79
72 80 /**
73 81 * Add CSS classes and inline styles for typography features such as font sizes
@@ -73,10 +81,10 @@
73 81 * Add CSS classes and inline styles for typography features such as font sizes
74 82 * to the incoming attributes array. This will be applied to the block markup in
75 83 * the front-end.
76 84 *
77 - * @param WP_Block_Type $block_type Block type.
78 - * @param array $block_attributes Block attributes.
85 + * @param WP_Block_Type $block_type Block type.
86 + * @param array $block_attributes Block attributes.
79 87 *
80 88 * @return array Typography CSS classes and inline styles.
81 89 */
82 90 function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
@@ -103,8 +111,9 @@
103 111 $has_text_columns_support = $typography_supports['textColumns'] ?? false;
104 112 $has_text_decoration_support = $typography_supports['__experimentalTextDecoration'] ?? false;
105 113 $has_text_transform_support = $typography_supports['__experimentalTextTransform'] ?? false;
106 114 $has_text_indent_support = $typography_supports['textIndent'] ?? false;
115 + $has_text_shadow_support = $typography_supports['textShadow'] ?? false;
107 116 $has_writing_mode_support = $typography_supports['__experimentalWritingMode'] ?? false;
108 117
109 118 // Whether to skip individual block support features.
110 119 $should_skip_font_size = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontSize' );
@@ -117,8 +126,9 @@
117 126 $should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' );
118 127 $should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' );
119 128 $should_skip_letter_spacing = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' );
120 129 $should_skip_text_indent = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textIndent' );
130 + $should_skip_text_shadow = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textShadow' );
121 131 $should_skip_writing_mode = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'writingMode' );
122 132
123 133 $typography_block_styles = array();
124 134 if ( $has_font_size_support && ! $should_skip_font_size ) {
@@ -181,8 +191,14 @@
181 191 if ( $has_text_indent_support && ! $should_skip_text_indent && isset( $block_attributes['style']['typography']['textIndent'] ) ) {
182 192 $typography_block_styles['textIndent'] = $block_attributes['style']['typography']['textIndent'] ?? null;
183 193 }
184 194
195 + if ( $has_text_shadow_support && ! $should_skip_text_shadow ) {
196 + $preset_text_shadow = array_key_exists( 'textShadow', $block_attributes ) ? "var:preset|text-shadow|{$block_attributes['textShadow']}" : null;
197 + $custom_text_shadow = $block_attributes['style']['typography']['textShadow'] ?? null;
198 + $typography_block_styles['textShadow'] = $preset_text_shadow ? $preset_text_shadow : $custom_text_shadow;
199 + }
200 +
185 201 $attributes = array();
186 202 $classnames = array();
187 203 $styles = gutenberg_style_engine_get_styles(
188 204 array( 'typography' => $typography_block_styles ),
@@ -246,11 +262,11 @@
246 262
247 263 /**
248 264 * Renders typography styles/content to the block wrapper.
249 265 *
250 - * @param string $block_content Rendered block content.
251 - * @param array $block Block object.
252 - * @return string Filtered block content.
266 + * @param string $block_content Rendered block content.
267 + * @param array $block Block object.
268 + * @return string Filtered block content.
253 269 */
254 270 function gutenberg_render_typography_support( $block_content, $block ) {
255 271 if ( ! empty( $block['attrs']['fitText'] ) && $block['attrs']['fitText'] && ! is_admin() ) {
256 272 wp_enqueue_script_module( '@wordpress/block-editor/utils/fit-text-frontend' );
@@ -258,8 +274,9 @@
258 274 // Add Interactivity API directives for fit text to work with client-side navigation.
259 275 if ( ! empty( $block_content ) ) {
260 276 $processor = new WP_HTML_Tag_Processor( $block_content );
261 277 if ( $processor->next_tag() ) {
278 + $processor->add_class( 'has-fit-text' );
262 279 if ( ! $processor->get_attribute( 'data-wp-interactive' ) ) {
263 280 $processor->set_attribute( 'data-wp-interactive', true );
264 281 }
265 282 $processor->set_attribute( 'data-wp-context---core-fit-text', 'core/fit-text::{"fontSize":""}' );
@@ -478,9 +495,9 @@
478 495 * @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema.
479 496 * @since 6.6.0 Deprecated bool argument $should_use_fluid_typography.
480 497 * @since 6.7.0 Font size presets can enable fluid typography individually, even if it’s disabled globally.
481 498 *
482 - * @param array $preset {
499 + * @param array $preset {
483 500 * Required. fontSizes preset value as seen in theme.json.
484 501 *
485 502 * @type string $name Name of the font size preset.
486 503 * @type string $slug Kebab-case unique identifier for the font size preset.