Make WordPress Core

Ticket #58366: 58366-poc.2.diff

File 58366-poc.2.diff, 2.6 KB (added by SirLouen, 9 months ago)
  • src/wp-includes/block-template.php

    diff --git src/wp-includes/block-template.php src/wp-includes/block-template.php
    index affae1c09a..4cd7d5b691 100644
    function get_the_block_template_html() { 
    259259        $content = $wp_embed->run_shortcode( $_wp_current_template_content );
    260260        $content = $wp_embed->autoembed( $content );
    261261        $content = shortcode_unautop( $content );
     262        $line_break_placeholder = function( $shortcode_output ) {
     263            return str_replace( "\n", '<!-- wp-block-theme-line-break-placeholder -->', $shortcode_output );
     264    };
     265        add_filter( 'do_shortcode_tag', $line_break_placeholder, 100 );
    262266        $content = do_shortcode( $content );
    263 
     267        remove_filter( 'do_shortcode_tag', $line_break_placeholder, 100 );
    264268        /*
    265269         * Most block themes omit the `core/query` and `core/post-template` blocks in their singular content templates.
    266270         * While this technically still works since singular content templates are always for only one post, it results in
    function get_the_block_template_html() { 
    297301        $content = wptexturize( $content );
    298302        $content = convert_smilies( $content );
    299303        $content = wp_filter_content_tags( $content, 'template' );
     304        $content = str_replace( '<!-- wp-block-theme-line-break-placeholder -->', "\n", $content );
    300305        $content = str_replace( ']]>', ']]&gt;', $content );
    301306
    302307        // Wrap block template in .wp-site-blocks to allow for specific descendant styles
  • src/wp-includes/blocks/template-part.php

    diff --git src/wp-includes/blocks/template-part.php src/wp-includes/blocks/template-part.php
    index c73b644087..07ad2c8ac0 100644
    function render_block_core_template_part( $attributes ) { 
    151151
    152152        // Run through the actions that are typically taken on the_content.
    153153        $content                       = shortcode_unautop( $content );
     154        $line_break_placeholder = function( $shortcode_output ) {
     155                return str_replace( "\n", '<!-- wp-block-theme-line-break-placeholder -->', $shortcode_output );
     156        };
     157        add_filter( 'do_shortcode_tag', $line_break_placeholder, 100 );
    154158        $content                       = do_shortcode( $content );
     159        remove_filter( 'do_shortcode_tag', $line_break_placeholder, 100 );
    155160        $seen_ids[ $template_part_id ] = true;
    156161        $content                       = do_blocks( $content );
    157162        unset( $seen_ids[ $template_part_id ] );
    158163        $content = wptexturize( $content );
    159164        $content = convert_smilies( $content );
     165        $content = str_replace( '<!-- wp-block-theme-line-break-placeholder -->', "\n", $content );
    160166        $content = wp_filter_content_tags( $content, "template_part_{$area}" );
    161167
    162168        // Handle embeds for block template parts.