Make WordPress Core

Ticket #14953: 14953-2.diff

File 14953-2.diff, 27.1 KB (added by boonebgorges, 15 years ago)
  • ms-functions.php

     
    447447        return $id;
    448448}
    449449
    450 // wpmu admin functions
     450// Admin functions
    451451
     452/**
     453 * Redirect a user based on $_GET or $_POST arguments.
     454 *
     455 * The function looks for redirect arguments in the following order:
     456 * 1) $_GET['ref']
     457 * 2) $_POST['ref']
     458 * 3) $_SERVER['HTTP_REFERER']
     459 * 4) $_GET['redirect']
     460 * 5) $_POST['redirect']
     461 * 6) $url
     462 *
     463 * @since MU
     464 * @uses wpmu_admin_redirect_add_updated_param()
     465 *
     466 * @param string $url
     467 * @return none
     468 */
    452469function wpmu_admin_do_redirect( $url = '' ) {
    453470        $ref = '';
    454471        if ( isset( $_GET['ref'] ) )
     
    477494        exit();
    478495}
    479496
     497/**
     498 * Adds an 'updated=true' argument to a URL.
     499 *
     500 * @since MU
     501 *
     502 * @param string $url
     503 * @return string $url
     504 */
    480505function wpmu_admin_redirect_add_updated_param( $url = '' ) {
    481506        if ( strpos( $url, 'updated=true' ) === false ) {
    482507                if ( strpos( $url, '?' ) === false )
     
    487512        return $url;
    488513}
    489514
     515/**
     516 * Checks an email address against a list of banned domains.
     517 *
     518 * This function checks against the Banned Email Domains list
     519 * at wp-admin/network/settings.php. The check is only run on
     520 * self-registrations; user creation at wp-admin/network/users.php
     521 * bypasses this check.
     522 *
     523 * @since MU
     524 * @uses get_site_option()
     525 *
     526 * @param string $user_email The email provided by the user at registration.
     527 * @return bool Returns true when the email address is banned.
     528 */
    490529function is_email_address_unsafe( $user_email ) {
    491530        $banned_names = get_site_option( 'banned_email_domains' );
    492531        if ($banned_names && !is_array( $banned_names ))
     
    510549        return false;
    511550}
    512551
     552/**
     553 * Processes new user registrations.
     554 *
     555 * Checks the data provided by the user during signup. Verifies
     556 * the validity and uniqueness of user names and user email addresses,
     557 * and checks email addresses against admin-provided domain
     558 * whitelists and blacklists.
     559 *
     560 * The hook 'wpmu_validate_user_signup' provides an easy way
     561 * to modify the signup process. The value $result, which is passed
     562 * to the hook, contains both the user-provided info and the error
     563 * messages created by the function. 'wpmu_validate_user_signup' allows
     564 * you to process the data in any way you'd like, and unset the
     565 * relevant errors if necessary.
     566 *
     567 * @since MU
     568 * @uses sanitize_user()
     569 * @uses sanitize_email()
     570 * @uses get_site_option()
     571 * @uses is_email_address_unsafe()
     572 * @uses username_exists()
     573 * @uses email_exists()
     574 * @uses $wpdb
     575 *
     576 * @param string $user_name The login name provided by the user.
     577 * @param string $user_email The email provided by the user.
     578 * @return array $result Contains username, email, and error messages.
     579 */
    513580function wpmu_validate_user_signup($user_name, $user_email) {
    514581        global $wpdb;
    515582
     
    602669        return apply_filters('wpmu_validate_user_signup', $result);
    603670}
    604671
     672/**
     673 * Processes new site registrations.
     674 *
     675 * Checks the data provided by the user during blog signup. Verifies
     676 * the validity and uniqueness of blog paths and domains.
     677 *
     678 * This function prevents the current user from registering a new site
     679 * with a blogname equivalent to another user's login name. Passing the
     680 * $user parameter to the function, where $user is the other user, is
     681 * effectively an override of this limitation.
     682 *
     683 * Filter 'wpmu_validate_blog_signup' if you want to modify
     684 * the way that WordPress validates new site signups.
     685 *
     686 * @since MU
     687 * @uses is_subdomain_install()
     688 * @uses add_site_option()
     689 * @uses get_site_option()
     690 * @uses domain_exists()
     691 * @uses username_exists()
     692 * @uses $wpdb
     693 *
     694 * @param string $blogname The blog name provided by the user. Must be unique.
     695 * @param string $blog_title The blog title provided by the user.
     696 * @return array $result Contains the new site data and error messages.
     697 */
    605698function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
    606699        global $wpdb, $domain, $base, $current_site;
    607700
     
    685778        return apply_filters('wpmu_validate_blog_signup', $result);
    686779}
    687780
    688 // Record signup information for future activation. wpmu_validate_signup() should be run
    689 // on the inputs before calling wpmu_signup().
     781/**
     782 * Record site signup information for future activation.
     783 *
     784 * @since MU
     785 * @uses wpmu_signup_blog_notification()
     786 * @uses $wpdb
     787 *
     788 * @param string $domain The requested domain.
     789 * @param string $path The requested path.
     790 * @param string $title The requested site title.
     791 * @param string $user The user's requested login name.
     792 * @param string $user_email The user's email address.
     793 * @param array $meta By default, contains the requested privacy setting and lang_id.
     794 * @return none
     795 */
    690796function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = '') {
    691797        global $wpdb;
    692798
     
    710816        wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta);
    711817}
    712818
     819/**
     820 * Record user signup information for future activation.
     821 *
     822 * This function is used when user registration is open but
     823 * new site registration is not.
     824 *
     825 * @since MU
     826 * @uses wpmu_signup_user_notification()
     827 * @uses $wpdb
     828 *
     829 * @param string $user The user's requested login name.
     830 * @param string $user_email The user's email address.
     831 * @param array $meta By default, this is an empty array.
     832 * @return none
     833 */
    713834function wpmu_signup_user($user, $user_email, $meta = '') {
    714835        global $wpdb;
    715836
     
    733854        wpmu_signup_user_notification($user, $user_email, $key, $meta);
    734855}
    735856
    736 // Notify user of signup success.
     857/**
     858 * Notify user of signup success.
     859 *
     860 * This is the notification function used when site registration
     861 * is enabled.
     862 *
     863 * Filter 'wpmu_signup_blog_notification' to bypass this function or
     864 * replace it with your own notification behavior.
     865 *
     866 * Filter 'wpmu_signup_blog_notification_email' and
     867 * 'wpmu_signup_blog_notification_email' to change the content
     868 * and subject line of the email sent to newly registered users.
     869 *
     870 * @since MU
     871 * @uses is_subdomain_install()
     872 * @uses get_site_option()
     873 * @uses wp_mail()
     874 *
     875 * @param string $domain The new blog domain.
     876 * @param string $path The new blog path.
     877 * @param string $title The site title.
     878 * @param string $user The user's login name.
     879 * @param string $user_email The user's email address.
     880 * @param array $meta By default, contains the requested privacy setting and lang_id.
     881 * @param string $key The activation key created in wpmu_signup_blog()
     882 * @return bool
     883 */
    737884function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta = '') {
    738885        global $current_site;
    739886
     
    774921        return true;
    775922}
    776923
     924/**
     925 * Notify user of signup success.
     926 *
     927 * This is the notification function used when no new site has
     928 * been requested.
     929 *
     930 * Filter 'wpmu_signup_user_notification' to bypass this function or
     931 * replace it with your own notification behavior.
     932 *
     933 * Filter 'wpmu_signup_user_notification_email' and
     934 * 'wpmu_signup_user_notification_subject' to change the content
     935 * and subject line of the email sent to newly registered users.
     936 *
     937 * @since MU
     938 * @uses get_site_option()
     939 * @uses site_url()
     940 * @uses wp_mail()
     941 *
     942 * @param string $user The user's login name.
     943 * @param string $user_email The user's email address.
     944 * @param array $meta By default, an empty array.
     945 * @param string $key The activation key created in wpmu_signup_user()
     946 * @return bool
     947 */
    777948function wpmu_signup_user_notification($user, $user_email, $key, $meta = '') {
    778949        if ( !apply_filters('wpmu_signup_user_notification', $user, $user_email, $key, $meta) )
    779950                return false;
     
    805976        return true;
    806977}
    807978
     979/**
     980 * Activate a signup.
     981 *
     982 * Hook to 'wpmu_activate_user' or 'wpmu_activate_blog' for events
     983 * that should happen only when users or sites are self-created (since
     984 * those actions are not called when users and sites are created
     985 * by a Super Admin).
     986 *
     987 * @since MU
     988 * @uses $wpdb
     989 * @uses wp_generate_password()
     990 * @uses wpmu_welcome_user_notification()
     991 * @uses get_site_option()
     992 * @uses add_user_to_blog()
     993 * @uses add_new_user_to_blog()
     994 * @uses wpmu_create_user()
     995 * @uses wpmu_create_blog()
     996 * @uses is_wp_error()
     997 * @uses wpmu_welcome_notification()
     998 *
     999 * @param string $key The activation key provided to the user.
     1000 * @return array An array containing information about the activated user and/or blog
     1001 */
    8081002function wpmu_activate_signup($key) {
    8091003        global $wpdb, $current_site;
    8101004
     
    8721066        return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
    8731067}
    8741068
     1069/**
     1070 * Create a user.
     1071 *
     1072 * This function runs when a user self-registers as well as when
     1073 * a Super Admin creates a new user. Hook to 'wpmu_new_user' for events
     1074 * that should affect all new users, but only on Multisite (otherwise
     1075 * use 'user_register').
     1076 *
     1077 * @since MU
     1078 * @uses wp_create_user()
     1079 * @uses is_wp_error()
     1080 * @uses delete_user_option()
     1081 *
     1082 * @param string $user_name The new user's login name.
     1083 * @param string $password The new user's password.
     1084 * @param string $email The new user's email address.
     1085 * @return mixed Returns false on failure, or int $user_id on success
     1086 */
    8751087function wpmu_create_user( $user_name, $password, $email) {
    8761088        $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
    8771089
     
    8881100        return $user_id;
    8891101}
    8901102
     1103/**
     1104 * Create a site.
     1105 *
     1106 * This function runs when a user self-registers a new site as well
     1107 * as when a Super Admin creates a new site. Hook to 'wpmu_new_blog'
     1108 * for events that should affect all new sites.
     1109 *
     1110 * On subdirectory installs, $domain is the same as the main site's
     1111 * domain, and the path is the subdirectory name (eg 'example.com'
     1112 * and '/blog1/'). On subdomain installs, $domain is the new subdomain +
     1113 * root domain (eg 'blog1.example.com'), and $path is '/'.
     1114 *
     1115 * @since MU
     1116 * @uses is_subdomain_install()
     1117 * @uses domain_exists()
     1118 * @uses insert_blog()
     1119 * @uses switch_to_blog()
     1120 * @uses wp_install_defaults()
     1121 * @uses add_user_to_blog()
     1122 * @uses update_blog_status()
     1123 * @uses restore_current_blog()
     1124 *
     1125 * @param string $domain The new site's domain.
     1126 * @param string $path The new site's path.
     1127 * @param string $title The new site's title.
     1128 * @param int $user_id The user ID of the new site's admin.
     1129 * @param array $meta Optional. Used to set initial site options.
     1130 * @param int $site_id Optional. Only relevant on multi-network installs.
     1131 * @return mixed Returns WP_Error object on failure, int $blog_id on success
     1132 */
    8911133function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
    8921134        $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
    8931135
     
    9351177        return $blog_id;
    9361178}
    9371179
     1180/**
     1181 * Notifies the network admin that a new site has been activated.
     1182 *
     1183 * Filter 'newblog_notify_siteadmin' to change the content of
     1184 * the notification email.
     1185 *
     1186 * @since MU
     1187 * @uses switch_to_blog()
     1188 * @uses site_url()
     1189 * @uses get_site_option()
     1190 * @uses network_admin_url()
     1191 * @uses restore_current_blog()
     1192 * @uses wp_mail()
     1193 *
     1194 * @param int $blog_id The new site's ID.
     1195 * @return bool
     1196 */
    9381197function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
    9391198        if ( get_site_option( 'registrationnotification' ) != 'yes' )
    9401199                return false;
     
    9611220        return true;
    9621221}
    9631222
     1223/**
     1224 * Notifies the network admin that a new user has been activated.
     1225 *
     1226 * Filter 'newuser_notify_siteadmin' to change the content of
     1227 * the notification email.
     1228 *
     1229 * @since MU
     1230 * @uses get_site_option()
     1231 * @uses network_admin_url()
     1232 * @uses wp_mail()
     1233 *
     1234 * @param int $user_id The new user's ID.
     1235 * @return bool
     1236 */
    9641237function newuser_notify_siteadmin( $user_id ) {
    9651238        if ( get_site_option( 'registrationnotification' ) != 'yes' )
    9661239                return false;
     
    9831256        return true;
    9841257}
    9851258
     1259/**
     1260 * Check whether a blogname is already taken.
     1261 *
     1262 * Used during the new site registration process to ensure
     1263 * that each blogname is unique.
     1264 *
     1265 * @since MU
     1266 * @uses $wpdb
     1267 *
     1268 * @param string $domain The domain to be checked.
     1269 * @param string $path The path to be checked.
     1270 * @param int $site_id Optional. Relevant only on multi-network installs.
     1271 * @return int $blog_id
     1272 */
    9861273function domain_exists($domain, $path, $site_id = 1) {
    9871274        global $wpdb;
    9881275        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) );
    9891276}
    9901277
     1278/**
     1279 * Store basic site info in the blogs table.
     1280 *
     1281 * This function creates a row in the wp_blogs table and returns
     1282 * the new blog's ID. It is the first step in creating a new blog.
     1283 *
     1284 * @since MU
     1285 * @uses $wpdb
     1286 * @uses trailingslashit()
     1287 * @uses refresh_blog_details()
     1288 *
     1289 * @param string $domain The domain of the new site.
     1290 * @param string $path The path of the new site.
     1291 * @param int $site_id Unless you're running a multi-network install, be sure to set this value to 1.
     1292 * @return int $blog_id The ID of the new row
     1293 */
    9911294function insert_blog($domain, $path, $site_id) {
    9921295        global $wpdb;
    9931296
     
    10021305        return $wpdb->insert_id;
    10031306}
    10041307
    1005 // Install an empty blog.  wpdb should already be switched.
     1308/**
     1309 * Install an empty blog.
     1310 *
     1311 * Creates the new blog tables and options. If calling this function
     1312 * directly, be sure to use switch_to_blog() first, so that $wpdb
     1313 * points to the new blog.
     1314 *
     1315 * @since MU
     1316 * @uses $wpdb
     1317 * @uses get_blogaddress_by_id()
     1318 * @uses make_db_current_silent()
     1319 * @uses populate_roles()
     1320 * @uses update_option()
     1321 *
     1322 * @param int $blog_id The value returned by insert_blog().
     1323 * @param string $blog_title The title of the new site.
     1324 * @return none
     1325 */
    10061326function install_blog($blog_id, $blog_title = '') {
    10071327        global $wpdb, $table_prefix, $wp_roles;
    10081328        $wpdb->suppress_errors();
     
    10411361        $wpdb->suppress_errors( false );
    10421362}
    10431363
    1044 // Deprecated, use wp_install_defaults()
    1045 // should be switched already as $blog_id is ignored.
     1364/**
     1365 * Set blog defaults.
     1366 *
     1367 * This function creates a row in the wp_blogs table.
     1368 *
     1369 * @since MU
     1370 * @deprecated MU
     1371 * @deprecated Use wp_install_defaults()
     1372 * @uses wp_install_defaults()
     1373 *
     1374 * @param int $blog_id Ignored in this function.
     1375 * @param int $user_id
     1376 * @return none
     1377 */
    10461378function install_blog_defaults($blog_id, $user_id) {
    10471379        global $wpdb;
    10481380
     
    10551387        $wpdb->suppress_errors( false );
    10561388}
    10571389
     1390/**
     1391 * Notify a user that her blog activation has been successful.
     1392 *
     1393 * Filter 'wpmu_welcome_notification' to disable or bypass.
     1394 *
     1395 * Filter 'update_welcome_email' and 'update_welcome_subject' to
     1396 * modify the content and subject line of the notification email.
     1397 *
     1398 * @since MU
     1399 * @uses get_site_option()
     1400 * @uses get_blogaddress_by_id()
     1401 * @uses wp_mail()
     1402 *
     1403 * @param int $blog_id
     1404 * @param int $user_id
     1405 * @param string $password
     1406 * @param string $title The new blog's title
     1407 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization.
     1408 * @return bool
     1409 */
    10581410function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = '') {
    10591411        global $current_site;
    10601412
     
    11051457        return true;
    11061458}
    11071459
     1460/**
     1461 * Notify a user that her account activation has been successful.
     1462 *
     1463 * Filter 'wpmu_welcome_user_notification' to disable or bypass.
     1464 *
     1465 * Filter 'update_welcome_user_email' and 'update_welcome_user_subject' to
     1466 * modify the content and subject line of the notification email.
     1467 *
     1468 * @since MU
     1469 * @uses get_site_option()
     1470 * @uses wp_mail()
     1471 *
     1472 * @param int $user_id
     1473 * @param string $password
     1474 * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization.
     1475 * @return bool
     1476 */
    11081477function wpmu_welcome_user_notification($user_id, $password, $meta = '') {
    11091478        global $current_site;
    11101479
     
    11381507        return true;
    11391508}
    11401509
     1510/**
     1511 * Get the current site info.
     1512 *
     1513 * Returns an object containing the ID, domain, path, and site_name
     1514 * of the site being viewed.
     1515 *
     1516 * @since MU
     1517 *
     1518 * @return object $current_site
     1519 */
    11411520function get_current_site() {
    11421521        global $current_site;
    11431522        return $current_site;
    11441523}
    11451524
     1525/**
     1526 * Get a numeric user ID from either an email address or a login.
     1527 *
     1528 * @since MU
     1529 * @uses is_email()
     1530 * @uses get_user_by()
     1531 *
     1532 * @param string $string
     1533 * @return int $user_id
     1534 */
    11461535function get_user_id_from_string( $string ) {
    11471536        $user_id = 0;
    11481537        if ( is_email( $string ) ) {
     
    11601549        return $user_id;
    11611550}
    11621551
     1552/**
     1553 * Get a user's most recent post.
     1554 *
     1555 * Walks through each of a user's blogs to find the post with
     1556 * the most recent post_date_gmt.
     1557 *
     1558 * @since MU
     1559 * @uses $wpdb
     1560 * @uses get_blogs_of_user()
     1561 *
     1562 * @param int $user_id
     1563 * @return array $most_recent_post Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts
     1564 */
    11631565function get_most_recent_post_of_user( $user_id ) {
    11641566        global $wpdb;
    11651567
     
    11921594        return $most_recent_post;
    11931595}
    11941596
    1195 /* Misc functions */
     1597// Misc functions
     1598
     1599/**
     1600 * Get the size of a directory.
     1601 *
     1602 * A helper function that is used primarily to check whether
     1603 * a blog has exceeded its allowed upload space.
     1604 *
     1605 * @since MU
     1606 * @uses $wpdb
     1607 * @uses get_transient()
     1608 * @uses recurse_dirsize()
     1609 * @uses set_transient()
     1610 *
     1611 * @param string $directory
     1612 * @return int
     1613 */
    11961614function get_dirsize( $directory ) {
    11971615        $dirsize = get_transient( 'dirsize_cache' );
    11981616        if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
     
    12071625        return $dirsize[ $directory ][ 'size' ];
    12081626}
    12091627
     1628/**
     1629 * Get the size of a directory recursively.
     1630 *
     1631 * Used by get_dirsize() to get a directory's size when it contains
     1632 * other directories.
     1633 *
     1634 * @since MU
     1635 *
     1636 * @param string $directory
     1637 * @return int $size
     1638 */
    12101639function recurse_dirsize( $directory ) {
    12111640        $size = 0;
    12121641
     
    12341663        return $size;
    12351664}
    12361665
     1666/**
     1667 * Check whether a blog has used its allotted upload space.
     1668 *
     1669 * Used by get_dirsize() to get a directory's size when it contains
     1670 * other directories.
     1671 *
     1672 * @since MU
     1673 * @uses get_site_option()
     1674 * @uses get_dirsize()
     1675 *
     1676 * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
     1677 * @return int $size
     1678 */
    12371679function upload_is_user_over_quota( $echo = true ) {
    12381680        if ( get_site_option( 'upload_space_check_disabled' ) )
    12391681                return true;
     
    12541696        }
    12551697}
    12561698
     1699/**
     1700 * Check an array of MIME types against a whitelist.
     1701 *
     1702 * WordPress ships with a set of allowed upload filetypes,
     1703 * which is defined in wp-includes/functions.php in
     1704 * get_allowed_mime_types(). This function is used to filter
     1705 * that list against the filetype whitelist provided by Multisite
     1706 * Super Admins at wp-admin/network/settings.php.
     1707 *
     1708 * @since MU
     1709 * @uses get_site_option()
     1710 *
     1711 * @param array $mimes
     1712 * @return array $site_mimes
     1713 */
    12571714function check_upload_mimes( $mimes ) {
    12581715        $site_exts = explode( ' ', get_site_option( 'upload_filetypes' ) );
    12591716        foreach ( $site_exts as $ext ) {
     
    12651722        return $site_mimes;
    12661723}
    12671724
     1725/**
     1726 * Update a blog's post count.
     1727 *
     1728 * WordPress MS stores a blog's post count as an option so as
     1729 * to avoid extraneous COUNTs when a blog's details are fetched
     1730 * with get_blog_details(). This function is called when posts
     1731 * are published to make sure the count stays current.
     1732 *
     1733 * @since MU
     1734 * @uses $wpdb
     1735 * @uses update_option()
     1736 *
     1737 * @return none
     1738 */
    12681739function update_posts_count( $deprecated = '' ) {
    12691740        global $wpdb;
    12701741        update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );
    12711742}
    12721743
     1744/**
     1745 * Logs user registrations.
     1746 *
     1747 * @since MU
     1748 * @uses $wpdb
     1749 *
     1750 * @param int $blog_id
     1751 * @param int $user_id
     1752 * @return none
     1753 */
    12731754function wpmu_log_new_registrations( $blog_id, $user_id ) {
    12741755        global $wpdb;
    12751756        $user = new WP_User( (int) $user_id );
    12761757        $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')) );
    12771758}
    12781759
     1760/**
     1761 * Get the remaining upload space for this blog.
     1762 *
     1763 * @since MU
     1764 * @uses upload_is_user_over_quota()
     1765 * @uses get_space_allowed()
     1766 * @uses get_dirsize()
     1767 *
     1768 * @param int $size
     1769 * @return int $size
     1770 */
    12791771function fix_import_form_size( $size ) {
    12801772        if ( upload_is_user_over_quota( false ) == true )
    12811773                return 0;
     
    13571849        return $global_id;
    13581850}
    13591851
     1852/**
     1853 * Ensure that the current site's domain is listed in the allowed redirect host list.
     1854 *
     1855 * @see wp_validate_redirect()
     1856 *
     1857 * @since MU
     1858 *
     1859 * @return array The current site's domain
     1860 */
    13601861function redirect_this_site( $deprecated = '' ) {
    13611862        global $current_site;
    13621863        return array( $current_site->domain );
    13631864}
    13641865
     1866/**
     1867 * Check whether an upload is too big.
     1868 *
     1869 * @since MU
     1870 * @uses get_site_option()
     1871 *
     1872 * @param array $upload
     1873 * @return mixed If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
     1874 */
    13651875function upload_is_file_too_big( $upload ) {
    13661876        if ( is_array( $upload ) == false || defined( 'WP_IMPORTING' ) )
    13671877                return $upload;
     
    13721882        return $upload;
    13731883}
    13741884
     1885/**
     1886 * Ensure that the from address on outgoing mail is the blog's correct admin_email. Filters 'wp_mail_from'.
     1887 *
     1888 * @since MU
     1889 * @uses get_option()
     1890 *
     1891 * @param string $email
     1892 * @return string $email
     1893 */
    13751894function wordpressmu_wp_mail_from( $email ) {
    13761895        if ( strpos( $email, 'wordpress@' ) !== false )
    13771896                $email = get_option( 'admin_email' );
    13781897        return $email;
    13791898}
    13801899
     1900/**
     1901 * Add a nonce field to the signup page.
     1902 *
     1903 * @since MU
     1904 * @uses wp_nonce_field()
     1905 *
     1906 * @return none
     1907 */
    13811908function signup_nonce_fields() {
    13821909        $id = mt_rand();
    13831910        echo "<input type='hidden' name='signup_form_id' value='{$id}' />";
    13841911        wp_nonce_field('signup_form_' . $id, '_signup_form', false);
    13851912}
    13861913
     1914/**
     1915 * Process the signup nonce created in signup_nonce_fields().
     1916 *
     1917 * @since MU
     1918 * @uses wp_create_nonce()
     1919 *
     1920 * @param array $result
     1921 * @return array $result
     1922 */
    13871923function signup_nonce_check( $result ) {
    13881924        if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
    13891925                return $result;
     
    13941930        return $result;
    13951931}
    13961932
     1933/**
     1934 * Correct 404 redirects when NOBLOGREDIRECT is defined.
     1935 *
     1936 * @since MU
     1937 * @uses is_main_site()
     1938 * @uses is_404()
     1939 * @uses network_home_url()
     1940 * @uses wp_redirect()
     1941 *
     1942 * @return none
     1943 */
    13971944function maybe_redirect_404() {
    13981945        global $current_site;
    13991946        if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
     
    14041951        }
    14051952}
    14061953
     1954/**
     1955 * Add a new user to a blog by visiting /newbloguser/username/.
     1956 *
     1957 * This will only work when the user's details are saved as an option
     1958 * keyed as 'new_user_x', where 'x' is the username of the user to be
     1959 * added, as when a user is invited through the regular WP Add User interface.
     1960 *
     1961 * @since MU
     1962 * @uses get_option()
     1963 * @uses add_existing_user_to_blog()
     1964 * @uses is_wp_error()
     1965 * @uses wp_die()
     1966 *
     1967 * @return none
     1968 */     
    14071969function maybe_add_existing_user_to_blog() {
    14081970        if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
    14091971                return false;
     
    14241986        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') );
    14251987}
    14261988
     1989/**
     1990 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
     1991 *
     1992 * @since MU
     1993 * @uses add_user_to_blog()
     1994 *
     1995 * @param array $details
     1996 * @return none
     1997 */     
    14271998function add_existing_user_to_blog( $details = false ) {
    14281999        if ( is_array( $details ) ) {
    14292000                $result = add_user_to_blog( '', $details[ 'user_id' ], $details[ 'role' ] );
     
    14322003        return $result;
    14332004}
    14342005
     2006/**
     2007 * Add a newly created user to the appropriate blog
     2008 *
     2009 * @since MU
     2010 * @uses remove_user_from_blog()
     2011 * @uses add_user_to_blog()
     2012 * @uses update_user_meta()
     2013 *
     2014 * @param int $user_id
     2015 * @param string $email
     2016 * @param array $meta
     2017 * @return none
     2018 */     
    14352019function add_new_user_to_blog( $user_id, $email, $meta ) {
    14362020        global $current_site;
    14372021        if ( $meta[ 'add_to_blog' ] ) {
     
    14432027        }
    14442028}
    14452029
     2030/**
     2031 * Correct From host on outgoing mail to match the site domain
     2032 *
     2033 * @since MU
     2034 *
     2035 * @return none
     2036 */     
    14462037function fix_phpmailer_messageid( $phpmailer ) {
    14472038        global $current_site;
    14482039        $phpmailer->Hostname = $current_site->domain;
    14492040}
    14502041
     2042/**
     2043 * Check to see whether a user is marked as a spammer, based on username
     2044 *
     2045 * @since MU
     2046 * @uses get_current_user_id()
     2047 * @uses get_user_id_from_string()
     2048 *
     2049 * @param string $username
     2050 * @return bool
     2051 */     
    14512052function is_user_spammy( $username = 0 ) {
    14522053        if ( $username == 0 ) {
    14532054                $user_id = get_current_user_id();
     
    14592060        return ( isset( $u->spam ) && $u->spam == 1 );
    14602061}
    14612062
     2063/**
     2064 * Update this blog's 'public' setting in the global blogs table.
     2065 *
     2066 * Public blogs have a setting of 1, private blogs are 0.
     2067 *
     2068 * @since MU
     2069 * @uses update_blog_status()
     2070 *
     2071 * @param int $old_value
     2072 * @param int $value The new public value
     2073 * @return bool
     2074 */     
    14622075function update_blog_public( $old_value, $value ) {
    14632076        global $wpdb;
    14642077        do_action('update_blog_public');
     
    14662079}
    14672080add_action('update_option_blog_public', 'update_blog_public', 10, 2);
    14682081
    1469 /* Redirect all hits to "dashboard" blog to wp-admin/ Dashboard. */
     2082/**
     2083 * Redirect all hits to "dashboard" blog to wp-admin/ Dashboard.
     2084 *
     2085 * @since MU
     2086 * @uses get_dashboard_blog()
     2087 * @uses wp_redirect()
     2088 * @uses trailingslashit()
     2089 *
     2090 * @return none
     2091 */     
    14702092function redirect_mu_dashboard() {
    14712093        global $current_site, $current_blog;
    14722094
     
    14792101}
    14802102add_action( 'template_redirect', 'redirect_mu_dashboard' );
    14812103
     2104/**
     2105 * Get the "dashboard blog", the blog where users without a blog edit their profile data.
     2106 *
     2107 * @since MU
     2108 * @uses get_site_option()
     2109 * @uses get_blog_details()
     2110 *
     2111 * @return int
     2112 */     
    14822113function get_dashboard_blog() {
    14832114        if ( $blog = get_site_option( 'dashboard_blog' ) )
    14842115                return get_blog_details( $blog );
     
    14862117        return get_blog_details( $GLOBALS['current_site']->blog_id );
    14872118}
    14882119
     2120/**
     2121 * Check whether a usermeta key has to do with the current blog.
     2122 *
     2123 * @since MU
     2124 * @uses wp_get_current_user()
     2125 *
     2126 * @param string $key
     2127 * @param int $user_id Optional. Defaults to current user.
     2128 * @param int $blog_id Optional. Defaults to current blog.
     2129 * @return bool
     2130 */     
    14892131function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
    14902132        global $wpdb;
    14912133
     
    15032145        return false;
    15042146}
    15052147
     2148/**
     2149 * Check whether users can self-register, based on Network settings.
     2150 *
     2151 * @since MU
     2152 * @uses get_site_option()
     2153 *
     2154 * @return bool
     2155 */     
    15062156function users_can_register_signup_filter() {
    15072157        $registration = get_site_option('registration');
    15082158        if ( $registration == 'all' || $registration == 'user' )
     
    15122162}
    15132163add_filter('option_users_can_register', 'users_can_register_signup_filter');
    15142164
     2165/**
     2166 * Ensure that the welcome message is not empty. Currently unused.
     2167 *
     2168 * @since MU
     2169 *
     2170 * @param string $text
     2171 * @return string $text
     2172 */     
    15152173function welcome_user_msg_filter( $text ) {
    15162174        if ( !$text ) {
    15172175                return __( 'Dear User,