1 <?php
2 3 4 5 6 7 8 9 10
11
12 if ( ! defined( 'ABSPATH' ) ) exit;
13
14 class WC_Widget_Product_Search extends WC_Widget {
15
16 17 18
19 public function __construct() {
20 $this->widget_cssclass = 'woocommerce widget_product_search';
21 $this->widget_description = __( 'A Search box for products only.', 'woocommerce' );
22 $this->widget_id = 'woocommerce_product_search';
23 $this->widget_name = __( 'WooCommerce Product Search', 'woocommerce' );
24 $this->settings = array(
25 'title' => array(
26 'type' => 'text',
27 'std' => __( 'Search Products', 'woocommerce' ),
28 'label' => __( 'Title', 'woocommerce' )
29 )
30 );
31 parent::__construct();
32 }
33
34 35 36 37 38 39 40 41 42
43 function widget( $args, $instance ) {
44 extract( $args );
45
46 $title = $instance['title'];
47 $title = apply_filters('widget_title', $title, $instance, $this->id_base);
48
49 echo $before_widget;
50
51 if ( $title )
52 echo $before_title . $title . $after_title;
53
54 get_product_search_form();
55
56 echo $after_widget;
57 }
58 }
59
60 register_widget( 'WC_Widget_Product_Search' );