Support » Plugin: WP External Links (nofollow new tab seo) » Set up exclusion by code?

  • Resolved Martin



    First up great plugin. I use it on all my sites and works great.

    I’ve just installed one of the best insite Advertising platforms called OIO Publisher which allows automatically selling advertising including inline text links. The platform allows follow and nofollow as advertiser option choices.

    I was wondering whether there’s an easy way for the developer to interface with your plugin so that any purchases of dofollow links can be added to your plugins database of exclusions? Is it just a matter of adding one to a particular database table and when the purchase expires, then remove the URL from the table?

    Any help would really be appreciated.

Viewing 15 replies - 1 through 15 (of 21 total)
  • I’ve also been chatting the the developer of OIO Publisher.

    While he can give me assistance in hacking some code to then hack your plugin’s database, he suggested the following as a much more elegant solution:

    A cleaner solution, if the other plugin supports it, would be to exclude links based on criteria such as whether a specific class appears on the link. If it doesn’t support that kind of exclusion, it might be worth putting in a request for it.

    For example, I could easily stick class=”oio-link” on to all links generated by OIO, which the plugin could then exclude.

    Is this a possibility that WP External Links can simply ignore / bypass links that have a particularly configured class?

    Plugin Author FineWebdev


    There is a possibility to exclude links that contain a certain text in the url (for example, all urls to

    I have to think about the exclusion of certain classes. Maybe I would rather add a filter hook, so you can manipulate the output yourself on your own criteria.

    I’ll get back on this one…

    Thanks heaps for giving it some thought. Will wait to hear back with what you consider optimal.

    Any updates on the filter hook – keen to get this functional in my advertising platform. Thanks for any efforts too

    Plugin Author FineWebdev


    Hello Martin,
    I’ve been working on my other plugins. WP External links needs a refactoring and I first wanted to test it on another plugin.

    A quick solution if you now how to code, is implementing the filter yourself in the file:

    Add just a line of code on line 278:

    $link .= '>'. $matches[ 2 ] .'</a>';
    // add this code for the filter:
    $link = apply_filters('wpel_external_link', $matches[0], $link, $matches[2], $attrs);
    return $link;

    Now you can add something to the filter in the file functions.php file of your template, like:

    function own_external_link($original_link, $created_link, $label, $attrs = array()) {
        return 'This is an external link: ' . $created_link;
    apply_filters('wpel_external_link', 'own_external_link', 10, 4)

    I haven’t tested this code yet.


    OK, thanks for this, Victor.

    I’m OK with the alterations and just confused on the triggering mechanism so have just asked the OIO Publisher author for his input.
    I just had a dofollow incontent purchase today as a matter of fact and needed to apply a manual entry and prompted me to move on your wonderful work and suggestion of code alterations.

    I’ll update the post on progress as it might help others in a similar situation.

    Plugin Author FineWebdev


    Hello Martin, the filter “wpel_external_link” is added in version 1.40.

    Cool – so it’s just a new functions.php inclusion now?

    Plugin Author FineWebdev


    Yep 🙂

    Ok, I’ll set it up on my localhost and give it a try out – will report back with findings

    Maybe I’ve got the usage wrong here.

    I’ve got the following in my functions.php

    function extra_filters($filter_callback, $object) {
        add_filter('gajnfads', $filter_callback);
    add_action('wpel_ready', 'extra_filters');

    The link that I want this plugin to ignore has an added class such as:
    <a class="gajnfads" target="_blank" title="dofollow testing" href="">

    When this plugin is active and the functions.php snippet is there, the link is still being altered.

    Have I messed up somewhere in what I’m doing?

    Plugin Author FineWebdev


    You will need to use the filter wpel_external_link. In your case it would look like:

    public function external_link_filter($created_link, $original_link, $label, $attrs = array()) {
    	if (isset($attrs['class']) && strpos($attrs['class'], 'gajnfads') !== false) {
    		return $original_link;
    	$this->external_link_filter_args = func_get_args();
    	return '<b>'. $created_link .'</b>';
    add_filter('wpel_external_link', array($this, 'external_link_filter'), 10, 4);

    I did found a bug though, so please update first.

    hmmm, using that code on my localhost, I get
    Parse error: syntax error, unexpected T_PUBLIC in /Users/MartinC/Sites/gaj/wp-content/plugins/my-functionality-plugin/my-functionality-plugin.php on line 55
    which is the first line of the function.

    I tried removing the public however the entire URL line vanished i.e.
    <a title="dofollow testing" href=""></a>
    is replaced by a space.

    Sorry I’m not good at code and seeing the error.

    Plugin Author FineWebdev


    Sorry I copy/pasted from my testing code, but that’s part of a test-class. Try this:

    function external_link_filter($created_link, $original_link, $label, $attrs = array()) {
    	if (isset($attrs['class']) && strpos($attrs['class'], 'gajnfads') !== false) {
    		return $original_link;
    	return '<b>'. $created_link .'</b>';
    add_filter('wpel_external_link', array($this, 'external_link_filter'), 10, 4);

    hmmm, not sure what’s going on here.
    I replaced with your code however the entire HTML is still being removed from the page for some reason … as in vanishing so like it’s identifying what needs to be left alone but removes it completely from the content.

    Hope that makes some sense.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Set up exclusion by code?’ is closed to new replies.