From 32ee02563aaa71a0f5798dec190f56634801ae4c Mon Sep 17 00:00:00 2001
From: Abhijit Rakas
Date: Wed, 5 Jun 2019 10:45:11 +0530
Subject: [PATCH 1/3] Fix phpcs
---
admin/class-fastcgi-purger.php | 6 +-
admin/class-nginx-helper-admin.php | 53 +++--
admin/class-phpredis-purger.php | 4 -
admin/class-predis-purger.php | 6 +-
admin/class-purger.php | 168 +++++++--------
admin/css/nginx-helper-admin.css | 104 ++++-----
admin/icons/css/nginx-fontello.css | 88 ++++----
admin/js/nginx-helper-admin.js | 200 ++++++++++--------
admin/partials/nginx-helper-admin-display.php | 19 +-
.../partials/nginx-helper-general-options.php | 139 ++++++++----
.../partials/nginx-helper-sidebar-display.php | 4 +-
...p => class-nginx-helper-wp-cli-command.php | 2 +-
includes/class-nginx-helper-loader.php | 2 +-
includes/class-nginx-helper.php | 6 +-
nginx-helper.php | 2 +-
15 files changed, 447 insertions(+), 356 deletions(-)
rename wp-cli.php => class-nginx-helper-wp-cli-command.php (95%)
diff --git a/admin/class-fastcgi-purger.php b/admin/class-fastcgi-purger.php
index 0862cfa5..3f414772 100644
--- a/admin/class-fastcgi-purger.php
+++ b/admin/class-fastcgi-purger.php
@@ -51,7 +51,7 @@ public function purge_url( $url, $feed = true ) {
$_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . $parse['path'];
$_url_purge = $_url_purge_base;
- if ( isset( $parse['query'] ) && $parse['query'] !== '' ) {
+ if ( isset( $parse['query'] ) && '' !== $parse['query'] ) {
$_url_purge .= '?' . $parse['query'];
}
@@ -131,9 +131,7 @@ public function custom_purge_urls() {
$this->delete_cache_file_for( $purge_url );
}
-
}
-
}
break;
@@ -155,9 +153,7 @@ public function custom_purge_urls() {
$this->do_remote_get( $purge_url );
}
-
}
-
}
break;
diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php
index 2ba4ecfd..55ff9442 100644
--- a/admin/class-nginx-helper-admin.php
+++ b/admin/class-nginx-helper-admin.php
@@ -82,7 +82,8 @@ public function __construct( $plugin_name, $version ) {
* Define settings tabs
*/
$this->settings_tabs = apply_filters(
- 'rt_nginx_helper_settings_tabs', array(
+ 'rt_nginx_helper_settings_tabs',
+ array(
'general' => array(
'menu_title' => __( 'General', 'nginx-helper' ),
'menu_slug' => 'general',
@@ -209,7 +210,7 @@ public function nginx_helper_toolbar_purge_link( $wp_admin_bar ) {
$link_title = __( 'Purge Current Page', 'nginx-helper' );
}
- $purge_url = add_query_arg(
+ $purge_url = add_query_arg(
array(
'nginx_helper_action' => 'purge',
'nginx_helper_urls' => $nginx_helper_urls,
@@ -237,7 +238,7 @@ public function nginx_helper_toolbar_purge_link( $wp_admin_bar ) {
* @since 2.0.0
*/
public function nginx_helper_setting_page() {
- include plugin_dir_path(__FILE__ ) . 'partials/nginx-helper-admin-display.php';
+ include plugin_dir_path( __FILE__ ) . 'partials/nginx-helper-admin-display.php';
}
/**
@@ -282,7 +283,14 @@ public function nginx_helper_default_settings() {
*/
public function nginx_helper_settings() {
- $options = get_site_option( 'rt_wp_nginx_helper_options', array( 'redis_hostname' => '127.0.0.1', 'redis_port' => '6379', 'redis_prefix' => 'nginx-cache:' ) );
+ $options = get_site_option(
+ 'rt_wp_nginx_helper_options',
+ array(
+ 'redis_hostname' => '127.0.0.1',
+ 'redis_port' => '6379',
+ 'redis_prefix' => 'nginx-cache:',
+ )
+ );
$data = wp_parse_args(
$options,
@@ -399,15 +407,22 @@ public function nginx_helper_get_feeds() {
echo wp_kses(
sprintf(
'%3$s',
- 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() )
+ 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() )
),
- array( 'strong' => array(), 'a' => array( 'href' => array(), 'title' => array() ) )
+ array(
+ 'strong' => array(),
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array(),
+ ),
+ )
);
?>
@@ -421,13 +436,13 @@ public function nginx_helper_get_feeds() {
*/
public function add_timestamps() {
- if ( is_admin() || (int) $this->options['enable_purge'] !== 1 || (int) $this->options['enable_stamp'] !== 1 ) {
+ if ( is_admin() || 1 !== (int) $this->options['enable_purge'] || 1 !== (int) $this->options['enable_stamp'] ) {
return;
}
foreach ( headers_list() as $header ) {
list( $key, $value ) = explode( ':', $header, 2 );
- $key = strtolower( $key );
+ $key = strtolower( $key );
if ( 'content-type' === $key && strpos( trim( $value ), 'text/html' ) !== 0 ) {
return;
}
@@ -480,7 +495,7 @@ public function get_map() {
$rt_all_blogs = $wpdb->get_results(
$wpdb->prepare(
- 'SELECT blog_id, domain, path FROM ' . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'",
+ 'SELECT blog_id, domain, path FROM ' . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'",
$wpdb->siteid
)
);
@@ -507,11 +522,8 @@ public function get_map() {
if ( 1 !== $blog->blog_id ) {
$rt_nginx_map_array[ $blog->path ] = $blog->blog_id;
}
-
}
-
}
-
}
if ( $rt_domain_map_sites ) {
@@ -519,7 +531,6 @@ public function get_map() {
foreach ( $rt_domain_map_sites as $site ) {
$rt_nginx_map_array[ $site->domain ] = $site->blog_id;
}
-
}
foreach ( $rt_nginx_map_array as $domain => $domain_id ) {
@@ -541,11 +552,11 @@ public function update_map() {
$rt_nginx_map = $this->get_map();
- if ( $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' ) ) {
+ $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' );
+ if ( $fp ) {
fwrite( $fp, $rt_nginx_map );
fclose( $fp );
}
-
}
}
@@ -580,11 +591,11 @@ public function set_future_post_option_on_future_status( $new_status, $old_statu
if (
'future' === $new_status && $post && 'future' === $post->post_status &&
(
- ( 'post' === $post->post_type || 'page' === $post->post_type ) ||
- (
- isset( $this->options['custom_post_types_recognized'] ) &&
- in_array( $post->post_type, $this->options['custom_post_types_recognized'], true )
- )
+ ( 'post' === $post->post_type || 'page' === $post->post_type ) ||
+ (
+ isset( $this->options['custom_post_types_recognized'] ) &&
+ in_array( $post->post_type, $this->options['custom_post_types_recognized'], true )
+ )
)
) {
diff --git a/admin/class-phpredis-purger.php b/admin/class-phpredis-purger.php
index 1943b426..ae9a971d 100644
--- a/admin/class-phpredis-purger.php
+++ b/admin/class-phpredis-purger.php
@@ -170,7 +170,6 @@ public function custom_purge_urls() {
} else {
$this->log( '- Cache Not Found | ' . $purge_url, 'ERROR' );
}
-
} else {
$purge_url = $_url_purge_base . $purge_url;
@@ -181,11 +180,8 @@ public function custom_purge_urls() {
} else {
$this->log( '- Cache Not Found | ' . $purge_url, 'ERROR' );
}
-
}
-
}
-
}
}
diff --git a/admin/class-predis-purger.php b/admin/class-predis-purger.php
index 27a04cbd..3457a662 100644
--- a/admin/class-predis-purger.php
+++ b/admin/class-predis-purger.php
@@ -73,7 +73,7 @@ public function purge_all() {
} else { // Else purge only site specific cache.
- $parse = wp_parse_url( get_home_url() );
+ $parse = wp_parse_url( get_home_url() );
$parse['path'] = empty( $parse['path'] ) ? '/' : $parse['path'];
$this->delete_keys_by_wildcard( $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'] . '*' );
$this->log( '* ' . get_home_url() . ' Purged! * ' );
@@ -160,7 +160,6 @@ public function custom_purge_urls() {
} else {
$this->log( '- Not Found | ' . $purge_url, 'ERROR' );
}
-
} else {
$purge_url = $_url_purge_base . $purge_url;
@@ -171,11 +170,8 @@ public function custom_purge_urls() {
} else {
$this->log( '- Not Found | ' . $purge_url, 'ERROR' );
}
-
}
-
}
-
}
}
diff --git a/admin/class-purger.php b/admin/class-purger.php
index e27dcb61..0ab3ef83 100644
--- a/admin/class-purger.php
+++ b/admin/class-purger.php
@@ -51,15 +51,15 @@ public function purge_post_on_comment( $comment_id, $comment ) {
$oldstatus = '';
$approved = $comment->comment_approved;
- if ( $approved === null ) {
+ if ( null === $approved ) {
$newstatus = false;
- } elseif ( $approved === '1' ) {
+ } elseif ( '1' === $approved ) {
$newstatus = 'approved';
- } elseif ( $approved === '0' ) {
+ } elseif ( '0' === $approved ) {
$newstatus = 'unapproved';
- } elseif ( $approved === 'spam' ) {
+ } elseif ( 'spam' === $approved ) {
$newstatus = 'spam';
- } elseif ( $approved === 'trash' ) {
+ } elseif ( 'trash' === $approved ) {
$newstatus = 'trash';
} else {
$newstatus = false;
@@ -108,7 +108,7 @@ public function purge_post_on_comment_change( $newstatus, $oldstatus, $comment )
case 'spam':
case 'unapproved':
case 'trash':
- if ( 'approved' === $oldstatus && 1 === (int)$nginx_helper_admin->options['purge_page_on_deleted_comment'] ) {
+ if ( 'approved' === $oldstatus && 1 === (int) $nginx_helper_admin->options['purge_page_on_deleted_comment'] ) {
$this->log( '* Comment ( ' . $_comment_id . ' ) removed as ( ' . $newstatus . ' ). Post ( ' . $_post_id . ' ) purging...' );
$this->log( '* * * * *' );
@@ -124,9 +124,9 @@ public function purge_post_on_comment_change( $newstatus, $oldstatus, $comment )
/**
* Purge post cache.
*
- * @param int $_ID Post id.
+ * @param int $post_id Post id.
*/
- public function purge_post( $_ID ) {
+ public function purge_post( $post_id ) {
global $nginx_helper_admin, $blog_id;
@@ -139,16 +139,16 @@ public function purge_post( $_ID ) {
case 'publish_post':
$this->log( '* * * * *' );
$this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
- $this->log( '* Post :: ' . get_the_title( $_ID ) . ' ( ' . $_ID . ' ).' );
- $this->log( '* Post ( ' . $_ID . ' ) published or edited and its status is published' );
+ $this->log( '* Post :: ' . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
+ $this->log( '* Post ( ' . $post_id . ' ) published or edited and its status is published' );
$this->log( '* * * * *' );
break;
case 'publish_page':
$this->log( '* * * * *' );
$this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
- $this->log( '* Page :: ' . get_the_title( $_ID ) . ' ( ' . $_ID . ' ).' );
- $this->log( '* Page ( ' . $_ID . ' ) published or edited and its status is published' );
+ $this->log( '* Page :: ' . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
+ $this->log( '* Page ( ' . $post_id . ' ) published or edited and its status is published' );
$this->log( '* * * * *' );
break;
@@ -157,11 +157,11 @@ public function purge_post( $_ID ) {
break;
default:
- $_post_type = get_post_type( $_ID );
+ $_post_type = get_post_type( $post_id );
$this->log( '* * * * *' );
$this->log( '* Blog :: ' . addslashes( get_bloginfo( 'name' ) ) . ' ( ' . $blog_id . ' ).' );
- $this->log( "* Custom post type '" . $_post_type . "' :: " . get_the_title( $_ID ) . ' ( ' . $_ID . ' ).' );
- $this->log( "* CPT '" . $_post_type . "' ( " . $_ID . ' ) published or edited and its status is published' );
+ $this->log( "* Custom post type '" . $_post_type . "' :: " . get_the_title( $post_id ) . ' ( ' . $post_id . ' ).' );
+ $this->log( "* CPT '" . $_post_type . "' ( " . $post_id . ' ) published or edited and its status is published' );
$this->log( '* * * * *' );
break;
@@ -176,13 +176,21 @@ public function purge_post( $_ID ) {
if ( 'comment_post' === current_filter() || 'wp_set_comment_status' === current_filter() ) {
$this->_purge_by_options(
- $_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']
+ $post_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']
);
} else {
$this->_purge_by_options(
- $_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']
+ $post_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']
);
}
@@ -228,7 +236,6 @@ private function _purge_by_options( $post_id, $blog_id, $_purge_page, $_purge_ar
} else {
$url = '';
}
-
} else {
$url = get_permalink( $post_id );
}
@@ -275,11 +282,8 @@ private function _purge_by_options( $post_id, $blog_id, $_purge_page, $_purge_ar
if ( $day ) {
$this->purge_url( get_day_link( $year, $month, $day ) );
}
-
}
-
}
-
}
$categories = wp_get_post_categories( $post_id );
@@ -294,7 +298,6 @@ private function _purge_by_options( $post_id, $blog_id, $_purge_page, $_purge_ar
$this->purge_url( get_category_link( $category_id ) );
}
-
}
$tags = get_the_tags( $post_id );
@@ -309,7 +312,6 @@ private function _purge_by_options( $post_id, $blog_id, $_purge_page, $_purge_ar
$this->purge_url( get_tag_link( $tag->term_id ) );
}
-
}
$author_id = get_post( $post_id )->post_author;
@@ -320,7 +322,6 @@ private function _purge_by_options( $post_id, $blog_id, $_purge_page, $_purge_ar
$this->purge_url( get_author_posts_url( $author_id ) );
}
-
}
if ( $_purge_custom_taxa ) {
@@ -347,9 +348,7 @@ private function _purge_by_options( $post_id, $blog_id, $_purge_page, $_purge_ar
foreach ( $terms as $term ) {
$this->purge_url( get_term_link( $term, $taxon ) );
}
-
}
-
} else {
$this->log( "Your built-in taxonomy '" . $taxon . "' has param '_builtin' set to false.", 'WARNING' );
}
@@ -480,7 +479,6 @@ protected function do_remote_get( $url ) {
$this->log( '- - ' . $url . ' not found ( ' . $response['response']['code'] . ' )', 'WARNING' );
}
-
}
/**
@@ -539,13 +537,13 @@ public function log( $msg, $level = 'INFO' ) {
if ( $log_levels[ $level ] >= $log_levels[ $nginx_helper_admin->options['log_level'] ] ) {
- if ( $fp = fopen( $nginx_helper_admin->functional_asset_path() . 'nginx.log', 'a+' ) ) {
+ $fp = fopen( $nginx_helper_admin->functional_asset_path() . 'nginx.log', 'a+' );
+ if ( $fp ) {
fwrite( $fp, "\n" . gmdate( 'Y-m-d H:i:s ' ) . ' | ' . $level . ' | ' . $msg );
fclose( $fp );
}
-
}
return true;
@@ -565,21 +563,22 @@ public function check_and_truncate_log_file() {
$nginx_asset_path = $nginx_helper_admin->functional_asset_path() . 'nginx.log';
- if ( ! file_exists($nginx_asset_path) ) {
+ if ( ! file_exists( $nginx_asset_path ) ) {
return;
}
$max_size_allowed = ( is_numeric( $nginx_helper_admin->options['log_filesize'] ) ) ? $nginx_helper_admin->options['log_filesize'] * 1048576 : 5242880;
- $fileSize = filesize( $nginx_asset_path );
+ $file_size = filesize( $nginx_asset_path );
- if ( $fileSize > $max_size_allowed ) {
+ if ( $file_size > $max_size_allowed ) {
- $offset = $fileSize - $max_size_allowed;
+ $offset = $file_size - $max_size_allowed;
$file_content = file_get_contents( $nginx_asset_path, null, null, $offset );
$file_content = empty( $file_content ) ? '' : strstr( $file_content, "\n" );
- if ( $file_content && $fp = fopen( $nginx_asset_path, 'w+' ) ) {
+ $fp = fopen( $nginx_asset_path, 'w+' );
+ if ( $file_content && $fp ) {
fwrite( $fp, $file_content );
fclose( $fp );
@@ -610,9 +609,7 @@ public function purge_image_on_edit( $attachment_id ) {
if ( $resize_image ) {
$this->purge_url( $resize_image[0], false );
}
-
}
-
}
$this->purge_url( get_attachment_link( $attachment_id ) );
@@ -710,7 +707,6 @@ private function _purge_personal_urls() {
foreach ( $nginx_helper_admin->options['purgeable_url']['urls'] as $url ) {
$this->purge_url( $url, false );
}
-
} else {
$this->log( '- ' . __( 'No personal urls available', 'nginx-helper' ) );
}
@@ -736,11 +732,11 @@ private function _purge_post_categories( $_post_id ) {
foreach ( $categories as $category_id ) {
+ // translators: %d: Category ID.
$this->log( sprintf( __( "Purging category '%d'", 'nginx-helper' ), $category_id ) );
$this->purge_url( get_category_link( $category_id ) );
}
-
}
return true;
@@ -767,7 +763,6 @@ private function _purge_post_tags( $_post_id ) {
$this->purge_url( get_tag_link( $tag->term_id ) );
}
-
}
return true;
@@ -796,6 +791,7 @@ private function _purge_post_custom_taxa( $_post_id ) {
foreach ( $custom_taxonomies as $taxon ) {
+ // translators: %s: Post taxonomy name.
$this->log( sprintf( '+ ' . __( "Purging custom taxonomy '%s'", 'nginx-helper' ), $taxon ) );
if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ), true ) ) {
@@ -807,14 +803,12 @@ private function _purge_post_custom_taxa( $_post_id ) {
foreach ( $terms as $term ) {
$this->purge_url( get_term_link( $term, $taxon ) );
}
-
}
-
} else {
+ // translators: %s: Post taxonomy name.
$this->log( sprintf( '- ' . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", 'nginx-helper' ), $taxon ), 'WARNING' );
}
}
-
} else {
$this->log( '- ' . __( 'No custom taxonomies', 'nginx-helper' ) );
}
@@ -841,7 +835,6 @@ private function _purge_all_categories() {
$this->purge_url( get_category_link( $c->term_id ) );
}
-
} else {
$this->log( __( 'No categories archives', 'nginx-helper' ) );
@@ -870,7 +863,6 @@ private function _purge_all_posttags() {
$this->purge_url( get_tag_link( $t->term_id ) );
}
-
} else {
$this->log( __( 'No tags archives', 'nginx-helper' ) );
}
@@ -899,6 +891,7 @@ private function _purge_all_customtaxa() {
foreach ( $custom_taxonomies as $taxon ) {
+ // translators: %s: Taxonomy name.
$this->log( sprintf( '+ ' . __( "Purging custom taxonomy '%s'", 'nginx-helper' ), $taxon ) );
if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ), true ) ) {
@@ -912,15 +905,12 @@ private function _purge_all_customtaxa() {
$this->purge_url( get_term_link( $term, $taxon ) );
}
-
}
-
} else {
- $this->log( sprintf( '- ' . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", 'nginx-helper' ), $taxon ), 'WARNING' );
+ // translators: %s: Taxonomy name.
+ $this->log( sprintf( '- ' . esc_html__( "Your built-in taxonomy '%s' has param '_builtin' set to false.", 'nginx-helper' ), $taxon ), 'WARNING' );
}
-
}
-
} else {
$this->log( '- ' . __( 'No custom taxonomies', 'nginx-helper' ) );
}
@@ -957,7 +947,7 @@ private function _purge_all_posts() {
'post_status' => 'publish',
);
- $get_posts = new WP_Query;
+ $get_posts = new WP_Query();
$_posts = $get_posts->query( $args );
if ( ! empty( $_posts ) ) {
@@ -968,7 +958,6 @@ private function _purge_all_posts() {
$this->purge_url( get_permalink( $p->ID ) );
}
-
} else {
$this->log( '- ' . __( 'No posts', 'nginx-helper' ) );
}
@@ -1005,11 +994,15 @@ private function _purge_all_daily_archives() {
$_query_daily_archives = $wpdb->prepare(
"SELECT YEAR(post_date) AS %s, MONTH(post_date) AS %s, DAYOFMONTH(post_date) AS %s, count(ID) as posts
- FROM $wpdb->posts
- WHERE post_type = %s AND post_status = %s
- GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date)
- ORDER BY post_date DESC",
- 'year', 'month', 'dayofmonth', 'post', 'publish'
+ FROM $wpdb->posts
+ WHERE post_type = %s AND post_status = %s
+ GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date)
+ ORDER BY post_date DESC",
+ 'year',
+ 'month',
+ 'dayofmonth',
+ 'post',
+ 'publish'
);
$_daily_archives = $wpdb->get_results( $_query_daily_archives ); // phpcs:ignore
@@ -1020,14 +1013,16 @@ private function _purge_all_daily_archives() {
$this->log(
sprintf(
- '+ ' . __( "Purging daily archive '%1\$s/%2\$s/%3\$s'", 'nginx-helper' ), $_da->year, $_da->month, $_da->dayofmonth
+ '+ ' . __( "Purging daily archive '%1\$s/%2\$s/%3\$s'", 'nginx-helper' ),
+ $_da->year,
+ $_da->month,
+ $_da->dayofmonth
)
);
$this->purge_url( get_day_link( $_da->year, $_da->month, $_da->dayofmonth ) );
}
-
} else {
$this->log( '- ' . __( 'No daily archives', 'nginx-helper' ) );
}
@@ -1049,20 +1044,22 @@ private function _purge_all_monthly_archives() {
$_query_monthly_archives = $wpdb->prepare(
"SELECT YEAR(post_date) AS %s, MONTH(post_date) AS %s, count(ID) as posts
- FROM $wpdb->posts
- WHERE post_type = %s AND post_status = %s
- GROUP BY YEAR(post_date), MONTH(post_date)
- ORDER BY post_date DESC",
- 'year', 'month', 'post', 'publish'
+ FROM $wpdb->posts
+ WHERE post_type = %s AND post_status = %s
+ GROUP BY YEAR(post_date), MONTH(post_date)
+ ORDER BY post_date DESC",
+ 'year',
+ 'month',
+ 'post',
+ 'publish'
);
$_monthly_archives = $wpdb->get_results( $_query_monthly_archives ); // phpcs:ignore
- wp_cache_set( 'nginx_helper_monthly_archives', $_monthly_archives, 'nginx_helper', 24*60*60 );
+ wp_cache_set( 'nginx_helper_monthly_archives', $_monthly_archives, 'nginx_helper', 24 * 60 * 60 );
}
-
if ( ! empty( $_monthly_archives ) ) {
foreach ( $_monthly_archives as $_ma ) {
@@ -1071,7 +1068,6 @@ private function _purge_all_monthly_archives() {
$this->purge_url( get_month_link( $_ma->year, $_ma->month ) );
}
-
} else {
$this->log( '- ' . __( 'No monthly archives', 'nginx-helper' ) );
}
@@ -1093,16 +1089,18 @@ private function _purge_all_yearly_archives() {
$_query_yearly_archives = $wpdb->prepare(
"SELECT YEAR(post_date) AS %s, count(ID) as posts
- FROM $wpdb->posts
- WHERE post_type = %s AND post_status = %s
- GROUP BY YEAR(post_date)
- ORDER BY post_date DESC",
- 'year', 'post', 'publish'
+ FROM $wpdb->posts
+ WHERE post_type = %s AND post_status = %s
+ GROUP BY YEAR(post_date)
+ ORDER BY post_date DESC",
+ 'year',
+ 'post',
+ 'publish'
);
$_yearly_archives = $wpdb->get_results( $_query_yearly_archives ); // phpcs:ignore
- wp_cache_set( 'nginx_helper_yearly_archives', $_yearly_archives, 'nginx_helper', 24*60*60 );
+ wp_cache_set( 'nginx_helper_yearly_archives', $_yearly_archives, 'nginx_helper', 24 * 60 * 60 );
}
@@ -1110,11 +1108,11 @@ private function _purge_all_yearly_archives() {
foreach ( $_yearly_archives as $_ya ) {
- $this->log( sprintf( '+ ' . __( "Purging yearly archive '%s'", 'nginx-helper' ), $_ya->year ) );
+ // translators: %s: Year to purge cache.
+ $this->log( sprintf( '+ ' . esc_html__( "Purging yearly archive '%s'", 'nginx-helper' ), $_ya->year ) );
$this->purge_url( get_year_link( $_ya->year ) );
}
-
} else {
$this->log( '- ' . __( 'No yearly archives', 'nginx-helper' ) );
}
@@ -1202,38 +1200,40 @@ public function purge_on_check_ajax_referer( $action ) {
* Source - http://stackoverflow.com/a/1360437/156336
*
* @param string $dir Directory.
- * @param bool $deleteRootToo Delete root or not.
+ * @param bool $delete_root_too Delete root or not.
+ *
+ * @return void
*/
- public function unlink_recursive( $dir, $deleteRootToo ) {
+ public function unlink_recursive( $dir, $delete_root_too ) {
if ( ! is_dir( $dir ) ) {
return;
}
- if ( ! $dh = opendir( $dir ) ) {
+ $dh = opendir( $dir );
+
+ if ( ! $dh ) {
return;
}
- while ( false !== ( $obj = readdir( $dh ) ) ) {
+ $obj = readdir( $dh );
- if ( $obj == '.' || $obj == '..' ) {
+ while ( false !== $obj ) {
+
+ if ( '.' === $obj || '..' === $obj ) {
continue;
}
if ( ! @unlink( $dir . '/' . $obj ) ) {
$this->unlink_recursive( $dir . '/' . $obj, false );
}
-
}
- if ( $deleteRootToo ) {
+ if ( $delete_root_too ) {
rmdir( $dir );
}
closedir( $dh );
-
- return;
-
}
}
diff --git a/admin/css/nginx-helper-admin.css b/admin/css/nginx-helper-admin.css
index a797b3e4..1948365b 100644
--- a/admin/css/nginx-helper-admin.css
+++ b/admin/css/nginx-helper-admin.css
@@ -4,101 +4,101 @@
*/
.clearfix {
- *zoom: 1;
+ *zoom: 1;
}
.clearfix:before,
.clearfix:after {
- content: " ";
- display: table;
+ content: " ";
+ display: table;
}
.clearfix:after {
- clear: both;
+ clear: both;
}
h4 {
- margin: 0;
+ margin: 0;
}
.form-table th,
.form-wrap label {
- vertical-align: middle;
+ vertical-align: middle;
}
table.rtnginx-table {
- border-bottom: 1px solid #EEE;
+ border-bottom: 1px solid #EEE;
}
table.rtnginx-table:last-child {
- border-bottom: 0;
+ border-bottom: 0;
}
.rtnginx-table p.error {
- color: red;
+ color: red;
}
pre#map {
- background: #e5e5e5 none;
- border-radius: 10px;
- padding: 10px;
+ background: #e5e5e5 none;
+ border-radius: 10px;
+ padding: 10px;
}
.wrap h2.rt_option_title {
- background: url(../icons/nginx-icon-32x32.png) 0 6px no-repeat rgba(0, 0, 0, 0);
- padding-left: 40px;
+ background: url(../icons/nginx-icon-32x32.png) 0 6px no-repeat rgba(0, 0, 0, 0);
+ padding-left: 40px;
}
#poststuff h2 {
- padding: 0 0 0 10px;
- margin-top: 0;
+ padding: 0 0 0 10px;
+ margin-top: 0;
}
form#purgeall .button-primary {
- margin-bottom: 20px;
- box-shadow: inset 0 -2px rgba(0, 0, 0, 0.14);
- padding: 15px 30px;
- font-size: 1rem;
- border: 0;
- border-radius: 5px;
- color: #FFF;
- background: #DD3D36;
- height: auto;
+ margin-bottom: 20px;
+ box-shadow: inset 0 -2px rgba(0, 0, 0, 0.14);
+ padding: 15px 30px;
+ font-size: 1rem;
+ border: 0;
+ border-radius: 5px;
+ color: #FFF;
+ background: #DD3D36;
+ height: auto;
}
form#purgeall .button-primary:hover,
form#purgeall .button-primary:focus {
- background: #d52c24;
+ background: #d52c24;
}
.nh-aligncenter {
- display: block;
- text-align: center;
- line-height: 2;
+ display: block;
+ text-align: center;
+ line-height: 2;
}
#latest_news .inside ul,
#useful-links .inside ul {
- margin: 0 0 0 12px;
+ margin: 0 0 0 12px;
}
#latest_news .inside ul li,
#useful-links .inside ul li {
- list-style: square;
- padding: 0 0 7px;
+ list-style: square;
+ padding: 0 0 7px;
}
#social .inside a {
- background-color: #666;
- color: #FFF;
- display: inline-block;
- height: 30px;
- font-size: 1.25rem;
- line-height: 30px;
- margin: 10px 20px 0 0;
- overflow: hidden;
- padding: 0;
- text-align: center;
- text-decoration: none;
- width: 30px;
- -webkit-border-radius: 1000px;
- -moz-border-radius: 1000px;
- border-radius: 1000px;
+ background-color: #666;
+ color: #FFF;
+ display: inline-block;
+ height: 30px;
+ font-size: 1.25rem;
+ line-height: 30px;
+ margin: 10px 20px 0 0;
+ overflow: hidden;
+ padding: 0;
+ text-align: center;
+ text-decoration: none;
+ width: 30px;
+ -webkit-border-radius: 1000px;
+ -moz-border-radius: 1000px;
+ border-radius: 1000px;
}
#social .inside .nginx-helper-rss:hover {
- background-color: #FAA33D;
+ background-color: #FAA33D;
}
#social .inside .nginx-helper-facebook:hover {
- background-color: #537BBD;
+ background-color: #537BBD;
}
#social .inside .nginx-helper-twitter:hover {
- background-color: #40BFF5;
+ background-color: #40BFF5;
}
#social .inside .nginx-helper-gplus:hover {
- background-color: #DD4B39;
+ background-color: #DD4B39;
}
-.rt-purge_url { width: 100%; }
+.rt-purge_url { width: 100%; }
diff --git a/admin/icons/css/nginx-fontello.css b/admin/icons/css/nginx-fontello.css
index baffe651..f134e8f9 100644
--- a/admin/icons/css/nginx-fontello.css
+++ b/admin/icons/css/nginx-fontello.css
@@ -1,56 +1,56 @@
@font-face {
- font-family: 'nginx-fontello';
- src: url('../font/nginx-fontello.eot?7388141');
- src: url('../font/nginx-fontello.eot?7388141#iefix') format('embedded-opentype'),
- url('../font/nginx-fontello.woff?7388141') format('woff'),
- url('../font/nginx-fontello.ttf?7388141') format('truetype'),
- url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
- font-weight: normal;
- font-style: normal;
+ font-family: 'nginx-fontello';
+ src: url('../font/nginx-fontello.eot?7388141');
+ src: url('../font/nginx-fontello.eot?7388141#iefix') format('embedded-opentype'),
+ url('../font/nginx-fontello.woff?7388141') format('woff'),
+ url('../font/nginx-fontello.ttf?7388141') format('truetype'),
+ url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
+ font-weight: normal;
+ font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
- @font-face {
- font-family: 'nginx-fontello';
- src: url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
- }
+ @font-face {
+ font-family: 'nginx-fontello';
+ src: url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
+ }
}
*/
-
- [class^="nginx-helper-"]:before, [class*=" nginx-helper-"]:before {
- font-family: "nginx-fontello";
- font-style: normal;
- font-weight: normal;
- speak: none;
-
- display: inline-block;
- text-decoration: inherit;
- width: 1em;
- margin-right: .2em;
- text-align: center;
- /* opacity: .8; */
-
- /* For safety - reset parent styles, that can break glyph codes*/
- font-variant: normal;
- text-transform: none;
-
- /* fix buttons height, for twitter bootstrap */
- line-height: 1em;
-
- /* Animation center compensation - margins should be symmetric */
- /* remove if not needed */
- margin-left: .2em;
-
- /* you can be more comfortable with increased icons size */
- /* font-size: 120%; */
-
- /* Uncomment for 3D effect */
- /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
+
+[class^="nginx-helper-"]:before, [class*=" nginx-helper-"]:before {
+ font-family: "nginx-fontello";
+ font-style: normal;
+ font-weight: normal;
+ speak: none;
+
+ display: inline-block;
+ text-decoration: inherit;
+ width: 1em;
+ margin-right: .2em;
+ text-align: center;
+ /* opacity: .8; */
+
+ /* For safety - reset parent styles, that can break glyph codes*/
+ font-variant: normal;
+ text-transform: none;
+
+ /* fix buttons height, for twitter bootstrap */
+ line-height: 1em;
+
+ /* Animation center compensation - margins should be symmetric */
+ /* remove if not needed */
+ margin-left: .2em;
+
+ /* you can be more comfortable with increased icons size */
+ /* font-size: 120%; */
+
+ /* Uncomment for 3D effect */
+ /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
}
-
+
.nginx-helper-rss:before { content: '\e803'; } /* '' */
.nginx-helper-twitter:before { content: '\e802'; } /* '' */
.nginx-helper-facebook:before { content: '\e801'; } /* '' */
-.nginx-helper-gplus:before { content: '\e800'; } /* '' */
\ No newline at end of file
+.nginx-helper-gplus:before { content: '\e800'; } /* '' */
diff --git a/admin/js/nginx-helper-admin.js b/admin/js/nginx-helper-admin.js
index 1628474b..540fae8e 100644
--- a/admin/js/nginx-helper-admin.js
+++ b/admin/js/nginx-helper-admin.js
@@ -1,92 +1,110 @@
+/**
+ * File to add JavaScript for nginx-helper.
+ *
+ * @package nginx-helper
+ */
+
(function ($) {
- 'use strict';
-
- /**
- * All of the code for your admin-specific JavaScript source
- * should reside in this file.
- *
- * Note that this assume you're going to use jQuery, so it prepares
- * the $ function reference to be used within the scope of this
- * function.
- *
- * From here, you're able to define handlers for when the DOM is
- * ready:
- *
- * $(function() {
- *
- * });
- *
- * Or when the window is loaded:
- *
- * $( window ).load(function() {
- *
- * });
- *
- * ...and so on.
- *
- * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
- * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
- * be doing this, we should try to minimize doing that in our own work.
- */
- $(function () {
-
- var news_section = jQuery( '#latest_news' );
-
- if ( news_section.length > 0 ) {
-
- var args = {
- 'action': 'rt_get_feeds'
- };
-
- jQuery.get( ajaxurl, args, function (data) {
- news_section.find( '.inside' ).html( data );
- console.log(data);
- });
-
- }
-
- jQuery( "form#purgeall a" ).click( function (e) {
-
- if ( confirm( "Purging entire cache is not recommended. Would you like to continue ?" ) == true ) {
- // continue submitting form
- } else {
- e.preventDefault();
- }
-
- });
-
- /**
- * Show OR Hide options on option checkbox
- * @param {type} selector Selector of Checkbox and PostBox
- */
- function nginx_show_option( selector ) {
-
- jQuery( '#' + selector ).on( 'change', function () {
-
- if ( jQuery( this ).is( ':checked' ) ) {
-
- jQuery( '.' + selector ).show();
-
- if ( selector == "cache_method_redis" ) {
- jQuery( '.cache_method_fastcgi' ).hide();
- } else if ( selector == "cache_method_fastcgi" ) {
- jQuery( '.cache_method_redis' ).hide();
- }
-
- } else {
- jQuery( '.' + selector ).hide();
- }
-
- });
-
- }
-
- /* Function call with parameter */
- nginx_show_option( 'cache_method_fastcgi' );
- nginx_show_option( 'cache_method_redis' );
- nginx_show_option( 'enable_map' );
- nginx_show_option( 'enable_log' );
- nginx_show_option( 'enable_purge' );
-
- });
-})(jQuery);
+ 'use strict';
+
+ /**
+ * All of the code for your admin-specific JavaScript source
+ * should reside in this file.
+ *
+ * Note that this assume you're going to use jQuery, so it prepares
+ * the $ function reference to be used within the scope of this
+ * function.
+ *
+ * From here, you're able to define handlers for when the DOM is
+ * ready:
+ *
+ * $(function() {
+ *
+ * });
+ *
+ * Or when the window is loaded:
+ *
+ * $( window ).load(function() {
+ *
+ * });
+ *
+ * ...and so on.
+ *
+ * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
+ * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
+ * be doing this, we should try to minimize doing that in our own work.
+ */
+ $(
+ function () {
+
+ var news_section = jQuery( '#latest_news' );
+
+ if ( news_section.length > 0 ) {
+
+ var args = {
+ 'action': 'rt_get_feeds'
+ };
+
+ jQuery.get(
+ ajaxurl,
+ args,
+ function (data) {
+ news_section.find( '.inside' ).html( data );
+ console.log( data );
+ }
+ );
+
+ }
+
+ jQuery( "form#purgeall a" ).click(
+ function (e) {
+
+ if ( confirm( "Purging entire cache is not recommended. Would you like to continue ?" ) == true ) {
+ // continue submitting form.
+ } else {
+ e.preventDefault();
+ }
+
+ }
+ );
+
+ /**
+ * Show OR Hide options on option checkbox
+ *
+ * @param {type} selector Selector of Checkbox and PostBox
+ */
+ function nginx_show_option( selector ) {
+
+ jQuery( '#' + selector ).on(
+ 'change',
+ function () {
+
+ if ( jQuery( this ).is( ':checked' ) ) {
+
+ jQuery( '.' + selector ).show();
+
+ if ( selector == "cache_method_redis" ) {
+ jQuery( '.cache_method_fastcgi' ).hide();
+ } else if ( selector == "cache_method_fastcgi" ) {
+ jQuery( '.cache_method_redis' ).hide();
+ }
+
+ } else {
+ jQuery( '.' + selector ).hide();
+ }
+
+ }
+ );
+
+ }
+
+ /* Function call with parameter */
+ nginx_show_option( 'cache_method_fastcgi' );
+ nginx_show_option( 'cache_method_redis' );
+ nginx_show_option( 'enable_map' );
+ nginx_show_option( 'enable_log' );
+ nginx_show_option( 'enable_purge' );
+
+ }
+ );
+})( jQuery );
diff --git a/admin/partials/nginx-helper-admin-display.php b/admin/partials/nginx-helper-admin-display.php
index fe254787..c0364fcf 100644
--- a/admin/partials/nginx-helper-admin-display.php
+++ b/admin/partials/nginx-helper-admin-display.php
@@ -25,7 +25,7 @@
';
@@ -35,9 +35,16 @@
echo wp_kses(
sprintf(
'
%3$s',
- esc_attr( $class ), esc_attr( $setting_name['menu_slug'] ), esc_html( $setting_name['menu_title'] )
+ esc_attr( $class ),
+ esc_attr( $setting_name['menu_slug'] ),
+ esc_html( $setting_name['menu_title'] )
),
- array( 'a' => array( 'href' => array(), 'class' => array(), ) )
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'class' => array(),
+ ),
+ )
);
}
echo '';
@@ -45,10 +52,10 @@
switch ( $current_setting_tab ) {
case 'general':
- include plugin_dir_path(__FILE__ ) . 'nginx-helper-general-options.php';
+ include plugin_dir_path( __FILE__ ) . 'nginx-helper-general-options.php';
break;
case 'support':
- include plugin_dir_path(__FILE__ ) . 'nginx-helper-support-options.php';
+ include plugin_dir_path( __FILE__ ) . 'nginx-helper-support-options.php';
break;
}
@@ -56,7 +63,7 @@
diff --git a/admin/partials/nginx-helper-general-options.php b/admin/partials/nginx-helper-general-options.php
index 9c2ed003..7856c2a9 100644
--- a/admin/partials/nginx-helper-general-options.php
+++ b/admin/partials/nginx-helper-general-options.php
@@ -40,7 +40,7 @@
'purge_page_on_deleted_comment' => FILTER_SANITIZE_STRING,
);
-$all_inputs = filter_input_array(INPUT_POST, $args);
+$all_inputs = filter_input_array( INPUT_POST, $args );
if ( isset( $all_inputs['smart_http_expire_save'] ) && 'Save All Changes' === $all_inputs['smart_http_expire_save'] ) {
@@ -118,12 +118,21 @@
@@ -162,7 +171,8 @@
echo wp_kses(
sprintf(
'%1$s PURGE/url %2$s',
- esc_html__( 'Using a GET request to', 'nginx-helper' ), esc_html__( '(Default option)', 'nginx-helper' )
+ esc_html__( 'Using a GET request to', 'nginx-helper' ),
+ esc_html__( '(Default option)', 'nginx-helper' )
),
array( 'strong' => array() )
);
@@ -173,9 +183,13 @@
echo wp_kses(
sprintf(
'%1$s ngx_cache_purge %2$s.',
- esc_html__( 'Uses the', 'nginx-helper' ), esc_html__( 'module', 'nginx-helper' )
+ esc_html__( 'Uses the', 'nginx-helper' ),
+ esc_html__( 'module', 'nginx-helper' )
),
- array( 'strong' => array(), 'a' => array( 'href' => array() ) )
+ array(
+ 'strong' => array(),
+ 'a' => array( 'href' => array() ),
+ )
);
?>
@@ -193,7 +207,8 @@
echo wp_kses(
sprintf(
'%1$sRT_WP_NGINX_HELPER_CACHE_PATH. %2$s',
- 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' )
+ 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' )
),
array( 'strong' => array() )
);
@@ -287,9 +302,14 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s%5$s%6$s.',
- 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' )
+ 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' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -311,9 +331,12 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s.',
- 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' )
+ 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' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -345,9 +368,12 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s.',
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'post', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'published', 'nginx-helper' )
+ esc_html__( 'when a ', 'nginx-helper' ),
+ esc_html__( 'post', 'nginx-helper' ),
+ esc_html__( ' is ', 'nginx-helper' ),
+ esc_html__( 'published', 'nginx-helper' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -369,9 +395,12 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s.',
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'comment', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'approved/published', 'nginx-helper' )
+ esc_html__( 'when a ', 'nginx-helper' ),
+ esc_html__( 'comment', 'nginx-helper' ),
+ esc_html__( ' is ', 'nginx-helper' ),
+ esc_html__( 'approved/published', 'nginx-helper' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -393,9 +422,12 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s.',
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'comment', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'unapproved/deleted', 'nginx-helper' )
+ esc_html__( 'when a ', 'nginx-helper' ),
+ esc_html__( 'comment', 'nginx-helper' ),
+ esc_html__( ' is ', 'nginx-helper' ),
+ esc_html__( 'unapproved/deleted', 'nginx-helper' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -429,9 +461,14 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s%5$s%6$s.',
- 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' )
+ 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' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -453,9 +490,12 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s.',
- 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' )
+ 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' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -478,9 +518,12 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s.',
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'comment', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'approved/published', 'nginx-helper' )
+ esc_html__( 'when a ', 'nginx-helper' ),
+ esc_html__( 'comment', 'nginx-helper' ),
+ esc_html__( ' is ', 'nginx-helper' ),
+ esc_html__( 'approved/published', 'nginx-helper' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -502,9 +545,12 @@
echo wp_kses(
sprintf(
'%1$s%2$s%3$s%4$s.',
- esc_html__( 'when a ', 'nginx-helper' ), esc_html__( 'comment', 'nginx-helper' ), esc_html__( ' is ', 'nginx-helper' ), esc_html__( 'unapproved/deleted', 'nginx-helper' )
+ esc_html__( 'when a ', 'nginx-helper' ),
+ esc_html__( 'comment', 'nginx-helper' ),
+ esc_html__( ' is ', 'nginx-helper' ),
+ esc_html__( 'unapproved/deleted', 'nginx-helper' )
),
- array( 'strong' => array(), )
+ array( 'strong' => array() )
);
?>
@@ -569,7 +615,7 @@
@@ -587,9 +633,14 @@
echo wp_kses(
sprintf(
'%1$s
%2$s%3$s',
- 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' )
+ 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' )
),
- array( 'br' => array(), 'strong' => array(), )
+ array(
+ 'br' => array(),
+ 'strong' => array(),
+ )
);
?>
@@ -604,9 +655,13 @@
echo wp_kses(
sprintf(
'%1$s
%2$s',
- esc_html__( 'Nginx Map path to include in nginx settings', 'nginx-helper' ), esc_html__( '(recommended)', 'nginx-helper' )
+ esc_html__( 'Nginx Map path to include in nginx settings', 'nginx-helper' ),
+ esc_html__( '(recommended)', 'nginx-helper' )
),
- array( 'br' => array(), 'small' => array(), )
+ array(
+ 'br' => array(),
+ 'small' => array(),
+ )
);
?>
@@ -620,9 +675,14 @@
echo wp_kses(
sprintf(
'%1$s
%2$s
%3$s',
- 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' )
+ 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' )
),
- array( 'br' => array(), 'small' => array(), )
+ array(
+ 'br' => array(),
+ 'small' => array(),
+ )
);
?>
@@ -659,9 +719,14 @@
echo wp_kses(
sprintf(
'%1$s
%2$s%3$s',
- 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' )
+ 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' )
),
- array( 'br' => array(), 'strong' => array(), )
+ array(
+ 'br' => array(),
+ 'strong' => array(),
+ )
);
?>
diff --git a/admin/partials/nginx-helper-sidebar-display.php b/admin/partials/nginx-helper-sidebar-display.php
index 5d386fff..7dc0a845 100644
--- a/admin/partials/nginx-helper-sidebar-display.php
+++ b/admin/partials/nginx-helper-sidebar-display.php
@@ -36,7 +36,9 @@
echo wp_kses(
sprintf(
'%1$s %3$s.',
- esc_html__( 'Please use our', 'nginx-helper' ), esc_url( 'http://rtcamp.com/support/forum/wordpress-nginx/' ), esc_html__( 'free support forum', 'nginx-helper' )
+ esc_html__( 'Please use our', 'nginx-helper' ),
+ esc_url( 'http://rtcamp.com/support/forum/wordpress-nginx/' ),
+ esc_html__( 'free support forum', 'nginx-helper' )
),
array( 'a' => array( 'href' => array() ) )
);
diff --git a/wp-cli.php b/class-nginx-helper-wp-cli-command.php
similarity index 95%
rename from wp-cli.php
rename to class-nginx-helper-wp-cli-command.php
index 134a1bc5..7862e982 100644
--- a/wp-cli.php
+++ b/class-nginx-helper-wp-cli-command.php
@@ -16,7 +16,7 @@
if ( ! class_exists( 'Nginx_Helper_WP_CLI_Command' ) ) {
/**
- * Class Nginx_Helper_WP_CLI_Command
+ * Purge site cache from Nginx.
*/
class Nginx_Helper_WP_CLI_Command extends WP_CLI_Command {
diff --git a/includes/class-nginx-helper-loader.php b/includes/class-nginx-helper-loader.php
index d1aceeeb..f58d9373 100644
--- a/includes/class-nginx-helper-loader.php
+++ b/includes/class-nginx-helper-loader.php
@@ -112,7 +112,7 @@ private function add( $hooks, $hook, $component, $callback, $priority, $accepted
'component' => $component,
'callback' => $callback,
'priority' => $priority,
- 'accepted_args' => $accepted_args
+ 'accepted_args' => $accepted_args,
);
return $hooks;
diff --git a/includes/class-nginx-helper.php b/includes/class-nginx-helper.php
index 93a05cf7..fceacf3c 100644
--- a/includes/class-nginx-helper.php
+++ b/includes/class-nginx-helper.php
@@ -171,7 +171,7 @@ private function define_admin_hooks() {
$nginx_helper_admin = new Nginx_Helper_Admin( $this->get_plugin_name(), $this->get_version() );
// Defines global variables.
- if ( ! empty( $nginx_helper_admin->options['cache_method'] ) && $nginx_helper_admin->options['cache_method'] === 'enable_redis' ) {
+ if ( ! empty( $nginx_helper_admin->options['cache_method'] ) && 'enable_redis' === $nginx_helper_admin->options['cache_method'] ) {
if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis extension if installed.
@@ -184,7 +184,6 @@ private function define_admin_hooks() {
$nginx_purger = new Predis_Purger();
}
-
} else {
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-fastcgi-purger.php';
@@ -306,7 +305,8 @@ public function display_notices() {
minimum_WP )
+ esc_html__( 'Sorry, Nginx Helper requires WordPress %s or higher', 'nginx-helper' ),
+ esc_html( $this->minimum_WP )
);
?>
diff --git a/nginx-helper.php b/nginx-helper.php
index 55bee55b..87d7e927 100644
--- a/nginx-helper.php
+++ b/nginx-helper.php
@@ -88,7 +88,7 @@ function run_nginx_helper() {
// Load WP-CLI command.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
- require_once NGINX_HELPER_BASEPATH . 'wp-cli.php';
+ require_once NGINX_HELPER_BASEPATH . 'class-nginx-helper-wp-cli-command.php';
\WP_CLI::add_command( 'nginx-helper', 'Nginx_Helper_WP_CLI_Command' );
}
From 25bf7f13d6e8ee1dfb13c8d47e290c289d3bc380 Mon Sep 17 00:00:00 2001
From: Abhijit Rakas
Date: Wed, 12 Jun 2019 11:43:36 +0530
Subject: [PATCH 2/3] Remove extra escaping and make alert message translatable
---
admin/class-fastcgi-purger.php | 2 +-
admin/class-nginx-helper-admin.php | 26 ++++++++-----------
admin/js/nginx-helper-admin.js | 16 ++++++------
admin/partials/nginx-helper-admin-display.php | 18 ++++---------
.../partials/nginx-helper-general-options.php | 21 +++++----------
.../partials/nginx-helper-sidebar-display.php | 13 ++++------
6 files changed, 36 insertions(+), 60 deletions(-)
diff --git a/admin/class-fastcgi-purger.php b/admin/class-fastcgi-purger.php
index 3f414772..53c01624 100644
--- a/admin/class-fastcgi-purger.php
+++ b/admin/class-fastcgi-purger.php
@@ -51,7 +51,7 @@ public function purge_url( $url, $feed = true ) {
$_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . $parse['path'];
$_url_purge = $_url_purge_base;
- if ( isset( $parse['query'] ) && '' !== $parse['query'] ) {
+ if ( ! empty( $parse['query'] ) ) {
$_url_purge .= '?' . $parse['query'];
}
diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php
index 55ff9442..65d1f6b4 100644
--- a/admin/class-nginx-helper-admin.php
+++ b/admin/class-nginx-helper-admin.php
@@ -79,8 +79,8 @@ public function __construct( $plugin_name, $version ) {
$this->version = $version;
/**
- * Define settings tabs
- */
+ * Define settings tabs
+ */
$this->settings_tabs = apply_filters(
'rt_nginx_helper_settings_tabs',
array(
@@ -154,7 +154,12 @@ public function enqueue_scripts( $hook ) {
return;
}
- wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/nginx-helper-admin.js', array( 'jquery' ), $this->version, false );
+ wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/nginx-helper-admin.js', array( 'jquery' ), $this->version );
+
+ $do_localize = array(
+ 'purge_confirm_string' => esc_html__( 'Purging entire cache is not recommended. Would you like to continue?', 'nginx-helper' ),
+ );
+ wp_localize_script( $this->plugin_name, 'nginx_helper', $do_localize );
}
@@ -404,21 +409,12 @@ public function nginx_helper_get_feeds() {
?>
%3$s',
+ printf(
+ '%s',
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() )
- ),
- array(
- 'strong' => array(),
- 'a' => array(
- 'href' => array(),
- 'title' => array(),
- ),
- )
- );
+ );
?>
settings_tabs as $setting_tab => $setting_name ) {
$class = ( $setting_tab === $current_setting_tab ) ? ' nav-tab-active' : '';
- echo wp_kses(
- sprintf(
- '%3$s',
- esc_attr( $class ),
- esc_attr( $setting_name['menu_slug'] ),
- esc_html( $setting_name['menu_title'] )
- ),
- array(
- 'a' => array(
- 'href' => array(),
- 'class' => array(),
- ),
- )
+ printf(
+ '%s',
+ esc_attr( 'nav-tab' . $class ),
+ esc_url( '?page=nginx&tab=' . $setting_name['menu_slug'] ),
+ esc_html( $setting_name['menu_title'] )
);
}
echo '';
diff --git a/admin/partials/nginx-helper-general-options.php b/admin/partials/nginx-helper-general-options.php
index 7856c2a9..3f7e5af3 100644
--- a/admin/partials/nginx-helper-general-options.php
+++ b/admin/partials/nginx-helper-general-options.php
@@ -117,21 +117,12 @@
/>
diff --git a/admin/partials/nginx-helper-sidebar-display.php b/admin/partials/nginx-helper-sidebar-display.php
index 7dc0a845..e44fbc3c 100644
--- a/admin/partials/nginx-helper-sidebar-display.php
+++ b/admin/partials/nginx-helper-sidebar-display.php
@@ -33,14 +33,11 @@
%3$s.',
- esc_html__( 'Please use our', 'nginx-helper' ),
- esc_url( 'http://rtcamp.com/support/forum/wordpress-nginx/' ),
- esc_html__( 'free support forum', 'nginx-helper' )
- ),
- array( 'a' => array( 'href' => array() ) )
+ printf(
+ '%s %s.',
+ esc_html__( 'Please use our', 'nginx-helper' ),
+ esc_url( 'http://rtcamp.com/support/forum/wordpress-nginx/' ),
+ esc_html__( 'free support forum', 'nginx-helper' )
);
?>
From cf3d04f9b9a7fe442f0aa37f1c93c8b6963bf310 Mon Sep 17 00:00:00 2001
From: Thrijith Thankachan
Date: Fri, 20 Dec 2019 19:58:19 +0530
Subject: [PATCH 3/3] Use Yoda check Exclude vendor directory from PHPCS checks
---
admin/js/nginx-helper-admin.js | 2 +-
phpcs.xml | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/admin/js/nginx-helper-admin.js b/admin/js/nginx-helper-admin.js
index 2f4371c0..966ef593 100644
--- a/admin/js/nginx-helper-admin.js
+++ b/admin/js/nginx-helper-admin.js
@@ -83,7 +83,7 @@
jQuery( '.' + selector ).show();
- if ( selector === 'cache_method_redis' ) {
+ if ( 'cache_method_redis' === selector ) {
jQuery( '.cache_method_fastcgi' ).hide();
} else if ( selector === 'cache_method_fastcgi' ) {
jQuery( '.cache_method_redis' ).hide();
diff --git a/phpcs.xml b/phpcs.xml
index d3bc1193..868090ce 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -22,6 +22,7 @@
*/languages/*
*/admin/predis.php
+ */vendor/*
@@ -57,4 +58,4 @@
-
\ No newline at end of file
+