Make WordPress Core


Ignore:
Timestamp:
01/24/2023 08:38:25 PM (16 months ago)
Author:
hellofromTonya
Message:

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:

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

Props andrewserong, ramonopoly, hellofromTonya, joen.
Fixes #57529.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/typography.php

    r54823 r55133  
    454454 * @since 6.1.0
    455455 * @since 6.1.1 Adjusted rules for min and max font sizes.
     456 * @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support.
    456457 *
    457458 * @param array $preset                     {
     
    480481
    481482    // Checks if fluid font sizes are activated.
    482     $typography_settings         = wp_get_global_settings( array( 'typography' ) );
    483     $should_use_fluid_typography = isset( $typography_settings['fluid'] ) && true === $typography_settings['fluid'] ? true : $should_use_fluid_typography;
     483    $typography_settings = wp_get_global_settings( array( 'typography' ) );
     484    if (
     485        isset( $typography_settings['fluid'] ) &&
     486        ( true === $typography_settings['fluid'] || is_array( $typography_settings['fluid'] ) )
     487    ) {
     488        $should_use_fluid_typography = true;
     489    }
    484490
    485491    if ( ! $should_use_fluid_typography ) {
    486492        return $preset['size'];
    487493    }
     494
     495    $fluid_settings = isset( $typography_settings['fluid'] ) && is_array( $typography_settings['fluid'] )
     496        ? $typography_settings['fluid']
     497        : array();
    488498
    489499    // Defaults.
     
    492502    $default_minimum_font_size_factor = 0.75;
    493503    $default_scale_factor             = 1;
    494     $default_minimum_font_size_limit  = '14px';
     504    $has_min_font_size                = isset( $fluid_settings['minFontSize'] ) && ! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
     505    $default_minimum_font_size_limit  = $has_min_font_size ? $fluid_settings['minFontSize'] : '14px';
    495506
    496507    // Font sizes.
Note: See TracChangeset for help on using the changeset viewer.