WordPress.org

Make WordPress Core

Ticket #14953: 14953-3.diff

File 14953-3.diff, 26.3 KB (added by SergeyBiryukov, 7 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 * @uses get_site_option()
     485 *
     486 * @param string $user_email The email provided by the user at registration.
     487 * @return bool Returns true when the email address is banned.
     488 */
    450489function is_email_address_unsafe( $user_email ) {
    451490        $banned_names = get_site_option( 'banned_email_domains' );
    452491        if ($banned_names && !is_array( $banned_names ))
     
    470509        return false;
    471510}
    472511
     512/**
     513 * Processes new user registrations.
     514 *
     515 * Checks the data provided by the user during signup. Verifies
     516 * the validity and uniqueness of user names and user email addresses,
     517 * and checks email addresses against admin-provided domain
     518 * whitelists and blacklists.
     519 *
     520 * The hook 'wpmu_validate_user_signup' provides an easy way
     521 * to modify the signup process. The value $result, which is passed
     522 * to the hook, contains both the user-provided info and the error
     523 * messages created by the function. 'wpmu_validate_user_signup' allows
     524 * you to process the data in any way you'd like, and unset the
     525 * relevant errors if necessary.
     526 *
     527 * @since MU
     528 * @uses sanitize_user()
     529 * @uses sanitize_email()
     530 * @uses get_site_option()
     531 * @uses is_email_address_unsafe()
     532 * @uses username_exists()
     533 * @uses email_exists()
     534 * @uses $wpdb
     535 *
     536 * @param string $user_name The login name provided by the user.
     537 * @param string $user_email The email provided by the user.
     538 * @return array $result Contains username, email, and error messages.
     539 */
    473540function wpmu_validate_user_signup($user_name, $user_email) {
    474541        global $wpdb;
    475542
     
    562629        return apply_filters('wpmu_validate_user_signup', $result);
    563630}
    564631
     632/**
     633 * Processes new site registrations.
     634 *
     635 * Checks the data provided by the user during blog signup. Verifies
     636 * the validity and uniqueness of blog paths and domains.
     637 *
     638 * This function prevents the current user from registering a new site
     639 * with a blogname equivalent to another user's login name. Passing the
     640 * $user parameter to the function, where $user is the other user, is
     641 * effectively an override of this limitation.
     642 *
     643 * Filter 'wpmu_validate_blog_signup' if you want to modify
     644 * the way that WordPress validates new site signups.
     645 *
     646 * @since MU
     647 * @uses is_subdomain_install()
     648 * @uses add_site_option()
     649 * @uses get_site_option()
     650 * @uses domain_exists()
     651 * @uses username_exists()
     652 * @uses $wpdb
     653 *
     654 * @param string $blogname The blog name provided by the user. Must be unique.
     655 * @param string $blog_title The blog title provided by the user.
     656 * @return array $result Contains the new site data and error messages.
     657 */
    565658function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
    566659        global $wpdb, $domain, $base, $current_site;
    567660
     
    645738        return apply_filters('wpmu_validate_blog_signup', $result);
    646739}
    647740
    648 // Record signup information for future activation. wpmu_validate_signup() should be run
    649 // on the inputs before calling wpmu_signup().
     741/**
     742 * Record site signup information for future activation.
     743 *
     744 * @since MU
     745 * @uses wpmu_signup_blog_notification()
     746 * @uses $wpdb
     747 *
     748 * @param string $domain The requested domain.
     749 * @param string $path The requested path.
     750 * @param string $title The requested site title.
     751 * @param string $user The user's requested login name.
     752 * @param string $user_email The user's email address.
     753 * @param array $meta By default, contains the requested privacy setting and lang_id.
     754 * @return none
     755 */
    650756function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = '') {
    651757        global $wpdb;
    652758
     
    670776        wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta);
    671777}
    672778
     779/**
     780 * Record user signup information for future activation.
     781 *
     782 * This function is used when user registration is open but
     783 * new site registration is not.
     784 *
     785 * @since MU
     786 * @uses wpmu_signup_user_notification()
     787 * @uses $wpdb
     788 *
     789 * @param string $user The user's requested login name.
     790 * @param string $user_email The user's email address.
     791 * @param array $meta By default, this is an empty array.
     792 * @return none
     793 */
    673794function wpmu_signup_user($user, $user_email, $meta = '') {
    674795        global $wpdb;
    675796
     
    693814        wpmu_signup_user_notification($user, $user_email, $key, $meta);
    694815}
    695816
    696 // Notify user of signup success.
     817/**
     818 * Notify user of signup success.
     819 *
     820 * This is the notification function used when site registration
     821 * is enabled.
     822 *
     823 * Filter 'wpmu_signup_blog_notification' to bypass this function or
     824 * replace it with your own notification behavior.
     825 *
     826 * Filter 'wpmu_signup_blog_notification_email' and
     827 * 'wpmu_signup_blog_notification_email' to change the content
     828 * and subject line of the email sent to newly registered users.
     829 *
     830 * @since MU
     831 * @uses is_subdomain_install()
     832 * @uses get_site_option()
     833 * @uses wp_mail()
     834 *
     835 * @param string $domain The new blog domain.
     836 * @param string $path The new blog path.
     837 * @param string $title The site title.
     838 * @param string $user The user's login name.
     839 * @param string $user_email The user's email address.
     840 * @param array $meta By default, contains the requested privacy setting and lang_id.
     841 * @param string $key The activation key created in wpmu_signup_blog()
     842 * @return bool
     843 */
    697844function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta = '') {
    698845        global $current_site;
    699846
     
    734881        return true;
    735882}
    736883
     884/**
     885 * Notify user of signup success.
     886 *
     887 * This is the notification function used when no new site has
     888 * been requested.
     889 *
     890 * Filter 'wpmu_signup_user_notification' to bypass this function or
     891 * replace it with your own notification behavior.
     892 *
     893 * Filter 'wpmu_signup_user_notification_email' and
     894 * 'wpmu_signup_user_notification_subject' to change the content
     895 * and subject line of the email sent to newly registered users.
     896 *
     897 * @since MU
     898 * @uses get_site_option()
     899 * @uses site_url()
     900 * @uses wp_mail()
     901 *
     902 * @param string $user The user's login name.
     903 * @param string $user_email The user's email address.
     904 * @param array $meta By default, an empty array.
     905 * @param string $key The activation key created in wpmu_signup_user()
     906 * @return bool
     907 */
    737908function wpmu_signup_user_notification($user, $user_email, $key, $meta = '') {
    738909        if ( !apply_filters('wpmu_signup_user_notification', $user, $user_email, $key, $meta) )
    739910                return false;
     
    765936        return true;
    766937}
    767938
     939/**
     940 * Activate a signup.
     941 *
     942 * Hook to 'wpmu_activate_user' or 'wpmu_activate_blog' for events
     943 * that should happen only when users or sites are self-created (since
     944 * those actions are not called when users and sites are created
     945 * by a Super Admin).
     946 *
     947 * @since MU
     948 * @uses $wpdb
     949 * @uses wp_generate_password()
     950 * @uses wpmu_welcome_user_notification()
     951 * @uses get_site_option()
     952 * @uses add_user_to_blog()
     953 * @uses add_new_user_to_blog()
     954 * @uses wpmu_create_user()
     955 * @uses wpmu_create_blog()
     956 * @uses is_wp_error()
     957 * @uses wpmu_welcome_notification()
     958 *
     959 * @param string $key The activation key provided to the user.
     960 * @return array An array containing information about the activated user and/or blog
     961 */
    768962function wpmu_activate_signup($key) {
    769963        global $wpdb, $current_site;
    770964
     
    8301024        return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
    8311025}
    8321026
     1027/**
     1028 * Create a user.
     1029 *
     1030 * This function runs when a user self-registers as well as when
     1031 * a Super Admin creates a new user. Hook to 'wpmu_new_user' for events
     1032 * that should affect all new users, but only on Multisite (otherwise
     1033 * use 'user_register').
     1034 *
     1035 * @since MU
     1036 * @uses wp_create_user()
     1037 * @uses is_wp_error()
     1038 * @uses delete_user_option()
     1039 *
     1040 * @param string $user_name The new user's login name.
     1041 * @param string $password The new user's password.
     1042 * @param string $email The new user's email address.
     1043 * @return mixed Returns false on failure, or int $user_id on success
     1044 */
    8331045function wpmu_create_user( $user_name, $password, $email) {
    8341046        $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
    8351047
     
    8461058        return $user_id;
    8471059}
    8481060
     1061/**
     1062 * Create a site.
     1063 *
     1064 * This function runs when a user self-registers a new site as well
     1065 * as when a Super Admin creates a new site. Hook to 'wpmu_new_blog'
     1066 * for events that should affect all new sites.
     1067 *
     1068 * On subdirectory installs, $domain is the same as the main site's
     1069 * domain, and the path is the subdirectory name (eg 'example.com'
     1070 * and '/blog1/'). On subdomain installs, $domain is the new subdomain +
     1071 * root domain (eg 'blog1.example.com'), and $path is '/'.
     1072 *
     1073 * @since MU
     1074 * @uses is_subdomain_install()
     1075 * @uses domain_exists()
     1076 * @uses insert_blog()
     1077 * @uses switch_to_blog()
     1078 * @uses wp_install_defaults()
     1079 * @uses add_user_to_blog()
     1080 * @uses update_blog_status()
     1081 * @uses restore_current_blog()
     1082 *
     1083 * @param string $domain The new site's domain.
     1084 * @param string $path The new site's path.
     1085 * @param string $title The new site's title.
     1086 * @param int $user_id The user ID of the new site's admin.
     1087 * @param array $meta Optional. Used to set initial site options.
     1088 * @param int $site_id Optional. Only relevant on multi-network installs.
     1089 * @return mixed Returns WP_Error object on failure, int $blog_id on success
     1090 */
    8491091function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
    8501092        $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
    8511093
     
    8931135        return $blog_id;
    8941136}
    8951137
     1138/**
     1139 * Notifies the network admin that a new site has been activated.
     1140 *
     1141 * Filter 'newblog_notify_siteadmin' to change the content of
     1142 * the notification email.
     1143 *
     1144 * @since MU
     1145 * @uses switch_to_blog()
     1146 * @uses site_url()
     1147 * @uses get_site_option()
     1148 * @uses network_admin_url()
     1149 * @uses restore_current_blog()
     1150 * @uses wp_mail()
     1151 *
     1152 * @param int $blog_id The new site's ID.
     1153 * @return bool
     1154 */
    8961155function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
    8971156        if ( get_site_option( 'registrationnotification' ) != 'yes' )
    8981157                return false;
     
    9191178        return true;
    9201179}
    9211180
     1181/**
     1182 * Notifies the network admin that a new user has been activated.
     1183 *
     1184 * Filter 'newuser_notify_siteadmin' to change the content of
     1185 * the notification email.
     1186 *
     1187 * @since MU
     1188 * @uses get_site_option()
     1189 * @uses network_admin_url()
     1190 * @uses wp_mail()
     1191 *
     1192 * @param int $user_id The new user's ID.
     1193 * @return bool
     1194 */
    9221195function newuser_notify_siteadmin( $user_id ) {
    9231196        if ( get_site_option( 'registrationnotification' ) != 'yes' )
    9241197                return false;
     
    9411214        return true;
    9421215}
    9431216
     1217/**
     1218 * Check whether a blogname is already taken.
     1219 *
     1220 * Used during the new site registration process to ensure
     1221 * that each blogname is unique.
     1222 *
     1223 * @since MU
     1224 * @uses $wpdb
     1225 *
     1226 * @param string $domain The domain to be checked.
     1227 * @param string $path The path to be checked.
     1228 * @param int $site_id Optional. Relevant only on multi-network installs.
     1229 * @return int $blog_id
     1230 */
    9441231function domain_exists($domain, $path, $site_id = 1) {
    9451232        global $wpdb;
    9461233        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) );
    9471234}
    9481235
     1236/**
     1237 * Store basic site info in the blogs table.
     1238 *
     1239 * This function creates a row in the wp_blogs table and returns
     1240 * the new blog's ID. It is the first step in creating a new blog.
     1241 *
     1242 * @since MU
     1243 * @uses $wpdb
     1244 * @uses trailingslashit()
     1245 * @uses refresh_blog_details()
     1246 *
     1247 * @param string $domain The domain of the new site.
     1248 * @param string $path The path of the new site.
     1249 * @param int $site_id Unless you're running a multi-network install, be sure to set this value to 1.
     1250 * @return int $blog_id The ID of the new row
     1251 */
    9491252function insert_blog($domain, $path, $site_id) {
    9501253        global $wpdb;
    9511254
     
    9601263        return $wpdb->insert_id;
    9611264}
    9621265
    963 // Install an empty blog.  wpdb should already be switched.
     1266/**
     1267 * Install an empty blog.
     1268 *
     1269 * Creates the new blog tables and options. If calling this function
     1270 * directly, be sure to use switch_to_blog() first, so that $wpdb
     1271 * points to the new blog.
     1272 *
     1273 * @since MU
     1274 * @uses $wpdb
     1275 * @uses get_blogaddress_by_id()
     1276 * @uses make_db_current_silent()
     1277 * @uses populate_roles()
     1278 * @uses update_option()
     1279 *
     1280 * @param int $blog_id The value returned by insert_blog().
     1281 * @param string $blog_title The title of the new site.
     1282 * @return none
     1283 */
    9641284function install_blog($blog_id, $blog_title = '') {
    9651285        global $wpdb, $table_prefix, $wp_roles;
    9661286        $wpdb->suppress_errors();
     
    9991319        $wpdb->suppress_errors( false );
    10001320}
    10011321
    1002 // Deprecated, use wp_install_defaults()
    1003 // should be switched already as $blog_id is ignored.
     1322/**
     1323 * Set blog defaults.
     1324 *
     1325 * This function creates a row in the wp_blogs table.
     1326 *
     1327 * @since MU
     1328 * @deprecated MU
     1329 * @deprecated Use wp_install_defaults()
     1330 * @uses wp_install_defaults()
     1331 *
     1332 * @param int $blog_id Ignored in this function.
     1333 * @param int $user_id
     1334 * @return none
     1335 */
    10041336function install_blog_defaults($blog_id, $user_id) {
    10051337        global $wpdb;
    10061338
     
    10131345        $wpdb->suppress_errors( false );
    10141346}
    10151347
     1348/**
     1349 * Notify a user that her blog activation has been successful.
     1350 *
     1351 * Filter 'wpmu_welcome_notification' to disable or bypass.
     1352 *
     1353 * Filter 'update_welcome_email' and 'update_welcome_subject' to
     1354 * modify the content and subject line of the notification email.
     1355 *
     1356 * @since MU
     1357 * @uses get_site_option()
     1358 * @uses get_blogaddress_by_id()
     1359 * @uses wp_mail()
     1360 *
     1361 * @param int $blog_id
     1362 * @param int $user_id
     1363 * @param string $password
     1364 * @param string $title The new blog's title
     1365 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization.
     1366 * @return bool
     1367 */
    10161368function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = '') {
    10171369        global $current_site;
    10181370
     
    10631415        return true;
    10641416}
    10651417
     1418/**
     1419 * Notify a user that her account activation has been successful.
     1420 *
     1421 * Filter 'wpmu_welcome_user_notification' to disable or bypass.
     1422 *
     1423 * Filter 'update_welcome_user_email' and 'update_welcome_user_subject' to
     1424 * modify the content and subject line of the notification email.
     1425 *
     1426 * @since MU
     1427 * @uses get_site_option()
     1428 * @uses wp_mail()
     1429 *
     1430 * @param int $user_id
     1431 * @param string $password
     1432 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization.
     1433 * @return bool
     1434 */
    10661435function wpmu_welcome_user_notification($user_id, $password, $meta = '') {
    10671436        global $current_site;
    10681437
     
    10961465        return true;
    10971466}
    10981467
     1468/**
     1469 * Get the current site info.
     1470 *
     1471 * Returns an object containing the ID, domain, path, and site_name
     1472 * of the site being viewed.
     1473 *
     1474 * @since MU
     1475 *
     1476 * @return object $current_site
     1477 */
    10991478function get_current_site() {
    11001479        global $current_site;
    11011480        return $current_site;
    11021481}
    11031482
     1483/**
     1484 * Get a numeric user ID from either an email address or a login.
     1485 *
     1486 * @since MU
     1487 * @uses is_email()
     1488 * @uses get_user_by()
     1489 *
     1490 * @param string $string
     1491 * @return int $user_id
     1492 */
    11041493function get_user_id_from_string( $string ) {
    11051494        $user_id = 0;
    11061495        if ( is_email( $string ) ) {
     
    11181507        return $user_id;
    11191508}
    11201509
     1510/**
     1511 * Get a user's most recent post.
     1512 *
     1513 * Walks through each of a user's blogs to find the post with
     1514 * the most recent post_date_gmt.
     1515 *
     1516 * @since MU
     1517 * @uses $wpdb
     1518 * @uses get_blogs_of_user()
     1519 *
     1520 * @param int $user_id
     1521 * @return array $most_recent_post Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts
     1522 */
    11211523function get_most_recent_post_of_user( $user_id ) {
    11221524        global $wpdb;
    11231525
     
    11501552        return $most_recent_post;
    11511553}
    11521554
    1153 /* Misc functions */
     1555// Misc functions
     1556
     1557/**
     1558 * Get the size of a directory.
     1559 *
     1560 * A helper function that is used primarily to check whether
     1561 * a blog has exceeded its allowed upload space.
     1562 *
     1563 * @since MU
     1564 * @uses $wpdb
     1565 * @uses get_transient()
     1566 * @uses recurse_dirsize()
     1567 * @uses set_transient()
     1568 *
     1569 * @param string $directory
     1570 * @return int
     1571 */
    11541572function get_dirsize( $directory ) {
    11551573        $dirsize = get_transient( 'dirsize_cache' );
    11561574        if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
     
    11651583        return $dirsize[ $directory ][ 'size' ];
    11661584}
    11671585
     1586/**
     1587 * Get the size of a directory recursively.
     1588 *
     1589 * Used by get_dirsize() to get a directory's size when it contains
     1590 * other directories.
     1591 *
     1592 * @since MU
     1593 *
     1594 * @param string $directory
     1595 * @return int $size
     1596 */
    11681597function recurse_dirsize( $directory ) {
    11691598        $size = 0;
    11701599
     
    11921621        return $size;
    11931622}
    11941623
     1624/**
     1625 * Check whether a blog has used its allotted upload space.
     1626 *
     1627 * Used by get_dirsize() to get a directory's size when it contains
     1628 * other directories.
     1629 *
     1630 * @since MU
     1631 * @uses get_site_option()
     1632 * @uses get_dirsize()
     1633 *
     1634 * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
     1635 * @return int $size
     1636 */
    11951637function upload_is_user_over_quota( $echo = true ) {
    11961638        if ( get_site_option( 'upload_space_check_disabled' ) )
    11971639                return false;
     
    12121654        }
    12131655}
    12141656
     1657/**
     1658 * Check an array of MIME types against a whitelist.
     1659 *
     1660 * WordPress ships with a set of allowed upload filetypes,
     1661 * which is defined in wp-includes/functions.php in
     1662 * get_allowed_mime_types(). This function is used to filter
     1663 * that list against the filetype whitelist provided by Multisite
     1664 * Super Admins at wp-admin/network/settings.php.
     1665 *
     1666 * @since MU
     1667 * @uses get_site_option()
     1668 *
     1669 * @param array $mimes
     1670 * @return array $site_mimes
     1671 */
    12151672function check_upload_mimes( $mimes ) {
    12161673        $site_exts = explode( ' ', get_site_option( 'upload_filetypes' ) );
    12171674        foreach ( $site_exts as $ext ) {
     
    12231680        return $site_mimes;
    12241681}
    12251682
     1683/**
     1684 * Update a blog's post count.
     1685 *
     1686 * WordPress MS stores a blog's post count as an option so as
     1687 * to avoid extraneous COUNTs when a blog's details are fetched
     1688 * with get_blog_details(). This function is called when posts
     1689 * are published to make sure the count stays current.
     1690 *
     1691 * @since MU
     1692 * @uses $wpdb
     1693 * @uses update_option()
     1694 *
     1695 * @return none
     1696 */
    12261697function update_posts_count( $deprecated = '' ) {
    12271698        global $wpdb;
    12281699        update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );
    12291700}
    12301701
     1702/**
     1703 * Logs user registrations.
     1704 *
     1705 * @since MU
     1706 * @uses $wpdb
     1707 *
     1708 * @param int $blog_id
     1709 * @param int $user_id
     1710 * @return none
     1711 */
    12311712function wpmu_log_new_registrations( $blog_id, $user_id ) {
    12321713        global $wpdb;
    12331714        $user = new WP_User( (int) $user_id );
    12341715        $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')) );
    12351716}
    12361717
     1718/**
     1719 * Get the remaining upload space for this blog.
     1720 *
     1721 * @since MU
     1722 * @uses upload_is_user_over_quota()
     1723 * @uses get_space_allowed()
     1724 * @uses get_dirsize()
     1725 *
     1726 * @param int $size
     1727 * @return int $size
     1728 */
    12371729function fix_import_form_size( $size ) {
    12381730        if ( upload_is_user_over_quota( false ) == true )
    12391731                return 0;
     
    13151807        return $global_id;
    13161808}
    13171809
     1810/**
     1811 * Ensure that the current site's domain is listed in the allowed redirect host list.
     1812 *
     1813 * @see wp_validate_redirect()
     1814 *
     1815 * @since MU
     1816 *
     1817 * @return array The current site's domain
     1818 */
    13181819function redirect_this_site( $deprecated = '' ) {
    13191820        global $current_site;
    13201821        return array( $current_site->domain );
    13211822}
    13221823
     1824/**
     1825 * Check whether an upload is too big.
     1826 *
     1827 * @since MU
     1828 * @uses get_site_option()
     1829 *
     1830 * @param array $upload
     1831 * @return mixed If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
     1832 */
    13231833function upload_is_file_too_big( $upload ) {
    13241834        if ( is_array( $upload ) == false || defined( 'WP_IMPORTING' ) )
    13251835                return $upload;
     
    13301840        return $upload;
    13311841}
    13321842
     1843/**
     1844 * Add a nonce field to the signup page.
     1845 *
     1846 * @since MU
     1847 * @uses wp_nonce_field()
     1848 *
     1849 * @return none
     1850 */
    13331851function signup_nonce_fields() {
    13341852        $id = mt_rand();
    13351853        echo "<input type='hidden' name='signup_form_id' value='{$id}' />";
    13361854        wp_nonce_field('signup_form_' . $id, '_signup_form', false);
    13371855}
    13381856
     1857/**
     1858 * Process the signup nonce created in signup_nonce_fields().
     1859 *
     1860 * @since MU
     1861 * @uses wp_create_nonce()
     1862 *
     1863 * @param array $result
     1864 * @return array $result
     1865 */
    13391866function signup_nonce_check( $result ) {
    13401867        if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
    13411868                return $result;
     
    13461873        return $result;
    13471874}
    13481875
     1876/**
     1877 * Correct 404 redirects when NOBLOGREDIRECT is defined.
     1878 *
     1879 * @since MU
     1880 * @uses is_main_site()
     1881 * @uses is_404()
     1882 * @uses network_home_url()
     1883 * @uses wp_redirect()
     1884 *
     1885 * @return none
     1886 */
    13491887function maybe_redirect_404() {
    13501888        global $current_site;
    13511889        if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
     
    13561894        }
    13571895}
    13581896
     1897/**
     1898 * Add a new user to a blog by visiting /newbloguser/username/.
     1899 *
     1900 * This will only work when the user's details are saved as an option
     1901 * keyed as 'new_user_x', where 'x' is the username of the user to be
     1902 * added, as when a user is invited through the regular WP Add User interface.
     1903 *
     1904 * @since MU
     1905 * @uses get_option()
     1906 * @uses add_existing_user_to_blog()
     1907 * @uses is_wp_error()
     1908 * @uses wp_die()
     1909 *
     1910 * @return none
     1911 */     
    13591912function maybe_add_existing_user_to_blog() {
    13601913        if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
    13611914                return false;
     
    13761929        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') );
    13771930}
    13781931
     1932/**
     1933 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
     1934 *
     1935 * @since MU
     1936 * @uses add_user_to_blog()
     1937 *
     1938 * @param array $details
     1939 * @return none
     1940 */     
    13791941function add_existing_user_to_blog( $details = false ) {
    13801942        global $blog_id;
    13811943
     
    13861948        return $result;
    13871949}
    13881950
     1951/**
     1952 * Add a newly created user to the appropriate blog
     1953 *
     1954 * @since MU
     1955 * @uses remove_user_from_blog()
     1956 * @uses add_user_to_blog()
     1957 * @uses update_user_meta()
     1958 *
     1959 * @param int $user_id
     1960 * @param string $email
     1961 * @param array $meta
     1962 * @return none
     1963 */     
    13891964function add_new_user_to_blog( $user_id, $email, $meta ) {
    13901965        global $current_site;
    13911966        if ( $meta[ 'add_to_blog' ] ) {
     
    13971972        }
    13981973}
    13991974
     1975/**
     1976 * Correct From host on outgoing mail to match the site domain
     1977 *
     1978 * @since MU
     1979 *
     1980 * @return none
     1981 */     
    14001982function fix_phpmailer_messageid( $phpmailer ) {
    14011983        global $current_site;
    14021984        $phpmailer->Hostname = $current_site->domain;
    14031985}
    14041986
     1987/**
     1988 * Check to see whether a user is marked as a spammer, based on username
     1989 *
     1990 * @since MU
     1991 * @uses get_current_user_id()
     1992 * @uses get_user_id_from_string()
     1993 *
     1994 * @param string $username
     1995 * @return bool
     1996 */     
    14051997function is_user_spammy( $username = 0 ) {
    14061998        if ( $username == 0 ) {
    14071999                $user_id = get_current_user_id();
     
    14132005        return ( isset( $u->spam ) && $u->spam == 1 );
    14142006}
    14152007
     2008/**
     2009 * Update this blog's 'public' setting in the global blogs table.
     2010 *
     2011 * Public blogs have a setting of 1, private blogs are 0.
     2012 *
     2013 * @since MU
     2014 * @uses update_blog_status()
     2015 *
     2016 * @param int $old_value
     2017 * @param int $value The new public value
     2018 * @return bool
     2019 */     
    14162020function update_blog_public( $old_value, $value ) {
    14172021        global $wpdb;
    14182022        do_action('update_blog_public');
     
    14202024}
    14212025add_action('update_option_blog_public', 'update_blog_public', 10, 2);
    14222026
     2027/**
     2028 * Get the "dashboard blog", the blog where users without a blog edit their profile data.
     2029 *
     2030 * @since MU
     2031 * @uses get_site_option()
     2032 * @uses get_blog_details()
     2033 *
     2034 * @return int
     2035 */     
    14232036function get_dashboard_blog() {
    14242037        if ( $blog = get_site_option( 'dashboard_blog' ) )
    14252038                return get_blog_details( $blog );
     
    14272040        return get_blog_details( $GLOBALS['current_site']->blog_id );
    14282041}
    14292042
     2043/**
     2044 * Check whether a usermeta key has to do with the current blog.
     2045 *
     2046 * @since MU
     2047 * @uses wp_get_current_user()
     2048 *
     2049 * @param string $key
     2050 * @param int $user_id Optional. Defaults to current user.
     2051 * @param int $blog_id Optional. Defaults to current blog.
     2052 * @return bool
     2053 */     
    14302054function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
    14312055        global $wpdb;
    14322056
     
    14442068        return false;
    14452069}
    14462070
     2071/**
     2072 * Check whether users can self-register, based on Network settings.
     2073 *
     2074 * @since MU
     2075 * @uses get_site_option()
     2076 *
     2077 * @return bool
     2078 */     
    14472079function users_can_register_signup_filter() {
    14482080        $registration = get_site_option('registration');
    14492081        if ( $registration == 'all' || $registration == 'user' )
     
    14532085}
    14542086add_filter('option_users_can_register', 'users_can_register_signup_filter');
    14552087
     2088/**
     2089 * Ensure that the welcome message is not empty. Currently unused.
     2090 *
     2091 * @since MU
     2092 *
     2093 * @param string $text
     2094 * @return string $text
     2095 */     
    14562096function welcome_user_msg_filter( $text ) {
    14572097        if ( !$text ) {
    14582098                return __( 'Dear User,