Yoast_Input_Validation::yoast_form_control_has_error()public staticYoast 12.1

Checks whether a specific form input field was submitted with an invalid value.

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

Хуков нет.


true|false. Whether or not the submitted input field contained an invalid value.


$result = Yoast_Input_Validation::yoast_form_control_has_error( $error_code );
$error_code(строка) (обязательный)
Must be the same slug-name used for the field variable and for add_settings_error().

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

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

Код Yoast_Input_Validation::yoast_form_control_has_error() Yoast 22.1

public static function yoast_form_control_has_error( $error_code ) {
	$errors = get_settings_errors();

	foreach ( $errors as $error ) {
		if ( $error['code'] === $error_code ) {
			return true;

	return false;