woocommerce/classes/widgets/class-wc-widget-product-sea...

60 lines
1.3 KiB
PHP

<?php
/**
* Product Search Widget
*
* @author WooThemes
* @category Widgets
* @package WooCommerce/Widgets
* @version 2.1.0
* @extends WC_Widget
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class WC_Widget_Product_Search extends WC_Widget {
/**
* Constructor
*/
public function __construct() {
$this->widget_cssclass = 'woocommerce widget_product_search';
$this->widget_description = __( 'A Search box for products only.', 'woocommerce' );
$this->widget_id = 'woocommerce_product_search';
$this->widget_name = __( 'WooCommerce Product Search', 'woocommerce' );
$this->settings = array(
'title' => array(
'type' => 'text',
'std' => __( 'Search Products', 'woocommerce' ),
'label' => __( 'Title', 'woocommerce' )
)
);
parent::__construct();
}
/**
* widget function.
*
* @see WP_Widget
* @access public
* @param array $args
* @param array $instance
* @return void
*/
function widget( $args, $instance ) {
extract( $args );
$title = $instance['title'];
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
get_product_search_form();
echo $after_widget;
}
}
register_widget( 'WC_Widget_Product_Search' );