mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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.
|
* @return string|null String when retrieving, null when displaying or if searchform.php exists.
|
||||||
*/
|
*/
|
||||||
function get_search_form( $echo = true ) {
|
function get_search_form( $echo = true ) {
|
||||||
static $search_form_counter = 0;
|
|
||||||
|
|
||||||
do_action( 'pre_get_search_form' );
|
do_action( 'pre_get_search_form' );
|
||||||
|
|
||||||
$format = apply_filters( 'search_form_format', 'xhtml' );
|
$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' );
|
$search_form_template = locate_template( 'searchform.php' );
|
||||||
if ( '' != $search_form_template ) {
|
if ( '' != $search_form_template ) {
|
||||||
ob_start();
|
ob_start();
|
||||||
@ -171,21 +164,19 @@ function get_search_form( $echo = true ) {
|
|||||||
$form = ob_get_clean();
|
$form = ob_get_clean();
|
||||||
} else {
|
} else {
|
||||||
if ( 'html5' == $format ) {
|
if ( 'html5' == $format ) {
|
||||||
$form = '<form role="search" method="get" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
$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>
|
||||||
<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' ) . '" />
|
||||||
<input type="search" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . _x( 'Search for:', 'label' ) . '" />
|
</label>
|
||||||
</label>
|
<input type="submit" class="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
|
||||||
<input type="submit" class="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
|
</form>';
|
||||||
</div>
|
} else {
|
||||||
</form>';
|
$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
||||||
} else {
|
<div>
|
||||||
$form = '<form role="search" method="get"' . $form_id . ' class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
|
<label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
|
||||||
<div>
|
<input type="text" value="' . get_search_query() . '" name="s" id="s" />
|
||||||
<label class="screen-reader-text" for="' . $text_id . '">' . _x( 'Search for:', 'label' ) . '</label>
|
<input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
|
||||||
<input type="text" value="' . get_search_query() . '" name="s" id="' . $text_id . '" />
|
</div>
|
||||||
<input type="submit"' . $submit_id . ' value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
|
|
||||||
</div>
|
|
||||||
</form>';
|
</form>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,8 +185,6 @@ function get_search_form( $echo = true ) {
|
|||||||
if ( null === $result )
|
if ( null === $result )
|
||||||
$result = $form;
|
$result = $form;
|
||||||
|
|
||||||
$search_form_counter++;
|
|
||||||
|
|
||||||
if ( $echo )
|
if ( $echo )
|
||||||
echo $result;
|
echo $result;
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user