WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

thank you

share|improve this question
up vote 1 down vote accepted

Not tested, but I imagine

add_filter('the_content', 'wp_kses_post');

will scrub it good. Might need playing with priority.

share|improve this answer
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? – mathiregister Apr 1 '11 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 '11 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 '11 at 23:50
@t31os I think that would be pretty good answer on its own? – Rarst Apr 1 '11 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 '11 at 0:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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