WP_REST_Widgets_Controller::prepare_links() WordPress Method

The WP_REST_Widgets_Controller::prepare_links() method is used to prepare links for the REST API. This method is called by the WP_REST_Controller::prepare_links() method.

WP_REST_Widgets_Controller::prepare_links( array $prepared ) #

Prepares links for the widget.


Parameters

$prepared

(array)(Required)Widget.


Top ↑

Return

(array) Links for the given widget.


Top ↑

Source

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

	protected function prepare_links( $prepared ) {
		$id_base = ! empty( $prepared['id_base'] ) ? $prepared['id_base'] : $prepared['id'];

		return array(
			'self'                      => array(
				'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $prepared['id'] ) ),
			),
			'collection'                => array(
				'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
			),
			'about'                     => array(
				'href'       => rest_url( sprintf( 'wp/v2/widget-types/%s', $id_base ) ),
				'embeddable' => true,
			),
			'https://api.w.org/sidebar' => array(
				'href' => rest_url( sprintf( 'wp/v2/sidebars/%s/', $prepared['sidebar'] ) ),
			),
		);
	}


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.