From 337a910076f4e62d81fdb7328f0bc124304c0f6c Mon Sep 17 00:00:00 2001 From: isabel_brison Date: Thu, 7 Sep 2023 04:30:21 +0000 Subject: [PATCH] Editor: add configurable viewport sizes for fluid typography. Adds options to configure min and max viewport sizes for fluid typography in theme.json settings. Props ramonopoly. Fixes #59048. Built from https://develop.svn.wordpress.org/trunk@56535 git-svn-id: http://core.svn.wordpress.org/trunk@56047 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-supports/typography.php | 22 +++++++++++++++------- wp-includes/version.php | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/wp-includes/block-supports/typography.php b/wp-includes/block-supports/typography.php index 34345ca4ec..b31464c12d 100644 --- a/wp-includes/block-supports/typography.php +++ b/wp-includes/block-supports/typography.php @@ -471,6 +471,7 @@ function wp_get_computed_fluid_typography_value( $args = array() ) { * @since 6.1.1 Adjusted rules for min and max font sizes. * @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support. * @since 6.3.0 Using layout.wideSize as max viewport width, and logarithmic scale factor to calculate minimum font scale. + * @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema. * * @param array $preset { * Required. fontSizes preset value as seen in theme.json. @@ -517,14 +518,21 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph : array(); // Defaults. - $default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( wp_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : '1600px'; + $default_maximum_viewport_width = '1600px'; $default_minimum_viewport_width = '320px'; $default_minimum_font_size_factor_max = 0.75; $default_minimum_font_size_factor_min = 0.25; $default_scale_factor = 1; - $has_min_font_size = isset( $fluid_settings['minFontSize'] ) && - ! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) ); - $default_minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px'; + $default_minimum_font_size_limit = '14px'; + + // Defaults overrides. + $minimum_viewport_width = isset( $fluid_settings['minViewportWidth'] ) ? $fluid_settings['minViewportWidth'] : $default_minimum_viewport_width; + $maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( wp_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : $default_maximum_viewport_width; + if ( isset( $fluid_settings['maxViewportWidth'] ) ) { + $maximum_viewport_width = $fluid_settings['maxViewportWidth']; + } + $has_min_font_size = isset( $fluid_settings['minFontSize'] ) && ! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) ); + $minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : $default_minimum_font_size_limit; // Font sizes. $fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null; @@ -551,7 +559,7 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph * in order to perform comparative checks. */ $minimum_font_size_limit = wp_get_typography_value_and_unit( - $default_minimum_font_size_limit, + $minimum_font_size_limit, array( 'coerce_to' => $preferred_size['unit'], ) @@ -600,8 +608,8 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph $fluid_font_size_value = wp_get_computed_fluid_typography_value( array( - 'minimum_viewport_width' => $default_minimum_viewport_width, - 'maximum_viewport_width' => $default_maximum_viewport_width, + 'minimum_viewport_width' => $minimum_viewport_width, + 'maximum_viewport_width' => $maximum_viewport_width, 'minimum_font_size' => $minimum_font_size_raw, 'maximum_font_size' => $maximum_font_size_raw, 'scale_factor' => $default_scale_factor, diff --git a/wp-includes/version.php b/wp-includes/version.php index 56ef5085ed..3e8a5a1287 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56534'; +$wp_version = '6.4-alpha-56535'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.