Skip to content

Instantly share code, notes, and snippets.

View kriskhoury's full-sized avatar
🏠
Working from home

Kris kriskhoury

🏠
Working from home
View GitHub Profile
@kriskhoury
kriskhoury / pantheon-wp-mu-cache-exception.php
Created June 9, 2021 15:25 — forked from cyberhobo/pantheon-wp-mu-cache-exception.php
Example of excluding a couple of checkout pages from Pantheon caching in a WordPress must-use plugin:
<?php
if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ) :
// Disable caching on checkout pages as per https://pantheon.io/docs/cache-control/
$regex_path_match = '#/foundation/donation-options/(checkout|shopping-cart)#';
if (preg_match($regex_path_match, $_SERVER['REQUEST_URI'])) {
// Use a later priority to make sure it runs after native Pantheon caching
add_action( 'send_headers', 'cth_add_header_nocache', 50 );
add_filter('acf/validate_value/name=validate_this_image', 'my_acf_validate_value', 10, 4);
function my_acf_validate_value( $valid, $value, $field, $input ){
// bail early if value is already invalid
if( !$valid ) {
return $valid;
}