• Resolved Martin

    (@rastarr)


    Hi,

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

    https://www.ads-software.com/extend/plugins/wp-external-links/

Viewing 6 replies - 16 through 21 (of 21 total)
  • Pi Zi

    (@freelancephp)

    pfff…sorry still some test code…
    Now I tested it exactly the way you want to implement it. And this works on my local WP installation:

    function external_link_filter($created_link, $original_link, $label, $attrs = array()) {
    	if (isset($attrs['class']) && strpos($attrs['class'], 'gajnfads') !== false) {
    		return $original_link;
    	}
    
    	return $created_link;
    }
    add_filter('wpel_external_link', 'external_link_filter', 10, 4);
    Thread Starter Martin

    (@rastarr)

    Absolutely BRILLIANT!
    A few tweaks to the OIO-Publisher plugin and now your plugin’s enhancement has the links working perfectly.

    Thank you so much for a brilliant plugin! Rated 5 Stars

    Pi Zi

    (@freelancephp)

    Thanks Martin!

    This is the second support topic I’ve posted in for WP External Links, and the second time I’ve been really impressed by @freelancephp responses! ??

    I’ll post my problem/solution here just in case it saves someone else the 2hrs I’ve spent on this today.

    My problem:
    ==========
    WP External Links produces strange mangled output of <a> tags that contain custom HTML5 attributes.

    For example:

    <a href="https://example.com" data-referer="something.com">External Link</a>

    will get output as:

    <a class="ext-link ext-icon-6" href="https://example.com" rel="external nofollow" 0="data-referer="something.com"">External Link</a>

    I’m guessing this is because when the regex rebuilds the <a> tag, it doesn’t recognize the data-* attributes, so creates an array of them.. hence the extra 0=… 1=…. 2=…. etc.

    My solution:
    =============
    Using the new & excellent wpel_external_link() filter hook, it’s easy to exclude this links from being processed.

    However it would be perfect if the rebuilding function could account for these custom attributes and preserve them… but I don’t know the level-of-effort required for this. ??

    I have tried that code with class name “sfx” for https://www.peleke.de/galerie/flickr/?page_id=0&albid=72157633109872572 but that doesn’t seem to work.
    Can you please take a look why?
    Thanks!

    Hello!
    I tried to use the hook to exclude a class “not-external” and place this code into functions.php

    function external_link_filter($created_link, $original_link, $label, $attrs = array()) {
    	if (isset($attrs['class']) && strpos($attrs['class'], 'not-external') !== false) {
    		return $original_link;
    	}
    	return $created_link;
    }
    add_filter('wpel_external_link', 'external_link_filter', 10, 4);

    my link is a kind of
    <a href="https://fc00.deviantart.net/fs70/i/2013/220/4/2/horo_by_mrshlapa-d6h90v5.png" class="not-external"> 12313213</a>

    But is doesn’t seem to work. I don’t know what’s wrong. Please, any help

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