Link Cloaking Plugin for WordPress

I’ve created a plugin for WordPress that can cloak outgoing links in your posts and/or pages.

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.
  • Configure the URL – you can set the “prefix” part of the URL (see examples below).
  • 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.
  • As of version 1.1, static link cloaking.

New! The premium version of this plugin is now available and includes several new features :

  • Cloak links in any part of your site, including the comment section and the sidebar.
  • Works with plugin-created links.
  • Five new cloaking types – for example, you can display the cloaked URL in a frame, or use a special redirect that hides the referrer.
  • Improved link management and click statistics.
  • Free automatic updates.
  • And more. Check out EclipseCloaker.com for complete details.

Examples

Here’s a link explicitly tagged for cloaking -
<a href="http://evil-guide.tripod.com/"><!--cloak-->A Cloaked Link</a>
And here’s what it looks like in the post – A Cloaked Link
If you have configured the plugin to cloak all links (the default) you don’t need the <!–cloak–> tag inside your links.

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 Options -> Link Cloaking and modify the default settings to your liking.
  6. Re-save your permalink settings to insert the plugin’s link redirection code to the WordPress .htaccess file :
    • WP 2.7 and above : Go to Settings -> Permalinks and click “Save Changes”.
    • Older versions of WP : Go to Options -> Permalinks and click “Update Permalinks”.

Download

Version 1.4.1 : link-cloaking-plugin.zip (9 KB)

Requirements :

  • WordPress 2.2 – 2.9
  • mod_rewrite. If “pretty permalinks” work on your blog then you probably have this already.
Share :
  • Reddit
  • del.icio.us
  • Digg
  • StumbleUpon
  • DZone
  • Ping.fm
  • Sphinn
  • Twitter
Related posts :

480 Responses to “Link Cloaking Plugin for WordPress”

Pages: « 1 [2] 3 4 5 6 7 8 9 10 1116 » Show All

  1. 31
    amy says:

    Yeah, I updated permalinks.

  2. 32
    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?

  3. 33
    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’

  4. 34
    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.

  5. 35
    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

  6. 36
    White Shadow says:

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

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

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

  9. 39
    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?

  10. 40
    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.

  11. 41
    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.

  12. 42
    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

  13. 43
    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 “?>” -

    <html>
    <frameset cols="100%" rows="100%">
      <frame src="<?php echo $url; ?>" scrolling="auto" frameborder="0">
    </frameset>
    </html>

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

  14. Hello,

    I get this error. Visit my site for an example.

    Parse error: syntax error, unexpected ‘<’ in /home/halcyonr/public_html/3magin8/site/2/wp-content/plugins/plugins/wplc_redirector.php on line 39

    This is the same problem I had before when I tried to do it myself. How do you insert an html code into a php file?

    Thanks!

  15. 45
    White Shadow says:

    PHP code is between “<?php” and “?>”, everything outside these separators will be treated as HTML. You should be OK inserting HTML after the last “?>” in the file. It is also possible to output HTML (or something else) from PHP code by using the echo function.

  16. 46
    Chirs says:

    Awesome plugin! Just what I’ve been looking for :)

    Is it possible to tell the plugin to encode not only the post content but also a custom tag?

    e.g. for ach of my blog posts I have a custom tag called ‘deeplink’ – how can I get the plugin to cloak this?

  17. 47
    White Shadow says:

    If the tag is added by another plugin and shows up inside the post when the post is displayed, you can’t really cloak it (at least not without some changes to the cloaking plugin… which might lead to new bugs).

    Arrgh, I need more information to really answer your question :P Is this tag part of the post or do you enter it in an additional field on the ‘Write Post’ screen? Also, if it’s added by a plugin, which plugin? It would be easier if I could look at the source code.

  18. 48
    Chirs says:

    Hey, thanks for your quick response.

    Yes, its one of the additional tags that you enter as part of the Write screen.
    I am able to reference it in my templates using:

    ID, “deeplink”, true); ?>

  19. 49
    White Shadow says:

    Looks like your code example got messed up; you should wrap it in <pre lang=”php”> … </pre> tags for it to display correctly (you even get syntax highlighting then).

    Anyway, since you use it in your templates, there is no other way to cloak the links than to modify both the template code and the cloaking plugin. It’s complex, but doable if you’re sufficiently familiar with PHP and WordPress. I can give you a few hints on what to look for, but you’d be largely on your own.

  20. 50
    Chirs says:

    This is the code I use to reference the custom field in my templates.

    ID, “Thumbnail”, true); ?>

    Any tips would be much appreciated!

  21. 51
    Chirs says:


    php echo get_post_meta($post->ID, "deeplink", true);

  22. 52
    White Shadow says:

    Hmm, is <pre> not allowed in normal comments? (It works for me, but then I’m the admin of this blog).

    Okay, there are two things you need to do – rewrite the “deeplink” so that it’s cloaked and modify wplc_redirector.php so that it can recognize the links.

    Rewriting the link : I’d replace your template code with something like this -

    $url = get_post_meta($post->ID, "deeplink", true);
    if (isset($ws_link_cloaker)) {
    	$url = get_option('siteurl').'/'.$ws_link_cloaker->options['prefix'].
    			'/deeplink/'.($post->ID)."/0";
    }
    echo $url;

    You can put something else in place of the “deeplink” text there, like “info”, “details” or whatever you want. This will create an URL that has the same pattern as other cloaked links, yet can be recognized and treated differently because it ends with a zero (normal cloaked links end with above zero numbers). This code should also gracefully handle the situation when the plugin is no longer active, falling back to uncloaked links.

    Modifying the redirector : you’ll need to edit wplc_redirector.php for this, adding special handling for links that end with zero. This can be done in several ways… Look at the first if block, find code that looks like this -

    $link_count=preg_match_all($wplc_url_pattern, $this_post->post_content, 
    	$matches, PREG_SET_ORDER);
     
    if($link_count >= $link_num){
    	$url = $matches[$link_num-1][2];
    	$url = str_replace('&amp;','&',$url);
    } else {
    	$url = get_option('siteurl');
    }

    I’d do it like this -

    if (0 == $link_num) {
    	$url = get_post_meta($post_id, "deeplink", true);
    } else {
    	$link_count=preg_match_all($wplc_url_pattern, 
    			$this_post->post_content, 
    			$matches, PREG_SET_ORDER);
     
    	if($link_count >= $link_num){
    		$url = $matches[$link_num-1][2];
    		$url = str_replace('&amp;','&',$url);
    	} else {
    		$url = get_option('siteurl');
    	}
    }

    Well, that’s all. Unless I’ve forgotten something, or made some typos there (possible, didn’t check), it should work.

  23. 53
    Chris says:

    That worked a treat!

    I owe you a beer

  24. [...] Link Cloaking – Protect your affiliate links. This plug-in allows you cloak (hide) outgoing links in your posts and/or pages [...]

  25. 56
    bonafide says:

    ok, I’ve installed the plugin, and it seems to be working. yay! thanks for the work on this.

    What I’d like to know is why your example on link cloaking, ie the how to be evil site, which is promoting a book, doesn’t have the amazon link cloaked to something that looks way nicer?…

    oh, and could you possibly, in your copious spare time, do a single site step by step walkthrough? for all us noobs to the wonderful world of WordPress?…

    thanks for the work!

  26. 57
    White Shadow says:

    That site isn’t mine, it’s just a random site that I found one day and liked enough to use it as an example here :) I’m in no way affiliated with that website.

    What do you mean with “a single site walkthrough”? Cloaking links on a site that isn’t running on WordPress? Or something else?

  27. 58
    cloudstrif3 says:

    Thanks again for the help!
    Happy Holidays!

  28. 59
    Ben says:

    I keep getting a 404 page. This is the page – http://www.smartgeezer.co.uk/2008/rip-curl-hells-bells-reversible-beanie-hat/ – permalinks has been updated, htaccess updated, I’m pretty sure I set it up right.

    Also, the link doesn’t open in a new window, even if I add the relevant code to Line 90.

    Any ideas?

  29. 60
    Ben says:

    OK, I’ve fixed the opening in a new window (had to remove nofollow in the Link Cloaking options) but not the actual link. It just tries to open the link – http://www.smartgeezer.co.uk/goto/link/68/1 – rather than converting it to the proper cloaked link.

Pages: « 1 [2] 3 4 5 6 7 8 9 10 1116 » Show All

Leave a Reply