| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Welcart_search Class |
| 5 |
*/ |
| 6 |
class Welcart_search extends WP_Widget { |
| 7 |
/** constructor */ |
| 8 |
function Welcart_search() { |
| 9 |
parent::WP_Widget(false, $name = 'Welcart '.__('keyword search', 'usces')); |
| 10 |
} |
| 11 |
|
| 12 |
/** @see WP_Widget::widget */ |
| 13 |
function widget($args, $instance) { |
| 14 |
global $usces; |
| 15 |
extract( $args ); |
| 16 |
$title = ( !isset($instance['title']) || WCUtils::is_blank($instance['title'])) ? 'Welcart '.__('keyword search', 'usces') : $instance['title']; |
| 17 |
$icon = ( !isset($instance['icon']) || WCUtils::is_blank($instance['icon'])) ? 1 : (int)$instance['icon']; |
| 18 |
//if($icon == 1) $before_title = '<div class="widget_title"><img src="' . USCES_PLUGIN_URL . '/images/find.png" alt="' . $title . '" width="24" height="24" />'; |
| 19 |
$img_path = file_exists(get_stylesheet_directory().'/images/search.png') ? get_stylesheet_directory_uri().'/images/search.png' : USCES_FRONT_PLUGIN_URL . '/images/search.png'; |
| 20 |
if($icon == 1) $before_title .= '<img src="' . $img_path . '" alt="' . $title . '" />'; |
| 21 |
?> |
| 22 |
<?php echo $before_widget; ?> |
| 23 |
<?php echo $before_title |
| 24 |
. esc_html($title) |
| 25 |
. $after_title; ?> |
| 26 |
|
| 27 |
<ul class="ucart_search_body ucart_widget_body"><li> |
| 28 |
<form method="get" id="searchform" action="<?php echo home_url(); ?>" > |
| 29 |
<input type="text" value="" name="s" id="s" class="searchtext" /><input type="submit" id="searchsubmit" value="<?php _e('Search', 'usces'); ?>" /> |
| 30 |
<?php |
| 31 |
$search_form = '<div><a href="' . (USCES_CART_URL . $usces->delim) . 'page=search_item">' . __("'AND' search by categories", 'usces') . '></a></div>'; |
| 32 |
echo apply_filters( 'usces_filter_search_widget_form', $search_form ); |
| 33 |
?> |
| 34 |
</form> |
| 35 |
</li></ul> |
| 36 |
|
| 37 |
<?php echo $after_widget; ?> |
| 38 |
<?php |
| 39 |
} |
| 40 |
|
| 41 |
/** @see WP_Widget::update */ |
| 42 |
function update($new_instance, $old_instance) { |
| 43 |
return $new_instance; |
| 44 |
} |
| 45 |
|
| 46 |
/** @see WP_Widget::form */ |
| 47 |
function form($instance) { |
| 48 |
$title = ( !isset($instance['title']) || WCUtils::is_blank($instance['title'])) ? 'Welcart '.__('keyword search', 'usces') : esc_attr($instance['title']); |
| 49 |
$icon = ( !isset($instance['icon']) || WCUtils::is_blank($instance['icon'])) ? 1 : (int)$instance['icon']; |
| 50 |
?> |
| 51 |
<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 $title; ?>" /></label></p> |
| 52 |
<p><label for="<?php echo $this->get_field_id('icon'); ?>"><?php _e('display of icon', 'usces'); ?>: <select class="widefat" id="<?php echo $this->get_field_id('icon'); ?>" name="<?php echo $this->get_field_name('icon'); ?>"><option value="1"<?php if($icon == 1){echo ' selected="selected"';} ?>><?php _e('Indication', 'usces'); ?></option><option value="2"<?php if($icon == 2){echo ' selected="selected"';} ?>><?php _e('Non-indication', 'usces'); ?></option></select></label></p> |
| 53 |
<?php |
| 54 |
} |
| 55 |
|
| 56 |
} |
| 57 |
?> |