Make WordPress Core

Ticket #58366: 58366-poc.diff

File 58366-poc.diff, 2.4 KB (added by peterwilsoncc, 2 years ago)

POC -- not for commit

  • src/wp-includes/block-template.php

    diff --git a/src/wp-includes/block-template.php b/src/wp-includes/block-template.php
    index a65283cbe7..a43ec09439 100644
    a b function get_the_block_template_html() { 
    237237        $content = $wp_embed->run_shortcode( $_wp_current_template_content );
    238238        $content = $wp_embed->autoembed( $content );
    239239        $content = shortcode_unautop( $content );
     240        $line_break_placeholder = function( $shortcode_output ) {
     241                return str_replace( "\n", '<!-- wp-block-theme-line-break-placeholder -->', $shortcode_output );
     242        };
     243        add_filter( 'do_shortcode_tag', $line_break_placeholder, 100 );
    240244        $content = do_shortcode( $content );
     245        remove_filter( 'do_shortcode_tag', $line_break_placeholder, 100 );
    241246        $content = do_blocks( $content );
    242247        $content = wptexturize( $content );
    243248        $content = convert_smilies( $content );
    244249        $content = wp_filter_content_tags( $content, 'template' );
     250        $content = str_replace( '<!-- wp-block-theme-line-break-placeholder -->', "\n", $content );
    245251        $content = str_replace( ']]>', ']]&gt;', $content );
    246252
    247253        // Wrap block template in .wp-site-blocks to allow for specific descendant styles
  • src/wp-includes/blocks/template-part.php

    diff --git a/src/wp-includes/blocks/template-part.php b/src/wp-includes/blocks/template-part.php
    index 6f41f2a793..a3bc38fd85 100644
    a b function render_block_core_template_part( $attributes ) { 
    143143
    144144        // Run through the actions that are typically taken on the_content.
    145145        $content                       = shortcode_unautop( $content );
     146        $line_break_placeholder = function( $shortcode_output ) {
     147                return str_replace( "\n", '<!-- wp-block-theme-line-break-placeholder -->', $shortcode_output );
     148        };
     149        add_filter( 'do_shortcode_tag', $line_break_placeholder, 100 );
    146150        $content                       = do_shortcode( $content );
     151        remove_filter( 'do_shortcode_tag', $line_break_placeholder, 100 );
    147152        $seen_ids[ $template_part_id ] = true;
    148153        $content                       = do_blocks( $content );
    149154        unset( $seen_ids[ $template_part_id ] );
    150155        $content = wptexturize( $content );
    151156        $content = convert_smilies( $content );
     157        $content = str_replace( '<!-- wp-block-theme-line-break-placeholder -->', "\n", $content );
    152158        $content = wp_filter_content_tags( $content, "template_part_{$area}" );
    153159
    154160        // Handle embeds for block template parts.