Current Path : /var/www/ooareogundevinitiative/wp-content/themes/pain/framework/widgets/ |
Current File : /var/www/ooareogundevinitiative/wp-content/themes/pain/framework/widgets/search-causes.php |
<?php class Pain_WC_Widget_SearchCauses extends WC_Widget { /** * Constructor */ public function __construct() { $this->widget_cssclass = 'widget_search_causese'; $this->widget_description = __( 'Shows a custom Search Causes', 'pain' ); $this->widget_id = 'pain_woocommerce_searchbar'; $this->widget_name = __( 'Search Causes', 'pain' ); $this->settings = array( 'title' => array( 'type' => 'text', 'std' => __( '', 'pain' ), 'label' => __( 'Title', 'pain' ) ), 'label' => array( 'type' => 'text', 'std' => __( '', 'pain' ), 'label' => __( 'Label text', 'pain' ) ), 'hide_empty' => array( 'type' => 'checkbox', 'std' => 0, 'label' => __( 'Hide if category is empty', 'pain' ) ), 'el_class' => array( 'type' => 'text', 'std' => '', 'label' => __( 'Extra class', 'pain' ) ) ); parent::__construct(); } /** * widget function. * * @see WP_Widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { ob_start(); echo '<div class="container">'; $this->widget_start( $args, $instance ); $hide_empty = esc_attr( $instance['hide_empty'] ); $label = esc_attr( $instance['label'] ); $el_class= ! empty( $instance['el_class'] ) ? esc_attr( $instance['el_class'] ) : ''; $class = array('searchform'); $class[] = $el_class; $argss = array( 'orderby' => 'titles', 'order' => 'ASC', 'exclude' => 1,//remove uncategory 'hide_empty' => $hide_empty ); $cat = 'give_forms_category'; $product_categories = get_terms( $cat, $argss ); $count = count($product_categories); ?> <div class="search_causes"> <div class="title-left"><?php esc_html_e( 'SEARCH CAUSES', 'pain' ) ?></div> <div class="description"><?php echo wp_kses_post($label); ?></div> <form method="get" id="tb-mega-searchform" class="<?php echo esc_attr( implode( ' ', $class ) );?>" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <input type="hidden" name="post_type" value="give_forms"> <div class="clearfix"> <div class="cat-causes"> <div class="dropdown"> <select name="give_forms_category"> <option value=""><?php echo esc_html__('Cause Category','pain'); ?></option> <?php if ( $count > 0 ){ foreach ( $product_categories as $product_category ) { ?> <option value="<?php echo esc_attr( $product_category->slug );?>"> <?php echo esc_attr( $product_category->name); ?> </option> <?php } } ?> </select> </div> </div> <div class="input-causes"> <input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" placeholder="Search for a cause by their name....." /> </div> <div class="submit-causes"> <button type="submit" id="searchsubmit"><i class="fa fa-search"></i></button> </div> <!-- <button id="searchsubmit" type="submit"><i class="fa fa-search"></i></button> --> </div> </form> <div class="title-right"><?php esc_html_e( 'BROWSE CAUSES', 'pain' ) ?> </div> </div> <?php $this->widget_end( $args ); echo '</div>'; echo ob_get_clean(); } } if(function_exists('insert_widgets')) { function register_pain_searchcauses() { insert_widgets('Pain_WC_Widget_SearchCauses'); } add_action('widgets_init', 'register_pain_searchcauses'); }