| 1 |
<?php |
| 2 |
/** |
| 3 |
* Functions to improve compatibility with WP Super Cache. |
| 4 |
* |
| 5 |
* @package Charitable/Functions/Compatibility |
| 6 |
* @author David Bisset |
| 7 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.4.18 |
| 10 |
* @version 1.6.46 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Clear the campaign page cache after a donation is received. |
| 20 |
* |
| 21 |
* @since 1.4.18 |
| 22 |
* |
| 23 |
* @param int $campaign_id The campaign ID. |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
function charitable_compat_wp_super_cache_clear_campaign_cache( $campaign_id ) { |
| 27 |
/* Set super cache to enabled. */ |
| 28 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- $GLOBALS['super_cache_enabled'] is a third-party global variable used by WP Super Cache plugin for compatibility. |
| 29 |
$GLOBALS['super_cache_enabled'] = 1; |
| 30 |
|
| 31 |
if ( ! function_exists( 'wp_cache_post_change' ) ) { |
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
wp_cache_post_change( $campaign_id ); |
| 36 |
} |
| 37 |
|
| 38 |
add_action( 'charitable_flush_campaign_cache', 'charitable_compat_wp_super_cache_clear_campaign_cache' ); |
| 39 |
|
| 40 |
/** |
| 41 |
* Prevent caching on certain Charitable pages. |
| 42 |
* |
| 43 |
* @deprecated 1.9.0 |
| 44 |
* |
| 45 |
* @since 1.5.4 |
| 46 |
* @since 1.6.14 Deprecated. |
| 47 |
* |
| 48 |
* @return void |
| 49 |
*/ |
| 50 |
function charitable_compat_wp_super_cache_disable_cache() { |
| 51 |
charitable_get_deprecated()->deprecated_function( |
| 52 |
__FUNCTION__, |
| 53 |
'1.6.14', |
| 54 |
'charitable()->endpoints()->disable_endpoint_cache()' |
| 55 |
); |
| 56 |
|
| 57 |
charitable()->endpoints()->disable_endpoint_cache(); |
| 58 |
} |
| 59 |
|