Automattic/o2

Migrate from the custom O2 API to Core's `wp.api` client.

georgestephanis opened this issue · 0 comments

When O2 was written, Core's Rest API wasn't a thing, so we needed our own api endpoints and method for querying them.

With the WP Rest API mature and in core, with a very stable Backbone-powered client in core, it would make more sense to use the existing infrastructure, rather than reinventing the wheel. This could be swapped out bit-by-bit and need not be done all at once.

Documentation: https://developer.wordpress.org/rest-api/using-the-rest-api/backbone-javascript-client/

An example of how to publish a post:

const newPost = new wp.api.models.Post( {
	content: 'i am a new post',
	status: 'publish'
} );
newPost.save();

and then newPost has details of the post.