From 65a23e8a44f135c1e0c1c6c220660fef54d91be4 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Tue, 21 Dec 2021 08:58:45 +0100 Subject: [PATCH 1/3] Try: parse shortcode blocks outside the content Adds do_shortcode() to parse the shortcode outside the content (block templates, block patterns) --- packages/block-library/src/shortcode/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/shortcode/index.php b/packages/block-library/src/shortcode/index.php index 97a40b386d9c92..3eb3055c205445 100644 --- a/packages/block-library/src/shortcode/index.php +++ b/packages/block-library/src/shortcode/index.php @@ -6,7 +6,7 @@ */ /** - * Performs wpautop() on the shortcode block content. + * Performs wpautop() and do_shortcode() on the shortcode block content. * * @param array $attributes The block attributes. * @param string $content The block content. @@ -14,7 +14,7 @@ * @return string Returns the block content. */ function render_block_core_shortcode( $attributes, $content ) { - return wpautop( $content ); + return wpautop( do_shortcode( $content ) ); } /** From 0f45df52f3ecbce3551fc468c93d87a06191f152 Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Wed, 22 Dec 2021 05:21:13 +0100 Subject: [PATCH 2/3] Move do_shortcode from the block to gutenberg_get_the_template_html --- lib/compat/wordpress-5.9/block-template.php | 1 + packages/block-library/src/shortcode/index.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/compat/wordpress-5.9/block-template.php b/lib/compat/wordpress-5.9/block-template.php index f348818f8aa53c..dc6848c22a1b62 100644 --- a/lib/compat/wordpress-5.9/block-template.php +++ b/lib/compat/wordpress-5.9/block-template.php @@ -217,6 +217,7 @@ function gutenberg_get_the_template_html() { $content = do_blocks( $content ); $content = wptexturize( $content ); $content = wp_filter_content_tags( $content ); + $content = do_shortcode( $content ); $content = str_replace( ']]>', ']]>', $content ); // Wrap block template in .wp-site-blocks to allow for specific descendant styles diff --git a/packages/block-library/src/shortcode/index.php b/packages/block-library/src/shortcode/index.php index 3eb3055c205445..97a40b386d9c92 100644 --- a/packages/block-library/src/shortcode/index.php +++ b/packages/block-library/src/shortcode/index.php @@ -6,7 +6,7 @@ */ /** - * Performs wpautop() and do_shortcode() on the shortcode block content. + * Performs wpautop() on the shortcode block content. * * @param array $attributes The block attributes. * @param string $content The block content. @@ -14,7 +14,7 @@ * @return string Returns the block content. */ function render_block_core_shortcode( $attributes, $content ) { - return wpautop( do_shortcode( $content ) ); + return wpautop( $content ); } /** From bda91beb43b6d9c4fb5a54dc812476f5a8fc10bd Mon Sep 17 00:00:00 2001 From: Carolina Nymark Date: Wed, 22 Dec 2021 08:43:28 +0100 Subject: [PATCH 3/3] add convert_smilies and shortcode_unautop --- lib/compat/wordpress-5.9/block-template.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/compat/wordpress-5.9/block-template.php b/lib/compat/wordpress-5.9/block-template.php index dc6848c22a1b62..1ecc2887d9f0a6 100644 --- a/lib/compat/wordpress-5.9/block-template.php +++ b/lib/compat/wordpress-5.9/block-template.php @@ -216,6 +216,8 @@ function gutenberg_get_the_template_html() { $content = $wp_embed->autoembed( $content ); $content = do_blocks( $content ); $content = wptexturize( $content ); + $content = convert_smilies( $content ); + $content = shortcode_unautop( $content ); $content = wp_filter_content_tags( $content ); $content = do_shortcode( $content ); $content = str_replace( ']]>', ']]>', $content );