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.
- 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 Options -> 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 :
- WP 2.7 and above : Go to Settings -> Permalinks and click “Save Changes”.
- Older versions of WP : Go to Options -> Permalinks and click “Update Permalinks”.
Download
Version 1.3 : link-cloaking-plugin.zip (9 KB)
Requirements :
- WordPress 2.2 – 2.8.4
mod_rewrite. If “pretty permalinks” work on your blog then you probably have this already.
[I got your email, but couldn't respond to it - my email got bounced with a "No such user" error message. So I'm posting my comment here.]
Ah, I see.
However, that behaviour is *by design* – it’s supposed to show the
original URL in the address bar when you actually visit that page. The
cloaking is currently only useful to hide the destination of the link from
people browsing your site and, say, hovering their cursor over a link to
see where it leads – not for fooling those who actually click the link.
I’m currently working on an improved version of the plugin that will have
the option to display the linked page inside a frame, which would create
the effect you desire.
How exactly do you make his plugin work, when you have fancy permalinks. Please help.
Generally you just have to update your permalinks (click “Save Changes” on the permalink settings without actually changing anything).
[...] first commercial WordPress plugin later this month. The plugin will be an improved version of the Link Cloaking plugin and will include a bunch of new and exciting features, like cloaking links anywhere on the site (as [...]
Hi,
Does your plugin work with WP 2.8.4? I just upgraded and I think the plugin no longer works. My cloaked links now show 404 pages
Yes, 2.8.4 should work fine. You probably need to update your permalinks again (and check the .htaccess to make sure the cloaker code is above the WP code).
Hi,
I’ve rechecked my htaccess and nothing wrong there. Why I think it doesnt work with WP 2.8.4 is because I have 2 sites, one is WP 2.7.1 and the other I upgraded to WP 2.8.4.
The one with WP 2.7.1 is still working fine. The one with WP 2.8.4 is NOT
I also have a site on another server and this one also the plugin failed to work after I upgraded to WP 2.8.4.
When I meant fail, it means Failed to redirect….so ends up with a Page Not Found (404)
This site also runs on WP 2.8.4 as well, so I’m quite sure the plugin should be compatible with it.
Could you perhaps email me your .htaccess and site URL? Maybe that would help me find some clues. My email is whiteshadow (@) w-shadow (.) com
I realised a “bug” in your script. If the URL has an space inside the link wont be cloaked.
@Marco : Fixed. You can download the updated version via the download link in the post above.
It would be nice if you can extend your plugin with “link cloaking in comments”!
Hi. Me again.
I left a comment a few weeks ago about how the plugin was not cloaking rover.ebay.com stuff on my blog (although it seems to be working for everything else). Well, over the weekend I upgraded the plugin to 1.2.7 and now it’s working again. Not sure why it stopped, but things are ok now. Except…
Now sure if you recall, but at one point I asked why the plugin didn’t seem to function with my version of the_excerpt_reloaded (I say “my” version – it’s essentially unchanged other than I overrode the defaults in the plugin). I am forcing the plugin to display an excerpted version of the_content.
Question – it’s pulling the content as $post->post_content? Does that pull the content before your plugin has filtered it?
Any help or insight would be greatly appreciated!
The cloaker filters the post in the “the_content” hook. If the excerpt plugin deals with $post->post_content directly (without calling the aforementioned hook), the cloaker probably won’t catch the post and thus won’t cloak it.
Try modifying the excerpt plugin so that it calls
before it outputs the excerpt. Obviously you’ll need to replace “$excerpt” with whatever variable the plugin uses.
Hmmm.
Right before
return $output;
I added
$output = do_action( “the_content”, $output);
Now all I get is titles (no excerpt). Did I misunderstand?
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”?