PluginProbe
Countdown Timer – Widget Countdown / trunk
Countdown Timer – Widget Countdown vtrunk
2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 All 182 releases
widget-countdown / includes / admin / ThemeController.php

ThemeController.php in Countdown Timer – Widget Countdown trunk, at includes/admin/ThemeController.php

1,137 lines 42.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( "ABSPATH" ) ) exit;
3 class wpda_countdown_theme_page{
4
5 private $options;
6 private $repo;
7
8 function __construct( $repo = null ){
9 $this->repo = $repo ?: new Wpda_Countdown_Theme_Repository();
10 $this->options=self::return_params_array();
11 // Free mode: keep every field visible but mark Pro ones with a (pro)
12 // badge and lock interaction via the shared pro-lock script.
13 if ( ! WPDA_COUNTDOWN_IS_PRO ) {
14 $this->options = self::mark_pro_fields( $this->options );
15 }
16 }
17
18 /**
19 * Individual Pro-only option keys inside mixed groups (General and Standard).
20 * Standard view is almost entirely free; only the responsive layout toggle
21 * and the two animation settings are Pro-gated.
22 */
23 public static function pro_field_keys() {
24 return array(
25 // General group — Pro
26 'countdown_date_display', // Which time units to show (free is fixed to day/hour/minut/second)
27 // Standard view — Pro (responsive layout + animations)
28 'countdown_standart_display_inline', // Fit on one row
29 'countdown_standart_gorup_animation', // Set animation for each element or for group
30 'countdown_standart_animation_type', // Animation Effect
31 );
32 }
33
34 /**
35 * Groups that are entirely Pro (every field inside them is Pro).
36 */
37 public static function pro_groups() {
38 return array( 'vertical_countdown', 'circle_countdown', 'countdown_flip_settings' );
39 }
40
41 /**
42 * Add `pro => true` to every Pro-only field so description_cell() renders
43 * the (pro) badge and the shared JS lock intercepts interactions.
44 */
45 private static function mark_pro_fields( array $options ) {
46 $pro_keys = self::pro_field_keys();
47 $pro_groups = self::pro_groups();
48 foreach ( $options as $gk => $group ) {
49 if ( empty( $group['params'] ) ) continue;
50 $whole_group_pro = in_array( $gk, $pro_groups, true );
51 foreach ( $group['params'] as $pk => $field ) {
52 if ( $whole_group_pro || in_array( $pk, $pro_keys, true ) ) {
53 $options[ $gk ]['params'][ $pk ]['pro'] = true;
54 }
55 }
56 }
57 return $options;
58 }
59
60 public static function return_params_array(){
61 return array(
62 "countdown_theme_general"=>array(
63 "heading_name"=>"General Settings",
64 "params"=>array(
65 "countdown_type"=>array(
66 "title"=>"Countdown design type",
67 "description"=>"Select the countdown design type",
68 "function_name"=>"simple_select",
69 "values"=>WPDA_COUNTDOWN_IS_PRO?array("standart"=>"Standard","vertical"=>"Vertical","circle"=>"Circle","flip"=>"Flip Clock"):array("standart"=>"Standard","vertical"=>"Vertical (Pro)","circle"=>"Circle (Pro)","flip"=>"Flip Clock (Pro)"),
70 "default_value"=>"standart",
71 ),
72 "countdown_global_width"=>array(
73 "title"=>"Countdown width",
74 "description"=>"Set the countdown container width and unit",
75 "function_name"=>"input_with_unit",
76 "unit_name"=>"countdown_global_width_metrick",
77 "unit_default"=>"%",
78 "units"=>array("px"=>"px","%"=>"%"),
79 "default_value"=>"100",
80 ),
81 "countdown_global_width_metrick"=>array(
82 "title"=>"",
83 "description"=>"",
84 "function_name"=>"hidden_input",
85 "default_value"=>"%",
86 ),
87 "countdown_horizontal_position"=>array(
88 "title"=>"Countdown position",
89 "description"=>"Select the countdown position",
90 "function_name"=>"simple_select",
91 "values"=>array("left"=>"Left","center"=>"Center","right"=>"Right"),
92 "default_value"=>"center",
93 ),
94 "countdown_date_display"=>array(
95 "title"=>"Select the countdown timer fields you want to display",
96 "description"=>"Slect the timer fields you want to display in front-end",
97 "values"=>array(
98 "week"=>"Weeks",
99 "day"=>"Days",
100 "hour"=>"Hours",
101 "minut"=>"Minutes",
102 "second"=>"Seconds",
103 ),
104 "function_name"=>"simple_checkbox",
105 "default_value"=>array("day","hour","minut","second"),
106 ),
107 "countdown_text_type"=>array(
108 "title"=>"Type timer texts or use translation file",
109 "description"=>"You can type texts manually or use WordPress standard translation method with .po and .mo files",
110 "function_name"=>"simple_select",
111 "values"=>array("standart"=>"Type texts","po_mo"=>"Use .mo translation file"),
112 "default_value"=>"po_mo",
113 ),
114 "text_for_weeks"=>array(
115 "title"=>"Text for weeks",
116 "description"=>"Type text for weeks",
117 "function_name"=>"simple_input",
118 "default_value"=>"Weeks",
119 ),
120 "text_for_day"=>array(
121 "title"=>"Text for days",
122 "description"=>"Type text for days",
123 "function_name"=>"simple_input",
124 "default_value"=>"Days",
125 ),
126 "text_for_hour"=>array(
127 "title"=>"Text for hours",
128 "description"=>"Type text for hours",
129 "function_name"=>"simple_input",
130 "default_value"=>"Hours",
131 ),
132 "text_for_minute"=>array(
133 "title"=>"Text for minutes",
134 "description"=>"Type text for minutes",
135 "function_name"=>"simple_input",
136 "default_value"=>"Minutes",
137 ),
138 "text_for_second"=>array(
139 "title"=>"Text for seconds",
140 "description"=>"Type text for seconds",
141 "function_name"=>"simple_input",
142 "default_value"=>"Seconds",
143 ),
144
145 )
146 ),
147 "Standart_countdown"=>array(
148 "heading_name"=>"Standard countdown",
149 "params"=>array(
150 "countdown_standart_elements_width"=>array(
151 "title"=>"Countdown elements(fields) width",
152 "description"=>"Type here the width of countdown timer elements(fields)",
153 "function_name"=>"simple_input",
154 "type"=>"number",
155 "default_value"=>"80",
156 ),
157 "countdown_standart_elements_distance"=>array(
158 "title"=>"Distance between countdown elements",
159 "description"=>"Type here distance between countdown elements",
160 "function_name"=>"simple_input",
161 "type"=>"number",
162 "default_value"=>"5",
163 ),
164 "countdown_standart_time_bg_color"=>array(
165 "title"=>"Time(numbers) fields background color",
166 "description"=>"Select time fields background color",
167 "default_value"=>"#FFFFFF",
168 "function_name"=>"color_input",
169 ),
170 "countdown_standart_time_text_bg_color"=>array(
171 "title"=>"Time text fields background color",
172 "description"=>"Select time text fields(Weeks,Days,Hours,Minutes,Seconds) background color",
173 "default_value"=>"#000000",
174 "function_name"=>"color_input",
175 ),
176 "countdown_standart_time_font_size"=>array(
177 "title"=>"Time(numbers) font size",
178 "description"=>"Type here time(numbers) font size",
179 "function_name"=>"simple_input",
180 "type"=>"number",
181 "default_value"=>"21",
182 ),
183 "countdown_standart_time_text_font_size"=>array(
184 "title"=>"Time text font size",
185 "description"=>"Type here time text font size",
186 "function_name"=>"simple_input",
187 "type"=>"number",
188 "default_value"=>"11",
189 ),
190
191 "countdown_standart_time_color"=>array(
192 "title"=>"Time(numbers) color",
193 "description"=>"Type here time(numbers) color",
194 "default_value"=>"#000000",
195 "function_name"=>"color_input",
196 ),
197 "countdown_standart_time_text_color"=>array(
198 "title"=>"Time text color",
199 "description"=>"Type here time text color",
200 "default_value"=>"#000000",
201 "function_name"=>"color_input",
202 ),
203 "countdown_standart_time_font_famely"=>array(
204 "title"=>"Time(numbers) font family",
205 "description"=>"Type here time(numbers) font family",
206 "function_name"=>"font_select",
207 "values"=>Wpda_Countdown_Admin_Fields::font_choices(),
208 "default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
209 ),
210 "countdown_standart_time_text_font_famely"=>array(
211 "title"=>"Time text font family",
212 "description"=>"Type here time text font family",
213 "function_name"=>"font_select",
214 "values"=>Wpda_Countdown_Admin_Fields::font_choices(),
215 "default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
216 ),
217 "countdown_standart_time_padding"=>array(
218 "title"=>"Time(numbers) padding",
219 "description"=>"Type here time(numbers) padding",
220 "function_name"=>"padding_margin_input",
221 "values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
222 "default_value"=>array("top"=>"0","right"=>"5","bottom"=>"0","left"=>"5"),
223 ),
224 "countdown_standart_time_text_padding"=>array(
225 "title"=>"Time text padding",
226 "description"=>"Type here time text padding",
227 "function_name"=>"padding_margin_input",
228 "values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
229 "default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
230 ),
231 "countdown_standart_time_margin"=>array(
232 "title"=>"Time(numbers) margin",
233 "description"=>"Type here time(numbers) margin",
234 "function_name"=>"padding_margin_input",
235 "values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
236 "default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
237 ),
238 "countdown_standart_time_text_margin"=>array(
239 "title"=>"Time text margin",
240 "description"=>"Type here time text margin",
241 "function_name"=>"padding_margin_input",
242 "values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
243 "default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
244 ),
245 "countdown_standart_time_border_width"=>array(
246 "title"=>"Time(numbers) fields border width",
247 "description"=>"Type here time(numbers) fields border width",
248 "function_name"=>"simple_input",
249 "type"=>"number",
250 "default_value"=>"0",
251 ),
252 "countdown_standart_time_text_border_width"=>array(
253 "title"=>"Time text fields border width",
254 "description"=>"Type here time text fields border width",
255 "function_name"=>"simple_input",
256 "type"=>"number",
257 "default_value"=>"0",
258 ),
259 "countdown_standart_time_border_radius"=>array(
260 "title"=>"Time(numbers) fields border radius",
261 "description"=>"Type here time(numbers) fields border radius",
262 "function_name"=>"simple_input",
263 "type"=>"number",
264 "default_value"=>"0",
265 ),
266 "countdown_standart_time_text_border_radius"=>array(
267 "title"=>"Time text fields border radius",
268 "description"=>"Type here time text fields border radius",
269 "function_name"=>"simple_input",
270 "type"=>"number",
271 "default_value"=>"0",
272 ),
273 "countdown_standart_time_border_color"=>array(
274 "title"=>"Time(numbers) fields border color",
275 "description"=>"Type here time(numbers) fields border color",
276 "default_value"=>"#FFFFFF",
277 "function_name"=>"color_input",
278 ),
279 "countdown_standart_time_text_border_color"=>array(
280 "title"=>"Time text fields border color",
281 "description"=>"Type here time text fields border color",
282 "default_value"=>"#FFFFFF",
283 "function_name"=>"color_input",
284 ),
285 "countdown_standart_display_inline"=>array(
286 "title"=>"Fit on one row",
287 "description"=>"If elements would overflow the container, automatically scale them down so they fit on one row.",
288 "function_name"=>"simple_select",
289 "values"=>array("0"=>"Original sizes","1"=>"Scale to fit row"),
290 "default_value"=>"0",
291 ),
292 "countdown_standart_gorup_animation"=>array(
293 "title"=>"Set animation for each element or for group",
294 "description"=>"Select the animation type for elements",
295 "function_name"=>"simple_select",
296 "values"=>array("group"=>"Group","one"=>"One element"),
297 "default_value"=>"standart",
298 ),
299 "countdown_standart_animation_type"=>array(
300 "title"=>"Animation Effect",
301 "description"=>"Select the animation effect",
302 "function_name"=>"simple_select",
303 "values"=>array(
304 "none"=>"None",
305 "random"=>"Random",
306 "Attention_Seekers"=>array(
307 "bounce"=>"Bounce",
308 "flash"=>"Flash",
309 "pulse"=>"Pulse",
310 "rubberBand"=>"RubberBand",
311 "shake"=>"Shake",
312 "swing"=>"Swing",
313 "tada"=>"tada",
314 "wobble"=>"wobble",
315 ),
316 "Bouncing_Entrances"=>array(
317 "bounceIn"=>"BounceIn",
318 "bounceInDown"=>"BounceInDown",
319 "bounceInLeft"=>"BounceInLeft",
320 "bounceInRight"=>"BounceInRight",
321 "bounceInUp"=>"BounceInUp",
322 ),
323 "Fading_Entrances"=>array(
324 "fadeIn"=>"FadeIn",
325 "fadeInDown"=>"FadeInDown",
326 "fadeInDownBig"=>"FadeInDownBig",
327 "fadeInLeft"=>"FadeInLeft",
328 "fadeInLeftBig"=>"FadeInLeftBig",
329 "fadeInRight"=>"FadeInRight",
330 "fadeInRightBig"=>"FadeInRightBig",
331 "fadeInUp"=>"FadeInUp",
332 "fadeInUpBig"=>"FadeInUpBig",
333 ),
334 "Flippers"=>array(
335 "flip"=>"Flip",
336 "flipInX"=>"FlipInX",
337 "flipInY"=>"FlipInY",
338 ),
339 "Lightspeed"=>array(
340 "lightSpeedIn"=>"LightSpeedIn",
341 ),
342 "Rotating_Entrances"=>array(
343 "rotateIn"=>"RotateIn",
344 "rotateInDownLeft"=>"RotateInDownLeft",
345 "rotateInDownRight"=>"RotateInDownRight",
346 "rotateInUpLeft"=>"RotateInUpLeft",
347 "rotateInUpRight"=>"RotateInUpRight",
348 ),
349 "Specials"=>array(
350 "rollIn"=>"RollIn",
351 ),
352 "Zoom_Entrances"=>array(
353 "zoomIn"=>"ZoomIn",
354 "zoomInDown"=>"ZoomInDown",
355 "zoomInLeft"=>"ZoomInLeft",
356 "zoomInRight"=>"ZoomInRight",
357 "zoomInUp"=>"ZoomInUp",
358 ),
359 ),
360 "default_value"=>"none",
361 ),
362 ),
363 ),
364 "vertical_countdown"=>array(
365 "heading_name"=>"Vertical countdown",
366 "params"=>array(
367 "countdown_vertical_time_font_size"=>array(
368 "title"=>"Time(numbers) font size",
369 "description"=>"Type here time(numbers) font size",
370 "function_name"=>"simple_input",
371 "type"=>"number",
372 "default_value"=>"5",
373 ),
374 "countdown_vertical_elements_distance"=>array(
375 "title"=>"Distance between countdown elements",
376 "description"=>"Type here distance between countdown elements",
377 "function_name"=>"simple_input",
378 "type"=>"number",
379 "default_value"=>"12",
380 "small_text"=>"px"
381 ),
382 "countdown_vertical_time_font_famely"=>array(
383 "title"=>"Time(numbers) font family",
384 "description"=>"Type here time(numbers) font family",
385 "function_name"=>"font_select",
386 "values"=>Wpda_Countdown_Admin_Fields::font_choices(),
387 "default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
388 ),
389 "countdown_vertical_time_color"=>array(
390 "title"=>"Time(numbers) color",
391 "description"=>"Type here time(numbers) color",
392 "default_value"=>"#FFFFFF",
393 "function_name"=>"color_input",
394 ),
395 "countdown_vertical_background_color"=>array(
396 "title"=>"Time(numbers) fields background color",
397 "description"=>"Type here time(numbers) fields background color",
398 "default_value"=>"#FFFFFF",
399 "function_name"=>"color_input",
400 ),
401 "countdown_vertical_time_border_width"=>array(
402 "title"=>"Time(numbers) fields border width",
403 "description"=>"Type here time(numbers) fields border width",
404 "function_name"=>"simple_input",
405 "type"=>"number",
406 "default_value"=>"1",
407 ),
408 "countdown_vertical_time_border_color"=>array(
409 "title"=>"Time(numbers) fields border color",
410 "description"=>"Type here time(numbers) fields border color",
411 "default_value"=>"#000000",
412 "function_name"=>"color_input",
413 ),
414 "countdown_vertical_time_text_bg_color"=>array(
415 "title"=>"Time text fields background color",
416 "description"=>"Select time text fields(Weeks,Days,Hours,Minutes,Seconds) background color",
417 "default_value"=>"#FFFFFF",
418 "function_name"=>"color_input",
419 ),
420
421 "countdown_vertical_time_text_font_size"=>array(
422 "title"=>"Time text font size",
423 "description"=>"Type here time text font size",
424 "function_name"=>"simple_input",
425 "type"=>"number",
426 "default_value"=>"5",
427 ),
428 "countdown_vertical_time_text_color"=>array(
429 "title"=>"Time text color",
430 "description"=>"Type here time text color",
431 "default_value"=>"#FFFFFF",
432 "function_name"=>"color_input",
433 ),
434 "countdown_vertical_time_text_font_famely"=>array(
435 "title"=>"Time text font family",
436 "description"=>"Select here time text font family",
437 "function_name"=>"font_select",
438 "values"=>Wpda_Countdown_Admin_Fields::font_choices(),
439 "default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
440 ),
441 "countdown_vertical_time_text_padding"=>array(
442 "title"=>"Time text padding",
443 "description"=>"Type here time text padding",
444 "function_name"=>"padding_margin_input",
445 "values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
446 "default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
447 ),
448 "countdown_vertical_time_text_margin"=>array(
449 "title"=>"Time text margin",
450 "description"=>"Type here time text margin",
451 "function_name"=>"padding_margin_input",
452 "values"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
453 "default_value"=>array("top"=>"0","right"=>"0","bottom"=>"0","left"=>"0"),
454 ),
455 "countdown_vertical_time_text_border_width"=>array(
456 "title"=>"Time text fields border width",
457 "description"=>"Type here time text fields border width",
458 "function_name"=>"simple_input",
459 "type"=>"number",
460 "default_value"=>"0",
461 ),
462 "countdown_vertical_time_text_border_radius"=>array(
463 "title"=>"Time text fields border radius",
464 "description"=>"Type here time text fields border radius",
465 "function_name"=>"simple_input",
466 "type"=>"number",
467 "default_value"=>"0",
468 ),
469 "countdown_vertical_time_text_border_color"=>array(
470 "title"=>"Time text fields border color",
471 "description"=>"Type here time text fields border color",
472 "default_value"=>"#FFFFFF",
473 "function_name"=>"color_input",
474 ),
475 "countdown_vertical_display_inline"=>array(
476 "title"=>"Fit on one row",
477 "description"=>"If elements would overflow the container, automatically scale them down so they fit on one row.",
478 "function_name"=>"simple_select",
479 "values"=>array("0"=>"Original sizes","1"=>"Scale to fit row"),
480 "default_value"=>"0",
481 ),
482 "countdown_vertical_gorup_animation"=>array(
483 "title"=>"Set animation for each element or for group",
484 "description"=>"Select the animation type for elements",
485 "function_name"=>"simple_select",
486 "values"=>array("group"=>"Group","one"=>"One element"),
487 "default_value"=>"standart",
488 ),
489 "countdown_vertical_animation_type"=>array(
490 "title"=>"Animation Effect",
491 "description"=>"Select the animation effect",
492 "function_name"=>"simple_select",
493 "values"=>array(
494 "none"=>"None",
495 "random"=>"Random",
496 "Attention_Seekers"=>array(
497 "bounce"=>"Bounce",
498 "flash"=>"Flash",
499 "pulse"=>"Pulse",
500 "rubberBand"=>"RubberBand",
501 "shake"=>"Shake",
502 "swing"=>"Swing",
503 "tada"=>"tada",
504 "wobble"=>"wobble",
505 ),
506 "Bouncing_Entrances"=>array(
507 "bounceIn"=>"BounceIn",
508 "bounceInDown"=>"BounceInDown",
509 "bounceInLeft"=>"BounceInLeft",
510 "bounceInRight"=>"BounceInRight",
511 "bounceInUp"=>"BounceInUp",
512 ),
513 "Fading_Entrances"=>array(
514 "fadeIn"=>"FadeIn",
515 "fadeInDown"=>"FadeInDown",
516 "fadeInDownBig"=>"FadeInDownBig",
517 "fadeInLeft"=>"FadeInLeft",
518 "fadeInLeftBig"=>"FadeInLeftBig",
519 "fadeInRight"=>"FadeInRight",
520 "fadeInRightBig"=>"FadeInRightBig",
521 "fadeInUp"=>"FadeInUp",
522 "fadeInUpBig"=>"FadeInUpBig",
523 ),
524 "Flippers"=>array(
525 "flip"=>"Flip",
526 "flipInX"=>"FlipInX",
527 "flipInY"=>"FlipInY",
528 ),
529 "Lightspeed"=>array(
530 "lightSpeedIn"=>"LightSpeedIn",
531 ),
532 "Rotating_Entrances"=>array(
533 "rotateIn"=>"RotateIn",
534 "rotateInDownLeft"=>"RotateInDownLeft",
535 "rotateInDownRight"=>"RotateInDownRight",
536 "rotateInUpLeft"=>"RotateInUpLeft",
537 "rotateInUpRight"=>"RotateInUpRight",
538 ),
539 "Specials"=>array(
540 "rollIn"=>"RollIn",
541 ),
542 "Zoom_Entrances"=>array(
543 "zoomIn"=>"ZoomIn",
544 "zoomInDown"=>"ZoomInDown",
545 "zoomInLeft"=>"ZoomInLeft",
546 "zoomInRight"=>"ZoomInRight",
547 "zoomInUp"=>"ZoomInUp",
548 ),
549 ),
550 "default_value"=>"none",
551 ),
552 ),
553 ),
554 "circle_countdown"=>array(
555 "heading_name"=>"Circle countdown",
556 "params"=>array(
557 "countdown_circle_elements_width_height"=>array(
558 "title"=>"Circle size",
559 "description"=>"Diameter of each circle in pixels",
560 "function_name"=>"range_input",
561 "min_value"=>"60",
562 "max_value"=>"250",
563 "default_value"=>"120",
564 "small_text"=>"px",
565 ),
566 "countdown_circle_elements_distance"=>array(
567 "title"=>"Gap between circles",
568 "description"=>"Space between each circle element",
569 "function_name"=>"range_input",
570 "min_value"=>"0",
571 "max_value"=>"50",
572 "default_value"=>"12",
573 "small_text"=>"px",
574 ),
575 "countdown_circle_background_color"=>array(
576 "title"=>"Circle fill color",
577 "description"=>"Background color inside the circle",
578 "default_value"=>"#ffffff",
579 "function_name"=>"color_input",
580 ),
581 "countdown_circle_background_color_opacity"=>array(
582 "title"=>"Circle fill opacity",
583 "description"=>"Opacity of the circle fill (0 = transparent)",
584 "function_name"=>"range_input",
585 "small_text"=>"%",
586 "default_value"=>"100",
587 ),
588 "countdown_circle_border_color_outside"=>array(
589 "title"=>"Track color",
590 "description"=>"Color of the ring background track",
591 "default_value"=>"#e0e0e0",
592 "function_name"=>"color_input",
593 ),
594 "countdown_circle_border_color_inside"=>array(
595 "title"=>"Progress color",
596 "description"=>"Color of the ring progress arc",
597 "default_value"=>"#2271b1",
598 "function_name"=>"color_input",
599 ),
600 "countdown_circle_width_parcents"=>array(
601 "title"=>"Ring thickness",
602 "description"=>"Thickness of the progress ring as percentage of circle size",
603 "function_name"=>"range_input",
604 "min_value"=>"1",
605 "max_value"=>"30",
606 "small_text"=>"%",
607 "default_value"=>"8",
608 ),
609 "countdown_circle_type_of_rounding"=>array(
610 "title"=>"Ring end caps",
611 "description"=>"Shape of the progress ring endpoints",
612 "function_name"=>"simple_select",
613 "values"=>array("butt"=>"Flat","round"=>"Rounded"),
614 "default_value"=>"round",
615 ),
616 "countdown_circle_border_direction"=>array(
617 "title"=>"Progress direction",
618 "description"=>"Which direction the ring fills",
619 "function_name"=>"simple_select",
620 "values"=>array("right"=>"Clockwise","left"=>"Counter-clockwise"),
621 "default_value"=>"right",
622 ),
623 "countdown_circle_time_font_size"=>array(
624 "title"=>"Number font size",
625 "description"=>"Font size for the countdown digits",
626 "function_name"=>"range_input",
627 "min_value"=>"10",
628 "max_value"=>"60",
629 "default_value"=>"28",
630 "small_text"=>"px",
631 ),
632 "countdown_circle_time_text_font_size"=>array(
633 "title"=>"Label font size",
634 "description"=>"Font size for the labels (Days, Hours, etc.)",
635 "function_name"=>"range_input",
636 "min_value"=>"8",
637 "max_value"=>"30",
638 "default_value"=>"12",
639 "small_text"=>"px",
640 ),
641 "countdown_circle_time_color"=>array(
642 "title"=>"Number color",
643 "description"=>"Color of the countdown digits",
644 "default_value"=>"#1d2327",
645 "function_name"=>"color_input",
646 ),
647 "countdown_circle_time_text_color"=>array(
648 "title"=>"Label color",
649 "description"=>"Color of the labels",
650 "default_value"=>"#50575e",
651 "function_name"=>"color_input",
652 ),
653 "countdown_circle_time_font_famely"=>array(
654 "title"=>"Font family",
655 "description"=>"Font for numbers and labels",
656 "function_name"=>"font_select",
657 "values"=>Wpda_Countdown_Admin_Fields::font_choices(),
658 "default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
659 ),
660 "countdown_circle_display_inline"=>array(
661 "title"=>"Fit on one row",
662 "description"=>"If circles would overflow the container, automatically scale them down so they fit on one row.",
663 "function_name"=>"simple_select",
664 "values"=>array("0"=>"Original sizes","1"=>"Scale to fit row"),
665 "default_value"=>"0",
666 ),
667 "countdown_circle_gorup_animation"=>array(
668 "title"=>"Set animation for each element or for group",
669 "description"=>"Select the animation type for elements",
670 "function_name"=>"simple_select",
671 "values"=>array("group"=>"Group","one"=>"One element"),
672 "default_value"=>"group",
673 ),
674 "countdown_circle_animation_type"=>array(
675 "title"=>"Animation Effect",
676 "description"=>"Select the animation effect",
677 "function_name"=>"simple_select",
678 "values"=>array(
679 "none"=>"None",
680 "random"=>"Random",
681 "Attention_Seekers"=>array(
682 "bounce"=>"Bounce",
683 "flash"=>"Flash",
684 "pulse"=>"Pulse",
685 "rubberBand"=>"RubberBand",
686 "shake"=>"Shake",
687 "swing"=>"Swing",
688 "tada"=>"tada",
689 "wobble"=>"wobble",
690 ),
691 "Bouncing_Entrances"=>array(
692 "bounceIn"=>"BounceIn",
693 "bounceInDown"=>"BounceInDown",
694 "bounceInLeft"=>"BounceInLeft",
695 "bounceInRight"=>"BounceInRight",
696 "bounceInUp"=>"BounceInUp",
697 ),
698 "Fading_Entrances"=>array(
699 "fadeIn"=>"FadeIn",
700 "fadeInDown"=>"FadeInDown",
701 "fadeInDownBig"=>"FadeInDownBig",
702 "fadeInLeft"=>"FadeInLeft",
703 "fadeInLeftBig"=>"FadeInLeftBig",
704 "fadeInRight"=>"FadeInRight",
705 "fadeInRightBig"=>"FadeInRightBig",
706 "fadeInUp"=>"FadeInUp",
707 "fadeInUpBig"=>"FadeInUpBig",
708 ),
709 "Flippers"=>array(
710 "flip"=>"Flip",
711 "flipInX"=>"FlipInX",
712 "flipInY"=>"FlipInY",
713 ),
714 "Lightspeed"=>array(
715 "lightSpeedIn"=>"LightSpeedIn",
716 ),
717 "Rotating_Entrances"=>array(
718 "rotateIn"=>"RotateIn",
719 "rotateInDownLeft"=>"RotateInDownLeft",
720 "rotateInDownRight"=>"RotateInDownRight",
721 "rotateInUpLeft"=>"RotateInUpLeft",
722 "rotateInUpRight"=>"RotateInUpRight",
723 ),
724 "Specials"=>array(
725 "rollIn"=>"RollIn",
726 ),
727 "Zoom_Entrances"=>array(
728 "zoomIn"=>"ZoomIn",
729 "zoomInDown"=>"ZoomInDown",
730 "zoomInLeft"=>"ZoomInLeft",
731 "zoomInRight"=>"ZoomInRight",
732 "zoomInUp"=>"ZoomInUp",
733 ),
734 ),
735 "default_value"=>"none",
736 ),
737 ),
738 ),
739 "countdown_flip_settings"=>array(
740 "heading_name"=>"Flip Clock",
741 "params"=>array(
742 "countdown_flip_card_bg"=>array(
743 "title"=>"Card background",
744 "description"=>"Background color of the flip cards",
745 "function_name"=>"color_input",
746 "default_value"=>"#1d2327",
747 ),
748 "countdown_flip_card_color"=>array(
749 "title"=>"Card text color",
750 "description"=>"Digit color on the flip cards",
751 "function_name"=>"color_input",
752 "default_value"=>"#ffffff",
753 ),
754 "countdown_flip_label_color"=>array(
755 "title"=>"Label color",
756 "description"=>"Color of the labels below the cards (Days, Hours, etc.)",
757 "function_name"=>"color_input",
758 "default_value"=>"#50575e",
759 ),
760 "countdown_flip_card_width"=>array(
761 "title"=>"Card width",
762 "description"=>"Width of each flip card in pixels",
763 "function_name"=>"range_input",
764 "min_value"=>"40",
765 "max_value"=>"150",
766 "default_value"=>"70",
767 "small_text"=>"px",
768 ),
769 "countdown_flip_card_height"=>array(
770 "title"=>"Card height",
771 "description"=>"Height of each flip card in pixels",
772 "function_name"=>"range_input",
773 "min_value"=>"40",
774 "max_value"=>"180",
775 "default_value"=>"80",
776 "small_text"=>"px",
777 ),
778 "countdown_flip_font_size"=>array(
779 "title"=>"Digit font size",
780 "description"=>"Font size of the digits in pixels",
781 "function_name"=>"range_input",
782 "min_value"=>"16",
783 "max_value"=>"80",
784 "default_value"=>"36",
785 "small_text"=>"px",
786 ),
787 "countdown_flip_gap"=>array(
788 "title"=>"Gap between cards",
789 "description"=>"Space between flip cards in pixels",
790 "function_name"=>"range_input",
791 "min_value"=>"4",
792 "max_value"=>"40",
793 "default_value"=>"12",
794 "small_text"=>"px",
795 ),
796 "countdown_flip_border_radius"=>array(
797 "title"=>"Card border radius",
798 "description"=>"Corner roundness of the flip cards",
799 "function_name"=>"range_input",
800 "min_value"=>"0",
801 "max_value"=>"20",
802 "default_value"=>"8",
803 "small_text"=>"px",
804 ),
805 "countdown_flip_font_family"=>array(
806 "title"=>"Font family",
807 "description"=>"Font for the digits",
808 "function_name"=>"font_select",
809 "values"=>Wpda_Countdown_Admin_Fields::font_choices(),
810 "default_value"=>"Arial,Helvetica Neue,Helvetica,sans-serif",
811 ),
812 "countdown_flip_display_inline"=>array(
813 "title"=>"Fit on one row",
814 "description"=>"If flip cards would overflow the container, automatically scale them down so they fit on one row.",
815 "function_name"=>"simple_select",
816 "values"=>array("0"=>"Original sizes","1"=>"Scale to fit row"),
817 "default_value"=>"0",
818 ),
819 "countdown_flip_gorup_animation"=>array(
820 "title"=>"Set animation for each element or for group",
821 "description"=>"Select the animation type for elements",
822 "function_name"=>"simple_select",
823 "values"=>array("group"=>"Group","one"=>"One element"),
824 "default_value"=>"group",
825 ),
826 "countdown_flip_animation_type"=>array(
827 "title"=>"Animation Effect",
828 "description"=>"Select the animation effect",
829 "function_name"=>"simple_select",
830 "values"=>array(
831 "none"=>"None",
832 "random"=>"Random",
833 "Attention_Seekers"=>array(
834 "bounce"=>"Bounce",
835 "flash"=>"Flash",
836 "pulse"=>"Pulse",
837 "rubberBand"=>"RubberBand",
838 "shake"=>"Shake",
839 "swing"=>"Swing",
840 "tada"=>"tada",
841 "wobble"=>"wobble",
842 ),
843 "Bouncing_Entrances"=>array(
844 "bounceIn"=>"BounceIn",
845 "bounceInDown"=>"BounceInDown",
846 "bounceInLeft"=>"BounceInLeft",
847 "bounceInRight"=>"BounceInRight",
848 "bounceInUp"=>"BounceInUp",
849 ),
850 "Fading_Entrances"=>array(
851 "fadeIn"=>"FadeIn",
852 "fadeInDown"=>"FadeInDown",
853 "fadeInDownBig"=>"FadeInDownBig",
854 "fadeInLeft"=>"FadeInLeft",
855 "fadeInLeftBig"=>"FadeInLeftBig",
856 "fadeInRight"=>"FadeInRight",
857 "fadeInRightBig"=>"FadeInRightBig",
858 "fadeInUp"=>"FadeInUp",
859 "fadeInUpBig"=>"FadeInUpBig",
860 ),
861 "Flippers"=>array(
862 "flip"=>"Flip",
863 "flipInX"=>"FlipInX",
864 "flipInY"=>"FlipInY",
865 ),
866 "Lightspeed"=>array(
867 "lightSpeedIn"=>"LightSpeedIn",
868 ),
869 "Rotating_Entrances"=>array(
870 "rotateIn"=>"RotateIn",
871 "rotateInDownLeft"=>"RotateInDownLeft",
872 "rotateInDownRight"=>"RotateInDownRight",
873 "rotateInUpLeft"=>"RotateInUpLeft",
874 "rotateInUpRight"=>"RotateInUpRight",
875 ),
876 "Specials"=>array(
877 "rollIn"=>"RollIn",
878 ),
879 "Zoom_Entrances"=>array(
880 "zoomIn"=>"ZoomIn",
881 "zoomInDown"=>"ZoomInDown",
882 "zoomInLeft"=>"ZoomInLeft",
883 "zoomInRight"=>"ZoomInRight",
884 "zoomInUp"=>"ZoomInUp",
885 ),
886 ),
887 "default_value"=>"none",
888 ),
889 ),
890 ),
891 );
892 }
893 public static function get_default_values_array(){
894 $array_of_returned=array();
895 $options=self::return_params_array();
896 foreach($options as $param_heading_key=>$param_heading_value){
897 foreach($param_heading_value['params'] as $key=>$value){
898 $array_of_returned[$key]=$value['default_value'];
899 }
900 }
901 return $array_of_returned;
902 }
903 public function controller_page(){
904 $task = isset( $_GET['task'] ) ? sanitize_text_field( $_GET['task'] ) : 'default';
905 $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
906
907 switch ( $task ) {
908 case 'add_wpda_countdown_theme':
909 case 'add_edit_theme':
910 $this->add_edit_theme( $id );
911 break;
912
913 case 'save_theme':
914 $this->save_theme( $id );
915 $this->display_table_list_theme();
916 break;
917
918 case 'update_theme':
919 $result_id = $this->save_theme( $id );
920 if ( ! $id && $result_id ) $id = $result_id;
921 $this->add_edit_theme( $id );
922 break;
923
924 case 'set_default_theme':
925 // Default-setting already handled by AdminMenu::process_theme_actions() before render
926 $this->display_table_list_theme();
927 break;
928
929 case 'remove_theme':
930 // Delete already handled by AdminMenu::process_theme_actions() before render
931 $this->display_table_list_theme();
932 break;
933
934 default:
935 $this->display_table_list_theme();
936 }
937 }
938
939 /*############ Save / Update (unified via Repository) ################*/
940
941 private function save_theme( $id = 0 ) {
942 if ( count( $_POST ) === 0 ) return 0;
943 if ( ! isset( $_POST['wpda_theme_nonce'] ) || ! wp_verify_nonce( $_POST['wpda_theme_nonce'], 'wpda_theme_save' ) ) return 0;
944
945 $name = isset( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : 'theme';
946 if ( $name === '' || $name === '0' ) $name = 'Unnamed';
947
948 // Free mode: Pro fields render but are locked from editing. Load the
949 // existing theme data so we can preserve all Pro field values (spacing,
950 // sizing, vertical/circle/flip settings) across a free-mode save.
951 $existing = ( $id && ! WPDA_COUNTDOWN_IS_PRO ) ? ( $this->repo->find_data( $id ) ?: array() ) : array();
952 $pro_keys = self::pro_field_keys();
953 $pro_groups = self::pro_groups();
954
955 $data = array( 'name' => $name );
956 foreach ( $this->options as $gk => $group ) {
957 if ( empty( $group['params'] ) ) continue;
958 $whole_group_pro = in_array( $gk, $pro_groups, true );
959 foreach ( $group['params'] as $key => $field ) {
960 $is_pro_field = ! WPDA_COUNTDOWN_IS_PRO && ( $whole_group_pro || in_array( $key, $pro_keys, true ) );
961 if ( $is_pro_field ) {
962 // Keep the stored value (or fall back to the field default)
963 $data[ $key ] = isset( $existing[ $key ] ) ? $existing[ $key ] : $field['default_value'];
964 continue;
965 }
966 $data[ $key ] = isset( $_POST[ $key ] )
967 ? Wpda_Countdown_Admin_Fields::sanitize_field_value( $field, $_POST[ $key ] )
968 : $field['default_value'];
969 }
970 }
971
972 $result_id = $this->repo->save( $id, $name, $data );
973 if ( $result_id ) {
974 echo '<div class="updated"><p><strong>Item Saved</strong></p></div>';
975 } else {
976 echo '<div id="message" class="error"><p>Error please reinstall plugin</p></div>';
977 }
978 return $result_id;
979 }
980
981
982 private function display_table_list_theme(){
983 // Output fresh list data so the table reflects any save/delete
984 // that happened earlier in this request (enqueue hook localized
985 // data BEFORE the save, so JS would otherwise see a stale snapshot).
986 echo '<script>window.wpdaPageRowsList = ' . wp_json_encode( $this->get_row_list() ) . ';</script>';
987
988 $params = array(
989 'name' => 'Themes',
990 'add_new_link' => 'admin.php?page=wpda_countdown_themes&task=add_wpda_countdown_theme',
991 'support_link' => wpdevart_countdown_support_url,
992 );
993 include wpda_countdown_plugin_path . 'includes/admin/Views/list-header.php';
994 }
995
996 public function get_row_list(){
997 $rows = $this->repo->all();
998 $type_labels=array('standart'=>'Standard','vertical'=>'Vertical','circle'=>'Circle','flip'=>'Flip Clock');
999 $result = array();
1000 foreach($rows as $row){
1001 $data=json_decode($row->option_value,true);
1002 $type=isset($data['countdown_type'])?$data['countdown_type']:'standart';
1003 $result[] = array('id' => $row->id, 'name' => strip_tags($row->name), 'design' => isset($type_labels[$type])?$type_labels[$type]:$type, 'default' => $row->default);
1004 }
1005 return $result;
1006 }
1007
1008 public function get_table_info(){
1009 $nonce = wp_create_nonce( 'wpda_theme_action' );
1010 return array(
1011 'keys' => array(
1012 'id' => array( 'name' => 'ID', 'sortable' => true ),
1013 'name' => array( 'name' => 'Name', 'link' => '&task=add_edit_theme', 'sortable' => true ),
1014 'design' => array( 'name' => 'Design', 'sortable' => true ),
1015 'default' => array( 'name' => 'Default', 'link' => '&task=set_default_theme&_wpnonce=' . $nonce, 'replace_value' => array(
1016 '1' => '<svg width="18" height="18" viewBox="0 0 24 24" fill="#f0b849" stroke="#f0b849" stroke-width="1"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>',
1017 '0' => '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#c3c4c7" stroke-width="1.5"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>',
1018 ) ),
1019 'edit' => array( 'name' => 'Edit', 'link' => '&task=add_edit_theme' ),
1020 'delete' => array( 'name' => 'Delete', 'link' => '&task=remove_theme&_wpnonce=' . $nonce ),
1021 ),
1022 'link_page' => 'wpda_countdown_themes',
1023 );
1024 }
1025
1026 private function generete_theme_parametrs($id=0){
1027 $theme_params = null;
1028 $new_theme = 1;
1029 if ( $id ) {
1030 $theme_params = $this->repo->find( $id );
1031 $new_theme = 0;
1032 } else {
1033 $theme_params = $this->repo->find_default();
1034 }
1035 if($theme_params==NULL){
1036 foreach($this->options as $param_heading_key=>$param_heading_value){
1037 foreach($param_heading_value['params'] as $key=>$value){
1038 $this->options[$param_heading_key]['params'][$key]["value"]=$this->options[$param_heading_key]['params'][$key]["default_value"];
1039 }
1040 }
1041 }else{
1042 $databases_parametrs=json_decode($theme_params->option_value, true);
1043 foreach($this->options as $param_heading_key=>$param_heading_value){
1044 foreach($param_heading_value['params'] as $key=>$value){
1045 if(isset($databases_parametrs[$key])){
1046 $this->options[$param_heading_key]['params'][$key]["value"]=$databases_parametrs[$key];
1047 }else{
1048 $this->options[$param_heading_key]['params'][$key]["value"]=$this->options[$param_heading_key]['params'][$key]["default_value"];
1049 }
1050 }
1051 }
1052 if($new_theme){
1053 return "New Theme";
1054 }else{
1055 return $theme_params->name;
1056 }
1057 }
1058 }
1059
1060
1061 private function add_edit_theme( $id = 0 ) {
1062 $name = $this->generete_theme_parametrs( $id );
1063 ?>
1064 <form action="admin.php?page=wpda_countdown_themes<?php if($id) echo '&id='.$id; ?>" method="post" name="adminForm" class="top_description_table" id="adminForm">
1065 <?php wp_nonce_field('wpda_theme_save','wpda_theme_nonce'); ?>
1066 <div class="conteiner">
1067 <?php Wpda_Countdown_Admin_Fields::render_pro_banner(); ?>
1068 <div class="header">
1069 <span><h2 class="wpda_theme_title"><?php echo $id?"Edit":"Add" ?> Theme</h2></span>
1070 <div class="header_action_buttons">
1071 <span><input type="button" onclick="submitbutton('save_theme')" value="Save" class="button-primary action"> </span>
1072 <span><input type="button" onclick="submitbutton('update_theme')" value="Apply" class="button-primary action"> </span>
1073 <span><input type="button" onclick="window.location.href='admin.php?page=wpda_countdown_themes'" value="Cancel" class="button-secondary action"> </span>
1074 </div>
1075 </div>
1076 <div id="wpda_theme_preview_wrap" style="margin:12px 0;padding:20px;background:#f0f0f1;border:1px solid #ddd;border-radius:8px;">
1077 <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;">
1078 <span style="font-weight:600;font-size:13px;color:#1d2327;">Preview</span>
1079 <button type="button" id="wpda_refresh_preview" class="button button-small">Refresh Preview</button>
1080 </div>
1081 <div id="wpda_theme_preview" style="padding:20px;border-radius:6px;text-align:center;background:#fff;min-height:60px;display:flex;align-items:center;justify-content:center;"></div>
1082 </div>
1083 <div class="option_panel">
1084 <div class="parametr_name"></div>
1085 <div class="all_options_panel">
1086 <input type="text" class="theme_name" name="name" placeholder="Enter name here" value="<?php echo esc_attr( isset( $name ) ? $name : '' ); ?>">
1087 <div class="wpda_theme_link_tabs">
1088 <?php
1089 $type_map=array('standart'=>'Standart_countdown','vertical'=>'vertical_countdown','circle'=>'circle_countdown','flip'=>'countdown_flip_settings');
1090 $cur_type=isset($this->options['countdown_theme_general']['params']['countdown_type']['value'])?$this->options['countdown_theme_general']['params']['countdown_type']['value']:'standart';
1091 $active_type_tab=isset($type_map[$cur_type])?$type_map[$cur_type]:'Standart_countdown';
1092 echo '<ul>';
1093 foreach ( $this->options as $params_grup_name => $params_group_value ) {
1094 $is_type_tab = in_array( $params_grup_name, $type_map );
1095 $is_active_type = ( $params_grup_name === $active_type_tab );
1096 $cls = ( $is_type_tab && ! $is_active_type ) ? 'wpda_type_tab' : 'wpda_type_tab wpda_type_tab_visible';
1097 if ( ! $is_type_tab ) $cls = '';
1098 echo '<li id="' . esc_attr( $params_grup_name ) . '_tab" class="' . esc_attr( $cls ) . '">' . esc_html( $params_group_value['heading_name'] ) . '</li>';
1099 }
1100 echo '</ul>';
1101 ?>
1102 </div>
1103 <table>
1104 <?php
1105 foreach($this->options as $params_grup_name =>$params_group_value){
1106 Wpda_Countdown_Admin_Fields::heading($params_group_value['heading_name'],$params_grup_name);
1107 foreach($params_group_value['params'] as $param_name => $param_value){
1108 $args=array(
1109 "name"=>$param_name,
1110 "heading_name"=>$params_group_value['heading_name'],
1111 "heading_group"=>$params_grup_name,
1112 );
1113 $args=array_merge($args,$param_value);
1114 if($param_value['function_name']==='input_with_unit'&&isset($param_value['unit_name'])){
1115 $un=$param_value['unit_name'];
1116 if(isset($params_group_value['params'][$un]['value']))
1117 $args['unit_value']=$params_group_value['params'][$un]['value'];
1118 elseif(isset($param_value['unit_default']))
1119 $args['unit_value']=$param_value['unit_default'];
1120 }
1121 $function_name=$param_value['function_name'];
1122 Wpda_Countdown_Admin_Fields::$function_name($args);
1123 }
1124 }
1125
1126 ?>
1127 </table>
1128 </div>
1129 </div>
1130 </div>
1131 </form>
1132 <?php
1133
1134
1135 }
1136 }
1137