Skip to content

Commit 826a4e9

Browse files
committed
Walk back PHP 5.4+ changes
Given we'll probably use this to test in lower PHP versions
1 parent 958ee74 commit 826a4e9

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Download and install just like any other WordPress plugin. If you want to be rea
4848
* Refactor - Use namespaces and rename classes
4949
* Tweak - Add support for ngrok
5050
* Fix - Ensure images load for products when using an https tunnel
51+
* Misc - Require PHP 5.3+
5152

5253
### 0.8.1 - 2017.12.13
5354
* Fix - Remove WC 3.3+ "Connect to WooCommerce" notice when official plugins are active

includes/Forwarded_URLs.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Forwarded_URLs {
3535
public $non_forwarded_host;
3636

3737
/** @var array values to find and replace in URLS */
38-
private $find_replace = [];
38+
private $find_replace = array();
3939

4040

4141
/**
@@ -135,7 +135,7 @@ private function has_forwarded_host() {
135135
public function get_forwarded_host() {
136136

137137
// are we using Forward HQ?
138-
$host = $_SERVER['HTTP_X_FORWARDED_HOST'] ?? false;
138+
$host = isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : false;
139139

140140
// if not, check if we're using ngrok
141141
$host = ! $host && isset( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) ? $_SERVER['HTTP_X_ORIGINAL_HOST'] : $_SERVER['HTTP_HOST'];
@@ -161,13 +161,13 @@ public function replace_with_forwarded_url( $content ) {
161161
$forwarded_host = $this->get_forwarded_host();
162162

163163
// http, https, and protocol-less URLs
164-
$this->find_replace = [
164+
$this->find_replace = array(
165165
"http://{$non_forwarded_host}" => "http://{$forwarded_host}",
166166
"https://{$non_forwarded_host}" => "https://{$forwarded_host}",
167167
"//{$non_forwarded_host}" => "//{$forwarded_host}",
168-
];
168+
);
169169

170-
$new = is_array( $content ) ? array_walk_recursive( $content, [ $this, 'replace_url' ] ) : str_replace( array_keys( $this->find_replace ), array_values( $this->find_replace ), $content );
170+
$new = is_array( $content ) ? array_walk_recursive( $content, array( $this, 'replace_url' ) ) : str_replace( array_keys( $this->find_replace ), array_values( $this->find_replace ), $content );
171171

172172
return $new;
173173
}

0 commit comments

Comments
 (0)