Make WordPress Core

Ticket #7910: get_search_tag.2.diff

File get_search_tag.2.diff, 2.3 KB (added by technosailor, 17 years ago)

change to get_search_form to avoid possible collision of function names with query

  • wp-content/themes/default/searchform.php

     
    1 <?php
    2 /**
    3  * @package WordPress
    4  * @subpackage Default_Theme
    5  */
    6 ?>
    7 <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    8 <label class="hidden" for="s"><?php _e('Search for:'); ?></label>
    9 <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    10 <input type="submit" id="searchsubmit" value="Search" />
    11 </div>
    12 </form>
  • wp-includes/general-template.php

     
    9393                load_template( get_theme_root() . '/default/sidebar.php');
    9494}
    9595
     96function get_search_form() {
     97        do_action( 'get_search' );
     98        if('' == locate_template(array('searchform.php'), true))
     99        {
     100                $form = '<form method="get" id="searchform" action="' . get_option('siteurl') . '/" >
     101                <label class="hidden" for="s">' . __('Search for:') . '</label>
     102                <div><input type="text" value="' . the_search_query() . '" name="s" id="s" />
     103                <input type="submit" id="searchsubmit" value="Search" />
     104                </div>
     105                </form>';
     106        }
     107        echo apply_filters('get_searchform', $form);
     108}
     109
    96110/**
    97111 * Display the Log In/Out link.
    98112 *
  • wp-includes/widgets.php

     
    763763 */
    764764function wp_widget_search($args) {
    765765        extract($args);
    766         $searchform_template = get_template_directory() . '/searchform.php';
    767 
    768766        echo $before_widget;
    769767
    770768        // Use current theme search form if it exists
    771         if ( file_exists($searchform_template) ) {
    772                 include_once($searchform_template);
    773         } else { ?>
    774                 <form id="searchform" method="get" action="<?php bloginfo('url'); ?>/"><div>
    775                         <label class="hidden" for="s"><?php _e('Search for:'); ?></label>
    776                         <input type="text" name="s" id="s" size="15" value="<?php the_search_query(); ?>" />
    777                         <input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" />
    778                 </div></form>
    779         <?php }
    780 
     769        get_search_form();
     770       
    781771        echo $after_widget;
    782772}
    783773