I am running Michael Wöhrer's "Link Indication" plugin and have noticed that it ignores stuff after the domain.
I.E. if I have a link that is dx.doi.org/10.1002/ao9283902, it will ignore 10.1002. It has something to do with the way the url string is filtered, but I'm not sure where in here it is:
/**
* The main function
*/
function LinkIndicationMain($content) {
/* ***************** Pattern ******************
match1 (.*?):
everything between <a and href
match2 (href=("|\')(.*?)("|\')(.*?)|):
the entire href="url", just to support anchors with missing href as well
match3 ("|\'):
double or single quoted link. We use it instead of ["\'] so that
also non quoted URLs are possible
match4 (.*?):
the URL
match5 ("|\'):
double or single quoted link
match6 (.*?):
everything between the href="..." and ">"
match7 (.*?):
text of the link
**********************************************/
$pattern = '/<a (.*?)(href=("|\')(.*?)("|\')(.*?)|)>(.*?)<\/a>/i'; // don't remove space between '<a' and '(.*?)' to avoid that plugin is not applied when abbr or acronyms are used
$result = preg_replace_callback($pattern,array(&$this,'ParseLinks'),$content);
return $result;
}
/**
* Parses the links
*/
function ParseLinks($matches){
/**********************
* If there is no href...
*********************/
if ($matches[4] == '') {
// There is no href so we return it just at is was provided;
return '<a ' . $matches[1] . '>' . $matches[7] . '</a>'; // Don't remove space in '<a ' or it will cause an error for the "more" anchor: <aid="more-123">
}
/**********************
* Prepare blog urls
*********************/
$blogurlsArray = explode(' ', $this->g_opt['mwli_blogurls']);
$loopcount = 0;
foreach ($blogurlsArray as $loopval) {
$blogurlsArrayClean[$loopcount] = $this->GetDomainnameFromUri($loopval);
$loopcount++;
}
/**********************
* Get the domain name
*********************/
$domainname_link = $this->GetDomainnameFromUri($matches[4]); // edited jg
/**********************
* Get the type of the link
*********************/
$linktype = 'internal'; // default is internal, e.g. <a href="index.php?option=com...
if (substr($matches[4], 0, 4) == 'http') $linktype = 'external-http'; // https as well...
if (substr($matches[4], 0, 3) == 'ftp') $linktype = 'external-ftp';
if (substr($matches[4], 0, 7) == 'mailto:') $linktype = 'mailto';
if ( ($linktype == 'external-http') and ( in_array($domainname_link, $blogurlsArrayClean) ) ) {
// -- the link is internal but with leading http...
$linktype = 'internal';
}
/**********************
* Check if the link is user defined or if a file extension needs to be applied
*********************/
$loopCount = 0;
foreach ($this->g_opt['mwli_searchstrings'] as $loopVar) {
if ( ($loopVar != '') ) {
// User can enter more than one value and separate them by pipe symbol '|' or comma or semicolon.
// So we need an arrray of all values and check each by looping through the array.
// By the way, explode returns an array containing the source string
// if the '|' is not contained in the string.
$loopVar = str_replace(';', '|', $loopVar);
$loopVar = str_replace(',', '|', $loopVar);
$searchstringArray = explode('|', $loopVar);
foreach ($searchstringArray as $loopSearchString) {
$loopSearchString = str_replace(' ', '', $loopSearchString); // remove all spaces
if ( $loopSearchString != '' ) {
// Finally we have a matching
if ( ($linktype == 'external-http') && ($this->g_opt['mwli_types'][$loopCount] == 'External URL') && (strpos($domainname_link, $loopSearchString) !== false) ) {
// external URL...
$linktype = 'external-userdefined';
$csssetting = $this->g_opt['mwli_cssclasses'][$loopCount];
break;
} elseif ( (substr($matches[2], -strlen($loopSearchString)) == $loopSearchString) && ($this->g_opt['mwli_types'][$loopCount] == 'File Extension') ) {
$linktype = 'filename-extension';
$csssetting = $this->g_opt['mwli_cssclasses'][$loopCount];
break;
}
}
}
}
if ( $csssetting != '' ) {
// exit loop now, no need to continue...
break;
}
$loopCount++;
}