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% [?]



17 Comments to “Get rid of boring WPMU’s post html/javascript filtering…”

  1. ray | October 1st, 2007 at 6:37 pm

    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.

  2. WebGuru | October 7th, 2007 at 5:52 pm

    How to enable or use Javascript and Flash embed in WordPress MU

  3. 2-Blog » WPMU killt html-Code | October 28th, 2007 at 6:12 am

    […] 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. […]

  4. Ales | November 12th, 2007 at 4:49 pm

    Geessh… Thanks for letting me know what to comment out! Quite useful.

  5. Simply-Basic.com » Stop Wordpress MU From Blocking Your Code | December 17th, 2007 at 11:49 pm

    […] 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 […]

  6. John Kolbert | December 17th, 2007 at 11:50 pm

    Thanks for the tip. I’m sure some of my readers will find this useful!

  7. How to Remove Crazy WordPress MU HTML Filter | Binh dot Name | December 21st, 2007 at 4:27 pm

    […] 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 […]

  8. Joe | December 27th, 2007 at 10:01 am

    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

  9. Joe | December 27th, 2007 at 10:04 am

    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.

  10. Joe | December 27th, 2007 at 10:10 am

    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

  11. Joe | December 27th, 2007 at 10:42 am

    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.

  12. 去掉讨厌的WP HTML过滤 at 北冥之鱼 | January 3rd, 2008 at 9:47 pm

    […] Get rid of boring WPMU’s post html/javascript filtering… […]

  13. Robert | January 9th, 2008 at 7:24 pm

    Joe, your solution is better. Thanks!

  14. get rid of html/javascript filter on the post » Live Free Or Die | January 10th, 2008 at 9:56 am

    […] Credits to http://dev.robertmao.com/2007/07/18/get-rid-of-boring-wpmus-post-htmljavascript-filtering/ […]

  15. Jim W | February 2nd, 2008 at 3:58 pm

    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.

  16. Binh Nguyen | March 4th, 2008 at 6:23 am

    So… so long already, did anyone make a plugin for this purpose? If not, I’m gonna do it.

  17. Vixthant | March 31st, 2008 at 4:05 pm

    Hi
    Wasjust serfing on net and found this site…want to say thanks. Great site and content!

Leave a Comment

Close
E-mail It
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.