Make WordPress Core

Ticket #15081: 15081.diff

File 15081.diff, 1.3 KB (added by georgestephanis, 12 years ago)
  • wp-includes/general-template.php

     
    147147 *
    148148 * @since 2.7.0
    149149 * @param boolean $echo Default to echo and not return the form.
     150 * @param string $format What type to use for the search field. If set to 'html5' it changes to type="search".
    150151 * @return string|null String when retrieving, null when displaying or if searchform.php exists.
    151152 */
    152 function get_search_form($echo = true) {
     153function get_search_form( $echo = true, $format = 'xhtml' ) {
    153154        do_action( 'get_search_form' );
    154155
    155156        $search_form_template = locate_template('searchform.php');
     
    158159                return;
    159160        }
    160161
     162        $type = ( 'html5' == strtolower( $format ) ) ? 'search' : 'text';
     163
    161164        $form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" >
    162165        <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
    163         <input type="text" value="' . get_search_query() . '" name="s" id="s" />
     166        <input type="' . $type . '" value="' . get_search_query() . '" name="s" id="s" />
    164167        <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
    165168        </div>
    166169        </form>';