- Developer
- Marios Alexandrou
This plugin allows you to dynamically (i.e. at the time when a page is generated) replace code and text from themes and other plugins with code and text of your choosing before a page is delivered to a user's browser.
Because the find and replace happens in real-time no changes are needed to plugins or themes which means upgrades remain easy!
Here are some examples:
- Are plugins inserting redundant JavaScript files such as multiple versions of jQuery? Get rid of all but one!
- Want to change the URLs of JS or CSS files, including those inserted by plugins, to load from a CDN instead of locally? No problem!
- Want to tweak how Woocommerce product pages display headings without modifying the template? It's easy.
- Don't like the “Category:” text that the Dagon Design Sitemap plugin puts in front of every category? Remove it!
- Annoyed by the link that Global Translator adds to every page? Remove it!
- Have you noticed that the Sociable plugin doesn't correctly display the Twitter image? No problem, insert it!
- Don't like the link that the Photodropper plugin inserts with every image? It's out of there!
Real-World Examples
First of all, the interface (shown below) is pretty straightforward. On the left is where you specify what to search for. On the right is what, if anything, you want to replace it with. And in the middle you can indicate whether you're specifying a standard rule or a regular expression i.e. with pattern matching.1. Have you ever noticed that Google is picking up multiple versions of your pages with different replytocom parameters? This can result in a lot of duplicate content. There are have been a bunch of suggestions on how to fix this including redirects, disallow entries in your robots.txt file, and dynamic parameter settings in Google Webmaster Tools. With the Real-Time Find and Replace plugin you can keep Google from finding these URLs entirely while still keeping the commenting functionality. Just add this rule:
?replytocom= replaced with #replytocom=
Pretty sweet, right? Now the duplicate URLs don't even exist so you don't have to block them and you won't lose link equity.
Note: This solution works perfectly on this site with this theme. I haven't tested it exhaustively with other themes so be sure to test our your comment form after implementing.
2. Sometimes I close comments on a page or post. I don't like having the text that reads “Comments are closed”. I figure such a message is redundant since you can't enter a comment. To remove this I use this regex rule:
/<p class=\"nocomments\">(\s)*Comments are closed.(\s)*<\/p>/
Note: With regex rules you to need to start and end with a forward slash.
3. I use the Author Bio Widget, but it spits out a tag I don't use. I could modify the plugin to remove it, but that would mean that when I upgrade the plugin I'll lose the code update I made. So instead I use this rule:
<span class="bio-title"></span>
4. I want Gravatar support on this site in some areas, but I hate having the same unknown icon displayed for commenters that don't have a Gravatar image and in my case that's most of them. To keep Gravatar support on while also eliminating the image I use this regex rule:
/<img(.*)?gravatar\.com\/avatar(.*)?>/
As an added bonus, removing all of these Gravatar calls reduces page load time.
5. I use the Digg Digg plugin for displaying social media buttons. This plugin injects an unnecessary call to a big JavaScript file that just slows down the page. I remove it from the HTML code using this regex rule:
/<script(.*)?sharethis\.com\/button\/buttons\.js(.*)?<\/script>/
6. The Photodropper Plugin outputs a link to an external site for every image it adds to a post. I think this is excessive so I remove the link with this rule:
<a href="http://www.photodropper.com/photos/">photo</a>
which is replaced with just "photo"Note this technique of removing links from plugins works everywhere. I've used it for a bunch of plugins.
7. The Digg Digg plugin (mentioned above) calls a JavaScript file well above the closing body tag of the page. To help with fixing a problem related to Facebook generating pages by appending a parameter (see this discussion on the fb_xd_fragment problem) to my URLs I need to remove this JavaScript call so I can manually add it to footer.php in the right place. I remove this code with this replace rule:
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>