Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Backport of GB PR 44807 PHP code
  • Loading branch information
hellofromtonya committed Oct 10, 2022
commit 41448bdb8c1ac541e1a5f7c3967c5bfc1fbb0109
5 changes: 5 additions & 0 deletions src/wp-includes/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ function wp_get_typography_value_and_unit( $raw_value, $options = array() ) {
return null;
}

// Converts numbers to pixel values by default.
if ( is_numeric( $raw_value ) ) {
$raw_value = $raw_value . 'px';
}

$defaults = array(
'coerce_to' => '',
'root_size_value' => 16,
Expand Down
8 changes: 8 additions & 0 deletions tests/phpunit/tests/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ public function data_generate_font_size_preset_fixtures() {
'expected_output' => '28px',
),

'default_return_value_when_size_is_undefined' => array(
'font_size_preset' => array(
'size' => null,
),
'should_use_fluid_typography' => false,
'expected_output' => null,
),

'default_return_value_when_fluid_is_false' => array(
'font_size_preset' => array(
'size' => '28px',
Expand Down