Changeset 50929 for trunk/src/wp-includes/block-supports/border.php
- Timestamp:
- 05/19/2021 03:07:55 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/border.php
r50824 r50929 19 19 // Determine if any border related features are supported. 20 20 $has_border_support = block_has_support( $block_type, array( '__experimentalBorder' ) ); 21 $has_border_color_support = block_has_support( $block_type, array( '__experimentalBorder', 'color' ));21 $has_border_color_support = wp_has_border_feature_support( $block_type, 'color' ); 22 22 23 23 // Setup attributes and styles within that if needed. … … 61 61 // Border radius. 62 62 if ( 63 block_has_support( $block_type, array( '__experimentalBorder', 'radius' )) &&63 wp_has_border_feature_support( $block_type, 'radius' ) && 64 64 isset( $block_attributes['style']['border']['radius'] ) 65 65 ) { … … 70 70 // Border style. 71 71 if ( 72 block_has_support( $block_type, array( '__experimentalBorder', 'style' )) &&72 wp_has_border_feature_support( $block_type, 'style' ) && 73 73 isset( $block_attributes['style']['border']['style'] ) 74 74 ) { … … 79 79 // Border width. 80 80 if ( 81 block_has_support( $block_type, array( '__experimentalBorder', 'width' )) &&81 wp_has_border_feature_support( $block_type, 'width' ) && 82 82 isset( $block_attributes['style']['border']['width'] ) 83 83 ) { … … 87 87 88 88 // Border color. 89 if ( block_has_support( $block_type, array( '__experimentalBorder', 'color' )) ) {89 if ( wp_has_border_feature_support( $block_type, 'color' ) ) { 90 90 $has_named_border_color = array_key_exists( 'borderColor', $block_attributes ); 91 91 $has_custom_border_color = isset( $block_attributes['style']['border']['color'] ); … … 136 136 } 137 137 138 /** 139 * Checks whether the current block type supports the border feature requested. 140 * 141 * If the `__experimentalBorder` support flag is a boolean `true` all border 142 * support features are available. Otherwise, the specific feature's support 143 * flag nested under `experimentalBorder` must be enabled for the feature 144 * to be opted into. 145 * 146 * @since 5.8.0 147 * @access private 148 * 149 * @param WP_Block_Type $block_type Block type to check for support. 150 * @param string $feature Name of the feature to check support for. 151 * @param mixed $default Fallback value for feature support, defaults to false. 152 * 153 * @return boolean Whether or not the feature is supported. 154 */ 155 function wp_has_border_feature_support( $block_type, $feature, $default = false ) { 156 // Check if all border support features have been opted into via `"__experimentalBorder": true`. 157 if ( 158 property_exists( $block_type, 'supports' ) && 159 ( true === _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), $default ) ) 160 ) { 161 return true; 162 } 163 164 // Check if the specific feature has been opted into individually 165 // via nested flag under `__experimentalBorder`. 166 return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default ); 167 } 168 138 169 // Register the block support. 139 170 WP_Block_Supports::get_instance()->register(
Note: See TracChangeset
for help on using the changeset viewer.