WordPress.org

Make WordPress Core

Ticket #16539: 16539_searchform.2.2.diff

File 16539_searchform.2.2.diff, 9.0 KB (added by kurtpayne, 7 years ago)
  • wp-includes/general-template.php

     
    149149 * @param boolean $echo Default to echo and not return the form.
    150150 */
    151151function get_search_form($echo = true) {
     152        static $search_form_counter = 0;
     153        static $first_search_form = true;
     154
    152155        do_action( 'get_search_form' );
    153156
     157        if ($first_search_form) {
     158            $form_id = 'searchform';
     159            $text_id = 's';
     160            $submit_id = 'searchsubmit';
     161            $first_search_form = false;
     162        } else {
     163            $form_id = 'searchform-' . $search_form_counter;
     164            $text_id = 's-' . $search_form_counter;
     165            $submit_id = 'searchsubmit-' . $search_form_counter;
     166        }
     167
    154168        $search_form_template = locate_template('searchform.php');
    155169        if ( '' != $search_form_template ) {
    156170                require($search_form_template);
    157171                return;
    158172        }
    159173
    160         $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
    161         <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
    162         <input type="text" value="' . get_search_query() . '" name="s" id="s" />
    163         <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
     174        $form = '<form role="search" method="get" id="' . $form_id . '" class="searchform" action="' . home_url( '/' ) . '" >
     175        <div><label class="screen-reader-text" for="' . $text_id . '">' . __('Search for:') . '</label>
     176        <input type="text" class="searchinput field" value="' . get_search_query() . '" name="s" id="' . $text_id . '" />
     177        <input type="submit" class="searchsubmit submit" id="' . $submit_id . '" value="'. esc_attr__('Search') .'" />
    164178        </div>
    165179        </form>';
     180        $search_form_counter++;
    166181
    167182        if ( $echo )
    168183                echo apply_filters('get_search_form', $form);
  • wp-content/themes/twentyeleven/searchform.php

     
    1 <?php
    2 /**
    3  * The template for displaying search forms in Twenty Eleven
    4  *
    5  * @package WordPress
    6  * @subpackage Twenty_Eleven
    7  * @since Twenty Eleven 1.0
    8  */
    9 ?>
    10         <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    11                 <label for="s" class="assistive-text"><?php _e( 'Search', 'twentyeleven' ); ?></label>
    12                 <input type="text" class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Search', 'twentyeleven' ); ?>" />
    13                 <input type="submit" class="submit" name="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'twentyeleven' ); ?>" />
    14         </form>
  • wp-content/themes/twentyeleven/style.css

     
    278278        width: auto;
    279279}
    280280/* Make sure the logo and search form don't collide */
    281 .one-column #branding #searchform {
     281.one-column #branding #searchform,
     282.one-column #branding .searchform {
    282283        right: 40px;
    283284        top: 4em;
    284285}
     
    453454input[type=text] {
    454455        padding: 3px;
    455456}
    456 input#s {
     457input#s,
     458input.searchinput {
    457459        background: url(images/search.png) no-repeat 5px 6px;
    458460        -moz-border-radius: 2px;
    459461        border-radius: 2px;
     
    462464        line-height: 1.2em;
    463465        padding: 4px 10px 4px 28px;
    464466}
    465 input#searchsubmit {
     467input#searchsubmit,
     468input.searchsubmit {
    466469        display: none;
    467470}
    468471
     
    620623}
    621624
    622625/* Search Form */
    623 #branding #searchform {
     626#branding #searchform,
     627#branding .searchform {
    624628        position: absolute;
    625629        top: 3.8em;
    626630        right: 7.6%;
    627631        text-align: right;
    628632}
    629 #branding #searchform div {
     633#branding #searchform div,
     634#branding .searchform div {
    630635        margin: 0;
    631636}
    632 #branding #s {
     637#branding #s,
     638#branding .searchinput {
    633639        float: right;
    634640        -webkit-transition-duration: 400ms;
    635641        -webkit-transition-property: width, background;
     
    642648        -o-transition-timing-function: ease;
    643649        width: 72px;
    644650}
    645 #branding #s:focus {
     651#branding #s:focus,
     652#branding .searchinput:focus {
    646653        background-color: #f9f9f9;
    647654        width: 196px;
    648655}
    649 #branding #searchsubmit {
     656#branding #searchsubmit,
     657#branding .searchsubmit {
    650658        display: none;
    651659}
    652 #branding .only-search #searchform {
     660#branding .only-search #searchform,
     661#branding .only-search .searchform {
    653662        top: 5px;
    654663        z-index: 1;
    655664}
    656 #branding .only-search #s {
     665#branding .only-search #s,
     666#branding .only-search .searchinput {
    657667        background-color: #666;
    658668        border-color: #000;
    659669        color: #222;
    660670}
    661671#branding .only-search #s,
    662 #branding .only-search #s:focus {
     672#branding .only-search #s:focus,
     673#branding .only-search .searchinput,
     674#branding .only-search .searchinput:focus {
    663675        width: 85%;
    664676}
    665 #branding .only-search #s:focus {
     677#branding .only-search #s:focus,
     678#branding .only-search .searchinput:focus {
    666679        background-color: #bbb;
    667680}
    668 #branding .with-image #searchform {
     681#branding .with-image #searchform,
     682#branding .with-image .searchform {
    669683        top: auto;
    670684        bottom: -27px;
    671685        max-width: 195px;
     
    787801        border-top: 1px solid #ddd;
    788802        padding: 6px 10px 6px 0;
    789803}
    790 .entry-content #s {
     804.entry-content #s,
     805.entry-content .searchinput {
    791806        width: 75%;
    792807}
    793808.comment-content ul,
     
    12771292/* =error404
    12781293----------------------------------------------- */
    12791294
    1280 .error404 #main #searchform {
     1295.error404 #main #searchform,
     1296.error404 #main .searchform {
    12811297        background: #f9f9f9;
    12821298        border: 1px solid #ddd;
    12831299        border-width: 1px 0;
     
    12851301        overflow: hidden;
    12861302        padding: 1.625em 8.9%;
    12871303}
    1288 .error404 #main #s {
     1304.error404 #main #s,
     1305.error404 #main .searchinput {
    12891306        width: 95%;
    12901307}
    12911308.error404 #main .widget {
     
    17591776.widget_search form {
    17601777        margin: 0 0 1.625em;
    17611778}
    1762 .widget_search #s {
     1779.widget_search #searchsubmit,
     1780.widget_search .searchinput {
    17631781        width: 77%;
    17641782}
    1765 .widget_search #searchsubmit {
     1783.widget_search .searchsubmit {
    17661784        background: #ddd;
    17671785        border: 1px solid #ccc;
    17681786        -webkit-box-shadow: inset 0px -1px 1px rgba(0, 0, 0, 0.09);
     
    17741792        position: relative;
    17751793        top: -2px;
    17761794}
    1777 .widget_search #searchsubmit:active {
     1795.widget_search #searchsubmit:active,
     1796.widget_search .searchsubmit:active {
    17781797        background: #1982d1;
    17791798        border-color: #0861a5;
    17801799        -webkit-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.1);
     
    23992418                margin-right: 0;
    24002419        }
    24012420        /* Make sure the logo and search form don't collide */
    2402         #branding #searchform {
     2421        #branding #searchform,
     2422        #branding .searchform {
    24032423                top: 1.625em !important;
    24042424        }
    24052425        /* Floated content doesn't work well at this size */
     
    25132533        #site-description {
    25142534                font-size: 10pt;
    25152535        }
    2516         #branding #searchform {
     2536        #branding #searchform,
     2537        #branding .searchform {
    25172538                display: none;
    25182539        }
    25192540        #branding img {
  • wp-content/themes/twentyeleven/rtl.css

     
    5252        margin-right: 102px;
    5353}
    5454/* Make sure the logo and search form don't collide */
    55 .one-column #branding #searchform {
     55.one-column #branding form#searchform,
     56.one-column #branding form.searchform {
    5657        right: auto;
    5758        left: 40px;
    5859}
     
    99100        padding-left: 0;
    100101        padding-right: 3px;
    101102}
    102 input#s {
     103input#s,
     104input.searchinput {
    103105        background-position: 97% 6px;
    104106        padding: 4px 28px 4px 10px;
    105107}
     
    147149}
    148150
    149151/* Search Form */
    150 #branding #searchform {
     152#branding form#searchform,
     153#branding form.searchform {
    151154        right: auto;
    152155        left: 7.6%;
    153156        text-align: left;
    154157}
    155 #branding #s {
     158#branding #s,
     159#branding .searchinput {
    156160        float: left;
    157161}
    158162#branding .only-search + #access div {
  • wp-content/themes/twentyeleven/colors/dark.css

     
    4242input[type=text]:focus,
    4343textarea:focus {
    4444}
    45 input#s {
     45input#s,
     46input.searchinput {
    4647        background-color: #ddd;
    4748}
    4849
     
    6768#site-description {
    6869        color: #858585;
    6970}
    70 #branding #s {
     71#branding input#s,
     72#branding input.searchinput {
    7173        background-color: #ddd;
    7274}
    7375
     
    253255
    254256/* =error404
    255257----------------------------------------------- */
    256 .error404 #main #searchform {
     258.error404 #main #searchform,
     259.error404 #main .searchform {
    257260        background: #060606;
    258261        border-color: #222;
    259262}
     
    406409}
    407410
    408411/* Search Widget */
    409 .widget_search #searchsubmit {
     412.widget_search #searchsubmit,
     413.widget_search .searchsubmit {
    410414        background: #222;
    411415        border-color: #333;
    412416        -webkit-box-shadow: inset 0px -1px 1px rgba(0, 0, 0, 0.09);
     
    414418        box-shadow: inset 0px -1px 1px rgba(0, 0, 0, 0.09);
    415419        color: #777;
    416420}
    417 .widget_search #searchsubmit:active {
     421.widget_search #searchsubmit:active,
     422.widget_search .searchsubmit:active {
    418423        -webkit-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.1);
    419424        -moz-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.1);
    420425        box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.1);