BP_REST_Messages_Endpoint::register_routes()
Register the component routes.
Description Description
Source Source
File: bp-messages/classes/class-bp-rest-messages-endpoint.php
public function register_routes() { 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(), ), array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), ), 'schema' => array( $this, 'get_item_schema' ), ) ); // Attention: (?P<id>[\d]+) is the placeholder for **Thread** ID, not the Message ID one. $thread_endpoint = '/' . $this->rest_base . '/(?P<id>[\d]+)'; register_rest_route( $this->namespace, $thread_endpoint, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => array( $this, 'get_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::READABLE ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'update_item' ), 'permission_callback' => array( $this, 'update_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), ), array( 'methods' => WP_REST_Server::DELETABLE, 'callback' => array( $this, 'delete_item' ), 'permission_callback' => array( $this, 'delete_item_permissions_check' ), 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::DELETABLE ), ), 'schema' => array( $this, 'get_item_schema' ), ) ); // Register the starred route. if ( bp_is_active( 'messages', 'star' ) ) { // Attention: (?P<id>[\d]+) is the placeholder for **Message** ID, not the Thread ID one. $starred_endpoint = '/' . $this->rest_base . '/' . bp_get_messages_starred_slug() . '/(?P<id>[\d]+)'; register_rest_route( $this->namespace, $starred_endpoint, array( 'args' => array( 'id' => array( 'description' => __( 'ID of one of the message of the Thread.', 'buddypress' ), 'type' => 'integer', ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'update_starred' ), 'permission_callback' => array( $this, 'update_starred_permissions_check' ), ), 'schema' => array( $this, 'get_item_schema' ), ) ); } }
Changelog Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |