Changeset 62475 for trunk/src/wp-includes/block-supports/elements.php
- Timestamp:
- 06/09/2026 12:47:16 AM (3 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/block-supports/elements.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/elements.php
r61557 r62475 238 238 * @since 6.6.0 239 239 * 240 * @param string $block_content Rendered block content. 241 * @param array $block Block object. 242 * @return string Filtered block content. 240 * @param string $block_content Rendered block content. 241 * @param array $block Block object. 242 * @return string Filtered block content. 243 * 244 * @phpstan-param array{ 245 * attrs: array{ 246 * className?: string, 247 * ... 248 * }, 249 * ... 250 * } $block 243 251 */ 244 252 function wp_render_elements_class_name( $block_content, $block ) { 245 $class_string = $block['attrs']['className'] ?? ''; 246 preg_match( '/\bwp-elements-\S+\b/', $class_string, $matches ); 247 248 if ( empty( $matches ) ) { 253 $class_name_attr = $block['attrs']['className'] ?? null; 254 $class_name_prefix = 'wp-elements-'; 255 if ( ! is_string( $class_name_attr ) || ! str_contains( $class_name_attr, $class_name_prefix ) ) { 249 256 return $block_content; 250 257 } 251 258 259 // Parse out the 'wp-elements-*' class name. 260 $matched_class_name = null; 261 $token_delimiter = " \t\f\r\n"; 262 $class_token = strtok( $class_name_attr, $token_delimiter ); 263 while ( false !== $class_token ) { 264 if ( str_starts_with( $class_token, $class_name_prefix ) ) { 265 $matched_class_name = $class_token; 266 break; 267 } 268 $class_token = strtok( $token_delimiter ); 269 } 270 if ( null === $matched_class_name ) { 271 return $block_content; 272 } 273 252 274 $tags = new WP_HTML_Tag_Processor( $block_content ); 253 254 275 if ( $tags->next_tag() ) { 255 $tags->add_class( $matche s[0]);276 $tags->add_class( $matched_class_name ); 256 277 } 257 278
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)