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:

    Just to clarify, the plugin is designed so that you can add the nofollow tag to the uncloaked link and it will stay there when it’s cloaked, too.

    Now, for your question – the quick & dirty solution would be to replace line 90 (the one that starts with “return”) in the file wplc_link_cloaking_plugin.php with this line :

    return ''.$matches[4].$matches[5];

    Try it out. I have a sneaking suspicion that this might cause conflicts with other link rewriting plugins (and similar), but it should work well enough in most cases.

  2. Hi White Shadow,

    I found your plugin just a couple of days ago. After trying several other plugins/solutions to cloak my links…and failing to get them to work, imagine my excitement when I turned on your plugin and it worked right out of the box.

    I LOVE it!

    One question…

    Do “hits” refer to actual clicks on those links or just page views?

    Curtis Penner

  3. White Shadow says:

    Hey, I’m glad you like it 🙂

    “Hits” refer to the number of times a link has been followed, so you could say it’s pageviews… except the “real” pageview count is probably lower, because search engines and other bots would also be counted as “hits”.

    Creating a reliable click stats report is nontrivial and I’m not aiming for that – the “Hits” figure is there to give a general idea about the link’s popularity only. You might want to find a separate plugin for accurate stats, or use Google Analytics. You can put the Analytics code on your blog with the Ultimate Google Analytics plugin (this is what I do on this blog).

  4. Dolly says:

    Having problems with the 2.3 version of word press
    it seems to be slowing down
    Also it would not write to .ht access file
    Does it have anything to do with file permissions

  5. White Shadow says:

    What do you mean “slowing down”? Anyway, it’s probably something to do with WP itself.

    If WordPress can write to .htaccess, so can the plugin, because it works from within WP. I assume you have tried updatibg permalinks, right?

  6. amy says:

    Hi.

    Great plugin. However I am getting a 404 when I use it. Do you know how to fix it?

    Thanks.

  7. White Shadow says:

    Do you mean you get a 404 when you click a cloaked link? If so, have you updated the permalinks?

  8. amy says:

    Yeah, I updated permalinks.

  9. White Shadow says:

    Well, I don’t have any other bright ideas then. Care to give me a specific example of a link that doesn’t work?

  10. Toni says:

    a couple of things

    i am noticing problems when using text link ads… specifically, the ads don’t work. I’ve tried updating the permalinks and everything, but when i click on a text link ad, it just hits an error page…

    this could pose a big problem for people using TLA

    second of all, i wish there was a way to cloak links on the blog roll….maybe not automatically, but manually in the wp-admin.. where for example, you can set ‘blogrolllink/aff?123″ to ‘mywebsite/blablabla’

  11. White Shadow says:

    I don’t know about text link ads, but for the second idea – try going to Manage – Cloaked Links, this might be what you’re looking for.

    I don’t have any TLA ads (at the moment) on this blog, so I really have no easy way to investigate this problem. Maybe, if you have “cloak all links” enabled, it might clash with TLA… try setting it to “selective cloaking” and see if it helps.

  12. Toni says:

    text link ads provides users w/a wordpress plug-in so that they can sell context text links on their blog. So for example, an advertiser might pay you…oh i don’ t know, $4/mo (for example) for the word ‘cloaking’ in your post….

    i’ve put link cloaker on selective cloaking for now

    would it be too much work to create a drop down…or some sort of menu…in the link cloaker adminstration that lists all context links on a blog with a check box to let you cloak or uncloak? this way you don’t have to go through each post and manually cloak your links on ‘selective cloaking…’

    just a thought

  13. White Shadow says:

    It’s doable, but a lot of work. I’ll keep your suggestion in mind but I can’t promise anything.

  14. i’m also getting a 404 error. I’ve updated the permalinks and htaccess accordingly.
    my wordpress version is 2.3.1
    Please help me with this a.s.a.p
    Thanks!

  15. visit my site and click on a link in a post and you’ll see.

  16. White Shadow says:

    I looked at your site. I think the the problem is in the .htaccess. Where is your .htaccess located and what does it contain?

  17. cloudstrif3 says:

    i fixed the problem, the redirect.php file had to be in another folder called plugins within the orig. plugins directory. ex. plugins/plugins/redirect.php

    one more question, after a cloaked link is clicked, is there a way to cloak the url on the address bar? is there a plugin or script that can do this?

    a close example I can give are links on phazeddl.com and how .tk domains cloak site urls.

  18. White Shadow says:

    It’s good to hear that you got it fixed, though it still is a bug – it shouldn’t require another folder.

    I don’t know any WP plugins for cloaking the link in address bar, but I’ve seen various ways to do it in general. Frames (phazeddl.com uses an IFrame), JavaScript, etc. A quick Google search returns at least one free tool.

    The easiest solution would be to modify wplc_redirector.php, remove the redirection code (the last 3 lines or so) and instead create a single frame that contains the target page. This should be easy for anyone who knows a bit of PHP/HTML, but you’re on your own here. I don’t intend to add this feature to the plugin.

  19. cloudstrif3 says:

    Can you please help on creating a frame code.
    I don’t know how to insert the html code into the redirect php file

  20. White Shadow says:

    Fine. Open wplc_redirector.php and go to the end of file. Delete all lines that start with “header….” and the line that says “exit()”. Then insert the below code after the “?>” –

    
    
      
    
    
    

    That’s a very primitive version, but it should work. Not tested.

Leave a Reply