Changeset 4480 for trunk/includes/common/functions.php
- Timestamp:
- 11/23/2012 10:50:13 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/includes/common/functions.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/common/functions.php
r4361 r4480 244 244 245 245 // Are we appending the view=all vars? 246 if ( bbp_get_view_all() || !empty( $force ) ) 246 if ( bbp_get_view_all() || !empty( $force ) ) { 247 247 $link = add_query_arg( array( 'view' => 'all' ), $original_link ); 248 else248 } else { 249 249 $link = $original_link; 250 } 250 251 251 252 return apply_filters( 'bbp_add_view_all', $link, $original_link ); … … 430 431 function bbp_get_statistics( $args = '' ) { 431 432 432 $defaults = array ( 433 // Parse arguments 434 $r = bbp_parse_args( $args, array( 433 435 'count_users' => true, 434 436 'count_forums' => true, … … 443 445 'count_tags' => true, 444 446 'count_empty_tags' => true 445 ); 446 $r = bbp_parse_args( $args, $defaults, 'get_statistics' ); 447 extract( $r ); 447 ), 'get_statistics' ); 448 449 // Defaults 450 $user_count = 0; 451 $forum_count = 0; 452 $topic_count = 0; 453 $topic_count_hidden = 0; 454 $reply_count = 0; 455 $reply_count_hidden = 0; 456 $topic_tag_count = 0; 457 $empty_topic_tag_count = 0; 448 458 449 459 // Users 450 if ( !empty( $ count_users ) )460 if ( !empty( $r['count_users'] ) ) { 451 461 $user_count = bbp_get_total_users(); 462 } 452 463 453 464 // Forums 454 if ( !empty( $count_forums ) ) { 455 $forum_count = wp_count_posts( bbp_get_forum_post_type() ); 456 $forum_count = $forum_count->publish; 465 if ( !empty( $r['count_forums'] ) ) { 466 $forum_count = wp_count_posts( bbp_get_forum_post_type() )->publish; 457 467 } 458 468 … … 464 474 465 475 // Topics 466 if ( !empty( $count_topics ) ) { 467 476 if ( !empty( $r['count_topics'] ) ) { 468 477 $all_topics = wp_count_posts( bbp_get_topic_post_type() ); 469 478 … … 474 483 475 484 // Private 476 $topics['private'] = ( !empty( $ count_private_topics) && current_user_can( 'read_private_topics' ) ) ? (int) $all_topics->{$private} : 0;485 $topics['private'] = ( !empty( $r['count_private_topics'] ) && current_user_can( 'read_private_topics' ) ) ? (int) $all_topics->{$private} : 0; 477 486 478 487 // Spam 479 $topics['spammed'] = ( !empty( $ count_spammed_topics) && current_user_can( 'edit_others_topics' ) ) ? (int) $all_topics->{$spam} : 0;488 $topics['spammed'] = ( !empty( $r['count_spammed_topics'] ) && current_user_can( 'edit_others_topics' ) ) ? (int) $all_topics->{$spam} : 0; 480 489 481 490 // Trash 482 $topics['trashed'] = ( !empty( $ count_trashed_topics) && current_user_can( 'view_trash' ) ) ? (int) $all_topics->{$trash} : 0;491 $topics['trashed'] = ( !empty( $r['count_trashed_topics'] ) && current_user_can( 'view_trash' ) ) ? (int) $all_topics->{$trash} : 0; 483 492 484 493 // Total hidden (private + spam + trash) … … 496 505 497 506 // Replies 498 if ( !empty( $ count_replies) ) {507 if ( !empty( $r['count_replies'] ) ) { 499 508 500 509 $all_replies = wp_count_posts( bbp_get_reply_post_type() ); … … 506 515 507 516 // Private 508 $replies['private'] = ( !empty( $ count_private_replies) && current_user_can( 'read_private_replies' ) ) ? (int) $all_replies->{$private} : 0;517 $replies['private'] = ( !empty( $r['count_private_replies'] ) && current_user_can( 'read_private_replies' ) ) ? (int) $all_replies->{$private} : 0; 509 518 510 519 // Spam 511 $replies['spammed'] = ( !empty( $ count_spammed_replies) && current_user_can( 'edit_others_replies' ) ) ? (int) $all_replies->{$spam} : 0;520 $replies['spammed'] = ( !empty( $r['count_spammed_replies'] ) && current_user_can( 'edit_others_replies' ) ) ? (int) $all_replies->{$spam} : 0; 512 521 513 522 // Trash 514 $replies['trashed'] = ( !empty( $ count_trashed_replies) && current_user_can( 'view_trash' ) ) ? (int) $all_replies->{$trash} : 0;523 $replies['trashed'] = ( !empty( $r['count_trashed_replies'] ) && current_user_can( 'view_trash' ) ) ? (int) $all_replies->{$trash} : 0; 515 524 516 525 // Total hidden (private + spam + trash) … … 529 538 530 539 // Topic Tags 531 if ( !empty( $ count_tags) && bbp_allow_topic_tags() ) {540 if ( !empty( $r['count_tags'] ) && bbp_allow_topic_tags() ) { 532 541 533 542 // Get the count … … 535 544 536 545 // Empty tags 537 if ( !empty( $ count_empty_tags) && current_user_can( 'edit_topic_tags' ) ) {546 if ( !empty( $r['count_empty_tags'] ) && current_user_can( 'edit_topic_tags' ) ) { 538 547 $empty_topic_tag_count = wp_count_terms( bbp_get_topic_tag_tax_id() ) - $topic_tag_count; 539 548 } … … 541 550 542 551 // Tally the tallies 543 $statistics = compact( 'user_count', 'forum_count', 'topic_count', 'topic_count_hidden', 'reply_count', 'reply_count_hidden', 'topic_tag_count', 'empty_topic_tag_count' ); 544 $statistics = array_map( 'absint', $statistics ); 545 $statistics = array_map( 'number_format_i18n', $statistics ); 546 552 $statistics = array_map( 'number_format_i18n', array_map( 'absint', array( 553 $user_count, 554 $forum_count, 555 $topic_count, 556 $topic_count_hidden, 557 $reply_count, 558 $reply_count_hidden, 559 $topic_tag_count, 560 $empty_topic_tag_count 561 ) ) ); 562 547 563 // Add the hidden (topic/reply) count title attribute strings because we don't need to run the math functions on these (see above) 548 564 if ( isset( $hidden_topic_title ) )
Note: See TracChangeset
for help on using the changeset viewer.