Skip to:
Content

bbPress.org

Changeset 6227


Ignore:
Timestamp:
01/12/2017 11:21:05 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Akismet: Improve pluralization of statistics strings.

Fixes #2960. Props thebrandonallen, netweb.

Location:
trunk/src/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/metaboxes.php

    r6200 r6227  
    2626    if ( current_user_can( 'publish_forums' ) ) {
    2727        $link       = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null, 'edit.php' ) );
    28         $text       = sprintf( _n( '%s Forum', '%s Forums', $r['forum_count'], 'bbpress' ), $r['forum_count'] );
     28        $text       = sprintf( _n( '%s Forum', '%s Forums', $r['forum_count_int'], 'bbpress' ), $r['forum_count'] );
    2929        $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-forums">' . esc_html( $text ) . '</a>';
    3030    }
     
    3333    if ( current_user_can( 'publish_topics' ) ) {
    3434        $link       = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) );
    35         $text       = sprintf( _n( '%s Topic', '%s Topics', $r['topic_count'], 'bbpress' ), $r['topic_count'] );
     35        $text       = sprintf( _n( '%s Topic', '%s Topics', $r['topic_count_int'], 'bbpress' ), $r['topic_count'] );
    3636        $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-topics">' . esc_html( $text ) . '</a>';
    3737    }
     
    4040    if ( current_user_can( 'publish_replies' ) ) {
    4141        $link       = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) );
    42         $text       = sprintf( _n( '%s Reply', '%s Replies', $r['reply_count'], 'bbpress' ), $r['reply_count'] );
     42        $text       = sprintf( _n( '%s Reply', '%s Replies', $r['reply_count_int'], 'bbpress' ), $r['reply_count'] );
    4343        $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-replies">' . esc_html( $text ) . '</a>';
    4444    }
     
    4747    if ( bbp_allow_topic_tags() && current_user_can( 'manage_topic_tags' ) ) {
    4848        $link       = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
    49         $text       = sprintf( _n( '%s Topic Tag', '%s Topic Tags', $r['topic_tag_count'], 'bbpress' ), $r['topic_tag_count'] );
     49        $text       = sprintf( _n( '%s Topic Tag', '%s Topic Tags', $r['topic_tag_count_int'], 'bbpress' ), $r['topic_tag_count'] );
    5050        $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-topic-tags">' . esc_html( $text ) . '</a>';
    5151    }
     
    9595                <?php
    9696                    $num  = $r['forum_count'];
    97                     $text = _n( 'Forum', 'Forums', $r['forum_count'], 'bbpress' );
     97                    $text = _n( 'Forum', 'Forums', $r['forum_count_int'], 'bbpress' );
    9898                    if ( current_user_can( 'publish_forums' ) ) {
    9999                        $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null, 'edit.php' ) );
     
    112112                <?php
    113113                    $num  = $r['topic_count'];
    114                     $text = _n( 'Topic', 'Topics', $r['topic_count'], 'bbpress' );
     114                    $text = _n( 'Topic', 'Topics', $r['topic_count_int'], 'bbpress' );
    115115                    if ( current_user_can( 'publish_topics' ) ) {
    116116                        $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) );
     
    129129                <?php
    130130                    $num  = $r['reply_count'];
    131                     $text = _n( 'Reply', 'Replies', $r['reply_count'], 'bbpress' );
     131                    $text = _n( 'Reply', 'Replies', $r['reply_count_int'], 'bbpress' );
    132132                    if ( current_user_can( 'publish_replies' ) ) {
    133133                        $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) );
     
    148148                    <?php
    149149                        $num  = $r['topic_tag_count'];
    150                         $text = _n( 'Topic Tag', 'Topic Tags', $r['topic_tag_count'], 'bbpress' );
     150                        $text = _n( 'Topic Tag', 'Topic Tags', $r['topic_tag_count_int'], 'bbpress' );
    151151                        if ( current_user_can( 'manage_topic_tags' ) ) {
    152152                            $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
     
    180180                <?php
    181181                    $num  = $r['user_count'];
    182                     $text = _n( 'User', 'Users', $r['user_count'], 'bbpress' );
     182                    $text = _n( 'User', 'Users', $r['user_count_int'], 'bbpress' );
    183183                    if ( current_user_can( 'edit_users' ) ) {
    184184                        $link = get_admin_url( null, 'users.php' );
     
    199199                    <?php
    200200                        $num  = $r['topic_count_hidden'];
    201                         $text = _n( 'Hidden Topic', 'Hidden Topics', $r['topic_count_hidden'], 'bbpress' );
     201                        $text = _n( 'Hidden Topic', 'Hidden Topics', $r['topic_count_hidden_int'], 'bbpress' );
    202202                        $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) );
    203203                        if ( '0' !== $num ) {
     
    221221                    <?php
    222222                        $num  = $r['reply_count_hidden'];
    223                         $text = _n( 'Hidden Reply', 'Hidden Replies', $r['reply_count_hidden'], 'bbpress' );
     223                        $text = _n( 'Hidden Reply', 'Hidden Replies', $r['reply_count_hidden_int'], 'bbpress' );
    224224                        $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) );
    225225                        if ( '0' !== $num ) {
     
    243243                    <?php
    244244                        $num  = $r['empty_topic_tag_count'];
    245                         $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $r['empty_topic_tag_count'], 'bbpress' );
     245                        $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $r['empty_topic_tag_count_int'], 'bbpress' );
    246246                        $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
    247247                        $num  = '<a href="' . esc_url( $link ) . '">' . $num  . '</a>';
  • trunk/src/includes/common/functions.php

    r6219 r6227  
    453453 * @uses wp_count_terms() To count the number of topic tags
    454454 * @uses current_user_can() To check if the user is capable of doing things
    455  * @uses number_format_i18n() To format the number
     455 * @uses bbp_number_format_i18n() To format the number
    456456 * @uses apply_filters() Calls 'bbp_get_statistics' with the statistics and args
    457457 * @return object Walked forum tree
     
    528528            $topics['trashed'] = ( ! empty( $r['count_trashed_topics'] ) && current_user_can( 'view_trash'          ) ) ? (int) $all_topics->{$trash}   : 0;
    529529
    530             // Total hidden (private + spam + trash)
     530            // Total hidden (pending + private + spam + trash)
    531531            $topic_count_hidden = $topics['pending'] + $topics['private'] + $topics['spammed'] + $topics['trashed'];
    532532
    533533            // Generate the hidden topic count's title attribute
    534             $topic_titles[] = ! empty( $topics['pending'] ) ? sprintf( __( 'Pending: %s', 'bbpress' ), number_format_i18n( $topics['pending'] ) ) : '';
    535             $topic_titles[] = ! empty( $topics['private'] ) ? sprintf( __( 'Private: %s', 'bbpress' ), number_format_i18n( $topics['private'] ) ) : '';
    536             $topic_titles[] = ! empty( $topics['spammed'] ) ? sprintf( __( 'Spammed: %s', 'bbpress' ), number_format_i18n( $topics['spammed'] ) ) : '';
    537             $topic_titles[] = ! empty( $topics['trashed'] ) ? sprintf( __( 'Trashed: %s', 'bbpress' ), number_format_i18n( $topics['trashed'] ) ) : '';
     534            $topic_titles[] = ! empty( $topics['pending'] ) ? sprintf( __( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $topics['pending'] ) ) : '';
     535            $topic_titles[] = ! empty( $topics['private'] ) ? sprintf( __( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics['private'] ) ) : '';
     536            $topic_titles[] = ! empty( $topics['spammed'] ) ? sprintf( __( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['spammed'] ) ) : '';
     537            $topic_titles[] = ! empty( $topics['trashed'] ) ? sprintf( __( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $topics['trashed'] ) ) : '';
    538538
    539539            // Compile the hidden topic title
     
    567567            $replies['trashed'] = ( ! empty( $r['count_trashed_replies'] ) && current_user_can( 'view_trash'           ) ) ? (int) $all_replies->{$trash}   : 0;
    568568
    569             // Total hidden (private + spam + trash)
     569            // Total hidden (pending + private + spam + trash)
    570570            $reply_count_hidden = $replies['pending'] + $replies['private'] + $replies['spammed'] + $replies['trashed'];
    571571
    572572            // Generate the hidden topic count's title attribute
    573             $reply_titles[] = ! empty( $replies['pending'] ) ? sprintf( __( 'Pending: %s', 'bbpress' ), number_format_i18n( $replies['pending'] ) ) : '';
    574             $reply_titles[] = ! empty( $replies['private'] ) ? sprintf( __( 'Private: %s', 'bbpress' ), number_format_i18n( $replies['private'] ) ) : '';
    575             $reply_titles[] = ! empty( $replies['spammed'] ) ? sprintf( __( 'Spammed: %s', 'bbpress' ), number_format_i18n( $replies['spammed'] ) ) : '';
    576             $reply_titles[] = ! empty( $replies['trashed'] ) ? sprintf( __( 'Trashed: %s', 'bbpress' ), number_format_i18n( $replies['trashed'] ) ) : '';
     573            $reply_titles[] = ! empty( $replies['pending'] ) ? sprintf( __( 'Pending: %s', 'bbpress' ), bbp_number_format_i18n( $replies['pending'] ) ) : '';
     574            $reply_titles[] = ! empty( $replies['private'] ) ? sprintf( __( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies['private'] ) ) : '';
     575            $reply_titles[] = ! empty( $replies['spammed'] ) ? sprintf( __( 'Spammed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['spammed'] ) ) : '';
     576            $reply_titles[] = ! empty( $replies['trashed'] ) ? sprintf( __( 'Trashed: %s', 'bbpress' ), bbp_number_format_i18n( $replies['trashed'] ) ) : '';
    577577
    578578            // Compile the hidden replies title
     
    594594
    595595    // Tally the tallies
    596     $statistics = array_map( 'number_format_i18n', array_map( 'absint', compact(
     596    $counts = array_map( 'absint', compact(
    597597        'user_count',
    598598        'forum_count',
     
    603603        'topic_tag_count',
    604604        'empty_topic_tag_count'
    605     ) ) );
     605    ) );
     606
     607    // Loop through and store the integer and i18n formatted counts.
     608    foreach ( $counts as $key => $count ) {
     609        $statistics[ $key ]         = bbp_number_format_i18n( $count );
     610        $statistics[ "{$key}_int" ] = $count;
     611    }
    606612
    607613    // Add the hidden (topic/reply) count title attribute strings because we
Note: See TracChangeset for help on using the changeset viewer.