Skip to content

Commit 0202dc2

Browse files
committed
Merge pull request #1 from Arty2/master
Directory independent.
2 parents 1a9ca3d + 118fdd7 commit 0202dc2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

wp-stage-switcher.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Plugin Name: Stage Switcher
44
Plugin URI: http://roots.io/plugins/stage-switcher/
55
Description: A WordPress plugin that allows you to switch between different environments from the admin bar.
6-
Version: 1.0.0
6+
Version: 1.0.1
77
Author: Ben Word
88
Author URI: http://roots.io/
99
License: MIT License
10+
GitHub Plugin URI: https://github.com/roots/wp-stage-switcher
1011
*/
1112

1213
namespace Roots\Bedrock;
@@ -41,12 +42,14 @@ function admin_bar_stage_switcher($admin_bar) {
4142
'href' => '#'
4243
));
4344

45+
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
46+
4447
foreach($stages as $stage => $url) {
4548
if ($stage === $current_stage) {
4649
continue;
4750
}
4851

49-
$url .= $_SERVER['REQUEST_URI'];
52+
$url .= str_replace($stages[$current_stage], '', $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
5053

5154
$admin_bar->add_menu(array(
5255
'id' => $stage,

0 commit comments

Comments
 (0)