PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.3.0
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.3.0
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
← All changes | classes/class-cartflows-default-meta.php +998 -926 1.1.14 → 3.3.0 View file →
@@ -1,926 +1,998 @@
1 -<?php
2 -/**
3 - * Cartflow default options.
4 - *
5 - * @package Cartflows
6 - */
7 -
8 -/**
9 - * Initialization
10 - *
11 - * @since 1.0.0
12 - */
13 -class Cartflows_Default_Meta {
14 -
15 -
16 - /**
17 - * Member Variable
18 - *
19 - * @var instance
20 - */
21 - private static $instance;
22 -
23 - /**
24 - * Member Variable
25 - *
26 - * @var checkout_fields
27 - */
28 - private static $checkout_fields = null;
29 -
30 - /**
31 - * Member Variable
32 - *
33 - * @var checkout_fields
34 - */
35 - private static $thankyou_fields = null;
36 -
37 - /**
38 - * Member Variable
39 - *
40 - * @var flow_fields
41 - */
42 - private static $flow_fields = null;
43 -
44 - /**
45 - * Member Variable
46 - *
47 - * @var landing_fields
48 - */
49 - private static $landing_fields = null;
50 -
51 - /**
52 - * Initiator
53 - */
54 - public static function get_instance() {
55 - if ( ! isset( self::$instance ) ) {
56 - self::$instance = new self;
57 - }
58 - return self::$instance;
59 - }
60 -
61 - /**
62 - * Constructor
63 - */
64 - public function __construct() {
65 -
66 - }
67 -
68 - /**
69 - * Checkout Default fields.
70 - *
71 - * @param int $post_id post id.
72 - * @return array
73 - */
74 - function get_checkout_fields( $post_id ) {
75 -
76 - if ( null === self::$checkout_fields ) {
77 -
78 - self::$checkout_fields = array(
79 - 'wcf-field-google-font-url' => array(
80 - 'default' => '',
81 - 'sanitize' => 'FILTER_DEFAULT',
82 - ),
83 - 'wcf-checkout-products' => array(
84 - 'default' => array(),
85 - 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS',
86 - ),
87 - 'wcf-checkout-layout' => array(
88 - 'default' => 'two-column',
89 - 'sanitize' => 'FILTER_DEFAULT',
90 - ),
91 - 'wcf-input-font-family' => array(
92 - 'default' => '',
93 - 'sanitize' => 'FILTER_DEFAULT',
94 - ),
95 - 'wcf-input-font-weight' => array(
96 - 'default' => '',
97 - 'sanitize' => 'FILTER_DEFAULT',
98 - ),
99 - 'wcf-heading-font-family' => array(
100 - 'default' => '',
101 - 'sanitize' => 'FILTER_DEFAULT',
102 - ),
103 - 'wcf-heading-font-weight' => array(
104 - 'default' => '',
105 - 'sanitize' => 'FILTER_DEFAULT',
106 - ),
107 - 'wcf-base-font-family' => array(
108 - 'default' => '',
109 - 'sanitize' => 'FILTER_DEFAULT',
110 - ),
111 - 'wcf-advance-options-fields' => array(
112 - 'default' => '',
113 - 'sanitize' => 'FILTER_DEFAULT',
114 - ),
115 - 'wcf-base-font-weight' => array(
116 - 'default' => '',
117 - 'sanitize' => 'FILTER_DEFAULT',
118 - ),
119 - 'wcf-button-font-family' => array(
120 - 'default' => '',
121 - 'sanitize' => 'FILTER_DEFAULT',
122 - ),
123 - 'wcf-button-font-weight' => array(
124 - 'default' => '',
125 - 'sanitize' => 'FILTER_DEFAULT',
126 - ),
127 - 'wcf-primary-color' => array(
128 - 'default' => '',
129 - 'sanitize' => 'FILTER_DEFAULT',
130 - ),
131 - 'wcf-heading-color' => array(
132 - 'default' => '',
133 - 'sanitize' => 'FILTER_DEFAULT',
134 - ),
135 - 'wcf-section-bg-color' => array(
136 - 'default' => '',
137 - 'sanitize' => 'FILTER_DEFAULT',
138 - ),
139 - 'wcf-hl-bg-color' => array(
140 - 'default' => '',
141 - 'sanitize' => 'FILTER_DEFAULT',
142 - ),
143 - 'wcf-field-tb-padding' => array(
144 - 'default' => '',
145 - 'sanitize' => 'FILTER_DEFAULT',
146 - ),
147 - 'wcf-field-lr-padding' => array(
148 - 'default' => '',
149 - 'sanitize' => 'FILTER_DEFAULT',
150 - ),
151 - 'wcf-fields-skins' => array(
152 - 'default' => '',
153 - 'sanitize' => 'FILTER_DEFAULT',
154 - ),
155 - 'wcf-input-field-size' => array(
156 - 'default' => '33px',
157 - 'sanitize' => 'FILTER_DEFAULT',
158 - ),
159 - 'wcf-field-color' => array(
160 - 'default' => '',
161 - 'sanitize' => 'FILTER_DEFAULT',
162 - ),
163 - 'wcf-field-bg-color' => array(
164 - 'default' => '',
165 - 'sanitize' => 'FILTER_DEFAULT',
166 - ),
167 - 'wcf-field-border-color' => array(
168 - 'default' => '',
169 - 'sanitize' => 'FILTER_DEFAULT',
170 - ),
171 - 'wcf-box-border-color' => array(
172 - 'default' => '',
173 - 'sanitize' => 'FILTER_DEFAULT',
174 - ),
175 - 'wcf-field-label-color' => array(
176 - 'default' => '',
177 - 'sanitize' => 'FILTER_DEFAULT',
178 - ),
179 - 'wcf-submit-tb-padding' => array(
180 - 'default' => '',
181 - 'sanitize' => 'FILTER_DEFAULT',
182 - ),
183 - 'wcf-submit-lr-padding' => array(
184 - 'default' => '',
185 - 'sanitize' => 'FILTER_DEFAULT',
186 - ),
187 - 'wcf-input-button-size' => array(
188 - 'default' => '33px',
189 - 'sanitize' => 'FILTER_DEFAULT',
190 - ),
191 - 'wcf-submit-color' => array(
192 - 'default' => '',
193 - 'sanitize' => 'FILTER_DEFAULT',
194 - ),
195 - 'wcf-submit-hover-color' => array(
196 - 'default' => '',
197 - 'sanitize' => 'FILTER_DEFAULT',
198 - ),
199 - 'wcf-submit-bg-color' => array(
200 - 'default' => '',
201 - 'sanitize' => 'FILTER_DEFAULT',
202 - ),
203 - 'wcf-submit-bg-hover-color' => array(
204 - 'default' => '',
205 - 'sanitize' => 'FILTER_DEFAULT',
206 - ),
207 - 'wcf-submit-border-color' => array(
208 - 'default' => '',
209 - 'sanitize' => 'FILTER_DEFAULT',
210 - ),
211 - 'wcf-submit-border-hover-color' => array(
212 - 'default' => '',
213 - 'sanitize' => 'FILTER_DEFAULT',
214 - ),
215 - 'wcf-active-tab' => array(
216 - 'default' => '',
217 - 'sanitize' => 'FILTER_DEFAULT',
218 - ),
219 - 'wcf-header-logo-image' => array(
220 - 'default' => '',
221 - 'sanitize' => 'FILTER_DEFAULT',
222 - ),
223 - 'wcf-header-logo-width' => array(
224 - 'default' => '',
225 - 'sanitize' => 'FILTER_DEFAULT',
226 - ),
227 - 'wcf-custom-script' => array(
228 - 'default' => '',
229 - 'sanitize' => 'FILTER_DEFAULT',
230 - ),
231 - );
232 -
233 - self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id );
234 - }
235 -
236 - return self::$checkout_fields;
237 - }
238 -
239 - /**
240 - * Save Checkout Meta fields.
241 - *
242 - * @param int $post_id post id.
243 - * @return void
244 - */
245 - function save_checkout_fields( $post_id ) {
246 -
247 - $post_meta = $this->get_checkout_fields( $post_id );
248 -
249 - $this->save_meta_fields( $post_id, $post_meta );
250 - }
251 -
252 - /**
253 - * Save Landing Meta fields.
254 - *
255 - * @param int $post_id post id.
256 - * @return void
257 - */
258 - function save_landing_fields( $post_id ) {
259 -
260 - $post_meta = $this->get_landing_fields( $post_id );
261 -
262 - $this->save_meta_fields( $post_id, $post_meta );
263 - }
264 -
265 - /**
266 - * Save ThankYou Meta fields.
267 - *
268 - * @param int $post_id post id.
269 - * @return void
270 - */
271 - function save_thankyou_fields( $post_id ) {
272 -
273 - $post_meta = $this->get_thankyou_fields( $post_id );
274 -
275 - $this->save_meta_fields( $post_id, $post_meta );
276 - }
277 -
278 - /**
279 - * Flow Default fields.
280 - *
281 - * @param int $post_id post id.
282 - * @return array
283 - */
284 - function get_flow_fields( $post_id ) {
285 -
286 - if ( null === self::$flow_fields ) {
287 -
288 - self::$flow_fields = array(
289 - 'wcf-steps' => array(
290 - 'default' => array(),
291 - 'sanitize' => 'FILTER_DEFAULT',
292 - ),
293 -
294 - 'wcf-testing' => array(
295 - 'default' => 'yes',
296 - 'sanitize' => 'FILTER_DEFAULT',
297 - ),
298 - );
299 - }
300 -
301 - return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields );
302 - }
303 -
304 - /**
305 - * Save Flow Meta fields.
306 - *
307 - * @param int $post_id post id.
308 - * @return void
309 - */
310 - function save_flow_fields( $post_id ) {
311 -
312 - $post_meta = $this->get_flow_fields( $post_id );
313 -
314 - if ( isset( $post_meta['wcf-steps'] ) ) {
315 - unset( $post_meta['wcf-steps'] );
316 - }
317 -
318 - $this->save_meta_fields( $post_id, $post_meta );
319 - }
320 -
321 - /**
322 - * Save Meta fields - Common Function.
323 - *
324 - * @param int $post_id post id.
325 - * @param array $post_meta options to store.
326 - * @return void
327 - */
328 - function save_meta_fields( $post_id, $post_meta ) {
329 -
330 - if ( ! ( $post_id && is_array( $post_meta ) ) ) {
331 -
332 - return;
333 - }
334 -
335 - foreach ( $post_meta as $key => $data ) {
336 -
337 - $meta_value = false;
338 -
339 - // Sanitize values.
340 - $sanitize_filter = ( isset( $data['sanitize'] ) ) ? $data['sanitize'] : 'FILTER_DEFAULT';
341 -
342 - switch ( $sanitize_filter ) {
343 -
344 - case 'FILTER_SANITIZE_STRING':
345 - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING );
346 - break;
347 -
348 - case 'FILTER_SANITIZE_URL':
349 - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_URL );
350 - break;
351 -
352 - case 'FILTER_SANITIZE_NUMBER_INT':
353 - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT );
354 - break;
355 -
356 - case 'FILTER_CARTFLOWS_ARRAY':
357 - if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
358 - $meta_value = array_map( 'sanitize_text_field', $_POST[ $key ] );
359 - }
360 - break;
361 -
362 - case 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS':
363 - if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
364 -
365 - $i = 0;
366 - $q = 0;
367 -
368 - foreach ( $_POST[ $key ] as $p_index => $p_data ) {
369 -
370 - foreach ( $p_data as $i_key => $i_value ) {
371 -
372 - if ( is_array( $i_value ) ) {
373 -
374 - foreach ( $i_value as $q_key => $q_value ) {
375 -
376 - $meta_value[ $i ][ $i_key ][ $q ] = array_map( 'sanitize_text_field', $q_value );
377 -
378 - $q++;
379 - }
380 - } else {
381 - $meta_value[ $i ][ $i_key ] = sanitize_text_field( $i_value );
382 - }
383 - }
384 -
385 - $i++;
386 - }
387 - }
388 - break;
389 - case 'FILTER_CARTFLOWS_CHECKOUT_FIELDS':
390 - $count = 10;
391 - $ordered_fields = array();
392 - $billing_fields = array();
393 -
394 - if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
395 - $post_data = $_POST[ $key ];
396 -
397 - if ( 'wcf_field_order_billing' == $key ) {
398 -
399 - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
400 -
401 - foreach ( $post_data as $index => $value ) {
402 -
403 - if ( isset( $billing_fields[ $value ] ) ) {
404 - $ordered_fields[ $value ] = $billing_fields[ $value ];
405 - $ordered_fields[ $value ]['priority'] = $count;
406 - $count += 10;
407 - }
408 - }
409 -
410 - $meta_value = $ordered_fields;
411 - }
412 -
413 - if ( 'wcf_field_order_shipping' == $key ) {
414 -
415 - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
416 - foreach ( $post_data as $index => $value ) {
417 -
418 - if ( isset( $shipping_fields[ $value ] ) ) {
419 - $ordered_fields[ $value ] = $shipping_fields[ $value ];
420 - $ordered_fields[ $value ]['priority'] = $count;
421 - $count += 10;
422 - }
423 - }
424 - $meta_value = $ordered_fields;
425 - }
426 -
427 - if ( 'wcf_label_text_field_billing' == $key ) {
428 -
429 - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
430 -
431 - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
432 - echo 'con 1';
433 - $billing_fields = $get_ordered_billing_fields;
434 - } else {
435 - echo 'con 2';
436 - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
437 - }
438 -
439 - foreach ( $post_data as $index => $value ) {
440 -
441 - if ( isset( $billing_fields[ $index ] ) ) {
442 - $ordered_fields[ $index ] = $billing_fields[ $index ];
443 - $ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) );
444 - }
445 - }
446 - $key = 'wcf_field_order_billing';
447 - $meta_value = $ordered_fields;
448 - }
449 -
450 - if ( 'wcf_label_text_field_shipping' == $key ) {
451 -
452 - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
453 -
454 - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
455 - $shipping_fields = $get_ordered_shipping_fields;
456 - } else {
457 - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
458 - }
459 -
460 - foreach ( $post_data as $index => $value ) {
461 -
462 - if ( isset( $shipping_fields[ $index ] ) ) {
463 - $ordered_fields[ $index ] = $shipping_fields[ $index ];
464 - $ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) );
465 - }
466 - }
467 - $key = 'wcf_field_order_shipping';
468 - $meta_value = $ordered_fields;
469 - }
470 -
471 - if ( 'wcf_label_placeholder_field_billing' == $key ) {
472 - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
473 -
474 - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
475 - $billing_fields = $get_ordered_billing_fields;
476 - } else {
477 - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
478 - }
479 - foreach ( $post_data as $index => $value ) {
480 -
481 - if ( isset( $billing_fields[ $index ] ) ) {
482 - $ordered_fields[ $index ] = $billing_fields[ $index ];
483 - $ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) );
484 - }
485 - }
486 -
487 - $key = 'wcf_field_order_billing';
488 - $meta_value = $ordered_fields;
489 - }
490 -
491 - if ( 'wcf_label_placeholder_field_shipping' == $key ) {
492 - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
493 -
494 - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
495 - $shipping_fields = $get_ordered_shipping_fields;
496 - } else {
497 - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
498 - }
499 -
500 - foreach ( $post_data as $index => $value ) {
501 -
502 - if ( isset( $shipping_fields[ $index ] ) ) {
503 - $ordered_fields[ $index ] = $shipping_fields[ $index ];
504 - $ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) );
505 - }
506 - }
507 -
508 - $key = 'wcf_field_order_shipping';
509 - $meta_value = $ordered_fields;
510 -
511 - }
512 -
513 - if ( 'wcf_label_default_field_billing' == $key ) {
514 -
515 - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
516 -
517 - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
518 - $billing_fields = $get_ordered_billing_fields;
519 - } else {
520 - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
521 - }
522 -
523 - foreach ( $post_data as $index => $value ) {
524 -
525 - if ( isset( $billing_fields[ $index ] ) ) {
526 - $ordered_fields[ $index ] = $billing_fields[ $index ];
527 - $ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) );
528 - }
529 - }
530 -
531 - $key = 'wcf_field_order_billing';
532 - $meta_value = $ordered_fields;
533 - }
534 -
535 - if ( 'wcf_label_default_field_shipping' == $key ) {
536 -
537 - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
538 -
539 - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
540 - $shipping_fields = $get_ordered_shipping_fields;
541 - } else {
542 - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
543 - }
544 -
545 - foreach ( $post_data as $index => $value ) {
546 -
547 - if ( isset( $shipping_fields[ $index ] ) ) {
548 - $ordered_fields[ $index ] = $shipping_fields[ $index ];
549 - $ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) );
550 - }
551 - }
552 -
553 - $key = 'wcf_field_order_shipping';
554 - $meta_value = $ordered_fields;
555 - }
556 -
557 - if ( 'wcf_is_required_field_billing' == $key ) {
558 -
559 - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
560 -
561 - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
562 - $billing_fields = $get_ordered_billing_fields;
563 - } else {
564 - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
565 - }
566 -
567 - foreach ( $post_data as $index => $value ) {
568 -
569 - if ( isset( $billing_fields[ $index ] ) ) {
570 - $ordered_fields[ $index ] = $billing_fields[ $index ];
571 - if ( 'yes' == $value ) {
572 -
573 - $ordered_fields[ $index ]['required'] = true;
574 - } else {
575 - $ordered_fields[ $index ]['required'] = false;
576 - }
577 - }
578 - }
579 -
580 - $key = 'wcf_field_order_billing';
581 - $meta_value = $ordered_fields;
582 - }
583 -
584 - if ( 'wcf_is_required_field_shipping' == $key ) {
585 -
586 - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
587 -
588 - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
589 - $shipping_fields = $get_ordered_shipping_fields;
590 - } else {
591 - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
592 - }
593 -
594 - foreach ( $post_data as $index => $value ) {
595 -
596 - if ( isset( $shipping_fields[ $index ] ) ) {
597 - $ordered_fields[ $index ] = $shipping_fields[ $index ];
598 -
599 - if ( 'yes' == $value ) {
600 -
601 - $ordered_fields[ $index ]['required'] = true;
602 - } else {
603 - $ordered_fields[ $index ]['required'] = false;
604 - }
605 - }
606 - }
607 -
608 - $key = 'wcf_field_order_shipping';
609 - $meta_value = $ordered_fields;
610 - }
611 -
612 - if ( 'wcf_select_option_field_billing' == $key ) {
613 -
614 - $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
615 -
616 - if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
617 - $billing_fields = $get_ordered_billing_fields;
618 - } else {
619 - $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
620 - }
621 -
622 - foreach ( $post_data as $index => $value ) {
623 -
624 - $options = explode( ',', $value );
625 -
626 - if ( isset( $billing_fields[ $index ] ) ) {
627 - $ordered_fields[ $index ] = $billing_fields[ $index ];
628 -
629 - $ordered_fields[ $index ]['options'] = array();
630 -
631 - foreach ( $options as $key => $option ) {
632 -
633 - $ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) );
634 - }
635 - }
636 - }
637 -
638 - $key = 'wcf_field_order_billing';
639 - $meta_value = $ordered_fields;
640 - }
641 -
642 - if ( 'wcf_select_option_field_shipping' == $key ) {
643 -
644 - $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
645 -
646 - if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
647 - $shipping_fields = $get_ordered_shipping_fields;
648 - } else {
649 - $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
650 - }
651 -
652 - foreach ( $post_data as $index => $value ) {
653 -
654 - $options = explode( ',', $value );
655 -
656 - if ( isset( $shipping_fields[ $index ] ) ) {
657 -
658 - $ordered_fields[ $index ] = $shipping_fields[ $index ];
659 -
660 - $ordered_fields[ $index ]['options'] = array();
661 -
662 - foreach ( $options as $key => $option ) {
663 -
664 - $ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) );
665 - }
666 - }
667 - }
668 -
669 - $key = 'wcf_field_order_shipping';
670 - $meta_value = $ordered_fields;
671 - }
672 - }
673 - break;
674 -
675 - default:
676 - $meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT );
677 - break;
678 - }
679 -
680 - if ( false !== $meta_value ) {
681 - update_post_meta( $post_id, $key, $meta_value );
682 - } else {
683 - delete_post_meta( $post_id, $key );
684 - }
685 - }
686 - }
687 -
688 - /**
689 - * Get checkout meta.
690 - *
691 - * @param int $post_id post id.
692 - * @param string $key options key.
693 - * @param mix $default options default value.
694 - * @return string
695 - */
696 - function get_flow_meta_value( $post_id, $key, $default = false ) {
697 -
698 - $value = $this->get_save_meta( $post_id, $key );
699 -
700 - if ( ! $value ) {
701 -
702 - if ( $default ) {
703 -
704 - $value = $default;
705 - } else {
706 -
707 - $fields = $this->get_flow_fields( $post_id );
708 -
709 - if ( isset( $fields[ $key ]['default'] ) ) {
710 -
711 - $value = $fields[ $key ]['default'];
712 - }
713 - }
714 - }
715 -
716 - return $value;
717 - }
718 -
719 - /**
720 - * Get checkout meta.
721 - *
722 - * @param int $post_id post id.
723 - * @param string $key options key.
724 - * @param mix $default options default value.
725 - * @return string
726 - */
727 - function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) {
728 -
729 - $value = $this->get_save_meta( $post_id, $key );
730 -
731 - if ( ! $value ) {
732 -
733 - if ( false !== $default ) {
734 -
735 - $value = $default;
736 - } else {
737 -
738 - $fields = $this->get_checkout_fields( $post_id );
739 -
740 - if ( isset( $fields[ $key ]['default'] ) ) {
741 -
742 - $value = $fields[ $key ]['default'];
743 - }
744 - }
745 - }
746 -
747 - return $value;
748 - }
749 -
750 - /**
751 - * Get post meta.
752 - *
753 - * @param int $post_id post id.
754 - * @param string $key options key.
755 - * @return string
756 - */
757 - function get_save_meta( $post_id, $key ) {
758 -
759 - $value = get_post_meta( $post_id, $key, true );
760 -
761 - return $value;
762 - }
763 -
764 - /**
765 - * Thank You Default fields.
766 - *
767 - * @param int $post_id post id.
768 - * @return array
769 - */
770 - function get_thankyou_fields( $post_id ) {
771 -
772 - if ( null === self::$thankyou_fields ) {
773 -
774 - self::$thankyou_fields = array(
775 - 'wcf-field-google-font-url' => array(
776 - 'default' => '',
777 - 'sanitize' => 'FILTER_DEFAULT',
778 - ),
779 - 'wcf-active-tab' => array(
780 - 'default' => '',
781 - 'sanitize' => 'FILTER_DEFAULT',
782 - ),
783 - 'wcf-tq-text-color' => array(
784 - 'default' => '',
785 - 'sanitize' => 'FILTER_DEFAULT',
786 - ),
787 - 'wcf-tq-font-family' => array(
788 - 'default' => '',
789 - 'sanitize' => 'FILTER_DEFAULT',
790 - ),
791 - 'wcf-tq-heading-color' => array(
792 - 'default' => '',
793 - 'sanitize' => 'FILTER_DEFAULT',
794 - ),
795 - 'wcf-tq-heading-font-family' => array(
796 - 'default' => '',
797 - 'sanitize' => 'FILTER_DEFAULT',
798 - ),
799 - 'wcf-tq-heading-font-wt' => array(
800 - 'default' => '',
801 - 'sanitize' => 'FILTER_DEFAULT',
802 - ),
803 - 'wcf-tq-container-width' => array(
804 - 'default' => '',
805 - 'sanitize' => 'FILTER_DEFAULT',
806 - ),
807 - 'wcf-tq-section-bg-color' => array(
808 - 'default' => '',
809 - 'sanitize' => 'FILTER_DEFAULT',
810 - ),
811 - 'wcf-tq-advance-options-fields' => array(
812 - 'default' => '',
813 - 'sanitize' => 'FILTER_DEFAULT',
814 - ),
815 - 'wcf-show-overview-section' => array(
816 - 'default' => 'yes',
817 - 'sanitize' => 'FILTER_DEFAULT',
818 - ),
819 - 'wcf-show-details-section' => array(
820 - 'default' => 'yes',
821 - 'sanitize' => 'FILTER_DEFAULT',
822 - ),
823 - 'wcf-show-billing-section' => array(
824 - 'default' => 'yes',
825 - 'sanitize' => 'FILTER_DEFAULT',
826 - ),
827 - 'wcf-show-shipping-section' => array(
828 - 'default' => 'yes',
829 - 'sanitize' => 'FILTER_DEFAULT',
830 - ),
831 - 'wcf-custom-script' => array(
832 - 'default' => '',
833 - 'sanitize' => 'FILTER_DEFAULT',
834 - ),
835 - );
836 -
837 - }
838 -
839 - return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id );
840 - }
841 -
842 - /**
843 - * Get Thank you section meta.
844 - *
845 - * @param int $post_id post id.
846 - * @param string $key options key.
847 - * @param mix $default options default value.
848 - * @return string
849 - */
850 - function get_thankyou_meta_value( $post_id, $key, $default = false ) {
851 -
852 - $value = $this->get_save_meta( $post_id, $key );
853 -
854 - if ( ! $value ) {
855 -
856 - if ( $default ) {
857 -
858 - $value = $default;
859 - } else {
860 -
861 - $fields = $this->get_thankyou_fields( $post_id );
862 -
863 - if ( isset( $fields[ $key ]['default'] ) ) {
864 -
865 - $value = $fields[ $key ]['default'];
866 - }
867 - }
868 - }
869 -
870 - return $value;
871 - }
872 -
873 - /**
874 - * Get Landing section meta.
875 - *
876 - * @param int $post_id post id.
877 - * @param string $key options key.
878 - * @param mix $default options default value.
879 - * @return string
880 - */
881 - function get_landing_meta_value( $post_id, $key, $default = false ) {
882 -
883 - $value = $this->get_save_meta( $post_id, $key );
884 - if ( ! $value ) {
885 -
886 - if ( $default ) {
887 -
888 - $value = $default;
889 - } else {
890 -
891 - $fields = $this->get_landing_fields( $post_id );
892 -
893 - if ( isset( $fields[ $key ]['default'] ) ) {
894 - $value = $fields[ $key ]['default'];
895 - }
896 - }
897 - }
898 -
899 - return $value;
900 - }
901 -
902 - /**
903 - * Thank You Default fields.
904 - *
905 - * @param int $post_id post id.
906 - * @return array
907 - */
908 - function get_landing_fields( $post_id ) {
909 -
910 - if ( null === self::$landing_fields ) {
911 -
912 - self::$landing_fields = array(
913 - 'wcf-custom-script' => array(
914 - 'default' => '',
915 - 'sanitize' => 'FILTER_DEFAULT',
916 - ),
917 - );
918 - }
919 - return apply_filters( 'cartflows_landing_meta_options', self::$landing_fields, $post_id );
920 - }
921 -}
922 -
923 -/**
924 - * Kicking this off by calling 'get_instance()' method
925 - */
926 -Cartflows_Default_Meta::get_instance();
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();