Skip to content

Commit

Permalink
making work in WP 4.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
stubar committed Aug 10, 2015
1 parent 1574a1a commit 4fc63aa
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions DomainAgnostic.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

class DomainAgnostic {
static function getDomain($siteUrl) {
if ($host = $_SERVER['HTTP_X_FORWARDED_HOST'])
//takes the domain that comes from the DB ($siteUrl) and replaces the hostname with the real host.
if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $host = $_SERVER['HTTP_X_FORWARDED_HOST'])
{
$elements = explode(',', $host);

Expand All @@ -31,25 +32,15 @@ static function getDomain($siteUrl) {
// Remove port number from host
$host = preg_replace('/:\d+$/', '', $host);

$inputProtocol=(parse_url($siteUrl, PHP_URL_SCHEME));
if($inputProtocol!==null){
//$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http";
//$siteUrl = str_replace(parse_url($siteUrl, PHP_URL_SCHEME),$protocol,$siteUrl);
$siteUrl =parse_url($siteUrl, PHP_URL_PATH);
if($siteUrl="") $siteUrl="/";
}else{
$siteUrl = str_replace(explode('/',$siteUrl)[0],$host,$siteUrl);
}

$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http";

return trim($siteUrl);
return trim($protocol . '://' . $host . parse_url($siteUrl, PHP_URL_PATH));

}

}

//register_activation_hook(__FILE__,'portableDB_init');

add_filter ( 'option_siteurl', 'DomainAgnostic::getDomain' );
add_filter ( 'option_home', 'DomainAgnostic::getDomain' );
add_filter ( 'option_ossdl_off_cdn_url', 'DomainAgnostic::getDomain' );
add_filter ( 'option_ossdl_off_cdn_url', 'DomainAgnostic::getDomain' );

0 comments on commit 4fc63aa

Please sign in to comment.