PluginProbe
Countix Sales Countdown Timer / trunk
Countix Sales Countdown Timer vtrunk
sales-countdown-timer / includes / data.php

data.php in Countix Sales Countdown Timer trunk, at includes/data.php

428 lines 18.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 class SALES_COUNTDOWN_TIMER_Data {
7 private $params, $default;
8
9 /**
10 * SALES_COUNTDOWN_TIMER_Data constructor.
11 * Init setting
12 */
13 public function __construct() {
14
15 global $woo_ctr_settings;
16 $this->default = array(
17 'id' => array( 'salescountdowntimer' ),
18 'names' => array( 'Countdown timer' ),
19 'message' => array( 'Hurry Up! Offer ends in {countdown_timer}' ),
20 'active' => array( 1 ),
21 'enable_single_product' => array( 1 ),
22 'time_type' => array( 'fixed' ),
23 'count_style' => array( 2 ),
24 'sale_from_date' => array( gmdate( "Y-m-d", current_time( 'timestamp' ) ) ),
25 'sale_to_date' => array( gmdate( "Y-m-d", current_time( 'timestamp' ) + 30 * 86400 ) ),
26 'sale_from_time' => array( '' ),
27 'sale_to_time' => array( '' ),
28 'upcoming' => array( 1 ),
29 'upcoming_message' => array( 'Sale starts in {countdown_timer}' ),
30 'style' => array( '' ),
31 'position' => array( 'after_price' ),
32 'archive_page_position' => array( 'after_price' ),
33 'progress_bar' => array( 1 ),
34 'progress_bar_message' => array( '{quantity_sold}/{goal} sold' ),
35 'progress_bar_type' => array( 'increase' ),
36 'progress_bar_order_status' => array( '' ),
37 'progress_bar_total' => array( '' ),
38 'progress_bar_position' => array( 'below_countdown' ),
39 'progress_bar_style' => array( 1 ),
40 'progress_bar_width' => array( '' ),
41 'progress_bar_height' => array( 20 ),
42 'progress_bar_color' => array( '#ffb600' ),
43 'progress_bar_bg_color' => array( '#eeeeee' ),
44 'progress_bar_border_radius' => array( 20 ),
45 'time_separator' => array( 'blank' ),
46 'display_type' => array( 3 ),
47 'datetime_unit_bg_color' => array( '' ),
48 'datetime_unit_color' => array( '' ),
49 'datetime_unit_font_size' => array( 12),
50 'datetime_value_color' => array( '#ffb600' ),
51 'datetime_value_bg_color' => array( '' ),
52 'datetime_value_font_size' => array( 28 ),
53 'countdown_timer_hide_zero' => array( 1 ),
54 'countdown_timer_padding' => array( 2 ),
55 'countdown_timer_border_radius' => array( 0 ),
56 'countdown_timer_color' => array( '#000000' ),
57 'countdown_timer_bg_color' => array( '' ),
58 'countdown_timer_border_color' => array( '' ),
59 'countdown_timer_item_border_radius' => array( 0 ),
60 'countdown_timer_item_border_color' => array( '#e2e2e2' ),
61 'countdown_timer_item_height' => array( 70 ),
62 'countdown_timer_item_width' => array( 70 ),
63 'shop_page' => array( '' ),
64 'category_page' => array( '' ),
65 'size_on_archive_page' => array( '75' ),
66 'datetime_unit_position' => array( 'bottom' ),
67 'animation_style' => array( 'default' ),
68 'circle_smooth_animation' => array( 1 ),
69 'stick_to_top' => array( 1 ),
70
71 );
72 if (!$woo_ctr_settings){
73 $woo_ctr_settings = get_option( 'sales_countdown_timer_params', array() );
74 }
75 if (empty($woo_ctr_settings) || empty($woo_ctr_settings['names'])){
76 set_transient( '_sales_countdown_timer_demo_product_init', current_time( 'timestamp' ), 180 * DAY_IN_SECONDS );
77 }
78
79 $this->params = apply_filters( 'woo_ctr_settings_args', wp_parse_args( $woo_ctr_settings, $this->default ) );
80 }
81
82 /**
83 * Get add to cart redirect
84 * @return mixed|void
85 */
86 public function get_id() {
87 return apply_filters( 'woo_ctr_get_id', $this->params['id'] );
88 }
89
90 public function get_names() {
91 return apply_filters( 'woo_ctr_get_names', $this->params['names'] );
92 }
93
94 public function get_message() {
95 return apply_filters( 'woo_ctr_get_message', $this->params['message'] );
96 }
97
98 public function get_upcoming_message() {
99 return apply_filters( 'woo_ctr_get_upcoming_message', $this->params['upcoming_message'] );
100 }
101
102 public function get_time_type() {
103 return apply_filters( 'woo_ctr_get_time_type', $this->params['time_type'] );
104 }
105
106 public function get_count_style() {
107 return apply_filters( 'woo_ctr_get_count_style', $this->params['count_style'] );
108 }
109
110 public function get_active() {
111 return apply_filters( 'woo_ctr_get_active', $this->params['active'] );
112 }
113
114 public function get_enable_single_product() {
115 return apply_filters( 'woo_ctr_get_enable_single_product', $this->params['enable_single_product'] );
116 }
117
118 public function get_sale_from_date() {
119 return apply_filters( 'woo_ctr_get_sale_from_date', $this->params['sale_from_date'] );
120 }
121
122 public function get_sale_to_date() {
123 return apply_filters( 'woo_ctr_get_sale_to_date', $this->params['sale_to_date'] );
124 }
125
126 public function get_sale_from_time() {
127 return apply_filters( 'woo_ctr_get_sale_from_time', $this->params['sale_from_time'] );
128 }
129
130 public function get_sale_to_time() {
131 return apply_filters( 'woo_ctr_get_sale_to_time', $this->params['sale_to_time'] );
132 }
133
134 public function get_upcoming() {
135 return apply_filters( 'woo_ctr_get_upcoming', $this->params['upcoming'] );
136 }
137
138 public function get_style() {
139 return apply_filters( 'woo_ctr_get_style', $this->params['style'] );
140 }
141
142 public function get_position() {
143 return apply_filters( 'woo_ctr_get_position', $this->params['position'] );
144 }
145
146 public function get_archive_page_position() {
147 return apply_filters( 'woo_ctr_get_archive_page_position', $this->params['archive_page_position'] );
148 }
149
150 public function get_progress_bar() {
151 return apply_filters( 'woo_ctr_get_progress_bar', $this->params['progress_bar'] );
152 }
153
154 public function get_progress_bar_message() {
155 return apply_filters( 'woo_ctr_get_progress_bar_message', $this->params['progress_bar_message'] );
156 }
157
158 public function get_progress_bar_type() {
159 return apply_filters( 'woo_ctr_get_progress_bar_type', $this->params['progress_bar_type'] );
160 }
161
162 public function get_progress_bar_order_status() {
163 return apply_filters( 'woo_ctr_get_progress_bar_order_status', $this->params['progress_bar_order_status'] );
164 }
165
166 public function get_progress_bar_total() {
167 return apply_filters( 'woo_ctr_get_progress_bar_total', $this->params['progress_bar_total'] );
168 }
169
170 public function get_progress_bar_position() {
171 return apply_filters( 'woo_ctr_get_progress_bar_position', $this->params['progress_bar_position'] );
172 }
173
174 public function get_progress_bar_initial() {
175 return apply_filters( 'woo_ctr_get_progress_bar_initial', $this->params['progress_bar_initial'] );
176 }
177
178 public function get_progress_bar_max() {
179 return apply_filters( 'woo_ctr_get_progress_bar_max', $this->params['progress_bar_max'] );
180 }
181
182 public function get_progress_bar_style() {
183 return apply_filters( 'woo_ctr_get_progress_bar_style', $this->params['progress_bar_style'] );
184 }
185
186 public function get_progress_bar_border_radius() {
187 return apply_filters( 'woo_ctr_get_progress_bar_border_radius', $this->params['progress_bar_border_radius'] );
188 }
189
190 public function get_progress_bar_width() {
191 return apply_filters( 'woo_ctr_get_progress_bar_width', $this->params['progress_bar_width'] );
192 }
193
194 public function get_progress_bar_height() {
195 return apply_filters( 'woo_ctr_get_progress_bar_height', $this->params['progress_bar_height'] );
196 }
197
198 public function get_progress_bar_color() {
199 return apply_filters( 'woo_ctr_get_progress_bar_color', $this->params['progress_bar_color'] );
200 }
201
202 public function get_progress_bar_bg_color() {
203 return apply_filters( 'woo_ctr_get_progress_bar_bg_color', $this->params['progress_bar_bg_color'] );
204 }
205
206 public function get_time_separator() {
207 return apply_filters( 'woo_ctr_get_time_separator', $this->params['time_separator'] );
208 }
209
210 public function get_display_type() {
211 return apply_filters( 'woo_ctr_get_display_type', $this->params['display_type'] );
212 }
213
214 public function get_datetime_unit_color() {
215 return apply_filters( 'woo_ctr_get_datetime_unit_color', $this->params['datetime_unit_color'] );
216 }
217
218 public function get_datetime_unit_bg_color() {
219 return apply_filters( 'woo_ctr_get_datetime_unit_bg_color', $this->params['datetime_unit_bg_color'] );
220 }
221
222 public function get_datetime_unit_font_size() {
223 return apply_filters( 'woo_ctr_get_datetime_unit_font_size', $this->params['datetime_unit_font_size'] );
224 }
225
226 public function get_datetime_value_color() {
227 return apply_filters( 'woo_ctr_get_datetime_value_color', $this->params['datetime_value_color'] );
228 }
229
230 public function get_datetime_value_bg_color() {
231 return apply_filters( 'woo_ctr_get_datetime_value_bg_color', $this->params['datetime_value_bg_color'] );
232 }
233
234 public function get_datetime_value_font_size() {
235 return apply_filters( 'woo_ctr_get_datetime_value_font_size', $this->params['datetime_value_font_size'] );
236 }
237
238 public function get_countdown_timer_color() {
239 return apply_filters( 'woo_ctr_get_countdown_timer_color', $this->params['countdown_timer_color'] );
240 }
241
242 public function get_countdown_timer_hide_zero() {
243 return apply_filters( 'woo_ctr_countdown_timer_hide_zero', $this->params['countdown_timer_hide_zero'] );
244 }
245
246 public function get_countdown_timer_padding() {
247 return apply_filters( 'woo_ctr_get_countdown_timer_padding', $this->params['countdown_timer_padding'] );
248 }
249
250 public function get_countdown_timer_border_radius() {
251 return apply_filters( 'woo_ctr_get_countdown_timer_border_radius', $this->params['countdown_timer_border_radius'] );
252 }
253
254 public function get_countdown_timer_bg_color() {
255 return apply_filters( 'woo_ctr_get_countdown_timer_bg_color', $this->params['countdown_timer_bg_color'] );
256 }
257
258 public function get_countdown_timer_border_color() {
259 return apply_filters( 'woo_ctr_get_countdown_timer_border_color', $this->params['countdown_timer_border_color'] );
260 }
261
262 public function get_countdown_timer_item_border_color() {
263 return apply_filters( 'woo_ctr_get_countdown_timer_item_border_color', $this->params['countdown_timer_item_border_color'] );
264 }
265
266 public function get_countdown_timer_item_border_radius() {
267 return apply_filters( 'woo_ctr_get_countdown_timer_item_border_radius', $this->params['countdown_timer_item_border_radius'] );
268 }
269
270 public function get_countdown_timer_item_height() {
271 return apply_filters( 'woo_ctr_get_countdown_timer_item_height', $this->params['countdown_timer_item_height'] );
272 }
273
274 public function get_countdown_timer_item_width() {
275 return apply_filters( 'woo_ctr_get_countdown_timer_item_width', $this->params['countdown_timer_item_width'] );
276 }
277
278 public function get_category_page() {
279 return apply_filters( 'woo_ctr_get_category_page', $this->params['category_page'] );
280 }
281
282 public function get_shop_page() {
283 return apply_filters( 'woo_ctr_get_shop_page', $this->params['shop_page'] );
284 }
285
286 public function get_size_on_archive_page() {
287 return apply_filters( 'woo_ctr_get_size_on_archive_page', $this->params['size_on_archive_page'] );
288 }
289
290 public function get_datetime_unit_position() {
291 return apply_filters( 'woo_ctr_get_datetime_unit_position', $this->params['datetime_unit_position'] );
292 }
293
294 public function get_animation_style() {
295 return apply_filters( 'woo_ctr_get_animation_style', $this->params['animation_style'] );
296 }
297 public function get_circle_smooth_animation() {
298 return apply_filters( 'woo_ctr_get_circle_smooth_animation', $this->params['circle_smooth_animation'] );
299 }
300 public function get_stick_to_top() {
301 return apply_filters( 'woo_ctr_get_stick_to_top', $this->params['stick_to_top'] );
302 }
303
304 public function get_params( $name = "" ) {
305 if ( ! $name ) {
306 return $this->params;
307 } elseif ( isset( $this->params[ $name ] ) ) {
308 return apply_filters( 'sctv_countdown_settings-' . $name, $this->params[ $name ] );
309 } else {
310 return false;
311 }
312 }
313
314 public function get_default( $name = "" ) {
315 if ( ! $name ) {
316 return $this->default;
317 } elseif ( isset( $this->default[ $name ] ) ) {
318 return apply_filters( 'sctv_countdown_settings_default-' . $name, $this->default[ $name ] );
319 } else {
320 return false;
321 }
322 }
323 public function get_current_countdown( $name = "", $i = 0 ) {
324 $result =$this->get_params( $name )[ $i ] ?? $this->get_default( $name )[0] ?? false;
325
326 return $result;
327 }
328 public function get_countdown_inline_style() {
329 $id = $this->get_id();
330 $css = '';
331 if ( is_array( $id ) && count( $id ) ) {
332
333 for ( $i = 0; $i < count( $id ); $i ++ ) {
334 if ( $this->get_datetime_value_bg_color()[ $i ] ) {
335 $css .= '.woo-sctr-accordion-wrap[data-accordion_id="' . $i . '"] .woo-sctr-shortcode-countdown-style-4 .woo-sctr-shortcode-countdown-1 .woo-sctr-progress-circle:after{' . esc_attr__( 'background:' ) . $this->get_datetime_value_bg_color()[ $i ] . ';}';
336 }
337 if ( $this->get_countdown_timer_item_border_color()[ $i ] ) {
338 $css .= '.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-countdown-style-4 .woo-sctr-shortcode-countdown-1 .woo-sctr-progress-circle .woo-sctr-value-bar{' . esc_attr__( 'border-color: ' ) . $this->get_countdown_timer_item_border_color()[ $i ] . ';}';
339 $css .= '.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-countdown-style-4 .woo-sctr-shortcode-countdown-1 .woo-sctr-progress-circle .woo-sctr-first50-bar{' . esc_attr__( 'background-color: ' ) . $this->get_countdown_timer_item_border_color()[ $i ] . ';}';
340 }
341 if ( $this->get_datetime_value_font_size()[ $i ] ) {
342 $css .= '.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-countdown-style-4 .woo-sctr-shortcode-countdown-1 .woo-sctr-progress-circle{' . esc_attr__( 'font-size:' ) . $this->get_datetime_value_font_size()[ $i ] . 'px;}';
343 }
344
345 $css .= '.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-wrap-wrap:not(.woo-sctr-shortcode-wrap-wrap-inline) .woo-sctr-shortcode-countdown-1{';
346 if ( $this->get_countdown_timer_color()[ $i ] ) {
347 $css .= esc_attr__( 'color:' ) . $this->get_countdown_timer_color()[ $i ] . ';';
348 }
349 if ( $this->get_countdown_timer_bg_color()[ $i ] ) {
350 $css .= esc_html__( 'background:' ) . $this->get_countdown_timer_bg_color()[ $i ] . ';';
351 }
352 if ( $this->get_countdown_timer_padding()[ $i ] ) {
353 $css .= esc_html__( 'padding:' ) . $this->get_countdown_timer_padding()[ $i ] . 'px;';
354 }
355 if ( $this->get_countdown_timer_border_radius()[ $i ] ) {
356 $css .= esc_html__( 'border-radius:' ) . $this->get_countdown_timer_border_radius()[ $i ] . 'px;';
357 }
358 if ( $this->get_countdown_timer_border_color()[ $i ] ) {
359 $css .= esc_html__( 'border: 1px solid ' ) . $this->get_countdown_timer_border_color()[ $i ] . ';';
360 }
361 $css .= '}';
362
363 $css .= '.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-wrap-wrap.woo-sctr-shortcode-wrap-wrap-inline{';
364 if ( $this->get_countdown_timer_color()[ $i ] ) {
365 $css .= esc_attr__( 'color:' ) . $this->get_countdown_timer_color()[ $i ] . ';';
366 }
367 if ( $this->get_countdown_timer_bg_color()[ $i ] ) {
368 $css .= esc_html__( 'background:' ) . $this->get_countdown_timer_bg_color()[ $i ] . ';';
369 }
370 if ( $this->get_countdown_timer_padding()[ $i ] ) {
371 $css .= esc_html__( 'padding:' ) . $this->get_countdown_timer_padding()[ $i ] . 'px;';
372 }
373 if ( $this->get_countdown_timer_border_radius()[ $i ] ) {
374 $css .= esc_html__( 'border-radius:' ) . $this->get_countdown_timer_border_radius()[ $i ] . 'px;';
375 }
376 if ( $this->get_countdown_timer_border_color()[ $i ] ) {
377 $css .= esc_html__( 'border: 1px solid ' ) . $this->get_countdown_timer_border_color()[ $i ] . ';';
378 }
379 $css .= '}';
380
381 $css .= '.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-wrap-wrap .woo-sctr-shortcode-countdown-1 .woo-sctr-shortcode-countdown-value{';
382 if ( $this->get_datetime_value_color()[ $i ] ) {
383 $css .= esc_attr__( 'color:' ) . $this->get_datetime_value_color()[ $i ] . ';';
384 }
385 if ( $this->get_datetime_value_bg_color()[ $i ] ) {
386 $css .= esc_attr__( 'background:' ) . $this->get_datetime_value_bg_color()[ $i ] . ';';
387 }
388 if ( $this->get_datetime_value_font_size()[ $i ] ) {
389 $css .= esc_attr__( 'font-size:' ) . $this->get_datetime_value_font_size()[ $i ] . 'px;';
390 }
391 $css .= '}';
392 $css .= '.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-wrap-wrap .woo-sctr-shortcode-countdown-1 .woo-sctr-shortcode-countdown-text{';
393 if ( $this->get_datetime_unit_color()[ $i ] ) {
394 $css .= esc_attr__( 'color:' ) . $this->get_datetime_unit_color()[ $i ] . ';';
395 }
396 if ( $this->get_datetime_unit_bg_color()[ $i ] ) {
397 $css .= esc_attr__( 'background:' ) . $this->get_datetime_unit_bg_color()[ $i ] . ';';
398 }
399 if ( $this->get_datetime_unit_font_size()[ $i ] ) {
400 $css .= esc_attr__( 'font-size:' ) . $this->get_datetime_unit_font_size()[ $i ] . 'px;';
401 }
402 $css .= '}';
403
404 $css1 = '';
405 if ( $this->get_countdown_timer_item_height()[ $i ] ) {
406 $css1 .= esc_html__( 'height:' ) . $this->get_countdown_timer_item_height()[ $i ] . 'px;';
407 }
408 if ( $this->get_countdown_timer_item_width()[ $i ] ) {
409 $css1 .= esc_html__( 'width:' ) . $this->get_countdown_timer_item_width()[ $i ] . 'px;';
410 }
411 if ( $this->get_countdown_timer_item_border_radius()[ $i ] ) {
412 $css1 .= esc_html__( 'border-radius:' ) . $this->get_countdown_timer_item_border_radius()[ $i ] . 'px;';
413 }
414 if ( $this->get_countdown_timer_item_border_color()[ $i ] ) {
415 $css1 .= esc_html__( 'border:1px solid ' ) . $this->get_countdown_timer_item_border_color()[ $i ] . ';';
416 }
417 if ( $css1 ) {
418 $css .= '.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-countdown-wrap.woo-sctr-shortcode-countdown-style-1 .woo-sctr-shortcode-countdown-unit,.woo-sctr-shortcode-wrap-wrap-' . $id[$i] . ' .woo-sctr-shortcode-countdown-wrap.woo-sctr-shortcode-countdown-style-2 .woo-sctr-shortcode-countdown-value{' . $css1 . '}';
419 }
420
421 }
422 }
423
424 return $css;
425 }
426 }
427
428 new SALES_COUNTDOWN_TIMER_Data();