acf_get_fields()ACF 5.0.0

acf_get_fields

Returns and array of fields for the given $parent.

Хуки из функции

Возвращает

Массив.

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

acf_get_fields( $parent );
$parent((int|строка|array)) (обязательный)
The field group or field settings. Also accepts the field group ID or key.

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

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

Код acf_get_fields() ACF 5.10.2

function acf_get_fields( $parent ) {

	// Allow field group selector as $parent.
	if ( ! is_array( $parent ) ) {
		$parent = acf_get_field_group( $parent );
		if ( ! $parent ) {
			return array();
		}
	}

	// Vars.
	$fields = array();

	// Check local fields first.
	if ( acf_have_local_fields( $parent['key'] ) ) {
		$raw_fields = acf_get_local_fields( $parent['key'] );
		foreach ( $raw_fields as $raw_field ) {
			$fields[] = acf_get_field( $raw_field['key'] );
		}

		// Then check database.
	} else {
		$raw_fields = acf_get_raw_fields( $parent['ID'] );
		foreach ( $raw_fields as $raw_field ) {
			$fields[] = acf_get_field( $raw_field['ID'] );
		}
	}

	/**
	 * Filters the $fields array.
	 *
	 * @date    12/02/2014
	 * @since   5.0.0
	 *
	 * @param   array $fields The array of fields.
	 */
	$fields = apply_filters( 'acf/load_fields', $fields, $parent );

	// Return fields
	return $fields;
}