Ticket #2600: 2600-3.patch
File 2600-3.patch, 36.5 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'; -
bp-core/bp-core-templatetags.php
1695 1695 function bp_is_groups_component() { 1696 1696 global $bp; 1697 1697 1698 if ( BP_GROUPS_SLUG == $bp->current_component)1698 if ( bp_core_is_current_component( 'groups' ) ) 1699 1699 return true; 1700 1700 1701 1701 return false; … … 1785 1785 function bp_is_group() { 1786 1786 global $bp; 1787 1787 1788 if ( BP_GROUPS_SLUG == $bp->current_component&& isset( $bp->groups->current_group ) && $bp->groups->current_group )1788 if ( bp_core_is_current_component( 'groups' ) && isset( $bp->groups->current_group ) && $bp->groups->current_group ) 1789 1789 return true; 1790 1790 1791 1791 return false; … … 1794 1794 function bp_is_group_home() { 1795 1795 global $bp; 1796 1796 1797 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )1797 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) ) 1798 1798 return true; 1799 1799 1800 1800 return false; … … 1803 1803 function bp_is_group_create() { 1804 1804 global $bp; 1805 1805 1806 if ( BP_GROUPS_SLUG == $bp->current_component&& 'create' == $bp->current_action )1806 if ( bp_core_is_current_component( 'groups' ) && 'create' == $bp->current_action ) 1807 1807 return true; 1808 1808 1809 1809 return false; … … 1813 1813 function bp_is_group_admin_page() { 1814 1814 global $bp; 1815 1815 1816 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'admin' == $bp->current_action )1816 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'admin' == $bp->current_action ) 1817 1817 return true; 1818 1818 1819 1819 return false; … … 1822 1822 function bp_is_group_forum() { 1823 1823 global $bp; 1824 1824 1825 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'forum' == $bp->current_action )1825 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action ) 1826 1826 return true; 1827 1827 1828 1828 return false; … … 1831 1831 function bp_is_group_activity() { 1832 1832 global $bp; 1833 1833 1834 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'activity' == $bp->current_action )1834 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'activity' == $bp->current_action ) 1835 1835 return true; 1836 1836 1837 1837 return false; … … 1840 1840 function bp_is_group_forum_topic() { 1841 1841 global $bp; 1842 1842 1843 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )1843 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] ) 1844 1844 return true; 1845 1845 1846 1846 return false; … … 1849 1849 function bp_is_group_forum_topic_edit() { 1850 1850 global $bp; 1851 1851 1852 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] )1852 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] ) 1853 1853 return true; 1854 1854 1855 1855 return false; … … 1858 1858 function bp_is_group_members() { 1859 1859 global $bp; 1860 1860 1861 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'members' == $bp->current_action )1861 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'members' == $bp->current_action ) 1862 1862 return true; 1863 1863 1864 1864 return false; … … 1867 1867 function bp_is_group_invites() { 1868 1868 global $bp; 1869 1869 1870 if ( BP_GROUPS_SLUG == $bp->current_component&& 'send-invites' == $bp->current_action )1870 if ( bp_core_is_current_component( 'groups' ) && 'send-invites' == $bp->current_action ) 1871 1871 return true; 1872 1872 1873 1873 return false; … … 1876 1876 function bp_is_group_membership_request() { 1877 1877 global $bp; 1878 1878 1879 if ( BP_GROUPS_SLUG == $bp->current_component&& 'request-membership' == $bp->current_action )1879 if ( bp_core_is_current_component( 'groups' ) && 'request-membership' == $bp->current_action ) 1880 1880 return true; 1881 1881 1882 1882 return false; … … 1885 1885 function bp_is_group_leave() { 1886 1886 global $bp; 1887 1887 1888 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item && 'leave-group' == $bp->current_action )1888 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item && 'leave-group' == $bp->current_action ) 1889 1889 return true; 1890 1890 1891 1891 return false; … … 1894 1894 function bp_is_group_single() { 1895 1895 global $bp; 1896 1896 1897 if ( BP_GROUPS_SLUG == $bp->current_component&& $bp->is_single_item )1897 if ( bp_core_is_current_component( 'groups' ) && $bp->is_single_item ) 1898 1898 return true; 1899 1899 1900 1900 return false; -
bp-blogs.php
9 9 function bp_blogs_setup_globals() { 10 10 global $bp, $wpdb; 11 11 12 if ( !defined( 'BP_BLOGS_SLUG' ) ) 13 define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug ); 12 // Define a slug, if necessary 13 if ( !defined( 'BP_BLOGS_SLUG' ) ) { 14 define( 'BP_BLOGS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->blogs->slug ) ); 15 } 14 16 15 17 // For internal identification 16 18 $bp->blogs->id = 'blogs'; 17 19 18 20 $bp->blogs->slug = BP_BLOGS_SLUG; 21 $bp->blogs->root_slug = $bp->pages->blogs->slug; 19 22 20 23 $bp->blogs->table_name = $bp->table_prefix . 'bp_user_blogs'; 21 24 $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta'; -
bp-forums.php
19 19 function bp_forums_setup() { 20 20 global $bp; 21 21 22 if ( !defined( 'BP_FORUMS_SLUG' ) ) 23 define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug ); 22 // Define a slug, if necessary 23 if ( !defined( 'BP_FORUMS_SLUG' ) ) { 24 define( 'BP_FORUMS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->forums->slug ) ); 25 } 24 26 25 27 // For internal identification 26 28 $bp->forums->id = 'forums'; 27 29 28 30 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 29 31 $bp->forums->slug = BP_FORUMS_SLUG; 32 $bp->forums->root_slug = $bp->pages->forums->slug; 30 33 31 34 if ( isset( $bp->site_options['bb-config-location'] ) ) 32 35 $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 if ( !defined( 'BP_GROUPS_SLUG' ) ) 17 define ( 'BP_GROUPS_SLUG', $bp->pages->groups->slug ); 18 16 // Define a slug, if necessary 17 if ( !defined( 'BP_GROUPS_SLUG' ) ) { 18 define( 'BP_GROUPS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->groups->slug ) ); 19 } 20 19 21 /* For internal identification */ 20 22 $bp->groups->id = 'groups'; 21 23 $bp->groups->name = $bp->pages->groups->name; 22 24 $bp->groups->slug = BP_GROUPS_SLUG; 25 $bp->groups->root_slug = $bp->pages->groups->slug; 23 26 24 27 $bp->groups->table_name = $bp->table_prefix . 'bp_groups'; 25 28 $bp->groups->table_name_members = $bp->table_prefix . 'bp_groups_members'; … … 56 59 function groups_setup_nav() { 57 60 global $bp; 58 61 59 if ( $bp->current_component == $bp->groups->slug&& $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {62 if ( bp_core_is_current_component( 'groups' ) && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) { 60 63 61 64 /* This is a single group page. */ 62 65 $bp->is_single_item = true; … … 80 83 } 81 84 82 85 /* Add 'Groups' to the main navigation */ 83 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups-> name, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );86 bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) ); 84 87 85 $groups_link = $bp->loggedin_user->domain . $bp->groups-> name. '/';88 $groups_link = $bp->loggedin_user->domain . $bp->groups->root_slug . '/'; 86 89 87 90 /* Add the subnav items to the groups nav item */ 88 bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups-> name, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );89 bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups-> name, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );91 bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) ); 92 bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) ); 90 93 91 if ( $bp->current_component == $bp->groups->slug) {94 if ( bp_core_is_current_component( 'groups' ) ) { 92 95 93 96 if ( bp_is_my_profile() && !$bp->is_single_item ) { 94 97 … … 114 117 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 118 $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />'; 116 119 117 $group_link = $bp->root_domain . '/' . $bp->groups-> slug . '/' . $bp->groups->current_group->slug . '/';120 $group_link = $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $bp->groups->current_group->slug . '/'; 118 121 119 122 // If this is a private or hidden group, does the user have access? 120 123 if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) { … … 127 130 } 128 131 129 132 /* Reset the existing subnav items */ 130 bp_core_reset_subnav_items($bp->groups-> slug);133 bp_core_reset_subnav_items($bp->groups->root_slug); 131 134 132 135 /* Add a new default subnav item for when the groups nav is selected. */ 133 bp_core_new_nav_default( array( 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );136 bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) ); 134 137 135 138 /* Add the "Home" subnav item, as this will always be present */ 136 bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) );139 bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'home' ) ); 137 140 138 141 /* If the user is a group mod or more, then show the group admin nav item */ 139 142 if ( $bp->is_item_mod || $bp->is_item_admin ) 140 bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) );143 bp_core_new_subnav_item( array( 'name' => __( 'Admin', 'buddypress' ), 'slug' => 'admin', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_admin', 'position' => 20, 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ), 'item_css_id' => 'admin' ) ); 141 144 142 145 // If this is a private group, and the user is not a member, show a "Request Membership" nav item. 143 146 if ( !is_super_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' ) 144 bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );147 bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) ); 145 148 146 149 if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') ) 147 bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) );150 bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) ); 148 151 149 bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members' ) );152 bp_core_new_subnav_item( array( 'name' => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $bp->groups->current_group->total_member_count ) ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members' ) ); 150 153 151 154 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { 152 155 if ( bp_is_active('friends') ) 153 bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups-> slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) );156 bp_core_new_subnav_item( array( 'name' => __( 'Send Invites', 'buddypress' ), 'slug' => 'send-invites', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->root_slug, 'screen_function' => 'groups_screen_group_invite', 'item_css_id' => 'invite', 'position' => 70, 'user_has_access' => $bp->groups->current_group->user_has_access ) ); 154 157 } 155 158 } 156 159 } … … 165 168 function groups_directory_groups_setup() { 166 169 global $bp; 167 170 168 if ( $bp->current_component == $bp->groups->slug&& empty( $bp->current_action ) && empty( $bp->current_item ) ) {171 if ( bp_core_is_current_component( 'groups' ) && empty( $bp->current_action ) && empty( $bp->current_item ) ) { 169 172 $bp->is_directory = true; 170 173 171 174 do_action( 'groups_directory_groups_setup' ); … … 598 601 function groups_screen_group_activity_permalink() { 599 602 global $bp; 600 603 601 if ( $bp->current_component != $bp->groups->slug|| $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) )604 if ( !bp_core_is_current_component( 'groups' ) || $bp->current_action != $bp->activity->slug || empty( $bp->action_variables[0] ) ) 602 605 return false; 603 606 604 607 $bp->is_single_item = true; … … 609 612 610 613 function groups_screen_group_admin() { 611 614 global $bp; 612 613 if ( $bp->current_component != BP_GROUPS_SLUG|| 'admin' != $bp->current_action )615 616 if ( !bp_core_is_current_component( 'groups' ) || 'admin' != $bp->current_action ) 614 617 return false; 615 618 616 619 if ( !empty( $bp->action_variables[0] ) ) … … 622 625 function groups_screen_group_admin_edit_details() { 623 626 global $bp; 624 627 625 if ( $bp->current_component == $bp->groups->slug&& 'edit-details' == $bp->action_variables[0] ) {628 if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'edit-details' == $bp->action_variables[0] ) { 626 629 627 630 if ( $bp->is_item_admin || $bp->is_item_mod ) { 628 631 … … 654 657 function groups_screen_group_admin_settings() { 655 658 global $bp; 656 659 657 if ( $bp->current_component == $bp->groups->slug&& 'group-settings' == $bp->action_variables[0] ) {660 if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'group-settings' == $bp->action_variables[0] ) { 658 661 659 662 if ( !$bp->is_item_admin ) 660 663 return false; … … 691 694 function groups_screen_group_admin_avatar() { 692 695 global $bp; 693 696 694 if ( $bp->current_component == $bp->groups->slug&& 'group-avatar' == $bp->action_variables[0] ) {697 if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'group-avatar' == $bp->action_variables[0] ) { 695 698 696 699 if ( !$bp->is_item_admin ) 697 700 return false; … … 749 752 function groups_screen_group_admin_manage_members() { 750 753 global $bp; 751 754 752 if ( $bp->current_component == $bp->groups->slug&& 'manage-members' == $bp->action_variables[0] ) {755 if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'manage-members' == $bp->action_variables[0] ) { 753 756 754 757 if ( !$bp->is_item_admin ) 755 758 return false; … … 855 858 function groups_screen_group_admin_requests() { 856 859 global $bp; 857 860 858 if ( $bp->current_component == $bp->groups->slug&& 'membership-requests' == $bp->action_variables[0] ) {861 if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'membership-requests' == $bp->action_variables[0] ) { 859 862 860 863 /* Ask for a login if the user is coming here via an email notification */ 861 864 if ( !is_user_logged_in() ) … … 913 916 function groups_screen_group_admin_delete_group() { 914 917 global $bp; 915 918 916 if ( $bp->current_component == $bp->groups->slug&& 'delete-group' == $bp->action_variables[0] ) {919 if ( bp_core_is_current_component( 'groups' ) && !empty( $bp->action_variables[0] ) && 'delete-group' == $bp->action_variables[0] ) { 917 920 918 921 if ( !$bp->is_item_admin && !is_super_admin() ) 919 922 return false; … … 1021 1024 global $bp; 1022 1025 1023 1026 /* If we're not at domain.org/groups/create/ then return false */ 1024 if ( $bp->current_component != $bp->groups->slug|| 'create' != $bp->current_action )1027 if ( !bp_core_is_current_component( 'groups' ) || 'create' != $bp->current_action ) 1025 1028 return false; 1026 1029 1027 1030 if ( !is_user_logged_in() ) … … 1040 1043 setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH ); 1041 1044 1042 1045 $reset_steps = true; 1043 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' );1046 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps ) ) . '/' ); 1044 1047 } 1045 1048 1046 1049 /* If this is a creation step that is not recognized, just redirect them back to the first screen */ 1047 1050 if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) { 1048 1051 bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' ); 1049 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/' );1052 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/' ); 1050 1053 } 1051 1054 1052 1055 /* Fetch the currently completed steps variable */ … … 1068 1071 if ( 'group-details' == $bp->groups->current_create_step ) { 1069 1072 if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) || !strlen( trim( $_POST['group-name'] ) ) || !strlen( trim( $_POST['group-desc'] ) ) ) { 1070 1073 bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' ); 1071 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . $bp->groups->current_create_step . '/' );1074 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' ); 1072 1075 } 1073 1076 1074 1077 $new_group_id = isset( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : 0; 1075 1078 1076 1079 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 1080 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 1078 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . $bp->groups->current_create_step . '/' );1081 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' ); 1079 1082 } 1080 1083 1081 1084 groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 ); … … 1102 1105 1103 1106 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 1107 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); 1105 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . $bp->groups->current_create_step . '/' );1108 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $bp->groups->current_create_step . '/' ); 1106 1109 } 1107 1110 } 1108 1111 … … 1158 1161 } 1159 1162 } 1160 1163 1161 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/create/step/' . $next_step . '/' );1164 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/create/step/' . $next_step . '/' ); 1162 1165 } 1163 1166 } 1164 1167 … … 1194 1197 function groups_action_join_group() { 1195 1198 global $bp; 1196 1199 1197 if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug|| $bp->current_action != 'join' )1200 if ( !$bp->is_single_item || !bp_core_is_current_component( 'groups' ) || $bp->current_action != 'join' ) 1198 1201 return false; 1199 1202 1200 1203 // Nonce check … … 1229 1232 function groups_action_leave_group() { 1230 1233 global $bp; 1231 1234 1232 if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug|| $bp->current_action != 'leave-group' )1235 if ( !$bp->is_single_item || !bp_core_is_current_component( 'groups' ) || $bp->current_action != 'leave-group' ) 1233 1236 return false; 1234 1237 1235 1238 // Nonce check … … 1254 1257 function groups_action_sort_creation_steps() { 1255 1258 global $bp; 1256 1259 1257 if ( $bp->current_component != BP_GROUPS_SLUG&& $bp->current_action != 'create' )1260 if ( !bp_core_is_current_component( 'groups' ) && $bp->current_action != 'create' ) 1258 1261 return false; 1259 1262 1260 1263 if ( !is_array( $bp->groups->group_creation_steps ) ) … … 1278 1281 function groups_action_redirect_to_random_group() { 1279 1282 global $bp, $wpdb; 1280 1283 1281 if ( $bp->current_component == $bp->groups->slug&& isset( $_GET['random-group'] ) ) {1284 if ( bp_core_is_current_component( 'groups' ) && isset( $_GET['random-group'] ) ) { 1282 1285 $group = groups_get_groups( array( 'type' => 'random', 'per_page' => 1 ) ); 1283 1286 1284 bp_core_redirect( $bp->root_domain . '/' . $bp->groups-> slug . '/' . $group['groups'][0]->slug . '/' );1287 bp_core_redirect( $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $group['groups'][0]->slug . '/' ); 1285 1288 } 1286 1289 } 1287 1290 add_action( 'wp', 'groups_action_redirect_to_random_group', 6 ); … … 1289 1292 function groups_action_group_feed() { 1290 1293 global $bp, $wp_query; 1291 1294 1292 if ( !bp_is_active( 'activity' ) || $bp->current_component != $bp->groups->slug|| !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' )1295 if ( !bp_is_active( 'activity' ) || !bp_core_is_current_component( 'groups' ) || !isset( $bp->groups->current_group ) || $bp->current_action != 'feed' ) 1293 1296 return false; 1294 1297 1295 1298 $wp_query->is_404 = false; -
bp-core.php
83 83 // Set up the members id and active components entry 84 84 $bp->members->id = 'members'; 85 85 86 $bp->members->slug = $bp->pages->members->slug; 86 // Define a slug, if necessary 87 if ( !defined( 'BP_MEMBERS_SLUG' ) ) { 88 define( 'BP_MEMBERS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->members->slug ) ); 89 } 90 91 $bp->members->slug = BP_MEMBERS_SLUG; 92 $bp->members->root_slug = $bp->pages->members->slug; 87 93 $bp->active_components[$bp->members->slug] = $bp->members->id; 88 94 89 95 // The user ID of the user who is currently logged in. … … 201 207 function bp_core_define_slugs() { 202 208 global $bp; 203 209 204 if ( !defined( 'BP_MEMBERS_SLUG' ) )205 define( 'BP_MEMBERS_SLUG', $bp->pages->members->slug );206 207 210 if ( !defined( 'BP_REGISTER_SLUG' ) ) 208 211 define( 'BP_REGISTER_SLUG', $bp->pages->register->slug ); 209 212 … … 285 288 } 286 289 287 290 /** 291 * Creates a default component slug from a WP page root_slug 292 * 293 * Since 1.3, BP components get their root_slug (the slug used immediately following the root 294 * domain) from the slug of a corresponding WP page. E.g. if your BP installation at example.com 295 * has its members page at example.com/community/people, $bp->members->root_slug will be 296 * 'community/people'. By default, this function creates a shorter version of the root_slug for 297 * use elsewhere in the URL, by returning the content after the final '/' in the root_slug 298 * ('people' in the example above). 299 * 300 * Filter on 'bp_core_component_slug_from_root_slug' to override this method in general, or define a 301 * specific component slug constant (e.g. BP_MEMBERS_SLUG) to override specific component slugs. 302 * 303 * @package BuddyPress Core 304 * @since 1.3 305 * 306 * @param str $root_slug The root slug, which comes from $bp->pages->[component]->slug 307 * @return str $slug The short slug for use in the middle of URLs 308 */ 309 function bp_core_component_slug_from_root_slug( $root_slug ) { 310 $slug_chunks = explode( '/', $root_slug ); 311 $slug = array_pop( $slug_chunks ); 312 313 return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug ); 314 } 315 316 317 /** 288 318 * bp_core_admin_menu_init() 289 319 * 290 320 * Initializes the wp-admin area "BuddyPress" menus and sub menus. … … 351 381 return false; 352 382 } 353 383 384 354 385 /** 386 * Checks to see whether the current page belongs to the specified component 387 * 388 * This function is designed to be generous, accepting several different kinds of value for 389 * the $component_name parameter. It checks $component_name against: 390 * - the component's root_slug, which matches the page slug in $bp->pages 391 * - the component's regular slug 392 * - the component's id, or 'canonical' name 393 * 394 * @package BuddyPress Core 395 * @since 1.3 396 * @return true if root component, else false. 397 */ 398 function bp_core_is_current_component( $component_name ) { 399 global $bp; 400 401 $is_current_component = false; 402 403 if ( !empty( $bp->current_component ) ) { 404 foreach ( $bp->active_components as $key => $id ) { 405 if ( !empty( $bp->{$id}->root_slug ) && $bp->{$id}->root_slug == $component_name ) { 406 // First, check to see whether $component_name matches the root_slug 407 // This covers the case where the component name immediately follows 408 // the root domain, as 'members' in example.com/members/boonebgorges 409 // or 'groups' in example.com/groups/my-cool-group. Note: Only 410 // components that have corresponding WP pages will have root_slug 411 412 $is_current_component = true; 413 break; 414 } else if ( $bp->{$id}->slug == $component_name ) { 415 // Then, check to see whether $component_name matches the regular 416 // component slug. This accounts for instances when the component 417 // name appears further down the URL, as on profile tabs: e.g. 418 // 'friends' in example.com/members/boonebgorges/friends 419 420 $is_current_component = true; 421 break; 422 } else if ( $bp->{$id}->id == $component_name ) { 423 // Finally, check to see whether $component_name matches the 424 // unique, non-translatable component id 425 426 $is_current_component = true; 427 break; 428 } 429 } 430 } 431 432 return apply_filters( 'bp_core_is_current_component', $is_current_component, $component_name ); 433 } 434 435 /** 355 436 * bp_core_setup_nav() 356 437 * 357 438 * Sets up the profile navigation item if the Xprofile component is not installed. … … 865 946 'screen_function' => &$screen_function 866 947 ); 867 948 868 if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) { 949 if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) { 869 950 if ( !is_object( $screen_function[0] ) ) 870 951 add_action( 'wp', $screen_function, 3 ); 871 952 else -
bp-groups/bp-groups-templatetags.php
148 148 $user_id = $bp->displayed_user->id; 149 149 150 150 /* Type */ 151 if ( 'my-groups' == $bp->current_action ) {151 if ( 'my-groups' == $bp->current_action && !empty( $order ) ) { 152 152 if ( 'most-popular' == $order ) { 153 153 $type = 'popular'; 154 154 } elseif ( 'alphabetically' == $order ) { … … 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->current_component != $bp->groups->root_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 … … 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( 'groups' ) || 'admin' != $bp->current_action ) 1933 1933 return false; 1934 1934 1935 1935 if ( $bp->action_variables[0] == $slug )