- reordering advanced cache exceptions
- adding upgrade hook
This commit is contained in:
parent
84f23c9548
commit
37d3e25cea
4 changed files with 58 additions and 54 deletions
18
readme.txt
18
readme.txt
|
@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
||||||
Tags: cache, page cache, full page cache, nginx, memcached, apc, speed
|
Tags: cache, page cache, full page cache, nginx, memcached, apc, speed
|
||||||
Requires at least: 3.0
|
Requires at least: 3.0
|
||||||
Tested up to: 4.1
|
Tested up to: 4.1
|
||||||
Stable tag: 1.7.7
|
Stable tag: 1.7.9
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
@ -125,6 +125,22 @@ Version numbering logic:
|
||||||
* every .B version indicates new features.
|
* every .B version indicates new features.
|
||||||
* every ..C indicates bugfixes for A.B version.
|
* every ..C indicates bugfixes for A.B version.
|
||||||
|
|
||||||
|
= 1.7.9 =
|
||||||
|
*2015-01-30*
|
||||||
|
|
||||||
|
What's new:
|
||||||
|
|
||||||
|
* added auto-upgrade for advanced-cache.php on plugin upgrade
|
||||||
|
|
||||||
|
|
||||||
|
= 1.7.8 =
|
||||||
|
*2015-01-30*
|
||||||
|
|
||||||
|
What's new:
|
||||||
|
|
||||||
|
* merged pull request for [wp-ffpc-purge](https://github.com/zeroturnaround/wp-ffpc-purge)
|
||||||
|
|
||||||
|
|
||||||
= 1.7.7 =
|
= 1.7.7 =
|
||||||
*2015-01-14*
|
*2015-01-14*
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
if ( !WP_CACHE )
|
if ( !WP_CACHE )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* check for config */
|
|
||||||
if (!isset($wp_ffpc_config))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* no cache for post request (comments, plugins and so on) */
|
/* no cache for post request (comments, plugins and so on) */
|
||||||
if ($_SERVER["REQUEST_METHOD"] == 'POST')
|
if ($_SERVER["REQUEST_METHOD"] == 'POST')
|
||||||
return false;
|
return false;
|
||||||
|
@ -22,14 +18,13 @@ if ($_SERVER["REQUEST_METHOD"] == 'POST')
|
||||||
if (defined('SID') && SID != '')
|
if (defined('SID') && SID != '')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* check for config */
|
||||||
|
if (!isset($wp_ffpc_config))
|
||||||
|
return false;
|
||||||
|
|
||||||
/* request uri */
|
/* request uri */
|
||||||
$wp_ffpc_uri = $_SERVER['REQUEST_URI'];
|
$wp_ffpc_uri = $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
|
|
||||||
/* no cache for uri with query strings, things usually go bad that way */
|
|
||||||
if ( isset($wp_ffpc_config['nocache_dyn']) && !empty($wp_ffpc_config['nocache_dyn']) && stripos($wp_ffpc_uri, '?') !== false )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* no cache for robots.txt */
|
/* no cache for robots.txt */
|
||||||
if ( stripos($wp_ffpc_uri, 'robots.txt') )
|
if ( stripos($wp_ffpc_uri, 'robots.txt') )
|
||||||
return false;
|
return false;
|
||||||
|
@ -48,6 +43,10 @@ elseif ( !empty ( $wp_ffpc_config[ $_SERVER['HTTP_HOST'] ] ) )
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* no cache for uri with query strings, things usually go bad that way */
|
||||||
|
if ( isset($wp_ffpc_config['nocache_dyn']) && !empty($wp_ffpc_config['nocache_dyn']) && stripos($wp_ffpc_uri, '?') !== false )
|
||||||
|
return false;
|
||||||
|
|
||||||
/* check for cookies that will make us not cache the content, like logged in WordPress cookie */
|
/* check for cookies that will make us not cache the content, like logged in WordPress cookie */
|
||||||
if ( isset($wp_ffpc_config['nocache_cookies']) && !empty($wp_ffpc_config['nocache_cookies']) ) {
|
if ( isset($wp_ffpc_config['nocache_cookies']) && !empty($wp_ffpc_config['nocache_cookies']) ) {
|
||||||
$nocache_cookies = array_map('trim',explode(",", $wp_ffpc_config['nocache_cookies'] ) );
|
$nocache_cookies = array_map('trim',explode(",", $wp_ffpc_config['nocache_cookies'] ) );
|
||||||
|
|
|
@ -176,20 +176,11 @@ class WP_FFPC extends PluginAbstract {
|
||||||
/* initiate backend */
|
/* initiate backend */
|
||||||
$this->backend = new WP_FFPC_Backend ( $this->options );
|
$this->backend = new WP_FFPC_Backend ( $this->options );
|
||||||
|
|
||||||
/* get all available post types *
|
/* re-save settings after update */
|
||||||
$post_types = get_post_types( );*/
|
add_action( 'upgrader_process_complete', array ( &$this->plugin_upgrade ), 10, 2 );
|
||||||
|
|
||||||
/* cache invalidation hooks */
|
/* cache invalidation hooks */
|
||||||
add_action( 'transition_post_status', array( &$this->backend , 'clear_ng' ), 10, 3 );
|
add_action( 'transition_post_status', array( &$this->backend , 'clear_ng' ), 10, 3 );
|
||||||
/*
|
|
||||||
foreach ( $post_types as $post_type ) {
|
|
||||||
add_action( 'new_to_publish_' .$post_type , array( &$this->backend , 'clear' ), 0 );
|
|
||||||
add_action( 'draft_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 );
|
|
||||||
add_action( 'pending_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 );
|
|
||||||
add_action( 'private_to_publish' .$post_type , array( &$this->backend , 'clear' ), 0 );
|
|
||||||
add_action( 'publish_' . $post_type , array( &$this->backend , 'clear' ), 0 );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* comments invalidation hooks */
|
/* comments invalidation hooks */
|
||||||
if ( $this->options['comments_invalidate'] ) {
|
if ( $this->options['comments_invalidate'] ) {
|
||||||
|
@ -199,7 +190,6 @@ class WP_FFPC extends PluginAbstract {
|
||||||
add_action( 'pingback_post', array( &$this->backend , 'clear' ), 0 );
|
add_action( 'pingback_post', array( &$this->backend , 'clear' ), 0 );
|
||||||
add_action( 'trackback_post', array( &$this->backend , 'clear' ), 0 );
|
add_action( 'trackback_post', array( &$this->backend , 'clear' ), 0 );
|
||||||
add_action( 'wp_insert_comment', array( &$this->backend , 'clear' ), 0 );
|
add_action( 'wp_insert_comment', array( &$this->backend , 'clear' ), 0 );
|
||||||
add_action( '', array( &$this->backend , 'clear' ), 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invalidation on some other ocasions as well */
|
/* invalidation on some other ocasions as well */
|
||||||
|
@ -211,28 +201,30 @@ class WP_FFPC extends PluginAbstract {
|
||||||
if ( WP_CACHE )
|
if ( WP_CACHE )
|
||||||
add_filter('redirect_canonical', 'wp_ffpc_redirect_callback', 10, 2);
|
add_filter('redirect_canonical', 'wp_ffpc_redirect_callback', 10, 2);
|
||||||
|
|
||||||
/* clean up schedule if needed */
|
|
||||||
if ( !isset( $this->options['precache_schedule'] ) || $this->options['precache_schedule'] == 'null' ) {
|
|
||||||
$this->log ( sprintf ( __( 'clearing scheduled hook %s', $this->plugin_constant ), self::precache_id ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add precache coldrun action */
|
/* add precache coldrun action */
|
||||||
add_action( self::precache_id , array( &$this, 'precache_coldrun' ) );
|
add_action( self::precache_id , array( &$this, 'precache_coldrun' ) );
|
||||||
|
|
||||||
|
/* link on to settings for plugins page */
|
||||||
$settings_link = ' » <a href="' . $this->settings_link . '">' . __( 'WP-FFPC Settings', $this->plugin_constant ) . '</a>';
|
$settings_link = ' » <a href="' . $this->settings_link . '">' . __( 'WP-FFPC Settings', $this->plugin_constant ) . '</a>';
|
||||||
/* check for errors */
|
|
||||||
|
/* check & collect errors */
|
||||||
|
/* look for WP_CACHE */
|
||||||
if ( ! WP_CACHE )
|
if ( ! WP_CACHE )
|
||||||
$this->errors['no_wp_cache'] = __("WP_CACHE is disabled, plugin will not work that way. Please add `define ( 'WP_CACHE', true );` to wp-config.php", $this->plugin_constant ) . $settings_link;
|
$this->errors['no_wp_cache'] = __("WP_CACHE is disabled, plugin will not work that way. Please add `define ( 'WP_CACHE', true );` to wp-config.php", $this->plugin_constant ) . $settings_link;
|
||||||
|
|
||||||
|
/* look for global settings array */
|
||||||
if ( ! $this->global_saved )
|
if ( ! $this->global_saved )
|
||||||
$this->errors['no_global_saved'] = __("Plugin settings are not yet saved for the site, please save settings!", $this->plugin_constant) . $settings_link;
|
$this->errors['no_global_saved'] = __("Plugin settings are not yet saved for the site, please save settings!", $this->plugin_constant) . $settings_link;
|
||||||
|
|
||||||
if ( ! file_exists ( $this->acache ) )
|
/* look for writable acache file */
|
||||||
$this->errors['no_acache_saved'] = __("Advanced cache file is yet to be generated, please save settings!", $this->plugin_constant). $settings_link;
|
|
||||||
|
|
||||||
if ( file_exists ( $this->acache ) && ! is_writable ( $this->acache ) )
|
if ( file_exists ( $this->acache ) && ! is_writable ( $this->acache ) )
|
||||||
$this->errors['no_acache_write'] = __("Advanced cache file is not writeable!<br />Please change the permissions on the file: ", $this->plugin_constant) . $this->acache;
|
$this->errors['no_acache_write'] = __("Advanced cache file is not writeable!<br />Please change the permissions on the file: ", $this->plugin_constant) . $this->acache;
|
||||||
|
|
||||||
|
/* look for acache file */
|
||||||
|
if ( ! file_exists ( $this->acache ) )
|
||||||
|
$this->errors['no_acache_saved'] = __("Advanced cache file is yet to be generated, please save settings!", $this->plugin_constant). $settings_link;
|
||||||
|
|
||||||
|
/* look for extensions that should be available */
|
||||||
foreach ( $this->valid_cache_type as $backend => $status ) {
|
foreach ( $this->valid_cache_type as $backend => $status ) {
|
||||||
if ( $this->options['cache_type'] == $backend && ! $status ) {
|
if ( $this->options['cache_type'] == $backend && ! $status ) {
|
||||||
$this->errors['no_backend'] = sprintf ( __('%s cache backend activated but no PHP %s extension was found.<br />Please either use different backend or activate the module!', $this->plugin_constant), $backend, $backend );
|
$this->errors['no_backend'] = sprintf ( __('%s cache backend activated but no PHP %s extension was found.<br />Please either use different backend or activate the module!', $this->plugin_constant), $backend, $backend );
|
||||||
|
@ -287,6 +279,18 @@ class WP_FFPC extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* once upgrade is finished, deploy advanced cache and save the new settings, just in case
|
||||||
|
*/
|
||||||
|
public function plugin_upgrade ( $upgrader_object, $hook_extra ) {
|
||||||
|
if (is_plugin_active( $this->plugin_constant . DIRECTORY_SEPARATOR . $this->plugin_constant . '.php' )) {
|
||||||
|
$this->update_global_config();
|
||||||
|
$this->plugin_options_save();
|
||||||
|
$this->deploy_advanced_cache();
|
||||||
|
$this->utils->alert ( __('WP-FFPC settings were upgraded; please double check if everything is still working correctly.', $this->plugin_constant ), LOG_NOTICE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extending admin init
|
* extending admin init
|
||||||
*
|
*
|
||||||
|
@ -563,6 +567,9 @@ class WP_FFPC extends PluginAbstract {
|
||||||
|
|
||||||
<fieldset id="<?php echo $this->plugin_constant ?>-debug">
|
<fieldset id="<?php echo $this->plugin_constant ?>-debug">
|
||||||
<legend><?php _e( 'Debug & in-depth settings', $this->plugin_constant ); ?></legend>
|
<legend><?php _e( 'Debug & in-depth settings', $this->plugin_constant ); ?></legend>
|
||||||
|
<h3><?php _e('Notes', $this->plugin_constant);?></h3>
|
||||||
|
<p><?php _e('The former method of debug logging flag has been removed. In case you need debug log from WP-FFPC please set the <a href="http://codex.wordpress.org/WP_DEBUG">WP_DEBUG</a> constant `true`.<br /> This will enable NOTICE level messages apart from the WARNING level ones which are always displayed.', $this->plugin_constant); ?></p>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>
|
<dt>
|
||||||
<label for="pingback_header"><?php _e('Enable X-Pingback header preservation', $this->plugin_constant); ?></label>
|
<label for="pingback_header"><?php _e('Enable X-Pingback header preservation', $this->plugin_constant); ?></label>
|
||||||
|
@ -572,14 +579,6 @@ class WP_FFPC extends PluginAbstract {
|
||||||
<span class="description"><?php _e('Preserve X-Pingback URL in response header.', $this->plugin_constant); ?></span>
|
<span class="description"><?php _e('Preserve X-Pingback URL in response header.', $this->plugin_constant); ?></span>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>
|
|
||||||
<label for="log"><?php _e("Enable logging", $this->plugin_constant); ?></label>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<input type="checkbox" name="log" id="log" value="1" <?php checked($this->options['log'],true); ?> />
|
|
||||||
<span class="description"><?php _e('Enables log messages; if <a href="http://codex.wordpress.org/WP_DEBUG">WP_DEBUG</a> is enabled, notices and info level is displayed as well, otherwie only ERRORS are logged.', $this->plugin_constant); ?></span>
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt>
|
<dt>
|
||||||
<label for="response_header"><?php _e("Add X-Cache-Engine header", $this->plugin_constant); ?></label>
|
<label for="response_header"><?php _e("Add X-Cache-Engine header", $this->plugin_constant); ?></label>
|
||||||
</dt>
|
</dt>
|
||||||
|
@ -597,6 +596,7 @@ class WP_FFPC extends PluginAbstract {
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset id="<?php echo $this->plugin_constant ?>-exceptions">
|
<fieldset id="<?php echo $this->plugin_constant ?>-exceptions">
|
||||||
|
@ -869,11 +869,11 @@ class WP_FFPC extends PluginAbstract {
|
||||||
if ( $this->options['precache_schedule'] != 'null' ) {
|
if ( $this->options['precache_schedule'] != 'null' ) {
|
||||||
/* clear all other schedules before adding a new in order to replace */
|
/* clear all other schedules before adding a new in order to replace */
|
||||||
wp_clear_scheduled_hook ( self::precache_id );
|
wp_clear_scheduled_hook ( self::precache_id );
|
||||||
$this->log ( __( 'Scheduling WP-CRON event', $this->plugin_constant ) );
|
$this->utils->log ( $this->plugin_constant, __( 'Scheduling WP-CRON event', $this->plugin_constant ) );
|
||||||
$this->scheduled = wp_schedule_event( time(), $this->options['precache_schedule'] , self::precache_id );
|
$this->scheduled = wp_schedule_event( time(), $this->options['precache_schedule'] , self::precache_id );
|
||||||
}
|
}
|
||||||
elseif ( ( !isset($this->options['precache_schedule']) || $this->options['precache_schedule'] == 'null' ) && !empty( $schedule ) ) {
|
elseif ( ( !isset($this->options['precache_schedule']) || $this->options['precache_schedule'] == 'null' ) && !empty( $schedule ) ) {
|
||||||
$this->log ( __('Clearing WP-CRON scheduled hook ' , $this->plugin_constant ) );
|
$this->utils->log ( $this->plugin_constant, __('Clearing WP-CRON scheduled hook ' , $this->plugin_constant ) );
|
||||||
wp_clear_scheduled_hook ( self::precache_id );
|
wp_clear_scheduled_hook ( self::precache_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1253,17 +1253,6 @@ class WP_FFPC extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* log wrapper to include options
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function log ( $message, $log_level = LOG_NOTICE ) {
|
|
||||||
if ( !isset ( $this->options['log'] ) || $this->options['log'] != 1 )
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
$this->utils->log ( $this->plugin_constant, $message, $log_level );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBackend() {
|
public function getBackend() {
|
||||||
return $this->backend;
|
return $this->backend;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Plugin Name: WP-FFPC
|
Plugin Name: WP-FFPC
|
||||||
Plugin URI: https://github.com/petermolnar/wp-ffpc
|
Plugin URI: https://github.com/petermolnar/wp-ffpc
|
||||||
Description: WordPress in-memory full page cache plugin
|
Description: WordPress in-memory full page cache plugin
|
||||||
Version: 1.7.8
|
Version: 1.7.9
|
||||||
Author: Peter Molnar <hello@petermolnar.eu>
|
Author: Peter Molnar <hello@petermolnar.eu>
|
||||||
Author URI: http://petermolnar.eu/
|
Author URI: http://petermolnar.eu/
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
|
@ -58,6 +58,6 @@ $wp_ffpc_defaults = array (
|
||||||
'pingback_header' => false,
|
'pingback_header' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.7.4', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
|
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.7.9', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue