Extending Internal Classes Edit Page

WP-API has a deliberate design pattern for its internal classes. They can be categorized as either infrastructure or endpoints.

Infrastructure classes support the endpoint classes. They handle the logic for WP-API without performing any data transformation. Endpoint classes, on the other hand, encapsulate the functional logic necessary to perform CRUD operations on WordPress resources. More specifically, our infrastructure classes include WP_REST_Server and WP_REST_Request, where our endpoint classes include WP_REST_Posts_Controller and WP_REST_Users_Controller.

Let’s dive into what each infrastructure class does:

All endpoint classes extend WP_REST_Controller. This class is designed to represent a consistent pattern for manipulating WordPress resources. WP_REST_Controller implements these methods:

When interacting with an endpoint that implements WP_REST_Controller, a HTTP client can expect each endpoint to behave in a similar way.