BP_REST_Groups_Endpoint::get_endpoint_args_for_item_schema( string $method = WP_REST_Server::CREATABLE )
Edit some arguments for the endpoint’s CREATABLE and EDITABLE methods.
Description
Parameters
- $method
-
(Optional) HTTP method of the request.
Default value: WP_REST_Server::CREATABLE
Return
(array) Endpoint arguments.
Source
File: bp-groups/classes/class-bp-rest-groups-endpoint.php
public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) {
$args = WP_REST_Controller::get_endpoint_args_for_item_schema( $method );
$key = 'get_item';
if ( WP_REST_Server::CREATABLE === $method || WP_REST_Server::EDITABLE === $method ) {
$key = 'create_item';
$args['description']['type'] = 'string';
// Add group types.
$args['types'] = array(
'description' => __( 'Set type(s) for a group.', 'buddyboss' ),
'type' => 'array',
'enum' => bp_groups_get_group_types(),
'sanitize_callback' => 'bp_rest_sanitize_group_types',
'validate_callback' => 'bp_rest_validate_group_types',
'items' => array(
'type' => 'string',
),
);
if ( WP_REST_Server::EDITABLE === $method ) {
$key = 'update_item';
unset( $args['slug'] );
// Append group types.
$args['append_types'] = array(
'description' => __( 'Append type(s) for a group.', 'buddyboss' ),
'type' => 'array',
'enum' => bp_groups_get_group_types(),
'sanitize_callback' => 'bp_rest_sanitize_group_types',
'validate_callback' => 'bp_rest_validate_group_types',
'items' => array(
'type' => 'string',
),
);
// Remove group types.
$args['remove_types'] = array(
'description' => __( 'Remove type(s) for a group.', 'buddyboss' ),
'type' => 'array',
'enum' => bp_groups_get_group_types(),
'sanitize_callback' => 'bp_rest_sanitize_group_types',
'validate_callback' => 'bp_rest_validate_group_types',
'items' => array(
'type' => 'string',
),
);
}
} elseif ( WP_REST_Server::DELETABLE === $method ) {
$key = 'delete_item';
$args = array(
'id' => array(
'description' => __( 'A unique numeric ID for the Group.', 'buddyboss' ),
'type' => 'integer',
'required' => true,
),
);
if ( bp_is_active( 'forums' ) ) {
$args['delete_group_forum'] = array(
'description' => __( 'Delete the Group forum if exist.', 'buddyboss' ),
'type' => 'boolean',
'default' => false,
'sanitize_callback' => 'rest_sanitize_boolean',
'validate_callback' => 'rest_validate_request_arg',
);
}
}
/**
* Filters the method query arguments.
*
* @param array $args Query arguments.
* @param string $method HTTP method of the request.
*
* @since 0.1.0
*/
return apply_filters( "bp_rest_groups_{$key}_query_arguments", $args, $method );
}
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.