acf_get_field_group()ACF 5.0.0

acf_get_field_group

Retrieves a field group for the given identifier.

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

Возвращает

(Массив|false). The field group array.

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

acf_get_field_group( $id );
$id((int|string))
The field group ID, key or name.

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

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

Код acf_get_field_group() ACF 6.0.4

function acf_get_field_group( $id = 0 ) {

	// Allow WP_Post to be passed.
	if ( is_object( $id ) ) {
		$id = $id->ID;
	}

	// Check store.
	$store = acf_get_store( 'field-groups' );
	if ( $store->has( $id ) ) {
		return $store->get( $id );
	}

	// Check local fields first.
	if ( acf_is_local_field_group( $id ) ) {
		$field_group = acf_get_local_field_group( $id );

		// Then check database.
	} else {
		$field_group = acf_get_raw_field_group( $id );
	}

	// Bail early if no field group.
	if ( ! $field_group ) {
		return false;
	}

	// Validate field group.
	$field_group = acf_validate_field_group( $field_group );

	/**
	 * Filters the $field_group array after it has been loaded.
	 *
	 * @date    12/02/2014
	 * @since   5.0.0
	 *
	 * @param   array The field_group array.
	 */
	$field_group = apply_filters( 'acf/load_field_group', $field_group );

	// Store field group using aliasses to also find via key, ID and name.
	$store->set( $field_group['key'], $field_group );
	$store->alias( $field_group['key'], $field_group['ID'] );

	// Return.
	return $field_group;
}