diff --git wp-includes/general-template.php wp-includes/general-template.php
index 7b311b6..d5efff3 100644
|
|
|
function get_template_part( $slug, $name = null ) { |
| 174 | 174 | * |
| 175 | 175 | * @since 2.7.0 |
| 176 | 176 | * |
| 177 | | * @param bool $echo Default to echo and not return the form. |
| 178 | | * @return string|void String when $echo is false. |
| | 177 | * @param array $args Default args are to echo and include no custom label. |
| | 178 | * @return string|void String when $args['echo'] is false. |
| 179 | 179 | */ |
| 180 | | function get_search_form( $echo = true ) { |
| | 180 | function get_search_form( $args = array() ) { |
| 181 | 181 | /** |
| 182 | 182 | * Fires before the search form is retrieved, at the start of get_search_form(). |
| 183 | 183 | * |
| … |
… |
function get_search_form( $echo = true ) { |
| 200 | 200 | */ |
| 201 | 201 | $format = apply_filters( 'search_form_format', $format ); |
| 202 | 202 | |
| | 203 | /* |
| | 204 | Back compat: to ensure previous uses of get_search_form continue to |
| | 205 | function as expected first check if we have an array. If not treat as |
| | 206 | booleen - and if it's not explicitly FALSE then assume we want to echo. |
| | 207 | */ |
| | 208 | if( ! is_array( $args ) && ! false === $args ){ |
| | 209 | // we can set an empty array and allow default args to take over. |
| | 210 | $args = array(); |
| | 211 | } |
| | 212 | |
| | 213 | // defaults are to echo and to output no custom label on the landmark. |
| | 214 | $defaults = array( |
| | 215 | 'echo' => true, |
| | 216 | 'label' => false, |
| | 217 | ); |
| | 218 | |
| | 219 | // merge any args with the defaults. |
| | 220 | $args = wp_parse_args( $args, $defaults ); |
| | 221 | |
| | 222 | /** |
| | 223 | * Filters the array of args used when generating the search form. |
| | 224 | * |
| | 225 | * @since NEW |
| | 226 | * |
| | 227 | * @param array $args The array of args used when building the search form. |
| | 228 | */ |
| | 229 | $result = apply_filters( 'search_form_args', $args ); |
| | 230 | |
| 203 | 231 | $search_form_template = locate_template( 'searchform.php' ); |
| 204 | 232 | if ( '' != $search_form_template ) { |
| 205 | 233 | ob_start(); |
| 206 | 234 | require( $search_form_template ); |
| 207 | 235 | $form = ob_get_clean(); |
| 208 | 236 | } else { |
| | 237 | // form a string containaing a label to use for the search role. |
| | 238 | if( $args['label'] ){ |
| | 239 | $label = 'aria-label="' . esc_attr( $args['label'] ) . '" '; |
| | 240 | } else { |
| | 241 | // if there is no custom label we can set a default here. ATM it is |
| | 242 | // empty as there's uncertainty about what the default should be. |
| | 243 | $label = ''; |
| | 244 | } |
| 209 | 245 | if ( 'html5' == $format ) { |
| 210 | | $form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '"> |
| | 246 | $form = '<form role="search" ' . $label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '"> |
| 211 | 247 | <label> |
| 212 | 248 | <span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span> |
| 213 | 249 | <input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" /> |
| … |
… |
function get_search_form( $echo = true ) { |
| 215 | 251 | <input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" /> |
| 216 | 252 | </form>'; |
| 217 | 253 | } else { |
| 218 | | $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '"> |
| | 254 | $form = '<form role="search" ' . $label . 'method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '"> |
| 219 | 255 | <div> |
| 220 | 256 | <label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label> |
| 221 | 257 | <input type="text" value="' . get_search_query() . '" name="s" id="s" /> |
| … |
… |
function get_search_form( $echo = true ) { |
| 237 | 273 | if ( null === $result ) |
| 238 | 274 | $result = $form; |
| 239 | 275 | |
| 240 | | if ( $echo ) |
| | 276 | if ( array_key_exists( 'echo', $args ) && $args['echo'] ) |
| 241 | 277 | echo $result; |
| 242 | 278 | else |
| 243 | 279 | return $result; |