From 1f7444354130c91ce17a3bb0c8b18cb31ff52f90 Mon Sep 17 00:00:00 2001 From: benazeer1909 Date: Wed, 30 Oct 2024 17:06:45 +0530 Subject: [PATCH] stabilize-experimentalBorder php file changes --- src/wp-includes/block-supports/border.php | 42 ++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/block-supports/border.php b/src/wp-includes/block-supports/border.php index a11c099d9eb32..4864c15b147a6 100644 --- a/src/wp-includes/block-supports/border.php +++ b/src/wp-includes/block-supports/border.php @@ -22,7 +22,8 @@ function wp_register_border_support( $block_type ) { $block_type->attributes = array(); } - if ( block_has_support( $block_type, '__experimentalBorder' ) && ! array_key_exists( 'style', $block_type->attributes ) ) { + if ( ( block_has_support( $block_type, 'border' ) || block_has_support( $block_type, '__experimentalBorder' ) ) && + ! array_key_exists( 'style', $block_type->attributes ) ) { $block_type->attributes['style'] = array( 'type' => 'object', ); @@ -60,7 +61,8 @@ function wp_apply_border_support( $block_type, $block_attributes ) { if ( wp_has_border_feature_support( $block_type, 'radius' ) && isset( $block_attributes['style']['border']['radius'] ) && - ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'radius' ) + ( ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'radius' ) || + ! wp_should_skip_block_supports_serialization( $block_type, 'border', 'radius' ) ) ) { $border_radius = $block_attributes['style']['border']['radius']; @@ -75,7 +77,8 @@ function wp_apply_border_support( $block_type, $block_attributes ) { if ( wp_has_border_feature_support( $block_type, 'style' ) && isset( $block_attributes['style']['border']['style'] ) && - ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'style' ) + ( ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'style' ) || + ! wp_should_skip_block_supports_serialization( $block_type, 'border', 'style' ) ) ) { $border_block_styles['style'] = $block_attributes['style']['border']['style']; } @@ -84,7 +87,8 @@ function wp_apply_border_support( $block_type, $block_attributes ) { if ( $has_border_width_support && isset( $block_attributes['style']['border']['width'] ) && - ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'width' ) + ( ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'width' ) || + ! wp_should_skip_block_supports_serialization( $block_type, 'border', 'width' ) ) ) { $border_width = $block_attributes['style']['border']['width']; @@ -99,7 +103,8 @@ function wp_apply_border_support( $block_type, $block_attributes ) { // Border color. if ( $has_border_color_support && - ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'color' ) + ( ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'color' ) || + ! wp_should_skip_block_supports_serialization( $block_type, 'border', 'color' ) ) ) { $preset_border_color = array_key_exists( 'borderColor', $block_attributes ) ? "var:preset|color|{$block_attributes['borderColor']}" : null; $custom_border_color = isset( $block_attributes['style']['border']['color'] ) ? $block_attributes['style']['border']['color'] : null; @@ -111,9 +116,23 @@ function wp_apply_border_support( $block_type, $block_attributes ) { foreach ( array( 'top', 'right', 'bottom', 'left' ) as $side ) { $border = isset( $block_attributes['style']['border'][ $side ] ) ? $block_attributes['style']['border'][ $side ] : null; $border_side_values = array( - 'width' => isset( $border['width'] ) && ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'width' ) ? $border['width'] : null, - 'color' => isset( $border['color'] ) && ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'color' ) ? $border['color'] : null, - 'style' => isset( $border['style'] ) && ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'style' ) ? $border['style'] : null, + 'width' => isset( $border['width'] ) && + ! ( wp_should_skip_block_supports_serialization( $block_type, 'border', 'width' ) || + wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'width' ) ) + ? $border['width'] + : null, + + 'color' => isset( $border['color'] ) && + ! ( wp_should_skip_block_supports_serialization( $block_type, 'border', 'color' ) || + wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'color' ) ) + ? $border['color'] + : null, + + 'style' => isset( $border['style'] ) && + ! ( wp_should_skip_block_supports_serialization( $block_type, 'border', 'style' ) || + wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'style' ) ) + ? $border['style'] + : null, ); $border_block_styles[ $side ] = $border_side_values; } @@ -153,9 +172,7 @@ function wp_apply_border_support( $block_type, $block_attributes ) { function wp_has_border_feature_support( $block_type, $feature, $default_value = false ) { // Check if all border support features have been opted into via `"__experimentalBorder": true`. if ( $block_type instanceof WP_Block_Type ) { - $block_type_supports_border = isset( $block_type->supports['__experimentalBorder'] ) - ? $block_type->supports['__experimentalBorder'] - : $default_value; + $block_type_supports_border = $block_type->supports['border'] ?? $block_type->supports['__experimentalBorder'] ?? $default_value; if ( true === $block_type_supports_border ) { return true; } @@ -163,7 +180,8 @@ function wp_has_border_feature_support( $block_type, $feature, $default_value = // Check if the specific feature has been opted into individually // via nested flag under `__experimentalBorder`. - return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default_value ); + return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default_value ) + || block_has_support( $block_type, array( 'border', $feature ), $default_value ); } // Register the block support.