Skip to content
Docs
Get RestroPress

Filter

rp_rest_api_{$post_type}_schema

Updated
On this page

Filters the extra schema properties added to a menu item or order in the REST API.

Fired by the foods controller (post type fooditem) and the orders controller (post type rpress_payment) before their additional properties are merged into the item schema, giving the hook names rp_rest_api_fooditem_schema and rp_rest_api_rpress_payment_schema. Each key is a property name and each value a schema definition.

Parameters#

ParameterTypeDescription
$additional_schemaarrayProperty definitions to merge into the schema's properties.

Return value#

array. The additional schema properties.

Example#

function my_order_schema( $additional_schema ) {
	$additional_schema['my_reference'] = array(
		'description' => __( 'External reference.', 'my-textdomain' ),
		'type'        => 'string',
		'context'     => array( 'view', 'edit' ),
		'readonly'    => true,
	);
	return $additional_schema;
}
add_filter( 'rp_rest_api_rpress_payment_schema', 'my_order_schema' );

Notes#

Declaring a property here only describes it; the controller's response preparation must also output the value.

Source#

Applied in:

  • includes/rest-api/Controllers/Version1/class-rp-rest-foods-v1-controller.php (line 401), in RP_REST_Foods_V1_Controller::fooditem_item_schema()
  • includes/rest-api/Controllers/Version1/class-rp-rest-orders-v1-controller.php (line 429), in RP_REST_Orders_V1_Controller::rpress_payment_item_schema()
Was this page helpful?