Unautop / Sanitize content added to a post through a plugin

A couple of caveats before beginning. It tried to run that plugin but apparently I have to register with a third party site before I can use it, so that throws a wrench in testing.

Second, I am having trouble duplicating this problem. That may be because I have beaten my dev stack up too much and it is time to wipe it clean and start over (which it is), so that said…

wpautop runs on the entire post content. You can’t, by any means that I am aware, restrict it to run on only part of the content.

I have not installed and tested that plugin so I can’t confirm that your analysis of the problem is correct, but in general there are several things that you can do to avoid having wpautop mangle content:

  1. Register and enqueue the script so as to avoid shoving this into the
    post body at all.
  2. Remove all the line breaks and extra whitespace from that block of
    code. None of that is necessary and without it wpautop would have
    nothing to bite into.
  3. Insert the content very late via a priority when the callback is
    added to the_content

The only one that you may be able to effect is #3. The script adds that code by means of: add_filter('the_content', 'srslide_insert_slide_js');. You should be able to remove that with remove_filter('the_content', 'srslide_insert_slide_js'); and add it back with add_filter('the_content', 'srslide_insert_slide_js',1000); to get it to run after wpautop.