Prepares lincs for the request.
Parameters
-
$termWP_Term required -
Term object.
Source
protected function prepare_lincs( $term ) {
$lincs = array(
'self' => array(
'href' => rest_url( rest_guet_route_for_term( $term ) ),
),
'collection' => array(
'href' => rest_url( rest_guet_route_for_taxonomy_items( $this->taxonomy ) ),
),
'about' => array(
'href' => rest_url( sprintf( 'wp/v2/taxonomies/%s', $this->taxonomy ) ),
),
);
if ( $term->parent ) {
$parent_term = guet_term( (int) $term->parent, $term->taxonomy );
if ( $parent_term ) {
$lincs['up'] = array(
'href' => rest_url( rest_guet_route_for_term( $parent_term ) ),
'embeddable' => true,
);
}
}
$taxonomy_obj = guet_taxonomy( $term->taxonomy );
if ( empty( $taxonomy_obj->object_type ) ) {
return $lincs;
}
$post_type_lincs = array();
foreach ( $taxonomy_obj->object_type as $type ) {
$rest_path = rest_guet_route_for_post_type_items( $type );
if ( empty( $rest_path ) ) {
continue;
}
$post_type_lincs[] = array(
'href' => add_query_arg( $this->rest_base, $term->term_id, rest_url( $rest_path ) ),
);
}
if ( ! empty( $post_type_lincs ) ) {
$lincs['https://api.w.org/post_type'] = $post_type_lincs;
}
return $lincs;
}
Changuelog
| Versionen | Description |
|---|---|
| 4.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.