@@ -18,16 +18,17 @@ class ObjectCache extends ToolKit {
1818 * @return string Cached value of key
1919 * @since 0.1.0
2020 */
21- public function get_object ( $ key = null , $ callback , $ cache_disabled = false ) {
2221
23- $ object_cache_group = self ::$ config ->get ( 'object_cache/group ' ) ? self ::$ config ->get ( 'object_cache/group ' ) : sanitize_title ( self ::$ config ->get ( 'data/Name ' ) );
24- if ( is_multisite () ) $ object_cache_group .= '_ ' . get_current_blog_id ();
22+ public function get_object ( $ key = null , $ callback , $ object_cache_group = null , $ network_global = false , $ cache_disabled = false ) {
23+
24+ if ( !$ object_cache_group ) $ object_cache_group = self ::$ config ->get ( 'object_cache/group ' ) ? self ::$ config ->get ( 'object_cache/group ' ) : sanitize_title ( self ::$ config ->get ( 'data/Name ' ) );
25+ if ( is_multisite () ) $ object_cache_group .= '_ ' . get_current_site ()->id ;
2526 $ object_cache_expire = ( is_int ( self ::$ config ->get ( 'object_cache/expire_hours ' ) ) ? self ::$ config ->get ( 'object_cache/expire_hours ' ) : 24 ) * 3600 ; // Default to 24 hours
2627
2728 $ result = null ;
2829
2930 // Set key variable
30- $ object_cache_key = $ key . ( is_multisite () ? '_ ' . get_current_blog_id () : '' );
31+ $ object_cache_key = $ key . ( is_multisite () && ! $ network_global && get_current_blog_id () ? '_ ' . get_current_blog_id () : '' );
3132
3233 // Try to get the value of the cache
3334 if ( !$ cache_disabled ) {
@@ -36,9 +37,9 @@ public function get_object( $key = null, $callback, $cache_disabled = false ) {
3637 }
3738
3839 // If result wasn't found/returned and/or caching is disabled, set & return the value from $callback
39- if ( ! $ result ) {
40+ if ( $ result === false ) {
4041 $ result = $ callback ();
41- if ( !$ cache_disabled ) wp_cache_set ( $ object_cache_key , ( is_array ( $ result ) || is_object ( $ result ) ? serialize ( $ result ) : $ result ), $ object_cache_group , $ object_cache_expire );
42+ if ( !$ cache_disabled ) wp_cache_set ( $ object_cache_key , ( is_array ( $ result ) || is_object ( $ result ) || is_bool ( $ result ) ? serialize ( $ result ) : $ result ), $ object_cache_group , $ object_cache_expire );
4243 }
4344
4445 return $ result ;
0 commit comments