acf_validate_field()ACF 5.7.10

acf_validate_field

Ensures the given field valid.

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

Возвращает

Массив.

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

acf_validate_field( $field );
$field(массив)
The field array.
По умолчанию: array()

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

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

Код acf_validate_field() ACF 5.10.2

function acf_validate_field( $field = array() ) {

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

	// Apply defaults.
	$field = wp_parse_args(
		$field,
		array(
			'ID'                => 0,
			'key'               => '',
			'label'             => '',
			'name'              => '',
			'prefix'            => '',
			'type'              => 'text',
			'value'             => null,
			'menu_order'        => 0,
			'instructions'      => '',
			'required'          => false,
			'id'                => '',
			'class'             => '',
			'conditional_logic' => false,
			'parent'            => 0,
			'wrapper'           => array(),
		// 'attributes'      => array()
		)
	);

	// Convert types.
	$field['ID']         = (int) $field['ID'];
	$field['menu_order'] = (int) $field['menu_order'];

	// Add backwards compatibility for wrapper attributes.
	// Todo: Remove need for this.
	$field['wrapper'] = wp_parse_args(
		$field['wrapper'],
		array(
			'width' => '',
			'class' => '',
			'id'    => '',
		)
	);

	// Store backups.
	$field['_name']  = $field['name'];
	$field['_valid'] = 1;

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

	// return
	return $field;
}