Archive for July 18th, 2007

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

Wednesday, 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: 21% [?]

Google Maps / Ditu switcher bookmarklet

Wednesday, July 18th, 2007

Ditu.google.com is the Chinese version of Google Maps, Google maps is a great product however in China, there is no detailed map, all we can play around is the satellite images. Google China released Ditu which is the answer, however due to China’s local law google is not allowed to put it together with the satellite image.

I wrote a small bookmarklet to allow you siwtch between Ditu and Google Maps automatically, locate to a position either in Google Maps or Ditu, click the bookmarlet, the page will automatically switch to the same location of the other site.

Drag this link to your Firefox address bar:

Ditu/Maps Switcher

The source code is here:

<a href="javascript:url = ''+document.getElementById('link'); if ((url.search(/http:\/\/maps.goog/i) ==-1) && (url.search(/http:\/\/ditu.goog/i)==-1)) { alert('Do not click this links, drag it too your address bar. \nThis bookmarklet only works on maps.google.com or ditu.google.com.\nCheck update on http://dev.robertmao.com/category/google-maps for latest updates or other google maps hack.'); } else { if (url.search(/ditu/i)==-1) { url=url.replace(/maps./i, 'ditu.'); } else {url=url.replace(/ditu./i, 'maps.'); if (url.search(/&t=k/i) ==-1) url += '&t=k'; } window.location=url;}">Ditu/Maps Switcher</a>

You can also copy the part “javascript:….url;}” and paste in your address input box and hit return to make a switch. However I think drag the link as a bookbarklet is a better idea.

I didn’t test under IE, so not sure if it work. Try at your own risk.

I am thinking writing a hack to overlap the image files of Ditu and Google Maps, it gonna be cooler, but this is still just an idea. One issue is, during I play arround, I found Ditu’s position is not exactly match the satellites images, maybe it’s also because google need to follow some local policy.

Popularity: 14% [?]

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