Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/09/2021 04:10:21 AM (4 years ago)
Author:
espellcaste
Message:

Adding support to the offset pagination to Messages and Recipients in a thread.

Previously, the BP_Messages_Thread query class would grab ALL messages created for a thread and ALL its recipients. This commit introduces support to the offset pagination
allowing one to paginate both messages and recipients using parameters with a specific limit and offset.

Props imath
Fixes #8508

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-template.php

    r13096 r13102  
    16261626 * @param array|string $args {
    16271627 *     Array of arguments. All are optional.
    1628  *     @type int    $thread_id         ID of the thread whose messages you are displaying.
    1629  *                                     Default: if viewing a thread, the thread ID will be parsed from
    1630  *                                     the URL (bp_action_variable( 0 )).
    1631  *     @type string $order             'ASC' or 'DESC'. Default: 'ASC'.
    1632  *     @type bool   $update_meta_cache Whether to pre-fetch metadata for
    1633  *                                     queried message items. Default: true.
     1628 *     @type int      $thread_id         ID of the thread whose messages you are displaying.
     1629 *                                       Default: if viewing a thread, the thread ID will be parsed from
     1630 *                                       the URL (bp_action_variable( 0 )).
     1631 *     @type string   $order             'ASC' or 'DESC'. Default: 'ASC'.
     1632 *     @type bool     $update_meta_cache Whether to pre-fetch metadata for
     1633 *                                       queried message items. Default: true.
     1634 *     @type int|null $page              Page of messages being requested. Default to null, meaning all.
     1635 *     @type int|null $per_page          Messages to return per page. Default to null, meaning all.
    16341636 * }
     1637 *
    16351638 * @return bool True if there are messages to display, otherwise false.
    16361639 */
     
    16381641    global $thread_template;
    16391642
    1640     $r = bp_parse_args( $args, array(
    1641         'thread_id'         => false,
    1642         'order'             => 'ASC',
    1643         'update_meta_cache' => true,
    1644     ), 'thread_has_messages' );
     1643    $r = bp_parse_args(
     1644        $args,
     1645        array(
     1646            'thread_id'         => false,
     1647            'order'             => 'ASC',
     1648            'update_meta_cache' => true,
     1649            'page'              => null,
     1650            'per_page'          => null,
     1651        ),
     1652        'thread_has_messages'
     1653    );
    16451654
    16461655    if ( empty( $r['thread_id'] ) && bp_is_messages_component() && bp_is_current_action( 'view' ) ) {
Note: See TracChangeset for help on using the changeset viewer.