Changeset 58171 for trunk/src/wp-includes/block-supports/typography.php
- Timestamp:
- 05/18/2024 11:16:09 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/typography.php
r57329 r58171 499 499 * @since 6.3.0 Using layout.wideSize as max viewport width, and logarithmic scale factor to calculate minimum font scale. 500 500 * @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema. 501 * 502 * @param array $preset { 501 * @since 6.6.0 Deprecated bool argument $should_use_fluid_typography. 502 * 503 * @param array $preset { 503 504 * Required. fontSizes preset value as seen in theme.json. 504 505 * … … 507 508 * @type string|int|float $size CSS font-size value, including units if applicable. 508 509 * } 509 * @param bool $should_use_fluid_typography An override to switch fluid typography "on". Can be used for unit testing.510 * 510 * @param bool|array $settings Optional Theme JSON settings array that overrides any global theme settings. 511 * Default is false. 511 512 * @return string|null Font-size value or null if a size is not passed in $preset. 512 513 */ 513 function wp_get_typography_font_size_value( $preset, $should_use_fluid_typography = false ) { 514 515 516 function wp_get_typography_font_size_value( $preset, $settings = array() ) { 514 517 if ( ! isset( $preset['size'] ) ) { 515 518 return null; … … 524 527 } 525 528 526 // Checks if fluid font sizes are activated. 527 $global_settings = wp_get_global_settings(); 528 $typography_settings = isset( $global_settings['typography'] ) ? $global_settings['typography'] : array(); 529 $layout_settings = isset( $global_settings['layout'] ) ? $global_settings['layout'] : array(); 530 531 if ( 532 isset( $typography_settings['fluid'] ) && 533 ( true === $typography_settings['fluid'] || is_array( $typography_settings['fluid'] ) ) 534 ) { 535 $should_use_fluid_typography = true; 536 } 529 /* 530 * As a boolean (deprecated since 6.6), $settings acts as an override to switch fluid typography "on" (`true`) or "off" (`false`). 531 */ 532 if ( is_bool( $settings ) ) { 533 _deprecated_argument( __FUNCTION__, '6.6.0', __( '`boolean` type for second argument `$settings` is deprecated. Use `array()` instead.' ) ); 534 $settings = array( 535 'typography' => array( 536 'fluid' => $settings, 537 ), 538 ); 539 } 540 541 // Fallback to global settings as default. 542 $global_settings = wp_get_global_settings(); 543 $settings = wp_parse_args( 544 $settings, 545 $global_settings 546 ); 547 548 $typography_settings = isset( $settings['typography'] ) ? $settings['typography'] : array(); 549 $should_use_fluid_typography = ! empty( $typography_settings['fluid'] ); 537 550 538 551 if ( ! $should_use_fluid_typography ) { … … 540 553 } 541 554 542 $fluid_settings = isset( $typography_settings['fluid'] ) && is_array( $typography_settings['fluid'] )543 ? $typography_settings['fluid']544 555 // $typography_settings['fluid'] can be a bool or an array. Normalize to array. 556 $fluid_settings = is_array( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : array(); 557 $layout_settings = isset( $settings['layout'] ) ? $settings['layout'] : array(); 545 558 546 559 // Defaults.
Note: See TracChangeset
for help on using the changeset viewer.