Skip to content
This repository
Browse code

Minor cleanup and updates.

git-svn-id: http://svn.locallylost.com/themes/hybrid-core/trunk@1000 dba0f204-706d-4bc1-bc29-8b92e0485636
  • Loading branch information...
commit 3f8bc666cc18b0cbdbf0e4a28231316b04ee27ee 1 parent e1cf426
greenshady authored

Showing 1 changed file with 19 additions and 16 deletions. Show diff stats Hide diff stats

  1. +19 16 classes/widget-search.php
35 classes/widget-search.php
@@ -17,12 +17,12 @@
17 17 * Search Widget Class
18 18 *
19 19 * @since 0.6.0
20   - * @link http://themehybrid.com/themes/hybrid/widgets
21 20 */
22 21 class Hybrid_Widget_Search extends WP_Widget {
23 22
24 23 /**
25 24 * Set up the widget's unique name, ID, class, description, and other options.
  25 + *
26 26 * @since 1.2.0
27 27 */
28 28 function __construct() {
@@ -50,10 +50,11 @@ function __construct() {
50 50
51 51 /**
52 52 * Outputs the widget based on the arguments input through the widget controls.
53   - * @since 0.6
  53 + *
  54 + * @since 0.6.0
54 55 */
55   - function widget( $args, $instance ) {
56   - extract( $args );
  56 + function widget( $sidebar, $instance ) {
  57 + extract( $sidebar );
57 58
58 59 /* Output the theme's $before_widget wrapper. */
59 60 echo $before_widget;
@@ -71,31 +72,30 @@ function widget( $args, $instance ) {
71 72 else {
72 73
73 74 /* Set up some variables for the search form. */
74   - global $search_form_num;
75   - $search_num = ( ( $search_form_num ) ? '-' . esc_attr( $search_form_num ) : '' );
  75 + if ( empty( $instance['search_text'] ) )
  76 + $instance['search_text'] = '';
  77 +
76 78 $search_text = ( ( is_search() ) ? esc_attr( get_search_query() ) : esc_attr( $instance['search_text'] ) );
77 79
78 80 /* Open the form. */
79   - $search = '<form method="get" class="search-form" id="search-form' . $search_num . '" action="' . home_url() . '/"><div>';
  81 + $search = '<form method="get" class="search-form" id="search-form' . esc_attr( $this->id_base ) . '" action="' . home_url() . '/"><div>';
80 82
81 83 /* If a search label was set, add it. */
82 84 if ( !empty( $instance['search_label'] ) )
83   - $search .= '<label for="search-text' . $search_num . '">' . $instance['search_label'] . '</label>';
  85 + $search .= '<label for="search-text' . esc_attr( $this->id_base ) . '">' . $instance['search_label'] . '</label>';
84 86
85 87 /* Search form text input. */
86   - $search .= '<input class="search-text" type="text" name="s" id="search-text' . $search_num . '" value="' . $search_text . '" onfocus="if(this.value==this.defaultValue)this.value=\'\';" onblur="if(this.value==\'\')this.value=this.defaultValue;" />';
  88 + $search .= '<input class="search-text" type="text" name="s" id="search-text' . esc_attr( $this->id_base ) . '" value="' . $search_text . '" onfocus="if(this.value==this.defaultValue)this.value=\'\';" onblur="if(this.value==\'\')this.value=this.defaultValue;" />';
87 89
88 90 /* Search form submit button. */
89 91 if ( $instance['search_submit'] )
90   - $search .= '<input class="search-submit button" name="submit" type="submit" id="search-submit' . $search_num . '" value="' . esc_attr( $instance['search_submit'] ) . '" />';
  92 + $search .= '<input class="search-submit button" name="submit" type="submit" id="search-submit' . esc_attr( $this->id_base ). '" value="' . esc_attr( $instance['search_submit'] ) . '" />';
91 93
92 94 /* Close the form. */
93   - $search .= '</div></form><!-- .search-form -->';
  95 + $search .= '</div></form>';
94 96
95 97 /* Display the form. */
96 98 echo $search;
97   -
98   - $search_form_num++;
99 99 }
100 100
101 101 /* Close the theme's widget wrapper. */
@@ -104,10 +104,12 @@ function widget( $args, $instance ) {
104 104
105 105 /**
106 106 * Updates the widget control options for the particular instance of the widget.
107   - * @since 0.6
  107 + *
  108 + * @since 0.6.0
108 109 */
109 110 function update( $new_instance, $old_instance ) {
110   - $instance = $old_instance;
  111 + $instance = $new_instance;
  112 +
111 113 $instance['title'] = strip_tags( $new_instance['title'] );
112 114 $instance['search_label'] = strip_tags( $new_instance['search_label'] );
113 115 $instance['search_text'] = strip_tags( $new_instance['search_text'] );
@@ -119,7 +121,8 @@ function update( $new_instance, $old_instance ) {
119 121
120 122 /**
121 123 * Displays the widget control options in the Widgets admin screen.
122   - * @since 0.6
  124 + *
  125 + * @since 0.6.0
123 126 */
124 127 function form( $instance ) {
125 128

0 comments on commit 3f8bc66

Please sign in to comment.
Something went wrong with that request. Please try again.