Created
March 2, 2020 08:14
-
-
Save jonathan-dejong/08d1957bf75271e7b33d65dbc0c0d854 to your computer and use it in GitHub Desktop.
Drop cache on ACF options page update
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
// This is in the context of a namespaced class. | |
public function acf_save_post( $post_id ) { | |
// Retrieves all acf option page slugs. | |
$option_slugs = array_unique( | |
array_map( | |
function( $options_page ) { | |
return $options_page['post_id']; | |
}, | |
acf_get_option_pages() | |
) | |
); | |
// This is not the post_id you're looking for… | |
if ( ! in_array( $post_id, $slugs, true ) ) { | |
return; | |
} | |
// Drop it like it's hot! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment