Skip to content

Commit

Permalink
fix: Update clear cache function.
Browse files Browse the repository at this point in the history
  • Loading branch information
danimalweb committed Sep 16, 2024
1 parent 7e37fb2 commit 8a870e3
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions inc/lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,19 +341,10 @@ function truncate_excerpt_length($length)
// Clear cache on options save
function clear_cache_options_save($post_id)
{
$screen = get_current_screen();

if (strpos($screen->id, 'general-options') == true && $post_id == 'general-options') {
// Clear object cache
wp_cache_flush();

// Check if class WpeCommon exists
if (class_exists('\WpeCommon')) {
error_log('WpeCommon exists');

WpeCommon::purge_memcached();
WpeCommon::purge_varnish_cache();
}
}
// Check if it's an options page
if ($post_id === 'options') {
// Flush the object cache
wp_cache_flush();
}
}
add_action('acf/save_post', __NAMESPACE__ . '\\clear_cache_options_save', 20);

0 comments on commit 8a870e3

Please sign in to comment.