Ticket #3521: 3521.patch
File 3521.patch, 4.3 KB (added by , 12 years ago) |
---|
-
bp-activity/bp-activity-functions.php
809 809 'exclude' => false, // Comma-separated list of activity IDs to exclude 810 810 'in' => false, // Comma-separated list or array of activity IDs to which you want to limit the query 811 811 'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'. 812 'meta_query' => false, // Activity Meta Query 812 813 813 814 /** 814 815 * Pass filters as an array -- all filter items can be multiple values comma separated: … … 837 838 'filter' => $filter, 838 839 'display_comments' => $display_comments, 839 840 'show_hidden' => $show_hidden, 840 'spam' => $spam 841 'spam' => $spam, 842 'meta_query' => $meta_query, 841 843 ); 842 844 $activity = BP_Activity_Activity::get( $args ); 843 845 wp_cache_set( 'bp_activity_sitewide_front', $activity, 'bp' ); … … 855 857 'show_hidden' => $show_hidden, 856 858 'exclude' => $exclude, 857 859 'in' => $in, 858 'spam' => $spam 860 'spam' => $spam, 861 'meta_query' => $meta_query, 859 862 ); 860 863 $activity = BP_Activity_Activity::get( $args ); 861 864 } -
bp-activity/bp-activity-classes.php
149 149 'display_comments' => false, // Whether to include activity comments 150 150 'show_hidden' => false, // Show items marked hide_sitewide 151 151 'spam' => 'ham_only', // Spam status 152 'meta_query' => false, 152 153 ); 153 154 $r = wp_parse_args( $args, $defaults ); 154 155 extract( $r ); 155 156 156 // Select conditions 157 157 $select_sql = "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name"; 158 158 … … 197 197 $where_conditions['in'] = "a.id IN ({$in})"; 198 198 } 199 199 200 // Meta Query 201 if ( !empty( $meta_query ) ) { 202 $this_meta_query = new WP_Meta_Query( $meta_query ); 203 $wpdb->activitymeta = $bp->activity->table_name_meta; 204 $meta_sql = $this_meta_query->get_sql( 'activity', 'a', 'id' ); 205 $where_conditions['meta_query'] = preg_replace( '/^\sAND/', '', $meta_sql['where'] ); 206 $join_sql = $meta_sql['join']; 207 } else 208 $join_sql = ''; 209 200 210 // Alter the query based on whether we want to show activity item 201 211 // comments in the stream like normal comments or threaded below 202 212 // the activity. … … 228 238 $per_page = absint( $per_page ); 229 239 230 240 $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page ); 231 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$ where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ), $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );241 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ), $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) ); 232 242 } else { 233 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$ where_sql} ORDER BY a.date_recorded {$sort}" ), $select_sql, $from_sql, $where_sql, $sort ) );243 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ), $select_sql, $from_sql, $where_sql, $sort ) ); 234 244 } 235 245 236 $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$ where_sql} ORDER BY a.date_recorded {$sort}" ), $where_sql, $sort );246 $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$index_hint_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ), $where_sql, $sort ); 237 247 238 248 $total_activities = $wpdb->get_var( $total_activities_sql ); 239 249