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 +693 -247 1.1.1 → 3.3.0 View file →
@@ -4,8 +4,12 @@
4 4 *
5 5 * @package Cartflows
6 6 */
7 7
8 +// Exit if accessed directly.
9 +if ( ! defined( 'ABSPATH' ) ) {
10 + exit;
11 +}
8 12 /**
9 13 * Initialization
10 14 *
11 15 * @since 1.0.0
@@ -12,8 +16,9 @@
12 16 */
13 17 class Cartflows_Default_Meta {
14 18
15 19
20 +
16 21 /**
17 22 * Member Variable
18 23 *
19 24 * @var instance
@@ -33,9 +38,8 @@
33 38 * @var checkout_fields
34 39 */
35 40 private static $thankyou_fields = null;
36 41
37 -
38 42 /**
39 43 * Member Variable
40 44 *
41 45 * @var flow_fields
@@ -42,13 +46,34 @@
42 46 */
43 47 private static $flow_fields = null;
44 48
45 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 + /**
46 71 * Initiator
47 72 */
48 73 public static function get_instance() {
49 74 if ( ! isset( self::$instance ) ) {
50 - self::$instance = new self;
75 + self::$instance = new self();
51 76 }
52 77 return self::$instance;
53 78 }
54 79
@@ -55,9 +80,25 @@
55 80 /**
56 81 * Constructor
57 82 */
58 83 public function __construct() {
84 + }
59 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;
60 101 }
61 102
62 103 /**
63 104 * Checkout Default fields.
@@ -64,161 +105,298 @@
64 105 *
65 106 * @param int $post_id post id.
66 107 * @return array
67 108 */
68 - function get_checkout_fields( $post_id ) {
109 + public function get_checkout_fields( $post_id ) {
69 110
70 111 if ( null === self::$checkout_fields ) {
71 -
72 112 self::$checkout_fields = array(
73 - 'wcf-field-google-font-url' => 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(
74 122 'default' => '',
75 - 'sanitize' => 'FILTER_DEFAULT',
123 + 'sanitize' => 'FILTER_SANITIZE_URL',
76 124 ),
77 - 'wcf-checkout-products' => array(
125 + 'wcf-checkout-products' => array(
78 126 'default' => array(),
79 127 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS',
80 128 ),
81 - 'wcf-checkout-layout' => array(
82 - 'default' => 'two-column',
83 - 'sanitize' => 'FILTER_DEFAULT',
129 + 'wcf-checkout-layout' => array(
130 + 'default' => 'modern-checkout',
131 + 'sanitize' => 'FILTER_SANITIZE_STRING',
84 132 ),
85 - 'wcf-input-font-family' => array(
133 + 'wcf-input-font-family' => array(
86 134 'default' => '',
87 - 'sanitize' => 'FILTER_DEFAULT',
135 + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
88 136 ),
89 - 'wcf-input-font-weight' => array(
137 + 'wcf-input-font-weight' => array(
90 138 'default' => '',
91 - 'sanitize' => 'FILTER_DEFAULT',
139 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
92 140 ),
93 - 'wcf-heading-font-family' => array(
141 + 'wcf-heading-font-family' => array(
94 142 'default' => '',
95 - 'sanitize' => 'FILTER_DEFAULT',
143 + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
96 144 ),
97 - 'wcf-heading-font-weight' => array(
145 + 'wcf-heading-font-weight' => array(
98 146 'default' => '',
99 - 'sanitize' => 'FILTER_DEFAULT',
147 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
100 148 ),
101 - 'wcf-base-font-family' => array(
149 + 'wcf-base-font-family' => array(
102 150 'default' => '',
103 - 'sanitize' => 'FILTER_DEFAULT',
151 + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
104 152 ),
105 - 'wcf-advance-options-fields' => array(
153 + 'wcf-advance-options-fields' => array(
106 154 'default' => '',
107 - 'sanitize' => 'FILTER_DEFAULT',
155 + 'sanitize' => 'FILTER_SANITIZE_STRING',
108 156 ),
109 - 'wcf-base-font-weight' => array(
157 + 'wcf-remove-product-field' => array(
110 158 'default' => '',
111 - 'sanitize' => 'FILTER_DEFAULT',
159 + 'sanitize' => 'FILTER_SANITIZE_STRING',
112 160 ),
113 - 'wcf-button-font-family' => array(
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(
114 192 'default' => '',
115 - 'sanitize' => 'FILTER_DEFAULT',
193 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
116 194 ),
117 - 'wcf-button-font-weight' => array(
195 + 'wcf-button-font-family' => array(
118 196 'default' => '',
119 - 'sanitize' => 'FILTER_DEFAULT',
197 + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
120 198 ),
121 - 'wcf-primary-color' => array(
199 + 'wcf-button-font-weight' => array(
122 200 'default' => '',
123 - 'sanitize' => 'FILTER_DEFAULT',
201 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
124 202 ),
125 - 'wcf-heading-color' => array(
203 + 'wcf-primary-color' => array(
126 204 'default' => '',
127 - 'sanitize' => 'FILTER_DEFAULT',
205 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
128 206 ),
129 - 'wcf-section-bg-color' => array(
207 + 'wcf-heading-color' => array(
130 208 'default' => '',
131 - 'sanitize' => 'FILTER_DEFAULT',
209 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
132 210 ),
133 - 'wcf-hl-bg-color' => array(
211 + 'wcf-section-bg-color' => array(
134 212 'default' => '',
135 - 'sanitize' => 'FILTER_DEFAULT',
213 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
136 214 ),
137 - 'wcf-field-tb-padding' => array(
215 + 'wcf-hl-bg-color' => array(
138 216 'default' => '',
139 - 'sanitize' => 'FILTER_DEFAULT',
217 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
140 218 ),
141 - 'wcf-field-lr-padding' => array(
219 + 'wcf-field-tb-padding' => array(
142 220 'default' => '',
143 - 'sanitize' => 'FILTER_DEFAULT',
221 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
144 222 ),
145 - 'wcf-fields-skins' => array(
223 + 'wcf-field-lr-padding' => array(
146 224 'default' => '',
147 - 'sanitize' => 'FILTER_DEFAULT',
225 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
148 226 ),
149 - 'wcf-input-field-size' => array(
227 + 'wcf-fields-skins' => array(
228 + 'default' => 'modern-label',
229 + 'sanitize' => 'FILTER_SANITIZE_STRING',
230 + ),
231 + 'wcf-input-field-size' => array(
150 232 'default' => '33px',
151 - 'sanitize' => 'FILTER_DEFAULT',
233 + 'sanitize' => 'FILTER_SANITIZE_STRING',
152 234 ),
153 - 'wcf-field-color' => array(
235 + 'wcf-field-color' => array(
154 236 'default' => '',
155 - 'sanitize' => 'FILTER_DEFAULT',
237 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
156 238 ),
157 - 'wcf-field-bg-color' => array(
239 + 'wcf-field-bg-color' => array(
158 240 'default' => '',
159 - 'sanitize' => 'FILTER_DEFAULT',
241 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
160 242 ),
161 - 'wcf-field-border-color' => array(
243 + 'wcf-field-border-color' => array(
162 244 'default' => '',
163 - 'sanitize' => 'FILTER_DEFAULT',
245 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
164 246 ),
165 - 'wcf-box-border-color' => array(
247 + 'wcf-box-border-color' => array(
166 248 'default' => '',
167 - 'sanitize' => 'FILTER_DEFAULT',
249 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
168 250 ),
169 - 'wcf-field-label-color' => array(
251 + 'wcf-field-label-color' => array(
170 252 'default' => '',
171 - 'sanitize' => 'FILTER_DEFAULT',
253 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
172 254 ),
173 - 'wcf-submit-tb-padding' => array(
255 + 'wcf-submit-tb-padding' => array(
174 256 'default' => '',
175 - 'sanitize' => 'FILTER_DEFAULT',
257 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
176 258 ),
177 - 'wcf-submit-lr-padding' => array(
259 + 'wcf-submit-lr-padding' => array(
178 260 'default' => '',
179 - 'sanitize' => 'FILTER_DEFAULT',
261 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
180 262 ),
181 - 'wcf-input-button-size' => array(
263 + 'wcf-input-button-size' => array(
182 264 'default' => '33px',
183 - 'sanitize' => 'FILTER_DEFAULT',
265 + 'sanitize' => 'FILTER_SANITIZE_STRING',
184 266 ),
185 - 'wcf-submit-color' => array(
267 + 'wcf-submit-color' => array(
186 268 'default' => '',
187 - 'sanitize' => 'FILTER_DEFAULT',
269 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
188 270 ),
189 - 'wcf-submit-hover-color' => array(
271 + 'wcf-submit-hover-color' => array(
190 272 'default' => '',
191 - 'sanitize' => 'FILTER_DEFAULT',
273 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
192 274 ),
193 - 'wcf-submit-bg-color' => array(
275 + 'wcf-submit-bg-color' => array(
194 276 'default' => '',
195 - 'sanitize' => 'FILTER_DEFAULT',
277 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
196 278 ),
197 - 'wcf-submit-bg-hover-color' => array(
279 + 'wcf-submit-bg-hover-color' => array(
198 280 'default' => '',
199 - 'sanitize' => 'FILTER_DEFAULT',
281 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
200 282 ),
201 - 'wcf-submit-border-color' => array(
283 + 'wcf-submit-border-color' => array(
202 284 'default' => '',
203 - 'sanitize' => 'FILTER_DEFAULT',
285 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
204 286 ),
205 - 'wcf-submit-border-hover-color' => array(
287 + 'wcf-submit-border-hover-color' => array(
206 288 'default' => '',
207 - 'sanitize' => 'FILTER_DEFAULT',
289 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
208 290 ),
209 - 'wcf-active-tab' => array(
291 + 'wcf-header-logo-image' => array(
210 292 'default' => '',
211 - 'sanitize' => 'FILTER_DEFAULT',
293 + 'sanitize' => 'FILTER_SANITIZE_URL',
212 294 ),
213 - 'wcf-header-logo-image' => array(
295 + 'wcf-header-logo-width' => array(
214 296 'default' => '',
215 - 'sanitize' => 'FILTER_DEFAULT',
297 + 'sanitize' => 'FILTER_SANITIZE_STRING',
216 298 ),
217 - 'wcf-header-logo-width' => array(
299 + 'wcf-custom-script' => array(
218 300 'default' => '',
219 - 'sanitize' => 'FILTER_DEFAULT',
301 + 'sanitize' => 'FILTER_SCRIPT',
220 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 +
221 399 );
222 400
223 401 self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id );
224 402 }
@@ -226,40 +404,90 @@
226 404 return self::$checkout_fields;
227 405 }
228 406
229 407 /**
230 - * Save Checkout Meta fields.
231 - *
232 - * @param int $post_id post id.
233 - * @return void
234 - */
235 - function save_checkout_fields( $post_id ) {
236 -
237 - $post_meta = $this->get_checkout_fields( $post_id );
238 -
239 - $this->save_meta_fields( $post_id, $post_meta );
240 - }
241 -
242 - /**
243 408 * Flow Default fields.
244 409 *
245 410 * @param int $post_id post id.
246 411 * @return array
247 412 */
248 - function get_flow_fields( $post_id ) {
413 + public function get_flow_fields( $post_id ) {
249 414
250 415 if ( null === self::$flow_fields ) {
251 -
252 416 self::$flow_fields = array(
253 - 'wcf-steps' => array(
417 + 'wcf-steps' => array(
254 418 'default' => array(),
255 - 'sanitize' => 'FILTER_DEFAULT',
419 + 'sanitize' => '', // This key always updated from prepared array. Not from user input and save button click.
256 420 ),
257 -
258 - 'wcf-testing' => array(
259 - 'default' => 'yes',
260 - 'sanitize' => 'FILTER_DEFAULT',
421 + 'wcf-flow-indexing' => array(
422 + 'default' => '',
423 + 'sanitize' => 'FILTER_SANITIZE_STRING',
261 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 + ),
262 490 );
263 491 }
264 492
265 493 return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields );
@@ -265,108 +493,214 @@
265 493 return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields );
266 494 }
267 495
268 496 /**
269 - * Save Flow Meta fields.
497 + * Get checkout meta.
270 498 *
271 - * @param int $post_id post id.
272 - * @return void
499 + * @param int $post_id post id.
500 + * @param string $key options key.
501 + * @param mix $default options default value.
502 + * @return string
273 503 */
274 - function save_flow_fields( $post_id ) {
504 + public function get_flow_meta_value( $post_id, $key, $default = false ) {
505 + $value = $this->get_save_meta( $post_id, $key );
275 506
276 - $post_meta = $this->get_flow_fields( $post_id );
507 + if ( ! $value ) {
508 + if ( $default ) {
509 + $value = $default;
510 + } else {
511 + $fields = $this->get_flow_fields( $post_id );
277 512
278 - if ( isset( $post_meta['wcf-steps'] ) ) {
279 - unset( $post_meta['wcf-steps'] );
513 + if ( isset( $fields[ $key ]['default'] ) ) {
514 + $value = $fields[ $key ]['default'];
515 + }
516 + }
280 517 }
281 518
282 - $this->save_meta_fields( $post_id, $post_meta );
519 + return $value;
283 520 }
284 521
285 522 /**
286 - * Save Meta fields - Common Function.
523 + * Get checkout meta.
287 524 *
288 - * @param int $post_id post id.
289 - * @param array $post_meta options to store.
290 - * @return void
525 + * @param int $post_id post id.
526 + * @param string $key options key.
527 + * @param mix $default options default value.
528 + * @return string
291 529 */
292 - function save_meta_fields( $post_id, $post_meta ) {
530 + public function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) {
293 531
294 - if ( ! ( $post_id && is_array( $post_meta ) ) ) {
532 + $value = $this->get_save_meta( $post_id, $key );
295 533
296 - return;
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 + }
297 544 }
298 545
299 - foreach ( $post_meta as $key => $data ) {
546 + return apply_filters( "cartflows_checkout_meta_{$key}", $value );
547 + }
300 548
301 - $meta_value = false;
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 ) {
302 557
303 - // Sanitize values.
304 - $sanitize_filter = ( isset( $data['sanitize'] ) ) ? $data['sanitize'] : 'FILTER_DEFAULT';
558 + return get_post_meta( $post_id, $key, true );
559 + }
305 560
306 - switch ( $sanitize_filter ) {
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 ) {
307 568
308 - case 'FILTER_SANITIZE_STRING':
309 - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING );
310 - break;
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 + }
311 697
312 - case 'FILTER_SANITIZE_URL':
313 - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_URL );
314 - break;
315 -
316 - case 'FILTER_SANITIZE_NUMBER_INT':
317 - $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT );
318 - break;
319 -
320 - case 'FILTER_CARTFLOWS_ARRAY':
321 - if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
322 - $meta_value = array_map( 'sanitize_text_field', $_POST[ $key ] );
323 - }
324 - break;
325 -
326 - case 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS':
327 - if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
328 -
329 - $i = 0;
330 - $q = 0;
331 -
332 - foreach ( $_POST[ $key ] as $p_index => $p_data ) {
333 -
334 - foreach ( $p_data as $i_key => $i_value ) {
335 -
336 - if ( is_array( $i_value ) ) {
337 -
338 - foreach ( $i_value as $q_key => $q_value ) {
339 -
340 - $meta_value[ $i ][ $i_key ][ $q ] = array_map( 'sanitize_text_field', $q_value );
341 -
342 - $q++;
343 - }
344 - } else {
345 - $meta_value[ $i ][ $i_key ] = sanitize_text_field( $i_value );
346 - }
347 - }
348 -
349 - $i++;
350 - }
351 - }
352 - break;
353 -
354 - default:
355 - $meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT );
356 - break;
357 - }
358 -
359 - if ( false !== $meta_value ) {
360 - update_post_meta( $post_id, $key, $meta_value );
361 - } else {
362 - delete_post_meta( $post_id, $key );
363 - }
364 - }
698 + return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id );
365 699 }
366 700
367 701 /**
368 - * Get checkout meta.
702 + * Get Thank you section meta.
369 703 *
370 704 * @param int $post_id post id.
371 705 * @param string $key options key.
372 706 * @param mix $default options default value.
@@ -371,33 +705,29 @@
371 705 * @param string $key options key.
372 706 * @param mix $default options default value.
373 707 * @return string
374 708 */
375 - function get_flow_meta_value( $post_id, $key, $default = false ) {
709 + public function get_thankyou_meta_value( $post_id, $key, $default = false ) {
376 710
377 711 $value = $this->get_save_meta( $post_id, $key );
378 712
379 713 if ( ! $value ) {
380 -
381 714 if ( $default ) {
382 -
383 715 $value = $default;
384 716 } else {
717 + $fields = $this->get_thankyou_fields( $post_id );
385 718
386 - $fields = $this->get_flow_fields( $post_id );
387 -
388 719 if ( isset( $fields[ $key ]['default'] ) ) {
389 -
390 720 $value = $fields[ $key ]['default'];
391 721 }
392 722 }
393 723 }
394 724
395 - return $value;
725 + return apply_filters( "cartflows_thankyou_meta_{$key}", $value );
396 726 }
397 727
398 728 /**
399 - * Get checkout meta.
729 + * Get Landing section meta.
400 730 *
401 731 * @param int $post_id post id.
402 732 * @param string $key options key.
403 733 * @param mix $default options default value.
@@ -402,23 +732,18 @@
402 732 * @param string $key options key.
403 733 * @param mix $default options default value.
404 734 * @return string
405 735 */
406 - function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) {
736 + public function get_landing_meta_value( $post_id, $key, $default = false ) {
407 737
408 738 $value = $this->get_save_meta( $post_id, $key );
409 -
410 739 if ( ! $value ) {
411 -
412 740 if ( $default ) {
413 -
414 741 $value = $default;
415 742 } else {
743 + $fields = $this->get_landing_fields( $post_id );
416 744
417 - $fields = $this->get_checkout_fields( $post_id );
418 -
419 745 if ( isset( $fields[ $key ]['default'] ) ) {
420 -
421 746 $value = $fields[ $key ]['default'];
422 747 }
423 748 }
424 749 }
@@ -426,97 +751,222 @@
426 751 return $value;
427 752 }
428 753
429 754 /**
430 - * Get post meta.
755 + * Landing Default fields.
431 756 *
432 - * @param int $post_id post id.
433 - * @param string $key options key.
434 - * @return string
757 + * @param int $post_id post id.
758 + * @return array
435 759 */
436 - function get_save_meta( $post_id, $key ) {
760 + public function get_landing_fields( $post_id ) {
437 761
438 - $value = get_post_meta( $post_id, $key, true );
439 -
440 - return $value;
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 );
441 787 }
442 788
443 789 /**
444 - * Thank You Default fields.
790 + * Optin Default fields.
445 791 *
446 792 * @param int $post_id post id.
447 793 * @return array
448 794 */
449 - function get_thankyou_fields( $post_id ) {
795 + public function get_optin_fields( $post_id ) {
450 796
451 - if ( null === self::$thankyou_fields ) {
797 + if ( null === self::$optin_fields ) {
798 + self::$optin_fields = array(
452 799
453 - self::$thankyou_fields = array(
454 - 'wcf-field-google-font-url' => array(
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(
455 815 'default' => '',
456 - 'sanitize' => 'FILTER_DEFAULT',
816 + 'sanitize' => 'FILTER_SANITIZE_URL',
457 817 ),
458 - 'wcf-active-tab' => array(
818 + 'wcf-primary-color' => array(
459 819 'default' => '',
460 - 'sanitize' => 'FILTER_DEFAULT',
820 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
461 821 ),
462 - 'wcf-tq-text-color' => array(
822 + 'wcf-base-font-family' => array(
463 823 'default' => '',
464 - 'sanitize' => 'FILTER_DEFAULT',
824 + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
465 825 ),
466 - 'wcf-tq-font-family' => array(
826 + 'wcf-input-fields-skins' => array(
467 827 'default' => '',
468 - 'sanitize' => 'FILTER_DEFAULT',
828 + 'sanitize' => 'FILTER_SANITIZE_STRING',
469 829 ),
470 - 'wcf-tq-heading-color' => array(
830 + 'wcf-input-font-family' => array(
471 831 'default' => '',
472 - 'sanitize' => 'FILTER_DEFAULT',
832 + 'sanitize' => 'FILTER_SANITIZE_FONT_FAMILY',
473 833 ),
474 - 'wcf-tq-heading-font-family' => array(
834 + 'wcf-input-font-weight' => array(
475 835 'default' => '',
476 - 'sanitize' => 'FILTER_DEFAULT',
836 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
477 837 ),
478 - 'wcf-tq-heading-font-wt' => array(
838 + 'wcf-input-field-size' => array(
839 + 'default' => '33px',
840 + 'sanitize' => 'FILTER_SANITIZE_STRING',
841 + ),
842 + 'wcf-field-tb-padding' => array(
479 843 'default' => '',
480 - 'sanitize' => 'FILTER_DEFAULT',
844 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
481 845 ),
482 - 'wcf-tq-container-width' => array(
846 + 'wcf-field-lr-padding' => array(
483 847 'default' => '',
484 - 'sanitize' => 'FILTER_DEFAULT',
848 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
485 849 ),
486 - 'wcf-tq-section-bg-color' => array(
850 + 'wcf-field-color' => array(
487 851 'default' => '',
488 - 'sanitize' => 'FILTER_DEFAULT',
852 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
489 853 ),
490 - 'wcf-tq-advance-options-fields' => array(
854 + 'wcf-field-bg-color' => array(
491 855 'default' => '',
492 - 'sanitize' => 'FILTER_DEFAULT',
856 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
493 857 ),
494 - 'wcf-show-overview-section' => array(
495 - 'default' => 'yes',
496 - 'sanitize' => 'FILTER_DEFAULT',
858 + 'wcf-field-border-color' => array(
859 + 'default' => '',
860 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
497 861 ),
498 - 'wcf-show-details-section' => array(
499 - 'default' => 'yes',
500 - 'sanitize' => 'FILTER_DEFAULT',
862 + 'wcf-field-label-color' => array(
863 + 'default' => '',
864 + 'sanitize' => 'FILTER_SANITIZE_COLOR',
501 865 ),
502 - 'wcf-show-billing-section' => array(
503 - 'default' => 'yes',
504 - 'sanitize' => 'FILTER_DEFAULT',
866 + 'wcf-submit-button-text' => array(
867 + 'default' => __( 'Submit', 'cartflows' ),
868 + 'sanitize' => 'FILTER_SANITIZE_STRING',
505 869 ),
506 - 'wcf-show-shipping-section' => array(
507 - 'default' => 'yes',
508 - 'sanitize' => 'FILTER_DEFAULT',
870 + 'wcf-submit-font-size' => array(
871 + 'default' => '',
872 + 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT',
509 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 + ),
510 962 );
511 -
512 963 }
513 -
514 - return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id );
964 + return apply_filters( 'cartflows_optin_meta_options', self::$optin_fields, $post_id );
515 965 }
516 966
517 967 /**
518 - * Get Thank you section meta.
968 + * Get optin meta.
519 969 *
520 970 * @param int $post_id post id.
521 971 * @param string $key options key.
522 972 * @param mix $default options default value.
@@ -521,29 +971,25 @@
521 971 * @param string $key options key.
522 972 * @param mix $default options default value.
523 973 * @return string
524 974 */
525 - function get_thankyou_meta_value( $post_id, $key, $default = false ) {
975 + public function get_optin_meta_value( $post_id = 0, $key = '', $default = false ) {
526 976
527 977 $value = $this->get_save_meta( $post_id, $key );
528 978
529 979 if ( ! $value ) {
530 -
531 - if ( $default ) {
532 -
980 + if ( false !== $default ) {
533 981 $value = $default;
534 982 } else {
983 + $fields = $this->get_optin_fields( $post_id );
535 984
536 - $fields = $this->get_thankyou_fields( $post_id );
537 -
538 985 if ( isset( $fields[ $key ]['default'] ) ) {
539 -
540 986 $value = $fields[ $key ]['default'];
541 987 }
542 988 }
543 989 }
544 990
545 - return $value;
991 + return apply_filters( "cartflows_optin_meta_{$key}", $value );
546 992 }
547 993 }
548 994
549 995 /**