Merge pull request #32 from plescheff/master Implemented changes and extension points for WP-FFPC-Purge.
Peter Molnar hello@petermolnar.eu
Tue, 27 Jan 2015 12:09:17 +0000
3 files changed,
49 insertions(+),
21 deletions(-)
M
wp-ffpc-backend.php
→
wp-ffpc-backend.php
@@ -77,6 +77,20 @@ /* info level */
$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 @@ /**
* 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 @@
/* 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; - } + /* run clear */ + $this->clear_keys( $to_clear ); + } - /* 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 */ + 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 ); }
M
wp-ffpc-class.php
→
wp-ffpc-class.php
@@ -445,13 +445,12 @@ </div>
<form autocomplete="off" method="post" action="#" id="<?php echo $this->plugin_constant ?>-settings" class="plugin-admin"> <?php wp_nonce_field( $this->plugin_constant ); ?> + + <?php $switcher_tabs = $this->plugin_admin_panel_get_tabs(); ?> <ul class="tabs"> - <li><a href="#<?php echo $this->plugin_constant ?>-type" class="wp-switch-editor"><?php _e( 'Cache type', $this->plugin_constant ); ?></a></li> - <li><a href="#<?php echo $this->plugin_constant ?>-debug" class="wp-switch-editor"><?php _e( 'Debug & in-depth', $this->plugin_constant ); ?></a></li> - <li><a href="#<?php echo $this->plugin_constant ?>-exceptions" class="wp-switch-editor"><?php _e( 'Cache exceptions', $this->plugin_constant ); ?></a></li> - <li><a href="#<?php echo $this->plugin_constant ?>-servers" class="wp-switch-editor"><?php _e( 'Backend settings', $this->plugin_constant ); ?></a></li> - <li><a href="#<?php echo $this->plugin_constant ?>-nginx" class="wp-switch-editor"><?php _e( 'nginx', $this->plugin_constant ); ?></a></li> - <li><a href="#<?php echo $this->plugin_constant ?>-precache" class="wp-switch-editor"><?php _e( 'Precache & precache log', $this->plugin_constant ); ?></a></li> + <?php foreach($switcher_tabs AS $tab_section => $tab_label): ?> + <li><a href="#<?= $this->plugin_constant ?>-<?= $tab_section ?>" class="wp-switch-editor"><?= $tab_label ?></a></li> + <?php endforeach; ?> </ul> <fieldset id="<?php echo $this->plugin_constant ?>-type">@@ -785,6 +784,8 @@ </table></div>
<?php } ?> </fieldset> + <?php do_action('wp_ffpc_admin_panel_tabs_extra_content', $this->plugin_constant); ?> + <p class="clear"> <input class="button-primary" type="submit" name="<?php echo $this->button_save ?>" id="<?php echo $this->button_save ?>" value="<?php _e('Save Changes', $this->plugin_constant ) ?>" /> </p>@@ -844,6 +845,19 @@ </div>
<?php } + private function plugin_admin_panel_get_tabs() { + $default_tabs = array( + 'type' => __( '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 *@@ -1248,6 +1262,10 @@ if ( !isset ( $this->options['log'] ) || $this->options['log'] != 1 )
return false; else $this->utils->log ( $this->plugin_constant, $message, $log_level ); + } + + public function getBackend() { + return $this->backend; } }
M
wp-ffpc.php
→
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 <hello@petermolnar.eu> Author URI: http://petermolnar.eu/ License: GPLv3