Skip to content

Commit

Permalink
Merge pull request #18 from swissspidy/remove-purl
Browse files Browse the repository at this point in the history
Remove jwage/purl dependency
  • Loading branch information
swalkinshaw committed Oct 22, 2018
2 parents eca6d5b + d3d2ecf commit 5333b67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 106 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
},
"require": {
"php": ">=5.4.0",
"composer/installers": "~1.0",
"jwage/purl": "^0.0.6"
"composer/installers": "~1.0"
}
}
102 changes: 4 additions & 98 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions wp-stage-switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Roots\StageSwitcher;

use Purl\Url;

/**
* Require Composer autoloader if installed on it's own
*/
Expand Down Expand Up @@ -95,11 +93,12 @@ public function admin_css() { ?>
}

private function multisite_url($url) {
$stage_url = new Url($url);
$current_site = new Url(get_home_url(get_current_blog_id()));
$current_site->host = str_replace($current_site->registerableDomain, $stage_url->registerableDomain, $current_site->host);
$stage_host = wp_parse_url($url, PHP_URL_HOST);
$current_url = get_home_url(get_current_blog_id());
$current_host = wp_parse_url($current_url, PHP_URL_HOST);
$current_url= str_replace($current_host, $stage_host, $current_url);

return rtrim($current_site->getUrl(), '/') . $_SERVER['REQUEST_URI'];
return rtrim($current_url, '/') . $_SERVER['REQUEST_URI'];
}
}

Expand Down

0 comments on commit 5333b67

Please sign in to comment.