[wp-trac] [WordPress Trac] #16541: get_search_form() ignores $echo argument if searchform.php exists

WordPress Trac wp-trac at lists.automattic.com
Tue Dec 13 23:18:25 UTC 2011


#16541: get_search_form() ignores $echo argument if searchform.php exists
------------------------------------+------------------------------
 Reporter:  kawauso                 |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Template                |     Version:  3.0
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |
------------------------------------+------------------------------
Changes (by chipbennett):

 * cc: chip@… (added)


Comment:

 So, this could be a totally crazy idea (or totally stupid), but why not
 use `file_get_contents()`, and do something like:

 {{{
 $search_form_template = locate_template( 'searchform.php' );
 if ( '' != $search_form_template ) {
         $form = file_get_contents( $search_form_template );
 } else {
         // Default form handling goes here
 }

 if ( $echo ) {
         echo apply_filters('get_search_form', $form);
 } else {
         return apply_filters('get_search_form', $form);
 }
 }}}

 That way, both the searchform.php form, as a string, ''and'' the default
 form, also as a string, get passed through the `get_search_form` filter.

 Is there some performance and/or security issue with using
 `file_get_contents()`, or something else that I'm missing?

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


More information about the wp-trac mailing list