WordPress.org

Ready to get started?Download WordPress

Forums

Shortcodes, Content & Controlling Wpautop (2 posts)

  1. Baden
    Member
    Posted 2 years ago #

    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.

  2. dsent1976
    Member
    Posted 2 years ago #

    I wish I had the answer, I'm pretty much a coding novice, but I found this trying to find the solution.

    I couldn't for the life of me figure out why in my last column (of three columns) my first line of text was being pushed down. I do code well enough to use the html editor and I couldn't see anything that would cause the problem.

    Inspecting the page with Firebug I saw that in that column it had a br tag and a serious "wtf" moment occurred.

    My "fix" was to install the plugin called "PS Disable Auto Formatting" .. that screwed up my previous pages, but running the included Batch function seems to have worked getting my old pages looking the way they're supposed to - on the viewer's side, anyway. I was able to then go into the affected page and get rid of all the unnecessary code and get looking right.

    With that said, I have the feeling I just placed a big band aid on the problem. Perhaps a time bomb, even.

    I'm still searching for a real fix. Wouldn't it just be nice of wordpress to give us the option of turning it off and on for the pages that need it? Flip a switch, clean up code, problem solved?

    I'm sure it's much more complicated than all of that, but I'm subscribing to this in the hopes to get some new info.

Topic Closed

This topic has been closed to new replies.

About this Topic