WordPress.org

Make WordPress Core

Ticket #16702: 16702.4.patch

File 16702.4.patch, 3.0 KB (added by SergeyBiryukov, 7 years ago)
  • wp-includes/deprecated.php

     
    28702870                        $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
    28712871        }
    28722872}
     2873
     2874/**
     2875 * Checks if the current user belong to a given blog.
     2876 *
     2877 * @since MU
     2878 * @deprecated 3.3
     2879 * @deprecated Use is_user_member_of_blog()
     2880 * @see is_user_member_of_blog()
     2881 *
     2882 * @param int $blog_id Blog ID
     2883 * @return bool True if the current users belong to $blog_id, false if not.
     2884 */
     2885function is_blog_user( $blog_id = 0 ) {
     2886        _deprecated_function( __FUNCTION__, '3.3', 'is_user_member_of_blog()' );
     2887
     2888        return is_user_member_of_blog( get_current_user_id(), $blog_id );
     2889}
  • wp-includes/ms-functions.php

     
    119119}
    120120
    121121/**
    122  * Find out whether a user is a member of a given blog.
    123  *
    124  * @since MU 1.1
    125  * @uses get_blogs_of_user()
    126  *
    127  * @param int $user_id The unique ID of the user
    128  * @param int $blog Optional. If no blog_id is provided, current site is used
    129  * @return bool
    130  */
    131 function is_user_member_of_blog( $user_id, $blog_id = 0 ) {
    132         $user_id = (int) $user_id;
    133         $blog_id = (int) $blog_id;
    134 
    135         if ( $blog_id == 0 ) {
    136                 global $wpdb;
    137                 $blog_id = $wpdb->blogid;
    138         }
    139 
    140         $blogs = get_blogs_of_user( $user_id );
    141         if ( is_array( $blogs ) )
    142                 return array_key_exists( $blog_id, $blogs );
    143         else
    144                 return false;
    145 }
    146 
    147 /**
    148122 * The number of active users in your installation.
    149123 *
    150124 * The count is cached and updated twice daily. This is not a live count.
  • wp-includes/user.php

     
    720720}
    721721
    722722/**
    723  * Checks if the current user belong to a given blog.
     723 * Find out whether a user is a member of a given blog.
    724724 *
    725  * @since MU
     725 * @since MU 1.1
     726 * @uses get_blogs_of_user()
    726727 *
    727  * @param int $blog_id Blog ID
    728  * @return bool True if the current users belong to $blog_id, false if not.
     728 * @param int $user_id The unique ID of the user
     729 * @param int $blog Optional. If no blog_id is provided, current site is used
     730 * @return bool
    729731 */
    730 function is_blog_user( $blog_id = 0 ) {
    731         global $wpdb;
     732function is_user_member_of_blog( $user_id, $blog_id = 0 ) {
     733        $user_id = (int) $user_id;
     734        $blog_id = (int) $blog_id;
    732735
    733         if ( ! $blog_id )
     736        if ( $blog_id == 0 ) {
     737                global $wpdb;
    734738                $blog_id = $wpdb->blogid;
     739        }
    735740
    736         $blogs = get_blogs_of_user( get_current_user_id() );
    737 
    738         return is_array( $blogs ) && array_key_exists( $blog_id, $blogs );
     741        $blogs = get_blogs_of_user( $user_id );
     742        if ( is_array( $blogs ) )
     743                return array_key_exists( $blog_id, $blogs );
     744        else
     745                return false;
    739746}
    740747
    741748/**