-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhyper-admins.php
More file actions
71 lines (57 loc) · 1.42 KB
/
hyper-admins.php
File metadata and controls
71 lines (57 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/*
Plugin Name: Hyper Admins
Description: Show all sites in admin bar; show all themes in theme page. Only for super-admins.
Network: true
Author: scribu
Plugin URI: http://wordpress.org/extend/plugins/hyper-admins/
Version: 1.1
*/
if ( ! is_multisite() ) {
return;
}
add_filter( 'option_allowedthemes', 'all_the_themes' );
add_action( 'admin_bar_init', 'all_the_sites' );
function all_the_sites() {
if ( ! is_super_admin() ) {
return;
}
// Get all blog ids
global $wpdb;
$blog_ids = $wpdb->get_col( $wpdb->prepare( "
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = %d
AND spam = '0'
AND deleted = '0'
AND archived = '0'
ORDER BY registered DESC
", $wpdb->siteid ) );
// Populate blogs array
$blogs = array();
foreach ( $blog_ids as $blog_id ) {
$blog_id = (int) $blog_id;
$blog = get_blog_details( $blog_id );
$blogs[ $blog_id ] = (object) array(
'userblog_id' => $blog_id,
'blogname' => $blog->blogname,
'domain' => $blog->domain,
'path' => $blog->path,
'site_id' => $blog->site_id,
'siteurl' => $blog->siteurl,
);
}
// Send to admin bar object
$GLOBALS['wp_admin_bar']->user->blogs = $blogs;
}
// All sites have access to all themes
function all_the_themes( $themes ) {
if ( ! is_super_admin() ) {
return $themes;
}
$allowed = array();
foreach ( wp_get_themes() as $theme ) {
$allowed[ $theme->get_stylesheet() ] = true;
}
return $allowed;
}