Browse > Home /

| Subcribe via RSS

Hacking Kses

April 11th, 2008 | 4 Comments | Posted in Tutorials, development

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

As I spent a great deal of time (and hunting on the Internets) on this I thought I would share the result of my efforts and hopefully save your sanity and hairline.

kses is an HTML/XHTML filter written in PHP. It removes all unwanted HTML elements and attributes, and it also does several checks on attribute values. kses can be used to avoid Cross-Site Scripting (XSS).

It is built into WordPress and WordPress MU and acts on all the content you enter into your posts and pages and strips out all the nasties that WordPress doesn’t think you should be using. 99% of the time you won’t even notice that it is there, but everynow and then you will try to include something in your post and it just won’t save. In a round-a-bout way, this is the situation I found myself in earlier this week.

Try as I might, I just couldn’t get WordPress MU to accept style attributes (this is also the case for normal WordPress). Everytime I saved a post the style would be stripped out completely (MU also removes class and id attributes as well). Most annoying and after pulling out what little hair I had left I turned to the Oracle of all knowledge.

More »

Tags: , , , , ,