WP_REST_Abilities_V1_List_Controller::get_collection_paramspublicWP 6.9.0

Retrieves the query params for collections.

Method of the class: WP_REST_Abilities_V1_List_Controller{}

Hooks from the method

Returns

array<string, mixed>. Collection parameters.

Usage

$WP_REST_Abilities_V1_List_Controller = new WP_REST_Abilities_V1_List_Controller();
$WP_REST_Abilities_V1_List_Controller->get_collection_params(): array;

Changelog

Since 6.9.0 Introduced.

WP_REST_Abilities_V1_List_Controller::get_collection_params() code WP 7.1

public function get_collection_params(): array {
	$query_params = array(
		'context'   => $this->get_context_param( array( 'default' => 'view' ) ),
		'page'      => array(
			'description' => __( 'Current page of the collection.' ),
			'type'        => 'integer',
			'default'     => 1,
			'minimum'     => 1,
		),
		'per_page'  => array(
			'description' => __( 'Maximum number of items to be returned in result set.' ),
			'type'        => 'integer',
			'default'     => 50,
			'minimum'     => 1,
			'maximum'     => 100,
		),
		'category'  => array(
			'description'       => __( 'Limit results to abilities in specific ability category.' ),
			'type'              => 'string',
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		),
		'namespace' => array(
			'description'       => __( 'Limit results to abilities in a specific namespace.' ),
			'type'              => 'string',
			'sanitize_callback' => 'sanitize_key',
			'validate_callback' => 'rest_validate_request_arg',
		),
		'meta'      => array(
			'description'          => __( 'Limit results to abilities matching all of the given meta fields.' ),
			'type'                 => 'object',
			'properties'           => array(
				// show_in_rest is omitted on purpose. It is forced on and cannot be filtered by a caller.
				'annotations' => array(
					'description'          => __( 'Limit results to abilities matching the given behavioral annotations.' ),
					'type'                 => 'object',
					'properties'           => array(
						'readonly'    => array(
							'description' => __( 'Whether the ability does not modify its environment.' ),
							'type'        => array( 'boolean', 'null' ),
						),
						'destructive' => array(
							'description' => __( 'Whether the ability may perform destructive updates to its environment.' ),
							'type'        => array( 'boolean', 'null' ),
						),
						'idempotent'  => array(
							'description' => __( 'Whether repeated calls with the same arguments have no additional effect.' ),
							'type'        => array( 'boolean', 'null' ),
						),
					),
					'additionalProperties' => true,
				),
			),
			'additionalProperties' => true,
		),
	);

	/**
	 * Filters REST API collection parameters for the abilities controller.
	 *
	 * Use this to declare the schema type of a custom meta key. A declared
	 * type lets REST coerce a query-string value, for example "true" to a
	 * boolean, before the meta filter matches it.
	 *
	 * @since 7.1.0
	 *
	 * @param array $query_params JSON Schema-formatted collection parameters.
	 */
	return apply_filters( 'rest_abilities_collection_params', $query_params );
}