WC_REST_Setting_Options_V2_Controller::prepare_links()protectedWC 3.0.0

Prepare links for the request.

Method of the class: WC_REST_Setting_Options_V2_Controller{}

No Hooks.

Return

Array. Links for the given setting.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_links( $setting_id, $group_id );
$setting_id(string) (required)
Setting ID.
$group_id(string) (required)
Group ID.

Changelog

Since 3.0.0 Introduced.

WC_REST_Setting_Options_V2_Controller::prepare_links() code WC 8.6.1

protected function prepare_links( $setting_id, $group_id ) {
	$base  = str_replace( '(?P<group_id>[\w-]+)', $group_id, $this->rest_base );
	$links = array(
		'self'       => array(
			'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $base, $setting_id ) ),
		),
		'collection' => array(
			'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ),
		),
	);

	return $links;
}