Changeset 58479 for branches/6.2/src/wp-includes/blocks.php
- Timestamp:
- 06/24/2024 03:13:02 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.2/src/wp-includes/blocks.php
r55767 r58479 840 840 */ 841 841 function filter_block_kses( $block, $allowed_html, $allowed_protocols = array() ) { 842 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols );842 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols, $block ); 843 843 844 844 if ( is_array( $block['innerBlocks'] ) ) { … … 856 856 * 857 857 * @since 5.3.1 858 * @since 6.5.5 Added the `$block_context` parameter. 858 859 * 859 860 * @param string[]|string $value The attribute value to filter. … … 863 864 * @param string[] $allowed_protocols Optional. Array of allowed URL protocols. 864 865 * Defaults to the result of wp_allowed_protocols(). 866 * @param array $block_context Optional. The block the attribute belongs to, in parsed block array format. 865 867 * @return string[]|string The filtered and sanitized result. 866 868 */ 867 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array() ) {869 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array(), $block_context = null ) { 868 870 if ( is_array( $value ) ) { 869 871 foreach ( $value as $key => $inner_value ) { 870 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols ); 871 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols ); 872 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols, $block_context ); 873 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols, $block_context ); 874 875 if ( isset( $block_context['blockName'] ) && 'core/template-part' === $block_context['blockName'] ) { 876 $filtered_value = filter_block_core_template_part_attributes( $filtered_value, $filtered_key, $allowed_html ); 877 } 872 878 873 879 if ( $filtered_key !== $key ) { … … 882 888 883 889 return $value; 890 } 891 892 /** 893 * Sanitizes the value of the Template Part block's `tagName` attribute. 894 * 895 * @since 6.5.5 896 * 897 * @param string $attribute_value The attribute value to filter. 898 * @param string $attribute_name The attribute name. 899 * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, 900 * or a context name such as 'post'. See wp_kses_allowed_html() 901 * for the list of accepted context names. 902 * @return string The sanitized attribute value. 903 */ 904 function filter_block_core_template_part_attributes( $attribute_value, $attribute_name, $allowed_html ) { 905 if ( empty( $attribute_value ) || 'tagName' !== $attribute_name ) { 906 return $attribute_value; 907 } 908 if ( ! is_array( $allowed_html ) ) { 909 $allowed_html = wp_kses_allowed_html( $allowed_html ); 910 } 911 return isset( $allowed_html[ $attribute_value ] ) ? $attribute_value : ''; 884 912 } 885 913
Note: See TracChangeset
for help on using the changeset viewer.