Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonbahl/bb51b7193467673bea7d174e188daa4c to your computer and use it in GitHub Desktop.
Save jasonbahl/bb51b7193467673bea7d174e188daa4c to your computer and use it in GitHub Desktop.
Listen to custom events and call purge
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