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. Sebastian says:

    It would be nice if you can extend your plugin with “link cloaking in comments”!

  2. Walt says:

    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!

  3. White Shadow says:

    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

    $excerpt = do_action( "the_content", $excerpt );

    before it outputs the excerpt. Obviously you’ll need to replace “$excerpt” with whatever variable the plugin uses.

  4. Walt says:

    Hmmm.

    Right before

    return $output;

    I added

    $output = do_action( “the_content”, $output);

    Now all I get is titles (no excerpt). Did I misunderstand?

  5. White Shadow says:

    My mistake, it should be apply_filters(“the_content”, $output). do_action is almost the same thing but it doesn’t return any output.

  6. Walt says:

    That did the trick. Thanks!

  7. Walt says:

    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?

  8. White Shadow says:

    I’ve uploaded another update; maybe it will work now.

  9. Walt says:

    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.

  10. White Shadow says:

    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?

  11. Walt says:

    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.

  12. Walt says:

    OK. So, I tested it out. You were correct. Does this mean that any modifications to templates could have the same result?

  13. White Shadow says:

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

  14. Walt says:

    Will it be handled via database in the Pro version? Or some other mechanism?

    Any thoughts as to when pro might be available?

  15. White Shadow says:

    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.

  16. Walt says:

    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?

  17. White Shadow says:

    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?

  18. White Shadow says:

    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”?

  19. Walt says:

    Hmmm. I copied and pasted it as it shows up. When I view the source, there are no other tags associated with the href. I dunno – I’ll put some echo’s in and see where it’s dropping out. Maybe there’s another filter that’s doing something before it gets to the link cloaker.

Leave a Reply