Skip to:
Content

BuddyPress.org

Changeset 7520


Ignore:
Timestamp:
11/07/2013 03:10:11 PM (12 years ago)
Author:
boonebgorges
Message:

Improvements to i18n number formatting in activity count functions/templates

This changeset makes number formatting more consistent in the activity
templates of bp-legacy. The logic is as follows:

  • Move all number formatting out of the templates and into the relevant -template.php file.
  • Add number formatting to those _count() template functions that were missing it.
  • Clean up sprintf() swapping arguments to account for string vs int number formats

See #4997, #5228

Fixes #5231

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-template.php

    r7513 r7520  
    26532653        return apply_filters( 'bp_get_total_favorite_count_for_user', bp_activity_total_favorites_for_user( $user_id ) );
    26542654    }
     2655    add_filter( 'bp_get_total_favorite_count_for_user', 'bp_core_number_format' );
    26552656
    26562657/**
     
    26862687        return apply_filters( 'bp_get_total_mention_count_for_user', bp_get_user_meta( $user_id, 'bp_new_mention_count', true ) );
    26872688    }
     2689    add_filter( 'bp_get_total_mention_count_for_user', 'bp_core_number_format' );
    26882690
    26892691/**
  • trunk/bp-core/bp-core-template.php

    r7516 r7520  
    648648        return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() );
    649649    }
     650    add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
    650651
    651652/**
  • trunk/bp-groups/bp-groups-loader.php

    r7454 r7520  
    343343        // Add 'Groups' to the main navigation
    344344        $main_nav = array(
    345             'name'                => sprintf( __( 'Groups <span>%d</span>', 'buddypress' ), bp_get_total_group_count_for_user() ),
     345            'name'                => sprintf( __( 'Groups <span>%s</span>', 'buddypress' ), bp_get_total_group_count_for_user() ),
    346346            'slug'                => $this->slug,
    347347            'position'            => 70,
  • trunk/bp-groups/bp-groups-template.php

    r7513 r7520  
    18971897        return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ), $user_id );
    18981898    }
     1899    add_filter( 'bp_get_total_group_count_for_user', 'bp_core_number_format' );
    18991900
    19001901
  • trunk/bp-templates/bp-legacy/buddypress/activity/index.php

    r7193 r7520  
    1717            <?php do_action( 'bp_before_activity_type_tab_all' ); ?>
    1818
    19             <li class="selected" id="activity-all"><a href="<?php bp_activity_directory_permalink(); ?>" title="<?php _e( 'The public activity for everyone on this site.', 'buddypress' ); ?>"><?php printf( __( 'All Members <span>%s</span>', 'buddypress' ), number_format_i18n( bp_get_total_member_count() ) ); ?></a></li>
     19            <li class="selected" id="activity-all"><a href="<?php bp_activity_directory_permalink(); ?>" title="<?php _e( 'The public activity for everyone on this site.', 'buddypress' ); ?>"><?php printf( __( 'All Members <span>%s</span>', 'buddypress' ), bp_get_total_member_count() ); ?></a></li>
    2020
    2121            <?php if ( is_user_logged_in() ) : ?>
     
    2727                    <?php if ( bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?>
    2828
    29                         <li id="activity-friends"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/'; ?>" title="<?php _e( 'The activity of my friends only.', 'buddypress' ); ?>"><?php printf( __( 'My Friends <span>%s</span>', 'buddypress' ), number_format_i18n( bp_get_total_friend_count( bp_loggedin_user_id() ) ) ); ?></a></li>
     29                        <li id="activity-friends"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/'; ?>" title="<?php _e( 'The activity of my friends only.', 'buddypress' ); ?>"><?php printf( __( 'My Friends <span>%s</span>', 'buddypress' ), bp_get_total_friend_count( bp_loggedin_user_id() ) ); ?></a></li>
    3030
    3131                    <?php endif; ?>
     
    3939                    <?php if ( bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) : ?>
    4040
    41                         <li id="activity-groups"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/'; ?>" title="<?php _e( 'The activity of groups I am a member of.', 'buddypress' ); ?>"><?php printf( __( 'My Groups <span>%s</span>', 'buddypress' ), number_format_i18n( bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) ); ?></a></li>
     41                        <li id="activity-groups"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/'; ?>" title="<?php _e( 'The activity of groups I am a member of.', 'buddypress' ); ?>"><?php printf( __( 'My Groups <span>%s</span>', 'buddypress' ), bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ); ?></a></li>
    4242
    4343                    <?php endif; ?>
     
    4949                <?php if ( bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ) : ?>
    5050
    51                     <li id="activity-favorites"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/favorites/'; ?>" title="<?php _e( "The activity I've marked as a favorite.", 'buddypress' ); ?>"><?php printf( __( 'My Favorites <span>%s</span>', 'buddypress' ), number_format_i18n( bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ) ); ?></a></li>
     51                    <li id="activity-favorites"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/favorites/'; ?>" title="<?php _e( "The activity I've marked as a favorite.", 'buddypress' ); ?>"><?php printf( __( 'My Favorites <span>%s</span>', 'buddypress' ), bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ); ?></a></li>
    5252
    5353                <?php endif; ?>
     
    5757                    <?php do_action( 'bp_before_activity_type_tab_mentions' ); ?>
    5858
    59                     <li id="activity-mentions"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/'; ?>" title="<?php _e( 'Activity that I have been mentioned in.', 'buddypress' ); ?>"><?php _e( 'Mentions', 'buddypress' ); ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><span><?php printf( _nx( '%s new', '%s new', bp_get_total_mention_count_for_user( bp_loggedin_user_id() ), 'Number of new activity mentions', 'buddypress' ), number_format_i18n( bp_get_total_mention_count_for_user( bp_loggedin_user_id()  )) ); ?></span></strong><?php endif; ?></a></li>
     59                    <li id="activity-mentions"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/'; ?>" title="<?php _e( 'Activity that I have been mentioned in.', 'buddypress' ); ?>"><?php _e( 'Mentions', 'buddypress' ); ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><span><?php printf( _nx( '%s new', '%s new', bp_get_total_mention_count_for_user( bp_loggedin_user_id() ), 'Number of new activity mentions', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ); ?></span></strong><?php endif; ?></a></li>
    6060
    6161                <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.