Changeset 2061216
- Timestamp:
- 04/01/2019 10:15:37 PM (7 years ago)
- Location:
- multisite-admin-bar-switcher/trunk
- Files:
-
- 3 edited
-
mabs_admin_bar.php (modified) (3 diffs)
-
multisite-admin-bar-switcher.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
multisite-admin-bar-switcher/trunk/mabs_admin_bar.php
r1230917 r2061216 7 7 class MABS_Admin_Bar extends WP_Admin_Bar 8 8 { 9 protected $active_blog_for_user_cache = []; 10 9 11 /** 10 12 * This is the same as WP_Admin_Bar's initialize method but … … 76 78 * 77 79 * @param int $user_id The unique ID of the user 78 * @return object| voidThe blog object80 * @return object|array The blog object 79 81 */ 80 82 function mabs_get_active_blog_for_user( $user_id ) { 81 $cache = get_site_transient('mabs_activeblog_'.$user_id); 82 if ($cache) 83 return $cache; 83 if ($this->active_blog_for_user_cache) 84 return $this->active_blog_for_user_cache; 84 85 85 86 global $wpdb; 86 87 $blogs = mabs_get_blogs_of_user( $user_id ); 87 88 if ( empty( $blogs ) ) 88 return ;89 return []; 89 90 90 91 if ( !is_multisite() ) 91 92 { 92 $ cache = $blogs[$wpdb->blogid];93 set_site_transient('mabs_activeblog_'.$user_id, $ cache, apply_filters('mabs_cache_duration', 60*60*30));94 return $ cache;93 $this->active_blog_for_user_cache = $blogs[$wpdb->blogid]; 94 set_site_transient('mabs_activeblog_'.$user_id, $this->active_blog_for_user_cache, apply_filters('mabs_cache_duration', 60*60*30)); 95 return $this->active_blog_for_user_cache; 95 96 } 96 97 … … 129 130 } 130 131 } else { 131 return ;132 return []; 132 133 } 133 $cache = $ret; 134 set_site_transient('mabs_activeblog_'.$user_id, $cache, apply_filters('mabs_cache_duration', 60*60*30)); 135 return $cache; 134 $this->active_blog_for_user_cache = $ret; 135 136 136 } else { 137 $cache = $primary; 138 set_site_transient('mabs_activeblog_'.$user_id, $cache, apply_filters('mabs_cache_duration', 60*60*30)); 139 return $cache; 137 $this->active_blog_for_user_cache = $primary; 140 138 } 139 140 set_site_transient('mabs_activeblog_'.$user_id, $this->active_blog_for_user_cache, apply_filters('mabs_cache_duration', 60*60*30)); 141 return $this->active_blog_for_user_cache; 141 142 } 142 143 } -
multisite-admin-bar-switcher/trunk/multisite-admin-bar-switcher.php
r2058613 r2061216 4 4 Plugin URI: http://www.flynsarmy.com 5 5 Description: Replaces the built in 'My Sites' drop down with a better layed out one 6 Version: 1.3. 06 Version: 1.3.1 7 7 Author: Flyn San 8 8 Author URI: http://www.flynsarmy.com/ -
multisite-admin-bar-switcher/trunk/readme.txt
r2058613 r2061216 4 4 Requires at least: 3.2.1 5 5 Tested up to: 5.1.1 6 Stable tag: 1.3. 06 Stable tag: 1.3.1 7 7 8 8 == Description == … … 78 78 79 79 == Changelog == 80 81 = 1.3.1 = 82 * Remove some redundant database calls 80 83 81 84 = 1.3.0 =
Note: See TracChangeset
for help on using the changeset viewer.