wp/wp-admin/includes/ms.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    33 	if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
    33 	if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
    34 		$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
    34 		$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
    35 	if ( upload_is_user_over_quota( false ) ) {
    35 	if ( upload_is_user_over_quota( false ) ) {
    36 		$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
    36 		$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
    37 	}
    37 	}
    38 	if ( $file['error'] != '0' && !isset($_POST['html-upload']) )
    38 	if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
    39 		wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
    39 		wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
       
    40 	}
    40 
    41 
    41 	return $file;
    42 	return $file;
    42 }
    43 }
    43 add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
    44 add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
    44 
    45 
    45 /**
    46 /**
    46  * Delete a blog
    47  * Delete a blog.
    47  *
    48  *
    48  * @since 3.0.0
    49  * @since 3.0.0
    49  *
    50  *
    50  * @param int $blog_id Blog ID
    51  * @param int  $blog_id Blog ID.
    51  * @param bool $drop True if blog's table should be dropped. Default is false.
    52  * @param bool $drop    True if blog's table should be dropped. Default is false.
    52  * @return void
       
    53  */
    53  */
    54 function wpmu_delete_blog( $blog_id, $drop = false ) {
    54 function wpmu_delete_blog( $blog_id, $drop = false ) {
    55 	global $wpdb, $current_site;
    55 	global $wpdb;
    56 
    56 
    57 	$switch = false;
    57 	$switch = false;
    58 	if ( get_current_blog_id() != $blog_id ) {
    58 	if ( get_current_blog_id() != $blog_id ) {
    59 		$switch = true;
    59 		$switch = true;
    60 		switch_to_blog( $blog_id );
    60 		switch_to_blog( $blog_id );
    80 		}
    80 		}
    81 	}
    81 	}
    82 
    82 
    83 	update_blog_status( $blog_id, 'deleted', 1 );
    83 	update_blog_status( $blog_id, 'deleted', 1 );
    84 
    84 
       
    85 	$current_site = get_current_site();
       
    86 
       
    87 	// If a full blog object is not available, do not destroy anything.
       
    88 	if ( $drop && ! $blog ) {
       
    89 		$drop = false;
       
    90 	}
       
    91 
    85 	// Don't destroy the initial, main, or root blog.
    92 	// Don't destroy the initial, main, or root blog.
    86 	if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) )
    93 	if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) ) {
    87 		$drop = false;
    94 		$drop = false;
       
    95 	}
       
    96 
       
    97 	$upload_path = trim( get_option( 'upload_path' ) );
       
    98 
       
    99 	// If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable.
       
   100 	if ( $drop && get_site_option( 'ms_files_rewriting' ) && empty( $upload_path ) ) {
       
   101 		$drop = false;
       
   102 	}
    88 
   103 
    89 	if ( $drop ) {
   104 	if ( $drop ) {
       
   105 		$uploads = wp_upload_dir();
       
   106 
    90 		$tables = $wpdb->tables( 'blog' );
   107 		$tables = $wpdb->tables( 'blog' );
    91 		/**
   108 		/**
    92 		 * Filter the tables to drop when the blog is deleted.
   109 		 * Filter the tables to drop when the blog is deleted.
    93 		 *
   110 		 *
    94 		 * @since MU
   111 		 * @since MU
   102 			$wpdb->query( "DROP TABLE IF EXISTS `$table`" );
   119 			$wpdb->query( "DROP TABLE IF EXISTS `$table`" );
   103 		}
   120 		}
   104 
   121 
   105 		$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
   122 		$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
   106 
   123 
   107 		$uploads = wp_upload_dir();
       
   108 		/**
   124 		/**
   109 		 * Filter the upload base directory to delete when the blog is deleted.
   125 		 * Filter the upload base directory to delete when the blog is deleted.
   110 		 *
   126 		 *
   111 		 * @since MU
   127 		 * @since MU
   112 		 *
   128 		 *
   118 		$top_dir = $dir;
   134 		$top_dir = $dir;
   119 		$stack = array($dir);
   135 		$stack = array($dir);
   120 		$index = 0;
   136 		$index = 0;
   121 
   137 
   122 		while ( $index < count( $stack ) ) {
   138 		while ( $index < count( $stack ) ) {
   123 			# Get indexed directory from stack
   139 			// Get indexed directory from stack
   124 			$dir = $stack[$index];
   140 			$dir = $stack[$index];
   125 
   141 
   126 			$dh = @opendir( $dir );
   142 			$dh = @opendir( $dir );
   127 			if ( $dh ) {
   143 			if ( $dh ) {
   128 				while ( ( $file = @readdir( $dh ) ) !== false ) {
   144 				while ( ( $file = @readdir( $dh ) ) !== false ) {
   129 					if ( $file == '.' || $file == '..' )
   145 					if ( $file == '.' || $file == '..' )
   130 						continue;
   146 						continue;
   131 
   147 
   132 					if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) )
   148 					if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
   133 						$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
   149 						$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
   134 					else if ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) )
   150 					} elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
   135 						@unlink( $dir . DIRECTORY_SEPARATOR . $file );
   151 						@unlink( $dir . DIRECTORY_SEPARATOR . $file );
       
   152 					}
   136 				}
   153 				}
   137 				@closedir( $dh );
   154 				@closedir( $dh );
   138 			}
   155 			}
   139 			$index++;
   156 			$index++;
   140 		}
   157 		}
   150 
   167 
   151 	if ( $switch )
   168 	if ( $switch )
   152 		restore_current_blog();
   169 		restore_current_blog();
   153 }
   170 }
   154 
   171 
   155 // @todo Merge with wp_delete_user() ?
   172 /**
       
   173  * Delete a user from the network and remove from all sites.
       
   174  *
       
   175  * @since 3.0.0
       
   176  *
       
   177  * @todo Merge with wp_delete_user() ?
       
   178  *
       
   179  * @param int $id The user ID.
       
   180  * @return bool True if the user was deleted, otherwise false.
       
   181  */
   156 function wpmu_delete_user( $id ) {
   182 function wpmu_delete_user( $id ) {
   157 	global $wpdb;
   183 	global $wpdb;
   158 
   184 
   159 	$id = (int) $id;
   185 	$id = (int) $id;
   160 	$user = new WP_User( $id );
   186 	$user = new WP_User( $id );
   200 
   226 
   201 	$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
   227 	$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
   202 
   228 
   203 	clean_user_cache( $user );
   229 	clean_user_cache( $user );
   204 
   230 
   205 	/**
   231 	/** This action is documented in wp-admin/includes/user.php */
   206 	 * Fires after the user is deleted from the network.
       
   207 	 *
       
   208 	 * @since 2.8.0
       
   209 	 *
       
   210 	 * @param int $id ID of the user that was deleted from the network.
       
   211 	 */
       
   212 	do_action( 'deleted_user', $id );
   232 	do_action( 'deleted_user', $id );
   213 
   233 
   214 	return true;
   234 	return true;
   215 }
   235 }
   216 
   236 
       
   237 /**
       
   238  * Sends an email when a site administrator email address is changed.
       
   239  *
       
   240  * @since 3.0.0
       
   241  *
       
   242  * @param string $old_value The old email address. Not currently used.
       
   243  * @param string $value     The new email address.
       
   244  */
   217 function update_option_new_admin_email( $old_value, $value ) {
   245 function update_option_new_admin_email( $old_value, $value ) {
   218 	$email = get_option( 'admin_email' );
       
   219 	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
   246 	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
   220 		return;
   247 		return;
   221 
   248 
   222 	$hash = md5( $value. time() .mt_rand() );
   249 	$hash = md5( $value. time() .mt_rand() );
   223 	$new_admin_email = array(
   250 	$new_admin_email = array(
   224 		'hash' => $hash,
   251 		'hash' => $hash,
   225 		'newemail' => $value
   252 		'newemail' => $value
   226 	);
   253 	);
   227 	update_option( 'adminhash', $new_admin_email );
   254 	update_option( 'adminhash', $new_admin_email );
   228 
   255 
   229 	$email_text = __( 'Dear user,
   256 	$email_text = __( 'Howdy ###USERNAME###,
   230 
   257 
   231 You recently requested to have the administration email address on
   258 You recently requested to have the administration email address on
   232 your site changed.
   259 your site changed.
       
   260 
   233 If this is correct, please click on the following link to change it:
   261 If this is correct, please click on the following link to change it:
   234 ###ADMIN_URL###
   262 ###ADMIN_URL###
   235 
   263 
   236 You can safely ignore and delete this email if you do not want to
   264 You can safely ignore and delete this email if you do not want to
   237 take this action.
   265 take this action.
   244 
   272 
   245 	/**
   273 	/**
   246 	 * Filter the email text sent when the site admin email is changed.
   274 	 * Filter the email text sent when the site admin email is changed.
   247 	 *
   275 	 *
   248 	 * The following strings have a special meaning and will get replaced dynamically:
   276 	 * The following strings have a special meaning and will get replaced dynamically:
   249 	 * ###ADMIN_URL### The link to click on to confirm the email change. Required otherwise this functunalty is will break.
   277 	 * ###USERNAME###  The current user's username.
       
   278 	 * ###ADMIN_URL### The link to click on to confirm the email change.
   250 	 * ###EMAIL###     The new email.
   279 	 * ###EMAIL###     The new email.
   251 	 * ###SITENAME###  The name of the site.
   280 	 * ###SITENAME###  The name of the site.
   252 	 * ###SITEURL###   The URL to the site.
   281 	 * ###SITEURL###   The URL to the site.
   253 	 *
   282 	 *
   254 	 * @since MU
   283 	 * @since MU
   256 	 * @param string $email_text      Text in the email.
   285 	 * @param string $email_text      Text in the email.
   257 	 * @param string $new_admin_email New admin email that the current administration email was changed to.
   286 	 * @param string $new_admin_email New admin email that the current administration email was changed to.
   258 	 */
   287 	 */
   259 	$content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
   288 	$content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
   260 
   289 
       
   290 	$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
   261 	$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content );
   291 	$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content );
   262 	$content = str_replace( '###EMAIL###', $value, $content );
   292 	$content = str_replace( '###EMAIL###', $value, $content );
   263 	$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
   293 	$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
   264 	$content = str_replace( '###SITEURL###', network_home_url(), $content );
   294 	$content = str_replace( '###SITEURL###', network_home_url(), $content );
   265 
   295 
   266 	wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), get_option( 'blogname' ) ), $content );
   296 	wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
   267 }
   297 }
   268 add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
   298 add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
   269 add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
   299 add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
   270 
   300 
       
   301 /**
       
   302  * Sends an email when an email address change is requested.
       
   303  *
       
   304  * @since 3.0.0
       
   305  *
       
   306  * @global object $errors WP_Error object.
       
   307  * @global object $wpdb   WordPress database object.
       
   308  */
   271 function send_confirmation_on_profile_email() {
   309 function send_confirmation_on_profile_email() {
   272 	global $errors, $wpdb;
   310 	global $errors, $wpdb;
   273 	$current_user = wp_get_current_user();
   311 	$current_user = wp_get_current_user();
   274 	if ( ! is_object($errors) )
   312 	if ( ! is_object($errors) )
   275 		$errors = new WP_Error();
   313 		$errors = new WP_Error();
   294 				'hash' => $hash,
   332 				'hash' => $hash,
   295 				'newemail' => $_POST['email']
   333 				'newemail' => $_POST['email']
   296 				);
   334 				);
   297 		update_option( $current_user->ID . '_new_email', $new_user_email );
   335 		update_option( $current_user->ID . '_new_email', $new_user_email );
   298 
   336 
   299 		$email_text = __( 'Dear user,
   337 		$email_text = __( 'Howdy ###USERNAME###,
   300 
   338 
   301 You recently requested to have the email address on your account changed.
   339 You recently requested to have the email address on your account changed.
       
   340 
   302 If this is correct, please click on the following link to change it:
   341 If this is correct, please click on the following link to change it:
   303 ###ADMIN_URL###
   342 ###ADMIN_URL###
   304 
   343 
   305 You can safely ignore and delete this email if you do not want to
   344 You can safely ignore and delete this email if you do not want to
   306 take this action.
   345 take this action.
   313 
   352 
   314 		/**
   353 		/**
   315 		 * Filter the email text sent when a user changes emails.
   354 		 * Filter the email text sent when a user changes emails.
   316 		 *
   355 		 *
   317 		 * The following strings have a special meaning and will get replaced dynamically:
   356 		 * The following strings have a special meaning and will get replaced dynamically:
   318 		 * ###ADMIN_URL### The link to click on to confirm the email change. Required otherwise this functunalty is will break.
   357 		 * ###USERNAME###  The current user's username.
   319 		 * ###EMAIL### The new email.
   358 		 * ###ADMIN_URL### The link to click on to confirm the email change.
   320 		 * ###SITENAME### The name of the site.
   359 		 * ###EMAIL###     The new email.
   321 		 * ###SITEURL### The URL to the site.
   360 		 * ###SITENAME###  The name of the site.
       
   361 		 * ###SITEURL###   The URL to the site.
   322 		 *
   362 		 *
   323 		 * @since MU
   363 		 * @since MU
   324 		 *
   364 		 *
   325 		 * @param string $email_text     Text in the email.
   365 		 * @param string $email_text     Text in the email.
   326 		 * @param string $new_user_email New user email that the current user has changed to.
   366 		 * @param string $new_user_email New user email that the current user has changed to.
   327 		 */
   367 		 */
   328 		$content = apply_filters( 'new_user_email_content', $email_text, $new_user_email );
   368 		$content = apply_filters( 'new_user_email_content', $email_text, $new_user_email );
   329 
   369 
       
   370 		$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
   330 		$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
   371 		$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
   331 		$content = str_replace( '###EMAIL###', $_POST['email'], $content);
   372 		$content = str_replace( '###EMAIL###', $_POST['email'], $content);
   332 		$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
   373 		$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
   333 		$content = str_replace( '###SITEURL###', network_home_url(), $content );
   374 		$content = str_replace( '###SITEURL###', network_home_url(), $content );
   334 
   375 
   335 		wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), get_option( 'blogname' ) ), $content );
   376 		wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
   336 		$_POST['email'] = $current_user->user_email;
   377 		$_POST['email'] = $current_user->user_email;
   337 	}
   378 	}
   338 }
   379 }
   339 add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
   380 add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
   340 
   381 
       
   382 /**
       
   383  * Adds an admin notice alerting the user to check for confirmation email
       
   384  * after email address change.
       
   385  *
       
   386  * @since 3.0.0
       
   387  */
   341 function new_user_email_admin_notice() {
   388 function new_user_email_admin_notice() {
   342 	if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
   389 	if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
   343 		echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
   390 		echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
   344 }
   391 }
   345 add_action( 'admin_notices', 'new_user_email_admin_notice' );
   392 add_action( 'admin_notices', 'new_user_email_admin_notice' );
   348  * Check whether a blog has used its allotted upload space.
   395  * Check whether a blog has used its allotted upload space.
   349  *
   396  *
   350  * @since MU
   397  * @since MU
   351  *
   398  *
   352  * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
   399  * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
   353  * @return int
   400  * @return bool True if user is over upload space quota, otherwise false.
   354  */
   401  */
   355 function upload_is_user_over_quota( $echo = true ) {
   402 function upload_is_user_over_quota( $echo = true ) {
   356 	if ( get_site_option( 'upload_space_check_disabled' ) )
   403 	if ( get_site_option( 'upload_space_check_disabled' ) )
   357 		return false;
   404 		return false;
   358 
   405 
   398 
   445 
   399 /**
   446 /**
   400  * Get the remaining upload space for this blog.
   447  * Get the remaining upload space for this blog.
   401  *
   448  *
   402  * @since MU
   449  * @since MU
   403  * @uses upload_is_user_over_quota()
       
   404  * @uses get_space_allowed()
       
   405  * @uses get_upload_space_available()
       
   406  *
   450  *
   407  * @param int $size Current max size in bytes
   451  * @param int $size Current max size in bytes
   408  * @return int Max size in bytes
   452  * @return int Max size in bytes
   409  */
   453  */
   410 function fix_import_form_size( $size ) {
   454 function fix_import_form_size( $size ) {
   413 
   457 
   414 	$available = get_upload_space_available();
   458 	$available = get_upload_space_available();
   415 	return min( $size, $available );
   459 	return min( $size, $available );
   416 }
   460 }
   417 
   461 
   418 // Edit blog upload space setting on Edit Blog page
   462 /**
       
   463  * Displays the edit blog upload space setting form on the Edit Blog screen.
       
   464  *
       
   465  * @since 3.0.0
       
   466  *
       
   467  * @param int $id The ID of the blog to display the setting for.
       
   468  */
   419 function upload_space_setting( $id ) {
   469 function upload_space_setting( $id ) {
   420 	switch_to_blog( $id );
   470 	switch_to_blog( $id );
   421 	$quota = get_option( 'blog_upload_space' );
   471 	$quota = get_option( 'blog_upload_space' );
   422 	restore_current_blog();
   472 	restore_current_blog();
   423 
   473 
   424 	if ( !$quota )
   474 	if ( !$quota )
   425 		$quota = '';
   475 		$quota = '';
   426 
   476 
   427 	?>
   477 	?>
   428 	<tr>
   478 	<tr>
   429 		<th><?php _e( 'Site Upload Space Quota '); ?></th>
   479 		<th><label for="blog-upload-space-number"><?php _e( 'Site Upload Space Quota' ); ?></label></th>
   430 		<td><input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" value="<?php echo $quota; ?>" /> <?php _e( 'MB (Leave blank for network default)' ); ?></td>
   480 		<td>
       
   481 			<input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" id="blog-upload-space-number" aria-describedby="blog-upload-space-desc" value="<?php echo $quota; ?>" />
       
   482 			<span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e( 'Size in megabytes' ); ?></span> <?php _e( 'MB (Leave blank for network default)' ); ?></span>
       
   483 		</td>
   431 	</tr>
   484 	</tr>
   432 	<?php
   485 	<?php
   433 }
   486 }
   434 add_action( 'wpmueditblogaction', 'upload_space_setting' );
   487 add_action( 'wpmueditblogaction', 'upload_space_setting' );
   435 
   488 
       
   489 /**
       
   490  * Update the status of a user in the database.
       
   491  *
       
   492  * Used in core to mark a user as spam or "ham" (not spam) in Multisite.
       
   493  *
       
   494  * @since 3.0.0
       
   495  *
       
   496  * @param int    $id         The user ID.
       
   497  * @param string $pref       The column in the wp_users table to update the user's status
       
   498  *                           in (presumably user_status, spam, or deleted).
       
   499  * @param int    $value      The new status for the user.
       
   500  * @param null   $deprecated Deprecated as of 3.0.2 and should not be used.
       
   501  * @return int   The initially passed $value.
       
   502  */
   436 function update_user_status( $id, $pref, $value, $deprecated = null ) {
   503 function update_user_status( $id, $pref, $value, $deprecated = null ) {
   437 	global $wpdb;
   504 	global $wpdb;
   438 
   505 
   439 	if ( null !== $deprecated )
   506 	if ( null !== $deprecated )
   440 		_deprecated_argument( __FUNCTION__, '3.1' );
   507 		_deprecated_argument( __FUNCTION__, '3.1' );
   467 	}
   534 	}
   468 
   535 
   469 	return $value;
   536 	return $value;
   470 }
   537 }
   471 
   538 
       
   539 /**
       
   540  * Cleans the user cache for a specific user.
       
   541  *
       
   542  * @since 3.0.0
       
   543  *
       
   544  * @param int $id The user ID.
       
   545  * @return bool|int The ID of the refreshed user or false if the user does not exist.
       
   546  */
   472 function refresh_user_details( $id ) {
   547 function refresh_user_details( $id ) {
   473 	$id = (int) $id;
   548 	$id = (int) $id;
   474 
   549 
   475 	if ( !$user = get_userdata( $id ) )
   550 	if ( !$user = get_userdata( $id ) )
   476 		return false;
   551 		return false;
   478 	clean_user_cache( $user );
   553 	clean_user_cache( $user );
   479 
   554 
   480 	return $id;
   555 	return $id;
   481 }
   556 }
   482 
   557 
       
   558 /**
       
   559  * Returns the language for a language code.
       
   560  *
       
   561  * @since 3.0.0
       
   562  *
       
   563  * @param string $code Optional. The two-letter language code. Default empty.
       
   564  * @return string The language corresponding to $code if it exists. If it does not exist,
       
   565  *                then the first two letters of $code is returned.
       
   566  */
   483 function format_code_lang( $code = '' ) {
   567 function format_code_lang( $code = '' ) {
   484 	$code = strtolower( substr( $code, 0, 2 ) );
   568 	$code = strtolower( substr( $code, 0, 2 ) );
   485 	$lang_codes = array(
   569 	$lang_codes = array(
   486 		'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali',
   570 		'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali',
   487 		'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree',
   571 		'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree',
   505 	 */
   589 	 */
   506 	$lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
   590 	$lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
   507 	return strtr( $code, $lang_codes );
   591 	return strtr( $code, $lang_codes );
   508 }
   592 }
   509 
   593 
       
   594 /**
       
   595  * Synchronize category and post tag slugs when global terms are enabled.
       
   596  *
       
   597  * @since 3.0.0
       
   598  *
       
   599  * @param object $term     The term.
       
   600  * @param string $taxonomy The taxonomy for $term. Should be 'category' or 'post_tag', as these are
       
   601  *                         the only taxonomies which are processed by this function; anything else
       
   602  *                         will be returned untouched.
       
   603  * @return object|array Returns `$term`, after filtering the 'slug' field with {@see sanitize_title()}
       
   604  *                      if $taxonomy is 'category' or 'post_tag'.
       
   605  */
   510 function sync_category_tag_slugs( $term, $taxonomy ) {
   606 function sync_category_tag_slugs( $term, $taxonomy ) {
   511 	if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
   607 	if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
   512 		if ( is_object( $term ) ) {
   608 		if ( is_object( $term ) ) {
   513 			$term->slug = sanitize_title( $term->name );
   609 			$term->slug = sanitize_title( $term->name );
   514 		} else {
   610 		} else {
   517 	}
   613 	}
   518 	return $term;
   614 	return $term;
   519 }
   615 }
   520 add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
   616 add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
   521 
   617 
       
   618 /**
       
   619  * Displays an access denied message when a user tries to view a site's dashboard they
       
   620  * do not have access to.
       
   621  *
       
   622  * @since 3.2.0
       
   623  * @access private
       
   624  */
   522 function _access_denied_splash() {
   625 function _access_denied_splash() {
   523 	if ( ! is_user_logged_in() || is_network_admin() )
   626 	if ( ! is_user_logged_in() || is_network_admin() )
   524 		return;
   627 		return;
   525 
   628 
   526 	$blogs = get_blogs_of_user( get_current_user_id() );
   629 	$blogs = get_blogs_of_user( get_current_user_id() );
   529 		return;
   632 		return;
   530 
   633 
   531 	$blog_name = get_bloginfo( 'name' );
   634 	$blog_name = get_bloginfo( 'name' );
   532 
   635 
   533 	if ( empty( $blogs ) )
   636 	if ( empty( $blogs ) )
   534 		wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) );
   637 		wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
   535 
   638 
   536 	$output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
   639 	$output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
   537 	$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
   640 	$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
   538 
   641 
   539 	$output .= '<h3>' . __('Your Sites') . '</h3>';
   642 	$output .= '<h3>' . __('Your Sites') . '</h3>';
   540 	$output .= '<table>';
   643 	$output .= '<table>';
   541 
   644 
   542 	foreach ( $blogs as $blog ) {
   645 	foreach ( $blogs as $blog ) {
   543 		$output .= "<tr>";
   646 		$output .= '<tr>';
   544 		$output .= "<td valign='top'>";
   647 		$output .= "<td>{$blog->blogname}</td>";
   545 		$output .= "{$blog->blogname}";
   648 		$output .= '<td><a href="' . esc_url( get_admin_url( $blog->userblog_id ) ) . '">' . __( 'Visit Dashboard' ) . '</a> | ' .
   546 		$output .= "</td>";
   649 			'<a href="' . esc_url( get_home_url( $blog->userblog_id ) ). '">' . __( 'View Site' ) . '</a></td>';
   547 		$output .= "<td valign='top'>";
   650 		$output .= '</tr>';
   548 		$output .= "<a href='" . esc_url( get_admin_url( $blog->userblog_id ) ) . "'>" . __( 'Visit Dashboard' ) . "</a> | <a href='" . esc_url( get_home_url( $blog->userblog_id ) ). "'>" . __( 'View Site' ) . "</a>" ;
   651 	}
   549 		$output .= "</td>";
   652 
   550 		$output .= "</tr>";
       
   551 	}
       
   552 	$output .= '</table>';
   653 	$output .= '</table>';
   553 
   654 
   554 	wp_die( $output );
   655 	wp_die( $output, 403 );
   555 }
   656 }
   556 add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
   657 add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
   557 
   658 
       
   659 /**
       
   660  * Checks if the current user has permissions to import new users.
       
   661  *
       
   662  * @since 3.0.0
       
   663  *
       
   664  * @param string $permission A permission to be checked. Currently not used.
       
   665  * @return bool True if the user has proper permissions, false if they do not.
       
   666  */
   558 function check_import_new_users( $permission ) {
   667 function check_import_new_users( $permission ) {
   559 	if ( !is_super_admin() )
   668 	if ( !is_super_admin() )
   560 		return false;
   669 		return false;
   561 	return true;
   670 	return true;
   562 }
   671 }
   563 add_filter( 'import_allow_create_users', 'check_import_new_users' );
   672 add_filter( 'import_allow_create_users', 'check_import_new_users' );
   564 // See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too.
   673 // See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too.
   565 
   674 
       
   675 /**
       
   676  * Generates and displays a drop-down of available languages.
       
   677  *
       
   678  * @since 3.0.0
       
   679  *
       
   680  * @param array  $lang_files Optional. An array of the language files. Default empty array.
       
   681  * @param string $current    Optional. The current language code. Default empty.
       
   682  */
   566 function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
   683 function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
   567 	$flag = false;
   684 	$flag = false;
   568 	$output = array();
   685 	$output = array();
   569 
   686 
   570 	foreach ( (array) $lang_files as $val ) {
   687 	foreach ( (array) $lang_files as $val ) {
   588 	if ( $flag === false ) // WordPress english
   705 	if ( $flag === false ) // WordPress english
   589 		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
   706 		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
   590 
   707 
   591 	// Order by name
   708 	// Order by name
   592 	uksort( $output, 'strnatcasecmp' );
   709 	uksort( $output, 'strnatcasecmp' );
       
   710 
   593 	/**
   711 	/**
   594 	 * Filter the languages available in the dropdown.
   712 	 * Filter the languages available in the dropdown.
   595 	 *
   713 	 *
   596 	 * @since MU
   714 	 * @since MU
   597 	 *
   715 	 *
   598 	 * @param array $output     HTML output of the dropdown.
   716 	 * @param array $output     HTML output of the dropdown.
   599 	 * @param array $lang_files Available language files.
   717 	 * @param array $lang_files Available language files.
   600 	 * @param string $current   The current language code.
   718 	 * @param string $current   The current language code.
   601 	 */
   719 	 */
   602 	$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
   720 	$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
       
   721 
   603 	echo implode( "\n\t", $output );
   722 	echo implode( "\n\t", $output );
   604 }
   723 }
   605 
   724 
       
   725 /**
       
   726  * Displays an admin notice to upgrade all sites after a core upgrade.
       
   727  *
       
   728  * @since 3.0.0
       
   729  *
       
   730  * @global int $wp_db_version The version number of the database.
       
   731  */
   606 function site_admin_notice() {
   732 function site_admin_notice() {
   607 	global $wp_db_version;
   733 	global $wp_db_version;
   608 	if ( !is_super_admin() )
   734 	if ( !is_super_admin() )
   609 		return false;
   735 		return false;
   610 	if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version )
   736 	if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version )
   611 		echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>";
   737 		echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>";
   612 }
   738 }
   613 add_action( 'admin_notices', 'site_admin_notice' );
   739 add_action( 'admin_notices', 'site_admin_notice' );
   614 add_action( 'network_admin_notices', 'site_admin_notice' );
   740 add_action( 'network_admin_notices', 'site_admin_notice' );
   615 
   741 
       
   742 /**
       
   743  * Avoids a collision between a site slug and a permalink slug.
       
   744  *
       
   745  * In a subdirectory install this will make sure that a site and a post do not use the
       
   746  * same subdirectory by checking for a site with the same name as a new post.
       
   747  *
       
   748  * @since 3.0.0
       
   749  *
       
   750  * @param array $data    An array of post data.
       
   751  * @param array $postarr An array of posts. Not currently used.
       
   752  * @return array The new array of post data after checking for collisions.
       
   753  */
   616 function avoid_blog_page_permalink_collision( $data, $postarr ) {
   754 function avoid_blog_page_permalink_collision( $data, $postarr ) {
   617 	if ( is_subdomain_install() )
   755 	if ( is_subdomain_install() )
   618 		return $data;
   756 		return $data;
   619 	if ( $data['post_type'] != 'page' )
   757 	if ( $data['post_type'] != 'page' )
   620 		return $data;
   758 		return $data;
   634 	}
   772 	}
   635 	return $data;
   773 	return $data;
   636 }
   774 }
   637 add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
   775 add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
   638 
   776 
       
   777 /**
       
   778  * Handles the display of choosing a user's primary site.
       
   779  *
       
   780  * This displays the user's primary site and allows the user to choose
       
   781  * which site is primary.
       
   782  *
       
   783  * @since 3.0.0
       
   784  */
   639 function choose_primary_blog() {
   785 function choose_primary_blog() {
   640 	?>
   786 	?>
   641 	<table class="form-table">
   787 	<table class="form-table">
   642 	<tr>
   788 	<tr>
   643 	<?php /* translators: My sites label */ ?>
   789 	<?php /* translators: My sites label */ ?>
   644 		<th scope="row"><?php _e( 'Primary Site' ); ?></th>
   790 		<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th>
   645 		<td>
   791 		<td>
   646 		<?php
   792 		<?php
   647 		$all_blogs = get_blogs_of_user( get_current_user_id() );
   793 		$all_blogs = get_blogs_of_user( get_current_user_id() );
   648 		$primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
   794 		$primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
   649 		if ( count( $all_blogs ) > 1 ) {
   795 		if ( count( $all_blogs ) > 1 ) {
   650 			$found = false;
   796 			$found = false;
   651 			?>
   797 			?>
   652 			<select name="primary_blog">
   798 			<select name="primary_blog" id="primary_blog">
   653 				<?php foreach( (array) $all_blogs as $blog ) {
   799 				<?php foreach( (array) $all_blogs as $blog ) {
   654 					if ( $primary_blog == $blog->userblog_id )
   800 					if ( $primary_blog == $blog->userblog_id )
   655 						$found = true;
   801 						$found = true;
   656 					?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
   802 					?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
   657 				} ?>
   803 				} ?>
   658 			</select>
   804 			</select>
   659 			<?php
   805 			<?php
   660 			if ( !$found ) {
   806 			if ( !$found ) {
   661 				$blog = array_shift( $all_blogs );
   807 				$blog = reset( $all_blogs );
   662 				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
   808 				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
   663 			}
   809 			}
   664 		} elseif ( count( $all_blogs ) == 1 ) {
   810 		} elseif ( count( $all_blogs ) == 1 ) {
   665 			$blog = array_shift( $all_blogs );
   811 			$blog = reset( $all_blogs );
   666 			echo $blog->domain;
   812 			echo $blog->domain;
   667 			if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
   813 			if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
   668 				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
   814 				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
   669 		} else {
   815 		} else {
   670 			echo "N/A";
   816 			echo "N/A";
   674 	</tr>
   820 	</tr>
   675 	<?php if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) : ?>
   821 	<?php if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) : ?>
   676 		<tr>
   822 		<tr>
   677 			<th scope="row" colspan="2" class="th-full">
   823 			<th scope="row" colspan="2" class="th-full">
   678 				<?php
   824 				<?php
   679 				$signup_url = network_site_url( 'wp-signup.php' );
       
   680 				/** This filter is documented in wp-login.php */
   825 				/** This filter is documented in wp-login.php */
       
   826 				$sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) );
   681 				?>
   827 				?>
   682 				<a href="<?php echo apply_filters( 'wp_signup_location', $signup_url ); ?>"><?php _e( 'Create a New Site' ); ?></a>
   828 				<a href="<?php echo esc_url( $sign_up_url ); ?>"><?php _e( 'Create a New Site' ); ?></a>
   683 			</th>
   829 			</th>
   684 		</tr>
   830 		</tr>
   685 	<?php endif; ?>
   831 	<?php endif; ?>
   686 	</table>
   832 	</table>
   687 	<?php
   833 	<?php
   689 
   835 
   690 /**
   836 /**
   691  * Grants Super Admin privileges.
   837  * Grants Super Admin privileges.
   692  *
   838  *
   693  * @since 3.0.0
   839  * @since 3.0.0
       
   840  *
   694  * @param int $user_id ID of the user to be granted Super Admin privileges.
   841  * @param int $user_id ID of the user to be granted Super Admin privileges.
       
   842  * @return bool True on success, false on failure. This can fail when the user is
       
   843  *              already a super admin or when the `$super_admins` global is defined.
   695  */
   844  */
   696 function grant_super_admin( $user_id ) {
   845 function grant_super_admin( $user_id ) {
   697 	global $super_admins;
       
   698 
       
   699 	// If global super_admins override is defined, there is nothing to do here.
   846 	// If global super_admins override is defined, there is nothing to do here.
   700 	if ( isset( $super_admins ) )
   847 	if ( isset( $GLOBALS['super_admins'] ) ) {
   701 		return false;
   848 		return false;
       
   849 	}
   702 
   850 
   703 	/**
   851 	/**
   704 	 * Fires before the user is granted Super Admin privileges.
   852 	 * Fires before the user is granted Super Admin privileges.
   705 	 *
   853 	 *
   706 	 * @since 3.0.0
   854 	 * @since 3.0.0
   732 
   880 
   733 /**
   881 /**
   734  * Revokes Super Admin privileges.
   882  * Revokes Super Admin privileges.
   735  *
   883  *
   736  * @since 3.0.0
   884  * @since 3.0.0
       
   885  *
   737  * @param int $user_id ID of the user Super Admin privileges to be revoked from.
   886  * @param int $user_id ID of the user Super Admin privileges to be revoked from.
       
   887  * @return bool True on success, false on failure. This can fail when the user's email
       
   888  *              is the network admin email or when the `$super_admins` global is defined.
   738  */
   889  */
   739 function revoke_super_admin( $user_id ) {
   890 function revoke_super_admin( $user_id ) {
   740 	global $super_admins;
       
   741 
       
   742 	// If global super_admins override is defined, there is nothing to do here.
   891 	// If global super_admins override is defined, there is nothing to do here.
   743 	if ( isset( $super_admins ) )
   892 	if ( isset( $GLOBALS['super_admins'] ) ) {
   744 		return false;
   893 		return false;
       
   894 	}
   745 
   895 
   746 	/**
   896 	/**
   747 	 * Fires before the user's Super Admin privileges are revoked.
   897 	 * Fires before the user's Super Admin privileges are revoked.
   748 	 *
   898 	 *
   749 	 * @since 3.0.0
   899 	 * @since 3.0.0
   754 
   904 
   755 	// Directly fetch site_admins instead of using get_super_admins()
   905 	// Directly fetch site_admins instead of using get_super_admins()
   756 	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
   906 	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
   757 
   907 
   758 	$user = get_userdata( $user_id );
   908 	$user = get_userdata( $user_id );
   759 	if ( $user && $user->user_email != get_site_option( 'admin_email' ) ) {
   909 	if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) {
   760 		if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
   910 		if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
   761 			unset( $super_admins[$key] );
   911 			unset( $super_admins[$key] );
   762 			update_site_option( 'site_admins', $super_admins );
   912 			update_site_option( 'site_admins', $super_admins );
   763 
   913 
   764 			/**
   914 			/**
   774 	}
   924 	}
   775 	return false;
   925 	return false;
   776 }
   926 }
   777 
   927 
   778 /**
   928 /**
   779  * Whether or not we can edit this network from this page
   929  * Whether or not we can edit this network from this page.
   780  *
   930  *
   781  * By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden
   931  * By default editing of network is restricted to the Network Admin for that `$site_id`
       
   932  * this allows for this to be overridden.
   782  *
   933  *
   783  * @since 3.1.0
   934  * @since 3.1.0
   784  * @param integer $site_id The network/site ID to check.
   935  *
       
   936  * @param int $site_id The network/site ID to check.
       
   937  * @return bool True if network can be edited, otherwise false.
   785  */
   938  */
   786 function can_edit_network( $site_id ) {
   939 function can_edit_network( $site_id ) {
   787 	global $wpdb;
   940 	global $wpdb;
   788 
   941 
   789 	if ( $site_id == $wpdb->siteid )
   942 	if ( $site_id == $wpdb->siteid )
   804 
   957 
   805 /**
   958 /**
   806  * Thickbox image paths for Network Admin.
   959  * Thickbox image paths for Network Admin.
   807  *
   960  *
   808  * @since 3.1.0
   961  * @since 3.1.0
       
   962  *
   809  * @access private
   963  * @access private
   810  */
   964  */
   811 function _thickbox_path_admin_subfolder() {
   965 function _thickbox_path_admin_subfolder() {
   812 ?>
   966 ?>
   813 <script type="text/javascript">
   967 <script type="text/javascript">
   814 //<![CDATA[
   968 var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ); ?>";
   815 var tb_pathToImage = "../../wp-includes/js/thickbox/loadingAnimation.gif";
       
   816 //]]>
       
   817 </script>
   969 </script>
   818 <?php
   970 <?php
   819 }
   971 }