Nginx Helper - Version 1.6

Version Description

  • Revised code for improved multisite and multidomain mapping.
Download this release

Release Info

Developer saurabhshukla
Plugin Icon 128x128 Nginx Helper
Version 1.6
Comparing to
See all releases

Code changes from version 1.5 to 1.6

Files changed (3) hide show
  1. compatibility.php +37 -32
  2. nginx-helper.php +14 -9
  3. readme.txt +5 -3
compatibility.php CHANGED
@@ -1,36 +1,41 @@
1
  <?php
 
2
  namespace rtCamp\WP\Nginx {
3
- class Compatibility {
4
- protected $have_nginx;
5
-
6
- public static function instance() {
7
- static $self = false;
8
- if (!$self) {
9
- $self = new Compatibility();
10
- }
11
-
12
- return $self;
13
- }
14
-
15
- private function __construct() {
16
- $this->have_nginx = ('nginx' == substr($_SERVER['SERVER_SOFTWARE'], 0, 5));
17
- if ($this->have_nginx) {
18
- add_filter('got_rewrite', array($this, 'got_rewrite'), 999);
19
-
20
- // For compatibility with several plugins and nginx HTTPS proxying schemes
21
- if (empty($_SERVER['HTTPS']) || 'off' == $_SERVER['HTTPS']) {
22
- unset($_SERVER['HTTPS']);
23
- }
24
- }
25
- }
26
-
27
- public function got_rewrite($got) {
28
- return true;
29
- }
30
-
31
- public function haveNginx() {
32
- return $this->have_nginx;
33
- }
34
- }
 
 
 
 
35
  }
36
  ?>
1
  <?php
2
+
3
  namespace rtCamp\WP\Nginx {
4
+
5
+ class Compatibility {
6
+
7
+ protected $have_nginx;
8
+
9
+ public static function instance() {
10
+ static $self = false;
11
+ if ( ! $self ) {
12
+ $self = new Compatibility();
13
+ }
14
+
15
+ return $self;
16
+ }
17
+
18
+ private function __construct() {
19
+ $this->have_nginx = ('nginx' == substr( $_SERVER[ 'SERVER_SOFTWARE' ], 0, 5 ));
20
+ if ( $this->have_nginx ) {
21
+ add_filter( 'got_rewrite', array( $this, 'got_rewrite' ), 999 );
22
+
23
+ // For compatibility with several plugins and nginx HTTPS proxying schemes
24
+ if ( empty( $_SERVER[ 'HTTPS' ] ) || 'off' == $_SERVER[ 'HTTPS' ] ) {
25
+ unset( $_SERVER[ 'HTTPS' ] );
26
+ }
27
+ }
28
+ }
29
+
30
+ public function got_rewrite( $got ) {
31
+ return true;
32
+ }
33
+
34
+ public function haveNginx() {
35
+ return $this->have_nginx;
36
+ }
37
+
38
+ }
39
+
40
  }
41
  ?>
nginx-helper.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Nginx Helper
4
  Plugin URI: http://rtcamp.com/
5
  Description: An nginx helper that serves various functions.
6
- Version: 1.5
7
  Author: rtCamp
8
  Author URI: http://rtcamp.com
9
  Requires at least: 3.0
@@ -212,19 +212,24 @@ namespace rtCamp\WP\Nginx {
212
 
213
 
214
  if ( $rt_all_blogs )
215
- foreach ( $rt_all_blogs as $blog )
216
  if ( SUBDOMAIN_INSTALL == "yes" )
217
- $rt_nginx_map_array[ $blog->blog_id ] .= $blog->domain;
218
- else
 
219
  if ( $blog->blog_id != 1 )
220
- $rt_nginx_map_array[ $blog->blog_id ] = $blog->path;
 
 
221
 
222
  if ( $rt_domain_map_sites )
223
  foreach ( $rt_domain_map_sites as $site )
224
- $rt_nginx_map_array[ $site->blog_id ] .= $site->domain;
 
225
 
226
- foreach ( $rt_nginx_map_array as $blog_id => $blog )
227
- $rt_nginx_map .= "\t" . $blog . "\t" . $blog_id . ";\n";
 
228
 
229
  return $rt_nginx_map;
230
  }
@@ -246,7 +251,7 @@ namespace rtCamp\WP\Nginx {
246
  return;
247
  if ( $this->options[ 'enable_stamp' ] != 1 )
248
  return;
249
- if ($_SERVER["CONTENT_TYPE"]!='text/html')
250
  return;
251
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
252
  return;
3
  Plugin Name: Nginx Helper
4
  Plugin URI: http://rtcamp.com/
5
  Description: An nginx helper that serves various functions.
6
+ Version: 1.6
7
  Author: rtCamp
8
  Author URI: http://rtcamp.com
9
  Requires at least: 3.0
212
 
213
 
214
  if ( $rt_all_blogs )
215
+ foreach ( $rt_all_blogs as $blog ){
216
  if ( SUBDOMAIN_INSTALL == "yes" )
217
+ $rt_nginx_map_array['domain'] = $blog->domain;
218
+ $rt_nginx_map_array['id'] = $blog->blog_id;
219
+ }else{
220
  if ( $blog->blog_id != 1 )
221
+ $rt_nginx_map_array['domain'] = $blog->path;
222
+ $rt_nginx_map_array['id'] = $blog->blog_id;
223
+ }
224
 
225
  if ( $rt_domain_map_sites )
226
  foreach ( $rt_domain_map_sites as $site )
227
+ $rt_nginx_map_array['domain'] = $site->domain;
228
+ $rt_nginx_map_array['id'] = $site->blog_id;
229
 
230
+
231
+ foreach ( $rt_nginx_map_array as $blog )
232
+ $rt_nginx_map .= "\t" . $blog['domain'] . "\t" . $blog['id'] . ";\n";
233
 
234
  return $rt_nginx_map;
235
  }
251
  return;
252
  if ( $this->options[ 'enable_stamp' ] != 1 )
253
  return;
254
+ if ( $_SERVER[ "CONTENT_TYPE" ] != 'text/html' )
255
  return;
256
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
257
  return;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: rtcamp, rahul286, saurabhshukla
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
4
  Requires at least: 3.0
5
  Tested up to: 3.4.2
6
- Stable tag: 1.5
7
  License: GPLv2 or later (of-course)
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate Link: http://rtcamp.com/donate/
@@ -105,6 +105,8 @@ Its just that we are hyperactive on our own forum!
105
 
106
  == Changelog ==
107
 
 
 
108
  = 1.5 =
109
  * Timestamp now only gets added to content-type text/html
110
  * Added option to toggle timestamp creation
@@ -173,5 +175,5 @@ Its just that we are hyperactive on our own forum!
173
 
174
  == Upgrade Notice ==
175
 
176
- = 1.5 =
177
- Added content-type check to show timestamp only on text/html. Added option to toggle timestamp.
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
4
  Requires at least: 3.0
5
  Tested up to: 3.4.2
6
+ Stable tag: 1.6
7
  License: GPLv2 or later (of-course)
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate Link: http://rtcamp.com/donate/
105
 
106
  == Changelog ==
107
 
108
+ = 1.6 =
109
+ * Revised code for improved multisite and multidomain mapping.
110
  = 1.5 =
111
  * Timestamp now only gets added to content-type text/html
112
  * Added option to toggle timestamp creation
175
 
176
  == Upgrade Notice ==
177
 
178
+ = 1.6 =
179
+ Improved multisite, multidomain support!