Skip to:
Content

BuddyPress.org

Changeset 7758


Ignore:
Timestamp:
01/26/2014 02:53:22 PM (11 years ago)
Author:
djpaul
Message:

Navigation: add CSS classes for BP nav bar item counts

Allows themes to show/hide the bubble depending on if there is a count to display.

Fixes #5169, props markoheijnen

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-friends/bp-friends-loader.php

    r7756 r7758  
    113113
    114114        // Add 'Friends' to the main navigation
     115        $count    = friends_get_total_friend_count();
     116        $class    = ( 0 === $count ) ? 'no-count' : 'count';
    115117        $main_nav = array(
    116             'name'                => sprintf( __( 'Friends <span>%d</span>', 'buddypress' ), friends_get_total_friend_count() ),
     118            'name'                => sprintf( __( 'Friends <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) ),
    117119            'slug'                => $this->slug,
    118120            'position'            => 60,
  • trunk/bp-groups/bp-groups-loader.php

    r7756 r7758  
    342342
    343343        // Add 'Groups' to the main navigation
     344        $count    = bp_get_total_group_count_for_user();
     345        $class    = ( 0 === $count ) ? 'no-count' : 'count';
    344346        $main_nav = array(
    345             'name'                => sprintf( __( 'Groups <span>%s</span>', 'buddypress' ), bp_get_total_group_count_for_user() ),
     347            'name'                => sprintf( __( 'Groups <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) ),
    346348            'slug'                => $this->slug,
    347349            'position'            => 70,
  • trunk/bp-messages/bp-messages-loader.php

    r7756 r7758  
    103103    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    104104
    105         $name = sprintf( __( 'Messages <span>%s</span>', 'buddypress' ), bp_get_total_unread_messages_count() );
    106 
    107105        // Add 'Messages' to the main navigation
     106        $count    = bp_get_total_unread_messages_count();
     107        $class    = ( 0 === $count ) ? 'no-count' : 'count';
    108108        $main_nav = array(
    109             'name'                    => $name,
     109            'name'                    => sprintf( __( 'Messages <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) ),
    110110            'slug'                    => $this->slug,
    111111            'position'                => 50,
  • trunk/bp-notifications/bp-notifications-loader.php

    r7756 r7758  
    106106        // Add 'Notifications' to the main navigation
    107107        $count    = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
     108        $class    = ( 0 === $count ) ? 'no-count' : 'count';
    108109        $main_nav = array(
    109             'name'                    => sprintf( __( 'Notifications <span>%d</span>', 'buddypress' ), number_format_i18n( $count ) ),
     110            'name'                    => sprintf( __( 'Notifications <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), number_format_i18n( $count ) ),
    110111            'slug'                    => $this->slug,
    111112            'position'                => 30,
Note: See TracChangeset for help on using the changeset viewer.