diff --git src/bp-activity/bp-activity-admin.php src/bp-activity/bp-activity-admin.php
index 0150595..d4ec34f 100644
|
|
|
class BP_Activity_List_Table extends WP_List_Table {
|
| 1057 | 1057 | 'display_comments' => 'stream', |
| 1058 | 1058 | 'show_hidden' => true, |
| 1059 | 1059 | 'spam' => 'spam_only', |
| | 1060 | 'count_total' => 'count_query', |
| 1060 | 1061 | ) ); |
| 1061 | 1062 | $this->spam_count = $spams['total']; |
| 1062 | 1063 | unset( $spams ); |
| … |
… |
class BP_Activity_List_Table extends WP_List_Table {
|
| 1072 | 1073 | 'show_hidden' => true, |
| 1073 | 1074 | //'sort' => $sort, |
| 1074 | 1075 | 'spam' => $spam, |
| | 1076 | 'count_total' => 'count_query', |
| 1075 | 1077 | ) ); |
| 1076 | 1078 | |
| 1077 | 1079 | // If we're viewing a specific activity, flatten all activites into a single array. |
diff --git src/bp-activity/bp-activity-classes.php src/bp-activity/bp-activity-classes.php
index f1e6054..8881748 100644
|
|
|
class BP_Activity_Activity {
|
| 311 | 311 | 'show_hidden' => false, // Show items marked hide_sitewide |
| 312 | 312 | 'spam' => 'ham_only', // Spam status |
| 313 | 313 | 'update_meta_cache' => true, |
| | 314 | 'count_total' => false, |
| 314 | 315 | ); |
| 315 | 316 | $r = wp_parse_args( $args, $defaults ); |
| 316 | 317 | extract( $r ); |
| … |
… |
class BP_Activity_Activity {
|
| 411 | 412 | $page = absint( $page ); |
| 412 | 413 | $per_page = absint( $per_page ); |
| 413 | 414 | |
| | 415 | $retval = array( |
| | 416 | 'activities' => null, |
| | 417 | 'total' => null, |
| | 418 | 'has_more_items' => null, |
| | 419 | ); |
| | 420 | |
| 414 | 421 | // Filter and return true to use the legacy query structure (not recommended) |
| 415 | 422 | if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) { |
| 416 | 423 | |
| … |
… |
class BP_Activity_Activity {
|
| 431 | 438 | $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}"; |
| 432 | 439 | |
| 433 | 440 | if ( ! empty( $per_page ) && ! empty( $page ) ) { |
| 434 | | $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page ); |
| | 441 | $activity_ids_sql .= $wpdb->prepare( " LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page + 1 ); |
| 435 | 442 | } |
| 436 | 443 | |
| 437 | 444 | $activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r ); |
| 438 | 445 | |
| 439 | 446 | $activity_ids = $wpdb->get_col( $activity_ids_sql ); |
| 440 | | $activities = self::get_activity_data( $activity_ids ); |
| 441 | | } |
| 442 | 447 | |
| 443 | | $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort ); |
| 444 | | $total_activities = $wpdb->get_var( $total_activities_sql ); |
| | 448 | $retval['has_more_items'] = ! empty( $per_page ) && count( $activity_ids ) > $per_page; |
| | 449 | |
| | 450 | // We don't need the last activity id anymore, so we |
| | 451 | // trim it |
| | 452 | array_pop( $activity_ids ); |
| | 453 | |
| | 454 | $activities = self::get_activity_data( $activity_ids ); |
| | 455 | } |
| 445 | 456 | |
| 446 | 457 | // Get the fullnames of users so we don't have to query in the loop |
| 447 | 458 | $activities = self::append_user_fullnames( $activities ); |
| … |
… |
class BP_Activity_Activity {
|
| 465 | 476 | // Generate action strings |
| 466 | 477 | $activities = BP_Activity_Activity::generate_action_strings( $activities ); |
| 467 | 478 | |
| | 479 | $retval['activities'] = $activities; |
| | 480 | |
| 468 | 481 | // If $max is set, only return up to the max results |
| 469 | | if ( !empty( $max ) ) { |
| 470 | | if ( (int) $total_activities > (int) $max ) |
| 471 | | $total_activities = $max; |
| | 482 | if ( false !== $r['count_total'] ) { |
| | 483 | |
| | 484 | $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort ); |
| | 485 | $total_activities = $wpdb->get_var( $total_activities_sql ); |
| | 486 | |
| | 487 | if ( !empty( $max ) ) { |
| | 488 | if ( (int) $total_activities > (int) $max ) |
| | 489 | $total_activities = $max; |
| | 490 | } |
| | 491 | |
| | 492 | $retval['total'] = $total_activities; |
| 472 | 493 | } |
| 473 | 494 | |
| 474 | | return array( 'activities' => $activities, 'total' => (int) $total_activities ); |
| | 495 | return $retval; |
| 475 | 496 | } |
| 476 | 497 | |
| 477 | 498 | /** |
diff --git src/bp-activity/bp-activity-functions.php src/bp-activity/bp-activity-functions.php
index 507387e..3454cf0 100644
|
|
|
function bp_activity_get( $args = '' ) {
|
| 963 | 963 | 'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query |
| 964 | 964 | 'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'. |
| 965 | 965 | 'update_meta_cache' => true, |
| | 966 | 'count_total' => false, |
| 966 | 967 | |
| 967 | 968 | /** |
| 968 | 969 | * Pass filters as an array -- all filter items can be multiple values comma separated: |
| … |
… |
function bp_activity_get( $args = '' ) {
|
| 994 | 995 | 'show_hidden' => $show_hidden, |
| 995 | 996 | 'spam' => $spam, |
| 996 | 997 | 'update_meta_cache' => $update_meta_cache, |
| | 998 | 'count_total' => $count_total, |
| 997 | 999 | ); |
| 998 | 1000 | $activity = BP_Activity_Activity::get( $args ); |
| 999 | 1001 | wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); |
| … |
… |
function bp_activity_get( $args = '' ) {
|
| 1012 | 1014 | 'show_hidden' => $show_hidden, |
| 1013 | 1015 | 'exclude' => $exclude, |
| 1014 | 1016 | 'in' => $in, |
| 1015 | | 'spam' => $spam |
| | 1017 | 'spam' => $spam, |
| | 1018 | 'count_total' => $count_total, |
| 1016 | 1019 | ); |
| 1017 | 1020 | $activity = BP_Activity_Activity::get( $args ); |
| 1018 | 1021 | } |
diff --git src/bp-activity/bp-activity-template.php src/bp-activity/bp-activity-template.php
index 0a7ceeb..142f6e5 100644
|
|
|
class BP_Activity_Template {
|
| 220 | 220 | ) ); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | | if ( !$max || $max >= (int) $this->activities['total'] ) |
| 224 | | $this->total_activity_count = (int) $this->activities['total']; |
| 225 | | else |
| 226 | | $this->total_activity_count = (int) $max; |
| | 223 | if ( ! is_null( $this->activities['total'] ) ) { |
| | 224 | if ( !$max || $max >= (int) $this->activities['total'] ) |
| | 225 | $this->total_activity_count = (int) $this->activities['total']; |
| | 226 | else |
| | 227 | $this->total_activity_count = (int) $max; |
| | 228 | } |
| | 229 | |
| | 230 | $this->has_more_items = $this->activities['has_more_items']; |
| 227 | 231 | |
| 228 | 232 | $this->activities = $this->activities['activities']; |
| 229 | 233 | |
| … |
… |
function bp_activity_pagination_links() {
|
| 778 | 782 | function bp_activity_has_more_items() { |
| 779 | 783 | global $activities_template; |
| 780 | 784 | |
| 781 | | $remaining_pages = 0; |
| | 785 | if ( ! empty( $activities_template->has_more_items ) ) { |
| | 786 | $has_more_items = true; |
| | 787 | } else { |
| | 788 | $remaining_pages = 0; |
| 782 | 789 | |
| 783 | | if ( ! empty( $activities_template->pag_page ) ) { |
| 784 | | $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) ); |
| 785 | | } |
| | 790 | if ( ! empty( $activities_template->pag_page ) ) { |
| | 791 | $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) ); |
| | 792 | } |
| 786 | 793 | |
| 787 | | $has_more_items = (int) $remaining_pages ? true : false; |
| | 794 | $has_more_items = (int) $remaining_pages ? true : false; |
| | 795 | } |
| 788 | 796 | |
| 789 | 797 | return apply_filters( 'bp_activity_has_more_items', $has_more_items ); |
| 790 | 798 | } |