acf_field_post_object::get_rest_links()publicACF 1.0

Метод класса: 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|строка) (обязательный)
-
$field(массив) (обязательный)
-

Заметки

  • Смотрите: [acf_field::get_rest_links()](/plugin/acf/function/acf_field::get_rest_links)

Код acf_field_post_object::get_rest_links() ACF 6.0.4

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;
}