Set nocache constants on all nocache_headers
This commit is contained in:
parent
958bd092ba
commit
af1dce3544
|
@ -21,6 +21,7 @@ class WC_Cache_Helper {
|
|||
public static function init() {
|
||||
add_action( 'template_redirect', array( __CLASS__, 'geolocation_ajax_redirect' ) );
|
||||
add_action( 'wp', array( __CLASS__, 'prevent_caching' ) );
|
||||
add_filter( 'nocache_headers', array( __CLASS__, 'set_nocache_constants' ) );
|
||||
add_action( 'admin_notices', array( __CLASS__, 'notices' ) );
|
||||
add_action( 'delete_version_transients', array( __CLASS__, 'delete_version_transients' ) );
|
||||
}
|
||||
|
@ -158,16 +159,20 @@ class WC_Cache_Helper {
|
|||
$page_ids = array_filter( array( wc_get_page_id( 'cart' ), wc_get_page_id( 'checkout' ), wc_get_page_id( 'myaccount' ) ) );
|
||||
$current_page_id = get_queried_object_id();
|
||||
|
||||
if ( isset( $_GET['download_file'] ) || in_array( $current_page_id, $page_ids ) ) {
|
||||
self::nocache();
|
||||
if ( isset( $_GET['download_file'] ) || isset( $_GET['add-to-cart'] ) || in_array( $current_page_id, $page_ids ) ) {
|
||||
nocache_headers();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set nocache constants and headers.
|
||||
* @access private
|
||||
* Set constants to prevent caching by some plugins.
|
||||
*
|
||||
* Hooked into nocache_headers filter but does not change headers.
|
||||
*
|
||||
* @param array $value
|
||||
* @return array
|
||||
*/
|
||||
private static function nocache() {
|
||||
public static function set_nocache_constants( $value ) {
|
||||
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
|
||||
define( "DONOTCACHEPAGE", true );
|
||||
}
|
||||
|
@ -177,7 +182,7 @@ class WC_Cache_Helper {
|
|||
if ( ! defined( 'DONOTCACHEDB' ) ) {
|
||||
define( "DONOTCACHEDB", true );
|
||||
}
|
||||
nocache_headers();
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue