Community Forums › Forums › Archived Forums › Design Tips and Tricks › Search widget Validation Warning!
Tagged: genesis search section, Search widget, validation
- This topic has 1 reply, 2 voices, and was last updated 9 years, 6 months ago by Christoph.
-
AuthorPosts
-
June 24, 2015 at 9:59 am #157403PhillipDewsBloggerMember
I have been developing a child-theme on the genesis framework for a national blind charity and my brief included the criterion that the site passes website accesibility tests To WAI WCAG-AA and the W3C HTML5 Valaidation.
I got most of it done now but I have added the search widget to the top right header widget! I did customise it slightly in my functions.php file with this code....
add_filter( 'genesis_search_text', 'custom_search_text' ); function custom_search_text($text) { return esc_attr( 'Search NFBUK' ); }
Bit I am still getting a validation warning on that serch wiget! more specifically the section area.... Heere is the warning....
Warning: Section lacks heading. Consider using h2-h6 elements to add identifying headings to all sections.and here is the code the validation checker provides...
get-area"><section↩id="search-3" class="widget widget_search"><div↩c
I would still love to use this widget as it works really well on the site, but does any of you know how I can stop this warning by editing the code...
Many thanks!
- Phillip DewsJuly 2, 2015 at 10:39 pm #158253ChristophMemberHi Philip,
this great plugin takes care of most of the accessibility issues of the current Genesis version:
It includes a section just for the search widget:
/** forms.php * Description: Adds label and id to the search forms * Author: Rian Rietveld * Plugin URI: http://genesis-accessible.org/ * License: GPLv2 or later */ //* Replace the search form, function adds a real label and an id for the search input field //* Based on the genesis_search_form with Genesis 2.0.2, keeps the filters add_filter( 'get_search_form', 'wpaccgen_get_search_form_uniqueid', 20 ); /** * Replace the default search form with a Genesis-specific accessible form. * * The exact output depends on whether the child theme supports HTML5 or not. * * Applies the <code>genesis_search_text</code>, <code>genesis_search_button_text</code>, <code>genesis_search_form_label</code> and * <code>genesis_search_form</code> filters. * * @since 0.2.0 * * @uses genesis_html5() Check for HTML5 support. * * @return string HTML markup. */ function wpaccgen_get_search_form_uniqueid() { $search_text = get_search_query() ? apply_filters( 'the_search_query', get_search_query() ) : apply_filters( 'genesis_search_text', __( 'Search this website', 'genesis' ) . '…' ); $button_text = apply_filters( 'genesis_search_button_text', esc_attr__( 'Search', 'genesis' ) ); $onfocus = "if ('" . esc_js( $search_text ) . "' === this.value) {this.value = '';}"; $onblur = "if ('' === this.value) {this.value = '" . esc_js( $search_text ) . "';}"; //* Generate ramdom id for the search field (n case there are more than one search form on the page) $form_id = uniqid( 'searchform-' ); //* Empty label, by default. Filterable. $label = apply_filters( 'genesis_search_form_label', '' ); if ( '' == $label ) { $label = apply_filters( 'genesis_search_text', __( 'Search this website', 'genesis' ) ); } $value_or_placeholder = ( get_search_query() == '' ) ? 'placeholder' : 'value'; if ( genesis_html5() ) { if ( function_exists( 'genesis_a11y' ) ) { $form = sprintf( '<form %s>', genesis_attr( 'search-form' ) ); } else { $form = sprintf( '<form method="get" class="search-form" action="%s" role="search">', home_url( '/' ) ); } $form .= sprintf( '<meta itemprop="target" content="%s"/><label for="%s">%s</label><input itemprop="query-input" type="search" name="s" id="%s" %s="%s" /><input type="submit" value="%s" /></form>', home_url( '/?s={s}' ), esc_attr( $form_id ), esc_html( $label ), esc_attr( $form_id ), $value_or_placeholder, esc_attr( $search_text ), esc_attr( $button_text ) ); } else { $form = sprintf( '<form method="get" class="searchform search-form" action="%s" role="search" >%s<input type="text" value="%s" name="s" id="%s" class="s search-input" onfocus="%s" onblur="%s" /><input type="submit" class="searchsubmit search-submit" value="%s" /></form>', home_url( '/' ), $label, $id, esc_attr( $search_text ), esc_attr( $onfocus ), esc_attr( $onblur ), esc_attr( $button_text ) ); } return apply_filters( 'genesis_search_form', $form, $search_text, $button_text, $label ); }
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.