Processing requests (and responses)
The WP_REST_Request
class will receive as an object the callback function of each endpoint, which will then further be passed as an object. To receive the parameters from the request, which are mapped from any transport method provided, we will be using the efficient method of get_params()
to get all the data from the validated and sanitized request, with all of the correspondent defaults filled in. Instead of using the method of accessing the global GET or POST variables, we will be using the method described previously, and the reasons for that are the following:
- The array that is returned is validated and sanitized and will handle the switches between the transport method. Even if we choose to switch the endpoints ...
Get Learning WordPress REST API now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.