Link Cloaking Plugin for WordPress
I’ve created a plugin for WordPress that can cloak outgoing links in your posts and/or pages.
Features
- Choose what to cloak – all links, only the links you specify or no links at all.
- Choose where to cloak – posts, pages or both.
- Configure the URL – you can set the “prefix” part of the URL (see examples below).
- Exception list – links pointing to domains in this list will not be cloaked. For example, this is useful if you have chosen to cloak all links but don’t want to cloak the links to your own domains.
- Compatible with all browsers – the link cloaker plugin doesn’t use JavaScript so it will work even for visitors that have disabled JS.
- “Smart” cloaking – relative, ambiguous or malformed URLs will not be cloaked. Better safe than sorry.
- As of version 1.1, static link cloaking.
New! The premium version of this plugin is now available and includes several new features :
- Cloak links in any part of your site, including the comment section and the sidebar.
- Works with plugin-created links.
- Five new cloaking types – for example, you can display the cloaked URL in a frame, or use a special redirect that hides the referrer.
- Improved link management and click statistics.
- Free automatic updates.
- And more. Check out EclipseCloaker.com for complete details.
Examples
Here’s a link explicitly tagged for cloaking -
<a href="http://evil-guide.tripod.com/"><!--cloak-->A Cloaked Link</a>
And here’s what it looks like in the post – A Cloaked Link
If you have configured the plugin to cloak all links (the default) you don’t need the <!–cloak–> tag inside your links.
Installation
- Download the link-cloaking-plugin.zip file.
- Unzip the file.
- Upload the `link-cloaking-plugin` folder to the `/wp-content/plugins/` directory.
- Activate the plugin through the ‘Plugins’ menu in WordPress.
- (Optional) Go to Settings -> Link Cloaking and modify the default settings to your liking.
- Re-save your permalink settings to insert the plugin’s link redirection code to the WordPress .htaccess file : go to Settings -> Permalinks and click “Save Changes”.
Download
Version 1.8.2 : link-cloaking-plugin.zip (10 KB)
Requirements :
- WordPress 2.8 – 3.0.1
mod_rewrite. If “pretty permalinks” work on your blog then you probably have this already.
My mistake, it should be apply_filters(“the_content”, $output). do_action is almost the same thing but it doesn’t return any output.
That did the trick. Thanks!
However… I have a new problem. I have 2 links on the same page that (should) point to the same destination. The first one looks like:
/goto/visit_the_product_s_homepage_/4561/1
That one works
The second link, which is associated with an image looks like
/goto/link/4561/2
That one does not work. It just goes back to the blog’s home page. I tried to remove the /link part but that made no difference.
Any ideas?
I’ve uploaded another update; maybe it will work now.
I downloaded the release. It still seems to work the same. Here’s some clues (I hope).
I turned off the plugin completely. All (original) links worked as expected. When I turned it back on, the same thing as reported earlier was happening. The first rewritten link was working, the second with the /link in the URL was not.
Now, here’s the weird part. That particular post had a URL in the post plus a linked image. A similar post, that only had a single linked image, worked just fine. And, that linked image also had the /link in the URL.
So, it would appear that it’s not the /link that is throwing everything off, but the /2 that is doing it.
Well, the plugin will redirect a cloaked link to the homepage when it can’t find the original URL in the post. In this case, although it found and cloaked the image link at first, for some reason it couldn’t find the link again when it was time to redirect the user to the target page.
This usually happens when one of the links in the post is created by another plugin. Does that ring any bells?
Hmmmm. I see where you’re going with this. Yes, there is a plugin that adds the first link when the post is rendered. So, in the rendered post your plugin finds 2 links, but in the original version of the post there is actually only one.
The two displayed links are actually identical, but the link cloaker apparently just counts links regardless of what it finds.
I’m not entirely sure how to handle it other than just drop the automatic insertion of the first link.
OK. So, I tested it out. You were correct. Does this mean that any modifications to templates could have the same result?
Links inserted via template manipulation wouldn’t get cloaked at all.
Stuff like this will be fixed in the “Pro” version – among other things, it will be able to cloak any link, regardless of how it was added and where it’s located – but that version will be commercial (though the price will probably be relatively modest).
Will it be handled via database in the Pro version? Or some other mechanism?
Any thoughts as to when pro might be available?
Yes, all the links the plugin encounters and needs to cloak will be stored in a database. That is, both the automatically cloaked links and cloaked links that are explicitly defined by the user will be stored in one place. The analytics will be slightly improved, there will four or five redirection mechanisms, etc.
This version should be feature-complete and usable in a week or so, but I’m not sure how long the other stuff associated with this release will take – e.g. updating documentation and maybe even coming up with something akin to a sales page.
[...] You can download the plugin and get more information here: WordPress Link Cloaking Plugin [...]
Hi, me again. Got another “mystery” for you (or, maybe it won’t be for you
.
I have some feeds that are posting to my blog. One of the links won’t cloak. You can view the format of it in the website link I posted.
Anyway, it is formatted as
http://www.avantlink.com…………..&url=http://www.fetchdog.com……..
Since it is the only type of link I have that has two domains inside the url, I’m wondering if that is throwing the cloaking off?
The URL shouldn’t matter, unless it’s invalid. I tested the cloaker with URLs that contain two domains and it worked fine for me. Can you show me the full URL, or, better yet, the entire <a href=….>…</a> tag?
It looks like this
http://www.avantlink.com/click.php?tt=pl&ti=81&pw=19885&mi=10081&pt=3&pri=20319&url=http%3A%2F%2Fwww.fetchdog.com%2Fpet-supplies%2Fdogharnesses%2Falldogharnesses%2Fskull-bones-harness-narrow%2FA10009N
It still cloaks correctly in my tests. Maybe it’s not the URL itself but rather something in the tag that’s causing this? Is the URL properly quoted? Are there any additional parameters in the tag, like rel=”nofollow” or target=”_blank”?
Hmmm. I copied and pasted it as it shows up. When I view the source, there are no other tags associated with the href. I dunno – I’ll put some echo’s in and see where it’s dropping out. Maybe there’s another filter that’s doing something before it gets to the link cloaker.
Your plugin works fine on my site. everything except the affiliate link I have placed on the sidebar – on the home page. I think it may be because there is a configuration page for the theme that I am using which allows be to place the image location and re-direct link. I have set to cloak all pages by default. I tried adding at the end. did not work. any help? thanks.
The plugin doesn’t currently cloak links outside of post content (e.g. sidebars, comments, page header of footer). But due to popular demand, this feature will be added in the next version.
I am having the same problem with 2.8.4.
I have checked the .htaccess and the code is above the wordpress code.
I am getting 404′s aswell – does it conflict with phplinkdirectory?
I’m not aware of any conflicts with that plugin. Have you tried deactivating phplinkdirectory temporarily and seeing if you still get 404 on cloaked links?
[...] Link Cloaking Plugin for WordPress [...]
Hi,
I use the plugin about a year but never had cloak a link from ebay.
After having made it the plugin crashed and will not let me delete the link with the cloak i had before.
I uninstalled the plugin and reinstall again and everything was equal. I can no longer use the plugin at this site.
Someone can help me.
Regards
Unfortunately this version of the plugin doesn’t delete the saved cloaked links when you uninstall it. You need to manually remove the link from the wp_cloaked_links table in your database (this can be done with something like phpMyAdmin).
If you could post the eBay link here, I might be able to find out why it crashes the plugin, and fix the bug.
I just have to thank you for writing such a great and simple to use application. More people should know about this. I have spent hours and hours trying all sorts of cloaking plugins, you name it I downloaded it and isntalled it.
Basically every single plugin for wordpress I have tried and yours is the best.
The only flaw was that it didn’t open links in a new window, but that simple code that White Shadow posted does the trick, and it wasn’t scary at all to do. Phew.
Thanks again, great job.
OneMoreGadget
Now if I could only find a plugin that automatically fixes typos…ahem.
hello,
What can i do by custom_fields?
When i mouse over the link it is cloaked, but I get a 404. I deactivated all plug ins and still get 404. Any ideas?
Do you have a caching plugin installed? It might be serving the old cached version of the page.
Try going to the target (uncloaked) URL directly; maybe it’s simply down?
Sidebar links would be nice
Other than that, a nice handy plug-in.