Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/f7ace1a85337e0bc9605 to your computer and use it in GitHub Desktop.
Save zackkatz/f7ace1a85337e0bc9605 to your computer and use it in GitHub Desktop.
Prevent Easy Digital Downloads discounts from being cached by W3TC
<?php
/**
* Plugin Name: EDD W3TC Fix Discount Codes
* Plugin URI: http://gravityview.co
* Description: Fix discount code caching issues for Easy Digital Downloads when using W3 Total Cache
* Version: 1.1
*/
if( function_exists( 'wp_suspend_cache_addition' ) ) {
add_action('edd_pre_update_discount', 'w3tc_fix_edd_discount_pre');
add_action('edd_pre_insert_discount', 'w3tc_fix_edd_discount_pre');
add_action('edd_pre_delete_discount', 'w3tc_fix_edd_discount_pre');
add_action('edd_pre_update_discount_status', 'w3tc_fix_edd_discount_pre');
add_action('edd_pre_remove_cart_discount', 'w3tc_fix_edd_discount_pre');
function w3tc_fix_edd_discount_pre() {
wp_suspend_cache_addition(true);
}
add_action('edd_post_update_discount', 'w3tc_fix_edd_discount_post');
add_action('edd_post_insert_discount', 'w3tc_fix_edd_discount_post');
add_action('edd_post_delete_discount', 'w3tc_fix_edd_discount_post');
add_action('edd_post_update_discount_status', 'w3tc_fix_edd_discount_post');
add_action('edd_post_remove_cart_discount', 'w3tc_fix_edd_discount_post');
function w3tc_fix_edd_discount_post() {
wp_suspend_cache_addition();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment