Make WordPress Core

Changeset 19016


Ignore:
Timestamp:
10/19/2011 10:35:15 PM (12 years ago)
Author:
ryan
Message:

Turn is_blog_user() into a wrapper around is_user_member_of_blog() and deprecate. Make user_id optional for is_user_member_of_blog(). Props SergeyBiryukov. fixes #16702

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/deprecated.php

    r18907 r19016  
    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}
  • trunk/wp-includes/ms-functions.php

    r18899 r19016  
    117117        return $primary;
    118118    }
    119 }
    120 
    121 /**
    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;
    145119}
    146120
  • trunk/wp-includes/user.php

    r19005 r19016  
    721721
    722722/**
    723  * Checks if the current user belong to a given blog.
    724  *
    725  * @since MU
    726  *
    727  * @param int $blog_id Blog ID
    728  * @return bool True if the current users belong to $blog_id, false if not.
    729  */
    730 function is_blog_user( $blog_id = 0 ) {
    731     global $wpdb;
    732 
    733     if ( ! $blog_id )
     723 * Find out whether a user is a member of a given blog.
     724 *
     725 * @since MU 1.1
     726 * @uses get_blogs_of_user()
     727 *
     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
     731 */
     732function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) {
     733    $user_id = (int) $user_id;
     734    $blog_id = (int) $blog_id;
     735
     736    if ( empty( $user_id ) )
     737        $user_id = get_current_user_id();
     738
     739    if ( empty( $blog_id ) ) {
     740        global $wpdb;
    734741        $blog_id = $wpdb->blogid;
    735 
    736     $blogs = get_blogs_of_user( get_current_user_id() );
    737 
    738     return is_array( $blogs ) && array_key_exists( $blog_id, $blogs );
     742    }
     743
     744    $blogs = get_blogs_of_user( $user_id );
     745    if ( is_array( $blogs ) )
     746        return array_key_exists( $blog_id, $blogs );
     747    else
     748        return false;
    739749}
    740750
Note: See TracChangeset for help on using the changeset viewer.