Changeset 13918 for trunk/wp-admin/includes/ms.php
- Timestamp:
- 04/01/2010 09:21:27 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/ms.php (modified) (44 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ms.php
r13896 r13918 28 28 $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s Kb in size.'), get_site_option( 'fileupload_maxk', 1500 ) ); 29 29 if ( upload_is_user_over_quota( false ) ) { 30 $file['error'] = __( 'You have used your space quota. Please delete files before uploading.');30 $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); 31 31 } 32 32 if ( $file['error'] != '0' ) … … 46 46 * @return void 47 47 */ 48 function wpmu_delete_blog( $blog_id, $drop = false) {48 function wpmu_delete_blog( $blog_id, $drop = false ) { 49 49 global $wpdb; 50 50 51 $switch ed= false;51 $switch = false; 52 52 if ( $blog_id != $wpdb->blogid ) { 53 53 $switch = true; 54 switch_to_blog($blog_id); 55 } 56 57 do_action('delete_blog', $blog_id, $drop); 58 59 $users = get_users_of_blog($blog_id); 54 switch_to_blog( $blog_id ); 55 } 56 57 $blog_prefix = $wpdb->get_blog_prefix( $blog_id ); 58 59 do_action( 'delete_blog', $blog_id, $drop ); 60 61 $users = get_users_of_blog( $blog_id ); 60 62 61 63 // Remove users from this blog. 62 if ( ! empty($users) ) {63 foreach ( $users as $user) {64 remove_user_from_blog( $user->user_id, $blog_id);64 if ( ! empty( $users ) ) { 65 foreach ( $users as $user ) { 66 remove_user_from_blog( $user->user_id, $blog_id) ; 65 67 } 66 68 } … … 69 71 70 72 if ( $drop ) { 71 $drop_tables = $wpdb->get_results( "show tables LIKE '". $wpdb->base_prefix . $blog_id . "\_%'", ARRAY_A);73 $drop_tables = $wpdb->get_results( "SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A ); 72 74 $drop_tables = apply_filters( 'wpmu_drop_tables', $drop_tables ); 73 75 … … 76 78 $wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" ); 77 79 } 78 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id) );80 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); 79 81 $dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id ); 80 $dir = rtrim( $dir, DIRECTORY_SEPARATOR);82 $dir = rtrim( $dir, DIRECTORY_SEPARATOR ); 81 83 $top_dir = $dir; 82 84 $stack = array($dir); 83 85 $index = 0; 84 86 85 while ( $index < count( $stack) ) {87 while ( $index < count( $stack ) ) { 86 88 # Get indexed directory from stack 87 89 $dir = $stack[$index]; 88 90 89 $dh = @ opendir($dir);91 $dh = @opendir( $dir ); 90 92 if ( $dh ) { 91 while ( ( $file = @ readdir($dh)) !== false ) {92 if ( $file == '.' or $file == '..')93 while ( ( $file = @readdir( $dh ) ) !== false ) { 94 if ( $file == '.' || $file == '..' ) 93 95 continue; 94 96 95 if ( @ is_dir($dir . DIRECTORY_SEPARATOR . $file))97 if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) 96 98 $stack[] = $dir . DIRECTORY_SEPARATOR . $file; 97 else if ( @ is_file($dir . DIRECTORY_SEPARATOR . $file))98 @ unlink($dir . DIRECTORY_SEPARATOR . $file);99 else if ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) 100 @unlink( $dir . DIRECTORY_SEPARATOR . $file ); 99 101 } 100 102 } … … 102 104 } 103 105 104 $stack = array_reverse( $stack); // Last added dirs are deepest106 $stack = array_reverse( $stack ); // Last added dirs are deepest 105 107 foreach( (array) $stack as $dir ) { 106 108 if ( $dir != $top_dir) 107 @rmdir($dir); 108 } 109 } 110 $wpdb->query( $wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s", 'wp_{$blog_id}_autosave_draft_ids') ); 111 $blogs = get_site_option( "blog_list" ); 109 @rmdir( $dir ); 110 } 111 } 112 113 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}autosave_draft_ids'" ); 114 $blogs = get_site_option( 'blog_list' ); 112 115 if ( is_array( $blogs ) ) { 113 116 foreach ( $blogs as $n => $blog ) { 114 if ( $blog[ 'blog_id'] == $blog_id )115 unset( $blogs[ $n] );117 if ( $blog['blog_id'] == $blog_id ) 118 unset( $blogs[$n] ); 116 119 } 117 120 update_site_option( 'blog_list', $blogs ); … … 123 126 124 127 // @todo Merge with wp_delete_user() ? 125 function wpmu_delete_user( $id) {128 function wpmu_delete_user( $id ) { 126 129 global $wpdb; 127 130 128 131 $id = (int) $id; 129 132 130 do_action( 'wpmu_delete_user', $id);131 132 $blogs = get_blogs_of_user( $id);133 134 if ( ! empty( $blogs) ) {135 foreach ( $blogs as $blog) {136 switch_to_blog( $blog->userblog_id);137 remove_user_from_blog( $id, $blog->userblog_id);138 139 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );133 do_action( 'wpmu_delete_user', $id ); 134 135 $blogs = get_blogs_of_user( $id ); 136 137 if ( ! empty( $blogs ) ) { 138 foreach ( $blogs as $blog ) { 139 switch_to_blog( $blog->userblog_id ); 140 remove_user_from_blog( $id, $blog->userblog_id ); 141 142 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); 140 143 foreach ( (array) $post_ids as $post_id ) { 141 wp_delete_post( $post_id);144 wp_delete_post( $post_id ); 142 145 } 143 146 144 147 // Clean links 145 $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) );148 $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) ); 146 149 147 150 if ( $link_ids ) { 148 151 foreach ( $link_ids as $link_id ) 149 wp_delete_link( $link_id);152 wp_delete_link( $link_id ); 150 153 } 151 154 … … 154 157 } 155 158 156 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id) );157 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );158 159 clean_user_cache( $id);159 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id ) ); 160 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id ) ); 161 162 clean_user_cache( $id ); 160 163 161 164 // allow for commit transaction 162 do_action( 'deleted_user', $id);165 do_action( 'deleted_user', $id ); 163 166 164 167 return true; … … 170 173 return false; 171 174 172 screen_icon( 'tools');175 screen_icon(); 173 176 ?> 174 <h2><?php esc_html_e( 'Users'); ?></h2>175 <p><?php _e( 'Transfer posts before deleting users:' ); ?></p>176 <form action="ms-edit.php?action= allusers" method="post">177 <input type="hidden" name=" alluser_transfer_delete" />177 <h2><?php esc_html_e( 'Users' ); ?></h2> 178 <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p> 179 <form action="ms-edit.php?action=dodelete" method="post"> 180 <input type="hidden" name="dodelete" /> 178 181 <?php 179 wp_nonce_field( ' allusers' );182 wp_nonce_field( 'ms-users-delete' ); 180 183 $site_admins = get_site_option( 'site_admins', array( 'admin' ) ); 181 184 $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>"; … … 192 195 193 196 if ( !empty( $blogs ) ) { 194 echo '<p><strong>' . sprintf( __( 'Sites from %s:' ), $delete_user->user_login ) . '</strong></p>'; 197 ?> 198 <br /><fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p> 199 <?php 195 200 foreach ( (array) $blogs as $key => $details ) { 196 201 $blog_users = get_users_of_blog( $details->userblog_id ); 197 202 if ( is_array( $blog_users ) && !empty( $blog_users ) ) { 198 echo "<p><a href='http://{$details->domain}{$details->path}'>{$details->blogname}</a>";199 echo"<select name='blog[$val][{$key}]'>";200 $ out = '';203 $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>"; 204 $user_dropdown = "<select name='blog[$val][{$key}]'>"; 205 $user_list = ''; 201 206 foreach ( $blog_users as $user ) { 202 207 if ( $user->user_id != $val && !in_array( $user->user_id, $allusers ) ) 203 $ out .= "<option value='{$user->user_id}'>{$user->user_login}</option>";208 $user_list .= "<option value='{$user->user_id}'>{$user->user_login}</option>"; 204 209 } 205 if ( $out == '' ) 206 $out = $admin_out; 207 echo $out; 208 echo "</select>\n"; 210 if ( '' == $user_list ) 211 $user_list = $admin_out; 212 $user_dropdown .= $user_list; 213 $user_dropdown .= "</select>\n"; 214 ?> 215 <ul style="list-style:none;"> 216 <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li> 217 <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" /> 218 <?php _e( 'Delete all posts and links.' ); ?></label></li> 219 <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" /> 220 <?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li> 221 </ul> 222 <?php 209 223 } 210 224 } 225 echo "</fieldset>"; 211 226 } 212 227 } 213 228 } 214 229 ?> 215 <br class="clear" /> 216 <input type="submit" class="button-secondary delete" value="<?php _e( 'Delete user and transfer posts' ); ?> " /> 230 <p class="submit"><input type="submit" class="button-secondary delete" value="<?php esc_attr_e( 'Confirm Deletion' ); ?>" /></p> 217 231 </form> 218 232 <?php … … 226 240 switch_to_blog( $blog_id ); 227 241 228 $blog_allowed_themes = get_option( "allowedthemes");242 $blog_allowed_themes = get_option( 'allowedthemes' ); 229 243 if ( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes 230 $blog_allowed_themes = get_option( "allowed_themes");244 $blog_allowed_themes = get_option( 'allowed_themes' ); 231 245 232 246 if ( is_array( $blog_allowed_themes ) ) { 233 247 foreach( (array) $themes as $key => $theme ) { 234 $theme_key = esc_html( $theme[ 'Stylesheet'] );235 if ( isset( $blog_allowed_themes[ $key] ) == true ) {236 $blog_allowedthemes[ $theme_key] = 1;248 $theme_key = esc_html( $theme['Stylesheet'] ); 249 if ( isset( $blog_allowed_themes[$key] ) == true ) { 250 $blog_allowedthemes[$theme_key] = 1; 237 251 } 238 252 } 239 253 $blog_allowed_themes = $blog_allowedthemes; 240 add_option( "allowedthemes", $blog_allowed_themes );241 delete_option( "allowed_themes");254 add_option( 'allowedthemes', $blog_allowed_themes ); 255 delete_option( 'allowed_themes' ); 242 256 } 243 257 } … … 249 263 } 250 264 251 function update_option_new_admin_email( $old_value, $value) {265 function update_option_new_admin_email( $old_value, $value ) { 252 266 if ( $value == get_option( 'admin_email' ) || !is_email( $value ) ) 253 267 return; … … 255 269 $hash = md5( $value. time() .mt_rand() ); 256 270 $new_admin_email = array( 257 "hash"=> $hash,258 "newemail"=> $value271 'hash' => $hash, 272 'newemail' => $value 259 273 ); 260 274 update_option( 'adminhash', $new_admin_email ); 261 275 262 $content = apply_filters( 'new_admin_email_content', __( "Dear user,276 $content = apply_filters( 'new_admin_email_content', __( "Dear user, 263 277 264 278 You recently requested to have the administration email address on … … 274 288 Regards, 275 289 All at ###SITENAME### 276 ###SITEURL### "), $new_admin_email );277 278 $content = str_replace( '###ADMIN_URL###', esc_url(admin_url('options.php?adminhash='.$hash)), $content);279 $content = str_replace( '###EMAIL###', $value, $content);280 $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content);281 $content = str_replace( '###SITEURL###', network_home_url(), $content);282 283 wp_mail( $value, sprintf( __('[%s] New Admin Email Address'), get_option('blogname')), $content );284 } 285 add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);290 ###SITEURL### "), $new_admin_email ); 291 292 $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content ); 293 $content = str_replace( '###EMAIL###', $value, $content ); 294 $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content ); 295 $content = str_replace( '###SITEURL###', network_home_url(), $content ); 296 297 wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), get_option( 'blogname' ) ), $content ); 298 } 299 add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 ); 286 300 287 301 function send_confirmation_on_profile_email() { … … 290 304 $errors = new WP_Error(); 291 305 292 if ( $current_user->id != $_POST[ 'user_id'] )306 if ( $current_user->id != $_POST['user_id'] ) 293 307 return false; 294 308 295 if ( $current_user->user_email != $_POST[ 'email'] ) {296 if ( !is_email( $_POST[ 'email'] ) ) {309 if ( $current_user->user_email != $_POST['email'] ) { 310 if ( !is_email( $_POST['email'] ) ) { 297 311 $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); 298 312 return; 299 313 } 300 314 301 if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST[ 'email'] ) ) ) {315 if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) { 302 316 $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address is already used." ), array( 'form-field' => 'email' ) ); 303 317 delete_option( $current_user->ID . '_new_email' ); … … 305 319 } 306 320 307 $hash = md5( $_POST[ 'email'] . time() . mt_rand() );321 $hash = md5( $_POST['email'] . time() . mt_rand() ); 308 322 $new_user_email = array( 309 "hash"=> $hash,310 "newemail" => $_POST[ 'email']323 'hash' => $hash, 324 'newemail' => $_POST['email'] 311 325 ); 312 326 update_option( $current_user->ID . '_new_email', $new_user_email ); 313 327 314 $content = apply_filters( 'new_user_email_content', __( "Dear user,328 $content = apply_filters( 'new_user_email_content', __( "Dear user, 315 329 316 330 You recently requested to have the email address on your account changed. … … 325 339 Regards, 326 340 All at ###SITENAME### 327 ###SITEURL###" ), $new_user_email );328 329 $content = str_replace( '###ADMIN_URL###', esc_url(admin_url('profile.php?newuseremail='.$hash)), $content);330 $content = str_replace( '###EMAIL###', $_POST[ 'email'], $content);331 $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content);332 $content = str_replace( '###SITEURL###', network_home_url(), $content);333 334 wp_mail( $_POST[ 'email' ], sprintf(__('[%s] New Email Address'), get_option('blogname')), $content );335 $_POST[ 'email'] = $current_user->user_email;341 ###SITEURL###" ), $new_user_email ); 342 343 $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content ); 344 $content = str_replace( '###EMAIL###', $_POST['email'], $content); 345 $content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content ); 346 $content = str_replace( '###SITEURL###', network_home_url(), $content ); 347 348 wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), get_option( 'blogname' ) ), $content ); 349 $_POST['email'] = $current_user->user_email; 336 350 } 337 351 } … … 340 354 function new_user_email_admin_notice() { 341 355 global $current_user; 342 if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET[ 'updated'] ) && $email = get_option( $current_user->ID . '_new_email' ) )343 echo "<div id='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email[ 'newemail'] ) . "</div>";356 if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( $current_user->ID . '_new_email' ) ) 357 echo "<div id='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 358 } 345 359 add_action( 'admin_notices', 'new_user_email_admin_notice' ); … … 349 363 $allowed_themes = get_site_option( 'allowedthemes' ); 350 364 if ( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) { 351 $allowed_themes = get_site_option( "allowed_themes"); // convert old allowed_themes format365 $allowed_themes = get_site_option( 'allowed_themes' ); // convert old allowed_themes format 352 366 if ( !is_array( $allowed_themes ) ) { 353 367 $allowed_themes = array(); 354 368 } else { 355 369 foreach( (array) $themes as $key => $theme ) { 356 $theme_key = esc_html( $theme[ 'Stylesheet'] );370 $theme_key = esc_html( $theme['Stylesheet'] ); 357 371 if ( isset( $allowed_themes[ $key ] ) == true ) { 358 372 $allowedthemes[ $theme_key ] = 1; … … 377 391 378 392 $dir_name = trailingslashit( BLOGUPLOADDIR ); 379 if ( !( is_dir($dir_name) && is_readable($dir_name)) )393 if ( !( is_dir( $dir_name) && is_readable( $dir_name ) ) ) 380 394 return true; 381 395 382 $dir = dir( $dir_name);396 $dir = dir( $dir_name ); 383 397 $size = 0; 384 398 … … 386 400 if ( $file != '.' && $file != '..' ) { 387 401 if ( is_dir( $dir_name . $file) ) { 388 $size += get_dirsize( $dir_name . $file);402 $size += get_dirsize( $dir_name . $file ); 389 403 } else { 390 $size += filesize( $dir_name . $file);404 $size += filesize( $dir_name . $file ); 391 405 } 392 406 } … … 395 409 $size = $size / 1024 / 1024; 396 410 397 if ( ( $space_allowed - $size) <= 0 )411 if ( ( $space_allowed - $size ) <= 0 ) 398 412 return false; 399 413 … … 407 421 */ 408 422 function get_space_allowed() { 409 $space_allowed = get_option( 'blog_upload_space');423 $space_allowed = get_option( 'blog_upload_space' ); 410 424 if ( $space_allowed == false ) 411 $space_allowed = get_site_option( 'blog_upload_space');412 if ( empty( $space_allowed) || !is_numeric($space_allowed) )425 $space_allowed = get_site_option( 'blog_upload_space' ); 426 if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) ) 413 427 $space_allowed = 50; 414 428 … … 418 432 function display_space_usage() { 419 433 $space = get_space_allowed(); 420 $used = get_dirsize( BLOGUPLOADDIR ) /1024/1024;434 $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024; 421 435 422 436 if ( $used > $space ) … … 427 441 if ( $space > 1000 ) { 428 442 $space = number_format( $space / 1024 ); 429 $space .= __( 'GB');443 $space .= __( 'GB' ); 430 444 } else { 431 $space .= __( 'MB');445 $space .= __( 'MB' ); 432 446 } 433 447 ?> 434 <strong><?php printf( __('Used: %1s%% of %2s'), number_format($percentused), $space );?></strong>448 <strong><?php printf( __( 'Used: %1s%% of %2s' ), number_format( $percentused ), $space );?></strong> 435 449 <?php 436 450 } … … 442 456 443 457 $quota = get_space_allowed(); 444 $used = get_dirsize( BLOGUPLOADDIR ) /1024/1024;458 $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024; 445 459 446 460 if ( $used > $quota ) … … 448 462 else 449 463 $percentused = ( $used / $quota ) * 100; 450 $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';464 $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam'; 451 465 $used = round( $used, 2 ); 452 466 $percentused = number_format( $percentused ); 453 467 454 468 ?> 455 <p class="sub musub"><?php _e( 'Storage Space'); ?></p>456 <div class="table ">469 <p class="sub musub"><?php _e( 'Storage Space' ); ?></p> 470 <div class="table table_content musubtable"> 457 471 <table> 458 472 <tr class="first"> 459 <td class="first b b-posts"><?php printf( __( '<a href="upload.php" title="Manage Uploads" class="musublink">%sMB</a>' ), $quota ); ?></td> 460 <td class="t posts"><?php _e('Space Allowed'); ?></td> 461 <td class="b b-comments"><?php printf( __( '<a href="upload.php" title="Manage Uploads" class="musublink">%1sMB (%2$s%%)</a>' ), $used, $percentused ); ?></td> 462 <td class="last t comments <?php echo $used_color;?>"><?php _e('Space Used');?></td> 473 <td class="first b b-posts"><?php printf( __( '<a href="' . esc_url( admin_url( 'upload.php' ) ) . '" title="Manage Uploads" class="musublink">%sMB</a>' ), $quota ); ?></td> 474 <td class="t posts"><?php _e( 'Space Allowed' ); ?></td> 463 475 </tr> 464 476 </table> 465 477 </div> 478 <div class="table table_discussion musubtable"> 479 <table> 480 <tr class="first"> 481 <td class="b b-comments"><?php printf( __( '<a href="' . esc_url( admin_url( 'upload.php' ) ) . '" title="Manage Uploads" class="musublink">%1sMB (%2$s%%)</a>' ), $used, $percentused ); ?></td> 482 <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td> 483 </tr> 484 </table> 485 </div> 486 <br class="clear" /> 466 487 <?php 467 488 } 468 if ( current_user_can( 'edit_posts') )469 add_action( 'activity_box_end', 'dashboard_quota');489 if ( current_user_can( 'edit_posts' ) ) 490 add_action( 'activity_box_end', 'dashboard_quota' ); 470 491 471 492 // Edit blog upload space setting on Edit Blog page 472 493 function upload_space_setting( $id ) { 473 $quota = get_blog_option( $id, "blog_upload_space");494 $quota = get_blog_option( $id, 'blog_upload_space' ); 474 495 if ( !$quota ) 475 496 $quota = ''; … … 477 498 ?> 478 499 <tr> 479 <th><?php _e( 'Site Upload Space Quota'); ?></th>480 <td><input type="text" size="3" name="option[blog_upload_space]" value="<?php echo $quota; ?>" /> <?php _e('MB (Leave blank for network default)'); ?></td>500 <th><?php _e( 'Site Upload Space Quota '); ?></th> 501 <td><input type="text" size="3" name="option[blog_upload_space]" value="<?php echo $quota; ?>" /> <?php _e( 'MB (Leave blank for network default)' ); ?></td> 481 502 </tr> 482 503 <?php 483 504 } 484 add_action( 'wpmueditblogaction', 'upload_space_setting');505 add_action( 'wpmueditblogaction', 'upload_space_setting' ); 485 506 486 507 function update_user_status( $id, $pref, $value, $refresh = 1 ) { … … 490 511 491 512 if ( $refresh == 1 ) 492 refresh_user_details( $id);513 refresh_user_details( $id ); 493 514 494 515 if ( $pref == 'spam' ) { 495 516 if ( $value == 1 ) 496 do_action( "make_spam_user", $id );517 do_action( 'make_spam_user', $id ); 497 518 else 498 do_action( "make_ham_user", $id );519 do_action( 'make_ham_user', $id ); 499 520 } 500 521 … … 502 523 } 503 524 504 function refresh_user_details( $id) {525 function refresh_user_details( $id ) { 505 526 $id = (int) $id; 506 527 … … 508 529 return false; 509 530 510 clean_user_cache( $id);531 clean_user_cache( $id ); 511 532 512 533 return $id; … … 514 535 515 536 function format_code_lang( $code = '' ) { 516 $code = strtolower(substr($code, 0, 2)); 517 $lang_codes = array('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', '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', 'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic', 'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue', 'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz', 'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam', 'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', 'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian', 'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili', 'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek', 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh', 'wa' => 'Walloon' 518 , 'wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu'); 519 $lang_codes = apply_filters('lang_codes', $lang_codes, $code); 537 $code = strtolower( substr( $code, 0, 2 ) ); 538 $lang_codes = array( 539 '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', 540 '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', 541 'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijjian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic', 542 'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue', 543 'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz', 544 'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam', 545 'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', 546 'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian', 547 'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili', 548 'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek', 549 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' ); 550 $lang_codes = apply_filters( 'lang_codes', $lang_codes, $code ); 520 551 return strtr( $code, $lang_codes ); 521 552 } … … 526 557 $term->slug = sanitize_title( $term->name ); 527 558 } else { 528 $term[ 'slug' ] = sanitize_title( $term[ 'name'] );559 $term['slug'] = sanitize_title( $term['name'] ); 529 560 } 530 561 } … … 536 567 global $current_user; 537 568 $c = 0; 538 if ( isset( $_GET[ 'c'] ) )539 $c = (int) $_GET[ 'c'];569 if ( isset( $_GET['c'] ) ) 570 $c = (int) $_GET['c']; 540 571 541 572 if ( $c >= 5 ) { … … 547 578 $dashboard_blog = get_dashboard_blog(); 548 579 if ( is_object( $blog ) ) { 549 wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c) ); // redirect and count to 5, "just in case"580 wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case" 550 581 exit; 551 582 } … … 565 596 } 566 597 $blog = get_blog_details( get_user_meta( $current_user->ID, 'primary_blog', true ) ); 567 $protocol = ( is_ssl() ? 'https://' : 'http://' ); 568 wp_redirect( $protocol . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case" 598 wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); 569 599 exit; 570 600 } … … 590 620 if ( $code_lang == 'en_US' ) { // American English 591 621 $flag = true; 592 $ae = __( 'American English');593 $output[$ae] = '<option value="' .$code_lang.'"'.(($current == $code_lang) ? ' selected="selected"' : '').'> '.$ae.'</option>';622 $ae = __( 'American English' ); 623 $output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang ) . '> ' . $ae . '</option>'; 594 624 } elseif ( $code_lang == 'en_GB' ) { // British English 595 625 $flag = true; 596 $be = __( 'British English');597 $output[$be] = '<option value="' .$code_lang.'"'.(($current == $code_lang) ? ' selected="selected"' : '').'> '.$be.'</option>';626 $be = __( 'British English' ); 627 $output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang ) . '> ' . $be . '</option>'; 598 628 } else { 599 $translated = format_code_lang($code_lang); 600 $output[$translated] = '<option value="'.$code_lang.'"'.(($current == $code_lang) ? ' selected="selected"' : '').'> '.$translated.'</option>'; 601 } 602 603 } 604 605 if ( $flag === false ) { // WordPress english 606 $output[] = '<option value=""'.((empty($current)) ? ' selected="selected"' : '').'>'.__('English')."</option>"; 607 } 629 $translated = format_code_lang( $code_lang ); 630 $output[$translated] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang ) . '> ' . esc_html ( $translated ) . '</option>'; 631 } 632 633 } 634 635 if ( $flag === false ) // WordPress english 636 $output[] = '<option value=""' . selected( $current, '' ) . '>' . __( 'English' ) . "</option>"; 608 637 609 638 // Order by name 610 uksort( $output, 'strnatcasecmp');611 612 $output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current);613 echo implode( "\n\t", $output);639 uksort( $output, 'strnatcasecmp' ); 640 641 $output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current ); 642 echo implode( "\n\t", $output ); 614 643 } 615 644 … … 638 667 return; 639 668 640 if ( !empty( $_GET[ 'feed_dismiss'] ) )641 update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss'], true );669 if ( !empty( $_GET['feed_dismiss'] ) ) 670 update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET['feed_dismiss'], true ); 642 671 643 672 $url = get_site_option( 'admin_notice_feed' ); … … 667 696 return false; 668 697 if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) 669 echo "<div id='update-nag'>" . __( 'Thank you for Updating! Please visit the <a href="ms-upgrade-network.php">Update Network</a> page to update all your sites.') . "</div>";698 echo "<div id='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Update Network</a> page to update all your sites.' ), esc_url( admin_url( 'ms-upgrade-network.php' ) ) ) . "</div>"; 670 699 } 671 700 add_action( 'admin_notices', 'site_admin_notice' ); … … 674 703 if ( is_subdomain_install() ) 675 704 return $data; 676 if ( $data[ 'post_type'] != 'page' )705 if ( $data['post_type'] != 'page' ) 677 706 return $data; 678 if ( !isset( $data[ 'post_name' ] ) || $data[ 'post_name'] == '' )707 if ( !isset( $data['post_name'] ) || $data['post_name'] == '' ) 679 708 return $data; 680 709 if ( !is_main_site() ) 681 710 return $data; 682 711 683 $post_name = $data[ 'post_name'];712 $post_name = $data['post_name']; 684 713 $c = 0; 685 714 while( $c < 10 && get_id_from_blogname( $post_name ) ) { … … 687 716 $c ++; 688 717 } 689 if ( $post_name != $data[ 'post_name'] ) {690 $data[ 'post_name'] = $post_name;718 if ( $post_name != $data['post_name'] ) { 719 $data['post_name'] = $post_name; 691 720 } 692 721 return $data; … … 700 729 <tr> 701 730 <?php /* translators: My sites label */ ?> 702 <th scope="row"><?php _e( 'Primary Site'); ?></th>731 <th scope="row"><?php _e( 'Primary Site' ); ?></th> 703 732 <td> 704 733 <?php 705 734 $all_blogs = get_blogs_of_user( $current_user->ID ); 706 $primary_blog = get_user_meta( $current_user->ID, 'primary_blog', true);735 $primary_blog = get_user_meta( $current_user->ID, 'primary_blog', true ); 707 736 if ( count( $all_blogs ) > 1 ) { 708 737 $found = false; … … 712 741 if ( $primary_blog == $blog->userblog_id ) 713 742 $found = true; 714 ?><option value= '<?php echo $blog->userblog_id ?>'<?php if ( $primary_blog == $blog->userblog_id ) echo ' selected="selected"' ?>><?php echo get_home_url($blog->userblog_id) ?></option><?php743 ?><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 715 744 } ?> 716 745 </select> … … 739 768 return; 740 769 $mu_media_buttons = get_site_option( 'mu_media_buttons', array() ); 741 if ( empty($mu_media_buttons[ 'image']) && current_theme_supports( 'post-thumbnails' ) ) {742 echo "<div id='update-nag'>" . sprintf( __( "Warning! The current theme supports post thumbnails. You must enable image uploads on <a href='%s'>the options page</a> for it to work." ), admin_url( 'ms-options.php') ) . "</div>";770 if ( empty($mu_media_buttons['image']) && current_theme_supports( 'post-thumbnails' ) ) { 771 echo "<div id='update-nag'>" . sprintf( __( "Warning! The current theme supports post thumbnails. You must enable image uploads on <a href='%s'>the options page</a> for it to work." ), esc_url( admin_url( 'ms-options.php' ) ) ) . "</div>"; 743 772 } 744 773 } … … 761 790 */ 762 791 function _admin_notice_multisite_activate_plugins_page() { 763 $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href=" ms-options.php#menu">' . __( 'Activate' ) . '</a>' );792 $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href="' . esc_url( admin_url( 'ms-options.php#menu' ) ) . '">' . __( 'Activate' ) . '</a>' ); 764 793 echo "<div class='error'><p>$message</p></div>"; 765 794 }
Note: See TracChangeset
for help on using the changeset viewer.