What is the best practice for controlling wpautop in shortcode plugins?
On many of our shorcodes we have been running in to the issue with the wpautop filter being run before the shortcodes filter, which messes up the shrocode output. Famously adding p tags, auto closing p tags or adding br tags.
An excellent solution was recommend by automaton in this thread. Adding
add_filter( 'the_content', 'wpautop',20 );
to the functions.php file did the trick! However, however it did mess up the formatting of some of our other plugins, which means it will most likely effect other plugins as well.
Our first ideas was to have the plugin remove the wpautop filter, then do it’s thing, then turn the wpautop filter back on. Not only did this not seem to work… it seemed like an overal bad idea to toggle on/off filters each time a shortcode was processed.
The second idea is to simply reassign the order that wpautop is ran using automation’s suggestion. We would simply place the add_filter in each one of our plugins. But… we feel there might be serious back-lash from our plugin messing with other plugins.
The final ideas was to ask the great minds of you, the WordPress community!
We can provide links to examples of the exact issue if that will help—but wpautop issues are well known and discussed. We hope to get an official a best-practice solution of how plugin developers should incorporate wpautop fixes in shortcode output.
- The topic ‘Shortcodes, Content & Controlling Wpautop’ is closed to new replies.