Make WordPress Core

Opened 4 years ago

Last modified 5 months ago

#12061 new defect (bug)

Treatment of shortcodes by wpautop is incomplete

Reported by: gcorne Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Shortcodes Keywords: needs-patch wpautop
Focuses: Cc:


There are a number of issues that arise when shortcodes are embedded in a block of content that is filtered by wpautop. After studying the issue, I have come to the conclusion that the underlying issue is that a shortcode can result in a block-level HTML element or an inline snippet of HTML. Neither wpautop nor shortcode_unautop have the information necessary to know what the intended to be block-level or text-level, which results in <br /> tags to appear in places where they were not intended and causes invalid markup when paragraphs are not closed properly.

1) shorcodes when registered need to state the display type of the html that they return (inline or block). In addition, the javascript version of filters need to be provided with the same data.

2) An alternate mechanism for handling shortcodes prior to wpautop needs to be implemented. To maintain a separation between wpautop and shortcodes, temporarily replacing block-level shortcodes with unique tokens, running wpautop, running wpautop on the content of the shortcode (since this is a separate filter, plugins can disable it on a per shortcode basis), and then replacing the token with shortcodes post-wpautop.

As WP and plugin authors use shortcodes more and more, I think this is an issue that should not be left to the wayside. Shortcodes especially tied to tinymce buttons make working with WordPress easier for the average content producer.

Change History (5)

comment:1 scribu4 years ago

  • Keywords needs-patch added
  • Milestone changed from Unassigned to 3.0

I agree with both suggestions.

The problem now is coming up with a working patch.

comment:2 gcorne4 years ago

  • Cc gcorne@… added

comment:3 dd324 years ago

  • Keywords wpautop added
  • Milestone changed from 3.0 to Future Release

Moving to Future release pending a patch or traction.

comment:5 lkraav5 months ago

  • Cc leho@… added
Note: See TracTickets for help on using tickets.