Changeset 58476 for branches/6.3/src/wp-includes/blocks.php
- Timestamp:
- 06/24/2024 03:10:50 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.3/src/wp-includes/blocks.php
r57041 r58476 881 881 */ 882 882 function filter_block_kses( $block, $allowed_html, $allowed_protocols = array() ) { 883 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols );883 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols, $block ); 884 884 885 885 if ( is_array( $block['innerBlocks'] ) ) { … … 897 897 * 898 898 * @since 5.3.1 899 * @since 6.5.5 Added the `$block_context` parameter. 899 900 * 900 901 * @param string[]|string $value The attribute value to filter. … … 904 905 * @param string[] $allowed_protocols Optional. Array of allowed URL protocols. 905 906 * Defaults to the result of wp_allowed_protocols(). 907 * @param array $block_context Optional. The block the attribute belongs to, in parsed block array format. 906 908 * @return string[]|string The filtered and sanitized result. 907 909 */ 908 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array() ) {910 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array(), $block_context = null ) { 909 911 if ( is_array( $value ) ) { 910 912 foreach ( $value as $key => $inner_value ) { 911 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols ); 912 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols ); 913 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols, $block_context ); 914 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols, $block_context ); 915 916 if ( isset( $block_context['blockName'] ) && 'core/template-part' === $block_context['blockName'] ) { 917 $filtered_value = filter_block_core_template_part_attributes( $filtered_value, $filtered_key, $allowed_html ); 918 } 913 919 914 920 if ( $filtered_key !== $key ) { … … 923 929 924 930 return $value; 931 } 932 933 /** 934 * Sanitizes the value of the Template Part block's `tagName` attribute. 935 * 936 * @since 6.5.5 937 * 938 * @param string $attribute_value The attribute value to filter. 939 * @param string $attribute_name The attribute name. 940 * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, 941 * or a context name such as 'post'. See wp_kses_allowed_html() 942 * for the list of accepted context names. 943 * @return string The sanitized attribute value. 944 */ 945 function filter_block_core_template_part_attributes( $attribute_value, $attribute_name, $allowed_html ) { 946 if ( empty( $attribute_value ) || 'tagName' !== $attribute_name ) { 947 return $attribute_value; 948 } 949 if ( ! is_array( $allowed_html ) ) { 950 $allowed_html = wp_kses_allowed_html( $allowed_html ); 951 } 952 return isset( $allowed_html[ $attribute_value ] ) ? $attribute_value : ''; 925 953 } 926 954
Note: See TracChangeset
for help on using the changeset viewer.