BP_REST_Friends_Endpoint::prepare_links( BP_Friends_Friendship $friendship )

Prepare links for the request.


Parameters Parameters

$friendship

(BP_Friends_Friendship) (Required) Friendship item.


Top ↑

Return Return

(array) Links for the given plugin.


Source Source

File: bp-friends/classes/class-bp-rest-friends-endpoint.php

	protected function prepare_links( $friendship ) {
		$base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base );

		// Entity meta.
		$links = array(
			'self'       => array(
				'href' => rest_url( $base . $friendship->id ),
			),
			'collection' => array(
				'href' => rest_url( $base ),
			),
			'initiator'       => array(
				'href'       => rest_url( bp_rest_get_user_url( $friendship->initiator_user_id ) ),
				'embeddable' => true,
			),
			'friend'       => array(
				'href'       => rest_url( bp_rest_get_user_url( $friendship->friend_user_id ) ),
				'embeddable' => true,
			),
		);

		/**
		 * Filter links prepared for the REST response.
		 *
		 * @since 5.0.0
		 *
		 * @param array                 $links      The prepared links of the REST response.
		 * @param BP_Friends_Friendship $friendship Friendship object.
		 */
		return apply_filters( 'bp_rest_friends_prepare_links', $links, $friendship );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.