Changeset 58481 for branches/6.0/src/wp-includes/blocks.php
- Timestamp:
- 06/24/2024 03:17:32 PM (20 months ago)
- File:
-
- 1 edited
-
branches/6.0/src/wp-includes/blocks.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/6.0/src/wp-includes/blocks.php
r55773 r58481 688 688 */ 689 689 function filter_block_kses( $block, $allowed_html, $allowed_protocols = array() ) { 690 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols );690 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols, $block ); 691 691 692 692 if ( is_array( $block['innerBlocks'] ) ) { … … 704 704 * 705 705 * @since 5.3.1 706 * @since 6.5.5 Added the `$block_context` parameter. 706 707 * 707 708 * @param string[]|string $value The attribute value to filter. … … 710 711 * such as 'post'. 711 712 * @param string[] $allowed_protocols Array of allowed URL protocols. 713 * @param array $block_context Optional. The block the attribute belongs to, in parsed block array format. 712 714 * @return string[]|string The filtered and sanitized result. 713 715 */ 714 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array() ) {716 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array(), $block_context = null ) { 715 717 if ( is_array( $value ) ) { 716 718 foreach ( $value as $key => $inner_value ) { 717 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols ); 718 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols ); 719 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols, $block_context ); 720 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols, $block_context ); 721 722 if ( isset( $block_context['blockName'] ) && 'core/template-part' === $block_context['blockName'] ) { 723 $filtered_value = filter_block_core_template_part_attributes( $filtered_value, $filtered_key, $allowed_html ); 724 } 719 725 720 726 if ( $filtered_key !== $key ) { … … 729 735 730 736 return $value; 737 } 738 739 /** 740 * Sanitizes the value of the Template Part block's `tagName` attribute. 741 * 742 * @since 6.5.5 743 * 744 * @param string $attribute_value The attribute value to filter. 745 * @param string $attribute_name The attribute name. 746 * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, 747 * or a context name such as 'post'. See wp_kses_allowed_html() 748 * for the list of accepted context names. 749 * @return string The sanitized attribute value. 750 */ 751 function filter_block_core_template_part_attributes( $attribute_value, $attribute_name, $allowed_html ) { 752 if ( empty( $attribute_value ) || 'tagName' !== $attribute_name ) { 753 return $attribute_value; 754 } 755 if ( ! is_array( $allowed_html ) ) { 756 $allowed_html = wp_kses_allowed_html( $allowed_html ); 757 } 758 return isset( $allowed_html[ $attribute_value ] ) ? $attribute_value : ''; 731 759 } 732 760
Note: See TracChangeset
for help on using the changeset viewer.