Skip to content

Commit

Permalink
Editor: Adds 'settings.typography.fluid.minFontSize' support to wp_ge…
Browse files Browse the repository at this point in the history
…t_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 [WordPress/gutenberg#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
  • Loading branch information
hellofromtonya committed Jan 24, 2023
1 parent 16b9fdf commit fe2c8f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions wp-includes/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit fe2c8f9

Please sign in to comment.