Skip to content

Commit f60700a

Browse files
authored
Merge pull request #209 from abhijitrakas/feature/phpcs-fixes
Fix PHPCS errors and warnings
2 parents 2b46f45 + cf3d04f commit f60700a

16 files changed

+443
-375
lines changed

admin/class-fastcgi-purger.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function purge_url( $url, $feed = true ) {
5151
$_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . $parse['path'];
5252
$_url_purge = $_url_purge_base;
5353

54-
if ( isset( $parse['query'] ) && $parse['query'] !== '' ) {
54+
if ( ! empty( $parse['query'] ) ) {
5555
$_url_purge .= '?' . $parse['query'];
5656
}
5757

@@ -131,9 +131,7 @@ public function custom_purge_urls() {
131131
$this->delete_cache_file_for( $purge_url );
132132

133133
}
134-
135134
}
136-
137135
}
138136
break;
139137

@@ -155,9 +153,7 @@ public function custom_purge_urls() {
155153
$this->do_remote_get( $purge_url );
156154

157155
}
158-
159156
}
160-
161157
}
162158
break;
163159

admin/class-nginx-helper-admin.php

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ public function __construct( $plugin_name, $version ) {
7979
$this->version = $version;
8080

8181
/**
82-
* Define settings tabs
83-
*/
82+
* Define settings tabs
83+
*/
8484
$this->settings_tabs = apply_filters(
85-
'rt_nginx_helper_settings_tabs', array(
85+
'rt_nginx_helper_settings_tabs',
86+
array(
8687
'general' => array(
8788
'menu_title' => __( 'General', 'nginx-helper' ),
8889
'menu_slug' => 'general',
@@ -153,7 +154,12 @@ public function enqueue_scripts( $hook ) {
153154
return;
154155
}
155156

156-
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/nginx-helper-admin.js', array( 'jquery' ), $this->version, false );
157+
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/nginx-helper-admin.js', array( 'jquery' ), $this->version );
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 );
157163

158164
}
159165

@@ -209,7 +215,7 @@ public function nginx_helper_toolbar_purge_link( $wp_admin_bar ) {
209215
$link_title = __( 'Purge Current Page', 'nginx-helper' );
210216
}
211217

212-
$purge_url = add_query_arg(
218+
$purge_url = add_query_arg(
213219
array(
214220
'nginx_helper_action' => 'purge',
215221
'nginx_helper_urls' => $nginx_helper_urls,
@@ -237,7 +243,7 @@ public function nginx_helper_toolbar_purge_link( $wp_admin_bar ) {
237243
* @since 2.0.0
238244
*/
239245
public function nginx_helper_setting_page() {
240-
include plugin_dir_path(__FILE__ ) . 'partials/nginx-helper-admin-display.php';
246+
include plugin_dir_path( __FILE__ ) . 'partials/nginx-helper-admin-display.php';
241247
}
242248

243249
/**
@@ -282,7 +288,14 @@ public function nginx_helper_default_settings() {
282288
*/
283289
public function nginx_helper_settings() {
284290

285-
$options = get_site_option( 'rt_wp_nginx_helper_options', array( 'redis_hostname' => '127.0.0.1', 'redis_port' => '6379', 'redis_prefix' => 'nginx-cache:' ) );
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+
);
286299

287300
$data = wp_parse_args(
288301
$options,
@@ -396,18 +409,16 @@ public function nginx_helper_get_feeds() {
396409
?>
397410
<li role="listitem">
398411
<?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-
);
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+
);
406418
?>
407419
</li>
408420
<?php
409421
}
410-
411422
}
412423
?>
413424
</ul>
@@ -433,7 +444,7 @@ public function add_timestamps() {
433444

434445
foreach ( headers_list() as $header ) {
435446
list( $key, $value ) = explode( ':', $header, 2 );
436-
$key = strtolower( $key );
447+
$key = strtolower( $key );
437448
if ( 'content-type' === $key && strpos( trim( $value ), 'text/html' ) !== 0 ) {
438449
return;
439450
}
@@ -486,7 +497,7 @@ public function get_map() {
486497

487498
$rt_all_blogs = $wpdb->get_results(
488499
$wpdb->prepare(
489-
'SELECT blog_id, domain, path FROM ' . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'",
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'",
490501
$wpdb->siteid
491502
)
492503
);
@@ -513,19 +524,15 @@ public function get_map() {
513524
if ( 1 !== $blog->blog_id ) {
514525
$rt_nginx_map_array[ $blog->path ] = $blog->blog_id;
515526
}
516-
517527
}
518-
519528
}
520-
521529
}
522530

523531
if ( $rt_domain_map_sites ) {
524532

525533
foreach ( $rt_domain_map_sites as $site ) {
526534
$rt_nginx_map_array[ $site->domain ] = $site->blog_id;
527535
}
528-
529536
}
530537

531538
foreach ( $rt_nginx_map_array as $domain => $domain_id ) {
@@ -547,11 +554,11 @@ public function update_map() {
547554

548555
$rt_nginx_map = $this->get_map();
549556

550-
if ( $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' ) ) {
557+
$fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' );
558+
if ( $fp ) {
551559
fwrite( $fp, $rt_nginx_map );
552560
fclose( $fp );
553561
}
554-
555562
}
556563

557564
}
@@ -586,11 +593,11 @@ public function set_future_post_option_on_future_status( $new_status, $old_statu
586593
if (
587594
'future' === $new_status && $post && 'future' === $post->post_status &&
588595
(
589-
( 'post' === $post->post_type || 'page' === $post->post_type ) ||
590-
(
591-
isset( $this->options['custom_post_types_recognized'] ) &&
592-
in_array( $post->post_type, $this->options['custom_post_types_recognized'], true )
593-
)
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+
)
594601
)
595602
) {
596603

admin/class-phpredis-purger.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ public function custom_purge_urls() {
202202
} else {
203203
$this->log( '- Cache Not Found | ' . $purge_url, 'ERROR' );
204204
}
205-
206205
} else {
207206

208207
$purge_url = $_url_purge_base . $purge_url;
@@ -213,11 +212,8 @@ public function custom_purge_urls() {
213212
} else {
214213
$this->log( '- Cache Not Found | ' . $purge_url, 'ERROR' );
215214
}
216-
217215
}
218-
219216
}
220-
221217
}
222218

223219
}

admin/class-predis-purger.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function purge_all() {
7373

7474
} else { // Else purge only site specific cache.
7575

76-
$parse = wp_parse_url( get_home_url() );
76+
$parse = wp_parse_url( get_home_url() );
7777
$parse['path'] = empty( $parse['path'] ) ? '/' : $parse['path'];
7878
$this->delete_keys_by_wildcard( $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'] . '*' );
7979
$this->log( '* ' . get_home_url() . ' Purged! * ' );
@@ -198,7 +198,6 @@ public function custom_purge_urls() {
198198
} else {
199199
$this->log( '- Not Found | ' . $purge_url, 'ERROR' );
200200
}
201-
202201
} else {
203202

204203
$purge_url = $_url_purge_base . $purge_url;
@@ -209,11 +208,8 @@ public function custom_purge_urls() {
209208
} else {
210209
$this->log( '- Not Found | ' . $purge_url, 'ERROR' );
211210
}
212-
213211
}
214-
215212
}
216-
217213
}
218214

219215
}

0 commit comments

Comments
 (0)