WordPress at Your Fingertips
function is not described

WP_REST_Widgets_Controller::prepare_links() protected WP 5.8.0

Prepares links for the widget.

{} It's a method of the class: WP_REST_Widgets_Controller{}

No Hooks.

Return

Array. Links for the given widget.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_links( $prepared );
$prepared(array) (required)
Widget.

Changelog

Since 5.8.0 Introduced.

Code of WP_REST_Widgets_Controller::prepare_links() WP 5.8.1

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'] ) ),
		),
	);
}