Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template part - inconsistent / unwanted removal of <p> tag by shortcode_unautop() #33345

Open
bobbingwide opened this issue Jul 11, 2021 · 1 comment
Labels
[Block] Template Part Affects the Template Parts Block [Feature] Shortcodes Related to shortcode functionality [Type] Bug An existing feature does not function as intended

Comments

@bobbingwide
Copy link
Contributor

Description

While attempting to build a metadates block template part to display the Published and Last updated dates in a grid layout
I noticed some styling problems and determined that in some instances the shortcode_unautop() call in template-part.php was responsible. Its continued use in Gutenberg was questioned in #26809.

I wrote a post to demonstrate the problem. The fix is simple. Remove the call to shortcode_unautop().

Step-by-step reproduction instructions

See the video.

Expected behaviour

<p> tags from paragraph blocks should not be removed programmatically by shortcode_unautop().

Actual behaviour

When a template part is used from a custom template some <p> tags are removed programmatically by shortcode_unautop().

Screenshots or screen recording (optional)

image
image
image

Code snippet (optional)

Commenting out the call to shortcode_unautop() resolves the issue.

C:\apache\htdocs\hm\wp-content\plugins\gutenberg>git diff -w build/block-library/blocks/template-part.php
diff --git a/build/block-library/blocks/template-part.php b/build/block-library/blocks/template-part.php
index 2e020f3e..900f8f00 100644
--- a/build/block-library/blocks/template-part.php
+++ b/build/block-library/blocks/template-part.php
@@ -90,14 +90,13 @@ function gutenberg_render_block_core_template_part( $attributes ) {
        unset( $seen_ids[ $template_part_id ] );
        $content = wptexturize( $content );
        $content = convert_smilies( $content );
-       $content = shortcode_unautop( $content );
+       //$content = shortcode_unautop( $content );
        if ( function_exists( 'wp_filter_content_tags' ) ) {
                $content = wp_filter_content_tags( $content );
        } else {
                $content = wp_make_content_images_responsive( $content );
        }
        $content = do_shortcode( $content );
-
        // Handle embeds for block template parts.
        global $wp_embed;
        $content = $wp_embed->autoembed( $content );

image

WordPress information

  • WordPress version: 5.8-RC2
  • Gutenberg version: 11.0.0
  • Are all plugins except Gutenberg deactivated? No
  • Are you using a default theme (e.g. Twenty Twenty-One)? No.

Device information

  • Device: Desktop
  • Operating system: Windows 10
  • Browser: Chrome
@bobbingwide
Copy link
Contributor Author

Gutenberg-issue-33345.mp4

@annezazu annezazu added [Block] Template Part Affects the Template Parts Block [Type] Bug An existing feature does not function as intended [Feature] Shortcodes Related to shortcode functionality labels Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block [Feature] Shortcodes Related to shortcode functionality [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants