Skip to:
Content

BuddyPress.org

Changeset 8698


Ignore:
Timestamp:
07/27/2014 04:07:53 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Clean up bp-core-template.php:

  • Add brackets where necessary.
  • Wrap array/object references in empty() where necessary to avoid debug notices.
  • Replace $bp global touches with buddypress() calls.
  • Remove some trailing whitespace.
  • Add some inline/phpdoc doc.
  • Add filters to commonly used _is_ functions.
  • Clean-up logic in some _is_ functions.
File:
1 edited

Legend:

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

    r8682 r8698  
    2929 */
    3030function bp_get_options_nav() {
    31     global $bp;
    32 
    33     // If we are looking at a member profile, then the we can use the current component as an
    34     // index. Otherwise we need to use the component's root_slug
     31    $bp = buddypress();
     32
     33    // If we are looking at a member profile, then the we can use the current
     34    // component as an index. Otherwise we need to use the component's root_slug
    3535    $component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() );
    3636
    37     if ( !bp_is_single_item() ) {
     37    if ( ! bp_is_single_item() ) {
    3838        if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) {
    3939            return false;
     
    5151    // Loop through each navigation item
    5252    foreach ( (array) $bp->bp_options_nav[$the_index] as $subnav_item ) {
    53         if ( !$subnav_item['user_has_access'] )
     53        if ( empty( $subnav_item['user_has_access'] ) ) {
    5454            continue;
     55        }
    5556
    5657        // If the current action or an action variable matches the nav item id, then add a highlight CSS class.
     
    7677 */
    7778function bp_get_options_title() {
    78     global $bp;
    79 
    80     if ( empty( $bp->bp_options_title ) )
     79    $bp = buddypress();
     80
     81    if ( empty( $bp->bp_options_title ) ) {
    8182        $bp->bp_options_title = __( 'Options', 'buddypress' );
     83    }
    8284
    8385    echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) );
     
    119121 * Not currently used in BuddyPress.
    120122 *
    121  * @global BuddyPress $bp The one true BuddyPress instance.
     123 * @return bool Returns true if an options avatar has been set, otherwise false.
     124 */
     125function bp_has_options_avatar() {
     126    return (bool) buddypress()->bp_options_avatar;
     127}
     128
     129/**
     130 * Output the options avatar.
     131 *
     132 * Not currently used in BuddyPress.
     133 *
    122134 * @todo Deprecate.
    123  *
    124  * @return bool Returns true if an options avatar has been set, otherwise
    125  *         false.
    126  */
    127 function bp_has_options_avatar() {
    128     global $bp;
    129 
    130     if ( empty( $bp->bp_options_avatar ) )
    131         return false;
    132 
    133     return true;
    134 }
    135 
    136 /**
    137  * Output the options avatar.
     135 */
     136function bp_get_options_avatar() {
     137    echo apply_filters( 'bp_get_options_avatar', buddypress()->bp_options_avatar );
     138}
     139
     140/**
     141 * Output a comment author's avatar.
    138142 *
    139143 * Not currently used in BuddyPress.
    140  *
    141  * @todo Deprecate.
    142  */
    143 function bp_get_options_avatar() {
    144     global $bp;
    145 
    146     echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_avatar );
    147 }
    148 
    149 /**
    150  * Output a comment author's avatar.
    151  *
    152  * Not currently used in BuddyPress.
    153  *
    154  * @todo Deprecate.
    155144 */
    156145function bp_comment_author_avatar() {
    157146    global $comment;
    158147
    159     if ( function_exists( 'bp_core_fetch_avatar' ) )
    160         echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $comment->user_id ) ) ) ) );
    161     else if ( function_exists('get_avatar') )
     148    if ( function_exists( 'bp_core_fetch_avatar' ) ) {
     149        echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array(
     150            'item_id' => $comment->user_id,
     151            'type'    => 'thumb',
     152            'alt'     => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $comment->user_id ) )
     153        ) ) );
     154    } elseif ( function_exists( 'get_avatar' ) ) {
    162155        get_avatar();
     156    }
    163157}
    164158
     
    167161 *
    168162 * Not currently used in BuddyPress.
    169  *
    170  * @todo Deprecate.
    171163 */
    172164function bp_post_author_avatar() {
    173165    global $post;
    174166
    175     if ( function_exists( 'bp_core_fetch_avatar' ) )
    176         echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $post->post_author ) ) ) ) );
    177     else if ( function_exists('get_avatar') )
     167    if ( function_exists( 'bp_core_fetch_avatar' ) ) {
     168        echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array(
     169            'item_id' => $post->post_author,
     170            'type'    => 'thumb',
     171            'alt'     => sprintf( __( 'Profile photo of %s', 'buddypress' ), bp_core_get_user_displayname( $post->post_author ) )
     172        ) ) );
     173    } elseif ( function_exists( 'get_avatar' ) ) {
    178174        get_avatar();
     175    }
    179176}
    180177
     
    192189     */
    193190    function bp_get_avatar_admin_step() {
    194         global $bp;
    195 
    196         if ( isset( $bp->avatar_admin->step ) )
    197             $step = $bp->avatar_admin->step;
    198         else
    199             $step = 'upload-image';
     191        $bp   = buddypress();
     192        $step = isset( $bp->avatar_admin->step )
     193            ? $step = $bp->avatar_admin->step
     194            : 'upload-image';
    200195
    201196        return apply_filters( 'bp_get_avatar_admin_step', $step );
     
    214209     */
    215210    function bp_get_avatar_to_crop() {
    216         global $bp;
    217 
    218         if ( isset( $bp->avatar_admin->image->url ) )
    219             $url = $bp->avatar_admin->image->url;
    220         else
    221             $url = '';
     211        $bp  = buddypress();
     212        $url = isset( $bp->avatar_admin->image->url )
     213            ? $bp->avatar_admin->image->url
     214            : $url = '';
    222215
    223216        return apply_filters( 'bp_get_avatar_to_crop', $url );
     
    236229     */
    237230    function bp_get_avatar_to_crop_src() {
    238         global $bp;
    239 
    240         return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) );
     231        return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', buddypress()->avatar_admin->image->dir ) );
    241232    }
    242233
     
    249240 */
    250241function bp_avatar_cropper() {
    251     global $bp;
    252 
    253     echo '<img id="avatar-to-crop" class="avatar" src="' . $bp->avatar_admin->image . '" />';
     242?>
     243    <img id="avatar-to-crop" class="avatar" src="<?php echo esc_url( buddypress()->avatar_admin->image ); ?>" />
     244<?php
    254245}
    255246
     
    282273 */
    283274function bp_format_time( $time, $just_date = false, $localize_time = true ) {
    284     if ( !isset( $time ) || !is_numeric( $time ) )
     275
     276    if ( ! isset( $time ) || ! is_numeric( $time ) ) {
    285277        return false;
     278    }
    286279
    287280    // Get GMT offset from root blog
    288281    $root_blog_offset = false;
    289     if ( $localize_time )
     282    if ( ! empty( $localize_time ) ) {
    290283        $root_blog_offset = get_blog_option( bp_get_root_blog_id(), 'gmt_offset' );
     284    }
    291285
    292286    // Calculate offset time
     
    297291
    298292    // Should we show the time also?
    299     if ( !$just_date ) {
     293    if ( empty( $just_date ) ) {
    300294        // Current time (9:50pm)
    301295        $time = date_i18n( get_option( 'time_format' ), $time_offset );
     
    328322function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
    329323
    330     if ( !empty( $capitalize ) )
     324    if ( ! empty( $capitalize ) ) {
    331325        $youtext = bp_core_ucfirst( $youtext );
     326    }
    332327
    333328    if ( bp_displayed_user_id() == bp_loggedin_user_id() ) {
     
    383378    $options = array();
    384379
    385     if ( bp_is_active( 'xprofile' ) )
     380    if ( bp_is_active( 'xprofile' ) ) {
    386381        $options['members'] = __( 'Members', 'buddypress' );
    387 
    388     if ( bp_is_active( 'groups' ) )
     382    }
     383
     384    if ( bp_is_active( 'groups' ) ) {
    389385        $options['groups']  = __( 'Groups',  'buddypress' );
    390 
    391     if ( bp_is_active( 'blogs' ) && is_multisite() )
     386    }
     387
     388    if ( bp_is_active( 'blogs' ) && is_multisite() ) {
    392389        $options['blogs']   = __( 'Blogs',   'buddypress' );
    393 
    394     if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() )
     390    }
     391
     392    if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() ) {
    395393        $options['forums']  = __( 'Forums',  'buddypress' );
     394    }
    396395
    397396    $options['posts'] = __( 'Posts', 'buddypress' );
     
    402401
    403402    $options = apply_filters( 'bp_search_form_type_select_options', $options );
    404     foreach( (array) $options as $option_value => $option_title )
     403    foreach( (array) $options as $option_value => $option_title ) {
    405404        $selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title );
     405    }
    406406
    407407    $selection_box .= '</select>';
     
    433433        global $bp;
    434434
    435         if ( empty( $component ) )
     435        if ( empty( $component ) ) {
    436436            $component = bp_current_component();
     437        }
    437438
    438439        $default_text = __( 'Search anything...', 'buddypress' );
     
    447448                if ( !empty( $bp->pages->{$component}->slug ) ) {
    448449                    $key = $bp->pages->{$component}->slug;
    449                     if ( !empty( $bp->{$key}->search_string ) )
     450                    if ( !empty( $bp->{$key}->search_string ) ) {
    450451                        $default_text = $bp->{$key}->search_string;
     452                    }
    451453                }
    452454            }
     
    534536 */
    535537function bp_create_excerpt( $text, $length = 225, $options = array() ) {
     538
    536539    // Backward compatibility. The third argument used to be a boolean $filter_shortcodes
    537540    $filter_shortcodes_default = is_bool( $options ) ? $options : true;
    538541
    539     $defaults = array(
     542    $r = wp_parse_args( $options, array(
    540543        'ending'            => __( ' [&hellip;]', 'buddypress' ),
    541544        'exact'             => false,
    542545        'html'              => true,
    543546        'filter_shortcodes' => $filter_shortcodes_default
    544     );
    545     $r = wp_parse_args( $options, $defaults );
     547    ) );
    546548    extract( $r );
    547549
     
    554556
    555557    // Remove shortcodes if necessary
    556     if ( !empty( $filter_shortcodes ) )
     558    if ( ! empty( $filter_shortcodes ) ) {
    557559        $text = strip_shortcodes( $text );
     560    }
    558561
    559562    // When $html is true, the excerpt should be created without including HTML tags in the
    560563    // excerpt length
    561     if ( !empty( $html ) ) {
     564    if ( ! empty( $html ) ) {
    562565        // The text is short enough. No need to truncate
    563566        if ( mb_strlen( preg_replace( '/<.*?>/', '', $text ) ) <= $length ) {
     
    692695     */
    693696    function bp_get_blog_signup_allowed() {
    694         global $bp;
    695 
    696         if ( !is_multisite() )
     697
     698        if ( ! is_multisite() ) {
    697699            return false;
    698 
    699         $status = $bp->site_options['registration'];
    700         if ( 'none' != $status && 'user' != $status )
     700        }
     701
     702        $status = buddypress()->site_options['registration'];
     703        if ( ( 'none' !== $status ) && ( 'user' !== $status ) ) {
    701704            return true;
     705        }
    702706
    703707        return false;
     
    711715 */
    712716function bp_account_was_activated() {
    713     global $bp;
    714 
    715     $activation_complete = !empty( $bp->activation_complete ) ? $bp->activation_complete : false;
     717    $bp                  = buddypress();
     718    $activation_complete = !empty( $bp->activation_complete )
     719        ? $bp->activation_complete
     720        : false;
    716721
    717722    return $activation_complete;
     
    756761function bp_get_email_subject( $args = array() ) {
    757762
    758     $r = wp_parse_args( $args, array(
     763    $r = bp_parse_args( $args, array(
    759764        'before'  => '[',
    760765        'after'   => ']',
    761766        'default' => __( 'Community', 'buddypress' ),
    762767        'text'    => ''
    763     ) );
     768    ), 'get_email_subject' );
    764769
    765770    $subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text'];
     
    782787 */
    783788function bp_ajax_querystring( $object = false ) {
    784     global $bp;
    785 
    786     if ( !isset( $bp->ajax_querystring ) )
     789    $bp = buddypress();
     790
     791    if ( ! isset( $bp->ajax_querystring ) ) {
    787792        $bp->ajax_querystring = '';
     793    }
    788794
    789795    return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object );
     
    798804 */
    799805function bp_current_component() {
    800     global $bp;
     806    $bp                = buddypress();
    801807    $current_component = !empty( $bp->current_component ) ? $bp->current_component : false;
    802808    return apply_filters( 'bp_current_component', $current_component );
     
    809815 */
    810816function bp_current_action() {
    811     global $bp;
     817    $bp            = buddypress();
    812818    $current_action = !empty( $bp->current_action ) ? $bp->current_action : '';
    813819    return apply_filters( 'bp_current_action', $current_action );
     
    820826 */
    821827function bp_current_item() {
    822     global $bp;
     828    $bp           = buddypress();
    823829    $current_item = !empty( $bp->current_item ) ? $bp->current_item : false;
    824830    return apply_filters( 'bp_current_item', $current_item );
     
    832838 */
    833839function bp_action_variables() {
    834     global $bp;
     840    $bp               = buddypress();
    835841    $action_variables = !empty( $bp->action_variables ) ? $bp->action_variables : false;
    836842    return apply_filters( 'bp_action_variables', $action_variables );
     
    865871     */
    866872    function bp_get_root_domain() {
    867         global $bp;
     873        $bp = buddypress();
    868874
    869875        if ( isset( $bp->root_domain ) && !empty( $bp->root_domain ) ) {
     
    920926     */
    921927    function bp_get_root_slug( $component = '' ) {
    922         global $bp;
    923 
     928        $bp        = buddypress();
    924929        $root_slug = '';
    925930
    926931        // Use current global component if none passed
    927         if ( empty( $component ) )
     932        if ( empty( $component ) ) {
    928933            $component = bp_current_component();
     934        }
    929935
    930936        // Component is active
     
    941947
    942948        // No specific root slug, so fall back to component slug
    943         if ( empty( $root_slug ) )
     949        if ( empty( $root_slug ) ) {
    944950            $root_slug = $component;
     951        }
    945952
    946953        return apply_filters( 'bp_get_root_slug', $root_slug, $component );
     
    958965 */
    959966function bp_get_name_from_root_slug( $root_slug = '' ) {
    960     global $bp;
     967    $bp = buddypress();
    961968
    962969    // If no slug is passed, look at current_component
    963     if ( empty( $root_slug ) )
     970    if ( empty( $root_slug ) ) {
    964971        $root_slug = bp_current_component();
     972    }
    965973
    966974    // No current component or root slug, so flee
    967     if ( empty( $root_slug ) )
     975    if ( empty( $root_slug ) ) {
    968976        return false;
     977    }
    969978
    970979    // Loop through active components and look for a match
     
    10601069
    10611070    // Backward compatibility: 'xprofile' should be read as 'profile'
    1062     if ( 'xprofile' == $component )
     1071    if ( 'xprofile' === $component ) {
    10631072        $component = 'profile';
     1073    }
    10641074
    10651075    if ( ! empty( $bp->current_component ) ) {
     
    11411151 */
    11421152function bp_is_current_action( $action = '' ) {
    1143     if ( $action == bp_current_action() )
     1153    if ( $action === bp_current_action() ) {
    11441154        return true;
     1155    }
    11451156
    11461157    return false;
     
    11941205 */
    11951206function bp_is_current_item( $item = '' ) {
    1196     if ( !empty( $item ) && $item == bp_current_item() )
    1197         return true;
    1198 
    1199     return false;
     1207    $retval = ( $item === bp_current_item() );
     1208
     1209    return (bool) apply_filters( 'bp_is_current_item', $retval, $item );
    12001210}
    12011211
     
    12061216 */
    12071217function bp_is_single_item() {
    1208     global $bp;
    1209 
    1210     if ( !empty( $bp->is_single_item ) )
    1211         return true;
    1212 
    1213     return false;
     1218    $bp     = buddypress();
     1219    $retval = false;
     1220
     1221    if ( isset( $bp->is_single_item ) ) {
     1222        $retval = $bp->is_single_item;
     1223    }
     1224
     1225    return (bool) apply_filters( 'bp_is_single_item', $retval );
    12141226}
    12151227
     
    12211233 */
    12221234function bp_is_item_admin() {
    1223     global $bp;
    1224 
    1225     if ( !empty( $bp->is_item_admin ) )
    1226         return true;
    1227 
    1228     return false;
     1235    $bp     = buddypress();
     1236    $retval = false;
     1237
     1238    if ( isset( $bp->is_item_admin ) ) {
     1239        $retval = $bp->is_item_admin;
     1240    }
     1241
     1242    return (bool) apply_filters( 'bp_is_item_admin', $retval );
    12291243}
    12301244
     
    12361250 */
    12371251function bp_is_item_mod() {
    1238     global $bp;
    1239 
    1240     if ( !empty( $bp->is_item_mod ) )
    1241         return true;
    1242 
    1243     return false;
     1252    $bp     = buddypress();
     1253    $retval = false;
     1254
     1255    if ( isset( $bp->is_item_mod ) ) {
     1256        $retval = $bp->is_item_mod;
     1257    }
     1258
     1259    return (bool) apply_filters( 'bp_is_item_mod', $retval );
    12441260}
    12451261
     
    12511267 */
    12521268function bp_is_directory() {
    1253     global $bp;
    1254 
    1255     if ( !empty( $bp->is_directory ) )
    1256         return true;
    1257 
    1258     return false;
     1269    $bp     = buddypress();
     1270    $retval = false;
     1271
     1272    if ( isset( $bp->is_directory ) ) {
     1273        $retval = $bp->is_directory;
     1274    }
     1275
     1276    return (bool) apply_filters( 'bp_is_directory', $retval );
    12591277}
    12601278
     
    12621280 * Check to see if a component's URL should be in the root, not under a member page.
    12631281 *
    1264  *   Yes ('groups' is root): http://domain.com/groups/the-group
    1265  *   No ('groups' is not-root):  http://domain.com/members/andy/groups/the-group
     1282 * - Yes ('groups' is root)    : http://domain.com/groups/the-group
     1283 * - No  ('groups' is not-root): http://domain.com/members/andy/groups/the-group
     1284 *
     1285 * This function is on the chopping block. It's currently only used by a few
     1286 * already deprecated functions.
    12661287 *
    12671288 * @return bool True if root component, else false.
    12681289 */
    1269 function bp_is_root_component( $component_name ) {
    1270     global $bp;
    1271 
    1272     if ( !isset( $bp->active_components ) )
     1290function bp_is_root_component( $component_name = '' ) {
     1291    $bp     = buddypress();
     1292    $retval = false;
     1293
     1294    // Default to the current component if none is passed
     1295    if ( empty( $component_name ) ) {
     1296        $component_name = bp_current_component();
     1297    }
     1298
     1299    // Loop through active components and check for key/slug matches
     1300    if ( ! empty( $bp->active_components ) ) {
     1301        foreach ( (array) $bp->active_components as $key => $slug ) {
     1302            if ( ( $key === $component_name ) || ( $slug === $component_name ) ) {
     1303                $retval = true;
     1304                break;
     1305            }
     1306        }
     1307    }
     1308
     1309    return (bool) apply_filters( 'bp_is_root_component', $retval );
     1310}
     1311
     1312/**
     1313 * Check if the specified BuddyPress component directory is set to be the front page.
     1314 *
     1315 * Corresponds to the setting in wp-admin's Settings > Reading screen.
     1316 *
     1317 * @since BuddyPress (1.5.0)
     1318 *
     1319 * @global $current_blog WordPress global for the current blog.
     1320 *
     1321 * @param string $component Optional. Name of the component to check for.
     1322 *                          Default: current component.
     1323 * @return bool True if the specified component is set to be the site's front
     1324 *              page, otherwise false.
     1325 */
     1326function bp_is_component_front_page( $component = '' ) {
     1327    global $current_blog;
     1328
     1329    $bp = buddypress();
     1330
     1331    // Default to the current component if none is passed
     1332    if ( empty( $component ) ) {
     1333        $component = bp_current_component();
     1334    }
     1335
     1336    // Get the path for the current blog/site
     1337    $path = is_main_site()
     1338        ? bp_core_get_site_path()
     1339        : $current_blog->path;
     1340
     1341    // Get the front page variables
     1342    $show_on_front = get_option( 'show_on_front' );
     1343    $page_on_front = get_option( 'page_on_front' );
     1344
     1345    if ( ( 'page' !== $show_on_front ) || empty( $component ) || empty( $bp->pages->{$component} ) || ( $_SERVER['REQUEST_URI'] !== $path ) ) {
    12731346        return false;
    1274 
    1275     foreach ( (array) $bp->active_components as $key => $slug ) {
    1276         if ( $key == $component_name || $slug == $component_name )
    1277             return true;
    1278     }
    1279 
    1280     return false;
    1281 }
    1282 
    1283 /**
    1284  * Check if the specified BuddyPress component directory is set to be the front page.
    1285  *
    1286  * Corresponds to the setting in wp-admin's Settings > Reading screen.
    1287  *
    1288  * @since BuddyPress (1.5.0)
    1289  *
    1290  * @global BuddyPress $bp The one true BuddyPress instance.
    1291  * @global $current_blog WordPress global for the current blog.
    1292  *
    1293  * @param string $component Optional. Name of the component to check for.
    1294  *        Default: current component.
    1295  * @return bool True if the specified component is set to be the site's front
    1296  *         page, otherwise false.
    1297  */
    1298 function bp_is_component_front_page( $component = '' ) {
    1299     global $bp, $current_blog;
    1300 
    1301     if ( !$component && !empty( $bp->current_component ) )
    1302         $component = $bp->current_component;
    1303 
    1304     $path = is_main_site() ? bp_core_get_site_path() : $current_blog->path;
    1305 
    1306     if ( 'page' != get_option( 'show_on_front' ) || !$component || empty( $bp->pages->{$component} ) || $_SERVER['REQUEST_URI'] != $path )
    1307         return false;
    1308 
    1309     return apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == get_option( 'page_on_front' ) ), $component );
     1347    }
     1348
     1349    return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );
    13101350}
    13111351
     
    13221362    $is_blog_page = false;
    13231363
    1324     // Generally, we can just check to see that there's no current component. The one exception
    1325     // is single user home tabs, where $bp->current_component is unset. Thus the addition
    1326     // of the bp_is_user() check.
    1327     if ( !bp_current_component() && !bp_is_user() )
     1364    // Generally, we can just check to see that there's no current component.
     1365    // The one exception is single user home tabs, where $bp->current_component
     1366    // is unset. Thus the addition of the bp_is_user() check.
     1367    if ( ! bp_current_component() && ! bp_is_user() ) {
    13281368        $is_blog_page = true;
    1329 
    1330     return apply_filters( 'bp_is_blog_page', $is_blog_page );
     1369    }
     1370
     1371    return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page );
    13311372}
    13321373
     
    13591400 * @return bool True if the component is active, otherwise false.
    13601401 */
    1361 function bp_is_active( $component ) {
    1362     global $bp;
    1363 
    1364     if ( isset( $bp->active_components[$component] ) || 'core' == $component )
    1365         return true;
    1366 
    1367     return false;
     1402function bp_is_active( $component = '' ) {
     1403    $retval = false;
     1404
     1405    // Default to the current component if none is passed
     1406    if ( empty( $component ) ) {
     1407        $component = bp_current_component();
     1408    }
     1409
     1410    // Is component in either the active or required components arrays
     1411    if ( isset( buddypress()->active_components[ $component ] ) || isset( buddypress()->required_components[ $component ] ) ) {
     1412        $retval = true;
     1413    }
     1414
     1415    return apply_filters( 'bp_is_active', $retval, $component );
    13681416}
    13691417
     
    13741422 */
    13751423function bp_is_members_component() {
    1376     if ( bp_is_current_component( 'members' ) )
    1377         return true;
    1378 
    1379     return false;
     1424    return (bool) bp_is_current_component( 'members' );
    13801425}
    13811426
     
    13861431 */
    13871432function bp_is_profile_component() {
    1388     if ( bp_is_current_component( 'xprofile' ) )
    1389         return true;
    1390 
    1391     return false;
     1433    return (bool) bp_is_current_component( 'xprofile' );
    13921434}
    13931435
     
    13981440 */
    13991441function bp_is_activity_component() {
    1400     if ( bp_is_current_component( 'activity' ) )
    1401         return true;
    1402 
    1403     return false;
     1442    return (bool) bp_is_current_component( 'activity' );
    14041443}
    14051444
     
    14221461 */
    14231462function bp_is_messages_component() {
    1424     if ( bp_is_current_component( 'messages' ) )
    1425         return true;
    1426 
    1427     return false;
     1463    return (bool) bp_is_current_component( 'messages' );
    14281464}
    14291465
     
    14341470 */
    14351471function bp_is_friends_component() {
    1436     if ( bp_is_current_component( 'friends' ) )
    1437         return true;
    1438 
    1439     return false;
     1472    return (bool) bp_is_current_component( 'friends' );
    14401473}
    14411474
     
    14461479 */
    14471480function bp_is_groups_component() {
    1448     if ( bp_is_current_component( 'groups' ) )
    1449         return true;
    1450 
    1451     return false;
     1481    return (bool) bp_is_current_component( 'groups' );
    14521482}
    14531483
     
    14581488 */
    14591489function bp_is_forums_component() {
    1460     if ( bp_is_current_component( 'forums' ) )
    1461         return true;
    1462 
    1463     return false;
     1490    return (bool) bp_is_current_component( 'forums' );
    14641491}
    14651492
     
    14721499 */
    14731500function bp_is_notifications_component() {
    1474     if ( bp_is_current_component( 'notifications' ) ) {
    1475         return true;
    1476     }
    1477 
    1478     return false;
     1501    return (bool) bp_is_current_component( 'notifications' );
    14791502}
    14801503
     
    14851508 */
    14861509function bp_is_settings_component() {
    1487     if ( bp_is_current_component( 'settings' ) )
    1488         return true;
    1489 
    1490     return false;
     1510    return (bool) bp_is_current_component( 'settings' );
    14911511}
    14921512
     
    15271547 */
    15281548function bp_is_activity_directory() {
    1529     if ( ! bp_displayed_user_id() && bp_is_activity_component() && ! bp_current_action() )
     1549    if ( ! bp_displayed_user_id() && bp_is_activity_component() && ! bp_current_action() ) {
    15301550        return true;
     1551    }
    15311552
    15321553    return false;
     
    15391560 */
    15401561function bp_is_single_activity() {
    1541     if ( bp_is_activity_component() && is_numeric( bp_current_action() ) )
     1562    return (bool) ( bp_is_activity_component() && is_numeric( bp_current_action() ) );
     1563}
     1564
     1565/** User **********************************************************************/
     1566
     1567/**
     1568 * Is the current page the members directory ?
     1569 *
     1570 * @since BuddyPress (2.0.0)
     1571 *
     1572 * @return True if the current page is the members directory.
     1573 */
     1574function bp_is_members_directory() {
     1575    if ( ! bp_is_user() && bp_is_members_component() ) {
    15421576        return true;
    1543 
    1544     return false;
    1545 }
    1546 
    1547 /** User **********************************************************************/
    1548 
    1549 /**
    1550  * Is the current page the members directory ?
    1551  *
    1552  * @since BuddyPress (2.0.0)
    1553  *
    1554  * @return True if the current page is the members directory.
    1555  */
    1556 function bp_is_members_directory() {
    1557     if ( ! bp_is_user() && bp_is_members_component() )
    1558         return true;
     1577    }
    15591578
    15601579    return false;
     
    15701589 */
    15711590function bp_is_my_profile() {
    1572     if ( is_user_logged_in() && bp_loggedin_user_id() == bp_displayed_user_id() )
     1591    if ( is_user_logged_in() && bp_loggedin_user_id() == bp_displayed_user_id() ) {
    15731592        $my_profile = true;
    1574     else
     1593    } else {
    15751594        $my_profile = false;
     1595    }
    15761596
    15771597    return apply_filters( 'bp_is_my_profile', $my_profile );
     
    15861606 */
    15871607function bp_is_user() {
    1588     if ( bp_displayed_user_id() )
     1608    return (bool) bp_displayed_user_id();
     1609}
     1610
     1611/**
     1612 * Is the current page a user's activity stream page?
     1613 *
     1614 * Eg http://example.com/members/joe/activity/ (or any subpages thereof).
     1615 *
     1616 * @return True if the current page is a user's activity stream page.
     1617 */
     1618function bp_is_user_activity() {
     1619    return (bool) ( bp_is_user() && bp_is_activity_component() );
     1620}
     1621
     1622/**
     1623 * Is the current page a user's Friends activity stream?
     1624 *
     1625 * Eg http://example.com/members/joe/friends/
     1626 *
     1627 * @return True if the current page is a user's Friends activity stream.
     1628 */
     1629function bp_is_user_friends_activity() {
     1630
     1631    if ( ! bp_is_active( 'friends' ) ) {
     1632        return false;
     1633    }
     1634
     1635    $slug = bp_get_friends_slug();
     1636
     1637    if ( empty( $slug ) ) {
     1638        $slug = 'friends';
     1639    }
     1640
     1641    if ( bp_is_user_activity() && bp_is_current_action( $slug ) ) {
    15891642        return true;
     1643    }
    15901644
    15911645    return false;
     
    15931647
    15941648/**
    1595  * Is the current page a user's activity stream page?
    1596  *
    1597  * Eg http://example.com/members/joe/activity/ (or any subpages thereof).
    1598  *
    1599  * @return True if the current page is a user's activity stream page.
    1600  */
    1601 function bp_is_user_activity() {
    1602     if ( bp_is_user() && bp_is_activity_component() )
     1649 * Is the current page a user's Groups activity stream?
     1650 *
     1651 * Eg http://example.com/members/joe/groups/
     1652 *
     1653 * @return True if the current page is a user's Groups activity stream.
     1654 */
     1655function bp_is_user_groups_activity() {
     1656
     1657    if ( ! bp_is_active( 'groups' ) ) {
     1658        return false;
     1659    }
     1660
     1661    $slug = ( bp_get_groups_slug() )
     1662        ? bp_get_groups_slug()
     1663        : 'groups';
     1664
     1665    if ( bp_is_user_activity() && bp_is_current_action( $slug ) ) {
    16031666        return true;
     1667    }
    16041668
    16051669    return false;
     
    16071671
    16081672/**
    1609  * Is the current page a user's Friends activity stream?
    1610  *
    1611  * Eg http://example.com/members/joe/friends/
    1612  *
    1613  * @return True if the current page is a user's Friends activity stream.
    1614  */
    1615 function bp_is_user_friends_activity() {
    1616 
    1617     if ( !bp_is_active( 'friends' ) )
     1673 * Is the current page part of a user's extended profile?
     1674 *
     1675 * Eg http://example.com/members/joe/profile/ (or a subpage thereof).
     1676 *
     1677 * @return True if the current page is part of a user's extended profile.
     1678 */
     1679function bp_is_user_profile() {
     1680    return (bool) ( bp_is_profile_component() || bp_is_current_component( 'profile' ) );
     1681}
     1682
     1683/**
     1684 * Is the current page part of a user's profile editing section?
     1685 *
     1686 * Eg http://example.com/members/joe/profile/edit/ (or a subpage thereof).
     1687 *
     1688 * @return True if the current page is a user's profile edit page.
     1689 */
     1690function bp_is_user_profile_edit() {
     1691    return (bool) ( bp_is_profile_component() && bp_is_current_action( 'edit' ) );
     1692}
     1693
     1694function bp_is_user_change_avatar() {
     1695    return (bool) ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) );
     1696}
     1697
     1698/**
     1699 * Is this a user's forums page?
     1700 *
     1701 * Eg http://example.com/members/joe/forums/ (or a subpage thereof).
     1702 *
     1703 * @return bool True if the current page is a user's forums page.
     1704 */
     1705function bp_is_user_forums() {
     1706
     1707    if ( ! bp_is_active( 'forums' ) ) {
    16181708        return false;
    1619 
    1620     $slug = bp_get_friends_slug();
    1621 
    1622     if ( empty( $slug ) )
    1623         $slug = 'friends';
    1624 
    1625     if ( bp_is_user_activity() && bp_is_current_action( $slug ) )
     1709    }
     1710
     1711    if ( bp_is_user() && bp_is_forums_component() ) {
    16261712        return true;
     1713    }
    16271714
    16281715    return false;
     
    16301717
    16311718/**
    1632  * Is the current page a user's Groups activity stream?
    1633  *
    1634  * Eg http://example.com/members/joe/groups/
    1635  *
    1636  * @return True if the current page is a user's Groups activity stream.
    1637  */
    1638 function bp_is_user_groups_activity() {
    1639 
    1640     if ( !bp_is_active( 'groups' ) )
    1641         return false;
    1642 
    1643     $slug = bp_get_groups_slug();
    1644 
    1645     if ( empty( $slug ) )
    1646         $slug = 'groups';
    1647 
    1648     if ( bp_is_user_activity() && bp_is_current_action( $slug ) )
     1719 * Is this a user's "Topics Started" page?
     1720 *
     1721 * Eg http://example.com/members/joe/forums/topics/.
     1722 *
     1723 * @since BuddyPress (1.5.0)
     1724 *
     1725 * @return bool True if the current page is a user's Topics Started page.
     1726 */
     1727function bp_is_user_forums_started() {
     1728    return (bool) ( bp_is_user_forums() && bp_is_current_action( 'topics' ) );
     1729}
     1730
     1731/**
     1732 * Is this a user's "Replied To" page?
     1733 *
     1734 * Eg http://example.com/members/joe/forums/replies/.
     1735 *
     1736 * @since BuddyPress (1.5.0)
     1737 *
     1738 * @return bool True if the current page is a user's Replied To forums page.
     1739 */
     1740function bp_is_user_forums_replied_to() {
     1741    return (bool) ( bp_is_user_forums() && bp_is_current_action( 'replies' ) );
     1742}
     1743
     1744/**
     1745 * Is the current page part of a user's Groups page?
     1746 *
     1747 * Eg http://example.com/members/joe/groups/ (or a subpage thereof).
     1748 *
     1749 * @return bool True if the current page is a user's Groups page.
     1750 */
     1751function bp_is_user_groups() {
     1752    return (bool) ( bp_is_user() && bp_is_groups_component() );
     1753}
     1754
     1755/**
     1756 * Is the current page part of a user's Blogs page?
     1757 *
     1758 * Eg http://example.com/members/joe/blogs/ (or a subpage thereof).
     1759 *
     1760 * @return bool True if the current page is a user's Blogs page.
     1761 */
     1762function bp_is_user_blogs() {
     1763    return (bool) ( bp_is_user() && bp_is_blogs_component() );
     1764}
     1765
     1766/**
     1767 * Is the current page a user's Recent Blog Posts page?
     1768 *
     1769 * Eg http://example.com/members/joe/blogs/recent-posts/.
     1770 *
     1771 * @return bool True if the current page is a user's Recent Blog Posts page.
     1772 */
     1773function bp_is_user_recent_posts() {
     1774    return (bool) ( bp_is_user_blogs() && bp_is_current_action( 'recent-posts' ) );
     1775}
     1776
     1777/**
     1778 * Is the current page a user's Recent Blog Comments page?
     1779 *
     1780 * Eg http://example.com/members/joe/blogs/recent-comments/.
     1781 *
     1782 * @return bool True if the current page is a user's Recent Blog Comments page.
     1783 */
     1784function bp_is_user_recent_commments() {
     1785    return (bool) ( bp_is_user_blogs() && bp_is_current_action( 'recent-comments' ) );
     1786}
     1787
     1788/**
     1789 * Is the current page a user's Friends page?
     1790 *
     1791 * Eg http://example.com/members/joe/blogs/friends/ (or a subpage thereof).
     1792 *
     1793 * @return bool True if the current page is a user's Friends page.
     1794 */
     1795function bp_is_user_friends() {
     1796    return (bool) ( bp_is_user() && bp_is_friends_component() );
     1797}
     1798
     1799/**
     1800 * Is the current page a user's Friend Requests page?
     1801 *
     1802 * Eg http://example.com/members/joe/friends/requests/.
     1803 *
     1804 * @return bool True if the current page is a user's Friends Requests page.
     1805 */
     1806function bp_is_user_friend_requests() {
     1807    return (bool) ( bp_is_user_friends() && bp_is_current_action( 'requests' ) );
     1808}
     1809
     1810/**
     1811 * Is this a user's notifications page?
     1812 *
     1813 * Eg http://example.com/members/joe/notifications/ (or a subpage thereof).
     1814 *
     1815 * @since BuddyPress (1.9.0)
     1816 *
     1817 * @return bool True if the current page is a user's Notifications page.
     1818 */
     1819function bp_is_user_notifications() {
     1820    return (bool) ( bp_is_user() && bp_is_notifications_component() );
     1821}
     1822
     1823/**
     1824 * Is this a user's settings page?
     1825 *
     1826 * Eg http://example.com/members/joe/settings/ (or a subpage thereof).
     1827 *
     1828 * @return bool True if the current page is a user's Settings page.
     1829 */
     1830function bp_is_user_settings() {
     1831    return (bool) ( bp_is_user() && bp_is_settings_component() );
     1832}
     1833
     1834/**
     1835 * Is this a user's General Settings page?
     1836 *
     1837 * Eg http://example.com/members/joe/settings/general/.
     1838 *
     1839 * @since BuddyPress (1.5.0)
     1840 *
     1841 * @return bool True if the current page is a user's General Settings page.
     1842 */
     1843function bp_is_user_settings_general() {
     1844    return (bool) ( bp_is_user_settings() && bp_is_current_action( 'general' ) );
     1845}
     1846
     1847/**
     1848 * Is this a user's Notification Settings page?
     1849 *
     1850 * Eg http://example.com/members/joe/settings/notifications/.
     1851 *
     1852 * @since BuddyPress (1.5.0)
     1853 *
     1854 * @return bool True if the current page is a user's Notification Settings page.
     1855 */
     1856function bp_is_user_settings_notifications() {
     1857    return (bool) ( bp_is_user_settings() && bp_is_current_action( 'notifications' ) );
     1858}
     1859
     1860/**
     1861 * Is this a user's Account Deletion page?
     1862 *
     1863 * Eg http://example.com/members/joe/settings/delete-account/.
     1864 *
     1865 * @since BuddyPress (1.5.0)
     1866 *
     1867 * @return bool True if the current page is a user's Delete Account page.
     1868 */
     1869function bp_is_user_settings_account_delete() {
     1870    return (bool) ( bp_is_user_settings() && bp_is_current_action( 'delete-account' ) );
     1871}
     1872
     1873/**
     1874 * Is this a user's profile settings?
     1875 *
     1876 * Eg http://example.com/members/joe/settings/profile/.
     1877 *
     1878 * @since BuddyPress (2.0.0)
     1879 *
     1880 * @return bool True if the current page is a user's Profile Settings page.
     1881 */
     1882function bp_is_user_settings_profile() {
     1883    return (bool) ( bp_is_user_settings() && bp_is_current_action( 'profile' ) );
     1884}
     1885
     1886/** Groups ********************************************************************/
     1887
     1888/**
     1889 * Is the current page the groups directory ?
     1890 *
     1891 * @since BuddyPress (2.0.0)
     1892 *
     1893 * @return True if the current page is the groups directory.
     1894 */
     1895function bp_is_groups_directory() {
     1896    if ( bp_is_groups_component() && ! bp_current_action() && ! bp_current_item() ) {
    16491897        return true;
     1898    }
    16501899
    16511900    return false;
     
    16531902
    16541903/**
    1655  * Is the current page part of a user's extended profile?
    1656  *
    1657  * Eg http://example.com/members/joe/profile/ (or a subpage thereof).
    1658  *
    1659  * @return True if the current page is part of a user's extended profile.
    1660  */
    1661 function bp_is_user_profile() {
    1662     if ( bp_is_profile_component() || bp_is_current_component( 'profile' ) )
    1663         return true;
    1664 
    1665     return false;
    1666 }
    1667 
    1668 /**
    1669  * Is the current page part of a user's profile editing section?
    1670  *
    1671  * Eg http://example.com/members/joe/profile/edit/ (or a subpage thereof).
    1672  *
    1673  * @return True if the current page is a user's profile edit page.
    1674  */
    1675 function bp_is_user_profile_edit() {
    1676     if ( bp_is_profile_component() && bp_is_current_action( 'edit' ) )
    1677         return true;
    1678 
    1679     return false;
    1680 }
    1681 
    1682 function bp_is_user_change_avatar() {
    1683     if ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) )
    1684         return true;
    1685 
    1686     return false;
    1687 }
    1688 
    1689 /**
    1690  * Is this a user's forums page?
    1691  *
    1692  * Eg http://example.com/members/joe/forums/ (or a subpage thereof).
    1693  *
    1694  * @return bool True if the current page is a user's forums page.
    1695  */
    1696 function bp_is_user_forums() {
    1697 
    1698     if ( ! bp_is_active( 'forums' ) )
    1699         return false;
    1700 
    1701     if ( bp_is_user() && bp_is_forums_component() )
    1702         return true;
    1703 
    1704     return false;
    1705 }
    1706 
    1707 /**
    1708  * Is this a user's "Topics Started" page?
    1709  *
    1710  * Eg http://example.com/members/joe/forums/topics/.
    1711  *
    1712  * @since BuddyPress (1.5.0)
    1713  *
    1714  * @return bool True if the current page is a user's Topics Started page.
    1715  */
    1716 function bp_is_user_forums_started() {
    1717     if ( bp_is_user_forums() && bp_is_current_action( 'topics' ) )
    1718         return true;
    1719 
    1720     return false;
    1721 }
    1722 
    1723 /**
    1724  * Is this a user's "Replied To" page?
    1725  *
    1726  * Eg http://example.com/members/joe/forums/replies/.
    1727  *
    1728  * @since BuddyPress (1.5.0)
    1729  *
    1730  * @return bool True if the current page is a user's Replied To forums page.
    1731  */
    1732 function bp_is_user_forums_replied_to() {
    1733     if ( bp_is_user_forums() && bp_is_current_action( 'replies' ) )
    1734         return true;
    1735 
    1736     return false;
    1737 }
    1738 
    1739 /**
    1740  * Is the current page part of a user's Groups page?
    1741  *
    1742  * Eg http://example.com/members/joe/groups/ (or a subpage thereof).
    1743  *
    1744  * @return bool True if the current page is a user's Groups page.
    1745  */
    1746 function bp_is_user_groups() {
    1747     if ( bp_is_user() && bp_is_groups_component() )
    1748         return true;
    1749 
    1750     return false;
    1751 }
    1752 
    1753 /**
    1754  * Is the current page part of a user's Blogs page?
    1755  *
    1756  * Eg http://example.com/members/joe/blogs/ (or a subpage thereof).
    1757  *
    1758  * @return bool True if the current page is a user's Blogs page.
    1759  */
    1760 function bp_is_user_blogs() {
    1761     if ( bp_is_user() && bp_is_blogs_component() )
    1762         return true;
    1763 
    1764     return false;
    1765 }
    1766 
    1767 /**
    1768  * Is the current page a user's Recent Blog Posts page?
    1769  *
    1770  * Eg http://example.com/members/joe/blogs/recent-posts/.
    1771  *
    1772  * @return bool True if the current page is a user's Recent Blog Posts page.
    1773  */
    1774 function bp_is_user_recent_posts() {
    1775     if ( bp_is_user_blogs() && bp_is_current_action( 'recent-posts' ) )
    1776         return true;
    1777 
    1778     return false;
    1779 }
    1780 
    1781 /**
    1782  * Is the current page a user's Recent Blog Comments page?
    1783  *
    1784  * Eg http://example.com/members/joe/blogs/recent-comments/.
    1785  *
    1786  * @return bool True if the current page is a user's Recent Blog Comments page.
    1787  */
    1788 function bp_is_user_recent_commments() {
    1789     if ( bp_is_user_blogs() && bp_is_current_action( 'recent-comments' ) )
    1790         return true;
    1791 
    1792     return false;
    1793 }
    1794 
    1795 /**
    1796  * Is the current page a user's Friends page?
    1797  *
    1798  * Eg http://example.com/members/joe/blogs/friends/ (or a subpage thereof).
    1799  *
    1800  * @return bool True if the current page is a user's Friends page.
    1801  */
    1802 function bp_is_user_friends() {
    1803     if ( bp_is_user() && bp_is_friends_component() )
    1804         return true;
    1805 
    1806     return false;
    1807 }
    1808 
    1809 /**
    1810  * Is the current page a user's Friend Requests page?
    1811  *
    1812  * Eg http://example.com/members/joe/friends/requests/.
    1813  *
    1814  * @return bool True if the current page is a user's Friends Requests page.
    1815  */
    1816 function bp_is_user_friend_requests() {
    1817     if ( bp_is_user_friends() && bp_is_current_action( 'requests' ) )
    1818         return true;
    1819 
    1820     return false;
    1821 }
    1822 
    1823 /**
    1824  * Is this a user's notifications page?
    1825  *
    1826  * Eg http://example.com/members/joe/notifications/ (or a subpage thereof).
    1827  *
    1828  * @since BuddyPress (1.9.0)
    1829  *
    1830  * @return bool True if the current page is a user's Notifications page.
    1831  */
    1832 function bp_is_user_notifications() {
    1833     if ( bp_is_user() && bp_is_notifications_component() ) {
    1834         return true;
    1835     }
    1836 
    1837     return false;
    1838 }
    1839 
    1840 /**
    1841  * Is this a user's settings page?
    1842  *
    1843  * Eg http://example.com/members/joe/settings/ (or a subpage thereof).
    1844  *
    1845  * @return bool True if the current page is a user's Settings page.
    1846  */
    1847 function bp_is_user_settings() {
    1848     if ( bp_is_user() && bp_is_settings_component() )
    1849         return true;
    1850 
    1851     return false;
    1852 }
    1853 
    1854 /**
    1855  * Is this a user's General Settings page?
    1856  *
    1857  * Eg http://example.com/members/joe/settings/general/.
    1858  *
    1859  * @since BuddyPress (1.5.0)
    1860  *
    1861  * @return bool True if the current page is a user's General Settings page.
    1862  */
    1863 function bp_is_user_settings_general() {
    1864     if ( bp_is_user_settings() && bp_is_current_action( 'general' ) )
    1865         return true;
    1866 
    1867     return false;
    1868 }
    1869 
    1870 /**
    1871  * Is this a user's Notification Settings page?
    1872  *
    1873  * Eg http://example.com/members/joe/settings/notifications/.
    1874  *
    1875  * @since BuddyPress (1.5.0)
    1876  *
    1877  * @return bool True if the current page is a user's Notification Settings page.
    1878  */
    1879 function bp_is_user_settings_notifications() {
    1880     if ( bp_is_user_settings() && bp_is_current_action( 'notifications' ) )
    1881         return true;
    1882 
    1883     return false;
    1884 }
    1885 
    1886 /**
    1887  * Is this a user's Account Deletion page?
    1888  *
    1889  * Eg http://example.com/members/joe/settings/delete-account/.
    1890  *
    1891  * @since BuddyPress (1.5.0)
    1892  *
    1893  * @return bool True if the current page is a user's Delete Account page.
    1894  */
    1895 function bp_is_user_settings_account_delete() {
    1896     if ( bp_is_user_settings() && bp_is_current_action( 'delete-account' ) )
    1897         return true;
    1898 
    1899     return false;
    1900 }
    1901 
    1902 /**
    1903  * Is this a user's profile settings?
    1904  *
    1905  * Eg http://example.com/members/joe/settings/profile/.
    1906  *
    1907  * @since BuddyPress (2.0.0)
    1908  *
    1909  * @return bool True if the current page is a user's Profile Settings page.
    1910  */
    1911 function bp_is_user_settings_profile() {
    1912     if ( bp_is_user_settings() && bp_is_current_action( 'profile' ) )
    1913         return true;
    1914 
    1915     return false;
    1916 }
    1917 
    1918 /** Groups ********************************************************************/
    1919 
    1920 /**
    1921  * Is the current page the groups directory ?
    1922  *
    1923  * @since BuddyPress (2.0.0)
    1924  *
    1925  * @return True if the current page is the groups directory.
    1926  */
    1927 function bp_is_groups_directory() {
    1928     if ( bp_is_groups_component() && ! bp_current_action() && ! bp_current_item() )
    1929         return true;
    1930 
    1931     return false;
    1932 }
    1933 
    1934 /**
    19351904 * Does the current page belong to a single group?
    19361905 *
     
    19401909 */
    19411910function bp_is_group() {
    1942     global $bp;
    1943 
    1944     if ( bp_is_groups_component() && isset( $bp->groups->current_group ) && $bp->groups->current_group )
    1945         return true;
    1946 
    1947     return false;
     1911    return (bool) ( bp_is_groups_component() && groups_get_current_group() );
    19481912}
    19491913
     
    19571921 */
    19581922function bp_is_group_home() {
    1959     if ( bp_is_single_item() && bp_is_groups_component() && ( !bp_current_action() || bp_is_current_action( 'home' ) ) )
     1923    if ( bp_is_single_item() && bp_is_groups_component() && ( ! bp_current_action() || bp_is_current_action( 'home' ) ) ) {
    19601924        return true;
     1925    }
    19611926
    19621927    return false;
     
    19691934 */
    19701935function bp_is_group_create() {
    1971     if ( bp_is_groups_component() && bp_is_current_action( 'create' ) )
    1972         return true;
    1973 
    1974     return false;
     1936    return (bool) ( bp_is_groups_component() && bp_is_current_action( 'create' ) );
    19751937}
    19761938
     
    19831945 */
    19841946function bp_is_group_admin_page() {
    1985     if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) )
    1986         return true;
    1987 
    1988     return false;
     1947    return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) );
    19891948}
    19901949
     
    20191978 */
    20201979function bp_is_group_activity() {
    2021     if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) )
     1980    return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) );
     1981}
     1982
     1983/**
     1984 * Is the current page a group forum topic?
     1985 *
     1986 * Only applies to legacy bbPress (1.x) forums.
     1987 *
     1988 * @return bool True if the current page is part of a group forum topic.
     1989 */
     1990function bp_is_group_forum_topic() {
     1991    return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) );
     1992}
     1993
     1994/**
     1995 * Is the current page a group forum topic edit page?
     1996 *
     1997 * Only applies to legacy bbPress (1.x) forums.
     1998 *
     1999 * @return bool True if the current page is part of a group forum topic edit page.
     2000 */
     2001function bp_is_group_forum_topic_edit() {
     2002    return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_is_action_variable( 'edit', 2 ) );
     2003}
     2004
     2005/**
     2006 * Is the current page a group's Members page?
     2007 *
     2008 * Eg http://example.com/groups/mygroup/members/.
     2009 *
     2010 * @return bool True if the current page is part of a group's Members page.
     2011 */
     2012function bp_is_group_members() {
     2013    return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) );
     2014}
     2015
     2016/**
     2017 * Is the current page a group's Invites page?
     2018 *
     2019 * Eg http://example.com/groups/mygroup/send-invites/.
     2020 *
     2021 * @return bool True if the current page is a group's Send Invites page.
     2022 */
     2023function bp_is_group_invites() {
     2024    return (bool) ( bp_is_groups_component() && bp_is_current_action( 'send-invites' ) );
     2025}
     2026
     2027/**
     2028 * Is the current page a group's Request Membership page?
     2029 *
     2030 * Eg http://example.com/groups/mygroup/request-membership/.
     2031 *
     2032 * @return bool True if the current page is a group's Request Membership page.
     2033 */
     2034function bp_is_group_membership_request() {
     2035    return (bool) ( bp_is_groups_component() && bp_is_current_action( 'request-membership' ) );
     2036}
     2037
     2038/**
     2039 * Is the current page a leave group attempt?
     2040 *
     2041 * @return bool True if the current page is a Leave Group attempt.
     2042 */
     2043function bp_is_group_leave() {
     2044    return (bool) ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) );
     2045}
     2046
     2047/**
     2048 * Is the current page part of a single group?
     2049 *
     2050 * Not currently used by BuddyPress.
     2051 *
     2052 * @todo How is this functionally different from bp_is_group()?
     2053 *
     2054 * @return bool True if the current page is part of a single group.
     2055 */
     2056function bp_is_group_single() {
     2057    return (bool) ( bp_is_groups_component() && bp_is_single_item() );
     2058}
     2059
     2060/**
     2061 * Is the current page the Create a Blog page?
     2062 *
     2063 * Eg http://example.com/sites/create/.
     2064 *
     2065 * @return bool True if the current page is the Create a Blog page.
     2066 */
     2067function bp_is_create_blog() {
     2068    return (bool) ( bp_is_blogs_component() && bp_is_current_action( 'create' ) );
     2069}
     2070
     2071/**
     2072 * Is the current page the blogs directory ?
     2073 *
     2074 * @since BuddyPress (2.0.0)
     2075 *
     2076 * @return True if the current page is the blogs directory.
     2077 */
     2078function bp_is_blogs_directory() {
     2079    if ( is_multisite() && bp_is_blogs_component() && ! bp_current_action() ) {
    20222080        return true;
     2081    }
    20232082
    20242083    return false;
    20252084}
    20262085
    2027 /**
    2028  * Is the current page a group forum topic?
    2029  *
    2030  * Only applies to legacy bbPress (1.x) forums.
    2031  *
    2032  * @return bool True if the current page is part of a group forum topic.
    2033  */
    2034 function bp_is_group_forum_topic() {
    2035     if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) )
     2086/** Messages ******************************************************************/
     2087
     2088/**
     2089 * Is the current page part of a user's Messages pages?
     2090 *
     2091 * Eg http://example.com/members/joe/messages/ (or a subpage thereof).
     2092 *
     2093 * @return bool True if the current page is part of a user's Messages pages.
     2094 */
     2095function bp_is_user_messages() {
     2096    return (bool) ( bp_is_user() && bp_is_messages_component() );
     2097}
     2098
     2099/**
     2100 * Is the current page a user's Messages Inbox?
     2101 *
     2102 * Eg http://example.com/members/joe/messages/inbox/.
     2103 *
     2104 * @return bool True if the current page is a user's Messages Inbox.
     2105 */
     2106function bp_is_messages_inbox() {
     2107    if ( bp_is_user_messages() && ( ! bp_current_action() || bp_is_current_action( 'inbox' ) ) ) {
    20362108        return true;
     2109    }
    20372110
    20382111    return false;
     
    20402113
    20412114/**
    2042  * Is the current page a group forum topic edit page?
    2043  *
    2044  * Only applies to legacy bbPress (1.x) forums.
    2045  *
    2046  * @return bool True if the current page is part of a group forum topic edit page.
    2047  */
    2048 function bp_is_group_forum_topic_edit() {
    2049     if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_is_action_variable( 'edit', 2 ) )
    2050         return true;
    2051 
    2052     return false;
    2053 }
    2054 
    2055 /**
    2056  * Is the current page a group's Members page?
    2057  *
    2058  * Eg http://example.com/groups/mygroup/members/.
    2059  *
    2060  * @return bool True if the current page is part of a group's Members page.
    2061  */
    2062 function bp_is_group_members() {
    2063     if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) )
    2064         return true;
    2065 
    2066     return false;
    2067 }
    2068 
    2069 /**
    2070  * Is the current page a group's Invites page?
    2071  *
    2072  * Eg http://example.com/groups/mygroup/send-invites/.
    2073  *
    2074  * @return bool True if the current page is a group's Send Invites page.
    2075  */
    2076 function bp_is_group_invites() {
    2077     if ( bp_is_groups_component() && bp_is_current_action( 'send-invites' ) )
    2078         return true;
    2079 
    2080     return false;
    2081 }
    2082 
    2083 /**
    2084  * Is the current page a group's Request Membership page?
    2085  *
    2086  * Eg http://example.com/groups/mygroup/request-membership/.
    2087  *
    2088  * @return bool True if the current page is a group's Request Membership page.
    2089  */
    2090 function bp_is_group_membership_request() {
    2091     if ( bp_is_groups_component() && bp_is_current_action( 'request-membership' ) )
    2092         return true;
    2093 
    2094     return false;
    2095 }
    2096 
    2097 /**
    2098  * Is the current page a leave group attempt?
    2099  *
    2100  * @return bool True if the current page is a Leave Group attempt.
    2101  */
    2102 function bp_is_group_leave() {
    2103 
    2104     if ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) )
    2105         return true;
    2106 
    2107     return false;
    2108 }
    2109 
    2110 /**
    2111  * Is the current page part of a single group?
    2112  *
     2115 * Is the current page a user's Messages Sentbox?
     2116 *
     2117 * Eg http://example.com/members/joe/messages/sentbox/.
     2118 *
     2119 * @return bool True if the current page is a user's Messages Sentbox.
     2120 */
     2121function bp_is_messages_sentbox() {
     2122    return (bool) ( bp_is_user_messages() && bp_is_current_action( 'sentbox' ) );
     2123}
     2124
     2125/**
     2126 * Is the current page a user's Messages Compose screen??
     2127 *
     2128 * Eg http://example.com/members/joe/messages/compose/.
     2129 *
     2130 * @return bool True if the current page is a user's Messages Compose screen.
     2131 */
     2132function bp_is_messages_compose_screen() {
     2133    return (bool) ( bp_is_user_messages() && bp_is_current_action( 'compose' ) );
     2134}
     2135
     2136/**
     2137 * Is the current page the Notices screen?
     2138 *
     2139 * Eg http://example.com/members/joe/messages/notices/.
     2140 *
     2141 * @return bool True if the current page is the Notices screen.
     2142 */
     2143function bp_is_notices() {
     2144    return (bool) ( bp_is_user_messages() && bp_is_current_action( 'notices' ) );
     2145}
     2146
     2147/**
     2148 * Is the current page a single Messages conversation thread?
     2149 *
     2150 * @return bool True if the current page a single Messages conversation thread?
     2151 */
     2152function bp_is_messages_conversation() {
     2153    return (bool) ( bp_is_user_messages() && ( bp_is_current_action( 'view' ) ) );
     2154}
     2155
     2156/**
    21132157 * Not currently used by BuddyPress.
    21142158 *
    2115  * @todo How is this functionally different from bp_is_group()?
    2116  *
    2117  * @return bool True if the current page is part of a single group.
    2118  */
    2119 function bp_is_group_single() {
    2120     if ( bp_is_groups_component() && bp_is_single_item() )
    2121         return true;
    2122 
    2123     return false;
    2124 }
    2125 
    2126 /**
    2127  * Is the current page the Create a Blog page?
    2128  *
    2129  * Eg http://example.com/sites/create/.
    2130  *
    2131  * @return bool True if the current page is the Create a Blog page.
    2132  */
    2133 function bp_is_create_blog() {
    2134     if ( bp_is_blogs_component() && bp_is_current_action( 'create' ) )
    2135         return true;
    2136 
    2137     return false;
    2138 }
    2139 
    2140 /**
    2141  * Is the current page the blogs directory ?
    2142  *
    2143  * @since BuddyPress (2.0.0)
    2144  *
    2145  * @return True if the current page is the blogs directory.
    2146  */
    2147 function bp_is_blogs_directory() {
    2148     if ( is_multisite() && bp_is_blogs_component() && ! bp_current_action() )
    2149         return true;
    2150 
    2151     return false;
    2152 }
    2153 
    2154 /** Messages ******************************************************************/
    2155 
    2156 /**
    2157  * Is the current page part of a user's Messages pages?
    2158  *
    2159  * Eg http://example.com/members/joe/messages/ (or a subpage thereof).
    2160  *
    2161  * @return bool True if the current page is part of a user's Messages pages.
    2162  */
    2163 function bp_is_user_messages() {
    2164     if ( bp_is_user() && bp_is_messages_component() )
    2165         return true;
    2166 
    2167     return false;
    2168 }
    2169 
    2170 /**
    2171  * Is the current page a user's Messages Inbox?
    2172  *
    2173  * Eg http://example.com/members/joe/messages/inbox/.
    2174  *
    2175  * @return bool True if the current page is a user's Messages Inbox.
    2176  */
    2177 function bp_is_messages_inbox() {
    2178     if ( bp_is_user_messages() && ( !bp_current_action() || bp_is_current_action( 'inbox' ) ) )
    2179         return true;
    2180 
    2181     return false;
    2182 }
    2183 
    2184 /**
    2185  * Is the current page a user's Messages Sentbox?
    2186  *
    2187  * Eg http://example.com/members/joe/messages/sentbox/.
    2188  *
    2189  * @return bool True if the current page is a user's Messages Sentbox.
    2190  */
    2191 function bp_is_messages_sentbox() {
    2192     if ( bp_is_user_messages() && bp_is_current_action( 'sentbox' ) )
    2193         return true;
    2194 
    2195     return false;
    2196 }
    2197 
    2198 /**
    2199  * Is the current page a user's Messages Compose screen??
    2200  *
    2201  * Eg http://example.com/members/joe/messages/compose/.
    2202  *
    2203  * @return bool True if the current page is a user's Messages Compose screen.
    2204  */
    2205 function bp_is_messages_compose_screen() {
    2206     if ( bp_is_user_messages() && bp_is_current_action( 'compose' ) )
    2207         return true;
    2208 
    2209     return false;
    2210 }
    2211 
    2212 /**
    2213  * Is the current page the Notices screen?
    2214  *
    2215  * Eg http://example.com/members/joe/messages/notices/.
    2216  *
    2217  * @return bool True if the current page is the Notices screen.
    2218  */
    2219 function bp_is_notices() {
    2220     if ( bp_is_user_messages() && bp_is_current_action( 'notices' ) )
    2221         return true;
    2222 
    2223     return false;
    2224 }
    2225 
    2226 /**
    2227  * Is the current page a single Messages conversation thread?
    2228  *
    2229  * @return bool True if the current page a single Messages conversation thread?
    2230  */
    2231 function bp_is_messages_conversation() {
    2232     if ( bp_is_user_messages() && ( bp_is_current_action( 'view' ) ) )
    2233         return true;
    2234 
    2235     return false;
    2236 }
    2237 
    2238 /**
    2239  * Not currently used by BuddyPress.
    2240  *
    22412159 * @return bool
    22422160 */
    22432161function bp_is_single( $component, $callback ) {
    2244     if ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) )
    2245         return true;
    2246 
    2247     return false;
     2162    return (bool) ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) );
    22482163}
    22492164
     
    22582173 */
    22592174function bp_is_activation_page() {
    2260     if ( bp_is_current_component( 'activate' ) )
    2261         return true;
    2262 
    2263     return false;
     2175    return (bool) bp_is_current_component( 'activate' );
    22642176}
    22652177
     
    22722184 */
    22732185function bp_is_register_page() {
    2274     if ( bp_is_current_component( 'register' ) )
    2275         return true;
    2276 
    2277     return false;
     2186    return (bool) bp_is_current_component( 'register' );
    22782187}
    22792188
     
    22962205        /** Pages *************************************************************/
    22972206
    2298         if ( is_front_page() )
     2207        if ( is_front_page() ) {
    22992208            $bp_classes[] = 'home-page';
    2300 
    2301         if ( bp_is_directory() )
     2209        }
     2210
     2211        if ( bp_is_directory() ) {
    23022212            $bp_classes[] = 'directory';
    2303 
    2304         if ( bp_is_single_item() )
     2213        }
     2214
     2215        if ( bp_is_single_item() ) {
    23052216            $bp_classes[] = 'single-item';
     2217        }
    23062218
    23072219        /** Components ********************************************************/
    23082220
    2309         if ( !bp_is_blog_page() ) :
    2310             if ( bp_is_user_profile() )
     2221        if ( ! bp_is_blog_page() ) {
     2222            if ( bp_is_user_profile() )  {
    23112223                $bp_classes[] = 'xprofile';
    2312 
    2313             if ( bp_is_activity_component() )
     2224            }
     2225
     2226            if ( bp_is_activity_component() ) {
    23142227                $bp_classes[] = 'activity';
    2315 
    2316             if ( bp_is_blogs_component() )
     2228            }
     2229
     2230            if ( bp_is_blogs_component() ) {
    23172231                $bp_classes[] = 'blogs';
    2318 
    2319             if ( bp_is_messages_component() )
     2232            }
     2233
     2234            if ( bp_is_messages_component() ) {
    23202235                $bp_classes[] = 'messages';
    2321 
    2322             if ( bp_is_friends_component() )
     2236            }
     2237
     2238            if ( bp_is_friends_component() ) {
    23232239                $bp_classes[] = 'friends';
    2324 
    2325             if ( bp_is_groups_component() )
     2240            }
     2241
     2242            if ( bp_is_groups_component() ) {
    23262243                $bp_classes[] = 'groups';
    2327 
    2328             if ( bp_is_settings_component()  )
     2244            }
     2245
     2246            if ( bp_is_settings_component()  ) {
    23292247                $bp_classes[] = 'settings';
    2330         endif;
     2248            }
     2249        }
    23312250
    23322251        /** User **************************************************************/
    23332252
    2334         if ( bp_is_user() )
     2253        if ( bp_is_user() ) {
    23352254            $bp_classes[] = 'bp-user';
    2336 
    2337         if ( !bp_is_directory() ) :
    2338             if ( bp_is_user_blogs() )
     2255        }
     2256
     2257        if ( ! bp_is_directory() ) {
     2258            if ( bp_is_user_blogs() ) {
    23392259                $bp_classes[] = 'my-blogs';
    2340 
    2341             if ( bp_is_user_groups() )
     2260            }
     2261
     2262            if ( bp_is_user_groups() ) {
    23422263                $bp_classes[] = 'my-groups';
    2343 
    2344             if ( bp_is_user_activity() )
     2264            }
     2265
     2266            if ( bp_is_user_activity() ) {
    23452267                $bp_classes[] = 'my-activity';
    2346         endif;
    2347 
    2348         if ( bp_is_my_profile() )
     2268            }
     2269        }
     2270
     2271        if ( bp_is_my_profile() ) {
    23492272            $bp_classes[] = 'my-account';
    2350 
    2351         if ( bp_is_user_profile() )
     2273        }
     2274
     2275        if ( bp_is_user_profile() ) {
    23522276            $bp_classes[] = 'my-profile';
    2353 
    2354         if ( bp_is_user_friends() )
     2277        }
     2278
     2279        if ( bp_is_user_friends() ) {
    23552280            $bp_classes[] = 'my-friends';
    2356 
    2357         if ( bp_is_user_messages() )
     2281        }
     2282
     2283        if ( bp_is_user_messages() ) {
    23582284            $bp_classes[] = 'my-messages';
    2359 
    2360         if ( bp_is_user_recent_commments() )
     2285        }
     2286
     2287        if ( bp_is_user_recent_commments() ) {
    23612288            $bp_classes[] = 'recent-comments';
    2362 
    2363         if ( bp_is_user_recent_posts() )
     2289        }
     2290
     2291        if ( bp_is_user_recent_posts() ) {
    23642292            $bp_classes[] = 'recent-posts';
    2365 
    2366         if ( bp_is_user_change_avatar() )
     2293        }
     2294
     2295        if ( bp_is_user_change_avatar() ) {
    23672296            $bp_classes[] = 'change-avatar';
    2368 
    2369         if ( bp_is_user_profile_edit() )
     2297        }
     2298
     2299        if ( bp_is_user_profile_edit() ) {
    23702300            $bp_classes[] = 'profile-edit';
    2371 
    2372         if ( bp_is_user_friends_activity() )
     2301        }
     2302
     2303        if ( bp_is_user_friends_activity() ) {
    23732304            $bp_classes[] = 'friends-activity';
    2374 
    2375         if ( bp_is_user_groups_activity() )
     2305        }
     2306
     2307        if ( bp_is_user_groups_activity() ) {
    23762308            $bp_classes[] = 'groups-activity';
     2309        }
    23772310
    23782311        /** Messages **********************************************************/
    23792312
    2380         if ( bp_is_messages_inbox() )
     2313        if ( bp_is_messages_inbox() ) {
    23812314            $bp_classes[] = 'inbox';
    2382 
    2383         if ( bp_is_messages_sentbox() )
     2315        }
     2316
     2317        if ( bp_is_messages_sentbox() ) {
    23842318            $bp_classes[] = 'sentbox';
    2385 
    2386         if ( bp_is_messages_compose_screen() )
     2319        }
     2320
     2321        if ( bp_is_messages_compose_screen() ) {
    23872322            $bp_classes[] = 'compose';
    2388 
    2389         if ( bp_is_notices() )
     2323        }
     2324
     2325        if ( bp_is_notices() ) {
    23902326            $bp_classes[] = 'notices';
    2391 
    2392         if ( bp_is_user_friend_requests() )
     2327        }
     2328
     2329        if ( bp_is_user_friend_requests() ) {
    23932330            $bp_classes[] = 'friend-requests';
    2394 
    2395         if ( bp_is_create_blog() )
     2331        }
     2332
     2333        if ( bp_is_create_blog() ) {
    23962334            $bp_classes[] = 'create-blog';
     2335        }
    23972336
    23982337        /** Groups ************************************************************/
    23992338
    2400         if ( bp_is_group_leave() )
     2339        if ( bp_is_group_leave() ) {
    24012340            $bp_classes[] = 'leave-group';
    2402 
    2403         if ( bp_is_group_invites() )
     2341        }
     2342
     2343        if ( bp_is_group_invites() ) {
    24042344            $bp_classes[] = 'group-invites';
    2405 
    2406         if ( bp_is_group_members() )
     2345        }
     2346
     2347        if ( bp_is_group_members() ) {
    24072348            $bp_classes[] = 'group-members';
    2408 
    2409         if ( bp_is_group_forum_topic() )
     2349        }
     2350
     2351        if ( bp_is_group_forum_topic() ) {
    24102352            $bp_classes[] = 'group-forum-topic';
    2411 
    2412         if ( bp_is_group_forum_topic_edit() )
     2353        }
     2354
     2355        if ( bp_is_group_forum_topic_edit() ) {
    24132356            $bp_classes[] = 'group-forum-topic-edit';
    2414 
    2415         if ( bp_is_group_forum() )
     2357        }
     2358
     2359        if ( bp_is_group_forum() ) {
    24162360            $bp_classes[] = 'group-forum';
     2361        }
    24172362
    24182363        if ( bp_is_group_admin_page() ) {
     
    24262371        }
    24272372
    2428         if ( bp_is_group_home() )
     2373        if ( bp_is_group_home() ) {
    24292374            $bp_classes[] = 'group-home';
    2430 
    2431         if ( bp_is_single_activity() )
     2375        }
     2376
     2377        if ( bp_is_single_activity() ) {
    24322378            $bp_classes[] = 'activity-permalink';
     2379        }
    24332380
    24342381        /** Registration ******************************************************/
    24352382
    2436         if ( bp_is_register_page() )
     2383        if ( bp_is_register_page() ) {
    24372384            $bp_classes[] = 'registration';
    2438 
    2439         if ( bp_is_activation_page() )
     2385        }
     2386
     2387        if ( bp_is_activation_page() ) {
    24402388            $bp_classes[] = 'activation';
     2389        }
    24412390
    24422391        /** Current Component & Action ****************************************/
    24432392
    2444         if ( !bp_is_blog_page() ) {
     2393        if ( ! bp_is_blog_page() ) {
    24452394            $bp_classes[] = bp_current_component();
    24462395            $bp_classes[] = bp_current_action();
     
    25372486 */
    25382487function _bp_nav_menu_sort( $a, $b ) {
    2539     if ( $a["position"] == $b["position"] )
     2488    if ( $a['position'] == $b['position'] ) {
    25402489        return 0;
    2541 
    2542     else if ( $a["position"] < $b["position"] )
     2490    } elseif ( $a['position'] < $b['position'] ) {
    25432491        return -1;
    2544 
    2545     else
     2492    } else {
    25462493        return 1;
     2494    }
    25472495}
    25482496
     
    25612509
    25622510        // The root menu's ID is "xprofile", but the Profile submenus are using "profile". See BP_Core::setup_nav().
    2563         if ( 'profile' == $parent_menu )
     2511        if ( 'profile' === $parent_menu ) {
    25642512            $parent_menu = 'xprofile';
     2513        }
    25652514
    25662515        // Sort the items in this menu's navigation by their position property
     
    25722521
    25732522            // Skip items we don't have access to
    2574             if ( ! $sub_nav['user_has_access'] )
     2523            if ( empty( $sub_nav['user_has_access'] ) ) {
    25752524                continue;
     2525            }
    25762526
    25772527            // Add this menu
     
    26012551
    26022552        // Skip items marked as user-specific if you're not on your own profile
    2603         if ( ! $nav['show_for_displayed_user'] && ! bp_core_can_edit_settings()  )
     2553        if ( empty( $nav['show_for_displayed_user'] ) && ! bp_core_can_edit_settings()  ) {
    26042554            continue;
     2555        }
    26052556
    26062557        // Get the correct menu link. See http://buddypress.trac.wordpress.org/ticket/4624
     
    26162567
    26172568        // Check if we need to mark this menu as selected
    2618         if ( in_array( $nav['css_id'], $selected_menus ) )
     2569        if ( in_array( $nav['css_id'], $selected_menus ) ) {
    26192570            $menu->class[] = 'current-menu-parent';
     2571        }
    26202572
    26212573        $menus[] = $menu;
     
    26882640
    26892641    // Create custom walker if one wasn't set
    2690     if ( empty( $args->walker ) )
     2642    if ( empty( $args->walker ) ) {
    26912643        $args->walker = new BP_Walker_Nav_Menu;
     2644    }
    26922645
    26932646    // Sanitise values for class and ID
     
    27222675        // If a specific ID wasn't requested, and there are multiple menus on the same screen, make sure the autogenerated ID is unique
    27232676        while ( in_array( $wrap_id, $menu_id_slugs ) ) {
    2724             if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) )
     2677            if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) {
    27252678                $wrap_id = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $wrap_id );
    2726             else
     2679            } else {
    27272680                $wrap_id = $wrap_id . '-1';
     2681            }
    27282682        }
    27292683    }
     
    27392693
    27402694    // If we've wrapped the ul, close it
    2741     if ( $show_container )
     2695    if ( ! empty( $show_container ) ) {
    27422696        $nav_menu .= '</' . $args->container . '>';
     2697    }
    27432698
    27442699    // Final chance to modify output
    27452700    $nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args );
    27462701
    2747     if ( $args->echo )
     2702    if ( ! empty( $args->echo ) ) {
    27482703        echo $nav_menu;
    2749     else
     2704    } else {
    27502705        return $nav_menu;
    2751 }
     2706    }
     2707}
Note: See TracChangeset for help on using the changeset viewer.