ACF\Meta

MetaLocation::get_metapublicACF 6.4

Retrieves all ACF meta for the provided object ID.

Метод класса: MetaLocation{}

Хуков нет.

Возвращает

Массив.

Использование

$MetaLocation = new MetaLocation();
$MetaLocation->get_meta( $object_id ): array;
$object_id(int|строка)
The ID of the object to get meta from.

Список изменений

С версии 6.4 Введена.

Код MetaLocation::get_meta() ACF 6.4.2

public function get_meta( $object_id = 0 ): array {
	$meta     = array();
	$all_meta = get_metadata( $this->location_type, $object_id );

	if ( $all_meta ) {
		foreach ( $all_meta as $key => $value ) {
			// If a reference exists for this value, add it to the meta array.
			if ( isset( $all_meta[ $this->reference_prefix . $key ] ) ) {
				$meta[ $key ]                           = $value[0];
				$meta[ $this->reference_prefix . $key ] = $all_meta[ $this->reference_prefix . $key ][0];
			}
		}
	}

	// Unserialize results and return.
	return array_map( 'acf_maybe_unserialize', $meta );
}