[wp-hackers] Howto exclude capital words (within URL address) from being searched and replaced?

Dougal Campbell dougal at gunters.org
Thu Jan 22 18:14:23 GMT 2009


Chetan Kunte wrote:
> [...]
>
> This code works well--with an exception and an unintended consequence.
> For example, if a URL has a Capital words in them like for example
> below,
>
> http://somesite.com/2007/04/i-worship-GANDHI/
>
> then this plugin does, yes you guessed it:
>
> http://somesite.com/2007/04/i-worship-<abbr>GANDHI</abbr>/
>
> And thus potentially breaking the link.
>
> Could anyone suggest how I could escape the words inside <a> tag please?
>   

You could check out my Text Filter Suite plugin:

  http://wordpress.org/extend/plugins/text-filter-suite/

In particular, check out the filter_cdata_content() function in 
tfs-core.php. This function uses preg_replace_callback() and a tricky 
regex to only perform replacements to text that is not part of an HTML tag.

-- 
Dougal Campbell <dougal at gunters.org>
http://dougal.gunters.org/
http://twitter.com/dougal


More information about the wp-hackers mailing list