Changeset 12752 for trunk/wp-admin/includes/ms.php
- Timestamp:
- 01/18/2010 08:34:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ms.php
r12674 r12752 4 4 return $file; 5 5 } 6 if ( $file['error'] != '0' ) // there's already an error6 if ( $file['error'] != '0' ) // there's already an error 7 7 return $file; 8 8 … … 14 14 $space_left = $space_allowed - $space_used; 15 15 $file_size = filesize( $file['tmp_name'] ); 16 if ( $space_left < $file_size )16 if ( $space_left < $file_size ) 17 17 $file['error'] = sprintf( __( 'Not enough space to upload. %1$s Kb needed.' ), number_format( ($file_size - $space_left) /1024 ) ); 18 if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )18 if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) 19 19 $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s Kb in size.'), get_site_option( 'fileupload_maxk', 1500 ) ); 20 if ( upload_is_user_over_quota( false ) ) {20 if ( upload_is_user_over_quota( false ) ) { 21 21 $file['error'] = __('You have used your space quota. Please delete files before uploading.'); 22 22 } 23 if ( $file['error'] != '0' )23 if ( $file['error'] != '0' ) 24 24 wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' ); 25 25 … … 91 91 if ( is_array( $blogs ) ) { 92 92 foreach( $blogs as $n => $blog ) { 93 if ( $blog[ 'blog_id' ] == $blog_id ) {93 if ( $blog[ 'blog_id' ] == $blog_id ) { 94 94 unset( $blogs[ $n ] ); 95 95 } … … 139 139 140 140 function confirm_delete_users( $users ) { 141 if ( !is_array( $users ) )141 if ( !is_array( $users ) ) 142 142 return false; 143 143 … … 148 148 wp_nonce_field( 'allusers' ); 149 149 foreach ( (array) $_POST['allusers'] as $key => $val ) { 150 if ( $val != '' && $val != '0' ) {150 if ( $val != '' && $val != '0' ) { 151 151 $user = new WP_User( $val ); 152 152 if ( in_array( $user->user_login, get_site_option( 'site_admins', array( 'admin' ) ) ) ) { … … 155 155 echo "<input type='hidden' name='user[]' value='{$val}'/>\n"; 156 156 $blogs = get_blogs_of_user( $val, true ); 157 if ( !empty( $blogs ) ) {157 if ( !empty( $blogs ) ) { 158 158 foreach ( (array) $blogs as $key => $details ) { 159 159 $blog_users = get_users_of_blog( $details->userblog_id ); 160 if ( is_array( $blog_users ) && !empty( $blog_users ) ) {160 if ( is_array( $blog_users ) && !empty( $blog_users ) ) { 161 161 echo "<p><a href='http://{$details->domain}{$details->path}'>{$details->blogname}</a> "; 162 162 echo "<select name='blog[$val][{$key}]'>"; 163 163 $out = ''; 164 164 foreach( $blog_users as $user ) { 165 if ( $user->user_id != $val )165 if ( $user->user_id != $val ) 166 166 $out .= "<option value='{$user->user_id}'>{$user->user_login}</option>"; 167 167 } 168 if ( $out == '' )168 if ( $out == '' ) 169 169 $out = "<option value='1'>admin</option>"; 170 170 echo $out; … … 183 183 $themes = get_themes(); 184 184 185 if ( $blog_id != 0 )185 if ( $blog_id != 0 ) 186 186 switch_to_blog( $blog_id ); 187 187 188 188 $blog_allowed_themes = get_option( "allowedthemes" ); 189 if ( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes189 if ( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes 190 190 $blog_allowed_themes = get_option( "allowed_themes" ); 191 191 192 if ( is_array( $blog_allowed_themes ) ) {192 if ( is_array( $blog_allowed_themes ) ) { 193 193 foreach( (array) $themes as $key => $theme ) { 194 194 $theme_key = wp_specialchars( $theme[ 'Stylesheet' ] ); 195 if ( isset( $blog_allowed_themes[ $key ] ) == true ) {195 if ( isset( $blog_allowed_themes[ $key ] ) == true ) { 196 196 $blog_allowedthemes[ $theme_key ] = 1; 197 197 } … … 203 203 } 204 204 205 if ( $blog_id != 0 )205 if ( $blog_id != 0 ) 206 206 restore_current_blog(); 207 207 … … 257 257 function update_profile_email() { 258 258 global $current_user, $wpdb; 259 if ( isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {259 if ( isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) { 260 260 $new_email = get_option( $current_user->ID . '_new_email' ); 261 if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {261 if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) { 262 262 $user->ID = $current_user->ID; 263 263 $user->user_email = wp_specialchars( trim( $new_email[ 'newemail' ] ) ); … … 278 278 $errors = new WP_Error(); 279 279 280 if ( $current_user->id != $_POST[ 'user_id' ] )280 if ( $current_user->id != $_POST[ 'user_id' ] ) 281 281 return false; 282 282 283 if ( $current_user->user_email != $_POST[ 'email' ] ) {283 if ( $current_user->user_email != $_POST[ 'email' ] ) { 284 284 if ( !is_email( $_POST[ 'email' ] ) ) { 285 285 $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) ); … … 287 287 } 288 288 289 if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST[ 'email' ] ) ) ) {289 if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST[ 'email' ] ) ) ) { 290 290 $errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address is already used." ), array( 'form-field' => 'email' ) ); 291 291 delete_option( $current_user->ID . '_new_email' ); … … 328 328 function new_user_email_admin_notice() { 329 329 global $current_user; 330 if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET[ 'updated' ] ) && $email = get_option( $current_user->ID . '_new_email' ) )330 if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET[ 'updated' ] ) && $email = get_option( $current_user->ID . '_new_email' ) ) 331 331 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>"; 332 332 } … … 336 336 $themes = get_themes(); 337 337 $allowed_themes = get_site_option( 'allowedthemes' ); 338 if ( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) {338 if ( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) { 339 339 $allowed_themes = get_site_option( "allowed_themes" ); // convert old allowed_themes format 340 if ( !is_array( $allowed_themes ) ) {340 if ( !is_array( $allowed_themes ) ) { 341 341 $allowed_themes = array(); 342 342 } else { 343 343 foreach( (array) $themes as $key => $theme ) { 344 344 $theme_key = wp_specialchars( $theme[ 'Stylesheet' ] ); 345 if ( isset( $allowed_themes[ $key ] ) == true ) {345 if ( isset( $allowed_themes[ $key ] ) == true ) { 346 346 $allowedthemes[ $theme_key ] = 1; 347 347 } … … 355 355 function get_space_allowed() { 356 356 $spaceAllowed = get_option("blog_upload_space"); 357 if ( $spaceAllowed == false )357 if ( $spaceAllowed == false ) 358 358 $spaceAllowed = get_site_option("blog_upload_space"); 359 if ( empty($spaceAllowed) || !is_numeric($spaceAllowed) )359 if ( empty($spaceAllowed) || !is_numeric($spaceAllowed) ) 360 360 $spaceAllowed = 50; 361 361 … … 370 370 else $percentused = ( $used / $space ) * 100; 371 371 372 if ( $space > 1000 ) {372 if ( $space > 1000 ) { 373 373 $space = number_format( $space / 1024 ); 374 374 $space .= __('GB'); … … 408 408 <?php 409 409 } 410 if ( current_user_can('edit_posts') )410 if ( current_user_can('edit_posts') ) 411 411 add_action('activity_box_end', 'dashboard_quota'); 412 412 … … 414 414 function upload_space_setting( $id ) { 415 415 $quota = get_blog_option($id, "blog_upload_space"); 416 if ( !$quota )416 if ( !$quota ) 417 417 $quota = ''; 418 418 … … 431 431 $wpdb->update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) ); 432 432 433 if ( $refresh == 1 )433 if ( $refresh == 1 ) 434 434 refresh_user_details($id); 435 435 436 if ( $pref == 'spam' ) {437 if ( $value == 1 )436 if ( $pref == 'spam' ) { 437 if ( $value == 1 ) 438 438 do_action( "make_spam_user", $id ); 439 439 else … … 483 483 $size = $size / 1024 / 1024; 484 484 485 if ( ($spaceAllowed - $size) <= 0 ) {485 if ( ($spaceAllowed - $size) <= 0 ) { 486 486 wp_die( __('Sorry, you must delete files before you can upload any more.') ); 487 487 } … … 497 497 498 498 function sync_category_tag_slugs( $term, $taxonomy ) { 499 if ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) {500 if ( is_object( $term ) ) {499 if ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) { 500 if ( is_object( $term ) ) { 501 501 $term->slug = sanitize_title( $term->name ); 502 502 } else { … … 521 521 $blog = get_active_blog_for_user( $current_user->ID ); 522 522 $dashboard_blog = get_dashboard_blog(); 523 if ( is_object( $blog ) ) {523 if ( is_object( $blog ) ) { 524 524 $protocol = ( is_ssl() ? 'https://' : 'http://' ); 525 525 wp_redirect( $protocol . $blog->domain . $blog->path . 'wp-admin/?c=' . $c ); // redirect and count to 5, "just in case" … … 626 626 $mu_media_buttons = get_site_option( 'mu_media_buttons' ); 627 627 $out = ''; 628 if ( $mu_media_buttons[ 'image' ] ) {628 if ( $mu_media_buttons[ 'image' ] ) { 629 629 $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image"); 630 630 $image_title = __('Add an Image'); 631 631 $out .= "<a href='{$image_upload_iframe_src}&TB_iframe=true' id='add_image' class='thickbox' title='$image_title'><img src='images/media-button-image.gif' alt='$image_title' /></a>"; 632 632 } 633 if ( $mu_media_buttons[ 'video' ] ) {633 if ( $mu_media_buttons[ 'video' ] ) { 634 634 $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video"); 635 635 $video_title = __('Add Video'); 636 636 $out .= "<a href='{$video_upload_iframe_src}&TB_iframe=true' id='add_video' class='thickbox' title='$video_title'><img src='images/media-button-video.gif' alt='$video_title' /></a>"; 637 637 } 638 if ( $mu_media_buttons[ 'audio' ] ) {638 if ( $mu_media_buttons[ 'audio' ] ) { 639 639 $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio"); 640 640 $audio_title = __('Add Audio'); … … 649 649 /* Warn the admin if SECRET SALT information is missing from wp-config.php */ 650 650 function secret_salt_warning() { 651 if ( !is_super_admin() )651 if ( !is_super_admin() ) 652 652 return; 653 653 $secret_keys = array( 'NONCE_KEY', 'AUTH_KEY', 'AUTH_SALT', 'LOGGED_IN_KEY', 'LOGGED_IN_SALT', 'SECURE_AUTH_KEY', 'SECURE_AUTH_SALT' ); 654 654 $out = ''; 655 655 foreach( $secret_keys as $key ) { 656 if ( !defined( $key ) )656 if ( !defined( $key ) ) 657 657 $out .= "define( '$key', '" . wp_generate_password() . wp_generate_password() . "' );<br />"; 658 658 } 659 if ( $out != '' ) {659 if ( $out != '' ) { 660 660 $msg = sprintf( __( 'Warning! WordPress encrypts user cookies, but you must add the following lines to <strong>%swp-config.php</strong> for it to be more secure.<br />Please add the code before the line, <code>/* That\'s all, stop editing! Happy blogging. */</code>' ), ABSPATH ); 661 661 $msg .= "<blockquote>$out</blockquote>"; … … 687 687 function admin_notice_feed() { 688 688 global $current_user; 689 if ( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' )689 if ( substr( $_SERVER[ 'PHP_SELF' ], -19 ) != '/wp-admin/index.php' ) 690 690 return; 691 691 692 if ( isset( $_GET[ 'feed_dismiss' ] ) )692 if ( isset( $_GET[ 'feed_dismiss' ] ) ) 693 693 update_user_option( $current_user->id, 'admin_feed_dismiss', $_GET[ 'feed_dismiss' ], true ); 694 694 695 695 $url = get_site_option( 'admin_notice_feed' ); 696 if ( $url == '' )696 if ( $url == '' ) 697 697 return; 698 698 include_once( ABSPATH . 'wp-includes/rss.php' ); 699 699 $rss = @fetch_rss( $url ); 700 if ( isset($rss->items) && 1 <= count($rss->items) ) {701 if ( md5( $rss->items[0][ 'title' ] ) == get_user_option( 'admin_feed_dismiss', $current_user->id ) )700 if ( isset($rss->items) && 1 <= count($rss->items) ) { 701 if ( md5( $rss->items[0][ 'title' ] ) == get_user_option( 'admin_feed_dismiss', $current_user->id ) ) 702 702 return; 703 703 $item = $rss->items[0]; … … 715 715 $msg .= "<p>" . $content . " <a href='$link'>" . __( 'Read More' ) . "</a> <a href='index.php?feed_dismiss=" . md5( $item[ 'title' ] ) . "'>" . __( "Dismiss" ) . "</a></p>"; 716 716 echo "<div class='updated fade'>$msg</div>"; 717 } elseif ( is_super_admin() ) {717 } elseif ( is_super_admin() ) { 718 718 printf("<div id='update-nag'>" . __("Your feed at %s is empty.") . "</div>", wp_specialchars( $url )); 719 719 } … … 723 723 function site_admin_notice() { 724 724 global $current_user, $wp_db_version; 725 if ( !is_super_admin() )725 if ( !is_super_admin() ) 726 726 return false; 727 727 printf("<div id='update-nag'>" . __("Hi %s! You're logged in as a site administrator.") . "</div>", $current_user->user_login); … … 733 733 734 734 function avoid_blog_page_permalink_collision( $data, $postarr ) { 735 if ( is_subdomain_install() )735 if ( is_subdomain_install() ) 736 736 return $data; 737 if ( $data[ 'post_type' ] != 'page' )737 if ( $data[ 'post_type' ] != 'page' ) 738 738 return $data; 739 if ( !isset( $data[ 'post_name' ] ) || $data[ 'post_name' ] == '' )739 if ( !isset( $data[ 'post_name' ] ) || $data[ 'post_name' ] == '' ) 740 740 return $data; 741 if ( !is_main_blog() )741 if ( !is_main_blog() ) 742 742 return $data; 743 743 … … 748 748 $c ++; 749 749 } 750 if ( $post_name != $data[ 'post_name' ] ) {750 if ( $post_name != $data[ 'post_name' ] ) { 751 751 $data[ 'post_name' ] = $post_name; 752 752 } … … 1034 1034 function remove_edit_plugin_link( $action_links, $plugin_file, $plugin_data, $context ) { 1035 1035 foreach( $action_links as $t => $link ) { 1036 if ( !strpos( $link, __( "Open this file in the Plugin Editor" ) ) )1036 if ( !strpos( $link, __( "Open this file in the Plugin Editor" ) ) ) 1037 1037 $links[ $t ] = $link; 1038 1038 } … … 1051 1051 $all_blogs = get_blogs_of_user( $current_user->ID ); 1052 1052 $primary_blog = get_usermeta($current_user->ID, 'primary_blog'); 1053 if ( count( $all_blogs ) > 1 ) {1053 if ( count( $all_blogs ) > 1 ) { 1054 1054 $found = false; 1055 1055 ?> 1056 1056 <select name="primary_blog"> 1057 1057 <?php foreach( (array) $all_blogs as $blog ) { 1058 if ( $primary_blog == $blog->userblog_id )1058 if ( $primary_blog == $blog->userblog_id ) 1059 1059 $found = true; 1060 ?><option value='<?php echo $blog->userblog_id ?>'<?php if ( $primary_blog == $blog->userblog_id ) echo ' selected="selected"' ?>>http://<?php echo $blog->domain.$blog->path ?></option><?php1060 ?><option value='<?php echo $blog->userblog_id ?>'<?php if ( $primary_blog == $blog->userblog_id ) echo ' selected="selected"' ?>>http://<?php echo $blog->domain.$blog->path ?></option><?php 1061 1061 } ?> 1062 1062 </select> 1063 1063 <?php 1064 if ( !$found ) {1064 if ( !$found ) { 1065 1065 $blog = array_shift( $all_blogs ); 1066 1066 update_usermeta( $current_user->ID, 'primary_blog', $blog->userblog_id ); 1067 1067 } 1068 } elseif ( count( $all_blogs ) == 1 ) {1068 } elseif ( count( $all_blogs ) == 1 ) { 1069 1069 $blog = array_shift( $all_blogs ); 1070 1070 echo $blog->domain; 1071 if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.1071 if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list. 1072 1072 update_usermeta( $current_user->ID, 'primary_blog', $blog->userblog_id ); 1073 1073 } else { … … 1082 1082 add_action ( 'myblogs_allblogs_options', 'choose_primary_blog' ); 1083 1083 1084 if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) ) {1084 if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) ) { 1085 1085 add_action( 'admin_init', 'update_profile_email' ); 1086 1086 add_action( 'admin_init', 'profile_page_email_warning_ob_start' ); … … 1133 1133 1134 1134 $blogs = get_blogs_of_user( $current_user->ID ); 1135 if ( !$blogs || ( is_array( $blogs ) && empty( $blogs ) ) ) {1135 if ( !$blogs || ( is_array( $blogs ) && empty( $blogs ) ) ) { 1136 1136 wp_die( __( 'You must be a member of at least one blog to use this page.' ) ); 1137 1137 } … … 1141 1141 ?> 1142 1142 <div class="wrap"> 1143 <?php if ( $_GET[ 'updated' ] ) { ?>1143 <?php if ( $_GET[ 'updated' ] ) { ?> 1144 1144 <div id="message" class="updated fade"><p><strong><?php _e( 'Your blog options have been updated.' ); ?></strong></p></div> 1145 1145 <?php } ?>
Note: See TracChangeset
for help on using the changeset viewer.