Link Cloaking Plugin for WordPress
I’ve created a plugin for WordPress that can cloak outgoing links in your posts and/or pages (note : if you’d rather have a more general link cloaking tool, take a look at Link Manager).
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.
- Update : version 1.1 available - now with static link cloaking!
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
- Download the link-cloaking-plugin.zip file.
- Unzip the file.
- Upload the `link-cloaking-plugin` folder to the `/wp-content/plugins/` directory.
- Activate the plugin through the ‘Plugins’ menu in WordPress.
- (Optional) Go to Options -> Link Cloaking and modify the default settings to your liking.
- Go to Options -> Permalinks and click “Update Permalinks”. This ensures the plugin’s link redirection code is added to WordPress .htaccess file.
Download
Version 1.2.2 : link-cloaking-plugin.zip (9 KB)
Tested on WP 2.2 - 2.6.2.
mod_rewrite is required. If “fancy permalinks” work on your blog then you probably have this.
November 15th, 2007 at 8:34 pm
php echo get_post_meta($post->ID, "deeplink", true);
November 15th, 2007 at 8:33 pm
This is the code I use to reference the custom field in my templates.
ID, “Thumbnail”, true); ?>
Any tips would be much appreciated!
November 15th, 2007 at 8:14 pm
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.
November 15th, 2007 at 7:57 pm
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); ?>
November 15th, 2007 at 7:34 pm
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
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.
November 15th, 2007 at 6:43 pm
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?
November 13th, 2007 at 12:41 pm
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.
November 13th, 2007 at 6:37 am
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!
November 10th, 2007 at 2:02 am
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 “?>” -
That’s a very primitive version, but it should work. Not tested.
November 10th, 2007 at 1:43 am
Can you please help on creating a frame code.
I don’t know how to insert the html code into the redirect php file
November 4th, 2007 at 1:44 am
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.
November 4th, 2007 at 12:19 am
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.
November 3rd, 2007 at 1:58 pm
I looked at your site. I think the the problem is in the .htaccess. Where is your .htaccess located and what does it contain?
November 3rd, 2007 at 4:24 am
visit my site and click on a link in a post and you’ll see.
November 3rd, 2007 at 4:20 am
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!
November 3rd, 2007 at 12:05 am
It’s doable, but a lot of work. I’ll keep your suggestion in mind but I can’t promise anything.
November 2nd, 2007 at 11:42 pm
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
November 2nd, 2007 at 10:27 pm
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.
November 2nd, 2007 at 10:11 pm
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’
November 2nd, 2007 at 2:11 pm
Well, I don’t have any other bright ideas then. Care to give me a specific example of a link that doesn’t work?
November 2nd, 2007 at 11:02 am
Yeah, I updated permalinks.
November 1st, 2007 at 2:31 pm
Do you mean you get a 404 when you click a cloaked link? If so, have you updated the permalinks?
November 1st, 2007 at 7:06 am
Hi.
Great plugin. However I am getting a 404 when I use it. Do you know how to fix it?
Thanks.
October 22nd, 2007 at 1:40 am
What do you mean “slowing down”? Anyway, it’s probably something to do with WP itself.
If Wordpress can write to .htaccess, so can the plugin, because it works from within WP. I assume you have tried updatibg permalinks, right?
October 22nd, 2007 at 1:00 am
Having problems with the 2.3 version of word press
it seems to be slowing down
Also it would not write to .ht access file
Does it have anything to do with file permissions
October 14th, 2007 at 2:48 pm
[...] Cloak Affiliate Links Что умеет этот плагин: Заботитесь о виде своих [...]
October 11th, 2007 at 2:33 am
Hey, I’m glad you like it
“Hits” refer to the number of times a link has been followed, so you could say it’s pageviews… except the “real” pageview count is probably lower, because search engines and other bots would also be counted as “hits”.
Creating a reliable click stats report is nontrivial and I’m not aiming for that - the “Hits” figure is there to give a general idea about the link’s popularity only. You might want to find a separate plugin for accurate stats, or use Google Analytics. You can put the Analytics code on your blog with the Ultimate Google Analytics plugin (this is what I do on this blog).
October 11th, 2007 at 2:16 am
Hi White Shadow,
I found your plugin just a couple of days ago. After trying several other plugins/solutions to cloak my links…and failing to get them to work, imagine my excitement when I turned on your plugin and it worked right out of the box.
I LOVE it!
One question…
Do “hits” refer to actual clicks on those links or just page views?
Curtis Penner
October 10th, 2007 at 11:55 pm
Just to clarify, the plugin is designed so that you can add the nofollow tag to the uncloaked link and it will stay there when it’s cloaked, too.
Now, for your question - the quick & dirty solution would be to replace line 90 (the one that starts with “return”) in the file wplc_link_cloaking_plugin.php with this line :
Try it out. I have a sneaking suspicion that this might cause conflicts with other link rewriting plugins (and similar), but it should work well enough in most cases.
October 10th, 2007 at 11:24 pm
First of all, great plugin! Thank you!
I’m trying to add NOFOLLOW tags to my cloaked affiliate links so the end result is:
Test
becomes
Test
Can you tell me which lines of the script I should replace, and with what?
Thank you again!