[wp-trac] [WordPress Trac] #14851: Add ¨searchform-{name}.php¨ support

WordPress Trac noreply at wordpress.org
Sat Mar 23 10:19:59 UTC 2013


#14851: Add ¨searchform-{name}.php¨ support
------------------------------------+-----------------------------
 Reporter:  ramiy                   |       Owner:  nacin
     Type:  enhancement             |      Status:  reviewing
 Priority:  normal                  |   Milestone:  Future Release
Component:  Template                |     Version:  3.1
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |
------------------------------------+-----------------------------

Comment (by ramiy):

 The patch with legacy check to return the search form:

 {{{
 function get_search_form( $name = null) {
         $default_search_form = '<form role="search" method="get"
 id="searchform" action="' . home_url( '/' ) . '" >
                 <div><label class="screen-reader-text" for="s">' .
 __('Search for:') . '</label>
                 <input type="text" value="' . get_search_query() . '"
 name="s" id="s" />
                 <input type="submit" id="searchsubmit" value="'.
 esc_attr__('Search') .'" />
                 </div>
                 </form>';

         // Legacy check to return the search form
         if ( ( is_bool( $name ) ) && ( $name = false ) ) {
                 return $default_search_form;
         }

         do_action( 'get_search_form', $name );

         $templates = array();
         if ( isset( $name ) )
                 $templates[] = "searchform-{$name}.php";

         $templates[] = "searchform.php";

         // if file doesn't exist, the default search form will be
 displayed
         if ( '' == locate_template( $templates, true ) )
                 echo $default_search_form;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14851#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list