plugin updates
This commit is contained in:
@@ -42,6 +42,7 @@ function wp_register_background_support( $block_type ) {
|
||||
* @since 6.4.0
|
||||
* @since 6.5.0 Added support for `backgroundPosition` and `backgroundRepeat` output.
|
||||
* @since 6.6.0 Removed requirement for `backgroundImage.source`. A file/url is the default.
|
||||
* @since 6.7.0 Added support for `backgroundAttachment` output.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
@@ -62,17 +63,19 @@ function wp_render_background_support( $block_content, $block ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
$background_styles = array();
|
||||
$background_styles['backgroundImage'] = isset( $block_attributes['style']['background']['backgroundImage'] ) ? $block_attributes['style']['background']['backgroundImage'] : array();
|
||||
$background_styles = array();
|
||||
$background_styles['backgroundImage'] = $block_attributes['style']['background']['backgroundImage'] ?? null;
|
||||
$background_styles['backgroundSize'] = $block_attributes['style']['background']['backgroundSize'] ?? null;
|
||||
$background_styles['backgroundPosition'] = $block_attributes['style']['background']['backgroundPosition'] ?? null;
|
||||
$background_styles['backgroundRepeat'] = $block_attributes['style']['background']['backgroundRepeat'] ?? null;
|
||||
$background_styles['backgroundAttachment'] = $block_attributes['style']['background']['backgroundAttachment'] ?? null;
|
||||
|
||||
if ( ! empty( $background_styles['backgroundImage'] ) ) {
|
||||
$background_styles['backgroundSize'] = isset( $block_attributes['style']['background']['backgroundSize'] ) ? $block_attributes['style']['background']['backgroundSize'] : 'cover';
|
||||
$background_styles['backgroundPosition'] = isset( $block_attributes['style']['background']['backgroundPosition'] ) ? $block_attributes['style']['background']['backgroundPosition'] : null;
|
||||
$background_styles['backgroundRepeat'] = isset( $block_attributes['style']['background']['backgroundRepeat'] ) ? $block_attributes['style']['background']['backgroundRepeat'] : null;
|
||||
$background_styles['backgroundSize'] = $background_styles['backgroundSize'] ?? 'cover';
|
||||
|
||||
// If the background size is set to `contain` and no position is set, set the position to `center`.
|
||||
if ( 'contain' === $background_styles['backgroundSize'] && ! $background_styles['backgroundPosition'] ) {
|
||||
$background_styles['backgroundPosition'] = 'center';
|
||||
$background_styles['backgroundPosition'] = '50% 50%';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,21 +7,6 @@
|
||||
* @since 6.6.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate block style variation instance name.
|
||||
*
|
||||
* @since 6.6.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $block Block object.
|
||||
* @param string $variation Slug for the block style variation.
|
||||
*
|
||||
* @return string The unique variation name.
|
||||
*/
|
||||
function wp_create_block_style_variation_instance_name( $block, $variation ) {
|
||||
return $variation . '--' . md5( serialize( $block ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the block style variation names within a CSS class string.
|
||||
*
|
||||
@@ -124,7 +109,7 @@ function wp_render_block_style_variation_support_styles( $parsed_block ) {
|
||||
*/
|
||||
wp_resolve_block_style_variation_ref_values( $variation_data, $theme_json );
|
||||
|
||||
$variation_instance = wp_create_block_style_variation_instance_name( $parsed_block, $variation );
|
||||
$variation_instance = wp_unique_id( $variation . '--' );
|
||||
$class_name = "is-style-$variation_instance";
|
||||
$updated_class_name = $parsed_block['attrs']['className'] . " $class_name";
|
||||
|
||||
@@ -230,11 +215,9 @@ function wp_render_block_style_variation_class_name( $block_content, $block ) {
|
||||
|
||||
/*
|
||||
* Matches a class prefixed by `is-style`, followed by the
|
||||
* variation slug, then `--`, and finally a hash.
|
||||
*
|
||||
* See `wp_create_block_style_variation_instance_name` for class generation.
|
||||
* variation slug, then `--`, and finally an instance number.
|
||||
*/
|
||||
preg_match( '/\bis-style-(\S+?--\w+)\b/', $block['attrs']['className'], $matches );
|
||||
preg_match( '/\bis-style-(\S+?--\d+)\b/', $block['attrs']['className'], $matches );
|
||||
|
||||
if ( empty( $matches ) ) {
|
||||
return $block_content;
|
||||
|
||||
@@ -959,6 +959,7 @@ add_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );
|
||||
* to avoid breaking styles relying on that div.
|
||||
*
|
||||
* @since 5.8.0
|
||||
* @since 6.6.1 Removed inner container from Grid variations.
|
||||
* @access private
|
||||
*
|
||||
* @param string $block_content Rendered block content.
|
||||
@@ -975,7 +976,7 @@ function wp_restore_group_inner_container( $block_content, $block ) {
|
||||
if (
|
||||
wp_theme_has_theme_json() ||
|
||||
1 === preg_match( $group_with_inner_container_regex, $block_content ) ||
|
||||
( isset( $block['attrs']['layout']['type'] ) && 'flex' === $block['attrs']['layout']['type'] )
|
||||
( isset( $block['attrs']['layout']['type'] ) && ( 'flex' === $block['attrs']['layout']['type'] || 'grid' === $block['attrs']['layout']['type'] ) )
|
||||
) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
@@ -518,6 +518,7 @@ function wp_get_computed_fluid_typography_value( $args = array() ) {
|
||||
* @since 6.3.0 Using layout.wideSize as max viewport width, and logarithmic scale factor to calculate minimum font scale.
|
||||
* @since 6.4.0 Added configurable min and max viewport width values to the typography.fluid theme.json schema.
|
||||
* @since 6.6.0 Deprecated bool argument $should_use_fluid_typography.
|
||||
* @since 6.7.0 Font size presets can enable fluid typography individually, even if it’s disabled globally.
|
||||
*
|
||||
* @param array $preset {
|
||||
* Required. fontSizes preset value as seen in theme.json.
|
||||
@@ -538,10 +539,11 @@ function wp_get_typography_font_size_value( $preset, $settings = array() ) {
|
||||
}
|
||||
|
||||
/*
|
||||
* Catches empty values and 0/'0'.
|
||||
* Fluid calculations cannot be performed on 0.
|
||||
* Catches falsy values and 0/'0'. Fluid calculations cannot be performed on `0`.
|
||||
* Also returns early when a preset font size explicitly disables fluid typography with `false`.
|
||||
*/
|
||||
if ( empty( $preset['size'] ) ) {
|
||||
$fluid_font_size_settings = $preset['fluid'] ?? null;
|
||||
if ( false === $fluid_font_size_settings || empty( $preset['size'] ) ) {
|
||||
return $preset['size'];
|
||||
}
|
||||
|
||||
@@ -564,15 +566,20 @@ function wp_get_typography_font_size_value( $preset, $settings = array() ) {
|
||||
$global_settings
|
||||
);
|
||||
|
||||
$typography_settings = isset( $settings['typography'] ) ? $settings['typography'] : array();
|
||||
$should_use_fluid_typography = ! empty( $typography_settings['fluid'] );
|
||||
$typography_settings = $settings['typography'] ?? array();
|
||||
|
||||
if ( ! $should_use_fluid_typography ) {
|
||||
/*
|
||||
* Return early when fluid typography is disabled in the settings, and there
|
||||
* are no local settings to enable it for the individual preset.
|
||||
*
|
||||
* If this condition isn't met, either the settings or individual preset settings
|
||||
* have enabled fluid typography.
|
||||
*/
|
||||
if ( empty( $typography_settings['fluid'] ) && empty( $fluid_font_size_settings ) ) {
|
||||
return $preset['size'];
|
||||
}
|
||||
|
||||
// $typography_settings['fluid'] can be a bool or an array. Normalize to array.
|
||||
$fluid_settings = is_array( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : array();
|
||||
$fluid_settings = isset( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : array();
|
||||
$layout_settings = isset( $settings['layout'] ) ? $settings['layout'] : array();
|
||||
|
||||
// Defaults.
|
||||
@@ -592,14 +599,6 @@ function wp_get_typography_font_size_value( $preset, $settings = array() ) {
|
||||
$has_min_font_size = isset( $fluid_settings['minFontSize'] ) && ! empty( wp_get_typography_value_and_unit( $fluid_settings['minFontSize'] ) );
|
||||
$minimum_font_size_limit = $has_min_font_size ? $fluid_settings['minFontSize'] : $default_minimum_font_size_limit;
|
||||
|
||||
// Font sizes.
|
||||
$fluid_font_size_settings = isset( $preset['fluid'] ) ? $preset['fluid'] : null;
|
||||
|
||||
// A font size has explicitly bypassed fluid calculations.
|
||||
if ( false === $fluid_font_size_settings ) {
|
||||
return $preset['size'];
|
||||
}
|
||||
|
||||
// Try to grab explicit min and max fluid font sizes.
|
||||
$minimum_font_size_raw = isset( $fluid_font_size_settings['min'] ) ? $fluid_font_size_settings['min'] : null;
|
||||
$maximum_font_size_raw = isset( $fluid_font_size_settings['max'] ) ? $fluid_font_size_settings['max'] : null;
|
||||
|
||||
Reference in New Issue
Block a user