BP_REST_Notifications_Endpoint::get_collection_params()
Get the query params for the notifications collections.
Description
Return
(array)
Source
File: bp-notifications/classes/class-bp-rest-notifications-endpoint.php
public function get_collection_params() {
$params = parent::get_collection_params();
$params['context']['default'] = 'view';
// Remove the search argument.
unset( $params['search'] );
$params['order_by'] = array(
'description' => __( 'Name of the field to order according to.', 'buddyboss' ),
'default' => 'id',
'type' => 'string',
'enum' => array(
'id',
'date_notified',
'item_id',
'secondary_item_id',
'component_name',
'component_action',
),
'sanitize_callback' => 'sanitize_key',
'validate_callback' => 'rest_validate_request_arg',
);
$params['sort_order'] = array(
'description' => __( 'Order sort attribute ascending or descending.', 'buddyboss' ),
'default' => 'ASC',
'type' => 'string',
'enum' => array( 'ASC', 'DESC' ),
'sanitize_callback' => 'sanitize_key',
'validate_callback' => 'rest_validate_request_arg',
);
$params['component_name'] = array(
'description' => __( 'Limit result set to notifications associated with a specific component', 'buddyboss' ),
'default' => '',
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',
);
$params['component_action'] = array(
'description' => __( 'Limit result set to notifications associated with a specific component\'s action name.', 'buddyboss' ),
'default' => '',
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',
);
$params['user_id'] = array(
'description' => __( 'Limit result set to notifications addressed to a specific user.', 'buddyboss' ),
'default' => bp_loggedin_user_id(),
'type' => 'integer',
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
);
$params['item_id'] = array(
'description' => __( 'Limit result set to notifications associated with a specific item ID.', 'buddyboss' ),
'default' => 0,
'type' => 'integer',
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
);
$params['secondary_item_id'] = array(
'description' => __( 'Limit result set to notifications associated with a specific secondary item ID.', 'buddyboss' ),
'default' => 0,
'type' => 'integer',
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
);
$params['is_new'] = array(
'description' => __( 'Limit result set to items from specific states.', 'buddyboss' ),
'default' => true,
'type' => 'boolean',
'sanitize_callback' => 'rest_sanitize_boolean',
'validate_callback' => 'rest_validate_request_arg',
);
/**
* Filters the collection query params.
*
* @param array $params Query params.
*/
return apply_filters( 'bp_rest_notifications_collection_params', $params );
}
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.