3 * Action handler for Multisite administration panels.
6 * @subpackage Multisite
10 /** Load WordPress Administration Bootstrap */
11 require_once( './admin.php' );
13 if ( ! is_multisite() )
14 wp_die( __( 'Multisite support is not enabled.' ) );
16 if ( empty( $_GET['action'] ) ) {
17 wp_redirect( admin_url( 'index.php' ) );
21 function confirm_delete_users( $users ) {
22 $current_user = wp_get_current_user();
23 if ( !is_array( $users ) )
28 <h2><?php esc_html_e( 'Users' ); ?></h2>
29 <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
30 <form action="edit.php?action=dodelete" method="post">
31 <input type="hidden" name="dodelete" />
33 wp_nonce_field( 'ms-users-delete' );
34 $site_admins = get_super_admins();
35 $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>";
37 foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) {
38 if ( $val != '' && $val != '0' ) {
39 $delete_user = new WP_User( $val );
41 if ( ! current_user_can( 'delete_user', $delete_user->ID ) )
42 wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) );
44 if ( in_array( $delete_user->user_login, $site_admins ) )
45 wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network admnistrator.' ), $delete_user->user_login ) );
47 echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
48 $blogs = get_blogs_of_user( $val, true );
50 if ( !empty( $blogs ) ) {
52 <br /><fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
54 foreach ( (array) $blogs as $key => $details ) {
55 $blog_users = get_users( array( 'blog_id' => $details->userblog_id ) );
56 if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
57 $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
58 $user_dropdown = "<select name='blog[$val][{$key}]'>";
60 foreach ( $blog_users as $user ) {
61 if ( ! in_array( $user->ID, $allusers ) )
62 $user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
64 if ( '' == $user_list )
65 $user_list = $admin_out;
66 $user_dropdown .= $user_list;
67 $user_dropdown .= "</select>\n";
69 <ul style="list-style:none;">
70 <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
71 <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
72 <?php _e( 'Delete all posts and links.' ); ?></label></li>
73 <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
74 <?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
84 submit_button( __('Confirm Deletion'), 'delete' );
91 do_action( 'wpmuadminedit' , '');
93 if ( isset( $_GET['id' ]) )
94 $id = intval( $_GET['id'] );
95 elseif ( isset( $_POST['id'] ) )
96 $id = intval( $_POST['id'] );
98 switch ( $_GET['action'] ) {
100 check_admin_referer( 'siteoptions' );
101 if ( ! current_user_can( 'manage_network_options' ) )
102 wp_die( __( 'You do not have permission to access this page.' ) );
104 if ( empty( $_POST ) )
105 wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">options page</a>.' ), esc_url( admin_url( 'settings.php' ) ) ) );
107 if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) )
108 update_site_option( 'WPLANG', $_POST['WPLANG'] );
110 if ( is_email( $_POST['admin_email'] ) )
111 update_site_option( 'admin_email', $_POST['admin_email'] );
113 $illegal_names = split( ' ', $_POST['illegal_names'] );
114 foreach ( (array) $illegal_names as $name ) {
115 $name = trim( $name );
117 $names[] = trim( $name );
119 update_site_option( 'illegal_names', $names );
121 if ( $_POST['limited_email_domains'] != '' ) {
122 $limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] );
123 $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) );
124 $limited_email = array();
125 foreach ( (array) $limited_email_domains as $domain ) {
126 $domain = trim( $domain );
127 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
128 $limited_email[] = trim( $domain );
130 update_site_option( 'limited_email_domains', $limited_email );
132 update_site_option( 'limited_email_domains', '' );
135 if ( $_POST['banned_email_domains'] != '' ) {
136 $banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) );
138 foreach ( (array) $banned_email_domains as $domain ) {
139 $domain = trim( $domain );
140 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
141 $banned[] = trim( $domain );
143 update_site_option( 'banned_email_domains', $banned );
145 update_site_option( 'banned_email_domains', '' );
148 $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled' );
149 $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 );
150 foreach ( $checked_options as $option_name => $option_unchecked_value ) {
151 if ( ! isset( $_POST[$option_name] ) )
152 $_POST[$option_name] = $option_unchecked_value;
154 foreach ( $options as $option_name ) {
155 if ( ! isset($_POST[$option_name]) )
157 $value = stripslashes_deep( $_POST[$option_name] );
158 update_site_option( $option_name, $value );
161 // Update more options here
162 do_action( 'update_wpmu_options' );
164 wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) );
173 check_admin_referer('deleteblog');
174 if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) )
175 wp_die( __( 'You do not have permission to access this page.' ) );
177 if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
178 wpmu_delete_blog( $id, true );
179 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
181 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) );
188 if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
189 check_admin_referer( 'bulk-sites' );
191 if ( ! current_user_can( 'manage_sites' ) )
192 wp_die( __( 'You do not have permission to access this page.' ) );
194 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
195 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
199 foreach ( (array) $_POST['allblogs'] as $key => $val ) {
200 if ( $val != '0' && $val != $current_site->blog_id ) {
201 switch ( $doaction ) {
203 if ( ! current_user_can( 'delete_site', $val ) )
204 wp_die( __( 'You are not allowed to delete the site.' ) );
205 $blogfunction = 'all_delete';
206 wpmu_delete_blog( $val, true );
210 $blogfunction = 'all_spam';
211 update_blog_status( $val, 'spam', '1' );
212 set_time_limit( 60 );
216 $blogfunction = 'all_notspam';
217 update_blog_status( $val, 'spam', '0' );
218 set_time_limit( 60 );
222 wp_die( __( 'You are not allowed to change the current site.' ) );
226 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
228 wp_redirect( network_admin_url( 'sites.php' ) );
234 check_admin_referer( 'archiveblog' );
235 if ( ! current_user_can( 'manage_sites' ) )
236 wp_die( __( 'You do not have permission to access this page.' ) );
238 update_blog_status( $id, 'archived', '1' );
239 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
243 case 'unarchiveblog':
244 check_admin_referer( 'unarchiveblog' );
245 if ( ! current_user_can( 'manage_sites' ) )
246 wp_die( __( 'You do not have permission to access this page.' ) );
248 update_blog_status( $id, 'archived', '0' );
249 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
254 check_admin_referer( 'activateblog' );
255 if ( ! current_user_can( 'manage_sites' ) )
256 wp_die( __( 'You do not have permission to access this page.' ) );
258 update_blog_status( $id, 'deleted', '0' );
259 do_action( 'activate_blog', $id );
260 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
264 case 'deactivateblog':
265 check_admin_referer( 'deactivateblog' );
266 if ( ! current_user_can( 'manage_sites' ) )
267 wp_die( __( 'You do not have permission to access this page.' ) );
269 do_action( 'deactivate_blog', $id );
270 update_blog_status( $id, 'deleted', '1' );
271 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
276 check_admin_referer( 'unspamblog' );
277 if ( ! current_user_can( 'manage_sites' ) )
278 wp_die( __( 'You do not have permission to access this page.' ) );
280 update_blog_status( $id, 'spam', '0' );
281 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
286 check_admin_referer( 'spamblog' );
287 if ( ! current_user_can( 'manage_sites' ) )
288 wp_die( __( 'You do not have permission to access this page.' ) );
290 update_blog_status( $id, 'spam', '1' );
291 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
296 check_admin_referer( 'unmatureblog' );
297 if ( ! current_user_can( 'manage_sites' ) )
298 wp_die( __( 'You do not have permission to access this page.' ) );
300 update_blog_status( $id, 'mature', '0' );
301 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
306 check_admin_referer( 'matureblog' );
307 if ( ! current_user_can( 'manage_sites' ) )
308 wp_die( __( 'You do not have permission to access this page.' ) );
310 update_blog_status( $id, 'mature', '1' );
311 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
317 check_admin_referer( 'confirm' );
318 if ( !headers_sent() ) {
320 header( 'Content-Type: text/html; charset=utf-8' );
322 if ( $current_site->blog_id == $id )
323 wp_die( __( 'You are not allowed to change the current site.' ) );
325 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
326 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
328 <title><?php _e( 'WordPress › Confirm your action' ); ?></title>
330 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
332 wp_admin_css( 'install', true );
333 wp_admin_css( 'ie', true );
337 <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
338 <form action="edit.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
339 <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
340 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
341 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
342 <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
343 <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
344 <?php submit_button( __('Confirm'), 'button' ); ?>
354 if ( ! current_user_can( 'manage_network_users' ) )
355 wp_die( __( 'You do not have permission to access this page.' ) );
357 check_admin_referer( 'deleteuser' );
359 if ( $id != '0' && $id != '1' ) {
360 $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays
361 $title = __( 'Users' );
362 $parent_file = 'users.php';
363 require_once( '../admin-header.php' );
364 echo '<div class="wrap">';
365 confirm_delete_users( $_POST['allusers'] );
367 require_once( '../admin-footer.php' );
369 wp_redirect( network_admin_url( 'users.php' ) );
375 if ( !current_user_can( 'manage_network_users' ) )
376 wp_die( __( 'You do not have permission to access this page.' ) );
378 if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) {
379 check_admin_referer( 'bulk-users-network' );
381 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
382 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
386 foreach ( (array) $_POST['allusers'] as $key => $val ) {
387 if ( !empty( $val ) ) {
388 switch ( $doaction ) {
390 if ( ! current_user_can( 'delete_users' ) )
391 wp_die( __( 'You do not have permission to access this page.' ) );
392 $title = __( 'Users' );
393 $parent_file = 'users.php';
394 require_once( '../admin-header.php' );
395 echo '<div class="wrap">';
396 confirm_delete_users( $_POST['allusers'] );
398 require_once( '../admin-footer.php' );
403 $user = new WP_User( $val );
404 if ( in_array( $user->user_login, get_super_admins() ) )
405 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) );
407 $userfunction = 'all_spam';
408 $blogs = get_blogs_of_user( $val, true );
409 foreach ( (array) $blogs as $key => $details ) {
410 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
411 update_blog_status( $details->userblog_id, 'spam', '1' );
413 update_user_status( $val, 'spam', '1' );
417 $userfunction = 'all_notspam';
418 $blogs = get_blogs_of_user( $val, true );
419 foreach ( (array) $blogs as $key => $details )
420 update_blog_status( $details->userblog_id, 'spam', '0' );
422 update_user_status( $val, 'spam', '0' );
428 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
430 $location = network_admin_url( 'users.php' );
432 if ( ! empty( $_REQUEST['paged'] ) )
433 $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
434 wp_redirect( $location );
440 check_admin_referer( 'ms-users-delete' );
441 if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) )
442 wp_die( __( 'You do not have permission to access this page.' ) );
444 if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
445 foreach ( $_POST['blog'] as $id => $users ) {
446 foreach ( $users as $blogid => $user_id ) {
447 if ( ! current_user_can( 'delete_user', $id ) )
450 if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
451 remove_user_from_blog( $id, $blogid, $user_id );
453 remove_user_from_blog( $id, $blogid );
458 if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
459 foreach( $_POST['user'] as $id ) {
460 if ( ! current_user_can( 'delete_user', $id ) )
462 wpmu_delete_user( $id );
467 $deletefunction = 'delete';
469 $deletefunction = 'all_delete';
471 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) );
476 // Let plugins use us as a post handler easily
477 do_action( 'network_admin_edit_' . $_GET['action'] );
478 wp_redirect( network_admin_url( 'index.php' ) );