Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
georgestephanis opened this issue Apr 2, 2020 · 0 comments
Open

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

georgestephanis opened this issue Apr 2, 2020 · 0 comments

Comments

@georgestephanis
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant