Identify External Links

About

This plugin will add a special CSS class to all links in your entries and in your comments that go to external sites (sites other than your site). For more complex external link identification needs, check out Link Indication.

Download

Instructions

Copy and paste the text. Save it in a file named identify-external-links.php. Make sure there are no spaces before the opening <?php or after the closing ?>. Activate it from within the WordPress admin interface. You can then use a.extlink { } in your CSS to style it.

You can also edit a setting in the top of the plugin to add target="_blank" to external links, so that they open in a new window (this is from popular demand… please note that this is an annoying thing to do to your readers.)

Versions

Version 1.3 Filter priority has been upped to 999 to get around some issues with markup plugins… option added to do target="_blank" Version 1.2 Doesn’t apply extlink class if there is an image within the link Version 1.1 Works for subdomains now (thanks h0bbel!) Version 1.0 Initial release

I’ve spent a lot of time writing this code and supporting it. If you derive some benefit from this code, please consider showing your gratitute in a more tangible
way. Thanks!

I have received $0 this month for my coding efforts.

Donate with PayPalAmazon.com Wishlist


203 Responses to “Identify External Links”

Comment pages: « 1 [2] 3 »

Mark (post author) |

you could do a find/replace in the database, or use a filter to remove it on-the-fly…

$text = str_replace(' target="blank"', '', $text);

Fred |

Hi I found a bug in Version 1.3
Your current code recognises two types of hrefs:

href=”http://www.mysite.com/mypage.htm”
-and-
href=”http://www.othersite.com/theirpage.htm”

I modified the code to deal with a type of href that I use on my site, which is

href=”/mypage.htm”

I would like to share the bugfix. Where can I post it?

Yansky |

Hi, I’m having a problem getting the plugin to work with external links that are in a list. It doesn’t seem to add the â€Âextlink†class to the links.

Any help would be appreciated.

Cheers.

Yansky |

re: my previous post.

I forgot to mention that it’s only in the feedback section that it doesn’t seem to be working.

http://goodbyepolar.com/2006/11/04/external-links-in-a-list/

dereinzige |

thanks!
works like expected :)

that’s my style: .extlink:after { content: “279A” }

shown eg. here

Vitaliy Köln |

Boah, really great job! Thanks

Mark Wilson |

Great plugin - thanks; however I seem to be having a slight problem with it… most of my links are working fine, but the plugin doesn’t seem to identify anything with a .co.uk domain name as being external to my site (www.markwilson.co.uk/).

As I have a UK-based website it’s a bit of a problem! Strangely it’s OK with .me.uk and .com.au so it’s not all two-level TLDs that cause an issue.

Thanks for any advice that you can give?

Ana |

Good site! I found in google.com +

download |

I hate to sound like a broken record but it works great.

indir |

Heading right over to install

Vijay

youtube |

Well, i still like the plugin however it’s also good to use 301 Redirect

Alfons |

Well, the plugin ad a class=”extlink” but no target=”_blank” even if I set it “true” in php file

Any hints?

Murattx |

Thanx… its work!

trademark registration |

Thanks. I will install to see how it works. =)

GooHackle |

If you want to know the external links that exist in internet to your site or to any site you can use this webmaster online tool:
Who links to me

jay |

This plug-in is great!

But..it doesn’t add ‘target=”_blank”‘ to the title linked to the external link.

It’s common that syndicated article’s(by auto-feeder) title is linked to the external site(to the original source) and it’s needed esp. when the contents are excerpt; so the user can go see entire contents from the source site rather than seeing full post which is just the same excerpt…

Could you update the code or let me know how to add that that feature?

Thank you in advance!

Super Dave |

I’m submitting a fix for the target “_blank” issue. It actually only opens links in a new page with if there is an image. Add the following to make it work with text too.

Change your parse_external_links function with this one:

function parse_external_links($matches){
global $txfx_iel_use_target_blank;
if ($txfx_iel_use_target_blank)
{
if ( wp_get_domain_name_from_uri($matches[3]) != wp_get_domain_name_from_uri($_SERVER["HTTP_HOST"]) )
{
return ‘‘ . $matches[5] . ‘‘;
}
}
if ( wp_get_domain_name_from_uri($matches[3]) != wp_get_domain_name_from_uri($_SERVER["HTTP_HOST"]) )
{
return ‘‘ . $matches[5] . ‘‘;
}
else
{
return ‘‘ . $matches[5] . ‘‘;
}
}

(This plugin still also appears to only add the class attribute to text links. So another fix is probably needed if it is desirable to have the class on images and text links too.)

Bob |

Hi,

I installed this on a customers blog for them ..

I set: $txfx_iel_use_target_blank = true;

I activated the plugin, but it appears to have no effect?

Wordpress is V.2.2.2

Any Ideas? It can be seen at http://www.gatewaydiscovery.com

T |

I’m having the same problem as #190 - activated but it doesn’t seem to affect anything (looking to open new window). Any ideas? Thanks.

Comment pages: « 1 [2] 3 »

Leave a Reply


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser