Text to manually copy and paste in nginx settings (if your network is small and new sites are not added frequently)', 'nginx-helper' );
+ printf(
+ wp_kses( '%1$s %2$s %3$s', array( 'br' => array(), 'small' => array(), ) ),
+ 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' )
+ );
?>
@@ -512,8 +554,8 @@
Check you have write permission on %s', 'nginx-helper' ),
- $log_path . 'nginx.log'
+ wp_kses( '%1$s
%2$s%3$s', array( 'br' => array(), 'strong' => array(), ) ),
+ 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' )
);
?>
%3$s.", array( 'a' => array( 'href' => array() ) ) ),
+ wp_kses( '%1$s %3$s.', array( 'a' => array( 'href' => array() ) ) ),
esc_html__( 'Please use our', 'nginx-helper' ), esc_url( 'http://rtcamp.com/support/forum/wordpress-nginx/' ), esc_html__( 'free support forum', 'nginx-helper' )
);
?>
diff --git a/includes/class-nginx-helper-activator.php b/includes/class-nginx-helper-activator.php
index c6e0ebd7..ec179928 100644
--- a/includes/class-nginx-helper-activator.php
+++ b/includes/class-nginx-helper-activator.php
@@ -12,6 +12,10 @@
*
* @author rtCamp
*/
+
+/**
+ * Class Nginx_Helper_Activator
+ */
class Nginx_Helper_Activator {
/**
@@ -19,11 +23,15 @@ class Nginx_Helper_Activator {
* Schedule event to check log file size daily.
*
* @since 2.0.0
+ *
+ * @global Nginx_Helper_Admin $nginx_helper_admin
*/
public static function activate() {
- global $wp_roles, $nginx_helper_admin;
+
+ global $nginx_helper_admin;
$path = $nginx_helper_admin->functional_asset_path();
+
if ( ! is_dir( $path ) ) {
mkdir( $path );
}
@@ -35,16 +43,21 @@ public static function activate() {
$role = get_role( 'administrator' );
if ( empty( $role ) ) {
+
update_site_option(
'rt_wp_nginx_helper_init_check',
__( 'Sorry, you need to be an administrator to use Nginx Helper', 'nginx-helper' )
);
+
return;
+
}
$role->add_cap( 'Nginx Helper | Config' );
$role->add_cap( 'Nginx Helper | Purge cache' );
wp_schedule_event( time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily' );
+
}
+
}
diff --git a/includes/class-nginx-helper-deactivator.php b/includes/class-nginx-helper-deactivator.php
index c767f92f..354c42d0 100644
--- a/includes/class-nginx-helper-deactivator.php
+++ b/includes/class-nginx-helper-deactivator.php
@@ -32,6 +32,7 @@ public static function deactivate() {
$role = get_role( 'administrator' );
$role->remove_cap( 'Nginx Helper | Config' );
$role->remove_cap( 'Nginx Helper | Purge cache' );
+
}
}
diff --git a/includes/class-nginx-helper-i18n.php b/includes/class-nginx-helper-i18n.php
index 11ae7d83..826d9769 100644
--- a/includes/class-nginx-helper-i18n.php
+++ b/includes/class-nginx-helper-i18n.php
@@ -1,5 +1,4 @@
domain = $domain;
diff --git a/includes/class-nginx-helper-loader.php b/includes/class-nginx-helper-loader.php
index e449c641..d1aceeeb 100644
--- a/includes/class-nginx-helper-loader.php
+++ b/includes/class-nginx-helper-loader.php
@@ -1,5 +1,4 @@
actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
@@ -71,11 +77,12 @@ public function add_action( $hook, $component, $callback, $priority = 10, $accep
* Add a new filter to the collection to be registered with WordPress.
*
* @since 2.0.0
- * @param string $hook The name of the WordPress filter that is being registered.
- * @param object $component A reference to the instance of the object on which the filter is defined.
- * @param string $callback The name of the function definition on the $component.
- * @param int Optional $priority The priority at which the function should be fired.
- * @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
+ *
+ * @param string $hook The name of the WordPress filter that is being registered.
+ * @param object $component A reference to the instance of the object on which the filter is defined.
+ * @param string $callback The name of the function definition on the $component.
+ * @param int $priority The priority at which the function should be fired.
+ * @param int $accepted_args The number of arguments that should be passed to the $callback.
*/
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
@@ -86,14 +93,17 @@ public function add_filter( $hook, $component, $callback, $priority = 10, $accep
* collection.
*
* @since 2.0.0
+ *
* @access private
- * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
- * @param string $hook The name of the WordPress filter that is being registered.
- * @param object $component A reference to the instance of the object on which the filter is defined.
- * @param string $callback The name of the function definition on the $component.
- * @param int Optional $priority The priority at which the function should be fired.
- * @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
- * @return type The collection of actions and filters registered with WordPress.
+ *
+ * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
+ * @param string $hook The name of the WordPress filter that is being registered.
+ * @param object $component A reference to the instance of the object on which the filter is defined.
+ * @param string $callback The name of the function definition on the $component.
+ * @param int $priority The priority at which the function should be fired.
+ * @param int $accepted_args The number of arguments that should be passed to the $callback.
+ *
+ * @return array The collection of actions and filters registered with WordPress.
*/
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
diff --git a/includes/class-nginx-helper.php b/includes/class-nginx-helper.php
index fd7d228d..5f6dd462 100644
--- a/includes/class-nginx-helper.php
+++ b/includes/class-nginx-helper.php
@@ -1,5 +1,4 @@
get_plugin_name(), $this->get_version() );
- if ( ! empty( $nginx_helper_admin->options['cache_method'] ) && $nginx_helper_admin->options['cache_method'] == 'enable_redis' ) {
+ // Defines global variables.
+ if ( ! empty( $nginx_helper_admin->options['cache_method'] ) && $nginx_helper_admin->options['cache_method'] === 'enable_redis' ) {
+
if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis extension if installed.
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-phpredis-purger.php';
$nginx_purger = new PhpRedis_Purger();
+
} else {
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-predis-purger.php';
$nginx_purger = new Predis_Purger();
+
}
+
} else {
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-fastcgi-purger.php';
$nginx_purger = new FastCGI_Purger();
+
}
$this->loader->add_action( 'admin_enqueue_scripts', $nginx_helper_admin, 'enqueue_styles' );
@@ -203,12 +210,12 @@ private function define_admin_hooks() {
$this->loader->add_action( 'add_init', $nginx_helper_admin, 'update_map' );
// Add actions to purge.
- $this->loader->add_action( 'wp_insert_comment', $nginx_purger, 'purgePostOnComment', 200, 2 );
- $this->loader->add_action( 'transition_comment_status', $nginx_purger, 'purgePostOnCommentChange', 200, 3 );
+ $this->loader->add_action( 'wp_insert_comment', $nginx_purger, 'purge_post_on_comment', 200, 2 );
+ $this->loader->add_action( 'transition_comment_status', $nginx_purger, 'purge_post_on_comment_change', 200, 3 );
$this->loader->add_action( 'transition_post_status', $nginx_helper_admin, 'set_future_post_option_on_future_status', 20, 3 );
$this->loader->add_action( 'delete_post', $nginx_helper_admin, 'unset_future_post_option_on_delete', 20, 1 );
- $this->loader->add_action( 'nm_check_log_file_size_daily', $nginx_purger, 'checkAndTruncateLogFile', 100, 1 );
- $this->loader->add_action( 'edit_attachment', $nginx_purger, 'purgeImageOnEdit', 100, 1 );
+ $this->loader->add_action( 'nm_check_log_file_size_daily', $nginx_purger, 'check_and_truncate_log_file', 100, 1 );
+ $this->loader->add_action( 'edit_attachment', $nginx_purger, 'purge_image_on_edit', 100, 1 );
$this->loader->add_action( 'wpmu_new_blog', $nginx_helper_admin, 'update_new_blog_options', 10, 1 );
$this->loader->add_action( 'transition_post_status', $nginx_purger, 'purge_on_post_moved_to_trash', 20, 3 );
$this->loader->add_action( 'edit_term', $nginx_purger, 'purge_on_term_taxonomy_edited', 20, 3 );
@@ -216,24 +223,8 @@ private function define_admin_hooks() {
$this->loader->add_action( 'check_ajax_referer', $nginx_purger, 'purge_on_check_ajax_referer', 20, 2 );
$this->loader->add_action( 'admin_init', $nginx_helper_admin, 'purge_all' );
- // expose action to allow other plugins to purge the cache
- $this->loader->add_action( 'rt_nginx_helper_purge_all', $nginx_purger, 'purgeAll' );
- }
-
- /**
- * Register all of the hooks related to the public-facing functionality
- * of the plugin.
- *
- * @since 2.0.0
- * @access private
- */
- private function define_public_hooks() {
-
- $plugin_public = new Nginx_Helper_Public( $this->get_plugin_name(), $this->get_version() );
-
- $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
- $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
-
+ // expose action to allow other plugins to purge the cache.
+ $this->loader->add_action( 'rt_nginx_helper_purge_all', $nginx_purger, 'purge_all' );
}
/**
@@ -260,7 +251,8 @@ public function get_plugin_name() {
* The reference to the class that orchestrates the hooks with the plugin.
*
* @since 2.0.0
- * @return Nginx_Helper_Loader Orchestrates the hooks of the plugin.
+ *
+ * @return Nginx_Helper_Loader Orchestrates the hooks of the plugin.
*/
public function get_loader() {
return $this->loader;
@@ -280,21 +272,27 @@ public function get_version() {
* Check wp version.
*
* @since 2.0.0
- * @global type $wp_version
+ *
+ * @global string $wp_version
+ *
* @return boolean
*/
public function required_wp_version() {
+
global $wp_version;
- $wp_ok = version_compare( $wp_version, $this->minimum_wp, '>=' );
+ $wp_ok = version_compare( $wp_version, $this->minimum_WP, '>=' );
if ( false === $wp_ok ) {
+
add_action( 'admin_notices', array( &$this, 'display_notices' ) );
add_action( 'network_admin_notices', array( &$this, 'display_notices' ) );
return false;
+
}
return true;
+
}
/**
diff --git a/includes/index.php b/includes/index.php
index e71af0ef..f0dd56b9 100644
--- a/includes/index.php
+++ b/includes/index.php
@@ -1 +1,8 @@
-
-
-
-
-
+
-
-
+
+ .*/languages/*
+ */admin/predis.php
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/readme.txt b/readme.txt
index 45544ea3..94dc13af 100644
--- a/readme.txt
+++ b/readme.txt
@@ -5,8 +5,8 @@ Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis,
License: GPLv2 or later (of-course)
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Requires at least: 3.0
-Tested up to: 4.9.5
-Stable tag: 1.9.11
+Tested up to: 4.9.8
+Stable tag: 1.9.12
Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
@@ -92,6 +92,19 @@ To purge a page immediately, follow these instructions:
* Just open this in a browser and the page will be purged instantly.
* Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
+= FAQ - Nginx Redis Cache =
+
+**Q. Can I override the redis hostname, port and prefix?**
+
+Yes, you can force override the redis hostname, port or prefix by defining constant in wp-config.php. For example:
+
+```
+define('RT_WP_NGINX_HELPER_REDIS_HOSTNAME', '10.0.0.1');
+
+define('RT_WP_NGINX_HELPER_REDIS_PORT', '6000');
+
+define('RT_WP_NGINX_HELPER_REDIS_PREFIX', 'page-cache:');
+```
= FAQ - Nginx Map =
@@ -114,6 +127,9 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
== Changelog ==
+= 1.9.12 =
+* Allow override Redis host/port/prefix by defining constant in wp-config.php [#152](https://github.com/rtCamp/nginx-helper/pull/152) - by [vincent-lu](https://github.com/vincent-lu)
+
= 1.9.11 =
* Fixed issue where permalinks without trailing slash does not purging [#124](https://github.com/rtCamp/nginx-helper/issues/124) - by Patrick
* Check whether role exist or not before removing capability. [#134](https://github.com/rtCamp/nginx-helper/pull/134) - by [1gor](https://github.com/1gor)
@@ -344,6 +360,5 @@ Fix url escaping [#82](https://github.com/rtCamp/nginx-helper/pull/82) - by
== Upgrade Notice ==
-= 1.9.11 =
-* Fixed issue where permalinks without trailing slash does not purging [#124](https://github.com/rtCamp/nginx-helper/issues/124) - by Patrick
-* Check whether role exist or not before removing capability. [#134](https://github.com/rtCamp/nginx-helper/pull/134) - by [1gor](https://github.com/1gor)
+= 1.9.12 =
+* Allow override Redis host/port/prefix by defining constant in wp-config.php [#152](https://github.com/rtCamp/nginx-helper/pull/152) - by [vincent-lu](https://github.com/vincent-lu)
diff --git a/uninstall.php b/uninstall.php
index 4f070208..dfa8d76a 100644
--- a/uninstall.php
+++ b/uninstall.php
@@ -1,5 +1,4 @@
purgeAll();
+ $nginx_purger->purge_all();
- $message = __( 'Purged Everything!' );
+ $message = __( 'Purged Everything!', 'nginx-helper' );
WP_CLI::success( $message );
}
From d3c134c7ea62fbf983eced9b3248d732157dbd15 Mon Sep 17 00:00:00 2001
From: Vaishali Agola
Date: Fri, 12 Oct 2018 15:09:45 +0530
Subject: [PATCH 3/8] Ignore filesytem operations in phpcs
---
phpcs.xml | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/phpcs.xml b/phpcs.xml
index 09f23b77..d3bc1193 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -24,7 +24,16 @@
*/admin/predis.php
-
+
+
+
+
+
+
+
+
+
+
\n" .
'';
- echo wp_kses( $timestamps, array() );
+ echo $timestamps;//wp_kses( $timestamps, array() );
}
@@ -636,7 +636,7 @@ public function purge_all() {
global $nginx_purger;
- $action = get_query_var( 'nginx_helper_action', false );
+ $action = filter_input( INPUT_GET, 'nginx_helper_action', FILTER_SANITIZE_STRING );
if ( empty( $action ) ) {
return;
@@ -671,7 +671,7 @@ public function purge_all() {
* Dispay plugin notices.
*/
public function display_notices() {
- echo '