I’ve defined a REST endpoint /my-plugin/v1/post-read to show whether a post has been read or not, per-user. In PHP, my plugin keeps track of this depending on page views while logged in.
automatically for you. This is the recommended way to use the API for
plugins and themes. Custom data models can extend wp.api.models.Base
to ensure this is sent correctly for any custom requests.
I’d like to use this so I don’t have to deal with nonces. I’ve found an example how to use the library with the built-in post model, but I want to extend this for my custom endpoint.
I want to know whether it’s appropriate to use and extend this library for sending POST requests, and if so, how I extend wp.api.models.Base to support this simple endpoint. All the examples I’ve found are for built-in objects like post, taxonomy, etc.