Skip to content

Commit

Permalink
remove "block_thing" function 😅
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Dec 13, 2024
1 parent 28b34dd commit e105add
Showing 1 changed file with 0 additions and 56 deletions.
56 changes: 0 additions & 56 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2227,62 +2227,6 @@ function parse_blocks( $content ) {
return $parser->parse( $content );
}

function block_thing( array &$parsed_blocks ) {
$block_registry = WP_Block_Type_Registry::get_instance();

foreach ( $parsed_blocks as &$block ) {
if ( isset( $block['blockName'] ) ) {
$block_type = $block_registry->get_registered( $block['blockName'] );

if ( null !== $block_type && null !== $block_type->attributes ) {
foreach ( $block_type->attributes as $attribute_name => $attribute ) {
if ( ! isset( $attribute['selector'] ) ) {
continue;
}
if ( ! isset( $block['attrs'][ $attribute_name ] ) && '' !== $block['innerHTML'] ) {
$processor = WP_HTML_Processor::create_fragment( $block['innerHTML'] );

$selector = $attribute['selector'];

// This is a workaround for a known unsupported selector in a core block.
if ( 'a:not([download])' === $selector ) {
$selector = 'a';
}

foreach ( $processor->select_all( $selector ) as $_ ) {
// This is a workaround for a known unsupported selector in a core block.
if (
'a:not([download])' === $attribute['selector'] &&
null !== $processor->get_attribute( 'download' )
) {
continue;
}

switch ( $attribute['source'] ) {
case 'attribute':
$attr_value = $processor->get_attribute( $attribute['attribute'] );
// This could be null, string, true, check what JS parser does.
$block['attrs'][ $attribute_name ] = $attr_value;
break;

// @todo see about supporting these.
case 'text':
case 'rich-text':
case 'query':
break;
}
}
}
}
}
}
if ( isset( $block['innerBlocks'] ) ) {
block_thing( $block['innerBlocks'] );
}
}
return $parsed_blocks;
}

/**
* Parses dynamic blocks out of `post_content` and re-renders them.
*
Expand Down

0 comments on commit e105add

Please sign in to comment.