Skip to content

Commit

Permalink
Re-add the index.php file.
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinan committed May 8, 2024
1 parent 70adc20 commit a242f0a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function gutenberg_reregister_core_block_types() {
'form-submit-button',
'group',
'html',
'list',
'list-item',
'missing',
'more',
Expand Down Expand Up @@ -76,6 +75,7 @@ function gutenberg_reregister_core_block_types() {
'heading.php' => 'core/heading',
'latest-comments.php' => 'core/latest-comments',
'latest-posts.php' => 'core/latest-posts',
'list.php' => 'core/list',
'loginout.php' => 'core/loginout',
'media-text.php' => 'core/media-text',
'navigation.php' => 'core/navigation',
Expand Down
54 changes: 54 additions & 0 deletions packages/block-library/src/list/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* Adds the wp-block-list class to the rendered list block.
*
* @package WordPress
*/

/**
* Adds the wp-block-list class to the rendered list block.
* Ensures that pre-existing list blocks use the class name on the front.
* For example, <ol> is transformed to <ol class="wp-block-list">.
*
* @since 6.6.0
*
* @see https://github.com/WordPress/gutenberg/issues/12420
*
* @param array $attributes Attributes of the block being rendered.
* @param string $content Content of the block being rendered.
*
* @return string The content of the block being rendered.
*/
function block_core_list_render( $attributes, $content ) {
if ( ! $content ) {
return $content;
}

$processor = new WP_HTML_Tag_Processor( $content );

$list_tags = array( 'OL', 'UL' );
while ( $processor->next_tag() ) {
if ( in_array( $processor->get_tag(), $list_tags, true ) ) {
$processor->add_class( 'wp-block-list' );
break;
}
}

return $processor->get_updated_html();
}

/**
* Registers the `core/list` block on server.
*
* @since 6.6.0
*/
function register_block_core_list() {
register_block_type_from_metadata(
__DIR__ . '/list',
array(
'render_callback' => 'block_core_list_render',
)
);
}

add_action( 'init', 'register_block_core_list' );

0 comments on commit a242f0a

Please sign in to comment.