PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/crafterads.online/wp-content/plugins/classified-listing-store/app/Widgets/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : /home/trave494/crafterads.online/wp-content/plugins/classified-listing-store/app/Widgets/Search.php

<?php

namespace RtclStore\Widgets;

use Rtcl\Helpers\Functions;
use Rtcl\Models\WidgetFields;
use RtclStore\Resources\Options;

class Search extends \WP_Widget {

	protected $style = [];

	protected $widget_slug;

	public function __construct() {

		$this->widget_slug = 'rtcl-widget-store-search';

		parent::__construct(
			$this->widget_slug,
			esc_html__( 'Classified Listing Store Search', 'classified-listing-store' ),
			array(
				'classname'   => 'rtcl ' . $this->widget_slug,
				'description' => esc_html__( 'A Search feature for store', 'classified-listing-store' )
			)
		);
	}

	public function widget( $args, $instance ) {
		$data             = [
			'id'                          => wp_rand(),
			'style'                       => ! empty( $instance['style'] ) && $instance['style'] === 'inline' ? 'inline' : 'vertical',
			'can_search_by_keyword'      => ! empty( $instance['search_by_keyword'] ) ? 1 : 0,
			'can_search_by_category'      => ! empty( $instance['search_by_category'] ) ? 1 : 0,
			'selected_category'           => false,
		];
		$data['template'] = "widgets/search/{$data['style']}";
		$data             = apply_filters( 'rtcl_widget_store_search_values', $data, $args, $instance, $this );
		echo $args['before_widget'];

		if ( ! empty( $instance['title'] ) ) {
			echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
		}

		Functions::get_template( $data['template'], $data, '', rtclStore()->get_plugin_template_path() );

		echo $args['after_widget'];

	}

	public function update( $new_instance, $old_instance ) {
		$instance                           = $old_instance;
		$instance['title']                  = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
		$instance['style']                  = ! empty( $new_instance['style'] ) ? strip_tags( $new_instance['style'] ) : 'vertical';
		$instance['search_by_keyword']      = ! empty( $new_instance['search_by_keyword'] ) ? 1 : 0;
		$instance['search_by_category']     = ! empty( $new_instance['search_by_category'] ) ? 1 : 0;

		return apply_filters( 'rtcl_widget_store_search_update_values', $instance, $new_instance, $old_instance, $this );
	}

	public function form( $instance ) {

		// Define the array of defaults
		$defaults = [
			'title'                 => esc_html__( 'Search Store', 'classified-listing-store' ),
			'style'                 => 'vertical',
			'search_by_keyword'     => 1,
			'search_by_category'    => 1,
		];

		// Parse incoming $instance into an array and merge it with $defaults
		$instance     = wp_parse_args(
			(array) $instance,
			apply_filters( 'rtcl_widget_store_search_default_values', $defaults, $instance, $this )
		);
		$fields       = Options::store_search_widget_fields();
		$widgetFields = new WidgetFields( $fields, $instance, $this );
		$widgetFields->render();
	}

}