acf_field_file::render_field_validation_settings()publicACF 6.0

Renders the field settings used in the "Validation" tab.

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

Хуков нет.

Возвращает

null. Ничего.

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

$acf_field_file = new acf_field_file();
$acf_field_file->render_field_validation_settings( $field );
$field(массив) (обязательный)
The field settings array.

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

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

Код acf_field_file::render_field_validation_settings() ACF 6.0.4

function render_field_validation_settings( $field ) {
	// Clear numeric settings.
	$clear = array(
		'min_size',
		'max_size',
	);

	foreach ( $clear as $k ) {

		if ( empty( $field[ $k ] ) ) {
			$field[ $k ] = '';
		}
	}

	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Minimum', 'acf' ),
			'instructions' => __( 'Restrict which files can be uploaded', 'acf' ),
			'type'         => 'text',
			'name'         => 'min_size',
			'prepend'      => __( 'File size', 'acf' ),
			'append'       => 'MB',
		)
	);

	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Maximum', 'acf' ),
			'instructions' => __( 'Restrict which files can be uploaded', 'acf' ),
			'type'         => 'text',
			'name'         => 'max_size',
			'prepend'      => __( 'File size', 'acf' ),
			'append'       => 'MB',
		)
	);

	acf_render_field_setting(
		$field,
		array(
			'label' => __( 'Allowed file types', 'acf' ),
			'hint'  => __( 'Comma separated list. Leave blank for all types', 'acf' ),
			'type'  => 'text',
			'name'  => 'mime_types',
		)
	);
}