Changeset 3424794
- Timestamp:
- 12/21/2025 04:27:36 PM (3 months ago)
- Location:
- multisite-administration-tools/trunk
- Files:
-
- 2 edited
-
multisite-administration-tools.php (modified) (10 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
multisite-administration-tools/trunk/multisite-administration-tools.php
r3424416 r3424794 4 4 * Plugin URI: https://wordpress.org/plugins/multisite-administration-tools/ 5 5 * Description: Adds information to the network admin sites, plugins and themes pages. Allows you to easily see what theme and plugins are enabled on a site. 6 * Version: 1.2 06 * Version: 1.21 7 7 * Author: Aaron Axelsen 8 8 * Author URI: http://aaron.axelsen.us … … 48 48 static $site_ids = null; 49 49 50 $batch_size = 200; 51 50 52 if ($site_ids !== null) { 51 53 return $site_ids; 52 54 } 53 55 54 $site_ids = get_sites([ 56 $site_ids = []; 57 58 $args = [ 55 59 'fields' => 'ids', 56 'number' => 0, // all 57 ]); 58 59 if (!is_array($site_ids)) { 60 $site_ids = []; 60 'number' => $batch_size, 61 'offset' => 0, 62 ]; 63 64 while (true) { 65 $batch = get_sites($args); 66 67 if (!is_array($batch) || empty($batch)) { 68 break; 69 } 70 71 $site_ids = array_merge($site_ids, $batch); 72 73 if (count($batch) < $batch_size) { 74 break; 75 } 76 77 $args['offset'] += $batch_size; 61 78 } 62 79 63 80 return $site_ids; 81 } 82 83 /** 84 * Switch to a blog and ensure we always restore the previous context. 85 */ 86 function msadmintools_with_blog(int $blog_id, callable $callback) 87 { 88 $switched = switch_to_blog($blog_id); 89 90 try { 91 return $callback(); 92 } finally { 93 if ($switched) { 94 restore_current_blog(); 95 } 96 } 64 97 } 65 98 … … 141 174 } 142 175 143 $columns['msadmintools_viewthemes'] = esc_html__('Current Theme', 'm sadmintools');144 $columns['msadmintools_viewplugins'] = esc_html__('Current Plugins', 'm sadmintools');176 $columns['msadmintools_viewthemes'] = esc_html__('Current Theme', 'multisite-administration-tools'); 177 $columns['msadmintools_viewplugins'] = esc_html__('Current Plugins', 'multisite-administration-tools'); 145 178 146 179 return $columns; … … 159 192 160 193 if ($column_name === 'msadmintools_viewthemes') { 161 switch_to_blog($blog_id); 162 163 $theme = wp_get_theme(); 164 $name = $theme ? $theme->get('Name') : ''; 165 $stylesheet = $theme ? $theme->get_stylesheet() : ''; 166 $template = $theme ? $theme->get_template() : ''; 167 168 restore_current_blog(); 194 $theme_details = msadmintools_with_blog($blog_id, static function () { 195 $theme = wp_get_theme(); 196 197 return [ 198 'name' => $theme ? $theme->get('Name') : '', 199 'stylesheet' => $theme ? $theme->get_stylesheet() : '', 200 'template' => $theme ? $theme->get_template() : '', 201 ]; 202 }); 203 204 if (!is_array($theme_details)) { 205 return; 206 } 207 208 $name = (string) ($theme_details['name'] ?? ''); 209 $stylesheet = (string) ($theme_details['stylesheet'] ?? ''); 210 $template = (string) ($theme_details['template'] ?? ''); 169 211 170 212 if ($name !== '') { 171 echo '<div><strong>' . esc_html__('Name:', 'm sadmintools') . '</strong> ' . esc_html($name) . '</div>';213 echo '<div><strong>' . esc_html__('Name:', 'multisite-administration-tools') . '</strong> ' . esc_html($name) . '</div>'; 172 214 } 173 215 if ($template !== '') { 174 echo '<div><strong>' . esc_html__('Template:', 'm sadmintools') . '</strong> ' . esc_html($template) . '</div>';216 echo '<div><strong>' . esc_html__('Template:', 'multisite-administration-tools') . '</strong> ' . esc_html($template) . '</div>'; 175 217 } 176 218 if ($stylesheet !== '') { 177 echo '<div><strong>' . esc_html__('Stylesheet:', 'm sadmintools') . '</strong> ' . esc_html($stylesheet) . '</div>';219 echo '<div><strong>' . esc_html__('Stylesheet:', 'multisite-administration-tools') . '</strong> ' . esc_html($stylesheet) . '</div>'; 178 220 } 179 221 … … 188 230 189 231 if (empty($active_plugins)) { 190 echo '<em>' . esc_html__('None', 'm sadmintools') . '</em>';232 echo '<em>' . esc_html__('None', 'multisite-administration-tools') . '</em>'; 191 233 return; 192 234 } … … 194 236 // Use <details> so big lists don’t destroy the Sites table row height. 195 237 echo '<details>'; 196 echo '<summary>' . esc_html(sprintf(_n('%d plugin', '%d plugins', count($active_plugins), 'm sadmintools'), count($active_plugins))) . '</summary>';238 echo '<summary>' . esc_html(sprintf(_n('%d plugin', '%d plugins', count($active_plugins), 'multisite-administration-tools'), count($active_plugins))) . '</summary>'; 197 239 echo '<div style="margin-top:6px;">'; 198 240 … … 228 270 } 229 271 230 $columns['msadmintools_viewsites'] = esc_html__('Sites', 'm sadmintools');272 $columns['msadmintools_viewsites'] = esc_html__('Sites', 'multisite-administration-tools'); 231 273 return $columns; 232 274 } … … 250 292 $sites = $theme_to_sites[$stylesheet] ?? []; 251 293 if (empty($sites)) { 252 echo '<em>' . esc_html__('None', 'm sadmintools') . '</em>';294 echo '<em>' . esc_html__('None', 'multisite-administration-tools') . '</em>'; 253 295 return; 254 296 } … … 270 312 } 271 313 272 $columns['msadmintools_viewsites'] = esc_html__('Sites', 'm sadmintools');314 $columns['msadmintools_viewsites'] = esc_html__('Sites', 'multisite-administration-tools'); 273 315 return $columns; 274 316 } … … 292 334 $sites = $plugin_to_sites[$plugin_file] ?? []; 293 335 if (empty($sites)) { 294 echo '<em>' . esc_html__('None', 'm sadmintools') . '</em>';336 echo '<em>' . esc_html__('None', 'multisite-administration-tools') . '</em>'; 295 337 return; 296 338 } -
multisite-administration-tools/trunk/readme.txt
r3424420 r3424794 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.2 7 Stable tag: 1.2 07 Stable tag: 1.21 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 27 27 == Changelog == 28 28 29 = 1.21 = 30 * Harden blog context switching and align translation text domain usage. 31 * Batch site indexing queries to improve performance on large networks. 32 29 33 = 1.20 = 30 34 * Compatibility updates for current WordPress multisite Network Admin screens. … … 41 45 == Upgrade Notice == 42 46 47 = 1.21 = 48 Improves multisite safety and performance for Network Admin reporting. 49 43 50 = 1.20 = 44 51 Compatibility and performance improvements for multisite Network Admin reporting.
Note: See TracChangeset
for help on using the changeset viewer.