Tribe__Events__REST__V1__Endpoints__Term_Single_Base::create( WP_REST_Request $request, bool $return_id = false )
Handles POST requests on the endpoint.
Contents
Parameters
- $request
-
(WP_REST_Request) (Required)
- $return_id
-
(bool) (Optional) Whether the created post ID should be returned or the full response object.
Default value: false
Return
(WP_Error|WP_REST_Response|int) An array containing the data on success or a WP_Error instance on failure.
Source
File: src/Tribe/REST/V1/Endpoints/Term_Single_Base.php
public function create( WP_REST_Request $request, $return_id = false ) {
$term_response = $this->terms_controller->create_item( $request );
if ( is_wp_error( $term_response ) ) {
return $term_response;
}
$term_data = $term_response->get_data();
if ( $return_id ) {
return $term_data['id'];
}
$data = $this->repository->prepare_term_data( $term_data, $this->get_taxonomy(), $this->get_term_namespace() );
$term_response->set_data( $data );
return $term_response;
}
Changelog
| Version | Description |
|---|---|
| 4.6 | Introduced. |