Ticket #14435: 14435.2.diff
File 14435.2.diff, 231.7 KB (added by , 14 years ago) |
---|
-
wp-includes/load.php
569 569 } 570 570 571 571 /** 572 * Whether the current request is in WordPress network admin Panel 573 * 574 * Does not inform on whether the user is a network admin! Use capability checks to 575 * tell if the user should be accessing a section or not. 576 * 577 * @since 3.1.0 578 * 579 * @return bool True if inside WordPress network administration pages. 580 */ 581 function is_network_admin() { 582 if ( defined( 'WP_NETWORK_ADMIN' ) ) 583 return WP_NETWORK_ADMIN; 584 return false; 585 } 586 587 /** 572 588 * Whether Multisite support is enabled 573 589 * 574 590 * @since 3.0.0 -
wp-includes/link-template.php
2132 2132 * @return string Admin url link with optional path appended 2133 2133 */ 2134 2134 function network_admin_url( $path = '', $scheme = 'admin' ) { 2135 $url = network_site_url('wp-admin/ ', $scheme);2135 $url = network_site_url('wp-admin/network/', $scheme); 2136 2136 2137 2137 if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) 2138 2138 $url .= ltrim($path, '/'); -
wp-admin/ms-edit.php
9 9 10 10 require_once( './admin.php' ); 11 11 12 if ( ! is_multisite() ) 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 15 if ( empty( $_GET['action'] ) ) 16 wp_redirect( admin_url( 'ms-admin.php' ) ); 17 18 do_action( 'wpmuadminedit' , ''); 19 20 if ( isset( $_GET['id' ]) ) 21 $id = intval( $_GET['id'] ); 22 elseif ( isset( $_POST['id'] ) ) 23 $id = intval( $_POST['id'] ); 24 25 switch ( $_GET['action'] ) { 26 case 'siteoptions': 27 check_admin_referer( 'siteoptions' ); 28 if ( ! current_user_can( 'manage_network_options' ) ) 29 wp_die( __( 'You do not have permission to access this page.' ) ); 30 31 if ( empty( $_POST ) ) 32 wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">options page</a>.', esc_url( admin_url( 'ms-options.php' ) ) ) ) ); 33 34 if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) ) 35 update_site_option( 'WPLANG', $_POST['WPLANG'] ); 36 37 if ( is_email( $_POST['admin_email'] ) ) 38 update_site_option( 'admin_email', $_POST['admin_email'] ); 39 40 $illegal_names = split( ' ', $_POST['illegal_names'] ); 41 foreach ( (array) $illegal_names as $name ) { 42 $name = trim( $name ); 43 if ( $name != '' ) 44 $names[] = trim( $name ); 45 } 46 update_site_option( 'illegal_names', $names ); 47 48 if ( $_POST['limited_email_domains'] != '' ) { 49 $limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] ); 50 $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) ); 51 $limited_email = array(); 52 foreach ( (array) $limited_email_domains as $domain ) { 53 $domain = trim( $domain ); 54 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) 55 $limited_email[] = trim( $domain ); 56 } 57 update_site_option( 'limited_email_domains', $limited_email ); 58 } else { 59 update_site_option( 'limited_email_domains', '' ); 60 } 61 62 if ( $_POST['banned_email_domains'] != '' ) { 63 $banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) ); 64 $banned = array(); 65 foreach ( (array) $banned_email_domains as $domain ) { 66 $domain = trim( $domain ); 67 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) 68 $banned[] = trim( $domain ); 69 } 70 update_site_option( 'banned_email_domains', $banned ); 71 } else { 72 update_site_option( 'banned_email_domains', '' ); 73 } 74 update_site_option( 'default_user_role', $_POST['default_user_role'] ); 75 if ( trim( $_POST['dashboard_blog_orig'] ) == '' ) 76 $_POST['dashboard_blog_orig'] = $current_site->blog_id; 77 if ( trim( $_POST['dashboard_blog'] ) == '' ) { 78 $_POST['dashboard_blog'] = $current_site->blog_id; 79 $dashboard_blog_id = $current_site->blog_id; 80 } elseif ( ! preg_match( '/(--|\.)/', $_POST['dashboard_blog'] ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $_POST['dashboard_blog'] ) ) { 81 $dashboard_blog = $_POST['dashboard_blog']; 82 $blog_details = get_blog_details( $dashboard_blog ); 83 if ( false === $blog_details ) { 84 if ( is_numeric( $dashboard_blog ) ) 85 wp_die( __( 'A dashboard site referenced by ID must already exist' ) ); 86 if ( is_subdomain_install() ) { 87 $domain = $dashboard_blog . '.' . $current_site->domain; 88 $path = $current_site->path; 89 } else { 90 $domain = $current_site->domain; 91 $path = trailingslashit( $current_site->path . $dashboard_blog ); 92 } 93 $wpdb->hide_errors(); 94 $dashboard_blog_id = wpmu_create_blog( $domain, $path, __( 'My Dashboard' ), $current_user->id , array( 'public' => 0 ), $current_site->id ); 95 $wpdb->show_errors(); 96 } else { 97 $dashboard_blog_id = $blog_details->blog_id; 98 } 99 } 100 if ( is_wp_error( $dashboard_blog_id ) ) 101 wp_die( __( 'Problem creating dashboard site: ' ) . $dashboard_blog_id->get_error_message() ); 102 if ( $_POST['dashboard_blog_orig'] != $_POST['dashboard_blog'] ) { 103 $users = get_users_of_blog( get_site_option( 'dashboard_blog' ) ); 104 $move_users = array(); 105 foreach ( (array)$users as $user ) { 106 $user_meta_value = unserialize( $user->meta_value ); 107 if ( is_array( $user_meta_value ) && array_pop( $var_by_ref = array_keys( $user_meta_value ) ) == 'subscriber' ) 108 $move_users[] = $user->user_id; 109 } 110 if ( false == empty( $move_users ) ) { 111 foreach ( (array)$move_users as $user_id ) { 112 remove_user_from_blog($user_id, get_site_option( 'dashboard_blog' ) ); 113 add_user_to_blog( $dashboard_blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 114 update_user_meta( $user_id, 'primary_blog', $dashboard_blog_id ); 115 } 116 } 117 } 118 update_site_option( 'dashboard_blog', $dashboard_blog_id ); 119 120 $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', 'admin_notice_feed', 'global_terms_enabled' ); 121 $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 ); 122 foreach ( $checked_options as $option_name => $option_unchecked_value ) { 123 if ( ! isset( $_POST[$option_name] ) ) 124 $_POST[$option_name] = $option_unchecked_value; 125 } 126 foreach ( $options as $option_name ) { 127 if ( ! isset($_POST[$option_name]) ) 128 continue; 129 $value = stripslashes_deep( $_POST[$option_name] ); 130 update_site_option( $option_name, $value ); 131 } 132 133 // Update more options here 134 do_action( 'update_wpmu_options' ); 135 136 wp_redirect( add_query_arg( 'updated', 'true', admin_url( 'ms-options.php' ) ) ); 137 exit(); 138 break; 139 case 'addblog': 140 check_admin_referer( 'add-blog', '_wpnonce_add-blog' ); 141 142 if ( ! current_user_can( 'manage_sites' ) ) 143 wp_die( __( 'You do not have permission to access this page.' ) ); 144 145 if ( is_array( $_POST['blog'] ) == false ) 146 wp_die( __( 'Can’t create an empty site.' ) ); 147 $blog = $_POST['blog']; 148 $domain = ''; 149 if ( ! preg_match( '/(--)/', $blog['domain'] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) 150 $domain = strtolower( $blog['domain'] ); 151 152 // If not a subdomain install, make sure the domain isn't a reserved word 153 if ( ! is_subdomain_install() ) { 154 $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ); 155 if ( in_array( $domain, $subdirectory_reserved_names ) ) 156 wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: <code>%s</code>' ), implode( '</code>, <code>', $subdirectory_reserved_names ) ) ); 157 } 158 159 $email = sanitize_email( $blog['email'] ); 160 $title = $blog['title']; 161 162 if ( empty( $domain ) ) 163 wp_die( __( 'Missing or invalid site address.' ) ); 164 if ( empty( $email ) ) 165 wp_die( __( 'Missing email address.' ) ); 166 if ( !is_email( $email ) ) 167 wp_die( __( 'Invalid email address.' ) ); 168 169 if ( is_subdomain_install() ) { 170 $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); 171 $path = $base; 172 } else { 173 $newdomain = $current_site->domain; 174 $path = $base . $domain . '/'; 175 } 176 177 $password = 'N/A'; 178 $user_id = email_exists($email); 179 if ( !$user_id ) { // Create a new user with a random password 180 $password = wp_generate_password(); 181 $user_id = wpmu_create_user( $domain, $password, $email ); 182 if ( false == $user_id ) 183 wp_die( __( 'There was an error creating the user.' ) ); 184 else 185 wp_new_user_notification( $user_id, $password ); 186 } 187 188 $wpdb->hide_errors(); 189 $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id ); 190 $wpdb->show_errors(); 191 if ( !is_wp_error( $id ) ) { 192 $dashboard_blog = get_dashboard_blog(); 193 if ( !is_super_admin( $user_id ) && get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id ) 194 update_user_option( $user_id, 'primary_blog', $id, true ); 195 $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) ); 196 wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' ); 197 wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) ); 198 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add-blog' ), wp_get_referer() ) ); 199 exit(); 200 } else { 201 wp_die( $id->get_error_message() ); 202 } 203 break; 204 205 case 'updateblog': 206 check_admin_referer( 'editblog' ); 207 if ( ! current_user_can( 'manage_sites' ) ) 208 wp_die( __( 'You do not have permission to access this page.' ) ); 209 210 if ( empty( $_POST ) ) 211 wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">sites page</a>', esc_url( admin_url( 'ms-sites.php' ) ) ) ) ); 212 213 switch_to_blog( $id ); 214 215 // themes 216 $allowedthemes = array(); 217 if ( isset($_POST['theme']) && is_array( $_POST['theme'] ) ) { 218 foreach ( $_POST['theme'] as $theme => $val ) { 219 if ( 'on' == $val ) 220 $allowedthemes[$theme] = true; 221 } 222 } 223 update_option( 'allowedthemes', $allowedthemes ); 224 225 // options 226 if ( is_array( $_POST['option'] ) ) { 227 $c = 1; 228 $count = count( $_POST['option'] ); 229 $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form. 230 foreach ( (array) $_POST['option'] as $key => $val ) { 231 if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) ) 232 continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options 233 if ( $c == $count ) 234 update_option( $key, stripslashes( $val ) ); 235 else 236 update_option( $key, stripslashes( $val ), false ); // no need to refresh blog details yet 237 $c++; 238 } 239 } 240 241 // home and siteurl 242 if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) { 243 $blog_address = get_blogaddress_by_domain( $_POST['blog']['domain'], $_POST['blog']['path'] ); 244 if ( get_option( 'siteurl' ) != $blog_address ) 245 update_option( 'siteurl', $blog_address ); 246 247 if ( get_option( 'home' ) != $blog_address ) 248 update_option( 'home', $blog_address ); 249 } 250 251 // rewrite rules can't be flushed during switch to blog 252 delete_option( 'rewrite_rules' ); 253 254 // update blogs table 255 $blog_data = stripslashes_deep( $_POST['blog'] ); 256 update_blog_details( $id, $blog_data ); 257 258 // get blog prefix 259 $blog_prefix = $wpdb->get_blog_prefix( $id ); 260 261 // user roles 262 if ( isset( $_POST['role'] ) && is_array( $_POST['role'] ) == true ) { 263 $newroles = $_POST['role']; 264 265 reset( $newroles ); 266 foreach ( (array) $newroles as $userid => $role ) { 267 $user = new WP_User( $userid ); 268 if ( empty( $user->ID ) ) 269 continue; 270 $user->for_blog( $id ); 271 $user->set_role( $role ); 272 } 273 } 274 275 // remove user 276 if ( isset( $_POST['blogusers'] ) && is_array( $_POST['blogusers'] ) ) { 277 reset( $_POST['blogusers'] ); 278 foreach ( (array) $_POST['blogusers'] as $key => $val ) 279 remove_user_from_blog( $key, $id ); 280 } 281 282 // change password 283 if ( isset( $_POST['user_password'] ) && is_array( $_POST['user_password'] ) ) { 284 reset( $_POST['user_password'] ); 285 $newroles = $_POST['role']; 286 foreach ( (array) $_POST['user_password'] as $userid => $pass ) { 287 unset( $_POST['role'] ); 288 $_POST['role'] = $newroles[ $userid ]; 289 if ( $pass != '' ) { 290 $cap = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) ); 291 $userdata = get_userdata($userid); 292 $_POST['pass1'] = $_POST['pass2'] = $pass; 293 $_POST['email'] = $userdata->user_email; 294 $_POST['rich_editing'] = $userdata->rich_editing; 295 edit_user( $userid ); 296 if ( $cap == null ) 297 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) ); 298 } 299 } 300 unset( $_POST['role'] ); 301 $_POST['role'] = $newroles; 302 } 303 304 // add user 305 if ( !empty( $_POST['newuser'] ) ) { 306 $newuser = $_POST['newuser']; 307 $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); 308 if ( $userid ) { 309 $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" ); 310 if ( $user == false ) 311 add_user_to_blog( $id, $userid, $_POST['new_role'] ); 312 } 313 } 314 do_action( 'wpmu_update_blog_options' ); 315 restore_current_blog(); 316 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'editblog', 'id' => $id ), wp_get_referer() ) ); 317 break; 318 319 case 'deleteblog': 320 check_admin_referer('deleteblog'); 321 if ( ! current_user_can( 'manage_sites' ) ) 322 wp_die( __( 'You do not have permission to access this page.' ) ); 323 324 if ( $id != '0' && $id != $current_site->blog_id ) 325 wpmu_delete_blog( $id, true ); 326 327 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) ); 328 exit(); 329 break; 330 331 case 'allblogs': 332 if ( isset( $_POST['doaction']) || isset($_POST['doaction2'] ) ) { 333 check_admin_referer( 'bulk-ms-sites', '_wpnonce_bulk-ms-sites' ); 334 335 if ( ! current_user_can( 'manage_sites' ) ) 336 wp_die( __( 'You do not have permission to access this page.' ) ); 337 338 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 ) 339 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; 340 341 342 foreach ( (array) $_POST['allblogs'] as $key => $val ) { 343 if ( $val != '0' && $val != $current_site->blog_id ) { 344 switch ( $doaction ) { 345 case 'delete': 346 $blogfunction = 'all_delete'; 347 wpmu_delete_blog( $val, true ); 348 break; 349 350 case 'spam': 351 $blogfunction = 'all_spam'; 352 update_blog_status( $val, 'spam', '1', 0 ); 353 set_time_limit( 60 ); 354 break; 355 356 case 'notspam': 357 $blogfunction = 'all_notspam'; 358 update_blog_status( $val, 'spam', '0', 0 ); 359 set_time_limit( 60 ); 360 break; 361 } 362 } else { 363 wp_die( __( 'You are not allowed to change the current site.' ) ); 364 } 365 } 366 367 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) ); 368 exit(); 369 } else { 370 wp_redirect( admin_url( 'ms-sites.php' ) ); 371 } 372 break; 373 374 case 'archiveblog': 375 check_admin_referer( 'archiveblog' ); 376 if ( ! current_user_can( 'manage_sites' ) ) 377 wp_die( __( 'You do not have permission to access this page.' ) ); 378 379 update_blog_status( $id, 'archived', '1' ); 380 do_action( 'archive_blog', $id ); 381 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) ); 382 exit(); 383 break; 384 385 case 'unarchiveblog': 386 check_admin_referer( 'unarchiveblog' ); 387 if ( ! current_user_can( 'manage_sites' ) ) 388 wp_die( __( 'You do not have permission to access this page.' ) ); 389 390 do_action( 'unarchive_blog', $id ); 391 update_blog_status( $id, 'archived', '0' ); 392 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) ); 393 exit(); 394 break; 395 396 case 'activateblog': 397 check_admin_referer( 'activateblog' ); 398 if ( ! current_user_can( 'manage_sites' ) ) 399 wp_die( __( 'You do not have permission to access this page.' ) ); 400 401 update_blog_status( $id, 'deleted', '0' ); 402 do_action( 'activate_blog', $id ); 403 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) ); 404 exit(); 405 break; 406 407 case 'deactivateblog': 408 check_admin_referer( 'deactivateblog' ); 409 if ( ! current_user_can( 'manage_sites' ) ) 410 wp_die( __( 'You do not have permission to access this page.' ) ); 411 412 do_action( 'deactivate_blog', $id ); 413 update_blog_status( $id, 'deleted', '1' ); 414 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) ); 415 exit(); 416 break; 417 418 case 'unspamblog': 419 check_admin_referer( 'unspamblog' ); 420 if ( ! current_user_can( 'manage_sites' ) ) 421 wp_die( __( 'You do not have permission to access this page.' ) ); 422 423 update_blog_status( $id, 'spam', '0' ); 424 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) ); 425 exit(); 426 break; 427 428 case 'spamblog': 429 check_admin_referer( 'spamblog' ); 430 if ( ! current_user_can( 'manage_sites' ) ) 431 wp_die( __( 'You do not have permission to access this page.' ) ); 432 433 update_blog_status( $id, 'spam', '1' ); 434 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) ); 435 exit(); 436 break; 437 438 // Themes 439 case 'updatethemes': 440 if ( ! current_user_can( 'manage_network_themes' ) ) 441 wp_die( __( 'You do not have permission to access this page.' ) ); 442 443 if ( is_array( $_POST['theme'] ) ) { 444 $themes = get_themes(); 445 reset( $themes ); 446 $allowed_themes = array(); 447 foreach ( (array) $themes as $key => $theme ) { 448 if ( $_POST['theme'][ esc_html( $theme['Stylesheet'] ) ] == 'enabled' ) 449 $allowed_themes[ esc_html( $theme['Stylesheet'] ) ] = true; 450 } 451 update_site_option( 'allowedthemes', $allowed_themes ); 452 } 453 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'themes' ), wp_get_referer() ) ); 454 exit(); 455 break; 456 457 // Common 458 case 'confirm': 459 if ( !headers_sent() ) { 460 nocache_headers(); 461 header( 'Content-Type: text/html; charset=utf-8' ); 462 } 463 if ( $current_site->blog_id == $id ) 464 wp_die( __( 'You are not allowed to change the current site.' ) ); 465 ?> 466 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 467 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>> 468 <head> 469 <title><?php _e( 'WordPress › Confirm your action' ); ?></title> 470 471 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 472 <?php 473 wp_admin_css( 'install', true ); 474 wp_admin_css( 'ie', true ); 475 ?> 476 </head> 477 <body> 478 <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1> 479 <form action="ms-edit.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post"> 480 <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" /> 481 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 482 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> 483 <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?> 484 <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p> 485 <p class="submit"><input class="button" type="submit" value="<?php _e( 'Confirm' ); ?>" /></p> 486 </form> 487 </body> 488 </html> 489 <?php 490 break; 491 492 // Users 493 case 'deleteuser': 494 if ( ! current_user_can( 'manage_network_users' ) ) 495 wp_die( __( 'You do not have permission to access this page.' ) ); 496 497 check_admin_referer( 'deleteuser' ); 498 499 if ( $id != '0' && $id != '1' ) { 500 $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays 501 $title = __( 'Users' ); 502 $parent_file = 'ms-admin.php'; 503 require_once( 'admin-header.php' ); 504 echo '<div class="wrap">'; 505 confirm_delete_users( $_POST['allusers'] ); 506 echo '</div>'; 507 require_once( 'admin-footer.php' ); 508 exit(); 509 } else { 510 wp_redirect( admin_url( 'ms-users.php' ) ); 511 } 512 break; 513 514 case 'allusers': 515 if ( ! current_user_can( 'manage_network_users' ) ) 516 wp_die( __( 'You do not have permission to access this page.' ) ); 517 518 if ( isset( $_POST['doaction']) || isset($_POST['doaction2'] ) ) { 519 check_admin_referer( 'bulk-ms-users', '_wpnonce_bulk-ms-users' ); 520 521 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 ) 522 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; 523 524 foreach ( (array) $_POST['allusers'] as $key => $val ) { 525 if ( !empty( $val ) ) { 526 switch ( $doaction ) { 527 case 'delete': 528 $title = __( 'Users' ); 529 $parent_file = 'ms-admin.php'; 530 require_once( 'admin-header.php' ); 531 echo '<div class="wrap">'; 532 confirm_delete_users( $_POST['allusers'] ); 533 echo '</div>'; 534 require_once( 'admin-footer.php' ); 535 exit(); 536 break; 537 538 case 'spam': 539 $user = new WP_User( $val ); 540 if ( in_array( $user->user_login, get_super_admins() ) ) 541 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); 542 543 $userfunction = 'all_spam'; 544 $blogs = get_blogs_of_user( $val, true ); 545 foreach ( (array) $blogs as $key => $details ) { 546 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! 547 update_blog_status( $details->userblog_id, 'spam', '1' ); 548 } 549 update_user_status( $val, 'spam', '1', 1 ); 550 break; 551 552 case 'notspam': 553 $userfunction = 'all_notspam'; 554 $blogs = get_blogs_of_user( $val, true ); 555 foreach ( (array) $blogs as $key => $details ) 556 update_blog_status( $details->userblog_id, 'spam', '0' ); 557 558 update_user_status( $val, 'spam', '0', 1 ); 559 break; 560 } 561 } 562 } 563 564 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) ); 565 exit(); 566 } else { 567 wp_redirect( admin_url( 'ms-users.php' ) ); 568 } 569 break; 570 571 case 'dodelete': 572 check_admin_referer( 'ms-users-delete' ); 573 if ( ! current_user_can( 'manage_network_users' ) ) 574 wp_die( __( 'You do not have permission to access this page.' ) ); 575 576 if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) { 577 foreach ( $_POST['blog'] as $id => $users ) { 578 foreach ( $users as $blogid => $user_id ) { 579 if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] ) 580 remove_user_from_blog( $id, $blogid, $user_id ); 581 else 582 remove_user_from_blog( $id, $blogid ); 583 } 584 } 585 } 586 $i = 0; 587 if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) 588 foreach( $_POST['user'] as $id ) { 589 wpmu_delete_user( $id ); 590 $i++; 591 } 592 593 if ( $i == 1 ) 594 $deletefunction = 'delete'; 595 else 596 $deletefunction = 'all_delete'; 597 598 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), admin_url( 'ms-users.php' ) ) ); 599 break; 600 601 case 'adduser': 602 check_admin_referer( 'add-user', '_wpnonce_add-user' ); 603 if ( ! current_user_can( 'manage_network_users' ) ) 604 wp_die( __( 'You do not have permission to access this page.' ) ); 605 606 if ( is_array( $_POST['user'] ) == false ) 607 wp_die( __( 'Cannot create an empty user.' ) ); 608 $user = $_POST['user']; 609 if ( empty($user['username']) && empty($user['email']) ) 610 wp_die( __( 'Missing username and email.' ) ); 611 elseif ( empty($user['username']) ) 612 wp_die( __( 'Missing username.' ) ); 613 elseif ( empty($user['email']) ) 614 wp_die( __( 'Missing email.' ) ); 615 616 $password = wp_generate_password(); 617 $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) ); 618 619 if ( false == $user_id ) 620 wp_die( __( 'Duplicated username or email address.' ) ); 621 else 622 wp_new_user_notification( $user_id, $password ); 623 624 if ( get_site_option( 'dashboard_blog' ) == false ) 625 add_user_to_blog( $current_site->blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 626 else 627 add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 628 629 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) ); 630 exit(); 631 break; 632 633 default: 634 wp_redirect( admin_url( 'ms-admin.php' ) ); 635 break; 636 } 637 ?> 12 wp_redirect( network_admin_url() ); 13 No newline at end of file -
wp-admin/includes/menu.php
1 <?php 2 3 /** 4 * Build Administration Menu. 5 * 6 * @package WordPress 7 * @subpackage Administration 8 */ 9 10 if ( is_network_admin() ) 11 do_action('_network_admin_menu'); 12 else 13 do_action('_admin_menu'); 14 15 // Create list of page plugin hook names. 16 foreach ($menu as $menu_page) { 17 if ( false !== $pos = strpos($menu_page[2], '?') ) { 18 // Handle post_type=post|page|foo pages. 19 $hook_name = substr($menu_page[2], 0, $pos); 20 $hook_args = substr($menu_page[2], $pos + 1); 21 wp_parse_str($hook_args, $hook_args); 22 // Set the hook name to be the post type. 23 if ( isset($hook_args['post_type']) ) 24 $hook_name = $hook_args['post_type']; 25 else 26 $hook_name = basename($hook_name, '.php'); 27 unset($hook_args); 28 } else { 29 $hook_name = basename($menu_page[2], '.php'); 30 } 31 $hook_name = sanitize_title($hook_name); 32 33 if ( isset($compat[$hook_name]) ) 34 $hook_name = $compat[$hook_name]; 35 elseif ( !$hook_name ) 36 continue; 37 38 $admin_page_hooks[$menu_page[2]] = $hook_name; 39 } 40 unset($menu_page, $compat); 41 42 $_wp_submenu_nopriv = array(); 43 $_wp_menu_nopriv = array(); 44 // Loop over submenus and remove pages for which the user does not have privs. 45 foreach ( array( 'submenu' ) as $sub_loop ) { 46 foreach ($$sub_loop as $parent => $sub) { 47 foreach ($sub as $index => $data) { 48 if ( ! current_user_can($data[1]) ) { 49 unset(${$sub_loop}[$parent][$index]); 50 $_wp_submenu_nopriv[$parent][$data[2]] = true; 51 } 52 } 53 unset($index, $data); 54 55 if ( empty(${$sub_loop}[$parent]) ) 56 unset(${$sub_loop}[$parent]); 57 } 58 unset($sub, $parent); 59 } 60 unset($sub_loop); 61 62 // Loop over the top-level menu. 63 // Menus for which the original parent is not accessible due to lack of privs will have the next 64 // submenu in line be assigned as the new menu parent. 65 foreach ( $menu as $id => $data ) { 66 if ( empty($submenu[$data[2]]) ) 67 continue; 68 $subs = $submenu[$data[2]]; 69 $first_sub = array_shift($subs); 70 $old_parent = $data[2]; 71 $new_parent = $first_sub[2]; 72 // If the first submenu is not the same as the assigned parent, 73 // make the first submenu the new parent. 74 if ( $new_parent != $old_parent ) { 75 $_wp_real_parent_file[$old_parent] = $new_parent; 76 $menu[$id][2] = $new_parent; 77 78 foreach ($submenu[$old_parent] as $index => $data) { 79 $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; 80 unset($submenu[$old_parent][$index]); 81 } 82 unset($submenu[$old_parent], $index); 83 84 if ( isset($_wp_submenu_nopriv[$old_parent]) ) 85 $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent]; 86 } 87 } 88 unset($id, $data, $subs, $first_sub, $old_parent, $new_parent); 89 90 if ( is_network_admin() ) 91 do_action('network_admin_menu', ''); 92 else 93 do_action('admin_menu', ''); 94 95 // Remove menus that have no accessible submenus and require privs that the user does not have. 96 // Run re-parent loop again. 97 foreach ( $menu as $id => $data ) { 98 if ( ! current_user_can($data[1]) ) 99 $_wp_menu_nopriv[$data[2]] = true; 100 101 // If submenu is empty... 102 if ( empty($submenu[$data[2]]) ) { 103 // And user doesn't have privs, remove menu. 104 if ( isset( $_wp_menu_nopriv[$data[2]] ) ) { 105 unset($menu[$id]); 106 } 107 } 108 } 109 unset($id, $data); 110 111 // Remove any duplicated seperators 112 $seperator_found = false; 113 foreach ( $menu as $id => $data ) { 114 if ( 0 == strcmp('wp-menu-separator', $data[4] ) ) { 115 if (false == $seperator_found) { 116 $seperator_found = true; 117 } else { 118 unset($menu[$id]); 119 $seperator_found = false; 120 } 121 } else { 122 $seperator_found = false; 123 } 124 } 125 unset($id, $data); 126 127 function add_cssclass($add, $class) { 128 $class = empty($class) ? $add : $class .= ' ' . $add; 129 return $class; 130 } 131 132 function add_menu_classes($menu) { 133 134 $first = $lastorder = false; 135 $i = 0; 136 $mc = count($menu); 137 foreach ( $menu as $order => $top ) { 138 $i++; 139 140 if ( 0 == $order ) { // dashboard is always shown/single 141 $menu[0][4] = add_cssclass('menu-top-first', $top[4]); 142 $lastorder = 0; 143 continue; 144 } 145 146 if ( 0 === strpos($top[2], 'separator') ) { // if separator 147 $first = true; 148 $c = $menu[$lastorder][4]; 149 $menu[$lastorder][4] = add_cssclass('menu-top-last', $c); 150 continue; 151 } 152 153 if ( $first ) { 154 $c = $menu[$order][4]; 155 $menu[$order][4] = add_cssclass('menu-top-first', $c); 156 $first = false; 157 } 158 159 if ( $mc == $i ) { // last item 160 $c = $menu[$order][4]; 161 $menu[$order][4] = add_cssclass('menu-top-last', $c); 162 } 163 164 $lastorder = $order; 165 } 166 167 return apply_filters( 'add_menu_classes', $menu ); 168 } 169 170 uksort($menu, "strnatcasecmp"); // make it all pretty 171 172 if ( apply_filters('custom_menu_order', false) ) { 173 $menu_order = array(); 174 foreach ( $menu as $menu_item ) { 175 $menu_order[] = $menu_item[2]; 176 } 177 unset($menu_item); 178 $default_menu_order = $menu_order; 179 $menu_order = apply_filters('menu_order', $menu_order); 180 $menu_order = array_flip($menu_order); 181 $default_menu_order = array_flip($default_menu_order); 182 183 function sort_menu($a, $b) { 184 global $menu_order, $default_menu_order; 185 $a = $a[2]; 186 $b = $b[2]; 187 if ( isset($menu_order[$a]) && !isset($menu_order[$b]) ) { 188 return -1; 189 } elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) { 190 return 1; 191 } elseif ( isset($menu_order[$a]) && isset($menu_order[$b]) ) { 192 if ( $menu_order[$a] == $menu_order[$b] ) 193 return 0; 194 return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1; 195 } else { 196 return ($default_menu_order[$a] <= $default_menu_order[$b]) ? -1 : 1; 197 } 198 } 199 200 usort($menu, 'sort_menu'); 201 unset($menu_order, $default_menu_order); 202 } 203 204 $menu = add_menu_classes($menu); 205 206 if ( !user_can_access_admin_page() ) { 207 do_action('admin_page_access_denied'); 208 wp_die( __('You do not have sufficient permissions to access this page.') ); 209 } 210 211 ?> 212 No newline at end of file -
wp-admin/admin.php
Property changes on: wp-admin/includes/menu.php ___________________________________________________________________ Added: svn:eol-style + native
14 14 if ( !defined('WP_ADMIN') ) 15 15 define('WP_ADMIN', TRUE); 16 16 17 if ( !defined('WP_NETWORK_ADMIN') ) 18 define('WP_NETWORK_ADMIN', FALSE); 19 17 20 if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') ) 18 21 define('WP_LOAD_IMPORTERS', true); 19 22 … … 90 93 else 91 94 $taxnow = ''; 92 95 93 require(ABSPATH . 'wp-admin/menu.php'); 96 if ( WP_NETWORK_ADMIN ) 97 require(ABSPATH . 'wp-admin/network/menu.php'); 98 else 99 require(ABSPATH . 'wp-admin/menu.php'); 94 100 95 101 if ( current_user_can( 'manage_options' ) ) 96 102 @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) ); -
wp-admin/ms-sites.php
9 9 10 10 require_once( './admin.php' ); 11 11 12 if ( ! is_multisite() ) 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 15 if ( ! current_user_can( 'manage_sites' ) ) 16 wp_die( __( 'You do not have permission to access this page.' ) ); 17 18 $title = __( 'Sites' ); 19 $parent_file = 'ms-admin.php'; 20 21 if ( isset( $_GET['action'] ) && 'editblog' == $_GET['action'] ) { 22 add_contextual_help($current_screen, 23 '<p>' . __('This extensive list of options has five modules: Site Info, Site Options, allowing Site Themes for this given site, changing user roles and passwords for that site, adding a new user, and Miscellaneous Site Actions (upload size limits).') . '</p>' . 24 '<p>' . __('Note that some fields in Site Options are grayed out and say Serialized Data. These are stored values in the database which you cannot change from here.') . '</p>' . 25 '<p><strong>' . __('For more information:') . '</strong></p>' . 26 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Sites_Edit_Site" target="_blank">Documentation on Editing Sites</a>') . '</p>' . 27 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 28 ); 29 } else { 30 add_contextual_help($current_screen, 31 '<p>' . __('Add New takes you farther down on this same page. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' . 32 '<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' . 33 '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' . 34 '<ul><li>' . __('an Edit link to a separate Edit Site screen.') . '</li>' . 35 '<li>' . __('Backend means the Dashboard for that site.') . '</li>' . 36 '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' . 37 '<li>' . __('Delete which is a permanent action after the confirmations screen.') . '</li>' . 38 '<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' . 39 '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' . 40 '<p>' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '</p>' . 41 '<p>' . __("Clicking on Add Site, after filling out the address, title, and admin's email address, adds the site instantly to the network and this table. You may want to then click on the action link to edit options for that site.") . '</p>' . 42 '<p>' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '</p>' . 43 '<p><strong>' . __('For more information:') . '</strong></p>' . 44 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Sites_SubPanel" target="_blank">Documentation on Sites</a>') . '</p>' . 45 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 46 ); 47 } 48 49 wp_enqueue_script( 'admin-forms' ); 50 51 require_once( './admin-header.php' ); 52 53 $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; 54 55 if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) { 56 ?> 57 <div id="message" class="updated"><p> 58 <?php 59 switch ( $_GET['action'] ) { 60 case 'all_notspam': 61 _e( 'Sites removed from spam.' ); 62 break; 63 case 'all_spam': 64 _e( 'Sites marked as spam.' ); 65 break; 66 case 'all_delete': 67 _e( 'Sites deleted.' ); 68 break; 69 case 'delete': 70 _e( 'Site deleted.' ); 71 break; 72 case 'add-blog': 73 _e( 'Site added.' ); 74 break; 75 case 'archive': 76 _e( 'Site archived.' ); 77 break; 78 case 'unarchive': 79 _e( 'Site unarchived.' ); 80 break; 81 case 'activate': 82 _e( 'Site activated.' ); 83 break; 84 case 'deactivate': 85 _e( 'Site deactivated.' ); 86 break; 87 case 'unspam': 88 _e( 'Site removed from spam.' ); 89 break; 90 case 'spam': 91 _e( 'Site marked as spam.' ); 92 break; 93 default: 94 _e( 'Settings saved.' ); 95 break; 96 } 97 ?> 98 </p></div> 99 <?php 100 } 101 102 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'list'; 103 104 switch ( $action ) { 105 // Edit site 106 case 'editblog': 107 $blog_prefix = $wpdb->get_blog_prefix( $id ); 108 $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" ); 109 $details = get_blog_details( $id ); 110 if ( $details->site_id != $wpdb->siteid ) 111 wp_die( __( 'You do not have permission to access this page.' ) ); 112 113 $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" ); 114 $is_main_site = is_main_site( $id ); 115 ?> 116 <div class="wrap"> 117 <?php screen_icon(); ?> 118 <h2><?php _e( 'Edit Site' ); ?> - <a href="<?php echo esc_url( get_home_url( $id ) ); ?>"><?php echo esc_url( get_home_url( $id ) ); ?></a></h2> 119 <form method="post" action="ms-edit.php?action=updateblog"> 120 <?php wp_nonce_field( 'editblog' ); ?> 121 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> 122 <div class="metabox-holder" style="width:49%;float:left;"> 123 <div id="blogedit_bloginfo" class="postbox"> 124 <h3 class="hndle"><span><?php _e( 'Site info (wp_blogs)' ); ?></span></h3> 125 <div class="inside"> 126 <table class="form-table"> 127 <tr class="form-field form-required"> 128 <th scope="row"><?php _e( 'Domain' ) ?></th> 129 <?php 130 $protocol = is_ssl() ? 'https://' : 'http://'; 131 if ( $is_main_site ) { ?> 132 <td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td> 133 <?php } else { ?> 134 <td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td> 135 <?php } ?> 136 </tr> 137 <tr class="form-field form-required"> 138 <th scope="row"><?php _e( 'Path' ) ?></th> 139 <?php if ( $is_main_site ) { ?> 140 <td><code><?php echo esc_attr( $details->path ) ?></code></td> 141 <?php } else { ?> 142 <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' /> 143 <br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_blog_option( $id, 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_blog_option( $id, 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td> 144 <?php } ?> 145 </tr> 146 <tr class="form-field"> 147 <th scope="row"><?php _ex( 'Registered', 'site' ) ?></th> 148 <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td> 149 </tr> 150 <tr class="form-field"> 151 <th scope="row"><?php _e('Last Updated') ?></th> 152 <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td> 153 </tr> 154 <?php 155 $radio_fields = array( 'public' => __( 'Public' ) ); 156 if ( ! $is_main_site ) { 157 $radio_fields['archived'] = __( 'Archived' ); 158 $radio_fields['spam'] = _x( 'Spam', 'site' ); 159 $radio_fields['deleted'] = __( 'Deleted' ); 160 } 161 $radio_fields['mature'] = __( 'Mature' ); 162 foreach ( $radio_fields as $field_key => $field_label ) { 163 ?> 164 <tr> 165 <th scope="row"><?php echo $field_label; ?></th> 166 <td> 167 <input type="radio" name="blog[<?php echo $field_key; ?>]" id="blog_<?php echo $field_key; ?>_1" value="1"<?php checked( $details->$field_key, 1 ); ?> /> 168 <label for="blog_<?php echo $field_key; ?>_1"><?php _e('Yes'); ?></label> 169 <input type="radio" name="blog[<?php echo $field_key; ?>]" id="blog_<?php echo $field_key; ?>_0" value="0"<?php checked( $details->$field_key, 0 ); ?> /> 170 <label for="blog_<?php echo $field_key; ?>_0"><?php _e('No'); ?></label> 171 </td> 172 </tr> 173 <?php } ?> 174 </table> 175 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 176 </div> 177 </div> 178 179 <div id="blogedit_blogoptions" class="postbox" > 180 <h3 class="hndle"><span><?php printf( __( 'Site options (%soptions)' ), $blog_prefix ); ?></span></h3> 181 <div class="inside"> 182 <table class="form-table"> 183 <?php 184 $editblog_default_role = 'subscriber'; 185 foreach ( $options as $option ) { 186 if ( $option->option_name == 'default_role' ) 187 $editblog_default_role = $option->option_value; 188 $disabled = false; 189 $class = 'all-options'; 190 if ( is_serialized( $option->option_value ) ) { 191 if ( is_serialized_string( $option->option_value ) ) { 192 $option->option_value = esc_html( maybe_unserialize( $option->option_value ), 'single' ); 193 } else { 194 $option->option_value = 'SERIALIZED DATA'; 195 $disabled = true; 196 $class = 'all-options disabled'; 197 } 198 } 199 if ( strpos( $option->option_value, "\n" ) !== false ) { 200 ?> 201 <tr class="form-field"> 202 <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th> 203 <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php echo wp_htmledit_pre( $option->option_value ) ?></textarea></td> 204 </tr> 205 <?php 206 } else { 207 ?> 208 <tr class="form-field"> 209 <th scope="row"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></th> 210 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?> 211 <td><code><?php echo esc_html( $option->option_value ) ?></code></td> 212 <?php } else { ?> 213 <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td> 214 <?php } ?> 215 </tr> 216 <?php 217 } 218 } // End foreach 219 ?> 220 </table> 221 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 222 </div> 223 </div> 224 </div> 225 226 <div class="metabox-holder" style="width:49%;float:right;"> 227 <?php 228 // Site Themes 229 $themes = get_themes(); 230 $blog_allowed_themes = wpmu_get_blog_allowedthemes( $id ); 231 $allowed_themes = get_site_option( 'allowedthemes' ); 232 233 if ( ! $allowed_themes ) 234 $allowed_themes = array_keys( $themes ); 235 236 $out = ''; 237 foreach ( $themes as $key => $theme ) { 238 $theme_key = esc_html( $theme['Stylesheet'] ); 239 if ( ! isset( $allowed_themes[$theme_key] ) ) { 240 $checked = isset( $blog_allowed_themes[ $theme_key ] ) ? 'checked="checked"' : ''; 241 $out .= '<tr class="form-field form-required"> 242 <th title="' . esc_attr( $theme["Description"] ).'" scope="row">' . esc_html( $key ) . '</th> 243 <td><label><input name="theme[' . esc_attr( $theme_key ) . ']" type="checkbox" style="width:20px;" value="on" '.$checked.'/> ' . __( 'Active' ) . '</label></td> 244 </tr>'; 245 } 246 } 247 248 if ( $out != '' ) { 249 ?> 250 <div id="blogedit_blogthemes" class="postbox"> 251 <h3 class="hndle"><span><?php esc_html_e( 'Site Themes' ); ?></span></h3> 252 <div class="inside"> 253 <p class="description"><?php _e( 'Activate the themename of an existing theme and hit "Update Options" to allow the theme for this site.' ) ?></p> 254 <table class="form-table"> 255 <?php echo $out; ?> 256 </table> 257 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 258 </div></div> 259 <?php } 260 261 // Site users 262 $blogusers = get_users_of_blog( $id ); 263 if ( is_array( $blogusers ) ) { 264 echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">'; 265 echo '<table class="form-table">'; 266 echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>"; 267 reset( $blogusers ); 268 foreach ( (array) $blogusers as $key => $val ) { 269 if ( isset( $val->meta_value ) && ! $val->meta_value ) 270 continue; 271 $t = @unserialize( $val->meta_value ); 272 if ( is_array( $t ) ) { 273 reset( $t ); 274 $existing_role = key( $t ); 275 } 276 echo '<tr><td><a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a></td>'; 277 if ( $val->user_id != $current_user->data->ID ) { 278 ?> 279 <td> 280 <select name="role[<?php echo $val->user_id ?>]" id="new_role_1"><?php 281 foreach ( $editblog_roles as $role => $role_assoc ){ 282 $name = translate_user_role( $role_assoc['name'] ); 283 echo '<option ' . selected( $role, $existing_role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>'; 284 } 285 ?> 286 </select> 287 </td> 288 <td> 289 <input type="text" name="user_password[<?php echo esc_attr( $val->user_id ) ?>]" /> 290 </td> 291 <?php 292 echo '<td><input title="' . __( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr( $val->user_id ) . ']" /></td>'; 293 } else { 294 echo "<td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __( 'N/A' ) . "</strong></td>"; 295 } 296 echo '</tr>'; 297 } 298 echo "</table>"; 299 echo '<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="' . esc_attr__( 'Update Options' ) . '" /></p>'; 300 echo "</div></div>"; 301 } 302 ?> 303 304 <div id="blogedit_blogadduser" class="postbox"> 305 <h3 class="hndle"><span><?php _e( 'Add a new user' ); ?></span></h3> 306 <div class="inside"> 307 <p class="description"><?php _e( 'Enter the username of an existing user and hit “Update Options” to add the user.' ) ?></p> 308 <table class="form-table"> 309 <tr> 310 <th scope="row"><?php _e( 'User Login:' ) ?></th> 311 <td><input type="text" name="newuser" id="newuser" /></td> 312 </tr> 313 <tr> 314 <th scope="row"><?php _e( 'Role:' ) ?></th> 315 <td> 316 <select name="new_role" id="new_role_0"> 317 <?php 318 reset( $editblog_roles ); 319 foreach ( $editblog_roles as $role => $role_assoc ){ 320 $name = translate_user_role( $role_assoc['name'] ); 321 $selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : ''; 322 echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>'; 323 } 324 ?> 325 </select> 326 </td> 327 </tr> 328 </table> 329 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 330 </div> 331 </div> 332 333 <div id="blogedit_miscoptions" class="postbox"> 334 <h3 class="hndle"><span><?php _e( 'Misc Site Actions' ) ?></span></h3> 335 <div class="inside"> 336 <table class="form-table"> 337 <?php do_action( 'wpmueditblogaction', $id ); ?> 338 </table> 339 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 340 </div> 341 </div> 342 </div> 343 344 <div style="clear:both;"></div> 345 </form> 346 </div> 347 <?php 348 break; 349 350 // List sites 351 case 'list': 352 default: 353 $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; 354 if ( empty($pagenum) ) 355 $pagenum = 1; 356 357 $per_page = (int) get_user_option( 'ms_sites_per_page' ); 358 if ( empty( $per_page ) || $per_page < 1 ) 359 $per_page = 15; 360 361 $per_page = apply_filters( 'ms_sites_per_page', $per_page ); 362 363 $s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : ''; 364 $like_s = esc_sql( like_escape( $s ) ); 365 366 $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; 367 368 if ( isset( $_GET['searchaction'] ) ) { 369 if ( 'name' == $_GET['searchaction'] ) { 370 $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) "; 371 } elseif ( 'id' == $_GET['searchaction'] ) { 372 $query .= " AND {$wpdb->blogs}.blog_id = '{$like_s}' "; 373 } elseif ( 'ip' == $_GET['searchaction'] ) { 374 $query = "SELECT * 375 FROM {$wpdb->blogs}, {$wpdb->registration_log} 376 WHERE site_id = '{$wpdb->siteid}' 377 AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id 378 AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')"; 379 } 380 } 381 382 $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id'; 383 if ( $order_by == 'registered' ) { 384 $query .= ' ORDER BY registered '; 385 } elseif ( $order_by == 'lastupdated' ) { 386 $query .= ' ORDER BY last_updated '; 387 } elseif ( $order_by == 'blogname' ) { 388 $query .= ' ORDER BY domain '; 389 } else { 390 $order_by = 'id'; 391 $query .= " ORDER BY {$wpdb->blogs}.blog_id "; 392 } 393 394 $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? "DESC" : "ASC"; 395 $query .= $order; 396 397 $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(blog_id)', $query ) ); 398 399 $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page ); 400 $blog_list = $wpdb->get_results( $query, ARRAY_A ); 401 402 $num_pages = ceil($total / $per_page); 403 $page_links = paginate_links( array( 404 'base' => add_query_arg( 'paged', '%#%' ), 405 'format' => '', 406 'prev_text' => __( '«' ), 407 'next_text' => __( '»' ), 408 'total' => $num_pages, 409 'current' => $pagenum 410 )); 411 412 if ( empty( $_GET['mode'] ) ) 413 $mode = 'list'; 414 else 415 $mode = esc_attr( $_GET['mode'] ); 416 ?> 417 418 <div class="wrap"> 419 <?php screen_icon(); ?> 420 <h2><?php _e('Sites') ?> 421 <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a> 422 <?php 423 if ( isset( $_GET['s'] ) && $_GET['s'] ) 424 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); 425 ?> 426 </h2> 427 428 <form action="ms-sites.php" method="get" id="ms-search"> 429 <p class="search-box"> 430 <input type="hidden" name="action" value="blogs" /> 431 <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" /> 432 <input type="submit" class="button" value="<?php esc_attr_e( 'Search Site by' ) ?>" /> 433 <select name="searchaction"> 434 <option value="name" selected="selected"><?php _e( 'Name' ); ?></option> 435 <option value="id"><?php _e( 'ID' ); ?></option> 436 <option value="ip"><?php _e( 'IP address' ); ?></option> 437 </select> 438 </p> 439 </form> 440 441 <form id="form-site-list" action="ms-edit.php?action=allblogs" method="post"> 442 <input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" /> 443 <div class="tablenav"> 444 <div class="alignleft actions"> 445 <select name="action"> 446 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 447 <option value="delete"><?php _e( 'Delete' ); ?></option> 448 <option value="spam"><?php _ex( 'Mark as Spam', 'site' ); ?></option> 449 <option value="notspam"><?php _ex( 'Not Spam', 'site' ); ?></option> 450 </select> 451 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" /> 452 <?php wp_nonce_field( 'bulk-ms-sites', '_wpnonce_bulk-ms-sites' ); ?> 453 </div> 454 455 <?php if ( $page_links ) { ?> 456 <div class="tablenav-pages"> 457 <?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 458 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), 459 number_format_i18n( min( $pagenum * $per_page, $total ) ), 460 number_format_i18n( $total ), 461 $page_links 462 ); echo $page_links_text; ?> 463 </div> 464 <?php } ?> 465 466 <div class="view-switch"> 467 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a> 468 <a href="<?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a> 469 </div> 470 471 </div> 472 473 <div class="clear"></div> 474 475 <?php 476 // define the columns to display, the syntax is 'internal name' => 'display name' 477 $blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' ); 478 $sites_columns = array( 479 'id' => __( 'ID' ), 480 'blogname' => $blogname_columns, 481 'lastupdated' => __( 'Last Updated'), 482 'registered' => _x( 'Registered', 'site' ), 483 'users' => __( 'Users' ) 484 ); 485 486 if ( has_filter( 'wpmublogsaction' ) ) 487 $sites_columns['plugins'] = __( 'Actions' ); 488 489 $sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns ); 490 ?> 491 492 <table class="widefat"> 493 <thead> 494 <tr> 495 <th class="manage-column column-cb check-column" id="cb" scope="col"> 496 <input type="checkbox" /> 497 </th> 498 <?php 499 $col_url = ''; 500 foreach($sites_columns as $column_id => $column_display_name) { 501 $column_link = "<a href='"; 502 $order2 = ''; 503 if ( $order_by == $column_id ) 504 $order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC'; 505 506 $column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array('action', 'updated'), $_SERVER['REQUEST_URI'] ) ) ); 507 $column_link .= "'>{$column_display_name}</a>"; 508 $col_url .= '<th scope="col">' . ( ( $column_id == 'users' || $column_id == 'plugins' ) ? $column_display_name : $column_link ) . '</th>'; 509 } 510 echo $col_url ?> 511 </tr> 512 </thead> 513 <tfoot> 514 <tr> 515 <th class="manage-column column-cb check-column" id="cb1" scope="col"> 516 <input type="checkbox" /> 517 </th> 518 <?php echo $col_url ?> 519 </tr> 520 </tfoot> 521 <tbody id="the-site-list" class="list:site"> 522 <?php 523 $status_list = array( 'archived' => array( 'site-archived', __( 'Archived' ) ), 'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ), 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), 'mature' => array( 'site-mature', __( 'Mature' ) ) ); 524 if ( $blog_list ) { 525 $class = ''; 526 foreach ( $blog_list as $blog ) { 527 $class = ( 'alternate' == $class ) ? '' : 'alternate'; 528 reset( $status_list ); 529 530 $blog_states = array(); 531 foreach ( $status_list as $status => $col ) { 532 if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) { 533 $class = $col[0]; 534 $blog_states[] = $col[1]; 535 } 536 } 537 $blog_state = ''; 538 if ( ! empty( $blog_states ) ) { 539 $state_count = count( $blog_states ); 540 $i = 0; 541 $blog_state .= ' - '; 542 foreach ( $blog_states as $state ) { 543 ++$i; 544 ( $i == $state_count ) ? $sep = '' : $sep = ', '; 545 $blog_state .= "<span class='post-state'>$state$sep</span>"; 546 } 547 } 548 echo "<tr class='$class'>"; 549 550 $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path']; 551 foreach ( $sites_columns as $column_name=>$column_display_name ) { 552 switch ( $column_name ) { 553 case 'id': ?> 554 <th scope="row" class="check-column"> 555 <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" /> 556 </th> 557 <th valign="top" scope="row"> 558 <?php echo $blog['blog_id'] ?> 559 </th> 560 <?php 561 break; 562 563 case 'blogname': ?> 564 <td class="column-title"> 565 <a href="<?php echo esc_url( admin_url( 'ms-sites.php?action=editblog&id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> 566 <?php 567 if ( 'list' != $mode ) 568 echo '<p>' . sprintf( _x( '%1$s – <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '</p>'; 569 570 // Preordered. 571 $actions = array( 572 'edit' => '', 'backend' => '', 573 'activate' => '', 'deactivate' => '', 574 'archive' => '', 'unarchive' => '', 575 'spam' => '', 'unspam' => '', 576 'delete' => '', 577 'visit' => '', 578 ); 579 580 $actions['edit'] = '<span class="edit"><a href="' . esc_url( admin_url( 'ms-sites.php?action=editblog&id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>'; 581 $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url($blog['blog_id']) ) . "' class='edit'>" . __( 'Backend' ) . '</a></span>'; 582 if ( $current_site->blog_id != $blog['blog_id'] ) { 583 if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' ) 584 $actions['activate'] = '<span class="activate"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ) ) . '">' . __( 'Activate' ) . '</a></span>'; 585 else 586 $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ) ) . '">' . __( 'Deactivate' ) . '</a></span>'; 587 588 if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' ) 589 $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ) ) . '">' . __( 'Unarchive' ) . '</a></span>'; 590 else 591 $actions['archive'] = '<span class="archive"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>'; 592 593 if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' ) 594 $actions['unspam'] = '<span class="spam"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>'; 595 else 596 $actions['spam'] = '<span class="spam"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>'; 597 598 $actions['delete'] = '<span class="delete"><a href="' . esc_url( admin_url( 'ms-edit.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ) ) . '">' . __( 'Delete' ) . '</a></span>'; 599 } 600 601 $actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'] ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>'; 602 $actions = array_filter( $actions ); 603 if ( count( $actions ) ) : ?> 604 <div class="row-actions"> 605 <?php echo implode( ' | ', $actions ); ?> 606 </div> 607 <?php endif; ?> 608 </td> 609 <?php 610 break; 611 612 case 'lastupdated': ?> 613 <td valign="top"> 614 <?php 615 if ( 'list' == $mode ) 616 $date = 'Y/m/d'; 617 else 618 $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 619 echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( __( $date ), $blog['last_updated'] ); ?> 620 </td> 621 <?php 622 break; 623 case 'registered': ?> 624 <td valign="top"> 625 <?php 626 if ( $blog['registered'] == '0000-00-00 00:00:00' ) 627 echo '—'; 628 else 629 echo mysql2date( __( $date ), $blog['registered'] ); 630 ?> 631 </td> 632 <?php 633 break; 634 case 'users': ?> 635 <td valign="top"> 636 <?php 637 $blogusers = get_users_of_blog( $blog['blog_id'] ); 638 if ( is_array( $blogusers ) ) { 639 $blogusers_warning = ''; 640 if ( count( $blogusers ) > 5 ) { 641 $blogusers = array_slice( $blogusers, 0, 5 ); 642 $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( get_admin_url( $blog['blog_id'], 'users.php' ) ) . '">' . __( 'More' ) . '</a>'; 643 } 644 foreach ( $blogusers as $key => $val ) { 645 echo '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $val->user_id ) ) . '">' . esc_html( $val->user_login ) . '</a> '; 646 if ( 'list' != $mode ) 647 echo '(' . $val->user_email . ')'; 648 echo '<br />'; 649 } 650 if ( $blogusers_warning != '' ) 651 echo '<strong>' . $blogusers_warning . '</strong><br />'; 652 } 653 ?> 654 </td> 655 <?php 656 break; 657 658 case 'plugins': ?> 659 <?php if ( has_filter( 'wpmublogsaction' ) ) { ?> 660 <td valign="top"> 661 <?php do_action( 'wpmublogsaction', $blog['blog_id'] ); ?> 662 </td> 663 <?php } ?> 664 <?php break; 665 666 default: ?> 667 <?php if ( has_filter( 'manage_blogs_custom_column' ) ) { ?> 668 <td valign="top"> 669 <?php do_action( 'manage_blogs_custom_column', $column_name, $blog['blog_id'] ); ?> 670 </td> 671 <?php } ?> 672 <?php break; 673 } 674 } 675 ?> 676 </tr> 677 <?php 678 } 679 } else { ?> 680 <tr> 681 <td colspan="<?php echo (int) count( $sites_columns ); ?>"><?php _e( 'No sites found.' ) ?></td> 682 </tr> 683 <?php 684 } // end if ($blogs) 685 ?> 686 687 </tbody> 688 </table> 689 <div class="tablenav"> 690 <?php 691 if ( $page_links ) 692 echo "<div class='tablenav-pages'>$page_links_text</div>"; 693 ?> 694 695 <div class="alignleft actions"> 696 <select name="action2"> 697 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 698 <option value="delete"><?php _e( 'Delete' ); ?></option> 699 <option value="spam"><?php _ex( 'Mark as Spam', 'site' ); ?></option> 700 <option value="notspam"><?php _ex( 'Not Spam', 'site' ); ?></option> 701 </select> 702 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 703 </div> 704 <br class="clear" /> 705 </div> 706 707 </form> 708 </div> 709 710 <div id="form-add-site" class="wrap"> 711 <h3><?php _e( 'Add Site' ) ?></h3> 712 <form method="post" action="ms-edit.php?action=addblog"> 713 <?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ) ?> 714 <table class="form-table"> 715 <tr class="form-field form-required"> 716 <th scope="row"><?php _e( 'Site Address' ) ?></th> 717 <td> 718 <?php if ( is_subdomain_install() ) { ?> 719 <input name="blog[domain]" type="text" class="regular-text" title="<?php _e( 'Domain' ) ?>"/>.<?php echo preg_replace( '|^www\.|', '', $current_site->domain );?> 720 <?php } else { 721 echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php _e( 'Domain' ) ?>"/> 722 <?php } 723 echo '<p>' . __( 'Only the characters a-z and 0-9 recommended.' ) . '</p>'; 724 ?> 725 </td> 726 </tr> 727 <tr class="form-field form-required"> 728 <th scope="row"><?php _e( 'Site Title' ) ?></th> 729 <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e( 'Title' ) ?>"/></td> 730 </tr> 731 <tr class="form-field form-required"> 732 <th scope="row"><?php _e( 'Admin Email' ) ?></th> 733 <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/></td> 734 </tr> 735 <tr class="form-field"> 736 <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td> 737 </tr> 738 </table> 739 <p class="submit"> 740 <input class="button" type="submit" name="go" value="<?php esc_attr_e( 'Add Site' ) ?>" /></p> 741 </form> 742 </div> 743 <?php 744 break; 745 } // end switch( $action ) 746 747 include( './admin-footer.php' ); ?> 12 wp_redirect( network_admin_url('sites.php') ); 13 No newline at end of file -
wp-admin/ms-upgrade-network.php
9 9 10 10 require_once('admin.php'); 11 11 12 if ( !is_multisite() ) 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 15 require_once( ABSPATH . WPINC . '/http.php' ); 16 17 $title = __( 'Update Network' ); 18 $parent_file = 'ms-admin.php'; 19 20 add_contextual_help($current_screen, 21 '<p>' . __('Only use this screen once you have updated to a new version of WordPress through Dashboard > Updates. Clicking the Update Network button will step through each site in the network, five at a time, and make sure any database upgrades are applied.') . '</p>' . 22 '<p>' . __('If a version update to core has not happened, clicking this button won’t affect anything.') . '</p>' . 23 '<p>' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '</p>' . 24 '<p><strong>' . __('For more information:') . '</strong></p>' . 25 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Update_SubPanel" target="_blank">Update Network Documentation</a>') . '</p>' . 26 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 27 ); 28 29 require_once('admin-header.php'); 30 31 if ( ! current_user_can( 'manage_network' ) ) 32 wp_die( __( 'You do not have permission to access this page.' ) ); 33 34 echo '<div class="wrap">'; 35 screen_icon(); 36 echo '<h2>' . __( 'Update Network' ) . '</h2>'; 37 38 $action = isset($_GET['action']) ? $_GET['action'] : 'show'; 39 40 switch ( $action ) { 41 case "upgrade": 42 $n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0; 43 44 if ( $n < 5 ) { 45 global $wp_db_version; 46 update_site_option( 'wpmu_upgrade_site', $wp_db_version ); 47 } 48 49 $blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A ); 50 if ( empty( $blogs ) ) { 51 echo '<p>' . __( 'All done!' ) . '</p>'; 52 break; 53 } 54 echo "<ul>"; 55 foreach ( (array) $blogs as $details ) { 56 $siteurl = get_blog_option( $details['blog_id'], 'siteurl' ); 57 echo "<li>$siteurl</li>"; 58 $response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=upgrade_db", array( 'timeout' => 120, 'httpversion' => '1.1' ) ); 59 if ( is_wp_error( $response ) ) 60 wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>' ), $siteurl, $response->get_error_message() ) ); 61 do_action( 'after_mu_upgrade', $response ); 62 do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] ); 63 } 64 echo "</ul>"; 65 ?><p><?php _e( 'If your browser doesn’t start loading the next page automatically, click this link:' ); ?> <a class="button" href="ms-upgrade-network.php?action=upgrade&n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p> 66 <script type='text/javascript'> 67 <!-- 68 function nextpage() { 69 location.href = "ms-upgrade-network.php?action=upgrade&n=<?php echo ($n + 5) ?>"; 70 } 71 setTimeout( "nextpage()", 250 ); 72 //--> 73 </script><?php 74 break; 75 case 'show': 76 default: 77 ?><p><?php _e( 'You can update all the sites on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update.' ); ?></p> 78 <p><a class="button" href="ms-upgrade-network.php?action=upgrade"><?php _e("Update Network"); ?></a></p><?php 79 do_action( 'wpmu_upgrade_page' ); 80 break; 81 } 82 ?> 83 </div> 84 85 <?php include('./admin-footer.php'); ?> 12 wp_redirect( network_admin_url('upgrade.php') ); 13 No newline at end of file -
wp-admin/network/settings.php
1 <?php 2 /** 3 * Multisite network settings administration panel. 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 * @since 3.0.0 8 */ 9 10 require_once( './admin.php' ); 11 12 if ( ! is_multisite() ) 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 15 if ( ! current_user_can( 'manage_network_options' ) ) 16 wp_die( __( 'You do not have permission to access this page.' ) ); 17 18 $title = __( 'Network Options' ); 19 $parent_file = 'settings.php'; 20 21 add_contextual_help($current_screen, 22 '<p>' . __('This screen sets and changes options for the network as a whole. The first site is the main site in the network and network options are pulled from that original site’s options.') . '</p>' . 23 '<p>' . __('Operational settings has fields for the network’s name and admin email.') . '</p>' . 24 '<p>' . __('Dashboard Site is an option to give a site to users who do not have a site on the system. Their default role is Subscriber, but that default can be changed. The Admin Notice Feed can provide a notice on all dashboards of the latest post via RSS or Atom, or provide no such notice if left blank.') . '</p>' . 25 '<p>' . __('Registration settings can disable/enable public signups. If you let others sign up for a site, install spam plugins. Spaces, not commas, should separate names banned as sites for this network.') . '</p>' . 26 '<p>' . __('New site settings are defaults applied when a new site is created in the network. These include welcome email for when a new site or user account is registered, and what᾿s put in the first post, page, comment, comment author, and comment URL.') . '</p>' . 27 '<p>' . __('Upload settings control the size of the uploaded files and the amount of available upload space for each site. You can change the default value for specific sites when you edit a particular site. Allowed file types are also listed (space separated only).') . '</p>' . 28 '<p>' . __('Checkboxes for media upload buttons set which are shown in the visual editor. If unchecked, a generic upload button is still visible; other media types can still be uploaded if on the allowed file types list.') . '</p>' . 29 '<p>' . __('Menu setting enables/disables the plugin menus from appearing for non super admins, so that only super admins, not site admins, have access to activate plugins.') . '</p>' . 30 '<p>' . __('Super admins can no longer be added on the Options screen. You must now go to the list of existing users on Super Admin > Users and click on Username or the Edit action link below that name. This goes to an Edit User page where you can check a box to grant super admin privileges.') . '</p>' . 31 '<p><strong>' . __('For more information:') . '</strong></p>' . 32 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Options_SubPanel" target="_blank">Network Options Documentation</a>') . '</p>' . 33 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 34 ); 35 36 include( '../admin-header.php' ); 37 38 if (isset($_GET['updated'])) { 39 ?> 40 <div id="message" class="updated"><p><?php _e( 'Options saved.' ) ?></p></div> 41 <?php 42 } 43 ?> 44 45 <div class="wrap"> 46 <?php screen_icon(); ?> 47 <h2><?php _e( 'Network Options' ) ?></h2> 48 <form method="post" action="edit.php?action=siteoptions"> 49 <?php wp_nonce_field( 'siteoptions' ); ?> 50 <h3><?php _e( 'Operational Settings' ); ?></h3> 51 <table class="form-table"> 52 <tr valign="top"> 53 <th scope="row"><label for="site_name"><?php _e( 'Network Name' ) ?></label></th> 54 <td> 55 <input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr( $current_site->site_name ) ?>" /> 56 <br /> 57 <?php _e( 'What you would like to call this website.' ) ?> 58 </td> 59 </tr> 60 61 <tr valign="top"> 62 <th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ) ?></label></th> 63 <td> 64 <input name="admin_email" type="text" id="admin_email" class="regular-text" value="<?php echo esc_attr( get_site_option('admin_email') ) ?>" /> 65 <br /> 66 <?php printf( __( 'Registration and support emails will come from this address. An address such as <code>support@%s</code> is recommended.' ), $current_site->domain ); ?> 67 </td> 68 </tr> 69 </table> 70 <h3><?php _e( 'Dashboard Settings' ); ?></h3> 71 <table class="form-table"> 72 <tr valign="top"> 73 <th scope="row"><label for="dashboard_blog"><?php _e( 'Dashboard Site' ) ?></label></th> 74 <td> 75 <?php 76 if ( $dashboard_blog = get_site_option( 'dashboard_blog' ) ) { 77 $details = get_blog_details( $dashboard_blog ); 78 $blogname = untrailingslashit( sanitize_user( str_replace( '.', '', str_replace( $current_site->domain . $current_site->path, '', $details->domain . $details->path ) ) ) ); 79 } else { 80 $blogname = ''; 81 }?> 82 <input name="dashboard_blog_orig" type="hidden" id="dashboard_blog_orig" value="<?php echo esc_attr( $blogname ); ?>" /> 83 <input name="dashboard_blog" type="text" id="dashboard_blog" value="<?php echo esc_attr( $blogname ); ?>" class="regular-text" /> 84 <br /> 85 <?php _e( 'Site path (“dashboard”, “control”, “manager”, etc.) or blog ID.<br />New users are added to this site as the user role defined below if they don’t have a site. Leave blank for the main site. Users with the Subscriber role on the old site will be moved to the new site if changed. The new site will be created if it does not exist.' ); ?> 86 </td> 87 </tr> 88 <tr valign="top"> 89 <th scope="row"><label for="default_user_role"><?php _e( 'Dashboard User Default Role' ) ?></label></th> 90 <td> 91 <select name="default_user_role" id="default_user_role"><?php 92 wp_dropdown_roles( get_site_option( 'default_user_role', 'subscriber' ) ); 93 ?> 94 </select> 95 <br /> 96 <?php _e( 'The default role for new users on the Dashboard site. “Subscriber” or “Contributor” roles are recommended.' ); ?> 97 </td> 98 </tr> 99 <tr valign="top"> 100 <th scope="row"><label for="admin_notice_feed"><?php _e( 'Admin Notice Feed' ) ?></label></th> 101 <td><input name="admin_notice_feed" class="large-text" type="text" id="admin_notice_feed" value="<?php echo esc_attr( get_site_option( 'admin_notice_feed' ) ) ?>" size="80" /><br /> 102 <?php _e( 'Display the latest post from this RSS or Atom feed on all site dashboards. Leave blank to disable.' ); ?><br /> 103 104 <?php if ( get_site_option( 'admin_notice_feed' ) != get_home_url( $current_site->id, 'feed/' ) ) 105 echo __( 'A good one to use would be the feed from your main site: ' ) . esc_url( get_home_url( $current_site->id, 'feed/' ) ) ?></td> 106 </tr> 107 </table> 108 <h3><?php _e( 'Registration Settings' ); ?></h3> 109 <table class="form-table"> 110 <tr valign="top"> 111 <th scope="row"><?php _e( 'Allow new registrations' ) ?></th> 112 <?php 113 if ( !get_site_option( 'registration' ) ) 114 update_site_option( 'registration', 'none' ); 115 $reg = get_site_option( 'registration' ); 116 ?> 117 <td> 118 <label><input name="registration" type="radio" id="registration1" value="none"<?php checked( $reg, 'none') ?> /> <?php _e( 'Registration is disabled.' ); ?></label><br /> 119 <label><input name="registration" type="radio" id="registration2" value="user"<?php checked( $reg, 'user') ?> /> <?php _e( 'User accounts may be registered.' ); ?></label><br /> 120 <label><input name="registration" type="radio" id="registration3" value="blog"<?php checked( $reg, 'blog') ?> /> <?php _e( 'Logged in users may register new sites.' ); ?></label><br /> 121 <label><input name="registration" type="radio" id="registration4" value="all"<?php checked( $reg, 'all') ?> /> <?php _e( 'Both sites and user accounts can be registered.' ); ?></label><br /> 122 <p><?php _e( 'Disable or enable registration and who or what can be registered. (Default is disabled.)' ); ?></p> 123 <?php if ( is_subdomain_install() ) { 124 echo '<p>' . __( 'If registration is disabled, please set <code>NOBLOGREDIRECT</code> in <code>wp-config.php</code> to a URL you will redirect visitors to if they visit a non-existent site.' ) . '</p>'; 125 } ?> 126 </td> 127 </tr> 128 129 <tr valign="top"> 130 <th scope="row"><?php _e( 'Registration notification' ) ?></th> 131 <?php 132 if ( !get_site_option( 'registrationnotification' ) ) 133 update_site_option( 'registrationnotification', 'yes' ); 134 ?> 135 <td> 136 <label><input name="registrationnotification" type="checkbox" id="registrationnotification" value="yes"<?php checked( get_site_option( 'registrationnotification' ), 'yes' ) ?> /> <?php _e( 'Send the network admin an email notification every time someone registers a site or user account.' ) ?></label> 137 </td> 138 </tr> 139 140 <tr valign="top" id="addnewusers"> 141 <th scope="row"><?php _e( 'Add New Users' ) ?></th> 142 <td> 143 <label><input name="add_new_users" type="checkbox" id="add_new_users" value="1"<?php checked( get_site_option( 'add_new_users' ) ) ?> /> <?php _e( 'Allow site administrators to add new users to their site via the "Users->Add New" page.' ); ?></label> 144 </td> 145 </tr> 146 147 <tr valign="top"> 148 <th scope="row"><label for="illegal_names"><?php _e( 'Banned Names' ) ?></label></th> 149 <td> 150 <input name="illegal_names" type="text" id="illegal_names" class="large-text" value="<?php echo esc_attr( implode( " ", get_site_option( 'illegal_names' ) ) ); ?>" size="45" /> 151 <br /> 152 <?php _e( 'Users are not allowed to register these sites. Separate names by spaces.' ) ?> 153 </td> 154 </tr> 155 156 <tr valign="top"> 157 <th scope="row"><label for="limited_email_domains"><?php _e( 'Limited Email Registrations' ) ?></label></th> 158 <td> 159 <?php $limited_email_domains = get_site_option( 'limited_email_domains' ); 160 $limited_email_domains = str_replace( ' ', "\n", $limited_email_domains ); ?> 161 <textarea name="limited_email_domains" id="limited_email_domains" cols="45" rows="5"> 162 <?php echo wp_htmledit_pre( $limited_email_domains == '' ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea> 163 <br /> 164 <?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ) ?> 165 </td> 166 </tr> 167 168 <tr valign="top"> 169 <th scope="row"><label for="banned_email_domains"><?php _e('Banned Email Domains') ?></label></th> 170 <td> 171 <textarea name="banned_email_domains" id="banned_email_domains" cols="45" rows="5"> 172 <?php echo wp_htmledit_pre( get_site_option( 'banned_email_domains' ) == '' ? '' : implode( "\n", (array) get_site_option( 'banned_email_domains' ) ) ); ?></textarea> 173 <br /> 174 <?php _e( 'If you want to ban domains from site registrations. One domain per line.' ) ?> 175 </td> 176 </tr> 177 178 </table> 179 <h3><?php _e('New Site Settings'); ?></h3> 180 <table class="form-table"> 181 182 <tr valign="top"> 183 <th scope="row"><label for="welcome_email"><?php _e( 'Welcome Email' ) ?></label></th> 184 <td> 185 <textarea name="welcome_email" id="welcome_email" rows="5" cols="45" class="large-text"> 186 <?php echo wp_htmledit_pre( stripslashes( get_site_option( 'welcome_email' ) ) ) ?></textarea> 187 <br /> 188 <?php _e( 'The welcome email sent to new site owners.' ) ?> 189 </td> 190 </tr> 191 <tr valign="top"> 192 <th scope="row"><label for="welcome_user_email"><?php _e( 'Welcome User Email' ) ?></label></th> 193 <td> 194 <textarea name="welcome_user_email" id="welcome_user_email" rows="5" cols="45" class="large-text"> 195 <?php echo wp_htmledit_pre( stripslashes( get_site_option( 'welcome_user_email' ) ) ) ?></textarea> 196 <br /> 197 <?php _e( 'The welcome email sent to new users.' ) ?> 198 </td> 199 </tr> 200 <tr valign="top"> 201 <th scope="row"><label for="first_post"><?php _e( 'First Post' ) ?></label></th> 202 <td> 203 <textarea name="first_post" id="first_post" rows="5" cols="45" class="large-text"> 204 <?php echo wp_htmledit_pre( stripslashes( get_site_option( 'first_post' ) ) ) ?></textarea> 205 <br /> 206 <?php _e( 'The first post on a new site.' ) ?> 207 </td> 208 </tr> 209 <tr valign="top"> 210 <th scope="row"><label for="first_page"><?php _e( 'First Page' ) ?></label></th> 211 <td> 212 <textarea name="first_page" id="first_page" rows="5" cols="45" class="large-text"> 213 <?php echo wp_htmledit_pre( stripslashes( get_site_option('first_page') ) ) ?></textarea> 214 <br /> 215 <?php _e( 'The first page on a new site.' ) ?> 216 </td> 217 </tr> 218 <tr valign="top"> 219 <th scope="row"><label for="first_comment"><?php _e( 'First Comment' ) ?></label></th> 220 <td> 221 <textarea name="first_comment" id="first_comment" rows="5" cols="45" class="large-text"> 222 <?php echo wp_htmledit_pre( stripslashes( get_site_option('first_comment') ) ) ?></textarea> 223 <br /> 224 <?php _e( 'The first comment on a new site.' ) ?> 225 </td> 226 </tr> 227 <tr valign="top"> 228 <th scope="row"><label for="first_comment_author"><?php _e( 'First Comment Author' ) ?></label></th> 229 <td> 230 <input type="text" size="40" name="first_comment_author" id="first_comment_author" value="<?php echo get_site_option('first_comment_author') ?>" /> 231 <br /> 232 <?php _e( 'The author of the first comment on a new site.' ) ?> 233 </td> 234 </tr> 235 <tr valign="top"> 236 <th scope="row"><label for="first_comment_url"><?php _e( 'First Comment URL' ) ?></label></th> 237 <td> 238 <input type="text" size="40" name="first_comment_url" id="first_comment_url" value="<?php echo esc_attr( get_site_option( 'first_comment_url' ) ) ?>" /> 239 <br /> 240 <?php _e( 'The URL for the first comment on a new site.' ) ?> 241 </td> 242 </tr> 243 </table> 244 <h3><?php _e( 'Upload Settings' ); ?></h3> 245 <table class="form-table"> 246 <tr valign="top"> 247 <th scope="row"><?php _e( 'Media upload buttons' ) ?></th> 248 <?php $mu_media_buttons = get_site_option( 'mu_media_buttons', array() ); ?> 249 <td><label><input type="checkbox" id="mu_media_buttons_image" name="mu_media_buttons[image]" value="1"<?php checked( ! empty( $mu_media_buttons['image'] ) ) ?>/> <?php _e( 'Images' ); ?></label><br /> 250 <label><input type="checkbox" id="mu_media_buttons_video" name="mu_media_buttons[video]" value="1"<?php checked( ! empty( $mu_media_buttons['video'] ) ) ?>/> <?php _e( 'Videos' ); ?></label><br /> 251 <label><input type="checkbox" id="mu_media_buttons_audio" name="mu_media_buttons[audio]" value="1"<?php checked( ! empty( $mu_media_buttons['audio'] ) ) ?>/> <?php _e( 'Music' ); ?></label><br /> 252 <?php _e( 'The media upload buttons to display on the “Write Post” page. Make sure you update the allowed upload file types below as well.' ); ?></td> 253 </tr> 254 255 <tr valign="top"> 256 <th scope="row"><?php _e( 'Site upload space' ) ?></th> 257 <td> 258 <label><input type="checkbox" id="upload_space_check_disabled" name="upload_space_check_disabled" value="0"<?php checked( get_site_option( 'upload_space_check_disabled' ), 0 ) ?>/> <?php printf( __( 'Limit total size of files uploaded to %s MB' ), '</label><label><input name="blog_upload_space" type="text" id="blog_upload_space" value="' . esc_attr( get_site_option('blog_upload_space', 10) ) . '" size="3" />' ); ?></label><br /> 259 </td> 260 </tr> 261 262 <tr valign="top"> 263 <th scope="row"><label for="upload_filetypes"><?php _e( 'Upload file types' ) ?></label></th> 264 <td><input name="upload_filetypes" type="text" id="upload_filetypes" class="large-text" value="<?php echo esc_attr( get_site_option('upload_filetypes', 'jpg jpeg png gif') ) ?>" size="45" /></td> 265 </tr> 266 267 <tr valign="top"> 268 <th scope="row"><label for="fileupload_maxk"><?php _e( 'Max upload file size' ) ?></label></th> 269 <td><?php printf( _x( '%s KB', 'File size in kilobytes' ), '<input name="fileupload_maxk" type="text" id="fileupload_maxk" value="' . esc_attr( get_site_option( 'fileupload_maxk', 300 ) ) . '" size="5" />' ); ?></td> 270 </tr> 271 </table> 272 273 <?php 274 $languages = get_available_languages(); 275 if ( ! empty( $languages ) ) { 276 $lang = get_site_option( 'WPLANG' ); 277 ?> 278 <h3><?php _e( 'Network Wide Settings' ); ?></h3> 279 <div class="updated inline"><p><strong><?php _e( 'Notice:' ); ?></strong> <?php _e( 'These settings may be overridden by site owners.' ); ?></p></div> 280 <table class="form-table"> 281 <?php 282 ?> 283 <tr valign="top"> 284 <th><label for="WPLANG"><?php _e( 'Default Language' ) ?></label></th> 285 <td> 286 <select name="WPLANG" id="WPLANG"> 287 <?php mu_dropdown_languages( $languages, get_site_option( 'WPLANG' ) ); ?> 288 </select> 289 </td> 290 </tr> 291 </table> 292 <?php 293 } // languages 294 ?> 295 296 <h3><?php _e( 'Menu Settings' ); ?></h3> 297 <table id="menu" class="form-table"> 298 <tr valign="top"> 299 <th scope="row"><?php _e( 'Enable administration menus' ); ?></th> 300 <td> 301 <?php 302 $menu_perms = get_site_option( 'menu_items' ); 303 $menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) ); 304 foreach ( (array) $menu_items as $key => $val ) { 305 echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" . ( isset( $menu_perms[$key] ) ? checked( $menu_perms[$key], '1', false ) : '' ) . " /> " . esc_html( $val ) . "</label><br/>"; 306 } 307 ?> 308 </td> 309 </tr> 310 </table> 311 312 <?php do_action( 'wpmu_options' ); // Add more options here ?> 313 314 <p class="submit"><input type="submit" class="button-primary" name="Submit" value="<?php esc_attr_e( 'Save Changes' ) ?>" /></p> 315 </form> 316 </div> 317 318 <?php include( '../admin-footer.php' ); ?> -
wp-admin/network/users.php
Property changes on: wp-admin/network/settings.php ___________________________________________________________________ Added: svn:eol-style + native
1 <?php 2 /** 3 * Multisite users administration panel. 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 * @since 3.0.0 8 */ 9 10 require_once( './admin.php' ); 11 12 if ( !is_multisite() ) 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 15 if ( ! current_user_can( 'manage_network_users' ) ) 16 wp_die( __( 'You do not have permission to access this page.' ) ); 17 18 $title = __( 'Users' ); 19 $parent_file = 'users.php'; 20 21 add_contextual_help($current_screen, 22 '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' . 23 '<p>' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '</p>' . 24 '<p>' . __('You can also go to the user’s profile page by clicking on the individual username.') . '</p>' . 25 '<p>' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '</p>' . 26 '<p>' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '</p>' . 27 '<p>' . __('Add User will add that person to this table and send them an email.') . '</p>' . 28 '<p>' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '</p>' . 29 '<p>' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '</p>' . 30 '<p><strong>' . __('For more information:') . '</strong></p>' . 31 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Users_SubPanel" target="_blank">Network Users Documentation</a>') . '</p>' . 32 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 33 ); 34 35 wp_enqueue_script( 'admin-forms' ); 36 37 require_once( '../admin-header.php' ); 38 39 if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) { 40 ?> 41 <div id="message" class="updated"><p> 42 <?php 43 switch ( $_GET['action'] ) { 44 case 'delete': 45 _e( 'User deleted.' ); 46 break; 47 case 'all_spam': 48 _e( 'Users marked as spam.' ); 49 break; 50 case 'all_notspam': 51 _e( 'Users removed from spam.' ); 52 break; 53 case 'all_delete': 54 _e( 'Users deleted.' ); 55 break; 56 case 'add': 57 _e( 'User added.' ); 58 break; 59 } 60 ?> 61 </p></div> 62 <?php 63 } 64 65 $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; 66 if ( empty( $pagenum ) ) 67 $pagenum = 1; 68 69 $per_page = (int) get_user_option( 'ms_users_per_page' ); 70 if ( empty( $per_page ) || $per_page < 1 ) 71 $per_page = 15; 72 73 $per_page = apply_filters( 'ms_users_per_page', $per_page ); 74 75 $s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : ''; 76 $like_s = esc_sql( like_escape( $s ) ); 77 78 $query = "SELECT * FROM {$wpdb->users}"; 79 80 if ( !empty( $like_s ) ) { 81 $query .= " WHERE user_login LIKE '%$like_s%' OR user_email LIKE '%$like_s%'"; 82 } 83 84 $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id'; 85 if ( $order_by == 'email' ) { 86 $query .= ' ORDER BY user_email '; 87 } elseif ( $order_by == 'login' ) { 88 $query .= ' ORDER BY user_login '; 89 } elseif ( $order_by == 'name' ) { 90 $query .= ' ORDER BY display_name '; 91 } elseif ( $order_by == 'registered' ) { 92 $query .= ' ORDER BY user_registered '; 93 } else { 94 $order_by = 'id'; 95 $query .= ' ORDER BY ID '; 96 } 97 98 $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? 'DESC' : 'ASC'; 99 $query .= $order; 100 101 $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(ID)', $query ) ); 102 103 $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page ); 104 105 $user_list = $wpdb->get_results( $query, ARRAY_A ); 106 107 $num_pages = ceil( $total / $per_page ); 108 $page_links = paginate_links( array( 109 'base' => add_query_arg( 'paged', '%#%' ), 110 'format' => '', 111 'prev_text' => __( '«' ), 112 'next_text' => __( '»' ), 113 'total' => $num_pages, 114 'current' => $pagenum 115 )); 116 117 if ( empty( $_GET['mode'] ) ) 118 $mode = 'list'; 119 else 120 $mode = esc_attr( $_GET['mode'] ); 121 122 ?> 123 <div class="wrap"> 124 <?php screen_icon(); ?> 125 <h2><?php esc_html_e( 'Users' ); ?> 126 <a href="#form-add-user" class="button add-new-h2"><?php echo esc_html_x( 'Add New' , 'users'); ?></a> 127 <?php 128 if ( isset( $_GET['s'] ) && $_GET['s'] ) 129 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); 130 ?> 131 </h2> 132 133 <form action="users.php" method="get" class="search-form"> 134 <p class="search-box"> 135 <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" class="search-input" id="user-search-input" /> 136 <input type="submit" id="post-query-submit" value="<?php esc_attr_e( 'Search Users' ) ?>" class="button" /> 137 </p> 138 </form> 139 140 <form id="form-user-list" action='edit.php?action=allusers' method='post'> 141 <input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" /> 142 <div class="tablenav"> 143 <div class="alignleft actions"> 144 <select name="action"> 145 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 146 <option value="delete"><?php _e( 'Delete' ); ?></option> 147 <option value="spam"><?php _ex( 'Mark as Spam', 'user' ); ?></option> 148 <option value="notspam"><?php _ex( 'Not Spam', 'user' ); ?></option> 149 </select> 150 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" /> 151 <?php wp_nonce_field( 'bulk-ms-users', '_wpnonce_bulk-ms-users' ); ?> 152 </div> 153 154 <?php if ( $page_links ) { ?> 155 <div class="tablenav-pages"> 156 <?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 157 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), 158 number_format_i18n( min( $pagenum * $per_page, $total ) ), 159 number_format_i18n( $total ), 160 $page_links 161 ); echo $page_links_text; ?> 162 </div> 163 <?php } ?> 164 165 <div class="view-switch"> 166 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a> 167 <a href="<?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a> 168 </div> 169 </div> 170 <div class="clear"></div> 171 172 <?php 173 // define the columns to display, the syntax is 'internal name' => 'display name' 174 $users_columns = array( 175 'id' => __( 'ID' ), 176 'login' => __( 'Username' ), 177 'name' => __( 'Name' ), 178 'email' => __( 'E-mail' ), 179 'registered' => _x( 'Registered', 'user' ), 180 'blogs' => __( 'Sites' ) 181 ); 182 $users_columns = apply_filters( 'wpmu_users_columns', $users_columns ); 183 ?> 184 <table class="widefat"> 185 <thead> 186 <tr> 187 <th class="manage-column column-cb check-column" scope="col"> 188 <input type="checkbox" /> 189 </th> 190 <?php 191 $col_url = ''; 192 foreach($users_columns as $column_id => $column_display_name) { 193 $column_link = "<a href='"; 194 $order2 = ''; 195 if ( $order_by == $column_id ) 196 $order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC'; 197 198 $column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array( 'action', 'updated' ), $_SERVER['REQUEST_URI'] ) ) ); 199 $column_link .= "'>{$column_display_name}</a>"; 200 $col_url .= '<th scope="col">' . ( $column_id == 'blogs' ? $column_display_name : $column_link ) . '</th>'; 201 } 202 echo $col_url; ?> 203 </tr> 204 </thead> 205 <tfoot> 206 <tr> 207 <th class="manage-column column-cb check-column" scope="col"> 208 <input type="checkbox" /> 209 </th> 210 <?php echo $col_url; ?> 211 </tr> 212 </tfoot> 213 <tbody id="the-user-list" class="list:user"> 214 <?php if ( $user_list ) { 215 $class = ''; 216 $super_admins = get_super_admins(); 217 foreach ( (array) $user_list as $user ) { 218 $class = ( 'alternate' == $class ) ? '' : 'alternate'; 219 220 $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' ); 221 222 foreach ( $status_list as $status => $col ) { 223 if ( $user[$status] ) 224 $class = $col; 225 } 226 227 ?> 228 <tr class="<?php echo $class; ?>"> 229 <?php 230 foreach( (array) $users_columns as $column_name=>$column_display_name ) : 231 switch( $column_name ) { 232 case 'id': ?> 233 <th scope="row" class="check-column"> 234 <input type="checkbox" id="blog_<?php echo $user['ID'] ?>" name="allusers[]" value="<?php echo esc_attr( $user['ID'] ) ?>" /> 235 </th> 236 <th valign="top" scope="row"> 237 <?php echo $user['ID'] ?> 238 </th> 239 <?php 240 break; 241 242 case 'login': 243 $avatar = get_avatar( $user['user_email'], 32 ); 244 $edit_link = ( $current_user->ID == $user['ID'] ) ? 'profile.php' : 'user-edit.php?user_id=' . $user['ID']; 245 ?> 246 <td class="username column-username"> 247 <?php echo $avatar; ?><strong><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user['user_login'] ); ?></a><?php 248 if ( in_array( $user['user_login'], $super_admins ) ) 249 echo ' - ' . __( 'Super admin' ); 250 ?></strong> 251 <br/> 252 <div class="row-actions"> 253 <span class="edit"><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>"><?php _e( 'Edit' ); ?></a></span> 254 <?php if ( ! in_array( $user['user_login'], $super_admins ) ) { ?> 255 | <span class="delete"><a href="<?php echo $delete = esc_url( admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user['ID'] ) ) ); ?>" class="delete"><?php _e( 'Delete' ); ?></a></span> 256 <?php } ?> 257 </div> 258 </td> 259 <?php 260 break; 261 262 case 'name': ?> 263 <td class="name column-name"><?php echo $user['display_name'] ?></td> 264 <?php 265 break; 266 267 case 'email': ?> 268 <td class="email column-email"><a href="mailto:<?php echo $user['user_email'] ?>"><?php echo $user['user_email'] ?></a></td> 269 <?php 270 break; 271 272 case 'registered': 273 if ( 'list' == $mode ) 274 $date = 'Y/m/d'; 275 else 276 $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 277 ?> 278 <td><?php echo mysql2date( __( $date ), $user['user_registered'] ); ?></td> 279 <?php 280 break; 281 282 case 'blogs': 283 $blogs = get_blogs_of_user( $user['ID'], true ); 284 ?> 285 <td> 286 <?php 287 if ( is_array( $blogs ) ) { 288 foreach ( (array) $blogs as $key => $val ) { 289 $path = ( $val->path == '/' ) ? '' : $val->path; 290 echo '<a href="'. esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>'; 291 echo ' <small class="row-actions">'; 292 293 // Edit 294 echo '<a href="'. esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a> | '; 295 296 // View 297 echo '<a '; 298 if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 ) 299 echo 'style="background-color: #faa" '; 300 echo 'href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>'; 301 302 echo '</small><br />'; 303 } 304 } 305 ?> 306 </td> 307 <?php 308 break; 309 310 default: ?> 311 <td><?php do_action( 'manage_users_custom_column', $column_name, $user['ID'] ); ?></td> 312 <?php 313 break; 314 } 315 endforeach 316 ?> 317 </tr> 318 <?php 319 } 320 } else { 321 ?> 322 <tr> 323 <td colspan="<?php echo (int) count($users_columns); ?>"><?php _e( 'No users found.' ) ?></td> 324 </tr> 325 <?php 326 } // end if ($users) 327 ?> 328 </tbody> 329 </table> 330 331 <div class="tablenav"> 332 <?php 333 if ( $page_links ) 334 echo "<div class='tablenav-pages'>$page_links_text</div>"; 335 ?> 336 337 <div class="alignleft actions"> 338 <select name="action2"> 339 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 340 <option value="delete"><?php _e( 'Delete' ); ?></option> 341 <option value="spam"><?php _ex( 'Mark as Spam', 'user' ); ?></option> 342 <option value="notspam"><?php _ex( 'Not Spam', 'user' ); ?></option> 343 </select> 344 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 345 </div> 346 <br class="clear" /> 347 </div> 348 349 </form> 350 </div> 351 352 <?php 353 if ( apply_filters( 'show_adduser_fields', true ) ) : 354 ?> 355 <div class="wrap" id="form-add-user"> 356 <h3><?php _e( 'Add User' ) ?></h3> 357 <form action="edit.php?action=adduser" method="post"> 358 <table class="form-table"> 359 <tr class="form-field form-required"> 360 <th scope="row"><?php _e( 'Username' ) ?></th> 361 <td><input type="text" class="regular-text" name="user[username]" /></td> 362 </tr> 363 <tr class="form-field form-required"> 364 <th scope="row"><?php _e( 'Email' ) ?></th> 365 <td><input type="text" class="regular-text" name="user[email]" /></td> 366 </tr> 367 <tr class="form-field"> 368 <td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td> 369 </tr> 370 </table> 371 <p class="submit"> 372 <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?> 373 <input class="button" type="submit" value="<?php esc_attr_e( 'Add user' ) ?>" /></p> 374 </form> 375 </div> 376 <?php endif; ?> 377 378 <?php include( '../admin-footer.php' ); ?> -
wp-admin/network/plugins.php
Property changes on: wp-admin/network/users.php ___________________________________________________________________ Added: svn:eol-style + native
1 <?php 2 3 require_once( './admin.php' ); 4 5 require( '../plugins.php' ); 6 No newline at end of file -
wp-admin/network/menu.php
Property changes on: wp-admin/network/plugins.php ___________________________________________________________________ Added: svn:eol-style + native
1 <?php 2 3 /* translators: Network menu item */ 4 $menu[0] = array(__('Dashboard'), 'manage_network', 'index.php', '', 'menu-top menu-top-first menu-icon-site', 'menu-site', 'div'); 5 6 $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); 7 8 /* translators: Sites menu item */ 9 $menu[5] = array(__('Sites'), 'manage_sites', 'sites.php', '', 'menu-top menu-icon-site', 'menu-site', 'div'); 10 $menu[10] = array(__('Users'), 'manage_network_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div'); 11 $menu[15] = array(__('Themes'), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div'); 12 $menu[15] = array(__('Plugins'), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div'); 13 $menu[20] = array(__('Settings'), 'manage_network_options', 'settings.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'div'); 14 $menu[25] = array(__('Update'), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div'); 15 16 $menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator-last' ); 17 18 $compat = array(); 19 $submenu = array(); 20 21 require(ABSPATH . 'wp-admin/includes/menu.php'); 22 23 ?> 24 No newline at end of file -
wp-admin/network/edit.php
Property changes on: wp-admin/network/menu.php ___________________________________________________________________ Added: svn:eol-style + native
1 <?php 2 /** 3 * Action handler for Multisite administration panels. 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 * @since 3.0.0 8 */ 9 10 require_once( './admin.php' ); 11 12 if ( ! is_multisite() ) 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 15 if ( empty( $_GET['action'] ) ) 16 wp_redirect( admin_url( 'ms-admin.php' ) ); 17 18 do_action( 'wpmuadminedit' , ''); 19 20 if ( isset( $_GET['id' ]) ) 21 $id = intval( $_GET['id'] ); 22 elseif ( isset( $_POST['id'] ) ) 23 $id = intval( $_POST['id'] ); 24 25 switch ( $_GET['action'] ) { 26 case 'siteoptions': 27 check_admin_referer( 'siteoptions' ); 28 if ( ! current_user_can( 'manage_network_options' ) ) 29 wp_die( __( 'You do not have permission to access this page.' ) ); 30 31 if ( empty( $_POST ) ) 32 wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">options page</a>.', esc_url( admin_url( 'ms-options.php' ) ) ) ) ); 33 34 if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) ) 35 update_site_option( 'WPLANG', $_POST['WPLANG'] ); 36 37 if ( is_email( $_POST['admin_email'] ) ) 38 update_site_option( 'admin_email', $_POST['admin_email'] ); 39 40 $illegal_names = split( ' ', $_POST['illegal_names'] ); 41 foreach ( (array) $illegal_names as $name ) { 42 $name = trim( $name ); 43 if ( $name != '' ) 44 $names[] = trim( $name ); 45 } 46 update_site_option( 'illegal_names', $names ); 47 48 if ( $_POST['limited_email_domains'] != '' ) { 49 $limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] ); 50 $limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) ); 51 $limited_email = array(); 52 foreach ( (array) $limited_email_domains as $domain ) { 53 $domain = trim( $domain ); 54 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) 55 $limited_email[] = trim( $domain ); 56 } 57 update_site_option( 'limited_email_domains', $limited_email ); 58 } else { 59 update_site_option( 'limited_email_domains', '' ); 60 } 61 62 if ( $_POST['banned_email_domains'] != '' ) { 63 $banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) ); 64 $banned = array(); 65 foreach ( (array) $banned_email_domains as $domain ) { 66 $domain = trim( $domain ); 67 if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) 68 $banned[] = trim( $domain ); 69 } 70 update_site_option( 'banned_email_domains', $banned ); 71 } else { 72 update_site_option( 'banned_email_domains', '' ); 73 } 74 update_site_option( 'default_user_role', $_POST['default_user_role'] ); 75 if ( trim( $_POST['dashboard_blog_orig'] ) == '' ) 76 $_POST['dashboard_blog_orig'] = $current_site->blog_id; 77 if ( trim( $_POST['dashboard_blog'] ) == '' ) { 78 $_POST['dashboard_blog'] = $current_site->blog_id; 79 $dashboard_blog_id = $current_site->blog_id; 80 } elseif ( ! preg_match( '/(--|\.)/', $_POST['dashboard_blog'] ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $_POST['dashboard_blog'] ) ) { 81 $dashboard_blog = $_POST['dashboard_blog']; 82 $blog_details = get_blog_details( $dashboard_blog ); 83 if ( false === $blog_details ) { 84 if ( is_numeric( $dashboard_blog ) ) 85 wp_die( __( 'A dashboard site referenced by ID must already exist' ) ); 86 if ( is_subdomain_install() ) { 87 $domain = $dashboard_blog . '.' . $current_site->domain; 88 $path = $current_site->path; 89 } else { 90 $domain = $current_site->domain; 91 $path = trailingslashit( $current_site->path . $dashboard_blog ); 92 } 93 $wpdb->hide_errors(); 94 $dashboard_blog_id = wpmu_create_blog( $domain, $path, __( 'My Dashboard' ), $current_user->id , array( 'public' => 0 ), $current_site->id ); 95 $wpdb->show_errors(); 96 } else { 97 $dashboard_blog_id = $blog_details->blog_id; 98 } 99 } 100 if ( is_wp_error( $dashboard_blog_id ) ) 101 wp_die( __( 'Problem creating dashboard site: ' ) . $dashboard_blog_id->get_error_message() ); 102 if ( $_POST['dashboard_blog_orig'] != $_POST['dashboard_blog'] ) { 103 $users = get_users_of_blog( get_site_option( 'dashboard_blog' ) ); 104 $move_users = array(); 105 foreach ( (array)$users as $user ) { 106 $user_meta_value = unserialize( $user->meta_value ); 107 if ( is_array( $user_meta_value ) && array_pop( $var_by_ref = array_keys( $user_meta_value ) ) == 'subscriber' ) 108 $move_users[] = $user->user_id; 109 } 110 if ( false == empty( $move_users ) ) { 111 foreach ( (array)$move_users as $user_id ) { 112 remove_user_from_blog($user_id, get_site_option( 'dashboard_blog' ) ); 113 add_user_to_blog( $dashboard_blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 114 update_user_meta( $user_id, 'primary_blog', $dashboard_blog_id ); 115 } 116 } 117 } 118 update_site_option( 'dashboard_blog', $dashboard_blog_id ); 119 120 $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', 'admin_notice_feed', 'global_terms_enabled' ); 121 $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 ); 122 foreach ( $checked_options as $option_name => $option_unchecked_value ) { 123 if ( ! isset( $_POST[$option_name] ) ) 124 $_POST[$option_name] = $option_unchecked_value; 125 } 126 foreach ( $options as $option_name ) { 127 if ( ! isset($_POST[$option_name]) ) 128 continue; 129 $value = stripslashes_deep( $_POST[$option_name] ); 130 update_site_option( $option_name, $value ); 131 } 132 133 // Update more options here 134 do_action( 'update_wpmu_options' ); 135 136 wp_redirect( add_query_arg( 'updated', 'true', admin_url( 'ms-options.php' ) ) ); 137 exit(); 138 break; 139 case 'addblog': 140 check_admin_referer( 'add-blog', '_wpnonce_add-blog' ); 141 142 if ( ! current_user_can( 'manage_sites' ) ) 143 wp_die( __( 'You do not have permission to access this page.' ) ); 144 145 if ( is_array( $_POST['blog'] ) == false ) 146 wp_die( __( 'Can’t create an empty site.' ) ); 147 $blog = $_POST['blog']; 148 $domain = ''; 149 if ( ! preg_match( '/(--)/', $blog['domain'] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) 150 $domain = strtolower( $blog['domain'] ); 151 152 // If not a subdomain install, make sure the domain isn't a reserved word 153 if ( ! is_subdomain_install() ) { 154 $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ); 155 if ( in_array( $domain, $subdirectory_reserved_names ) ) 156 wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: <code>%s</code>' ), implode( '</code>, <code>', $subdirectory_reserved_names ) ) ); 157 } 158 159 $email = sanitize_email( $blog['email'] ); 160 $title = $blog['title']; 161 162 if ( empty( $domain ) ) 163 wp_die( __( 'Missing or invalid site address.' ) ); 164 if ( empty( $email ) ) 165 wp_die( __( 'Missing email address.' ) ); 166 if ( !is_email( $email ) ) 167 wp_die( __( 'Invalid email address.' ) ); 168 169 if ( is_subdomain_install() ) { 170 $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); 171 $path = $base; 172 } else { 173 $newdomain = $current_site->domain; 174 $path = $base . $domain . '/'; 175 } 176 177 $password = 'N/A'; 178 $user_id = email_exists($email); 179 if ( !$user_id ) { // Create a new user with a random password 180 $password = wp_generate_password(); 181 $user_id = wpmu_create_user( $domain, $password, $email ); 182 if ( false == $user_id ) 183 wp_die( __( 'There was an error creating the user.' ) ); 184 else 185 wp_new_user_notification( $user_id, $password ); 186 } 187 188 $wpdb->hide_errors(); 189 $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id ); 190 $wpdb->show_errors(); 191 if ( !is_wp_error( $id ) ) { 192 $dashboard_blog = get_dashboard_blog(); 193 if ( !is_super_admin( $user_id ) && get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id ) 194 update_user_option( $user_id, 'primary_blog', $id, true ); 195 $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) ); 196 wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' ); 197 wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) ); 198 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add-blog' ), wp_get_referer() ) ); 199 exit(); 200 } else { 201 wp_die( $id->get_error_message() ); 202 } 203 break; 204 205 case 'updateblog': 206 check_admin_referer( 'editblog' ); 207 if ( ! current_user_can( 'manage_sites' ) ) 208 wp_die( __( 'You do not have permission to access this page.' ) ); 209 210 if ( empty( $_POST ) ) 211 wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">sites page</a>', esc_url( admin_url( 'ms-sites.php' ) ) ) ) ); 212 213 switch_to_blog( $id ); 214 215 // themes 216 $allowedthemes = array(); 217 if ( isset($_POST['theme']) && is_array( $_POST['theme'] ) ) { 218 foreach ( $_POST['theme'] as $theme => $val ) { 219 if ( 'on' == $val ) 220 $allowedthemes[$theme] = true; 221 } 222 } 223 update_option( 'allowedthemes', $allowedthemes ); 224 225 // options 226 if ( is_array( $_POST['option'] ) ) { 227 $c = 1; 228 $count = count( $_POST['option'] ); 229 $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form. 230 foreach ( (array) $_POST['option'] as $key => $val ) { 231 if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) ) 232 continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options 233 if ( $c == $count ) 234 update_option( $key, stripslashes( $val ) ); 235 else 236 update_option( $key, stripslashes( $val ), false ); // no need to refresh blog details yet 237 $c++; 238 } 239 } 240 241 // home and siteurl 242 if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) { 243 $blog_address = get_blogaddress_by_domain( $_POST['blog']['domain'], $_POST['blog']['path'] ); 244 if ( get_option( 'siteurl' ) != $blog_address ) 245 update_option( 'siteurl', $blog_address ); 246 247 if ( get_option( 'home' ) != $blog_address ) 248 update_option( 'home', $blog_address ); 249 } 250 251 // rewrite rules can't be flushed during switch to blog 252 delete_option( 'rewrite_rules' ); 253 254 // update blogs table 255 $blog_data = stripslashes_deep( $_POST['blog'] ); 256 update_blog_details( $id, $blog_data ); 257 258 // get blog prefix 259 $blog_prefix = $wpdb->get_blog_prefix( $id ); 260 261 // user roles 262 if ( isset( $_POST['role'] ) && is_array( $_POST['role'] ) == true ) { 263 $newroles = $_POST['role']; 264 265 reset( $newroles ); 266 foreach ( (array) $newroles as $userid => $role ) { 267 $user = new WP_User( $userid ); 268 if ( empty( $user->ID ) ) 269 continue; 270 $user->for_blog( $id ); 271 $user->set_role( $role ); 272 } 273 } 274 275 // remove user 276 if ( isset( $_POST['blogusers'] ) && is_array( $_POST['blogusers'] ) ) { 277 reset( $_POST['blogusers'] ); 278 foreach ( (array) $_POST['blogusers'] as $key => $val ) 279 remove_user_from_blog( $key, $id ); 280 } 281 282 // change password 283 if ( isset( $_POST['user_password'] ) && is_array( $_POST['user_password'] ) ) { 284 reset( $_POST['user_password'] ); 285 $newroles = $_POST['role']; 286 foreach ( (array) $_POST['user_password'] as $userid => $pass ) { 287 unset( $_POST['role'] ); 288 $_POST['role'] = $newroles[ $userid ]; 289 if ( $pass != '' ) { 290 $cap = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) ); 291 $userdata = get_userdata($userid); 292 $_POST['pass1'] = $_POST['pass2'] = $pass; 293 $_POST['email'] = $userdata->user_email; 294 $_POST['rich_editing'] = $userdata->rich_editing; 295 edit_user( $userid ); 296 if ( $cap == null ) 297 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE user_id = %d AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'", $userid ) ); 298 } 299 } 300 unset( $_POST['role'] ); 301 $_POST['role'] = $newroles; 302 } 303 304 // add user 305 if ( !empty( $_POST['newuser'] ) ) { 306 $newuser = $_POST['newuser']; 307 $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) ); 308 if ( $userid ) { 309 $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" ); 310 if ( $user == false ) 311 add_user_to_blog( $id, $userid, $_POST['new_role'] ); 312 } 313 } 314 do_action( 'wpmu_update_blog_options' ); 315 restore_current_blog(); 316 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'editblog', 'id' => $id ), wp_get_referer() ) ); 317 break; 318 319 case 'deleteblog': 320 check_admin_referer('deleteblog'); 321 if ( ! current_user_can( 'manage_sites' ) ) 322 wp_die( __( 'You do not have permission to access this page.' ) ); 323 324 if ( $id != '0' && $id != $current_site->blog_id ) 325 wpmu_delete_blog( $id, true ); 326 327 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) ); 328 exit(); 329 break; 330 331 case 'allblogs': 332 if ( isset( $_POST['doaction']) || isset($_POST['doaction2'] ) ) { 333 check_admin_referer( 'bulk-ms-sites', '_wpnonce_bulk-ms-sites' ); 334 335 if ( ! current_user_can( 'manage_sites' ) ) 336 wp_die( __( 'You do not have permission to access this page.' ) ); 337 338 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 ) 339 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; 340 341 342 foreach ( (array) $_POST['allblogs'] as $key => $val ) { 343 if ( $val != '0' && $val != $current_site->blog_id ) { 344 switch ( $doaction ) { 345 case 'delete': 346 $blogfunction = 'all_delete'; 347 wpmu_delete_blog( $val, true ); 348 break; 349 350 case 'spam': 351 $blogfunction = 'all_spam'; 352 update_blog_status( $val, 'spam', '1', 0 ); 353 set_time_limit( 60 ); 354 break; 355 356 case 'notspam': 357 $blogfunction = 'all_notspam'; 358 update_blog_status( $val, 'spam', '0', 0 ); 359 set_time_limit( 60 ); 360 break; 361 } 362 } else { 363 wp_die( __( 'You are not allowed to change the current site.' ) ); 364 } 365 } 366 367 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) ); 368 exit(); 369 } else { 370 wp_redirect( admin_url( 'ms-sites.php' ) ); 371 } 372 break; 373 374 case 'archiveblog': 375 check_admin_referer( 'archiveblog' ); 376 if ( ! current_user_can( 'manage_sites' ) ) 377 wp_die( __( 'You do not have permission to access this page.' ) ); 378 379 update_blog_status( $id, 'archived', '1' ); 380 do_action( 'archive_blog', $id ); 381 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) ); 382 exit(); 383 break; 384 385 case 'unarchiveblog': 386 check_admin_referer( 'unarchiveblog' ); 387 if ( ! current_user_can( 'manage_sites' ) ) 388 wp_die( __( 'You do not have permission to access this page.' ) ); 389 390 do_action( 'unarchive_blog', $id ); 391 update_blog_status( $id, 'archived', '0' ); 392 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) ); 393 exit(); 394 break; 395 396 case 'activateblog': 397 check_admin_referer( 'activateblog' ); 398 if ( ! current_user_can( 'manage_sites' ) ) 399 wp_die( __( 'You do not have permission to access this page.' ) ); 400 401 update_blog_status( $id, 'deleted', '0' ); 402 do_action( 'activate_blog', $id ); 403 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) ); 404 exit(); 405 break; 406 407 case 'deactivateblog': 408 check_admin_referer( 'deactivateblog' ); 409 if ( ! current_user_can( 'manage_sites' ) ) 410 wp_die( __( 'You do not have permission to access this page.' ) ); 411 412 do_action( 'deactivate_blog', $id ); 413 update_blog_status( $id, 'deleted', '1' ); 414 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) ); 415 exit(); 416 break; 417 418 case 'unspamblog': 419 check_admin_referer( 'unspamblog' ); 420 if ( ! current_user_can( 'manage_sites' ) ) 421 wp_die( __( 'You do not have permission to access this page.' ) ); 422 423 update_blog_status( $id, 'spam', '0' ); 424 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) ); 425 exit(); 426 break; 427 428 case 'spamblog': 429 check_admin_referer( 'spamblog' ); 430 if ( ! current_user_can( 'manage_sites' ) ) 431 wp_die( __( 'You do not have permission to access this page.' ) ); 432 433 update_blog_status( $id, 'spam', '1' ); 434 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) ); 435 exit(); 436 break; 437 438 // Themes 439 case 'updatethemes': 440 if ( ! current_user_can( 'manage_network_themes' ) ) 441 wp_die( __( 'You do not have permission to access this page.' ) ); 442 443 if ( is_array( $_POST['theme'] ) ) { 444 $themes = get_themes(); 445 reset( $themes ); 446 $allowed_themes = array(); 447 foreach ( (array) $themes as $key => $theme ) { 448 if ( $_POST['theme'][ esc_html( $theme['Stylesheet'] ) ] == 'enabled' ) 449 $allowed_themes[ esc_html( $theme['Stylesheet'] ) ] = true; 450 } 451 update_site_option( 'allowedthemes', $allowed_themes ); 452 } 453 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'themes' ), wp_get_referer() ) ); 454 exit(); 455 break; 456 457 // Common 458 case 'confirm': 459 if ( !headers_sent() ) { 460 nocache_headers(); 461 header( 'Content-Type: text/html; charset=utf-8' ); 462 } 463 if ( $current_site->blog_id == $id ) 464 wp_die( __( 'You are not allowed to change the current site.' ) ); 465 ?> 466 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 467 <html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>> 468 <head> 469 <title><?php _e( 'WordPress › Confirm your action' ); ?></title> 470 471 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 472 <?php 473 wp_admin_css( 'install', true ); 474 wp_admin_css( 'ie', true ); 475 ?> 476 </head> 477 <body> 478 <h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1> 479 <form action="ms-edit.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post"> 480 <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" /> 481 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> 482 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> 483 <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?> 484 <p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p> 485 <p class="submit"><input class="button" type="submit" value="<?php _e( 'Confirm' ); ?>" /></p> 486 </form> 487 </body> 488 </html> 489 <?php 490 break; 491 492 // Users 493 case 'deleteuser': 494 if ( ! current_user_can( 'manage_network_users' ) ) 495 wp_die( __( 'You do not have permission to access this page.' ) ); 496 497 check_admin_referer( 'deleteuser' ); 498 499 if ( $id != '0' && $id != '1' ) { 500 $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays 501 $title = __( 'Users' ); 502 $parent_file = 'ms-admin.php'; 503 require_once( 'admin-header.php' ); 504 echo '<div class="wrap">'; 505 confirm_delete_users( $_POST['allusers'] ); 506 echo '</div>'; 507 require_once( 'admin-footer.php' ); 508 exit(); 509 } else { 510 wp_redirect( admin_url( 'ms-users.php' ) ); 511 } 512 break; 513 514 case 'allusers': 515 if ( ! current_user_can( 'manage_network_users' ) ) 516 wp_die( __( 'You do not have permission to access this page.' ) ); 517 518 if ( isset( $_POST['doaction']) || isset($_POST['doaction2'] ) ) { 519 check_admin_referer( 'bulk-ms-users', '_wpnonce_bulk-ms-users' ); 520 521 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 ) 522 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; 523 524 foreach ( (array) $_POST['allusers'] as $key => $val ) { 525 if ( !empty( $val ) ) { 526 switch ( $doaction ) { 527 case 'delete': 528 $title = __( 'Users' ); 529 $parent_file = 'ms-admin.php'; 530 require_once( 'admin-header.php' ); 531 echo '<div class="wrap">'; 532 confirm_delete_users( $_POST['allusers'] ); 533 echo '</div>'; 534 require_once( 'admin-footer.php' ); 535 exit(); 536 break; 537 538 case 'spam': 539 $user = new WP_User( $val ); 540 if ( in_array( $user->user_login, get_super_admins() ) ) 541 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); 542 543 $userfunction = 'all_spam'; 544 $blogs = get_blogs_of_user( $val, true ); 545 foreach ( (array) $blogs as $key => $details ) { 546 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! 547 update_blog_status( $details->userblog_id, 'spam', '1' ); 548 } 549 update_user_status( $val, 'spam', '1', 1 ); 550 break; 551 552 case 'notspam': 553 $userfunction = 'all_notspam'; 554 $blogs = get_blogs_of_user( $val, true ); 555 foreach ( (array) $blogs as $key => $details ) 556 update_blog_status( $details->userblog_id, 'spam', '0' ); 557 558 update_user_status( $val, 'spam', '0', 1 ); 559 break; 560 } 561 } 562 } 563 564 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) ); 565 exit(); 566 } else { 567 wp_redirect( admin_url( 'ms-users.php' ) ); 568 } 569 break; 570 571 case 'dodelete': 572 check_admin_referer( 'ms-users-delete' ); 573 if ( ! current_user_can( 'manage_network_users' ) ) 574 wp_die( __( 'You do not have permission to access this page.' ) ); 575 576 if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) { 577 foreach ( $_POST['blog'] as $id => $users ) { 578 foreach ( $users as $blogid => $user_id ) { 579 if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] ) 580 remove_user_from_blog( $id, $blogid, $user_id ); 581 else 582 remove_user_from_blog( $id, $blogid ); 583 } 584 } 585 } 586 $i = 0; 587 if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) 588 foreach( $_POST['user'] as $id ) { 589 wpmu_delete_user( $id ); 590 $i++; 591 } 592 593 if ( $i == 1 ) 594 $deletefunction = 'delete'; 595 else 596 $deletefunction = 'all_delete'; 597 598 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), admin_url( 'ms-users.php' ) ) ); 599 break; 600 601 case 'adduser': 602 check_admin_referer( 'add-user', '_wpnonce_add-user' ); 603 if ( ! current_user_can( 'manage_network_users' ) ) 604 wp_die( __( 'You do not have permission to access this page.' ) ); 605 606 if ( is_array( $_POST['user'] ) == false ) 607 wp_die( __( 'Cannot create an empty user.' ) ); 608 $user = $_POST['user']; 609 if ( empty($user['username']) && empty($user['email']) ) 610 wp_die( __( 'Missing username and email.' ) ); 611 elseif ( empty($user['username']) ) 612 wp_die( __( 'Missing username.' ) ); 613 elseif ( empty($user['email']) ) 614 wp_die( __( 'Missing email.' ) ); 615 616 $password = wp_generate_password(); 617 $user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) ); 618 619 if ( false == $user_id ) 620 wp_die( __( 'Duplicated username or email address.' ) ); 621 else 622 wp_new_user_notification( $user_id, $password ); 623 624 if ( get_site_option( 'dashboard_blog' ) == false ) 625 add_user_to_blog( $current_site->blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 626 else 627 add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); 628 629 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) ); 630 exit(); 631 break; 632 633 default: 634 wp_redirect( admin_url( 'ms-admin.php' ) ); 635 break; 636 } 637 ?> -
wp-admin/network/themes.php
Property changes on: wp-admin/network/edit.php ___________________________________________________________________ Added: svn:eol-style + native
1 <?php 2 /** 3 * Multisite themes administration panel. 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 * @since 3.0.0 8 */ 9 10 require_once( './admin.php' ); 11 12 if ( ! current_user_can( 'manage_network_themes' ) ) 13 wp_die( __( 'You do not have permission to access this page.' ) ); 14 15 $title = __( 'Network Themes' ); 16 $parent_file = 'themes.php'; 17 18 add_contextual_help($current_screen, 19 '<p>' . __('This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.') . '</p>' . 20 '<p>' . __('If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site’s Appearance > Themes screen.') . '</p>' . 21 '<p>' . __('Themes can be enabled on a site by site basis by the network admin on the Edit Site screen you go to via the Edit action link on the Sites screen.') . '</p>' . 22 '<p><strong>' . __('For more information:') . '</strong></p>' . 23 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Themes_SubPanel" target="_blank">Documentation on Network Themes</a>') . '</p>' . 24 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 25 ); 26 27 require_once( '../admin-header.php' ); 28 29 if ( isset( $_GET['updated'] ) ) { 30 ?> 31 <div id="message" class="updated"><p><?php _e( 'Site themes saved.' ) ?></p></div> 32 <?php 33 } 34 35 $themes = get_themes(); 36 $allowed_themes = get_site_allowed_themes(); 37 ?> 38 <div class="wrap"> 39 <form action="<?php echo esc_url( network_admin_url( 'edit.php?action=updatethemes' ) ); ?>" method="post"> 40 <?php screen_icon(); ?> 41 <h2><?php _e( 'Network Themes' ) ?></h2> 42 <p><?php _e( 'Themes must be enabled for your network before they will be available to individual sites.' ) ?></p> 43 <p class="submit"> 44 <input type="submit" value="<?php _e( 'Apply Changes' ) ?>" /></p> 45 <table class="widefat"> 46 <thead> 47 <tr> 48 <th style="width:15%;"><?php _e( 'Enable' ) ?></th> 49 <th style="width:25%;"><?php _e( 'Theme' ) ?></th> 50 <th style="width:10%;"><?php _e( 'Version' ) ?></th> 51 <th style="width:60%;"><?php _e( 'Description' ) ?></th> 52 </tr> 53 </thead> 54 <tbody id="plugins"> 55 <?php 56 $total_theme_count = $activated_themes_count = 0; 57 $class = ''; 58 foreach ( (array) $themes as $key => $theme ) { 59 $total_theme_count++; 60 $theme_key = esc_html( $theme['Stylesheet'] ); 61 $class = ( 'alt' == $class ) ? '' : 'alt'; 62 $class1 = $enabled = $disabled = ''; 63 $enabled = $disabled = false; 64 65 if ( isset( $allowed_themes[$theme_key] ) == true ) { 66 $enabled = true; 67 $activated_themes_count++; 68 $class1 = 'active'; 69 } else { 70 $disabled = true; 71 } 72 ?> 73 <tr valign="top" class="<?php echo $class . ' ' . $class1; ?>"> 74 <td> 75 <label><input name="theme[<?php echo $theme_key ?>]" type="radio" id="enabled_<?php echo $theme_key ?>" value="enabled" <?php checked( $enabled ) ?> /> <?php _e( 'Yes' ) ?></label> 76 77 <label><input name="theme[<?php echo $theme_key ?>]" type="radio" id="disabled_<?php echo $theme_key ?>" value="disabled" <?php checked( $disabled ) ?> /> <?php _e( 'No' ) ?></label> 78 </td> 79 <th scope="row" style="text-align:left;"><?php echo $key ?></th> 80 <td><?php echo $theme['Version'] ?></td> 81 <td><?php echo $theme['Description'] ?></td> 82 </tr> 83 <?php } ?> 84 </tbody> 85 </table> 86 87 <p class="submit"> 88 <input type="submit" value="<?php _e( 'Apply Changes' ) ?>" /></p> 89 </form> 90 91 <h3><?php _e( 'Total' )?></h3> 92 <p> 93 <?php printf( __( 'Themes Installed: %d' ), $total_theme_count); ?> 94 <br /> 95 <?php printf( __( 'Themes Enabled: %d' ), $activated_themes_count); ?> 96 </p> 97 </div> 98 99 <?php include( '../admin-footer.php' ); ?> -
wp-admin/network/index.php
Property changes on: wp-admin/network/themes.php ___________________________________________________________________ Added: svn:eol-style + native
1 <?php 2 /** 3 * Multisite administration panel. 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 * @since 3.0.0 8 */ 9 10 require_once( './admin.php' ); 11 12 if ( !is_multisite() ) 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 15 if ( ! current_user_can( 'manage_network' ) ) 16 wp_die( __( 'You do not have permission to access this page.' ) ); 17 18 $title = __( 'Network Admin' ); 19 $parent_file = 'index.php'; 20 21 add_contextual_help($current_screen, 22 '<p>' . __('Until WordPress 3.0, running multiple sites required using WordPress MU instead of regular WordPress. In version 3.0, these applications have merged. If you are a former MU user, you should be aware of the following changes:') . '</p>' . 23 '<ul><li>' . __('Site Admin is now Super Admin (we highly encourage you to get yourself a cape!).') . '</li>' . 24 '<li>' . __('Blogs are now called Sites; Site is now called Network.') . '</li></ul>' . 25 '<p>' . __('This screen provides the network administrator with links to the screens for Sites and Users to either create a new site or user, or to search existing users and sites. Those screens are also accessible through the left-hand navigation in the Super Admin section.') . '</p>' . 26 '<p><strong>' . __('For more information:') . '</strong></p>' . 27 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Super_Admin_Menu" target="_blank">Documentation on Super Admin Menu</a>') . '</p>' . 28 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 29 ); 30 31 require_once( '../admin-header.php' ); 32 33 $c_users = get_user_count(); 34 $c_blogs = get_blog_count(); 35 36 $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); 37 $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); 38 39 $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); 40 ?> 41 42 <div class="wrap"> 43 <?php screen_icon(); ?> 44 <h2><?php echo esc_html( $title ); ?></h2> 45 46 <ul class="subsubsub"> 47 <li><a href="sites.php#form-add-site"><?php _e( 'Create a New Site' ); ?></a> |</li> 48 <li><a href="users.php#form-add-user"><?php _e( 'Create a New User' ); ?></a></li> 49 </ul> 50 <br class="clear" /> 51 52 <p class="youhave"><?php echo $sentence; ?></p> 53 <?php do_action( 'wpmuadminresult', '' ); ?> 54 55 <form name="searchform" action="users.php" method="get"> 56 <p> 57 <input type="hidden" name="action" value="users" /> 58 <input type="text" name="s" value="" size="17" /> 59 <input class="button" type="submit" name="submit" value="<?php esc_attr_e( 'Search Users' ); ?>" /> 60 </p> 61 </form> 62 63 <form name="searchform" action="sites.php" method="get"> 64 <p> 65 <input type="hidden" name="action" value="blogs" /> 66 <input type="hidden" name="searchaction" value="name" /> 67 <input type="text" name="s" value="" size="17" /> 68 <input class="button" type="submit" name="blog_name" value="<?php esc_attr_e( 'Search Sites' ); ?>" /> 69 </p> 70 </form> 71 72 <?php do_action( 'mu_rightnow_end' ); ?> 73 <?php do_action( 'mu_activity_box_end' ); ?> 74 </div> 75 76 <?php include( '../admin-footer.php' ); ?> -
wp-admin/network/sites.php
Property changes on: wp-admin/network/index.php ___________________________________________________________________ Added: svn:eol-style + native
1 <?php 2 /** 3 * Multisite sites administration panel. 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 * @since 3.0.0 8 */ 9 10 require_once( './admin.php' ); 11 12 if ( ! is_multisite() ) 13 wp_die( __( 'Multisite support is not enabled.' ) ); 14 15 if ( ! current_user_can( 'manage_sites' ) ) 16 wp_die( __( 'You do not have permission to access this page.' ) ); 17 18 $title = __( 'Sites' ); 19 $parent_file = 'sites.php'; 20 21 if ( isset( $_GET['action'] ) && 'editblog' == $_GET['action'] ) { 22 add_contextual_help($current_screen, 23 '<p>' . __('This extensive list of options has five modules: Site Info, Site Options, allowing Site Themes for this given site, changing user roles and passwords for that site, adding a new user, and Miscellaneous Site Actions (upload size limits).') . '</p>' . 24 '<p>' . __('Note that some fields in Site Options are grayed out and say Serialized Data. These are stored values in the database which you cannot change from here.') . '</p>' . 25 '<p><strong>' . __('For more information:') . '</strong></p>' . 26 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Sites_Edit_Site" target="_blank">Documentation on Editing Sites</a>') . '</p>' . 27 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 28 ); 29 } else { 30 add_contextual_help($current_screen, 31 '<p>' . __('Add New takes you farther down on this same page. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' . 32 '<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' . 33 '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' . 34 '<ul><li>' . __('an Edit link to a separate Edit Site screen.') . '</li>' . 35 '<li>' . __('Backend means the Dashboard for that site.') . '</li>' . 36 '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' . 37 '<li>' . __('Delete which is a permanent action after the confirmations screen.') . '</li>' . 38 '<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' . 39 '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' . 40 '<p>' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '</p>' . 41 '<p>' . __("Clicking on Add Site, after filling out the address, title, and admin's email address, adds the site instantly to the network and this table. You may want to then click on the action link to edit options for that site.") . '</p>' . 42 '<p>' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '</p>' . 43 '<p><strong>' . __('For more information:') . '</strong></p>' . 44 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Sites_SubPanel" target="_blank">Documentation on Sites</a>') . '</p>' . 45 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 46 ); 47 } 48 49 wp_enqueue_script( 'admin-forms' ); 50 51 require_once( '../admin-header.php' ); 52 53 $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; 54 55 if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) { 56 ?> 57 <div id="message" class="updated"><p> 58 <?php 59 switch ( $_GET['action'] ) { 60 case 'all_notspam': 61 _e( 'Sites removed from spam.' ); 62 break; 63 case 'all_spam': 64 _e( 'Sites marked as spam.' ); 65 break; 66 case 'all_delete': 67 _e( 'Sites deleted.' ); 68 break; 69 case 'delete': 70 _e( 'Site deleted.' ); 71 break; 72 case 'add-blog': 73 _e( 'Site added.' ); 74 break; 75 case 'archive': 76 _e( 'Site archived.' ); 77 break; 78 case 'unarchive': 79 _e( 'Site unarchived.' ); 80 break; 81 case 'activate': 82 _e( 'Site activated.' ); 83 break; 84 case 'deactivate': 85 _e( 'Site deactivated.' ); 86 break; 87 case 'unspam': 88 _e( 'Site removed from spam.' ); 89 break; 90 case 'spam': 91 _e( 'Site marked as spam.' ); 92 break; 93 default: 94 _e( 'Settings saved.' ); 95 break; 96 } 97 ?> 98 </p></div> 99 <?php 100 } 101 102 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'list'; 103 104 switch ( $action ) { 105 // Edit site 106 case 'editblog': 107 $blog_prefix = $wpdb->get_blog_prefix( $id ); 108 $options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" ); 109 $details = get_blog_details( $id ); 110 if ( $details->site_id != $wpdb->siteid ) 111 wp_die( __( 'You do not have permission to access this page.' ) ); 112 113 $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" ); 114 $is_main_site = is_main_site( $id ); 115 ?> 116 <div class="wrap"> 117 <?php screen_icon(); ?> 118 <h2><?php _e( 'Edit Site' ); ?> - <a href="<?php echo esc_url( get_home_url( $id ) ); ?>"><?php echo esc_url( get_home_url( $id ) ); ?></a></h2> 119 <form method="post" action="edit.php?action=updateblog"> 120 <?php wp_nonce_field( 'editblog' ); ?> 121 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> 122 <div class="metabox-holder" style="width:49%;float:left;"> 123 <div id="blogedit_bloginfo" class="postbox"> 124 <h3 class="hndle"><span><?php _e( 'Site info (wp_blogs)' ); ?></span></h3> 125 <div class="inside"> 126 <table class="form-table"> 127 <tr class="form-field form-required"> 128 <th scope="row"><?php _e( 'Domain' ) ?></th> 129 <?php 130 $protocol = is_ssl() ? 'https://' : 'http://'; 131 if ( $is_main_site ) { ?> 132 <td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td> 133 <?php } else { ?> 134 <td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td> 135 <?php } ?> 136 </tr> 137 <tr class="form-field form-required"> 138 <th scope="row"><?php _e( 'Path' ) ?></th> 139 <?php if ( $is_main_site ) { ?> 140 <td><code><?php echo esc_attr( $details->path ) ?></code></td> 141 <?php } else { ?> 142 <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' /> 143 <br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_blog_option( $id, 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_blog_option( $id, 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td> 144 <?php } ?> 145 </tr> 146 <tr class="form-field"> 147 <th scope="row"><?php _ex( 'Registered', 'site' ) ?></th> 148 <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td> 149 </tr> 150 <tr class="form-field"> 151 <th scope="row"><?php _e('Last Updated') ?></th> 152 <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td> 153 </tr> 154 <?php 155 $radio_fields = array( 'public' => __( 'Public' ) ); 156 if ( ! $is_main_site ) { 157 $radio_fields['archived'] = __( 'Archived' ); 158 $radio_fields['spam'] = _x( 'Spam', 'site' ); 159 $radio_fields['deleted'] = __( 'Deleted' ); 160 } 161 $radio_fields['mature'] = __( 'Mature' ); 162 foreach ( $radio_fields as $field_key => $field_label ) { 163 ?> 164 <tr> 165 <th scope="row"><?php echo $field_label; ?></th> 166 <td> 167 <input type="radio" name="blog[<?php echo $field_key; ?>]" id="blog_<?php echo $field_key; ?>_1" value="1"<?php checked( $details->$field_key, 1 ); ?> /> 168 <label for="blog_<?php echo $field_key; ?>_1"><?php _e('Yes'); ?></label> 169 <input type="radio" name="blog[<?php echo $field_key; ?>]" id="blog_<?php echo $field_key; ?>_0" value="0"<?php checked( $details->$field_key, 0 ); ?> /> 170 <label for="blog_<?php echo $field_key; ?>_0"><?php _e('No'); ?></label> 171 </td> 172 </tr> 173 <?php } ?> 174 </table> 175 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 176 </div> 177 </div> 178 179 <div id="blogedit_blogoptions" class="postbox" > 180 <h3 class="hndle"><span><?php printf( __( 'Site options (%soptions)' ), $blog_prefix ); ?></span></h3> 181 <div class="inside"> 182 <table class="form-table"> 183 <?php 184 $editblog_default_role = 'subscriber'; 185 foreach ( $options as $option ) { 186 if ( $option->option_name == 'default_role' ) 187 $editblog_default_role = $option->option_value; 188 $disabled = false; 189 $class = 'all-options'; 190 if ( is_serialized( $option->option_value ) ) { 191 if ( is_serialized_string( $option->option_value ) ) { 192 $option->option_value = esc_html( maybe_unserialize( $option->option_value ), 'single' ); 193 } else { 194 $option->option_value = 'SERIALIZED DATA'; 195 $disabled = true; 196 $class = 'all-options disabled'; 197 } 198 } 199 if ( strpos( $option->option_value, "\n" ) !== false ) { 200 ?> 201 <tr class="form-field"> 202 <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th> 203 <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php echo wp_htmledit_pre( $option->option_value ) ?></textarea></td> 204 </tr> 205 <?php 206 } else { 207 ?> 208 <tr class="form-field"> 209 <th scope="row"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></th> 210 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?> 211 <td><code><?php echo esc_html( $option->option_value ) ?></code></td> 212 <?php } else { ?> 213 <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td> 214 <?php } ?> 215 </tr> 216 <?php 217 } 218 } // End foreach 219 ?> 220 </table> 221 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 222 </div> 223 </div> 224 </div> 225 226 <div class="metabox-holder" style="width:49%;float:right;"> 227 <?php 228 // Site Themes 229 $themes = get_themes(); 230 $blog_allowed_themes = wpmu_get_blog_allowedthemes( $id ); 231 $allowed_themes = get_site_option( 'allowedthemes' ); 232 233 if ( ! $allowed_themes ) 234 $allowed_themes = array_keys( $themes ); 235 236 $out = ''; 237 foreach ( $themes as $key => $theme ) { 238 $theme_key = esc_html( $theme['Stylesheet'] ); 239 if ( ! isset( $allowed_themes[$theme_key] ) ) { 240 $checked = isset( $blog_allowed_themes[ $theme_key ] ) ? 'checked="checked"' : ''; 241 $out .= '<tr class="form-field form-required"> 242 <th title="' . esc_attr( $theme["Description"] ).'" scope="row">' . esc_html( $key ) . '</th> 243 <td><label><input name="theme[' . esc_attr( $theme_key ) . ']" type="checkbox" style="width:20px;" value="on" '.$checked.'/> ' . __( 'Active' ) . '</label></td> 244 </tr>'; 245 } 246 } 247 248 if ( $out != '' ) { 249 ?> 250 <div id="blogedit_blogthemes" class="postbox"> 251 <h3 class="hndle"><span><?php esc_html_e( 'Site Themes' ); ?></span></h3> 252 <div class="inside"> 253 <p class="description"><?php _e( 'Activate the themename of an existing theme and hit "Update Options" to allow the theme for this site.' ) ?></p> 254 <table class="form-table"> 255 <?php echo $out; ?> 256 </table> 257 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 258 </div></div> 259 <?php } 260 261 // Site users 262 $blogusers = get_users_of_blog( $id ); 263 if ( is_array( $blogusers ) ) { 264 echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">'; 265 echo '<table class="form-table">'; 266 echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>"; 267 reset( $blogusers ); 268 foreach ( (array) $blogusers as $key => $val ) { 269 if ( isset( $val->meta_value ) && ! $val->meta_value ) 270 continue; 271 $t = @unserialize( $val->meta_value ); 272 if ( is_array( $t ) ) { 273 reset( $t ); 274 $existing_role = key( $t ); 275 } 276 echo '<tr><td><a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a></td>'; 277 if ( $val->user_id != $current_user->data->ID ) { 278 ?> 279 <td> 280 <select name="role[<?php echo $val->user_id ?>]" id="new_role_1"><?php 281 foreach ( $editblog_roles as $role => $role_assoc ){ 282 $name = translate_user_role( $role_assoc['name'] ); 283 echo '<option ' . selected( $role, $existing_role, false ) . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>'; 284 } 285 ?> 286 </select> 287 </td> 288 <td> 289 <input type="text" name="user_password[<?php echo esc_attr( $val->user_id ) ?>]" /> 290 </td> 291 <?php 292 echo '<td><input title="' . __( 'Click to remove user' ) . '" type="checkbox" name="blogusers[' . esc_attr( $val->user_id ) . ']" /></td>'; 293 } else { 294 echo "<td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __ ( 'N/A' ) . "</strong></td><td><strong>" . __( 'N/A' ) . "</strong></td>"; 295 } 296 echo '</tr>'; 297 } 298 echo "</table>"; 299 echo '<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="' . esc_attr__( 'Update Options' ) . '" /></p>'; 300 echo "</div></div>"; 301 } 302 ?> 303 304 <div id="blogedit_blogadduser" class="postbox"> 305 <h3 class="hndle"><span><?php _e( 'Add a new user' ); ?></span></h3> 306 <div class="inside"> 307 <p class="description"><?php _e( 'Enter the username of an existing user and hit “Update Options” to add the user.' ) ?></p> 308 <table class="form-table"> 309 <tr> 310 <th scope="row"><?php _e( 'User Login:' ) ?></th> 311 <td><input type="text" name="newuser" id="newuser" /></td> 312 </tr> 313 <tr> 314 <th scope="row"><?php _e( 'Role:' ) ?></th> 315 <td> 316 <select name="new_role" id="new_role_0"> 317 <?php 318 reset( $editblog_roles ); 319 foreach ( $editblog_roles as $role => $role_assoc ){ 320 $name = translate_user_role( $role_assoc['name'] ); 321 $selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : ''; 322 echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>'; 323 } 324 ?> 325 </select> 326 </td> 327 </tr> 328 </table> 329 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 330 </div> 331 </div> 332 333 <div id="blogedit_miscoptions" class="postbox"> 334 <h3 class="hndle"><span><?php _e( 'Misc Site Actions' ) ?></span></h3> 335 <div class="inside"> 336 <table class="form-table"> 337 <?php do_action( 'wpmueditblogaction', $id ); ?> 338 </table> 339 <p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Update Options' ) ?>" /></p> 340 </div> 341 </div> 342 </div> 343 344 <div style="clear:both;"></div> 345 </form> 346 </div> 347 <?php 348 break; 349 350 // List sites 351 case 'list': 352 default: 353 $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; 354 if ( empty($pagenum) ) 355 $pagenum = 1; 356 357 $per_page = (int) get_user_option( 'ms_sites_per_page' ); 358 if ( empty( $per_page ) || $per_page < 1 ) 359 $per_page = 15; 360 361 $per_page = apply_filters( 'ms_sites_per_page', $per_page ); 362 363 $s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : ''; 364 $like_s = esc_sql( like_escape( $s ) ); 365 366 $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; 367 368 if ( isset( $_GET['searchaction'] ) ) { 369 if ( 'name' == $_GET['searchaction'] ) { 370 $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) "; 371 } elseif ( 'id' == $_GET['searchaction'] ) { 372 $query .= " AND {$wpdb->blogs}.blog_id = '{$like_s}' "; 373 } elseif ( 'ip' == $_GET['searchaction'] ) { 374 $query = "SELECT * 375 FROM {$wpdb->blogs}, {$wpdb->registration_log} 376 WHERE site_id = '{$wpdb->siteid}' 377 AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id 378 AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')"; 379 } 380 } 381 382 $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id'; 383 if ( $order_by == 'registered' ) { 384 $query .= ' ORDER BY registered '; 385 } elseif ( $order_by == 'lastupdated' ) { 386 $query .= ' ORDER BY last_updated '; 387 } elseif ( $order_by == 'blogname' ) { 388 $query .= ' ORDER BY domain '; 389 } else { 390 $order_by = 'id'; 391 $query .= " ORDER BY {$wpdb->blogs}.blog_id "; 392 } 393 394 $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? "DESC" : "ASC"; 395 $query .= $order; 396 397 $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(blog_id)', $query ) ); 398 399 $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page ); 400 $blog_list = $wpdb->get_results( $query, ARRAY_A ); 401 402 $num_pages = ceil($total / $per_page); 403 $page_links = paginate_links( array( 404 'base' => add_query_arg( 'paged', '%#%' ), 405 'format' => '', 406 'prev_text' => __( '«' ), 407 'next_text' => __( '»' ), 408 'total' => $num_pages, 409 'current' => $pagenum 410 )); 411 412 if ( empty( $_GET['mode'] ) ) 413 $mode = 'list'; 414 else 415 $mode = esc_attr( $_GET['mode'] ); 416 ?> 417 418 <div class="wrap"> 419 <?php screen_icon(); ?> 420 <h2><?php _e('Sites') ?> 421 <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a> 422 <?php 423 if ( isset( $_GET['s'] ) && $_GET['s'] ) 424 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); 425 ?> 426 </h2> 427 428 <form action="sites.php" method="get" id="ms-search"> 429 <p class="search-box"> 430 <input type="hidden" name="action" value="blogs" /> 431 <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" /> 432 <input type="submit" class="button" value="<?php esc_attr_e( 'Search Site by' ) ?>" /> 433 <select name="searchaction"> 434 <option value="name" selected="selected"><?php _e( 'Name' ); ?></option> 435 <option value="id"><?php _e( 'ID' ); ?></option> 436 <option value="ip"><?php _e( 'IP address' ); ?></option> 437 </select> 438 </p> 439 </form> 440 441 <form id="form-site-list" action="edit.php?action=allblogs" method="post"> 442 <input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" /> 443 <div class="tablenav"> 444 <div class="alignleft actions"> 445 <select name="action"> 446 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 447 <option value="delete"><?php _e( 'Delete' ); ?></option> 448 <option value="spam"><?php _ex( 'Mark as Spam', 'site' ); ?></option> 449 <option value="notspam"><?php _ex( 'Not Spam', 'site' ); ?></option> 450 </select> 451 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" /> 452 <?php wp_nonce_field( 'bulk-ms-sites', '_wpnonce_bulk-ms-sites' ); ?> 453 </div> 454 455 <?php if ( $page_links ) { ?> 456 <div class="tablenav-pages"> 457 <?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 458 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), 459 number_format_i18n( min( $pagenum * $per_page, $total ) ), 460 number_format_i18n( $total ), 461 $page_links 462 ); echo $page_links_text; ?> 463 </div> 464 <?php } ?> 465 466 <div class="view-switch"> 467 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a> 468 <a href="<?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a> 469 </div> 470 471 </div> 472 473 <div class="clear"></div> 474 475 <?php 476 // define the columns to display, the syntax is 'internal name' => 'display name' 477 $blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' ); 478 $sites_columns = array( 479 'id' => __( 'ID' ), 480 'blogname' => $blogname_columns, 481 'lastupdated' => __( 'Last Updated'), 482 'registered' => _x( 'Registered', 'site' ), 483 'users' => __( 'Users' ) 484 ); 485 486 if ( has_filter( 'wpmublogsaction' ) ) 487 $sites_columns['plugins'] = __( 'Actions' ); 488 489 $sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns ); 490 ?> 491 492 <table class="widefat"> 493 <thead> 494 <tr> 495 <th class="manage-column column-cb check-column" id="cb" scope="col"> 496 <input type="checkbox" /> 497 </th> 498 <?php 499 $col_url = ''; 500 foreach($sites_columns as $column_id => $column_display_name) { 501 $column_link = "<a href='"; 502 $order2 = ''; 503 if ( $order_by == $column_id ) 504 $order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC'; 505 506 $column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array('action', 'updated'), $_SERVER['REQUEST_URI'] ) ) ); 507 $column_link .= "'>{$column_display_name}</a>"; 508 $col_url .= '<th scope="col">' . ( ( $column_id == 'users' || $column_id == 'plugins' ) ? $column_display_name : $column_link ) . '</th>'; 509 } 510 echo $col_url ?> 511 </tr> 512 </thead> 513 <tfoot> 514 <tr> 515 <th class="manage-column column-cb check-column" id="cb1" scope="col"> 516 <input type="checkbox" /> 517 </th> 518 <?php echo $col_url ?> 519 </tr> 520 </tfoot> 521 <tbody id="the-site-list" class="list:site"> 522 <?php 523 $status_list = array( 'archived' => array( 'site-archived', __( 'Archived' ) ), 'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ), 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), 'mature' => array( 'site-mature', __( 'Mature' ) ) ); 524 if ( $blog_list ) { 525 $class = ''; 526 foreach ( $blog_list as $blog ) { 527 $class = ( 'alternate' == $class ) ? '' : 'alternate'; 528 reset( $status_list ); 529 530 $blog_states = array(); 531 foreach ( $status_list as $status => $col ) { 532 if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) { 533 $class = $col[0]; 534 $blog_states[] = $col[1]; 535 } 536 } 537 $blog_state = ''; 538 if ( ! empty( $blog_states ) ) { 539 $state_count = count( $blog_states ); 540 $i = 0; 541 $blog_state .= ' - '; 542 foreach ( $blog_states as $state ) { 543 ++$i; 544 ( $i == $state_count ) ? $sep = '' : $sep = ', '; 545 $blog_state .= "<span class='post-state'>$state$sep</span>"; 546 } 547 } 548 echo "<tr class='$class'>"; 549 550 $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path']; 551 foreach ( $sites_columns as $column_name=>$column_display_name ) { 552 switch ( $column_name ) { 553 case 'id': ?> 554 <th scope="row" class="check-column"> 555 <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" /> 556 </th> 557 <th valign="top" scope="row"> 558 <?php echo $blog['blog_id'] ?> 559 </th> 560 <?php 561 break; 562 563 case 'blogname': ?> 564 <td class="column-title"> 565 <a href="<?php echo esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a> 566 <?php 567 if ( 'list' != $mode ) 568 echo '<p>' . sprintf( _x( '%1$s – <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '</p>'; 569 570 // Preordered. 571 $actions = array( 572 'edit' => '', 'backend' => '', 573 'activate' => '', 'deactivate' => '', 574 'archive' => '', 'unarchive' => '', 575 'spam' => '', 'unspam' => '', 576 'delete' => '', 577 'visit' => '', 578 ); 579 580 $actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>'; 581 $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url($blog['blog_id']) ) . "' class='edit'>" . __( 'Backend' ) . '</a></span>'; 582 if ( $current_site->blog_id != $blog['blog_id'] ) { 583 if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' ) 584 $actions['activate'] = '<span class="activate"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ) ) . '">' . __( 'Activate' ) . '</a></span>'; 585 else 586 $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ) ) . '">' . __( 'Deactivate' ) . '</a></span>'; 587 588 if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' ) 589 $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ) ) . '">' . __( 'Unarchive' ) . '</a></span>'; 590 else 591 $actions['archive'] = '<span class="archive"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>'; 592 593 if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' ) 594 $actions['unspam'] = '<span class="spam"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>'; 595 else 596 $actions['spam'] = '<span class="spam"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>'; 597 598 $actions['delete'] = '<span class="delete"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ) ) . '">' . __( 'Delete' ) . '</a></span>'; 599 } 600 601 $actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'] ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>'; 602 $actions = array_filter( $actions ); 603 if ( count( $actions ) ) : ?> 604 <div class="row-actions"> 605 <?php echo implode( ' | ', $actions ); ?> 606 </div> 607 <?php endif; ?> 608 </td> 609 <?php 610 break; 611 612 case 'lastupdated': ?> 613 <td valign="top"> 614 <?php 615 if ( 'list' == $mode ) 616 $date = 'Y/m/d'; 617 else 618 $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 619 echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( __( $date ), $blog['last_updated'] ); ?> 620 </td> 621 <?php 622 break; 623 case 'registered': ?> 624 <td valign="top"> 625 <?php 626 if ( $blog['registered'] == '0000-00-00 00:00:00' ) 627 echo '—'; 628 else 629 echo mysql2date( __( $date ), $blog['registered'] ); 630 ?> 631 </td> 632 <?php 633 break; 634 case 'users': ?> 635 <td valign="top"> 636 <?php 637 $blogusers = get_users_of_blog( $blog['blog_id'] ); 638 if ( is_array( $blogusers ) ) { 639 $blogusers_warning = ''; 640 if ( count( $blogusers ) > 5 ) { 641 $blogusers = array_slice( $blogusers, 0, 5 ); 642 $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( get_admin_url( $blog['blog_id'], 'users.php' ) ) . '">' . __( 'More' ) . '</a>'; 643 } 644 foreach ( $blogusers as $key => $val ) { 645 echo '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $val->user_id ) ) . '">' . esc_html( $val->user_login ) . '</a> '; 646 if ( 'list' != $mode ) 647 echo '(' . $val->user_email . ')'; 648 echo '<br />'; 649 } 650 if ( $blogusers_warning != '' ) 651 echo '<strong>' . $blogusers_warning . '</strong><br />'; 652 } 653 ?> 654 </td> 655 <?php 656 break; 657 658 case 'plugins': ?> 659 <?php if ( has_filter( 'wpmub