Treatment of shortcodes by wpautop is incomplete
|Reported by:||gcorne||Owned by:|
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.
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 (14)
comment:9 @aaroncampbell — 6 months ago
- Keywords needs-testing added; has-patch needs-unit-tests removed