Skip to:
Content

BuddyPress.org

Ticket #3560: 3560.002.diff

File 3560.002.diff, 1.3 KB (added by cnorris23, 13 years ago)
  • bp-core/bp-core-buddybar.php

     
    524524}
    525525
    526526/**
     527 * Retrieve the admin bar display preference of a user based on context.
     528 *
     529 * This is a direct copy of WP's private _get_admin_bar_pref()
     530 *
     531 * @since 1.5.0
     532 *
     533 * @param string $context Context of this preference check, either 'admin' or 'front'.
     534 * @param int $user Optional. ID of the user to check, defaults to 0 for current user.
     535 *
     536 * @uses get_user_option()
     537 *
     538 * @return bool Whether the admin bar should be showing for this user.
     539 */
     540function bp_get_admin_bar_pref( $context, $user = 0 ) {
     541        $pref = get_user_option( "show_admin_bar_{$context}", $user );
     542        if ( false === $pref )
     543                return true;
     544
     545        return 'true' === $pref;
     546}
     547
     548/**
    527549 * Handle the Admin Bar/BuddyBar business
    528550 *
    529551 * @since 1.2.0
     
    550572
    551573        // Show the WordPress admin bar
    552574        if ( bp_use_wp_admin_bar() && $wp_version >= 3.1 ) {
     575                // Respect user's admin bar display preferences
     576                if ( bp_get_admin_bar_pref( 'front', bp_loggedin_user_id() ) || bp_get_admin_bar_pref( 'admin', bp_loggedin_user_id() ) )
     577                        return;
     578
    553579                show_admin_bar( true );
    554580
    555581        // Hide the WordPress admin bar