wppaste
WordPress

WP_REST_Abilities_V1_List_Controller

Since
6.9.0
Source
wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-controller.php:19
Core controller used to access abilities via the REST API.

Compatibility

WordPress
since 6.9.0
  • 6.7.10
  • 6.8.11
  • 6.9.10
  • 7.0.7
  • 7.1.3

Present in 3 of the 5 tracked releases, added in 6.9.0.

Properties · 2

$namespacestringprotected
REST API namespace.
$rest_basestringprotected
REST API base route.

Methods · 9

Source code

class WP_REST_Abilities_V1_List_Controller extends WP_REST_Controller { 	/**	 * REST API namespace.	 *	 * @since 6.9.0	 * @var string	 */	protected $namespace = 'wp-abilities/v1'; 	/**	 * REST API base route.	 *	 * @since 6.9.0	 * @var string	 */	protected $rest_base = 'abilities'; 	/**	 * Registers the routes for abilities.	 *	 * @since 6.9.0	 *	 * @see register_rest_route()	 */	public function register_routes(): void {		register_rest_route(			$this->namespace,			'/' . $this->rest_base,			array(				array(					'methods'             => WP_REST_Server::READABLE,					'callback'            => array( $this, 'get_items' ),					'permission_callback' => array( $this, 'get_items_permissions_check' ),					'args'                => $this->get_collection_params(),				),				'schema' => array( $this, 'get_public_item_schema' ),			)		); 		register_rest_route(			$this->namespace,			'/' . $this->rest_base . '/(?P<name>[a-zA-Z0-9\-\/]+)',			array(				'args'   => array(					'name' => array(						'description' => __( 'Unique identifier for the ability.' ),						'type'        => 'string',						'pattern'     => '^[a-zA-Z0-9\-\/]+$',					),				),				array(					'methods'             => WP_REST_Server::READABLE,					'callback'            => array( $this, 'get_item' ),					'permission_callback' => array( $this, 'get_item_permissions_check' ),				),				'schema' => array( $this, 'get_public_item_schema' ),			)		);	} 	/**	 * Retrieves all abilities.	 *	 * @since 6.9.0	 *	 * @param WP_REST_Request $request Full details about the request.	 * @return WP_REST_Response Response object on success.	 */	public function get_items( $request ) {		$abilities = array_filter(			wp_get_abilities(),			static function ( $ability ) {				return $ability->get_meta_item( 'show_in_rest' );			}		); 		// Filter by ability category if specified.		$category = $request['category'];		if ( ! empty( $category ) ) {

Changelog

Introduced in 6.9.0. 3 changes between 6.9.10 and 7.1.3.

  1. 6.9.10
  2. 7.0.7
  3. 7.1.3

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

7.1.3
Method normalize_schema_empty_object_defaults() removed.verified against source
7.1.3
Method strip_internal_schema_keywords() removed.verified against source
7.0.7
Method strip_internal_schema_keywords() added.verified against source
6.9.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.9.10 tag, from src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-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.