Make WordPress Core

Changeset 11274


Ignore:
Timestamp:
05/11/2009 07:48:56 PM (16 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-widgets.php

    r11254 r11274  
    180180    function widget( $args, $instance ) {
    181181        extract($args);
     182        $title = apply_filters('widget_title', $instance['title']);
     183
    182184        echo $before_widget;
     185        if ( $title )
     186            echo $before_title . $title . $after_title;
    183187
    184188        // Use current theme search form if it exists
     
    187191        echo $after_widget;
    188192    }
     193   
     194    function form( $instance ) {
     195        $instance = wp_parse_args( (array) $instance, array( 'title' => '') );
     196        $title = $instance['title'];
     197?>
     198        <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>
     199<?php
     200    }
     201   
     202    function update( $new_instance, $old_instance ) {
     203        $instance = $old_instance;
     204        $new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
     205        $instance['title'] = strip_tags($new_instance['title']);
     206        return $instance;
     207    }   
     208   
    189209}
    190210
Note: See TracChangeset for help on using the changeset viewer.