]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/ms-functions.php
WordPress 4.2.5
[autoinstalls/wordpress.git] / wp-includes / ms-functions.php
index 6d7a2fbd52bef85c4778fa4a40d19fdfed60bddd..6dbcf086d828433ced83bed1006b3a7003d3ed8d 100644 (file)
@@ -11,8 +11,6 @@
  * Gets the network's site and user counts.
  *
  * @since MU 1.0
- * @uses get_blog_count()
- * @uses get_user_count()
  *
  * @return array Site and user count for the network.
  */
@@ -58,9 +56,6 @@ function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
  * is returned.
  *
  * @since MU 1.0
- * @uses get_blogs_of_user()
- * @uses add_user_to_blog()
- * @uses get_blog_details()
  *
  * @param int $user_id The unique ID of the user
  * @return object The blog object
@@ -298,7 +293,6 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
  * Create an empty blog.
  *
  * @since MU 1.0
- * @uses install_blog()
  *
  * @param string $domain The new blog's domain.
  * @param string $path The new blog's path.
@@ -440,26 +434,20 @@ function is_email_address_unsafe( $user_email ) {
 }
 
 /**
- * Processes new user registrations.
+ * Sanitize and validate data required for a user sign-up.
  *
- * Checks the data provided by the user during signup. Verifies
- * the validity and uniqueness of user names and user email addresses,
- * and checks email addresses against admin-provided domain
- * whitelists and blacklists.
+ * Verifies the validity and uniqueness of user names and user email addresses,
+ * and checks email addresses against admin-provided domain whitelists and blacklists.
  *
- * The hook 'wpmu_validate_user_signup' provides an easy way
- * to modify the signup process. The value $result, which is passed
- * to the hook, contains both the user-provided info and the error
- * messages created by the function. 'wpmu_validate_user_signup' allows
- * you to process the data in any way you'd like, and unset the
- * relevant errors if necessary.
+ * The {@see 'wpmu_validate_user_signup'} hook provides an easy way to modify the sign-up
+ * process. The value $result, which is passed to the hook, contains both the user-provided
+ * info and the error messages created by the function. {@see 'wpmu_validate_user_signup'}
+ * allows you to process the data in any way you'd like, and unset the relevant errors if
+ * necessary.
  *
  * @since MU
- * @uses is_email_address_unsafe()
- * @uses username_exists()
- * @uses email_exists()
  *
- * @param string $user_name The login name provided by the user.
+ * @param string $user_name  The login name provided by the user.
  * @param string $user_email The email provided by the user.
  * @return array Contains username, email, and error messages.
  */
@@ -580,8 +568,6 @@ function wpmu_validate_user_signup($user_name, $user_email) {
  * the way that WordPress validates new site signups.
  *
  * @since MU
- * @uses domain_exists()
- * @uses username_exists()
  *
  * @param string $blogname The blog name provided by the user. Must be unique.
  * @param string $blog_title The blog title provided by the user.
@@ -713,7 +699,6 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
  * Record site signup information for future activation.
  *
  * @since MU
- * @uses wpmu_signup_blog_notification()
  *
  * @param string $domain The requested domain.
  * @param string $path The requested path.
@@ -749,7 +734,6 @@ function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = a
  * new site registration is not.
  *
  * @since MU
- * @uses wpmu_signup_user_notification()
  *
  * @param string $user The user's requested login name.
  * @param string $user_email The user's email address.
@@ -978,12 +962,6 @@ function wpmu_signup_user_notification( $user, $user_email, $key, $meta = array(
  * by a Super Admin).
  *
  * @since MU
- * @uses wp_generate_password()
- * @uses wpmu_welcome_user_notification()
- * @uses add_user_to_blog()
- * @uses wpmu_create_user()
- * @uses wpmu_create_blog()
- * @uses wpmu_welcome_notification()
  *
  * @param string $key The activation key provided to the user.
  * @return array An array containing information about the activated user and/or blog
@@ -1078,12 +1056,11 @@ function wpmu_activate_signup($key) {
  * use 'user_register').
  *
  * @since MU
- * @uses wp_create_user()
  *
  * @param string $user_name The new user's login name.
  * @param string $password The new user's password.
  * @param string $email The new user's email address.
- * @return mixed Returns false on failure, or int $user_id on success
+ * @return int|bool Returns false on failure, or int $user_id on success
  */
 function wpmu_create_user( $user_name, $password, $email ) {
        $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
@@ -1121,10 +1098,6 @@ function wpmu_create_user( $user_name, $password, $email ) {
  * root domain (eg 'blog1.example.com'), and $path is '/'.
  *
  * @since MU
- * @uses domain_exists()
- * @uses insert_blog()
- * @uses wp_install_defaults()
- * @uses add_user_to_blog()
  *
  * @param string $domain The new site's domain.
  * @param string $path The new site's path.
@@ -1248,7 +1221,6 @@ Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash( $_SERVER[
  * the notification email.
  *
  * @since MU
- * @uses apply_filters() Filter newuser_notify_siteadmin to change the content of the email message
  *
  * @param int $user_id The new user's ID.
  * @return bool
@@ -1354,8 +1326,6 @@ function insert_blog($domain, $path, $site_id) {
  * points to the new blog.
  *
  * @since MU
- * @uses make_db_current_silent()
- * @uses populate_roles()
  *
  * @param int $blog_id The value returned by insert_blog().
  * @param string $blog_title The title of the new site.
@@ -1379,7 +1349,9 @@ function install_blog( $blog_id, $blog_title = '' ) {
        make_db_current_silent( 'blog' );
        populate_options();
        populate_roles();
-       $wp_roles->_init();
+
+       // populate_roles() clears previous role definitions so we start over.
+       $wp_roles = new WP_Roles();
 
        $url = untrailingslashit( $url );
 
@@ -1408,7 +1380,6 @@ function install_blog( $blog_id, $blog_title = '' ) {
  * @since MU
  * @deprecated MU
  * @deprecated Use wp_install_defaults()
- * @uses wp_install_defaults()
  *
  * @param int $blog_id Ignored in this function.
  * @param int $user_id
@@ -1463,12 +1434,13 @@ function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta
 
        $welcome_email = get_site_option( 'welcome_email' );
        if ( $welcome_email == false )
-               $welcome_email = __( 'Dear User,
+               $welcome_email = __( 'Howdy USERNAME,
 
 Your new SITE_NAME site has been successfully set up at:
 BLOG_URL
 
 You can log in to the administrator account with the following information:
+
 Username: USERNAME
 Password: PASSWORD
 Log in here: BLOG_URLwp-login.php
@@ -1627,7 +1599,6 @@ function get_current_site() {
  * the most recent post_date_gmt.
  *
  * @since MU
- * @uses get_blogs_of_user()
  *
  * @param int $user_id
  * @return array Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts
@@ -1674,7 +1645,6 @@ function get_most_recent_post_of_user( $user_id ) {
  * a blog has exceeded its allowed upload space.
  *
  * @since MU
- * @uses recurse_dirsize()
  *
  * @param string $directory
  * @return int
@@ -1745,7 +1715,8 @@ function recurse_dirsize( $directory ) {
  * @return array
  */
 function check_upload_mimes( $mimes ) {
-       $site_exts = explode( ' ', get_site_option( 'upload_filetypes' ) );
+       $site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );
+       $site_mimes = array();
        foreach ( $site_exts as $ext ) {
                foreach ( $mimes as $ext_pattern => $mime ) {
                        if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false )
@@ -1830,11 +1801,13 @@ function global_terms( $term_id, $deprecated = '' ) {
                        $global_id = $wpdb->insert_id;
                }
        } elseif ( $global_id != $term_id ) {
-               $local_id = $wpdb->get_row( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) );
-               if ( null != $local_id )
-                       $local_id = global_terms( $local_id );
-                       if ( 10 < $global_terms_recurse )
+               $local_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) );
+               if ( null != $local_id ) {
+                       global_terms( $local_id );
+                       if ( 10 < $global_terms_recurse ) {
                                $global_id = $term_id;
+                       }
+               }
        }
 
        if ( $global_id != $term_id ) {
@@ -1887,7 +1860,6 @@ function upload_is_file_too_big( $upload ) {
  * Add a nonce field to the signup page.
  *
  * @since MU
- * @uses wp_nonce_field()
  */
 function signup_nonce_fields() {
        $id = mt_rand();
@@ -1899,7 +1871,6 @@ function signup_nonce_fields() {
  * Process the signup nonce created in signup_nonce_fields().
  *
  * @since MU
- * @uses wp_create_nonce()
  *
  * @param array $result
  * @return array
@@ -1945,7 +1916,6 @@ function maybe_redirect_404() {
  * added, as when a user is invited through the regular WP Add User interface.
  *
  * @since MU
- * @uses add_existing_user_to_blog()
  */
 function maybe_add_existing_user_to_blog() {
        if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
@@ -1964,14 +1934,13 @@ function maybe_add_existing_user_to_blog() {
        if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
                wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) );
 
-       wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ) );
+       wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ), array( 'response' => 200 ) );
 }
 
 /**
  * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
  *
  * @since MU
- * @uses add_user_to_blog()
  *
  * @param array $details
  */
@@ -2029,18 +1998,18 @@ function fix_phpmailer_messageid( $phpmailer ) {
  * Check to see whether a user is marked as a spammer, based on user login.
  *
  * @since MU
- * @uses get_user_by()
  *
  * @param string|WP_User $user Optional. Defaults to current user. WP_User object,
  *     or user login name as a string.
  * @return bool
  */
 function is_user_spammy( $user = null ) {
-    if ( ! is_a( $user, 'WP_User' ) ) {
-               if ( $user )
+    if ( ! ( $user instanceof WP_User ) ) {
+               if ( $user ) {
                        $user = get_user_by( 'login', $user );
-               else
+               } else {
                        $user = wp_get_current_user();
+               }
        }
 
        return $user && isset( $user->spam ) && 1 == $user->spam;
@@ -2052,22 +2021,18 @@ function is_user_spammy( $user = null ) {
  * Public blogs have a setting of 1, private blogs are 0.
  *
  * @since MU
- * @uses update_blog_status()
  *
  * @param int $old_value
  * @param int $value The new public value
- * @return bool
  */
 function update_blog_public( $old_value, $value ) {
        update_blog_status( get_current_blog_id(), 'public', (int) $value );
 }
-add_action('update_option_blog_public', 'update_blog_public', 10, 2);
 
 /**
  * Check whether a usermeta key has to do with the current blog.
  *
  * @since MU
- * @uses wp_get_current_user()
  *
  * @param string $key
  * @param int $user_id Optional. Defaults to current user.
@@ -2103,7 +2068,6 @@ function users_can_register_signup_filter() {
 
        return false;
 }
-add_filter('option_users_can_register', 'users_can_register_signup_filter');
 
 /**
  * Ensure that the welcome message is not empty. Currently unused.
@@ -2116,7 +2080,7 @@ add_filter('option_users_can_register', 'users_can_register_signup_filter');
 function welcome_user_msg_filter( $text ) {
        if ( !$text ) {
                remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
-               $text = __( 'Dear User,
+               $text = __( 'Howdy USERNAME,
 
 Your new account is set up.
 
@@ -2132,7 +2096,6 @@ Thanks!
        }
        return $text;
 }
-add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
 
 /**
  * Whether to force SSL on content.
@@ -2204,8 +2167,6 @@ function wp_update_network_counts() {
  * on a network when a site is created or its status is updated.
  *
  * @since 3.7.0
- *
- * @uses wp_update_network_site_counts()
  */
 function wp_maybe_update_network_site_counts() {
        $is_small_network = ! wp_is_large_network( 'sites' );
@@ -2233,8 +2194,6 @@ function wp_maybe_update_network_site_counts() {
  * on a network when a user is created or its status is updated.
  *
  * @since 3.7.0
- *
- * @uses wp_update_network_user_counts()
  */
 function wp_maybe_update_network_user_counts() {
        $is_small_network = ! wp_is_large_network( 'users' );