Snoopy::_expandlinks()publicWP 1.0

Method of the class: Snoopy{}

No Hooks.

Return

null. Nothing (null).

Usage

$Snoopy = new Snoopy();
$Snoopy->_expandlinks( $links, $URI );
$links (required)
-
$URI (required)
-

Snoopy::_expandlinks() code WP 6.6.2

function _expandlinks($links,$URI)
{

	preg_match("/^[^\?]+/",$URI,$match);

	$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
	$match = preg_replace("|/$|","",$match);
	$match_part = parse_url($match);
	$match_root =
	$match_part["scheme"]."://".$match_part["host"];

	$search = array( 	"|^http://".preg_quote($this->host)."|i",
						"|^(\/)|i",
						"|^(?!http://)(?!mailto:)|i",
						"|/\./|",
						"|/[^\/]+/\.\./|"
					);

	$replace = array(	"",
						$match_root."/",
						$match."/",
						"/",
						"/"
					);

	$expandedLinks = preg_replace($search,$replace,$links);

	return $expandedLinks;
}