diff --git a/packages/block-library/src/post-content/index.php b/packages/block-library/src/post-content/index.php index 228a0d52f40699..652c1b1fb87966 100644 --- a/packages/block-library/src/post-content/index.php +++ b/packages/block-library/src/post-content/index.php @@ -51,10 +51,33 @@ function render_block_core_post_content( $attributes, $content, $block ) { $content .= wp_link_pages( array( 'echo' => 0 ) ); } + $filters_to_remove = array( + 'wptexturize' => false, + 'shortcode_unautop' => false, + 'wp_filter_content_tags' => false, + 'do_shortcode' => false, + 'convert_smilies' => false, + ); + + // Temporarily remove some filters that are not suitable for this block. + foreach ( $filters_to_remove as $filter => &$priority ) { + $priority = has_filter( 'the_content', $filter ); + if ( false !== $priority ) { + remove_filter( 'the_content', $filter, $priority ); + } + } + /** This filter is documented in wp-includes/post-template.php */ $content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) ); unset( $seen_ids[ $post_id ] ); + // Restore filters. + foreach ( $filters_to_remove as $filter => $priority ) { + if ( false !== $priority ) { + add_filter( 'the_content', $filter, $priority ); + } + } + if ( empty( $content ) ) { return ''; } diff --git a/packages/block-library/src/template-part/index.php b/packages/block-library/src/template-part/index.php index 838210480ca288..db50743d60f69f 100644 --- a/packages/block-library/src/template-part/index.php +++ b/packages/block-library/src/template-part/index.php @@ -127,20 +127,16 @@ function render_block_core_template_part( $attributes ) { ''; } - // Run through the actions that are typically taken on the_content. $seen_ids[ $template_part_id ] = true; - $content = do_blocks( $content ); - unset( $seen_ids[ $template_part_id ] ); - $content = wptexturize( $content ); - $content = convert_smilies( $content ); - $content = shortcode_unautop( $content ); - $content = wp_filter_content_tags( $content ); - $content = do_shortcode( $content ); // Handle embeds for block template parts. global $wp_embed; + $content = $wp_embed->run_shortcode( $content ); $content = $wp_embed->autoembed( $content ); + $content = do_blocks( $content ); + unset( $seen_ids[ $template_part_id ] ); + if ( empty( $attributes['tagName'] ) ) { $defined_areas = get_allowed_block_template_part_areas(); $area_tag = 'div';