In the HTML outputted from get_search_form(): remove incrementing the IDs for XHTML after the first call, remove the <div> wrapper for HTML5. Props obenland, props bpetty. Fixes #16539
git-svn-id: http://core.svn.wordpress.org/trunk@23916 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c7dabe0e5d
commit
49f185ae09
|
@ -153,17 +153,10 @@ function get_template_part( $slug, $name = null ) {
|
|||
* @return string|null String when retrieving, null when displaying or if searchform.php exists.
|
||||
*/
|
||||
function get_search_form( $echo = true ) {
|
||||
static $search_form_counter = 0;
|
||||
|
||||
do_action( 'pre_get_search_form' );
|
||||
|
||||
$format = apply_filters( 'search_form_format', 'xhtml' );
|
||||
|
||||
// Initialize the values
|
||||
$form_id = $search_form_counter ? '' : ' id="searchform"';
|
||||
$submit_id = $search_form_counter ? '' : ' id="searchsubmit"';
|
||||
$text_id = $search_form_counter ? 's-' . $search_form_counter : 's';
|
||||
|
||||
$search_form_template = locate_template( 'searchform.php' );
|
||||
if ( '' != $search_form_template ) {
|
||||
ob_start();
|
||||
|
@ -171,21 +164,19 @@ function get_search_form( $echo = true ) {
|
|||
$form = ob_get_clean();
|
||||
} else {
|
||||
if ( 'html5' == $format ) {
|
||||
$form = '<form role="search" method="get" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
||||
<div>
|
||||
<label><span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
|
||||
<input type="search" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . _x( 'Search for:', 'label' ) . '" />
|
||||
</label>
|
||||
<input type="submit" class="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
|
||||
</div>
|
||||
</form>';
|
||||
} else {
|
||||
$form = '<form role="search" method="get"' . $form_id . ' class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
||||
<div>
|
||||
<label class="screen-reader-text" for="' . $text_id . '">' . _x( 'Search for:', 'label' ) . '</label>
|
||||
<input type="text" value="' . get_search_query() . '" name="s" id="' . $text_id . '" />
|
||||
<input type="submit"' . $submit_id . ' value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
|
||||
</div>
|
||||
$form = '<form role="search" method="get" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
||||
<label><span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
|
||||
<input type="search" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . _x( 'Search for:', 'label' ) . '" />
|
||||
</label>
|
||||
<input type="submit" class="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
|
||||
</form>';
|
||||
} else {
|
||||
$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
||||
<div>
|
||||
<label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
|
||||
<input type="text" value="' . get_search_query() . '" name="s" id="s" />
|
||||
<input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
|
||||
</div>
|
||||
</form>';
|
||||
}
|
||||
}
|
||||
|
@ -194,8 +185,6 @@ function get_search_form( $echo = true ) {
|
|||
if ( null === $result )
|
||||
$result = $form;
|
||||
|
||||
$search_form_counter++;
|
||||
|
||||
if ( $echo )
|
||||
echo $result;
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue