Skip to content

Commit

Permalink
Harmonizing the function signatures of gutenberg_get_typography_font_…
Browse files Browse the repository at this point in the history
…size_value (PHP) and getTypographyFontSizeValue (JS)

Updated doc comment
  • Loading branch information
ramonjd committed Jan 30, 2024
1 parent 12e7477 commit c21c420
Show file tree
Hide file tree
Showing 9 changed files with 637 additions and 216 deletions.
9 changes: 5 additions & 4 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,15 @@ function gutenberg_get_computed_fluid_typography_value( $args = array() ) {
* @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema.
* @since 6.5.0 Changing the type and name of the bool argument $should_use_fluid_typography.
*
* @param array $preset {
* @param array $preset {
* Required. fontSizes preset value as seen in theme.json.
*
* @type string $name Name of the font size preset.
* @type string $slug Kebab-case unique identifier for the font size preset.
* @type string|int|float $size CSS font-size value, including units where applicable.
* }
* @param bool|array $settings Optional Theme JSON settings array that overrides any global theme settings.
* As a bool, it acts as an override to switch fluid typography "on" (`true`) or "off" (`false`).
* As a bool (deprecated), it acts as an override to switch fluid typography "on" (`true`) or "off" (`false`).
* Can be used for unit testing. Default is `array()`.
*
* @return string|null Font-size value or `null` if a size is not passed in $preset.
Expand All @@ -464,15 +464,16 @@ function gutenberg_get_typography_font_size_value( $preset, $settings = array()
* If the settings argument is a boolean, it's a fluid typography override.
*/
if ( is_bool( $settings ) ) {
_deprecated_argument( __FUNCTION__, '6.5.0', __( '`boolean` type for second argument `$settings` is deprecated. Use `array()` instead.', 'gutenberg' ) );
$settings = array(
'typography' => array(
'fluid' => $settings,
),
);
}

// Checks if fluid font sizes are activated.
$global_settings = gutenberg_get_global_settings( array(), 'base' );
// Fallback to global settings as default.
$global_settings = gutenberg_get_global_settings();
$settings = wp_parse_args(
$settings,
$global_settings
Expand Down
3 changes: 2 additions & 1 deletion lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ public function get_stylesheet( $types = array( 'variables', 'styles', 'presets'
if ( null === $origins ) {
$origins = static::VALID_ORIGINS;
}
//var_dump($this->get_settings());

if ( is_string( $types ) ) {
// Dispatch error and map old arguments to new ones.
_deprecated_argument( __FUNCTION__, '5.9.0' );
Expand Down Expand Up @@ -2092,6 +2092,7 @@ protected static function compute_style_properties( $styles, $settings = array()
* whether the incoming value can be converted to a fluid value.
* Values that already have a clamp() function will not pass the test,
* and therefore the original $value will be returned.
* Pass the current theme_json settings to override any global settings.
*/
$value = gutenberg_get_typography_font_size_value( array( 'size' => $value ), $settings );
}
Expand Down
Loading

0 comments on commit c21c420

Please sign in to comment.