[wp-trac] [WordPress Trac] #58366: Shortcode Support Regained but Content Filters are messing with Shortcode HTML

WordPress Trac noreply at wordpress.org
Tue Jun 13 07:20:43 UTC 2023


#58366: Shortcode Support Regained but Content Filters are messing with Shortcode
HTML
-------------------------------------------------+-------------------------
 Reporter:  domainsupport                        |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Shortcodes                           |     Version:  6.2.2
 Severity:  normal                               |  Resolution:
 Keywords:  needs-testing has-testing-info       |     Focuses:
  needs-unit-tests                               |
-------------------------------------------------+-------------------------

Comment (by rilwis):

 We experienced a [https://support.metabox.io/topic/line-breaks-in-css-
 getting-wrapped-in-paragraphs/ similar problem] with shortcode and
 `wpautop` recently with our [https://metabox.io/plugins/mb-views/ MB
 Views] plugin.

 After investigating, we found that in a block theme, there are 2 issues:

 1. The "shortcode" block uses `wpautop` to
 [https://github.com/WordPress/WordPress/blob/master/wp-
 includes/blocks/shortcode.php wrap content in paragraphs]. I have no idea
 why is that. In my opinion, this should be removed.
 2. The process order of rendering block templates changed and caused the
 bug. See these 2 commits:

 https://github.com/WordPress/WordPress/commit/6a077b35f15590a843ff8a6c97a135f3a34872dd
 https://github.com/WordPress/WordPress/commit/2bb3a5169548d16173cf48ca9da1111efc428f86

 Previously, the content of a block template goes through `do_blocks`
 ("shortcode" blocks apply `wpautop`, but since shortcodes are not parsed,
 nothing happens), then `shortcode_unautop`, then `do_shortcode`, which
 doesn't cause the bug.

 However, after the change, the content goes through `shortcode_unautop`,
 `do_shortcode` (shorcodes are pased here), then `do_blocks` (and
 "shortcode" blocks apply `wpautop` here).

 My suggestions:

 1. Remove applying `wpautop` for the shortcode block
 2. Correct the order of processing content for block templates

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58366#comment:44>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list