Hi Camu,
Thanks for your response. The problem is that our website has several authors and it will be a mess to ask them to insert code in the external links (both the ones they insert in their articles and the affiliate links they insert via some tools). The ideal solution would be that the class=”noslimstat” will be inserted automatically in all external links that open in a new tab.
We think inserting a code in functions.php forcing all external links to be opened in a new tab will be a solution, including in this code the class=”noslimstat”.
This is the code we will insert in functions.php:
function autoblank($text) {
$return = str_replace(‘href=’, ‘target=”_blank” href=’, $text);
$return = str_replace(‘target=”_blank” href=”https://ourdomain.com’, ‘href=”https://ourdomain.com’, $return);
$return = str_replace(‘target=”_blank” href=”#’, ‘href=”#’, $return);
$return = str_replace(‘ target = “_blank”>’, ‘>’, $return);
return $return;
}
add_filter(‘the_content’, ‘autoblank’);
add_filter(‘comment_text’, ‘autoblank’);
The question is, what should we add in this code to insert automatically the class=”noslimstat” in all external links?
Can you help us with this? Thank you anyway!