Last active
August 29, 2015 14:04
-
-
Save zackkatz/f7ace1a85337e0bc9605 to your computer and use it in GitHub Desktop.
Prevent Easy Digital Downloads discounts from being cached by W3TC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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