Changeset 56382
- Timestamp:
- 08/10/2023 04:47:00 PM (16 months ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/align.php
r52302 r56382 16 16 */ 17 17 function wp_register_alignment_support( $block_type ) { 18 $has_align_support = block_has_support( $block_type, array( 'align' ), false );18 $has_align_support = block_has_support( $block_type, 'align', false ); 19 19 if ( $has_align_support ) { 20 20 if ( ! $block_type->attributes ) { … … 44 44 function wp_apply_alignment_support( $block_type, $block_attributes ) { 45 45 $attributes = array(); 46 $has_align_support = block_has_support( $block_type, array( 'align' ), false );46 $has_align_support = block_has_support( $block_type, 'align', false ); 47 47 if ( $has_align_support ) { 48 48 $has_block_alignment = array_key_exists( 'align', $block_attributes ); -
trunk/src/wp-includes/block-supports/border.php
r54211 r56382 23 23 } 24 24 25 if ( block_has_support( $block_type, array( '__experimentalBorder' )) && ! array_key_exists( 'style', $block_type->attributes ) ) {25 if ( block_has_support( $block_type, '__experimentalBorder' ) && ! array_key_exists( 'style', $block_type->attributes ) ) { 26 26 $block_type->attributes['style'] = array( 27 27 'type' => 'object', -
trunk/src/wp-includes/block-supports/custom-classname.php
r54873 r56382 16 16 */ 17 17 function wp_register_custom_classname_support( $block_type ) { 18 $has_custom_classname_support = block_has_support( $block_type, array( 'customClassName' ), true );18 $has_custom_classname_support = block_has_support( $block_type, 'customClassName', true ); 19 19 20 20 if ( $has_custom_classname_support ) { … … 43 43 */ 44 44 function wp_apply_custom_classname_support( $block_type, $block_attributes ) { 45 $has_custom_classname_support = block_has_support( $block_type, array( 'customClassName' ), true );45 $has_custom_classname_support = block_has_support( $block_type, 'customClassName', true ); 46 46 $attributes = array(); 47 47 if ( $has_custom_classname_support ) { -
trunk/src/wp-includes/block-supports/dimensions.php
r55175 r56382 30 30 } 31 31 32 $has_dimensions_support = block_has_support( $block_type, array( 'dimensions' ), false );32 $has_dimensions_support = block_has_support( $block_type, 'dimensions', false ); 33 33 34 34 if ( $has_dimensions_support ) { -
trunk/src/wp-includes/block-supports/generated-classname.php
r54874 r56382 51 51 function wp_apply_generated_classname_support( $block_type ) { 52 52 $attributes = array(); 53 $has_generated_classname_support = block_has_support( $block_type, array( 'className' ), true );53 $has_generated_classname_support = block_has_support( $block_type, 'className', true ); 54 54 if ( $has_generated_classname_support ) { 55 55 $block_classname = wp_get_block_default_classname( $block_type->name ); -
trunk/src/wp-includes/block-supports/layout.php
r56055 r56382 203 203 */ 204 204 function wp_register_layout_support( $block_type ) { 205 $support_layout = block_has_support( $block_type, array( 'layout' ), false ) || block_has_support( $block_type, array( '__experimentalLayout' ), false );205 $support_layout = block_has_support( $block_type, 'layout', false ) || block_has_support( $block_type, '__experimentalLayout', false ); 206 206 if ( $support_layout ) { 207 207 if ( ! $block_type->attributes ) { … … 549 549 function wp_render_layout_support_flag( $block_content, $block ) { 550 550 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); 551 $support_layout = block_has_support( $block_type, array( 'layout' ), false ) || block_has_support( $block_type, array( '__experimentalLayout' ), false );551 $support_layout = block_has_support( $block_type, 'layout', false ) || block_has_support( $block_type, '__experimentalLayout', false ); 552 552 $has_child_layout = isset( $block['attrs']['style']['layout']['selfStretch'] ); 553 553 -
trunk/src/wp-includes/block-supports/position.php
r55286 r56382 16 16 */ 17 17 function wp_register_position_support( $block_type ) { 18 $has_position_support = block_has_support( $block_type, array( 'position' ), false );18 $has_position_support = block_has_support( $block_type, 'position', false ); 19 19 20 20 // Set up attributes and styles within that if needed. … … 42 42 function wp_render_position_support( $block_content, $block ) { 43 43 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); 44 $has_position_support = block_has_support( $block_type, array( 'position' ), false );44 $has_position_support = block_has_support( $block_type, 'position', false ); 45 45 46 46 if ( -
trunk/src/wp-includes/block-supports/settings.php
r56146 r56382 41 41 // return early if the block doesn't have support for settings. 42 42 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); 43 if ( ! block_has_support( $block_type, array( '__experimentalSettings' ), false ) ) {43 if ( ! block_has_support( $block_type, '__experimentalSettings', false ) ) { 44 44 return $block_content; 45 45 } … … 78 78 // Return early if the block has not support for descendent block styles. 79 79 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); 80 if ( ! block_has_support( $block_type, array( '__experimentalSettings' ), false ) ) {80 if ( ! block_has_support( $block_type, '__experimentalSettings', false ) ) { 81 81 return null; 82 82 } -
trunk/src/wp-includes/block-supports/shadow.php
r56046 r56382 16 16 */ 17 17 function wp_register_shadow_support( $block_type ) { 18 $has_shadow_support = block_has_support( $block_type, array( 'shadow' ), false );18 $has_shadow_support = block_has_support( $block_type, 'shadow', false ); 19 19 20 20 if ( ! $has_shadow_support ) { … … 51 51 */ 52 52 function wp_apply_shadow_support( $block_type, $block_attributes ) { 53 $has_shadow_support = block_has_support( $block_type, array( 'shadow' ), false );53 $has_shadow_support = block_has_support( $block_type, 'shadow', false ); 54 54 55 55 if ( ! $has_shadow_support ) { -
trunk/src/wp-includes/block-supports/spacing.php
r54874 r56382 19 19 */ 20 20 function wp_register_spacing_support( $block_type ) { 21 $has_spacing_support = block_has_support( $block_type, array( 'spacing' ), false );21 $has_spacing_support = block_has_support( $block_type, 'spacing', false ); 22 22 23 23 // Setup attributes and styles within that if needed. -
trunk/src/wp-includes/blocks.php
r56244 r56382 1249 1249 * 1250 1250 * @since 5.8.0 1251 * @since 6.4.0 The `$feature` parameter now supports a string. 1251 1252 * 1252 1253 * @param WP_Block_Type $block_type Block type to check for support. 1253 * @param array $feature Path to a specific feature to check support for.1254 * @param string|array $feature Feature slug, or path to a specific feature to check support for. 1254 1255 * @param mixed $default_value Optional. Fallback value for feature support. Default false. 1255 1256 * @return bool Whether the feature is supported. … … 1258 1259 $block_support = $default_value; 1259 1260 if ( $block_type && property_exists( $block_type, 'supports' ) ) { 1260 $block_support = _wp_array_get( $block_type->supports, $feature, $default_value ); 1261 if ( is_array( $feature ) && count( $feature ) === 1 ) { 1262 $feature = $feature[0]; 1263 } 1264 1265 if ( is_array( $feature ) ) { 1266 $block_support = _wp_array_get( $block_type->supports, $feature, $default_value ); 1267 } elseif ( isset( $block_type->supports[ $feature ] ) ) { 1268 $block_support = $block_type->supports[ $feature ]; 1269 } 1261 1270 } 1262 1271 -
trunk/src/wp-includes/class-wp-theme-json.php
r56345 r56382 1264 1264 if ( isset( $block_metadata['name'] ) ) { 1265 1265 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] ); 1266 if ( ! block_has_support( $block_type, array( 'layout' ), false ) && ! block_has_support( $block_type, array( '__experimentalLayout' ), false ) ) {1266 if ( ! block_has_support( $block_type, 'layout', false ) && ! block_has_support( $block_type, '__experimentalLayout', false ) ) { 1267 1267 return $block_rules; 1268 1268 } -
trunk/tests/phpunit/tests/blocks/wpBlock.php
r55822 r56382 684 684 685 685 /** 686 * @ticket 58532 687 * 688 * @dataProvider data_block_has_support_string 689 * 690 * @param array $block_data Block data. 691 * @param string $support Support string to check. 692 * @param bool $expected Expected result. 693 */ 694 public function test_block_has_support_string( $block_data, $support, $expected, $message ) { 695 $this->registry->register( 'core/example', $block_data ); 696 $block_type = $this->registry->get_registered( 'core/example' ); 697 $has_support = block_has_support( $block_type, $support ); 698 $this->assertEquals( $expected, $has_support, $message ); 699 } 700 701 /** 702 * Data provider for test_block_has_support_string 703 */ 704 public function data_block_has_support_string() { 705 return array( 706 array( 707 array(), 708 'color', 709 false, 710 'Block with empty support array.', 711 ), 712 array( 713 array( 714 'supports' => array( 715 'align' => array( 'wide', 'full' ), 716 'fontSize' => true, 717 'color' => array( 718 'link' => true, 719 'gradient' => false, 720 ), 721 ), 722 ), 723 'align', 724 true, 725 'Feature present in support array.', 726 ), 727 array( 728 array( 729 'supports' => array( 730 'align' => array( 'wide', 'full' ), 731 'fontSize' => true, 732 'color' => array( 733 'link' => true, 734 'gradient' => false, 735 ), 736 ), 737 ), 738 'anchor', 739 false, 740 'Feature not present in support array.', 741 ), 742 array( 743 array( 744 'supports' => array( 745 'align' => array( 'wide', 'full' ), 746 'fontSize' => true, 747 'color' => array( 748 'link' => true, 749 'gradient' => false, 750 ), 751 ), 752 ), 753 array( 'align' ), 754 true, 755 'Feature present in support array, single element array.', 756 ), 757 ); 758 } 759 760 /** 686 761 * @ticket 51612 687 762 */
Note: See TracChangeset
for help on using the changeset viewer.