Implemented changes and extension points for WP-FFPC-Purge.
This commit is contained in:
parent
5d86db9cb1
commit
17669f272b
3 changed files with 49 additions and 21 deletions
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -445,13 +445,12 @@ class WP_FFPC extends PluginAbstract {
|
|||
<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 @@ class WP_FFPC extends PluginAbstract {
|
|||
<?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 @@ class WP_FFPC extends PluginAbstract {
|
|||
<?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
|
||||
*
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue