public function prepare_item_for_response( $taxonomy, $request ) {

		$data = array(
			'name'         => $taxonomy->label,
			'slug'         => $taxonomy->name,
			'capabilities' => $taxonomy->cap,
			'description'  => $taxonomy->description,
			'labels'       => $taxonomy->labels,
			'types'        => $taxonomy->object_type,
			'show_cloud'   => $taxonomy->show_tagcloud,
			'hierarchical' => $taxonomy->hierarchical,
		);

		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
		$data = $this->add_additional_fields_to_object( $data, $request );
		$data = $this->filter_response_by_context( $data, $context );

		// Wrap the data in a response object.
		$response = rest_ensure_response( $data );

		$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
		$response->add_links( array(
			'collection'                => array(
				'href'                  => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
			),
			'https://api.w.org/items'   => array(
				'href'                  => rest_url( sprintf( 'wp/v2/%s', $base ) ),
			),
		) );

		/**
		 * Filter a taxonomy returned from the API.
		 *
		 * Allows modification of the taxonomy data right before it is returned.
		 *
		 * @param WP_REST_Response  $response   The response object.
		 * @param object            $item       The original taxonomy object.
		 * @param WP_REST_Request   $request    Request used to generate the response.
		 */
		return apply_filters( 'rest_prepare_taxonomy', $response, $taxonomy, $request );
	}
public function prepare_item_for_response( $taxonomy, $request ) {

		$data = array(
			'name'         => $taxonomy->label,
			'slug'         => $taxonomy->name,
			'capabilities' => $taxonomy->cap,
			'description'  => $taxonomy->description,
			'labels'       => $taxonomy->labels,
			'types'        => $taxonomy->object_type,
			'show_cloud'   => $taxonomy->show_tagcloud,
			'hierarchical' => $taxonomy->hierarchical,
		);

		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
		$data = $this->add_additional_fields_to_object( $data, $request );
		$data = $this->filter_response_by_context( $data, $context );

		// Wrap the data in a response object.
		$response = rest_ensure_response( $data );

		$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
		$response->add_links( array(
			'collection'                => array(
				'href'                  => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
			),
			'https://api.w.org/items'   => array(
				'href'                  => rest_url( sprintf( 'wp/v2/%s', $base ) ),
			),
		) );

		/**
		 * Filter a taxonomy returned from the API.
		 *
		 * Allows modification of the taxonomy data right before it is returned.
		 *
		 * @param WP_REST_Response  $response   The response object.
		 * @param object            $item       The original taxonomy object.
		 * @param WP_REST_Request   $request    Request used to generate the response.
		 */
		return apply_filters( 'rest_prepare_taxonomy', $response, $taxonomy, $request );
	}
public function prepare_item_for_response ( $ taxonomy , $ request ) { $ data = array ( 'name' => $ taxonomy -> label , 'slug' => $ taxonomy -> name , 'capabilities' => $ taxonomy -> cap , 'description' => $ taxonomy -> description , 'labels' => $ taxonomy -> labels , 'types' => $ taxonomy -> object_type , 'show_cloud' => $ taxonomy -> show_tagcloud , 'hierarchical' => $ taxonomy -> hierarchical , ) ; $ context = ! empty ( $ request [ 'context' ] ) ? $ request [ 'context' ] : 'view' ; $ data = $ this -> add_additional_fields_to_object ( $ data , $ request ) ; $ data = $ this -> filter_response_by_context ( $ data , $ context ) ; // Wrap the data in a response object. $ response = rest_ensure_response ( $ data ) ; $ base = ! empty ( $ taxonomy -> rest_base ) ? $ taxonomy -> rest_base : $ taxonomy -> name ; $ response -> add_links ( array ( 'collection' => array ( 'href' => rest_url ( sprintf ( '%s/%s' , $ this -> namespace , $ this -> rest_base ) ) , ) , 'https://api.w.org/items' => array ( 'href' => rest_url ( sprintf ( 'wp/v2/%s' , $ base ) ) , ) , ) ) ; /**
		 * Filter a taxonomy returned from the API.
		 *
		 * Allows modification of the taxonomy data right before it is returned.
		 *
		 * @param WP_REST_Response  $response   The response object.
		 * @param object            $item       The original taxonomy object.
		 * @param WP_REST_Request   $request    Request used to generate the response.
		 */ return apply_filters ( 'rest_prepare_taxonomy' , $ response , $ taxonomy , $ request ) ; }
Prepare a taxonomy object for serialization

@param stdClass $taxonomy Taxonomy data
@param WP_REST_Request $request
@return WP_REST_Response $response
Prepare a taxonomy object for serialization