Prepares links for the request.
Parameters
$block_type
WP_Block_Typerequired- Block type data.
Source
protected function prepare_links( $block_type ) {
list( $namespace ) = explode( '/', $block_type->name );
$links = 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, $block_type->name ) ),
),
'up' => array(
'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $namespace ) ),
),
);
if ( $block_type->is_dynamic() ) {
$links['https://api.w.org/render-block'] = array(
'href' => add_query_arg(
'context',
'edit',
rest_url( sprintf( '%s/%s/%s', 'wp/v2', 'block-renderer', $block_type->name ) )
),
);
}
return $links;
}
Changelog
Version | Description |
---|---|
5.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.