woocommerce/widgets/widget-product_search.php

95 lines
2.3 KiB
PHP
Raw Normal View History

2011-08-10 17:11:11 +00:00
<?php
/**
* Product Search Widget
2012-08-14 17:37:50 +00:00
*
* @author WooThemes
* @category Widgets
* @package WooCommerce/Widgets
* @version 1.6.4
* @extends WP_Widget
2011-08-10 17:11:11 +00:00
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2011-08-10 17:11:11 +00:00
class WooCommerce_Widget_Product_Search extends WP_Widget {
2011-08-26 21:28:55 +00:00
var $woo_widget_cssclass;
var $woo_widget_description;
var $woo_widget_idbase;
var $woo_widget_name;
2012-08-14 17:37:50 +00:00
/**
* constructor
*
* @access public
* @return void
*/
2011-08-10 17:11:11 +00:00
function WooCommerce_Widget_Product_Search() {
2012-08-14 17:37:50 +00:00
2011-08-26 21:28:55 +00:00
/* Widget variable settings. */
$this->woo_widget_cssclass = 'widget_product_search';
2012-01-05 11:31:22 +00:00
$this->woo_widget_description = __( 'A Search box for products only.', 'woocommerce' );
2011-08-26 21:28:55 +00:00
$this->woo_widget_idbase = 'woocommerce_product_search';
2012-10-16 09:45:33 +00:00
$this->woo_widget_name = __( 'WooCommerce Product Search', 'woocommerce' );
2012-08-14 17:37:50 +00:00
2011-08-26 21:28:55 +00:00
/* Widget settings. */
$widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description );
2012-08-14 17:37:50 +00:00
2011-08-26 21:28:55 +00:00
/* Create the widget. */
$this->WP_Widget('product_search', $this->woo_widget_name, $widget_ops);
2011-08-10 17:11:11 +00:00
}
2012-08-14 17:37:50 +00:00
/**
* widget function.
*
* @see WP_Widget
* @access public
* @param array $args
* @param array $instance
* @return void
*/
2011-08-10 17:11:11 +00:00
function widget( $args, $instance ) {
extract($args);
$title = $instance['title'];
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
2012-08-14 17:37:50 +00:00
2011-08-10 17:11:11 +00:00
echo $before_widget;
2012-08-14 17:37:50 +00:00
2011-08-10 17:11:11 +00:00
if ($title) echo $before_title . $title . $after_title;
2012-08-14 17:37:50 +00:00
2012-04-16 13:32:58 +00:00
get_product_search_form();
2012-08-14 17:37:50 +00:00
2011-08-10 17:11:11 +00:00
echo $after_widget;
}
2012-08-14 17:37:50 +00:00
/**
* update function.
*
* @see WP_Widget->update
* @access public
* @param array $new_instance
* @param array $old_instance
* @return array
*/
2011-08-10 17:11:11 +00:00
function update( $new_instance, $old_instance ) {
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
return $instance;
}
2012-08-14 17:37:50 +00:00
/**
* form function.
*
* @see WP_Widget->form
* @access public
* @param array $instance
* @return void
*/
2011-08-10 17:11:11 +00:00
function form( $instance ) {
global $wpdb;
?>
2012-10-16 09:45:33 +00:00
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'woocommerce' ) ?></label>
2011-09-19 06:01:26 +00:00
<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
2011-08-10 17:11:11 +00:00
<?php
}
2012-08-14 17:37:50 +00:00
}