acf_field_post_object::get_rest_links
REST link attributes generator for this field.
Метод класса: acf_field_post_object{}
Хуков нет.
Возвращает
Массив.
Использование
$acf_field_post_object = new acf_field_post_object(); $acf_field_post_object->get_rest_links( $value, $post_id, $field );
- $value(разное) (обязательный)
- The raw (unformatted) field value.
- $post_id(int|строка) (обязательный)
- The post ID being queried.
- $field(массив) (обязательный)
- The field array.
Заметки
- Смотрите: [acf_field::get_rest_links()](/plugin/acf/function/acf_field::get_rest_links)
Список изменений
| С версии 5.11 | Введена. |
Код acf_field_post_object::get_rest_links() acf field post object::get rest links ACF 6.4.2
public function get_rest_links( $value, $post_id, array $field ) {
$links = array();
if ( empty( $value ) ) {
return $links;
}
foreach ( (array) $value as $object_id ) {
if ( ! $post_type = get_post_type( $object_id ) ) {
continue;
}
if ( ! $post_type_object = get_post_type_object( $post_type ) ) {
continue;
}
$rest_base = acf_get_object_type_rest_base( $post_type_object );
$links[] = array(
'rel' => $post_type_object->name === 'attachment' ? 'acf:attachment' : 'acf:post',
'href' => rest_url( sprintf( '/wp/v2/%s/%s', $rest_base, $object_id ) ),
'embeddable' => true,
);
}
return $links;
}