Ticket #2600: 2600-4.patch
File 2600-4.patch, 50.7 KB (added by , 13 years ago) |
---|
-
bp-activity.php
6 6 function bp_activity_setup_globals() { 7 7 global $bp, $current_blog; 8 8 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 } 11 13 12 14 // For internal identification 13 15 $bp->activity->id = 'activity'; 14 16 $bp->activity->name = $bp->pages->activity->name; 15 17 $bp->activity->slug = BP_ACTIVITY_SLUG; 18 $bp->activity->root_slug = $bp->pages->activity->slug; 16 19 17 20 $bp->activity->table_name = $bp->table_prefix . 'bp_activity'; 18 21 $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta'; … … 37 40 38 41 $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; 39 42 $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 . '/'; 41 44 42 45 /* Add the subnav items to the activity nav item if we are using a theme that supports this */ 43 46 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 ) ); 44 47 45 48 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' ) ); 47 50 48 51 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' ) ); 50 53 51 54 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' ) ); 52 55 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' ) ); … … 59 62 $bp->bp_options_title = $bp->displayed_user->fullname; 60 63 } 61 64 } 62 65 63 66 do_action( 'bp_activity_setup_nav' ); 64 67 } 65 68 add_action( 'bp_setup_nav', 'bp_activity_setup_nav' ); -
bp-themes/bp-default/groups/index.php
4 4 <div class="padder"> 5 5 6 6 <form action="" method="post" id="groups-directory-form" class="dir-form"> 7 <h3><?php _e( 'Groups Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> <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() ) : ?> <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> 8 8 9 9 <?php do_action( 'bp_before_directory_groups_content' ) ?> 10 10 -
bp-core/bp-core-templatetags.php
162 162 } 163 163 164 164 // 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 ) 166 166 return false; 167 167 168 168 $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras, $exclude ); … … 582 582 */ 583 583 function bp_get_options_nav() { 584 584 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 ) 587 591 return false; 588 592 589 593 /* 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 ) { 591 595 if ( !$subnav_item['user_has_access'] ) 592 596 continue; 593 597 … … 1556 1560 return apply_filters( 'bp_get_root_domain', $bp->root_domain ); 1557 1561 } 1558 1562 1563 /** 1564 * Echoes the output of bp_get_root_slug() 1565 * 1566 * @package BuddyPress Core 1567 * @since 1.3 1568 */ 1569 function 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 1559 1616 /* Template is_() functions to determine the current page */ 1560 1617 1561 1618 /** … … 1662 1719 function bp_is_profile_component() { 1663 1720 global $bp; 1664 1721 1665 if ( BP_XPROFILE_SLUG == $bp->current_component)1722 if ( bp_core_is_current_component( BP_XPROFILE_SLUG ) ) 1666 1723 return true; 1667 1724 1668 1725 return false; … … 1671 1728 function bp_is_activity_component() { 1672 1729 global $bp; 1673 1730 1674 if ( BP_ACTIVITY_SLUG == $bp->current_component)1731 if ( bp_core_is_current_component( BP_ACTIVITY_SLUG ) ) 1675 1732 return true; 1676 1733 1677 1734 return false; … … 1680 1737 function bp_is_blogs_component() { 1681 1738 global $bp; 1682 1739 1683 if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component)1740 if ( is_multisite() && bp_core_is_current_component( BP_BLOGS_SLUG ) ) 1684 1741 return true; 1685 1742 1686 1743 return false; … … 1689 1746 function bp_is_messages_component() { 1690 1747 global $bp; 1691 1748 1692 if ( BP_MESSAGES_SLUG == $bp->current_component)1749 if ( bp_core_is_current_component( BP_MESSAGES_SLUG ) ) 1693 1750 return true; 1694 1751 1695 1752 return false; … … 1698 1755 function bp_is_friends_component() { 1699 1756 global $bp; 1700 1757 1701 if ( BP_FRIENDS_SLUG == $bp->current_component)1758 if ( bp_core_is_current_component( BP_FRIENDS_SLUG ) ) 1702 1759 return true; 1703 1760 1704 1761 return false; … … 1707 1764 function bp_is_groups_component() { 1708 1765 global $bp; 1709 1766 1710 if ( BP_GROUPS_SLUG == $bp->current_component)1767 if ( bp_core_is_current_component( BP_GROUPS_SLUG ) ) 1711 1768 return true; 1712 1769 1713 1770 return false; … … 1716 1773 function bp_is_settings_component() { 1717 1774 global $bp; 1718 1775 1719 if ( BP_SETTINGS_SLUG == $bp->current_component)1776 if ( bp_core_is_current_component( BP_SETTINGS_SLUG ) ) 1720 1777 return true; 1721 1778 1722 1779 return false; … … 1734 1791 function bp_is_user_activity() { 1735 1792 global $bp; 1736 1793 1737 if ( $bp->activity->slug == $bp->current_component)1794 if ( bp_core_is_current_component( $bp->activity->slug ) ) 1738 1795 return true; 1739 1796 1740 1797 return false; … … 1743 1800 function bp_is_user_friends_activity() { 1744 1801 global $bp; 1745 1802 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 ) 1747 1804 return true; 1748 1805 1749 1806 return false; … … 1752 1809 function bp_is_activity_permalink() { 1753 1810 global $bp; 1754 1811 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 ) ) 1756 1813 return true; 1757 1814 1758 1815 return false; … … 1761 1818 function bp_is_user_profile() { 1762 1819 global $bp; 1763 1820 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 ) ) 1765 1822 return true; 1766 1823 1767 1824 return false; … … 1770 1827 function bp_is_profile_edit() { 1771 1828 global $bp; 1772 1829 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 ) 1774 1831 return true; 1775 1832 1776 1833 return false; … … 1779 1836 function bp_is_change_avatar() { 1780 1837 global $bp; 1781 1838 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 ) 1783 1840 return true; 1784 1841 1785 1842 return false; … … 1787 1844 1788 1845 function bp_is_user_groups() { 1789 1846 global $bp; 1790 1791 if ( $bp->groups->slug == $bp->current_component)1847 1848 if ( bp_core_is_current_component( BP_GROUPS_SLUG ) ) 1792 1849 return true; 1793 1850 1794 1851 return false; … … 1796 1853 1797 1854 function bp_is_group() { 1798 1855 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 ) 1801 1858 return true; 1802 1859 1803 1860 return false; … … 1806 1863 function bp_is_group_home() { 1807 1864 global $bp; 1808 1865 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 ) ) 1810 1867 return true; 1811 1868 1812 1869 return false; … … 1815 1872 function bp_is_group_create() { 1816 1873 global $bp; 1817 1874 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 ) 1819 1876 return true; 1820 1877 1821 1878 return false; … … 1825 1882 function bp_is_group_admin_page() { 1826 1883 global $bp; 1827 1884 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 ) 1829 1886 return true; 1830 1887 1831 1888 return false; … … 1834 1891 function bp_is_group_forum() { 1835 1892 global $bp; 1836 1893 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 ) 1838 1895 return true; 1839 1896 1840 1897 return false; … … 1843 1900 function bp_is_group_activity() { 1844 1901 global $bp; 1845 1902 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 ) 1847 1904 return true; 1848 1905 1849 1906 return false; … … 1852 1909 function bp_is_group_forum_topic() { 1853 1910 global $bp; 1854 1911 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] ) 1856 1913 return true; 1857 1914 1858 1915 return false; … … 1861 1918 function bp_is_group_forum_topic_edit() { 1862 1919 global $bp; 1863 1920 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] ) 1865 1922 return true; 1866 1923 1867 1924 return false; … … 1870 1927 function bp_is_group_members() { 1871 1928 global $bp; 1872 1929 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 ) 1874 1931 return true; 1875 1932 1876 1933 return false; … … 1879 1936 function bp_is_group_invites() { 1880 1937 global $bp; 1881 1938 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 ) 1883 1940 return true; 1884 1941 1885 1942 return false; … … 1888 1945 function bp_is_group_membership_request() { 1889 1946 global $bp; 1890 1947 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 ) 1892 1949 return true; 1893 1950 1894 1951 return false; … … 1897 1954 function bp_is_group_leave() { 1898 1955 global $bp; 1899 1956 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 ) 1901 1958 return true; 1902 1959 1903 1960 return false; … … 1906 1963 function bp_is_group_single() { 1907 1964 global $bp; 1908 1965 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 ) 1910 1967 return true; 1911 1968 1912 1969 return false; … … 1915 1972 function bp_is_user_blogs() { 1916 1973 global $bp; 1917 1974 1918 if ( is_multisite() && BP_BLOGS_SLUG == $bp->current_component)1975 if ( is_multisite() && bp_core_is_current_component( BP_BLOGS_SLUG ) ) 1919 1976 return true; 1920 1977 1921 1978 return false; … … 1924 1981 function bp_is_user_recent_posts() { 1925 1982 global $bp; 1926 1983 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 ) 1928 1985 return true; 1929 1986 1930 1987 return false; … … 1933 1990 function bp_is_user_recent_commments() { 1934 1991 global $bp; 1935 1992 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 ) 1937 1994 return true; 1938 1995 1939 1996 return false; … … 1942 1999 function bp_is_create_blog() { 1943 2000 global $bp; 1944 2001 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 ) 1946 2003 return true; 1947 2004 1948 2005 return false; … … 1951 2008 function bp_is_user_friends() { 1952 2009 global $bp; 1953 2010 1954 if ( BP_FRIENDS_SLUG == $bp->current_component)2011 if ( bp_core_is_current_component( BP_FRIENDS_SLUG ) ) 1955 2012 return true; 1956 2013 1957 2014 return false; … … 1960 2017 function bp_is_friend_requests() { 1961 2018 global $bp; 1962 2019 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 ) 1964 2021 return true; 1965 2022 1966 2023 return false; … … 1969 2026 function bp_is_user_messages() { 1970 2027 global $bp; 1971 2028 1972 if ( BP_MESSAGES_SLUG == $bp->current_component)2029 if ( bp_core_is_current_component( BP_MESSAGES_SLUG ) ) 1973 2030 return true; 1974 2031 1975 2032 return false; … … 1978 2035 function bp_is_messages_inbox() { 1979 2036 global $bp; 1980 2037 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 ) ) 1982 2039 return true; 1983 2040 1984 2041 return false; … … 1987 2044 function bp_is_messages_sentbox() { 1988 2045 global $bp; 1989 2046 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 ) 1991 2048 return true; 1992 2049 1993 2050 return false; … … 1997 2054 function bp_is_notices() { 1998 2055 global $bp; 1999 2056 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 ) 2001 2058 return true; 2002 2059 2003 2060 return false; … … 2007 2064 function bp_is_messages_compose_screen() { 2008 2065 global $bp; 2009 2066 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 ) 2011 2068 return true; 2012 2069 2013 2070 return false; … … 2025 2082 function bp_is_activation_page() { 2026 2083 global $bp; 2027 2084 2028 if ( BP_ACTIVATION_SLUG == $bp->current_component)2085 if ( bp_core_is_current_component( BP_ACTIVATION_SLUG ) ) 2029 2086 return true; 2030 2087 2031 2088 return false; … … 2034 2091 function bp_is_register_page() { 2035 2092 global $bp; 2036 2093 2037 if ( BP_REGISTER_SLUG == $bp->current_component)2094 if ( bp_core_is_current_component( BP_REGISTER_SLUG ) ) 2038 2095 return true; 2039 2096 2040 2097 return false; -
bp-activity/bp-activity-templatetags.php
198 198 'show_hidden' => $show_hidden, // Show activity items that are hidden site-wide? 199 199 200 200 /* Scope - pre-built activity filters for a user (friends/groups/favorites/mentions) */ 201 'scope' => $ bp->current_action,201 'scope' => $scope, 202 202 203 203 /* Filtering */ 204 204 'user_id' => $user_id, // user_id to filter on -
bp-blogs.php
9 9 function bp_blogs_setup_globals() { 10 10 global $bp, $wpdb; 11 11 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' ) ) { 15 15 define ( 'BP_BLOGS_SLUG', 'blogs' ); 16 } 16 17 17 18 // For internal identification 18 19 $bp->blogs->id = 'blogs'; 19 20 20 21 $bp->blogs->slug = BP_BLOGS_SLUG; 22 $bp->blogs->root_slug = $bp->pages->blogs->slug; 21 23 22 24 $bp->blogs->table_name = $bp->table_prefix . 'bp_user_blogs'; 23 25 $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta'; -
bp-forums.php
20 20 global $bp; 21 21 22 22 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 ) ); 24 24 25 25 // For internal identification 26 26 $bp->forums->id = 'forums'; 27 27 28 28 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 29 29 $bp->forums->slug = BP_FORUMS_SLUG; 30 $bp->forums->root_slug = $bp->pages->forums->slug; 30 31 31 32 if ( isset( $bp->site_options['bb-config-location'] ) ) 32 33 $bp->forums->bbconfig = $bp->site_options['bb-config-location']; -
bp-groups.php
13 13 function groups_setup_globals() { 14 14 global $bp; 15 15 16 // Define a slug, if necessary 16 17 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 ) ); 18 19 19 20 /* For internal identification */ 20 21 $bp->groups->id = 'groups'; 21 22 $bp->groups->name = $bp->pages->groups->name; 22 23 $bp->groups->slug = BP_GROUPS_SLUG; 24 $bp->groups->root_slug = $bp->pages->groups->slug; 23 25 24 26 $bp->groups->table_name = $bp->table_prefix . 'bp_groups'; 25 27 $bp->groups->table_name_members = $bp->table_prefix . 'bp_groups_members'; … … 56 58 function groups_setup_nav() { 57 59 global $bp; 58 60 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) ) { 60 62 61 63 /* This is a single group page. */ 62 64 $bp->is_single_item = true; … … 80 82 } 81 83 82 84 /* 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 ) ); 84 86 85 $groups_link = $bp->loggedin_user->domain . $bp->groups-> name. '/';87 $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/'; 86 88 87 89 /* 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() ) ); 90 92 91 if ( $bp->current_component == $bp->groups->slug) {93 if ( bp_core_is_current_component( $bp->groups->slug ) ) { 92 94 93 95 if ( bp_is_my_profile() && !$bp->is_single_item ) { 94 96 … … 114 116 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' ) ) ) ) 115 117 $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />'; 116 118 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 . '/'; 118 120 119 121 // If this is a private or hidden group, does the user have access? 120 122 if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) { … … 127 129 } 128 130 129 131 /* Reset the existing subnav items */ 130 bp_core_reset_subnav_items($bp->groups-> slug);132 bp_core_reset_subnav_items($bp->groups->root_slug); 131 133 132 134 /* 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' ) ); 134 136 135 137 /* 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' ) ); 137 139 138 140 /* If the user is a group mod or more, then show the group admin nav item */ 139 141 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' ) ); 141 143 142 144 // If this is a private group, and the user is not a member, show a "Request Membership" nav item. 143 145 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 ) ); 145 147 146 148 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' ) ); 148 150 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' ) ); 150 152 151 153 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 152 154 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 ) ); 154 156 } 155 157 } 156 158 } … … 164 166 165 167 function groups_directory_groups_setup() { 166 168 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 ) ) { 169 171 $bp->is_directory = true; 170 172 171 173 do_action( 'groups_directory_groups_setup' ); … … 598 600 function groups_screen_group_activity_permalink() { 599 601 global $bp; 600 602 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] ) ) 602 604 return false; 603 605 604 606 $bp->is_single_item = true; … … 610 612 function groups_screen_group_admin() { 611 613 global $bp; 612 614 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 ) 614 616 return false; 615 617 616 618 if ( !empty( $bp->action_variables[0] ) ) … … 622 624 function groups_screen_group_admin_edit_details() { 623 625 global $bp; 624 626 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] ) { 626 628 627 629 if ( $bp->is_item_admin || $bp->is_item_mod ) { 628 630 … … 654 656 function groups_screen_group_admin_settings() { 655 657 global $bp; 656 658 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] ) { 658 660 659 661 if ( !$bp->is_item_admin ) 660 662 return false; … … 691 693 function groups_screen_group_admin_avatar() { 692 694 global $bp; 693 695 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] ) { 695 697 696 698 if ( !$bp->is_item_admin ) 697 699 return false; … … 749 751 function groups_screen_group_admin_manage_members() { 750 752 global $bp; 751 753 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] ) { 753 755 754 756 if ( !$bp->is_item_admin ) 755 757 return false; … … 855 857 function groups_screen_group_admin_requests() { 856 858 global $bp; 857 859 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] ) { 859 861 860 862 /* Ask for a login if the user is coming here via an email notification */ 861 863 if ( !is_user_logged_in() ) … … 913 915 function groups_screen_group_admin_delete_group() { 914 916 global $bp; 915 917 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] ) { 917 919 918 920 if ( !$bp->is_item_admin && !is_super_admin() ) 919 921 return false; … … 1021 1023 global $bp; 1022 1024 1023 1025 /* 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 ) 1025 1027 return false; 1026 1028 1027 1029 if ( !is_user_logged_in() ) … … 1040 1042 setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH ); 1041 1043 1042 1044 $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 ) ) . '/' ); 1044 1046 } 1045 1047 1046 1048 /* If this is a creation step that is not recognized, just redirect them back to the first screen */ 1047 1049 if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) { 1048 1050 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/' ); 1050 1052 } 1051 1053 1052 1054 /* Fetch the currently completed steps variable */ … … 1068 1070 if ( 'group-details' == $bp->groups->current_create_step ) { 1069 1071 if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) { 1070 1072 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 . '/' ); 1072 1074 } 1073 1075 1074 1076 $new_group_id = isset( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : 0; 1075 1077 1076 1078 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' ) ) ) { 1077 1079 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 . '/' ); 1079 1081 } 1080 1082 1081 1083 groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 ); … … 1102 1104 1103 1105 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 ) ) ) { 1104 1106 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 . '/' ); 1106 1108 } 1107 1109 } 1108 1110 … … 1158 1160 } 1159 1161 } 1160 1162 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 . '/' ); 1162 1164 } 1163 1165 } 1164 1166 … … 1194 1196 function groups_action_join_group() { 1195 1197 global $bp; 1196 1198 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' ) 1198 1200 return false; 1199 1201 1200 1202 // Nonce check … … 1229 1231 function groups_action_leave_group() { 1230 1232 global $bp; 1231 1233 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' ) 1233 1235 return false; 1234 1236 1235 1237 // Nonce check … … 1254 1256 function groups_action_sort_creation_steps() { 1255 1257 global $bp; 1256 1258 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' ) 1258 1260 return false; 1259 1261 1260 1262 if ( !is_array( $bp->groups->group_creation_steps ) ) … … 1278 1280 function groups_action_redirect_to_random_group() { 1279 1281 global $bp, $wpdb; 1280 1282 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'] ) ) { 1282 1284 $group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) ); 1283 1285 1284 1286 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/' . $group['groups'][0]->slug . '/' ); … … 1289 1291 function groups_action_group_feed() { 1290 1292 global $bp, $wp_query; 1291 1293 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' ) 1293 1295 return false; 1294 1296 1295 1297 $wp_query->is_404 = false; -
bp-core.php
284 284 return apply_filters( 'bp_core_get_page_names', $pages ); 285 285 } 286 286 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 */ 306 function 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 287 313 /** 288 314 * bp_core_admin_menu_init() 289 315 * … … 332 358 } 333 359 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_core_add_admin_menu', 9 ); 334 360 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 */ 374 function 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 335 416 /** 336 417 * bp_core_is_root_component() 337 418 * … … 343 424 */ 344 425 function bp_core_is_root_component( $component_name ) { 345 426 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 ) 349 430 return true; 350 431 } 351 432 … … 865 946 'user_has_access' => $user_has_access, 866 947 'screen_function' => &$screen_function 867 948 ); 868 949 869 950 if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) { 870 951 if ( !is_object( $screen_function[0] ) ) 871 952 add_action( 'wp', $screen_function, 3 ); -
bp-groups/bp-groups-templatetags.php
350 350 if ( !$group ) 351 351 $group =& $groups_template->group; 352 352 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 . '/' ); 354 354 } 355 355 356 356 function bp_group_admin_permalink() { … … 362 362 if ( !$group ) 363 363 $group =& $groups_template->group; 364 364 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' ); 366 366 } 367 367 368 368 function bp_group_slug() { … … 547 547 function bp_group_is_activity_permalink() { 548 548 global $bp; 549 549 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 ) 551 551 return false; 552 552 553 553 return true; … … 929 929 $current_tab = $bp->action_variables[0]; 930 930 ?> 931 931 <?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> 933 933 <?php } ?> 934 934 935 935 <?php 936 936 if ( !$bp->is_item_admin ) 937 937 return false; 938 938 ?> 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> 942 942 943 943 <?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> 945 945 <?php endif; ?> 946 946 947 947 <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?> 948 948 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> 950 950 <?php 951 951 } 952 952 … … 1619 1619 foreach ( (array)$bp->groups->group_creation_steps as $slug => $step ) { 1620 1620 $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?> 1621 1621 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><?php1622 <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 1623 1623 $counter++; 1624 1624 } 1625 1625 … … 1643 1643 if ( empty( $bp->action_variables[1] ) ) 1644 1644 $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) ); 1645 1645 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] ); 1647 1647 } 1648 1648 1649 1649 function bp_is_group_creation_step( $step_slug ) { 1650 1650 global $bp; 1651 1651 1652 1652 /* 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 ) 1654 1654 return false; 1655 1655 1656 1656 /* If this the first step, we can just accept and return true */ … … 1929 1929 function bp_is_group_admin_screen( $slug ) { 1930 1930 global $bp; 1931 1931 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 ) 1933 1933 return false; 1934 1934 1935 1935 if ( $bp->action_variables[0] == $slug )