From 17669f272bccbda75e68ee3087ec65f71bbc3d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Peles=CC=8Cev?= Date: Tue, 20 Jan 2015 21:31:13 +0200 Subject: [PATCH] Implemented changes and extension points for WP-FFPC-Purge. --- wp-ffpc-backend.php | 38 ++++++++++++++++++++++++-------------- wp-ffpc-class.php | 30 ++++++++++++++++++++++++------ wp-ffpc.php | 2 +- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/wp-ffpc-backend.php b/wp-ffpc-backend.php index 99889be..de6fa40 100644 --- a/wp-ffpc-backend.php +++ b/wp-ffpc-backend.php @@ -77,6 +77,20 @@ class WP_FFPC_Backend { $this->log ( __translate__('init starting', $this->plugin_constant )); $this->$init(); + + if (is_admin() && function_exists('add_filter')) { + add_filter('wp_ffpc_clear_keys_array', function($to_clear, $options) { + $filtered_result = array(); + foreach ( $to_clear as $link => $dummy ) { + /* clear feeds, meta and data as well */ + $filtered_result[ $options[ 'prefix_meta' ] . $link ] = true; + $filtered_result[ $options[ 'prefix_data' ] . $link ] = true; + $filtered_result[ $options[ 'prefix_meta' ] . $link . 'feed' ] = true; + $filtered_result[ $options[ 'prefix_data' ] . $link . 'feed' ] = true; + } + return $filtered_result; + }, 10, 2); + } } @@ -106,11 +120,14 @@ class WP_FFPC_Backend { * build key to make requests with * * @param string $prefix prefix to add to prefix + * @param array $customUrimap to override defaults * */ - public function key ( &$prefix ) { + public function key ( $prefix, $customUrimap = null ) { + $urimap = $customUrimap ?: $this->urimap; + /* data is string only with content, meta is not used in nginx */ - $key = $prefix . self::map_urimap($this->urimap, $this->options['key']); + $key = $prefix . self::map_urimap($urimap, $this->options['key']); $this->log ( sprintf( __translate__( 'original key configuration: %s', $this->plugin_constant ), $this->options['key'] ) ); $this->log ( sprintf( __translate__( 'setting key to: %s', $this->plugin_constant ), $key ) ); return $key; @@ -283,19 +300,12 @@ class WP_FFPC_Backend { /* Hook to custom clearing array. */ $to_clear = apply_filters('wp_ffpc_to_clear_array', $to_clear, $post_id); - foreach ( $to_clear as $link => $dummy ) { - /* clear all feeds as well */ - $to_clear[ $link. 'feed' ] = true; - } - - /* add data & meta prefixes */ - foreach ( $to_clear as $link => $dummy ) { - unset ( $to_clear [ $link ]); - $to_clear[ $this->options[ 'prefix_meta' ] . $link ] = true; - $to_clear[ $this->options[ 'prefix_data' ] . $link ] = true; - } - /* run clear */ + $this->clear_keys( $to_clear ); + } + + public function clear_keys( $keys ) { + $to_clear = apply_filters('wp_ffpc_clear_keys_array', $keys, $this->options); $internal = $this->proxy ( 'clear' ); $this->$internal ( $to_clear ); } diff --git a/wp-ffpc-class.php b/wp-ffpc-class.php index dbfbf75..76fb621 100644 --- a/wp-ffpc-class.php +++ b/wp-ffpc-class.php @@ -445,13 +445,12 @@ class WP_FFPC extends PluginAbstract {
plugin_constant ); ?> + + plugin_admin_panel_get_tabs(); ?>
@@ -785,6 +784,8 @@ class WP_FFPC extends PluginAbstract {
+ plugin_constant); ?> +

@@ -844,6 +845,19 @@ class WP_FFPC extends PluginAbstract { __( 'Cache type', $this->plugin_constant ), + 'debug' => __( 'Debug & in-depth', $this->plugin_constant ), + 'exceptions' => __( 'Cache exceptions', $this->plugin_constant ), + 'servers' => __( 'Backend settings', $this->plugin_constant ), + 'nginx' => __( 'nginx', $this->plugin_constant ), + 'precache' => __( 'Precache & precache log', $this->plugin_constant ) + ); + + return apply_filters('wp_ffpc_admin_panel_tabs', $default_tabs); + } + /** * extending options_save * @@ -1251,6 +1265,10 @@ class WP_FFPC extends PluginAbstract { $this->utils->log ( $this->plugin_constant, $message, $log_level ); } + public function getBackend() { + return $this->backend; + } + } endif; diff --git a/wp-ffpc.php b/wp-ffpc.php index 2cf4c77..de9c952 100644 --- a/wp-ffpc.php +++ b/wp-ffpc.php @@ -3,7 +3,7 @@ Plugin Name: WP-FFPC Plugin URI: https://github.com/petermolnar/wp-ffpc Description: WordPress in-memory full page cache plugin -Version: 1.7.7 +Version: 1.7.8 Author: Peter Molnar Author URI: http://petermolnar.eu/ License: GPLv3