Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/13/2021 06:54:07 PM (5 years ago)
Author:
espellcaste
Message:

Adding support to paginate messages/recipients to the BP_Messages_Box_Template class.

When querying threads using the BP_Messages_Box_Template class, one might set a default of messages/recipients, instead of returning all items.

Fixes #8597

File:
1 edited

Legend:

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

    r13147 r13148  
    2424 * @param array|string $args {
    2525 *     Array of arguments. All are optional.
    26  *     @type int    $user_id      ID of the user whose threads are being loaded.
    27  *                                Default: ID of the logged-in user.
    28  *     @type string $box          Current "box" view. If not provided here, the current
    29  *                                view will be inferred from the URL.
    30  *     @type int    $per_page     Number of results to return per page. Default: 10.
    31  *     @type int    $max          Max results to return. Default: false.
    32  *     @type string $type         Type of messages to return. Values: 'all', 'read', 'unread'
    33  *                                Default: 'all'
    34  *     @type string $search_terms Terms to which to limit results. Default:
    35  *                                the value of $_REQUEST['s'].
    36  *     @type string $page_arg     URL argument used for the pagination param.
    37  *                                Default: 'mpage'.
    38  *     @type array  $meta_query   Meta query arguments. Only applicable if $box is
    39  *                                not 'notices'. See WP_Meta_Query more details.
     26 *     @type int      $user_id             ID of the user whose threads are being loaded.
     27 *                                         Default: ID of the logged-in user.
     28 *     @type string   $box                 Current "box" view. If not provided here, the current
     29 *                                         view will be inferred from the URL.
     30 *     @type int      $per_page            Number of results to return per page. Default: 10.
     31 *     @type int      $max                 Max results to return. Default: false.
     32 *     @type string   $type                Type of messages to return. Values: 'all', 'read', 'unread'
     33 *                                         Default: 'all'
     34 *     @type string   $search_terms        Terms to which to limit results. Default:
     35 *                                         the value of $_REQUEST['s'].
     36 *     @type string   $page_arg            URL argument used for the pagination param.
     37 *                                         Default: 'mpage'.
     38 *     @type array    $meta_query          Meta query arguments. Only applicable if $box is
     39 *                                         not 'notices'. See WP_Meta_Query more details.
     40 *     @type int|null $recipients_page     Page of recipients being requested. Default to null, meaning all.
     41 *     @type int|null $recipients_per_page Recipients to return per page. Defaults to null, meaning all.
     42 *     @type int|null $messages_page       Page of messages being requested. Default to null, meaning all.
     43 *     @type int|null $messages_per_page   Messages to return per page. Defaults to null, meaning all
    4044 * }
    4145 * @return bool True if there are threads to display, otherwise false.
     
    4751        $current_action = bp_current_action();
    4852        switch ( $current_action ) {
    49                 case 'sentbox' :
    50                 case 'notices' :
    51                 case 'inbox'   :
     53                case 'sentbox':
     54                case 'notices':
     55                case 'inbox':
    5256                        $default_box = $current_action;
    5357                        break;
    54                 default :
     58                default:
    5559                        $default_box = 'inbox';
    5660                        break;
     
    6872                $args,
    6973                array(
    70                         'user_id'      => $user_id,
    71                         'box'          => $default_box,
    72                         'per_page'     => 10,
    73                         'max'          => false,
    74                         'type'         => 'all',
    75                         'search_terms' => $search_terms,
    76                         'page_arg'     => 'mpage', // See https://buddypress.trac.wordpress.org/ticket/3679.
    77                         'meta_query'   => array(),
     74                        'user_id'             => $user_id,
     75                        'box'                 => $default_box,
     76                        'per_page'            => 10,
     77                        'max'                 => false,
     78                        'type'                => 'all',
     79                        'search_terms'        => $search_terms,
     80                        'page_arg'            => 'mpage', // See https://buddypress.trac.wordpress.org/ticket/3679.
     81                        'meta_query'          => array(),
     82                        'recipients_page'     => null,
     83                        'recipients_per_page' => null,
     84                        'messages_page'       => null,
     85                        'messages_per_page'   => null,
    7886                ),
    7987                'has_message_threads'
Note: See TracChangeset for help on using the changeset viewer.