PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.49
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.49
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 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Business_Hours / Business_Hours.php

Business_Hours.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.49, at includes/widgets/Business_Hours/Business_Hours.php

381 lines 14.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /** @noinspection SpellCheckingInspection, DuplicatedCode, PhpUnused */
2
3 namespace King_Addons;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Typography;
7 use Elementor\Repeater;
8 use Elementor\Widget_Base;
9
10 if (!defined('ABSPATH')) {
11 exit; // Exit if accessed directly.
12 }
13
14
15
16 class Business_Hours extends Widget_Base
17 {
18
19
20 public function get_name(): string
21 {
22 return 'king-addons-business-hours';
23 }
24
25 public function get_title(): string
26 {
27 return esc_html__('Business Hours', 'king-addons');
28 }
29
30 public function get_icon(): string
31 {
32 return 'king-addons-icon king-addons-business-hours';
33 }
34
35 public function get_style_depends(): array
36 {
37 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-business-hours-style'];
38 }
39
40 public function get_categories(): array
41 {
42 return ['king-addons'];
43 }
44
45 public function get_keywords(): array
46 {
47 return ['rows', 'kingaddons', 'king-addons', 'king', 'addons', 'business hours', 'opening', 'working', 'office',
48 'store', 'hours of operation', 'schedule', 'time', 'availability', 'service', 'schedule', 'operating',
49 'opening', 'working times', 'office times', 'store times', 'operational', 'timings', 'shop', 'list',
50 'business', 'hours', 'times', 'time', 'operation', 'calendar', 'week', 'day', 'days', 'weekend', 'weekends',
51 'holidays', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'January',
52 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December',
53 ];
54 }
55
56 public function get_custom_help_url()
57 {
58 return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
59 }
60
61 protected function register_controls(): void
62 {
63 /** CONTENT SECTION: Items ===================== */
64 $this->start_controls_section(
65 'kng_business_hours_content_section_items',
66 [
67 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Items', 'king-addons'),
68 'tab' => Controls_Manager::TAB_CONTENT,
69 ]
70 );
71
72 $repeater = new Repeater();
73
74 $repeater->add_control(
75 'kng_business_hours_day',
76 [
77 'label' => esc_html__('Day', 'king-addons'),
78 'default' => esc_html__('Day', 'king-addons'),
79 'type' => Controls_Manager::TEXT,
80 'label_block' => true,
81 ]
82 );
83
84 $repeater->add_control(
85 'kng_business_hours_hours',
86 [
87 'label' => esc_html__('Hours', 'king-addons'),
88 'default' => esc_html__('Hours', 'king-addons'),
89 'type' => Controls_Manager::TEXT,
90 'label_block' => true,
91 ]
92 );
93
94 $repeater->add_control(
95 'kng_business_hours_custom_styles_switcher',
96 [
97 'label' => esc_html__('Custom styles', 'king-addons'),
98 'type' => Controls_Manager::SWITCHER,
99 ]
100 );
101
102 $repeater->add_group_control(
103 Group_Control_Typography::get_type(),
104 [
105 'label' => esc_html__('Day Typography', 'king-addons'),
106 'name' => 'kng_business_hours_custom_day_typography',
107 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} .king-addons-business-hours-item-day',
108 'condition' => [
109 'kng_business_hours_custom_styles_switcher' => 'yes'
110 ]
111 ]
112 );
113
114 $repeater->add_control(
115 'kng_business_hours_custom_day_color',
116 [
117 'label' => esc_html__('Day Color', 'king-addons'),
118 'type' => Controls_Manager::COLOR,
119 'default' => '#1E1E1E59',
120 'selectors' => [
121 '{{WRAPPER}} {{CURRENT_ITEM}} .king-addons-business-hours-item-day' => 'color: {{VALUE}};',
122 ],
123 'condition' => [
124 'kng_business_hours_custom_styles_switcher' => 'yes'
125 ]
126 ]
127 );
128
129 $repeater->add_group_control(
130 Group_Control_Typography::get_type(),
131 [
132 'label' => esc_html__('Hours Typography', 'king-addons'),
133 'name' => 'kng_business_hours_custom_hours_typography',
134 'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} .king-addons-business-hours-item-hours',
135 'condition' => [
136 'kng_business_hours_custom_styles_switcher' => 'yes'
137 ]
138 ]
139 );
140
141 $repeater->add_control(
142 'kng_business_hours_custom_hours_color',
143 [
144 'label' => esc_html__('Hours Color', 'king-addons'),
145 'type' => Controls_Manager::COLOR,
146 'default' => '#1E1E1E59',
147 'selectors' => [
148 '{{WRAPPER}} {{CURRENT_ITEM}} .king-addons-business-hours-item-hours' => 'color: {{VALUE}};',
149 ],
150 'condition' => [
151 'kng_business_hours_custom_styles_switcher' => 'yes'
152 ]
153 ]
154 );
155
156 $repeater->add_control(
157 'kng_business_hours_custom_line_color',
158 [
159 'label' => esc_html__('Line Color', 'king-addons'),
160 'type' => Controls_Manager::COLOR,
161 'default' => '#1E1E1E59',
162 'selectors' => [
163 '{{WRAPPER}} {{CURRENT_ITEM}} .king-addons-business-hours-item-line' => 'border-color: {{VALUE}};',
164 ],
165 'condition' => [
166 'kng_business_hours_custom_styles_switcher' => 'yes'
167 ]
168 ]
169 );
170
171 $this->add_control(
172 'kng_business_hours_content_items',
173 [
174 'type' => Controls_Manager::REPEATER,
175 'fields' => $repeater->get_controls(),
176 'default' => [
177 [
178 'kng_business_hours_day' => esc_html__('Monday', 'king-addons'),
179 'kng_business_hours_hours' => esc_html__('9:00 AM - 5:00 PM', 'king-addons'),
180 ],
181 [
182 'kng_business_hours_day' => esc_html__('Tuesday', 'king-addons'),
183 'kng_business_hours_hours' => esc_html__('9:00 AM - 5:00 PM', 'king-addons'),
184 ],
185 [
186 'kng_business_hours_day' => esc_html__('Wednesday', 'king-addons'),
187 'kng_business_hours_hours' => esc_html__('9:00 AM - 5:00 PM', 'king-addons'),
188 ],
189 [
190 'kng_business_hours_day' => esc_html__('Thursday', 'king-addons'),
191 'kng_business_hours_hours' => esc_html__('9:00 AM - 5:00 PM', 'king-addons'),
192 ],
193 [
194 'kng_business_hours_day' => esc_html__('Friday', 'king-addons'),
195 'kng_business_hours_hours' => esc_html__('9:00 AM - 5:00 PM', 'king-addons'),
196 ],
197 [
198 'kng_business_hours_custom_styles_switcher' => 'yes',
199 'kng_business_hours_day' => esc_html__('Saturday', 'king-addons'),
200 'kng_business_hours_hours' => esc_html__('Closed', 'king-addons'),
201 ],
202 [
203 'kng_business_hours_custom_styles_switcher' => 'yes',
204 'kng_business_hours_day' => esc_html__('Sunday', 'king-addons'),
205 'kng_business_hours_hours' => esc_html__('Closed', 'king-addons'),
206 ],
207 ],
208 'title_field' => '{{kng_business_hours_day}}',
209 ]
210 );
211
212 $this->end_controls_section();
213 /** END CONTENT SECTION: Items ===================== */
214
215 /** STYLE SECTION: Items ===================== */
216 $this->start_controls_section(
217 'kng_business_hours_style_section_items',
218 [
219 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Items', 'king-addons'),
220 'tab' => Controls_Manager::TAB_STYLE,
221 ]
222 );
223
224 $this->add_group_control(
225 Group_Control_Typography::get_type(),
226 [
227 'label' => esc_html__('Day Typography', 'king-addons'),
228 'name' => 'kng_business_hours_typography_day',
229 'fields_options' => [
230 'font_size' => [
231 'default' => [
232 'size' => 20,
233 'unit' => 'px'
234 ],
235 ],
236 'typography' => [
237 'default' => 'custom',
238 ]
239 ],
240 'selector' => '{{WRAPPER}} .king-addons-business-hours-item-day',
241 ]
242 );
243
244 $this->add_group_control(
245 Group_Control_Typography::get_type(),
246 [
247 'label' => esc_html__('Hours Typography', 'king-addons'),
248 'name' => 'kng_business_hours_typography_hours',
249 'fields_options' => [
250 'font_size' => [
251 'default' => [
252 'size' => 20,
253 'unit' => 'px'
254 ],
255 ],
256 'typography' => [
257 'default' => 'custom',
258 ]
259 ],
260 'selector' => '{{WRAPPER}} .king-addons-business-hours-item-hours',
261 ]
262 );
263
264 $this->add_control(
265 'kng_business_hours_color_day',
266 [
267 'label' => esc_html__('Day Color', 'king-addons'),
268 'type' => Controls_Manager::COLOR,
269 'default' => '#1E1E1E',
270 'selectors' => [
271 '{{WRAPPER}} .king-addons-business-hours-item-day' => 'color: {{VALUE}};',
272 ],
273 ]
274 );
275
276 $this->add_control(
277 'kng_business_hours_color_hours',
278 [
279 'label' => esc_html__('Hours Color', 'king-addons'),
280 'type' => Controls_Manager::COLOR,
281 'default' => '#1E1E1E',
282 'selectors' => [
283 '{{WRAPPER}} .king-addons-business-hours-item-hours' => 'color: {{VALUE}};',
284 ],
285 ]
286 );
287
288 $this->add_responsive_control(
289 'kng_business_hours_space_between_items',
290 [
291 'label' => esc_html__('Space between items (px)', 'king-addons'),
292 'type' => Controls_Manager::NUMBER,
293 'min' => 0,
294 'default' => 23,
295 'step' => 1,
296 'selectors' => [
297 '{{WRAPPER}} .king-addons-business-hours-item:not(:last-child)' => 'margin-bottom: {{SIZE}}px;',
298 ],
299 ]
300 );
301
302 $this->add_control(
303 'kng_business_hours_line_color',
304 [
305 'label' => esc_html__('Line Color', 'king-addons'),
306 'type' => Controls_Manager::COLOR,
307 'default' => '#1E1E1E59',
308 'selectors' => [
309 '{{WRAPPER}} .king-addons-business-hours-item-line' => 'border-bottom-color: {{VALUE}};',
310 ],
311 ]
312 );
313
314 $this->add_control(
315 'kng_business_hours_line_type',
316 [
317 'label' => esc_html__('Line Type', 'king-addons'),
318 'type' => Controls_Manager::SELECT,
319 'options' => [
320 'none' => esc_html__('None', 'king-addons'),
321 'solid' => esc_html__('Solid', 'king-addons'),
322 'dotted' => esc_html__('Dotted', 'king-addons'),
323 'dashed' => esc_html__('Dashed', 'king-addons'),
324 ],
325 'default' => 'solid',
326 'selectors' => [
327 '{{WRAPPER}} .king-addons-business-hours-item-line' => 'border-bottom-style: {{VALUE}};',
328 ],
329 ]
330 );
331
332 $this->add_control(
333 'kng_business_hours_line_width',
334 [
335 'label' => esc_html__('Line Width', 'king-addons'),
336 'type' => Controls_Manager::NUMBER,
337 'min' => 0,
338 'default' => 1,
339 'step' => 1,
340 'selectors' => [
341 '{{WRAPPER}} .king-addons-business-hours-item-line' => 'border-bottom-width: {{SIZE}}px;',
342 ],
343 ]
344 );
345
346 $this->add_control(
347 'kng_business_hours_column_position',
348 [
349 'label' => esc_html__('Column Position', 'king-addons'),
350 'type' => Controls_Manager::SELECT,
351 'options' => [
352 'row' => esc_html__('Default', 'king-addons'),
353 'row-reverse' => esc_html__('Reverse', 'king-addons'),
354 ],
355 'default' => 'row',
356 'selectors' => [
357 '{{WRAPPER}} .king-addons-business-hours-item' => 'flex-direction: {{VALUE}};',
358 ],
359 ]
360 );
361
362 $this->end_controls_section();
363 /** END STYLE SECTION: Items ===================== */
364 }
365
366 protected function render(): void
367 {
368 $settings = $this->get_settings();
369 echo '<div class="king-addons-business-hours-items">';
370 foreach ($settings['kng_business_hours_content_items'] as $item) {
371 echo '<div class="king-addons-business-hours-item elementor-repeater-item-' . esc_attr($item['_id']) . '">';
372
373 echo '<div class="king-addons-business-hours-item-day">' . wp_kses_post($item['kng_business_hours_day']) . '</div>';
374 echo '<div class="king-addons-business-hours-item-line"></div>';
375 echo '<div class="king-addons-business-hours-item-hours">' . wp_kses_post($item['kng_business_hours_hours']) . '</div>';
376
377 echo '</div>';
378 }
379 echo '</div>';
380 }
381 }