Skip to:
Content

BuddyPress.org

Changeset 9470


Ignore:
Timestamp:
02/10/2015 01:09:09 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Beautify /deprecated/2.1.php:

  • Add brackets
  • Remove $bp global touches (See #5138)
  • Use bp_is_root_blog() rather than direct comparisons to bp_get_root_blog()
  • Easier to navigate when testing & debugging deprecated functionality
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/deprecated/2.1.php

    r9468 r9470  
    9797 */
    9898function bp_adminbar_blogs_menu() {
    99         global $bp;
    100 
    101         if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )
    102                 return false;
    103 
    104         if ( !is_multisite() )
    105                 return false;
     99
     100        if ( ! is_user_logged_in() || ! bp_is_active( 'blogs' ) ) {
     101                return false;
     102        }
     103
     104        if ( ! is_multisite() ) {
     105                return false;
     106        }
    106107
    107108        $blogs = wp_cache_get( 'bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', 'bp' );
    … …  
    192193 */
    193194function bp_core_admin_bar() {
    194         global $bp;
    195 
    196         if ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR )
    197                 return false;
    198 
    199         if ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
    200                 return false;
     195        $bp = buddypress();
     196
     197        if ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR ) {
     198                return false;
     199        }
     200
     201        if ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) {
     202                return false;
     203        }
    201204
    202205        $bp->doing_admin_bar = true;
    … …  
    238241function bp_adminbar_login_menu() {
    239242
    240         if ( is_user_logged_in() )
    241                 return false;
     243        if ( is_user_logged_in() ) {
     244                return false;
     245        }
    242246
    243247        echo '<li class="bp-login no-arrow"><a href="' . wp_login_url() . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
    244248
    245249        // Show "Sign Up" link if user registrations are allowed
    246         if ( bp_get_signup_allowed() )
     250        if ( bp_get_signup_allowed() ) {
    247251                echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page() . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
     252        }
    248253}
    249254
    … …  
    256261 */
    257262function bp_adminbar_account_menu() {
    258         global $bp;
    259 
    260         if ( !$bp->bp_nav || !is_user_logged_in() )
    261                 return false;
     263        $bp = buddypress();
     264
     265        if ( empty( $bp->bp_nav ) || ! is_user_logged_in() ) {
     266                return false;
     267        }
    262268
    263269        echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
    … …  
    270276                $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    271277
    272                 if ( -1 == $nav_item['position'] )
     278                if ( -1 == $nav_item['position'] ) {
    273279                        continue;
     280                }
    274281
    275282                echo '<li' . $alt . '>';
    … …  
    284291                                $name = $subnav_item['name'];
    285292
    286                                 if ( bp_displayed_user_domain() )
     293                                if ( bp_displayed_user_domain() ) {
    287294                                        $link = str_replace( bp_displayed_user_domain(), bp_loggedin_user_domain(), $subnav_item['link'] );
    288 
    289                                 if ( isset( $bp->displayed_user->userdata->user_login ) )
     295                                }
     296
     297                                if ( isset( $bp->displayed_user->userdata->user_login ) ) {
    290298                                        $name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
     299                                }
    291300
    292301                                $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
    … …  
    368377 */
    369378function bp_core_load_buddybar_css() {
    370         if ( bp_use_wp_admin_bar() || ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) || ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR ) )
     379
     380        if ( bp_use_wp_admin_bar() || ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) || ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR ) ) {
    371381                return;
     382        }
    372383
    373384        $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
    … …  
    394405 *
    395406 * @deprecated BuddyPress (2.1.0)
    396  *
    397  * @global BuddyPress $bp
    398407 */
    399408function bp_groups_adminbar_admin_menu() {
    400         global $bp;
    401 
    402         if ( empty( $bp->groups->current_group ) )
    403                 return false;
     409        $bp = buddypress();
     410
     411        if ( empty( $bp->groups->current_group ) ) {
     412                return false;
     413        }
    404414
    405415        // Only group admins and site admins can see this menu
    406         if ( !current_user_can( 'edit_users' ) && !bp_current_user_can( 'bp_moderate' ) && !bp_is_item_admin() )
    407                 return false; ?>
     416        if ( !current_user_can( 'edit_users' ) && !bp_current_user_can( 'bp_moderate' ) && !bp_is_item_admin() ) {
     417                return false;
     418        } ?>
    408419
    409420        <li id="bp-adminbar-adminoptions-menu">
    … …  
    471482
    472483        // Only for multisite
    473         if ( !is_multisite() )
    474                 return false;
     484        if ( ! is_multisite() ) {
     485                return false;
     486        }
    475487
    476488        // Hide on root blog
    477         if ( $wpdb->blogid == bp_get_root_blog_id() || !bp_is_active( 'blogs' ) )
    478                 return false;
     489        if ( bp_is_root_blog( $wpdb->blogid ) || ! bp_is_active( 'blogs' ) ) {
     490                return false;
     491        }
    479492
    480493        $blog_prefix = $wpdb->get_blog_prefix( $wpdb->blogid );
    … …  
    490503                foreach( (array) $authors as $author ) {
    491504                        $caps = maybe_unserialize( $author->caps );
    492                         if ( isset( $caps['subscriber'] ) || isset( $caps['contributor'] ) ) continue;
     505                        if ( isset( $caps['subscriber'] ) || isset( $caps['contributor'] ) ) {
     506                                continue;
     507                        }
    493508
    494509                        echo '<li>';
    … …  
    522537
    523538        // Only show if viewing a user
    524         if ( !bp_displayed_user_id() )
    525                 return false;
     539        if ( ! bp_displayed_user_id() ) {
     540                return false;
     541        }
    526542
    527543        // Don't show this menu to non site admins or if you're viewing your own profile
    528         if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() )
    529                 return false; ?>
     544        if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() ) {
     545                return false;
     546        } ?>
    530547
    531548        <li id="bp-adminbar-adminoptions-menu">
    … …  
    570587        _e( 'Notifications', 'buddypress' );
    571588
    572         if ( $notification_count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) ) : ?>
     589        $notification_count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
     590        $notifications      = bp_notifications_get_notifications_for_user( bp_loggedin_user_id() );
     591
     592        if ( ! empty( $notification_count ) ) : ?>
    573593                <span><?php echo bp_core_number_format( $notification_count ); ?></span>
    574594        <?php
    … …  
    578598        echo '<ul>';
    579599
    580         if ( $notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id() ) ) {
     600        if ( ! empty( $notifications ) ) {
    581601                $counter = 0;
    582602                for ( $i = 0, $count = count( $notifications ); $i < $count; ++$i ) {
Note: See TracChangeset for help on using the changeset viewer.