hey guys, any idea how I could filter all inline javascripts from the content()?

thank you

1 Answer 1


Not tested, but I imagine

add_filter('the_content', 'wp_kses_post');

will scrub it good. Might need playing with priority.

  • thank you, I'll give it a try. A lot of plugins are creating script tags at the bottom of my <bod> tag. Any idea how to prevent that plugins do that? Apr 1, 2011 at 16:07
  • @mathiregister likely they are either echoing them or queuing them for footer. Hard to say without looking at specific code. Please ask that as separate question with details like specific plugins you use.
    – Rarst
    Apr 1, 2011 at 16:16
  • @mathiregister - You could print out a list of the filters on the_content, and remove them in groups or one at a time, to see which ones(if any) get rid of the scripts you're having an issue with. I could add an example to Rarst's answer (if that's ok with Rarst?) of printing out the functions attached to that hook.
    – t31os
    Apr 1, 2011 at 23:50
  • @t31os I think that would be pretty good answer on its own?
    – Rarst
    Apr 1, 2011 at 23:52
  • Sure it could be, but you've already addressed the original question, this is more an additional to the solution, which is why i thought it might be appropriate to add it to the existing answer. I don't mind really, i'll add an answer if you prefer... :)
    – t31os
    Apr 2, 2011 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.