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

    White Shadow, thank you for a great plugin. I have it configured and working on my blog, now I am having a weird problem on another blog I am configuring. Is it possible that it works properly with some WP themes but not with others? For this new blog I am configuring I decided to use AjaxBerlee theme and it doesn’t work with it. If I select some other theme it appears to be working fine. This theme uses AJAX, so the URL doesn’t always change in the address bar when you navigate posts and pages of the blog. Clicking on any external cloaked links gives me a page not found message. Any thoughts?

  2. White Shadow says:

    I’m guessing the theme uses some non-standard mechanism for loading posts and the plugin can’t figure out which post/page is currently visible, leading to invalid cloaked links. I’ll take a look at the theme tomorrow, but can’t promise anything – analysing other people’s code usually isn’t easy.

  3. Alex says:

    I ended up using a different theme. I just wanted to give you heads up and I was curious what you think might be causing this. I think using these AJAXy themes could hurt my SEO ratings anyways, that’s why I switched themes.

  4. White Shadow says:

    Ahha, I actually didn’t get anywhere with that theme. And I agree that AJAX is probably bad for SEO.

  5. Marc says:

    Great help, thanks.

  6. Prashant says:

    Plugin tested with WP 2.7 and it works though you will need to update the permanent link tab once you have upgraded to 2.7.

  7. John says:

    The plugin looks great, but I have slightly different requirements. Can you point me to a plugin that would actually CHANGE the outgoing links (not just cloak them for the user) to links pointing to my own domain?

    So basically I’m blogging using an RSS feed and the posts contain lots of outgoing links. I’d like these links to be changed to http://www.mydomain.com/link-1234.html or something which would then re-direct users to the actual page. I’m guessing this would have some SEO benefit by not having too many outgoing links in the posts.

    Is my logic here wrong, or is there a plugin that does this?

    Thanks!

  8. White Shadow says:

    I think your logic is a bit confused, yes.

    You want a plugin that will rewrite all external links to look like internal ones. However, when the user clicks on such link, they should be redirected to the actual external page. As I see it, this is exactly what Link Cloaker does (except the URLs don’t end in .html).

    Or did you perhaps mean that you want a plugin that would create actual HTML pages that contain nothing but a meta redirect/Javascript redirect? IMHO that would have no SEO benefit and would look weird from the user’s perspective.

    If your main concern is SEO and having too many external links, just check “Nofollow cloaked links” in the plugin’s configuration. This way the cloaked links won’t “count” from the search engine’s perspective.

  9. uhubuhu says:

    Plugin tested with WP 2.7 and works just fine.

    Still there is a problem with the images. Let me explain.
    I use two plugins for them.
    jQuery-Lightbox(http://www.pedrolamas.com/projectos/jquery-lightbox) and Add Lightbox (http://mdkart.fr/blog/plugin-add-lightbox-pour-wordpress/)
    The Add Lightbox plugin automatically adds the rel=”lightbox[ID_OF_THE_POST]” to images linked in a post using the code href=(‘|\”)([^>]*).(bmp|gif|jpeg|jpg|png)(‘|\”)(.*?)>(.*?)/i. BUT it cannot do that since they have already being cloaked. 🙁
    Any way of getting the lot working in harmony/
    Thanx in advance. Great work

  10. John says:

    Your cloaker works fine for affiliate links in the posts. However, I noticed that the affiliate links are NOT cloaked in the side widgets.

    How can I do this?

    Thank you,

    John

  11. White Shadow says:

    @ uhubuhu : That’s a bit hard to fix properly in the current release. As a workaround, giving the cloaking hook a later priority might help. To do that, open wplc_link_cloaking_plugin.php and on line 38 change the 2 to 20. The new line should look like this :

    add_filter('the_content', array(&$this,'content_filter'), 20);

    @ John : Currently this plugin can’t automatically cloak links in widgets. However, you could create “static” cloaked links (Tools -> Cloaker Links) and use the cloaked URLs in the widgets.

  12. Todd says:

    This plug in looks great! Does it also have click tracking so you can track how many people are clicking your affiliate links?

  13. White Shadow says:

    @ Todd : Yes, but only for “static” links, i.e. automatically cloaked links aren’t tracked.

  14. Erskine says:

    Hey. I’m having a bit of a problem with the plugin on WordPress 2.7. I’m trying to cloak my links in the side bar. I’ve used the static cloaking tool and have manually copied and pasted the links into the blogroll, but I get a 404 error when clicking on the links. Any ideas?

  15. White Shadow says:

    Most likely it’s something to do with .htaccess rules. Do automatically cloaked links work (in posts)? If not, update your permalinks and ensure the cloaking-related rules are near the top of the .htaccess.

  16. Erskine says:

    @White Shadow – Thanks! Totally works. And also, thanks for the quick reply.

  17. […] Link Cloaking: Automatically cloaks outgoing links in your posts and pages. You can also add static cloaked links manually. […]

  18. Justin G says:

    works like a champ. I have 2.7 and it worked without any refreshing. Thank you for this simple yet invaluable plugin.

  19. Daniel says:

    Hi,
    I’m having trouble with the Link Cloaking plugin. I have tried every way but I only got 404 pages from the links.

    I have wordpress 2.7, PHP Version 5.2.2 and the following plugins installed:

    All in One SEO Pack
    Easy AdSenser
    Google Analytics for WordPress
    Google XML Sitemaps
    My Category Order
    Sociable
    WassUp
    WordPress Database Backup
    WP-PostViews

    My .htaccess file:

    # Link Cloaker Plugin BEGIN

    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]

    # Link Cloaker Plugin ENDS

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

    Would be very grateful if I could get some expert help.

    Sincerely
    // Daniel

  20. White Shadow says:

    Looks like your wp-content folder is in a different location than the plugin expects (this is probably a bug). For now, you could try changing two lines in the .htaccess like this :

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

    I’m not sure if the forward slash is required before “wordpress”, so try removing it if still doesn’t work.

Leave a Reply