Make WordPress Core

Ticket #16539: 16539-6.patch

File 16539-6.patch, 2.2 KB (added by WraithKenny, 12 years ago)
  • wp-includes/general-template.php

     
    151151 * @return string|null String when retrieving, null when displaying or if searchform.php exists.
    152152 */
    153153function get_search_form( $echo = true, $format = 'xhtml' ) {
     154        static $search_form_counter = 0;
     155
    154156        do_action( 'get_search_form' );
    155157
     158        // Initialize the values
     159        if ( 'html5' === $format ) {
     160                $type        = 'search';
     161                $placeholder = 'placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" ';
     162                $form_id     = '';
     163                $submit_id   = '';
     164        } else {
     165                $type        = 'text';
     166                $placeholder = '';
     167                $form_id     = $search_form_counter ? '' : ' id="searchform"';
     168                $submit_id   = $search_form_counter ? '' : ' id="searchsubmit"';
     169        }
     170        $text_id = $search_form_counter ? 's-' . $search_form_counter : 's';
     171
     172        $search_form_counter++;
     173
    156174        $search_form_template = locate_template( 'searchform.php' );
    157175        if ( '' != $search_form_template ) {
    158176                ob_start();
    159177                require( $search_form_template );
    160178                $form = ob_get_clean();
    161179        } else {
    162                 $type        = ( 'html5' === $format ) ? 'search' : 'text';
    163                 $placeholder = ( 'html5' === $format ) ? 'placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" ' : '';
    164 
    165                 $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
     180                $form = '<form role="search" method="get"' . $form_id . ' class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
    166181                        <div>
    167                                 <label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
    168                                 <input type="' . $type . '" ' . $placeholder . 'value="' . get_search_query() . '" name="s" id="s" />
    169                                 <input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
     182                                <label class="screen-reader-text" for="' . $text_id . '">' . _x( 'Search for:', 'label' ) . '</label>
     183                                <input type="' . $type . '" ' . $placeholder . 'value="' . get_search_query() . '" name="s" id="' . $text_id . '" />
     184                                <input type="submit"' . $submit_id . ' value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
    170185                        </div>
    171186                </form>';
    172187        }