| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Aria label block support flag. 4 * 5 * @package WordPress 6 * @since 6.8.0 7 */ 8 9 /** 10 * Registers the aria-label block attribute for block types that support it. 11 * 12 * @since 6.8.0 13 * @access private 14 * 15 * @param WP_Block_Type $block_type Block Type. 16 */ 17 function wp_register_aria_label_support( $block_type ) { 18 $has_aria_label_support = block_has_support( $block_type, array( 'ariaLabel' ), false ); 19 20 if ( ! $has_aria_label_support ) { 21 return; 22 } 23 24 if ( ! $block_type->attributes ) { 25 $block_type->attributes = array(); 26 } 27 28 if ( ! array_key_exists( 'ariaLabel', $block_type->attributes ) ) { 29 $block_type->attributes['ariaLabel'] = array( 30 'type' => 'string', 31 ); 32 } 33 } 34 35 /** 36 * Add the aria-label to the output. 37 * 38 * @since 6.8.0 39 * @access private 40 * 41 * @param WP_Block_Type $block_type Block Type. 42 * @param array $block_attributes Block attributes. 43 * 44 * @return array Block aria-label. 45 */ 46 function wp_apply_aria_label_support( $block_type, $block_attributes ) { 47 if ( ! $block_attributes ) { 48 return array(); 49 } 50 51 $has_aria_label_support = block_has_support( $block_type, array( 'ariaLabel' ), false ); 52 if ( 53 ! $has_aria_label_support || 54 wp_should_skip_block_supports_serialization( $block_type, 'ariaLabel' ) 55 ) { 56 return array(); 57 } 58 59 $has_aria_label = array_key_exists( 'ariaLabel', $block_attributes ); 60 if ( ! $has_aria_label ) { 61 return array(); 62 } 63 return array( 'aria-label' => $block_attributes['ariaLabel'] ); 64 } 65 66 // Register the block support. 67 WP_Block_Supports::get_instance()->register( 68 'aria-label', 69 array( 70 'register_attribute' => 'wp_register_aria_label_support', 71 'apply' => 'wp_apply_aria_label_support', 72 ) 73 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Jun 24 08:20:11 2026 | Cross-referenced by PHPXref |