JSON REST API: Version 0.4

After a week’s hiatus thanks to WCSF and the midsemester review, I’m back with a new release of WP APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways.! Version 0.4 is now available with the following changes:

  • Add Backbone-based models and collections – These are available to your code by declaring a dependency on wp-api (#270)
  • Check json_route before using it (#336)
  • Conditionally load classes (#337)
  • Add additional test helper pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party – Provides code coverage as needed to the API client tests. Currently unused. (#269)
  • Move json_url() and get_json_url() to plugin.php – This allows using both outside of the API itself (#343)
  • getPost(0) now returns an error rather than the latest post (#344)

As always, the full changes are available if you’re interested.

This release brings the first version of the JavascriptJavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. API, based on Backbone models and collections. To use it, simply declare `wp-api` as a dependency to your script, then start using the `wp.api` classes. Here’s a quick example of how to use it:

var posts = new wp.api.collections.Posts();
	success: function (posts) {
		var post = posts.at(0);
		var title = post.get('title');
		post.set('title', title + ' (Updated!)');

These are intended purely as building blocks for your own software. I had been looking at rewriting P2P2 A free theme for WordPress, known for front-end posting, used by WordPress for development updates and project management. See our main development blog and other workgroup blogs. partially to use these, however it appears that would require gutting P2 and basically starting from scratch, due to P2’s architecture. I’d love to see what you can do with this though, and bonus points if you can get a API-ified P2!

The coming week will introduce some specialised page handling as an example of how to enable custom post typeCustom Post Type WordPress can hold and display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. Custom Post Types gives your site the ability to have templated posts, to simplify the concept. support, plus the beginning of the media/attachment-related APIs. These will probably be a fair bit of work, so it’s possible only basic functionality will land next week.

#gsoc, #gsoc2013, #json-api, #rest-api