|
<?php |
|
/** |
|
* Plugin Name: WP Rocket | AffiliateWP Cookie Cache |
|
* Description: Creates a specific cache for each affiliate ref ID. |
|
* Author: WP Rocket Support Team |
|
* Author URI: http://wp-rocket.me/ |
|
* Plugin URI: https://gist.github.com/glueckpress/d379c5534708f440942523fe205ec840 |
|
* License: GNU General Public License v3 or later |
|
* License URI: http://www.gnu.org/licenses/gpl-3.0.html |
|
*/ |
|
|
|
defined( 'ABSPATH' ) or die(); |
|
|
|
/** |
|
* Add Affiliate WP cookie ID to dynamic caches. |
|
* @param array $cookies Array of cookie IDs used for dynamic caches |
|
* @return array (Maybe) Extended array of cookie IDs |
|
*/ |
|
function wp_rocket_affiliate_wp__dynamic_cookie( $cookies ) { |
|
|
|
$cookies[] = 'affwp_ref'; |
|
|
|
return $cookies; |
|
} |
|
add_filter( 'rocket_cache_dynamic_cookies', 'wp_rocket_affiliate_wp__dynamic_cookie' ); |
|
|
|
/** |
|
* Updates .htaccess, and regenerates config file. |
|
* |
|
* @return bool |
|
*/ |
|
function wp_rocket_affiliate_wp__housekeeping() { |
|
|
|
if ( ! function_exists( 'flush_rocket_htaccess' ) |
|
|| ! function_exists( 'rocket_generate_config_file' ) ) { |
|
return false; |
|
} |
|
|
|
flush_rocket_htaccess(); |
|
rocket_generate_config_file(); |
|
|
|
return true; |
|
} |
|
register_activation_hook( __FILE__, 'wp_rocket_affiliate_wp__housekeeping' ); |
|
|
|
/** |
|
* Removes plugin additions, updates .htaccess, and regenerates config file. |
|
* |
|
* @return bool |
|
*/ |
|
function wp_rocket_affiliate_wp__deactivate() { |
|
|
|
remove_filter( 'rocket_cache_dynamic_cookies', 'wp_rocket_affiliate_wp__dynamic_cookie' ); |
|
|
|
wp_rocket_affiliate_wp__housekeeping(); |
|
} |
|
register_deactivation_hook( __FILE__, 'wp_rocket_affiliate_wp__deactivate' ); |