Back to Top

Better WordPress External Links

Better WordPress External Links

Gives you total control over external links on your website. This plugin also comes with a comprehensive domain filtering feature.

 Sponsor   Themes by Elegant Themes - $39 for unlimited access to 80+ WordPress Themes!

BWP External Links gives you total control over external links on your WordPress websites. Your visitors can easily distinguish between internal and external links, and you can make external links automatically open in a new tab/window or add a redirection page.

Plugin Features

  • Process links for post contents, comment text, text widgets, or the whole page
  • Domain filtering:
    • You can specify which sub-domains of your website to consider local (all subdomains, no subdomain, or some)
    • You can specify which external domains to consider local (e.g. if you link to wordpress.org a lot you might want to force that domain local)
    • You can forbid certain external domains  (e.g. pron.com, warez.com) and replace URLs linking to them with a URL of choice (useful for filtering links in visitors’ comments)
    • Wildcard support, e.g. *.example.com, *.subdomain.example.com
  • You can add rel="external", rel="nofollow" or any custom relation tag you could think of to external links
  • You can specify CSS classes for both local and external links, as well as external image links
  • You can use provided CSS (an external icon is added to each external link) or define your own
  • Choose whether or not to open a completely new window for each external link
  • Choose between three ‘new window’ modes: `onclick` attribute, `target` attribute or jQuery
  • Add a prefix to external links. Example use would be a redirection page that warns your visitors about the danger of visiting external sites, e.g. http://yourdomain.com/out?
  • WordPress Multi-site compatible

Plugin Usage

Domain filtering

Under Settings > BWP External Links > Link Options you will be able to define domain filtering rules.

Subdomains

By default BWP External Links does not make links pointing to subdomains of your website/blog external. For example plugin.betterwp.net or premium.plugin.betterwp.net is considered local. If you select the opposite (i.e. “Links to all subdomains are considered external”), all subdomains will then be considered external.

You can also select a third option:  ‘Links to some subdomains are considered local’. For this setting to work you must tell the plugin which subdomains to filter out, by specifying each subdomain (WITHOUT scheme and root domain) on a separate line in “Local subdomains” setting. Assuming that your website is at http://example.com, you can have something like this:

premium.theme
*.theme
plugin
theme

By specifying plugin, theme, and premium.theme you are effectively making plugin.example.com, theme.example.com , as well as premium.theme.example.com local.

With *.theme you make premium.theme.example.com and any other subdomains on theme.example.com, such as free.theme.example.com, local.

Subdomains that are not specified such as photos.example.com are considered external.

Important note: in some cases when the same subdomain name is used on multiple subdomain level, e.g. en.example.com and en.plugin.example.com, the order in which you specify each subdomain name is crucial. A simple rule to follow: the lower level a subdomain is (further from the root domain), the higher the position its name should be in the “Local subdomains” setting. So in the above example, to make both en.example.com and en.plugin.example.com local, use this:

en.plugin
en
Domains

Apart from subdomain filtering rules, you also have the option to make links to external domains become local, or forbid linking to some external domains entirely.

To make external domains local, simply type in one external domain per line (without scheme) into the “Forced local domains” setting textarea. Note that you would specify the full domain (including the TLD or extension, along with wildcard if needed), e.g. wordpress.org or *.wordpress.org instead of just wordpress.

You can do the same thing with “Forbidden domains” plus setting a replacement URL for any links to forbidden domains. Settings the replacement URL to # is a good example.

Redirection page

This is actually a favourite feature of mine.

The redirection page is often used on external links to warn you about the fact that you’re going to leave the current website, and will be on your own after confirming to leave. Sites with lots of comments and links use it, for example http://www.deviantart.com/.

BWP External Links allows you to set a prefix for any external link, and you can use such feature to construct a redirection URL, e.g. http://example.com/out.php?url=....

By default hxxp://anonym.to is available to help you anonymize links in your posts, but you can set the prefix to any custom URL on your site. Check out this Redirect external links tutorial for some tips to get a custom redirection page up and running.

Opening external links

This plugin offers three ways to open an external link: open a new tab/window for each link (‘_blank’ – this is the default setting), open just one new tab/window for any link (‘_new’) or use the same tab/window for all links.

When a new tab/window is preferred, BWP External Links also supports three methods (the rule of three anyone?) to achieve just that: use the target attribute (which was formerly not W3 compliant), use the onclick attribute (which might get blocked) or use jQuery. If jQuery is already being used on your website, I’d recommend that you use the jQuery method, it is clean and safe :).

Styling external links

With the CSS classes in hands there would be no trouble beautifying your external (or even local) links. I would just add a ‘pointing out’ icon to the end of every external link and add some ‘text-decoration’ rules if needed. You might find some icons here and a neat tutorial about this here.

As of version 1.1.3 a new CSS class, i.e. ext-image, is used instead of ext-link for any link pointing to an external image, so make sure you make good use of that one as well.

That’s all for now, thanks for reading, and please rate this plugin 5 shining stars if you like it!

To-do List

  • (planned) Remove anchors pointing to forbidden domains completely rather than just the href.
  • (This section is open for feature request)

Hook References

  • bwp_ext_image_extensions – pipe-separated list of image extensions to assign the ext-image class (filter, default is jpg|jpeg|png|gif)

Credits

BWP External Links is based on the idea of a phpBB3 mod named Prime Links © Ken F. Innes IV, also known as Prime Halo.

Contribute to this Plugin

This plugin is licensed under GPL version 3, and it needs contributions from the community.

Buy me some special coffees!

My plugins and support for them are free. If you like my work and could buy me some (special) coffees, I would be much appreciated! They might help with some overnight times debugging my plugins, you know.

Support, Feedback, and Code Improvement

i18n (Translate the plugin)

If you are a translator, please help translating this plugin. Even if you aren't, you can become one, it is very easy and fun! If you want to know how, please read here: Create a .pot or .po File using Poedit.

Print Article Watch Log