0
|
1 |
<?php |
|
2 |
/** |
|
3 |
* My Sites dashboard. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Multisite |
|
7 |
* @since 3.0.0 |
|
8 |
*/ |
|
9 |
|
|
10 |
require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 |
|
|
12 |
if ( !is_multisite() ) |
|
13 |
wp_die( __( 'Multisite support is not enabled.' ) ); |
|
14 |
|
|
15 |
if ( ! current_user_can('read') ) |
|
16 |
wp_die( __( 'You do not have sufficient permissions to view this page.' ) ); |
|
17 |
|
|
18 |
$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash'; |
|
19 |
|
|
20 |
$blogs = get_blogs_of_user( $current_user->ID ); |
|
21 |
|
|
22 |
$updated = false; |
|
23 |
if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) { |
|
24 |
check_admin_referer( 'update-my-sites' ); |
|
25 |
|
|
26 |
$blog = get_blog_details( (int) $_POST['primary_blog'] ); |
|
27 |
if ( $blog && isset( $blog->domain ) ) { |
|
28 |
update_user_option( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'], true ); |
|
29 |
$updated = true; |
|
30 |
} else { |
|
31 |
wp_die( __( 'The primary site you chose does not exist.' ) ); |
|
32 |
} |
|
33 |
} |
|
34 |
|
|
35 |
$title = __( 'My Sites' ); |
|
36 |
$parent_file = 'index.php'; |
|
37 |
|
|
38 |
get_current_screen()->add_help_tab( array( |
|
39 |
'id' => 'overview', |
|
40 |
'title' => __('Overview'), |
|
41 |
'content' => |
5
|
42 |
'<p>' . __('This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. They can use the links under each site to visit either the frontend or the dashboard for that site.') . '</p>' . |
0
|
43 |
'<p>' . __('Up until WordPress version 3.0, what is now called a Multisite Network had to be installed separately as WordPress MU (multi-user).') . '</p>' |
|
44 |
) ); |
|
45 |
|
|
46 |
get_current_screen()->set_help_sidebar( |
|
47 |
'<p><strong>' . __('For more information:') . '</strong></p>' . |
5
|
48 |
'<p>' . __('<a href="https://codex.wordpress.org/Dashboard_My_Sites_Screen" target="_blank">Documentation on My Sites</a>') . '</p>' . |
|
49 |
'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
0
|
50 |
); |
|
51 |
|
|
52 |
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
53 |
|
|
54 |
if ( $updated ) { ?> |
5
|
55 |
<div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div> |
0
|
56 |
<?php } ?> |
|
57 |
|
|
58 |
<div class="wrap"> |
|
59 |
<h2><?php echo esc_html( $title ); ?></h2> |
|
60 |
<?php |
|
61 |
if ( empty( $blogs ) ) : |
|
62 |
echo '<p>'; |
|
63 |
_e( 'You must be a member of at least one site to use this page.' ); |
|
64 |
echo '</p>'; |
|
65 |
else : |
|
66 |
?> |
5
|
67 |
<form id="myblogs" method="post"> |
0
|
68 |
<?php |
|
69 |
choose_primary_blog(); |
5
|
70 |
/** |
|
71 |
* Fires before the sites table on the My Sites screen. |
|
72 |
* |
|
73 |
* @since 3.0.0 |
|
74 |
*/ |
0
|
75 |
do_action( 'myblogs_allblogs_options' ); |
|
76 |
?> |
|
77 |
<br clear="all" /> |
5
|
78 |
<table class="widefat fixed striped"> |
0
|
79 |
<?php |
5
|
80 |
/** |
|
81 |
* Enable the Global Settings section on the My Sites screen. |
|
82 |
* |
|
83 |
* By default, the Global Settings section is hidden. Passing a non-empty |
|
84 |
* string to this filter will enable the section, and allow new settings |
|
85 |
* to be added, either globally or for specific sites. |
|
86 |
* |
|
87 |
* @since MU |
|
88 |
* |
|
89 |
* @param string $settings_html The settings HTML markup. Default empty. |
|
90 |
* @param object $context Context of the setting (global or site-specific). Default 'global'. |
|
91 |
*/ |
0
|
92 |
$settings_html = apply_filters( 'myblogs_options', '', 'global' ); |
|
93 |
if ( $settings_html != '' ) { |
5
|
94 |
echo '<tr><td><h3>' . __( 'Global Settings' ) . '</h3></td><td>'; |
0
|
95 |
echo $settings_html; |
|
96 |
echo '</td></tr>'; |
|
97 |
} |
|
98 |
reset( $blogs ); |
|
99 |
$num = count( $blogs ); |
|
100 |
$cols = 1; |
|
101 |
if ( $num >= 20 ) |
|
102 |
$cols = 4; |
|
103 |
elseif ( $num >= 10 ) |
|
104 |
$cols = 2; |
|
105 |
$num_rows = ceil( $num / $cols ); |
|
106 |
$split = 0; |
|
107 |
for ( $i = 1; $i <= $num_rows; $i++ ) { |
|
108 |
$rows[] = array_slice( $blogs, $split, $cols ); |
|
109 |
$split = $split + $cols; |
|
110 |
} |
|
111 |
|
|
112 |
foreach ( $rows as $row ) { |
5
|
113 |
echo "<tr>"; |
0
|
114 |
$i = 0; |
|
115 |
foreach ( $row as $user_blog ) { |
|
116 |
$s = $i == 3 ? '' : 'border-right: 1px solid #ccc;'; |
5
|
117 |
echo "<td style='$s'>"; |
0
|
118 |
echo "<h3>{$user_blog->blogname}</h3>"; |
5
|
119 |
/** |
|
120 |
* Filter the row links displayed for each site on the My Sites screen. |
|
121 |
* |
|
122 |
* @since MU |
|
123 |
* |
|
124 |
* @param string $string The HTML site link markup. |
|
125 |
* @param object $user_blog An object containing the site data. |
|
126 |
*/ |
0
|
127 |
echo "<p>" . apply_filters( 'myblogs_blog_actions', "<a href='" . esc_url( get_home_url( $user_blog->userblog_id ) ). "'>" . __( 'Visit' ) . "</a> | <a href='" . esc_url( get_admin_url( $user_blog->userblog_id ) ) . "'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>"; |
5
|
128 |
/** This filter is documented in wp-admin/my-sites.php */ |
0
|
129 |
echo apply_filters( 'myblogs_options', '', $user_blog ); |
|
130 |
echo "</td>"; |
|
131 |
$i++; |
|
132 |
} |
|
133 |
echo "</tr>"; |
|
134 |
}?> |
|
135 |
</table> |
|
136 |
<input type="hidden" name="action" value="updateblogsettings" /> |
|
137 |
<?php wp_nonce_field( 'update-my-sites' ); ?> |
|
138 |
<?php submit_button(); ?> |
|
139 |
</form> |
|
140 |
<?php endif; ?> |
|
141 |
</div> |
|
142 |
<?php |
|
143 |
include( ABSPATH . 'wp-admin/admin-footer.php' ); |