Created
June 1, 2023 16:33
-
-
Save jasonbahl/bb51b7193467673bea7d174e188daa4c to your computer and use it in GitHub Desktop.
Listen to custom events and call purge
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
add_action( 'graphql_cache_invalidation_init', static function( \WPGraphQL\SmartCache\Cache\Invalidation $invalidation ) { | |
add_action( 'updated_option', static function( $option, $value, $original_value ) use ( $invalidation ) { | |
// phpcs:ignore | |
if ( ! isset( $_POST['_acf_screen'] ) || 'options' !== $_POST['_acf_screen'] ) { | |
return; | |
} | |
// phpcs:ignore | |
$options_page = isset( $_GET['page'] ) ? $_GET['page'] : null; | |
if ( empty( $options_page ) ) { | |
return; | |
} | |
$invalidation->purge( 'graphql:Query', sprintf( 'update_acf_options_page ( "%s" )', $options_page ) ); | |
}, 10, 4 ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment