Changeset 9936 for trunk/src/bp-messages/bp-messages-loader.php
- Timestamp:
- 06/11/2015 06:53:59 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-loader.php
r9934 r9936 91 91 92 92 // Define a slug, if necessary 93 if ( ! defined( 'BP_MESSAGES_SLUG' ) ) {93 if ( ! defined( 'BP_MESSAGES_SLUG' ) ) { 94 94 define( 'BP_MESSAGES_SLUG', $this->id ); 95 95 } … … 130 130 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 131 131 132 // Only grab count if we're on a user page and current user has access133 if ( bp_is_user() && bp_user_has_access() ) {134 $count = bp_get_total_unread_messages_count();135 $class = ( 0 === $count ) ? 'no-count' : 'count';136 $nav_name = sprintf( __( 'Messages <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) );137 } else {138 $nav_name = __( 'Messages', 'buddypress' );139 }140 141 // Add 'Messages' to the main navigation142 $main_nav = array(143 'name' => $nav_name,144 'slug' => $this->slug,145 'position' => 50,146 'show_for_displayed_user' => bp_core_can_edit_settings(),147 'screen_function' => 'messages_screen_inbox',148 'default_subnav_slug' => 'inbox',149 'item_css_id' => $this->id150 );151 152 132 // Determine user to use 153 133 if ( bp_displayed_user_domain() ) { … … 159 139 } 160 140 161 // Link to user messages 162 $messages_link = trailingslashit( $user_domain . $this->slug ); 141 $access = bp_core_can_edit_settings(); 142 $slug = bp_get_messages_slug(); 143 $messages_link = trailingslashit( $user_domain . $slug ); 144 145 // Only grab count if we're on a user page and current user has access 146 if ( bp_is_user() && bp_user_has_access() ) { 147 $count = bp_get_total_unread_messages_count(); 148 $class = ( 0 === $count ) ? 'no-count' : 'count'; 149 $nav_name = sprintf( __( 'Messages <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), bp_core_number_format( $count ) ); 150 } else { 151 $nav_name = __( 'Messages', 'buddypress' ); 152 } 153 154 // Add 'Messages' to the main navigation 155 $main_nav = array( 156 'name' => $nav_name, 157 'slug' => $slug, 158 'position' => 50, 159 'show_for_displayed_user' => $access, 160 'screen_function' => 'messages_screen_inbox', 161 'default_subnav_slug' => 'inbox', 162 'item_css_id' => $this->id 163 ); 163 164 164 165 // Add the subnav items to the profile … … 167 168 'slug' => 'inbox', 168 169 'parent_url' => $messages_link, 169 'parent_slug' => $ this->slug,170 'parent_slug' => $slug, 170 171 'screen_function' => 'messages_screen_inbox', 171 172 'position' => 10, 172 'user_has_access' => bp_core_can_edit_settings()173 'user_has_access' => $access 173 174 ); 174 175 … … 178 179 'slug' => bp_get_messages_starred_slug(), 179 180 'parent_url' => $messages_link, 180 'parent_slug' => $ this->slug,181 'parent_slug' => $slug, 181 182 'screen_function' => 'bp_messages_star_screen', 182 183 'position' => 11, 183 'user_has_access' => bp_core_can_edit_settings()184 'user_has_access' => $access 184 185 ); 185 186 } … … 189 190 'slug' => 'sentbox', 190 191 'parent_url' => $messages_link, 191 'parent_slug' => $ this->slug,192 'parent_slug' => $slug, 192 193 'screen_function' => 'messages_screen_sentbox', 193 194 'position' => 20, 194 'user_has_access' => bp_core_can_edit_settings()195 'user_has_access' => $access 195 196 ); 196 197 … … 199 200 'slug' => 'compose', 200 201 'parent_url' => $messages_link, 201 'parent_slug' => $ this->slug,202 'parent_slug' => $slug, 202 203 'screen_function' => 'messages_screen_compose', 203 204 'position' => 30, 204 'user_has_access' => bp_core_can_edit_settings()205 'user_has_access' => $access 205 206 ); 206 207 … … 210 211 'slug' => 'notices', 211 212 'parent_url' => $messages_link, 212 'parent_slug' => $ this->slug,213 'parent_slug' => $slug, 213 214 'screen_function' => 'messages_screen_notices', 214 215 'position' => 90, 215 'user_has_access' => bp_current_user_can( 'bp_moderate' )216 'user_has_access' => true 216 217 ); 217 218 } … … 227 228 */ 228 229 public function setup_admin_bar( $wp_admin_nav = array() ) { 229 $bp = buddypress();230 230 231 231 // Menus for logged in user … … 233 233 234 234 // Setup the logged in user variables 235 $user_domain = bp_loggedin_user_domain(); 236 $messages_link = trailingslashit( $user_domain . $this->slug ); 235 $messages_link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() ); 237 236 238 237 // Unread message count 239 238 $count = messages_get_unread_count(); 240 239 if ( !empty( $count ) ) { 241 $title = sprintf( __( 'Messages <span class="count">%s</span>', 'buddypress' ), number_format_i18n( $count ) );242 $inbox = sprintf( __( 'Inbox <span class="count">%s</span>', 'buddypress' ), number_format_i18n( $count ) );240 $title = sprintf( __( 'Messages <span class="count">%s</span>', 'buddypress' ), bp_core_number_format( $count ) ); 241 $inbox = sprintf( __( 'Inbox <span class="count">%s</span>', 'buddypress' ), bp_core_number_format( $count ) ); 243 242 } else { 244 243 $title = __( 'Messages', 'buddypress' ); … … 248 247 // Add main Messages menu 249 248 $wp_admin_nav[] = array( 250 'parent' => $bp->my_account_menu_id,249 'parent' => buddypress()->my_account_menu_id, 251 250 'id' => 'my-account-' . $this->id, 252 251 'title' => $title, 253 'href' => trailingslashit( $messages_link )252 'href' => $messages_link 254 253 ); 255 254 … … 259 258 'id' => 'my-account-' . $this->id . '-inbox', 260 259 'title' => $inbox, 261 'href' => trailingslashit( $messages_link . 'inbox' )260 'href' => $messages_link 262 261 ); 263 262 … … 306 305 */ 307 306 public function setup_title() { 308 $bp = buddypress();309 307 310 308 if ( bp_is_messages_component() ) { 309 $bp = buddypress(); 310 311 311 if ( bp_is_my_profile() ) { 312 312 $bp->bp_options_title = __( 'My Messages', 'buddypress' );
Note: See TracChangeset
for help on using the changeset viewer.