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:

    Sorry, but I think you’ve misunderstood something. You can’t include the post name in the cloaked link. The plugin can use the anchor text of the link in the URL, but not the post name.

  2. Norm says:

    Ah ok, my apologies. I did misunderstand, I was under the impression it would replace the word “link” for the /%postname%/.

    Thanks
    By the way, great plugin and have sent a donation your way.

  3. White Shadow says:

    Thanks for the donation 🙂

  4. Tim says:

    I’m having the same problem with the links being redirected to a 404 error page. For ex. if your go to my post http://www.therealtimscott.com/build-wealth-quickly-upmost-integrity/ and click on the link under the vid, it redirects to this page: http://www.therealtimscott.com/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?post_id=562&link_num=1&cloaked_url=goto/Top_Tier_Marketing_PRO/562/1

    The htaccess is a 777, and the linkcloak code is at the top of the file, so I’m at a loss

  5. White Shadow says:

    Are you using a plugin, or some .htaccess trick, to prevent visitors from accessing .php files in the /wp-content/plugins/ directory?

    From the error messages, it looks as if both wplc_redirector.php and wplc_link_cloaking_plugin.php are missing from the “link-cloaking-plugin” folder, but if that was true then the plugin wouldn’t work at all.

  6. Free Bets says:

    Hi White Shadow,

    First off, thanks for a fantastic plugin… Ran into a little issue that was addressed a while back.

    I am using custom fields to insert links into the template and the plugin does not seem able to cloak it. There was a fix you recommended, but it seems the code has changed since then. I was wondering if you had an up to date fix or if the premium version caters to this.

  7. White Shadow says:

    The premium version should be able to cloak links from custom fields, yes.

    I can’t seem to recall the fix you mentioned, can you point me to the specific comment?

  8. Free Bets says:

    It is comment number 50 in your comment list.

  9. White Shadow says:

    I see. It should be pretty easy to tweak the code in that comment to work with the latest version of the plugin.

    To wit, everything said in the “rewriting the link” section of that comment still applies. The redirector code itself (wplc_redirector.php) has changed, but very little. You just need to replace lines 19-25 in that file with something like this :

    if (0 == $link_num) {
    	$url = get_post_meta($post_id, "custom_field_name", true);
    } else {
    		$link_count = preg_match_all( $ws_link_cloaker->url_pattern, $this_post->post_content, $matches, PREG_SET_ORDER );
    			
    		if($link_count >= $link_num){
    			$url = empty($matches[$link_num-1][3])?$matches[$link_num-1][2]:$matches[$link_num-1][3];
    			$url = str_replace('&','&',$url);
    			$url = ltrim($url);
    		}
    }
  10. Free Bets Uk says:

    Hi White Shadow,

    Thanks for taking the time out to help. It now masks the url, but the URL is broken… it just leads to a white page, no redirection.

    Any Ideas?

  11. White Shadow says:

    Hmm, what’s your site URL? Maybe I should take a look.

  12. Tim Scott says:

    I’m using a blank html page to hide my plugins, and both of those php files were in the plugin folder. I delted the pluging and re-installed it, and I’m still getting the same issues

    {Are you using a plugin, or some .htaccess trick, to prevent visitors from accessing .php files in the /wp-content/plugins/ directory?

    From the error messages, it looks as if both wplc_redirector.php and wplc_link_cloaking_plugin.php are missing from the “link-cloaking-plugin” folder, but if that was true then the plugin wouldn’t work at all.}

  13. Tim Scott says:

    Is there a way to diagnose this issue over email instead of by this comment section?

  14. White Shadow says:

    You can email me at whiteshadow {at} w-shadow {dot} com.

  15. Tim Scott says:

    I emailed you and have not received an email back yet

  16. White Shadow says:

    Weird, my response must’ve been caught by your spam filter or otherwise gotten lost. I’ll post it here then :

    Hey Tim,

    Here’s what I’ve found. The .php files are indeed where they should be, and are visible when accessing the directory URL like this :

    http://[edited]/wp-content/plugins/link-cloaking-plugin/

    However, if you try to click on one of the .php files, e.g.

    http://[edited]/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php

    …you’ll get a 404. This doesn’t happen for other files in that directory – for example, clicking on “tick.png” will display the green “tick” icon (as expected). This is a very strong indication that something in your server configuration or your .htaccess file(s) is preventing visitors from accessing .php files within the /wp-content/plugins/ directory.

    Perhaps you should ask your hosting provider about this?

    Cheers,
    Janis Elsts / White Shadow

  17. Tim Scott says:

    Heres what my htaccess looks like

    # BEGIN WordPress

    # Link Cloaker Plugin BEGIN

    RewriteEngine On
    RewriteRule ^goto/([^/]*)/([0-9]+)/([0-9]+)/?$ http://www.therealtimscott.com/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php?post_id=$2&link_num=$3&cloaked_url=$0 [L]
    RewriteRule ^goto/([^/]+)[/]?$ http://www.therealtimscott.com/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]

    # END WordPress

  18. Tim Scott says:

    Also i’m hosting another site on the same account and the link cloaking plugin is working just fine

  19. White Shadow says:

    That .htaccess looks fine. However, check /wp-content/ and /wp-content/plugins/ for extra .htaccess files.

    Other than that, I’m fresh out of ideas. Get the premium version, perhaps? 🙂 It doesn’t use .htaccess redirects and doesn’t need the plugin folder to be web-accessible.

Leave a Reply