Get rid of boring WPMU’s post html/javascript filtering…
Wordpress July 18th, 2007
Today I spend about 10 minutes to wrote a small javascript code and wish to release it in my blog, then I spend almost 2 hours to find out how to get rid of boring WPMU(Wordpress Multi Users)’s post html tags filtering.
I searched across the Internet, lots of people are asking how, very few information are helpful. The official “how to use Javascript” is actually missleading. It suggest to install “text-control plugin”, turn off rich editor are totally useless in WPMU.
Finally I got a simple solution by hack some code:
edit wp-include/kses.php, found “Post filtering”, and simply comment out a line:
// Post filtering
//add_filter(’content_save_pre’, ‘wp_filter_post_kses’);
UPDATED (Jan 10, 2008)
Joe in his comment point out the better solution, thanks Joe!
At around line 742 of kses.php, do the following commenting out:
function kses_init_filters() {
// Normal filtering.
add_filter(’pre_comment_content’, ‘wp_filter_kses’);
add_filter(’title_save_pre’, ‘wp_filter_kses’);// Post filtering
// add_filter(’content_save_pre’, ‘wp_filter_post_kses’);
// add_filter(’excerpt_save_pre’, ‘wp_filter_post_kses’);
// add_filter(’content_filtered_save_pre’, ‘wp_filter_post_kses’);
}This allows you to only stop filtering of the POST, but the comments still get filtered.
Popularity: 20% [?]
About
dude, i tried to include a simple tables into a post. it would not even allow me to assign classes, it just just filtered out everything. those two hours were well spent, you just saved me from eternal wpmu-boredom.
How to enable or use Javascript and Flash embed in WordPress MU
[…] Wenn man lediglich eigene Blogs damit verwaltet wird man auf das Problem stoßen, dass WPMU nahezu jeden Javascript oder html Code aus den Beiträgen löscht. Die Lösung ist simpel, aber ich habe sie nirgends dokumentiert gefunden. Nach längerer Suche wurde ich doch noch fündig. […]
Geessh… Thanks for letting me know what to comment out! Quite useful.
[…] truth, I had know idea, but I agreed to check it out with him. He was quicker then I and found an easy way to fix it […]
Thanks for the tip. I’m sure some of my readers will find this useful!
[…] I found a a quick and easy solution to solve the issue. The credit goes to Robert Mao, who wrote Get rid of boring WPMU’s post html/javascript filtering…, which pointed directly at the problem and give the solution. I follow what Robert said and found […]
This is just a guess, but won’t that leave your comments open to insertion of javascript?
Im going to test below to see if that is the case:
Your Market Research Here
It seems like it block some of the text, but as you can see in the post above, I was able to get some Jscript through.
May want to block that in your Options page.
Can you email me back, if you find a different work-around for handling HTML, jscript in the post, but at the same time avoiding the ability for people to post such in your comments?
Thanks
Hey man,
Sorry for writing so often.
I found a solution.
At around line 742 of kses.php, do the following commenting out:
function kses_init_filters() {
// Normal filtering.
add_filter(’pre_comment_content’, ‘wp_filter_kses’);
add_filter(’title_save_pre’, ‘wp_filter_kses’);
// Post filtering
// add_filter(’content_save_pre’, ‘wp_filter_post_kses’);
// add_filter(’excerpt_save_pre’, ‘wp_filter_post_kses’);
// add_filter(’content_filtered_save_pre’, ‘wp_filter_post_kses’);
}
This allows you to only stop filtering of the POST, but the comments still get filtered.
I hope this help you.
And make sure you make changes quick, because your vulnerable to jscript insertion in your comments.
[…] Get rid of boring WPMU’s post html/javascript filtering… […]
Joe, your solution is better. Thanks!
[…] Credits to http://dev.robertmao.com/2007/07/18/get-rid-of-boring-wpmus-post-htmljavascript-filtering/ […]
WP internally uses the KSES PHP script (developed outside WP) to sanitize user input (to strip certain HTML tags, remove XSS, etc.). However, KSES has many bugs and lacks many features, and though it has ‘evolved’ into the much better htmLawed, WP doesn’t use the new code. But htmLawed seems to be easily integrable in WP, and some WP-admins may want to give it a try for its extended features.
So… so long already, did anyone make a plugin for this purpose? If not, I’m gonna do it.
Hi
Wasjust serfing on net and found this site…want to say thanks. Great site and content!