Changeset 9936 for trunk/src/bp-friends/bp-friends-loader.php
- Timestamp:
- 06/11/2015 06:53:59 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-loader.php
r9819 r9936 76 76 77 77 // Define a slug, if necessary 78 if ( ! defined( 'BP_FRIENDS_SLUG' ) )78 if ( ! defined( 'BP_FRIENDS_SLUG' ) ) { 79 79 define( 'BP_FRIENDS_SLUG', $this->id ); 80 } 80 81 81 82 // Global tables for the friends component … … 111 112 */ 112 113 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 113 $bp = buddypress();114 115 // Add 'Friends' to the main navigation116 $count = friends_get_total_friend_count();117 $class = ( 0 === $count ) ? 'no-count' : 'count';118 $main_nav = array(119 'name' => sprintf( __( 'Friends <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) ),120 'slug' => $this->slug,121 'position' => 60,122 'screen_function' => 'friends_screen_my_friends',123 'default_subnav_slug' => 'my-friends',124 'item_css_id' => $bp->friends->id125 );126 114 127 115 // Determine user to use … … 134 122 } 135 123 136 $friends_link = trailingslashit( $user_domain . bp_get_friends_slug() ); 124 $access = bp_core_can_edit_settings(); 125 $slug = bp_get_friends_slug(); 126 $friends_link = trailingslashit( $user_domain . $slug ); 127 128 // Add 'Friends' to the main navigation 129 $count = friends_get_total_friend_count(); 130 $class = ( 0 === $count ) ? 'no-count' : 'count'; 131 $main_nav = array( 132 'name' => sprintf( __( 'Friends <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), bp_core_number_format( $count ) ), 133 'slug' => $slug, 134 'position' => 60, 135 'screen_function' => 'friends_screen_my_friends', 136 'default_subnav_slug' => 'my-friends', 137 'item_css_id' => $this->id 138 ); 137 139 138 140 // Add the subnav items to the friends nav item … … 141 143 'slug' => 'my-friends', 142 144 'parent_url' => $friends_link, 143 'parent_slug' => bp_get_friends_slug(),145 'parent_slug' => $slug, 144 146 'screen_function' => 'friends_screen_my_friends', 145 147 'position' => 10, … … 151 153 'slug' => 'requests', 152 154 'parent_url' => $friends_link, 153 'parent_slug' => bp_get_friends_slug(),155 'parent_slug' => $slug, 154 156 'screen_function' => 'friends_screen_requests', 155 157 'position' => 20, 156 'user_has_access' => bp_core_can_edit_settings()158 'user_has_access' => $access 157 159 ); 158 160 … … 171 173 */ 172 174 public function setup_admin_bar( $wp_admin_nav = array() ) { 173 $bp = buddypress();174 175 175 176 // Menus for logged in user … … 177 178 178 179 // Setup the logged in user variables 179 $user_domain = bp_loggedin_user_domain(); 180 $friends_link = trailingslashit( $user_domain . $this->slug ); 180 $friends_link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() ); 181 181 182 182 // Pending friend requests 183 183 $count = count( friends_get_friendship_request_user_ids( bp_loggedin_user_id() ) ); 184 184 if ( !empty( $count ) ) { 185 $title = sprintf( _x( 'Friends <span class="count">%s</span>', 'My Account Friends menu', 'buddypress' ), number_format_i18n( $count ) );186 $pending = sprintf( _x( 'Pending Requests <span class="count">%s</span>', 'My Account Friends menu sub nav', 'buddypress' ), number_format_i18n( $count ) );185 $title = sprintf( _x( 'Friends <span class="count">%s</span>', 'My Account Friends menu', 'buddypress' ), bp_core_number_format( $count ) ); 186 $pending = sprintf( _x( 'Pending Requests <span class="count">%s</span>', 'My Account Friends menu sub nav', 'buddypress' ), bp_core_number_format( $count ) ); 187 187 } else { 188 $title = _x( 'Friends', 'My Account Friends menu','buddypress' );188 $title = _x( 'Friends', 'My Account Friends menu', 'buddypress' ); 189 189 $pending = _x( 'No Pending Requests','My Account Friends menu sub nav', 'buddypress' ); 190 190 } … … 192 192 // Add the "My Account" sub menus 193 193 $wp_admin_nav[] = array( 194 'parent' => $bp->my_account_menu_id,194 'parent' => buddypress()->my_account_menu_id, 195 195 'id' => 'my-account-' . $this->id, 196 196 'title' => $title, 197 'href' => trailingslashit( $friends_link )197 'href' => $friends_link 198 198 ); 199 199 … … 203 203 'id' => 'my-account-' . $this->id . '-friendships', 204 204 'title' => _x( 'Friendships', 'My Account Friends menu sub nav', 'buddypress' ), 205 'href' => trailingslashit( $friends_link )205 'href' => $friends_link 206 206 ); 207 207 … … 222 222 */ 223 223 public function setup_title() { 224 $bp = buddypress();225 224 226 225 // Adjust title 227 226 if ( bp_is_friends_component() ) { 227 $bp = buddypress(); 228 228 229 if ( bp_is_my_profile() ) { 229 230 $bp->bp_options_title = __( 'Friendships', 'buddypress' );
Note: See TracChangeset
for help on using the changeset viewer.