WP_REST_Sidebars_Controller::prepare_links() WordPress Method

The WP_REST_Sidebars_Controller::prepare_links() method is used to prepare links for the rest of the sidebar objects. This includes links for the individual sidebar objects and the sidebar objects' links.

WP_REST_Sidebars_Controller::prepare_links( array $sidebar ) #

Prepares links for the sidebar.


Parameters

$sidebar

(array)(Required)Sidebar.


Top ↑

Return

(array) Links for the given widget.


Top ↑

Source

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

	protected function prepare_links( $sidebar ) {
		return array(
			'collection'               => array(
				'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
			),
			'self'                     => array(
				'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $sidebar['id'] ) ),
			),
			'https://api.w.org/widget' => array(
				'href'       => add_query_arg( 'sidebar', $sidebar['id'], rest_url( '/wp/v2/widgets' ) ),
				'embeddable' => true,
			),
		);
	}


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.