Last active
July 23, 2018 13:08
-
-
Save einkoro/11078440 to your computer and use it in GitHub Desktop.
Must-use plugin for WordPress to flush fields and post meta when using Advanced Custom Fields
This file contains hidden or 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
<?php | |
/** | |
* Plugin Name: WP ACF Obj Cache Fix | |
* Plugin URI: http://bitpiston.com/ | |
* Description: Fix for Advanced Custom Fields expiry with 3rd party Object Caches. | |
* Author: BitPiston Studios | |
* Author URI: http://bitpiston.com/ | |
* Version: 1.1.1 | |
* Licence: BSD | |
*/ | |
// Fix for Object Cache not flushing fields: | |
add_action( "acf/update_field", function( $field ) { | |
wp_cache_delete( 'load_field/key=' . $field['key'], 'acf' ); | |
return $field; | |
}, 5, 1 ); | |
// Flush post meta when saving a post: | |
add_action( "acf/save_post", function( $post_id ) { | |
wp_cache_delete( $post_id, 'post_meta' ); | |
}, 20, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Both these issues appear to still exist under v5.