acf_validate_field_group()ACF 5.7.10

acf_validate_field_group

Ensures the given field group is valid.

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

Возвращает

Массив.

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

acf_validate_field_group( $field_group );
$field_group **
-
По умолчанию: array()

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

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

Код acf_validate_field_group() ACF 5.10.2

function acf_validate_field_group( $field_group = array() ) {

	// Bail early if already valid.
	if ( is_array( $field_group ) && ! empty( $field_group['_valid'] ) ) {
		return $field_group;
	}

	// Apply defaults.
	$field_group = wp_parse_args(
		$field_group,
		array(
			'ID'                    => 0,
			'key'                   => '',
			'title'                 => '',
			'fields'                => array(),
			'location'              => array(),
			'menu_order'            => 0,
			'position'              => 'normal',
			'style'                 => 'default',
			'label_placement'       => 'top',
			'instruction_placement' => 'label',
			'hide_on_screen'        => array(),
			'active'                => true,
			'description'           => '',
		)
	);

	// Convert types.
	$field_group['ID']         = (int) $field_group['ID'];
	$field_group['menu_order'] = (int) $field_group['menu_order'];
	$field_group['active']     = (bool) $field_group['active'];

	// Field group is now valid.
	$field_group['_valid'] = true;

	/**
	 * Filters the $field_group array to validate settings.
	 *
	 * @date    12/02/2014
	 * @since   5.0.0
	 *
	 * @param   array $field_group The field group array.
	 */
	$field_group = apply_filters( 'acf/validate_field_group', $field_group );

	// return
	return $field_group;
}