Make WordPress Core

Ticket #15081: 15081.2.diff

File 15081.2.diff, 1.7 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
    161         $form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" >
    162         <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
    163         <input type="text" value="' . get_search_query() . '" name="s" id="s" />
    164         <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
     162        $type = ( 'html5' == strtolower( $format ) ) ? 'search' : 'text';
     163        $placeholder = ( 'html5' == strtolower( $format ) ) ? 'placeholder="' . esc_attr_x( 'Search &#x2026;', 'placeholder' ) . '" ' : '';
     164
     165        $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '" >
     166        <div><label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
     167        <input type="' . $type . '" ' . $placeholder . 'value="' . get_search_query() . '" name="s" id="s" />
     168        <input type="submit" id="searchsubmit" class="submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
    165169        </div>
    166170        </form>';
    167171