wppaste
WordPress

WP_REST_Controller

Since
4.7.0
Source
wp-includes/rest-api/endpoints/class-wp-rest-controller.php:15
Core base controller for managing and interacting with REST API items.

Compatibility

WordPress
since 4.7.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 3

$namespacestringprotected
The namespace of this controller's route.
$rest_basestringprotected
The base of this controller's route.
$schemaarrayprotected
Cached results of get_item_schema.

Methods · 27

Source code

#[AllowDynamicProperties]abstract class WP_REST_Controller { 	/**	 * The namespace of this controller's route.	 *	 * @since 4.7.0	 * @var string	 */	protected $namespace; 	/**	 * The base of this controller's route.	 *	 * @since 4.7.0	 * @var string	 */	protected $rest_base; 	/**	 * Cached results of get_item_schema.	 *	 * @since 5.3.0	 * @var array	 */	protected $schema; 	/**	 * Registers the routes for the objects of the controller.	 *	 * @since 4.7.0	 *	 * @see register_rest_route()	 */	public function register_routes() {		_doing_it_wrong(			'WP_REST_Controller::register_routes',			/* translators: %s: register_routes() */			sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ),			'4.7.0'		);	} 	/**	 * Checks if a given request has access to get items.	 *	 * @since 4.7.0	 *	 * @param WP_REST_Request $request Full details about the request.	 * @return true|WP_Error True if the request has read access, WP_Error object otherwise.	 */	public function get_items_permissions_check( $request ) {		return new WP_Error(			'invalid-method',			/* translators: %s: Method name. */			sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ),			array( 'status' => 405 )		);	} 	/**	 * Retrieves a collection of items.	 *	 * @since 4.7.0	 *	 * @param WP_REST_Request $request Full details about the request.	 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.	 */	public function get_items( $request ) {		return new WP_Error(			'invalid-method',			/* translators: %s: Method name. */			sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ),			array( 'status' => 405 )		);	} 	/**	 * Checks if a given request has access to get a specific item.	 *

Changelog

Introduced in 4.7.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.