Changeset 9936 for trunk/src/bp-notifications/bp-notifications-loader.php
- Timestamp:
- 06/11/2015 06:53:59 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/bp-notifications-loader.php
r9819 r9936 68 68 69 69 // Define a slug, if necessary 70 if ( ! defined( 'BP_NOTIFICATIONS_SLUG' ) ) {70 if ( ! defined( 'BP_NOTIFICATIONS_SLUG' ) ) { 71 71 define( 'BP_NOTIFICATIONS_SLUG', $this->id ); 72 72 } … … 104 104 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 105 105 106 // Only grab count if we're on a user page and current user has access107 if ( bp_is_user() && bp_user_has_access() ) {108 $count = bp_notifications_get_unread_notification_count( bp_displayed_user_id() );109 $class = ( 0 === $count ) ? 'no-count' : 'count';110 $nav_name = sprintf( _x( 'Notifications <span class="%s">%s</span>', 'Profile screen nav', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) );111 } else {112 $nav_name = _x( 'Notifications', 'Profile screen nav', 'buddypress' );113 }114 115 // Add 'Notifications' to the main navigation116 $main_nav = array(117 'name' => $nav_name,118 'slug' => $this->slug,119 'position' => 30,120 'show_for_displayed_user' => bp_core_can_edit_settings(),121 'screen_function' => 'bp_notifications_screen_unread',122 'default_subnav_slug' => 'unread',123 'item_css_id' => $this->id,124 );125 126 106 // Determine user to use 127 107 if ( bp_displayed_user_domain() ) { … … 133 113 } 134 114 135 $notifications_link = trailingslashit( $user_domain . bp_get_notifications_slug() ); 115 $access = bp_core_can_edit_settings(); 116 $slug = bp_get_notifications_slug(); 117 $notifications_link = trailingslashit( $user_domain . $slug ); 118 119 // Only grab count if we're on a user page and current user has access 120 if ( bp_is_user() && bp_user_has_access() ) { 121 $count = bp_notifications_get_unread_notification_count( bp_displayed_user_id() ); 122 $class = ( 0 === $count ) ? 'no-count' : 'count'; 123 $nav_name = sprintf( _x( 'Notifications <span class="%s">%s</span>', 'Profile screen nav', 'buddypress' ), esc_attr( $class ), bp_core_number_format( $count ) ); 124 } else { 125 $nav_name = _x( 'Notifications', 'Profile screen nav', 'buddypress' ); 126 } 127 128 // Add 'Notifications' to the main navigation 129 $main_nav = array( 130 'name' => $nav_name, 131 'slug' => $slug, 132 'position' => 30, 133 'show_for_displayed_user' => $access, 134 'screen_function' => 'bp_notifications_screen_unread', 135 'default_subnav_slug' => 'unread', 136 'item_css_id' => $this->id, 137 ); 136 138 137 139 // Add the subnav items to the notifications nav item … … 140 142 'slug' => 'unread', 141 143 'parent_url' => $notifications_link, 142 'parent_slug' => bp_get_notifications_slug(),144 'parent_slug' => $slug, 143 145 'screen_function' => 'bp_notifications_screen_unread', 144 146 'position' => 10, 145 147 'item_css_id' => 'notifications-my-notifications', 146 'user_has_access' => bp_core_can_edit_settings(),148 'user_has_access' => $access, 147 149 ); 148 150 … … 151 153 'slug' => 'read', 152 154 'parent_url' => $notifications_link, 153 'parent_slug' => bp_get_notifications_slug(),155 'parent_slug' => $slug, 154 156 'screen_function' => 'bp_notifications_screen_read', 155 157 'position' => 20, 156 'user_has_access' => bp_core_can_edit_settings(),158 'user_has_access' => $access, 157 159 ); 158 160 … … 177 179 178 180 // Setup the logged in user variables 179 $notifications_link = trailingslashit( bp_loggedin_user_domain() . $this->slug);181 $notifications_link = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() ); 180 182 181 183 // Pending notification requests 182 184 $count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ); 183 185 if ( ! empty( $count ) ) { 184 $title = sprintf( _x( 'Notifications <span class="count">%s</span>', 'My Account Notification pending', 'buddypress' ), number_format_i18n( $count ) );185 $unread = sprintf( _x( 'Unread <span class="count">%s</span>', 'My Account Notification pending', 'buddypress' ), number_format_i18n( $count ) );186 $title = sprintf( _x( 'Notifications <span class="count">%s</span>', 'My Account Notification pending', 'buddypress' ), bp_core_number_format( $count ) ); 187 $unread = sprintf( _x( 'Unread <span class="count">%s</span>', 'My Account Notification pending', 'buddypress' ), bp_core_number_format( $count ) ); 186 188 } else { 187 $title = _x( 'Notifications', 'My Account Notification', 'buddypress' );188 $unread = _x( 'Unread', 'My Account Notification sub nav', 'buddypress' );189 $title = _x( 'Notifications', 'My Account Notification', 'buddypress' ); 190 $unread = _x( 'Unread', 'My Account Notification sub nav', 'buddypress' ); 189 191 } 190 192 … … 194 196 'id' => 'my-account-' . $this->id, 195 197 'title' => $title, 196 'href' => trailingslashit( $notifications_link ),198 'href' => $notifications_link 197 199 ); 198 200 … … 202 204 'id' => 'my-account-' . $this->id . '-unread', 203 205 'title' => $unread, 204 'href' => trailingslashit( $notifications_link ),206 'href' => $notifications_link 205 207 ); 206 208 … … 223 225 */ 224 226 public function setup_title() { 225 $bp = buddypress();226 227 227 228 // Adjust title 228 229 if ( bp_is_notifications_component() ) { 230 $bp = buddypress(); 231 229 232 if ( bp_is_my_profile() ) { 230 233 $bp->bp_options_title = __( 'Notifications', 'buddypress' );
Note: See TracChangeset
for help on using the changeset viewer.