WPCF7_ContactForm::screen_reader_response()publicCF7 1.0

Returns the response output that is only accessible from screen readers.

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

Хуков нет.

Возвращает

null. Ничего.

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

$WPCF7_ContactForm = new WPCF7_ContactForm();
$WPCF7_ContactForm->screen_reader_response();

Код WPCF7_ContactForm::screen_reader_response() CF7 5.7.3

public function screen_reader_response() {
	$primary_response = '';
	$validation_errors = array();

	if ( $this->is_posted() ) { // Post response output for non-AJAX
		$submission = WPCF7_Submission::get_instance();
		$primary_response = $submission->get_response();

		if ( $invalid_fields = $submission->get_invalid_fields() ) {
			foreach ( (array) $invalid_fields as $name => $field ) {
				$list_item = esc_html( $field['reason'] );

				if ( $field['idref'] ) {
					$list_item = sprintf(
						'<a href="#%1$s">%2$s</a>',
						esc_attr( $field['idref'] ),
						$list_item
					);
				}

				$validation_error_id = wpcf7_get_validation_error_reference(
					$name,
					$this->unit_tag()
				);

				if ( $validation_error_id ) {
					$list_item = sprintf(
						'<li id="%1$s">%2$s</li>',
						esc_attr( $validation_error_id ),
						$list_item
					);

					$validation_errors[] = $list_item;
				}
			}
		}
	}

	$primary_response = sprintf(
		'<p role="status" aria-live="polite" aria-atomic="true">%s</p>',
		esc_html( $primary_response )
	);

	$validation_errors = sprintf(
		'<ul>%s</ul>',
		implode( "\n", $validation_errors )
	);

	$output = sprintf(
		'<div class="screen-reader-response">%1$s %2$s</div>',
		$primary_response,
		$validation_errors
	);

	return $output;
}