Creating a new WordPress REST endpoint
The REST API is an interface that allows application developers to exchange data with the core of a WordPress site. This API can be used for anything, from developing a mobile application that displays WordPress pages or custom post types to creating a complete replacement interface for content creation.
The new WordPress block editor was built using the REST API to interact with the rest of WordPress. As such, plugins occasionally need to extend the REST API to be able to implement new endpoints. This allows custom block JavaScript code to get access to data that is not part of the default WordPress REST API.
Getting ready
You should have already followed the Managing multiple sets of user settings from a single admin page recipe in Chapter 3, User Settings and Administration Pages, to have a starting point for this recipe. The resulting plugin should still be active on your development site. Alternatively, you can get the resulting...