Nginx Helper - Version 2.2.0

Version Description

  • Add filter rt_nginx_helper_fastcgi_purge_suffix to change purge suffix for FastCGI cache. #141 - by stayallive
  • Add filter rt_nginx_helper_fastcgi_purge_url_base to change purge URL base for FastCGI cache. #141 - by stayallive
  • Update our code to be in line with WordPress Coding standards in various places. #209, #225 - by abhijitrakas, chandrapatel
  • Check and verify purging is enabled before purging cache. #168 - by jaredwsmith
  • Hide Purge Cache button in admin bar when purge is disabled. #218, #219 - by mbautista, chandrapatel
  • Don't add Nginx Timestamp on WordPress login page. #204, #220 - by peixotorms, chandrapatel
Download this release

Release Info

Developer rtcamp
Plugin Icon 128x128 Nginx Helper
Version 2.2.0
Comparing to
See all releases

Code changes from version 2.1.0 to 2.2.0

admin/class-fastcgi-purger.php CHANGED
@@ -51,7 +51,7 @@ class FastCGI_Purger extends Purger {
51
  $_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . $parse['path'];
52
  $_url_purge = $_url_purge_base;
53
 
54
- if ( isset( $parse['query'] ) && $parse['query'] !== '' ) {
55
  $_url_purge .= '?' . $parse['query'];
56
  }
57
 
@@ -70,7 +70,7 @@ class FastCGI_Purger extends Purger {
70
  case 'get_request':
71
  // Go to default case.
72
  default:
73
- $_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . '/purge' . $parse['path'];
74
  $_url_purge = $_url_purge_base;
75
 
76
  if ( isset( $parse['query'] ) && '' !== $parse['query'] ) {
@@ -100,7 +100,7 @@ class FastCGI_Purger extends Purger {
100
 
101
  global $nginx_helper_admin;
102
 
103
- $parse = wp_parse_url( site_url() );
104
 
105
  $purge_urls = isset( $nginx_helper_admin->options['purge_url'] ) && ! empty( $nginx_helper_admin->options['purge_url'] ) ?
106
  explode( "\r\n", $nginx_helper_admin->options['purge_url'] ) : array();
@@ -131,16 +131,14 @@ class FastCGI_Purger extends Purger {
131
  $this->delete_cache_file_for( $purge_url );
132
 
133
  }
134
-
135
  }
136
-
137
  }
138
  break;
139
 
140
  case 'get_request':
141
  // Go to default case.
142
  default:
143
- $_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . '/purge';
144
 
145
  if ( is_array( $purge_urls ) && ! empty( $purge_urls ) ) {
146
 
@@ -155,9 +153,7 @@ class FastCGI_Purger extends Purger {
155
  $this->do_remote_get( $purge_url );
156
 
157
  }
158
-
159
  }
160
-
161
  }
162
  break;
163
 
@@ -183,4 +179,43 @@ class FastCGI_Purger extends Purger {
183
  do_action( 'rt_nginx_helper_after_fastcgi_purge_all' );
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  }
51
  $_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . $parse['path'];
52
  $_url_purge = $_url_purge_base;
53
 
54
+ if ( ! empty( $parse['query'] ) ) {
55
  $_url_purge .= '?' . $parse['query'];
56
  }
57
 
70
  case 'get_request':
71
  // Go to default case.
72
  default:
73
+ $_url_purge_base = $this->purge_base_url() . $parse['path'];
74
  $_url_purge = $_url_purge_base;
75
 
76
  if ( isset( $parse['query'] ) && '' !== $parse['query'] ) {
100
 
101
  global $nginx_helper_admin;
102
 
103
+ $parse = wp_parse_url( home_url() );
104
 
105
  $purge_urls = isset( $nginx_helper_admin->options['purge_url'] ) && ! empty( $nginx_helper_admin->options['purge_url'] ) ?
106
  explode( "\r\n", $nginx_helper_admin->options['purge_url'] ) : array();
131
  $this->delete_cache_file_for( $purge_url );
132
 
133
  }
 
134
  }
 
135
  }
136
  break;
137
 
138
  case 'get_request':
139
  // Go to default case.
140
  default:
141
+ $_url_purge_base = $this->purge_base_url();
142
 
143
  if ( is_array( $purge_urls ) && ! empty( $purge_urls ) ) {
144
 
153
  $this->do_remote_get( $purge_url );
154
 
155
  }
 
156
  }
 
157
  }
158
  break;
159
 
179
  do_action( 'rt_nginx_helper_after_fastcgi_purge_all' );
180
  }
181
 
182
+ /**
183
+ * Constructs the base url to call when purging using the "get_request" method.
184
+ *
185
+ * @since 2.2.0
186
+ *
187
+ * @return string
188
+ */
189
+ private function purge_base_url() {
190
+
191
+ $parse = wp_parse_url( home_url() );
192
+
193
+ /**
194
+ * Filter to change purge suffix for FastCGI cache.
195
+ *
196
+ * @param string $suffix Purge suffix. Default is purge.
197
+ *
198
+ * @since 2.2.0
199
+ */
200
+ $path = apply_filters( 'rt_nginx_helper_fastcgi_purge_suffix', 'purge' );
201
+
202
+ // Prevent users from inserting a trailing '/' that could break the url purging.
203
+ $path = trim( $path, '/' );
204
+
205
+ $purge_url_base = $parse['scheme'] . '://' . $parse['host'] . '/' . $path;
206
+
207
+ /**
208
+ * Filter to change purge URL base for FastCGI cache.
209
+ *
210
+ * @param string $purge_url_base Purge URL base.
211
+ *
212
+ * @since 2.2.0
213
+ */
214
+ $purge_url_base = apply_filters( 'rt_nginx_helper_fastcgi_purge_url_base', $purge_url_base );
215
+
216
+ // Prevent users from inserting a trailing '/' that could break the url purging.
217
+ return untrailingslashit( $purge_url_base );
218
+
219
+ }
220
+
221
  }
admin/class-nginx-helper-admin.php CHANGED
@@ -79,10 +79,11 @@ class Nginx_Helper_Admin {
79
  $this->version = $version;
80
 
81
  /**
82
- * Define settings tabs
83
- */
84
  $this->settings_tabs = apply_filters(
85
- 'rt_nginx_helper_settings_tabs', array(
 
86
  'general' => array(
87
  'menu_title' => __( 'General', 'nginx-helper' ),
88
  'menu_slug' => 'general',
@@ -155,6 +156,11 @@ class Nginx_Helper_Admin {
155
 
156
  wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/nginx-helper-admin.js', array( 'jquery' ), $this->version, false );
157
 
 
 
 
 
 
158
  }
159
 
160
  /**
@@ -209,7 +215,7 @@ class Nginx_Helper_Admin {
209
  $link_title = __( 'Purge Current Page', 'nginx-helper' );
210
  }
211
 
212
- $purge_url = add_query_arg(
213
  array(
214
  'nginx_helper_action' => 'purge',
215
  'nginx_helper_urls' => $nginx_helper_urls,
@@ -237,7 +243,7 @@ class Nginx_Helper_Admin {
237
  * @since 2.0.0
238
  */
239
  public function nginx_helper_setting_page() {
240
- include plugin_dir_path(__FILE__ ) . 'partials/nginx-helper-admin-display.php';
241
  }
242
 
243
  /**
@@ -282,7 +288,14 @@ class Nginx_Helper_Admin {
282
  */
283
  public function nginx_helper_settings() {
284
 
285
- $options = get_site_option( 'rt_wp_nginx_helper_options', array( 'redis_hostname' => '127.0.0.1', 'redis_port' => '6379', 'redis_prefix' => 'nginx-cache:' ) );
 
 
 
 
 
 
 
286
 
287
  $data = wp_parse_args(
288
  $options,
@@ -396,18 +409,16 @@ class Nginx_Helper_Admin {
396
  ?>
397
  <li role="listitem">
398
  <?php
399
- echo wp_kses(
400
- sprintf(
401
- '<a href="%1$s" title="%2$s">%3$s</a>',
402
- esc_url( $item->get_permalink() ), esc_attr__( 'Posted ', 'nginx-helper' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ), esc_html( $item->get_title() )
403
- ),
404
- array( 'strong' => array(), 'a' => array( 'href' => array(), 'title' => array() ) )
405
- );
406
  ?>
407
  </li>
408
  <?php
409
  }
410
-
411
  }
412
  ?>
413
  </ul>
@@ -421,13 +432,19 @@ class Nginx_Helper_Admin {
421
  */
422
  public function add_timestamps() {
423
 
424
- if ( is_admin() || (int) $this->options['enable_purge'] !== 1 || (int) $this->options['enable_stamp'] !== 1 ) {
 
 
 
 
 
 
425
  return;
426
  }
427
 
428
  foreach ( headers_list() as $header ) {
429
  list( $key, $value ) = explode( ':', $header, 2 );
430
- $key = strtolower( $key );
431
  if ( 'content-type' === $key && strpos( trim( $value ), 'text/html' ) !== 0 ) {
432
  return;
433
  }
@@ -480,7 +497,7 @@ class Nginx_Helper_Admin {
480
 
481
  $rt_all_blogs = $wpdb->get_results(
482
  $wpdb->prepare(
483
- 'SELECT blog_id, domain, path FROM ' . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'",
484
  $wpdb->siteid
485
  )
486
  );
@@ -507,11 +524,8 @@ class Nginx_Helper_Admin {
507
  if ( 1 !== $blog->blog_id ) {
508
  $rt_nginx_map_array[ $blog->path ] = $blog->blog_id;
509
  }
510
-
511
  }
512
-
513
  }
514
-
515
  }
516
 
517
  if ( $rt_domain_map_sites ) {
@@ -519,7 +533,6 @@ class Nginx_Helper_Admin {
519
  foreach ( $rt_domain_map_sites as $site ) {
520
  $rt_nginx_map_array[ $site->domain ] = $site->blog_id;
521
  }
522
-
523
  }
524
 
525
  foreach ( $rt_nginx_map_array as $domain => $domain_id ) {
@@ -541,11 +554,11 @@ class Nginx_Helper_Admin {
541
 
542
  $rt_nginx_map = $this->get_map();
543
 
544
- if ( $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' ) ) {
 
545
  fwrite( $fp, $rt_nginx_map );
546
  fclose( $fp );
547
  }
548
-
549
  }
550
 
551
  }
@@ -580,11 +593,11 @@ class Nginx_Helper_Admin {
580
  if (
581
  'future' === $new_status && $post && 'future' === $post->post_status &&
582
  (
583
- ( 'post' === $post->post_type || 'page' === $post->post_type ) ||
584
- (
585
- isset( $this->options['custom_post_types_recognized'] ) &&
586
- in_array( $post->post_type, $this->options['custom_post_types_recognized'], true )
587
- )
588
  )
589
  ) {
590
 
79
  $this->version = $version;
80
 
81
  /**
82
+ * Define settings tabs
83
+ */
84
  $this->settings_tabs = apply_filters(
85
+ 'rt_nginx_helper_settings_tabs',
86
+ array(
87
  'general' => array(
88
  'menu_title' => __( 'General', 'nginx-helper' ),
89
  'menu_slug' => 'general',
156
 
157
  wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/nginx-helper-admin.js', array( 'jquery' ), $this->version, false );
158
 
159
+ $do_localize = array(
160
+ 'purge_confirm_string' => esc_html__( 'Purging entire cache is not recommended. Would you like to continue?', 'nginx-helper' ),
161
+ );
162
+ wp_localize_script( $this->plugin_name, 'nginx_helper', $do_localize );
163
+
164
  }
165
 
166
  /**
215
  $link_title = __( 'Purge Current Page', 'nginx-helper' );
216
  }
217
 
218
+ $purge_url = add_query_arg(
219
  array(
220
  'nginx_helper_action' => 'purge',
221
  'nginx_helper_urls' => $nginx_helper_urls,
243
  * @since 2.0.0
244
  */
245
  public function nginx_helper_setting_page() {
246
+ include plugin_dir_path( __FILE__ ) . 'partials/nginx-helper-admin-display.php';
247
  }
248
 
249
  /**
288
  */
289
  public function nginx_helper_settings() {
290
 
291
+ $options = get_site_option(
292
+ 'rt_wp_nginx_helper_options',
293
+ array(
294
+ 'redis_hostname' => '127.0.0.1',
295
+ 'redis_port' => '6379',
296
+ 'redis_prefix' => 'nginx-cache:',
297
+ )
298
+ );
299
 
300
  $data = wp_parse_args(
301
  $options,
409
  ?>
410
  <li role="listitem">
411
  <?php
412
+ printf(
413
+ '<a href="%s" title="%s">%s</a>',
414
+ esc_url( $item->get_permalink() ),
415
+ esc_attr__( 'Posted ', 'nginx-helper' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ),
416
+ esc_html( $item->get_title() )
417
+ );
 
418
  ?>
419
  </li>
420
  <?php
421
  }
 
422
  }
423
  ?>
424
  </ul>
432
  */
433
  public function add_timestamps() {
434
 
435
+ global $pagenow;
436
+
437
+ if ( is_admin() || 1 !== (int) $this->options['enable_purge'] || 1 !== (int) $this->options['enable_stamp'] ) {
438
+ return;
439
+ }
440
+
441
+ if ( ! empty( $pagenow ) && 'wp-login.php' === $pagenow ) {
442
  return;
443
  }
444
 
445
  foreach ( headers_list() as $header ) {
446
  list( $key, $value ) = explode( ':', $header, 2 );
447
+ $key = strtolower( $key );
448
  if ( 'content-type' === $key && strpos( trim( $value ), 'text/html' ) !== 0 ) {
449
  return;
450
  }
497
 
498
  $rt_all_blogs = $wpdb->get_results(
499
  $wpdb->prepare(
500
+ 'SELECT blog_id, domain, path FROM ' . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'",
501
  $wpdb->siteid
502
  )
503
  );
524
  if ( 1 !== $blog->blog_id ) {
525
  $rt_nginx_map_array[ $blog->path ] = $blog->blog_id;
526
  }
 
527
  }
 
528
  }
 
529
  }
530
 
531
  if ( $rt_domain_map_sites ) {
533
  foreach ( $rt_domain_map_sites as $site ) {
534
  $rt_nginx_map_array[ $site->domain ] = $site->blog_id;
535
  }
 
536
  }
537
 
538
  foreach ( $rt_nginx_map_array as $domain => $domain_id ) {
554
 
555
  $rt_nginx_map = $this->get_map();
556
 
557
+ $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' );
558
+ if ( $fp ) {
559
  fwrite( $fp, $rt_nginx_map );
560
  fclose( $fp );
561
  }
 
562
  }
563
 
564
  }
593
  if (
594
  'future' === $new_status && $post && 'future' === $post->post_status &&
595
  (
596
+ ( 'post' === $post->post_type || 'page' === $post->post_type ) ||
597
+ (
598
+ isset( $this->options['custom_post_types_recognized'] ) &&
599
+ in_array( $post->post_type, $this->options['custom_post_types_recognized'], true )
600
+ )
601
  )
602
  ) {
603
 
admin/class-phpredis-purger.php CHANGED
@@ -147,7 +147,6 @@ class PhpRedis_Purger extends Purger {
147
  } else {
148
  $this->log( '- Cache Not Found | ' . $_url_purge_base, 'ERROR' );
149
  }
150
-
151
  } else {
152
 
153
  $status = $this->delete_keys_by_wildcard( $_url_purge_base );
@@ -157,7 +156,6 @@ class PhpRedis_Purger extends Purger {
157
  } else {
158
  $this->log( '- Cache Not Found | ' . $_url_purge_base, 'ERROR' );
159
  }
160
-
161
  }
162
 
163
  $this->log( '* * * * *' );
@@ -171,7 +169,7 @@ class PhpRedis_Purger extends Purger {
171
 
172
  global $nginx_helper_admin;
173
 
174
- $parse = wp_parse_url( site_url() );
175
  $prefix = $nginx_helper_admin->options['redis_prefix'];
176
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'];
177
 
@@ -202,7 +200,6 @@ class PhpRedis_Purger extends Purger {
202
  } else {
203
  $this->log( '- Cache Not Found | ' . $purge_url, 'ERROR' );
204
  }
205
-
206
  } else {
207
 
208
  $purge_url = $_url_purge_base . $purge_url;
@@ -213,11 +210,8 @@ class PhpRedis_Purger extends Purger {
213
  } else {
214
  $this->log( '- Cache Not Found | ' . $purge_url, 'ERROR' );
215
  }
216
-
217
  }
218
-
219
  }
220
-
221
  }
222
 
223
  }
147
  } else {
148
  $this->log( '- Cache Not Found | ' . $_url_purge_base, 'ERROR' );
149
  }
 
150
  } else {
151
 
152
  $status = $this->delete_keys_by_wildcard( $_url_purge_base );
156
  } else {
157
  $this->log( '- Cache Not Found | ' . $_url_purge_base, 'ERROR' );
158
  }
 
159
  }
160
 
161
  $this->log( '* * * * *' );
169
 
170
  global $nginx_helper_admin;
171
 
172
+ $parse = wp_parse_url( home_url() );
173
  $prefix = $nginx_helper_admin->options['redis_prefix'];
174
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'];
175
 
200
  } else {
201
  $this->log( '- Cache Not Found | ' . $purge_url, 'ERROR' );
202
  }
 
203
  } else {
204
 
205
  $purge_url = $_url_purge_base . $purge_url;
210
  } else {
211
  $this->log( '- Cache Not Found | ' . $purge_url, 'ERROR' );
212
  }
 
213
  }
 
214
  }
 
215
  }
216
 
217
  }
admin/class-predis-purger.php CHANGED
@@ -73,7 +73,7 @@ class Predis_Purger extends Purger {
73
 
74
  } else { // Else purge only site specific cache.
75
 
76
- $parse = wp_parse_url( get_home_url() );
77
  $parse['path'] = empty( $parse['path'] ) ? '/' : $parse['path'];
78
  $this->delete_keys_by_wildcard( $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'] . '*' );
79
  $this->log( '* ' . get_home_url() . ' Purged! * ' );
@@ -146,7 +146,6 @@ class Predis_Purger extends Purger {
146
  } else {
147
  $this->log( '- Cache Not Found | ' . $_url_purge_base, 'ERROR' );
148
  }
149
-
150
  } else {
151
 
152
  $status = $this->delete_keys_by_wildcard( $_url_purge_base );
@@ -156,7 +155,6 @@ class Predis_Purger extends Purger {
156
  } else {
157
  $this->log( '- Cache Not Found | ' . $_url_purge_base, 'ERROR' );
158
  }
159
-
160
  }
161
 
162
  }
@@ -168,7 +166,7 @@ class Predis_Purger extends Purger {
168
 
169
  global $nginx_helper_admin;
170
 
171
- $parse = wp_parse_url( site_url() );
172
  $prefix = $nginx_helper_admin->options['redis_prefix'];
173
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'];
174
 
@@ -198,7 +196,6 @@ class Predis_Purger extends Purger {
198
  } else {
199
  $this->log( '- Not Found | ' . $purge_url, 'ERROR' );
200
  }
201
-
202
  } else {
203
 
204
  $purge_url = $_url_purge_base . $purge_url;
@@ -209,11 +206,8 @@ class Predis_Purger extends Purger {
209
  } else {
210
  $this->log( '- Not Found | ' . $purge_url, 'ERROR' );
211
  }
212
-
213
  }
214
-
215
  }
216
-
217
  }
218
 
219
  }
73
 
74
  } else { // Else purge only site specific cache.
75
 
76
+ $parse = wp_parse_url( get_home_url() );
77
  $parse['path'] = empty( $parse['path'] ) ? '/' : $parse['path'];
78
  $this->delete_keys_by_wildcard( $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'] . '*' );
79
  $this->log( '* ' . get_home_url() . ' Purged! * ' );
146
  } else {
147
  $this->log( '- Cache Not Found | ' . $_url_purge_base, 'ERROR' );
148
  }
 
149
  } else {
150
 
151
  $status = $this->delete_keys_by_wildcard( $_url_purge_base );
155
  } else {
156
  $this->log( '- Cache Not Found | ' . $_url_purge_base, 'ERROR' );
157
  }
 
158
  }
159
 
160
  }
166
 
167
  global $nginx_helper_admin;
168
 
169
+ $parse = wp_parse_url( home_url() );
170
  $prefix = $nginx_helper_admin->options['redis_prefix'];
171
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'];
172
 
196
  } else {
197
  $this->log( '- Not Found | ' . $purge_url, 'ERROR' );
198
  }
 
199
  } else {
200
 
201
  $purge_url = $_url_purge_base . $purge_url;
206
  } else {
207
  $this->log( '- Not Found | ' . $purge_url, 'ERROR' );
208
  }
 
209
  }
 
210
  }
 
211
  }
212
 
213
  }
admin/class-purger.php CHANGED
@@ -51,15 +51,15 @@ abstract class Purger {
51
  $oldstatus = '';
52
  $approved = $comment->comment_approved;
53
 
54
- if ( $approved === null ) {
55
  $newstatus = false;
56
- } elseif ( $approved === '1' ) {
57
  $newstatus = 'approved';
58
- } elseif ( $approved === '0' ) {
59
  $newstatus = 'unapproved';
60
- } elseif ( $approved === 'spam' ) {
61
  $newstatus = 'spam';
62
- } elseif ( $approved === 'trash' ) {
63
  $newstatus = 'trash';
64
  } else {
65
  $newstatus = false;
@@ -96,7 +96,7 @@ abstract class Purger {
96
  switch ( $newstatus ) {
97
 
98
  case 'approved':
99
- if ( 1 === (int)$nginx_helper_admin->options['purge_page_on_new_comment'] ) {
100
 
101
  $this->log( '* Comment ( ' . $_comment_id . ' ) approved. Post ( ' . $_post_id . ' ) purging...' );
102
  $this->log( '* * * * *' );
@@ -108,7 +108,7 @@ abstract class Purger {
108
  case 'spam':
109
  case 'unapproved':
110
  case 'trash':
111
- if ( 'approved' === $oldstatus && 1 === (int)$nginx_helper_admin->options['purge_page_on_deleted_comment'] ) {
112
 
113
  $this->log( '* Comment ( ' . $_comment_id . ' ) removed as ( ' . $newstatus . ' ). Post ( ' . $_post_id . ' ) purging...' );
114
  $this->log( '* * * * *' );
@@ -124,9 +124,9 @@ abstract class Purger {
124
  /**
125
  * Purge post cache.
126
  *
127
- * @param int $_ID Post id.
128
  */
129
- public function purge_post( $_ID ) {
130
 
131
  global $nginx_helper_admin, $blog_id;
132
 
@@ -139,16 +139,16 @@ abstract class Purger {
139
  case 'publish_post':
140
  $this->log( '* * * * *' );
141
  $this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
142
- $this->log( '* Post :: ' . get_the_title( $_ID ) . ' ( ' . $_ID . ' ).' );
143
- $this->log( '* Post ( ' . $_ID . ' ) published or edited and its status is published' );
144
  $this->log( '* * * * *' );
145
  break;
146
 
147
  case 'publish_page':
148
  $this->log( '* * * * *' );
149
  $this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
150
- $this->log( '* Page :: ' . get_the_title( $_ID ) . ' ( ' . $_ID . ' ).' );
151
- $this->log( '* Page ( ' . $_ID . ' ) published or edited and its status is published' );
152
  $this->log( '* * * * *' );
153
  break;
154
 
@@ -157,11 +157,11 @@ abstract class Purger {
157
  break;
158
 
159
  default:
160
- $_post_type = get_post_type( $_ID );
161
  $this->log( '* * * * *' );
162
  $this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
163
- $this->log( "* Custom post type '" . $_post_type . "' :: " . get_the_title( $_ID ) . ' ( ' . $_ID . ' ).' );
164
- $this->log( "* CPT '" . $_post_type . "' ( " . $_ID . ' ) published or edited and its status is published' );
165
  $this->log( '* * * * *' );
166
  break;
167
 
@@ -176,13 +176,21 @@ abstract class Purger {
176
  if ( 'comment_post' === current_filter() || 'wp_set_comment_status' === current_filter() ) {
177
 
178
  $this->_purge_by_options(
179
- $_ID, $blog_id, $nginx_helper_admin->options['purge_page_on_new_comment'], $nginx_helper_admin->options['purge_archive_on_new_comment'], $nginx_helper_admin->options['purge_archive_on_new_comment']
 
 
 
 
180
  );
181
 
182
  } else {
183
 
184
  $this->_purge_by_options(
185
- $_ID, $blog_id, $nginx_helper_admin->options['purge_page_on_mod'], $nginx_helper_admin->options['purge_archive_on_edit'], $nginx_helper_admin->options['purge_archive_on_edit']
 
 
 
 
186
  );
187
 
188
  }
@@ -228,7 +236,6 @@ abstract class Purger {
228
  } else {
229
  $url = '';
230
  }
231
-
232
  } else {
233
  $url = get_permalink( $post_id );
234
  }
@@ -275,11 +282,8 @@ abstract class Purger {
275
  if ( $day ) {
276
  $this->purge_url( get_day_link( $year, $month, $day ) );
277
  }
278
-
279
  }
280
-
281
  }
282
-
283
  }
284
 
285
  $categories = wp_get_post_categories( $post_id );
@@ -294,7 +298,6 @@ abstract class Purger {
294
  $this->purge_url( get_category_link( $category_id ) );
295
 
296
  }
297
-
298
  }
299
 
300
  $tags = get_the_tags( $post_id );
@@ -309,7 +312,6 @@ abstract class Purger {
309
  $this->purge_url( get_tag_link( $tag->term_id ) );
310
 
311
  }
312
-
313
  }
314
 
315
  $author_id = get_post( $post_id )->post_author;
@@ -320,7 +322,6 @@ abstract class Purger {
320
  $this->purge_url( get_author_posts_url( $author_id ) );
321
 
322
  }
323
-
324
  }
325
 
326
  if ( $_purge_custom_taxa ) {
@@ -347,9 +348,7 @@ abstract class Purger {
347
  foreach ( $terms as $term ) {
348
  $this->purge_url( get_term_link( $term, $taxon ) );
349
  }
350
-
351
  }
352
-
353
  } else {
354
  $this->log( "Your built-in taxonomy '" . $taxon . "' has param '_builtin' set to false.", 'WARNING' );
355
  }
@@ -480,7 +479,6 @@ abstract class Purger {
480
  $this->log( '- - ' . $url . ' not found ( ' . $response['response']['code'] . ' )', 'WARNING' );
481
 
482
  }
483
-
484
  }
485
 
486
  /**
@@ -539,13 +537,13 @@ abstract class Purger {
539
 
540
  if ( $log_levels[ $level ] >= $log_levels[ $nginx_helper_admin->options['log_level'] ] ) {
541
 
542
- if ( $fp = fopen( $nginx_helper_admin->functional_asset_path() . 'nginx.log', 'a+' ) ) {
 
543
 
544
  fwrite( $fp, "\n" . gmdate( 'Y-m-d H:i:s ' ) . ' | ' . $level . ' | ' . $msg );
545
  fclose( $fp );
546
 
547
  }
548
-
549
  }
550
 
551
  return true;
@@ -565,21 +563,22 @@ abstract class Purger {
565
 
566
  $nginx_asset_path = $nginx_helper_admin->functional_asset_path() . 'nginx.log';
567
 
568
- if ( ! file_exists($nginx_asset_path) ) {
569
  return;
570
  }
571
 
572
  $max_size_allowed = ( is_numeric( $nginx_helper_admin->options['log_filesize'] ) ) ? $nginx_helper_admin->options['log_filesize'] * 1048576 : 5242880;
573
 
574
- $fileSize = filesize( $nginx_asset_path );
575
 
576
- if ( $fileSize > $max_size_allowed ) {
577
 
578
- $offset = $fileSize - $max_size_allowed;
579
  $file_content = file_get_contents( $nginx_asset_path, null, null, $offset );
580
  $file_content = empty( $file_content ) ? '' : strstr( $file_content, "\n" );
581
 
582
- if ( $file_content && $fp = fopen( $nginx_asset_path, 'w+' ) ) {
 
583
 
584
  fwrite( $fp, $file_content );
585
  fclose( $fp );
@@ -594,6 +593,13 @@ abstract class Purger {
594
  */
595
  public function purge_image_on_edit( $attachment_id ) {
596
 
 
 
 
 
 
 
 
597
  $this->log( 'Purging media on edit BEGIN ===' );
598
 
599
  if ( wp_attachment_is_image( $attachment_id ) ) {
@@ -610,9 +616,7 @@ abstract class Purger {
610
  if ( $resize_image ) {
611
  $this->purge_url( $resize_image[0], false );
612
  }
613
-
614
  }
615
-
616
  }
617
 
618
  $this->purge_url( get_attachment_link( $attachment_id ) );
@@ -710,7 +714,6 @@ abstract class Purger {
710
  foreach ( $nginx_helper_admin->options['purgeable_url']['urls'] as $url ) {
711
  $this->purge_url( $url, false );
712
  }
713
-
714
  } else {
715
  $this->log( '- ' . __( 'No personal urls available', 'nginx-helper' ) );
716
  }
@@ -736,11 +739,11 @@ abstract class Purger {
736
 
737
  foreach ( $categories as $category_id ) {
738
 
 
739
  $this->log( sprintf( __( "Purging category '%d'", 'nginx-helper' ), $category_id ) );
740
  $this->purge_url( get_category_link( $category_id ) );
741
 
742
  }
743
-
744
  }
745
 
746
  return true;
@@ -767,7 +770,6 @@ abstract class Purger {
767
  $this->purge_url( get_tag_link( $tag->term_id ) );
768
 
769
  }
770
-
771
  }
772
 
773
  return true;
@@ -796,6 +798,7 @@ abstract class Purger {
796
 
797
  foreach ( $custom_taxonomies as $taxon ) {
798
 
 
799
  $this->log( sprintf( '+ ' . __( "Purging custom taxonomy '%s'", 'nginx-helper' ), $taxon ) );
800
 
801
  if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ), true ) ) {
@@ -807,14 +810,12 @@ abstract class Purger {
807
  foreach ( $terms as $term ) {
808
  $this->purge_url( get_term_link( $term, $taxon ) );
809
  }
810
-
811
  }
812
-
813
  } else {
 
814
  $this->log( sprintf( '- ' . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", 'nginx-helper' ), $taxon ), 'WARNING' );
815
  }
816
  }
817
-
818
  } else {
819
  $this->log( '- ' . __( 'No custom taxonomies', 'nginx-helper' ) );
820
  }
@@ -841,7 +842,6 @@ abstract class Purger {
841
  $this->purge_url( get_category_link( $c->term_id ) );
842
 
843
  }
844
-
845
  } else {
846
 
847
  $this->log( __( 'No categories archives', 'nginx-helper' ) );
@@ -870,7 +870,6 @@ abstract class Purger {
870
  $this->purge_url( get_tag_link( $t->term_id ) );
871
 
872
  }
873
-
874
  } else {
875
  $this->log( __( 'No tags archives', 'nginx-helper' ) );
876
  }
@@ -899,6 +898,7 @@ abstract class Purger {
899
 
900
  foreach ( $custom_taxonomies as $taxon ) {
901
 
 
902
  $this->log( sprintf( '+ ' . __( "Purging custom taxonomy '%s'", 'nginx-helper' ), $taxon ) );
903
 
904
  if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ), true ) ) {
@@ -912,15 +912,12 @@ abstract class Purger {
912
  $this->purge_url( get_term_link( $term, $taxon ) );
913
 
914
  }
915
-
916
  }
917
-
918
  } else {
919
- $this->log( sprintf( '- ' . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", 'nginx-helper' ), $taxon ), 'WARNING' );
 
920
  }
921
-
922
  }
923
-
924
  } else {
925
  $this->log( '- ' . __( 'No custom taxonomies', 'nginx-helper' ) );
926
  }
@@ -957,7 +954,7 @@ abstract class Purger {
957
  'post_status' => 'publish',
958
  );
959
 
960
- $get_posts = new WP_Query;
961
  $_posts = $get_posts->query( $args );
962
 
963
  if ( ! empty( $_posts ) ) {
@@ -968,7 +965,6 @@ abstract class Purger {
968
  $this->purge_url( get_permalink( $p->ID ) );
969
 
970
  }
971
-
972
  } else {
973
  $this->log( '- ' . __( 'No posts', 'nginx-helper' ) );
974
  }
@@ -1005,11 +1001,15 @@ abstract class Purger {
1005
 
1006
  $_query_daily_archives = $wpdb->prepare(
1007
  "SELECT YEAR(post_date) AS %s, MONTH(post_date) AS %s, DAYOFMONTH(post_date) AS %s, count(ID) as posts
1008
- FROM $wpdb->posts
1009
- WHERE post_type = %s AND post_status = %s
1010
- GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date)
1011
- ORDER BY post_date DESC",
1012
- 'year', 'month', 'dayofmonth', 'post', 'publish'
 
 
 
 
1013
  );
1014
 
1015
  $_daily_archives = $wpdb->get_results( $_query_daily_archives ); // phpcs:ignore
@@ -1020,14 +1020,16 @@ abstract class Purger {
1020
 
1021
  $this->log(
1022
  sprintf(
1023
- '+ ' . __( "Purging daily archive '%1\$s/%2\$s/%3\$s'", 'nginx-helper' ), $_da->year, $_da->month, $_da->dayofmonth
 
 
 
1024
  )
1025
  );
1026
 
1027
  $this->purge_url( get_day_link( $_da->year, $_da->month, $_da->dayofmonth ) );
1028
 
1029
  }
1030
-
1031
  } else {
1032
  $this->log( '- ' . __( 'No daily archives', 'nginx-helper' ) );
1033
  }
@@ -1049,20 +1051,22 @@ abstract class Purger {
1049
 
1050
  $_query_monthly_archives = $wpdb->prepare(
1051
  "SELECT YEAR(post_date) AS %s, MONTH(post_date) AS %s, count(ID) as posts
1052
- FROM $wpdb->posts
1053
- WHERE post_type = %s AND post_status = %s
1054
- GROUP BY YEAR(post_date), MONTH(post_date)
1055
- ORDER BY post_date DESC",
1056
- 'year', 'month', 'post', 'publish'
 
 
 
1057
  );
1058
 
1059
  $_monthly_archives = $wpdb->get_results( $_query_monthly_archives ); // phpcs:ignore
1060
 
1061
- wp_cache_set( 'nginx_helper_monthly_archives', $_monthly_archives, 'nginx_helper', 24*60*60 );
1062
 
1063
  }
1064
 
1065
-
1066
  if ( ! empty( $_monthly_archives ) ) {
1067
 
1068
  foreach ( $_monthly_archives as $_ma ) {
@@ -1071,7 +1075,6 @@ abstract class Purger {
1071
  $this->purge_url( get_month_link( $_ma->year, $_ma->month ) );
1072
 
1073
  }
1074
-
1075
  } else {
1076
  $this->log( '- ' . __( 'No monthly archives', 'nginx-helper' ) );
1077
  }
@@ -1093,16 +1096,18 @@ abstract class Purger {
1093
 
1094
  $_query_yearly_archives = $wpdb->prepare(
1095
  "SELECT YEAR(post_date) AS %s, count(ID) as posts
1096
- FROM $wpdb->posts
1097
- WHERE post_type = %s AND post_status = %s
1098
- GROUP BY YEAR(post_date)
1099
- ORDER BY post_date DESC",
1100
- 'year', 'post', 'publish'
 
 
1101
  );
1102
 
1103
  $_yearly_archives = $wpdb->get_results( $_query_yearly_archives ); // phpcs:ignore
1104
 
1105
- wp_cache_set( 'nginx_helper_yearly_archives', $_yearly_archives, 'nginx_helper', 24*60*60 );
1106
 
1107
  }
1108
 
@@ -1110,11 +1115,11 @@ abstract class Purger {
1110
 
1111
  foreach ( $_yearly_archives as $_ya ) {
1112
 
1113
- $this->log( sprintf( '+ ' . __( "Purging yearly archive '%s'", 'nginx-helper' ), $_ya->year ) );
 
1114
  $this->purge_url( get_year_link( $_ya->year ) );
1115
 
1116
  }
1117
-
1118
  } else {
1119
  $this->log( '- ' . __( 'No yearly archives', 'nginx-helper' ) );
1120
  }
@@ -1151,6 +1156,12 @@ abstract class Purger {
1151
  */
1152
  public function purge_on_term_taxonomy_edited( $term_id, $tt_id, $taxon ) {
1153
 
 
 
 
 
 
 
1154
  $this->log( __( 'Term taxonomy edited or deleted', 'nginx-helper' ) );
1155
 
1156
  $term = get_term( $term_id, $taxon );
@@ -1181,6 +1192,12 @@ abstract class Purger {
1181
  */
1182
  public function purge_on_check_ajax_referer( $action ) {
1183
 
 
 
 
 
 
 
1184
  switch ( $action ) {
1185
 
1186
  case 'save-sidebar-widgets':
@@ -1202,38 +1219,40 @@ abstract class Purger {
1202
  * Source - http://stackoverflow.com/a/1360437/156336
1203
  *
1204
  * @param string $dir Directory.
1205
- * @param bool $deleteRootToo Delete root or not.
 
 
1206
  */
1207
- public function unlink_recursive( $dir, $deleteRootToo ) {
1208
 
1209
  if ( ! is_dir( $dir ) ) {
1210
  return;
1211
  }
1212
 
1213
- if ( ! $dh = opendir( $dir ) ) {
 
 
1214
  return;
1215
  }
1216
 
1217
- while ( false !== ( $obj = readdir( $dh ) ) ) {
 
 
1218
 
1219
- if ( $obj == '.' || $obj == '..' ) {
1220
  continue;
1221
  }
1222
 
1223
- if ( ! @unlink( $dir . '/' . $obj ) ) {
1224
  $this->unlink_recursive( $dir . '/' . $obj, false );
1225
  }
1226
-
1227
  }
1228
 
1229
- if ( $deleteRootToo ) {
1230
  rmdir( $dir );
1231
  }
1232
 
1233
  closedir( $dh );
1234
-
1235
- return;
1236
-
1237
  }
1238
 
1239
  }
51
  $oldstatus = '';
52
  $approved = $comment->comment_approved;
53
 
54
+ if ( null === $approved ) {
55
  $newstatus = false;
56
+ } elseif ( '1' === $approved ) {
57
  $newstatus = 'approved';
58
+ } elseif ( '0' === $approved ) {
59
  $newstatus = 'unapproved';
60
+ } elseif ( 'spam' === $approved ) {
61
  $newstatus = 'spam';
62
+ } elseif ( 'trash' === $approved ) {
63
  $newstatus = 'trash';
64
  } else {
65
  $newstatus = false;
96
  switch ( $newstatus ) {
97
 
98
  case 'approved':
99
+ if ( 1 === (int) $nginx_helper_admin->options['purge_page_on_new_comment'] ) {
100
 
101
  $this->log( '* Comment ( ' . $_comment_id . ' ) approved. Post ( ' . $_post_id . ' ) purging...' );
102
  $this->log( '* * * * *' );
108
  case 'spam':
109
  case 'unapproved':
110
  case 'trash':
111
+ if ( 'approved' === $oldstatus && 1 === (int) $nginx_helper_admin->options['purge_page_on_deleted_comment'] ) {
112
 
113
  $this->log( '* Comment ( ' . $_comment_id . ' ) removed as ( ' . $newstatus . ' ). Post ( ' . $_post_id . ' ) purging...' );
114
  $this->log( '* * * * *' );
124
  /**
125
  * Purge post cache.
126
  *
127
+ * @param int $post_id Post id.
128
  */
129
+ public function purge_post( $post_id ) {
130
 
131
  global $nginx_helper_admin, $blog_id;
132
 
139
  case 'publish_post':
140
  $this->log( '* * * * *' );
141
  $this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
142
+ $this->log( '* Post :: ' . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
143
+ $this->log( '* Post ( ' . $post_id . ' ) published or edited and its status is published' );
144
  $this->log( '* * * * *' );
145
  break;
146
 
147
  case 'publish_page':
148
  $this->log( '* * * * *' );
149
  $this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
150
+ $this->log( '* Page :: ' . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
151
+ $this->log( '* Page ( ' . $post_id . ' ) published or edited and its status is published' );
152
  $this->log( '* * * * *' );
153
  break;
154
 
157
  break;
158
 
159
  default:
160
+ $_post_type = get_post_type( $post_id );
161
  $this->log( '* * * * *' );
162
  $this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
163
+ $this->log( "* Custom post type '" . $_post_type . "' :: " . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
164
+ $this->log( "* CPT '" . $_post_type . "' ( " . $post_id . ' ) published or edited and its status is published' );
165
  $this->log( '* * * * *' );
166
  break;
167
 
176
  if ( 'comment_post' === current_filter() || 'wp_set_comment_status' === current_filter() ) {
177
 
178
  $this->_purge_by_options(
179
+ $post_id,
180
+ $blog_id,
181
+ $nginx_helper_admin->options['purge_page_on_new_comment'],
182
+ $nginx_helper_admin->options['purge_archive_on_new_comment'],
183
+ $nginx_helper_admin->options['purge_archive_on_new_comment']
184
  );
185
 
186
  } else {
187
 
188
  $this->_purge_by_options(
189
+ $post_id,
190
+ $blog_id,
191
+ $nginx_helper_admin->options['purge_page_on_mod'],
192
+ $nginx_helper_admin->options['purge_archive_on_edit'],
193
+ $nginx_helper_admin->options['purge_archive_on_edit']
194
  );
195
 
196
  }
236
  } else {
237
  $url = '';
238
  }
 
239
  } else {
240
  $url = get_permalink( $post_id );
241
  }
282
  if ( $day ) {
283
  $this->purge_url( get_day_link( $year, $month, $day ) );
284
  }
 
285
  }
 
286
  }
 
287
  }
288
 
289
  $categories = wp_get_post_categories( $post_id );
298
  $this->purge_url( get_category_link( $category_id ) );
299
 
300
  }
 
301
  }
302
 
303
  $tags = get_the_tags( $post_id );
312
  $this->purge_url( get_tag_link( $tag->term_id ) );
313
 
314
  }
 
315
  }
316
 
317
  $author_id = get_post( $post_id )->post_author;
322
  $this->purge_url( get_author_posts_url( $author_id ) );
323
 
324
  }
 
325
  }
326
 
327
  if ( $_purge_custom_taxa ) {
348
  foreach ( $terms as $term ) {
349
  $this->purge_url( get_term_link( $term, $taxon ) );
350
  }
 
351
  }
 
352
  } else {
353
  $this->log( "Your built-in taxonomy '" . $taxon . "' has param '_builtin' set to false.", 'WARNING' );
354
  }
479
  $this->log( '- - ' . $url . ' not found ( ' . $response['response']['code'] . ' )', 'WARNING' );
480
 
481
  }
 
482
  }
483
 
484
  /**
537
 
538
  if ( $log_levels[ $level ] >= $log_levels[ $nginx_helper_admin->options['log_level'] ] ) {
539
 
540
+ $fp = fopen( $nginx_helper_admin->functional_asset_path() . 'nginx.log', 'a+' );
541
+ if ( $fp ) {
542
 
543
  fwrite( $fp, "\n" . gmdate( 'Y-m-d H:i:s ' ) . ' | ' . $level . ' | ' . $msg );
544
  fclose( $fp );
545
 
546
  }
 
547
  }
548
 
549
  return true;
563
 
564
  $nginx_asset_path = $nginx_helper_admin->functional_asset_path() . 'nginx.log';
565
 
566
+ if ( ! file_exists( $nginx_asset_path ) ) {
567
  return;
568
  }
569
 
570
  $max_size_allowed = ( is_numeric( $nginx_helper_admin->options['log_filesize'] ) ) ? $nginx_helper_admin->options['log_filesize'] * 1048576 : 5242880;
571
 
572
+ $file_size = filesize( $nginx_asset_path );
573
 
574
+ if ( $file_size > $max_size_allowed ) {
575
 
576
+ $offset = $file_size - $max_size_allowed;
577
  $file_content = file_get_contents( $nginx_asset_path, null, null, $offset );
578
  $file_content = empty( $file_content ) ? '' : strstr( $file_content, "\n" );
579
 
580
+ $fp = fopen( $nginx_asset_path, 'w+' );
581
+ if ( $file_content && $fp ) {
582
 
583
  fwrite( $fp, $file_content );
584
  fclose( $fp );
593
  */
594
  public function purge_image_on_edit( $attachment_id ) {
595
 
596
+ global $nginx_helper_admin;
597
+
598
+ // Do not purge if not enabled.
599
+ if ( ! $nginx_helper_admin->options['enable_purge'] ) {
600
+ return;
601
+ }
602
+
603
  $this->log( 'Purging media on edit BEGIN ===' );
604
 
605
  if ( wp_attachment_is_image( $attachment_id ) ) {
616
  if ( $resize_image ) {
617
  $this->purge_url( $resize_image[0], false );
618
  }
 
619
  }
 
620
  }
621
 
622
  $this->purge_url( get_attachment_link( $attachment_id ) );
714
  foreach ( $nginx_helper_admin->options['purgeable_url']['urls'] as $url ) {
715
  $this->purge_url( $url, false );
716
  }
 
717
  } else {
718
  $this->log( '- ' . __( 'No personal urls available', 'nginx-helper' ) );
719
  }
739
 
740
  foreach ( $categories as $category_id ) {
741
 
742
+ // translators: %d: Category ID.
743
  $this->log( sprintf( __( "Purging category '%d'", 'nginx-helper' ), $category_id ) );
744
  $this->purge_url( get_category_link( $category_id ) );
745
 
746
  }
 
747
  }
748
 
749
  return true;
770
  $this->purge_url( get_tag_link( $tag->term_id ) );
771
 
772
  }
 
773
  }
774
 
775
  return true;
798
 
799
  foreach ( $custom_taxonomies as $taxon ) {
800
 
801
+ // translators: %s: Post taxonomy name.
802
  $this->log( sprintf( '+ ' . __( "Purging custom taxonomy '%s'", 'nginx-helper' ), $taxon ) );
803
 
804
  if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ), true ) ) {
810
  foreach ( $terms as $term ) {
811
  $this->purge_url( get_term_link( $term, $taxon ) );
812
  }
 
813
  }
 
814
  } else {
815
+ // translators: %s: Post taxonomy name.
816
  $this->log( sprintf( '- ' . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", 'nginx-helper' ), $taxon ), 'WARNING' );
817
  }
818
  }
 
819
  } else {
820
  $this->log( '- ' . __( 'No custom taxonomies', 'nginx-helper' ) );
821
  }
842
  $this->purge_url( get_category_link( $c->term_id ) );
843
 
844
  }
 
845
  } else {
846
 
847
  $this->log( __( 'No categories archives', 'nginx-helper' ) );
870
  $this->purge_url( get_tag_link( $t->term_id ) );
871
 
872
  }
 
873
  } else {
874
  $this->log( __( 'No tags archives', 'nginx-helper' ) );
875
  }
898
 
899
  foreach ( $custom_taxonomies as $taxon ) {
900
 
901
+ // translators: %s: Taxonomy name.
902
  $this->log( sprintf( '+ ' . __( "Purging custom taxonomy '%s'", 'nginx-helper' ), $taxon ) );
903
 
904
  if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ), true ) ) {
912
  $this->purge_url( get_term_link( $term, $taxon ) );
913
 
914
  }
 
915
  }
 
916
  } else {
917
+ // translators: %s: Taxonomy name.
918
+ $this->log( sprintf( '- ' . esc_html__( "Your built-in taxonomy '%s' has param '_builtin' set to false.", 'nginx-helper' ), $taxon ), 'WARNING' );
919
  }
 
920
  }
 
921
  } else {
922
  $this->log( '- ' . __( 'No custom taxonomies', 'nginx-helper' ) );
923
  }
954
  'post_status' => 'publish',
955
  );
956
 
957
+ $get_posts = new WP_Query();
958
  $_posts = $get_posts->query( $args );
959
 
960
  if ( ! empty( $_posts ) ) {
965
  $this->purge_url( get_permalink( $p->ID ) );
966
 
967
  }
 
968
  } else {
969
  $this->log( '- ' . __( 'No posts', 'nginx-helper' ) );
970
  }
1001
 
1002
  $_query_daily_archives = $wpdb->prepare(
1003
  "SELECT YEAR(post_date) AS %s, MONTH(post_date) AS %s, DAYOFMONTH(post_date) AS %s, count(ID) as posts
1004
+ FROM $wpdb->posts
1005
+ WHERE post_type = %s AND post_status = %s
1006
+ GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date)
1007
+ ORDER BY post_date DESC",
1008
+ 'year',
1009
+ 'month',
1010
+ 'dayofmonth',
1011
+ 'post',
1012
+ 'publish'
1013
  );
1014
 
1015
  $_daily_archives = $wpdb->get_results( $_query_daily_archives ); // phpcs:ignore
1020
 
1021
  $this->log(
1022
  sprintf(
1023
+ '+ ' . __( "Purging daily archive '%1\$s/%2\$s/%3\$s'", 'nginx-helper' ),
1024
+ $_da->year,
1025
+ $_da->month,
1026
+ $_da->dayofmonth
1027
  )
1028
  );
1029
 
1030
  $this->purge_url( get_day_link( $_da->year, $_da->month, $_da->dayofmonth ) );
1031
 
1032
  }
 
1033
  } else {
1034
  $this->log( '- ' . __( 'No daily archives', 'nginx-helper' ) );
1035
  }
1051
 
1052
  $_query_monthly_archives = $wpdb->prepare(
1053
  "SELECT YEAR(post_date) AS %s, MONTH(post_date) AS %s, count(ID) as posts
1054
+ FROM $wpdb->posts
1055
+ WHERE post_type = %s AND post_status = %s
1056
+ GROUP BY YEAR(post_date), MONTH(post_date)
1057
+ ORDER BY post_date DESC",
1058
+ 'year',
1059
+ 'month',
1060
+ 'post',
1061
+ 'publish'
1062
  );
1063
 
1064
  $_monthly_archives = $wpdb->get_results( $_query_monthly_archives ); // phpcs:ignore
1065
 
1066
+ wp_cache_set( 'nginx_helper_monthly_archives', $_monthly_archives, 'nginx_helper', 24 * 60 * 60 );
1067
 
1068
  }
1069
 
 
1070
  if ( ! empty( $_monthly_archives ) ) {
1071
 
1072
  foreach ( $_monthly_archives as $_ma ) {
1075
  $this->purge_url( get_month_link( $_ma->year, $_ma->month ) );
1076
 
1077
  }
 
1078
  } else {
1079
  $this->log( '- ' . __( 'No monthly archives', 'nginx-helper' ) );
1080
  }
1096
 
1097
  $_query_yearly_archives = $wpdb->prepare(
1098
  "SELECT YEAR(post_date) AS %s, count(ID) as posts
1099
+ FROM $wpdb->posts
1100
+ WHERE post_type = %s AND post_status = %s
1101
+ GROUP BY YEAR(post_date)
1102
+ ORDER BY post_date DESC",
1103
+ 'year',
1104
+ 'post',
1105
+ 'publish'
1106
  );
1107
 
1108
  $_yearly_archives = $wpdb->get_results( $_query_yearly_archives ); // phpcs:ignore
1109
 
1110
+ wp_cache_set( 'nginx_helper_yearly_archives', $_yearly_archives, 'nginx_helper', 24 * 60 * 60 );
1111
 
1112
  }
1113
 
1115
 
1116
  foreach ( $_yearly_archives as $_ya ) {
1117
 
1118
+ // translators: %s: Year to purge cache.
1119
+ $this->log( sprintf( '+ ' . esc_html__( "Purging yearly archive '%s'", 'nginx-helper' ), $_ya->year ) );
1120
  $this->purge_url( get_year_link( $_ya->year ) );
1121
 
1122
  }
 
1123
  } else {
1124
  $this->log( '- ' . __( 'No yearly archives', 'nginx-helper' ) );
1125
  }
1156
  */
1157
  public function purge_on_term_taxonomy_edited( $term_id, $tt_id, $taxon ) {
1158
 
1159
+ global $nginx_helper_admin;
1160
+
1161
+ if ( ! $nginx_helper_admin->options['enable_purge'] ) {
1162
+ return;
1163
+ }
1164
+
1165
  $this->log( __( 'Term taxonomy edited or deleted', 'nginx-helper' ) );
1166
 
1167
  $term = get_term( $term_id, $taxon );
1192
  */
1193
  public function purge_on_check_ajax_referer( $action ) {
1194
 
1195
+ global $nginx_helper_admin;
1196
+
1197
+ if ( ! $nginx_helper_admin->options['enable_purge'] ) {
1198
+ return;
1199
+ }
1200
+
1201
  switch ( $action ) {
1202
 
1203
  case 'save-sidebar-widgets':
1219
  * Source - http://stackoverflow.com/a/1360437/156336
1220
  *
1221
  * @param string $dir Directory.
1222
+ * @param bool $delete_root_too Delete root or not.
1223
+ *
1224
+ * @return void
1225
  */
1226
+ public function unlink_recursive( $dir, $delete_root_too ) {
1227
 
1228
  if ( ! is_dir( $dir ) ) {
1229
  return;
1230
  }
1231
 
1232
+ $dh = opendir( $dir );
1233
+
1234
+ if ( ! $dh ) {
1235
  return;
1236
  }
1237
 
1238
+ $obj = readdir( $dh );
1239
+
1240
+ while ( false !== $obj ) {
1241
 
1242
+ if ( '.' === $obj || '..' === $obj ) {
1243
  continue;
1244
  }
1245
 
1246
+ if ( ! @unlink( $dir . '/' . $obj ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
1247
  $this->unlink_recursive( $dir . '/' . $obj, false );
1248
  }
 
1249
  }
1250
 
1251
+ if ( $delete_root_too ) {
1252
  rmdir( $dir );
1253
  }
1254
 
1255
  closedir( $dh );
 
 
 
1256
  }
1257
 
1258
  }
admin/css/nginx-helper-admin.css CHANGED
@@ -4,101 +4,97 @@
4
  */
5
 
6
  .clearfix {
7
- *zoom: 1;
8
  }
9
  .clearfix:before,
10
  .clearfix:after {
11
- content: " ";
12
- display: table;
13
  }
14
  .clearfix:after {
15
- clear: both;
16
  }
17
  h4 {
18
- margin: 0;
19
  }
20
  .form-table th,
21
  .form-wrap label {
22
- vertical-align: middle;
23
  }
24
  table.rtnginx-table {
25
- border-bottom: 1px solid #EEE;
26
  }
27
  table.rtnginx-table:last-child {
28
- border-bottom: 0;
29
  }
30
  .rtnginx-table p.error {
31
- color: red;
32
  }
33
  pre#map {
34
- background: #e5e5e5 none;
35
- border-radius: 10px;
36
- padding: 10px;
37
  }
38
  .wrap h2.rt_option_title {
39
- background: url(../icons/nginx-icon-32x32.png) 0 6px no-repeat rgba(0, 0, 0, 0);
40
- padding-left: 40px;
41
  }
42
  #poststuff h2 {
43
- padding: 0 0 0 10px;
44
- margin-top: 0;
45
  }
46
  form#purgeall .button-primary {
47
- margin-bottom: 20px;
48
- box-shadow: inset 0 -2px rgba(0, 0, 0, 0.14);
49
- padding: 15px 30px;
50
- font-size: 1rem;
51
- border: 0;
52
- border-radius: 5px;
53
- color: #FFF;
54
- background: #DD3D36;
55
- height: auto;
56
  }
57
  form#purgeall .button-primary:hover,
58
  form#purgeall .button-primary:focus {
59
- background: #d52c24;
60
  }
61
  .nh-aligncenter {
62
- display: block;
63
- text-align: center;
64
- line-height: 2;
65
  }
66
  #latest_news .inside ul,
67
  #useful-links .inside ul {
68
- margin: 0 0 0 12px;
69
  }
70
  #latest_news .inside ul li,
71
  #useful-links .inside ul li {
72
- list-style: square;
73
- padding: 0 0 7px;
74
  }
75
  #social .inside a {
76
- background-color: #666;
77
- color: #FFF;
78
- display: inline-block;
79
- height: 30px;
80
- font-size: 1.25rem;
81
- line-height: 30px;
82
- margin: 10px 20px 0 0;
83
- overflow: hidden;
84
- padding: 0;
85
- text-align: center;
86
- text-decoration: none;
87
- width: 30px;
88
- -webkit-border-radius: 1000px;
89
- -moz-border-radius: 1000px;
90
- border-radius: 1000px;
91
- }
92
- #social .inside .nginx-helper-rss:hover {
93
- background-color: #FAA33D;
94
  }
 
95
  #social .inside .nginx-helper-facebook:hover {
96
- background-color: #537BBD;
97
  }
98
  #social .inside .nginx-helper-twitter:hover {
99
- background-color: #40BFF5;
100
- }
101
- #social .inside .nginx-helper-gplus:hover {
102
- background-color: #DD4B39;
103
  }
104
- .rt-purge_url { width: 100%; }
 
4
  */
5
 
6
  .clearfix {
7
+ *zoom: 1;
8
  }
9
  .clearfix:before,
10
  .clearfix:after {
11
+ content: " ";
12
+ display: table;
13
  }
14
  .clearfix:after {
15
+ clear: both;
16
  }
17
  h4 {
18
+ margin: 0;
19
  }
20
  .form-table th,
21
  .form-wrap label {
22
+ vertical-align: middle;
23
  }
24
  table.rtnginx-table {
25
+ border-bottom: 1px solid #EEE;
26
  }
27
  table.rtnginx-table:last-child {
28
+ border-bottom: 0;
29
  }
30
  .rtnginx-table p.error {
31
+ color: red;
32
  }
33
  pre#map {
34
+ background: #e5e5e5 none;
35
+ border-radius: 10px;
36
+ padding: 10px;
37
  }
38
  .wrap h2.rt_option_title {
39
+ background: url(../icons/nginx-icon-32x32.png) 0 6px no-repeat rgba(0, 0, 0, 0);
40
+ padding-left: 40px;
41
  }
42
  #poststuff h2 {
43
+ padding: 0 0 0 10px;
44
+ margin-top: 0;
45
  }
46
  form#purgeall .button-primary {
47
+ margin-bottom: 20px;
48
+ box-shadow: inset 0 -2px rgba(0, 0, 0, 0.14);
49
+ padding: 15px 30px;
50
+ font-size: 1rem;
51
+ border: 0;
52
+ border-radius: 5px;
53
+ color: #FFF;
54
+ background: #DD3D36;
55
+ height: auto;
56
  }
57
  form#purgeall .button-primary:hover,
58
  form#purgeall .button-primary:focus {
59
+ background: #d52c24;
60
  }
61
  .nh-aligncenter {
62
+ display: block;
63
+ text-align: center;
64
+ line-height: 2;
65
  }
66
  #latest_news .inside ul,
67
  #useful-links .inside ul {
68
+ margin: 0 0 0 12px;
69
  }
70
  #latest_news .inside ul li,
71
  #useful-links .inside ul li {
72
+ list-style: square;
73
+ padding: 0 0 7px;
74
  }
75
  #social .inside a {
76
+ background-color: #666;
77
+ color: #FFF;
78
+ display: inline-block;
79
+ height: 30px;
80
+ font-size: 1.25rem;
81
+ line-height: 30px;
82
+ margin: 10px 20px 0 0;
83
+ overflow: hidden;
84
+ padding: 0;
85
+ text-align: center;
86
+ text-decoration: none;
87
+ width: 30px;
88
+ -webkit-border-radius: 1000px;
89
+ -moz-border-radius: 1000px;
90
+ border-radius: 1000px;
 
 
 
91
  }
92
+
93
  #social .inside .nginx-helper-facebook:hover {
94
+ background-color: #537BBD;
95
  }
96
  #social .inside .nginx-helper-twitter:hover {
97
+ background-color: #40BFF5;
 
 
 
98
  }
99
+
100
+ .rt-purge_url { width: 100%; }
admin/icons/css/nginx-fontello.css CHANGED
@@ -1,56 +1,54 @@
1
  @font-face {
2
- font-family: 'nginx-fontello';
3
- src: url('../font/nginx-fontello.eot?7388141');
4
- src: url('../font/nginx-fontello.eot?7388141#iefix') format('embedded-opentype'),
5
- url('../font/nginx-fontello.woff?7388141') format('woff'),
6
- url('../font/nginx-fontello.ttf?7388141') format('truetype'),
7
- url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
8
- font-weight: normal;
9
- font-style: normal;
10
  }
11
  /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
12
  /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
13
- /*
14
  @media screen and (-webkit-min-device-pixel-ratio:0) {
15
- @font-face {
16
- font-family: 'nginx-fontello';
17
- src: url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
18
- }
19
  }
20
  */
21
-
22
- [class^="nginx-helper-"]:before, [class*=" nginx-helper-"]:before {
23
- font-family: "nginx-fontello";
24
- font-style: normal;
25
- font-weight: normal;
26
- speak: none;
27
-
28
- display: inline-block;
29
- text-decoration: inherit;
30
- width: 1em;
31
- margin-right: .2em;
32
- text-align: center;
33
- /* opacity: .8; */
34
-
35
- /* For safety - reset parent styles, that can break glyph codes*/
36
- font-variant: normal;
37
- text-transform: none;
38
-
39
- /* fix buttons height, for twitter bootstrap */
40
- line-height: 1em;
41
-
42
- /* Animation center compensation - margins should be symmetric */
43
- /* remove if not needed */
44
- margin-left: .2em;
45
-
46
- /* you can be more comfortable with increased icons size */
47
- /* font-size: 120%; */
48
-
49
- /* Uncomment for 3D effect */
50
- /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
51
  }
52
-
53
- .nginx-helper-rss:before { content: '\e803'; } /* '' */
54
  .nginx-helper-twitter:before { content: '\e802'; } /* '' */
55
  .nginx-helper-facebook:before { content: '\e801'; } /* '' */
56
- .nginx-helper-gplus:before { content: '\e800'; } /* '' */
1
  @font-face {
2
+ font-family: 'nginx-fontello';
3
+ src: url('../font/nginx-fontello.eot?7388141');
4
+ src: url('../font/nginx-fontello.eot?7388141#iefix') format('embedded-opentype'),
5
+ url('../font/nginx-fontello.woff?7388141') format('woff'),
6
+ url('../font/nginx-fontello.ttf?7388141') format('truetype'),
7
+ url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
8
+ font-weight: normal;
9
+ font-style: normal;
10
  }
11
  /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
12
  /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
13
+ /* // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
14
  @media screen and (-webkit-min-device-pixel-ratio:0) {
15
+ @font-face {
16
+ font-family: 'nginx-fontello';
17
+ src: url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
18
+ }
19
  }
20
  */
21
+
22
+ [class^="nginx-helper-"]:before, [class*=" nginx-helper-"]:before {
23
+ font-family: "nginx-fontello";
24
+ font-style: normal;
25
+ font-weight: normal;
26
+ speak: none;
27
+
28
+ display: inline-block;
29
+ text-decoration: inherit;
30
+ width: 1em;
31
+ margin-right: .2em;
32
+ text-align: center;
33
+ /* opacity: .8; */
34
+
35
+ /* For safety - reset parent styles, that can break glyph codes*/
36
+ font-variant: normal;
37
+ text-transform: none;
38
+
39
+ /* fix buttons height, for twitter bootstrap */
40
+ line-height: 1em;
41
+
42
+ /* Animation center compensation - margins should be symmetric */
43
+ /* remove if not needed */
44
+ margin-left: .2em;
45
+
46
+ /* you can be more comfortable with increased icons size */
47
+ /* font-size: 120%; */
48
+
49
+ /* Uncomment for 3D effect */
50
+ /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
51
  }
52
+
 
53
  .nginx-helper-twitter:before { content: '\e802'; } /* '' */
54
  .nginx-helper-facebook:before { content: '\e801'; } /* '' */
 
admin/js/nginx-helper-admin.js CHANGED
@@ -1,92 +1,117 @@
 
 
 
 
 
 
1
  (function ($) {
2
- 'use strict';
3
-
4
- /**
5
- * All of the code for your admin-specific JavaScript source
6
- * should reside in this file.
7
- *
8
- * Note that this assume you're going to use jQuery, so it prepares
9
- * the $ function reference to be used within the scope of this
10
- * function.
11
- *
12
- * From here, you're able to define handlers for when the DOM is
13
- * ready:
14
- *
15
- * $(function() {
16
- *
17
- * });
18
- *
19
- * Or when the window is loaded:
20
- *
21
- * $( window ).load(function() {
22
- *
23
- * });
24
- *
25
- * ...and so on.
26
- *
27
- * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
28
- * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
29
- * be doing this, we should try to minimize doing that in our own work.
30
- */
31
- $(function () {
32
-
33
- var news_section = jQuery( '#latest_news' );
34
-
35
- if ( news_section.length > 0 ) {
36
-
37
- var args = {
38
- 'action': 'rt_get_feeds'
39
- };
40
-
41
- jQuery.get( ajaxurl, args, function (data) {
42
- news_section.find( '.inside' ).html( data );
43
- console.log(data);
44
- });
45
-
46
- }
47
-
48
- jQuery( "form#purgeall a" ).click( function (e) {
49
-
50
- if ( confirm( "Purging entire cache is not recommended. Would you like to continue ?" ) == true ) {
51
- // continue submitting form
52
- } else {
53
- e.preventDefault();
54
- }
55
-
56
- });
57
-
58
- /**
59
- * Show OR Hide options on option checkbox
60
- * @param {type} selector Selector of Checkbox and PostBox
61
- */
62
- function nginx_show_option( selector ) {
63
-
64
- jQuery( '#' + selector ).on( 'change', function () {
65
-
66
- if ( jQuery( this ).is( ':checked' ) ) {
67
-
68
- jQuery( '.' + selector ).show();
69
-
70
- if ( selector == "cache_method_redis" ) {
71
- jQuery( '.cache_method_fastcgi' ).hide();
72
- } else if ( selector == "cache_method_fastcgi" ) {
73
- jQuery( '.cache_method_redis' ).hide();
74
- }
75
-
76
- } else {
77
- jQuery( '.' + selector ).hide();
78
- }
79
-
80
- });
81
-
82
- }
83
-
84
- /* Function call with parameter */
85
- nginx_show_option( 'cache_method_fastcgi' );
86
- nginx_show_option( 'cache_method_redis' );
87
- nginx_show_option( 'enable_map' );
88
- nginx_show_option( 'enable_log' );
89
- nginx_show_option( 'enable_purge' );
90
-
91
- });
92
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * File to add JavaScript for nginx-helper.
3
+ *
4
+ * @package nginx-helper
5
+ */
6
+
7
  (function ($) {
8
+ 'use strict';
9
+
10
+ /**
11
+ * All of the code for your admin-specific JavaScript source
12
+ * should reside in this file.
13
+ *
14
+ * Note that this assume you're going to use jQuery, so it prepares
15
+ * the $ function reference to be used within the scope of this
16
+ * function.
17
+ *
18
+ * From here, you're able to define handlers for when the DOM is
19
+ * ready:
20
+ *
21
+ * $(function() {
22
+ *
23
+ * });
24
+ *
25
+ * Or when the window is loaded:
26
+ *
27
+ * $( window ).load(function() {
28
+ *
29
+ * });
30
+ *
31
+ * ...and so on.
32
+ *
33
+ * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
34
+ * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
35
+ * be doing this, we should try to minimize doing that in our own work.
36
+ */
37
+ $(
38
+ function () {
39
+
40
+ var news_section = jQuery( '#latest_news' );
41
+
42
+ if ( news_section.length > 0 ) {
43
+
44
+ var args = {
45
+ 'action': 'rt_get_feeds'
46
+ };
47
+
48
+ jQuery.get(
49
+ ajaxurl,
50
+ args,
51
+ function( data ) {
52
+ /**
53
+ * Received markup is safe and escaped appropriately.
54
+ *
55
+ * File: admin/class-nginx-helper-admin.php
56
+ * Method: nginx_helper_get_feeds();
57
+ */
58
+
59
+ // phpcs:ignore -- WordPressVIPMinimum.JS.HTMLExecutingFunctions.append
60
+ news_section.find( '.inside' ).empty().append( data );
61
+ }
62
+ );
63
+
64
+ }
65
+
66
+ jQuery( "form#purgeall a" ).click(
67
+ function (e) {
68
+
69
+ if ( confirm( nginx_helper.purge_confirm_string ) === true ) {
70
+ // Continue submitting form.
71
+ } else {
72
+ e.preventDefault();
73
+ }
74
+
75
+ }
76
+ );
77
+
78
+ /**
79
+ * Show OR Hide options on option checkbox
80
+ *
81
+ * @param {type} selector Selector of Checkbox and PostBox
82
+ */
83
+ function nginx_show_option( selector ) {
84
+
85
+ jQuery( '#' + selector ).on(
86
+ 'change',
87
+ function () {
88
+
89
+ if ( jQuery( this ).is( ':checked' ) ) {
90
+
91
+ jQuery( '.' + selector ).show();
92
+
93
+ if ( 'cache_method_redis' === selector ) {
94
+ jQuery( '.cache_method_fastcgi' ).hide();
95
+ } else if ( selector === 'cache_method_fastcgi' ) {
96
+ jQuery( '.cache_method_redis' ).hide();
97
+ }
98
+
99
+ } else {
100
+ jQuery( '.' + selector ).hide();
101
+ }
102
+
103
+ }
104
+ );
105
+
106
+ }
107
+
108
+ /* Function call with parameter */
109
+ nginx_show_option( 'cache_method_fastcgi' );
110
+ nginx_show_option( 'cache_method_redis' );
111
+ nginx_show_option( 'enable_map' );
112
+ nginx_show_option( 'enable_log' );
113
+ nginx_show_option( 'enable_purge' );
114
+
115
+ }
116
+ );
117
+ })( jQuery );
admin/partials/nginx-helper-admin-display.php CHANGED
@@ -25,19 +25,18 @@ global $pagenow;
25
  <div id="post-body-content">
26
  <?php
27
  /* Show settinhs tabs */
28
- $current_tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_STRING );
29
  $current_setting_tab = ( ! empty( $current_tab ) ) ? $current_tab : 'general';
30
 
31
  echo '<h2 class="nav-tab-wrapper">';
32
  foreach ( $this->settings_tabs as $setting_tab => $setting_name ) {
33
 
34
  $class = ( $setting_tab === $current_setting_tab ) ? ' nav-tab-active' : '';
35
- echo wp_kses(
36
- sprintf(
37
- '<a class="nav-tab%1$s" href="?page=nginx&tab=%2$s">%3$s</a>',
38
- esc_attr( $class ), esc_attr( $setting_name['menu_slug'] ), esc_html( $setting_name['menu_title'] )
39
- ),
40
- array( 'a' => array( 'href' => array(), 'class' => array(), ) )
41
  );
42
  }
43
  echo '</h2>';
@@ -45,10 +44,10 @@ global $pagenow;
45
  switch ( $current_setting_tab ) {
46
 
47
  case 'general':
48
- include plugin_dir_path(__FILE__ ) . 'nginx-helper-general-options.php';
49
  break;
50
  case 'support':
51
- include plugin_dir_path(__FILE__ ) . 'nginx-helper-support-options.php';
52
  break;
53
 
54
  }
@@ -56,7 +55,7 @@ global $pagenow;
56
  </div> <!-- End of #post-body-content -->
57
  <div id="postbox-container-1" class="postbox-container">
58
  <?php
59
- require plugin_dir_path(__FILE__ ) . 'nginx-helper-sidebar-display.php';
60
  ?>
61
  </div> <!-- End of #postbox-container-1 -->
62
  </div> <!-- End of #post-body -->
25
  <div id="post-body-content">
26
  <?php
27
  /* Show settinhs tabs */
28
+ $current_tab = filter_input( INPUT_GET, 'tab', FILTER_SANITIZE_STRING );
29
  $current_setting_tab = ( ! empty( $current_tab ) ) ? $current_tab : 'general';
30
 
31
  echo '<h2 class="nav-tab-wrapper">';
32
  foreach ( $this->settings_tabs as $setting_tab => $setting_name ) {
33
 
34
  $class = ( $setting_tab === $current_setting_tab ) ? ' nav-tab-active' : '';
35
+ printf(
36
+ '<a class="%s" href="%s">%s</a>',
37
+ esc_attr( 'nav-tab' . $class ),
38
+ esc_url( '?page=nginx&tab=' . $setting_name['menu_slug'] ),
39
+ esc_html( $setting_name['menu_title'] )
 
40
  );
41
  }
42
  echo '</h2>';
44
  switch ( $current_setting_tab ) {
45
 
46
  case 'general':
47
+ include plugin_dir_path( __FILE__ ) . 'nginx-helper-general-options.php';
48
  break;
49
  case 'support':
50
+ include plugin_dir_path( __FILE__ ) . 'nginx-helper-support-options.php';
51
  break;
52
 
53
  }
55
  </div> <!-- End of #post-body-content -->
56
  <div id="postbox-container-1" class="postbox-container">
57
  <?php
58
+ require plugin_dir_path( __FILE__ ) . 'nginx-helper-sidebar-display.php';
59
  ?>
60
  </div> <!-- End of #postbox-container-1 -->
61
  </div> <!-- End of #post-body -->
admin/partials/nginx-helper-general-options.php CHANGED
@@ -40,7 +40,7 @@ $args = array(
40
  'purge_page_on_deleted_comment' => FILTER_SANITIZE_STRING,
41
  );
42
 
43
- $all_inputs = filter_input_array(INPUT_POST, $args);
44
 
45
  if ( isset( $all_inputs['smart_http_expire_save'] ) && 'Save All Changes' === $all_inputs['smart_http_expire_save'] ) {
46
 
@@ -117,13 +117,13 @@ if ( is_multisite() ) {
117
  <input type="radio" value="enable_fastcgi" id="cache_method_fastcgi" name="cache_method" <?php echo checked( $nginx_helper_settings['cache_method'], 'enable_fastcgi' ); ?> />
118
  <label for="cache_method_fastcgi">
119
  <?php
120
- echo wp_kses(
121
- sprintf(
122
- '%1$s (<a target="_blank" href="%2$s" title="%3$s">%4$s</a>)',
123
- esc_html__( 'nginx Fastcgi cache', 'nginx-helper' ), esc_url( $nginx_setting_link ), esc_attr__( 'External settings for nginx', 'nginx-helper' ), esc_html__( 'requires external settings for nginx', 'nginx-helper' )
124
- ),
125
- array( 'strong' => array(), 'a' => array( 'href' => array(), 'title' => array() ) )
126
- );
127
  ?>
128
  </label>
129
  </td>
@@ -161,8 +161,9 @@ if ( is_multisite() ) {
161
  <?php
162
  echo wp_kses(
163
  sprintf(
164
- '%1$s <strong>PURGE/url</strong> %2$s',
165
- esc_html__( 'Using a GET request to', 'nginx-helper' ), esc_html__( '(Default option)', 'nginx-helper' )
 
166
  ),
167
  array( 'strong' => array() )
168
  );
@@ -172,10 +173,16 @@ if ( is_multisite() ) {
172
  <?php
173
  echo wp_kses(
174
  sprintf(
175
- '%1$s <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> %2$s.',
176
- esc_html__( 'Uses the', 'nginx-helper' ), esc_html__( 'module', 'nginx-helper' )
 
177
  ),
178
- array( 'strong' => array(), 'a' => array( 'href' => array() ) )
 
 
 
 
 
179
  );
180
  ?>
181
  </small>
@@ -191,10 +198,7 @@ if ( is_multisite() ) {
191
  <small>
192
  <?php
193
  echo wp_kses(
194
- sprintf(
195
- '%1$s<strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. %2$s',
196
- esc_html__( 'Checks for matching cache file in ', 'nginx-helper' ), esc_html__( 'Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri").', 'nginx-helper' )
197
- ),
198
  array( 'strong' => array() )
199
  );
200
  ?>
@@ -285,11 +289,8 @@ if ( is_multisite() ) {
285
  &nbsp;
286
  <?php
287
  echo wp_kses(
288
- sprintf(
289
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>%5$s<strong>%6$s</strong>.',
290
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'post', 'nginx-helper' ), esc_html__( ' (or page/custom post) is ', 'nginx-helper' ), esc_html__( 'modified', 'nginx-helper' ), esc_html__( ' or ', 'nginx-helper' ), esc_html__( 'added', 'nginx-helper' )
291
- ),
292
- array( 'strong' => array(), )
293
  );
294
  ?>
295
  </label>
@@ -309,11 +310,8 @@ if ( is_multisite() ) {
309
  &nbsp;
310
  <?php
311
  echo wp_kses(
312
- sprintf(
313
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>.',
314
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'published post', 'nginx-helper' ), esc_html__( ' (or page/custom post) is ', 'nginx-helper' ), esc_html__( 'trashed', 'nginx-helper' )
315
- ),
316
- array( 'strong' => array(), )
317
  );
318
  ?>
319
  </label>
@@ -343,11 +341,8 @@ if ( is_multisite() ) {
343
  &nbsp;
344
  <?php
345
  echo wp_kses(
346
- sprintf(
347
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>.',
348
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'post', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'published', 'nginx-helper' )
349
- ),
350
- array( 'strong' => array(), )
351
  );
352
  ?>
353
  </label>
@@ -367,11 +362,8 @@ if ( is_multisite() ) {
367
  &nbsp;
368
  <?php
369
  echo wp_kses(
370
- sprintf(
371
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>.',
372
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'comment', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'approved/published', 'nginx-helper' )
373
- ),
374
- array( 'strong' => array(), )
375
  );
376
  ?>
377
  </label>
@@ -391,11 +383,8 @@ if ( is_multisite() ) {
391
  &nbsp;
392
  <?php
393
  echo wp_kses(
394
- sprintf(
395
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>.',
396
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'comment', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'unapproved/deleted', 'nginx-helper' )
397
- ),
398
- array( 'strong' => array(), )
399
  );
400
  ?>
401
  </label>
@@ -427,11 +416,8 @@ if ( is_multisite() ) {
427
  &nbsp;
428
  <?php
429
  echo wp_kses(
430
- sprintf(
431
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>%5$s<strong>%6$s</strong>.',
432
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'post', 'nginx-helper' ), esc_html__( ' (or page/custom post) is ', 'nginx-helper' ), esc_html__( 'modified', 'nginx-helper' ), esc_html__( ' or ', 'nginx-helper' ), esc_html__( 'added', 'nginx-helper' )
433
- ),
434
- array( 'strong' => array(), )
435
  );
436
  ?>
437
  </label>
@@ -451,11 +437,8 @@ if ( is_multisite() ) {
451
  &nbsp;
452
  <?php
453
  echo wp_kses(
454
- sprintf(
455
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>.',
456
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'published post', 'nginx-helper' ), esc_html__( ' (or page/custom post) is ', 'nginx-helper' ), esc_html__( 'trashed', 'nginx-helper' )
457
- ),
458
- array( 'strong' => array(), )
459
  );
460
  ?>
461
  </label>
@@ -476,11 +459,8 @@ if ( is_multisite() ) {
476
  &nbsp;
477
  <?php
478
  echo wp_kses(
479
- sprintf(
480
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>.',
481
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'comment', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'approved/published', 'nginx-helper' )
482
- ),
483
- array( 'strong' => array(), )
484
  );
485
  ?>
486
  </label>
@@ -500,11 +480,8 @@ if ( is_multisite() ) {
500
  &nbsp;
501
  <?php
502
  echo wp_kses(
503
- sprintf(
504
- '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>.',
505
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'comment', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'unapproved/deleted', 'nginx-helper' )
506
- ),
507
- array( 'strong' => array(), )
508
  );
509
  ?>
510
  </label>
@@ -521,11 +498,16 @@ if ( is_multisite() ) {
521
  <td>
522
  <textarea rows="5"class="rt-purge_url" id="purge_url" name="purge_url"><?php echo esc_textarea( $nginx_helper_admin->options['purge_url'] ); ?></textarea>
523
  <p class="description">
524
- Add one URL per line. URL should not contain domain name.
525
- <br>
526
- Eg: To purge http://example.com/sample-page/ add <strong>/sample-page/</strong> in above textarea.
527
- <br>
528
- '*' will only work with redis cache server.
 
 
 
 
 
529
  </p>
530
  </td>
531
  </tr>
@@ -569,10 +551,10 @@ if ( is_multisite() ) {
569
  </div> <!-- End of .inside -->
570
  </div>
571
  <?php
572
- } // End of if ( ! ( ! is_network_admin() && is_multisite() ) )
573
 
574
- if ( is_network_admin() ) {
575
- ?>
576
  <div class="postbox enable_map"<?php echo ( empty( $nginx_helper_settings['enable_map'] ) ) ? ' style="display: none;"' : ''; ?>>
577
  <h3 class="hndle">
578
  <span><?php esc_html_e( 'Nginx Map', 'nginx-helper' ); ?></span>
@@ -584,12 +566,15 @@ if ( is_network_admin() ) {
584
  <span class="error fade" style="display: block">
585
  <p>
586
  <?php
 
 
587
  echo wp_kses(
588
  sprintf(
589
- '%1$s<br /><br />%2$s<strong>%3$s</strong>',
590
- esc_html__( 'Can\'t write on map file.', 'nginx-helper' ), esc_html__( 'Check you have write permission on ', 'nginx-helper' ), esc_url( $log_path . 'map.conf' )
 
591
  ),
592
- array( 'br' => array(), 'strong' => array(), )
593
  );
594
  ?>
595
  </p>
@@ -601,12 +586,10 @@ if ( is_network_admin() ) {
601
  <tr>
602
  <th>
603
  <?php
604
- echo wp_kses(
605
- sprintf(
606
- '%1$s<br /><small>%2$s</small>',
607
- esc_html__( 'Nginx Map path to include in nginx settings', 'nginx-helper' ), esc_html__( '(recommended)', 'nginx-helper' )
608
- ),
609
- array( 'br' => array(), 'small' => array(), )
610
  );
611
  ?>
612
  </th>
@@ -617,12 +600,11 @@ if ( is_network_admin() ) {
617
  <tr>
618
  <th>
619
  <?php
620
- echo wp_kses(
621
- sprintf(
622
- '%1$s<br />%2$s<br /><small>%3$s</small>',
623
- esc_html__( 'Or,', 'nginx-helper' ), esc_html__( 'Text to manually copy and paste in nginx settings', 'nginx-helper' ), esc_html__( '(if your network is small and new sites are not added frequently)', 'nginx-helper' )
624
- ),
625
- array( 'br' => array(), 'small' => array(), )
626
  );
627
  ?>
628
  </th>
@@ -635,9 +617,9 @@ if ( is_network_admin() ) {
635
  </table>
636
  </div> <!-- End of .inside -->
637
  </div>
638
- <?php
639
- }
640
- ?>
641
  <div class="postbox enable_log"<?php echo ( empty( $nginx_helper_settings['enable_log'] ) ) ? ' style="display: none;"' : ''; ?>>
642
  <h3 class="hndle">
643
  <span><?php esc_html_e( 'Logging Options', 'nginx-helper' ); ?></span>
@@ -656,12 +638,15 @@ if ( is_network_admin() ) {
656
  <span class="error fade" style="display : block">
657
  <p>
658
  <?php
 
 
659
  echo wp_kses(
660
  sprintf(
661
- '%1$s<br /><br />%2$s<strong>%3$s</strong>',
662
- esc_html__( 'Can\'t write on log file.', 'nginx-helper' ), esc_html__( 'Check you have write permission on ', 'nginx-helper' ), esc_url( $log_path . 'nginx.log' )
 
663
  ),
664
- array( 'br' => array(), 'strong' => array(), )
665
  );
666
  ?>
667
  </p>
40
  'purge_page_on_deleted_comment' => FILTER_SANITIZE_STRING,
41
  );
42
 
43
+ $all_inputs = filter_input_array( INPUT_POST, $args );
44
 
45
  if ( isset( $all_inputs['smart_http_expire_save'] ) && 'Save All Changes' === $all_inputs['smart_http_expire_save'] ) {
46
 
117
  <input type="radio" value="enable_fastcgi" id="cache_method_fastcgi" name="cache_method" <?php echo checked( $nginx_helper_settings['cache_method'], 'enable_fastcgi' ); ?> />
118
  <label for="cache_method_fastcgi">
119
  <?php
120
+ printf(
121
+ '%s (<a target="_blank" href="%s" title="%s">%s</a>)',
122
+ esc_html__( 'nginx Fastcgi cache', 'nginx-helper' ),
123
+ esc_url( $nginx_setting_link ),
124
+ esc_attr__( 'External settings for nginx', 'nginx-helper' ),
125
+ esc_html__( 'requires external settings for nginx', 'nginx-helper' )
126
+ );
127
  ?>
128
  </label>
129
  </td>
161
  <?php
162
  echo wp_kses(
163
  sprintf(
164
+ '%1$s <strong>PURGE/url</strong> %2$s',
165
+ esc_html__( 'Using a GET request to', 'nginx-helper' ),
166
+ esc_html__( '(Default option)', 'nginx-helper' )
167
  ),
168
  array( 'strong' => array() )
169
  );
173
  <?php
174
  echo wp_kses(
175
  sprintf(
176
+ // translators: %s Nginx cache purge module link.
177
+ __( 'Uses the %s module.', 'nginx-helper' ),
178
+ '<strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong>'
179
  ),
180
+ array(
181
+ 'strong' => array(),
182
+ 'a' => array(
183
+ 'href' => array(),
184
+ ),
185
+ )
186
  );
187
  ?>
188
  </small>
198
  <small>
199
  <?php
200
  echo wp_kses(
201
+ __( 'Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri").', 'nginx-helper' ),
 
 
 
202
  array( 'strong' => array() )
203
  );
204
  ?>
289
  &nbsp;
290
  <?php
291
  echo wp_kses(
292
+ __( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ),
293
+ array( 'strong' => array() )
 
 
 
294
  );
295
  ?>
296
  </label>
310
  &nbsp;
311
  <?php
312
  echo wp_kses(
313
+ __( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>', 'nginx-helper' ),
314
+ array( 'strong' => array() )
 
 
 
315
  );
316
  ?>
317
  </label>
341
  &nbsp;
342
  <?php
343
  echo wp_kses(
344
+ __( 'when a <strong>post</strong> is <strong>published</strong>.', 'nginx-helper' ),
345
+ array( 'strong' => array() )
 
 
 
346
  );
347
  ?>
348
  </label>
362
  &nbsp;
363
  <?php
364
  echo wp_kses(
365
+ __( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ),
366
+ array( 'strong' => array() )
 
 
 
367
  );
368
  ?>
369
  </label>
383
  &nbsp;
384
  <?php
385
  echo wp_kses(
386
+ __( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ),
387
+ array( 'strong' => array() )
 
 
 
388
  );
389
  ?>
390
  </label>
416
  &nbsp;
417
  <?php
418
  echo wp_kses(
419
+ __( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ),
420
+ array( 'strong' => array() )
 
 
 
421
  );
422
  ?>
423
  </label>
437
  &nbsp;
438
  <?php
439
  echo wp_kses(
440
+ __( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ),
441
+ array( 'strong' => array() )
 
 
 
442
  );
443
  ?>
444
  </label>
459
  &nbsp;
460
  <?php
461
  echo wp_kses(
462
+ __( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ),
463
+ array( 'strong' => array() )
 
 
 
464
  );
465
  ?>
466
  </label>
480
  &nbsp;
481
  <?php
482
  echo wp_kses(
483
+ __( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ),
484
+ array( 'strong' => array() )
 
 
 
485
  );
486
  ?>
487
  </label>
498
  <td>
499
  <textarea rows="5"class="rt-purge_url" id="purge_url" name="purge_url"><?php echo esc_textarea( $nginx_helper_admin->options['purge_url'] ); ?></textarea>
500
  <p class="description">
501
+ <?php
502
+ esc_html_e( 'Add one URL per line. URL should not contain domain name.', 'nginx-helper' );
503
+ echo '<br>';
504
+ echo wp_kses(
505
+ __( 'Eg: To purge http://example.com/sample-page/ add <strong>/sample-page/</strong> in above textarea.', 'nginx-helper' ),
506
+ array( 'strong' => array() )
507
+ );
508
+ echo '<br>';
509
+ esc_html_e( "'*' will only work with redis cache server.", 'nginx-helper' );
510
+ ?>
511
  </p>
512
  </td>
513
  </tr>
551
  </div> <!-- End of .inside -->
552
  </div>
553
  <?php
554
+ } // End of if.
555
 
556
+ if ( is_network_admin() ) {
557
+ ?>
558
  <div class="postbox enable_map"<?php echo ( empty( $nginx_helper_settings['enable_map'] ) ) ? ' style="display: none;"' : ''; ?>>
559
  <h3 class="hndle">
560
  <span><?php esc_html_e( 'Nginx Map', 'nginx-helper' ); ?></span>
566
  <span class="error fade" style="display: block">
567
  <p>
568
  <?php
569
+ esc_html_e( 'Can\'t write on map file.', 'nginx-helper' );
570
+ echo '<br /><br />';
571
  echo wp_kses(
572
  sprintf(
573
+ // translators: %s file url.
574
+ __( 'Check you have write permission on <strong>%s</strong>', 'nginx-helper' ),
575
+ esc_url( $log_path . 'map.conf' )
576
  ),
577
+ array( 'strong' => array() )
578
  );
579
  ?>
580
  </p>
586
  <tr>
587
  <th>
588
  <?php
589
+ printf(
590
+ '%1$s<br /><small>%2$s</small>',
591
+ esc_html__( 'Nginx Map path to include in nginx settings', 'nginx-helper' ),
592
+ esc_html__( '(recommended)', 'nginx-helper' )
 
 
593
  );
594
  ?>
595
  </th>
600
  <tr>
601
  <th>
602
  <?php
603
+ printf(
604
+ '%1$s<br />%2$s<br /><small>%3$s</small>',
605
+ esc_html__( 'Or,', 'nginx-helper' ),
606
+ esc_html__( 'Text to manually copy and paste in nginx settings', 'nginx-helper' ),
607
+ esc_html__( '(if your network is small and new sites are not added frequently)', 'nginx-helper' )
 
608
  );
609
  ?>
610
  </th>
617
  </table>
618
  </div> <!-- End of .inside -->
619
  </div>
620
+ <?php
621
+ }
622
+ ?>
623
  <div class="postbox enable_log"<?php echo ( empty( $nginx_helper_settings['enable_log'] ) ) ? ' style="display: none;"' : ''; ?>>
624
  <h3 class="hndle">
625
  <span><?php esc_html_e( 'Logging Options', 'nginx-helper' ); ?></span>
638
  <span class="error fade" style="display : block">
639
  <p>
640
  <?php
641
+ esc_html_e( 'Can\'t write on log file.', 'nginx-helper' );
642
+ echo '<br /><br />';
643
  echo wp_kses(
644
  sprintf(
645
+ // translators: %s file url.
646
+ __( 'Check you have write permission on <strong>%s</strong>', 'nginx-helper' ),
647
+ esc_url( $log_path . 'nginx.log' )
648
  ),
649
+ array( 'strong' => array() )
650
  );
651
  ?>
652
  </p>
admin/partials/nginx-helper-sidebar-display.php CHANGED
@@ -33,12 +33,11 @@ $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
33
  <div class="inside">
34
  <p>
35
  <?php
36
- echo wp_kses(
37
- sprintf(
38
- '%1$s <a href=\'%2$s\'>%3$s</a>.',
39
- esc_html__( 'Please use our', 'nginx-helper' ), esc_url( 'http://rtcamp.com/support/forum/wordpress-nginx/' ), esc_html__( 'free support forum', 'nginx-helper' )
40
- ),
41
- array( 'a' => array( 'href' => array() ) )
42
  );
43
  ?>
44
  </p>
@@ -54,8 +53,6 @@ $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
54
  <div style="text-align:center;" class="inside">
55
  <a class="nginx-helper-facebook" title="<?php esc_attr_e( 'Become a fan on Facebook', 'nginx-helper' ); ?>" target="_blank" href="http://www.facebook.com/rtCamp.solutions/"></a>
56
  <a class="nginx-helper-twitter" title="<?php esc_attr_e( 'Follow us on Twitter', 'nginx-helper' ); ?>" target="_blank" href="https://twitter.com/rtcamp/"></a>
57
- <a class="nginx-helper-gplus" title="<?php esc_attr_e( 'Add to Circle', 'nginx-helper' ); ?>" target="_blank" href="https://plus.google.com/110214156830549460974/posts"></a>
58
- <a class="nginx-helper-rss" title="<?php esc_attr_e( 'Subscribe to our feeds', 'nginx-helper' ); ?>" target="_blank" href="http://feeds.feedburner.com/rtcamp/"></a>
59
  </div>
60
  </div>
61
 
33
  <div class="inside">
34
  <p>
35
  <?php
36
+ printf(
37
+ '%s <a href=\'%s\'>%s</a>.',
38
+ esc_html__( 'Please use our', 'nginx-helper' ),
39
+ esc_url( 'http://rtcamp.com/support/forum/wordpress-nginx/' ),
40
+ esc_html__( 'free support forum', 'nginx-helper' )
 
41
  );
42
  ?>
43
  </p>
53
  <div style="text-align:center;" class="inside">
54
  <a class="nginx-helper-facebook" title="<?php esc_attr_e( 'Become a fan on Facebook', 'nginx-helper' ); ?>" target="_blank" href="http://www.facebook.com/rtCamp.solutions/"></a>
55
  <a class="nginx-helper-twitter" title="<?php esc_attr_e( 'Follow us on Twitter', 'nginx-helper' ); ?>" target="_blank" href="https://twitter.com/rtcamp/"></a>
 
 
56
  </div>
57
  </div>
58
 
admin/partials/nginx-helper-support-options.php CHANGED
@@ -24,7 +24,7 @@
24
  <?php esc_html_e( 'Free Support', 'nginx-helper' ); ?>
25
  </th>
26
  <td>
27
- <a href="https://rtcamp.com/support/forum/wordpress-nginx/" title="<?php esc_attr_e( 'Free Support Forum', 'nginx-helper' ); ?>" target="_blank">
28
  <?php esc_html_e( 'Link to forum', 'nginx-helper' ); ?>
29
  </a>
30
  </td>
@@ -34,7 +34,7 @@
34
  <?php esc_html_e( 'Premium Support', 'nginx-helper' ); ?>
35
  </th>
36
  <td>
37
- <a href="https://rtcamp.com/wordpress-nginx/pricing/" title="<?php esc_attr_e( 'Premium Support Forum', 'nginx-helper' ); ?>" target="_blank">
38
  <?php esc_html_e( 'Link to forum', 'nginx-helper' ); ?>
39
  </a>
40
  </td>
24
  <?php esc_html_e( 'Free Support', 'nginx-helper' ); ?>
25
  </th>
26
  <td>
27
+ <a href="https://community.easyengine.io/c/wordpress-nginx/" title="<?php esc_attr_e( 'Free Support Forum', 'nginx-helper' ); ?>" target="_blank">
28
  <?php esc_html_e( 'Link to forum', 'nginx-helper' ); ?>
29
  </a>
30
  </td>
34
  <?php esc_html_e( 'Premium Support', 'nginx-helper' ); ?>
35
  </th>
36
  <td>
37
+ <a href="https://easyengine.io/contact/" title="<?php esc_attr_e( 'Premium Support Forum', 'nginx-helper' ); ?>" target="_blank">
38
  <?php esc_html_e( 'Link to forum', 'nginx-helper' ); ?>
39
  </a>
40
  </td>
admin/predis.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
 
3
  /*
4
  * This file is part of the Predis package.
@@ -15200,3 +15200,4 @@ class ReplicationStrategy
15200
  }
15201
 
15202
  /* --------------------------------------------------------------------------- */
 
1
+ <?php // phpcs:disable
2
 
3
  /*
4
  * This file is part of the Predis package.
15200
  }
15201
 
15202
  /* --------------------------------------------------------------------------- */
15203
+ // phpcs:enable
wp-cli.php → class-nginx-helper-wp-cli-command.php RENAMED
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
16
  if ( ! class_exists( 'Nginx_Helper_WP_CLI_Command' ) ) {
17
 
18
  /**
19
- * Class Nginx_Helper_WP_CLI_Command
20
  */
21
  class Nginx_Helper_WP_CLI_Command extends WP_CLI_Command {
22
 
16
  if ( ! class_exists( 'Nginx_Helper_WP_CLI_Command' ) ) {
17
 
18
  /**
19
+ * Purge site cache from Nginx.
20
  */
21
  class Nginx_Helper_WP_CLI_Command extends WP_CLI_Command {
22
 
includes/class-nginx-helper-loader.php CHANGED
@@ -112,7 +112,7 @@ class Nginx_Helper_Loader {
112
  'component' => $component,
113
  'callback' => $callback,
114
  'priority' => $priority,
115
- 'accepted_args' => $accepted_args
116
  );
117
 
118
  return $hooks;
112
  'component' => $component,
113
  'callback' => $callback,
114
  'priority' => $priority,
115
+ 'accepted_args' => $accepted_args,
116
  );
117
 
118
  return $hooks;
includes/class-nginx-helper.php CHANGED
@@ -61,9 +61,9 @@ class Nginx_Helper {
61
  *
62
  * @since 2.0.0
63
  * @access public
64
- * @var string $minium_WP
65
  */
66
- protected $minimum_WP;
67
 
68
  /**
69
  * Define the core functionality of the plugin.
@@ -77,8 +77,8 @@ class Nginx_Helper {
77
  public function __construct() {
78
 
79
  $this->plugin_name = 'nginx-helper';
80
- $this->version = '2.0.1';
81
- $this->minimum_WP = '3.0';
82
 
83
  if ( ! $this->required_wp_version() ) {
84
  return;
@@ -171,7 +171,7 @@ class Nginx_Helper {
171
  $nginx_helper_admin = new Nginx_Helper_Admin( $this->get_plugin_name(), $this->get_version() );
172
 
173
  // Defines global variables.
174
- if ( ! empty( $nginx_helper_admin->options['cache_method'] ) && $nginx_helper_admin->options['cache_method'] === 'enable_redis' ) {
175