Inventory_Presser_REST::add_hooks()
add_hooks
Return Return
(void)
Source Source
File: includes/class-rest.php
public function add_hooks() {
/*
Adds
/invp/v1/settings
/invp/v1/feed-complete routes.
*/
add_action( 'rest_api_init', array( $this, 'add_routes' ) );
// Adds the inventory_type_slugs field to the response of the /wp-json/wp/v2/inventory_vehicle route.
add_action( 'rest_api_init', array( $this, 'add_inventory_type_slugs_to_posts' ) );
// Allow attachments to be ordered by the inventory_presser_photo_number meta value.
add_filter( 'rest_attachment_collection_params', array( $this, 'allow_orderby_photo_number' ) );
add_filter( 'rest_attachment_query', array( $this, 'orderby_photo_number' ), 10, 2 );
if ( defined( 'INVP::POST_TYPE' ) ) {
// Allow vehicles to be returned in a random order.
add_filter( 'rest_' . INVP::POST_TYPE . '_collection_params', array( $this, 'allow_orderby_rand' ) );
// Prevent REST API warnings when vehicles are deleted during request processing.
add_filter( 'rest_prepare_' . INVP::POST_TYPE, array( $this, 'handle_null_post' ), 10, 3 );
}
}
Expand full source codeCollapse full source codeView on Github