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.
[...] Link Cloaking Plugin [...]
Hi White Shadow,
First off, thanks for a fantastic plugin… Ran into a little issue that was addressed a while back.
I am using custom fields to insert links into the template and the plugin does not seem able to cloak it. There was a fix you recommended, but it seems the code has changed since then. I was wondering if you had an up to date fix or if the premium version caters to this.
The premium version should be able to cloak links from custom fields, yes.
I can’t seem to recall the fix you mentioned, can you point me to the specific comment?
It is comment number 50 in your comment list.
I see. It should be pretty easy to tweak the code in that comment to work with the latest version of the plugin.
To wit, everything said in the “rewriting the link” section of that comment still applies. The redirector code itself (wplc_redirector.php) has changed, but very little. You just need to replace lines 19-25 in that file with something like this :
Hi White Shadow,
Thanks for taking the time out to help. It now masks the url, but the URL is broken… it just leads to a white page, no redirection.
Any Ideas?
Hmm, what’s your site URL? Maybe I should take a look.
I’m using a blank html page to hide my plugins, and both of those php files were in the plugin folder. I delted the pluging and re-installed it, and I’m still getting the same issues
{Are you using a plugin, or some .htaccess trick, to prevent visitors from accessing .php files in the /wp-content/plugins/ directory?
From the error messages, it looks as if both wplc_redirector.php and wplc_link_cloaking_plugin.php are missing from the “link-cloaking-plugin” folder, but if that was true then the plugin wouldn’t work at all.}
Is there a way to diagnose this issue over email instead of by this comment section?
You can email me at whiteshadow {at} w-shadow {dot} com.
I emailed you and have not received an email back yet
Weird, my response must’ve been caught by your spam filter or otherwise gotten lost. I’ll post it here then :
Hey Tim,
Here’s what I’ve found. The .php files are indeed where they should be, and are visible when accessing the directory URL like this :
http://edited/wp-content/plugins/link-cloaking-plugin/
However, if you try to click on one of the .php files, e.g.
http://edited/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php
…you’ll get a 404. This doesn’t happen for other files in that directory – for example, clicking on “tick.png” will display the green “tick” icon (as expected). This is a very strong indication that something in your server configuration or your .htaccess file(s) is preventing visitors from accessing .php files within the /wp-content/plugins/ directory.
Perhaps you should ask your hosting provider about this?
Cheers,
Janis Elsts / White Shadow
Heres what my htaccess looks like
# BEGIN WordPress
# Link Cloaker Plugin BEGIN
RewriteEngine On
RewriteRule ^goto/([^/]*)/([0-9]+)/([0-9]+)/?$ http://www.therealtimscott.com/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?post_id=$2&link_num=$3&cloaked_url=$0 [L]
RewriteRule ^goto/([^/]+)[/]?$ http://www.therealtimscott.com/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?name=$1&cloaked_url=$0 [L]
# Link Cloaker Plugin ENDS
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Also i’m hosting another site on the same account and the link cloaking plugin is working just fine
That .htaccess looks fine. However, check /wp-content/ and /wp-content/plugins/ for extra .htaccess files.
Other than that, I’m fresh out of ideas. Get the premium version, perhaps?
It doesn’t use .htaccess redirects and doesn’t need the plugin folder to be web-accessible.
Hi thanks for such a great plugin!
However, I have a question about the type of link created…
Does the plugin produce 301 or 302 redirects?
It does a 301 redirect.
Oops! Thought as much.
I was using the plugin to cloak ebay links. However they recently announced they are not allowing 301 redirects and must change to 302.
Can I do this within the plugin or would this total defeat the purpose of the plugin?
Thanks.
Assuming you’re not averse to manual editing, you can change the redirect type pretty easily. Just open up wplc_redirector.php in any text editor and change line 42 from this :
to this :
Got it, that’s perfect, thanks!
Hi
Do you know why im getting this error message when i try to use the link cloaking plugin : http://www.pandadragon.co.uk/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?post_id=4579&link_num=2&cloaked_url=View/link/4579/2
I have had to disable the plugin for now as it makes my site inaccessiable.
It appears that something on your site is blocking direct access to .php files in the /wp-content/ directory. For example, this works :
http://www.pandadragon.co.uk/wp-content/plugins/link-cloaking-plugin/readme.txt
… but this doesn’t :
http://www.pandadragon.co.uk/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php
Unless this block is disabled, the free version of the cloaker will not work on your blog. You could try the premium version though – it has a more sophisticated cloaking mechanism that won’t be affected by this problem.
Hi Thanks for your reply.
Do you have any ideas what could be blocking it? i checked my robots.txt and nothing there?
Thanks
Phil
It’s more likely to be something in the .htaccess or the server config. itself.
HIya
i used to have it working so i know its most prob not a server issue, also it works on four of my new domains :-S, i looked at htaccess one part did have a old sub directory in it so changed it but still nothing, perhaps if anyone else reading this has any ideas, i would be extremely grateful.
Thanks
Phil: you could try disabling your plugins one by one just to see if there is some conflict – maybe a recent plugin update might have triggered the issue
Hi Dermot
I could do but my plugins mirror on all sites and i have link cloaking plugin successfully running on 4 of my 10 sites so i 95% sure its not a plugin conflict.
Thanks for the suggestion though
I got a malfunction today, although this has never happened before:
I usually use to cloak the link, it works fine for me. Until my latest blog post (it today), doesn’t work. The cloaked link just go to my blog home page.
Anyone can help me?! Thanks b4.
@ Phil : I still think it’s something in the server conf. that’s causing the problem.
@ tantan : I’ve looked at the post you mention and I can’t find anything that would cause the plugin to not cloak the link. I’m guessing WP filters out or normalizes whatever is wrong with the link (if there is something wrong with it), so could you check it in the post editor and send me the HTML code corresponding to that link?
TanTan i’m having the same problem, it was working fine this morning and I haven’t changed anything. Now none of my cloaked links work, they just redirect to my ownsite/error page.