BP_REST_Reply_Endpoint::get_collection_params()

Get the query params for collections.

Description

Return

(array)

Source

File: bp-forums/classes/class-bp-rest-reply-endpoint.php

2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
public function get_collection_params() {
    $params                       = parent::get_collection_params();
    $params['context']['default'] = 'view';
 
    $params['author'] = array(
        'description'       => __( 'Author ID, or comma-separated list of IDs.', 'buddyboss' ),
        'default'           => '',
        'type'              => 'string',
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['author_exclude'] = array(
        'description'       => __( 'An array of author IDs not to query from.', 'buddyboss' ),
        'type'              => 'array',
        'items'             => array( 'type' => 'integer' ),
        'sanitize_callback' => 'wp_parse_id_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['exclude'] = array(
        'description'       => __( 'An array of reply IDs not to retrieve.', 'buddyboss' ),
        'type'              => 'array',
        'items'             => array( 'type' => 'integer' ),
        'sanitize_callback' => 'wp_parse_id_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['include'] = array(
        'description'       => __( 'An array of reply IDs to retrieve.', 'buddyboss' ),
        'type'              => 'array',
        'items'             => array( 'type' => 'integer' ),
        'sanitize_callback' => 'wp_parse_id_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['offset'] = array(
        'description'       => __( 'The number of reply to offset before retrieval.', 'buddyboss' ),
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['order'] = array(
        'description'       => __( 'Designates ascending or descending order of replies.', 'buddyboss' ),
        'default'           => 'asc',
        'type'              => 'string',
        'enum'              => array( 'asc', 'desc' ),
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['orderby'] = array(
        'description'       => __( 'Sort retrieved replies by parameter.', 'buddyboss' ),
        'type'              => 'array',
        'items'             => array(
            'type' => 'string',
            'enum' => array(
                'meta_value',
                'date',
                'ID',
                'author',
                'title',
                'modified',
                'parent',
                'rand',
            ),
        ),
        'sanitize_callback' => 'bp_rest_sanitize_string_list',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['parent'] = array(
        'description'       => __( 'Topic or Reply ID to retrieve all the child replies.', 'buddyboss' ),
        'default'           => '0',
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['thread_replies'] = array(
        'description'       => __( 'Calculated value and the thread replies depth.', 'buddyboss' ),
        'default'           => bbp_thread_replies(),
        'type'              => 'boolean',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    /**
     * Filters the collection query params.
     *
     * @param array $params Query params.
     */
    return apply_filters( 'bp_rest_replys_collection_params', $params );
}

Changelog

Changelog
Version Description
0.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.