Skip to content

Commit

Permalink
Merge pull request #93 from SynergyWholesale/hotfix/add-in-missing-ge…
Browse files Browse the repository at this point in the history
…t-full-url-function

Hotfix/add in missing get full url function
  • Loading branch information
Sn0wCrack authored Jul 31, 2022
2 parents 8585bff + a5cc976 commit aa22439
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,32 @@ function synergywholesaledomains_adhocSync(array $params, $domainInfo)
];
}

/**
* Returns a full relative URL from a URL path
* This returns the URL _without_ the Base URL before it
* Example: clientarea.php -> /subwhmcs/clientarea.php or /clientarea.php depending upon the base URL
* Basically this is what WHMCS' menu items setUri function does to relative URLs
*
* @param string $uri
* @return string
*/
function synergywholesaledomains_getFullUrl(string $uri)
{
if (filter_var($uri, FILTER_VALIDATE_URL)) {
return $uri;
}

$base = \WHMCS\Utility\Environment\WebHelper::getBaseUrl();

if (empty($base) || strpos($uri, $base) !== 0) {
$uri = "${base}/{$uri}";
}

$uri = preg_replace("/\\/+/", "/", $uri);

return $uri;
}

if (
class_exists('\WHMCS\Domains\DomainLookup\SearchResult') &&
class_exists('\WHMCS\Domains\DomainLookup\ResultsList')
Expand Down

0 comments on commit aa22439

Please sign in to comment.