PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.84
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.84
51.1.86 51.1.84 51.1.85 51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 All 40 releases
king-addons / includes / widgets / Facet_Search / Facet_Search.php

Facet_Search.php in King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder 51.1.84, at includes/widgets/Facet_Search/Facet_Search.php

175 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Facet Search widget.
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Widget_Base;
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 /**
18 * Search filter widget.
19 */
20 class Facet_Search extends Widget_Base
21 {
22 /**
23 * Widget slug.
24 *
25 * @return string
26 */
27 public function get_name(): string
28 {
29 return 'king-addons-facet-search';
30 }
31
32 /**
33 * Widget title.
34 *
35 * @return string
36 */
37 public function get_title(): string
38 {
39 return esc_html__('Search Filter', 'king-addons');
40 }
41
42 /**
43 * Keywords.
44 *
45 * @return array<int, string>
46 */
47 public function get_keywords(): array
48 {
49 return ['shop', 'product', 'filter', 'filters', 'ajax', 'woocommerce', 'search', 'faceted', 'smart filters'];
50 }
51
52 /**
53 * Widget icon.
54 *
55 * @return string
56 */
57 public function get_icon(): string
58 {
59 return 'king-addons-icon king-addons-facet-search';
60 }
61
62 /**
63 * Categories.
64 *
65 * @return array<int, string>
66 */
67 public function get_categories(): array
68 {
69 return ['king-addons'];
70 }
71
72 /**
73 * Style dependencies.
74 *
75 * @return array<int, string>
76 */
77 public function get_style_depends(): array
78 {
79 return [
80 KING_ADDONS_ASSETS_UNIQUE_KEY . '-facet-search-style',
81 ];
82 }
83
84 /**
85 * Script dependencies.
86 *
87 * @return array<int, string>
88 */
89 public function get_script_depends(): array
90 {
91 return [
92 KING_ADDONS_ASSETS_UNIQUE_KEY . '-facet-search-script',
93 ];
94 }
95
96 public function get_custom_help_url()
97 {
98 return 'mailto:[email protected]?subject=Bug Report - King Addons&body=Please describe the issue';
99 }
100
101 /**
102 * Register controls.
103 *
104 * @return void
105 */
106 public function register_controls(): void
107 {
108 $this->start_controls_section(
109 'kng_facet_search_section',
110 [
111 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Search Filter', 'king-addons'),
112 'tab' => Controls_Manager::TAB_CONTENT,
113 ]
114 );
115
116 $this->add_control(
117 'kng_filters_query_id',
118 [
119 'label' => esc_html__('Shop Filters ID', 'king-addons'),
120 'type' => Controls_Manager::TEXT,
121 'placeholder' => esc_html__('shop_grid_1', 'king-addons'),
122 'description' => esc_html__('Must match the Shop Filters ID on the product grid.', 'king-addons'),
123 ]
124 );
125
126 $this->add_control(
127 'kng_placeholder',
128 [
129 'label' => esc_html__('Placeholder', 'king-addons'),
130 'type' => Controls_Manager::TEXT,
131 'default' => esc_html__('Search...', 'king-addons'),
132 ]
133 );
134
135 $this->end_controls_section();
136
137 require_once KING_ADDONS_PATH . 'includes/helpers/Faceted/Style_Controls.php';
138 Facet_Style_Controls::fields($this, '{{WRAPPER}} .king-addons-facet--search .king-addons-facet__input');
139 }
140
141 /**
142 * Render widget output.
143 *
144 * @return void
145 */
146 public function render(): void
147 {
148 $settings = $this->get_settings_for_display();
149 $query_id = sanitize_title($settings['kng_filters_query_id'] ?? '');
150 $placeholder = $settings['kng_placeholder'] ?? '';
151
152 if ('' === $query_id) {
153 return;
154 }
155
156 ?>
157 <div class="king-addons-facet king-addons-facet--search">
158 <input
159 type="search"
160 class="king-addons-facet__input"
161 data-ka-filter-type="search"
162 data-ka-filters-query-id="<?php echo esc_attr($query_id); ?>"
163 placeholder="<?php echo esc_attr($placeholder); ?>"
164 />
165 </div>
166 <?php
167 }
168 }
169
170
171
172
173
174
175