Index: general-template.php
===================================================================
--- general-template.php	(revision 19598)
+++ general-template.php	(working copy)
@@ -131,43 +131,127 @@
 /**
  * Display search form.
  *
+ * This function is primarily used by themes that want to hardcode the search
+ * form into the sidebar and also by the search widget in WordPress.
+ *
  * Will first attempt to locate the searchform.php file in either the child or
  * the parent, then load it. If it doesn't exist, then the default search form
  * will be displayed. The default search form is HTML, which will be displayed.
- * There is a filter applied to the search form HTML in order to edit or replace
- * it. The filter is 'get_search_form'.
+ * 
+ * The 'get_search_form' action is fired when the function is called, which can
+ * be useful for outputting search-form dependent JavaScript or various formatting
+ * that applies to the beginning of the search form.
+ * 
+ * The 'search_form_defaults' filter is applied to the parsed argument array, 
+ * which can be useful for filtering the defaults in lieu of passing an argument 
+ * array directly to the function.
+ * 
+ * The 'get_search_form' filter applied to the search form HTML in order to edit 
+ * or replace it.
+ * 
+ * For consistency with other template-loading functions, the function will also 
+ * accept a string $name argument, that will be used to locate template
+ * searchform-$name.php.
+ * 
+ * For backward compatibility, the function will also accept a boolean $echo 
+ * argument, to determine if the search form is echoed (true) or returned (false).
  *
- * This function is primarily used by themes which want to hardcode the search
- * form into the sidebar and also by the search widget in WordPress.
- *
- * There is also an action that is called whenever the function is run called,
- * 'get_search_form'. This can be useful for outputting JavaScript that the
- * search relies on or various formatting that applies to the beginning of the
- * search. To give a few examples of what it can be used for.
- *
- * @since 2.7.0
- * @param boolean $echo Default to echo and not return the form.
+ * @since	2.7.0
+ * @param	array	$args	Array of arguments passed to the search form
  */
-function get_search_form($echo = true) {
+function get_search_form( $args = array() ) {
 	do_action( 'get_search_form' );
-
-	$search_form_template = locate_template('searchform.php');
+	
+	// Support searchform-$name.php
+	$form_template = false;
+	if ( isset( $args['template'] ) {
+		$form_template = $args['template'];
+	} else if ( is_string( $args ) ) {
+		$form_template = $args;
+	}
+	
+	// If a search form template is found, use it
+	$templates = array();	
+	if ( $form_template ) {
+		$templates[] = 'searchform-' . $form_template . '.php';
+	}
+	$templates[] = 'searchform.php';
+	
+	$search_form_template = locate_template( $templates );	
+	
 	if ( '' != $search_form_template ) {
-		require($search_form_template);
+		require( $search_form_template );
 		return;
 	}
 
-	$form = '<form role="search" method="get" id="searchform" action="' . esc_url( 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>';
+	// Define default arguments
+	$defaults = array(
+		'template'		=> null,
+		'id'			=> 's'
+		'container'		=> 'div',
+		'form_id'		=> 'searchform',
+		'label_atts'		=> array(
+			'class'			=> 'screen-reader-text'
+		),
+		'label_text'	=> __( 'Search for:' ),
+		'input_atts'	=> array(
+			'type'			=> 'text',
+			'value'			=> get_search_query()
+		),
+		'submit_atts'	=> array(
+			'type'			=> 'submit',
+			'value'			=> __( 'Search' ),
+		),
+		'echo'			=> true
+	);
+	
+	// Maintain backward compatibility with $echo = true
+	$echo = ( is_bool( $args ) ? $args : $args['echo'] );
+	$args = ( is_array( $args ) ? wp_parse_args( $args, $defaults ) : $defaults );
 
-	if ( $echo )
-		echo apply_filters('get_search_form', $form);
-	else
-		return apply_filters('get_search_form', $form);
+	// Allow search form arguments to be filtered
+	$args = apply_filters( 'search_form_defaults', $args );
+
+	// Label attributes
+	$label_atts = '';
+	foreach ( $args['label_atts'] as $att => $value ) {
+		$label_atts .= $att . '="' . esc_attr( $value ) . '"';
+	}
+	$label_atts = implode( ' ', $label_atts );
+	
+	// Input attributes
+	$input_atts = '';
+	foreach ( $args['input_atts'] as $att => $value ) {
+		$input_atts .= $att . '="' . esc_attr( $value ) . '"';
+	}
+	$input_atts = implode( ' ', $input_atts );
+	
+	// Submit attributes
+	$submit_atts = '';
+	foreach ( $args['submit_atts'] as $att => $value ) {
+		$submit_atts .= $att . '="' . esc_attr( $value ) . '"';
+	}
+	$submit_atts = implode( ' ', $submit_atts );
+
+	// Construct the form markup	
+	$form = '<form role="search" method="get" id="' . esc_attr( $args['form_id'] ) . '" action="' . esc_url( home_url( '/' ) ) . '" >';
+	if ( false != $args['container'] ) {
+		$form .= '<' . esc_attr( $args['container'] ) . '>';
+	}
+	$form .= '<label for="' . esc_attr( $args['id'] ) . '" ' . $label_atts . '>' . esc_attr( $args['label_text'] ) . '</label>';
+	$form .= '<input name="' . esc_attr( $args['id'] ) . '" id="' . esc_attr( $args['id'] ) . '" ' . $input_atts . ' />';
+	$form .= '<input id="' . esc_attr( $args['form_id'] ) . '" ' . $submit_atts . ' />';
+	if ( false != $args['container'] ) {
+		$form .= '</' . esc_attr( $args['container'] ) . '>';
+	}
+	$form .= '</form>';
+
+	// Echo or return	
+	if ( $echo ) {
+		echo apply_filters( 'get_search_form', $form );
+	} else {
+		return apply_filters( 'get_search_form', $form );
+	}
 }
 
 /**
