Make WordPress Core

Ticket #16539: 16539-7.patch

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

     
    153153 * @return string|null String when retrieving, null when displaying or if searchform.php exists.
    154154 */
    155155function get_search_form( $echo = true ) {
     156        static $search_form_counter = 0;
     157
    156158        do_action( 'pre_get_search_form' );
    157159
    158160        $format = apply_filters( 'search_form_format', 'xhtml' );
    159161
     162        // Initialize the values
     163        $form_id   = $search_form_counter ? '' : ' id="searchform"';
     164        $submit_id = $search_form_counter ? '' : ' id="searchsubmit"';
     165        $text_id   = $search_form_counter ? 's-' . $search_form_counter : 's';
     166
    160167        $search_form_template = locate_template( 'searchform.php' );
    161168        if ( '' != $search_form_template ) {
    162169                ob_start();
    163170                require( $search_form_template );
    164171                $form = ob_get_clean();
    165172        } else {
    166                 $type        = ( 'html5' === $format ) ? 'search' : 'text';
    167                 $placeholder = ( 'html5' === $format ) ? 'placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" ' : '';
    168 
    169                 $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
    170                         <div>
    171                                 <label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
    172                                 <input type="' . $type . '" ' . $placeholder . 'value="' . get_search_query() . '" name="s" id="s" />
    173                                 <input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
    174                         </div>
    175                 </form>';
     173                if ( 'html5' == $format ) {
     174                        $form = '<form role="search" method="get" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
     175                                <div>
     176                                        <label><span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
     177                                                <input type="search" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . _x( 'Search for:', 'label' ) . '" />
     178                                        </label>
     179                                        <input type="submit" class="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
     180                                </div>
     181                        </form>';
     182                } else {
     183                        $form = '<form role="search" method="get"' . $form_id . ' class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
     184                                <div>
     185                                        <label class="screen-reader-text" for="' . $text_id . '">' . _x( 'Search for:', 'label' ) . '</label>
     186                                        <input type="text" value="' . get_search_query() . '" name="s" id="' . $text_id . '" />
     187                                        <input type="submit"' . $submit_id . ' value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
     188                                </div>
     189                        </form>';
     190                }
    176191        }
    177192
    178193        $result = apply_filters( 'get_search_form', $form );
    179194        if ( null === $result )
    180195                $result = $form;
    181196
     197        $search_form_counter++;
     198
    182199        if ( $echo )
    183200                echo $result;
    184201        else