Skip to:
Content

BuddyPress.org

Ticket #2600: 2600-3.patch

File 2600-3.patch, 36.5 KB (added by boonebgorges, 13 years ago)
  • bp-activity.php

     
    66function bp_activity_setup_globals() {
    77        global $bp, $current_blog;
    88
    9         if ( !defined( 'BP_ACTIVITY_SLUG' ) )
    10                 define ( 'BP_ACTIVITY_SLUG', $bp->pages->activity->slug );
     9        // Define a slug, if necessary
     10        if ( !defined( 'BP_ACTIVITY_SLUG' ) ) {
     11                define( 'BP_ACTIVITY_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->activity->slug ) );
     12        }
    1113
    1214        // For internal identification
    1315        $bp->activity->id = 'activity';
    1416        $bp->activity->name = $bp->pages->activity->name;
    1517        $bp->activity->slug = BP_ACTIVITY_SLUG;
     18        $bp->activity->root_slug = $bp->pages->activity->slug;
    1619
    1720        $bp->activity->table_name      = $bp->table_prefix . 'bp_activity';
    1821        $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
  • bp-core/bp-core-templatetags.php

     
    16951695function bp_is_groups_component() {
    16961696        global $bp;
    16971697
    1698         if ( BP_GROUPS_SLUG == $bp->current_component )
     1698        if ( bp_core_is_current_component( 'groups' ) )
    16991699                return true;
    17001700
    17011701        return false;
     
    17851785function bp_is_group() {
    17861786        global $bp;
    17871787
    1788         if ( BP_GROUPS_SLUG == $bp->current_component && isset( $bp->groups->current_group ) && $bp->groups->current_group )
     1788        if ( bp_core_is_current_component( 'groups' ) && isset( $bp->groups->current_group ) && $bp->groups->current_group )
    17891789                return true;
    17901790
    17911791        return false;
     
    17941794function bp_is_group_home() {
    17951795        global $bp;
    17961796
    1797         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
     1797        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
    17981798                return true;
    17991799
    18001800        return false;
     
    18031803function bp_is_group_create() {
    18041804        global $bp;
    18051805
    1806         if ( BP_GROUPS_SLUG == $bp->current_component && 'create' == $bp->current_action )
     1806        if ( bp_core_is_current_component( 'groups' ) && 'create' == $bp->current_action )
    18071807                return true;
    18081808
    18091809        return false;
     
    18131813function bp_is_group_admin_page() {
    18141814        global $bp;
    18151815
    1816         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'admin' == $bp->current_action )
     1816        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'admin' == $bp->current_action )
    18171817                return true;
    18181818
    18191819        return false;
     
    18221822function bp_is_group_forum() {
    18231823        global $bp;
    18241824
    1825         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action )
     1825        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action )
    18261826                return true;
    18271827
    18281828        return false;
     
    18311831function bp_is_group_activity() {
    18321832        global $bp;
    18331833
    1834         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'activity' == $bp->current_action )
     1834        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'activity' == $bp->current_action )
    18351835                return true;
    18361836
    18371837        return false;
     
    18401840function bp_is_group_forum_topic() {
    18411841        global $bp;
    18421842
    1843         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )
     1843        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )
    18441844                return true;
    18451845
    18461846        return false;
     
    18491849function bp_is_group_forum_topic_edit() {
    18501850        global $bp;
    18511851
    1852         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] )
     1852        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] )
    18531853                return true;
    18541854
    18551855        return false;
     
    18581858function bp_is_group_members() {
    18591859        global $bp;
    18601860
    1861         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'members' == $bp->current_action )
     1861        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'members' == $bp->current_action )
    18621862                return true;
    18631863
    18641864        return false;
     
    18671867function bp_is_group_invites() {
    18681868        global $bp;
    18691869
    1870         if ( BP_GROUPS_SLUG == $bp->current_component && 'send-invites' == $bp->current_action )
     1870        if ( bp_core_is_current_component( 'groups' ) && 'send-invites' == $bp->current_action )
    18711871                return true;
    18721872
    18731873        return false;
     
    18761876function bp_is_group_membership_request() {
    18771877        global $bp;
    18781878
    1879         if ( BP_GROUPS_SLUG == $bp->current_component && 'request-membership' == $bp->current_action )
     1879        if ( bp_core_is_current_component( 'groups' ) && 'request-membership' == $bp->current_action )
    18801880                return true;
    18811881
    18821882        return false;
     
    18851885function bp_is_group_leave() {
    18861886        global $bp;
    18871887
    1888         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'leave-group' == $bp->current_action )
     1888        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'leave-group' == $bp->current_action )
    18891889                return true;
    18901890
    18911891        return false;
     
    18941894function bp_is_group_single() {
    18951895        global $bp;
    18961896
    1897         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item )
     1897        if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item )
    18981898                return true;
    18991899
    19001900        return false;
  • bp-blogs.php

     
    99function bp_blogs_setup_globals() {
    1010        global $bp, $wpdb;
    1111
    12         if ( !defined( 'BP_BLOGS_SLUG' ) )
    13                 define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );
     12        // Define a slug, if necessary
     13        if ( !defined( 'BP_BLOGS_SLUG' ) ) {
     14                define( 'BP_BLOGS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->blogs->slug ) );
     15        }
    1416
    1517        // For internal identification
    1618        $bp->blogs->id = 'blogs';
    1719
    1820        $bp->blogs->slug = BP_BLOGS_SLUG;
     21        $bp->blogs->root_slug = $bp->pages->blogs->slug;
    1922
    2023        $bp->blogs->table_name          = $bp->table_prefix . 'bp_user_blogs';
    2124        $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta';
  • bp-forums.php

     
    1919function bp_forums_setup() {
    2020        global $bp;
    2121       
    22         if ( !defined( 'BP_FORUMS_SLUG' ) )
    23                 define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );
     22        // Define a slug, if necessary
     23        if ( !defined( 'BP_FORUMS_SLUG' ) ) {
     24                define( 'BP_FORUMS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->forums->slug ) );
     25        }
    2426
    2527        // For internal identification
    2628        $bp->forums->id = 'forums';
    2729
    2830        $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
    2931        $bp->forums->slug = BP_FORUMS_SLUG;
     32        $bp->forums->root_slug = $bp->pages->forums->slug;
    3033
    3134        if ( isset( $bp->site_options['bb-config-location'] ) )
    3235                $bp->forums->bbconfig = $bp->site_options['bb-config-location'];
  • bp-groups.php

     
    1313function groups_setup_globals() {
    1414        global $bp;
    1515
    16         if ( !defined( 'BP_GROUPS_SLUG' ) )
    17                 define ( 'BP_GROUPS_SLUG', $bp->pages->groups->slug );
    18 
     16       // Define a slug, if necessary
     17       if ( !defined( 'BP_GROUPS_SLUG' ) ) {
     18                define( 'BP_GROUPS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->groups->slug ) );
     19        }
     20       
    1921        /* For internal identification */
    2022        $bp->groups->id = 'groups';
    2123        $bp->groups->name = $bp->pages->groups->name;
    2224        $bp->groups->slug = BP_GROUPS_SLUG;
     25        $bp->groups->root_slug = $bp->pages->groups->slug;
    2326
    2427        $bp->groups->table_name           = $bp->table_prefix . 'bp_groups';
    2528        $bp->groups->table_name_members   = $bp->table_prefix . 'bp_groups_members';
     
    5659function groups_setup_nav() {
    5760        global $bp;
    5861
    59         if ( $bp->current_component == $bp->groups->slug && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
     62        if ( bp_core_is_current_component( 'groups' ) && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
    6063
    6164                /* This is a single group page. */
    6265                $bp->is_single_item = true;
     
    8083        }
    8184
    8285        /* Add 'Groups' to the main navigation */
    83         bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->name, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
     86        bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
    8487
    85         $groups_link = $bp->loggedin_user->domain . $bp->groups->name . '/';
     88        $groups_link = $bp->loggedin_user->domain . $bp->groups->root_slug . '/';
    8689
    8790        /* Add the subnav items to the groups nav item */
    88         bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
    89         bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
     91        bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
     92        bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
    9093
    91         if ( $bp->current_component == $bp->groups->slug ) {
     94        if ( bp_core_is_current_component( 'groups' ) ) {
    9295
    9396                if ( bp_is_my_profile() && !$bp->is_single_item ) {
    9497
     
    114117                        if ( !$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) )
    115118                                $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
    116119
    117                         $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
     120                        $group_link = $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $bp->groups->current_group->slug . '/';
    118121
    119122                        // If this is a private or hidden group, does the user have access?
    120123                        if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
     
    127130                        }
    128131
    129132                        /* Reset the existing subnav items */
    130                         bp_core_reset_subnav_items($bp->groups->slug);
     133                        bp_core_reset_subnav_items($bp->groups->root_slug);
    131134
    132135                        /* Add a new default subnav item for when the groups nav is selected. */
    133                         bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
     136                        bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
    134137
    135138                        /* Add the "Home" subnav item, as this will always be present */
    136                         bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) );
     139                        bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) );
    137140
    138141                        /* If the user is a group mod or more, then show the group admin nav item */
    139142                        if ( $bp->is_item_mod || $bp->is_item_admin )
    140                                 bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) );
     143                                bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) );
    141144
    142145                        // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
    143146                        if ( !is_super_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' )
    144                                 bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );
     147                                bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );
    145148
    146149                        if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') )
    147                                 bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) );
     150                                bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) );
    148151
    149                         bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members'  ) );
     152                        bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members'  ) );
    150153
    151154                        if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    152155                                if ( bp_is_active('friends') )
    153                                         bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
     156                                        bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );
    154157                        }
    155158                }
    156159        }
     
    165168function groups_directory_groups_setup() {
    166169        global $bp;
    167170
    168         if ( $bp->current_component == $bp->groups->slug && empty( $bp->current_action ) && empty( $bp->current_item ) ) {
     171        if ( bp_core_is_current_component( 'groups' ) && empty( $bp->current_action ) && empty( $bp->current_item ) ) {
    169172                $bp->is_directory = true;
    170173
    171174                do_action( 'groups_directory_groups_setup' );
     
    598601function groups_screen_group_activity_permalink() {
    599602        global $bp;
    600603
    601         if ( $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )
     604        if ( !bp_core_is_current_component( 'groups' ) || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )
    602605                return false;
    603606
    604607        $bp->is_single_item = true;
     
    609612
    610613function groups_screen_group_admin() {
    611614        global $bp;
    612 
    613         if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
     615       
     616        if ( !bp_core_is_current_component( 'groups' ) || 'admin' != $bp->current_action )
    614617                return false;
    615618
    616619        if ( !empty( $bp->action_variables[0] ) )
     
    622625function groups_screen_group_admin_edit_details() {
    623626        global $bp;
    624627
    625         if ( $bp->current_component == $bp->groups->slug && 'edit-details' == $bp->action_variables[0] ) {
     628        if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'edit-details' == $bp->action_variables[0] ) {
    626629
    627630                if ( $bp->is_item_admin || $bp->is_item_mod  ) {
    628631
     
    654657function groups_screen_group_admin_settings() {
    655658        global $bp;
    656659
    657         if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) {
     660        if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'group-settings' == $bp->action_variables[0] ) {
    658661
    659662                if ( !$bp->is_item_admin )
    660663                        return false;
     
    691694function groups_screen_group_admin_avatar() {
    692695        global $bp;
    693696
    694         if ( $bp->current_component == $bp->groups->slug && 'group-avatar' == $bp->action_variables[0] ) {
     697        if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'group-avatar' == $bp->action_variables[0] ) {
    695698
    696699                if ( !$bp->is_item_admin )
    697700                        return false;
     
    749752function groups_screen_group_admin_manage_members() {
    750753        global $bp;
    751754
    752         if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) {
     755        if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'manage-members' == $bp->action_variables[0] ) {
    753756
    754757                if ( !$bp->is_item_admin )
    755758                        return false;
     
    855858function groups_screen_group_admin_requests() {
    856859        global $bp;
    857860
    858         if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
     861        if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'membership-requests' == $bp->action_variables[0] ) {
    859862
    860863                /* Ask for a login if the user is coming here via an email notification */
    861864                if ( !is_user_logged_in() )
     
    913916function groups_screen_group_admin_delete_group() {
    914917        global $bp;
    915918
    916         if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
     919        if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'delete-group' == $bp->action_variables[0] ) {
    917920
    918921                if ( !$bp->is_item_admin && !is_super_admin() )
    919922                        return false;
     
    10211024        global $bp;
    10221025
    10231026        /* If we're not at domain.org/groups/create/ then return false */
    1024         if ( $bp->current_component != $bp->groups->slug || 'create' != $bp->current_action )
     1027        if ( !bp_core_is_current_component( 'groups' ) || 'create' != $bp->current_action )
    10251028                return false;
    10261029
    10271030        if ( !is_user_logged_in() )
     
    10401043                setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
    10411044
    10421045                $reset_steps = true;
    1043                 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
     1046                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
    10441047        }
    10451048
    10461049        /* If this is a creation step that is not recognized, just redirect them back to the first screen */
    10471050        if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
    10481051                bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
    1049                 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/' );
     1052                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/' );
    10501053        }
    10511054
    10521055        /* Fetch the currently completed steps variable */
     
    10681071                if ( 'group-details' == $bp->groups->current_create_step ) {
    10691072                        if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) {
    10701073                                bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
    1071                                 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
     1074                                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
    10721075                        }
    10731076
    10741077                        $new_group_id = isset( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : 0;
    10751078
    10761079                        if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => bp_core_current_time(), 'status' => 'public' ) ) ) {
    10771080                                bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
    1078                                 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
     1081                                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
    10791082                        }
    10801083
    10811084                        groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 );
     
    11021105
    11031106                        if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_forum' => $group_enable_forum ) ) ) {
    11041107                                bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
    1105                                 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
     1108                                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
    11061109                        }
    11071110                }
    11081111
     
    11581161                                }
    11591162                        }
    11601163
    1161                         bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $next_step . '/' );
     1164                        bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $next_step . '/' );
    11621165                }
    11631166        }
    11641167
     
    11941197function groups_action_join_group() {
    11951198        global $bp;
    11961199
    1197         if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' )
     1200        if ( !$bp->is_single_item || !bp_core_is_current_component( 'groups' ) || $bp->current_action != 'join' )
    11981201                return false;
    11991202
    12001203        // Nonce check
     
    12291232function groups_action_leave_group() {
    12301233        global $bp;
    12311234
    1232         if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'leave-group' )
     1235        if ( !$bp->is_single_item || !bp_core_is_current_component( 'groups' ) || $bp->current_action != 'leave-group' )
    12331236                return false;
    12341237
    12351238        // Nonce check
     
    12541257function groups_action_sort_creation_steps() {
    12551258        global $bp;
    12561259
    1257         if ( $bp->current_component != BP_GROUPS_SLUG && $bp->current_action != 'create' )
     1260        if ( !bp_core_is_current_component( 'groups' ) && $bp->current_action != 'create' )
    12581261                return false;
    12591262
    12601263        if ( !is_array( $bp->groups->group_creation_steps ) )
     
    12781281function groups_action_redirect_to_random_group() {
    12791282        global $bp, $wpdb;
    12801283
    1281         if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) {
     1284        if ( bp_core_is_current_component( 'groups' ) && isset( $_GET['random-group'] ) ) {
    12821285                $group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) );
    12831286
    1284                 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/' . $group['groups'][0]->slug . '/' );
     1287                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $group['groups'][0]->slug . '/' );
    12851288        }
    12861289}
    12871290add_action( 'wp', 'groups_action_redirect_to_random_group', 6 );
     
    12891292function groups_action_group_feed() {
    12901293        global $bp, $wp_query;
    12911294
    1292         if ( !bp_is_active( 'activity' ) || $bp->current_component != $bp->groups->slug || !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' )
     1295        if ( !bp_is_active( 'activity' ) || !bp_core_is_current_component( 'groups' ) || !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' )
    12931296                return false;
    12941297
    12951298        $wp_query->is_404 = false;
  • bp-core.php

     
    8383        // Set up the members id and active components entry
    8484        $bp->members->id = 'members';
    8585
    86         $bp->members->slug = $bp->pages->members->slug;
     86        // Define a slug, if necessary
     87        if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
     88                define( 'BP_MEMBERS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->members->slug ) );
     89        }
     90
     91        $bp->members->slug = BP_MEMBERS_SLUG;
     92        $bp->members->root_slug = $bp->pages->members->slug;
    8793        $bp->active_components[$bp->members->slug] = $bp->members->id;
    8894
    8995        // The user ID of the user who is currently logged in.
     
    201207function bp_core_define_slugs() {
    202208        global $bp;
    203209
    204         if ( !defined( 'BP_MEMBERS_SLUG' ) )
    205                 define( 'BP_MEMBERS_SLUG', $bp->pages->members->slug );
    206 
    207210        if ( !defined( 'BP_REGISTER_SLUG' ) )
    208211                define( 'BP_REGISTER_SLUG', $bp->pages->register->slug );
    209212
     
    285288}
    286289
    287290/**
     291 * Creates a default component slug from a WP page root_slug
     292 *
     293 * Since 1.3, BP components get their root_slug (the slug used immediately following the root
     294 * domain) from the slug of a corresponding WP page. E.g. if your BP installation at example.com
     295 * has its members page at example.com/community/people, $bp->members->root_slug will be
     296 * 'community/people'. By default, this function creates a shorter version of the root_slug for
     297 * use elsewhere in the URL, by returning the content after the final '/' in the root_slug
     298 * ('people' in the example above).
     299 *
     300 * Filter on 'bp_core_component_slug_from_root_slug' to override this method in general, or define a
     301 * specific component slug constant (e.g. BP_MEMBERS_SLUG) to override specific component slugs.
     302 *
     303 * @package BuddyPress Core
     304 * @since 1.3
     305 *
     306 * @param str $root_slug The root slug, which comes from $bp->pages->[component]->slug
     307 * @return str $slug The short slug for use in the middle of URLs
     308 */
     309function bp_core_component_slug_from_root_slug( $root_slug ) {
     310        $slug_chunks = explode( '/', $root_slug );
     311        $slug = array_pop( $slug_chunks );
     312       
     313        return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug );
     314}
     315
     316
     317/**
    288318 * bp_core_admin_menu_init()
    289319 *
    290320 * Initializes the wp-admin area "BuddyPress" menus and sub menus.
     
    351381        return false;
    352382}
    353383
     384
    354385/**
     386 * Checks to see whether the current page belongs to the specified component
     387 *
     388 * This function is designed to be generous, accepting several different kinds of value for
     389 * the $component_name parameter. It checks $component_name against:
     390 *      - the component's root_slug, which matches the page slug in $bp->pages
     391 *      - the component's regular slug
     392 *      - the component's id, or 'canonical' name
     393 *
     394 * @package BuddyPress Core
     395 * @since 1.3
     396 * @return true if root component, else false.
     397 */
     398function bp_core_is_current_component( $component_name ) {
     399        global $bp;
     400       
     401        $is_current_component = false;
     402
     403        if ( !empty( $bp->current_component ) ) {
     404                foreach ( $bp->active_components as $key => $id ) {
     405                        if ( !empty( $bp->{$id}->root_slug ) && $bp->{$id}->root_slug == $component_name ) {
     406                                // First, check to see whether $component_name matches the root_slug
     407                                // This covers the case where the component name immediately follows
     408                                // the root domain, as 'members' in example.com/members/boonebgorges
     409                                // or 'groups' in example.com/groups/my-cool-group. Note: Only
     410                                // components that have corresponding WP pages will have root_slug
     411
     412                                $is_current_component = true;
     413                                break;
     414                        } else if ( $bp->{$id}->slug == $component_name ) {
     415                                // Then, check to see whether $component_name matches the regular
     416                                // component slug. This accounts for instances when the component
     417                                // name appears further down the URL, as on profile tabs: e.g.
     418                                // 'friends' in example.com/members/boonebgorges/friends
     419
     420                                $is_current_component = true;
     421                                break;
     422                        } else if ( $bp->{$id}->id == $component_name ) {
     423                                // Finally, check to see whether $component_name matches the
     424                                // unique, non-translatable component id
     425                               
     426                                $is_current_component = true;
     427                                break;
     428                        }
     429                }
     430        }
     431       
     432        return apply_filters( 'bp_core_is_current_component', $is_current_component, $component_name );
     433}
     434
     435/**
    355436 * bp_core_setup_nav()
    356437 *
    357438 * Sets up the profile navigation item if the Xprofile component is not installed.
     
    865946                'screen_function' => &$screen_function
    866947        );
    867948
    868         if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
     949        if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) { 
    869950                if ( !is_object( $screen_function[0] ) )
    870951                        add_action( 'wp', $screen_function, 3 );
    871952                else
  • bp-groups/bp-groups-templatetags.php

     
    148148                $user_id = $bp->displayed_user->id;
    149149
    150150        /* Type */
    151         if ( 'my-groups' == $bp->current_action ) {
     151        if ( 'my-groups' == $bp->current_action && !empty( $order ) ) {
    152152                if ( 'most-popular' == $order ) {
    153153                        $type = 'popular';
    154154                } elseif ( 'alphabetically' == $order ) {
     
    350350                if ( !$group )
    351351                        $group =& $groups_template->group;
    352352
    353                 return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/' );
     353                return apply_filters( 'bp_get_group_permalink', $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $group->slug . '/' );
    354354        }
    355355
    356356function bp_group_admin_permalink() {
     
    362362                if ( !$group )
    363363                        $group =& $groups_template->group;
    364364
    365                 return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' );
     365                return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $group->slug . '/admin' );
    366366        }
    367367
    368368function bp_group_slug() {
     
    547547function bp_group_is_activity_permalink() {
    548548        global $bp;
    549549
    550         if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug )
     550        if ( !$bp->is_single_item || $bp->current_component != $bp->groups->root_slug || $bp->current_action != $bp->activity->slug )
    551551                return false;
    552552
    553553        return true;
     
    929929        $current_tab = $bp->action_variables[0];
    930930?>
    931931        <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?>
    932                 <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
     932                <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
    933933        <?php } ?>
    934934
    935935        <?php
    936936                if ( !$bp->is_item_admin )
    937937                        return false;
    938938        ?>
    939         <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li>
    940         <li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li>
    941         <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li>
     939        <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/group-settings"><?php _e('Group Settings', 'buddypress') ?></a></li>
     940        <li<?php if ( 'group-avatar' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/group-avatar"><?php _e('Group Avatar', 'buddypress') ?></a></li>
     941        <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/manage-members"><?php _e('Manage Members', 'buddypress') ?></a></li>
    942942
    943943        <?php if ( $groups_template->group->status == 'private' ) : ?>
    944                 <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
     944                <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
    945945        <?php endif; ?>
    946946
    947947        <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
    948948
    949         <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
     949        <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
    950950<?php
    951951}
    952952
     
    19291929function bp_is_group_admin_screen( $slug ) {
    19301930        global $bp;
    19311931
    1932         if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
     1932        if ( !bp_core_is_current_component( 'groups' ) || 'admin' != $bp->current_action )
    19331933                return false;
    19341934
    19351935        if ( $bp->action_variables[0] == $slug )