Changeset 58475 for branches/6.4/src/wp-includes/blocks.php
- Timestamp:
- 06/24/2024 03:08:05 PM (17 months ago)
- File:
-
- 1 edited
-
branches/6.4/src/wp-includes/blocks.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/6.4/src/wp-includes/blocks.php
r57071 r58475 1227 1227 */ 1228 1228 function filter_block_kses( $block, $allowed_html, $allowed_protocols = array() ) { 1229 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols );1229 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols, $block ); 1230 1230 1231 1231 if ( is_array( $block['innerBlocks'] ) ) { … … 1243 1243 * 1244 1244 * @since 5.3.1 1245 * @since 6.5.5 Added the `$block_context` parameter. 1245 1246 * 1246 1247 * @param string[]|string $value The attribute value to filter. … … 1250 1251 * @param string[] $allowed_protocols Optional. Array of allowed URL protocols. 1251 1252 * Defaults to the result of wp_allowed_protocols(). 1253 * @param array $block_context Optional. The block the attribute belongs to, in parsed block array format. 1252 1254 * @return string[]|string The filtered and sanitized result. 1253 1255 */ 1254 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array() ) {1256 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array(), $block_context = null ) { 1255 1257 if ( is_array( $value ) ) { 1256 1258 foreach ( $value as $key => $inner_value ) { 1257 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols ); 1258 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols ); 1259 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols, $block_context ); 1260 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols, $block_context ); 1261 1262 if ( isset( $block_context['blockName'] ) && 'core/template-part' === $block_context['blockName'] ) { 1263 $filtered_value = filter_block_core_template_part_attributes( $filtered_value, $filtered_key, $allowed_html ); 1264 } 1259 1265 1260 1266 if ( $filtered_key !== $key ) { … … 1269 1275 1270 1276 return $value; 1277 } 1278 1279 /** 1280 * Sanitizes the value of the Template Part block's `tagName` attribute. 1281 * 1282 * @since 6.5.5 1283 * 1284 * @param string $attribute_value The attribute value to filter. 1285 * @param string $attribute_name The attribute name. 1286 * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, 1287 * or a context name such as 'post'. See wp_kses_allowed_html() 1288 * for the list of accepted context names. 1289 * @return string The sanitized attribute value. 1290 */ 1291 function filter_block_core_template_part_attributes( $attribute_value, $attribute_name, $allowed_html ) { 1292 if ( empty( $attribute_value ) || 'tagName' !== $attribute_name ) { 1293 return $attribute_value; 1294 } 1295 if ( ! is_array( $allowed_html ) ) { 1296 $allowed_html = wp_kses_allowed_html( $allowed_html ); 1297 } 1298 return isset( $allowed_html[ $attribute_value ] ) ? $attribute_value : ''; 1271 1299 } 1272 1300
Note: See TracChangeset
for help on using the changeset viewer.