Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_search_form

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
144  * 'get_search_form'. This can be useful for outputting JavaScript that the
145  * search relies on or various formatting that applies to the beginning of the
146  * search. To give a few examples of what it can be used for.
147  *
148  * @since 2.7.0
149  * @param boolean $echo Default to echo and not return the form.
150  * @return string|null String when retrieving, null when displaying or if searchform.php exists.
151  */
152 function get_search_form($echo = true) {
153      do_action( 'get_search_form' );
154
155      $search_form_template = locate_template('searchform.php');
156      if ( '' != $search_form_template ) {
157           require($search_form_template);
158           return;
159      }
160
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>
166      </form>';
167
168      if ( $echo )
169           echo apply_filters('get_search_form', $form);
170      else
171           return apply_filters('get_search_form', $form);
172 }
173
174 /**
175  * Display the Log In/Out link.
176  *
177  * Displays a link, which allows users to navigate to the Log In page to log in
178  * or log out depending on whether they are currently logged in.
179  *
180  * @since 1.5.0