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:

    I think there might be a way to do it with Google Analytics. The “/goto/” (or whatever prefix you have) should look like a normal directory to GA and thus the details should be available in GA -> Content -> Content Drilldown. Unfortunately I can’t test this myself, as I have very few cloaked links on this site.

    If it doesn’t work right away you can probably force GA to track those clicks using something similar to the code that this plugin uses to track outgoing links.

  2. Paul Palmer says:

    Does anyone get an Internal Server Error when the plugin is activated? Mine does and I don’t know whats wrong.

  3. tomron says:

    thanks a lot for your fast response.
    Unfortunately /goto/ doesnt show in content drilldown…i tired to find it there before and no no 🙁 ga doesnt track /goto/ at least for me…its something to do with “outbound” links (although your links are outbound as they are cloked they seem to be inbound)
    so tehre is a solution for outbound clicks and you kind fo mention it…you need to tag all your links with onclick parameter.The problme is that i have quite a lot of cloaked links all over the place, and tagging them manually seems like a waste of time. i havent tried oratranslplant plugin yet, i was trying to do the same with yoast – ga for wordpress plugin that is supposed to tag all outbound links automaticlly but it seems it doesnt like links your plugin create…so i dont know really…i thought you may have some solution you are using yourself or other people figured out how to do that. ill try plugin you mentioned and see what happens.thanks anyway!

  4. White Shadow says:

    You might also be able to adapt this script for your needs.

  5. Larry says:

    I am having a similar problem to Your Netbook above, but the solution seems to be different. I have resaved the permalinks and the code appears in the htaccess file as it is supposed to (code appears below). The links are cloaked in the status bar, but when you click one, it redirects to my homepage.

    Does it matter that the affiliate links use this format already?:

    ?url=

    (as in this CJ affiliate link:) http://www.anrdoezrs.net/click-(feed-id)-(my-aff-id)?url=http://www.merchant-site.com/

    # Link Cloaker Plugin BEGIN

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

    # Link Cloaker Plugin ENDS
    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

  6. White Shadow says:

    The plugin redirects to the homepage when it can’t find the original link in the source post. Links in the “?url=” format should be fine (I checked).

    This problem usually happens when the link is added by another plugin. Does that give you any clues?

  7. Larry says:

    Thanks White Shadow. I think it might.

    I am using ExecPHP, which allows me to put php inside the post and executes it for me. The affiliate links are generated dynamically by the php script inside the post or pulled directly from the database.

    Any way to get the cloaker to work anyway?

  8. White Shadow says:

    This has been a common request and will be added in a future version. However, that version may very possibly be commercial.

  9. Richard says:

    Hi,
    Please can you help.
    I have spent many hours trying to get the link cloaking plugin to work.
    I have read all of the recent forum posts and have done all the things that are talked about. Updated permalinks , checked htaccess files they are all OK and still no success.
    I have tried creating posts in two different domains that I have. One is on wordpress version 2.8.1 and the other on 2.8.2. They have different themes – one is dateless sniper and the other is on Semiologic. But there is no difference.
    I do not know which way to turn next. When I am creating a post should I be able to see the cloaking process within the link because at the moment the link just looks like a normal link when viewed in the html window.
    I await your comments.

  10. White Shadow says:

    So what exactly doesn’t work? Is it that links don’t get cloaked, or that they don’t redirect properly?

    A cloaked link will look the same when creating or editing a post. The actual cloaking happens when the post is displayed on the blog (this should also work in the post preview, if you use that).

    If you can’t get any links to cloak, check the settings page – maybe you’ve got selective cloaking turned on when what you really want is the “cloak everything” option. Or maybe the exclusion list contains something that it shouldn’t.

  11. White Shadow says:

    [I got your email, but couldn’t respond to it – my email got bounced with a “No such user” error message. So I’m posting my comment here.]

    Ah, I see.

    However, that behaviour is *by design* – it’s supposed to show the
    original URL in the address bar when you actually visit that page. The
    cloaking is currently only useful to hide the destination of the link from
    people browsing your site and, say, hovering their cursor over a link to
    see where it leads – not for fooling those who actually click the link.

    I’m currently working on an improved version of the plugin that will have
    the option to display the linked page inside a frame, which would create
    the effect you desire.

  12. Tim Scot says:

    How exactly do you make his plugin work, when you have fancy permalinks. Please help.

  13. White Shadow says:

    Generally you just have to update your permalinks (click “Save Changes” on the permalink settings without actually changing anything).

  14. […] first commercial WordPress plugin later this month. The plugin will be an improved version of the Link Cloaking plugin and will include a bunch of new and exciting features, like cloaking links anywhere on the site (as […]

  15. Sham says:

    Hi,

    Does your plugin work with WP 2.8.4? I just upgraded and I think the plugin no longer works. My cloaked links now show 404 pages

  16. White Shadow says:

    Yes, 2.8.4 should work fine. You probably need to update your permalinks again (and check the .htaccess to make sure the cloaker code is above the WP code).

  17. Sham says:

    Hi,

    I’ve rechecked my htaccess and nothing wrong there. Why I think it doesnt work with WP 2.8.4 is because I have 2 sites, one is WP 2.7.1 and the other I upgraded to WP 2.8.4.

    The one with WP 2.7.1 is still working fine. The one with WP 2.8.4 is NOT 🙁

    I also have a site on another server and this one also the plugin failed to work after I upgraded to WP 2.8.4.

    When I meant fail, it means Failed to redirect….so ends up with a Page Not Found (404)

  18. White Shadow says:

    This site also runs on WP 2.8.4 as well, so I’m quite sure the plugin should be compatible with it.

    Could you perhaps email me your .htaccess and site URL? Maybe that would help me find some clues. My email is whiteshadow (@) w-shadow (.) com

  19. Marco says:

    I realised a “bug” in your script. If the URL has an space inside the link wont be cloaked.

  20. White Shadow says:

    @Marco : Fixed. You can download the updated version via the download link in the post above.

Leave a Reply