This is certainly a pain on this plugin. I think the programmer abonded the ship just a bit too early here. But I have modified the code and the following code is working for multi URL’s. Hopefully the programmer will modify this, otherwise on an update you might have to do it again.
File: open-external-links-in-a-new-window.php
If you want to add multiple URL’s to force or ignore, separate them by a semicolon(;). The modified code will split and iterate the URL’s you have entered. For the rest it follows the original code of the maker of this plugin.
Replace the function external_links_in_new_window_client with this one:
// Loads the code for the website
function external_links_in_new_windows_client() {
echo "\n\n<!-- " . __("Plugin: Open external links a new window.", "open-external-links-in-a-new-window") . " " . __("Plugin by", "open-external-links-in-a-new-window") . " Kristian Risager Larsen, https://kristianrisagerlarsen.dk . " . __("Download it at", "open-external-links-in-a-new-window") . " https://www.ads-software.com/extend/plugins/open-external-links-in-a-new-window/ -->\n";
$blogdomain = parse_url(get_option('home'));
echo "<script type=\"text/javascript\">//<![CDATA[";
echo "
function external_links_in_new_windows_loop() {
if (!document.links) {
document.links = document.getElementsByTagName('a');
}
var change_link = false;
var force = '" . get_option("external_links_in_new_windows_force") . "';
var ignore = '" . get_option("external_links_in_new_windows_ignore") . "';
var force_split = force.split(';');
var ignore_split = ignore.split(';');
for (var t=0; t<document.links.length; t++) {
var all_links = document.links[t];
change_link = false;
if(document.links[t].hasAttribute('onClick') == false) {
// forced if the address starts with http (or also https), but does not link to the current domain
if(all_links.href.search(/^http/) != -1 && all_links.href.search('" . $blogdomain['host'] . "') == -1) {
// alert('Changeda '+all_links.href);
change_link = true;
}
var found_force = -1;
for (var i = 0; i < force.length; i++) {
if (all_links.href.search(trim(force_split[i])) != -1) {
found_force = 0;
}
}
var found_ignore = -1;
for (var i = 0; i < ignore.length; i++) {
if (all_links.href.search(trim(ignore_split[i])) != -1) {
found_ignore = 0;
}
}
if(force != '' && found_force != -1) {
// forced
// alert('force '+all_links.href);
change_link = true;
}
if(ignore != '' && found_ignore != -1) {
// alert('ignore '+all_links.href);
// ignored
change_link = false;
}
if(change_link == true) {
// alert('Changed '+all_links.href);
document.links[t].setAttribute('onClick', 'javascript:window.open(\\''+all_links.href+'\\'); return false;');
document.links[t].removeAttribute('target');
}
}
}
}
// Load
function external_links_in_new_windows_load(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function(){
oldonload();
func();
}
}
}
external_links_in_new_windows_load(external_links_in_new_windows_loop);
";
echo "//]]></script>\n\n";
}