Skip to:
Content

BuddyPress.org

Ticket #4535: 4535.patch

File 4535.patch, 6.1 KB (added by imath, 16 months ago)
  • src/bp-activity/bp-activity-template.php

    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 = '' ) { 
    272272                        'primary_id'        => $primary_id,  // Object ID to filter on e.g. a group_id or blog_id etc.
    273273                        'secondary_id'      => false,        // Secondary object ID to filter on e.g. a post_id.
    274274                        'offset'            => false,        // Return only items >= this ID.
     275                        'offset_lower'      => false,        // Return only items < this ID.
    275276                        'since'             => false,        // Return only items recorded since this Y-m-d H:i:s date.
    276277
    277278                        'meta_query'        => false,        // Filter on activity meta. See WP_Meta_Query for format.
    function bp_has_activities( $args = '' ) { 
    326327                $r['filter'] = array(
    327328                        'object' => $_GET['afilter']
    328329                );
    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'] ) ) {
    330331                $r['filter'] = array(
    331332                        'user_id'      => $r['user_id'],
    332333                        'object'       => $r['object'],
    function bp_has_activities( $args = '' ) { 
    334335                        'primary_id'   => $r['primary_id'],
    335336                        'secondary_id' => $r['secondary_id'],
    336337                        'offset'       => $r['offset'],
     338                        'offset_lower' => $r['offset_lower'],
    337339                        'since'        => $r['since']
    338340                );
    339341        } else {
    function bp_activity_load_more_link() { 
    410412        function bp_get_activity_load_more_link() {
    411413                global $activities_template;
    412414
    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 );
    415427
    416428                /**
    417429                 * Filters the Load More link URL.
  • src/bp-activity/classes/class-bp-activity-activity.php

    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 { 
    18681868         *                                          'secondary_item_id' column in the database.
    18691869         *     @type int              $offset       Return only those items with an ID greater
    18701870         *                                          than the offset value.
     1871         *     @type int              $offset_lower Return only those items with an ID lower
     1872         *                                          than the offset value.
    18711873         *     @type string           $since        Return only those items that have a
    18721874         *                                          date_recorded value greater than a
    18731875         *                                          given MySQL-formatted date.
    class BP_Activity_Activity { 
    19131915                        $filter_sql[] = "a.id >= {$sid_sql}";
    19141916                }
    19151917
     1918                if ( ! empty( $filter_array['offset_lower'] ) ) {
     1919                        $sid_sql = absint( $filter_array['offset_lower'] );
     1920                        $filter_sql[] = "a.id < {$sid_sql}";
     1921                }
     1922
    19161923                if ( ! empty( $filter_array['since'] ) ) {
    19171924                        // Validate that this is a proper Y-m-d H:i:s date.
    19181925                        // Trick: parse to UNIX date then translate back.
  • src/bp-templates/bp-nouveau/includes/functions.php

    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 ) { 
    117117                $qs[] = 'offset=' . intval( $post_query['offset'] );
    118118        }
    119119
     120        if ( ! empty( $post_query['offset_lower'] ) ) {
     121                $qs[] = 'offset_lower=' . intval( $post_query['offset_lower'] );
     122        }
     123
    120124        $object_search_text = bp_get_search_default_text( $object );
    121125        if ( ! empty( $post_query['search_terms'] ) && $object_search_text != $post_query['search_terms'] && 'false' != $post_query['search_terms'] && 'undefined' != $post_query['search_terms'] ) {
    122126                $qs[] = 'search_terms=' . urlencode( $_POST['search_terms'] );
  • src/bp-templates/bp-nouveau/js/buddypress-activity.js

    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 || {}; 
    273273
    274274                        // Load more activities
    275275                        } 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;
    277279
    278280                                // Stop event propagation
    279281                                event.preventDefault();
    280282
    281                                 $( event.currentTarget ).find( 'a' ).first().addClass( 'loading' );
     283                                loadMoreLink.addClass( 'loading' );
    282284
    283285                                // reset the just posted
    284286                                this.just_posted = [];
    window.bp = window.bp || {}; 
    300302                                        page                : next_page,
    301303                                        method              : 'append',
    302304                                        exclude_just_posted : this.just_posted.join( ',' ),
     305                                        offset_lower        : offsetLower,
    303306                                        target              : '#buddypress [data-bp-list] ul.bp-list'
    304307                                } ).done( function( response ) {
    305308                                        if ( true === response.success ) {