[buddypress-trac] [BuddyPress Trac] #5413: Don't query for item counts in profile nav when not needed

buddypress-trac noreply at wordpress.org
Thu Feb 20 18:43:52 UTC 2014


#5413: Don't query for item counts in profile nav when not needed
--------------------------+------------------
 Reporter:  r-a-y         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  2.0
Component:  Core          |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------

Comment (by boonebgorges):

 Good idea.

 > The only caveat with the patch is if a dev is manually calling the
 profile nav somewhere else that is not a profile page.

 I don't think we really support this anyway - our nav is riddled with
 calls to bp_displayed_user_id(). That said, one way to work around it
 would be to skip adding the counts in those cases:

 {{{
 if ( bp_is_user() ) {
     $count    = bp_get_total_group_count_for_user();
     $class    = ( 0 === $count ) ? 'no-count' : 'count';
     $nav_name = sprintf( __( 'Groups <span class=%s">%s</span>',
 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) );
 } else {
     $nav_name = __( 'Groups', 'buddypress' );
 }
 }}}

 Then, at least, we won't be outputting zeros where a zero would be
 technically incorrect.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5413#comment:2>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list