wpcf7_enctype_value()CF7 1.0

Returns an enctype attribute value.

Хуков нет.

Возвращает

Строку. Enctype value. Empty if not a valid enctype.

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

wpcf7_enctype_value( $enctype );
$enctype(строка) (обязательный)
Enctype value.

Код wpcf7_enctype_value() CF7 5.9.3

function wpcf7_enctype_value( $enctype ) {
	$enctype = trim( $enctype );

	if ( empty( $enctype ) ) {
		return '';
	}

	$valid_enctypes = array(
		'application/x-www-form-urlencoded',
		'multipart/form-data',
		'text/plain',
	);

	if ( in_array( $enctype, $valid_enctypes ) ) {
		return $enctype;
	}

	$pattern = '%^enctype="(' . implode( '|', $valid_enctypes ) . ')"$%';

	if ( preg_match( $pattern, $enctype, $matches ) ) {
		return $matches[1]; // for back-compat
	}

	return '';
}