Changeset 55133
- Timestamp:
- 01/24/2023 08:38:25 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 edited
-
src/wp-includes/block-supports/typography.php (modified) (3 diffs)
-
tests/phpunit/data/themedir1/block-theme-child-with-fluid-typography-config (added)
-
tests/phpunit/data/themedir1/block-theme-child-with-fluid-typography-config/style.css (added)
-
tests/phpunit/data/themedir1/block-theme-child-with-fluid-typography-config/theme.json (added)
-
tests/phpunit/tests/block-supports/typography.php (modified) (3 diffs)
-
tests/phpunit/tests/theme/themeDir.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/typography.php
r54823 r55133 454 454 * @since 6.1.0 455 455 * @since 6.1.1 Adjusted rules for min and max font sizes. 456 * @since 6.2.0 Added 'settings.typography.fluid.minFontSize' support. 456 457 * 457 458 * @param array $preset { … … 480 481 481 482 // 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 } 484 490 485 491 if ( ! $should_use_fluid_typography ) { 486 492 return $preset['size']; 487 493 } 494 495 $fluid_settings = isset( $typography_settings['fluid'] ) && is_array( $typography_settings['fluid'] ) 496 ? $typography_settings['fluid'] 497 : array(); 488 498 489 499 // Defaults. … … 492 502 $default_minimum_font_size_factor = 0.75; 493 503 $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'; 495 506 496 507 // Font sizes. -
trunk/tests/phpunit/tests/block-supports/typography.php
r54889 r55133 568 568 * @ticket 56467 569 569 * @ticket 57065 570 * @ticket 57529 570 571 * 571 572 * @covers ::wp_register_typography_support … … 573 574 * @dataProvider data_generate_block_supports_font_size_fixtures 574 575 * 575 * @param string $font_size_value The block supports custom font size value. 576 * @param bool $should_use_fluid_typography An override to switch fluid typography "on". Can be used for unit testing. 577 * @param string $expected_output Expected value of style property from wp_apply_typography_support(). 578 */ 579 public function test_should_covert_font_sizes_to_fluid_values( $font_size_value, $should_use_fluid_typography, $expected_output ) { 580 if ( $should_use_fluid_typography ) { 581 switch_theme( 'block-theme-child-with-fluid-typography' ); 582 } else { 583 switch_theme( 'default' ); 584 } 576 * @param string $font_size_value The block supports custom font size value. 577 * @param string $theme_slug A theme slug corresponding to an available test theme. 578 * @param string $expected_output Expected value of style property from wp_apply_typography_support(). 579 */ 580 public function test_should_covert_font_sizes_to_fluid_values( $font_size_value, $theme_slug, $expected_output ) { 581 switch_theme( $theme_slug ); 585 582 586 583 $this->test_block_name = 'test/font-size-fluid-value'; … … 624 621 public function data_generate_block_supports_font_size_fixtures() { 625 622 return array( 626 'default_return_value' => array( 627 'font_size_value' => '50px', 628 'should_use_fluid_typography' => false, 629 'expected_output' => 'font-size:50px;', 630 ), 631 'return_value_with_fluid_typography' => array( 632 'font_size_value' => '50px', 633 'should_use_fluid_typography' => true, 634 'expected_output' => 'font-size:clamp(37.5px, 2.344rem + ((1vw - 7.68px) * 1.502), 50px);', 623 'returns value when fluid typography is not active' => array( 624 'font_size_value' => '15px', 625 'theme_slug' => 'default', 626 'expected_output' => 'font-size:15px;', 627 ), 628 'returns clamp value using default config' => array( 629 'font_size_value' => '15px', 630 'theme_slug' => 'block-theme-child-with-fluid-typography', 631 'expected_output' => 'font-size:clamp(14px, 0.875rem + ((1vw - 7.68px) * 0.12), 15px);', 632 ), 633 'returns value when font size <= default min font size bound' => array( 634 'font_size_value' => '13px', 635 'theme_slug' => 'block-theme-child-with-fluid-typography', 636 'expected_output' => 'font-size:13px;', 637 ), 638 'returns clamp value using custom fluid config' => array( 639 'font_size_value' => '17px', 640 'theme_slug' => 'block-theme-child-with-fluid-typography-config', 641 'expected_output' => 'font-size:clamp(16px, 1rem + ((1vw - 7.68px) * 0.12), 17px);', 642 ), 643 'returns value when font size <= custom min font size bound' => array( 644 'font_size_value' => '15px', 645 'theme_slug' => 'block-theme-child-with-fluid-typography-config', 646 'expected_output' => 'font-size:15px;', 635 647 ), 636 648 ); -
trunk/tests/phpunit/tests/theme/themeDir.php
r55086 r55133 181 181 'Block Theme Child with no theme.json', 182 182 'Block Theme Child Theme With Fluid Typography', 183 'Block Theme Child Theme With Fluid Typography Config', 183 184 'Block Theme [0.4.0]', 184 185 'Block Theme [1.0.0] in subdirectory',
Note: See TracChangeset
for help on using the changeset viewer.