We fixed it like such:
I’m sure there is a better, more long term solution than to hack some actions and filters, but in the mean time if anyone wants a cheap and chearful answer:
// Enable caching transient options
/**
* Turn on caching if it is turned off
*
*/
function liberal_turn_on_admin_cache($value) {
global $wp_object_cache;
//save old value to check if we need to restore it later; save it at first visit only
if( !$wp_object_cache->_caching_saved && !$wp_object_cache->_caching ) {
$wp_object_cache->_caching_saved = true;
$wp_object_cache->_caching = true;
}
//Do nothing with the input value
return $value;
}
/**
* Turn off caching if it was turned on before
*
*/
function liberal_turn_off_admin_cache($value=false) {
global $wp_object_cache;
//restore value if it was saved
if( $wp_object_cache->_caching_saved && $wp_object_cache->_caching ) {
$wp_object_cache->_caching_saved = false;
$wp_object_cache->_caching = false;
}
//Do nothing with the input value
return $value;
}
/**
* Init filters for caching transient options
*
*/
function liberal_enable_caching_transient_options() {
$transient_options = array(
'update_core',
'update_plugins',
'update_themes',
'theme_roots',
);
foreach($transient_options as $option_name) {
add_filter( 'pre_set_site_transient_'.$option_name, 'liberal_turn_on_admin_cache', 10, 1 );
add_action( 'set_site_transient_'.$option_name , 'liberal_turn_off_admin_cache', 10, 0 );
add_filter( 'pre_site_transient_'.$option_name, 'liberal_turn_on_admin_cache', 10, 1 );
add_filter( 'site_transient_'.$option_name , 'liberal_turn_off_admin_cache', 10, 1 );
}
}
if( defined('WP_ADMIN') ) liberal_enable_caching_transient_options();
// End Enable caching transient options
Nice code, thanks a lot for that.
But where exactly has this to go? All locations I tried, didn’t work. 🙁