Hooks::register_rest_endpoints()
Registers the REST endpoints that will be used to return the Views HTML.
Source
File: src/Tribe/Views/V2/Hooks.php
public function register_rest_endpoints() {
register_rest_route( Service_Provider::NAME_SPACE, '/html', [
'methods' => \WP_REST_Server::READABLE,
/**
* @todo Make sure we do proper handling of cache longer then 12h.
*/
'permission_callback' => static function ( \WP_REST_Request $request ) {
return wp_verify_nonce( $request->get_param( '_wpnonce' ), 'wp_rest' );
},
'callback' => static function ( \WP_REST_Request $request ) {
View::make_for_rest( $request )->send_html();
},
'args' => [
'url' => [
'required' => true,
'validate_callback' => static function ( $url ) {
return is_string( $url );
},
'sanitize_callback' => static function ( $url ) {
return filter_var( $url, FILTER_SANITIZE_URL );
}
],
],
] );
}
Changelog
| Version | Description |
|---|---|
| 4.9.2 | Introduced. |