DO NOT USE THIS YET, IT IS UNDER HEAVY DEVELOPMENT.
However, a lot of native WordPress functionality that we would also need for a JS-based app only exists in PHP, so we would need to rebuild many components every time we build a WordPress-powered web or mobile app. That's where WP-JS comes into place. This library offers an interface to all the important WordPress REST API endpoints, plus it includes useful components that we often need when working with WordPress data.
Before you start to use the library in any project, you need to install the WP-JS plugin to the instance of WordPress that you're going to connect your website to.
The following global JS variables should (or can) be set before including WP-JS:
- WPJS_REST_URL (required)
- WPJS_DISABLE_CACHE (optional)
- WPJS_DEBUG (optional)
To start WP-JS, simply run
wpjs.load() after including it. You can add a callback function to execute after the loading process by running
wpjs.ready( callback ).
A client that offers access to the WordPress REST API.
This allows retrieving WordPress options.
A group of formatting functions based on WordPress equivalents. For example, date and time are automatically formatted based on the site's settings.