Link Cloaking Plugin for WordPress

This is a plugin for WordPress that can automatically cloak outgoing links in your posts and/or pages.

Download plugin
(Note: May not be compatible with the latest version of Eclipse Link Cloaker.)

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.
  • 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.
  • If desired, you can also add your own cloaked links manually.

Examples

Lets say you’ve got a link you want to be cloaked.

<a href="http://example.com/?affiliate=me">Cloak Me</a>

Once you install the plugin, it will automatically, without requiring any configuration, turn it into a cloaked link when it’s displayed to a visitor:

<a href="http://yoursite.com/goto/Cloak_Me/12/34">Cloak Me</a>

Here’s a live example: Cloak Me

As an alternative to the fully automatic cloaking, you can switch the plugin to “selective cloaking” and tag the links you want to cloak manually:

<a href="http://example.com/?affiliate=me">Cloak Me<!--cloak--></a>

Note: The plugin does not actually edit your posts or permanently modify your links. Instead, it switches them on-the-fly whenever someone views them on your site. When editing a post in the admin panel, you will see the original, uncloaked link.

Download

Version 1.8.4 : link-cloaking-plugin.zip (16 KB)

Requirements :

  • WordPress 2.8 – 3.3
  • mod_rewrite. If “pretty permalinks” work on your blog then you probably have this already.

(Note: May not be compatible with the latest version of Eclipse Link Cloaker.)

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 Settings -> Link Cloaking and modify the default settings to your liking.

FAQ

Why are some of my links not getting cloaked?

The most common possibilities are:

  • Links in the sidebar, header, comment area and so on can’t be cloaked by the free version of the plugin. It only works on links in page/post body. Upgrade to the premium version to cloak links anywhere on the page.
  • Links added using other plugins, theme features or custom fields are also supported only in the premium version.
  • JavaScript links, as well as Flash and context-sensitive ads are not supported by any version of this plugin.

Why are none of my links getting cloaked?

  • If using “Seletive cloaking”, make sure you have actually marked some links with the <!--cloak--> tag.
  • Double-check that the links in question aren’t added or modified by plugins, the theme, or custom fields.
  • Contact me. You might have found a bug.

The exception list doesn’t seem to work. What could be the problem?

Make sure to enter only domain names in the “Exceptions” box. For example, given a link like “http://example.com/directory/page.html”, the domain name is the “example.com” part. So to prevent the plugin from cloaking that link, add “example.com” (sans quotes) to the “Exceptions” box. Entering the full URL or “http://example.com/” will not work.

Additionally, if some of your links point to example.com and some to www.example.com, you will need to add both of those to the exceptions.

Why do some cloaked links redirect me back to my homepage?

Most likely, your post(s) contain links created or modified by other plugins, the theme, or custom fields. Either remove those links, or upgrade to the premium version.

Why do some cloaked links redirect me back to my homepage?

See the previous question.

Why do cloaked links display a “Not Found” error?

  • Make sure you’re using pretty permalinks.
  • Your .htaccess might be out of date. To update it, go to Settings -> Permalinks and click “Save Changes”.
  • Your hosting company may be blocking browser access to PHP files in the /wp-content/plugins/ directory, usually as a security measure. The free version of the plugin is not compatible with these hosts. Consider using the premium version instead.

I have a question not addressed in this FAQ. What should I do?

Either leave a comment below, or email me directly. My email address can be found on the contact page.

Related posts :

802 Responses to “Link Cloaking Plugin for WordPress”

  1. White Shadow says:

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

  2. 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.

  3. 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!

  4. 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.

  5. 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.

  6. Ash says:

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

  7. Ash says:

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

  8. White Shadow says:

    @Ash – Not at this time; not in the foreseeable future either 😛

  9. 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

  10. 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.

  11. Hugo Santos says:

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

  12. White Shadow says:

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

  13. minimaus says:

    @White Shadow

    Hi White Shadow,

    I put your plugin onto my website: http://nguyenngocminhhanh.com/

    But when clicking on cloaked link, it redirected to not_found.html.

    Could you please take a look and help me work out?

    Thanks

  14. White Shadow says:

    @minimaus – Looks like the plugin isn’t executed when you click the link. Have you updated the permalinks after setting up the plugin? If yes, check the .htaccess file and make sure the “cloaking”-related rules (they should be marked as such) come before the main WordPress rules.

    Addendum : I looked at your site more in-depth and it appears you are not using “fancy” permalinks. Might it be because mod_rewrite isn’t supported by your host? If that’s the case then this plugin will not work on your site.

  15. minimaus says:

    @White Shadow

    Many thanks. Could you please give me a recommendation of a script, plugin that overcome this host limitation.

    minimaus

  16. White Shadow says:

    @minimaus – I don’t have any specific recommendations, but you should be able to find something on Google.

  17. minimaus says:

    @White Shadow

    How the .htaccess file look like?
    Mine like this:

    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    order deny,allow
    deny from all
    allow from all

    order deny,allow
    deny from all

    # BEGIN WordPress

    # END WordPress

  18. White Shadow says:

    @minimaus – Try adding these three lines between the lines that say “Begin WordPress” and “End WordPress” :

    RewriteEngine On
    RewriteRule goto/([^/]*)/([0-9]+)/([0-9]+)/? wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?post_id=$2&link_num=$3&cloaked_url=$0 [L]
    RewriteRule goto/([^/]+)[/]? wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?name=$1&cloaked_url=$0 [L]
    

    I’m not 100% sure it’ll work, but it could make the plugin function correctly.

  19. minimaus says:

    @White Shadow

    Big big thanks to your helps, White Shadow, even it turn out that the host do not support this plug-in. Maybe i would consider to change to another hosting service.

    bigmaus

  20. Wally says:

    I’ve tried getting this plugin to work in WP 2.51 and am NOT having success. I followed the suggestions about the .htaccess file but still the links get sent to my 404 page.

    I could not find a place to “update permalinks”. In settings/permalinks the only option is to update the settings. I’ve tried clicking that to no avail.

    Mod rewrite IS available on my host.

    My blog is in a “blog” folder and I’ve tried putting the .htaccess in the root and in the folder.

    Any other suggestions would be appreciated.

    Wally

Leave a Reply