File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,20 +13,21 @@ class Cache extends Plugin {
1313 */
1414 public static function get_object ( $ key = null , $ callback ) {
1515
16- $ object_cache_group = self ::$ settings ['object_cache_group ' ] ?: sanitize_title ( self ::$ settings ['data ' ]['Name ' ] );
16+ $ object_cache_group = isset ( self ::$ settings ['object_cache_group ' ]) && self ::$ settings ['object_cache_group ' ] ?: sanitize_title ( self ::$ settings ['data ' ]['Name ' ] );
17+ if ( is_multisite () ) $ object_cache_group .= '_ ' . get_current_blog_id ();
1718 $ object_cache_expire = self ::$ settings ['object_cache_expire ' ] ?: 86400 ; // Default to 24 hours of null
1819
1920 // Set key variable
20- $ caller = end ( debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 2 ) );
21- $ caller_class_name = strtolower ( end ( explode ( "\\" , $ caller ['class ' ] ) ) );
22- $ object_cache_key = $ caller_class_name . '_ ' . $ caller ['function ' ] . ( $ key ? '_ ' . $ key : '' );
21+ $ object_cache_key = self ::$ prefix . '_ ' . $ key . ( is_multisite () ? '_ ' . get_current_blog_id () : '' );
2322
2423 // Try to get the value of the cache
2524 $ result = wp_cache_get ( $ object_cache_key , $ object_cache_group );
25+ if ( is_serialized ($ result ) ) $ result = unserialize ($ result );
2626
2727 // If result wasn't found/returned and/or caching is disabled, set & return the value from $callback
2828 if (!$ result ) {
2929 $ result = $ callback ();
30+ if ( is_array ( $ result ) || is_object ( $ result ) ) $ result = serialize ( $ result );
3031 wp_cache_set ( $ object_cache_key , $ result , $ object_cache_group , $ object_cache_expire );
3132 }
3233
You can’t perform that action at this time.
0 commit comments