WP_REST_Response::add_link
Adds a link to the response.
{@internal The $rel parameter is first, as this looks nicer when sending multiple.}
Метод класса: WP_REST_Response{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WP_REST_Response = new WP_REST_Response(); $WP_REST_Response->add_link( $rel, $href, $attributes );
- $rel(строка) (обязательный)
- Link relation. Either an IANA registered type, or an absolute URL.
- $href(строка) (обязательный)
- Target URI for the link.
- $attributes(массив)
- Link parameters to send along with the URL.
По умолчанию:empty array
Список изменений
| С версии 4.4.0 | Введена. |
Код WP_REST_Response::add_link() WP REST Response::add link WP 7.0.2
public function add_link( $rel, $href, $attributes = array() ) {
if ( empty( $this->links[ $rel ] ) ) {
$this->links[ $rel ] = array();
}
if ( isset( $attributes['href'] ) ) {
// Remove the href attribute, as it's used for the main URL.
unset( $attributes['href'] );
}
$this->links[ $rel ][] = array(
'href' => $href,
'attributes' => $attributes,
);
}