WordPress.org

Make WordPress Core

Ticket #14953: 14953-4.diff

File 14953-4.diff, 25.5 KB (added by SergeyBiryukov, 3 years ago)
  • wp-includes/ms-functions.php

     
    407407        return $id; 
    408408} 
    409409 
    410 // wpmu admin functions 
     410// Admin functions 
    411411 
     412/** 
     413 * Redirect a user based on $_GET or $_POST arguments. 
     414 * 
     415 * The function looks for redirect arguments in the following order: 
     416 * 1) $_GET['ref'] 
     417 * 2) $_POST['ref'] 
     418 * 3) $_SERVER['HTTP_REFERER'] 
     419 * 4) $_GET['redirect'] 
     420 * 5) $_POST['redirect'] 
     421 * 6) $url 
     422 * 
     423 * @since MU 
     424 * @uses wpmu_admin_redirect_add_updated_param() 
     425 * 
     426 * @param string $url 
     427 * @return none 
     428 */ 
    412429function wpmu_admin_do_redirect( $url = '' ) { 
    413430        $ref = ''; 
    414431        if ( isset( $_GET['ref'] ) ) 
     
    437454        exit(); 
    438455} 
    439456 
     457/** 
     458 * Adds an 'updated=true' argument to a URL. 
     459 * 
     460 * @since MU 
     461 * 
     462 * @param string $url 
     463 * @return string $url 
     464 */ 
    440465function wpmu_admin_redirect_add_updated_param( $url = '' ) { 
    441466        if ( strpos( $url, 'updated=true' ) === false ) { 
    442467                if ( strpos( $url, '?' ) === false ) 
     
    447472        return $url; 
    448473} 
    449474 
     475/** 
     476 * Checks an email address against a list of banned domains. 
     477 * 
     478 * This function checks against the Banned Email Domains list 
     479 * at wp-admin/network/settings.php. The check is only run on 
     480 * self-registrations; user creation at wp-admin/network/users.php 
     481 * bypasses this check.  
     482 * 
     483 * @since MU 
     484 * 
     485 * @param string $user_email The email provided by the user at registration. 
     486 * @return bool Returns true when the email address is banned. 
     487 */ 
    450488function is_email_address_unsafe( $user_email ) { 
    451489        $banned_names = get_site_option( 'banned_email_domains' ); 
    452490        if ($banned_names && !is_array( $banned_names )) 
     
    470508        return false; 
    471509} 
    472510 
     511/** 
     512 * Processes new user registrations. 
     513 * 
     514 * Checks the data provided by the user during signup. Verifies 
     515 * the validity and uniqueness of user names and user email addresses, 
     516 * and checks email addresses against admin-provided domain 
     517 * whitelists and blacklists. 
     518 * 
     519 * The hook 'wpmu_validate_user_signup' provides an easy way 
     520 * to modify the signup process. The value $result, which is passed 
     521 * to the hook, contains both the user-provided info and the error 
     522 * messages created by the function. 'wpmu_validate_user_signup' allows 
     523 * you to process the data in any way you'd like, and unset the 
     524 * relevant errors if necessary. 
     525 * 
     526 * @since MU 
     527 * @uses sanitize_user() 
     528 * @uses sanitize_email() 
     529 * @uses is_email_address_unsafe() 
     530 * @uses username_exists() 
     531 * @uses email_exists() 
     532 * @uses $wpdb 
     533 * 
     534 * @param string $user_name The login name provided by the user. 
     535 * @param string $user_email The email provided by the user. 
     536 * @return array $result Contains username, email, and error messages. 
     537 */ 
    473538function wpmu_validate_user_signup($user_name, $user_email) { 
    474539        global $wpdb; 
    475540 
     
    562627        return apply_filters('wpmu_validate_user_signup', $result); 
    563628} 
    564629 
     630/** 
     631 * Processes new site registrations. 
     632 * 
     633 * Checks the data provided by the user during blog signup. Verifies 
     634 * the validity and uniqueness of blog paths and domains. 
     635 * 
     636 * This function prevents the current user from registering a new site 
     637 * with a blogname equivalent to another user's login name. Passing the 
     638 * $user parameter to the function, where $user is the other user, is 
     639 * effectively an override of this limitation. 
     640 * 
     641 * Filter 'wpmu_validate_blog_signup' if you want to modify  
     642 * the way that WordPress validates new site signups. 
     643 * 
     644 * @since MU 
     645 * @uses is_subdomain_install() 
     646 * @uses domain_exists() 
     647 * @uses username_exists() 
     648 * @uses $wpdb 
     649 * 
     650 * @param string $blogname The blog name provided by the user. Must be unique. 
     651 * @param string $blog_title The blog title provided by the user. 
     652 * @return array $result Contains the new site data and error messages. 
     653 */ 
    565654function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') { 
    566655        global $wpdb, $domain, $base, $current_site; 
    567656 
     
    645734        return apply_filters('wpmu_validate_blog_signup', $result); 
    646735} 
    647736 
    648 // Record signup information for future activation. wpmu_validate_signup() should be run 
    649 // on the inputs before calling wpmu_signup(). 
     737/** 
     738 * Record site signup information for future activation. 
     739 * 
     740 * @since MU 
     741 * @uses wpmu_signup_blog_notification() 
     742 * @uses $wpdb 
     743 * 
     744 * @param string $domain The requested domain. 
     745 * @param string $path The requested path. 
     746 * @param string $title The requested site title. 
     747 * @param string $user The user's requested login name. 
     748 * @param string $user_email The user's email address. 
     749 * @param array $meta By default, contains the requested privacy setting and lang_id. 
     750 * @return none 
     751 */ 
    650752function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = '') { 
    651753        global $wpdb; 
    652754 
     
    670772        wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta); 
    671773} 
    672774 
     775/** 
     776 * Record user signup information for future activation. 
     777 * 
     778 * This function is used when user registration is open but 
     779 * new site registration is not. 
     780 * 
     781 * @since MU 
     782 * @uses wpmu_signup_user_notification() 
     783 * @uses $wpdb 
     784 * 
     785 * @param string $user The user's requested login name. 
     786 * @param string $user_email The user's email address. 
     787 * @param array $meta By default, this is an empty array. 
     788 * @return none 
     789 */ 
    673790function wpmu_signup_user($user, $user_email, $meta = '') { 
    674791        global $wpdb; 
    675792 
     
    693810        wpmu_signup_user_notification($user, $user_email, $key, $meta); 
    694811} 
    695812 
    696 // Notify user of signup success. 
     813/** 
     814 * Notify user of signup success. 
     815 * 
     816 * This is the notification function used when site registration 
     817 * is enabled. 
     818 * 
     819 * Filter 'wpmu_signup_blog_notification' to bypass this function or 
     820 * replace it with your own notification behavior. 
     821 * 
     822 * Filter 'wpmu_signup_blog_notification_email' and 
     823 * 'wpmu_signup_blog_notification_email' to change the content 
     824 * and subject line of the email sent to newly registered users. 
     825 * 
     826 * @since MU 
     827 * @uses is_subdomain_install() 
     828 * @uses wp_mail() 
     829 * 
     830 * @param string $domain The new blog domain. 
     831 * @param string $path The new blog path. 
     832 * @param string $title The site title. 
     833 * @param string $user The user's login name. 
     834 * @param string $user_email The user's email address. 
     835 * @param array $meta By default, contains the requested privacy setting and lang_id. 
     836 * @param string $key The activation key created in wpmu_signup_blog() 
     837 * @return bool 
     838 */ 
    697839function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta = '') { 
    698840        global $current_site; 
    699841 
     
    734876        return true; 
    735877} 
    736878 
     879/** 
     880 * Notify user of signup success. 
     881 * 
     882 * This is the notification function used when no new site has 
     883 * been requested. 
     884 * 
     885 * Filter 'wpmu_signup_user_notification' to bypass this function or 
     886 * replace it with your own notification behavior. 
     887 * 
     888 * Filter 'wpmu_signup_user_notification_email' and 
     889 * 'wpmu_signup_user_notification_subject' to change the content 
     890 * and subject line of the email sent to newly registered users. 
     891 * 
     892 * @since MU 
     893 * @uses wp_mail() 
     894 * 
     895 * @param string $user The user's login name. 
     896 * @param string $user_email The user's email address. 
     897 * @param array $meta By default, an empty array. 
     898 * @param string $key The activation key created in wpmu_signup_user() 
     899 * @return bool 
     900 */ 
    737901function wpmu_signup_user_notification($user, $user_email, $key, $meta = '') { 
    738902        if ( !apply_filters('wpmu_signup_user_notification', $user, $user_email, $key, $meta) ) 
    739903                return false; 
     
    765929        return true; 
    766930} 
    767931 
     932/** 
     933 * Activate a signup. 
     934 * 
     935 * Hook to 'wpmu_activate_user' or 'wpmu_activate_blog' for events 
     936 * that should happen only when users or sites are self-created (since 
     937 * those actions are not called when users and sites are created 
     938 * by a Super Admin). 
     939 * 
     940 * @since MU 
     941 * @uses $wpdb 
     942 * @uses wp_generate_password() 
     943 * @uses wpmu_welcome_user_notification() 
     944 * @uses add_user_to_blog() 
     945 * @uses add_new_user_to_blog() 
     946 * @uses wpmu_create_user() 
     947 * @uses wpmu_create_blog() 
     948 * @uses wpmu_welcome_notification() 
     949 * 
     950 * @param string $key The activation key provided to the user. 
     951 * @return array An array containing information about the activated user and/or blog 
     952 */ 
    768953function wpmu_activate_signup($key) { 
    769954        global $wpdb, $current_site; 
    770955 
     
    8301015        return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta); 
    8311016} 
    8321017 
     1018/** 
     1019 * Create a user. 
     1020 * 
     1021 * This function runs when a user self-registers as well as when 
     1022 * a Super Admin creates a new user. Hook to 'wpmu_new_user' for events 
     1023 * that should affect all new users, but only on Multisite (otherwise 
     1024 * use 'user_register'). 
     1025 * 
     1026 * @since MU 
     1027 * @uses wp_create_user() 
     1028 * @uses delete_user_option() 
     1029 * 
     1030 * @param string $user_name The new user's login name. 
     1031 * @param string $password The new user's password. 
     1032 * @param string $email The new user's email address. 
     1033 * @return mixed Returns false on failure, or int $user_id on success 
     1034 */ 
    8331035function wpmu_create_user( $user_name, $password, $email) { 
    8341036        $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); 
    8351037 
     
    8461048        return $user_id; 
    8471049} 
    8481050 
     1051/** 
     1052 * Create a site. 
     1053 * 
     1054 * This function runs when a user self-registers a new site as well 
     1055 * as when a Super Admin creates a new site. Hook to 'wpmu_new_blog' 
     1056 * for events that should affect all new sites. 
     1057 * 
     1058 * On subdirectory installs, $domain is the same as the main site's 
     1059 * domain, and the path is the subdirectory name (eg 'example.com' 
     1060 * and '/blog1/'). On subdomain installs, $domain is the new subdomain + 
     1061 * root domain (eg 'blog1.example.com'), and $path is '/'. 
     1062 * 
     1063 * @since MU 
     1064 * @uses is_subdomain_install() 
     1065 * @uses domain_exists() 
     1066 * @uses insert_blog() 
     1067 * @uses switch_to_blog() 
     1068 * @uses wp_install_defaults() 
     1069 * @uses add_user_to_blog() 
     1070 * @uses update_blog_status() 
     1071 * @uses restore_current_blog() 
     1072 * 
     1073 * @param string $domain The new site's domain. 
     1074 * @param string $path The new site's path. 
     1075 * @param string $title The new site's title. 
     1076 * @param int $user_id The user ID of the new site's admin. 
     1077 * @param array $meta Optional. Used to set initial site options. 
     1078 * @param int $site_id Optional. Only relevant on multi-network installs. 
     1079 * @return mixed Returns WP_Error object on failure, int $blog_id on success 
     1080 */ 
    8491081function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) { 
    8501082        $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) ); 
    8511083 
     
    8931125        return $blog_id; 
    8941126} 
    8951127 
     1128/** 
     1129 * Notifies the network admin that a new site has been activated. 
     1130 * 
     1131 * Filter 'newblog_notify_siteadmin' to change the content of 
     1132 * the notification email. 
     1133 * 
     1134 * @since MU 
     1135 * @uses switch_to_blog() 
     1136 * @uses restore_current_blog() 
     1137 * @uses wp_mail() 
     1138 * 
     1139 * @param int $blog_id The new site's ID. 
     1140 * @return bool 
     1141 */ 
    8961142function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) { 
    8971143        if ( get_site_option( 'registrationnotification' ) != 'yes' ) 
    8981144                return false; 
     
    9191165        return true; 
    9201166} 
    9211167 
     1168/** 
     1169 * Notifies the network admin that a new user has been activated. 
     1170 * 
     1171 * Filter 'newuser_notify_siteadmin' to change the content of 
     1172 * the notification email. 
     1173 * 
     1174 * @since MU 
     1175 * @uses wp_mail() 
     1176 * 
     1177 * @param int $user_id The new user's ID. 
     1178 * @return bool 
     1179 */ 
    9221180function newuser_notify_siteadmin( $user_id ) { 
    9231181        if ( get_site_option( 'registrationnotification' ) != 'yes' ) 
    9241182                return false; 
     
    9411199        return true; 
    9421200} 
    9431201 
     1202/** 
     1203 * Check whether a blogname is already taken. 
     1204 * 
     1205 * Used during the new site registration process to ensure 
     1206 * that each blogname is unique. 
     1207 * 
     1208 * @since MU 
     1209 * @uses $wpdb 
     1210 * 
     1211 * @param string $domain The domain to be checked. 
     1212 * @param string $path The path to be checked. 
     1213 * @param int $site_id Optional. Relevant only on multi-network installs. 
     1214 * @return int $blog_id 
     1215 */ 
    9441216function domain_exists($domain, $path, $site_id = 1) { 
    9451217        global $wpdb; 
    9461218        return $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s AND site_id = %d", $domain, $path, $site_id) ); 
    9471219} 
    9481220 
     1221/** 
     1222 * Store basic site info in the blogs table. 
     1223 * 
     1224 * This function creates a row in the wp_blogs table and returns 
     1225 * the new blog's ID. It is the first step in creating a new blog. 
     1226 * 
     1227 * @since MU 
     1228 * @uses $wpdb 
     1229 * @uses refresh_blog_details() 
     1230 * 
     1231 * @param string $domain The domain of the new site. 
     1232 * @param string $path The path of the new site. 
     1233 * @param int $site_id Unless you're running a multi-network install, be sure to set this value to 1. 
     1234 * @return int $blog_id The ID of the new row 
     1235 */ 
    9491236function insert_blog($domain, $path, $site_id) { 
    9501237        global $wpdb; 
    9511238 
     
    9601247        return $wpdb->insert_id; 
    9611248} 
    9621249 
    963 // Install an empty blog.  wpdb should already be switched. 
     1250/** 
     1251 * Install an empty blog. 
     1252 * 
     1253 * Creates the new blog tables and options. If calling this function 
     1254 * directly, be sure to use switch_to_blog() first, so that $wpdb 
     1255 * points to the new blog. 
     1256 * 
     1257 * @since MU 
     1258 * @uses $wpdb 
     1259 * @uses make_db_current_silent() 
     1260 * @uses populate_roles() 
     1261 * 
     1262 * @param int $blog_id The value returned by insert_blog(). 
     1263 * @param string $blog_title The title of the new site. 
     1264 * @return none 
     1265 */ 
    9641266function install_blog($blog_id, $blog_title = '') { 
    9651267        global $wpdb, $table_prefix, $wp_roles; 
    9661268        $wpdb->suppress_errors(); 
     
    9991301        $wpdb->suppress_errors( false ); 
    10001302} 
    10011303 
    1002 // Deprecated, use wp_install_defaults() 
    1003 // should be switched already as $blog_id is ignored. 
     1304/** 
     1305 * Set blog defaults. 
     1306 * 
     1307 * This function creates a row in the wp_blogs table. 
     1308 * 
     1309 * @since MU 
     1310 * @deprecated MU 
     1311 * @deprecated Use wp_install_defaults() 
     1312 * @uses wp_install_defaults() 
     1313 * 
     1314 * @param int $blog_id Ignored in this function. 
     1315 * @param int $user_id 
     1316 * @return none 
     1317 */ 
    10041318function install_blog_defaults($blog_id, $user_id) { 
    10051319        global $wpdb; 
    10061320 
     
    10131327        $wpdb->suppress_errors( false ); 
    10141328} 
    10151329 
     1330/** 
     1331 * Notify a user that her blog activation has been successful. 
     1332 * 
     1333 * Filter 'wpmu_welcome_notification' to disable or bypass. 
     1334 * 
     1335 * Filter 'update_welcome_email' and 'update_welcome_subject' to 
     1336 * modify the content and subject line of the notification email. 
     1337 * 
     1338 * @since MU 
     1339 * @uses wp_mail() 
     1340 * 
     1341 * @param int $blog_id 
     1342 * @param int $user_id 
     1343 * @param string $password 
     1344 * @param string $title The new blog's title 
     1345 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. 
     1346 * @return bool 
     1347 */ 
    10161348function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = '') { 
    10171349        global $current_site; 
    10181350 
     
    10631395        return true; 
    10641396} 
    10651397 
     1398/** 
     1399 * Notify a user that her account activation has been successful. 
     1400 * 
     1401 * Filter 'wpmu_welcome_user_notification' to disable or bypass. 
     1402 * 
     1403 * Filter 'update_welcome_user_email' and 'update_welcome_user_subject' to 
     1404 * modify the content and subject line of the notification email. 
     1405 * 
     1406 * @since MU 
     1407 * @uses wp_mail() 
     1408 * 
     1409 * @param int $user_id 
     1410 * @param string $password 
     1411 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. 
     1412 * @return bool 
     1413 */ 
    10661414function wpmu_welcome_user_notification($user_id, $password, $meta = '') { 
    10671415        global $current_site; 
    10681416 
     
    10961444        return true; 
    10971445} 
    10981446 
     1447/** 
     1448 * Get the current site info. 
     1449 * 
     1450 * Returns an object containing the ID, domain, path, and site_name 
     1451 * of the site being viewed. 
     1452 * 
     1453 * @since MU 
     1454 * 
     1455 * @return object $current_site 
     1456 */ 
    10991457function get_current_site() { 
    11001458        global $current_site; 
    11011459        return $current_site; 
    11021460} 
    11031461 
     1462/** 
     1463 * Get a numeric user ID from either an email address or a login. 
     1464 * 
     1465 * @since MU 
     1466 * @uses is_email() 
     1467 * @uses get_user_by() 
     1468 * 
     1469 * @param string $string 
     1470 * @return int $user_id 
     1471 */ 
    11041472function get_user_id_from_string( $string ) { 
    11051473        $user_id = 0; 
    11061474        if ( is_email( $string ) ) { 
     
    11181486        return $user_id; 
    11191487} 
    11201488 
     1489/** 
     1490 * Get a user's most recent post. 
     1491 * 
     1492 * Walks through each of a user's blogs to find the post with 
     1493 * the most recent post_date_gmt. 
     1494 * 
     1495 * @since MU 
     1496 * @uses $wpdb 
     1497 * @uses get_blogs_of_user() 
     1498 * 
     1499 * @param int $user_id 
     1500 * @return array $most_recent_post Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts 
     1501 */ 
    11211502function get_most_recent_post_of_user( $user_id ) { 
    11221503        global $wpdb; 
    11231504 
     
    11501531        return $most_recent_post; 
    11511532} 
    11521533 
    1153 /* Misc functions */ 
     1534// Misc functions 
     1535 
     1536/** 
     1537 * Get the size of a directory. 
     1538 * 
     1539 * A helper function that is used primarily to check whether 
     1540 * a blog has exceeded its allowed upload space. 
     1541 * 
     1542 * @since MU 
     1543 * @uses $wpdb 
     1544 * @uses recurse_dirsize() 
     1545 * 
     1546 * @param string $directory 
     1547 * @return int 
     1548 */ 
    11541549function get_dirsize( $directory ) { 
    11551550        $dirsize = get_transient( 'dirsize_cache' ); 
    11561551        if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) 
     
    11651560        return $dirsize[ $directory ][ 'size' ]; 
    11661561} 
    11671562 
     1563/** 
     1564 * Get the size of a directory recursively. 
     1565 * 
     1566 * Used by get_dirsize() to get a directory's size when it contains 
     1567 * other directories. 
     1568 * 
     1569 * @since MU 
     1570 * 
     1571 * @param string $directory 
     1572 * @return int $size 
     1573 */ 
    11681574function recurse_dirsize( $directory ) { 
    11691575        $size = 0; 
    11701576 
     
    11921598        return $size; 
    11931599} 
    11941600 
     1601/** 
     1602 * Check whether a blog has used its allotted upload space. 
     1603 * 
     1604 * Used by get_dirsize() to get a directory's size when it contains 
     1605 * other directories. 
     1606 * 
     1607 * @since MU 
     1608 * @uses get_dirsize() 
     1609 * 
     1610 * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true. 
     1611 * @return int $size 
     1612 */ 
    11951613function upload_is_user_over_quota( $echo = true ) { 
    11961614        if ( get_site_option( 'upload_space_check_disabled' ) ) 
    11971615                return false; 
     
    12121630        } 
    12131631} 
    12141632 
     1633/** 
     1634 * Check an array of MIME types against a whitelist. 
     1635 * 
     1636 * WordPress ships with a set of allowed upload filetypes,  
     1637 * which is defined in wp-includes/functions.php in 
     1638 * get_allowed_mime_types(). This function is used to filter 
     1639 * that list against the filetype whitelist provided by Multisite  
     1640 * Super Admins at wp-admin/network/settings.php.  
     1641 * 
     1642 * @since MU 
     1643 * @uses get_site_option() 
     1644 * 
     1645 * @param array $mimes 
     1646 * @return array $site_mimes 
     1647 */ 
    12151648function check_upload_mimes( $mimes ) { 
    12161649        $site_exts = explode( ' ', get_site_option( 'upload_filetypes' ) ); 
    12171650        foreach ( $site_exts as $ext ) { 
     
    12231656        return $site_mimes; 
    12241657} 
    12251658 
     1659/** 
     1660 * Update a blog's post count. 
     1661 * 
     1662 * WordPress MS stores a blog's post count as an option so as 
     1663 * to avoid extraneous COUNTs when a blog's details are fetched 
     1664 * with get_blog_details(). This function is called when posts 
     1665 * are published to make sure the count stays current. 
     1666 * 
     1667 * @since MU 
     1668 * @uses $wpdb 
     1669 * 
     1670 * @return none 
     1671 */ 
    12261672function update_posts_count( $deprecated = '' ) { 
    12271673        global $wpdb; 
    12281674        update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) ); 
    12291675} 
    12301676 
     1677/** 
     1678 * Logs user registrations. 
     1679 * 
     1680 * @since MU 
     1681 * @uses $wpdb 
     1682 * 
     1683 * @param int $blog_id 
     1684 * @param int $user_id 
     1685 * @return none 
     1686 */ 
    12311687function wpmu_log_new_registrations( $blog_id, $user_id ) { 
    12321688        global $wpdb; 
    12331689        $user = new WP_User( (int) $user_id ); 
    12341690        $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) ); 
    12351691} 
    12361692 
     1693/** 
     1694 * Get the remaining upload space for this blog. 
     1695 * 
     1696 * @since MU 
     1697 * @uses upload_is_user_over_quota() 
     1698 * @uses get_space_allowed() 
     1699 * @uses get_dirsize() 
     1700 * 
     1701 * @param int $size 
     1702 * @return int $size 
     1703 */ 
    12371704function fix_import_form_size( $size ) { 
    12381705        if ( upload_is_user_over_quota( false ) == true ) 
    12391706                return 0; 
     
    13151782        return $global_id; 
    13161783} 
    13171784 
     1785/** 
     1786 * Ensure that the current site's domain is listed in the allowed redirect host list. 
     1787 * 
     1788 * @see wp_validate_redirect() 
     1789 * 
     1790 * @since MU 
     1791 * 
     1792 * @return array The current site's domain 
     1793 */ 
    13181794function redirect_this_site( $deprecated = '' ) { 
    13191795        global $current_site; 
    13201796        return array( $current_site->domain ); 
    13211797} 
    13221798 
     1799/** 
     1800 * Check whether an upload is too big. 
     1801 * 
     1802 * @since MU 
     1803 * 
     1804 * @param array $upload 
     1805 * @return mixed If the upload is under the size limit, $upload is returned. Otherwise returns an error message. 
     1806 */ 
    13231807function upload_is_file_too_big( $upload ) { 
    13241808        if ( is_array( $upload ) == false || defined( 'WP_IMPORTING' ) ) 
    13251809                return $upload; 
     
    13301814        return $upload; 
    13311815} 
    13321816 
     1817/** 
     1818 * Add a nonce field to the signup page. 
     1819 * 
     1820 * @since MU 
     1821 * @uses wp_nonce_field() 
     1822 * 
     1823 * @return none 
     1824 */ 
    13331825function signup_nonce_fields() { 
    13341826        $id = mt_rand(); 
    13351827        echo "<input type='hidden' name='signup_form_id' value='{$id}' />"; 
    13361828        wp_nonce_field('signup_form_' . $id, '_signup_form', false); 
    13371829} 
    13381830 
     1831/** 
     1832 * Process the signup nonce created in signup_nonce_fields(). 
     1833 * 
     1834 * @since MU 
     1835 * @uses wp_create_nonce() 
     1836 * 
     1837 * @param array $result 
     1838 * @return array $result 
     1839 */ 
    13391840function signup_nonce_check( $result ) { 
    13401841        if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) ) 
    13411842                return $result; 
     
    13461847        return $result; 
    13471848} 
    13481849 
     1850/** 
     1851 * Correct 404 redirects when NOBLOGREDIRECT is defined. 
     1852 * 
     1853 * @since MU 
     1854 * @uses is_main_site() 
     1855 * @uses is_404() 
     1856 * @uses network_home_url() 
     1857 * @uses wp_redirect() 
     1858 * 
     1859 * @return none 
     1860 */ 
    13491861function maybe_redirect_404() { 
    13501862        global $current_site; 
    13511863        if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) { 
     
    13561868        } 
    13571869} 
    13581870 
     1871/** 
     1872 * Add a new user to a blog by visiting /newbloguser/username/. 
     1873 * 
     1874 * This will only work when the user's details are saved as an option 
     1875 * keyed as 'new_user_x', where 'x' is the username of the user to be 
     1876 * added, as when a user is invited through the regular WP Add User interface. 
     1877 * 
     1878 * @since MU 
     1879 * @uses add_existing_user_to_blog() 
     1880 * 
     1881 * @return none 
     1882 */      
    13591883function maybe_add_existing_user_to_blog() { 
    13601884        if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) 
    13611885                return false; 
     
    13761900        wp_die( sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">login</a> using your username and password.'), site_url(), admin_url() ), __('Success') ); 
    13771901} 
    13781902 
     1903/** 
     1904 * Add a user to a blog based on details from maybe_add_existing_user_to_blog(). 
     1905 * 
     1906 * @since MU 
     1907 * @uses add_user_to_blog() 
     1908 *  
     1909 * @param array $details 
     1910 * @return none 
     1911 */      
    13791912function add_existing_user_to_blog( $details = false ) { 
    13801913        global $blog_id; 
    13811914 
     
    13861919        return $result; 
    13871920} 
    13881921 
     1922/** 
     1923 * Add a newly created user to the appropriate blog 
     1924 * 
     1925 * @since MU 
     1926 * @uses remove_user_from_blog() 
     1927 * @uses add_user_to_blog() 
     1928 * @uses update_user_meta() 
     1929 *  
     1930 * @param int $user_id 
     1931 * @param string $email 
     1932 * @param array $meta 
     1933 * @return none 
     1934 */      
    13891935function add_new_user_to_blog( $user_id, $email, $meta ) { 
    13901936        global $current_site; 
    13911937        if ( $meta[ 'add_to_blog' ] ) { 
     
    13971943        } 
    13981944} 
    13991945 
     1946/** 
     1947 * Correct From host on outgoing mail to match the site domain 
     1948 * 
     1949 * @since MU 
     1950 * 
     1951 * @return none 
     1952 */      
    14001953function fix_phpmailer_messageid( $phpmailer ) { 
    14011954        global $current_site; 
    14021955        $phpmailer->Hostname = $current_site->domain; 
    14031956} 
    14041957 
     1958/** 
     1959 * Check to see whether a user is marked as a spammer, based on username 
     1960 * 
     1961 * @since MU 
     1962 * @uses get_current_user_id() 
     1963 * @uses get_user_id_from_string() 
     1964 * 
     1965 * @param string $username 
     1966 * @return bool 
     1967 */      
    14051968function is_user_spammy( $username = 0 ) { 
    14061969        if ( $username == 0 ) { 
    14071970                $user_id = get_current_user_id(); 
     
    14131976        return ( isset( $u->spam ) && $u->spam == 1 ); 
    14141977} 
    14151978 
     1979/** 
     1980 * Update this blog's 'public' setting in the global blogs table. 
     1981 * 
     1982 * Public blogs have a setting of 1, private blogs are 0. 
     1983 * 
     1984 * @since MU 
     1985 * @uses update_blog_status() 
     1986 * 
     1987 * @param int $old_value 
     1988 * @param int $value The new public value 
     1989 * @return bool 
     1990 */      
    14161991function update_blog_public( $old_value, $value ) { 
    14171992        global $wpdb; 
    14181993        do_action('update_blog_public'); 
     
    14201995} 
    14211996add_action('update_option_blog_public', 'update_blog_public', 10, 2); 
    14221997 
     1998/** 
     1999 * Get the "dashboard blog", the blog where users without a blog edit their profile data. 
     2000 * 
     2001 * @since MU 
     2002 * @uses get_blog_details() 
     2003 * 
     2004 * @return int 
     2005 */      
    14232006function get_dashboard_blog() { 
    14242007        if ( $blog = get_site_option( 'dashboard_blog' ) ) 
    14252008                return get_blog_details( $blog ); 
     
    14272010        return get_blog_details( $GLOBALS['current_site']->blog_id ); 
    14282011} 
    14292012 
     2013/** 
     2014 * Check whether a usermeta key has to do with the current blog. 
     2015 * 
     2016 * @since MU 
     2017 * @uses wp_get_current_user() 
     2018 * 
     2019 * @param string $key 
     2020 * @param int $user_id Optional. Defaults to current user. 
     2021 * @param int $blog_id Optional. Defaults to current blog. 
     2022 * @return bool 
     2023 */      
    14302024function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) { 
    14312025        global $wpdb; 
    14322026 
     
    14442038        return false; 
    14452039} 
    14462040 
     2041/** 
     2042 * Check whether users can self-register, based on Network settings. 
     2043 * 
     2044 * @since MU 
     2045 * 
     2046 * @return bool 
     2047 */      
    14472048function users_can_register_signup_filter() { 
    14482049        $registration = get_site_option('registration'); 
    14492050        if ( $registration == 'all' || $registration == 'user' ) 
     
    14532054} 
    14542055add_filter('option_users_can_register', 'users_can_register_signup_filter'); 
    14552056 
     2057/** 
     2058 * Ensure that the welcome message is not empty. Currently unused. 
     2059 * 
     2060 * @since MU 
     2061 * 
     2062 * @param string $text 
     2063 * @return string $text 
     2064 */      
    14562065function welcome_user_msg_filter( $text ) { 
    14572066        if ( !$text ) { 
    14582067                return __( 'Dear User, 
     
    15402149        update_site_option( 'user_count', $count ); 
    15412150} 
    15422151 
    1543 ?> 
     2152?> 
     2153 No newline at end of file