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

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

Related posts :

201 Responses to “Link Cloaking Plugin for WordPress”

Pages: « 7 [6] 5 4 3 2 1 » Show All

  1. 171
    White Shadow Says:

    @Wally - Web browsers don’t normally show HTTP headers anyway. You’d need a special program or a FF extension to see them…

  2. 170
    Wally Says:

    @White Shadow - I don’t see any extra text in my 404 page when the link doesn’t work but I use a custom 404 page.

    I notice my SocioFluid plugin doesn’t work when the link cloaker is turned on. I guess I’ll just leave it alone for now since there seems to be several confilicts or problems.

    Thanks again.

    Wally

  3. 169
    White Shadow Says:

    @Wally - AFAIK permalinks beginning with index.php still don’t use .htaccess/mod_rewrite.

    Ahhh, it’s already past midnight in this timezone and I can’t think of anything else useful :P

    BTW : There is a way to tell if the plugin actually gets executed when a cloaked link is clicked - it generates a HTTP 301 response and adds a “X-Redirect-Src” field to the header…

  4. 168
    Wally Says:

    WS,

    No I use the custom permalink: /index.php/%year%/%monthnum%/%postname%.html

    When I try to go to the file domain.com/blog/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php, I just get “Index of /blog/wp-content/plugins/link-cloaking-plugin”. It doesn’t list any files but all three php files are there.

    Wally

  5. 167
    White Shadow Says:

    @Wally - Hmm, let me guess - you’re using the basic “?p=xyz” permalinks for your posts, right? In that case WP doesn’t need the .htaccess file and might be deleting it when you update permalink options (just a guess, I have never seen WP actually do that).

    But still, if you create the file manually and put the right lines in it the plugin should work. The challenge might be getting the rules right when doing it by hand.

    By the way, have you tested if you can access domain.com/blog/wp-content/plugins/link-cloaking-plugin/wplc_redirector.php in your browser? If the plugin is correctly installed in the default location that file should redirect to your homepage (not 404).

  6. 166
    Wally Says:

    WS,

    My blog path is just domain.com/blog/. Then it is the normal WP setup. The path to the linkcloaker plugin is \blog\wp-content\plugins\link-cloaking-plugin and I have it set to the default settings for now.

    There wasn’t a .htaccess file in the /blog directory so I just created one with the 3 lines mentioned below in a post between the # START Wordpress and # END Wordpress. BUT… after trying to get the plugin to work the .htaccess file disappears. I guess WP must be deleting it.

    So, maybe there is another conflict and this won’t work on my blog.

    Thanks anyway.

    Wally

  7. 165
    White Shadow Says:

    @Wally - The wording on the options page has been changed in newer WordPress versions and it doesn’t say “Update Permalinks” anymore; anyway, saving the settings should be enough.

    Just to clear this one up, the .htaccess file needs to be in the directory that the blog is installed in (or your post permalinks probably wouldn’t work).

    I would guess that the plugin-related .htaccess rules are incorrect in your case, most likely either in the prefix or path; I can’t provide any more details without knowing your directory structure and plugin configuration.

  8. 164
    Wally Says:

    I’ve tried getting this plugin to work in WP 2.51 and am NOT having success. I followed the suggestions about the .htaccess file but still the links get sent to my 404 page.

    I could not find a place to “update permalinks”. In settings/permalinks the only option is to update the settings. I’ve tried clicking that to no avail.

    Mod rewrite IS available on my host.

    My blog is in a “blog” folder and I’ve tried putting the .htaccess in the root and in the folder.

    Any other suggestions would be appreciated.

    Wally

  9. 163
    minimaus Says:

    @White Shadow -

    Big big thanks to your helps, White Shadow, even it turn out that the host do not support this plug-in. Maybe i would consider to change to another hosting service.

    bigmaus

  10. 162
    White Shadow Says:

    @minimaus - Try adding these three lines between the lines that say “Begin WordPress” and “End WordPress” :

    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]

    I’m not 100% sure it’ll work, but it could make the plugin function correctly.

  11. 161
    minimaus Says:

    @White Shadow -

    How the .htaccess file look like?
    Mine like this:

    # -FrontPage-

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    order deny,allow
    deny from all
    allow from all

    order deny,allow
    deny from all

    # BEGIN WordPress

    # END WordPress

  12. 160
    White Shadow Says:

    @minimaus - I don’t have any specific recommendations, but you should be able to find something on Google.

  13. 159
    minimaus Says:

    @White Shadow -

    Many thanks. Could you please give me a recommendation of a script, plugin that overcome this host limitation.

    minimaus

  14. 158
    White Shadow Says:

    @minimaus - Looks like the plugin isn’t executed when you click the link. Have you updated the permalinks after setting up the plugin? If yes, check the .htaccess file and make sure the “cloaking”-related rules (they should be marked as such) come before the main WordPress rules.

    Addendum : I looked at your site more in-depth and it appears you are not using “fancy” permalinks. Might it be because mod_rewrite isn’t supported by your host? If that’s the case then this plugin will not work on your site.

  15. 157
    minimaus Says:

    @White Shadow -

    Hi White Shadow,

    I put your plugin onto my website: http://nguyenngocminhhanh.com/

    But when clicking on cloaked link, it redirected to not_found.html.

    Could you please take a look and help me work out?

    Thanks

  16. 156
    White Shadow Says:

    @Hugo Santos - There are already other plugins that can do that :P However, most of them would have compatibility problems with this plugin, unless you use them to insert “statically cloaked” links.

  17. 155
    Hugo Santos Says:

    and what about an option to automatic link insertion to a given keyword instead? :)

  18. 154
    White Shadow Says:

    @Ash - It’s doable, but would take a lot of thinking/hacking. I’m not up for it at the time, sorry.

    If you want to give it a try yourself, you could use the $url_pattern regexp to extract the URL from the banner and then modify the previous hack to handle these additional URLs.

  19. 153
    Ash Says:

    Thanks White Shadow, i’ll try and find another way around the comment links.

    I’m having difficulty cloaking banner ads i’m running from custom fields, your previous ‘hack’ for custom fields worked a treat where i had a plain url to cloak but can this be modified where the url is included within banner code in the custom field?

    Here is an example of the code (links removed) that i include in a custom field called banner468

  20. 152
    White Shadow Says:

    @Ash - Not at this time; not in the foreseeable future either :P

  21. 151
    Ash Says:

    Found the solution to cloaking custom fields in the comments, thanks. Could’nt find anything regarding cloaking links within comments.

  22. 150
    Ash Says:

    Is is possible that this plugin can cloak urls in comments and custom fields (of posts)?

  23. 149
    Jeff Says:

    Yeah, the links from ALINKS were getting cloaked correctly… However, all the links were off by 1. Meaning…. If I had three links in the page… the first link would direct to the second, the second would direct to the third and the third would direct to the associated tag.

  24. 148
    White Shadow Says:

    @Jeff - It might be possible to make both plugins work together, but the links created by ALINK wouldn’t get cloaked anyway.

  25. 147
    Jeff Says:

    I just installed the plugin on a couple of my blogs. The first blog the plugin worked great. The second one I had some problems with it. It was interferring with my other plugin “ALINKS” … a plugin to create links to certain keywords. I couldn’t figure out a way to fix the plugin for this page so I just deactivated it because I need the alinks plugin more… If you have a fix for this I’d love to hear about it!

    Otherwise great plugin!

  26. 146
    Authcode Says:

    @White Shadow - Managed to fix it by updating cloaking settings several times (strangely, didn’t work the first couple of times). I think the Wordpress Automatic Upgrade plugin screwed my plugin settings when it tried to restart them all unsuccessfully after the upgrade. I’ll remember to check my links next time! Cheers.

  27. 145
    White Shadow Says:

    @Authcode - I had some problems with this, but I think updating permalinks fixed it.

  28. 144
    Authcode Says:

    I’m running version 1.2.2 of this plugin which seems to have stopped working after I upgraded Wordpress to version 2.6. Is anyone else getting this? All my cloaked links goto my blog’s 404 page - I’ve had to deactivate for now.

  29. 143
    Anybody a 301 redirect expert - Affiliate Marketing Says:

    [...] expert Hi I am currently experimenting with the ‘link cloaking plugin’ available here: Link Cloaking Plugin for WordPress | W-Shadow.com It automatically cloaks all links barr your own domain by default. Thats from memory but pretty [...]

  30. 142
    White Shadow Says:

    @affboy - yay, shameless self promotion.

Pages: « 7 [6] 5 4 3 2 1 » Show All

Leave a Reply