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%';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user