Syntax highlighting with Chili

I recently had some trouble getting wp-chili syntax highlighting working in my WordPress blog. I used the Apache module mod_rewrite and basically had 4 domains for this blog before moving it on a proper root server. With and without the subdomain blog. in front and with .de and .com as TLD in the end.

Some developers over at the Google Code Projekt Page of wp-chili discovered that the latest patch for chili 2.2 of March 2010 changes JSON to AJAX calls. Consequently cross domain functionality in wp-chili has been broken.
Let's change that php file to make this sweet syntax highlighting plugin work cross domain. Let's take a look at the wp-chili.php file:

$wpchili_url = get_bloginfo('wpurl').'/wp-content/plugins/wp-chili';

get_bloginfo is a php function of WordPress that retrieves your blog domain if you pass the wpurl parameter. The function looks into your static Wordpress settings to retrieve this info. Even though this is dynamic enough for most purposes, it does not suit Apache or IIS rewrites. However we won't change this line, because if we did, we would break JavaScript linkage to jquery.chili-2.2.js. We better implement a dynamic domain name retrieval using PHP a few lines farther down in the file; inside the script tag.

Find this method:


And change the string assigned to the method from

echo $wpchili_url;



Don't forget to complete your path to chili before and after above variable.
Unfortunately Chili has many other problems. Make sure you did include all the script tags in the head, like linkage to recipes.js or jquery.chili-2.2.js. Usually the WordPress Codex function wp_head() takes care of this.
Finally this blog displays syntax highlighting correctly on all subdomains and TLDs. First I thought this was a browser issue. Foolish me, since most of the time it's rather a developer's issue.
Luckily there's already development of wp-chili version 3 taking place on Git Hub.