Editor: Adds 'settings.typography.fluid.minFontSize' support to wp_get_typography_font_size_value().

In `wp_get_typography_font_size_value()`, adds support for using a minimum font size for fluid typography when defined in a theme's `theme.json` file.

Reference:
* Part of [https://github.com/WordPress/gutenberg/pull/42489 Gutenberg PR 42489]

Follow-up to [54497], [54260].

Props andrewserong, ramonopoly, hellofromTonya, joen.
Fixes #57529.
Built from https://develop.svn.wordpress.org/trunk@55133


git-svn-id: http://core.svn.wordpress.org/trunk@54666 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2023-01-24 20:40:10 +00:00
parent 16b9fdfc34
commit fe2c8f9237
2 changed files with 15 additions and 4 deletions

View File

@ -453,6 +453,7 @@ function wp_get_computed_fluid_typography_value( $args = array() ) {
*
* @since 6.1.0
* @since 6.1.1 Adjusted rules for min and max font sizes.
* @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support.
*
* @param array $preset {
* Required. fontSizes preset value as seen in theme.json.
@ -479,19 +480,29 @@ function wp_get_typography_font_size_value( $preset, $should_use_fluid_typograph
}
// Checks if fluid font sizes are activated.
$typography_settings = wp_get_global_settings( array( 'typography' ) );
$should_use_fluid_typography = isset( $typography_settings['fluid'] ) && true === $typography_settings['fluid'] ? true : $should_use_fluid_typography;
$typography_settings = wp_get_global_settings( array( 'typography' ) );
if (
isset( $typography_settings['fluid'] ) &&
( true === $typography_settings['fluid'] || is_array( $typography_settings['fluid'] ) )
) {
$should_use_fluid_typography = true;
}
if ( ! $should_use_fluid_typography ) {
return $preset['size'];
}
$fluid_settings = isset( $typography_settings['fluid'] ) && is_array( $typography_settings['fluid'] )
? $typography_settings['fluid']
: array();
// Defaults.
$default_maximum_viewport_width = '1600px';
$default_minimum_viewport_width = '768px';
$default_minimum_font_size_factor = 0.75;
$default_scale_factor = 1;
$default_minimum_font_size_limit = '14px';
$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';
// Font sizes.
$fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55132';
$wp_version = '6.2-alpha-55133';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.