]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/ms-functions.php
WordPress 4.0
[autoinstalls/wordpress.git] / wp-includes / ms-functions.php
index b7b4b6af35a5930b6c929dc6622c08d9e22bcd24..6d7a2fbd52bef85c4778fa4a40d19fdfed60bddd 100644 (file)
@@ -275,8 +275,18 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
 
        if ( $reassign != '' ) {
                $reassign = (int) $reassign;
-               $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id) );
-               $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id) );
+               $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) );
+               $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $user_id ) );
+
+               if ( ! empty( $post_ids ) ) {
+                       $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id ) );
+                       array_walk( $post_ids, 'clean_post_cache' );
+               }
+
+               if ( ! empty( $link_ids ) ) {
+                       $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id ) );
+                       array_walk( $link_ids, 'clean_bookmark_cache' );
+               }
        }
 
        restore_current_blog();
@@ -870,7 +880,7 @@ function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_ema
                $from_name,
                esc_url( 'http://' . $domain . $path )
        );
-       wp_mail($user_email, $subject, $message, $message_headers);
+       wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
        return true;
 }
 
@@ -955,7 +965,7 @@ function wpmu_signup_user_notification( $user, $user_email, $key, $meta = array(
                $from_name,
                $user
        );
-       wp_mail($user_email, $subject, $message, $message_headers);
+       wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
        return true;
 }
 
@@ -1289,7 +1299,9 @@ Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['RE
  */
 function domain_exists($domain, $path, $site_id = 1) {
        global $wpdb;
+       $path = trailingslashit( $path );
        $result = $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) );
+
        /**
         * Filter whether a blogname is taken.
         *
@@ -1509,7 +1521,7 @@ We hope you enjoy your new site. Thanks!
         * @param string $subject Subject of the email.
         */
        $subject = apply_filters( 'update_welcome_subject', sprintf( __( 'New %1$s Site: %2$s' ), $current_site->site_name, wp_unslash( $title ) ) );
-       wp_mail($user->user_email, $subject, $message, $message_headers);
+       wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
        return true;
 }
 
@@ -1587,7 +1599,7 @@ function wpmu_welcome_user_notification( $user_id, $password, $meta = array() )
         * @param string $subject Subject of the email.
         */
        $subject = apply_filters( 'update_welcome_user_subject', sprintf( __( 'New %1$s User: %2$s' ), $current_site->site_name, $user->user_login) );
-       wp_mail($user->user_email, $subject, $message, $message_headers);
+       wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
        return true;
 }
 
@@ -1749,7 +1761,7 @@ function check_upload_mimes( $mimes ) {
  * WordPress MS stores a blog's post count as an option so as
  * to avoid extraneous COUNTs when a blog's details are fetched
  * with get_blog_details(). This function is called when posts
- * are published to make sure the count stays current.
+ * are published or unpublished to make sure the count stays current.
  *
  * @since MU
  */
@@ -2066,11 +2078,9 @@ function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
        global $wpdb;
 
        $current_user = wp_get_current_user();
-       if ( $user_id == 0 )
-               $user_id = $current_user->ID;
-       if ( $blog_id == 0 )
+       if ( $blog_id == 0 ) {
                $blog_id = $wpdb->blogid;
-
+       }
        $local_key = $wpdb->get_blog_prefix( $blog_id ) . $key;
 
        if ( isset( $current_user->$local_key ) )