PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.4.4
Easy Elements for Elementor – Addons & Website Templates v1.4.4
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / widgets / search / search.php

search.php in Easy Elements for Elementor – Addons & Website Templates 1.4.4, at widgets/search/search.php

415 lines 13.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Widgets;
3 use Elementor\Controls_Manager;
4 use Elementor\Widget_Base;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 class Easyel_Search_Widget extends \Elementor\Widget_Base {
11
12 public function get_name() {
13 return 'eel-search';
14 }
15
16 public function get_title() {
17 return __( 'Search', 'easy-elements' );
18 }
19
20 public function get_icon() {
21 return 'easyicon easyelIcon-search';
22 }
23
24 public function get_categories() {
25 return [ 'easyelements_header_footer_category' ];
26 }
27
28 public function get_keywords() {
29 return [ 'search', 'input', 'field', 'click', 'text' ];
30 }
31
32 public function get_style_depends() {
33 return [
34 'eel-search',
35 ];
36 }
37
38 public function get_script_depends() {
39 return [
40 'eel-search',
41 ];
42 }
43
44
45 protected function register_controls() {
46
47 $this->start_controls_section(
48 'content_section',
49 [
50 'label' => esc_html__('Search Settings', 'easy-elements'),
51 'tab' => Controls_Manager::TAB_CONTENT,
52 ]
53 );
54
55 $this->add_control(
56 'select_style',
57 [
58 'label' => esc_html__( 'Search Skin', 'easy-elements' ),
59 'type' => \Elementor\Controls_Manager::SELECT,
60 'default' => '1',
61 'options' => [
62 '1' => esc_html__( 'Search Popup', 'easy-elements' ),
63 '2' => esc_html__( 'Search Fields', 'easy-elements' ),
64 ],
65 ]
66 );
67
68 $this->add_control(
69 'search_top_title',
70 [
71 'label' => esc_html__('Search Title', 'easy-elements'),
72 'type' => Controls_Manager::TEXT,
73 ]
74 );
75
76 $this->add_control(
77 'search_placeholder',
78 [
79 'label' => esc_html__('Search Placeholder', 'easy-elements'),
80 'type' => Controls_Manager::TEXT,
81 'default' => esc_html__('Type keywords here...', 'easy-elements'),
82 ]
83 );
84
85 $this->add_control(
86 'open_icon',
87 [
88 'label' => esc_html__('Search Icon', 'easy-elements'),
89 'type' => \Elementor\Controls_Manager::ICONS,
90 'default' => [
91 'value' => 'fas fa-search',
92 'library' => 'fa-solid',
93 ],
94 ]
95 );
96
97 $this->add_responsive_control(
98 'search_icon_size',
99 [
100 'label' => esc_html__('Icon Size (px)', 'easy-elements'),
101 'type' => Controls_Manager::SLIDER,
102 'range' => [
103 'px' => [
104 'min' => 10,
105 'max' => 100,
106 ],
107 ],
108 'selectors' => [
109 '{{WRAPPER}} .eel-search-open-btn i, {{WRAPPER}} .eel-search-open-btn svg' => 'font-size: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};',
110 '{{WRAPPER}} .eel-search-submit-btn i, {{WRAPPER}} .eel-search-submit-btn svg' => 'font-size: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};',
111 ],
112 ]
113 );
114
115 $this->add_control(
116 'icon_colors',
117 [
118 'label' => esc_html__('Icon Color', 'easy-elements'),
119 'type' => Controls_Manager::COLOR,
120 'selectors' => [
121 '{{WRAPPER}} .eel-search-open-btn i' => 'color: {{VALUE}};',
122 '{{WRAPPER}} .eel-search-open-btn svg, {{WRAPPER}} .eel-search-open-btn svg path' => 'fill: {{VALUE}};',
123 '{{WRAPPER}} .eel-search-style-2 .eel-search-submit-btn svg' => 'fill: {{VALUE}};',
124 '{{WRAPPER}} .eel-search-style-2 .eel-search-submit-btn svg path' => 'fill: {{VALUE}};',
125 ],
126 ]
127 );
128
129 $this->add_responsive_control(
130 'search_icon_vertical_position',
131 [
132 'label' => esc_html__('Icon Vertical Position (px)', 'easy-elements'),
133 'type' => Controls_Manager::SLIDER,
134 'range' => [
135 'px' => [
136 'min' => -50,
137 'max' => 50,
138 ],
139 ],
140 'default' => [
141 'unit' => 'px',
142 'size' => 0,
143 ],
144 'selectors' => [
145 '{{WRAPPER}} .eel-search-open-btn' => 'transform: translateY({{SIZE}}{{UNIT}});',
146 ],
147 'condition' => [
148 'select_style' => '1'
149 ]
150 ]
151 );
152
153 $this->add_responsive_control(
154 'search_icon_horizontal_position',
155 [
156 'label' => esc_html__('Icon Horizontal Position (px)', 'easy-elements'),
157 'type' => Controls_Manager::SLIDER,
158 'selectors' => [
159 '{{WRAPPER}} .eel-search-submit-btn' => 'right: {{SIZE}}{{UNIT}};',
160 ],
161 'condition' => [
162 'select_style' => '2'
163 ]
164 ]
165 );
166
167
168 $this->add_control(
169 'close_icon',
170 [
171 'label' => esc_html__('Close Icon', 'easy-elements'),
172 'type' => \Elementor\Controls_Manager::ICONS,
173 'default' => [
174 'value' => 'fas fa-arrow-up',
175 'library' => 'fa-solid',
176 ],
177 'condition' => [
178 'select_style' => '1'
179 ]
180 ]
181 );
182
183 $this->add_responsive_control(
184 'icon_size',
185 [
186 'label' => esc_html__('Close Icon Size (px)', 'easy-elements'),
187 'type' => Controls_Manager::SLIDER,
188 'range' => [
189 'px' => [
190 'min' => 10,
191 'max' => 100,
192 ],
193 ],
194 'selectors' => [
195 '{{WRAPPER}} .eel-search-close-btn i, {{WRAPPER}} .eel-search-close-btn svg' => 'font-size: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; width: {{SIZE}}{{UNIT}};',
196 ],
197 'condition' => [
198 'select_style' => '1'
199 ]
200 ]
201 );
202
203
204 $this->add_control(
205 'overlay_background',
206 [
207 'label' => esc_html__('Overlay Background', 'easy-elements'),
208 'type' => Controls_Manager::COLOR,
209 'default' => '',
210 'selectors' => [
211 '{{WRAPPER}} .eel-search-lightbox, {{WRAPPER}} .eel-search-overlay' => 'background: {{VALUE}};',
212 ],
213 'condition' => [
214 'select_style' => '1'
215 ]
216 ]
217 );
218
219 $this->add_control(
220 'input_text_color',
221 [
222 'label' => esc_html__('Input Text Color', 'easy-elements'),
223 'type' => Controls_Manager::COLOR,
224 'selectors' => [
225 '{{WRAPPER}} .eel-search-content .eel-search-field' => 'color: {{VALUE}};',
226 '{{WRAPPER}} .eel-search-style-2 .eel-search-field' => 'color: {{VALUE}};',
227 ],
228 ]
229 );
230
231 $this->add_control(
232 'input_bg_color',
233 [
234 'label' => esc_html__('Input Background Color', 'easy-elements'),
235 'type' => Controls_Manager::COLOR,
236 'selectors' => [
237 '{{WRAPPER}} .eel-search-content .eel-search-field' => 'background-color: {{VALUE}};',
238 '{{WRAPPER}} .eel-search-style-2 .eel-search-field' => 'background: {{VALUE}};',
239 ],
240 ]
241 );
242
243 $this->add_control(
244 'input_border_color',
245 [
246 'label' => esc_html__('Input Border Color', 'easy-elements'),
247 'type' => Controls_Manager::COLOR,
248 'selectors' => [
249 '{{WRAPPER}} .eel-search-style-2 .eel-search-field' => 'border-color: {{VALUE}};',
250 ],
251 'condition' => [
252 'select_style' => '2'
253 ]
254 ]
255 );
256
257 $this->add_control(
258 'input_focus_border_color',
259 [
260 'label' => esc_html__('Border Color (Focus)', 'easy-elements'),
261 'type' => Controls_Manager::COLOR,
262 'selectors' => [
263 '{{WRAPPER}} .eel-search-style-2 .eel-search-field:focus' => 'border-color: {{VALUE}};',
264 ],
265 'condition' => [
266 'select_style' => '2'
267 ]
268 ]
269 );
270
271 $this->add_responsive_control(
272 'search_input_field_width',
273 [
274 'label' => esc_html__('Input Field Width', 'easy-elements'),
275 'type' => Controls_Manager::SLIDER,
276 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
277 'range' => [
278 'px' => [
279 'min' => 10,
280 'max' => 100,
281 ],
282 ],
283 'selectors' => [
284 '{{WRAPPER}} .eel-search-style-2 .eel-search-field' => 'width: {{SIZE}}{{UNIT}};',
285 ],
286 'condition' => [
287 'select_style' => '2'
288 ]
289 ]
290 );
291
292 $this->add_responsive_control(
293 'input_field_border_radius',
294 [
295 'label' => esc_html__( 'Border Radius', 'easy-elements' ),
296 'type' => \Elementor\Controls_Manager::DIMENSIONS,
297 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
298 'selectors' => [
299 '{{WRAPPER}} .eel-search-style-2 .eel-search-field' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
300 ],
301 'condition' => [
302 'select_style' => '2'
303 ]
304 ]
305 );
306
307 $this->add_control(
308 'submit_btn_icon_color',
309 [
310 'label' => esc_html__('Submit Icon Color', 'easy-elements'),
311 'type' => Controls_Manager::COLOR,
312 'selectors' => [
313 '{{WRAPPER}} .eel-search-content .eel-search-submit' => 'color: {{VALUE}};',
314 '{{WRAPPER}} .eel-search-content .eel-search-submit svg' => 'fill: {{VALUE}};',
315 ],
316 'condition' => [
317 'select_style' => '1'
318 ]
319 ]
320 );
321
322 $this->add_control(
323 'submit_btn_icon_h_color',
324 [
325 'label' => esc_html__('Submit Icon Hover Color', 'easy-elements'),
326 'type' => Controls_Manager::COLOR,
327 'selectors' => [
328 '{{WRAPPER}} .eel-search-content .eel-search-submit:hover' => 'color: {{VALUE}};',
329 '{{WRAPPER}} .eel-search-content .eel-search-submit:hover svg' => 'fill: {{VALUE}};',
330 ],
331 'condition' => [
332 'select_style' => '1'
333 ]
334 ]
335 );
336
337 $this->add_control(
338 'submit_button_color',
339 [
340 'label' => esc_html__('Submit Icon Background', 'easy-elements'),
341 'type' => Controls_Manager::COLOR,
342 'selectors' => [
343 '{{WRAPPER}} .eel-search-content .eel-search-submit' => 'background-color: {{VALUE}};',
344 '{{WRAPPER}} .eel-search-style-2 .eel-search-submit-btn' => 'background-color: {{VALUE}};',
345 ],
346 'condition' => [
347 'select_style' => ['1', '2']
348 ]
349 ]
350 );
351
352 $this->add_control(
353 'submit_button_hover_bgcolor',
354 [
355 'label' => esc_html__('Submit Icon Hover Background', 'easy-elements'),
356 'type' => Controls_Manager::COLOR,
357 'selectors' => [
358 '{{WRAPPER}} .eel-search-content .eel-search-submit:hover' => 'background-color: {{VALUE}};',
359 ],
360 'condition' => [
361 'select_style' => '1'
362 ]
363 ]
364 );
365 $this->end_controls_section();
366 }
367
368 protected function render() {
369 $settings = $this->get_settings_for_display();
370 $style = $settings['select_style'];
371
372 if ( $style == '2' ) : ?>
373 <div class="eel-search-style-<?php echo esc_attr( $style ); ?>">
374 <form role="search" method="get" class="eel-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
375 <input type="search" class="eel-search-field" placeholder="<?php echo esc_attr( $settings['search_placeholder'] ?? 'Search..' ); ?>" value="" name="s" />
376 <button type="submit" class="eel-search-submit-btn" aria-label="Submit Search">
377 <?php
378 if( $settings['open_icon']['value'] ) :
379 \Elementor\Icons_Manager::render_icon( $settings['open_icon'], [ 'aria-hidden' => 'true' ] );
380 else : ?>
381 <i class="eel-absl unicon-search"></i>
382 <?php
383 endif; ?>
384 </button>
385 </form>
386 </div>
387 <?php
388 else: ?>
389 <a href="#" role="button" class="eel-search-open-btn" aria-label="<?php esc_attr_e('Open Search', 'easy-elements'); ?>">
390 <?php \Elementor\Icons_Manager::render_icon( $settings['open_icon'], [ 'aria-hidden' => 'true' ] ); ?>
391 </a>
392
393 <div class="eel-search-lightbox">
394 <div class="eel-search-overlay">
395 <a href="#" role="button" class="eel-search-close-btn" aria-label="<?php esc_attr_e('Close Search', 'easy-elements'); ?>">
396 <?php \Elementor\Icons_Manager::render_icon( $settings['close_icon'], [ 'aria-hidden' => 'true' ] ); ?>
397 </a>
398 </div>
399 <div class="eel-search-content">
400 <div class="eel-search-title">
401 <?php echo esc_attr( $settings['search_top_title'] ?: __( 'What are you looking for?', 'easy-elements' ) ); ?>
402 </div>
403 <form role="search" method="get" class="eel-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
404 <input type="search" class="eel-search-field" placeholder="<?php echo esc_attr( $settings['search_placeholder'] ?? 'Type keywords here...' ); ?>" value="" name="s" />
405 <button type="submit" class="eel-search-submit" aria-label="Submit Search">
406 <i class="eel-absl unicon-search"></i>
407 </button>
408 </form>
409 </div>
410 </div>
411 <?php
412 endif;
413 }
414 }
415