Summery Summery
Adds a link to the response.
Syntax Syntax
Parameters Parameters
- $rel
-
(Required) Link relation. Either an IANA registered type, or an absolute URL.
- $href
-
(Required) Target URI for the link.
- $attributes
-
(Optional) Link parameters to send along with the URL.
Default value: array()
Source Source
File: wp-includes/rest-api/class-wp-rest-response.php
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, ); }
Advertisement
Changelog Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |