New WordPress Plugin: Escape HTML

Many of WordPress users post codes online. Code can be HTML code, JavaScript code, PHP script or any other kind of code, codes need to be escaped so that it can come correctly in web page. I used to use this tool for escaping script for online posting on WordPress blog. It does not need to do much, just checking for <, > and & sign is enough for posting any code to webpage. Now, that extra step of using the tool is over. I can directly post the code to HTML editor and save the code for public viewing.

You may also using Syntax Highlighter. Server Side highlighter do the escaping job for you. Client side highlighter do not do this job. I am using Google Syntax Highlighter for WordPress, which is a client side Syntax Highlighter.

Download the Escape HTML WordPress plugin from

More about posting codes online:
I am using these settings on my WordPress installation for avoiding any big problem. In theme's functions.php file, I have these lines:

remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wlwmanifest_link');
remove_filter('the_content', 'wptexturize');

Still, whenever I save any kind of code/scripts, I use HTML editor as this does not convert the code I have written. Visual editor tends to convert text according to some semantic. Quote conversion is a big trouble for those who posts code online. WP convert single and double quote to curly quotes to look it fancy, but this destroy the validity of code and it will not work when someone copy and paste the code to editor. So, wptexturize is disabled (remove_filter('the_content', 'wptexturize');).

Update: I saw in WP 2.8.4 version that wptexturize is not applied to 'pre', 'code', 'kbd', 'style', 'script', 'tt' tags. and it is same in newer version. So, can I use wptexturize now! Need to check.

Update (08-09-2010): Added support for 'code' and 'tt' tag. Code tag can be used for inline code whereas 'pre' can be used for block code.
Hope, you have enjoyed the plugin and post. Please share it!

    Comment pages
    1 2 2483
    Comments are open for an year period. Please, write here on Facebook page.