Link Cloaking Plugin for WordPress

I’ve created a plugin for WordPress that can cloak outgoing links in your posts and/or pages (note : if you’d rather have a more general link cloaking tool, take a look at Link Manager).

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.
  • Update : version 1.1 available - now with static link cloaking!

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

  1. Download the link-cloaking-plugin.zip file.
  2. Unzip the file.
  3. Upload the `link-cloaking-plugin` folder to the `/wp-content/plugins/` directory.
  4. Activate the plugin through the ‘Plugins’ menu in WordPress.
  5. (Optional) Go to Options -> Link Cloaking and modify the default settings to your liking.
  6. Go to Options -> Permalinks and click “Update Permalinks”. This ensures the plugin’s link redirection code is added to WordPress .htaccess file.

Download
Version 1.2.2 : link-cloaking-plugin.zip (9 KB)
Tested on WP 2.2 - 2.3.1 (more or less).

Related posts:

156 Responses to “Link Cloaking Plugin for WordPress”

Pages: [6] 5 4 3 2 1 » Show All

  1. 156
    White Shadow Says:

    @Hugo Santos - There are already other plugins that can do that :P However, most of them would have compatibility problems with this plugin, unless you use them to insert “statically cloaked” links.

  2. 155
    Hugo Santos Says:

    and what about an option to automatic link insertion to a given keyword instead? :)

  3. 154
    White Shadow Says:

    @Ash - It’s doable, but would take a lot of thinking/hacking. I’m not up for it at the time, sorry.

    If you want to give it a try yourself, you could use the $url_pattern regexp to extract the URL from the banner and then modify the previous hack to handle these additional URLs.

  4. 153
    Ash Says:

    Thanks White Shadow, i’ll try and find another way around the comment links.

    I’m having difficulty cloaking banner ads i’m running from custom fields, your previous ‘hack’ for custom fields worked a treat where i had a plain url to cloak but can this be modified where the url is included within banner code in the custom field?

    Here is an example of the code (links removed) that i include in a custom field called banner468

  5. 152
    White Shadow Says:

    @Ash - Not at this time; not in the foreseeable future either :P

  6. 151
    Ash Says:

    Found the solution to cloaking custom fields in the comments, thanks. Could’nt find anything regarding cloaking links within comments.

  7. 150
    Ash Says:

    Is is possible that this plugin can cloak urls in comments and custom fields (of posts)?

  8. 149
    Jeff Says:

    Yeah, the links from ALINKS were getting cloaked correctly… However, all the links were off by 1. Meaning…. If I had three links in the page… the first link would direct to the second, the second would direct to the third and the third would direct to the associated tag.

  9. 148
    White Shadow Says:

    @Jeff - It might be possible to make both plugins work together, but the links created by ALINK wouldn’t get cloaked anyway.

  10. 147
    Jeff Says:

    I just installed the plugin on a couple of my blogs. The first blog the plugin worked great. The second one I had some problems with it. It was interferring with my other plugin “ALINKS” … a plugin to create links to certain keywords. I couldn’t figure out a way to fix the plugin for this page so I just deactivated it because I need the alinks plugin more… If you have a fix for this I’d love to hear about it!

    Otherwise great plugin!

  11. 146
    Authcode Says:

    @White Shadow - Managed to fix it by updating cloaking settings several times (strangely, didn’t work the first couple of times). I think the Wordpress Automatic Upgrade plugin screwed my plugin settings when it tried to restart them all unsuccessfully after the upgrade. I’ll remember to check my links next time! Cheers.

  12. 145
    White Shadow Says:

    @Authcode - I had some problems with this, but I think updating permalinks fixed it.

  13. 144
    Authcode Says:

    I’m running version 1.2.2 of this plugin which seems to have stopped working after I upgraded Wordpress to version 2.6. Is anyone else getting this? All my cloaked links goto my blog’s 404 page - I’ve had to deactivate for now.

  14. 143
    Anybody a 301 redirect expert - Affiliate Marketing Says:

    [...] expert Hi I am currently experimenting with the ‘link cloaking plugin’ available here: Link Cloaking Plugin for WordPress | W-Shadow.com It automatically cloaks all links barr your own domain by default. Thats from memory but pretty [...]

  15. 142
    White Shadow Says:

    @affboy - yay, shameless self promotion.

  16. 141
    affboy Says:

    Here is a easy tool can cloak, even encrypt links.
    FYR
    http://Hide-Affiliate-Links.com/

  17. 140
    White Shadow Says:

    That SQL query is executed only on the static link management page, so it can’t be running at activation.

    I don’t know what, exactly, causes the crash on activation, but apparently the required table wp_cloaked_links doesn’t get created. You could try creating it manually :

    CREATE TABLE wp_cloaked_links (
    	id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    	name VARCHAR( 150 ) NOT NULL ,
    	url TEXT NOT NULL ,
    	hits INT UNSIGNED NOT NULL,
    	UNIQUE KEY name (name),
    	PRIMARY KEY id (id)
    );
  18. 139
    gulflee Says:

    the problem occur here
    WordPress database error: [Table 'localhost_name.wp_cloaked_links' doesn't exist]
    SELECT * FROM wp_cloaked_links ORDER BY name ASC
    any ideal ? tq

  19. 138
    gulflee Says:

    The Plugin shows “could not be activated because it triggered a fatal error.”" in wordpress 2.3.1 ? is there any things have to be fix?

  20. 137
    bloggylicious Says:

    Thank You!!

  21. 136
    Authcode Says:

    @White Shadow - Not really! :) But I’ll see what I can do (or break). Thanks again for a great plugin.

  22. 135
    White Shadow Says:

    @Authcode - Yes, it probably can. I think you would only need to apply the plugin’s the_content filter to the_content_rss and/or the_excerpt_rss, too.

    I don’t know if that makes any sense to you ;)

  23. 134
    Authcode Says:

    This is a great plugin - thanks - but is there any way it can be modified to also mask links in the RSS feed? Can WP plugins even run on the RSS feed?

  24. 133
    Sebastian Says:

    perfect plugin, working with every wordpress version since 2.5.1 for me.

  25. 132
    3 Ways to Cloak Affiliate Links — TeenBlogger.net Says:

    [...] out this post for more [...]

  26. 131
    Barbara Ling | How to easily cloak your Clickbank and other affiliate links for free Says:

    [...] A Cloaked Link [...]

  27. 130
    Bert Says:

    I sent you an email with the details of the issue. Once we figure out what happen we can post the answer here for the benefit of all endusers. Thanks again!

  28. 129
    White Shadow Says:

    Hey Bert, thanks for the donation :)

    As far as I know, FF shows this error when a script redirects to itself several times, like in a loop. That should never happen with this plugin, but there’s always a possibility of a stealthy bug. Can you give me an example link that has this problem (so that I can investigate)?

  29. 128
    Bert Says:

    Want to say thanks again for the plugin, but nothing says thanks better than a donation. :)

  30. 127
    Bert Says:

    Hello,

    The start out working great then the redirects started to fail. Here is the error in Firefox.

    The page isn’t redirecting properly
    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
    * This problem can sometimes be caused by disabling or refusing to accept
    cookies.

    Any ideas of what it could be? Thank you for the your time,
    Bert

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    * This problem can sometimes be caused by disabling or refusing to accept
    cookies.

Pages: [6] 5 4 3 2 1 » Show All

Leave a Reply