Permalink
Browse files

Add wpsc_cookies and wpsc_plugins related actions to modify those set…

…tings (#582)

This PR adds four actions to modify wpsc_cookies and wpsc_plugins:

* wpsc_add_plugin
* wpsc_delete_plugin
* wpsc_add_cookie
* wpsc_delete_cookie

These actions will allow WordPress plugins to modify the cookies and
plugins lists used by WP Super Cache instead of the add/delete functions
introduced in #574 and #580.
Duplicate entries are removed. Example code:

For example, to add a cookie name called 'euCookie':

`do_action( 'wpsc_add_cookie', 'euCookie' );`

To remove that cookie:

`do_action( 'wpsc_delete_cookie', 'euCookie' );`
  • Loading branch information...
donnchawp committed Aug 9, 2018
1 parent b3e4857 commit b9e1dfd519156ac1fc9e55e134fe8f1871c51b75
Showing with 10 additions and 0 deletions.
  1. +10 −0 wp-cache.php
@@ -83,9 +83,11 @@ function wpsc_init() {
}
function wp_super_cache_init_action() {
load_plugin_textdomain( 'wp-super-cache', false, basename( dirname( __FILE__ ) ) . '/languages' );
wpsc_register_post_hooks();
}
add_action( 'init', 'wp_super_cache_init_action' );
@@ -4075,7 +4077,9 @@ function wpsc_add_plugin( $file ) {
$wpsc_plugins[] = $file;
wp_cache_setting( 'wpsc_plugins', $wpsc_plugins );
}
return $file;
}
add_action( 'wpsc_add_plugin', 'wpsc_add_plugin' );
function wpsc_delete_plugin( $file ) {
global $wpsc_plugins;
@@ -4090,7 +4094,9 @@ function wpsc_delete_plugin( $file ) {
unset( $wpsc_plugins[ array_search( $file, $wpsc_plugins ) ] );
wp_cache_setting( 'wpsc_plugins', $wpsc_plugins );
}
return $file;
}
add_action( 'wpsc_delete_plugin', 'wpsc_delete_plugin' );
function wpsc_get_plugins() {
global $wpsc_plugins;
@@ -4107,7 +4113,9 @@ function wpsc_add_cookie( $name ) {
$wpsc_cookies[] = $name;
wp_cache_setting( 'wpsc_cookies', $wpsc_cookies );
}
return $name;
}
add_action( 'wpsc_add_cookie', 'wpsc_add_cookie' );
function wpsc_delete_cookie( $name ) {
global $wpsc_cookies;
@@ -4119,7 +4127,9 @@ function wpsc_delete_cookie( $name ) {
unset( $wpsc_cookies[ array_search( $name, $wpsc_cookies ) ] );
wp_cache_setting( 'wpsc_cookies', $wpsc_cookies );
}
return $name;
}
add_action( 'wpsc_delete_cookie', 'wpsc_delete_cookie' );
function wpsc_get_cookies() {
global $wpsc_cookies;

0 comments on commit b9e1dfd

Please sign in to comment.