PluginProbe
Gutenberg / 16.2.0
Gutenberg v16.2.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 12.6.0 All 403 releases
← All changes | lib/block-supports/typography.php +71 -153 23.7.0 → 16.2.0 View file →
@@ -10,29 +10,27 @@
10 10 *
11 11 * @param WP_Block_Type $block_type Block Type.
12 12 */
13 13 function gutenberg_register_typography_support( $block_type ) {
14 - if ( ! $block_type instanceof WP_Block_Type ) {
14 + if ( ! property_exists( $block_type, 'supports' ) ) {
15 15 return;
16 16 }
17 17
18 - $typography_supports = $block_type->supports['typography'] ?? false;
18 + $typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false );
19 19 if ( ! $typography_supports ) {
20 20 return;
21 21 }
22 22
23 - $has_font_family_support = $typography_supports['__experimentalFontFamily'] ?? false;
24 - $has_font_size_support = $typography_supports['fontSize'] ?? false;
25 - $has_font_style_support = $typography_supports['__experimentalFontStyle'] ?? false;
26 - $has_font_weight_support = $typography_supports['__experimentalFontWeight'] ?? false;
27 - $has_letter_spacing_support = $typography_supports['__experimentalLetterSpacing'] ?? false;
28 - $has_line_height_support = $typography_supports['lineHeight'] ?? false;
29 - $has_text_align_support = $typography_supports['textAlign'] ?? false;
30 - $has_text_columns_support = $typography_supports['textColumns'] ?? false;
31 - $has_text_decoration_support = $typography_supports['__experimentalTextDecoration'] ?? false;
32 - $has_text_transform_support = $typography_supports['__experimentalTextTransform'] ?? false;
33 - $has_text_indent_support = $typography_supports['textIndent'] ?? false;
34 - $has_writing_mode_support = $typography_supports['__experimentalWritingMode'] ?? false;
23 + $has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false );
24 + $has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false );
25 + $has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false );
26 + $has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false );
27 + $has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false );
28 + $has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false );
29 + $has_text_columns_support = _wp_array_get( $typography_supports, array( 'textColumns' ), false );
30 + $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
31 + $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );
32 + $has_writing_mode_support = _wp_array_get( $typography_supports, array( '__experimentalWritingMode' ), false );
35 33
36 34 $has_typography_support = $has_font_family_support
37 35 || $has_font_size_support
38 36 || $has_font_style_support
@@ -38,13 +36,11 @@
38 36 || $has_font_style_support
39 37 || $has_font_weight_support
40 38 || $has_letter_spacing_support
41 39 || $has_line_height_support
42 - || $has_text_align_support
43 40 || $has_text_columns_support
44 41 || $has_text_decoration_support
45 42 || $has_text_transform_support
46 - || $has_text_indent_support
47 43 || $has_writing_mode_support;
48 44
49 45 if ( ! $block_type->attributes ) {
50 46 $block_type->attributes = array();
@@ -79,13 +75,13 @@
79 75 *
80 76 * @return array Typography CSS classes and inline styles.
81 77 */
82 78 function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
83 - if ( ! $block_type instanceof WP_Block_Type ) {
79 + if ( ! property_exists( $block_type, 'supports' ) ) {
84 80 return array();
85 81 }
86 82
87 - $typography_supports = $block_type->supports['typography'] ?? false;
83 + $typography_supports = _wp_array_get( $block_type->supports, array( 'typography' ), false );
88 84 if ( ! $typography_supports ) {
89 85 return array();
90 86 }
91 87
@@ -92,20 +88,18 @@
92 88 if ( wp_should_skip_block_supports_serialization( $block_type, 'typography' ) ) {
93 89 return array();
94 90 }
95 91
96 - $has_font_family_support = $typography_supports['__experimentalFontFamily'] ?? false;
97 - $has_font_size_support = $typography_supports['fontSize'] ?? false;
98 - $has_font_style_support = $typography_supports['__experimentalFontStyle'] ?? false;
99 - $has_font_weight_support = $typography_supports['__experimentalFontWeight'] ?? false;
100 - $has_letter_spacing_support = $typography_supports['__experimentalLetterSpacing'] ?? false;
101 - $has_line_height_support = $typography_supports['lineHeight'] ?? false;
102 - $has_text_align_support = $typography_supports['textAlign'] ?? false;
103 - $has_text_columns_support = $typography_supports['textColumns'] ?? false;
104 - $has_text_decoration_support = $typography_supports['__experimentalTextDecoration'] ?? false;
105 - $has_text_transform_support = $typography_supports['__experimentalTextTransform'] ?? false;
106 - $has_text_indent_support = $typography_supports['textIndent'] ?? false;
107 - $has_writing_mode_support = $typography_supports['__experimentalWritingMode'] ?? false;
92 + $has_font_family_support = _wp_array_get( $typography_supports, array( '__experimentalFontFamily' ), false );
93 + $has_font_size_support = _wp_array_get( $typography_supports, array( 'fontSize' ), false );
94 + $has_font_style_support = _wp_array_get( $typography_supports, array( '__experimentalFontStyle' ), false );
95 + $has_font_weight_support = _wp_array_get( $typography_supports, array( '__experimentalFontWeight' ), false );
96 + $has_letter_spacing_support = _wp_array_get( $typography_supports, array( '__experimentalLetterSpacing' ), false );
97 + $has_line_height_support = _wp_array_get( $typography_supports, array( 'lineHeight' ), false );
98 + $has_text_columns_support = _wp_array_get( $typography_supports, array( 'textColumns' ), false );
99 + $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
100 + $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );
101 + $has_writing_mode_support = _wp_array_get( $typography_supports, array( '__experimentalWritingMode' ), false );
108 102
109 103 // Whether to skip individual block support features.
110 104 $should_skip_font_size = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontSize' );
111 105 $should_skip_font_family = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontFamily' );
@@ -111,20 +105,18 @@
111 105 $should_skip_font_family = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontFamily' );
112 106 $should_skip_font_style = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontStyle' );
113 107 $should_skip_font_weight = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontWeight' );
114 108 $should_skip_line_height = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'lineHeight' );
115 - $should_skip_text_align = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textAlign' );
116 109 $should_skip_text_columns = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textColumns' );
117 110 $should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' );
118 111 $should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' );
119 112 $should_skip_letter_spacing = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' );
120 - $should_skip_text_indent = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textIndent' );
121 113 $should_skip_writing_mode = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'writingMode' );
122 114
123 115 $typography_block_styles = array();
124 116 if ( $has_font_size_support && ! $should_skip_font_size ) {
125 117 $preset_font_size = array_key_exists( 'fontSize', $block_attributes ) ? "var:preset|font-size|{$block_attributes['fontSize']}" : null;
126 - $custom_font_size = $block_attributes['style']['typography']['fontSize'] ?? null;
118 + $custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] ) ? $block_attributes['style']['typography']['fontSize'] : null;
127 119 $typography_block_styles['fontSize'] = $preset_font_size ? $preset_font_size : gutenberg_get_typography_font_size_value(
128 120 array(
129 121 'size' => $custom_font_size,
130 122 )
@@ -147,17 +139,13 @@
147 139 gutenberg_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['fontWeight'], 'font-weight' );
148 140 }
149 141
150 142 if ( $has_line_height_support && ! $should_skip_line_height ) {
151 - $typography_block_styles['lineHeight'] = $block_attributes['style']['typography']['lineHeight'] ?? null;
143 + $typography_block_styles['lineHeight'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'lineHeight' ), null );
152 144 }
153 145
154 - if ( $has_text_align_support && ! $should_skip_text_align ) {
155 - $typography_block_styles['textAlign'] = $block_attributes['style']['typography']['textAlign'] ?? null;
156 - }
157 -
158 146 if ( $has_text_columns_support && ! $should_skip_text_columns && isset( $block_attributes['style']['typography']['textColumns'] ) ) {
159 - $typography_block_styles['textColumns'] = $block_attributes['style']['typography']['textColumns'] ?? null;
147 + $typography_block_styles['textColumns'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'textColumns' ), null );
160 148 }
161 149
162 150 if ( $has_text_decoration_support && ! $should_skip_text_decoration && isset( $block_attributes['style']['typography']['textDecoration'] ) ) {
163 151 $typography_block_styles['textDecoration'] =
@@ -174,17 +162,12 @@
174 162 gutenberg_typography_get_preset_inline_style_value( $block_attributes['style']['typography']['letterSpacing'], 'letter-spacing' );
175 163 }
176 164
177 165 if ( $has_writing_mode_support && ! $should_skip_writing_mode && isset( $block_attributes['style']['typography']['writingMode'] ) ) {
178 - $typography_block_styles['writingMode'] = $block_attributes['style']['typography']['writingMode'] ?? null;
166 + $typography_block_styles['writingMode'] = _wp_array_get( $block_attributes, array( 'style', 'typography', 'writingMode' ), null );
179 167 }
180 168
181 - if ( $has_text_indent_support && ! $should_skip_text_indent && isset( $block_attributes['style']['typography']['textIndent'] ) ) {
182 - $typography_block_styles['textIndent'] = $block_attributes['style']['typography']['textIndent'] ?? null;
183 - }
184 -
185 169 $attributes = array();
186 - $classnames = array();
187 170 $styles = gutenberg_style_engine_get_styles(
188 171 array( 'typography' => $typography_block_styles ),
189 172 array( 'convert_vars_to_classnames' => true )
190 173 );
@@ -189,19 +172,11 @@
189 172 array( 'convert_vars_to_classnames' => true )
190 173 );
191 174
192 175 if ( ! empty( $styles['classnames'] ) ) {
193 - $classnames[] = $styles['classnames'];
176 + $attributes['class'] = $styles['classnames'];
194 177 }
195 178
196 - if ( $has_text_align_support && ! $should_skip_text_align && isset( $block_attributes['style']['typography']['textAlign'] ) ) {
197 - $classnames[] = 'has-text-align-' . $block_attributes['style']['typography']['textAlign'];
198 - }
199 -
200 - if ( ! empty( $classnames ) ) {
201 - $attributes['class'] = implode( ' ', $classnames );
202 - }
203 -
204 179 if ( ! empty( $styles['css'] ) ) {
205 180 $attributes['style'] = $styles['css'];
206 181 }
207 182
@@ -251,28 +226,8 @@
251 226 * @param array $block Block object.
252 227 * @return string Filtered block content.
253 228 */
254 229 function gutenberg_render_typography_support( $block_content, $block ) {
255 - if ( ! empty( $block['attrs']['fitText'] ) && $block['attrs']['fitText'] && ! is_admin() ) {
256 - wp_enqueue_script_module( '@wordpress/block-editor/utils/fit-text-frontend' );
257 -
258 - // Add Interactivity API directives for fit text to work with client-side navigation.
259 - if ( ! empty( $block_content ) ) {
260 - $processor = new WP_HTML_Tag_Processor( $block_content );
261 - if ( $processor->next_tag() ) {
262 - if ( ! $processor->get_attribute( 'data-wp-interactive' ) ) {
263 - $processor->set_attribute( 'data-wp-interactive', true );
264 - }
265 - $processor->set_attribute( 'data-wp-context---core-fit-text', 'core/fit-text::{"fontSize":""}' );
266 - $processor->set_attribute( 'data-wp-init---core-fit-text', 'core/fit-text::callbacks.init' );
267 - $processor->set_attribute( 'data-wp-style--font-size', 'core/fit-text::context.fontSize' );
268 - $block_content = $processor->get_updated_html();
269 - }
270 - }
271 - // fitText supersedes any other typography features
272 - return $block_content;
273 - }
274 -
275 230 if ( ! isset( $block['attrs']['style']['typography']['fontSize'] ) ) {
276 231 return $block_content;
277 232 }
278 233
@@ -288,8 +243,9 @@
288 243 return preg_replace( '/font-size\s*:\s*' . preg_quote( $custom_font_size, '/' ) . '\s*;?/', 'font-size:' . esc_attr( $fluid_font_size ) . ';', $block_content, 1 );
289 244 }
290 245
291 246 return $block_content;
247 +
292 248 }
293 249
294 250 /**
295 251 * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].
@@ -389,13 +345,13 @@
389 345 * }
390 346 * @return string|null A font-size value using clamp().
391 347 */
392 348 function gutenberg_get_computed_fluid_typography_value( $args = array() ) {
393 - $maximum_viewport_width_raw = $args['maximum_viewport_width'] ?? null;
394 - $minimum_viewport_width_raw = $args['minimum_viewport_width'] ?? null;
395 - $maximum_font_size_raw = $args['maximum_font_size'] ?? null;
396 - $minimum_font_size_raw = $args['minimum_font_size'] ?? null;
397 - $scale_factor = $args['scale_factor'] ?? null;
349 + $maximum_viewport_width_raw = isset( $args['maximum_viewport_width'] ) ? $args['maximum_viewport_width'] : null;
350 + $minimum_viewport_width_raw = isset( $args['minimum_viewport_width'] ) ? $args['minimum_viewport_width'] : null;
351 + $maximum_font_size_raw = isset( $args['maximum_font_size'] ) ? $args['maximum_font_size'] : null;
352 + $minimum_font_size_raw = isset( $args['minimum_font_size'] ) ? $args['minimum_font_size'] : null;
353 + $scale_factor = isset( $args['scale_factor'] ) ? $args['scale_factor'] : null;
398 354
399 355 // Normalizes the minimum font size in order to use the value for calculations.
400 356 $minimum_font_size = gutenberg_get_typography_value_and_unit( $minimum_font_size_raw );
401 357
@@ -402,9 +358,9 @@
402 358 /*
403 359 * We get a 'preferred' unit to keep units consistent when calculating,
404 360 * otherwise the result will not be accurate.
405 361 */
406 - $font_size_unit = $minimum_font_size['unit'] ?? 'rem';
362 + $font_size_unit = isset( $minimum_font_size['unit'] ) ? $minimum_font_size['unit'] : 'rem';
407 363
408 364 // Grabs the maximum font size and normalize it in order to use the value for calculations.
409 365 $maximum_font_size = gutenberg_get_typography_value_and_unit(
410 366 $maximum_font_size_raw,
@@ -445,20 +401,12 @@
445 401 if ( ! $minimum_viewport_width || ! $maximum_viewport_width ) {
446 402 return null;
447 403 }
448 404
449 - // Calculates the linear factor denominator. If it's 0, we cannot calculate a fluid value.
450 - $linear_factor_denominator = $maximum_viewport_width['value'] - $minimum_viewport_width['value'];
451 - if ( empty( $linear_factor_denominator ) ) {
452 - return null;
453 - }
454 -
455 - /*
456 - * Build CSS rule.
457 - * Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
458 - */
405 + // Build CSS rule.
406 + // Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
459 407 $view_port_width_offset = round( $minimum_viewport_width['value'] / 100, 3 ) . $font_size_unit;
460 - $linear_factor = 100 * ( ( $maximum_font_size['value'] - $minimum_font_size['value'] ) / ( $linear_factor_denominator ) );
408 + $linear_factor = 100 * ( ( $maximum_font_size['value'] - $minimum_font_size['value'] ) / ( $maximum_viewport_width['value'] - $minimum_viewport_width['value'] ) );
461 409 $linear_factor_scaled = round( $linear_factor * $scale_factor, 3 );
462 410 $linear_factor_scaled = empty( $linear_factor_scaled ) ? 1 : $linear_factor_scaled;
463 411 $fluid_target_font_size = implode( '', $minimum_font_size_rem ) . " + ((1vw - $view_port_width_offset) * $linear_factor_scaled)";
464 412
@@ -464,23 +412,13 @@
464 412
465 413 return "clamp($minimum_font_size_raw, $fluid_target_font_size, $maximum_font_size_raw)";
466 414 }
467 415
468 -
469 416 /**
470 417 * Returns a font-size value based on a given font-size preset.
471 - * Takes into account fluid typography parameters and attempts to return a CSS
472 - * formula depending on available, valid values.
418 + * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.
473 419 *
474 - * @since 6.1.0
475 - * @since 6.1.1 Adjusted rules for min and max font sizes.
476 - * @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support.
477 - * @since 6.3.0 Using layout.wideSize as max viewport width, and logarithmic scale factor to calculate minimum font scale.
478 - * @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema.
479 - * @since 6.6.0 Deprecated bool argument $should_use_fluid_typography.
480 - * @since 6.7.0 Font size presets can enable fluid typography individually, even if it’s disabled globally.
481 - *
482 - * @param array $preset {
420 + * @param array $preset {
483 421 * Required. fontSizes preset value as seen in theme.json.
484 422 *
485 423 * @type string $name Name of the font size preset.
486 424 * @type string $slug Kebab-case unique identifier for the font size preset.
@@ -485,82 +423,62 @@
485 423 * @type string $name Name of the font size preset.
486 424 * @type string $slug Kebab-case unique identifier for the font size preset.
487 425 * @type string|int|float $size CSS font-size value, including units where applicable.
488 426 * }
489 - * @param bool|array $settings Optional Theme JSON settings array that overrides any global theme settings.
490 - * Default is `array()`.
427 + * @param bool $should_use_fluid_typography An override to switch fluid typography "on". Can be used for unit testing. Default is `false`.
491 428 *
492 429 * @return string|null Font-size value or `null` if a size is not passed in $preset.
493 430 */
494 -function gutenberg_get_typography_font_size_value( $preset, $settings = array() ) {
431 +function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_typography = false ) {
495 432 if ( ! isset( $preset['size'] ) ) {
496 433 return null;
497 434 }
498 435
499 436 /*
500 - * Catch falsy values and 0/'0'. Fluid calculations cannot be performed on `0`.
501 - * Also return early when a preset font size explicitly disables fluid typography with `false`.
437 + * Catches empty values and 0/'0'.
438 + * Fluid calculations cannot be performed on 0.
502 439 */
503 - $fluid_font_size_settings = $preset['fluid'] ?? null;
504 - if ( false === $fluid_font_size_settings || empty( $preset['size'] ) ) {
440 + if ( empty( $preset['size'] ) ) {
505 441 return $preset['size'];
506 442 }
507 443
508 - /*
509 - * Backwards compatibility since 6.5.
510 - * As a bool (deprecated since 6.5), $settings acts as an override to switch fluid typography "on" (`true`) or "off" (`false`).
511 - */
512 - if ( is_bool( $settings ) ) {
513 - _deprecated_argument( __FUNCTION__, '6.6.0', __( '`boolean` type for second argument `$settings` is deprecated. Use `array()` instead.', 'gutenberg' ) );
514 - $settings = array(
515 - 'typography' => array(
516 - 'fluid' => $settings,
517 - ),
518 - );
519 - }
444 + // Checks if fluid font sizes are activated.
445 + $global_settings = gutenberg_get_global_settings();
446 + $typography_settings = isset( $global_settings['typography'] ) ? $global_settings['typography'] : array();
447 + $layout_settings = isset( $global_settings['layout'] ) ? $global_settings['layout'] : array();
520 448
521 - // Fallback to global settings as default.
522 - $global_settings = gutenberg_get_global_settings();
523 - $settings = wp_parse_args(
524 - $settings,
525 - $global_settings
526 - );
527 - $typography_settings = $settings['typography'] ?? array();
449 + $should_use_fluid_typography
450 + = isset( $typography_settings['fluid'] ) &&
451 + ( true === $typography_settings['fluid'] || is_array( $typography_settings['fluid'] ) ) ?
452 + true :
453 + $should_use_fluid_typography;
528 454
529 - /*
530 - * Return early when fluid typography is disabled in the settings, and there
531 - * are no local settings to enable it for the individual preset.
532 - *
533 - * If this condition isn't met, either the settings or individual preset settings
534 - * have enabled fluid typography.
535 - */
536 - if ( empty( $typography_settings['fluid'] ) && empty( $fluid_font_size_settings ) ) {
455 + if ( ! $should_use_fluid_typography ) {
537 456 return $preset['size'];
538 457 }
539 458
540 - $fluid_settings = $typography_settings['fluid'] ?? array();
541 - $layout_settings = $settings['layout'] ?? array();
459 + $fluid_settings = isset( $typography_settings['fluid'] ) && is_array( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : array();
542 460
543 461 // Defaults.
544 - $default_maximum_viewport_width = '1600px';
462 + $default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : '1600px';
545 463 $default_minimum_viewport_width = '320px';
546 464 $default_minimum_font_size_factor_max = 0.75;
547 465 $default_minimum_font_size_factor_min = 0.25;
548 466 $default_scale_factor = 1;
549 - $default_minimum_font_size_limit = '14px';
467 + $has_min_font_size = isset( $fluid_settings['minFontSize'] ) && ! empty( gutenberg_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
468 + $default_minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px';
550 469
551 - // Defaults overrides.
552 - $minimum_viewport_width = $fluid_settings['minViewportWidth'] ?? $default_minimum_viewport_width;
553 - $maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( gutenberg_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : $default_maximum_viewport_width;
554 - if ( isset( $fluid_settings['maxViewportWidth'] ) ) {
555 - $maximum_viewport_width = $fluid_settings['maxViewportWidth'];
470 + // Font sizes.
471 + $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;
472 +
473 + // A font size has explicitly bypassed fluid calculations.
474 + if ( false === $fluid_font_size_settings ) {
475 + return $preset['size'];
556 476 }
557 - $has_min_font_size = isset( $fluid_settings['minFontSize'] ) && ! empty( gutenberg_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
558 - $minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : $default_minimum_font_size_limit;
559 477
560 478 // Try to grab explicit min and max fluid font sizes.
561 - $minimum_font_size_raw = $fluid_font_size_settings['min'] ?? null;
562 - $maximum_font_size_raw = $fluid_font_size_settings['max'] ?? null;
479 + $minimum_font_size_raw = isset( $fluid_font_size_settings['min'] ) ? $fluid_font_size_settings['min'] : null;
480 + $maximum_font_size_raw = isset( $fluid_font_size_settings['max'] ) ? $fluid_font_size_settings['max'] : null;
563 481
564 482 // Font sizes.
565 483 $preferred_size = gutenberg_get_typography_value_and_unit( $preset['size'] );
566 484
@@ -570,9 +488,9 @@
570 488 }
571 489
572 490 // Parses the minimum font size limit, so we can perform checks using it.
573 491 $minimum_font_size_limit = gutenberg_get_typography_value_and_unit(
574 - $minimum_font_size_limit,
492 + $default_minimum_font_size_limit,
575 493 array(
576 494 'coerce_to' => $preferred_size['unit'],
577 495 )
578 496 );
@@ -619,10 +537,10 @@
619 537 }
620 538
621 539 $fluid_font_size_value = gutenberg_get_computed_fluid_typography_value(
622 540 array(
623 - 'minimum_viewport_width' => $minimum_viewport_width,
624 - 'maximum_viewport_width' => $maximum_viewport_width,
541 + 'minimum_viewport_width' => $default_minimum_viewport_width,
542 + 'maximum_viewport_width' => $default_maximum_viewport_width,
625 543 'minimum_font_size' => $minimum_font_size_raw,
626 544 'maximum_font_size' => $maximum_font_size_raw,
627 545 'scale_factor' => $default_scale_factor,
628 546 )