Skip to:
Content

bbPress.org

Changeset 6055


Ignore:
Timestamp:
06/05/2016 02:21:41 AM (6 years ago)
Author:
netweb
Message:

General - Administration: Add pending status topic and reply statistics to bbp_get_statistics()

Following the introduction of "pending" status topics and replies in bbPress 2.6, bbp_get_statistics() now includes these count statistics in the hidden topic and reply statistics.

Fixes #2958.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r6050 r6055  
    417417 *
    418418 * @since 2.0.0 bbPress (r2769)
     419 * @since 2.6.0 bbPress (r6055) Introduced the `count_pending_topics` and
     420 *                               `count_pending_replies` arguments.
    419421 *
    420422 * @param array $args Optional. The function supports these arguments (all
     
    424426 *  - count_topics: Count topics? If set to false, private, spammed and trashed
    425427 *                   topics are also not counted.
     428 *  - count_pending_topics: Count pending topics? (only counted if the current
     429 *                           user has edit_others_topics cap)
    426430 *  - count_private_topics: Count private topics? (only counted if the current
    427431 *                           user has read_private_topics cap)
     
    432436 *  - count_replies: Count replies? If set to false, private, spammed and
    433437 *                   trashed replies are also not counted.
     438 *  - count_pending_replies: Count pending replies? (only counted if the current
     439 *                           user has edit_others_replies cap)
    434440 *  - count_private_replies: Count private replies? (only counted if the current
    435441 *                           user has read_private_replies cap)
     
    440446 *  - count_tags: Count tags? If set to false, empty tags are also not counted
    441447 *  - count_empty_tags: Count empty tags?
    442  * @uses bbp_count_users() To count the number of registered users
     448 * @uses bbp_get_total_users() To count the number of registered users
    443449 * @uses bbp_get_forum_post_type() To get the forum post type
    444450 * @uses bbp_get_topic_post_type() To get the topic post type
     
    458464        'count_forums'          => true,
    459465        'count_topics'          => true,
     466        'count_pending_topics'  => true,
    460467        'count_private_topics'  => true,
    461468        'count_spammed_topics'  => true,
    462469        'count_trashed_topics'  => true,
    463470        'count_replies'         => true,
     471        'count_pending_replies' => true,
    464472        'count_private_replies' => true,
    465473        'count_spammed_replies' => true,
     
    490498
    491499    // Post statuses
     500    $pending = bbp_get_pending_status_id();
    492501    $private = bbp_get_private_status_id();
    493502    $spam    = bbp_get_spam_status_id();
     
    504513        if ( current_user_can( 'read_private_topics' ) || current_user_can( 'edit_others_topics' ) || current_user_can( 'view_trash' ) ) {
    505514
     515            // Pending
     516            $topics['pending'] = ( ! empty( $r['count_pending_topics'] ) && current_user_can( 'edit_others_topics' ) ) ? (int) $all_topics->{$pending} : 0;
     517
    506518            // Private
    507519            $topics['private'] = ( ! empty( $r['count_private_topics'] ) && current_user_can( 'read_private_topics' ) ) ? (int) $all_topics->{$private} : 0;
     
    514526
    515527            // Total hidden (private + spam + trash)
    516             $topic_count_hidden = $topics['private'] + $topics['spammed'] + $topics['trashed'];
     528            $topic_count_hidden = $topics['pending'] + $topics['private'] + $topics['spammed'] + $topics['trashed'];
    517529
    518530            // Generate the hidden topic count's title attribute
     531            $topic_titles[] = ! empty( $topics['pending'] ) ? sprintf( __( 'Pending: %s', 'bbpress' ), number_format_i18n( $topics['pending'] ) ) : '';
    519532            $topic_titles[] = ! empty( $topics['private'] ) ? sprintf( __( 'Private: %s', 'bbpress' ), number_format_i18n( $topics['private'] ) ) : '';
    520533            $topic_titles[] = ! empty( $topics['spammed'] ) ? sprintf( __( 'Spammed: %s', 'bbpress' ), number_format_i18n( $topics['spammed'] ) ) : '';
     
    536549        if ( current_user_can( 'read_private_replies' ) || current_user_can( 'edit_others_replies' ) || current_user_can( 'view_trash' ) ) {
    537550
     551            // Pending
     552            $replies['pending'] = ( ! empty( $r['count_pending_replies'] ) && current_user_can( 'edit_others_replies' ) ) ? (int) $all_replies->{$pending} : 0;
     553
    538554            // Private
    539555            $replies['private'] = ( ! empty( $r['count_private_replies'] ) && current_user_can( 'read_private_replies' ) ) ? (int) $all_replies->{$private} : 0;
     
    546562
    547563            // Total hidden (private + spam + trash)
    548             $reply_count_hidden = $replies['private'] + $replies['spammed'] + $replies['trashed'];
     564            $reply_count_hidden = $replies['pending'] + $replies['private'] + $replies['spammed'] + $replies['trashed'];
    549565
    550566            // Generate the hidden topic count's title attribute
     567            $reply_titles[] = ! empty( $replies['pending'] ) ? sprintf( __( 'Pending: %s', 'bbpress' ), number_format_i18n( $replies['pending'] ) ) : '';
    551568            $reply_titles[] = ! empty( $replies['private'] ) ? sprintf( __( 'Private: %s', 'bbpress' ), number_format_i18n( $replies['private'] ) ) : '';
    552569            $reply_titles[] = ! empty( $replies['spammed'] ) ? sprintf( __( 'Spammed: %s', 'bbpress' ), number_format_i18n( $replies['spammed'] ) ) : '';
Note: See TracChangeset for help on using the changeset viewer.