How to stop WP API endpoint from caching?
If you have access to your request header you can add the line. Cache-Control: private or Cache-Control: no-cache. This will force well-behaved hosts to send you fresh results.
If you have access to your request header you can add the line. Cache-Control: private or Cache-Control: no-cache. This will force well-behaved hosts to send you fresh results.
The filter param was removed in WP4.7, you should be able to access tags via their ID. For example to get the tag with the ID of 7 you could use: http://YOUSIITE.DEV/wp-json/wp/v2/posts?tags=7 If you would like to add filters back in the WP-API team released their own Filter plugin, I’d recommend that you check that … Read more
To process payment for an WooCommerce Order, the workflow goes like the following: Create an WooCommerce Order Process Payment for this order, using one of WC_Payment_Gateways Change order status (default is pending->processing, or to complete if empty order) IMHO, Step two can be implemented as the following: Use a front-end lib to tokenize payment info, … Read more
To modify the rest url prefix you can filter rest_url_prefix. But that just changes the /wp-json/ prefix that every namespace uses. Trying to modify wp/v2 means modifying the plugin and that namespace is hard-coded in several places like; WP_REST_Post_Statuses_Controller. To add your own custom endpoints, register_rest_route is in core to do just that. <?php add_action( … Read more
Retrieve CSS and JS From the REST API
“The REST API uses JSON exclusively as the request and response format, including error responses.” — WordPress REST API Reference I would try explicitly setting the content type/length and json encode your data with something like this (assuming you need to specify all the options you did in your code provided): $data = array( ‘title’ … Read more
Basic auth is a very common username/password authentication method and it’s as strong as the username-password combination and the encryption of the protocol you’re using. The weakness of basic auth is that if you use it with plain http instead of https then the username and password is susceptible to a man-in-the-middle attack. You can … Read more
WordPress REST Upload Media
WordPress REST API call generates nonce twice on every call
When working with the API recently I found if the authentication header with the consumer key as the username and the consumer secret as the password is present and valid this sets the current user global as the matched user. I found the core executes the REST route until current_user_can is called, at which point … Read more