Skip to:
Content

BuddyPress.org

Changeset 5072


Ignore:
Timestamp:
08/31/2011 01:12:04 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Audit _is_ functions and _current_component_ functions. Props r-a-y. Fixes #3399.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-actions.php

    r4961 r5072  
    242242        global $bp, $wp_query;
    243243
    244         if ( !bp_is_current_component( 'activity' ) || !bp_is_current_action( 'feed' ) || bp_is_user() || !empty( $bp->groups->current_group ) )
     244        if ( !bp_is_activity_component() || !bp_is_current_action( 'feed' ) || bp_is_user() || !empty( $bp->groups->current_group ) )
    245245                return false;
    246246
     
    256256        global $bp, $wp_query;
    257257
    258         if ( !bp_is_current_component( 'activity' ) || !bp_is_user() || !bp_is_current_action( 'feed' ) )
     258        if ( !bp_is_user_activity() || !bp_is_current_action( 'feed' ) )
    259259                return false;
    260260
     
    270270        global $bp, $wp_query;
    271271
    272         if ( !bp_is_active( 'friends' ) || !bp_is_current_component( 'activity' ) || !bp_is_user() || !bp_is_current_action( bp_get_friends_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
     272        if ( !bp_is_active( 'friends' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_friends_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
    273273                return false;
    274274
     
    284284        global $bp, $wp_query;
    285285
    286         if ( !bp_is_active( 'groups' ) || !bp_is_current_component( 'activity' ) || !bp_is_user() || !bp_is_current_action( bp_get_groups_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
     286        if ( !bp_is_active( 'groups' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_groups_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
    287287                return false;
    288288
     
    298298        global $bp, $wp_query;
    299299
    300         if ( !bp_is_current_component( 'activity' ) || !bp_is_user() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
     300        if ( !bp_is_user_activity() || !bp_is_current_action( 'mentions' ) || !bp_is_action_variable( 'feed', 0 ) )
    301301                return false;
    302302
     
    312312        global $bp, $wp_query;
    313313
    314         if ( !bp_is_current_component( 'activity' ) || !bp_is_user() || !bp_is_current_action( 'favorites' ) || !bp_is_action_variable( 'feed', 0 ) )
     314        if ( !bp_is_user_activity() || !bp_is_current_action( 'favorites' ) || !bp_is_action_variable( 'feed', 0 ) )
    315315                return false;
    316316
  • trunk/bp-core/bp-core-template.php

    r5071 r5072  
    587587function bp_action_variable( $position = 0 ) {
    588588        $action_variables = bp_action_variables();
    589 
    590         $action_variable = isset( $action_variables[$position] ) ? $action_variables[$position] : false;
     589        $action_variable  = isset( $action_variables[$position] ) ? $action_variables[$position] : false;
    591590
    592591        return apply_filters( 'bp_action_variable', $action_variable, $position );
     
    654653
    655654                        // Component has specific root slug
    656                         if ( !empty( $bp->{$component_name}->root_slug ) )
     655                        if ( !empty( $bp->{$component_name}->root_slug ) ) {
    657656                                $root_slug = $bp->{$component_name}->root_slug;
     657                        }
    658658                }
    659659
     
    718718         */
    719719        function bp_get_search_slug() {
    720                 global $bp;
    721 
    722720                return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
    723721        }
     
    967965 */
    968966function bp_is_blog_page() {
    969         global $bp, $wp_query;
     967        global $wp_query;
    970968
    971969        $is_blog_page = false;
     
    981979
    982980function bp_is_page( $page ) {
    983         global $bp;
    984 
    985981        if ( !bp_is_user() && bp_is_current_component( $page )  )
    986982                return true;
     
    1003999}
    10041000
     1001function bp_is_members_component() {
     1002        if ( bp_is_current_component( 'members' ) )
     1003                return true;
     1004
     1005        return false;
     1006}
     1007
    10051008function bp_is_profile_component() {
    10061009        if ( bp_is_current_component( 'xprofile' ) )
     
    10321035
    10331036function bp_is_friends_component() {
    1034 
    10351037        if ( bp_is_current_component( 'friends' ) )
    10361038                return true;
     
    10651067        global $bp;
    10661068
    1067         if ( bp_is_current_component( 'activity' ) && is_numeric( $bp->current_action ) )
     1069        if ( bp_is_activity_component() && is_numeric( $bp->current_action ) )
    10681070                return true;
    10691071
     
    10941096
    10951097function bp_is_user_activity() {
    1096         global $bp;
    1097 
    1098         if ( bp_is_current_component( 'activity' ) )
     1098        if ( bp_is_user() && bp_is_activity_component() )
    10991099                return true;
    11001100
     
    11031103
    11041104function bp_is_user_friends_activity() {
    1105         global $bp;
    11061105
    11071106        if ( !bp_is_active( 'friends' ) )
    11081107                return false;
    11091108
    1110         if ( bp_is_activity_component() && bp_is_current_action( bp_get_friends_slug() ) )
     1109        $slug = bp_get_friends_slug();
     1110
     1111        if ( empty( $slug ) )
     1112                $slug = 'friends';
     1113
     1114        if ( bp_is_user_activity() && bp_is_current_action( $slug ) )
    11111115                return true;
    11121116
     
    11151119
    11161120function bp_is_user_groups_activity() {
    1117         global $bp;
    11181121
    11191122        if ( !bp_is_active( 'groups' ) )
    11201123                return false;
    11211124
    1122         if ( bp_is_activity_component() && bp_is_current_action( bp_get_groups_slug() ) )
     1125        $slug = bp_get_groups_slug();
     1126
     1127        if ( empty( $slug ) )
     1128                $slug = 'groups';
     1129
     1130        if ( bp_is_user_activity() && bp_is_current_action( $slug ) )
    11231131                return true;
    11241132
     
    11271135
    11281136function bp_is_user_profile() {
    1129         global $bp;
    1130 
    11311137        if ( bp_is_profile_component() || bp_is_current_component( 'profile' ) )
    11321138                return true;
     
    11361142
    11371143function bp_is_user_profile_edit() {
    1138         global $bp;
    1139 
    11401144        if ( bp_is_profile_component() && bp_is_current_action( 'edit' ) )
    11411145                return true;
     
    11451149
    11461150function bp_is_user_change_avatar() {
    1147         global $bp;
    1148 
    1149         if ( bp_is_current_component( 'xprofile' ) && bp_is_current_action( 'change-avatar' ) )
     1151        if ( bp_is_profile_component() && bp_is_current_action( 'change-avatar' ) )
    11501152                return true;
    11511153
     
    11611163 */
    11621164function bp_is_user_forums() {
    1163         if ( bp_is_current_component( 'forums' ) )
     1165        if ( bp_is_user() && bp_is_forums_component() )
    11641166                return true;
    11651167
     
    11761178 */
    11771179function bp_is_user_forums_started() {
    1178         if ( bp_is_current_component( 'forums' ) && bp_is_current_action( 'topics' ) )
     1180        if ( bp_is_user_forums && bp_is_current_action( 'topics' ) )
    11791181                return true;
    11801182
     
    11911193 */
    11921194function bp_is_user_forums_replied_to() {
    1193         if ( bp_is_current_component( 'forums' ) && bp_is_current_action( 'replies' ) )
     1195        if ( bp_is_user_forums && bp_is_current_action( 'replies' ) )
    11941196                return true;
    11951197
     
    11981200
    11991201function bp_is_user_groups() {
    1200         global $bp;
    1201 
    1202         if ( bp_is_current_component( 'groups' ) )
     1202        if ( bp_is_user() && bp_is_groups_component() )
    12031203                return true;
    12041204
     
    12071207
    12081208function bp_is_user_blogs() {
    1209         global $bp;
    1210 
    1211         if ( is_multisite() && bp_is_current_component( 'blogs' ) )
     1209        if ( bp_is_user() && bp_is_blogs_component() )
    12121210                return true;
    12131211
     
    12161214
    12171215function bp_is_user_recent_posts() {
    1218         global $bp;
    1219 
    1220         if ( is_multisite() && bp_is_current_component( 'blogs' ) && bp_is_current_action( 'recent-posts' ) )
     1216        if ( bp_is_user_blogs() && bp_is_current_action( 'recent-posts' ) )
    12211217                return true;
    12221218
     
    12251221
    12261222function bp_is_user_recent_commments() {
    1227         global $bp;
    1228 
    1229         if ( is_multisite() && bp_is_current_component( 'blogs' ) && bp_is_current_action( 'recent-comments' ) )
     1223        if ( bp_is_user_blogs() && bp_is_current_action( 'recent-comments' ) )
    12301224                return true;
    12311225
     
    12341228
    12351229function bp_is_user_friends() {
    1236 
    1237         if ( bp_is_current_component( 'friends' ) )
     1230        if ( bp_is_user() && bp_is_friends_component() )
    12381231                return true;
    12391232
     
    12421235
    12431236function bp_is_user_friend_requests() {
    1244         global $bp;
    1245 
    1246         if ( bp_is_current_component( 'friends' ) && bp_is_current_action( 'requests' ) )
     1237        if ( bp_is_user_friends() && bp_is_current_action( 'requests' ) )
    12471238                return true;
    12481239
     
    12621253
    12631254function bp_is_group_home() {
    1264         global $bp;
    1265 
    12661255        if ( bp_is_single_item() && bp_is_groups_component() && ( !bp_current_action() || bp_is_current_action( 'home' ) ) )
    12671256                return true;
     
    12711260
    12721261function bp_is_group_create() {
    1273         global $bp;
    1274 
    12751262        if ( bp_is_groups_component() && bp_is_current_action( 'create' ) )
    12761263                return true;
     
    12801267
    12811268function bp_is_group_admin_page() {
    1282         global $bp;
    1283 
    12841269        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'admin' ) )
    12851270                return true;
     
    12891274
    12901275function bp_is_group_forum() {
    1291         global $bp;
    1292 
    12931276        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'forum' ) )
    12941277                return true;
     
    12981281
    12991282function bp_is_group_activity() {
    1300         global $bp;
    1301 
    13021283        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) )
    13031284                return true;
     
    13141295
    13151296function bp_is_group_forum_topic_edit() {
    1316         global $bp;
    1317 
    13181297        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 ) )
    13191298                return true;
     
    13231302
    13241303function bp_is_group_members() {
    1325         global $bp;
    1326 
    13271304        if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) )
    13281305                return true;
     
    13321309
    13331310function bp_is_group_invites() {
    1334         global $bp;
    1335 
    13361311        if ( bp_is_groups_component() && bp_is_current_action( 'send-invites' ) )
    13371312                return true;
     
    13411316
    13421317function bp_is_group_membership_request() {
    1343         global $bp;
    1344 
    13451318        if ( bp_is_groups_component() && bp_is_current_action( 'request-membership' ) )
    13461319                return true;
     
    13501323
    13511324function bp_is_group_leave() {
    1352         global $bp;
    13531325
    13541326        if ( bp_is_groups_component() && bp_is_single_item() && bp_is_current_action( 'leave-group' ) )
     
    13591331
    13601332function bp_is_group_single() {
    1361         global $bp;
    1362 
    13631333        if ( bp_is_groups_component() && bp_is_single_item() )
    13641334                return true;
     
    13681338
    13691339function bp_is_create_blog() {
    1370         global $bp;
    1371 
    1372         if ( is_multisite() && bp_is_current_component( 'blogs' ) && bp_is_current_action( 'create' ) )
     1340        if ( bp_is_blogs_component() && bp_is_current_action( 'create' ) )
    13731341                return true;
    13741342
     
    13791347
    13801348function bp_is_user_messages() {
    1381 
    1382         if ( bp_is_current_component( 'messages' ) )
     1349        if ( bp_is_user() && bp_is_messages_component() )
    13831350                return true;
    13841351
     
    13871354
    13881355function bp_is_messages_inbox() {
    1389         global $bp;
    1390 
    1391         if ( bp_is_current_component( 'messages' ) && ( !bp_current_action() || bp_is_current_action( 'inbox' ) ) )
     1356        if ( bp_is_user_messages() && ( !bp_current_action() || bp_is_current_action( 'inbox' ) ) )
    13921357                return true;
    13931358
     
    13961361
    13971362function bp_is_messages_sentbox() {
    1398         global $bp;
    1399 
    1400         if ( bp_is_current_component( 'messages' ) && bp_is_current_action( 'sentbox' ) )
     1363        if ( bp_is_user_messages() && bp_is_current_action( 'sentbox' ) )
    14011364                return true;
    14021365
     
    14051368
    14061369function bp_is_messages_compose_screen() {
    1407         global $bp;
    1408 
    1409         if ( bp_is_current_component( 'messages' ) && bp_is_current_action( 'compose' ) )
     1370        if ( bp_is_user_messages() && bp_is_current_action( 'compose' ) )
    14101371                return true;
    14111372
     
    14141375
    14151376function bp_is_notices() {
    1416         global $bp;
    1417 
    1418         if ( bp_is_current_component( 'messages' ) && bp_is_current_action( 'notices' ) )
     1377        if ( bp_is_user_messages() && bp_is_current_action( 'notices' ) )
    14191378                return true;
    14201379
     
    14241383
    14251384function bp_is_single( $component, $callback ) {
    1426         global $bp;
    1427 
    14281385        if ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) )
    14291386                return true;
     
    14621419}
    14631420        function bp_get_the_body_class( $wp_classes, $custom_classes = false ) {
    1464                 global $bp;
    14651421
    14661422                $bp_classes = array();
     
    16191575                // We don't want WordPress blog classes to appear on non-blog pages.
    16201576                if ( !bp_is_blog_page() ) {
     1577
    16211578                        // Preserve any custom classes already set
    1622                         if ( !empty( $custom_classes ) )
     1579                        if ( !empty( $custom_classes ) ) {
    16231580                                $wp_classes = (array) $custom_classes;
    1624                         else
     1581                        } else {
    16251582                                $wp_classes = array();
     1583                        }
    16261584                }
    16271585
     
    16341592                return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
    16351593        }
    1636 add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 )
     1594        add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );
     1595
    16371596?>
  • trunk/bp-forums/bp-forums-template.php

    r5047 r5072  
    10571057        extract( $r, EXTR_SKIP );
    10581058
    1059         if ( empty( $topic_id ) && bp_is_current_component( 'groups') && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_action_variable( 1 ) )
     1059        if ( empty( $topic_id ) && bp_is_groups_component() && bp_is_current_action( 'forum' ) && bp_is_action_variable( 'topic', 0 ) && bp_action_variable( 1 ) )
    10601060                $topic_id = bp_forums_get_topic_id_from_slug( bp_action_variable( 1 ) );
    1061         elseif ( empty( $topic_id ) && bp_is_current_component( 'forums') && bp_is_current_action( 'topic' ) && bp_action_variable( 0 ) )
     1061        elseif ( empty( $topic_id ) && bp_is_forums_component() && bp_is_current_action( 'topic' ) && bp_action_variable( 0 ) )
    10621062                $topic_id = bp_forums_get_topic_id_from_slug( bp_action_variable( 0 ) );
    10631063
  • trunk/bp-members/bp-members-screens.php

    r4961 r5072  
    3535 */
    3636function bp_members_screen_index() {
    37         if ( !bp_is_user() && bp_is_current_component( 'members' ) ) {
     37        if ( !bp_is_user() && bp_is_members_component() ) {
    3838                bp_update_is_directory( true, 'members' );
    3939
  • trunk/bp-messages/bp-messages-template.php

    r4955 r5072  
    723723        extract( $r, EXTR_SKIP );
    724724
    725         if ( !$thread_id && bp_is_current_component( 'messages' ) && bp_is_current_action( 'view' ) )
     725        if ( !$thread_id && bp_is_messages_component() && bp_is_current_action( 'view' ) )
    726726                $thread_id = (int)bp_action_variable( 0 );
    727727
  • trunk/bp-themes/bp-default/sidebar.php

    r5001 r5072  
    6060
    6161        <?php /* Show forum tags on the forums directory */
    62         if ( bp_is_active( 'forums' ) && bp_is_current_component( 'forums' ) && bp_is_directory() ) : ?>
     62        if ( bp_is_active( 'forums' ) && bp_is_forums_component() && bp_is_directory() ) : ?>
    6363                <div id="forum-directory-tags" class="widget tags">
    6464                        <h3 class="widgettitle"><?php _e( 'Forum Topic Tags', 'buddypress' ) ?></h3>
  • trunk/bp-xprofile/bp-xprofile-actions.php

    r4961 r5072  
    2424        global $bp;
    2525
    26         if ( !bp_is_current_component( 'profile' ) || !bp_is_current_action( 'change-avatar' ) || !bp_is_action_variable( 'delete-avatar', 0 ) )
     26        if ( !bp_is_user_change_avatar() || !bp_is_action_variable( 'delete-avatar', 0 ) )
    2727                return false;
    2828
Note: See TracChangeset for help on using the changeset viewer.