| @@ -93,9 +93,9 @@ | ||
| 93 | 93 | $has_border_color_support && |
| 94 | 94 | ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'color' ) |
| 95 | 95 | ) { |
| 96 | 96 | $preset_border_color = array_key_exists( 'borderColor', $block_attributes ) ? "var:preset|color|{$block_attributes['borderColor']}" : null; |
| 97 | - $custom_border_color = $block_attributes['style']['border']['color'] ?? null; | |
| 97 | + $custom_border_color = _wp_array_get( $block_attributes, array( 'style', 'border', 'color' ), null ); | |
| 98 | 98 | $border_block_styles['color'] = $preset_border_color ? $preset_border_color : $custom_border_color; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Generate styles for individual border sides. |
| @@ -100,9 +100,9 @@ | ||
| 100 | 100 | |
| 101 | 101 | // Generate styles for individual border sides. |
| 102 | 102 | if ( $has_border_color_support || $has_border_width_support ) { |
| 103 | 103 | foreach ( array( 'top', 'right', 'bottom', 'left' ) as $side ) { |
| 104 | - $border = $block_attributes['style']['border'][ $side ] ?? null; | |
| 104 | + $border = _wp_array_get( $block_attributes, array( 'style', 'border', $side ), null ); | |
| 105 | 105 | $border_side_values = array( |
| 106 | 106 | 'width' => isset( $border['width'] ) && ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'width' ) ? $border['width'] : null, |
| 107 | 107 | 'color' => isset( $border['color'] ) && ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'color' ) ? $border['color'] : null, |
| 108 | 108 | 'style' => isset( $border['style'] ) && ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'style' ) ? $border['style'] : null, |
| @@ -133,26 +133,26 @@ | ||
| 133 | 133 | * support features are available. Otherwise, the specific feature's support |
| 134 | 134 | * flag nested under `experimentalBorder` must be enabled for the feature |
| 135 | 135 | * to be opted into. |
| 136 | 136 | * |
| 137 | - * @param WP_Block_Type $block_type Block type to check for support. | |
| 138 | - * @param string $feature Name of the feature to check support for. | |
| 139 | - * @param mixed $default_value Fallback value for feature support, defaults to false. | |
| 137 | + * @param WP_Block_Type $block_type Block type to check for support. | |
| 138 | + * @param string $feature Name of the feature to check support for. | |
| 139 | + * @param mixed $default Fallback value for feature support, defaults to false. | |
| 140 | 140 | * |
| 141 | 141 | * @return boolean Whether or not the feature is supported. |
| 142 | 142 | */ |
| 143 | -function gutenberg_has_border_feature_support( $block_type, $feature, $default_value = false ) { | |
| 143 | +function gutenberg_has_border_feature_support( $block_type, $feature, $default = false ) { | |
| 144 | 144 | // Check if all border support features have been opted into via `"__experimentalBorder": true`. |
| 145 | - if ( $block_type instanceof WP_Block_Type ) { | |
| 146 | - $block_type_supports_border = $block_type->supports['__experimentalBorder'] ?? $default_value; | |
| 147 | - if ( true === $block_type_supports_border ) { | |
| 148 | - return true; | |
| 149 | - } | |
| 145 | + if ( | |
| 146 | + property_exists( $block_type, 'supports' ) && | |
| 147 | + ( true === _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), $default ) ) | |
| 148 | + ) { | |
| 149 | + return true; | |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // Check if the specific feature has been opted into individually |
| 153 | 153 | // via nested flag under `__experimentalBorder`. |
| 154 | - return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default_value ); | |
| 154 | + return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default ); | |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Register the block support. |
| 158 | 158 | WP_Block_Supports::get_instance()->register( |