wpcf7_is_number() │ CF7 1.0

Checks whether the given text is a well-formed number.

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

Возвращает

null. Ничего (null).

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

wpcf7_is_number( $text );
$text(обязательный)
.

Код wpcf7_is_number() CF7 6.2.4.1

function wpcf7_is_number( $text ) {
	$result = false;

	$patterns = array(
		'/^[-]?[0-9]+(?:[eE][+-]?[0-9]+)?$/',
		'/^[-]?(?:[0-9]+)?[.][0-9]+(?:[eE][+-]?[0-9]+)?$/',
	);

	foreach ( $patterns as $pattern ) {
		if ( preg_match( $pattern, $text ) ) {
			$result = true;
			break;
		}
	}

	return apply_filters( 'wpcf7_is_number', $result, $text );
}