WP_REST_Templates_Controller::prepare_links() WordPress Method

The prepare_links() method is used to prepare the links for a WP_REST_Templates_Controller object. This method is called by the WP_REST_Controller::prepare_links() method.

WP_REST_Templates_Controller::prepare_links( integer $id ) #

Prepares links for the request.


Parameters

$id

(integer)(Required)ID.


Top ↑

Return

(array) Links for the given post.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php

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

		$links = array(
			'self'       => array(
				'href' => rest_url( trailingslashit( $base ) . $id ),
			),
			'collection' => array(
				'href' => rest_url( $base ),
			),
			'about'      => array(
				'href' => rest_url( 'wp/v2/types/' . $this->post_type ),
			),
		);

		return $links;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.