Add title option to search widget. Props hakre. fixes #9756

git-svn-id: http://svn.automattic.com/wordpress/trunk@11274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-05-11 19:48:56 +00:00
parent e56e677ec1
commit 69bc51b14a
1 changed files with 20 additions and 0 deletions

View File

@ -179,13 +179,33 @@ class WP_Widget_Search extends WP_Widget {
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
// Use current theme search form if it exists
get_search_form();
echo $after_widget;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
$title = $instance['title'];
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
<?php
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
}
/**