| 1 |
<?php |
| 2 |
/** |
| 3 |
* Functions to improve compatibility with W3TC. |
| 4 |
* |
| 5 |
* @package Charitable/Functions/Compatibility |
| 6 |
* @version 1.4.18 |
| 7 |
* @author David Bisset |
| 8 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 9 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 10 |
*/ |
| 11 |
|
| 12 |
// Exit if accessed directly. |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Clear the campaign page cache after a donation is received. |
| 19 |
* |
| 20 |
* @since 1.4.18 |
| 21 |
* |
| 22 |
* @param int $campaign_id The campaign ID. |
| 23 |
* @return void |
| 24 |
*/ |
| 25 |
function charitable_compat_w3tc_clear_campaign_cache( $campaign_id ) { |
| 26 |
if ( function_exists( 'w3tc_flush_post' ) ) { |
| 27 |
w3tc_flush_post( $campaign_id ); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
add_action( 'charitable_flush_campaign_cache', 'charitable_compat_w3tc_clear_campaign_cache' ); |
| 32 |
|
| 33 |
/** |
| 34 |
* When W3TC database caching is turned on, notices can be |
| 35 |
* triggered during donation processing. |
| 36 |
* |
| 37 |
* DONOTCACHEDB is a constant which will, by default, prevent |
| 38 |
* database caching. |
| 39 |
* |
| 40 |
* @see https://github.com/Charitable/Charitable/issues/347 |
| 41 |
* |
| 42 |
* @since 1.4.18 |
| 43 |
* |
| 44 |
* @return void |
| 45 |
*/ |
| 46 |
function charitable_compat_w3tc_turn_off_donation_cache() { |
| 47 |
if ( ! defined( 'DONOTCACHEDB' ) ) { |
| 48 |
define( 'DONOTCACHEDB', true ); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
add_action( 'charitable_before_save_donation', 'charitable_compat_w3tc_turn_off_donation_cache' ); |
| 53 |
|