WordPress.org

Make WordPress Core

Ticket #16541: 16541.2.diff

File 16541.2.diff, 1.2 KB (added by garyc40, 7 years ago)

pass the form content through get_search_form filter no matter what $echo is

  • wp-includes/general-template.php

    diff --git wp-includes/general-template.php wp-includes/general-template.php
    index 19194f2..cc40984 100644
    function get_search_form($echo = true) { 
    153153
    154154        $search_form_template = locate_template('searchform.php');
    155155        if ( '' != $search_form_template ) {
     156                ob_start();
    156157                require($search_form_template);
    157                 return;
     158                $form = ob_get_clean();
     159        } else {
     160                $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
     161                <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
     162                <input type="text" value="' . get_search_query() . '" name="s" id="s" />
     163                <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
     164                </div>
     165                </form>';
    158166        }
    159167
    160         $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
    161         <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
    162         <input type="text" value="' . get_search_query() . '" name="s" id="s" />
    163         <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
    164         </div>
    165         </form>';
    166 
    167168        if ( $echo )
    168169                echo apply_filters('get_search_form', $form);
    169170        else