PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.0.1
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.0.1
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / classes / class-cartflows-default-meta.php

class-cartflows-default-meta.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.0.1, at classes/class-cartflows-default-meta.php

999 lines 27.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Cartflow default options.
4 *
5 * @package Cartflows
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12 /**
13 * Initialization
14 *
15 * @since 1.0.0
16 */
17 class Cartflows_Default_Meta {
18
19
20
21 /**
22 * Member Variable
23 *
24 * @var instance
25 */
26 private static $instance;
27
28 /**
29 * Member Variable
30 *
31 * @var checkout_fields
32 */
33 private static $checkout_fields = null;
34
35 /**
36 * Member Variable
37 *
38 * @var checkout_fields
39 */
40 private static $thankyou_fields = null;
41
42 /**
43 * Member Variable
44 *
45 * @var flow_fields
46 */
47 private static $flow_fields = null;
48
49 /**
50 * Member Variable
51 *
52 * @var landing_fields
53 */
54 private static $landing_fields = null;
55
56 /**
57 * Member Variable
58 *
59 * @var optin_fields
60 */
61 private static $optin_fields = null;
62
63 /**
64 * Member Variable
65 *
66 * @var show_design_meta
67 */
68 private static $show_design_meta = null;
69
70 /**
71 * Initiator
72 */
73 public static function get_instance() {
74 if ( ! isset( self::$instance ) ) {
75 self::$instance = new self();
76 }
77 return self::$instance;
78 }
79
80 /**
81 * Constructor
82 */
83 public function __construct() {
84 }
85
86 /**
87 * Show design meta options.
88 *
89 * @return string
90 */
91 public function get_show_design_meta_value() {
92
93 if ( null === self::$show_design_meta ) {
94
95 $show_design = get_option( 'cartflows-legacy-meta-show-design-options', false );
96
97 self::$show_design_meta = $show_design ? 'yes' : 'no';
98 }
99
100 return self::$show_design_meta;
101 }
102
103 /**
104 * Checkout Default fields.
105 *
106 * @param int $post_id post id.
107 * @return array
108 */
109 public function get_checkout_fields( $post_id ) {
110
111 if ( null === self::$checkout_fields ) {
112 self::$checkout_fields = array(
113 'wcf-enable-design-settings' => array(
114 'default' => $this->get_show_design_meta_value(),
115 'sanitize' => 'FILTER_SANITIZE_STRING',
116 ),
117 'wcf-disable-step' => array(
118 'default' => 'no',
119 'sanitize' => 'FILTER_SANITIZE_STRING',
120 ),
121 'wcf-field-google-font-url' => array(
122 'default' => '',
123 'sanitize' => 'FILTER_SANITIZE_URL',
124 ),
125 'wcf-checkout-products' => array(
126 'default' => array(),
127 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS',
128 ),
129 'wcf-checkout-layout' => array(
130 'default' => 'modern-checkout',
131 'sanitize' => 'FILTER_SANITIZE_STRING',
132 ),
133 'wcf-input-font-family' => array(
134 'default' => '',
135 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
136 ),
137 'wcf-input-font-weight' => array(
138 'default' => '',
139 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
140 ),
141 'wcf-heading-font-family' => array(
142 'default' => '',
143 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
144 ),
145 'wcf-heading-font-weight' => array(
146 'default' => '',
147 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
148 ),
149 'wcf-base-font-family' => array(
150 'default' => '',
151 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
152 ),
153 'wcf-advance-options-fields' => array(
154 'default' => '',
155 'sanitize' => 'FILTER_SANITIZE_STRING',
156 ),
157 'wcf-remove-product-field' => array(
158 'default' => '',
159 'sanitize' => 'FILTER_SANITIZE_STRING',
160 ),
161 // Custom Shipping error message start.
162 'wcf-custom-no-shipping-method-message-toggle' => array(
163 'default' => 'no',
164 'sanitize' => 'FILTER_SANITIZE_STRING',
165 ),
166 'wcf-no-shipping-method-message' => array(
167 'default' => __( 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'cartflows' ),
168 'sanitize' => 'FILTER_SANITIZE_STRING',
169 ),
170 // Custom Shipping error message end.
171 'wcf-order-review-show-product-images' => array(
172 'default' => 'yes',
173 'sanitize' => 'FILTER_SANITIZE_STRING',
174 ),
175 'wcf-order-review-summary-position' => array(
176 'default' => 'top',
177 'sanitize' => 'FILTER_SANITIZE_STRING',
178 ),
179 'wcf-checkout-place-order-button-text' => array(
180 'default' => __( 'Place Order', 'cartflows' ),
181 'sanitize' => 'FILTER_SANITIZE_STRING',
182 ),
183 'wcf-checkout-place-order-button-lock' => array(
184 'default' => 'yes',
185 'sanitize' => 'FILTER_SANITIZE_STRING',
186 ),
187 'wcf-checkout-place-order-button-price-display' => array(
188 'default' => 'yes',
189 'sanitize' => 'FILTER_SANITIZE_STRING',
190 ),
191 'wcf-base-font-weight' => array(
192 'default' => '',
193 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
194 ),
195 'wcf-button-font-family' => array(
196 'default' => '',
197 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
198 ),
199 'wcf-button-font-weight' => array(
200 'default' => '',
201 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
202 ),
203 'wcf-primary-color' => array(
204 'default' => '',
205 'sanitize' => 'FILTER_SANITIZE_COLOR',
206 ),
207 'wcf-heading-color' => array(
208 'default' => '',
209 'sanitize' => 'FILTER_SANITIZE_COLOR',
210 ),
211 'wcf-section-bg-color' => array(
212 'default' => '',
213 'sanitize' => 'FILTER_SANITIZE_COLOR',
214 ),
215 'wcf-hl-bg-color' => array(
216 'default' => '',
217 'sanitize' => 'FILTER_SANITIZE_COLOR',
218 ),
219 'wcf-field-tb-padding' => array(
220 'default' => '',
221 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
222 ),
223 'wcf-field-lr-padding' => array(
224 'default' => '',
225 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
226 ),
227 'wcf-fields-skins' => array(
228 'default' => 'modern-label',
229 'sanitize' => 'FILTER_SANITIZE_STRING',
230 ),
231 'wcf-input-field-size' => array(
232 'default' => '33px',
233 'sanitize' => 'FILTER_SANITIZE_STRING',
234 ),
235 'wcf-field-color' => array(
236 'default' => '',
237 'sanitize' => 'FILTER_SANITIZE_COLOR',
238 ),
239 'wcf-field-bg-color' => array(
240 'default' => '',
241 'sanitize' => 'FILTER_SANITIZE_COLOR',
242 ),
243 'wcf-field-border-color' => array(
244 'default' => '',
245 'sanitize' => 'FILTER_SANITIZE_COLOR',
246 ),
247 'wcf-box-border-color' => array(
248 'default' => '',
249 'sanitize' => 'FILTER_SANITIZE_COLOR',
250 ),
251 'wcf-field-label-color' => array(
252 'default' => '',
253 'sanitize' => 'FILTER_SANITIZE_COLOR',
254 ),
255 'wcf-submit-tb-padding' => array(
256 'default' => '',
257 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
258 ),
259 'wcf-submit-lr-padding' => array(
260 'default' => '',
261 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
262 ),
263 'wcf-input-button-size' => array(
264 'default' => '33px',
265 'sanitize' => 'FILTER_SANITIZE_STRING',
266 ),
267 'wcf-submit-color' => array(
268 'default' => '',
269 'sanitize' => 'FILTER_SANITIZE_COLOR',
270 ),
271 'wcf-submit-hover-color' => array(
272 'default' => '',
273 'sanitize' => 'FILTER_SANITIZE_COLOR',
274 ),
275 'wcf-submit-bg-color' => array(
276 'default' => '',
277 'sanitize' => 'FILTER_SANITIZE_COLOR',
278 ),
279 'wcf-submit-bg-hover-color' => array(
280 'default' => '',
281 'sanitize' => 'FILTER_SANITIZE_COLOR',
282 ),
283 'wcf-submit-border-color' => array(
284 'default' => '',
285 'sanitize' => 'FILTER_SANITIZE_COLOR',
286 ),
287 'wcf-submit-border-hover-color' => array(
288 'default' => '',
289 'sanitize' => 'FILTER_SANITIZE_COLOR',
290 ),
291 'wcf-header-logo-image' => array(
292 'default' => '',
293 'sanitize' => 'FILTER_SANITIZE_URL',
294 ),
295 'wcf-header-logo-width' => array(
296 'default' => '',
297 'sanitize' => 'FILTER_SANITIZE_STRING',
298 ),
299 'wcf-custom-script' => array(
300 'default' => '',
301 'sanitize' => 'FILTER_SCRIPT',
302 ),
303 'wcf-step-custom-js' => array(
304 'default' => '',
305 'sanitize' => 'FILTER_SCRIPT',
306 ),
307 'wcf-step-custom-css' => array(
308 'default' => '',
309 'sanitize' => 'FILTER_SCRIPT',
310 ),
311 'wcf-step-note' => array(
312 'default' => '',
313 'sanitize' => 'FILTER_SANITIZE_STRING',
314 ),
315
316 'wcf-custom-checkout-fields' => array(
317 'default' => 'no',
318 'sanitize' => 'FILTER_SANITIZE_STRING',
319 ),
320 'wcf-show-coupon-field' => array(
321 'default' => 'yes',
322 'sanitize' => 'FILTER_SANITIZE_STRING',
323 ),
324 'wcf-optimize-coupon-field' => array(
325 'default' => 'no',
326 'sanitize' => 'FILTER_SANITIZE_STRING',
327 ),
328 'wcf_field_order_billing' => array(
329 'default' => array(),
330 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_FIELDS',
331 ),
332 'wcf_field_order_shipping' => array(
333 'default' => array(),
334 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_FIELDS',
335 ),
336 'wcf-google-autoaddress' => array(
337 'default' => 'yes',
338 'sanitize' => 'FILTER_SANITIZE_STRING',
339 ),
340
341 'wcf-checkout-additional-fields' => array(
342 'default' => 'yes',
343 'sanitize' => 'FILTER_SANITIZE_STRING',
344 ),
345 'wcf-optimize-order-note-field' => array(
346 'default' => 'no',
347 'sanitize' => 'FILTER_SANITIZE_STRING',
348 ),
349
350 'wcf-shipto-diff-addr-fields' => array(
351 'default' => 'yes',
352 'sanitize' => 'FILTER_SANITIZE_STRING',
353 ),
354 'wcf-checkout-customer-info-text' => array(
355 'default' => '',
356 'sanitize' => 'FILTER_SANITIZE_STRING',
357 ),
358 'wcf-checkout-billing-details-text' => array(
359 'default' => '',
360 'sanitize' => 'FILTER_SANITIZE_STRING',
361 ),
362 'wcf-checkout-shipping-details-text' => array(
363 'default' => '',
364 'sanitize' => 'FILTER_SANITIZE_STRING',
365 ),
366 'wcf-checkout-your-order-text' => array(
367 'default' => '',
368 'sanitize' => 'FILTER_SANITIZE_STRING',
369 ),
370 'wcf-checkout-payment-text' => array(
371 'default' => '',
372 'sanitize' => 'FILTER_SANITIZE_STRING',
373 ),
374 'wcf-enable-checkout-field-validation-text' => array(
375 'default' => 'yes',
376 'sanitize' => 'FILTER_SANITIZE_STRING',
377 ),
378 'wcf-checkout-field-validation-text' => array(
379 'default' => __( 'is required', 'cartflows' ),
380 'sanitize' => 'FILTER_SANITIZE_STRING',
381 ),
382
383 /** Start Instant checkout section titles */
384 'wcf-instant-checkout-shipping-options-text' => array(
385 'default' => '',
386 'sanitize' => 'FILTER_SANITIZE_STRING',
387 ),
388
389 'wcf-instant-checkout-left-side-bg-color' => array(
390 'default' => '',
391 'sanitize' => 'FILTER_SANITIZE_STRING',
392 ),
393 'wcf-instant-checkout-right-side-bg-color' => array(
394 'default' => '',
395 'sanitize' => 'FILTER_SANITIZE_STRING',
396 ),
397 /** End Instant checkout section titles */
398
399 );
400
401 self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id );
402 }
403
404 return self::$checkout_fields;
405 }
406
407 /**
408 * Flow Default fields.
409 *
410 * @param int $post_id post id.
411 * @return array
412 */
413 public function get_flow_fields( $post_id ) {
414
415 if ( null === self::$flow_fields ) {
416 self::$flow_fields = array(
417 'wcf-steps' => array(
418 'default' => array(),
419 'sanitize' => '', // This key always updated from prepared array. Not from user input and save button click.
420 ),
421 'wcf-flow-indexing' => array(
422 'default' => '',
423 'sanitize' => 'FILTER_SANITIZE_STRING',
424 ),
425 'wcf-testing' => array(
426 'default' => 'no',
427 'sanitize' => 'FILTER_SANITIZE_STRING',
428 ),
429 'wcf-enable-analytics' => array(
430 'default' => 'no',
431 'sanitize' => 'FILTER_SANITIZE_STRING',
432 ),
433 'wcf-flow-custom-script' => array(
434 'default' => '',
435 'sanitize' => 'FILTER_SCRIPT',
436 ),
437 'wcf-flow-custom-js' => array(
438 'default' => '',
439 'sanitize' => 'FILTER_SCRIPT',
440 ),
441 'wcf-flow-custom-css' => array(
442 'default' => '',
443 'sanitize' => 'FILTER_SCRIPT',
444 ),
445 // Global Color Pallet color options.
446 'wcf-enable-gcp-styling' => array(
447 'default' => 'no',
448 'sanitize' => 'FILTER_SANITIZE_STRING',
449 ),
450 'wcf-gcp-primary-color' => array(
451 'default' => '#f16334',
452 'sanitize' => 'FILTER_SANITIZE_COLOR',
453 ),
454 'wcf-gcp-secondary-color' => array(
455 'default' => '#000000',
456 'sanitize' => 'FILTER_SANITIZE_COLOR',
457 ),
458 'wcf-gcp-text-color' => array(
459 'default' => '#4B5563',
460 'sanitize' => 'FILTER_SANITIZE_COLOR',
461 ),
462 'wcf-gcp-accent-color' => array(
463 'default' => '#1F2937',
464 'sanitize' => 'FILTER_SANITIZE_COLOR',
465 ),
466 'wcf-gcp-primary-base-font-family' => array(
467 'default' => '',
468 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
469 ),
470 'instant-layout-style' => array(
471 'default' => 'no',
472 'sanitize' => 'FILTER_SANITIZE_STRING',
473 ),
474 'wcf-instant-checkout-header-logo-width' => array(
475 'default' => '',
476 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
477 ),
478 'wcf-instant-checkout-header-logo' => array(
479 'default' => '',
480 'sanitize' => 'FILTER_SANITIZE_URL',
481 ),
482 'wcf-instant-checkout-header-logo-height' => array(
483 'default' => '',
484 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
485 ),
486 'wcf-instant-checkout-header-color' => array(
487 'default' => '',
488 'sanitize' => 'FILTER_SANITIZE_COLOR',
489 ),
490 );
491 }
492
493 return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields );
494 }
495
496 /**
497 * Get checkout meta.
498 *
499 * @param int $post_id post id.
500 * @param string $key options key.
501 * @param mix $default options default value.
502 * @return string
503 */
504 public function get_flow_meta_value( $post_id, $key, $default = false ) {
505 $value = $this->get_save_meta( $post_id, $key );
506
507 if ( ! $value ) {
508 if ( $default ) {
509 $value = $default;
510 } else {
511 $fields = $this->get_flow_fields( $post_id );
512
513 if ( isset( $fields[ $key ]['default'] ) ) {
514 $value = $fields[ $key ]['default'];
515 }
516 }
517 }
518
519 return $value;
520 }
521
522 /**
523 * Get checkout meta.
524 *
525 * @param int $post_id post id.
526 * @param string $key options key.
527 * @param mix $default options default value.
528 * @return string
529 */
530 public function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) {
531
532 $value = $this->get_save_meta( $post_id, $key );
533
534 if ( ! $value ) {
535 if ( false !== $default ) {
536 $value = $default;
537 } else {
538 $fields = $this->get_checkout_fields( $post_id );
539
540 if ( isset( $fields[ $key ]['default'] ) ) {
541 $value = $fields[ $key ]['default'];
542 }
543 }
544 }
545
546 return apply_filters( "cartflows_checkout_meta_{$key}", $value );
547 }
548
549 /**
550 * Get post meta.
551 *
552 * @param int $post_id post id.
553 * @param string $key options key.
554 * @return string
555 */
556 public function get_save_meta( $post_id, $key ) {
557
558 return get_post_meta( $post_id, $key, true );
559 }
560
561 /**
562 * Thank You Default fields.
563 *
564 * @param int $post_id post id.
565 * @return array
566 */
567 public function get_thankyou_fields( $post_id ) {
568
569 if ( null === self::$thankyou_fields ) {
570 self::$thankyou_fields = array(
571 'wcf-enable-design-settings' => array(
572 'default' => $this->get_show_design_meta_value(),
573 'sanitize' => 'FILTER_SANITIZE_STRING',
574 ),
575 'wcf-disable-step' => array(
576 'default' => 'no',
577 'sanitize' => 'FILTER_SANITIZE_STRING',
578 ),
579 'wcf-field-google-font-url' => array(
580 'default' => '',
581 'sanitize' => 'FILTER_SANITIZE_URL',
582 ),
583 'wcf-tq-primary-color' => array(
584 'default' => '',
585 'sanitize' => 'FILTER_SANITIZE_COLOR',
586 ),
587 'wcf-tq-text-color' => array(
588 'default' => '',
589 'sanitize' => 'FILTER_SANITIZE_COLOR',
590 ),
591 'wcf-tq-font-family' => array(
592 'default' => '',
593 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
594 ),
595 'wcf-tq-font-size' => array(
596 'default' => '',
597 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
598 ),
599 'wcf-tq-heading-color' => array(
600 'default' => '',
601 'sanitize' => 'FILTER_SANITIZE_COLOR',
602 ),
603 'wcf-tq-heading-font-family' => array(
604 'default' => '',
605 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
606 ),
607 'wcf-tq-heading-font-wt' => array(
608 'default' => '',
609 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
610 ),
611 'wcf-tq-container-width' => array(
612 'default' => '',
613 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
614 ),
615 'wcf-tq-section-bg-color' => array(
616 'default' => '',
617 'sanitize' => 'FILTER_SANITIZE_COLOR',
618 ),
619 'wcf-tq-advance-options-fields' => array(
620 'default' => '',
621 'sanitize' => 'FILTER_SANITIZE_STRING',
622 ),
623 'wcf-show-overview-section' => array(
624 'default' => 'yes',
625 'sanitize' => 'FILTER_SANITIZE_STRING',
626 ),
627 'wcf-show-details-section' => array(
628 'default' => 'yes',
629 'sanitize' => 'FILTER_SANITIZE_STRING',
630 ),
631 'wcf-show-billing-section' => array(
632 'default' => 'yes',
633 'sanitize' => 'FILTER_SANITIZE_STRING',
634 ),
635 'wcf-show-shipping-section' => array(
636 'default' => 'yes',
637 'sanitize' => 'FILTER_SANITIZE_STRING',
638 ),
639 'wcf-show-tq-redirect-section' => array(
640 'default' => '',
641 'sanitize' => 'FILTER_SANITIZE_STRING',
642 ),
643 'wcf-tq-redirect-link' => array(
644 'default' => '',
645 'sanitize' => 'FILTER_SANITIZE_URL',
646 ),
647 'wcf-tq-layout' => array(
648 'default' => 'legacy-tq-layout',
649 'sanitize' => 'FILTER_SANITIZE_STRING',
650 ),
651 'wcf-tq-text' => array(
652 'default' => __( 'Thank you. Your order has been received.', 'cartflows' ),
653 'sanitize' => 'FILTER_WP_KSES_POST',
654 ),
655 'wcf-custom-script' => array(
656 'default' => '',
657 'sanitize' => 'FILTER_SCRIPT',
658 ),
659 'wcf-step-custom-js' => array(
660 'default' => '',
661 'sanitize' => 'FILTER_SCRIPT',
662 ),
663 'wcf-step-custom-css' => array(
664 'default' => '',
665 'sanitize' => 'FILTER_SCRIPT',
666 ),
667 'wcf-step-note' => array(
668 'default' => '',
669 'sanitize' => 'FILTER_SANITIZE_STRING',
670 ),
671 'wcf-instant-thankyou-order-review-summary-position' => array(
672 'default' => 'top',
673 'sanitize' => 'FILTER_SANITIZE_STRING',
674 ),
675 'wcf-instant-thankyou-right-side-bg-color' => array(
676 'default' => '',
677 'sanitize' => 'FILTER_SANITIZE_COLOR',
678 ),
679 'wcf-instant-thankyou-left-side-bg-color' => array(
680 'default' => '',
681 'sanitize' => 'FILTER_SANITIZE_COLOR',
682 ),
683 'wcf-tq-button-text-color' => array(
684 'default' => '',
685 'sanitize' => 'FILTER_SANITIZE_COLOR',
686 ),
687 'wcf-tq-button-background-color' => array(
688 'default' => '',
689 'sanitize' => 'FILTER_SANITIZE_COLOR',
690 ),
691 'wcf-tq-button-font-family' => array(
692 'default' => '',
693 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
694 ),
695 );
696 }
697
698 return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id );
699 }
700
701 /**
702 * Get Thank you section meta.
703 *
704 * @param int $post_id post id.
705 * @param string $key options key.
706 * @param mix $default options default value.
707 * @return string
708 */
709 public function get_thankyou_meta_value( $post_id, $key, $default = false ) {
710
711 $value = $this->get_save_meta( $post_id, $key );
712
713 if ( ! $value ) {
714 if ( $default ) {
715 $value = $default;
716 } else {
717 $fields = $this->get_thankyou_fields( $post_id );
718
719 if ( isset( $fields[ $key ]['default'] ) ) {
720 $value = $fields[ $key ]['default'];
721 }
722 }
723 }
724
725 return apply_filters( "cartflows_thankyou_meta_{$key}", $value );
726 }
727
728 /**
729 * Get Landing section meta.
730 *
731 * @param int $post_id post id.
732 * @param string $key options key.
733 * @param mix $default options default value.
734 * @return string
735 */
736 public function get_landing_meta_value( $post_id, $key, $default = false ) {
737
738 $value = $this->get_save_meta( $post_id, $key );
739 if ( ! $value ) {
740 if ( $default ) {
741 $value = $default;
742 } else {
743 $fields = $this->get_landing_fields( $post_id );
744
745 if ( isset( $fields[ $key ]['default'] ) ) {
746 $value = $fields[ $key ]['default'];
747 }
748 }
749 }
750
751 return $value;
752 }
753
754 /**
755 * Landing Default fields.
756 *
757 * @param int $post_id post id.
758 * @return array
759 */
760 public function get_landing_fields( $post_id ) {
761
762 if ( null === self::$landing_fields ) {
763 self::$landing_fields = array(
764 'wcf-disable-step' => array(
765 'default' => 'no',
766 'sanitize' => 'FILTER_SANITIZE_STRING',
767 ),
768 'wcf-custom-script' => array(
769 'default' => '',
770 'sanitize' => 'FILTER_SCRIPT',
771 ),
772 'wcf-step-custom-js' => array(
773 'default' => '',
774 'sanitize' => 'FILTER_SCRIPT',
775 ),
776 'wcf-step-custom-css' => array(
777 'default' => '',
778 'sanitize' => 'FILTER_SCRIPT',
779 ),
780 'wcf-step-note' => array(
781 'default' => '',
782 'sanitize' => 'FILTER_SANITIZE_STRING',
783 ),
784 );
785 }
786 return apply_filters( 'cartflows_landing_meta_options', self::$landing_fields, $post_id );
787 }
788
789 /**
790 * Optin Default fields.
791 *
792 * @param int $post_id post id.
793 * @return array
794 */
795 public function get_optin_fields( $post_id ) {
796
797 if ( null === self::$optin_fields ) {
798 self::$optin_fields = array(
799
800 'wcf-disable-step' => array(
801 'default' => 'no',
802 'sanitize' => 'FILTER_SANITIZE_STRING',
803 ),
804 'wcf-optin-product' => array(
805 'default' => array(),
806 'sanitize' => 'FILTER_CARTFLOWS_ARRAY',
807 ),
808
809 /* Style */
810 'wcf-enable-design-settings' => array(
811 'default' => $this->get_show_design_meta_value(),
812 'sanitize' => 'FILTER_SANITIZE_STRING',
813 ),
814 'wcf-field-google-font-url' => array(
815 'default' => '',
816 'sanitize' => 'FILTER_SANITIZE_URL',
817 ),
818 'wcf-primary-color' => array(
819 'default' => '',
820 'sanitize' => 'FILTER_SANITIZE_COLOR',
821 ),
822 'wcf-base-font-family' => array(
823 'default' => '',
824 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
825 ),
826 'wcf-input-fields-skins' => array(
827 'default' => '',
828 'sanitize' => 'FILTER_SANITIZE_STRING',
829 ),
830 'wcf-input-font-family' => array(
831 'default' => '',
832 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
833 ),
834 'wcf-input-font-weight' => array(
835 'default' => '',
836 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
837 ),
838 'wcf-input-field-size' => array(
839 'default' => '33px',
840 'sanitize' => 'FILTER_SANITIZE_STRING',
841 ),
842 'wcf-field-tb-padding' => array(
843 'default' => '',
844 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
845 ),
846 'wcf-field-lr-padding' => array(
847 'default' => '',
848 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
849 ),
850 'wcf-field-color' => array(
851 'default' => '',
852 'sanitize' => 'FILTER_SANITIZE_COLOR',
853 ),
854 'wcf-field-bg-color' => array(
855 'default' => '',
856 'sanitize' => 'FILTER_SANITIZE_COLOR',
857 ),
858 'wcf-field-border-color' => array(
859 'default' => '',
860 'sanitize' => 'FILTER_SANITIZE_COLOR',
861 ),
862 'wcf-field-label-color' => array(
863 'default' => '',
864 'sanitize' => 'FILTER_SANITIZE_COLOR',
865 ),
866 'wcf-submit-button-text' => array(
867 'default' => __( 'Submit', 'cartflows' ),
868 'sanitize' => 'FILTER_SANITIZE_STRING',
869 ),
870 'wcf-submit-font-size' => array(
871 'default' => '',
872 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
873 ),
874 'wcf-button-font-family' => array(
875 'default' => '',
876 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
877 ),
878 'wcf-button-font-weight' => array(
879 'default' => '',
880 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
881 ),
882 'wcf-submit-button-size' => array(
883 'default' => '33px',
884 'sanitize' => 'FILTER_SANITIZE_STRING',
885 ),
886 'wcf-submit-tb-padding' => array(
887 'default' => '',
888 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
889 ),
890 'wcf-submit-lr-padding' => array(
891 'default' => '',
892 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
893 ),
894 'wcf-submit-button-position' => array(
895 'default' => 'center',
896 'sanitize' => 'FILTER_SANITIZE_STRING',
897 ),
898 'wcf-submit-color' => array(
899 'default' => '',
900 'sanitize' => 'FILTER_SANITIZE_COLOR',
901 ),
902 'wcf-submit-hover-color' => array(
903 'default' => '',
904 'sanitize' => 'FILTER_SANITIZE_COLOR',
905 ),
906 'wcf-submit-bg-color' => array(
907 'default' => '',
908 'sanitize' => 'FILTER_SANITIZE_COLOR',
909 ),
910 'wcf-submit-bg-hover-color' => array(
911 'default' => '',
912 'sanitize' => 'FILTER_SANITIZE_COLOR',
913 ),
914 'wcf-submit-border-color' => array(
915 'default' => '',
916 'sanitize' => 'FILTER_SANITIZE_COLOR',
917 ),
918 'wcf-submit-border-hover-color' => array(
919 'default' => '',
920 'sanitize' => 'FILTER_SANITIZE_COLOR',
921 ),
922
923 /* Settings */
924 'wcf-optin-pass-fields' => array(
925 'default' => '',
926 'sanitize' => 'FILTER_SANITIZE_STRING',
927 ),
928 'wcf-optin-pass-specific-fields' => array(
929 'default' => 'first_name',
930 'sanitize' => 'FILTER_SANITIZE_STRING',
931 ),
932
933 /* Script */
934 'wcf-custom-script' => array(
935 'default' => '',
936 'sanitize' => 'FILTER_SCRIPT',
937 ),
938 'wcf-step-custom-js' => array(
939 'default' => '',
940 'sanitize' => 'FILTER_SCRIPT',
941 ),
942 'wcf-step-custom-css' => array(
943 'default' => '',
944 'sanitize' => 'FILTER_SCRIPT',
945 ),
946
947 'wcf-step-note' => array(
948 'default' => '',
949 'sanitize' => 'FILTER_SANITIZE_STRING',
950 ),
951
952 /* Custom Fields Options*/
953 'wcf-optin-enable-custom-fields' => array(
954 'default' => 'no',
955 'sanitize' => 'FILTER_SANITIZE_STRING',
956 ),
957
958 'wcf-optin-fields-billing' => array(
959 'default' => \Cartflows_Helper::get_optin_default_fields(),
960 'sanitize' => 'FILTER_CARTFLOWS_OPTIN_FIELDS',
961 ),
962 );
963 }
964 return apply_filters( 'cartflows_optin_meta_options', self::$optin_fields, $post_id );
965 }
966
967 /**
968 * Get optin meta.
969 *
970 * @param int $post_id post id.
971 * @param string $key options key.
972 * @param mix $default options default value.
973 * @return string
974 */
975 public function get_optin_meta_value( $post_id = 0, $key = '', $default = false ) {
976
977 $value = $this->get_save_meta( $post_id, $key );
978
979 if ( ! $value ) {
980 if ( false !== $default ) {
981 $value = $default;
982 } else {
983 $fields = $this->get_optin_fields( $post_id );
984
985 if ( isset( $fields[ $key ]['default'] ) ) {
986 $value = $fields[ $key ]['default'];
987 }
988 }
989 }
990
991 return apply_filters( "cartflows_optin_meta_{$key}", $value );
992 }
993 }
994
995 /**
996 * Kicking this off by calling 'get_instance()' method
997 */
998 Cartflows_Default_Meta::get_instance();
999