Skip to:
Content

BuddyPress.org

Ticket #2600: 2600-4.patch

File 2600-4.patch, 50.7 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';
     
    3740
    3841        $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain;
    3942        $user_login = ( isset( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
    40         $activity_link = $user_domain . $bp->activity->name . '/';
     43        $activity_link = $user_domain . $bp->activity->slug . '/';
    4144
    4245        /* Add the subnav items to the activity nav item if we are using a theme that supports this */
    4346        bp_core_new_subnav_item( array( 'name' => __( 'Personal', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) );
    4447
    4548        if ( bp_is_active( 'friends' ) )
    46                 bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );
     49                bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );
    4750
    4851        if ( bp_is_active( 'groups' ) )
    49                 bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
     52                bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
    5053
    5154        bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );
    5255        bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) );
     
    5962                        $bp->bp_options_title = $bp->displayed_user->fullname;
    6063                }
    6164        }
    62 
     65       
    6366        do_action( 'bp_activity_setup_nav' );
    6467}
    6568add_action( 'bp_setup_nav', 'bp_activity_setup_nav' );
  • bp-themes/bp-default/groups/index.php

     
    44                <div class="padder">
    55
    66                <form action="" method="post" id="groups-directory-form" class="dir-form">
    7                         <h3><?php _e( 'Groups Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> &nbsp;<a class="button" href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG . '/create/' ?>"><?php _e( 'Create a Group', 'buddypress' ) ?></a><?php endif; ?></h3>
     7                        <h3><?php _e( 'Groups Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> &nbsp;<a class="button" href="<?php echo bp_get_root_domain() . '/' . bp_get_root_slug() . '/create/' ?>"><?php _e( 'Create a Group', 'buddypress' ) ?></a><?php endif; ?></h3>
    88
    99                        <?php do_action( 'bp_before_directory_groups_content' ) ?>
    1010
  • bp-core/bp-core-templatetags.php

     
    162162        }
    163163
    164164        // Make sure we return no members if we looking at friendship requests and there are none.
    165         if ( empty( $include ) && $bp->friends->slug == $bp->current_component && 'requests' == $bp->current_action )
     165        if ( empty( $include ) && bp_core_is_current_component( $bp->friends->slug ) && 'requests' == $bp->current_action )
    166166                return false;
    167167
    168168        $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras, $exclude );
     
    582582 */
    583583function bp_get_options_nav() {
    584584        global $bp;
    585 
    586         if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 )
     585       
     586        // If we are looking at a member profile, then the we can use the current component as an
     587        // index. Otherwise we need to use the component's root_slug
     588        $component_index = !empty( $bp->displayed_user ) ? $bp->current_component : bp_get_root_slug( $bp->current_component );
     589       
     590        if ( count( $bp->bp_options_nav[$component_index] ) < 1 )
    587591                return false;
    588592
    589593        /* Loop through each navigation item */
    590         foreach ( (array)$bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
     594        foreach ( (array)$bp->bp_options_nav[$component_index] as $subnav_item ) {
    591595                if ( !$subnav_item['user_has_access'] )
    592596                        continue;
    593597
     
    15561560                return apply_filters( 'bp_get_root_domain', $bp->root_domain );
    15571561        }
    15581562
     1563/**
     1564 * Echoes the output of bp_get_root_slug()
     1565 *
     1566 * @package BuddyPress Core
     1567 * @since 1.3
     1568 */
     1569function bp_root_slug() {
     1570        echo bp_get_root_slug();
     1571}
     1572        /**
     1573         * Gets the root slug for a component slug
     1574         *
     1575         * In order to maintain backward compatibility, the following procedure is used:
     1576         * 1) Use the short slug to get the canonical component name from the
     1577         *    active component array
     1578         * 2) Use the component name to get the root slug out of the appropriate part of the $bp
     1579         *    global
     1580         * 3) If nothing turns up, it probably means that $component is itself a root slug
     1581         *
     1582         * Example: If your groups directory is at /community/companies, this function first uses
     1583         * the short slug 'companies' (ie the current component) to look up the canonical name
     1584         * 'groups' in $bp->active_components. Then it uses 'groups' to get the root slug, from
     1585         * $bp->groups->root_slug.
     1586         *
     1587         * @package BuddyPress Core
     1588         * @since 1.3
     1589         *
     1590         * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     1591         * @param string $component Optional. Defaults to the current component
     1592         * @return string $root_slug The root slug
     1593         */
     1594        function bp_get_root_slug( $component = false ) {
     1595                global $bp;
     1596               
     1597                $root_slug = '';
     1598               
     1599                if ( !$component ) {
     1600                        $component = $bp->current_component;
     1601                }
     1602               
     1603                if ( !empty( $bp->active_components[$component] ) ) {
     1604                        $component_name = $bp->active_components[$component];
     1605                       
     1606                        if ( !empty( $bp->{$component_name}->root_slug ) )
     1607                                $root_slug = $bp->{$component_name}->root_slug;
     1608                }
     1609               
     1610                if ( empty( $root_slug ) )
     1611                        $root_slug = $component;
     1612                       
     1613                return apply_filters( 'bp_get_root_slug', $root_slug );
     1614        }
     1615
    15591616/* Template is_() functions to determine the current page */
    15601617
    15611618/**
     
    16621719function bp_is_profile_component() {
    16631720        global $bp;
    16641721
    1665         if ( BP_XPROFILE_SLUG == $bp->current_component )
     1722        if ( bp_core_is_current_component( BP_XPROFILE_SLUG ) )
    16661723                return true;
    16671724
    16681725        return false;
     
    16711728function bp_is_activity_component() {
    16721729        global $bp;
    16731730
    1674         if ( BP_ACTIVITY_SLUG == $bp->current_component )
     1731        if ( bp_core_is_current_component( BP_ACTIVITY_SLUG ) )
    16751732                return true;
    16761733
    16771734        return false;
     
    16801737function bp_is_blogs_component() {
    16811738        global $bp;
    16821739
    1683         if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component )
     1740        if ( is_multisite() && bp_core_is_current_component( BP_BLOGS_SLUG ) )
    16841741                return true;
    16851742
    16861743        return false;
     
    16891746function bp_is_messages_component() {
    16901747        global $bp;
    16911748
    1692         if ( BP_MESSAGES_SLUG == $bp->current_component )
     1749        if ( bp_core_is_current_component( BP_MESSAGES_SLUG ) )
    16931750                return true;
    16941751
    16951752        return false;
     
    16981755function bp_is_friends_component() {
    16991756        global $bp;
    17001757
    1701         if ( BP_FRIENDS_SLUG == $bp->current_component )
     1758        if ( bp_core_is_current_component( BP_FRIENDS_SLUG ) )
    17021759                return true;
    17031760
    17041761        return false;
     
    17071764function bp_is_groups_component() {
    17081765        global $bp;
    17091766
    1710         if ( BP_GROUPS_SLUG == $bp->current_component )
     1767        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) )
    17111768                return true;
    17121769
    17131770        return false;
     
    17161773function bp_is_settings_component() {
    17171774        global $bp;
    17181775
    1719         if ( BP_SETTINGS_SLUG == $bp->current_component )
     1776        if ( bp_core_is_current_component( BP_SETTINGS_SLUG ) )
    17201777                return true;
    17211778
    17221779        return false;
     
    17341791function bp_is_user_activity() {
    17351792        global $bp;
    17361793
    1737         if ( $bp->activity->slug == $bp->current_component )
     1794        if ( bp_core_is_current_component( $bp->activity->slug ) )
    17381795                return true;
    17391796
    17401797        return false;
     
    17431800function bp_is_user_friends_activity() {
    17441801        global $bp;
    17451802
    1746         if ( $bp->activity->slug == $bp->current_component && 'my-friends' == $bp->current_action )
     1803        if ( bp_core_is_current_component( $bp->activity->slug ) && 'my-friends' == $bp->current_action )
    17471804                return true;
    17481805
    17491806        return false;
     
    17521809function bp_is_activity_permalink() {
    17531810        global $bp;
    17541811
    1755         if ( BP_ACTIVITY_SLUG == $bp->current_component && is_numeric( $bp->current_action ) )
     1812        if ( bp_core_is_current_component( BP_ACTIVITY_SLUG ) && is_numeric( $bp->current_action ) )
    17561813                return true;
    17571814
    17581815        return false;
     
    17611818function bp_is_user_profile() {
    17621819        global $bp;
    17631820
    1764         if ( defined( 'BP_XPROFILE_SLUG' ) && BP_XPROFILE_SLUG == $bp->current_component || isset( $bp->core->profile->slug ) && $bp->core->profile->slug == $bp->current_component )
     1821        if ( defined( 'BP_XPROFILE_SLUG' ) && bp_core_is_current_component( BP_XPROFILE_SLUG ) || isset( $bp->core->profile->slug ) && bp_core_is_current_component( $bp->core->profile->slug ) )
    17651822                return true;
    17661823
    17671824        return false;
     
    17701827function bp_is_profile_edit() {
    17711828        global $bp;
    17721829
    1773         if ( BP_XPROFILE_SLUG == $bp->current_component && 'edit' == $bp->current_action )
     1830        if ( bp_core_is_current_component( BP_XPROFILE_SLUG ) && 'edit' == $bp->current_action )
    17741831                return true;
    17751832
    17761833        return false;
     
    17791836function bp_is_change_avatar() {
    17801837        global $bp;
    17811838
    1782         if ( BP_XPROFILE_SLUG == $bp->current_component && 'change-avatar' == $bp->current_action )
     1839        if ( bp_core_is_current_component( BP_XPROFILE_SLUG ) && 'change-avatar' == $bp->current_action )
    17831840                return true;
    17841841
    17851842        return false;
     
    17871844
    17881845function bp_is_user_groups() {
    17891846        global $bp;
    1790 
    1791         if ( $bp->groups->slug == $bp->current_component )
     1847       
     1848        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) )
    17921849                return true;
    17931850
    17941851        return false;
     
    17961853
    17971854function bp_is_group() {
    17981855        global $bp;
    1799 
    1800         if ( BP_GROUPS_SLUG == $bp->current_component && isset( $bp->groups->current_group ) && $bp->groups->current_group )
     1856       
     1857        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && isset( $bp->groups->current_group ) && $bp->groups->current_group )
    18011858                return true;
    18021859
    18031860        return false;
     
    18061863function bp_is_group_home() {
    18071864        global $bp;
    18081865
    1809         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
     1866        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
    18101867                return true;
    18111868
    18121869        return false;
     
    18151872function bp_is_group_create() {
    18161873        global $bp;
    18171874
    1818         if ( BP_GROUPS_SLUG == $bp->current_component && 'create' == $bp->current_action )
     1875        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && 'create' == $bp->current_action )
    18191876                return true;
    18201877
    18211878        return false;
     
    18251882function bp_is_group_admin_page() {
    18261883        global $bp;
    18271884
    1828         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'admin' == $bp->current_action )
     1885        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'admin' == $bp->current_action )
    18291886                return true;
    18301887
    18311888        return false;
     
    18341891function bp_is_group_forum() {
    18351892        global $bp;
    18361893
    1837         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action )
     1894        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'forum' == $bp->current_action )
    18381895                return true;
    18391896
    18401897        return false;
     
    18431900function bp_is_group_activity() {
    18441901        global $bp;
    18451902
    1846         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'activity' == $bp->current_action )
     1903        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'activity' == $bp->current_action )
    18471904                return true;
    18481905
    18491906        return false;
     
    18521909function bp_is_group_forum_topic() {
    18531910        global $bp;
    18541911
    1855         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] )
     1912        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )
    18561913                return true;
    18571914
    18581915        return false;
     
    18611918function bp_is_group_forum_topic_edit() {
    18621919        global $bp;
    18631920
    1864         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] )
     1921        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $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] )
    18651922                return true;
    18661923
    18671924        return false;
     
    18701927function bp_is_group_members() {
    18711928        global $bp;
    18721929
    1873         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'members' == $bp->current_action )
     1930        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'members' == $bp->current_action )
    18741931                return true;
    18751932
    18761933        return false;
     
    18791936function bp_is_group_invites() {
    18801937        global $bp;
    18811938
    1882         if ( BP_GROUPS_SLUG == $bp->current_component && 'send-invites' == $bp->current_action )
     1939        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && 'send-invites' == $bp->current_action )
    18831940                return true;
    18841941
    18851942        return false;
     
    18881945function bp_is_group_membership_request() {
    18891946        global $bp;
    18901947
    1891         if ( BP_GROUPS_SLUG == $bp->current_component && 'request-membership' == $bp->current_action )
     1948        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && 'request-membership' == $bp->current_action )
    18921949                return true;
    18931950
    18941951        return false;
     
    18971954function bp_is_group_leave() {
    18981955        global $bp;
    18991956
    1900         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'leave-group' == $bp->current_action )
     1957        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item && 'leave-group' == $bp->current_action )
    19011958                return true;
    19021959
    19031960        return false;
     
    19061963function bp_is_group_single() {
    19071964        global $bp;
    19081965
    1909         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item )
     1966        if ( bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->is_single_item )
    19101967                return true;
    19111968
    19121969        return false;
     
    19151972function bp_is_user_blogs() {
    19161973        global $bp;
    19171974
    1918         if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component )
     1975        if ( is_multisite() && bp_core_is_current_component( BP_BLOGS_SLUG ) )
    19191976                return true;
    19201977
    19211978        return false;
     
    19241981function bp_is_user_recent_posts() {
    19251982        global $bp;
    19261983
    1927         if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component && 'recent-posts' == $bp->current_action )
     1984        if ( is_multisite() && bp_core_is_current_component( BP_BLOGS_SLUG ) && 'recent-posts' == $bp->current_action )
    19281985                return true;
    19291986
    19301987        return false;
     
    19331990function bp_is_user_recent_commments() {
    19341991        global $bp;
    19351992
    1936         if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component && 'recent-comments' == $bp->current_action )
     1993        if ( is_multisite() && bp_core_is_current_component( BP_BLOGS_SLUG ) && 'recent-comments' == $bp->current_action )
    19371994                return true;
    19381995
    19391996        return false;
     
    19421999function bp_is_create_blog() {
    19432000        global $bp;
    19442001
    1945         if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component && 'create' == $bp->current_action )
     2002        if ( is_multisite() && bp_core_is_current_component( BP_BLOGS_SLUG ) && 'create' == $bp->current_action )
    19462003                return true;
    19472004
    19482005        return false;
     
    19512008function bp_is_user_friends() {
    19522009        global $bp;
    19532010
    1954         if ( BP_FRIENDS_SLUG == $bp->current_component )
     2011        if ( bp_core_is_current_component( BP_FRIENDS_SLUG ) )
    19552012                return true;
    19562013
    19572014        return false;
     
    19602017function bp_is_friend_requests() {
    19612018        global $bp;
    19622019
    1963         if ( BP_FRIENDS_SLUG == $bp->current_component && 'requests' == $bp->current_action )
     2020        if ( bp_core_is_current_component( BP_FRIENDS_SLUG ) && 'requests' == $bp->current_action )
    19642021                return true;
    19652022
    19662023        return false;
     
    19692026function bp_is_user_messages() {
    19702027        global $bp;
    19712028
    1972         if ( BP_MESSAGES_SLUG == $bp->current_component )
     2029        if ( bp_core_is_current_component( BP_MESSAGES_SLUG ) )
    19732030                return true;
    19742031
    19752032        return false;
     
    19782035function bp_is_messages_inbox() {
    19792036        global $bp;
    19802037
    1981         if ( BP_MESSAGES_SLUG == $bp->current_component && ( !$bp->current_action || 'inbox' == $bp->current_action ) )
     2038        if ( bp_core_is_current_component( BP_MESSAGES_SLUG ) && ( !$bp->current_action || 'inbox' == $bp->current_action ) )
    19822039                return true;
    19832040
    19842041        return false;
     
    19872044function bp_is_messages_sentbox() {
    19882045        global $bp;
    19892046
    1990         if ( BP_MESSAGES_SLUG == $bp->current_component && 'sentbox' == $bp->current_action )
     2047        if ( bp_core_is_current_component( BP_MESSAGES_SLUG ) && 'sentbox' == $bp->current_action )
    19912048                return true;
    19922049
    19932050        return false;
     
    19972054function bp_is_notices() {
    19982055        global $bp;
    19992056
    2000         if ( BP_MESSAGES_SLUG == $bp->current_component && 'notices' == $bp->current_action )
     2057        if ( bp_core_is_current_component( BP_MESSAGES_SLUG ) && 'notices' == $bp->current_action )
    20012058                return true;
    20022059
    20032060        return false;
     
    20072064function bp_is_messages_compose_screen() {
    20082065        global $bp;
    20092066
    2010         if ( BP_MESSAGES_SLUG == $bp->current_component && 'compose' == $bp->current_action )
     2067        if ( bp_core_is_current_component( BP_MESSAGES_SLUG ) && 'compose' == $bp->current_action )
    20112068                return true;
    20122069
    20132070        return false;
     
    20252082function bp_is_activation_page() {
    20262083        global $bp;
    20272084
    2028         if ( BP_ACTIVATION_SLUG == $bp->current_component )
     2085        if ( bp_core_is_current_component( BP_ACTIVATION_SLUG ) )
    20292086                return true;
    20302087
    20312088        return false;
     
    20342091function bp_is_register_page() {
    20352092        global $bp;
    20362093
    2037         if ( BP_REGISTER_SLUG == $bp->current_component )
     2094        if ( bp_core_is_current_component( BP_REGISTER_SLUG ) )
    20382095                return true;
    20392096
    20402097        return false;
  • bp-activity/bp-activity-templatetags.php

     
    198198                'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide?
    199199
    200200                /* Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) */
    201                 'scope' => $bp->current_action,
     201                'scope' => $scope,
    202202
    203203                /* Filtering */
    204204                'user_id' => $user_id, // user_id to filter on
  • bp-blogs.php

     
    99function bp_blogs_setup_globals() {
    1010        global $bp, $wpdb;
    1111
    12         if ( !defined( 'BP_BLOGS_SLUG' ) && isset( $bp->pages->blogs->slug ) )
    13                 define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );
    14         elseif( !defined( 'BP_BLOGS_SLUG' ) )
     12        if ( !defined( 'BP_BLOGS_SLUG' ) && isset( $bp->pages->blogs->slug ) ) {
     13                define ( 'BP_BLOGS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->blogs->slug ) );
     14        } else if( !defined( 'BP_BLOGS_SLUG' ) ) {
    1515                define ( 'BP_BLOGS_SLUG', 'blogs' );
     16        }
    1617
    1718        // For internal identification
    1819        $bp->blogs->id = 'blogs';
    1920
    2021        $bp->blogs->slug = BP_BLOGS_SLUG;
     22        $bp->blogs->root_slug = $bp->pages->blogs->slug;
    2123
    2224        $bp->blogs->table_name          = $bp->table_prefix . 'bp_user_blogs';
    2325        $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta';
  • bp-forums.php

     
    2020        global $bp;
    2121       
    2222        if ( !defined( 'BP_FORUMS_SLUG' ) )
    23                 define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );
     23                define ( 'BP_FORUMS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->forums->slug ) );
    2424
    2525        // For internal identification
    2626        $bp->forums->id = 'forums';
    2727
    2828        $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
    2929        $bp->forums->slug = BP_FORUMS_SLUG;
     30        $bp->forums->root_slug = $bp->pages->forums->slug;
    3031
    3132        if ( isset( $bp->site_options['bb-config-location'] ) )
    3233                $bp->forums->bbconfig = $bp->site_options['bb-config-location'];
  • bp-groups.php

     
    1313function groups_setup_globals() {
    1414        global $bp;
    1515
     16        // Define a slug, if necessary
    1617        if ( !defined( 'BP_GROUPS_SLUG' ) )
    17                 define ( 'BP_GROUPS_SLUG', $bp->pages->groups->slug );
     18                define ( 'BP_GROUPS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->groups->slug ) );
    1819
    1920        /* For internal identification */
    2021        $bp->groups->id = 'groups';
    2122        $bp->groups->name = $bp->pages->groups->name;
    2223        $bp->groups->slug = BP_GROUPS_SLUG;
     24        $bp->groups->root_slug = $bp->pages->groups->slug;
    2325
    2426        $bp->groups->table_name           = $bp->table_prefix . 'bp_groups';
    2527        $bp->groups->table_name_members   = $bp->table_prefix . 'bp_groups_members';
     
    5658function groups_setup_nav() {
    5759        global $bp;
    5860
    59         if ( $bp->current_component == $bp->groups->slug && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
     61        if ( bp_core_is_current_component( $bp->groups->slug ) && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
    6062
    6163                /* This is a single group page. */
    6264                $bp->is_single_item = true;
     
    8082        }
    8183
    8284        /* 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 ) );
     85        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 ) );
    8486
    85         $groups_link = $bp->loggedin_user->domain . $bp->groups->name . '/';
     87        $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
    8688
    8789        /* 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() ) );
     90        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' ) );
     91        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() ) );
    9092
    91         if ( $bp->current_component == $bp->groups->slug ) {
     93        if ( bp_core_is_current_component( $bp->groups->slug ) ) {
    9294
    9395                if ( bp_is_my_profile() && !$bp->is_single_item ) {
    9496
     
    114116                        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' ) ) ) )
    115117                                $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
    116118
    117                         $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
     119                        $group_link = $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $bp->groups->current_group->slug . '/';
    118120
    119121                        // If this is a private or hidden group, does the user have access?
    120122                        if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
     
    127129                        }
    128130
    129131                        /* Reset the existing subnav items */
    130                         bp_core_reset_subnav_items($bp->groups->slug);
     132                        bp_core_reset_subnav_items($bp->groups->root_slug);
    131133
    132134                        /* 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' ) );
     135                        bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
    134136
    135137                        /* 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' ) );
     138                        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' ) );
    137139
    138140                        /* If the user is a group mod or more, then show the group admin nav item */
    139141                        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' ) );
     142                                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' ) );
    141143
    142144                        // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
    143145                        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 ) );
     146                                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 ) );
    145147
    146148                        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' ) );
     149                                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' ) );
    148150
    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'  ) );
     151                        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'  ) );
    150152
    151153                        if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    152154                                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 ) );
     155                                        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 ) );
    154156                        }
    155157                }
    156158        }
     
    164166
    165167function groups_directory_groups_setup() {
    166168        global $bp;
    167 
    168         if ( $bp->current_component == $bp->groups->slug && empty( $bp->current_action ) && empty( $bp->current_item ) ) {
     169       
     170        if ( bp_core_is_current_component( $bp->groups->slug ) && empty( $bp->current_action ) && empty( $bp->current_item ) ) {
    169171                $bp->is_directory = true;
    170172
    171173                do_action( 'groups_directory_groups_setup' );
     
    598600function groups_screen_group_activity_permalink() {
    599601        global $bp;
    600602
    601         if ( $bp->current_component != $bp->groups->slug || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )
     603        if ( !bp_core_is_current_component( $bp->groups->slug ) || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )
    602604                return false;
    603605
    604606        $bp->is_single_item = true;
     
    610612function groups_screen_group_admin() {
    611613        global $bp;
    612614
    613         if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
     615        if ( !bp_core_is_current_component( BP_GROUPS_SLUG ) || 'admin' != $bp->current_action )
    614616                return false;
    615617
    616618        if ( !empty( $bp->action_variables[0] ) )
     
    622624function groups_screen_group_admin_edit_details() {
    623625        global $bp;
    624626
    625         if ( $bp->current_component == $bp->groups->slug && 'edit-details' == $bp->action_variables[0] ) {
     627        if ( bp_core_is_current_component( $bp->groups->slug ) && 'edit-details' == $bp->action_variables[0] ) {
    626628
    627629                if ( $bp->is_item_admin || $bp->is_item_mod  ) {
    628630
     
    654656function groups_screen_group_admin_settings() {
    655657        global $bp;
    656658
    657         if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) {
     659        if ( bp_core_is_current_component( $bp->groups->slug ) && 'group-settings' == $bp->action_variables[0] ) {
    658660
    659661                if ( !$bp->is_item_admin )
    660662                        return false;
     
    691693function groups_screen_group_admin_avatar() {
    692694        global $bp;
    693695
    694         if ( $bp->current_component == $bp->groups->slug && 'group-avatar' == $bp->action_variables[0] ) {
     696        if ( bp_core_is_current_component( $bp->groups->slug ) && 'group-avatar' == $bp->action_variables[0] ) {
    695697
    696698                if ( !$bp->is_item_admin )
    697699                        return false;
     
    749751function groups_screen_group_admin_manage_members() {
    750752        global $bp;
    751753
    752         if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) {
     754        if ( bp_core_is_current_component( $bp->groups->slug ) && 'manage-members' == $bp->action_variables[0] ) {
    753755
    754756                if ( !$bp->is_item_admin )
    755757                        return false;
     
    855857function groups_screen_group_admin_requests() {
    856858        global $bp;
    857859
    858         if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
     860        if ( bp_core_is_current_component( $bp->groups->slug ) && 'membership-requests' == $bp->action_variables[0] ) {
    859861
    860862                /* Ask for a login if the user is coming here via an email notification */
    861863                if ( !is_user_logged_in() )
     
    913915function groups_screen_group_admin_delete_group() {
    914916        global $bp;
    915917
    916         if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
     918        if ( bp_core_is_current_component( $bp->groups->slug ) && 'delete-group' == $bp->action_variables[0] ) {
    917919
    918920                if ( !$bp->is_item_admin && !is_super_admin() )
    919921                        return false;
     
    10211023        global $bp;
    10221024
    10231025        /* If we're not at domain.org/groups/create/ then return false */
    1024         if ( $bp->current_component != $bp->groups->slug || 'create' != $bp->current_action )
     1026        if ( !bp_core_is_current_component( $bp->groups->slug ) || 'create' != $bp->current_action )
    10251027                return false;
    10261028
    10271029        if ( !is_user_logged_in() )
     
    10401042                setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
    10411043
    10421044                $reset_steps = true;
    1043                 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
     1045                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );
    10441046        }
    10451047
    10461048        /* If this is a creation step that is not recognized, just redirect them back to the first screen */
    10471049        if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
    10481050                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/' );
     1051                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/' );
    10501052        }
    10511053
    10521054        /* Fetch the currently completed steps variable */
     
    10681070                if ( 'group-details' == $bp->groups->current_create_step ) {
    10691071                        if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) {
    10701072                                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 . '/' );
     1073                                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
    10721074                        }
    10731075
    10741076                        $new_group_id = isset( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : 0;
    10751077
    10761078                        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' ) ) ) {
    10771079                                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 . '/' );
     1080                                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
    10791081                        }
    10801082
    10811083                        groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 );
     
    11021104
    11031105                        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 ) ) ) {
    11041106                                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 . '/' );
     1107                                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' );
    11061108                        }
    11071109                }
    11081110
     
    11581160                                }
    11591161                        }
    11601162
    1161                         bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $next_step . '/' );
     1163                        bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $next_step . '/' );
    11621164                }
    11631165        }
    11641166
     
    11941196function groups_action_join_group() {
    11951197        global $bp;
    11961198
    1197         if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' )
     1199        if ( !$bp->is_single_item || !bp_core_is_current_component( $bp->groups->slug ) || $bp->current_action != 'join' )
    11981200                return false;
    11991201
    12001202        // Nonce check
     
    12291231function groups_action_leave_group() {
    12301232        global $bp;
    12311233
    1232         if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'leave-group' )
     1234        if ( !$bp->is_single_item || !bp_core_is_current_component( $bp->groups->slug ) || $bp->current_action != 'leave-group' )
    12331235                return false;
    12341236
    12351237        // Nonce check
     
    12541256function groups_action_sort_creation_steps() {
    12551257        global $bp;
    12561258
    1257         if ( $bp->current_component != BP_GROUPS_SLUG && $bp->current_action != 'create' )
     1259        if ( !bp_core_is_current_component( BP_GROUPS_SLUG ) && $bp->current_action != 'create' )
    12581260                return false;
    12591261
    12601262        if ( !is_array( $bp->groups->group_creation_steps ) )
     
    12781280function groups_action_redirect_to_random_group() {
    12791281        global $bp, $wpdb;
    12801282
    1281         if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) {
     1283        if ( bp_core_is_current_component( $bp->groups->slug ) && isset( $_GET['random-group'] ) ) {
    12821284                $group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) );
    12831285
    12841286                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/' . $group['groups'][0]->slug . '/' );
     
    12891291function groups_action_group_feed() {
    12901292        global $bp, $wp_query;
    12911293
    1292         if ( !bp_is_active( 'activity' ) || $bp->current_component != $bp->groups->slug || !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' )
     1294        if ( !bp_is_active( 'activity' ) || !bp_core_is_current_component( $bp->groups->slug ) || !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' )
    12931295                return false;
    12941296
    12951297        $wp_query->is_404 = false;
  • bp-core.php

     
    284284        return apply_filters( 'bp_core_get_page_names', $pages );
    285285}
    286286
     287/**
     288 * Creates a default component slug from a WP page root_slug
     289 *
     290 * Since 1.3, BP components get their root_slug (the slug used immediately following the root
     291 * domain) from the slug of a corresponding WP page. E.g. if your BP installation at example.com
     292 * has its members page at example.com/community/people, $bp->members->root_slug will be
     293 * 'community/people'. By default, this function creates a shorter version of the root_slug for
     294 * use elsewhere in the URL, by returning the content after the final '/' in the root_slug
     295 * ('people' in the example above).
     296 *
     297 * Filter on 'bp_core_component_slug_from_root_slug' to override this method in general, or define a
     298 * specific component slug constant (e.g. BP_MEMBERS_SLUG) to override specific component slugs.
     299 * 
     300 * @package BuddyPress Core
     301 * @since 1.3
     302 *
     303 * @param str $root_slug The root slug, which comes from $bp->pages->[component]->slug
     304 * @return str $slug The short slug for use in the middle of URLs
     305 */
     306function bp_core_component_slug_from_root_slug( $root_slug ) {
     307        $slug_chunks = explode( '/', $root_slug );
     308        $slug = array_pop( $slug_chunks );
     309       
     310        return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug );
     311 }
     312
    287313/**
    288314 * bp_core_admin_menu_init()
    289315 *
     
    332358}
    333359add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_add_admin_menu', 9 );
    334360
     361/**
     362 * Checks to see whether the current page belongs to the specified component
     363 *
     364 * This function is designed to be generous, accepting several different kinds of value for
     365 * the $component parameter. It checks $component_name against:
     366 *      - the component's root_slug, which matches the page slug in $bp->pages
     367 *      - the component's regular slug
     368 *      - the component's id, or 'canonical' name
     369 *
     370 * @package BuddyPress Core
     371 * @since 1.3
     372 * @return bool Returns true if the component matches, or else false.
     373 */
     374function bp_core_is_current_component( $component ) {
     375        global $bp;
     376       
     377        $is_current_component = false;
     378       
     379        if ( !empty( $bp->current_component ) ) {
     380                if ( $bp->current_component == $component ) {
     381               
     382                        // First, check to see whether $component_name and the current
     383                        // component are a simple match
     384                        $is_current_component = true;
     385               
     386                } else if ( $key = array_search( $component, $bp->active_components ) ) {
     387               
     388                        // Next, check to see whether $component is a canonical, non-translatable
     389                        // component name. If so, we can return its corresponding slug from $bp->
     390                        // active_components.
     391                       
     392                        if ( $key === $bp->current_component )
     393                                $is_current_component = true;
     394               
     395                } else {
     396               
     397                        // If we haven't found a match yet, check against the root_slugs created
     398                        // by $bp->pages
     399                        foreach ( $bp->active_components as $key => $id ) {
     400                                // If the $component parameter does not match the current_component,
     401                                // then move along, these are not the droids you are looking for
     402                                if ( $bp->{$id}->root_slug != $bp->current_component )
     403                                        continue;
     404                               
     405                                if ( $key == $component ) {
     406                                        $is_current_component = true;
     407                                        break;
     408                                }
     409                        }
     410                }
     411        }
     412                 
     413        return apply_filters( 'bp_core_is_current_component', $is_current_component, $component_name );
     414}
     415
    335416/**
    336417 * bp_core_is_root_component()
    337418 *
     
    343424 */
    344425function bp_core_is_root_component( $component_name ) {
    345426        global $bp;
    346 
    347         foreach ( (array) $bp->pages as $key => $page ) {
    348                 if ( $key == $component_name || $page->slug == $component_name )
     427       
     428        foreach ( (array) $bp->active_components as $key => $slug ) {
     429                if ( $key == $component_name || $slug == $component_name )
    349430                        return true;
    350431        }
    351432
     
    865946                'user_has_access' => $user_has_access,
    866947                'screen_function' => &$screen_function
    867948        );
    868 
     949       
    869950        if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
    870951                if ( !is_object( $screen_function[0] ) )
    871952                        add_action( 'wp', $screen_function, 3 );
  • bp-groups/bp-groups-templatetags.php

     
    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_core_is_current_component( $bp->groups->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
     
    16191619        foreach ( (array)$bp->groups->group_creation_steps as $slug => $step ) {
    16201620                $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
    16211621
    1622                 <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/create/step/<?php echo $slug ?>/"><?php else: ?><span><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php else: ?></span><?php endif ?></li><?php
     1622                <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->root_domain . '/' . $bp->groups->root_slug ?>/create/step/<?php echo $slug ?>/"><?php else: ?><span><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php else: ?></span><?php endif ?></li><?php
    16231623                $counter++;
    16241624        }
    16251625
     
    16431643                if ( empty( $bp->action_variables[1] ) )
    16441644                        $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
    16451645
    1646                 return apply_filters( 'bp_get_group_creation_form_action', $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
     1646                return apply_filters( 'bp_get_group_creation_form_action', $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->action_variables[1] );
    16471647        }
    16481648
    16491649function bp_is_group_creation_step( $step_slug ) {
    16501650        global $bp;
    16511651
    16521652        /* Make sure we are in the groups component */
    1653         if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action )
     1653        if ( !bp_core_is_current_component( BP_GROUPS_SLUG ) || 'create' != $bp->current_action )
    16541654                return false;
    16551655
    16561656        /* If this the first step, we can just accept and return true */
     
    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( BP_GROUPS_SLUG ) || 'admin' != $bp->current_action )
    19331933                return false;
    19341934
    19351935        if ( $bp->action_variables[0] == $slug )