Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#8851 closed defect (bug) (fixed)

invalid XHTML markup in get_search_form function in general-template.php

Reported by: jcraig90210's profile jcraig90210 Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

Old function:

function get_search_form() {

do_action( 'get_search_form' );

if ( != locate_template(array('searchform.php'), true) )

return;

$form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
<label class="hidden" for="s">' . ('Search') . '</label>
<div><input type="text" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
<input type="submit" id="searchsubmit" value="'.attribute_escape(
('Search')).'" />
</div>
</form>';

echo apply_filters('get_search_form', $form);

}

New Function:

function get_search_form() {

do_action( 'get_search_form' );

if ( != locate_template(array('searchform.php'), true) )

return;

$form = '<form method="get" id="searchform" action="' . get_option('home') . '/" >
<div><label class="hidden" for="s">' . ('Search') . '</label>
<input type="text" value="' . attribute_escape(apply_filters('the_search_query', get_search_query())) . '" name="s" id="s" />
<input type="submit" id="searchsubmit" value="'.attribute_escape(
('Search')).'" />
</div>
</form>';

echo apply_filters('get_search_form', $form);

}

Change History (2)

#1 @jcraig90210
16 years ago

Forgot to add. This corrects the fact that the search form doesn't validate according to XHTML standards. Will be correct for standard HTML as well.

#2 @azaozz
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10356]) Fix invalid HTML in get_search_form(), props jcraig90210, fixes #8851

Note: See TracTickets for help on using tickets.