diff --git src/bp-activity/bp-activity-template.php src/bp-activity/bp-activity-template.php
index 8165d22ca..60efa8762 100644
|
|
function bp_has_activities( $args = '' ) { |
272 | 272 | 'primary_id' => $primary_id, // Object ID to filter on e.g. a group_id or blog_id etc. |
273 | 273 | 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id. |
274 | 274 | 'offset' => false, // Return only items >= this ID. |
| 275 | 'offset_lower' => false, // Return only items < this ID. |
275 | 276 | 'since' => false, // Return only items recorded since this Y-m-d H:i:s date. |
276 | 277 | |
277 | 278 | 'meta_query' => false, // Filter on activity meta. See WP_Meta_Query for format. |
… |
… |
function bp_has_activities( $args = '' ) { |
326 | 327 | $r['filter'] = array( |
327 | 328 | 'object' => $_GET['afilter'] |
328 | 329 | ); |
329 | | } elseif ( ! empty( $r['user_id'] ) || ! empty( $r['object'] ) || ! empty( $r['action'] ) || ! empty( $r['primary_id'] ) || ! empty( $r['secondary_id'] ) || ! empty( $r['offset'] ) || ! empty( $r['since'] ) ) { |
| 330 | } elseif ( ! empty( $r['user_id'] ) || ! empty( $r['object'] ) || ! empty( $r['action'] ) || ! empty( $r['primary_id'] ) || ! empty( $r['secondary_id'] ) || ! empty( $r['offset'] ) || ! empty( $r['offset_lower'] ) || ! empty( $r['since'] ) ) { |
330 | 331 | $r['filter'] = array( |
331 | 332 | 'user_id' => $r['user_id'], |
332 | 333 | 'object' => $r['object'], |
… |
… |
function bp_has_activities( $args = '' ) { |
334 | 335 | 'primary_id' => $r['primary_id'], |
335 | 336 | 'secondary_id' => $r['secondary_id'], |
336 | 337 | 'offset' => $r['offset'], |
| 338 | 'offset_lower' => $r['offset_lower'], |
337 | 339 | 'since' => $r['since'] |
338 | 340 | ); |
339 | 341 | } else { |
… |
… |
function bp_activity_load_more_link() { |
410 | 412 | function bp_get_activity_load_more_link() { |
411 | 413 | global $activities_template; |
412 | 414 | |
413 | | $url = bp_get_requested_url(); |
414 | | $link = add_query_arg( $activities_template->pag_arg, $activities_template->pag_page + 1, $url ); |
| 415 | $url = bp_get_requested_url(); |
| 416 | $load_more_args = array( |
| 417 | $activities_template->pag_arg => $activities_template->pag_page + 1, |
| 418 | ); |
| 419 | |
| 420 | // Try to include the offset arg. |
| 421 | $last_displayed_activity = reset( $activities_template->activities ); |
| 422 | if ( isset( $last_displayed_activity->id ) && $last_displayed_activity->id ) { |
| 423 | $load_more_args['offset_lower'] = (int) $last_displayed_activity->id; |
| 424 | } |
| 425 | |
| 426 | $link = add_query_arg( $load_more_args, $url ); |
415 | 427 | |
416 | 428 | /** |
417 | 429 | * Filters the Load More link URL. |
diff --git src/bp-activity/classes/class-bp-activity-activity.php src/bp-activity/classes/class-bp-activity-activity.php
index 708f9a739..7a709d3a0 100644
|
|
class BP_Activity_Activity { |
1868 | 1868 | * 'secondary_item_id' column in the database. |
1869 | 1869 | * @type int $offset Return only those items with an ID greater |
1870 | 1870 | * than the offset value. |
| 1871 | * @type int $offset_lower Return only those items with an ID lower |
| 1872 | * than the offset value. |
1871 | 1873 | * @type string $since Return only those items that have a |
1872 | 1874 | * date_recorded value greater than a |
1873 | 1875 | * given MySQL-formatted date. |
… |
… |
class BP_Activity_Activity { |
1913 | 1915 | $filter_sql[] = "a.id >= {$sid_sql}"; |
1914 | 1916 | } |
1915 | 1917 | |
| 1918 | if ( ! empty( $filter_array['offset_lower'] ) ) { |
| 1919 | $sid_sql = absint( $filter_array['offset_lower'] ); |
| 1920 | $filter_sql[] = "a.id < {$sid_sql}"; |
| 1921 | } |
| 1922 | |
1916 | 1923 | if ( ! empty( $filter_array['since'] ) ) { |
1917 | 1924 | // Validate that this is a proper Y-m-d H:i:s date. |
1918 | 1925 | // Trick: parse to UNIX date then translate back. |
diff --git src/bp-templates/bp-nouveau/includes/functions.php src/bp-templates/bp-nouveau/includes/functions.php
index 3e6bb22b1..88c845e89 100644
|
|
function bp_nouveau_ajax_querystring( $query_string, $object ) { |
117 | 117 | $qs[] = 'offset=' . intval( $post_query['offset'] ); |
118 | 118 | } |
119 | 119 | |
| 120 | if ( ! empty( $post_query['offset_lower'] ) ) { |
| 121 | $qs[] = 'offset_lower=' . intval( $post_query['offset_lower'] ); |
| 122 | } |
| 123 | |
120 | 124 | $object_search_text = bp_get_search_default_text( $object ); |
121 | 125 | if ( ! empty( $post_query['search_terms'] ) && $object_search_text != $post_query['search_terms'] && 'false' != $post_query['search_terms'] && 'undefined' != $post_query['search_terms'] ) { |
122 | 126 | $qs[] = 'search_terms=' . urlencode( $_POST['search_terms'] ); |
diff --git src/bp-templates/bp-nouveau/js/buddypress-activity.js src/bp-templates/bp-nouveau/js/buddypress-activity.js
index f810dd9aa..fd97b753a 100644
|
|
window.bp = window.bp || {}; |
273 | 273 | |
274 | 274 | // Load more activities |
275 | 275 | } else if ( $( event.currentTarget ).hasClass( 'load-more' ) ) { |
276 | | var next_page = ( Number( this.current_page ) * 1 ) + 1, self = this, search_terms = ''; |
| 276 | var next_page = ( Number( this.current_page ) * 1 ) + 1, self = this, search_terms = '', |
| 277 | loadMoreLink = $( event.currentTarget ).children().first(); |
| 278 | offsetLower = loadMoreLink ? bp.Nouveau.getLinkParams( loadMoreLink.prop( 'href' ), 'offset_lower' ) : 0; |
277 | 279 | |
278 | 280 | // Stop event propagation |
279 | 281 | event.preventDefault(); |
280 | 282 | |
281 | | $( event.currentTarget ).find( 'a' ).first().addClass( 'loading' ); |
| 283 | loadMoreLink.addClass( 'loading' ); |
282 | 284 | |
283 | 285 | // reset the just posted |
284 | 286 | this.just_posted = []; |
… |
… |
window.bp = window.bp || {}; |
300 | 302 | page : next_page, |
301 | 303 | method : 'append', |
302 | 304 | exclude_just_posted : this.just_posted.join( ',' ), |
| 305 | offset_lower : offsetLower, |
303 | 306 | target : '#buddypress [data-bp-list] ul.bp-list' |
304 | 307 | } ).done( function( response ) { |
305 | 308 | if ( true === response.success ) { |