Changeset 23667
- Timestamp:
- 03/12/2013 10:25:08 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r23666 r23667 148 148 * @since 2.7.0 149 149 * @param boolean $echo Default to echo and not return the form. 150 * @param string $format Which type to use for the search field. If set to 'html5' it changes to search input type and adds placeholder text. 150 151 * @return string|null String when retrieving, null when displaying or if searchform.php exists. 151 152 */ 152 function get_search_form( $echo = true) {153 function get_search_form( $echo = true, $format = 'xhtml' ) { 153 154 do_action( 'get_search_form' ); 154 155 155 $search_form_template = locate_template( 'searchform.php');156 $search_form_template = locate_template( 'searchform.php' ); 156 157 if ( '' != $search_form_template ) { 157 158 ob_start(); 158 require( $search_form_template);159 require( $search_form_template ); 159 160 $form = ob_get_clean(); 160 161 } else { 161 $form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" > 162 <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label> 163 <input type="text" value="' . get_search_query() . '" name="s" id="s" /> 164 <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" /> 165 </div> 162 $type = ( 'html5' === $format ) ? 'search' : 'text'; 163 $placeholder = ( 'html5' === $format ) ? 'placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" ' : ''; 164 165 $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '"> 166 <div> 167 <label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label> 168 <input type="' . $type . '" ' . $placeholder . 'value="' . get_search_query() . '" name="s" id="s" /> 169 <input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" /> 170 </div> 166 171 </form>'; 167 172 } 168 173 169 174 if ( $echo ) 170 echo apply_filters( 'get_search_form', $form);175 echo apply_filters( 'get_search_form', $form ); 171 176 else 172 return apply_filters( 'get_search_form', $form);177 return apply_filters( 'get_search_form', $form ); 173 178 } 174 179
Note: See TracChangeset
for help on using the changeset viewer.