author | ymh <ymh.work@gmail.com> |
Tue, 15 Dec 2020 13:49:49 +0100 | |
changeset 16 | a86126ab1dd4 |
parent 9 | 177826044cd9 |
child 18 | be944660c56a |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Multisite administration functions. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Multisite |
|
7 |
* @since 3.0.0 |
|
8 |
*/ |
|
9 |
||
10 |
/** |
|
11 |
* Determine if uploaded file exceeds space quota. |
|
12 |
* |
|
13 |
* @since 3.0.0 |
|
14 |
* |
|
15 |
* @param array $file $_FILES array for a given file. |
|
16 |
* @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise. |
|
17 |
*/ |
|
18 |
function check_upload_size( $file ) { |
|
9 | 19 |
if ( get_site_option( 'upload_space_check_disabled' ) ) { |
0 | 20 |
return $file; |
9 | 21 |
} |
0 | 22 |
|
16 | 23 |
if ( '0' != $file['error'] ) { // There's already an error. |
0 | 24 |
return $file; |
9 | 25 |
} |
0 | 26 |
|
9 | 27 |
if ( defined( 'WP_IMPORTING' ) ) { |
0 | 28 |
return $file; |
9 | 29 |
} |
0 | 30 |
|
31 |
$space_left = get_upload_space_available(); |
|
32 |
||
33 |
$file_size = filesize( $file['tmp_name'] ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
if ( $space_left < $file_size ) { |
16 | 35 |
/* translators: %s: Required disk space in kilobytes. */ |
9 | 36 |
$file['error'] = sprintf( __( 'Not enough space to upload. %s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { |
16 | 40 |
/* translators: %s: Maximum allowed file size in kilobytes. */ |
9 | 41 |
$file['error'] = sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
|
0 | 44 |
if ( upload_is_user_over_quota( false ) ) { |
45 |
$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); |
|
46 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
|
16 | 48 |
if ( '0' != $file['error'] && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) { |
0 | 49 |
wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' ); |
5 | 50 |
} |
0 | 51 |
|
52 |
return $file; |
|
53 |
} |
|
54 |
||
55 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
* Delete a site. |
0 | 57 |
* |
58 |
* @since 3.0.0 |
|
9 | 59 |
* @since 5.1.0 Use wp_delete_site() internally to delete the site row from the database. |
0 | 60 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
* @param int $blog_id Site ID. |
16 | 64 |
* @param bool $drop True if site's database tables should be dropped. Default false. |
0 | 65 |
*/ |
66 |
function wpmu_delete_blog( $blog_id, $drop = false ) { |
|
5 | 67 |
global $wpdb; |
0 | 68 |
|
69 |
$switch = false; |
|
70 |
if ( get_current_blog_id() != $blog_id ) { |
|
71 |
$switch = true; |
|
72 |
switch_to_blog( $blog_id ); |
|
73 |
} |
|
74 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
$blog = get_site( $blog_id ); |
0 | 76 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
$current_network = get_network(); |
5 | 78 |
|
79 |
// If a full blog object is not available, do not destroy anything. |
|
80 |
if ( $drop && ! $blog ) { |
|
81 |
$drop = false; |
|
82 |
} |
|
83 |
||
0 | 84 |
// Don't destroy the initial, main, or root blog. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_network->path && $blog->domain == $current_network->domain ) ) ) { |
0 | 86 |
$drop = false; |
5 | 87 |
} |
88 |
||
89 |
$upload_path = trim( get_option( 'upload_path' ) ); |
|
90 |
||
91 |
// If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable. |
|
92 |
if ( $drop && get_site_option( 'ms_files_rewriting' ) && empty( $upload_path ) ) { |
|
93 |
$drop = false; |
|
94 |
} |
|
0 | 95 |
|
96 |
if ( $drop ) { |
|
9 | 97 |
wp_delete_site( $blog_id ); |
98 |
} else { |
|
99 |
/** This action is documented in wp-includes/ms-blogs.php */ |
|
100 |
do_action_deprecated( 'delete_blog', array( $blog_id, false ), '5.1.0' ); |
|
5 | 101 |
|
9 | 102 |
$users = get_users( |
103 |
array( |
|
104 |
'blog_id' => $blog_id, |
|
105 |
'fields' => 'ids', |
|
106 |
) |
|
107 |
); |
|
0 | 108 |
|
9 | 109 |
// Remove users from this blog. |
110 |
if ( ! empty( $users ) ) { |
|
111 |
foreach ( $users as $user_id ) { |
|
112 |
remove_user_from_blog( $user_id, $blog_id ); |
|
113 |
} |
|
0 | 114 |
} |
115 |
||
9 | 116 |
update_blog_status( $blog_id, 'deleted', 1 ); |
0 | 117 |
|
9 | 118 |
/** This action is documented in wp-includes/ms-blogs.php */ |
119 |
do_action_deprecated( 'deleted_blog', array( $blog_id, false ), '5.1.0' ); |
|
0 | 120 |
} |
121 |
||
9 | 122 |
if ( $switch ) { |
0 | 123 |
restore_current_blog(); |
9 | 124 |
} |
0 | 125 |
} |
126 |
||
5 | 127 |
/** |
128 |
* Delete a user from the network and remove from all sites. |
|
129 |
* |
|
130 |
* @since 3.0.0 |
|
131 |
* |
|
16 | 132 |
* @todo Merge with wp_delete_user()? |
5 | 133 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
* |
5 | 136 |
* @param int $id The user ID. |
137 |
* @return bool True if the user was deleted, otherwise false. |
|
138 |
*/ |
|
0 | 139 |
function wpmu_delete_user( $id ) { |
140 |
global $wpdb; |
|
141 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
if ( ! is_numeric( $id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
|
9 | 146 |
$id = (int) $id; |
0 | 147 |
$user = new WP_User( $id ); |
148 |
||
9 | 149 |
if ( ! $user->exists() ) { |
0 | 150 |
return false; |
9 | 151 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
152 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
// Global super-administrators are protected, and cannot be deleted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
$_super_admins = get_super_admins(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
if ( in_array( $user->user_login, $_super_admins, true ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
|
0 | 159 |
/** |
160 |
* Fires before a user is deleted from the network. |
|
161 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
162 |
* @since MU (3.0.0) |
16 | 163 |
* @since 5.5.0 Added the `$user` parameter. |
0 | 164 |
* |
16 | 165 |
* @param int $id ID of the user about to be deleted from the network. |
166 |
* @param WP_User $user WP_User object of the user about to be deleted from the network. |
|
0 | 167 |
*/ |
16 | 168 |
do_action( 'wpmu_delete_user', $id, $user ); |
0 | 169 |
|
170 |
$blogs = get_blogs_of_user( $id ); |
|
171 |
||
172 |
if ( ! empty( $blogs ) ) { |
|
173 |
foreach ( $blogs as $blog ) { |
|
174 |
switch_to_blog( $blog->userblog_id ); |
|
175 |
remove_user_from_blog( $id, $blog->userblog_id ); |
|
176 |
||
177 |
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); |
|
178 |
foreach ( (array) $post_ids as $post_id ) { |
|
179 |
wp_delete_post( $post_id ); |
|
180 |
} |
|
181 |
||
16 | 182 |
// Clean links. |
0 | 183 |
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) ); |
184 |
||
185 |
if ( $link_ids ) { |
|
9 | 186 |
foreach ( $link_ids as $link_id ) { |
0 | 187 |
wp_delete_link( $link_id ); |
9 | 188 |
} |
0 | 189 |
} |
190 |
||
191 |
restore_current_blog(); |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); |
|
9 | 196 |
foreach ( $meta as $mid ) { |
0 | 197 |
delete_metadata_by_mid( 'user', $mid ); |
9 | 198 |
} |
0 | 199 |
|
200 |
$wpdb->delete( $wpdb->users, array( 'ID' => $id ) ); |
|
201 |
||
202 |
clean_user_cache( $user ); |
|
203 |
||
5 | 204 |
/** This action is documented in wp-admin/includes/user.php */ |
16 | 205 |
do_action( 'deleted_user', $id, null, $user ); |
0 | 206 |
|
207 |
return true; |
|
208 |
} |
|
209 |
||
5 | 210 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
* Check whether a site has used its allotted upload space. |
5 | 212 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
* @since MU (3.0.0) |
0 | 214 |
* |
215 |
* @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true. |
|
5 | 216 |
* @return bool True if user is over upload space quota, otherwise false. |
0 | 217 |
*/ |
218 |
function upload_is_user_over_quota( $echo = true ) { |
|
9 | 219 |
if ( get_site_option( 'upload_space_check_disabled' ) ) { |
0 | 220 |
return false; |
9 | 221 |
} |
0 | 222 |
|
223 |
$space_allowed = get_space_allowed(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
if ( ! is_numeric( $space_allowed ) ) { |
16 | 225 |
$space_allowed = 10; // Default space allowed is 10 MB. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
} |
0 | 227 |
$space_used = get_space_used(); |
228 |
||
229 |
if ( ( $space_allowed - $space_used ) < 0 ) { |
|
9 | 230 |
if ( $echo ) { |
231 |
printf( |
|
16 | 232 |
/* translators: %s: Allowed space allocation. */ |
9 | 233 |
__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ), |
234 |
size_format( $space_allowed * MB_IN_BYTES ) |
|
235 |
); |
|
236 |
} |
|
0 | 237 |
return true; |
238 |
} else { |
|
239 |
return false; |
|
240 |
} |
|
241 |
} |
|
242 |
||
243 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
244 |
* Displays the amount of disk space used by the current site. Not used in core. |
0 | 245 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
* @since MU (3.0.0) |
0 | 247 |
*/ |
248 |
function display_space_usage() { |
|
249 |
$space_allowed = get_space_allowed(); |
|
9 | 250 |
$space_used = get_space_used(); |
0 | 251 |
|
252 |
$percent_used = ( $space_used / $space_allowed ) * 100; |
|
253 |
||
16 | 254 |
$space = size_format( $space_allowed * MB_IN_BYTES ); |
0 | 255 |
?> |
9 | 256 |
<strong> |
257 |
<?php |
|
16 | 258 |
/* translators: Storage space that's been used. 1: Percentage of used space, 2: Total space allowed in megabytes or gigabytes. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
printf( __( 'Used: %1$s%% of %2$s' ), number_format( $percent_used ), $space ); |
9 | 260 |
?> |
261 |
</strong> |
|
0 | 262 |
<?php |
263 |
} |
|
264 |
||
265 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
* Get the remaining upload space for this site. |
0 | 267 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
* @since MU (3.0.0) |
0 | 269 |
* |
270 |
* @param int $size Current max size in bytes |
|
271 |
* @return int Max size in bytes |
|
272 |
*/ |
|
273 |
function fix_import_form_size( $size ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
if ( upload_is_user_over_quota( false ) ) { |
0 | 275 |
return 0; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
} |
0 | 277 |
$available = get_upload_space_available(); |
278 |
return min( $size, $available ); |
|
279 |
} |
|
280 |
||
5 | 281 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
282 |
* Displays the site upload space quota setting form on the Edit Site Settings screen. |
5 | 283 |
* |
284 |
* @since 3.0.0 |
|
285 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
* @param int $id The ID of the site to display the setting for. |
5 | 287 |
*/ |
0 | 288 |
function upload_space_setting( $id ) { |
289 |
switch_to_blog( $id ); |
|
290 |
$quota = get_option( 'blog_upload_space' ); |
|
291 |
restore_current_blog(); |
|
292 |
||
9 | 293 |
if ( ! $quota ) { |
0 | 294 |
$quota = ''; |
9 | 295 |
} |
0 | 296 |
|
297 |
?> |
|
298 |
<tr> |
|
5 | 299 |
<th><label for="blog-upload-space-number"><?php _e( 'Site Upload Space Quota' ); ?></label></th> |
300 |
<td> |
|
301 |
<input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" id="blog-upload-space-number" aria-describedby="blog-upload-space-desc" value="<?php echo $quota; ?>" /> |
|
302 |
<span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e( 'Size in megabytes' ); ?></span> <?php _e( 'MB (Leave blank for network default)' ); ?></span> |
|
303 |
</td> |
|
0 | 304 |
</tr> |
305 |
<?php |
|
306 |
} |
|
307 |
||
5 | 308 |
/** |
309 |
* Cleans the user cache for a specific user. |
|
310 |
* |
|
311 |
* @since 3.0.0 |
|
312 |
* |
|
313 |
* @param int $id The user ID. |
|
314 |
* @return bool|int The ID of the refreshed user or false if the user does not exist. |
|
315 |
*/ |
|
0 | 316 |
function refresh_user_details( $id ) { |
317 |
$id = (int) $id; |
|
318 |
||
16 | 319 |
$user = get_userdata( $id ); |
320 |
if ( ! $user ) { |
|
0 | 321 |
return false; |
9 | 322 |
} |
0 | 323 |
|
324 |
clean_user_cache( $user ); |
|
325 |
||
326 |
return $id; |
|
327 |
} |
|
328 |
||
5 | 329 |
/** |
330 |
* Returns the language for a language code. |
|
331 |
* |
|
332 |
* @since 3.0.0 |
|
333 |
* |
|
334 |
* @param string $code Optional. The two-letter language code. Default empty. |
|
335 |
* @return string The language corresponding to $code if it exists. If it does not exist, |
|
336 |
* then the first two letters of $code is returned. |
|
337 |
*/ |
|
0 | 338 |
function format_code_lang( $code = '' ) { |
9 | 339 |
$code = strtolower( substr( $code, 0, 2 ) ); |
0 | 340 |
$lang_codes = array( |
9 | 341 |
'aa' => 'Afar', |
342 |
'ab' => 'Abkhazian', |
|
343 |
'af' => 'Afrikaans', |
|
344 |
'ak' => 'Akan', |
|
345 |
'sq' => 'Albanian', |
|
346 |
'am' => 'Amharic', |
|
347 |
'ar' => 'Arabic', |
|
348 |
'an' => 'Aragonese', |
|
349 |
'hy' => 'Armenian', |
|
350 |
'as' => 'Assamese', |
|
351 |
'av' => 'Avaric', |
|
352 |
'ae' => 'Avestan', |
|
353 |
'ay' => 'Aymara', |
|
354 |
'az' => 'Azerbaijani', |
|
355 |
'ba' => 'Bashkir', |
|
356 |
'bm' => 'Bambara', |
|
357 |
'eu' => 'Basque', |
|
358 |
'be' => 'Belarusian', |
|
359 |
'bn' => 'Bengali', |
|
360 |
'bh' => 'Bihari', |
|
361 |
'bi' => 'Bislama', |
|
362 |
'bs' => 'Bosnian', |
|
363 |
'br' => 'Breton', |
|
364 |
'bg' => 'Bulgarian', |
|
365 |
'my' => 'Burmese', |
|
366 |
'ca' => 'Catalan; Valencian', |
|
367 |
'ch' => 'Chamorro', |
|
368 |
'ce' => 'Chechen', |
|
369 |
'zh' => 'Chinese', |
|
370 |
'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', |
|
371 |
'cv' => 'Chuvash', |
|
372 |
'kw' => 'Cornish', |
|
373 |
'co' => 'Corsican', |
|
374 |
'cr' => 'Cree', |
|
375 |
'cs' => 'Czech', |
|
376 |
'da' => 'Danish', |
|
377 |
'dv' => 'Divehi; Dhivehi; Maldivian', |
|
378 |
'nl' => 'Dutch; Flemish', |
|
379 |
'dz' => 'Dzongkha', |
|
380 |
'en' => 'English', |
|
381 |
'eo' => 'Esperanto', |
|
382 |
'et' => 'Estonian', |
|
383 |
'ee' => 'Ewe', |
|
384 |
'fo' => 'Faroese', |
|
385 |
'fj' => 'Fijjian', |
|
386 |
'fi' => 'Finnish', |
|
387 |
'fr' => 'French', |
|
388 |
'fy' => 'Western Frisian', |
|
389 |
'ff' => 'Fulah', |
|
390 |
'ka' => 'Georgian', |
|
391 |
'de' => 'German', |
|
392 |
'gd' => 'Gaelic; Scottish Gaelic', |
|
393 |
'ga' => 'Irish', |
|
394 |
'gl' => 'Galician', |
|
395 |
'gv' => 'Manx', |
|
396 |
'el' => 'Greek, Modern', |
|
397 |
'gn' => 'Guarani', |
|
398 |
'gu' => 'Gujarati', |
|
399 |
'ht' => 'Haitian; Haitian Creole', |
|
400 |
'ha' => 'Hausa', |
|
401 |
'he' => 'Hebrew', |
|
402 |
'hz' => 'Herero', |
|
403 |
'hi' => 'Hindi', |
|
404 |
'ho' => 'Hiri Motu', |
|
405 |
'hu' => 'Hungarian', |
|
406 |
'ig' => 'Igbo', |
|
407 |
'is' => 'Icelandic', |
|
408 |
'io' => 'Ido', |
|
409 |
'ii' => 'Sichuan Yi', |
|
410 |
'iu' => 'Inuktitut', |
|
411 |
'ie' => 'Interlingue', |
|
412 |
'ia' => 'Interlingua (International Auxiliary Language Association)', |
|
413 |
'id' => 'Indonesian', |
|
414 |
'ik' => 'Inupiaq', |
|
415 |
'it' => 'Italian', |
|
416 |
'jv' => 'Javanese', |
|
417 |
'ja' => 'Japanese', |
|
418 |
'kl' => 'Kalaallisut; Greenlandic', |
|
419 |
'kn' => 'Kannada', |
|
420 |
'ks' => 'Kashmiri', |
|
421 |
'kr' => 'Kanuri', |
|
422 |
'kk' => 'Kazakh', |
|
423 |
'km' => 'Central Khmer', |
|
424 |
'ki' => 'Kikuyu; Gikuyu', |
|
425 |
'rw' => 'Kinyarwanda', |
|
426 |
'ky' => 'Kirghiz; Kyrgyz', |
|
427 |
'kv' => 'Komi', |
|
428 |
'kg' => 'Kongo', |
|
429 |
'ko' => 'Korean', |
|
430 |
'kj' => 'Kuanyama; Kwanyama', |
|
431 |
'ku' => 'Kurdish', |
|
432 |
'lo' => 'Lao', |
|
433 |
'la' => 'Latin', |
|
434 |
'lv' => 'Latvian', |
|
435 |
'li' => 'Limburgan; Limburger; Limburgish', |
|
436 |
'ln' => 'Lingala', |
|
437 |
'lt' => 'Lithuanian', |
|
438 |
'lb' => 'Luxembourgish; Letzeburgesch', |
|
439 |
'lu' => 'Luba-Katanga', |
|
440 |
'lg' => 'Ganda', |
|
441 |
'mk' => 'Macedonian', |
|
442 |
'mh' => 'Marshallese', |
|
443 |
'ml' => 'Malayalam', |
|
444 |
'mi' => 'Maori', |
|
445 |
'mr' => 'Marathi', |
|
446 |
'ms' => 'Malay', |
|
447 |
'mg' => 'Malagasy', |
|
448 |
'mt' => 'Maltese', |
|
449 |
'mo' => 'Moldavian', |
|
450 |
'mn' => 'Mongolian', |
|
451 |
'na' => 'Nauru', |
|
452 |
'nv' => 'Navajo; Navaho', |
|
453 |
'nr' => 'Ndebele, South; South Ndebele', |
|
454 |
'nd' => 'Ndebele, North; North Ndebele', |
|
455 |
'ng' => 'Ndonga', |
|
456 |
'ne' => 'Nepali', |
|
457 |
'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', |
|
458 |
'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', |
|
459 |
'no' => 'Norwegian', |
|
460 |
'ny' => 'Chichewa; Chewa; Nyanja', |
|
461 |
'oc' => 'Occitan, Provençal', |
|
462 |
'oj' => 'Ojibwa', |
|
463 |
'or' => 'Oriya', |
|
464 |
'om' => 'Oromo', |
|
465 |
'os' => 'Ossetian; Ossetic', |
|
466 |
'pa' => 'Panjabi; Punjabi', |
|
467 |
'fa' => 'Persian', |
|
468 |
'pi' => 'Pali', |
|
469 |
'pl' => 'Polish', |
|
470 |
'pt' => 'Portuguese', |
|
471 |
'ps' => 'Pushto', |
|
472 |
'qu' => 'Quechua', |
|
473 |
'rm' => 'Romansh', |
|
474 |
'ro' => 'Romanian', |
|
475 |
'rn' => 'Rundi', |
|
476 |
'ru' => 'Russian', |
|
477 |
'sg' => 'Sango', |
|
478 |
'sa' => 'Sanskrit', |
|
479 |
'sr' => 'Serbian', |
|
480 |
'hr' => 'Croatian', |
|
481 |
'si' => 'Sinhala; Sinhalese', |
|
482 |
'sk' => 'Slovak', |
|
483 |
'sl' => 'Slovenian', |
|
484 |
'se' => 'Northern Sami', |
|
485 |
'sm' => 'Samoan', |
|
486 |
'sn' => 'Shona', |
|
487 |
'sd' => 'Sindhi', |
|
488 |
'so' => 'Somali', |
|
489 |
'st' => 'Sotho, Southern', |
|
490 |
'es' => 'Spanish; Castilian', |
|
491 |
'sc' => 'Sardinian', |
|
492 |
'ss' => 'Swati', |
|
493 |
'su' => 'Sundanese', |
|
494 |
'sw' => 'Swahili', |
|
495 |
'sv' => 'Swedish', |
|
496 |
'ty' => 'Tahitian', |
|
497 |
'ta' => 'Tamil', |
|
498 |
'tt' => 'Tatar', |
|
499 |
'te' => 'Telugu', |
|
500 |
'tg' => 'Tajik', |
|
501 |
'tl' => 'Tagalog', |
|
502 |
'th' => 'Thai', |
|
503 |
'bo' => 'Tibetan', |
|
504 |
'ti' => 'Tigrinya', |
|
505 |
'to' => 'Tonga (Tonga Islands)', |
|
506 |
'tn' => 'Tswana', |
|
507 |
'ts' => 'Tsonga', |
|
508 |
'tk' => 'Turkmen', |
|
509 |
'tr' => 'Turkish', |
|
510 |
'tw' => 'Twi', |
|
511 |
'ug' => 'Uighur; Uyghur', |
|
512 |
'uk' => 'Ukrainian', |
|
513 |
'ur' => 'Urdu', |
|
514 |
'uz' => 'Uzbek', |
|
515 |
've' => 'Venda', |
|
516 |
'vi' => 'Vietnamese', |
|
517 |
'vo' => 'Volapük', |
|
518 |
'cy' => 'Welsh', |
|
519 |
'wa' => 'Walloon', |
|
520 |
'wo' => 'Wolof', |
|
521 |
'xh' => 'Xhosa', |
|
522 |
'yi' => 'Yiddish', |
|
523 |
'yo' => 'Yoruba', |
|
524 |
'za' => 'Zhuang; Chuang', |
|
525 |
'zu' => 'Zulu', |
|
526 |
); |
|
0 | 527 |
|
528 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
529 |
* Filters the language codes. |
0 | 530 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
531 |
* @since MU (3.0.0) |
0 | 532 |
* |
9 | 533 |
* @param string[] $lang_codes Array of key/value pairs of language codes where key is the short version. |
534 |
* @param string $code A two-letter designation of the language. |
|
0 | 535 |
*/ |
536 |
$lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); |
|
537 |
return strtr( $code, $lang_codes ); |
|
538 |
} |
|
539 |
||
5 | 540 |
/** |
9 | 541 |
* Synchronizes category and post tag slugs when global terms are enabled. |
5 | 542 |
* |
543 |
* @since 3.0.0 |
|
544 |
* |
|
9 | 545 |
* @param WP_Term|array $term The term. |
546 |
* @param string $taxonomy The taxonomy for `$term`. Should be 'category' or 'post_tag', as these are |
|
547 |
* the only taxonomies which are processed by this function; anything else |
|
548 |
* will be returned untouched. |
|
549 |
* @return WP_Term|array Returns `$term`, after filtering the 'slug' field with `sanitize_title()` |
|
550 |
* if `$taxonomy` is 'category' or 'post_tag'. |
|
5 | 551 |
*/ |
0 | 552 |
function sync_category_tag_slugs( $term, $taxonomy ) { |
16 | 553 |
if ( global_terms_enabled() && ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) ) { |
0 | 554 |
if ( is_object( $term ) ) { |
555 |
$term->slug = sanitize_title( $term->name ); |
|
556 |
} else { |
|
557 |
$term['slug'] = sanitize_title( $term['name'] ); |
|
558 |
} |
|
559 |
} |
|
560 |
return $term; |
|
561 |
} |
|
562 |
||
5 | 563 |
/** |
564 |
* Displays an access denied message when a user tries to view a site's dashboard they |
|
565 |
* do not have access to. |
|
566 |
* |
|
567 |
* @since 3.2.0 |
|
568 |
* @access private |
|
569 |
*/ |
|
0 | 570 |
function _access_denied_splash() { |
9 | 571 |
if ( ! is_user_logged_in() || is_network_admin() ) { |
0 | 572 |
return; |
9 | 573 |
} |
0 | 574 |
|
575 |
$blogs = get_blogs_of_user( get_current_user_id() ); |
|
576 |
||
9 | 577 |
if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) { |
0 | 578 |
return; |
9 | 579 |
} |
0 | 580 |
|
581 |
$blog_name = get_bloginfo( 'name' ); |
|
582 |
||
9 | 583 |
if ( empty( $blogs ) ) { |
16 | 584 |
wp_die( |
585 |
sprintf( |
|
586 |
/* translators: 1: Site title. */ |
|
587 |
__( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), |
|
588 |
$blog_name |
|
589 |
), |
|
590 |
403 |
|
591 |
); |
|
9 | 592 |
} |
0 | 593 |
|
16 | 594 |
$output = '<p>' . sprintf( |
595 |
/* translators: 1: Site title. */ |
|
596 |
__( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), |
|
597 |
$blog_name |
|
598 |
) . '</p>'; |
|
0 | 599 |
$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>'; |
600 |
||
9 | 601 |
$output .= '<h3>' . __( 'Your Sites' ) . '</h3>'; |
0 | 602 |
$output .= '<table>'; |
603 |
||
604 |
foreach ( $blogs as $blog ) { |
|
5 | 605 |
$output .= '<tr>'; |
606 |
$output .= "<td>{$blog->blogname}</td>"; |
|
607 |
$output .= '<td><a href="' . esc_url( get_admin_url( $blog->userblog_id ) ) . '">' . __( 'Visit Dashboard' ) . '</a> | ' . |
|
9 | 608 |
'<a href="' . esc_url( get_home_url( $blog->userblog_id ) ) . '">' . __( 'View Site' ) . '</a></td>'; |
5 | 609 |
$output .= '</tr>'; |
0 | 610 |
} |
5 | 611 |
|
0 | 612 |
$output .= '</table>'; |
613 |
||
5 | 614 |
wp_die( $output, 403 ); |
0 | 615 |
} |
616 |
||
5 | 617 |
/** |
618 |
* Checks if the current user has permissions to import new users. |
|
619 |
* |
|
620 |
* @since 3.0.0 |
|
621 |
* |
|
622 |
* @param string $permission A permission to be checked. Currently not used. |
|
623 |
* @return bool True if the user has proper permissions, false if they do not. |
|
624 |
*/ |
|
0 | 625 |
function check_import_new_users( $permission ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
if ( ! current_user_can( 'manage_network_users' ) ) { |
0 | 627 |
return false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
629 |
|
0 | 630 |
return true; |
631 |
} |
|
632 |
// See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too. |
|
633 |
||
5 | 634 |
/** |
635 |
* Generates and displays a drop-down of available languages. |
|
636 |
* |
|
637 |
* @since 3.0.0 |
|
638 |
* |
|
9 | 639 |
* @param string[] $lang_files Optional. An array of the language files. Default empty array. |
640 |
* @param string $current Optional. The current language code. Default empty. |
|
5 | 641 |
*/ |
0 | 642 |
function mu_dropdown_languages( $lang_files = array(), $current = '' ) { |
9 | 643 |
$flag = false; |
0 | 644 |
$output = array(); |
645 |
||
646 |
foreach ( (array) $lang_files as $val ) { |
|
647 |
$code_lang = basename( $val, '.mo' ); |
|
648 |
||
16 | 649 |
if ( 'en_US' === $code_lang ) { // American English. |
9 | 650 |
$flag = true; |
651 |
$ae = __( 'American English' ); |
|
652 |
$output[ $ae ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>'; |
|
16 | 653 |
} elseif ( 'en_GB' === $code_lang ) { // British English. |
9 | 654 |
$flag = true; |
655 |
$be = __( 'British English' ); |
|
656 |
$output[ $be ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>'; |
|
0 | 657 |
} else { |
9 | 658 |
$translated = format_code_lang( $code_lang ); |
659 |
$output[ $translated ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html( $translated ) . '</option>'; |
|
0 | 660 |
} |
661 |
} |
|
662 |
||
16 | 663 |
if ( false === $flag ) { // WordPress English. |
9 | 664 |
$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . '</option>'; |
665 |
} |
|
0 | 666 |
|
16 | 667 |
// Order by name. |
0 | 668 |
uksort( $output, 'strnatcasecmp' ); |
5 | 669 |
|
0 | 670 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
* Filters the languages available in the dropdown. |
0 | 672 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
* @since MU (3.0.0) |
0 | 674 |
* |
9 | 675 |
* @param string[] $output Array of HTML output for the dropdown. |
676 |
* @param string[] $lang_files Array of available language files. |
|
677 |
* @param string $current The current language code. |
|
0 | 678 |
*/ |
679 |
$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current ); |
|
5 | 680 |
|
0 | 681 |
echo implode( "\n\t", $output ); |
682 |
} |
|
683 |
||
5 | 684 |
/** |
685 |
* Displays an admin notice to upgrade all sites after a core upgrade. |
|
686 |
* |
|
687 |
* @since 3.0.0 |
|
688 |
* |
|
16 | 689 |
* @global int $wp_db_version WordPress database version. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
690 |
* @global string $pagenow |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
691 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
692 |
* @return false False if the current user is not a super admin. |
5 | 693 |
*/ |
0 | 694 |
function site_admin_notice() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
global $wp_db_version, $pagenow; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
if ( ! current_user_can( 'upgrade_network' ) ) { |
0 | 698 |
return false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
|
16 | 701 |
if ( 'upgrade.php' === $pagenow ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) { |
16 | 706 |
echo "<div class='update-nag notice notice-warning inline'>" . sprintf( |
707 |
/* translators: %s: URL to Upgrade Network screen. */ |
|
708 |
__( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), |
|
709 |
esc_url( network_admin_url( 'upgrade.php' ) ) |
|
710 |
) . '</div>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
} |
0 | 712 |
} |
713 |
||
5 | 714 |
/** |
715 |
* Avoids a collision between a site slug and a permalink slug. |
|
716 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
* In a subdirectory installation this will make sure that a site and a post do not use the |
5 | 718 |
* same subdirectory by checking for a site with the same name as a new post. |
719 |
* |
|
720 |
* @since 3.0.0 |
|
721 |
* |
|
722 |
* @param array $data An array of post data. |
|
723 |
* @param array $postarr An array of posts. Not currently used. |
|
724 |
* @return array The new array of post data after checking for collisions. |
|
725 |
*/ |
|
0 | 726 |
function avoid_blog_page_permalink_collision( $data, $postarr ) { |
9 | 727 |
if ( is_subdomain_install() ) { |
0 | 728 |
return $data; |
9 | 729 |
} |
16 | 730 |
if ( 'page' !== $data['post_type'] ) { |
0 | 731 |
return $data; |
9 | 732 |
} |
16 | 733 |
if ( ! isset( $data['post_name'] ) || '' === $data['post_name'] ) { |
0 | 734 |
return $data; |
9 | 735 |
} |
736 |
if ( ! is_main_site() ) { |
|
0 | 737 |
return $data; |
9 | 738 |
} |
0 | 739 |
|
740 |
$post_name = $data['post_name']; |
|
9 | 741 |
$c = 0; |
742 |
while ( $c < 10 && get_id_from_blogname( $post_name ) ) { |
|
0 | 743 |
$post_name .= mt_rand( 1, 10 ); |
744 |
$c ++; |
|
745 |
} |
|
746 |
if ( $post_name != $data['post_name'] ) { |
|
747 |
$data['post_name'] = $post_name; |
|
748 |
} |
|
749 |
return $data; |
|
750 |
} |
|
751 |
||
5 | 752 |
/** |
753 |
* Handles the display of choosing a user's primary site. |
|
754 |
* |
|
755 |
* This displays the user's primary site and allows the user to choose |
|
756 |
* which site is primary. |
|
757 |
* |
|
758 |
* @since 3.0.0 |
|
759 |
*/ |
|
0 | 760 |
function choose_primary_blog() { |
761 |
?> |
|
9 | 762 |
<table class="form-table" role="presentation"> |
0 | 763 |
<tr> |
16 | 764 |
<?php /* translators: My Sites label. */ ?> |
5 | 765 |
<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th> |
0 | 766 |
<td> |
767 |
<?php |
|
9 | 768 |
$all_blogs = get_blogs_of_user( get_current_user_id() ); |
0 | 769 |
$primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true ); |
770 |
if ( count( $all_blogs ) > 1 ) { |
|
771 |
$found = false; |
|
772 |
?> |
|
5 | 773 |
<select name="primary_blog" id="primary_blog"> |
9 | 774 |
<?php |
775 |
foreach ( (array) $all_blogs as $blog ) { |
|
776 |
if ( $primary_blog == $blog->userblog_id ) { |
|
0 | 777 |
$found = true; |
9 | 778 |
} |
779 |
?> |
|
780 |
<option value="<?php echo $blog->userblog_id; ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ); ?></option> |
|
781 |
<?php |
|
782 |
} |
|
783 |
?> |
|
0 | 784 |
</select> |
785 |
<?php |
|
9 | 786 |
if ( ! $found ) { |
5 | 787 |
$blog = reset( $all_blogs ); |
0 | 788 |
update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id ); |
789 |
} |
|
790 |
} elseif ( count( $all_blogs ) == 1 ) { |
|
5 | 791 |
$blog = reset( $all_blogs ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
792 |
echo esc_url( get_home_url( $blog->userblog_id ) ); |
9 | 793 |
if ( $primary_blog != $blog->userblog_id ) { // Set the primary blog again if it's out of sync with blog list. |
0 | 794 |
update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id ); |
9 | 795 |
} |
0 | 796 |
} else { |
9 | 797 |
echo 'N/A'; |
0 | 798 |
} |
799 |
?> |
|
800 |
</td> |
|
801 |
</tr> |
|
802 |
</table> |
|
803 |
<?php |
|
804 |
} |
|
805 |
||
806 |
/** |
|
5 | 807 |
* Whether or not we can edit this network from this page. |
0 | 808 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
809 |
* By default editing of network is restricted to the Network Admin for that `$network_id`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
810 |
* This function allows for this to be overridden. |
0 | 811 |
* |
812 |
* @since 3.1.0 |
|
5 | 813 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
814 |
* @param int $network_id The network ID to check. |
5 | 815 |
* @return bool True if network can be edited, otherwise false. |
0 | 816 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
817 |
function can_edit_network( $network_id ) { |
16 | 818 |
if ( get_current_network_id() == $network_id ) { |
0 | 819 |
$result = true; |
9 | 820 |
} else { |
0 | 821 |
$result = false; |
9 | 822 |
} |
0 | 823 |
|
824 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
825 |
* Filters whether this network can be edited from this page. |
0 | 826 |
* |
827 |
* @since 3.1.0 |
|
828 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
829 |
* @param bool $result Whether the network can be edited from this page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
830 |
* @param int $network_id The network ID to check. |
0 | 831 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
832 |
return apply_filters( 'can_edit_network', $result, $network_id ); |
0 | 833 |
} |
834 |
||
835 |
/** |
|
836 |
* Thickbox image paths for Network Admin. |
|
837 |
* |
|
838 |
* @since 3.1.0 |
|
5 | 839 |
* |
0 | 840 |
* @access private |
841 |
*/ |
|
842 |
function _thickbox_path_admin_subfolder() { |
|
9 | 843 |
?> |
0 | 844 |
<script type="text/javascript"> |
5 | 845 |
var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ); ?>"; |
0 | 846 |
</script> |
9 | 847 |
<?php |
0 | 848 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
849 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
850 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
851 |
* @param array $users |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
852 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
853 |
function confirm_delete_users( $users ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
854 |
$current_user = wp_get_current_user(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
855 |
if ( ! is_array( $users ) || empty( $users ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
856 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
857 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
858 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
859 |
<h1><?php esc_html_e( 'Users' ); ?></h1> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
|
16 | 861 |
<?php if ( 1 === count( $users ) ) : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
<?php else : ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
864 |
<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
<?php endif; ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
866 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
867 |
<form action="users.php?action=dodelete" method="post"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
868 |
<input type="hidden" name="dodelete" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
869 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
870 |
wp_nonce_field( 'ms-users-delete' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
$site_admins = get_super_admins(); |
9 | 872 |
$admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>'; |
873 |
?> |
|
874 |
<table class="form-table" role="presentation"> |
|
875 |
<?php |
|
16 | 876 |
$allusers = (array) $_POST['allusers']; |
877 |
foreach ( $allusers as $user_id ) { |
|
878 |
if ( '' !== $user_id && '0' != $user_id ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
$delete_user = get_userdata( $user_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
881 |
if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) { |
16 | 882 |
wp_die( |
883 |
sprintf( |
|
884 |
/* translators: %s: User login. */ |
|
885 |
__( 'Warning! User %s cannot be deleted.' ), |
|
886 |
$delete_user->user_login |
|
887 |
) |
|
888 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
889 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
|
16 | 891 |
if ( in_array( $delete_user->user_login, $site_admins, true ) ) { |
892 |
wp_die( |
|
893 |
sprintf( |
|
894 |
/* translators: %s: User login. */ |
|
895 |
__( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), |
|
896 |
'<em>' . $delete_user->user_login . '</em>' |
|
897 |
) |
|
898 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
899 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
<tr> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
<th scope="row"><?php echo $delete_user->user_login; ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
<?php echo '<input type="hidden" name="user[]" value="' . esc_attr( $user_id ) . '" />' . "\n"; ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
</th> |
9 | 905 |
<?php |
906 |
$blogs = get_blogs_of_user( $user_id, true ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
908 |
if ( ! empty( $blogs ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
909 |
?> |
9 | 910 |
<td><fieldset><p><legend> |
911 |
<?php |
|
912 |
printf( |
|
16 | 913 |
/* translators: %s: User login. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
__( 'What should be done with content owned by %s?' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
'<em>' . $delete_user->user_login . '</em>' |
9 | 916 |
); |
917 |
?> |
|
918 |
</legend></p> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
919 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
920 |
foreach ( (array) $blogs as $key => $details ) { |
9 | 921 |
$blog_users = get_users( |
922 |
array( |
|
923 |
'blog_id' => $details->userblog_id, |
|
924 |
'fields' => array( 'ID', 'user_login' ), |
|
925 |
) |
|
926 |
); |
|
16 | 927 |
|
9 | 928 |
if ( is_array( $blog_users ) && ! empty( $blog_users ) ) { |
929 |
$user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>"; |
|
930 |
$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
$user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>"; |
9 | 932 |
$user_list = ''; |
16 | 933 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
foreach ( $blog_users as $user ) { |
16 | 935 |
if ( ! in_array( (int) $user->ID, $allusers, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
} |
16 | 939 |
|
940 |
if ( '' === $user_list ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
941 |
$user_list = $admin_out; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
} |
16 | 943 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
944 |
$user_dropdown .= $user_list; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
945 |
$user_dropdown .= "</select>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
<ul style="list-style:none;"> |
16 | 948 |
<li> |
949 |
<?php |
|
950 |
/* translators: %s: Link to user's site. */ |
|
951 |
printf( __( 'Site: %s' ), $user_site ); |
|
952 |
?> |
|
953 |
</li> |
|
9 | 954 |
<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID; ?>]" value="delete" checked="checked" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
<?php _e( 'Delete all content.' ); ?></label></li> |
9 | 956 |
<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID; ?>]" value="reassign" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
<?php _e( 'Attribute all content to:' ); ?></label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
<?php echo $user_dropdown; ?></li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
959 |
</ul> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
960 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
961 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
962 |
} |
9 | 963 |
echo '</fieldset></td></tr>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
964 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
965 |
?> |
9 | 966 |
<td><p><?php _e( 'User has no sites or content and will be deleted.' ); ?></p></td> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
967 |
<?php } ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
968 |
</tr> |
9 | 969 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
970 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
972 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
973 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
</table> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
/** This action is documented in wp-admin/users.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
977 |
do_action( 'delete_user_form', $current_user, $allusers ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
|
16 | 979 |
if ( 1 === count( $users ) ) : |
9 | 980 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
981 |
<p><?php _e( 'Once you hit “Confirm Deletion”, the user will be permanently removed.' ); ?></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
982 |
<?php else : ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
983 |
<p><?php _e( 'Once you hit “Confirm Deletion”, these users will be permanently removed.' ); ?></p> |
9 | 984 |
<?php |
985 |
endif; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
986 |
|
9 | 987 |
submit_button( __( 'Confirm Deletion' ), 'primary' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
989 |
</form> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
991 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
992 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
994 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
* Print JavaScript in the header on the Network Settings screen. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
997 |
* @since 4.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
998 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
function network_settings_add_js() { |
9 | 1000 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
<script type="text/javascript"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
jQuery(document).ready( function($) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
var languageSelect = $( '#WPLANG' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
$( 'form' ).submit( function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1005 |
// Don't show a spinner for English and installed languages, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
// as there is nothing to download. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1007 |
if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
$( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1009 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1010 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1011 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
</script> |
9 | 1013 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1016 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1017 |
* Outputs the HTML for a network's "Edit Site" tabular interface. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1020 |
* |
16 | 1021 |
* @param array $args { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1022 |
* Optional. Array or string of Query parameters. Default empty array. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1023 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1024 |
* @type int $blog_id The site ID. Default is the current site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1025 |
* @type array $links The tabs to include with (label|url|cap) keys. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1026 |
* @type string $selected The ID of the selected link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1027 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1028 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1029 |
function network_edit_site_nav( $args = array() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1030 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1031 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1032 |
* Filters the links that appear on site-editing network pages. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1033 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1034 |
* Default links: 'site-info', 'site-users', 'site-themes', and 'site-settings'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1035 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1036 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1037 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1038 |
* @param array $links { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1039 |
* An array of link data representing individual network admin pages. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1041 |
* @type array $link_slug { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1042 |
* An array of information about the individual link to a page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1043 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1044 |
* $type string $label Label to use for the link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1045 |
* $type string $url URL, relative to `network_admin_url()` to use for the link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
* $type string $cap Capability required to see the link. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1048 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1049 |
*/ |
9 | 1050 |
$links = apply_filters( |
1051 |
'network_edit_site_nav_links', |
|
1052 |
array( |
|
1053 |
'site-info' => array( |
|
1054 |
'label' => __( 'Info' ), |
|
1055 |
'url' => 'site-info.php', |
|
1056 |
'cap' => 'manage_sites', |
|
1057 |
), |
|
1058 |
'site-users' => array( |
|
1059 |
'label' => __( 'Users' ), |
|
1060 |
'url' => 'site-users.php', |
|
1061 |
'cap' => 'manage_sites', |
|
1062 |
), |
|
1063 |
'site-themes' => array( |
|
1064 |
'label' => __( 'Themes' ), |
|
1065 |
'url' => 'site-themes.php', |
|
1066 |
'cap' => 'manage_sites', |
|
1067 |
), |
|
1068 |
'site-settings' => array( |
|
1069 |
'label' => __( 'Settings' ), |
|
1070 |
'url' => 'site-settings.php', |
|
1071 |
'cap' => 'manage_sites', |
|
1072 |
), |
|
1073 |
) |
|
1074 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1075 |
|
16 | 1076 |
// Parse arguments. |
1077 |
$parsed_args = wp_parse_args( |
|
9 | 1078 |
$args, |
1079 |
array( |
|
1080 |
'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0, |
|
1081 |
'links' => $links, |
|
1082 |
'selected' => 'site-info', |
|
1083 |
) |
|
1084 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
|
16 | 1086 |
// Setup the links array. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1087 |
$screen_links = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1088 |
|
16 | 1089 |
// Loop through tabs. |
1090 |
foreach ( $parsed_args['links'] as $link_id => $link ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
|
16 | 1092 |
// Skip link if user can't access. |
1093 |
if ( ! current_user_can( $link['cap'], $parsed_args['blog_id'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
|
16 | 1097 |
// Link classes. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
$classes = array( 'nav-tab' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1099 |
|
9 | 1100 |
// Aria-current attribute. |
1101 |
$aria_current = ''; |
|
1102 |
||
16 | 1103 |
// Selected is set by the parent OR assumed by the $pagenow global. |
1104 |
if ( $parsed_args['selected'] === $link_id || $link['url'] === $GLOBALS['pagenow'] ) { |
|
9 | 1105 |
$classes[] = 'nav-tab-active'; |
1106 |
$aria_current = ' aria-current="page"'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
|
16 | 1109 |
// Escape each class. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
$esc_classes = implode( ' ', $classes ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1111 |
|
16 | 1112 |
// Get the URL for this link. |
1113 |
$url = add_query_arg( array( 'id' => $parsed_args['blog_id'] ), network_admin_url( $link['url'] ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1114 |
|
16 | 1115 |
// Add link to nav links. |
9 | 1116 |
$screen_links[ $link_id ] = '<a href="' . esc_url( $url ) . '" id="' . esc_attr( $link_id ) . '" class="' . $esc_classes . '"' . $aria_current . '>' . esc_html( $link['label'] ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1117 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1118 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1119 |
// All done! |
9 | 1120 |
echo '<nav class="nav-tab-wrapper wp-clearfix" aria-label="' . esc_attr__( 'Secondary menu' ) . '">'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1121 |
echo implode( '', $screen_links ); |
9 | 1122 |
echo '</nav>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1123 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1124 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1125 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
* Returns the arguments for the help tab on the Edit Site screens. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1127 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1128 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
* @return array Help tab arguments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1131 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
function get_site_screen_help_tab_args() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1133 |
return array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
'id' => 'overview', |
9 | 1135 |
'title' => __( 'Overview' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
'content' => |
9 | 1137 |
'<p>' . __( 'The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.' ) . '</p>' . |
1138 |
'<p>' . __( '<strong>Info</strong> — The site URL is rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.' ) . '</p>' . |
|
1139 |
'<p>' . __( '<strong>Users</strong> — This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.' ) . '</p>' . |
|
16 | 1140 |
'<p>' . sprintf( |
1141 |
/* translators: %s: URL to Network Themes screen. */ |
|
1142 |
__( '<strong>Themes</strong> — This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site’s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), |
|
1143 |
network_admin_url( 'themes.php' ) |
|
1144 |
) . '</p>' . |
|
9 | 1145 |
'<p>' . __( '<strong>Settings</strong> — This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.' ) . '</p>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1146 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1147 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1148 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1149 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1150 |
* Returns the content for the help sidebar on the Edit Site screens. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1151 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1152 |
* @since 4.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1153 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
* @return string Help sidebar content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1155 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1156 |
function get_site_screen_help_sidebar_content() { |
9 | 1157 |
return '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
16 | 1158 |
'<p>' . __( '<a href="https://wordpress.org/support/article/network-admin-sites-screen/">Documentation on Site Management</a>' ) . '</p>' . |
9 | 1159 |
'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
} |