Version Description
Download this release
Release Info
Developer | sandesh055 |
Plugin | Funnel Builder by CartFlows – Create High Converting Sales Funnels For WordPress |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- admin/assets/css/arrow.png +0 -0
- assets/css/checkout-template-rtl.css +29 -0
- assets/css/checkout-template.css +29 -0
- assets/js/checkout-template.js +42 -1
- assets/min-css/checkout-template-rtl.min.css +1 -1
- assets/min-css/checkout-template.min.css +1 -1
- assets/min-js/checkout-template.min.js +1 -1
- cartflows.php +1 -1
- changelog.txt +5 -0
- classes/batch-process/class-cartflows-batch-process.php +270 -270
- classes/batch-process/class-cartflows-change-template-batch.php +61 -57
- classes/batch-process/class-cartflows-importer-divi.php +116 -116
- classes/class-cartflows-admin-fields.php +267 -267
- classes/class-cartflows-admin.php +620 -620
- classes/class-cartflows-api.php +381 -381
- classes/class-cartflows-bb-compatibility.php +76 -76
- classes/class-cartflows-cloning.php +445 -445
- classes/class-cartflows-compatibility.php +410 -404
- classes/class-cartflows-default-meta.php +879 -875
- classes/class-cartflows-flow-frontend.php +206 -206
- classes/class-cartflows-frontend.php +530 -530
- classes/class-cartflows-functions.php +447 -447
- classes/class-cartflows-helper.php +694 -694
- classes/class-cartflows-importer-core.php +272 -272
- classes/class-cartflows-importer.php +49 -48
- classes/class-cartflows-learndash-compatibility.php +133 -133
- classes/class-cartflows-loader.php +15 -19
- classes/class-cartflows-logger.php +183 -183
- classes/class-cartflows-meta.php +75 -75
- classes/class-cartflows-metabox.php +97 -97
- classes/class-cartflows-session.php +245 -245
- classes/class-cartflows-thrive-compatibility.php +77 -77
- classes/class-cartflows-update.php +146 -146
- classes/class-cartflows-utils.php +425 -426
- classes/class-cartflows-wizard.php +679 -679
- classes/fields/typography/class-cartflows-font-families.php +315 -315
- classes/logger/class-cartflows-log-handler-file.php +442 -442
- classes/logger/class-cartflows-log-handler.php +57 -57
- classes/logger/class-cartflows-wc-logger.php +301 -301
- includes/admin/cartflows-admin.php +35 -35
- includes/admin/cartflows-error-log.php +71 -71
- includes/admin/cartflows-general.php +370 -370
- languages/cartflows.pot +135 -105
- modules/checkout/classes/class-cartflows-checkout-markup.php +136 -45
- modules/checkout/classes/class-cartflows-checkout-meta.php +54 -14
- modules/checkout/templates/wcf-template.php +58 -58
- modules/flow/classes/class-cartflows-flow-loader.php +59 -59
- modules/flow/classes/class-cartflows-flow-meta.php +780 -778
- modules/flow/classes/class-cartflows-flow-post-type.php +334 -334
- modules/flow/classes/class-cartflows-flow-shortcodes.php +173 -173
- modules/flow/classes/class-cartflows-permalink.php +159 -159
- modules/flow/classes/class-cartflows-step-post-type.php +468 -468
- modules/landing/classes/class-cartflows-landing-markup.php +4 -4
- modules/landing/classes/class-cartflows-landing-meta.php +235 -236
- modules/thankyou/classes/class-cartflows-thankyou-markup.php +296 -296
- modules/thankyou/classes/class-cartflows-thankyou-meta.php +371 -371
- modules/widgets/class-cartflows-next-step.php +7 -7
- modules/widgets/class-cartflows-widgets.php +58 -58
- readme.txt +9 -3
- woocommerce/template/checkout/form-login.php +1 -1
- woocommerce/template/checkout/review-order.php +3 -2
admin/assets/css/arrow.png
ADDED
Binary file
|
assets/css/checkout-template-rtl.css
CHANGED
@@ -55,6 +55,35 @@
|
|
55 |
text-decoration: none;
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
/* To test divi and all */
|
59 |
|
60 |
.wcf-embed-checkout-form form .form-row-first.form-row-one{
|
55 |
text-decoration: none;
|
56 |
}
|
57 |
|
58 |
+
/* #wcf-embed-checkout-form .woocommerce .product-name a.remove:hover{
|
59 |
+
color:red !important;
|
60 |
+
} */
|
61 |
+
|
62 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove{
|
63 |
+
font-family: 'cartflows-icon';
|
64 |
+
display: inline-block;
|
65 |
+
font-size: 10px;
|
66 |
+
border: 1px #4d5763 solid;
|
67 |
+
-webkit-border-radius: 50%;
|
68 |
+
border-radius: 50%;
|
69 |
+
padding: 1px;
|
70 |
+
color: #4d5763 !important;
|
71 |
+
/* opacity: 0.6; */
|
72 |
+
line-height: 1;
|
73 |
+
margin-left: 5px;
|
74 |
+
text-align: center;
|
75 |
+
font-weight: 100;
|
76 |
+
width: 14px;
|
77 |
+
height: 14px;
|
78 |
+
background-color: #fff;
|
79 |
+
}
|
80 |
+
|
81 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{
|
82 |
+
color: #f1653c !important;
|
83 |
+
border: 1px #f1653c solid;
|
84 |
+
background-color: #fff;
|
85 |
+
}
|
86 |
+
|
87 |
/* To test divi and all */
|
88 |
|
89 |
.wcf-embed-checkout-form form .form-row-first.form-row-one{
|
assets/css/checkout-template.css
CHANGED
@@ -55,6 +55,35 @@
|
|
55 |
text-decoration: none;
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
/* To test divi and all */
|
59 |
|
60 |
.wcf-embed-checkout-form form .form-row-first.form-row-one{
|
55 |
text-decoration: none;
|
56 |
}
|
57 |
|
58 |
+
/* #wcf-embed-checkout-form .woocommerce .product-name a.remove:hover{
|
59 |
+
color:red !important;
|
60 |
+
} */
|
61 |
+
|
62 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove{
|
63 |
+
font-family: 'cartflows-icon';
|
64 |
+
display: inline-block;
|
65 |
+
font-size: 10px;
|
66 |
+
border: 1px #4d5763 solid;
|
67 |
+
-webkit-border-radius: 50%;
|
68 |
+
border-radius: 50%;
|
69 |
+
padding: 1px;
|
70 |
+
color: #4d5763 !important;
|
71 |
+
/* opacity: 0.6; */
|
72 |
+
line-height: 1;
|
73 |
+
margin-right: 5px;
|
74 |
+
text-align: center;
|
75 |
+
font-weight: 100;
|
76 |
+
width: 14px;
|
77 |
+
height: 14px;
|
78 |
+
background-color: #fff;
|
79 |
+
}
|
80 |
+
|
81 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{
|
82 |
+
color: #f1653c !important;
|
83 |
+
border: 1px #f1653c solid;
|
84 |
+
background-color: #fff;
|
85 |
+
}
|
86 |
+
|
87 |
/* To test divi and all */
|
88 |
|
89 |
.wcf-embed-checkout-form form .form-row-first.form-row-one{
|
assets/js/checkout-template.js
CHANGED
@@ -221,7 +221,13 @@
|
|
221 |
checkout_data = JSON.parse( localStorage.getItem('cartflows_checkout_form') );
|
222 |
|
223 |
for (var i = 0; i < checkout_data.length; i++) {
|
224 |
-
$('form.woocommerce-checkout [name='+checkout_data[i].name+']').
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
}
|
226 |
}
|
227 |
}
|
@@ -321,6 +327,39 @@
|
|
321 |
},
|
322 |
}
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
$(document).ready(function($) {
|
325 |
|
326 |
wcf_persistent_data();
|
@@ -331,6 +370,8 @@
|
|
331 |
|
332 |
add_custom_class_address_field();
|
333 |
|
|
|
|
|
334 |
wcf_checkout_coupons.init();
|
335 |
|
336 |
});
|
221 |
checkout_data = JSON.parse( localStorage.getItem('cartflows_checkout_form') );
|
222 |
|
223 |
for (var i = 0; i < checkout_data.length; i++) {
|
224 |
+
if($('form.woocommerce-checkout [name='+checkout_data[i].name+']').hasClass('select2-hidden-accessible'))
|
225 |
+
{
|
226 |
+
$('form.woocommerce-checkout [name='+checkout_data[i].name+']').selectWoo("val", [checkout_data[i].value]);
|
227 |
+
}else{
|
228 |
+
$('form.woocommerce-checkout [name='+checkout_data[i].name+']').val(checkout_data[i].value);
|
229 |
+
}
|
230 |
+
|
231 |
}
|
232 |
}
|
233 |
}
|
327 |
},
|
328 |
}
|
329 |
|
330 |
+
var wcf_remove_cart_products = function(){
|
331 |
+
|
332 |
+
$( document.body ).on( 'click', '#wcf-embed-checkout-form .remove', function(e){
|
333 |
+
e.preventDefault();
|
334 |
+
var p_id = $(this).attr("data-id");
|
335 |
+
var data = {
|
336 |
+
p_key : $(this).attr("data-item-key"),
|
337 |
+
p_id : p_id,
|
338 |
+
action : 'wcf_woo_remove_cart_product',
|
339 |
+
security : cartflows.wcf_validate_remove_cart_product_nonce
|
340 |
+
};
|
341 |
+
|
342 |
+
$.ajax({
|
343 |
+
type: 'POST',
|
344 |
+
url: cartflows.ajax_url,
|
345 |
+
data: data,
|
346 |
+
|
347 |
+
success: function( response ) {
|
348 |
+
var data = JSON.parse(response);
|
349 |
+
|
350 |
+
if( data.need_shipping == false ) {
|
351 |
+
// $('#wcf-embed-checkout-form').find('#ship-to-different-address-checkbox').hide();
|
352 |
+
$('#wcf-embed-checkout-form').find('#ship-to-different-address-checkbox').attr("checked",false);
|
353 |
+
}
|
354 |
+
$('#wcf-embed-checkout-form').find('.woocommerce-notices-wrapper').first().html(data.msg);
|
355 |
+
$(document).trigger('cartflows_remove_product',[p_id]);
|
356 |
+
$('#wcf-embed-checkout-form').trigger('update_checkout');
|
357 |
+
}
|
358 |
+
});
|
359 |
+
});
|
360 |
+
|
361 |
+
}
|
362 |
+
|
363 |
$(document).ready(function($) {
|
364 |
|
365 |
wcf_persistent_data();
|
370 |
|
371 |
add_custom_class_address_field();
|
372 |
|
373 |
+
wcf_remove_cart_products();
|
374 |
+
|
375 |
wcf_checkout_coupons.init();
|
376 |
|
377 |
});
|
assets/min-css/checkout-template-rtl.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.cartflows-container .wcf-embed-checkout-form,.cartflows-container .wcf-embed-checkout-form *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.wcf-embed-checkout-form .wc-backward{display:none!important}.wcf-embed-checkout-form .woocommerce form .form-row-first,.wcf-embed-checkout-form .woocommerce form .form-row-last,.wcf-embed-checkout-form .woocommerce-page form .form-row-first,.wcf-embed-checkout-form .woocommerce-page form .form-row-last{width:50%;display:block}.wcf-embed-checkout-form .woocommerce form .form-row-full,.wcf-embed-checkout-form .woocommerce-page form .form-row-full{width:100%;clear:both}.wcf-embed-checkout-form form .form-row-wide{width:100%}.wcf-embed-checkout-form form .wcf-column-33{width:33.33%}.wcf-embed-checkout-form .woocommerce form .form-row-first,.woocommerce-page form .form-row-first{float:right;clear:right}.wcf-embed-checkout-form .woocommerce form .form-row-last,.woocommerce-page form .form-row-last{float:left;clear:left}.wcf-embed-checkout-form .woocommerce form .form-row .required{color:red;font-weight:700;border:0!important;text-decoration:none}.wcf-embed-checkout-form form .form-row-first.form-row-one{clear:both}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login{display:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row{margin-bottom:15px}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .clear{clear:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row label{margin:0;line-height:1em;padding-top:0;position:relative;top:0}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .login-form-actions{-js-display:flex;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;margin-bottom:0}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .lost_password,.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .remember_me{-webkit-box-flex:1;-webkit-flex:1;-moz-box-flex:1;-ms-flex:1;flex:1;font-family:inherit;font-size:13px}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me label{margin-bottom:0;vertical-align:text-top}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me input,.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me span{vertical-align:middle}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .lost_password{text-align:left;margin-top:0;margin-bottom:0}.wcf-embed-checkout-form .woocommerce .blockUI.blockOverlay{font-size:15px}.wcf-embed-checkout-form .woocommerce form .form-row.mt20{margin-top:20px}.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid .select2-container,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid select{border-width:1px;border-color:#e2401c}.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated .select2-container,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated select{border-width:1px}.wcf-embed-checkout-form .select2-container--default.field-required .select2-selection--single,.wcf-embed-checkout-form .woocommerce #order_review .input-text.field-required,.wcf-embed-checkout-form .woocommerce form .form-row input.input-text.field-required,.wcf-embed-checkout-form .woocommerce form .form-row textarea.input-text.field-required{border-color:#e2401c}.wcf-embed-checkout-form .woocommerce form .form-row input.field-validated{border-right-width:2px;border-right-color:#69bf29}.wcf-embed-checkout-form .wcf-checkout-header-image{text-align:center}.wcf-embed-checkout-form .woocommerce #payment [type=radio]:checked+label,.wcf-embed-checkout-form .woocommerce #payment [type=radio]:not(:checked)+label{padding:0}.wcf-embed-checkout-form .woocommerce #payment input[type=radio]{-webkit-border-radius:50%;border-radius:50%;margin-left:4px;line-height:10px}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:checked:before{content:"\e600";margin:0;color:#f16334}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox],.wcf-embed-checkout-form .woocommerce #payment input[type=radio],.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox],.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox],.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 0 0 4px;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1);-webkit-transition:.05s border-color ease-in-out;transition:.05s border-color ease-in-out}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:focus{border-color:#f16334;-webkit-box-shadow:0 0 2px rgba(241,99,52,.8);box-shadow:0 0 2px rgba(241,99,52,.8)}.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{background-color:#f16334;-webkit-border-radius:50px;border-radius:50px;content:"\2022";font-size:24px;height:6px;line-height:16px;margin:4px;text-indent:-9999px;width:6px}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:before,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:checked:before{display:inline-block;float:right;font:normal 15px/1 cartflows-icon;speak:none;vertical-align:middle;width:6px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li input[type=checkbox]{min-width:16px}.wcf-embed-checkout-form .woocommerce .col2-set .col-1,.wcf-embed-checkout-form .woocommerce .col2-set .col-2,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-2{float:none;width:100%;max-width:100%;padding:0;-webkit-border-radius:0;border-radius:0;border:none;border-color:none;margin-bottom:0}.wcf-embed-checkout-form #order_review_heading,.wcf-embed-checkout-form .woocommerce #ship-to-different-address,.wcf-embed-checkout-form .woocommerce-additional-fields>h3,.wcf-embed-checkout-form .woocommerce-billing-fields>h3{font-family:inherit;font-weight:600;font-size:20px;text-transform:capitalize;margin:0 0 25px 0;padding:0;width:100%}.wcf-embed-checkout-form .woocommerce-checkout #payment{background:unset;-webkit-border-radius:0;border-radius:0}.wcf-embed-checkout-form .woocommerce-checkout #payment .form-row{margin:0;padding:0}.wcf-embed-checkout-form .woocommerce-checkout #payment .form-row label.checkbox{display:block;margin-bottom:1.1em}.wcf-embed-checkout-form .woocommerce-checkout #payment .payment_method_paypal .about_paypal{float:none;margin-right:10px}.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box .form-row{margin:0 0 .5em}.wcf-embed-checkout-form .woocommerce-checkout #payment fieldset .form-row .wcf-embed-checkout-form .woocommerce-checkout #payment fieldset p{margin-bottom:10px}.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{background-color:#eaeaea;font-family:inherit;font-weight:inherit;margin-bottom:.5em}.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before{content:'';display:block;border:1em solid;border-left-color:transparent;border-right-color:transparent;border-top-color:transparent;border-bottom-color:#eaeaea;position:absolute;top:-.75em;right:0;margin:-1em 2em 0 0}.wcf-embed-checkout-form .select2-container--default .select2-selection--single{display:block;width:100%;min-height:34px;height:auto;padding:11px 12px;font-size:14px;line-height:1.42857143!important;color:#555;background-color:#fff;background-image:none;border:1px solid;border-color:#d4d4d4;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;outline:0}.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered{color:#666;line-height:19px;min-height:19px;overflow:visible;padding-right:0}.select2-results__option[data-selected],.wcf-embed-checkout-form .select2-results__option[aria-selected]{font-size:14px}.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__arrow{height:100%}.select2-dropdown{border:1px solid #d4d4d4}.wcf-embed-checkout-form .woocommerce #order_review .input-text,.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row select,.wcf-embed-checkout-form .woocommerce form .form-row textarea{display:block;width:100%;min-height:34px;padding:11px 12px;font-family:inherit;font-weight:inherit;font-size:14px;line-height:1.42857143!important;color:#555;background-color:#fff;background-image:none;border:1px solid;border-color:#d4d4d4;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;height:auto}.wcf-embed-checkout-form #order_review{padding:3px;width:100%}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error,.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-message{padding:0 2em 1.2em 2em;background-color:transparent;border:none;margin:0;width:100%}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error li{list-style:none!important;margin:0}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error::before,.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-message::before{top:0;right:0}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error::before{content:'\e016'}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error li{margin:0 8px 0 0}.wcf-embed-checkout-form .woocommerce #order_review .wcf-custom-coupon-field input[type=text]{font-weight:400}.wcf-embed-checkout-form .wcf-custom-coupon-field{clear:right;-js-display:flex;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;margin-bottom:15px;margin-top:25px;border-top:1px solid #dcdcdc;border-bottom:1px solid #dcdcdc;padding-top:25px;padding-bottom:25px;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.wcf-embed-checkout-form #order_review .wcf-coupon-col-1{width:70%;display:inline-block;padding-left:20px}.wcf-embed-checkout-form #order_review .wcf-coupon-col-2{width:30%}.wcf-embed-checkout-form .select2-container--open,.wcf-embed-checkout-form input[type=email]:focus,.wcf-embed-checkout-form input[type=password]:focus,.wcf-embed-checkout-form input[type=tel]:focus,.wcf-embed-checkout-form input[type=text]:focus,.wcf-embed-checkout-form textarea:focus{border-color:#b3b3b3;-webkit-box-shadow:none;box-shadow:none;outline:0}.wcf-embed-checkout-form button:focus{outline:0;outline-color:none;outline-style:none;outline-width:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,.wcf-embed-checkout-form form.checkout_coupon .button{display:block;clear:both;border:none;font-size:15px;font-family:inherit;font-weight:inherit;background-color:#f16334;line-height:9px;padding:18px;margin-bottom:10px;width:100%;text-transform:uppercase}.wcf-embed-checkout-form .woocommerce #order_review button{border:1px solid;border-color:#f16334;background-color:#f16334;font-family:inherit;font-weight:inherit;font-size:18px;letter-spacing:.5px;width:100%;padding:16px 24px;font-size:16px;line-height:1.5;-webkit-border-radius:3px;border-radius:3px;color:#fff;text-transform:uppercase}.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small{padding:8px 6px;background-color:#c8c8c8;border:1px #c8c8c8 solid}.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{border-color:#f16334;background-color:#f16334}.wcf-embed-checkout-form .woocommerce #payment #place_order:hover{background-color:#f16334;border-color:#f16334;color:#fff}.wcf-embed-checkout-form .woocommerce-checkout{display:inline-block;text-align:inherit;width:100%}.wcf-embed-checkout-form .woocommerce-checkout .col2-set,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set{display:inline-block;width:55%;float:right;padding-left:40px;margin:20px 0 0}.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-billing-fields .woocommerce-billing-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-billing-fields .woocommerce-billing-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper{margin:0 -7px;-ms-flex-wrap:wrap;flex-wrap:wrap;-js-display:flex;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap}.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-additional-fields .woocommerce-additional-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-additional-fields .woocommerce-additional-fields__field-wrapper{margin:0 -7px}.wcf-embed-checkout-form-two-column .woocommerce-checkout .wcf-order-wrap{display:inline-block;float:none;width:45%;border:none;background-color:inherit;padding:0 10px;-webkit-border-radius:3px;border-radius:3px}.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{display:inline-block;font-family:inherit;font-weight:600;width:100%;margin:20px 0 0;padding:3px 3px 20px;border:none;border-bottom:none}.wcf-embed-checkout-form .woocommerce-checkout #payment{background-color:inherit;border:none;-webkit-border-radius:0;border-radius:0}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{padding:1em 0}.wcf-embed-checkout-form #add_payment_method #payment ul.payment_methods,.wcf-embed-checkout-form .woocommerce-cart #payment ul.payment_methods,.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{border:none}.wcf-embed-checkout-form #payment ul.payment_methods li,.wcf-embed-checkout-form #payment ul.payment_methods li:hover{background-color:transparent}.wcf-embed-checkout-form .woocommerce form .form-row{display:block;margin-bottom:1.1em;padding:3px 7px;position:relative}.wcf-embed-checkout-form .woocommerce form .woocommerce-account-fields .form-row{padding:0}.wcf-embed-checkout-form table.shop_table{border:none;border-bottom:0;background-color:inherit;-webkit-border-radius:0;border-radius:0;font-family:inherit;font-weight:inherit;font-size:.95em;margin:0!important;border-collapse:collapse;text-align:right}.wcf-embed-checkout-form table.shop_table td strong.product-quantity{font-weight:400}.wcf-embed-checkout-form table.shop_table #shipping_method{margin:0;padding:0;list-style:none}.wcf-embed-checkout-form table.shop_table #shipping_method .amount{font-weight:400}.wcf-embed-checkout-form table.shop_table th{border:none;font-weight:400;padding:9px 0;line-height:1.2em}.wcf-embed-checkout-form table.shop_table tfoot tr:last-child .woocommerce-Price-amount{font-size:1em}.wcf-embed-checkout-form table.shop_table td,.wcf-embed-checkout-form table.shop_table td dl dd,.wcf-embed-checkout-form table.shop_table td dl dt,.wcf-embed-checkout-form table.shop_table th{background-color:transparent;border:none;padding:.6em 0;line-height:1.4em}.wcf-embed-checkout-form table.shop_table td dl dd p{margin-top:0}.wcf-embed-checkout-form table.shop_table tbody th,.wcf-embed-checkout-form table.shop_table tfoot td,.wcf-embed-checkout-form table.shop_table tfoot th{border:none;display:table-cell;font-weight:400;width:50%}.wcf-embed-checkout-form table.shop_table thead{background-color:transparent}.wcf-embed-checkout-form table.shop_table tbody{border-top:1px dashed #ccc;border-bottom:1px dashed #ccc}.wcf-embed-checkout-form table.shop_table th.product-name,.wcf-embed-checkout-form table.shop_table th.product-total{font-weight:600}.wcf-embed-checkout-form table.shop_table tfoot tr.order-total:not(.recurring-total) td,.wcf-embed-checkout-form table.shop_table tfoot tr.order-total:not(.recurring-total) th{font-weight:600;border-top:1px dashed #ccc}.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-totals th{padding-top:1.8em;font-weight:600}.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-total td,.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-total th,.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-totals th{vertical-align:top}.wcf-embed-checkout-form table.shop_table tbody tr td:nth-child(1),.wcf-embed-checkout-form table.shop_table tfoot tr td:nth-child(1),.wcf-embed-checkout-form table.shop_table thead tr th:nth-child(1){width:70%}.wcf-embed-checkout-form table.shop_table tbody tr td:nth-child(2),.wcf-embed-checkout-form table.shop_table tfoot tr td:nth-child(2),.wcf-embed-checkout-form table.shop_table thead tr th:nth-child(2){width:30%}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row label,.wcf-embed-checkout-form .woocommerce-checkout .form-row label{font-size:13px;line-height:1em;letter-spacing:.3px;font-family:inherit;font-weight:inherit;text-transform:capitalize;margin-bottom:8px}.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields label,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields label{display:inherit}.wcf-embed-checkout-form .woocommerce .woocommerce-terms-and-conditions-wrapper .woocommerce-terms-and-conditions-checkbox-text{line-height:20px;text-transform:initial}.wcf-embed-checkout-form #payment .woocommerce-privacy-policy-text p{font-family:inherit;font-weight:inherit;font-size:11px;color:#777;margin-top:0;text-align:justify}.wcf-embed-checkout-form #payment .wc_payment_methods .payment_box p{margin:0}.wcf-embed-checkout-form .woocommerce a{color:#f16334;background-color:transparent;text-decoration:none}.wcf-embed-checkout-form .woocommerce .woocommerce-NoticeGroup .woocommerce-message,.wcf-embed-checkout-form .woocommerce .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-info,.wcf-embed-checkout-form .woocommerce .woocommerce-message,.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-message{padding:1em 2em .4em 2em;border-top:none;background-color:inherit;font-size:14px;font-weight:500;text-align:right;margin:0}.wcf-embed-checkout-form .woocommerce-info::before,.wcf-embed-checkout-form .woocommerce-message::before{right:.1em;color:#f16334}.wcf-embed-checkout-form .woocommerce .woocommerce-NoticeGroup .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-error{background-color:#fff6f6;border:dashed 1px #a00;padding:25px 25px 20px;color:#a00;margin:1rem 0 1rem;font-size:14px;width:100%}.wcf-embed-checkout-form .woocommerce .woocommerce-error::before{content:''}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li:not(.woocommerce-notice)::before{display:inline}.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-message{margin:1em 0 1em}.wcf-embed-checkout-form .woocommerce .woocommerce-error li{list-style:disc inside!important;margin:0 0 8px}.wcf-embed-checkout-form .woocommerce .woocommerce-error li strong{font-weight:400}.wcf-embed-checkout-form .woocommerce form.checkout_coupon{border:1px solid #d3ced2;padding:30px 20px 20px;margin:2em 0;text-align:right;-webkit-border-radius:5px;border-radius:5px}.wcf-embed-checkout-form .woocommerce .checkout_coupon p{font-size:14px}.wcf-embed-checkout-form .woocommerce .checkout_coupon p{font-family:inherit;font-weight:500;margin-top:0;margin-bottom:10px}@media only screen and (max-width:768px){.wcf-embed-checkout-form form .wcf-column-33{width:100%}.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{width:100%}.wcf-embed-checkout-form .woocommerce-checkout #order_review{width:100%}.wcf-embed-checkout-form .woocommerce-checkout .wcf-order-wrap{width:100%}.wcf-embed-checkout-form .woocommerce-checkout{display:block}.wcf-embed-checkout-form .woocommerce-checkout .col2-set,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set{display:block;width:100%;padding-left:0;margin:20px 0 0}.wcf-embed-checkout-form form.checkout_coupon .button{font-size:12px}.wcf-bump-order-field-wrap .wcf-bump-order-label{font-size:16px;text-transform:capitalize}.wcf-embed-checkout-form .woocommerce .col2-set .col-1,.wcf-embed-checkout-form .woocommerce .col2-set .col-2,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce .wcf-order-wrap,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-order-wrap{padding:15px 18px}.wcf-embed-checkout-form .woocommerce form .form-row-first,.wcf-embed-checkout-form .woocommerce form .form-row-last,.wcf-embed-checkout-form .woocommerce-page form .form-row-first,.wcf-embed-checkout-form .woocommerce-page form .form-row-last{width:100%}.wcf-embed-checkout-form #order_review_heading,.wcf-embed-checkout-form .woocommerce #ship-to-different-address,.wcf-embed-checkout-form .woocommerce-additional-fields>h3,.wcf-embed-checkout-form .woocommerce-billing-fields>h3{font-size:1em}}#et-info-email:before,#et-info-phone:before,#et_search_icon:before,.comment-reply-link:after,.et-cart-info span:before,.et-pb-arrow-next:before,.et-pb-arrow-prev:before,.et-social-icon a:before,.et_audio_container .mejs-playpause-button button:before,.et_audio_container .mejs-volume-button button:before,.et_overlay:before,.et_password_protected_form .et_submit_button:after,.et_pb_button:after,.et_pb_contact_reset:after,.et_pb_contact_submit:after,.et_pb_font_icon:before,.et_pb_newsletter_button:after,.et_pb_pricing_table_button:after,.et_pb_promo_button:after,.et_pb_social_icon a.icon:before,.et_pb_testimonial:before,.et_pb_toggle_title:before,.form-submit .et_pb_button:after,.mobile_menu_bar:before,.woocommerce #content input.button.alt:after,.woocommerce #content input.button:after,.woocommerce #respond input#submit.alt:after,.woocommerce #respond input#submit:after,.woocommerce a.button.alt:after,.woocommerce button.button.alt:after,.woocommerce button.button:after,.woocommerce button.single_add_to_cart_button.button:after,.woocommerce input.button.alt:after,.woocommerce input.button:after,.woocommerce-page #content input.button.alt:after,.woocommerce-page #content input.button:after,.woocommerce-page #respond input#submit.alt:after,.woocommerce-page #respond input#submit:after,.woocommerce-page a.button.alt:after,.woocommerce-page a.button:after,.woocommerce-page button.button.alt:after,.woocommerce-page button.button:after,.woocommerce-page input.button.alt:after,.woocommerce-page input.button:after,a.et_pb_more_button:after{text-shadow:0 0;font-family:none;font-weight:400;font-style:normal;font-variant:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:1;text-transform:none;speak:none}.comment-reply-link:hover:after,.woocommerce #content input.button.alt:hover:after,.woocommerce #content input.button:hover:after,.woocommerce #respond input#submit.alt:hover:after,.woocommerce #respond input#submit:hover:after,.woocommerce a.button.alt:hover:after,.woocommerce a.button:hover:after,.woocommerce button.button.alt:hover:after,.woocommerce button.button:hover:after,.woocommerce input.button.alt:hover:after,.woocommerce input.button:hover:after,.woocommerce-page #content input.button.alt:hover:after,.woocommerce-page #content input.button:hover:after,.woocommerce-page #respond input#submit.alt:hover:after,.woocommerce-page #respond input#submit:hover:after,.woocommerce-page a.button.alt:hover:after,.woocommerce-page a.button:hover:after,.woocommerce-page button.button.alt:hover:after,.woocommerce-page button.button:hover:after,.woocommerce-page input.button.alt:hover:after,.woocommerce-page input.button:hover:after{opacity:0}.thrv_wrapper .wcf-embed-checkout-form div{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
|
1 |
+
.cartflows-container .wcf-embed-checkout-form,.cartflows-container .wcf-embed-checkout-form *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.wcf-embed-checkout-form .wc-backward{display:none!important}.wcf-embed-checkout-form .woocommerce form .form-row-first,.wcf-embed-checkout-form .woocommerce form .form-row-last,.wcf-embed-checkout-form .woocommerce-page form .form-row-first,.wcf-embed-checkout-form .woocommerce-page form .form-row-last{width:50%;display:block}.wcf-embed-checkout-form .woocommerce form .form-row-full,.wcf-embed-checkout-form .woocommerce-page form .form-row-full{width:100%;clear:both}.wcf-embed-checkout-form form .form-row-wide{width:100%}.wcf-embed-checkout-form form .wcf-column-33{width:33.33%}.wcf-embed-checkout-form .woocommerce form .form-row-first,.woocommerce-page form .form-row-first{float:right;clear:right}.wcf-embed-checkout-form .woocommerce form .form-row-last,.woocommerce-page form .form-row-last{float:left;clear:left}.wcf-embed-checkout-form .woocommerce form .form-row .required{color:red;font-weight:700;border:0!important;text-decoration:none}.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove{font-family:cartflows-icon;display:inline-block;font-size:10px;border:1px #4d5763 solid;-webkit-border-radius:50%;border-radius:50%;padding:1px;color:#4d5763!important;line-height:1;margin-left:5px;text-align:center;font-weight:100;width:14px;height:14px;background-color:#fff}.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{color:#f1653c!important;border:1px #f1653c solid;background-color:#fff}.wcf-embed-checkout-form form .form-row-first.form-row-one{clear:both}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login{display:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row{margin-bottom:15px}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .clear{clear:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row label{margin:0;line-height:1em;padding-top:0;position:relative;top:0}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .login-form-actions{-js-display:flex;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;margin-bottom:0}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .lost_password,.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .remember_me{-webkit-box-flex:1;-webkit-flex:1;-moz-box-flex:1;-ms-flex:1;flex:1;font-family:inherit;font-size:13px}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me label{margin-bottom:0;vertical-align:text-top}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me input,.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me span{vertical-align:middle}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .lost_password{text-align:left;margin-top:0;margin-bottom:0}.wcf-embed-checkout-form .woocommerce .blockUI.blockOverlay{font-size:15px}.wcf-embed-checkout-form .woocommerce form .form-row.mt20{margin-top:20px}.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid .select2-container,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid select{border-width:1px;border-color:#e2401c}.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated .select2-container,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated select{border-width:1px}.wcf-embed-checkout-form .select2-container--default.field-required .select2-selection--single,.wcf-embed-checkout-form .woocommerce #order_review .input-text.field-required,.wcf-embed-checkout-form .woocommerce form .form-row input.input-text.field-required,.wcf-embed-checkout-form .woocommerce form .form-row textarea.input-text.field-required{border-color:#e2401c}.wcf-embed-checkout-form .woocommerce form .form-row input.field-validated{border-right-width:2px;border-right-color:#69bf29}.wcf-embed-checkout-form .wcf-checkout-header-image{text-align:center}.wcf-embed-checkout-form .woocommerce #payment [type=radio]:checked+label,.wcf-embed-checkout-form .woocommerce #payment [type=radio]:not(:checked)+label{padding:0}.wcf-embed-checkout-form .woocommerce #payment input[type=radio]{-webkit-border-radius:50%;border-radius:50%;margin-left:4px;line-height:10px}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:checked:before{content:"\e600";margin:0;color:#f16334}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox],.wcf-embed-checkout-form .woocommerce #payment input[type=radio],.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox],.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox],.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 0 0 4px;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1);-webkit-transition:.05s border-color ease-in-out;transition:.05s border-color ease-in-out}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:focus{border-color:#f16334;-webkit-box-shadow:0 0 2px rgba(241,99,52,.8);box-shadow:0 0 2px rgba(241,99,52,.8)}.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{background-color:#f16334;-webkit-border-radius:50px;border-radius:50px;content:"\2022";font-size:24px;height:6px;line-height:16px;margin:4px;text-indent:-9999px;width:6px}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:before,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:checked:before{display:inline-block;float:right;font:normal 15px/1 cartflows-icon;speak:none;vertical-align:middle;width:6px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li input[type=checkbox]{min-width:16px}.wcf-embed-checkout-form .woocommerce .col2-set .col-1,.wcf-embed-checkout-form .woocommerce .col2-set .col-2,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-2{float:none;width:100%;max-width:100%;padding:0;-webkit-border-radius:0;border-radius:0;border:none;border-color:none;margin-bottom:0}.wcf-embed-checkout-form #order_review_heading,.wcf-embed-checkout-form .woocommerce #ship-to-different-address,.wcf-embed-checkout-form .woocommerce-additional-fields>h3,.wcf-embed-checkout-form .woocommerce-billing-fields>h3{font-family:inherit;font-weight:600;font-size:20px;text-transform:capitalize;margin:0 0 25px 0;padding:0;width:100%}.wcf-embed-checkout-form .woocommerce-checkout #payment{background:unset;-webkit-border-radius:0;border-radius:0}.wcf-embed-checkout-form .woocommerce-checkout #payment .form-row{margin:0;padding:0}.wcf-embed-checkout-form .woocommerce-checkout #payment .form-row label.checkbox{display:block;margin-bottom:1.1em}.wcf-embed-checkout-form .woocommerce-checkout #payment .payment_method_paypal .about_paypal{float:none;margin-right:10px}.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box .form-row{margin:0 0 .5em}.wcf-embed-checkout-form .woocommerce-checkout #payment fieldset .form-row .wcf-embed-checkout-form .woocommerce-checkout #payment fieldset p{margin-bottom:10px}.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{background-color:#eaeaea;font-family:inherit;font-weight:inherit;margin-bottom:.5em}.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before{content:'';display:block;border:1em solid;border-left-color:transparent;border-right-color:transparent;border-top-color:transparent;border-bottom-color:#eaeaea;position:absolute;top:-.75em;right:0;margin:-1em 2em 0 0}.wcf-embed-checkout-form .select2-container--default .select2-selection--single{display:block;width:100%;min-height:34px;height:auto;padding:11px 12px;font-size:14px;line-height:1.42857143!important;color:#555;background-color:#fff;background-image:none;border:1px solid;border-color:#d4d4d4;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;outline:0}.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered{color:#666;line-height:19px;min-height:19px;overflow:visible;padding-right:0}.select2-results__option[data-selected],.wcf-embed-checkout-form .select2-results__option[aria-selected]{font-size:14px}.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__arrow{height:100%}.select2-dropdown{border:1px solid #d4d4d4}.wcf-embed-checkout-form .woocommerce #order_review .input-text,.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row select,.wcf-embed-checkout-form .woocommerce form .form-row textarea{display:block;width:100%;min-height:34px;padding:11px 12px;font-family:inherit;font-weight:inherit;font-size:14px;line-height:1.42857143!important;color:#555;background-color:#fff;background-image:none;border:1px solid;border-color:#d4d4d4;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;height:auto}.wcf-embed-checkout-form #order_review{padding:3px;width:100%}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error,.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-message{padding:0 2em 1.2em 2em;background-color:transparent;border:none;margin:0;width:100%}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error li{list-style:none!important;margin:0}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error::before,.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-message::before{top:0;right:0}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error::before{content:'\e016'}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error li{margin:0 8px 0 0}.wcf-embed-checkout-form .woocommerce #order_review .wcf-custom-coupon-field input[type=text]{font-weight:400}.wcf-embed-checkout-form .wcf-custom-coupon-field{clear:right;-js-display:flex;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;margin-bottom:15px;margin-top:25px;border-top:1px solid #dcdcdc;border-bottom:1px solid #dcdcdc;padding-top:25px;padding-bottom:25px;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.wcf-embed-checkout-form #order_review .wcf-coupon-col-1{width:70%;display:inline-block;padding-left:20px}.wcf-embed-checkout-form #order_review .wcf-coupon-col-2{width:30%}.wcf-embed-checkout-form .select2-container--open,.wcf-embed-checkout-form input[type=email]:focus,.wcf-embed-checkout-form input[type=password]:focus,.wcf-embed-checkout-form input[type=tel]:focus,.wcf-embed-checkout-form input[type=text]:focus,.wcf-embed-checkout-form textarea:focus{border-color:#b3b3b3;-webkit-box-shadow:none;box-shadow:none;outline:0}.wcf-embed-checkout-form button:focus{outline:0;outline-color:none;outline-style:none;outline-width:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,.wcf-embed-checkout-form form.checkout_coupon .button{display:block;clear:both;border:none;font-size:15px;font-family:inherit;font-weight:inherit;background-color:#f16334;line-height:9px;padding:18px;margin-bottom:10px;width:100%;text-transform:uppercase}.wcf-embed-checkout-form .woocommerce #order_review button{border:1px solid;border-color:#f16334;background-color:#f16334;font-family:inherit;font-weight:inherit;font-size:18px;letter-spacing:.5px;width:100%;padding:16px 24px;font-size:16px;line-height:1.5;-webkit-border-radius:3px;border-radius:3px;color:#fff;text-transform:uppercase}.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small{padding:8px 6px;background-color:#c8c8c8;border:1px #c8c8c8 solid}.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{border-color:#f16334;background-color:#f16334}.wcf-embed-checkout-form .woocommerce #payment #place_order:hover{background-color:#f16334;border-color:#f16334;color:#fff}.wcf-embed-checkout-form .woocommerce-checkout{display:inline-block;text-align:inherit;width:100%}.wcf-embed-checkout-form .woocommerce-checkout .col2-set,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set{display:inline-block;width:55%;float:right;padding-left:40px;margin:20px 0 0}.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-billing-fields .woocommerce-billing-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-billing-fields .woocommerce-billing-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper{margin:0 -7px;-ms-flex-wrap:wrap;flex-wrap:wrap;-js-display:flex;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap}.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-additional-fields .woocommerce-additional-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-additional-fields .woocommerce-additional-fields__field-wrapper{margin:0 -7px}.wcf-embed-checkout-form-two-column .woocommerce-checkout .wcf-order-wrap{display:inline-block;float:none;width:45%;border:none;background-color:inherit;padding:0 10px;-webkit-border-radius:3px;border-radius:3px}.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{display:inline-block;font-family:inherit;font-weight:600;width:100%;margin:20px 0 0;padding:3px 3px 20px;border:none;border-bottom:none}.wcf-embed-checkout-form .woocommerce-checkout #payment{background-color:inherit;border:none;-webkit-border-radius:0;border-radius:0}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{padding:1em 0}.wcf-embed-checkout-form #add_payment_method #payment ul.payment_methods,.wcf-embed-checkout-form .woocommerce-cart #payment ul.payment_methods,.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{border:none}.wcf-embed-checkout-form #payment ul.payment_methods li,.wcf-embed-checkout-form #payment ul.payment_methods li:hover{background-color:transparent}.wcf-embed-checkout-form .woocommerce form .form-row{display:block;margin-bottom:1.1em;padding:3px 7px;position:relative}.wcf-embed-checkout-form .woocommerce form .woocommerce-account-fields .form-row{padding:0}.wcf-embed-checkout-form table.shop_table{border:none;border-bottom:0;background-color:inherit;-webkit-border-radius:0;border-radius:0;font-family:inherit;font-weight:inherit;font-size:.95em;margin:0!important;border-collapse:collapse;text-align:right}.wcf-embed-checkout-form table.shop_table td strong.product-quantity{font-weight:400}.wcf-embed-checkout-form table.shop_table #shipping_method{margin:0;padding:0;list-style:none}.wcf-embed-checkout-form table.shop_table #shipping_method .amount{font-weight:400}.wcf-embed-checkout-form table.shop_table th{border:none;font-weight:400;padding:9px 0;line-height:1.2em}.wcf-embed-checkout-form table.shop_table tfoot tr:last-child .woocommerce-Price-amount{font-size:1em}.wcf-embed-checkout-form table.shop_table td,.wcf-embed-checkout-form table.shop_table td dl dd,.wcf-embed-checkout-form table.shop_table td dl dt,.wcf-embed-checkout-form table.shop_table th{background-color:transparent;border:none;padding:.6em 0;line-height:1.4em}.wcf-embed-checkout-form table.shop_table td dl dd p{margin-top:0}.wcf-embed-checkout-form table.shop_table tbody th,.wcf-embed-checkout-form table.shop_table tfoot td,.wcf-embed-checkout-form table.shop_table tfoot th{border:none;display:table-cell;font-weight:400;width:50%}.wcf-embed-checkout-form table.shop_table thead{background-color:transparent}.wcf-embed-checkout-form table.shop_table tbody{border-top:1px dashed #ccc;border-bottom:1px dashed #ccc}.wcf-embed-checkout-form table.shop_table th.product-name,.wcf-embed-checkout-form table.shop_table th.product-total{font-weight:600}.wcf-embed-checkout-form table.shop_table tfoot tr.order-total:not(.recurring-total) td,.wcf-embed-checkout-form table.shop_table tfoot tr.order-total:not(.recurring-total) th{font-weight:600;border-top:1px dashed #ccc}.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-totals th{padding-top:1.8em;font-weight:600}.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-total td,.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-total th,.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-totals th{vertical-align:top}.wcf-embed-checkout-form table.shop_table tbody tr td:nth-child(1),.wcf-embed-checkout-form table.shop_table tfoot tr td:nth-child(1),.wcf-embed-checkout-form table.shop_table thead tr th:nth-child(1){width:70%}.wcf-embed-checkout-form table.shop_table tbody tr td:nth-child(2),.wcf-embed-checkout-form table.shop_table tfoot tr td:nth-child(2),.wcf-embed-checkout-form table.shop_table thead tr th:nth-child(2){width:30%}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row label,.wcf-embed-checkout-form .woocommerce-checkout .form-row label{font-size:13px;line-height:1em;letter-spacing:.3px;font-family:inherit;font-weight:inherit;text-transform:capitalize;margin-bottom:8px}.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields label,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields label{display:inherit}.wcf-embed-checkout-form .woocommerce .woocommerce-terms-and-conditions-wrapper .woocommerce-terms-and-conditions-checkbox-text{line-height:20px;text-transform:initial}.wcf-embed-checkout-form #payment .woocommerce-privacy-policy-text p{font-family:inherit;font-weight:inherit;font-size:11px;color:#777;margin-top:0;text-align:justify}.wcf-embed-checkout-form #payment .wc_payment_methods .payment_box p{margin:0}.wcf-embed-checkout-form .woocommerce a{color:#f16334;background-color:transparent;text-decoration:none}.wcf-embed-checkout-form .woocommerce .woocommerce-NoticeGroup .woocommerce-message,.wcf-embed-checkout-form .woocommerce .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-info,.wcf-embed-checkout-form .woocommerce .woocommerce-message,.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-message{padding:1em 2em .4em 2em;border-top:none;background-color:inherit;font-size:14px;font-weight:500;text-align:right;margin:0}.wcf-embed-checkout-form .woocommerce-info::before,.wcf-embed-checkout-form .woocommerce-message::before{right:.1em;color:#f16334}.wcf-embed-checkout-form .woocommerce .woocommerce-NoticeGroup .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-error{background-color:#fff6f6;border:dashed 1px #a00;padding:25px 25px 20px;color:#a00;margin:1rem 0 1rem;font-size:14px;width:100%}.wcf-embed-checkout-form .woocommerce .woocommerce-error::before{content:''}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li:not(.woocommerce-notice)::before{display:inline}.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-message{margin:1em 0 1em}.wcf-embed-checkout-form .woocommerce .woocommerce-error li{list-style:disc inside!important;margin:0 0 8px}.wcf-embed-checkout-form .woocommerce .woocommerce-error li strong{font-weight:400}.wcf-embed-checkout-form .woocommerce form.checkout_coupon{border:1px solid #d3ced2;padding:30px 20px 20px;margin:2em 0;text-align:right;-webkit-border-radius:5px;border-radius:5px}.wcf-embed-checkout-form .woocommerce .checkout_coupon p{font-size:14px}.wcf-embed-checkout-form .woocommerce .checkout_coupon p{font-family:inherit;font-weight:500;margin-top:0;margin-bottom:10px}@media only screen and (max-width:768px){.wcf-embed-checkout-form form .wcf-column-33{width:100%}.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{width:100%}.wcf-embed-checkout-form .woocommerce-checkout #order_review{width:100%}.wcf-embed-checkout-form .woocommerce-checkout .wcf-order-wrap{width:100%}.wcf-embed-checkout-form .woocommerce-checkout{display:block}.wcf-embed-checkout-form .woocommerce-checkout .col2-set,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set{display:block;width:100%;padding-left:0;margin:20px 0 0}.wcf-embed-checkout-form form.checkout_coupon .button{font-size:12px}.wcf-bump-order-field-wrap .wcf-bump-order-label{font-size:16px;text-transform:capitalize}.wcf-embed-checkout-form .woocommerce .col2-set .col-1,.wcf-embed-checkout-form .woocommerce .col2-set .col-2,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce .wcf-order-wrap,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-order-wrap{padding:15px 18px}.wcf-embed-checkout-form .woocommerce form .form-row-first,.wcf-embed-checkout-form .woocommerce form .form-row-last,.wcf-embed-checkout-form .woocommerce-page form .form-row-first,.wcf-embed-checkout-form .woocommerce-page form .form-row-last{width:100%}.wcf-embed-checkout-form #order_review_heading,.wcf-embed-checkout-form .woocommerce #ship-to-different-address,.wcf-embed-checkout-form .woocommerce-additional-fields>h3,.wcf-embed-checkout-form .woocommerce-billing-fields>h3{font-size:1em}}#et-info-email:before,#et-info-phone:before,#et_search_icon:before,.comment-reply-link:after,.et-cart-info span:before,.et-pb-arrow-next:before,.et-pb-arrow-prev:before,.et-social-icon a:before,.et_audio_container .mejs-playpause-button button:before,.et_audio_container .mejs-volume-button button:before,.et_overlay:before,.et_password_protected_form .et_submit_button:after,.et_pb_button:after,.et_pb_contact_reset:after,.et_pb_contact_submit:after,.et_pb_font_icon:before,.et_pb_newsletter_button:after,.et_pb_pricing_table_button:after,.et_pb_promo_button:after,.et_pb_social_icon a.icon:before,.et_pb_testimonial:before,.et_pb_toggle_title:before,.form-submit .et_pb_button:after,.mobile_menu_bar:before,.woocommerce #content input.button.alt:after,.woocommerce #content input.button:after,.woocommerce #respond input#submit.alt:after,.woocommerce #respond input#submit:after,.woocommerce a.button.alt:after,.woocommerce button.button.alt:after,.woocommerce button.button:after,.woocommerce button.single_add_to_cart_button.button:after,.woocommerce input.button.alt:after,.woocommerce input.button:after,.woocommerce-page #content input.button.alt:after,.woocommerce-page #content input.button:after,.woocommerce-page #respond input#submit.alt:after,.woocommerce-page #respond input#submit:after,.woocommerce-page a.button.alt:after,.woocommerce-page a.button:after,.woocommerce-page button.button.alt:after,.woocommerce-page button.button:after,.woocommerce-page input.button.alt:after,.woocommerce-page input.button:after,a.et_pb_more_button:after{text-shadow:0 0;font-family:none;font-weight:400;font-style:normal;font-variant:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:1;text-transform:none;speak:none}.comment-reply-link:hover:after,.woocommerce #content input.button.alt:hover:after,.woocommerce #content input.button:hover:after,.woocommerce #respond input#submit.alt:hover:after,.woocommerce #respond input#submit:hover:after,.woocommerce a.button.alt:hover:after,.woocommerce a.button:hover:after,.woocommerce button.button.alt:hover:after,.woocommerce button.button:hover:after,.woocommerce input.button.alt:hover:after,.woocommerce input.button:hover:after,.woocommerce-page #content input.button.alt:hover:after,.woocommerce-page #content input.button:hover:after,.woocommerce-page #respond input#submit.alt:hover:after,.woocommerce-page #respond input#submit:hover:after,.woocommerce-page a.button.alt:hover:after,.woocommerce-page a.button:hover:after,.woocommerce-page button.button.alt:hover:after,.woocommerce-page button.button:hover:after,.woocommerce-page input.button.alt:hover:after,.woocommerce-page input.button:hover:after{opacity:0}.thrv_wrapper .wcf-embed-checkout-form div{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
|
assets/min-css/checkout-template.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.cartflows-container .wcf-embed-checkout-form,.cartflows-container .wcf-embed-checkout-form *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.wcf-embed-checkout-form .wc-backward{display:none!important}.wcf-embed-checkout-form .woocommerce form .form-row-first,.wcf-embed-checkout-form .woocommerce form .form-row-last,.wcf-embed-checkout-form .woocommerce-page form .form-row-first,.wcf-embed-checkout-form .woocommerce-page form .form-row-last{width:50%;display:block}.wcf-embed-checkout-form .woocommerce form .form-row-full,.wcf-embed-checkout-form .woocommerce-page form .form-row-full{width:100%;clear:both}.wcf-embed-checkout-form form .form-row-wide{width:100%}.wcf-embed-checkout-form form .wcf-column-33{width:33.33%}.wcf-embed-checkout-form .woocommerce form .form-row-first,.woocommerce-page form .form-row-first{float:left;clear:left}.wcf-embed-checkout-form .woocommerce form .form-row-last,.woocommerce-page form .form-row-last{float:right;clear:right}.wcf-embed-checkout-form .woocommerce form .form-row .required{color:red;font-weight:700;border:0!important;text-decoration:none}.wcf-embed-checkout-form form .form-row-first.form-row-one{clear:both}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login{display:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row{margin-bottom:15px}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .clear{clear:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row label{margin:0;line-height:1em;padding-top:0;position:relative;top:0}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .login-form-actions{-js-display:flex;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;margin-bottom:0}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .lost_password,.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .remember_me{-webkit-box-flex:1;-webkit-flex:1;-moz-box-flex:1;-ms-flex:1;flex:1;font-family:inherit;font-size:13px}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me label{margin-bottom:0;vertical-align:text-top}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me input,.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me span{vertical-align:middle}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .lost_password{text-align:right;margin-top:0;margin-bottom:0}.wcf-embed-checkout-form .woocommerce .blockUI.blockOverlay{font-size:15px}.wcf-embed-checkout-form .woocommerce form .form-row.mt20{margin-top:20px}.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid .select2-container,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid select{border-width:1px;border-color:#e2401c}.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated .select2-container,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated select{border-width:1px}.wcf-embed-checkout-form .select2-container--default.field-required .select2-selection--single,.wcf-embed-checkout-form .woocommerce #order_review .input-text.field-required,.wcf-embed-checkout-form .woocommerce form .form-row input.input-text.field-required,.wcf-embed-checkout-form .woocommerce form .form-row textarea.input-text.field-required{border-color:#e2401c}.wcf-embed-checkout-form .woocommerce form .form-row input.field-validated{border-left-width:2px;border-left-color:#69bf29}.wcf-embed-checkout-form .wcf-checkout-header-image{text-align:center}.wcf-embed-checkout-form .woocommerce #payment [type=radio]:checked+label,.wcf-embed-checkout-form .woocommerce #payment [type=radio]:not(:checked)+label{padding:0}.wcf-embed-checkout-form .woocommerce #payment input[type=radio]{-webkit-border-radius:50%;border-radius:50%;margin-right:4px;line-height:10px}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:checked:before{content:"\e600";margin:0;color:#f16334}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox],.wcf-embed-checkout-form .woocommerce #payment input[type=radio],.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox],.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox],.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 4px 0 0;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1);-webkit-transition:.05s border-color ease-in-out;transition:.05s border-color ease-in-out}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:focus{border-color:#f16334;-webkit-box-shadow:0 0 2px rgba(241,99,52,.8);box-shadow:0 0 2px rgba(241,99,52,.8)}.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{background-color:#f16334;-webkit-border-radius:50px;border-radius:50px;content:"\2022";font-size:24px;height:6px;line-height:16px;margin:4px;text-indent:-9999px;width:6px}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:before,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:checked:before{display:inline-block;float:left;font:normal 15px/1 cartflows-icon;speak:none;vertical-align:middle;width:6px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li input[type=checkbox]{min-width:16px}.wcf-embed-checkout-form .woocommerce .col2-set .col-1,.wcf-embed-checkout-form .woocommerce .col2-set .col-2,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-2{float:none;width:100%;max-width:100%;padding:0;-webkit-border-radius:0;border-radius:0;border:none;border-color:none;margin-bottom:0}.wcf-embed-checkout-form #order_review_heading,.wcf-embed-checkout-form .woocommerce #ship-to-different-address,.wcf-embed-checkout-form .woocommerce-additional-fields>h3,.wcf-embed-checkout-form .woocommerce-billing-fields>h3{font-family:inherit;font-weight:600;font-size:20px;text-transform:capitalize;margin:0 0 25px 0;padding:0;width:100%}.wcf-embed-checkout-form .woocommerce-checkout #payment{background:unset;-webkit-border-radius:0;border-radius:0}.wcf-embed-checkout-form .woocommerce-checkout #payment .form-row{margin:0;padding:0}.wcf-embed-checkout-form .woocommerce-checkout #payment .form-row label.checkbox{display:block;margin-bottom:1.1em}.wcf-embed-checkout-form .woocommerce-checkout #payment .payment_method_paypal .about_paypal{float:none;margin-left:10px}.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box .form-row{margin:0 0 .5em}.wcf-embed-checkout-form .woocommerce-checkout #payment fieldset .form-row .wcf-embed-checkout-form .woocommerce-checkout #payment fieldset p{margin-bottom:10px}.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{background-color:#eaeaea;font-family:inherit;font-weight:inherit;margin-bottom:.5em}.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before{content:'';display:block;border:1em solid;border-right-color:transparent;border-left-color:transparent;border-top-color:transparent;border-bottom-color:#eaeaea;position:absolute;top:-.75em;left:0;margin:-1em 0 0 2em}.wcf-embed-checkout-form .select2-container--default .select2-selection--single{display:block;width:100%;min-height:34px;height:auto;padding:11px 12px;font-size:14px;line-height:1.42857143!important;color:#555;background-color:#fff;background-image:none;border:1px solid;border-color:#d4d4d4;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;outline:0}.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered{color:#666;line-height:19px;min-height:19px;overflow:visible;padding-left:0}.select2-results__option[data-selected],.wcf-embed-checkout-form .select2-results__option[aria-selected]{font-size:14px}.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__arrow{height:100%}.select2-dropdown{border:1px solid #d4d4d4}.wcf-embed-checkout-form .woocommerce #order_review .input-text,.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row select,.wcf-embed-checkout-form .woocommerce form .form-row textarea{display:block;width:100%;min-height:34px;padding:11px 12px;font-family:inherit;font-weight:inherit;font-size:14px;line-height:1.42857143!important;color:#555;background-color:#fff;background-image:none;border:1px solid;border-color:#d4d4d4;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;height:auto}.wcf-embed-checkout-form #order_review{padding:3px;width:100%}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error,.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-message{padding:0 2em 1.2em 2em;background-color:transparent;border:none;margin:0;width:100%}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error li{list-style:none!important;margin:0}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error::before,.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-message::before{top:0;left:0}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error::before{content:'\e016'}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error li{margin:0 0 0 8px}.wcf-embed-checkout-form .woocommerce #order_review .wcf-custom-coupon-field input[type=text]{font-weight:400}.wcf-embed-checkout-form .wcf-custom-coupon-field{clear:left;-js-display:flex;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;margin-bottom:15px;margin-top:25px;border-top:1px solid #dcdcdc;border-bottom:1px solid #dcdcdc;padding-top:25px;padding-bottom:25px;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.wcf-embed-checkout-form #order_review .wcf-coupon-col-1{width:70%;display:inline-block;padding-right:20px}.wcf-embed-checkout-form #order_review .wcf-coupon-col-2{width:30%}.wcf-embed-checkout-form .select2-container--open,.wcf-embed-checkout-form input[type=email]:focus,.wcf-embed-checkout-form input[type=password]:focus,.wcf-embed-checkout-form input[type=tel]:focus,.wcf-embed-checkout-form input[type=text]:focus,.wcf-embed-checkout-form textarea:focus{border-color:#b3b3b3;-webkit-box-shadow:none;box-shadow:none;outline:0}.wcf-embed-checkout-form button:focus{outline:0;outline-color:none;outline-style:none;outline-width:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,.wcf-embed-checkout-form form.checkout_coupon .button{display:block;clear:both;border:none;font-size:15px;font-family:inherit;font-weight:inherit;background-color:#f16334;line-height:9px;padding:18px;margin-bottom:10px;width:100%;text-transform:uppercase}.wcf-embed-checkout-form .woocommerce #order_review button{border:1px solid;border-color:#f16334;background-color:#f16334;font-family:inherit;font-weight:inherit;font-size:18px;letter-spacing:.5px;width:100%;padding:16px 24px;font-size:16px;line-height:1.5;-webkit-border-radius:3px;border-radius:3px;color:#fff;text-transform:uppercase}.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small{padding:8px 6px;background-color:#c8c8c8;border:1px #c8c8c8 solid}.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{border-color:#f16334;background-color:#f16334}.wcf-embed-checkout-form .woocommerce #payment #place_order:hover{background-color:#f16334;border-color:#f16334;color:#fff}.wcf-embed-checkout-form .woocommerce-checkout{display:inline-block;text-align:inherit;width:100%}.wcf-embed-checkout-form .woocommerce-checkout .col2-set,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set{display:inline-block;width:55%;float:left;padding-right:40px;margin:20px 0 0}.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-billing-fields .woocommerce-billing-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-billing-fields .woocommerce-billing-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper{margin:0 -7px;-ms-flex-wrap:wrap;flex-wrap:wrap;-js-display:flex;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap}.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-additional-fields .woocommerce-additional-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-additional-fields .woocommerce-additional-fields__field-wrapper{margin:0 -7px}.wcf-embed-checkout-form-two-column .woocommerce-checkout .wcf-order-wrap{display:inline-block;float:none;width:45%;border:none;background-color:inherit;padding:0 10px;-webkit-border-radius:3px;border-radius:3px}.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{display:inline-block;font-family:inherit;font-weight:600;width:100%;margin:20px 0 0;padding:3px 3px 20px;border:none;border-bottom:none}.wcf-embed-checkout-form .woocommerce-checkout #payment{background-color:inherit;border:none;-webkit-border-radius:0;border-radius:0}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{padding:1em 0}.wcf-embed-checkout-form #add_payment_method #payment ul.payment_methods,.wcf-embed-checkout-form .woocommerce-cart #payment ul.payment_methods,.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{border:none}.wcf-embed-checkout-form #payment ul.payment_methods li,.wcf-embed-checkout-form #payment ul.payment_methods li:hover{background-color:transparent}.wcf-embed-checkout-form .woocommerce form .form-row{display:block;margin-bottom:1.1em;padding:3px 7px;position:relative}.wcf-embed-checkout-form .woocommerce form .woocommerce-account-fields .form-row{padding:0}.wcf-embed-checkout-form table.shop_table{border:none;border-bottom:0;background-color:inherit;-webkit-border-radius:0;border-radius:0;font-family:inherit;font-weight:inherit;font-size:.95em;margin:0!important;border-collapse:collapse;text-align:left}.wcf-embed-checkout-form table.shop_table td strong.product-quantity{font-weight:400}.wcf-embed-checkout-form table.shop_table #shipping_method{margin:0;padding:0;list-style:none}.wcf-embed-checkout-form table.shop_table #shipping_method .amount{font-weight:400}.wcf-embed-checkout-form table.shop_table th{border:none;font-weight:400;padding:9px 0;line-height:1.2em}.wcf-embed-checkout-form table.shop_table tfoot tr:last-child .woocommerce-Price-amount{font-size:1em}.wcf-embed-checkout-form table.shop_table td,.wcf-embed-checkout-form table.shop_table td dl dd,.wcf-embed-checkout-form table.shop_table td dl dt,.wcf-embed-checkout-form table.shop_table th{background-color:transparent;border:none;padding:.6em 0;line-height:1.4em}.wcf-embed-checkout-form table.shop_table td dl dd p{margin-top:0}.wcf-embed-checkout-form table.shop_table tbody th,.wcf-embed-checkout-form table.shop_table tfoot td,.wcf-embed-checkout-form table.shop_table tfoot th{border:none;display:table-cell;font-weight:400;width:50%}.wcf-embed-checkout-form table.shop_table thead{background-color:transparent}.wcf-embed-checkout-form table.shop_table tbody{border-top:1px dashed #ccc;border-bottom:1px dashed #ccc}.wcf-embed-checkout-form table.shop_table th.product-name,.wcf-embed-checkout-form table.shop_table th.product-total{font-weight:600}.wcf-embed-checkout-form table.shop_table tfoot tr.order-total:not(.recurring-total) td,.wcf-embed-checkout-form table.shop_table tfoot tr.order-total:not(.recurring-total) th{font-weight:600;border-top:1px dashed #ccc}.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-totals th{padding-top:1.8em;font-weight:600}.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-total td,.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-total th,.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-totals th{vertical-align:top}.wcf-embed-checkout-form table.shop_table tbody tr td:nth-child(1),.wcf-embed-checkout-form table.shop_table tfoot tr td:nth-child(1),.wcf-embed-checkout-form table.shop_table thead tr th:nth-child(1){width:70%}.wcf-embed-checkout-form table.shop_table tbody tr td:nth-child(2),.wcf-embed-checkout-form table.shop_table tfoot tr td:nth-child(2),.wcf-embed-checkout-form table.shop_table thead tr th:nth-child(2){width:30%}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row label,.wcf-embed-checkout-form .woocommerce-checkout .form-row label{font-size:13px;line-height:1em;letter-spacing:.3px;font-family:inherit;font-weight:inherit;text-transform:capitalize;margin-bottom:8px}.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields label,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields label{display:inherit}.wcf-embed-checkout-form .woocommerce .woocommerce-terms-and-conditions-wrapper .woocommerce-terms-and-conditions-checkbox-text{line-height:20px;text-transform:initial}.wcf-embed-checkout-form #payment .woocommerce-privacy-policy-text p{font-family:inherit;font-weight:inherit;font-size:11px;color:#777;margin-top:0;text-align:justify}.wcf-embed-checkout-form #payment .wc_payment_methods .payment_box p{margin:0}.wcf-embed-checkout-form .woocommerce a{color:#f16334;background-color:transparent;text-decoration:none}.wcf-embed-checkout-form .woocommerce .woocommerce-NoticeGroup .woocommerce-message,.wcf-embed-checkout-form .woocommerce .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-info,.wcf-embed-checkout-form .woocommerce .woocommerce-message,.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-message{padding:1em 2em .4em 2em;border-top:none;background-color:inherit;font-size:14px;font-weight:500;text-align:left;margin:0}.wcf-embed-checkout-form .woocommerce-info::before,.wcf-embed-checkout-form .woocommerce-message::before{left:.1em;color:#f16334}.wcf-embed-checkout-form .woocommerce .woocommerce-NoticeGroup .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-error{background-color:#fff6f6;border:dashed 1px #a00;padding:25px 25px 20px;color:#a00;margin:1rem 0 1rem;font-size:14px;width:100%}.wcf-embed-checkout-form .woocommerce .woocommerce-error::before{content:''}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li:not(.woocommerce-notice)::before{display:inline}.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-message{margin:1em 0 1em}.wcf-embed-checkout-form .woocommerce .woocommerce-error li{list-style:disc inside!important;margin:0 0 8px}.wcf-embed-checkout-form .woocommerce .woocommerce-error li strong{font-weight:400}.wcf-embed-checkout-form .woocommerce form.checkout_coupon{border:1px solid #d3ced2;padding:30px 20px 20px;margin:2em 0;text-align:left;-webkit-border-radius:5px;border-radius:5px}.wcf-embed-checkout-form .woocommerce .checkout_coupon p{font-size:14px}.wcf-embed-checkout-form .woocommerce .checkout_coupon p{font-family:inherit;font-weight:500;margin-top:0;margin-bottom:10px}@media only screen and (max-width:768px){.wcf-embed-checkout-form form .wcf-column-33{width:100%}.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{width:100%}.wcf-embed-checkout-form .woocommerce-checkout #order_review{width:100%}.wcf-embed-checkout-form .woocommerce-checkout .wcf-order-wrap{width:100%}.wcf-embed-checkout-form .woocommerce-checkout{display:block}.wcf-embed-checkout-form .woocommerce-checkout .col2-set,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set{display:block;width:100%;padding-right:0;margin:20px 0 0}.wcf-embed-checkout-form form.checkout_coupon .button{font-size:12px}.wcf-bump-order-field-wrap .wcf-bump-order-label{font-size:16px;text-transform:capitalize}.wcf-embed-checkout-form .woocommerce .col2-set .col-1,.wcf-embed-checkout-form .woocommerce .col2-set .col-2,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce .wcf-order-wrap,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-order-wrap{padding:15px 18px}.wcf-embed-checkout-form .woocommerce form .form-row-first,.wcf-embed-checkout-form .woocommerce form .form-row-last,.wcf-embed-checkout-form .woocommerce-page form .form-row-first,.wcf-embed-checkout-form .woocommerce-page form .form-row-last{width:100%}.wcf-embed-checkout-form #order_review_heading,.wcf-embed-checkout-form .woocommerce #ship-to-different-address,.wcf-embed-checkout-form .woocommerce-additional-fields>h3,.wcf-embed-checkout-form .woocommerce-billing-fields>h3{font-size:1em}}#et-info-email:before,#et-info-phone:before,#et_search_icon:before,.comment-reply-link:after,.et-cart-info span:before,.et-pb-arrow-next:before,.et-pb-arrow-prev:before,.et-social-icon a:before,.et_audio_container .mejs-playpause-button button:before,.et_audio_container .mejs-volume-button button:before,.et_overlay:before,.et_password_protected_form .et_submit_button:after,.et_pb_button:after,.et_pb_contact_reset:after,.et_pb_contact_submit:after,.et_pb_font_icon:before,.et_pb_newsletter_button:after,.et_pb_pricing_table_button:after,.et_pb_promo_button:after,.et_pb_social_icon a.icon:before,.et_pb_testimonial:before,.et_pb_toggle_title:before,.form-submit .et_pb_button:after,.mobile_menu_bar:before,.woocommerce #content input.button.alt:after,.woocommerce #content input.button:after,.woocommerce #respond input#submit.alt:after,.woocommerce #respond input#submit:after,.woocommerce a.button.alt:after,.woocommerce button.button.alt:after,.woocommerce button.button:after,.woocommerce button.single_add_to_cart_button.button:after,.woocommerce input.button.alt:after,.woocommerce input.button:after,.woocommerce-page #content input.button.alt:after,.woocommerce-page #content input.button:after,.woocommerce-page #respond input#submit.alt:after,.woocommerce-page #respond input#submit:after,.woocommerce-page a.button.alt:after,.woocommerce-page a.button:after,.woocommerce-page button.button.alt:after,.woocommerce-page button.button:after,.woocommerce-page input.button.alt:after,.woocommerce-page input.button:after,a.et_pb_more_button:after{text-shadow:0 0;font-family:none;font-weight:400;font-style:normal;font-variant:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:1;text-transform:none;speak:none}.comment-reply-link:hover:after,.woocommerce #content input.button.alt:hover:after,.woocommerce #content input.button:hover:after,.woocommerce #respond input#submit.alt:hover:after,.woocommerce #respond input#submit:hover:after,.woocommerce a.button.alt:hover:after,.woocommerce a.button:hover:after,.woocommerce button.button.alt:hover:after,.woocommerce button.button:hover:after,.woocommerce input.button.alt:hover:after,.woocommerce input.button:hover:after,.woocommerce-page #content input.button.alt:hover:after,.woocommerce-page #content input.button:hover:after,.woocommerce-page #respond input#submit.alt:hover:after,.woocommerce-page #respond input#submit:hover:after,.woocommerce-page a.button.alt:hover:after,.woocommerce-page a.button:hover:after,.woocommerce-page button.button.alt:hover:after,.woocommerce-page button.button:hover:after,.woocommerce-page input.button.alt:hover:after,.woocommerce-page input.button:hover:after{opacity:0}.thrv_wrapper .wcf-embed-checkout-form div{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
|
1 |
+
.cartflows-container .wcf-embed-checkout-form,.cartflows-container .wcf-embed-checkout-form *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.wcf-embed-checkout-form .wc-backward{display:none!important}.wcf-embed-checkout-form .woocommerce form .form-row-first,.wcf-embed-checkout-form .woocommerce form .form-row-last,.wcf-embed-checkout-form .woocommerce-page form .form-row-first,.wcf-embed-checkout-form .woocommerce-page form .form-row-last{width:50%;display:block}.wcf-embed-checkout-form .woocommerce form .form-row-full,.wcf-embed-checkout-form .woocommerce-page form .form-row-full{width:100%;clear:both}.wcf-embed-checkout-form form .form-row-wide{width:100%}.wcf-embed-checkout-form form .wcf-column-33{width:33.33%}.wcf-embed-checkout-form .woocommerce form .form-row-first,.woocommerce-page form .form-row-first{float:left;clear:left}.wcf-embed-checkout-form .woocommerce form .form-row-last,.woocommerce-page form .form-row-last{float:right;clear:right}.wcf-embed-checkout-form .woocommerce form .form-row .required{color:red;font-weight:700;border:0!important;text-decoration:none}.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove{font-family:cartflows-icon;display:inline-block;font-size:10px;border:1px #4d5763 solid;-webkit-border-radius:50%;border-radius:50%;padding:1px;color:#4d5763!important;line-height:1;margin-right:5px;text-align:center;font-weight:100;width:14px;height:14px;background-color:#fff}.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{color:#f1653c!important;border:1px #f1653c solid;background-color:#fff}.wcf-embed-checkout-form form .form-row-first.form-row-one{clear:both}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login{display:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row{margin-bottom:15px}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .clear{clear:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row label{margin:0;line-height:1em;padding-top:0;position:relative;top:0}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .login-form-actions{-js-display:flex;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;margin-bottom:0}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .lost_password,.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .remember_me{-webkit-box-flex:1;-webkit-flex:1;-moz-box-flex:1;-ms-flex:1;flex:1;font-family:inherit;font-size:13px}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me label{margin-bottom:0;vertical-align:text-top}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me input,.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row .remember_me span{vertical-align:middle}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .lost_password{text-align:right;margin-top:0;margin-bottom:0}.wcf-embed-checkout-form .woocommerce .blockUI.blockOverlay{font-size:15px}.wcf-embed-checkout-form .woocommerce form .form-row.mt20{margin-top:20px}.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid .select2-container,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-invalid select{border-width:1px;border-color:#e2401c}.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated .select2-container,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row.woocommerce-validated select{border-width:1px}.wcf-embed-checkout-form .select2-container--default.field-required .select2-selection--single,.wcf-embed-checkout-form .woocommerce #order_review .input-text.field-required,.wcf-embed-checkout-form .woocommerce form .form-row input.input-text.field-required,.wcf-embed-checkout-form .woocommerce form .form-row textarea.input-text.field-required{border-color:#e2401c}.wcf-embed-checkout-form .woocommerce form .form-row input.field-validated{border-left-width:2px;border-left-color:#69bf29}.wcf-embed-checkout-form .wcf-checkout-header-image{text-align:center}.wcf-embed-checkout-form .woocommerce #payment [type=radio]:checked+label,.wcf-embed-checkout-form .woocommerce #payment [type=radio]:not(:checked)+label{padding:0}.wcf-embed-checkout-form .woocommerce #payment input[type=radio]{-webkit-border-radius:50%;border-radius:50%;margin-right:4px;line-height:10px}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:checked:before{content:"\e600";margin:0;color:#f16334}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox],.wcf-embed-checkout-form .woocommerce #payment input[type=radio],.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox],.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox],.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]{border:1px solid #b4b9be;background:#fff;color:#555;clear:none;cursor:pointer;display:inline-block;line-height:0;height:16px;margin:-4px 4px 0 0;outline:0;padding:0!important;text-align:center;vertical-align:middle;width:16px;min-width:16px;-webkit-appearance:none;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1);-webkit-transition:.05s border-color ease-in-out;transition:.05s border-color ease-in-out}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:focus,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:focus{border-color:#f16334;-webkit-box-shadow:0 0 2px rgba(241,99,52,.8);box-shadow:0 0 2px rgba(241,99,52,.8)}.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{background-color:#f16334;-webkit-border-radius:50px;border-radius:50px;content:"\2022";font-size:24px;height:6px;line-height:16px;margin:4px;text-indent:-9999px;width:6px}.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-account-fields input[type=checkbox]:before,.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields [type=checkbox]:checked:before,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type=checkbox]:checked:before{display:inline-block;float:left;font:normal 15px/1 cartflows-icon;speak:none;vertical-align:middle;width:6px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li input[type=checkbox]{min-width:16px}.wcf-embed-checkout-form .woocommerce .col2-set .col-1,.wcf-embed-checkout-form .woocommerce .col2-set .col-2,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-2{float:none;width:100%;max-width:100%;padding:0;-webkit-border-radius:0;border-radius:0;border:none;border-color:none;margin-bottom:0}.wcf-embed-checkout-form #order_review_heading,.wcf-embed-checkout-form .woocommerce #ship-to-different-address,.wcf-embed-checkout-form .woocommerce-additional-fields>h3,.wcf-embed-checkout-form .woocommerce-billing-fields>h3{font-family:inherit;font-weight:600;font-size:20px;text-transform:capitalize;margin:0 0 25px 0;padding:0;width:100%}.wcf-embed-checkout-form .woocommerce-checkout #payment{background:unset;-webkit-border-radius:0;border-radius:0}.wcf-embed-checkout-form .woocommerce-checkout #payment .form-row{margin:0;padding:0}.wcf-embed-checkout-form .woocommerce-checkout #payment .form-row label.checkbox{display:block;margin-bottom:1.1em}.wcf-embed-checkout-form .woocommerce-checkout #payment .payment_method_paypal .about_paypal{float:none;margin-left:10px}.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box .form-row{margin:0 0 .5em}.wcf-embed-checkout-form .woocommerce-checkout #payment fieldset .form-row .wcf-embed-checkout-form .woocommerce-checkout #payment fieldset p{margin-bottom:10px}.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{background-color:#eaeaea;font-family:inherit;font-weight:inherit;margin-bottom:.5em}.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before{content:'';display:block;border:1em solid;border-right-color:transparent;border-left-color:transparent;border-top-color:transparent;border-bottom-color:#eaeaea;position:absolute;top:-.75em;left:0;margin:-1em 0 0 2em}.wcf-embed-checkout-form .select2-container--default .select2-selection--single{display:block;width:100%;min-height:34px;height:auto;padding:11px 12px;font-size:14px;line-height:1.42857143!important;color:#555;background-color:#fff;background-image:none;border:1px solid;border-color:#d4d4d4;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;outline:0}.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered{color:#666;line-height:19px;min-height:19px;overflow:visible;padding-left:0}.select2-results__option[data-selected],.wcf-embed-checkout-form .select2-results__option[aria-selected]{font-size:14px}.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__arrow{height:100%}.select2-dropdown{border:1px solid #d4d4d4}.wcf-embed-checkout-form .woocommerce #order_review .input-text,.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,.wcf-embed-checkout-form .woocommerce form .form-row select,.wcf-embed-checkout-form .woocommerce form .form-row textarea{display:block;width:100%;min-height:34px;padding:11px 12px;font-family:inherit;font-weight:inherit;font-size:14px;line-height:1.42857143!important;color:#555;background-color:#fff;background-image:none;border:1px solid;border-color:#d4d4d4;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;height:auto}.wcf-embed-checkout-form #order_review{padding:3px;width:100%}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error,.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-message{padding:0 2em 1.2em 2em;background-color:transparent;border:none;margin:0;width:100%}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error li{list-style:none!important;margin:0}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error::before,.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-message::before{top:0;left:0}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error::before{content:'\e016'}.wcf-embed-checkout-form .woocommerce .wcf-custom-coupon-field .woocommerce-error li{margin:0 0 0 8px}.wcf-embed-checkout-form .woocommerce #order_review .wcf-custom-coupon-field input[type=text]{font-weight:400}.wcf-embed-checkout-form .wcf-custom-coupon-field{clear:left;-js-display:flex;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;margin-bottom:15px;margin-top:25px;border-top:1px solid #dcdcdc;border-bottom:1px solid #dcdcdc;padding-top:25px;padding-bottom:25px;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.wcf-embed-checkout-form #order_review .wcf-coupon-col-1{width:70%;display:inline-block;padding-right:20px}.wcf-embed-checkout-form #order_review .wcf-coupon-col-2{width:30%}.wcf-embed-checkout-form .select2-container--open,.wcf-embed-checkout-form input[type=email]:focus,.wcf-embed-checkout-form input[type=password]:focus,.wcf-embed-checkout-form input[type=tel]:focus,.wcf-embed-checkout-form input[type=text]:focus,.wcf-embed-checkout-form textarea:focus{border-color:#b3b3b3;-webkit-box-shadow:none;box-shadow:none;outline:0}.wcf-embed-checkout-form button:focus{outline:0;outline-color:none;outline-style:none;outline-width:none}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,.wcf-embed-checkout-form form.checkout_coupon .button{display:block;clear:both;border:none;font-size:15px;font-family:inherit;font-weight:inherit;background-color:#f16334;line-height:9px;padding:18px;margin-bottom:10px;width:100%;text-transform:uppercase}.wcf-embed-checkout-form .woocommerce #order_review button{border:1px solid;border-color:#f16334;background-color:#f16334;font-family:inherit;font-weight:inherit;font-size:18px;letter-spacing:.5px;width:100%;padding:16px 24px;font-size:16px;line-height:1.5;-webkit-border-radius:3px;border-radius:3px;color:#fff;text-transform:uppercase}.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small{padding:8px 6px;background-color:#c8c8c8;border:1px #c8c8c8 solid}.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{border-color:#f16334;background-color:#f16334}.wcf-embed-checkout-form .woocommerce #payment #place_order:hover{background-color:#f16334;border-color:#f16334;color:#fff}.wcf-embed-checkout-form .woocommerce-checkout{display:inline-block;text-align:inherit;width:100%}.wcf-embed-checkout-form .woocommerce-checkout .col2-set,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set{display:inline-block;width:55%;float:left;padding-right:40px;margin:20px 0 0}.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-billing-fields .woocommerce-billing-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-billing-fields .woocommerce-billing-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-shipping-fields .woocommerce-shipping-fields__field-wrapper{margin:0 -7px;-ms-flex-wrap:wrap;flex-wrap:wrap;-js-display:flex;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:flex;display:-webkit-flex;flex-wrap:wrap;-webkit-flex-wrap:wrap}.wcf-embed-checkout-form .woocommerce-checkout .col2-set .woocommerce-additional-fields .woocommerce-additional-fields__field-wrapper,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set .woocommerce-additional-fields .woocommerce-additional-fields__field-wrapper{margin:0 -7px}.wcf-embed-checkout-form-two-column .woocommerce-checkout .wcf-order-wrap{display:inline-block;float:none;width:45%;border:none;background-color:inherit;padding:0 10px;-webkit-border-radius:3px;border-radius:3px}.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{display:inline-block;font-family:inherit;font-weight:600;width:100%;margin:20px 0 0;padding:3px 3px 20px;border:none;border-bottom:none}.wcf-embed-checkout-form .woocommerce-checkout #payment{background-color:inherit;border:none;-webkit-border-radius:0;border-radius:0}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{padding:1em 0}.wcf-embed-checkout-form #add_payment_method #payment ul.payment_methods,.wcf-embed-checkout-form .woocommerce-cart #payment ul.payment_methods,.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods{border:none}.wcf-embed-checkout-form #payment ul.payment_methods li,.wcf-embed-checkout-form #payment ul.payment_methods li:hover{background-color:transparent}.wcf-embed-checkout-form .woocommerce form .form-row{display:block;margin-bottom:1.1em;padding:3px 7px;position:relative}.wcf-embed-checkout-form .woocommerce form .woocommerce-account-fields .form-row{padding:0}.wcf-embed-checkout-form table.shop_table{border:none;border-bottom:0;background-color:inherit;-webkit-border-radius:0;border-radius:0;font-family:inherit;font-weight:inherit;font-size:.95em;margin:0!important;border-collapse:collapse;text-align:left}.wcf-embed-checkout-form table.shop_table td strong.product-quantity{font-weight:400}.wcf-embed-checkout-form table.shop_table #shipping_method{margin:0;padding:0;list-style:none}.wcf-embed-checkout-form table.shop_table #shipping_method .amount{font-weight:400}.wcf-embed-checkout-form table.shop_table th{border:none;font-weight:400;padding:9px 0;line-height:1.2em}.wcf-embed-checkout-form table.shop_table tfoot tr:last-child .woocommerce-Price-amount{font-size:1em}.wcf-embed-checkout-form table.shop_table td,.wcf-embed-checkout-form table.shop_table td dl dd,.wcf-embed-checkout-form table.shop_table td dl dt,.wcf-embed-checkout-form table.shop_table th{background-color:transparent;border:none;padding:.6em 0;line-height:1.4em}.wcf-embed-checkout-form table.shop_table td dl dd p{margin-top:0}.wcf-embed-checkout-form table.shop_table tbody th,.wcf-embed-checkout-form table.shop_table tfoot td,.wcf-embed-checkout-form table.shop_table tfoot th{border:none;display:table-cell;font-weight:400;width:50%}.wcf-embed-checkout-form table.shop_table thead{background-color:transparent}.wcf-embed-checkout-form table.shop_table tbody{border-top:1px dashed #ccc;border-bottom:1px dashed #ccc}.wcf-embed-checkout-form table.shop_table th.product-name,.wcf-embed-checkout-form table.shop_table th.product-total{font-weight:600}.wcf-embed-checkout-form table.shop_table tfoot tr.order-total:not(.recurring-total) td,.wcf-embed-checkout-form table.shop_table tfoot tr.order-total:not(.recurring-total) th{font-weight:600;border-top:1px dashed #ccc}.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-totals th{padding-top:1.8em;font-weight:600}.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-total td,.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-total th,.wcf-embed-checkout-form table.shop_table tfoot tr.recurring-totals th{vertical-align:top}.wcf-embed-checkout-form table.shop_table tbody tr td:nth-child(1),.wcf-embed-checkout-form table.shop_table tfoot tr td:nth-child(1),.wcf-embed-checkout-form table.shop_table thead tr th:nth-child(1){width:70%}.wcf-embed-checkout-form table.shop_table tbody tr td:nth-child(2),.wcf-embed-checkout-form table.shop_table tfoot tr td:nth-child(2),.wcf-embed-checkout-form table.shop_table thead tr th:nth-child(2){width:30%}.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row label,.wcf-embed-checkout-form .woocommerce-checkout .form-row label{font-size:13px;line-height:1em;letter-spacing:.3px;font-family:inherit;font-weight:inherit;text-transform:capitalize;margin-bottom:8px}.wcf-embed-checkout-form .woocommerce .woocommerce-billing-fields label,.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields label{display:inherit}.wcf-embed-checkout-form .woocommerce .woocommerce-terms-and-conditions-wrapper .woocommerce-terms-and-conditions-checkbox-text{line-height:20px;text-transform:initial}.wcf-embed-checkout-form #payment .woocommerce-privacy-policy-text p{font-family:inherit;font-weight:inherit;font-size:11px;color:#777;margin-top:0;text-align:justify}.wcf-embed-checkout-form #payment .wc_payment_methods .payment_box p{margin:0}.wcf-embed-checkout-form .woocommerce a{color:#f16334;background-color:transparent;text-decoration:none}.wcf-embed-checkout-form .woocommerce .woocommerce-NoticeGroup .woocommerce-message,.wcf-embed-checkout-form .woocommerce .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-info,.wcf-embed-checkout-form .woocommerce .woocommerce-message,.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-message{padding:1em 2em .4em 2em;border-top:none;background-color:inherit;font-size:14px;font-weight:500;text-align:left;margin:0}.wcf-embed-checkout-form .woocommerce-info::before,.wcf-embed-checkout-form .woocommerce-message::before{left:.1em;color:#f16334}.wcf-embed-checkout-form .woocommerce .woocommerce-NoticeGroup .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-error,.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-error{background-color:#fff6f6;border:dashed 1px #a00;padding:25px 25px 20px;color:#a00;margin:1rem 0 1rem;font-size:14px;width:100%}.wcf-embed-checkout-form .woocommerce .woocommerce-error::before{content:''}.wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li:not(.woocommerce-notice)::before{display:inline}.wcf-embed-checkout-form .woocommerce .woocommerce-notices-wrapper .woocommerce-message{margin:1em 0 1em}.wcf-embed-checkout-form .woocommerce .woocommerce-error li{list-style:disc inside!important;margin:0 0 8px}.wcf-embed-checkout-form .woocommerce .woocommerce-error li strong{font-weight:400}.wcf-embed-checkout-form .woocommerce form.checkout_coupon{border:1px solid #d3ced2;padding:30px 20px 20px;margin:2em 0;text-align:left;-webkit-border-radius:5px;border-radius:5px}.wcf-embed-checkout-form .woocommerce .checkout_coupon p{font-size:14px}.wcf-embed-checkout-form .woocommerce .checkout_coupon p{font-family:inherit;font-weight:500;margin-top:0;margin-bottom:10px}@media only screen and (max-width:768px){.wcf-embed-checkout-form form .wcf-column-33{width:100%}.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{width:100%}.wcf-embed-checkout-form .woocommerce-checkout #order_review{width:100%}.wcf-embed-checkout-form .woocommerce-checkout .wcf-order-wrap{width:100%}.wcf-embed-checkout-form .woocommerce-checkout{display:block}.wcf-embed-checkout-form .woocommerce-checkout .col2-set,.wcf-embed-checkout-form .woocommerce-checkout .wcf-col2-set{display:block;width:100%;padding-right:0;margin:20px 0 0}.wcf-embed-checkout-form form.checkout_coupon .button{font-size:12px}.wcf-bump-order-field-wrap .wcf-bump-order-label{font-size:16px;text-transform:capitalize}.wcf-embed-checkout-form .woocommerce .col2-set .col-1,.wcf-embed-checkout-form .woocommerce .col2-set .col-2,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce .wcf-order-wrap,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,.wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-1,.wcf-embed-checkout-form .woocommerce-page .wcf-col2-set .wcf-col-2,.wcf-embed-checkout-form .woocommerce-page .wcf-order-wrap{padding:15px 18px}.wcf-embed-checkout-form .woocommerce form .form-row-first,.wcf-embed-checkout-form .woocommerce form .form-row-last,.wcf-embed-checkout-form .woocommerce-page form .form-row-first,.wcf-embed-checkout-form .woocommerce-page form .form-row-last{width:100%}.wcf-embed-checkout-form #order_review_heading,.wcf-embed-checkout-form .woocommerce #ship-to-different-address,.wcf-embed-checkout-form .woocommerce-additional-fields>h3,.wcf-embed-checkout-form .woocommerce-billing-fields>h3{font-size:1em}}#et-info-email:before,#et-info-phone:before,#et_search_icon:before,.comment-reply-link:after,.et-cart-info span:before,.et-pb-arrow-next:before,.et-pb-arrow-prev:before,.et-social-icon a:before,.et_audio_container .mejs-playpause-button button:before,.et_audio_container .mejs-volume-button button:before,.et_overlay:before,.et_password_protected_form .et_submit_button:after,.et_pb_button:after,.et_pb_contact_reset:after,.et_pb_contact_submit:after,.et_pb_font_icon:before,.et_pb_newsletter_button:after,.et_pb_pricing_table_button:after,.et_pb_promo_button:after,.et_pb_social_icon a.icon:before,.et_pb_testimonial:before,.et_pb_toggle_title:before,.form-submit .et_pb_button:after,.mobile_menu_bar:before,.woocommerce #content input.button.alt:after,.woocommerce #content input.button:after,.woocommerce #respond input#submit.alt:after,.woocommerce #respond input#submit:after,.woocommerce a.button.alt:after,.woocommerce button.button.alt:after,.woocommerce button.button:after,.woocommerce button.single_add_to_cart_button.button:after,.woocommerce input.button.alt:after,.woocommerce input.button:after,.woocommerce-page #content input.button.alt:after,.woocommerce-page #content input.button:after,.woocommerce-page #respond input#submit.alt:after,.woocommerce-page #respond input#submit:after,.woocommerce-page a.button.alt:after,.woocommerce-page a.button:after,.woocommerce-page button.button.alt:after,.woocommerce-page button.button:after,.woocommerce-page input.button.alt:after,.woocommerce-page input.button:after,a.et_pb_more_button:after{text-shadow:0 0;font-family:none;font-weight:400;font-style:normal;font-variant:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:1;text-transform:none;speak:none}.comment-reply-link:hover:after,.woocommerce #content input.button.alt:hover:after,.woocommerce #content input.button:hover:after,.woocommerce #respond input#submit.alt:hover:after,.woocommerce #respond input#submit:hover:after,.woocommerce a.button.alt:hover:after,.woocommerce a.button:hover:after,.woocommerce button.button.alt:hover:after,.woocommerce button.button:hover:after,.woocommerce input.button.alt:hover:after,.woocommerce input.button:hover:after,.woocommerce-page #content input.button.alt:hover:after,.woocommerce-page #content input.button:hover:after,.woocommerce-page #respond input#submit.alt:hover:after,.woocommerce-page #respond input#submit:hover:after,.woocommerce-page a.button.alt:hover:after,.woocommerce-page a.button:hover:after,.woocommerce-page button.button.alt:hover:after,.woocommerce-page button.button:hover:after,.woocommerce-page input.button.alt:hover:after,.woocommerce-page input.button:hover:after{opacity:0}.thrv_wrapper .wcf-embed-checkout-form div{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
|
assets/min-js/checkout-template.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(a){function o(){function r(e,o,c,t){""==e||"select"==t&&" "==e?o.hasClass("validate-required")&&c.addClass("field-required"):c.removeClass("field-required")}var e=a("form.woocommerce-checkout #customer_details"),o=e.find("input, textarea"),c=e.find("select");o.blur(function(){var e=a(this),o=e.attr("type"),c=e.closest("p.form-row"),t=e.val();r(t,c,e,o)}),c.blur(function(){var e=a(this).closest("p.form-row"),o=e.find(".select2-container--default"),c=e.find("select").val();r(c,e,o,"select")})}function c(){if("yes"==cartflows.allow_persistance&&!1!==function(){var e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}()){var e="form.woocommerce-checkout #customer_details",o=function(){var e=[],o=a("form.woocommerce-checkout #customer_details");localStorage.removeItem("cartflows_checkout_form"),o.find("input[type=text], select, input[type=email], input[type=tel]").each(function(){e.push({name:this.name,value:this.value})}),cartflows_checkout_form=JSON.stringify(e),localStorage.setItem("cartflows_checkout_form",cartflows_checkout_form)};(function(){if(null!=localStorage.getItem("cartflows_checkout_form")){checkout_data=JSON.parse(localStorage.getItem("cartflows_checkout_form"));for(var e=0;e<checkout_data.length;e++)a("form.woocommerce-checkout [name="+checkout_data[e].name+"]").val(checkout_data[e].value)}})(),a(e+" input, "+e+" select").change(function(){o()})}}a(window).load(function(){a("body").trigger("update_checkout")});var t={init:function(){a(document.body).on("click",".wcf-submit-coupon",this.submit_coupon),a(document.body).on("click",".wcf-remove-coupon",this.remove_coupon)},submit_coupon:function(e){e.preventDefault();var o=a(".wcf-custom-coupon-field").find(".wcf-coupon-code-input"),c=o.val();if(""==c)return o.addClass("field-required"),!1;o.removeClass("field-required");var t={coupon_code:c,action:"wcf_woo_apply_coupon",security:cartflows.wcf_validate_coupon_nonce};a.ajax({type:"POST",url:cartflows.ajax_url,data:t,success:function(e){var o=a(".wcf-custom-coupon-field");o.find(".woocommerce-error, .woocommerce-message").remove();var c=JSON.parse(e);1==c.status&&a(document.body).trigger("update_checkout",{update_shipping_method:!1}),o.prepend(c.msg)}})},remove_coupon:function(e){e.preventDefault();var o={coupon_code:a(this).attr("data-coupon"),action:"wcf_woo_remove_coupon",security:cartflows.wcf_validate_remove_coupon_nonce};a.ajax({type:"POST",url:cartflows.ajax_url,data:o,success:function(e){var o=a(".wcf-custom-coupon-field");o.find(".woocommerce-error, .woocommerce-message").hide(),e&&(a(document.body).trigger("update_checkout",{update_shipping_method:!1}),o.prepend(e))}})}};a(document).ready(function(e){c(),o(),function(){a(".cartflows-container").find(".wcf-embed-checkout-form-two-column");var e=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_address_1_field"),o=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_address_2_field");e.hasClass("form-row-wide")&&(e.removeClass("form-row-wide"),e.addClass("form-row-first")),o.hasClass("form-row-wide")&&(o.removeClass("form-row-wide"),o.addClass("form-row-last"),o.find("label").hasClass("screen-reader-text")?o.addClass("mt20"):o.removeClass("mt20"));var c=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_address_1_field"),t=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_address_2_field");c.hasClass("form-row-wide")&&(c.removeClass("form-row-wide"),c.addClass("form-row-first")),t.hasClass("form-row-wide")&&(t.removeClass("form-row-wide"),t.addClass("form-row-last"),t.find("label").hasClass("screen-reader-text")?t.addClass("mt20"):t.removeClass("mt20")),a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_country").on("change",function(e){}),a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_country").on("change",function(e){})}(),t.init()})}(jQuery);
|
1 |
+
!function(a){function o(){function r(e,o,c,t){""==e||"select"==t&&" "==e?o.hasClass("validate-required")&&c.addClass("field-required"):c.removeClass("field-required")}var e=a("form.woocommerce-checkout #customer_details"),o=e.find("input, textarea"),c=e.find("select");o.blur(function(){var e=a(this),o=e.attr("type"),c=e.closest("p.form-row"),t=e.val();r(t,c,e,o)}),c.blur(function(){var e=a(this).closest("p.form-row"),o=e.find(".select2-container--default"),c=e.find("select").val();r(c,e,o,"select")})}function c(){if("yes"==cartflows.allow_persistance&&!1!==function(){var e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}()){var e="form.woocommerce-checkout #customer_details",o=function(){var e=[],o=a("form.woocommerce-checkout #customer_details");localStorage.removeItem("cartflows_checkout_form"),o.find("input[type=text], select, input[type=email], input[type=tel]").each(function(){e.push({name:this.name,value:this.value})}),cartflows_checkout_form=JSON.stringify(e),localStorage.setItem("cartflows_checkout_form",cartflows_checkout_form)};(function(){if(null!=localStorage.getItem("cartflows_checkout_form")){checkout_data=JSON.parse(localStorage.getItem("cartflows_checkout_form"));for(var e=0;e<checkout_data.length;e++)a("form.woocommerce-checkout [name="+checkout_data[e].name+"]").hasClass("select2-hidden-accessible")?a("form.woocommerce-checkout [name="+checkout_data[e].name+"]").selectWoo("val",[checkout_data[e].value]):a("form.woocommerce-checkout [name="+checkout_data[e].name+"]").val(checkout_data[e].value)}})(),a(e+" input, "+e+" select").change(function(){o()})}}a(window).load(function(){a("body").trigger("update_checkout")});var t={init:function(){a(document.body).on("click",".wcf-submit-coupon",this.submit_coupon),a(document.body).on("click",".wcf-remove-coupon",this.remove_coupon)},submit_coupon:function(e){e.preventDefault();var o=a(".wcf-custom-coupon-field").find(".wcf-coupon-code-input"),c=o.val();if(""==c)return o.addClass("field-required"),!1;o.removeClass("field-required");var t={coupon_code:c,action:"wcf_woo_apply_coupon",security:cartflows.wcf_validate_coupon_nonce};a.ajax({type:"POST",url:cartflows.ajax_url,data:t,success:function(e){var o=a(".wcf-custom-coupon-field");o.find(".woocommerce-error, .woocommerce-message").remove();var c=JSON.parse(e);1==c.status&&a(document.body).trigger("update_checkout",{update_shipping_method:!1}),o.prepend(c.msg)}})},remove_coupon:function(e){e.preventDefault();var o={coupon_code:a(this).attr("data-coupon"),action:"wcf_woo_remove_coupon",security:cartflows.wcf_validate_remove_coupon_nonce};a.ajax({type:"POST",url:cartflows.ajax_url,data:o,success:function(e){var o=a(".wcf-custom-coupon-field");o.find(".woocommerce-error, .woocommerce-message").hide(),e&&(a(document.body).trigger("update_checkout",{update_shipping_method:!1}),o.prepend(e))}})}};a(document).ready(function(e){c(),o(),function(){a(".cartflows-container").find(".wcf-embed-checkout-form-two-column");var e=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_address_1_field"),o=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_address_2_field");e.hasClass("form-row-wide")&&(e.removeClass("form-row-wide"),e.addClass("form-row-first")),o.hasClass("form-row-wide")&&(o.removeClass("form-row-wide"),o.addClass("form-row-last"),o.find("label").hasClass("screen-reader-text")?o.addClass("mt20"):o.removeClass("mt20"));var c=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_address_1_field"),t=a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_address_2_field");c.hasClass("form-row-wide")&&(c.removeClass("form-row-wide"),c.addClass("form-row-first")),t.hasClass("form-row-wide")&&(t.removeClass("form-row-wide"),t.addClass("form-row-last"),t.find("label").hasClass("screen-reader-text")?t.addClass("mt20"):t.removeClass("mt20")),a(".wcf-embed-checkout-form .woocommerce-checkout").find("#billing_country").on("change",function(e){}),a(".wcf-embed-checkout-form .woocommerce-checkout").find("#shipping_country").on("change",function(e){})}(),a(document.body).on("click","#wcf-embed-checkout-form .remove",function(e){e.preventDefault();var c=a(this).attr("data-id"),o={p_key:a(this).attr("data-item-key"),p_id:c,action:"wcf_woo_remove_cart_product",security:cartflows.wcf_validate_remove_cart_product_nonce};a.ajax({type:"POST",url:cartflows.ajax_url,data:o,success:function(e){var o=JSON.parse(e);0==o.need_shipping&&a("#wcf-embed-checkout-form").find("#ship-to-different-address-checkbox").attr("checked",!1),a("#wcf-embed-checkout-form").find(".woocommerce-notices-wrapper").first().html(o.msg),a(document).trigger("cartflows_remove_product",[c]),a("#wcf-embed-checkout-form").trigger("update_checkout")}})}),t.init()})}(jQuery);
|
cartflows.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: CartFlows
|
4 |
* Plugin URI: https://cartflows.com/
|
5 |
* Description: Create beautiful checkout pages & sales flows for WooCommerce.
|
6 |
-
* Version: 1.3.
|
7 |
* Author: CartFlows Inc
|
8 |
* Author URI: https://cartflows.com/
|
9 |
* Text Domain: cartflows
|
3 |
* Plugin Name: CartFlows
|
4 |
* Plugin URI: https://cartflows.com/
|
5 |
* Description: Create beautiful checkout pages & sales flows for WooCommerce.
|
6 |
+
* Version: 1.3.2
|
7 |
* Author: CartFlows Inc
|
8 |
* Author URI: https://cartflows.com/
|
9 |
* Text Domain: cartflows
|
changelog.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
Version 1.3.1 - Wednesday, 6th November 2019
|
2 |
- Improvement: Added compatibility for a future release of CartFlows Pro.
|
3 |
- Fix: Security issue fix & added user capability check.
|
1 |
+
Version 1.3.2 - Wednesday, 11th December 2019
|
2 |
+
- New: Option added to remove products on the checkout page.
|
3 |
+
- Fix: Checkout page's login form text was not able to translate.
|
4 |
+
- Fix: 2Checkout & PayPlus payment gateway's compatibility issue with global checkout.
|
5 |
+
|
6 |
Version 1.3.1 - Wednesday, 6th November 2019
|
7 |
- Improvement: Added compatibility for a future release of CartFlows Pro.
|
8 |
- Fix: Security issue fix & added user capability check.
|
classes/batch-process/class-cartflows-batch-process.php
CHANGED
@@ -1,270 +1,270 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Batch Processing
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows_Batch_Process
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class CartFlows_Batch_Process {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @since 1.0.0
|
22 |
-
* @var object Class object.
|
23 |
-
* @access private
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Elementor Batch Instance
|
29 |
-
*
|
30 |
-
* @since 1.1.1 Updated instance name with elementor specific.
|
31 |
-
*
|
32 |
-
* @since 1.0.0
|
33 |
-
* @var object Class object.
|
34 |
-
* @access public
|
35 |
-
*/
|
36 |
-
public static $batch_instance_elementor;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Beaver Builder Batch Instance
|
40 |
-
*
|
41 |
-
* @since 1.1.1
|
42 |
-
* @var object Class object.
|
43 |
-
* @access public
|
44 |
-
*/
|
45 |
-
public static $batch_instance_bb;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Divi Batch Instance
|
49 |
-
*
|
50 |
-
* @since 1.1.1
|
51 |
-
* @var object Class object.
|
52 |
-
* @access public
|
53 |
-
*/
|
54 |
-
public static $batch_instance_divi;
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Initiator
|
58 |
-
*
|
59 |
-
* @since 1.0.0
|
60 |
-
* @return object initialized object of class.
|
61 |
-
*/
|
62 |
-
public static function get_instance() {
|
63 |
-
if ( ! isset( self::$instance ) ) {
|
64 |
-
self::$instance = new self();
|
65 |
-
}
|
66 |
-
return self::$instance;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Constructor
|
71 |
-
*
|
72 |
-
* @since 1.0.0
|
73 |
-
*/
|
74 |
-
public function __construct() {
|
75 |
-
|
76 |
-
// Not BB or Elementor then avoid importer.
|
77 |
-
// if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
|
78 |
-
// return;
|
79 |
-
// }
|
80 |
-
// Core Helpers - Image.
|
81 |
-
require_once ABSPATH . 'wp-admin/includes/image.php';
|
82 |
-
|
83 |
-
// Core Helpers - Batch Processing.
|
84 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-cartflows-importer-image.php';
|
85 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
|
86 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';
|
87 |
-
|
88 |
-
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
89 |
-
|
90 |
-
// Elementor.
|
91 |
-
if ( ( 'elementor' === $default_page_builder ) && class_exists( '\Elementor\Plugin' ) ) {
|
92 |
-
// Add "elementor" in import [queue].
|
93 |
-
// @todo Remove required `allow_url_fopen` support.
|
94 |
-
if ( ini_get( 'allow_url_fopen' ) ) {
|
95 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
|
96 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor-batch.php';
|
97 |
-
self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
// Beaver Builder.
|
102 |
-
if ( ( 'beaver-builder' === $default_page_builder ) && class_exists( 'FLBuilder' ) ) {
|
103 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder.php';
|
104 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder-batch.php';
|
105 |
-
self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
|
106 |
-
}
|
107 |
-
|
108 |
-
// Divi.
|
109 |
-
if ( ( 'divi' === $default_page_builder ) && ( class_exists( 'ET_Builder_Plugin' ) || Cartflows_Compatibility::get_instance()->is_divi_enabled() ) ) {
|
110 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi.php';
|
111 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi-batch.php';
|
112 |
-
self::$batch_instance_divi = new Cartflows_Importer_Divi_Batch();
|
113 |
-
}
|
114 |
-
|
115 |
-
// Start image importing after site import complete.
|
116 |
-
add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
|
117 |
-
add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
|
118 |
-
add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
|
119 |
-
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Added .svg files as supported format in the uploader.
|
124 |
-
*
|
125 |
-
* @since 1.1.4
|
126 |
-
*
|
127 |
-
* @param array $mimes Already supported mime types.
|
128 |
-
*/
|
129 |
-
public function custom_upload_mimes( $mimes ) {
|
130 |
-
|
131 |
-
// Allow SVG files.
|
132 |
-
$mimes['svg'] = 'image/svg+xml';
|
133 |
-
$mimes['svgz'] = 'image/svg+xml';
|
134 |
-
|
135 |
-
// Allow XML files.
|
136 |
-
$mimes['xml'] = 'text/xml';
|
137 |
-
|
138 |
-
return $mimes;
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Add SVG image support
|
143 |
-
*
|
144 |
-
* @since 1.1.4
|
145 |
-
*
|
146 |
-
* @param array $response Attachment response.
|
147 |
-
* @param object $attachment Attachment object.
|
148 |
-
* @param array $meta Attachment meta data.
|
149 |
-
*/
|
150 |
-
function add_svg_image_support( $response, $attachment, $meta ) {
|
151 |
-
if ( ! function_exists( 'simplexml_load_file' ) ) {
|
152 |
-
return $response;
|
153 |
-
}
|
154 |
-
|
155 |
-
if ( ! empty( $response['sizes'] ) ) {
|
156 |
-
return $response;
|
157 |
-
}
|
158 |
-
|
159 |
-
if ( 'image/svg+xml' !== $response['mime'] ) {
|
160 |
-
return $response;
|
161 |
-
}
|
162 |
-
|
163 |
-
$svg_path = get_attached_file( $attachment->ID );
|
164 |
-
|
165 |
-
$dimensions = self::get_svg_dimensions( $svg_path );
|
166 |
-
|
167 |
-
$response['sizes'] = array(
|
168 |
-
'full' => array(
|
169 |
-
'url' => $response['url'],
|
170 |
-
'width' => $dimensions->width,
|
171 |
-
'height' => $dimensions->height,
|
172 |
-
'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
|
173 |
-
),
|
174 |
-
);
|
175 |
-
|
176 |
-
return $response;
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Get SVG Dimensions
|
181 |
-
*
|
182 |
-
* @since 1.1.4.
|
183 |
-
*
|
184 |
-
* @param string $svg SVG file path.
|
185 |
-
* @return array Return SVG file height & width for valid SVG file.
|
186 |
-
*/
|
187 |
-
public static function get_svg_dimensions( $svg ) {
|
188 |
-
|
189 |
-
$svg = simplexml_load_file( $svg );
|
190 |
-
|
191 |
-
if ( false === $svg ) {
|
192 |
-
$width = '0';
|
193 |
-
$height = '0';
|
194 |
-
} else {
|
195 |
-
$attributes = $svg->attributes();
|
196 |
-
$width = (string) $attributes->width;
|
197 |
-
$height = (string) $attributes->height;
|
198 |
-
}
|
199 |
-
|
200 |
-
return (object) array(
|
201 |
-
'width' => $width,
|
202 |
-
'height' => $height,
|
203 |
-
);
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Batch Process Complete.
|
208 |
-
*
|
209 |
-
* @return void
|
210 |
-
*/
|
211 |
-
public function complete_batch_import() {
|
212 |
-
wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Start Image Import
|
217 |
-
*
|
218 |
-
* @param integer $post_id Post Id.
|
219 |
-
*
|
220 |
-
* @return void
|
221 |
-
*/
|
222 |
-
public function start_batch_process( $post_id = '' ) {
|
223 |
-
|
224 |
-
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
225 |
-
|
226 |
-
wcf()->logger->import_log( '(✓) BATCH Started!' );
|
227 |
-
wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
|
228 |
-
|
229 |
-
// Add "elementor" in import [queue].
|
230 |
-
if ( 'beaver-builder' === $default_page_builder && self::$batch_instance_bb ) {
|
231 |
-
|
232 |
-
// Add to queue.
|
233 |
-
self::$batch_instance_bb->push_to_queue( $post_id );
|
234 |
-
|
235 |
-
// Dispatch Queue.
|
236 |
-
self::$batch_instance_bb->save()->dispatch();
|
237 |
-
|
238 |
-
wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
|
239 |
-
|
240 |
-
} elseif ( 'elementor' === $default_page_builder && self::$batch_instance_elementor ) {
|
241 |
-
|
242 |
-
// Add to queue.
|
243 |
-
self::$batch_instance_elementor->push_to_queue( $post_id );
|
244 |
-
|
245 |
-
// Dispatch Queue.
|
246 |
-
self::$batch_instance_elementor->save()->dispatch();
|
247 |
-
|
248 |
-
wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
|
249 |
-
} elseif ( 'divi' === $default_page_builder && self::$batch_instance_divi ) {
|
250 |
-
|
251 |
-
// Add to queue.
|
252 |
-
self::$batch_instance_divi->push_to_queue( $post_id );
|
253 |
-
|
254 |
-
// Dispatch Queue.
|
255 |
-
self::$batch_instance_divi->save()->dispatch();
|
256 |
-
|
257 |
-
wcf()->logger->import_log( '(✓) Dispatch "Divi" Request..' );
|
258 |
-
} else {
|
259 |
-
wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
|
260 |
-
}
|
261 |
-
}
|
262 |
-
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Kicking this off by calling 'get_instance()' method
|
267 |
-
*/
|
268 |
-
CartFlows_Batch_Process::get_instance();
|
269 |
-
|
270 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Batch Processing
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows_Batch_Process
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class CartFlows_Batch_Process {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @var object Class object.
|
23 |
+
* @access private
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Elementor Batch Instance
|
29 |
+
*
|
30 |
+
* @since 1.1.1 Updated instance name with elementor specific.
|
31 |
+
*
|
32 |
+
* @since 1.0.0
|
33 |
+
* @var object Class object.
|
34 |
+
* @access public
|
35 |
+
*/
|
36 |
+
public static $batch_instance_elementor;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Beaver Builder Batch Instance
|
40 |
+
*
|
41 |
+
* @since 1.1.1
|
42 |
+
* @var object Class object.
|
43 |
+
* @access public
|
44 |
+
*/
|
45 |
+
public static $batch_instance_bb;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Divi Batch Instance
|
49 |
+
*
|
50 |
+
* @since 1.1.1
|
51 |
+
* @var object Class object.
|
52 |
+
* @access public
|
53 |
+
*/
|
54 |
+
public static $batch_instance_divi;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Initiator
|
58 |
+
*
|
59 |
+
* @since 1.0.0
|
60 |
+
* @return object initialized object of class.
|
61 |
+
*/
|
62 |
+
public static function get_instance() {
|
63 |
+
if ( ! isset( self::$instance ) ) {
|
64 |
+
self::$instance = new self();
|
65 |
+
}
|
66 |
+
return self::$instance;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Constructor
|
71 |
+
*
|
72 |
+
* @since 1.0.0
|
73 |
+
*/
|
74 |
+
public function __construct() {
|
75 |
+
|
76 |
+
// Not BB or Elementor then avoid importer.
|
77 |
+
// if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
|
78 |
+
// return;
|
79 |
+
// }
|
80 |
+
// Core Helpers - Image.
|
81 |
+
require_once ABSPATH . 'wp-admin/includes/image.php';
|
82 |
+
|
83 |
+
// Core Helpers - Batch Processing.
|
84 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-cartflows-importer-image.php';
|
85 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
|
86 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';
|
87 |
+
|
88 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
89 |
+
|
90 |
+
// Elementor.
|
91 |
+
if ( ( 'elementor' === $default_page_builder ) && class_exists( '\Elementor\Plugin' ) ) {
|
92 |
+
// Add "elementor" in import [queue].
|
93 |
+
// @todo Remove required `allow_url_fopen` support.
|
94 |
+
if ( ini_get( 'allow_url_fopen' ) ) {
|
95 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
|
96 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor-batch.php';
|
97 |
+
self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
// Beaver Builder.
|
102 |
+
if ( ( 'beaver-builder' === $default_page_builder ) && class_exists( 'FLBuilder' ) ) {
|
103 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder.php';
|
104 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder-batch.php';
|
105 |
+
self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
|
106 |
+
}
|
107 |
+
|
108 |
+
// Divi.
|
109 |
+
if ( ( 'divi' === $default_page_builder ) && ( class_exists( 'ET_Builder_Plugin' ) || Cartflows_Compatibility::get_instance()->is_divi_enabled() ) ) {
|
110 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi.php';
|
111 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi-batch.php';
|
112 |
+
self::$batch_instance_divi = new Cartflows_Importer_Divi_Batch();
|
113 |
+
}
|
114 |
+
|
115 |
+
// Start image importing after site import complete.
|
116 |
+
add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
|
117 |
+
add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
|
118 |
+
add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
|
119 |
+
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Added .svg files as supported format in the uploader.
|
124 |
+
*
|
125 |
+
* @since 1.1.4
|
126 |
+
*
|
127 |
+
* @param array $mimes Already supported mime types.
|
128 |
+
*/
|
129 |
+
public function custom_upload_mimes( $mimes ) {
|
130 |
+
|
131 |
+
// Allow SVG files.
|
132 |
+
$mimes['svg'] = 'image/svg+xml';
|
133 |
+
$mimes['svgz'] = 'image/svg+xml';
|
134 |
+
|
135 |
+
// Allow XML files.
|
136 |
+
$mimes['xml'] = 'text/xml';
|
137 |
+
|
138 |
+
return $mimes;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Add SVG image support
|
143 |
+
*
|
144 |
+
* @since 1.1.4
|
145 |
+
*
|
146 |
+
* @param array $response Attachment response.
|
147 |
+
* @param object $attachment Attachment object.
|
148 |
+
* @param array $meta Attachment meta data.
|
149 |
+
*/
|
150 |
+
public function add_svg_image_support( $response, $attachment, $meta ) {
|
151 |
+
if ( ! function_exists( 'simplexml_load_file' ) ) {
|
152 |
+
return $response;
|
153 |
+
}
|
154 |
+
|
155 |
+
if ( ! empty( $response['sizes'] ) ) {
|
156 |
+
return $response;
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( 'image/svg+xml' !== $response['mime'] ) {
|
160 |
+
return $response;
|
161 |
+
}
|
162 |
+
|
163 |
+
$svg_path = get_attached_file( $attachment->ID );
|
164 |
+
|
165 |
+
$dimensions = self::get_svg_dimensions( $svg_path );
|
166 |
+
|
167 |
+
$response['sizes'] = array(
|
168 |
+
'full' => array(
|
169 |
+
'url' => $response['url'],
|
170 |
+
'width' => $dimensions->width,
|
171 |
+
'height' => $dimensions->height,
|
172 |
+
'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
|
173 |
+
),
|
174 |
+
);
|
175 |
+
|
176 |
+
return $response;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Get SVG Dimensions
|
181 |
+
*
|
182 |
+
* @since 1.1.4.
|
183 |
+
*
|
184 |
+
* @param string $svg SVG file path.
|
185 |
+
* @return array Return SVG file height & width for valid SVG file.
|
186 |
+
*/
|
187 |
+
public static function get_svg_dimensions( $svg ) {
|
188 |
+
|
189 |
+
$svg = simplexml_load_file( $svg );
|
190 |
+
|
191 |
+
if ( false === $svg ) {
|
192 |
+
$width = '0';
|
193 |
+
$height = '0';
|
194 |
+
} else {
|
195 |
+
$attributes = $svg->attributes();
|
196 |
+
$width = (string) $attributes->width;
|
197 |
+
$height = (string) $attributes->height;
|
198 |
+
}
|
199 |
+
|
200 |
+
return (object) array(
|
201 |
+
'width' => $width,
|
202 |
+
'height' => $height,
|
203 |
+
);
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Batch Process Complete.
|
208 |
+
*
|
209 |
+
* @return void
|
210 |
+
*/
|
211 |
+
public function complete_batch_import() {
|
212 |
+
wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Start Image Import
|
217 |
+
*
|
218 |
+
* @param integer $post_id Post Id.
|
219 |
+
*
|
220 |
+
* @return void
|
221 |
+
*/
|
222 |
+
public function start_batch_process( $post_id = '' ) {
|
223 |
+
|
224 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
225 |
+
|
226 |
+
wcf()->logger->import_log( '(✓) BATCH Started!' );
|
227 |
+
wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
|
228 |
+
|
229 |
+
// Add "elementor" in import [queue].
|
230 |
+
if ( 'beaver-builder' === $default_page_builder && self::$batch_instance_bb ) {
|
231 |
+
|
232 |
+
// Add to queue.
|
233 |
+
self::$batch_instance_bb->push_to_queue( $post_id );
|
234 |
+
|
235 |
+
// Dispatch Queue.
|
236 |
+
self::$batch_instance_bb->save()->dispatch();
|
237 |
+
|
238 |
+
wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
|
239 |
+
|
240 |
+
} elseif ( 'elementor' === $default_page_builder && self::$batch_instance_elementor ) {
|
241 |
+
|
242 |
+
// Add to queue.
|
243 |
+
self::$batch_instance_elementor->push_to_queue( $post_id );
|
244 |
+
|
245 |
+
// Dispatch Queue.
|
246 |
+
self::$batch_instance_elementor->save()->dispatch();
|
247 |
+
|
248 |
+
wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
|
249 |
+
} elseif ( 'divi' === $default_page_builder && self::$batch_instance_divi ) {
|
250 |
+
|
251 |
+
// Add to queue.
|
252 |
+
self::$batch_instance_divi->push_to_queue( $post_id );
|
253 |
+
|
254 |
+
// Dispatch Queue.
|
255 |
+
self::$batch_instance_divi->save()->dispatch();
|
256 |
+
|
257 |
+
wcf()->logger->import_log( '(✓) Dispatch "Divi" Request..' );
|
258 |
+
} else {
|
259 |
+
wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Kicking this off by calling 'get_instance()' method
|
267 |
+
*/
|
268 |
+
CartFlows_Batch_Process::get_instance();
|
269 |
+
|
270 |
+
endif;
|
classes/batch-process/class-cartflows-change-template-batch.php
CHANGED
@@ -1,57 +1,61 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Change Template Process
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.2.2
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'Cartflows_Change_Template_Batch' ) && class_exists( 'WP_Background_Process' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Change Template Process
|
13 |
-
*
|
14 |
-
* @since 1.2.2
|
15 |
-
*/
|
16 |
-
class Cartflows_Change_Template_Batch extends WP_Background_Process {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Template Process
|
20 |
-
*
|
21 |
-
* @var string
|
22 |
-
*/
|
23 |
-
protected $action = 'cartflows_change_template_process';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Task
|
27 |
-
*
|
28 |
-
* Override this method to perform any actions required on each
|
29 |
-
* queue item. Return the modified item for further processing
|
30 |
-
* in the next pass through. Or, return false to remove the
|
31 |
-
* item from the queue.
|
32 |
-
*
|
33 |
-
* @param mixed $post_id Queue item to iterate over.
|
34 |
-
*
|
35 |
-
* @return mixed
|
36 |
-
*/
|
37 |
-
protected function task( $post_id ) {
|
38 |
-
|
39 |
-
wcf()->logger->log( '(✓) Step ID ' . $post_id );
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
*
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Change Template Process
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.2.2
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'Cartflows_Change_Template_Batch' ) && class_exists( 'WP_Background_Process' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Change Template Process
|
13 |
+
*
|
14 |
+
* @since 1.2.2
|
15 |
+
*/
|
16 |
+
class Cartflows_Change_Template_Batch extends WP_Background_Process {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Template Process
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $action = 'cartflows_change_template_process';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Task
|
27 |
+
*
|
28 |
+
* Override this method to perform any actions required on each
|
29 |
+
* queue item. Return the modified item for further processing
|
30 |
+
* in the next pass through. Or, return false to remove the
|
31 |
+
* item from the queue.
|
32 |
+
*
|
33 |
+
* @param mixed $post_id Queue item to iterate over.
|
34 |
+
*
|
35 |
+
* @return mixed
|
36 |
+
*/
|
37 |
+
protected function task( $post_id ) {
|
38 |
+
|
39 |
+
wcf()->logger->log( '(✓) Step ID ' . $post_id );
|
40 |
+
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
41 |
+
error_log( 'Processed:' . $post_id ); //phpcs:ignore
|
42 |
+
}
|
43 |
+
update_post_meta( $post_id, '_wp_page_template', 'cartflows-default' );
|
44 |
+
return false;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Complete
|
49 |
+
*
|
50 |
+
* Override if applicable, but ensure that the below actions are
|
51 |
+
* performed, or, call parent::complete().
|
52 |
+
*/
|
53 |
+
protected function complete() {
|
54 |
+
parent::complete();
|
55 |
+
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
56 |
+
error_log( 'Process Complete' );//phpcs:ignore
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
endif;
|
classes/batch-process/class-cartflows-importer-divi.php
CHANGED
@@ -1,116 +1,116 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Divi Importer
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.1.1
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'CartFlows_Importer_Divi' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows Import Divi
|
13 |
-
*
|
14 |
-
* @since 1.1.1
|
15 |
-
*/
|
16 |
-
class CartFlows_Importer_Divi {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @since 1.1.1
|
22 |
-
* @access private
|
23 |
-
* @var object Class object.
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Initiator
|
29 |
-
*
|
30 |
-
* @since 1.1.1
|
31 |
-
* @return object initialized object of class.
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
|
35 |
-
if ( ! isset( self::$instance ) ) {
|
36 |
-
self::$instance = new self();
|
37 |
-
}
|
38 |
-
return self::$instance;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Constructor
|
43 |
-
*
|
44 |
-
* @since 1.1.1
|
45 |
-
*/
|
46 |
-
public function __construct() {}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Allowed tags for the batch update process
|
50 |
-
*
|
51 |
-
* @since x.x.x
|
52 |
-
*
|
53 |
-
* @param array $allowedposttags Array of default allowable HTML tags.
|
54 |
-
* @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
|
55 |
-
* 'strip', 'data', 'entities', or the name of a field filter such as
|
56 |
-
* 'pre_user_description'.
|
57 |
-
* @return array Array of allowed HTML tags and their allowed attributes.
|
58 |
-
*/
|
59 |
-
function allowed_tags_and_attributes( $allowedposttags, $context ) {
|
60 |
-
|
61 |
-
// Keep only for 'post' contenxt.
|
62 |
-
if ( 'post' === $context ) {
|
63 |
-
|
64 |
-
// <style> tag and attributes.
|
65 |
-
$allowedposttags['style'] = array();
|
66 |
-
}
|
67 |
-
|
68 |
-
return $allowedposttags;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Update post meta.
|
73 |
-
*
|
74 |
-
* @param integer $post_id Post ID.
|
75 |
-
* @return void
|
76 |
-
*/
|
77 |
-
public function import_single_post( $post_id = 0 ) {
|
78 |
-
|
79 |
-
// Allow the SVG tags in batch update process.
|
80 |
-
add_filter( 'wp_kses_allowed_html', array( $this, 'allowed_tags_and_attributes' ), 10, 2 );
|
81 |
-
|
82 |
-
// Download and replace images.
|
83 |
-
$content = get_post_meta( $post_id, 'divi_content', true );
|
84 |
-
|
85 |
-
if ( empty( $content ) ) {
|
86 |
-
wcf()->logger->import_log( '(✕) Not have "Divi" Data. Post content is empty!' );
|
87 |
-
} else {
|
88 |
-
|
89 |
-
wcf()->logger->import_log( '(✓) Processing Request..' );
|
90 |
-
|
91 |
-
// Update hotlink images.
|
92 |
-
$content = CartFlows_Importer::get_instance()->get_content( $content );
|
93 |
-
|
94 |
-
// Update post content.
|
95 |
-
wp_update_post(
|
96 |
-
array(
|
97 |
-
'ID' => $post_id,
|
98 |
-
'post_content' => $content,
|
99 |
-
)
|
100 |
-
);
|
101 |
-
|
102 |
-
// Delete temporary meta key.
|
103 |
-
delete_post_meta( $post_id, 'divi_content' );
|
104 |
-
|
105 |
-
wcf()->logger->import_log( '(✓) Process Complete' );
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Initialize class object with 'get_instance()' method
|
113 |
-
*/
|
114 |
-
CartFlows_Importer_Divi::get_instance();
|
115 |
-
|
116 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Divi Importer
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.1.1
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_Importer_Divi' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows Import Divi
|
13 |
+
*
|
14 |
+
* @since 1.1.1
|
15 |
+
*/
|
16 |
+
class CartFlows_Importer_Divi {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.1.1
|
22 |
+
* @access private
|
23 |
+
* @var object Class object.
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initiator
|
29 |
+
*
|
30 |
+
* @since 1.1.1
|
31 |
+
* @return object initialized object of class.
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
|
35 |
+
if ( ! isset( self::$instance ) ) {
|
36 |
+
self::$instance = new self();
|
37 |
+
}
|
38 |
+
return self::$instance;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor
|
43 |
+
*
|
44 |
+
* @since 1.1.1
|
45 |
+
*/
|
46 |
+
public function __construct() {}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Allowed tags for the batch update process
|
50 |
+
*
|
51 |
+
* @since x.x.x
|
52 |
+
*
|
53 |
+
* @param array $allowedposttags Array of default allowable HTML tags.
|
54 |
+
* @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
|
55 |
+
* 'strip', 'data', 'entities', or the name of a field filter such as
|
56 |
+
* 'pre_user_description'.
|
57 |
+
* @return array Array of allowed HTML tags and their allowed attributes.
|
58 |
+
*/
|
59 |
+
public function allowed_tags_and_attributes( $allowedposttags, $context ) {
|
60 |
+
|
61 |
+
// Keep only for 'post' contenxt.
|
62 |
+
if ( 'post' === $context ) {
|
63 |
+
|
64 |
+
// <style> tag and attributes.
|
65 |
+
$allowedposttags['style'] = array();
|
66 |
+
}
|
67 |
+
|
68 |
+
return $allowedposttags;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Update post meta.
|
73 |
+
*
|
74 |
+
* @param integer $post_id Post ID.
|
75 |
+
* @return void
|
76 |
+
*/
|
77 |
+
public function import_single_post( $post_id = 0 ) {
|
78 |
+
|
79 |
+
// Allow the SVG tags in batch update process.
|
80 |
+
add_filter( 'wp_kses_allowed_html', array( $this, 'allowed_tags_and_attributes' ), 10, 2 );
|
81 |
+
|
82 |
+
// Download and replace images.
|
83 |
+
$content = get_post_meta( $post_id, 'divi_content', true );
|
84 |
+
|
85 |
+
if ( empty( $content ) ) {
|
86 |
+
wcf()->logger->import_log( '(✕) Not have "Divi" Data. Post content is empty!' );
|
87 |
+
} else {
|
88 |
+
|
89 |
+
wcf()->logger->import_log( '(✓) Processing Request..' );
|
90 |
+
|
91 |
+
// Update hotlink images.
|
92 |
+
$content = CartFlows_Importer::get_instance()->get_content( $content );
|
93 |
+
|
94 |
+
// Update post content.
|
95 |
+
wp_update_post(
|
96 |
+
array(
|
97 |
+
'ID' => $post_id,
|
98 |
+
'post_content' => $content,
|
99 |
+
)
|
100 |
+
);
|
101 |
+
|
102 |
+
// Delete temporary meta key.
|
103 |
+
delete_post_meta( $post_id, 'divi_content' );
|
104 |
+
|
105 |
+
wcf()->logger->import_log( '(✓) Process Complete' );
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Initialize class object with 'get_instance()' method
|
113 |
+
*/
|
114 |
+
CartFlows_Importer_Divi::get_instance();
|
115 |
+
|
116 |
+
endif;
|
classes/class-cartflows-admin-fields.php
CHANGED
@@ -1,267 +1,267 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CARTFLOWS Admin Fields.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Cartflows_Admin_Fields.
|
10 |
-
*/
|
11 |
-
class Cartflows_Admin_Fields {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Title Field
|
15 |
-
*
|
16 |
-
* @param array $args Args.
|
17 |
-
* @return string
|
18 |
-
*/
|
19 |
-
public static function title_field( $args ) {
|
20 |
-
|
21 |
-
$title = $args['title'];
|
22 |
-
$description = isset( $args['description'] ) ? $args['description'] : '';
|
23 |
-
|
24 |
-
$output = '<h4 class="form-field wcf-title-field">';
|
25 |
-
$output .= '<span>' . $title . '</span>';
|
26 |
-
$output .= '</h4>';
|
27 |
-
|
28 |
-
if ( ! empty( $description ) ) {
|
29 |
-
$output .= '<div class="form-field-desc">';
|
30 |
-
$output .= '<p>' . $description . '</p>';
|
31 |
-
$output .= '</div>';
|
32 |
-
}
|
33 |
-
|
34 |
-
return $output;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Text Field
|
39 |
-
*
|
40 |
-
* @param array $args Args.
|
41 |
-
* @return string
|
42 |
-
*/
|
43 |
-
public static function text_field( $args ) {
|
44 |
-
|
45 |
-
$id = $args['id'];
|
46 |
-
$name = $args['name'];
|
47 |
-
$title = $args['title'];
|
48 |
-
$value = $args['value'];
|
49 |
-
$description = isset( $args['description'] ) ? $args['description'] : '';
|
50 |
-
$placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : '';
|
51 |
-
|
52 |
-
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
53 |
-
$output .= '<label for="' . $id . '">' . $title . '</label>';
|
54 |
-
$output .= '<input placeholder="' . $placeholder . '" type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
|
55 |
-
$output .= '</div>';
|
56 |
-
|
57 |
-
if ( ! empty( $description ) ) {
|
58 |
-
$output .= '<div class="form-field-desc">';
|
59 |
-
$output .= '<p>';
|
60 |
-
$output .= $description;
|
61 |
-
$output .= '</p>';
|
62 |
-
$output .= '</div>';
|
63 |
-
}
|
64 |
-
|
65 |
-
return $output;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* URL Field
|
70 |
-
*
|
71 |
-
* @param array $args Args.
|
72 |
-
* @return string
|
73 |
-
*/
|
74 |
-
public static function url_field( $args ) {
|
75 |
-
|
76 |
-
$id = $args['id'];
|
77 |
-
$name = $args['name'];
|
78 |
-
$title = $args['title'];
|
79 |
-
$value = $args['value'];
|
80 |
-
|
81 |
-
$output = '<div class="form-field">';
|
82 |
-
$output .= '<label for="' . $id . '">' . $title . '</label>';
|
83 |
-
$output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
|
84 |
-
$output .= '</div>';
|
85 |
-
|
86 |
-
return $output;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Checkbox Field
|
91 |
-
*
|
92 |
-
* @param array $args Args.
|
93 |
-
* @return string
|
94 |
-
*/
|
95 |
-
public static function checkobox_field( $args ) {
|
96 |
-
|
97 |
-
$id = $args['id'];
|
98 |
-
$name = $args['name'];
|
99 |
-
$title = $args['title'];
|
100 |
-
$value = $args['value'];
|
101 |
-
|
102 |
-
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
103 |
-
$output .= '<label for="' . $id . '">';
|
104 |
-
$output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
|
105 |
-
$output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
|
106 |
-
$output .= $title;
|
107 |
-
$output .= '</label>';
|
108 |
-
$output .= '</div>';
|
109 |
-
|
110 |
-
return $output;
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Radio Field
|
115 |
-
*
|
116 |
-
* @param array $args Args.
|
117 |
-
* @return string
|
118 |
-
*/
|
119 |
-
public static function radio_field( $args ) {
|
120 |
-
|
121 |
-
$name = $args['name'];
|
122 |
-
$id = $args['id'];
|
123 |
-
$options = $args['options'];
|
124 |
-
$value = $args['value'];
|
125 |
-
|
126 |
-
$output = '';
|
127 |
-
foreach ( $options as $type => $data ) {
|
128 |
-
|
129 |
-
$output .= '<div class="form-field">';
|
130 |
-
$output .= '<label for="' . $id . '">';
|
131 |
-
$output .= '<input type="radio" class="wcf_permalink_structure" name="' . $name . '" value="' . $type . '" ' . checked( $value, $type, false ) . '>' . $data['label'] . '</label>';
|
132 |
-
$output .= '<div class="form-field-desc">';
|
133 |
-
$output .= '<p>';
|
134 |
-
if ( empty( $type ) ) {
|
135 |
-
$output .= $data['description'];
|
136 |
-
} else {
|
137 |
-
$output .= get_site_url() . $data['description'];
|
138 |
-
}
|
139 |
-
|
140 |
-
$output .= '</p>';
|
141 |
-
$output .= '</div>';
|
142 |
-
$output .= '</div>';
|
143 |
-
}
|
144 |
-
|
145 |
-
return $output;
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Select Field
|
150 |
-
*
|
151 |
-
* @since 1.1.4
|
152 |
-
*
|
153 |
-
* @param array $args Args.
|
154 |
-
* @return string
|
155 |
-
*/
|
156 |
-
public static function select_field( $args ) {
|
157 |
-
|
158 |
-
$id = $args['id'];
|
159 |
-
$name = $args['name'];
|
160 |
-
$title = $args['title'];
|
161 |
-
$description = $args['description'];
|
162 |
-
$value = $args['value'];
|
163 |
-
$options = $args['options'];
|
164 |
-
|
165 |
-
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
166 |
-
|
167 |
-
$output .= '<div class="form-field-label">';
|
168 |
-
$output .= $title;
|
169 |
-
$output .= '</div>';
|
170 |
-
|
171 |
-
$output .= '<div class="form-field-data">';
|
172 |
-
$output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
|
173 |
-
foreach ( $options as $option_value => $option_title ) {
|
174 |
-
$output .= '<option value="' . $option_value . '" ' . selected( $value, $option_value, false ) . '>' . $option_title . '</option>';
|
175 |
-
}
|
176 |
-
$output .= '</select>';
|
177 |
-
$output .= '</div>';
|
178 |
-
|
179 |
-
$output .= '<div class="form-field-desc">';
|
180 |
-
$output .= '<p>';
|
181 |
-
$output .= $description;
|
182 |
-
$output .= '</p>';
|
183 |
-
$output .= '</div>';
|
184 |
-
$output .= '</div>';
|
185 |
-
|
186 |
-
return $output;
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Checkout Selection Field
|
191 |
-
*
|
192 |
-
* @param array $args Args.
|
193 |
-
* @return string
|
194 |
-
*/
|
195 |
-
public static function flow_checkout_selection_field( $args ) {
|
196 |
-
|
197 |
-
$id = $args['id'];
|
198 |
-
$name = $args['name'];
|
199 |
-
$title = $args['title'];
|
200 |
-
$value = $args['value'];
|
201 |
-
|
202 |
-
$checkout_steps = get_posts(
|
203 |
-
array(
|
204 |
-
'posts_per_page' => -1,
|
205 |
-
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
206 |
-
'post_status' => 'publish',
|
207 |
-
'orderby' => 'ID',
|
208 |
-
'order' => 'ASC',
|
209 |
-
'tax_query' => array(
|
210 |
-
array(
|
211 |
-
'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
|
212 |
-
'field' => 'slug',
|
213 |
-
'terms' => 'checkout',
|
214 |
-
),
|
215 |
-
),
|
216 |
-
)
|
217 |
-
);
|
218 |
-
|
219 |
-
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
220 |
-
|
221 |
-
$output .= '<div class="form-field-label">';
|
222 |
-
$output .= '<label for="' . $id . '">';
|
223 |
-
$output .= $title;
|
224 |
-
$output .= '</label>';
|
225 |
-
$output .= '</div>';
|
226 |
-
|
227 |
-
$output .= '<div class="form-field-data">';
|
228 |
-
$output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
|
229 |
-
|
230 |
-
if ( ! empty( $checkout_steps ) ) {
|
231 |
-
$output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
|
232 |
-
} else {
|
233 |
-
|
234 |
-
$output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
|
235 |
-
}
|
236 |
-
|
237 |
-
foreach ( $checkout_steps as $index => $step_data ) {
|
238 |
-
|
239 |
-
$output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
|
240 |
-
}
|
241 |
-
|
242 |
-
$output .= '</select>';
|
243 |
-
$output .= '</div>';
|
244 |
-
|
245 |
-
if ( '' !== $value ) {
|
246 |
-
$output .= '<div class="form-field-actions">';
|
247 |
-
$output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
|
248 |
-
$output .= '<span class="dashicons dashicons-edit"></span>';
|
249 |
-
$output .= '<span class="">Edit</span>';
|
250 |
-
$output .= '</a>';
|
251 |
-
$output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
|
252 |
-
$output .= '<span class="dashicons dashicons-visibility"></span>';
|
253 |
-
$output .= '<span class="">View</span>';
|
254 |
-
$output .= '</a>';
|
255 |
-
$output .= '</div>';
|
256 |
-
}
|
257 |
-
|
258 |
-
$output .= '<div class="form-field-desc">';
|
259 |
-
/* translators: %s: link */
|
260 |
-
$output .= '<p>' . sprintf( __( 'Be sure not to add any product in above selected Global Checkout step. Please read information about how to set up Global Checkout %1$shere%2$s.', 'cartflows' ), '<a href="https://cartflows.com/docs/global-checkout/" target="_blank">', '</a>' ) . '</p>';
|
261 |
-
$output .= '</div>';
|
262 |
-
|
263 |
-
$output .= '</div>';
|
264 |
-
|
265 |
-
return $output;
|
266 |
-
}
|
267 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CARTFLOWS Admin Fields.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Cartflows_Admin_Fields.
|
10 |
+
*/
|
11 |
+
class Cartflows_Admin_Fields {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Title Field
|
15 |
+
*
|
16 |
+
* @param array $args Args.
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
public static function title_field( $args ) {
|
20 |
+
|
21 |
+
$title = $args['title'];
|
22 |
+
$description = isset( $args['description'] ) ? $args['description'] : '';
|
23 |
+
|
24 |
+
$output = '<h4 class="form-field wcf-title-field">';
|
25 |
+
$output .= '<span>' . $title . '</span>';
|
26 |
+
$output .= '</h4>';
|
27 |
+
|
28 |
+
if ( ! empty( $description ) ) {
|
29 |
+
$output .= '<div class="form-field-desc">';
|
30 |
+
$output .= '<p>' . $description . '</p>';
|
31 |
+
$output .= '</div>';
|
32 |
+
}
|
33 |
+
|
34 |
+
return $output;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Text Field
|
39 |
+
*
|
40 |
+
* @param array $args Args.
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public static function text_field( $args ) {
|
44 |
+
|
45 |
+
$id = $args['id'];
|
46 |
+
$name = $args['name'];
|
47 |
+
$title = $args['title'];
|
48 |
+
$value = $args['value'];
|
49 |
+
$description = isset( $args['description'] ) ? $args['description'] : '';
|
50 |
+
$placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : '';
|
51 |
+
|
52 |
+
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
53 |
+
$output .= '<label for="' . $id . '">' . $title . '</label>';
|
54 |
+
$output .= '<input placeholder="' . $placeholder . '" type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
|
55 |
+
$output .= '</div>';
|
56 |
+
|
57 |
+
if ( ! empty( $description ) ) {
|
58 |
+
$output .= '<div class="form-field-desc">';
|
59 |
+
$output .= '<p>';
|
60 |
+
$output .= $description;
|
61 |
+
$output .= '</p>';
|
62 |
+
$output .= '</div>';
|
63 |
+
}
|
64 |
+
|
65 |
+
return $output;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* URL Field
|
70 |
+
*
|
71 |
+
* @param array $args Args.
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public static function url_field( $args ) {
|
75 |
+
|
76 |
+
$id = $args['id'];
|
77 |
+
$name = $args['name'];
|
78 |
+
$title = $args['title'];
|
79 |
+
$value = $args['value'];
|
80 |
+
|
81 |
+
$output = '<div class="form-field">';
|
82 |
+
$output .= '<label for="' . $id . '">' . $title . '</label>';
|
83 |
+
$output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
|
84 |
+
$output .= '</div>';
|
85 |
+
|
86 |
+
return $output;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Checkbox Field
|
91 |
+
*
|
92 |
+
* @param array $args Args.
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
public static function checkobox_field( $args ) {
|
96 |
+
|
97 |
+
$id = $args['id'];
|
98 |
+
$name = $args['name'];
|
99 |
+
$title = $args['title'];
|
100 |
+
$value = $args['value'];
|
101 |
+
|
102 |
+
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
103 |
+
$output .= '<label for="' . $id . '">';
|
104 |
+
$output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
|
105 |
+
$output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
|
106 |
+
$output .= $title;
|
107 |
+
$output .= '</label>';
|
108 |
+
$output .= '</div>';
|
109 |
+
|
110 |
+
return $output;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Radio Field
|
115 |
+
*
|
116 |
+
* @param array $args Args.
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
public static function radio_field( $args ) {
|
120 |
+
|
121 |
+
$name = $args['name'];
|
122 |
+
$id = $args['id'];
|
123 |
+
$options = $args['options'];
|
124 |
+
$value = $args['value'];
|
125 |
+
|
126 |
+
$output = '';
|
127 |
+
foreach ( $options as $type => $data ) {
|
128 |
+
|
129 |
+
$output .= '<div class="form-field">';
|
130 |
+
$output .= '<label for="' . $id . '">';
|
131 |
+
$output .= '<input type="radio" class="wcf_permalink_structure" name="' . $name . '" value="' . $type . '" ' . checked( $value, $type, false ) . '>' . $data['label'] . '</label>';
|
132 |
+
$output .= '<div class="form-field-desc">';
|
133 |
+
$output .= '<p>';
|
134 |
+
if ( empty( $type ) ) {
|
135 |
+
$output .= $data['description'];
|
136 |
+
} else {
|
137 |
+
$output .= get_site_url() . $data['description'];
|
138 |
+
}
|
139 |
+
|
140 |
+
$output .= '</p>';
|
141 |
+
$output .= '</div>';
|
142 |
+
$output .= '</div>';
|
143 |
+
}
|
144 |
+
|
145 |
+
return $output;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Select Field
|
150 |
+
*
|
151 |
+
* @since 1.1.4
|
152 |
+
*
|
153 |
+
* @param array $args Args.
|
154 |
+
* @return string
|
155 |
+
*/
|
156 |
+
public static function select_field( $args ) {
|
157 |
+
|
158 |
+
$id = $args['id'];
|
159 |
+
$name = $args['name'];
|
160 |
+
$title = $args['title'];
|
161 |
+
$description = $args['description'];
|
162 |
+
$value = $args['value'];
|
163 |
+
$options = $args['options'];
|
164 |
+
|
165 |
+
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
166 |
+
|
167 |
+
$output .= '<div class="form-field-label">';
|
168 |
+
$output .= $title;
|
169 |
+
$output .= '</div>';
|
170 |
+
|
171 |
+
$output .= '<div class="form-field-data">';
|
172 |
+
$output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
|
173 |
+
foreach ( $options as $option_value => $option_title ) {
|
174 |
+
$output .= '<option value="' . $option_value . '" ' . selected( $value, $option_value, false ) . '>' . $option_title . '</option>';
|
175 |
+
}
|
176 |
+
$output .= '</select>';
|
177 |
+
$output .= '</div>';
|
178 |
+
|
179 |
+
$output .= '<div class="form-field-desc">';
|
180 |
+
$output .= '<p>';
|
181 |
+
$output .= $description;
|
182 |
+
$output .= '</p>';
|
183 |
+
$output .= '</div>';
|
184 |
+
$output .= '</div>';
|
185 |
+
|
186 |
+
return $output;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Checkout Selection Field
|
191 |
+
*
|
192 |
+
* @param array $args Args.
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
public static function flow_checkout_selection_field( $args ) {
|
196 |
+
|
197 |
+
$id = $args['id'];
|
198 |
+
$name = $args['name'];
|
199 |
+
$title = $args['title'];
|
200 |
+
$value = $args['value'];
|
201 |
+
|
202 |
+
$checkout_steps = get_posts(
|
203 |
+
array(
|
204 |
+
'posts_per_page' => -1,
|
205 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
206 |
+
'post_status' => 'publish',
|
207 |
+
'orderby' => 'ID',
|
208 |
+
'order' => 'ASC',
|
209 |
+
'tax_query' => array( //phpcs:ignore
|
210 |
+
array(
|
211 |
+
'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
|
212 |
+
'field' => 'slug',
|
213 |
+
'terms' => 'checkout',
|
214 |
+
),
|
215 |
+
),
|
216 |
+
)
|
217 |
+
);
|
218 |
+
|
219 |
+
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
220 |
+
|
221 |
+
$output .= '<div class="form-field-label">';
|
222 |
+
$output .= '<label for="' . $id . '">';
|
223 |
+
$output .= $title;
|
224 |
+
$output .= '</label>';
|
225 |
+
$output .= '</div>';
|
226 |
+
|
227 |
+
$output .= '<div class="form-field-data">';
|
228 |
+
$output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
|
229 |
+
|
230 |
+
if ( ! empty( $checkout_steps ) ) {
|
231 |
+
$output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
|
232 |
+
} else {
|
233 |
+
|
234 |
+
$output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
|
235 |
+
}
|
236 |
+
|
237 |
+
foreach ( $checkout_steps as $index => $step_data ) {
|
238 |
+
|
239 |
+
$output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
|
240 |
+
}
|
241 |
+
|
242 |
+
$output .= '</select>';
|
243 |
+
$output .= '</div>';
|
244 |
+
|
245 |
+
if ( '' !== $value ) {
|
246 |
+
$output .= '<div class="form-field-actions">';
|
247 |
+
$output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
|
248 |
+
$output .= '<span class="dashicons dashicons-edit"></span>';
|
249 |
+
$output .= '<span class="">Edit</span>';
|
250 |
+
$output .= '</a>';
|
251 |
+
$output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
|
252 |
+
$output .= '<span class="dashicons dashicons-visibility"></span>';
|
253 |
+
$output .= '<span class="">View</span>';
|
254 |
+
$output .= '</a>';
|
255 |
+
$output .= '</div>';
|
256 |
+
}
|
257 |
+
|
258 |
+
$output .= '<div class="form-field-desc">';
|
259 |
+
/* translators: %s: link */
|
260 |
+
$output .= '<p>' . sprintf( __( 'Be sure not to add any product in above selected Global Checkout step. Please read information about how to set up Global Checkout %1$shere%2$s.', 'cartflows' ), '<a href="https://cartflows.com/docs/global-checkout/" target="_blank">', '</a>' ) . '</p>';
|
261 |
+
$output .= '</div>';
|
262 |
+
|
263 |
+
$output .= '</div>';
|
264 |
+
|
265 |
+
return $output;
|
266 |
+
}
|
267 |
+
}
|
classes/class-cartflows-admin.php
CHANGED
@@ -1,620 +1,620 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Admin.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Cartflows_Admin.
|
10 |
-
*/
|
11 |
-
class Cartflows_Admin {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Calls on initialization
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
*/
|
18 |
-
public static function init() {
|
19 |
-
|
20 |
-
self::initialise_plugin();
|
21 |
-
self::init_hooks();
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Init Hooks.
|
26 |
-
*
|
27 |
-
* @since 1.0.0
|
28 |
-
* @return void
|
29 |
-
*/
|
30 |
-
public static function init_hooks() {
|
31 |
-
|
32 |
-
if ( ! is_admin() ) {
|
33 |
-
return;
|
34 |
-
}
|
35 |
-
|
36 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
|
37 |
-
|
38 |
-
/*
|
39 |
-
Add CARTFLOWS menu option to admin.
|
40 |
-
add_action( 'network_admin_menu', __CLASS__ . '::menu' );
|
41 |
-
*/
|
42 |
-
add_action( 'admin_menu', __CLASS__ . '::menu' );
|
43 |
-
add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
|
44 |
-
|
45 |
-
add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
|
46 |
-
|
47 |
-
add_action( 'admin_init', __CLASS__ . '::settings_admin_scripts' );
|
48 |
-
|
49 |
-
/* Global Addmin Script */
|
50 |
-
add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
|
51 |
-
|
52 |
-
add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
|
53 |
-
|
54 |
-
/* Add lite version class to body */
|
55 |
-
add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
|
56 |
-
|
57 |
-
add_filter( 'plugin_action_links_' . CARTFLOWS_BASE, __CLASS__ . '::add_action_links' );
|
58 |
-
|
59 |
-
add_action( 'admin_init', __CLASS__ . '::cartflows_after_save_permalinks' );
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* After save of permalinks.
|
65 |
-
*/
|
66 |
-
public static function cartflows_after_save_permalinks() {
|
67 |
-
|
68 |
-
$has_saved_permalinks = get_option( 'cartflows_permalink_saved' );
|
69 |
-
if ( $has_saved_permalinks ) {
|
70 |
-
flush_rewrite_rules();
|
71 |
-
delete_option( 'cartflows_permalink_saved' );
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Initialize after Cartflows pro get loaded.
|
78 |
-
*/
|
79 |
-
public static function settings_admin_scripts() {
|
80 |
-
// Enqueue admin scripts.
|
81 |
-
if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
|
82 |
-
add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
|
83 |
-
|
84 |
-
self::save_settings();
|
85 |
-
}
|
86 |
-
}
|
87 |
-
/**
|
88 |
-
* Show action on plugin page.
|
89 |
-
*
|
90 |
-
* @param array $links links.
|
91 |
-
* @return array
|
92 |
-
*/
|
93 |
-
public static function add_action_links( $links ) {
|
94 |
-
$mylinks = array(
|
95 |
-
'<a href="' . admin_url( 'admin.php?page=' . CARTFLOWS_SETTINGS ) . '">Settings</a>',
|
96 |
-
'<a target="_blank" href="' . esc_url( 'https://cartflows.com/docs' ) . '">Docs</a>',
|
97 |
-
);
|
98 |
-
|
99 |
-
if ( ! _is_cartflows_pro() ) {
|
100 |
-
array_push( $mylinks, '<a style="color: #39b54a; font-weight: bold;" target="_blank" href="' . esc_url( 'https://cartflows.com/pricing/' ) . '"> Go Pro </a>' );
|
101 |
-
}
|
102 |
-
|
103 |
-
return array_merge( $links, $mylinks );
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Initialises the Plugin Name.
|
108 |
-
*
|
109 |
-
* @since 1.0.0
|
110 |
-
* @return void
|
111 |
-
*/
|
112 |
-
public static function initialise_plugin() {
|
113 |
-
|
114 |
-
$name = 'Cartflows';
|
115 |
-
$short_name = 'Cflows';
|
116 |
-
|
117 |
-
define( 'CARTFLOWS_PLUGIN_NAME', $name );
|
118 |
-
define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Renders the admin settings menu.
|
123 |
-
*
|
124 |
-
* @since 1.0.0
|
125 |
-
* @return void
|
126 |
-
*/
|
127 |
-
public static function menu() {
|
128 |
-
|
129 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
130 |
-
return;
|
131 |
-
}
|
132 |
-
|
133 |
-
add_menu_page(
|
134 |
-
'CartFlows',
|
135 |
-
'CartFlows',
|
136 |
-
'manage_options',
|
137 |
-
CARTFLOWS_SLUG,
|
138 |
-
__CLASS__ . '::render',
|
139 |
-
'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) )
|
140 |
-
39.7
|
141 |
-
);
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Add submenu to admin menu.
|
147 |
-
*
|
148 |
-
* @since 1.0.0
|
149 |
-
*/
|
150 |
-
static function submenu() {
|
151 |
-
|
152 |
-
$parent_slug = CARTFLOWS_SLUG;
|
153 |
-
$page_title = __( 'Settings', 'cartflows' );
|
154 |
-
$menu_title = __( 'Settings', 'cartflows' );
|
155 |
-
$capability = 'manage_options';
|
156 |
-
$menu_slug = 'cartflows_settings';
|
157 |
-
$callback = __CLASS__ . '::render';
|
158 |
-
|
159 |
-
add_submenu_page(
|
160 |
-
$parent_slug,
|
161 |
-
$page_title,
|
162 |
-
$menu_title,
|
163 |
-
$capability,
|
164 |
-
$menu_slug,
|
165 |
-
$callback
|
166 |
-
);
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Renders the admin settings.
|
171 |
-
*
|
172 |
-
* @since 1.0.0
|
173 |
-
* @return void
|
174 |
-
*/
|
175 |
-
public static function render() {
|
176 |
-
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
177 |
-
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
178 |
-
$action = str_replace( '_', '-', $action );
|
179 |
-
|
180 |
-
// Enable header icon filter below.
|
181 |
-
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
182 |
-
|
183 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
|
184 |
-
}
|
185 |
-
|
186 |
-
/**
|
187 |
-
* Renders the admin settings content.
|
188 |
-
*
|
189 |
-
* @since 1.0.0
|
190 |
-
* @return void
|
191 |
-
*/
|
192 |
-
public static function render_content() {
|
193 |
-
|
194 |
-
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
195 |
-
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
196 |
-
$action = str_replace( '_', '-', $action );
|
197 |
-
$action = 'general';
|
198 |
-
|
199 |
-
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
200 |
-
|
201 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Save Global Setting options.
|
206 |
-
*
|
207 |
-
* @since 1.0.0
|
208 |
-
*/
|
209 |
-
public static function save_common_settings() {
|
210 |
-
|
211 |
-
if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
|
212 |
-
|
213 |
-
$url = $_SERVER['REQUEST_URI'];
|
214 |
-
$new_settings = array();
|
215 |
-
|
216 |
-
if ( isset( $_POST['_cartflows_common'] ) ) {
|
217 |
-
// Loop through the input and sanitize each of the values.
|
218 |
-
$new_settings = self::sanitize_form_inputs( $_POST['_cartflows_common'] );
|
219 |
-
}
|
220 |
-
|
221 |
-
Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, false );
|
222 |
-
|
223 |
-
$query = array(
|
224 |
-
'message' => 'saved',
|
225 |
-
);
|
226 |
-
|
227 |
-
$redirect_to = add_query_arg( $query, $url );
|
228 |
-
|
229 |
-
|
230 |
-
exit;
|
231 |
-
} // End if statement.
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* Save Debug Setting options.
|
236 |
-
*
|
237 |
-
* @since 1.1.14
|
238 |
-
*/
|
239 |
-
public static function save_debug_settings() {
|
240 |
-
|
241 |
-
if ( isset( $_POST['cartflows-debug-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-debug-settings-nonce'], 'cartflows-debug-settings' ) ) {
|
242 |
-
|
243 |
-
$url = $_SERVER['REQUEST_URI'];
|
244 |
-
$new_settings = array();
|
245 |
-
|
246 |
-
if ( isset( $_POST['_cartflows_debug_data'] ) ) {
|
247 |
-
$new_settings = self::sanitize_form_inputs( $_POST['_cartflows_debug_data'] );
|
248 |
-
}
|
249 |
-
|
250 |
-
Cartflows_Helper::update_admin_settings_option( '_cartflows_debug_data', $new_settings, false );
|
251 |
-
|
252 |
-
$query = array(
|
253 |
-
'message' => 'saved',
|
254 |
-
);
|
255 |
-
|
256 |
-
$redirect_to = add_query_arg( $query, $url );
|
257 |
-
|
258 |
-
|
259 |
-
exit;
|
260 |
-
|
261 |
-
}
|
262 |
-
}
|
263 |
-
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Save permalink Setting options.
|
267 |
-
*
|
268 |
-
* @since 1.1.14
|
269 |
-
*/
|
270 |
-
public static function save_permalink_settings() {
|
271 |
-
|
272 |
-
if ( isset( $_POST['cartflows-permalink-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-permalink-settings-nonce'], 'cartflows-permalink-settings' ) ) {
|
273 |
-
|
274 |
-
$url = $_SERVER['REQUEST_URI'];
|
275 |
-
$new_settings = array();
|
276 |
-
|
277 |
-
if ( isset( $_POST['reset'] ) ) {
|
278 |
-
$_POST['_cartflows_permalink'] = array(
|
279 |
-
'permalink' => CARTFLOWS_STEP_POST_TYPE,
|
280 |
-
'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE,
|
281 |
-
'permalink_structure' => '',
|
282 |
-
);
|
283 |
-
|
284 |
-
}
|
285 |
-
|
286 |
-
if ( isset( $_POST['_cartflows_permalink'] ) ) {
|
287 |
-
$cartflows_permalink_settings = self::sanitize_form_inputs( $_POST['_cartflows_permalink'] );
|
288 |
-
|
289 |
-
if ( empty( $cartflows_permalink_settings['permalink'] ) ) {
|
290 |
-
$new_settings['permalink'] = CARTFLOWS_STEP_POST_TYPE;
|
291 |
-
} else {
|
292 |
-
$new_settings['permalink'] = $cartflows_permalink_settings['permalink'];
|
293 |
-
}
|
294 |
-
|
295 |
-
if ( empty( $cartflows_permalink_settings['permalink_flow_base'] ) ) {
|
296 |
-
$new_settings['permalink_flow_base'] = CARTFLOWS_FLOW_POST_TYPE;
|
297 |
-
} else {
|
298 |
-
$new_settings['permalink_flow_base'] = $cartflows_permalink_settings['permalink_flow_base'];
|
299 |
-
}
|
300 |
-
|
301 |
-
$new_settings['permalink_structure'] = $cartflows_permalink_settings['permalink_structure'];
|
302 |
-
|
303 |
-
}
|
304 |
-
|
305 |
-
Cartflows_Helper::update_admin_settings_option( '_cartflows_permalink', $new_settings, false );
|
306 |
-
|
307 |
-
$query = array(
|
308 |
-
'message' => 'saved',
|
309 |
-
);
|
310 |
-
|
311 |
-
$redirect_to = add_query_arg( $query, $url );
|
312 |
-
|
313 |
-
update_option( 'cartflows_permalink_saved', true );
|
314 |
-
|
315 |
-
|
316 |
-
exit;
|
317 |
-
|
318 |
-
}
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Loop through the input and sanitize each of the values.
|
323 |
-
*
|
324 |
-
* @param array $input_settings input settings.
|
325 |
-
* @return array
|
326 |
-
*/
|
327 |
-
public static function sanitize_form_inputs( $input_settings = array() ) {
|
328 |
-
$new_settings = array();
|
329 |
-
foreach ( $input_settings as $key => $val ) {
|
330 |
-
|
331 |
-
if ( is_array( $val ) ) {
|
332 |
-
foreach ( $val as $k => $v ) {
|
333 |
-
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
|
334 |
-
}
|
335 |
-
} else {
|
336 |
-
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
337 |
-
}
|
338 |
-
}
|
339 |
-
return $new_settings;
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Check is cartflows admin.
|
344 |
-
*
|
345 |
-
* @since 1.0.0
|
346 |
-
* @return boolean
|
347 |
-
*/
|
348 |
-
public static function is_global_admin() {
|
349 |
-
|
350 |
-
$current_screen = get_current_screen();
|
351 |
-
|
352 |
-
if (
|
353 |
-
is_object( $current_screen ) &&
|
354 |
-
isset( $current_screen->post_type ) &&
|
355 |
-
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
|
356 |
-
CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
|
357 |
-
)
|
358 |
-
) {
|
359 |
-
return true;
|
360 |
-
}
|
361 |
-
return false;
|
362 |
-
}
|
363 |
-
|
364 |
-
/**
|
365 |
-
* Check is flow admin.
|
366 |
-
*
|
367 |
-
* @since 1.0.0
|
368 |
-
* @return boolean
|
369 |
-
*/
|
370 |
-
public static function is_flow_edit_admin() {
|
371 |
-
|
372 |
-
$current_screen = get_current_screen();
|
373 |
-
|
374 |
-
if (
|
375 |
-
is_object( $current_screen ) &&
|
376 |
-
isset( $current_screen->post_type ) &&
|
377 |
-
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
|
378 |
-
isset( $current_screen->base ) &&
|
379 |
-
( 'post' === $current_screen->base )
|
380 |
-
) {
|
381 |
-
return true;
|
382 |
-
}
|
383 |
-
return false;
|
384 |
-
}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Global Admin Scripts.
|
388 |
-
*
|
389 |
-
* @since 1.0.0
|
390 |
-
*/
|
391 |
-
public static function global_admin_scripts() {
|
392 |
-
|
393 |
-
$installed_plugins = get_plugins();
|
394 |
-
$is_wc_installed = isset( $installed_plugins['woocommerce/woocommerce.php'] ) ? true : false;
|
395 |
-
$edit_test_mode = filter_input( INPUT_GET, 'edit_test_mode', FILTER_SANITIZE_STRING );
|
396 |
-
$edit_test_mode = 'yes' === $edit_test_mode ? true : false;
|
397 |
-
|
398 |
-
$localize = array(
|
399 |
-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
400 |
-
'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
|
401 |
-
'wc_status' => array(
|
402 |
-
'installed' => $is_wc_installed,
|
403 |
-
'active' => wcf()->is_woo_active,
|
404 |
-
),
|
405 |
-
'wc_activating_message' => __( 'Installing and activating..', 'cartflows' ),
|
406 |
-
'wc_install_error' => __( 'There was an error with the installation of plugin.', 'cartflows' ),
|
407 |
-
'wcf_edit_test_mode' => $edit_test_mode,
|
408 |
-
);
|
409 |
-
|
410 |
-
wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
|
411 |
-
|
412 |
-
if ( self::is_global_admin() ) {
|
413 |
-
|
414 |
-
// Styles.
|
415 |
-
wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
|
416 |
-
wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
|
417 |
-
|
418 |
-
wp_enqueue_script(
|
419 |
-
'wcf-global-admin',
|
420 |
-
CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
|
421 |
-
array( 'jquery' ),
|
422 |
-
CARTFLOWS_VER,
|
423 |
-
true
|
424 |
-
);
|
425 |
-
|
426 |
-
do_action( 'cartflows_global_admin_scripts' );
|
427 |
-
}
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
* Global Admin Data.
|
432 |
-
*
|
433 |
-
* @since 1.0.0
|
434 |
-
*/
|
435 |
-
public static function global_admin_data() {
|
436 |
-
|
437 |
-
$current_screen = get_current_screen();
|
438 |
-
|
439 |
-
if ( ! $current_screen ) {
|
440 |
-
return;
|
441 |
-
}
|
442 |
-
|
443 |
-
if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
|
444 |
-
return;
|
445 |
-
}
|
446 |
-
|
447 |
-
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
448 |
-
?>
|
449 |
-
|
450 |
-
<div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
|
451 |
-
<div class="wcf-templates-popup-content">
|
452 |
-
<div class="spinner"></div>
|
453 |
-
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
454 |
-
|
455 |
-
<div id="wcf-remote-flow-actions" class="wcf-template-header">
|
456 |
-
<div class="wcf-template-logo-wrap">
|
457 |
-
<span class="wcf-cartflows-logo-img">
|
458 |
-
<span class="cartflows-logo-icon"></span>
|
459 |
-
</span>
|
460 |
-
<span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
|
461 |
-
</div>
|
462 |
-
<div class="wcf-tab-wrapper">
|
463 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
464 |
-
<div id="wcf-get-started-steps">
|
465 |
-
<ul class="filter-links ">
|
466 |
-
<li>
|
467 |
-
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
468 |
-
</li>
|
469 |
-
<li>
|
470 |
-
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
471 |
-
</li>
|
472 |
-
</ul>
|
473 |
-
</div>
|
474 |
-
<?php } ?>
|
475 |
-
</div>
|
476 |
-
<div class="wcf-popup-close-wrap">
|
477 |
-
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
478 |
-
</div>
|
479 |
-
</div>
|
480 |
-
<!-- <div class="wcf-search-form">
|
481 |
-
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
482 |
-
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
483 |
-
</div> -->
|
484 |
-
|
485 |
-
<div id="wcf-remote-content">
|
486 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
487 |
-
<div id="wcf-ready-templates">
|
488 |
-
<div id="wcf-remote-filters">
|
489 |
-
<div id="wcf-page-builders"></div>
|
490 |
-
<div id="wcf-categories"></div>
|
491 |
-
</div>
|
492 |
-
<div class="wcf-page-builder-notice"></div>
|
493 |
-
<div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
494 |
-
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
495 |
-
</div>
|
496 |
-
<?php } ?>
|
497 |
-
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
498 |
-
<div class="inner">
|
499 |
-
<a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
|
500 |
-
<p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
|
501 |
-
</div>
|
502 |
-
</div>
|
503 |
-
</div>
|
504 |
-
</div>
|
505 |
-
</div>
|
506 |
-
</div>
|
507 |
-
|
508 |
-
<?php
|
509 |
-
}
|
510 |
-
|
511 |
-
/**
|
512 |
-
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
513 |
-
*
|
514 |
-
* @since 1.0.0
|
515 |
-
*/
|
516 |
-
public static function styles_scripts() {
|
517 |
-
|
518 |
-
// Styles.
|
519 |
-
wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
|
520 |
-
wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
|
521 |
-
|
522 |
-
// Script.
|
523 |
-
wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
|
524 |
-
|
525 |
-
$localize = array(
|
526 |
-
'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
|
527 |
-
);
|
528 |
-
|
529 |
-
wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
|
530 |
-
|
531 |
-
do_action( 'cartflows_admin_settings_after_enqueue_scripts' );
|
532 |
-
}
|
533 |
-
|
534 |
-
/**
|
535 |
-
* Save All admin settings here
|
536 |
-
*/
|
537 |
-
public static function save_settings() {
|
538 |
-
|
539 |
-
// Only admins can save settings.
|
540 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
541 |
-
return;
|
542 |
-
}
|
543 |
-
|
544 |
-
self::save_common_settings();
|
545 |
-
self::save_debug_settings();
|
546 |
-
self::save_permalink_settings();
|
547 |
-
self::save_facebook_settings();
|
548 |
-
|
549 |
-
// Let extensions hook into saving.
|
550 |
-
do_action( 'cartflows_admin_settings_save' );
|
551 |
-
}
|
552 |
-
|
553 |
-
/**
|
554 |
-
* Get and return page URL
|
555 |
-
*
|
556 |
-
* @param string $menu_slug Menu name.
|
557 |
-
* @since 1.0.0
|
558 |
-
* @return string page url
|
559 |
-
*/
|
560 |
-
public static function get_page_url( $menu_slug ) {
|
561 |
-
|
562 |
-
$parent_page = self::$default_menu_position;
|
563 |
-
|
564 |
-
if ( strpos( $parent_page, '?' ) !== false ) {
|
565 |
-
$query_var = '&page=' . self::$plugin_slug;
|
566 |
-
} else {
|
567 |
-
$query_var = '?page=' . self::$plugin_slug;
|
568 |
-
}
|
569 |
-
|
570 |
-
$parent_page_url = admin_url( $parent_page . $query_var );
|
571 |
-
|
572 |
-
$url = $parent_page_url . '&action=' . $menu_slug;
|
573 |
-
|
574 |
-
return esc_url( $url );
|
575 |
-
}
|
576 |
-
|
577 |
-
/**
|
578 |
-
* Admin body classes.
|
579 |
-
*
|
580 |
-
* Body classes to be added to <body> tag in admin page
|
581 |
-
*
|
582 |
-
* @param String $classes body classes returned from the filter.
|
583 |
-
* @return String body classes to be added to <body> tag in admin page
|
584 |
-
*/
|
585 |
-
public static function add_admin_body_class( $classes ) {
|
586 |
-
|
587 |
-
$classes .= ' cartflows-' . CARTFLOWS_VER;
|
588 |
-
|
589 |
-
return $classes;
|
590 |
-
}
|
591 |
-
|
592 |
-
/**
|
593 |
-
* Save Global Setting options.
|
594 |
-
*
|
595 |
-
* @since 1.0.0
|
596 |
-
*/
|
597 |
-
public static function save_facebook_settings() {
|
598 |
-
|
599 |
-
if ( isset( $_POST['cartflows-facebook-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-facebook-settings-nonce'], 'cartflows-facebook-settings' ) ) {
|
600 |
-
|
601 |
-
$url = $_SERVER['REQUEST_URI'];
|
602 |
-
$new_settings = array();
|
603 |
-
|
604 |
-
if ( isset( $_POST['_cartflows_facebook'] ) ) {
|
605 |
-
$new_settings = self::sanitize_form_inputs( $_POST['_cartflows_facebook'] );
|
606 |
-
}
|
607 |
-
|
608 |
-
Cartflows_Helper::update_admin_settings_option( '_cartflows_facebook', $new_settings, false );
|
609 |
-
$query = array(
|
610 |
-
'message' => 'saved',
|
611 |
-
);
|
612 |
-
$redirect_to = add_query_arg( $query, $url );
|
613 |
-
|
614 |
-
exit;
|
615 |
-
}
|
616 |
-
}
|
617 |
-
|
618 |
-
}
|
619 |
-
|
620 |
-
Cartflows_Admin::init();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Admin.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Cartflows_Admin.
|
10 |
+
*/
|
11 |
+
class Cartflows_Admin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Calls on initialization
|
15 |
+
*
|
16 |
+
* @since 1.0.0
|
17 |
+
*/
|
18 |
+
public static function init() {
|
19 |
+
|
20 |
+
self::initialise_plugin();
|
21 |
+
self::init_hooks();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Init Hooks.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
public static function init_hooks() {
|
31 |
+
|
32 |
+
if ( ! is_admin() ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
|
37 |
+
|
38 |
+
/*
|
39 |
+
Add CARTFLOWS menu option to admin.
|
40 |
+
add_action( 'network_admin_menu', __CLASS__ . '::menu' );
|
41 |
+
*/
|
42 |
+
add_action( 'admin_menu', __CLASS__ . '::menu' );
|
43 |
+
add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
|
44 |
+
|
45 |
+
add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
|
46 |
+
|
47 |
+
add_action( 'admin_init', __CLASS__ . '::settings_admin_scripts' );
|
48 |
+
|
49 |
+
/* Global Addmin Script */
|
50 |
+
add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
|
51 |
+
|
52 |
+
add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
|
53 |
+
|
54 |
+
/* Add lite version class to body */
|
55 |
+
add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
|
56 |
+
|
57 |
+
add_filter( 'plugin_action_links_' . CARTFLOWS_BASE, __CLASS__ . '::add_action_links' );
|
58 |
+
|
59 |
+
add_action( 'admin_init', __CLASS__ . '::cartflows_after_save_permalinks' );
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* After save of permalinks.
|
65 |
+
*/
|
66 |
+
public static function cartflows_after_save_permalinks() {
|
67 |
+
|
68 |
+
$has_saved_permalinks = get_option( 'cartflows_permalink_saved' );
|
69 |
+
if ( $has_saved_permalinks ) {
|
70 |
+
flush_rewrite_rules();
|
71 |
+
delete_option( 'cartflows_permalink_saved' );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Initialize after Cartflows pro get loaded.
|
78 |
+
*/
|
79 |
+
public static function settings_admin_scripts() {
|
80 |
+
// Enqueue admin scripts.
|
81 |
+
if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
|
82 |
+
add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
|
83 |
+
|
84 |
+
self::save_settings();
|
85 |
+
}
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* Show action on plugin page.
|
89 |
+
*
|
90 |
+
* @param array $links links.
|
91 |
+
* @return array
|
92 |
+
*/
|
93 |
+
public static function add_action_links( $links ) {
|
94 |
+
$mylinks = array(
|
95 |
+
'<a href="' . admin_url( 'admin.php?page=' . CARTFLOWS_SETTINGS ) . '">Settings</a>',
|
96 |
+
'<a target="_blank" href="' . esc_url( 'https://cartflows.com/docs' ) . '">Docs</a>',
|
97 |
+
);
|
98 |
+
|
99 |
+
if ( ! _is_cartflows_pro() ) {
|
100 |
+
array_push( $mylinks, '<a style="color: #39b54a; font-weight: bold;" target="_blank" href="' . esc_url( 'https://cartflows.com/pricing/' ) . '"> Go Pro </a>' );
|
101 |
+
}
|
102 |
+
|
103 |
+
return array_merge( $links, $mylinks );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Initialises the Plugin Name.
|
108 |
+
*
|
109 |
+
* @since 1.0.0
|
110 |
+
* @return void
|
111 |
+
*/
|
112 |
+
public static function initialise_plugin() {
|
113 |
+
|
114 |
+
$name = 'Cartflows';
|
115 |
+
$short_name = 'Cflows';
|
116 |
+
|
117 |
+
define( 'CARTFLOWS_PLUGIN_NAME', $name );
|
118 |
+
define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Renders the admin settings menu.
|
123 |
+
*
|
124 |
+
* @since 1.0.0
|
125 |
+
* @return void
|
126 |
+
*/
|
127 |
+
public static function menu() {
|
128 |
+
|
129 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
130 |
+
return;
|
131 |
+
}
|
132 |
+
|
133 |
+
add_menu_page(
|
134 |
+
'CartFlows',
|
135 |
+
'CartFlows',
|
136 |
+
'manage_options',
|
137 |
+
CARTFLOWS_SLUG,
|
138 |
+
__CLASS__ . '::render',
|
139 |
+
'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),//phpcs:ignore
|
140 |
+
39.7
|
141 |
+
);
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Add submenu to admin menu.
|
147 |
+
*
|
148 |
+
* @since 1.0.0
|
149 |
+
*/
|
150 |
+
public static function submenu() {
|
151 |
+
|
152 |
+
$parent_slug = CARTFLOWS_SLUG;
|
153 |
+
$page_title = __( 'Settings', 'cartflows' );
|
154 |
+
$menu_title = __( 'Settings', 'cartflows' );
|
155 |
+
$capability = 'manage_options';
|
156 |
+
$menu_slug = 'cartflows_settings';
|
157 |
+
$callback = __CLASS__ . '::render';
|
158 |
+
|
159 |
+
add_submenu_page(
|
160 |
+
$parent_slug,
|
161 |
+
$page_title,
|
162 |
+
$menu_title,
|
163 |
+
$capability,
|
164 |
+
$menu_slug,
|
165 |
+
$callback
|
166 |
+
);
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Renders the admin settings.
|
171 |
+
*
|
172 |
+
* @since 1.0.0
|
173 |
+
* @return void
|
174 |
+
*/
|
175 |
+
public static function render() {
|
176 |
+
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : '';
|
177 |
+
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
178 |
+
$action = str_replace( '_', '-', $action );
|
179 |
+
|
180 |
+
// Enable header icon filter below.
|
181 |
+
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
182 |
+
|
183 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Renders the admin settings content.
|
188 |
+
*
|
189 |
+
* @since 1.0.0
|
190 |
+
* @return void
|
191 |
+
*/
|
192 |
+
public static function render_content() {
|
193 |
+
|
194 |
+
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : '';
|
195 |
+
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
196 |
+
$action = str_replace( '_', '-', $action );
|
197 |
+
$action = 'general';
|
198 |
+
|
199 |
+
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
200 |
+
|
201 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Save Global Setting options.
|
206 |
+
*
|
207 |
+
* @since 1.0.0
|
208 |
+
*/
|
209 |
+
public static function save_common_settings() {
|
210 |
+
|
211 |
+
if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['cartflows-common-settings-nonce'] ), 'cartflows-common-settings' ) ) {
|
212 |
+
|
213 |
+
$url = isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '';
|
214 |
+
$new_settings = array();
|
215 |
+
|
216 |
+
if ( isset( $_POST['_cartflows_common'] ) ) {
|
217 |
+
// Loop through the input and sanitize each of the values.
|
218 |
+
$new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_common'] ) );
|
219 |
+
}
|
220 |
+
|
221 |
+
Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, false );
|
222 |
+
|
223 |
+
$query = array(
|
224 |
+
'message' => 'saved',
|
225 |
+
);
|
226 |
+
|
227 |
+
$redirect_to = add_query_arg( $query, $url );
|
228 |
+
|
229 |
+
wp_safe_redirect( $redirect_to );
|
230 |
+
exit;
|
231 |
+
} // End if statement.
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Save Debug Setting options.
|
236 |
+
*
|
237 |
+
* @since 1.1.14
|
238 |
+
*/
|
239 |
+
public static function save_debug_settings() {
|
240 |
+
|
241 |
+
if ( isset( $_POST['cartflows-debug-settings-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['cartflows-debug-settings-nonce'] ), 'cartflows-debug-settings' ) ) {
|
242 |
+
|
243 |
+
$url = isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '';
|
244 |
+
$new_settings = array();
|
245 |
+
|
246 |
+
if ( isset( $_POST['_cartflows_debug_data'] ) ) {
|
247 |
+
$new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_debug_data'] ) );
|
248 |
+
}
|
249 |
+
|
250 |
+
Cartflows_Helper::update_admin_settings_option( '_cartflows_debug_data', $new_settings, false );
|
251 |
+
|
252 |
+
$query = array(
|
253 |
+
'message' => 'saved',
|
254 |
+
);
|
255 |
+
|
256 |
+
$redirect_to = add_query_arg( $query, $url );
|
257 |
+
|
258 |
+
wp_safe_redirect( $redirect_to );
|
259 |
+
exit;
|
260 |
+
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Save permalink Setting options.
|
267 |
+
*
|
268 |
+
* @since 1.1.14
|
269 |
+
*/
|
270 |
+
public static function save_permalink_settings() {
|
271 |
+
|
272 |
+
if ( isset( $_POST['cartflows-permalink-settings-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['cartflows-permalink-settings-nonce'] ), 'cartflows-permalink-settings' ) ) {
|
273 |
+
|
274 |
+
$url = isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '';
|
275 |
+
$new_settings = array();
|
276 |
+
|
277 |
+
if ( isset( $_POST['reset'] ) ) {
|
278 |
+
$_POST['_cartflows_permalink'] = array(
|
279 |
+
'permalink' => CARTFLOWS_STEP_POST_TYPE,
|
280 |
+
'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE,
|
281 |
+
'permalink_structure' => '',
|
282 |
+
);
|
283 |
+
|
284 |
+
}
|
285 |
+
|
286 |
+
if ( isset( $_POST['_cartflows_permalink'] ) ) {
|
287 |
+
$cartflows_permalink_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_permalink'] ) );
|
288 |
+
|
289 |
+
if ( empty( $cartflows_permalink_settings['permalink'] ) ) {
|
290 |
+
$new_settings['permalink'] = CARTFLOWS_STEP_POST_TYPE;
|
291 |
+
} else {
|
292 |
+
$new_settings['permalink'] = $cartflows_permalink_settings['permalink'];
|
293 |
+
}
|
294 |
+
|
295 |
+
if ( empty( $cartflows_permalink_settings['permalink_flow_base'] ) ) {
|
296 |
+
$new_settings['permalink_flow_base'] = CARTFLOWS_FLOW_POST_TYPE;
|
297 |
+
} else {
|
298 |
+
$new_settings['permalink_flow_base'] = $cartflows_permalink_settings['permalink_flow_base'];
|
299 |
+
}
|
300 |
+
|
301 |
+
$new_settings['permalink_structure'] = $cartflows_permalink_settings['permalink_structure'];
|
302 |
+
|
303 |
+
}
|
304 |
+
|
305 |
+
Cartflows_Helper::update_admin_settings_option( '_cartflows_permalink', $new_settings, false );
|
306 |
+
|
307 |
+
$query = array(
|
308 |
+
'message' => 'saved',
|
309 |
+
);
|
310 |
+
|
311 |
+
$redirect_to = add_query_arg( $query, $url );
|
312 |
+
|
313 |
+
update_option( 'cartflows_permalink_saved', true );
|
314 |
+
|
315 |
+
wp_safe_redirect( $redirect_to );
|
316 |
+
exit;
|
317 |
+
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Loop through the input and sanitize each of the values.
|
323 |
+
*
|
324 |
+
* @param array $input_settings input settings.
|
325 |
+
* @return array
|
326 |
+
*/
|
327 |
+
public static function sanitize_form_inputs( $input_settings = array() ) {
|
328 |
+
$new_settings = array();
|
329 |
+
foreach ( $input_settings as $key => $val ) {
|
330 |
+
|
331 |
+
if ( is_array( $val ) ) {
|
332 |
+
foreach ( $val as $k => $v ) {
|
333 |
+
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
|
334 |
+
}
|
335 |
+
} else {
|
336 |
+
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
337 |
+
}
|
338 |
+
}
|
339 |
+
return $new_settings;
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Check is cartflows admin.
|
344 |
+
*
|
345 |
+
* @since 1.0.0
|
346 |
+
* @return boolean
|
347 |
+
*/
|
348 |
+
public static function is_global_admin() {
|
349 |
+
|
350 |
+
$current_screen = get_current_screen();
|
351 |
+
|
352 |
+
if (
|
353 |
+
is_object( $current_screen ) &&
|
354 |
+
isset( $current_screen->post_type ) &&
|
355 |
+
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
|
356 |
+
CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
|
357 |
+
)
|
358 |
+
) {
|
359 |
+
return true;
|
360 |
+
}
|
361 |
+
return false;
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Check is flow admin.
|
366 |
+
*
|
367 |
+
* @since 1.0.0
|
368 |
+
* @return boolean
|
369 |
+
*/
|
370 |
+
public static function is_flow_edit_admin() {
|
371 |
+
|
372 |
+
$current_screen = get_current_screen();
|
373 |
+
|
374 |
+
if (
|
375 |
+
is_object( $current_screen ) &&
|
376 |
+
isset( $current_screen->post_type ) &&
|
377 |
+
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
|
378 |
+
isset( $current_screen->base ) &&
|
379 |
+
( 'post' === $current_screen->base )
|
380 |
+
) {
|
381 |
+
return true;
|
382 |
+
}
|
383 |
+
return false;
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Global Admin Scripts.
|
388 |
+
*
|
389 |
+
* @since 1.0.0
|
390 |
+
*/
|
391 |
+
public static function global_admin_scripts() {
|
392 |
+
|
393 |
+
$installed_plugins = get_plugins();
|
394 |
+
$is_wc_installed = isset( $installed_plugins['woocommerce/woocommerce.php'] ) ? true : false;
|
395 |
+
$edit_test_mode = filter_input( INPUT_GET, 'edit_test_mode', FILTER_SANITIZE_STRING );
|
396 |
+
$edit_test_mode = 'yes' === $edit_test_mode ? true : false;
|
397 |
+
|
398 |
+
$localize = array(
|
399 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
400 |
+
'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
|
401 |
+
'wc_status' => array(
|
402 |
+
'installed' => $is_wc_installed,
|
403 |
+
'active' => wcf()->is_woo_active,
|
404 |
+
),
|
405 |
+
'wc_activating_message' => __( 'Installing and activating..', 'cartflows' ),
|
406 |
+
'wc_install_error' => __( 'There was an error with the installation of plugin.', 'cartflows' ),
|
407 |
+
'wcf_edit_test_mode' => $edit_test_mode,
|
408 |
+
);
|
409 |
+
|
410 |
+
wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
|
411 |
+
|
412 |
+
if ( self::is_global_admin() ) {
|
413 |
+
|
414 |
+
// Styles.
|
415 |
+
wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
|
416 |
+
wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
|
417 |
+
|
418 |
+
wp_enqueue_script(
|
419 |
+
'wcf-global-admin',
|
420 |
+
CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
|
421 |
+
array( 'jquery' ),
|
422 |
+
CARTFLOWS_VER,
|
423 |
+
true
|
424 |
+
);
|
425 |
+
|
426 |
+
do_action( 'cartflows_global_admin_scripts' );
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Global Admin Data.
|
432 |
+
*
|
433 |
+
* @since 1.0.0
|
434 |
+
*/
|
435 |
+
public static function global_admin_data() {
|
436 |
+
|
437 |
+
$current_screen = get_current_screen();
|
438 |
+
|
439 |
+
if ( ! $current_screen ) {
|
440 |
+
return;
|
441 |
+
}
|
442 |
+
|
443 |
+
if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
|
444 |
+
return;
|
445 |
+
}
|
446 |
+
|
447 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
448 |
+
?>
|
449 |
+
|
450 |
+
<div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
|
451 |
+
<div class="wcf-templates-popup-content">
|
452 |
+
<div class="spinner"></div>
|
453 |
+
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
454 |
+
|
455 |
+
<div id="wcf-remote-flow-actions" class="wcf-template-header">
|
456 |
+
<div class="wcf-template-logo-wrap">
|
457 |
+
<span class="wcf-cartflows-logo-img">
|
458 |
+
<span class="cartflows-logo-icon"></span>
|
459 |
+
</span>
|
460 |
+
<span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
|
461 |
+
</div>
|
462 |
+
<div class="wcf-tab-wrapper">
|
463 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
464 |
+
<div id="wcf-get-started-steps">
|
465 |
+
<ul class="filter-links ">
|
466 |
+
<li>
|
467 |
+
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
468 |
+
</li>
|
469 |
+
<li>
|
470 |
+
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
471 |
+
</li>
|
472 |
+
</ul>
|
473 |
+
</div>
|
474 |
+
<?php } ?>
|
475 |
+
</div>
|
476 |
+
<div class="wcf-popup-close-wrap">
|
477 |
+
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
478 |
+
</div>
|
479 |
+
</div>
|
480 |
+
<!-- <div class="wcf-search-form">
|
481 |
+
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
482 |
+
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
483 |
+
</div> -->
|
484 |
+
|
485 |
+
<div id="wcf-remote-content">
|
486 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
487 |
+
<div id="wcf-ready-templates">
|
488 |
+
<div id="wcf-remote-filters">
|
489 |
+
<div id="wcf-page-builders"></div>
|
490 |
+
<div id="wcf-categories"></div>
|
491 |
+
</div>
|
492 |
+
<div class="wcf-page-builder-notice"></div>
|
493 |
+
<div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
494 |
+
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
495 |
+
</div>
|
496 |
+
<?php } ?>
|
497 |
+
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
498 |
+
<div class="inner">
|
499 |
+
<a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
|
500 |
+
<p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
|
501 |
+
</div>
|
502 |
+
</div>
|
503 |
+
</div>
|
504 |
+
</div>
|
505 |
+
</div>
|
506 |
+
</div>
|
507 |
+
|
508 |
+
<?php
|
509 |
+
}
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
513 |
+
*
|
514 |
+
* @since 1.0.0
|
515 |
+
*/
|
516 |
+
public static function styles_scripts() {
|
517 |
+
|
518 |
+
// Styles.
|
519 |
+
wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
|
520 |
+
wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
|
521 |
+
|
522 |
+
// Script.
|
523 |
+
wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER, false );
|
524 |
+
|
525 |
+
$localize = array(
|
526 |
+
'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
|
527 |
+
);
|
528 |
+
|
529 |
+
wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
|
530 |
+
|
531 |
+
do_action( 'cartflows_admin_settings_after_enqueue_scripts' );
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Save All admin settings here
|
536 |
+
*/
|
537 |
+
public static function save_settings() {
|
538 |
+
|
539 |
+
// Only admins can save settings.
|
540 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
541 |
+
return;
|
542 |
+
}
|
543 |
+
|
544 |
+
self::save_common_settings();
|
545 |
+
self::save_debug_settings();
|
546 |
+
self::save_permalink_settings();
|
547 |
+
self::save_facebook_settings();
|
548 |
+
|
549 |
+
// Let extensions hook into saving.
|
550 |
+
do_action( 'cartflows_admin_settings_save' );
|
551 |
+
}
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Get and return page URL
|
555 |
+
*
|
556 |
+
* @param string $menu_slug Menu name.
|
557 |
+
* @since 1.0.0
|
558 |
+
* @return string page url
|
559 |
+
*/
|
560 |
+
public static function get_page_url( $menu_slug ) {
|
561 |
+
|
562 |
+
$parent_page = self::$default_menu_position;
|
563 |
+
|
564 |
+
if ( strpos( $parent_page, '?' ) !== false ) {
|
565 |
+
$query_var = '&page=' . self::$plugin_slug;
|
566 |
+
} else {
|
567 |
+
$query_var = '?page=' . self::$plugin_slug;
|
568 |
+
}
|
569 |
+
|
570 |
+
$parent_page_url = admin_url( $parent_page . $query_var );
|
571 |
+
|
572 |
+
$url = $parent_page_url . '&action=' . $menu_slug;
|
573 |
+
|
574 |
+
return esc_url( $url );
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Admin body classes.
|
579 |
+
*
|
580 |
+
* Body classes to be added to <body> tag in admin page
|
581 |
+
*
|
582 |
+
* @param String $classes body classes returned from the filter.
|
583 |
+
* @return String body classes to be added to <body> tag in admin page
|
584 |
+
*/
|
585 |
+
public static function add_admin_body_class( $classes ) {
|
586 |
+
|
587 |
+
$classes .= ' cartflows-' . CARTFLOWS_VER;
|
588 |
+
|
589 |
+
return $classes;
|
590 |
+
}
|
591 |
+
|
592 |
+
/**
|
593 |
+
* Save Global Setting options.
|
594 |
+
*
|
595 |
+
* @since 1.0.0
|
596 |
+
*/
|
597 |
+
public static function save_facebook_settings() {
|
598 |
+
|
599 |
+
if ( isset( $_POST['cartflows-facebook-settings-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['cartflows-facebook-settings-nonce'] ), 'cartflows-facebook-settings' ) ) {
|
600 |
+
|
601 |
+
$url = isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '';
|
602 |
+
$new_settings = array();
|
603 |
+
|
604 |
+
if ( isset( $_POST['_cartflows_facebook'] ) ) {
|
605 |
+
$new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_facebook'] ) );
|
606 |
+
}
|
607 |
+
|
608 |
+
Cartflows_Helper::update_admin_settings_option( '_cartflows_facebook', $new_settings, false );
|
609 |
+
$query = array(
|
610 |
+
'message' => 'saved',
|
611 |
+
);
|
612 |
+
$redirect_to = add_query_arg( $query, $url );
|
613 |
+
wp_safe_redirect( $redirect_to );
|
614 |
+
exit;
|
615 |
+
}
|
616 |
+
}
|
617 |
+
|
618 |
+
}
|
619 |
+
|
620 |
+
Cartflows_Admin::init();
|
classes/class-cartflows-api.php
CHANGED
@@ -1,381 +1,381 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows API
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'CartFlows_API' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows API
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class CartFlows_API {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @access private
|
22 |
-
* @var object Class object.
|
23 |
-
* @since 1.0.0
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Initiator
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
* @return object initialized object of class.
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
if ( ! isset( self::$instance ) ) {
|
35 |
-
self::$instance = new self();
|
36 |
-
}
|
37 |
-
return self::$instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor
|
42 |
-
*
|
43 |
-
* @since 1.0.0
|
44 |
-
*/
|
45 |
-
public function __construct() {
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Get site URL.
|
50 |
-
*
|
51 |
-
* @since 1.0.0
|
52 |
-
*
|
53 |
-
* @return string Site URL.
|
54 |
-
*/
|
55 |
-
public static function get_site_url() {
|
56 |
-
return apply_filters( 'cartflows_templates_url', CARTFLOWS_TEMPLATES_URL );
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Get Client Site Templates Rest API URL.
|
61 |
-
*
|
62 |
-
* @since 1.0.0
|
63 |
-
*
|
64 |
-
* @return string API site URL.
|
65 |
-
*/
|
66 |
-
public static function get_step_endpoint_url() {
|
67 |
-
return self::get_site_url() . 'wp-json/wp/v2/' . CARTFLOWS_STEP_POST_TYPE . '/';
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Get Client Site Category Rest API URL.
|
72 |
-
*
|
73 |
-
* @since 1.0.0
|
74 |
-
*
|
75 |
-
* @return string API site URL.
|
76 |
-
*/
|
77 |
-
public static function get_category_endpoint_url() {
|
78 |
-
return self::get_site_url() . 'wp-json/wp/v2/' . CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER . '/';
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Get API request URL.
|
83 |
-
*
|
84 |
-
* @since 1.0.0
|
85 |
-
*
|
86 |
-
* @param string $api_base base of api request.
|
87 |
-
* @return string API site URL.
|
88 |
-
*/
|
89 |
-
public static function get_request_api_url( $api_base = '' ) {
|
90 |
-
return self::get_site_url() . 'wp-json/' . CARTFLOWS_STEP_POST_TYPE . '/v1/' . $api_base;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* License Args.
|
95 |
-
*
|
96 |
-
* @return array License arguments.
|
97 |
-
*/
|
98 |
-
public static function get_licence_args() {
|
99 |
-
return apply_filters( 'cartflows_licence_args', array() );
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Get single demo.
|
104 |
-
*
|
105 |
-
* @since 1.0.0
|
106 |
-
*
|
107 |
-
* @param string $site_id Template ID of the site.
|
108 |
-
* @return array Template data.
|
109 |
-
*/
|
110 |
-
public static function get_template( $site_id ) {
|
111 |
-
// @codingStandardsIgnoreStart
|
112 |
-
$request_params = array(
|
113 |
-
'licence_args' => self::get_licence_args(),
|
114 |
-
'_fields' => 'id,slug,status,type,link,title,featured_media,template,cartflows_step_page_builder,cartflows_step_type,cartflows_step_flow,featured_image_url,licence_status,flow_type,step_type,page_builder,divi_content,post_meta',
|
115 |
-
);
|
116 |
-
// @codingStandardsIgnoreEnd
|
117 |
-
|
118 |
-
$url = add_query_arg( $request_params, self::get_step_endpoint_url() . $site_id );
|
119 |
-
|
120 |
-
$api_args = array(
|
121 |
-
'timeout' => 15,
|
122 |
-
);
|
123 |
-
|
124 |
-
$response = self::remote_get( $url, $api_args );
|
125 |
-
|
126 |
-
if ( $response['success'] ) {
|
127 |
-
$template = $response['data'];
|
128 |
-
return array(
|
129 |
-
'title' => ( isset( $template['title']->rendered ) ) ? $template['title']->rendered : '',
|
130 |
-
'post_meta' => ( isset( $template['post_meta'] ) ) ? $template['post_meta'] : '',
|
131 |
-
'data' => $template,
|
132 |
-
'divi_content' => isset( $response['data']['divi_content'] ) ? $response['data']['divi_content'] : '',
|
133 |
-
'message' => $response['message'], //
|
134 |
-
'success' => $response['success'],
|
135 |
-
);
|
136 |
-
}
|
137 |
-
|
138 |
-
return array(
|
139 |
-
'title' => '',
|
140 |
-
'post_meta' => array(),
|
141 |
-
'message' => $response['message'],
|
142 |
-
'data' => $response['data'],
|
143 |
-
'divi_content' => '',
|
144 |
-
'success' => $response['success'],
|
145 |
-
);
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Get Cloud Templates
|
150 |
-
*
|
151 |
-
* @since 1.0.0
|
152 |
-
*
|
153 |
-
* @param array $args For selecting the demos (Search terms, pagination etc).
|
154 |
-
* @return array CartFlows list.
|
155 |
-
*/
|
156 |
-
public static function get_templates( $args = array() ) {
|
157 |
-
|
158 |
-
$request_params = wp_parse_args(
|
159 |
-
$args,
|
160 |
-
array(
|
161 |
-
'page' => '1',
|
162 |
-
'per_page' => '15',
|
163 |
-
)
|
164 |
-
);
|
165 |
-
|
166 |
-
$url = add_query_arg( $request_params, self::get_step_endpoint_url() );
|
167 |
-
|
168 |
-
$api_args = array(
|
169 |
-
'timeout' => 15,
|
170 |
-
);
|
171 |
-
|
172 |
-
$response = self::remote_get( $url, $api_args );
|
173 |
-
|
174 |
-
if ( $response['success'] ) {
|
175 |
-
$templates_data = $response['data'];
|
176 |
-
$templates = array();
|
177 |
-
foreach ( $templates_data as $key => $template ) {
|
178 |
-
|
179 |
-
if ( ! isset( $template->id ) ) {
|
180 |
-
continue;
|
181 |
-
}
|
182 |
-
|
183 |
-
$templates[ $key ]['id'] = isset( $template->id ) ? esc_attr( $template->id ) : '';
|
184 |
-
$templates[ $key ]['slug'] = isset( $template->slug ) ? esc_attr( $template->slug ) : '';
|
185 |
-
$templates[ $key ]['link'] = isset( $template->link ) ? esc_url( $template->link ) : '';
|
186 |
-
$templates[ $key ]['date'] = isset( $template->date ) ? esc_attr( $template->date ) : '';
|
187 |
-
$templates[ $key ]['title'] = isset( $template->title->rendered ) ? esc_attr( $template->title->rendered ) : '';
|
188 |
-
$templates[ $key ]['featured_image_url'] = isset( $template->featured_image_url ) ? esc_url( $template->featured_image_url ) : '';
|
189 |
-
$templates[ $key ]['content'] = isset( $template->content->rendered ) ? $template->content->rendered : '';
|
190 |
-
$templates[ $key ]['divi_content'] = isset( $template->divi_content ) ? $template->divi_content : '';
|
191 |
-
$templates[ $key ]['post_meta'] = isset( $template->post_meta ) ? $template->post_meta : '';
|
192 |
-
}
|
193 |
-
|
194 |
-
return array(
|
195 |
-
'templates' => $templates,
|
196 |
-
'templates_count' => $response['count'],
|
197 |
-
'data' => $response,
|
198 |
-
);
|
199 |
-
}
|
200 |
-
|
201 |
-
return array(
|
202 |
-
'templates' => array(),
|
203 |
-
'templates_count' => 0,
|
204 |
-
'data' => $response,
|
205 |
-
);
|
206 |
-
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Get categories.
|
211 |
-
*
|
212 |
-
* @since 1.0.0
|
213 |
-
* @param array $args Arguments.
|
214 |
-
* @return array Category data.
|
215 |
-
*/
|
216 |
-
public static function get_categories( $args = array() ) {
|
217 |
-
|
218 |
-
$request_params = apply_filters(
|
219 |
-
'cartflows_categories_api_params',
|
220 |
-
wp_parse_args(
|
221 |
-
$args,
|
222 |
-
array(
|
223 |
-
'page' => '1',
|
224 |
-
'per_page' => '15',
|
225 |
-
)
|
226 |
-
)
|
227 |
-
);
|
228 |
-
|
229 |
-
$url = add_query_arg( $request_params, self::get_category_endpoint_url() );
|
230 |
-
|
231 |
-
$api_args = apply_filters(
|
232 |
-
'cartflows_api_args',
|
233 |
-
array(
|
234 |
-
'timeout' => 15,
|
235 |
-
)
|
236 |
-
);
|
237 |
-
|
238 |
-
$response = self::remote_get( $url, $api_args );
|
239 |
-
|
240 |
-
if ( $response['success'] ) {
|
241 |
-
$categories_data = $response['data'];
|
242 |
-
$categories = array();
|
243 |
-
|
244 |
-
foreach ( $categories_data as $key => $category ) {
|
245 |
-
if ( isset( $category->count ) && ! empty( $category->count ) ) {
|
246 |
-
$categories[] = array(
|
247 |
-
'id' => isset( $category->id ) ? absint( $category->id ) : 0,
|
248 |
-
'count' => isset( $category->count ) ? absint( $category->count ) : 0,
|
249 |
-
'description' => isset( $category->description ) ? $category->description : '',
|
250 |
-
'link' => isset( $category->link ) ? esc_url( $category->link ) : '',
|
251 |
-
'name' => isset( $category->name ) ? $category->name : '',
|
252 |
-
'slug' => isset( $category->slug ) ? sanitize_text_field( $category->slug ) : '',
|
253 |
-
'taxonomy' => isset( $category->taxonomy ) ? $category->taxonomy : '',
|
254 |
-
'parent' => isset( $category->parent ) ? $category->parent : '',
|
255 |
-
);
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
return array(
|
260 |
-
'categories' => $categories,
|
261 |
-
'categories_count' => $response['count'],
|
262 |
-
'data' => $response,
|
263 |
-
);
|
264 |
-
}
|
265 |
-
|
266 |
-
return array(
|
267 |
-
'categories' => array(),
|
268 |
-
'categories_count' => 0,
|
269 |
-
'data' => $response,
|
270 |
-
);
|
271 |
-
}
|
272 |
-
|
273 |
-
/**
|
274 |
-
* Remote GET API Request
|
275 |
-
*
|
276 |
-
* @since 1.0.0
|
277 |
-
*
|
278 |
-
* @param string $url Target server API URL.
|
279 |
-
* @param array $args Array of arguments for the API request.
|
280 |
-
* @return mixed Return the API request result.
|
281 |
-
*/
|
282 |
-
public static function remote_get( $url = '', $args = array() ) {
|
283 |
-
$request = wp_remote_get( $url, $args );
|
284 |
-
return self::request( $request );
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Remote POST API Request
|
289 |
-
*
|
290 |
-
* @since 1.0.0
|
291 |
-
*
|
292 |
-
* @param string $url Target server API URL.
|
293 |
-
* @param array $args Array of arguments for the API request.
|
294 |
-
* @return mixed Return the API request result.
|
295 |
-
*/
|
296 |
-
public static function remote_post( $url = '', $args = array() ) {
|
297 |
-
$request = wp_remote_post( $url, $args );
|
298 |
-
|
299 |
-
return self::request( $request );
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Site API Request
|
304 |
-
*
|
305 |
-
* @since 1.0.0
|
306 |
-
*
|
307 |
-
* @param boolean $api_base Target server API URL.
|
308 |
-
* @param array $args Array of arguments for the API request.
|
309 |
-
* @return mixed Return the API request result.
|
310 |
-
*/
|
311 |
-
public static function site_request( $api_base = '', $args = array() ) {
|
312 |
-
|
313 |
-
$api_url = self::get_request_api_url( $api_base );
|
314 |
-
|
315 |
-
return self::remote_post( $api_url, $args );
|
316 |
-
}
|
317 |
-
|
318 |
-
/**
|
319 |
-
* API Request
|
320 |
-
*
|
321 |
-
* Handle the API request and return the result.
|
322 |
-
*
|
323 |
-
* @since 1.0.0
|
324 |
-
*
|
325 |
-
* @param array $request Array of arguments for the API request.
|
326 |
-
* @return mixed Return the API request result.
|
327 |
-
*/
|
328 |
-
public static function request( $request ) {
|
329 |
-
|
330 |
-
// Is WP Error?
|
331 |
-
if ( is_wp_error( $request ) ) {
|
332 |
-
return array(
|
333 |
-
'success' => false,
|
334 |
-
'message' => $request->get_error_message(),
|
335 |
-
'data' => $request,
|
336 |
-
'count' => 0,
|
337 |
-
);
|
338 |
-
}
|
339 |
-
|
340 |
-
// Invalid response code.
|
341 |
-
if ( wp_remote_retrieve_response_code( $request ) != 200 ) {
|
342 |
-
return array(
|
343 |
-
'success' => false,
|
344 |
-
'message' => $request['response'],
|
345 |
-
'data' => $request,
|
346 |
-
'count' => 0,
|
347 |
-
);
|
348 |
-
}
|
349 |
-
|
350 |
-
// Get body data.
|
351 |
-
$body = wp_remote_retrieve_body( $request );
|
352 |
-
|
353 |
-
// Is WP Error?
|
354 |
-
if ( is_wp_error( $body ) ) {
|
355 |
-
return array(
|
356 |
-
'success' => false,
|
357 |
-
'message' => $body->get_error_message(),
|
358 |
-
'data' => $request,
|
359 |
-
'count' => 0,
|
360 |
-
);
|
361 |
-
}
|
362 |
-
|
363 |
-
// Decode body content.
|
364 |
-
$body_decoded = json_decode( $body );
|
365 |
-
|
366 |
-
return array(
|
367 |
-
'success' => true,
|
368 |
-
'message' => __( 'Request successfully processed!', 'cartflows' ),
|
369 |
-
'data' => (array) $body_decoded,
|
370 |
-
'count' => wp_remote_retrieve_header( $request, 'x-wp-total' ),
|
371 |
-
);
|
372 |
-
}
|
373 |
-
|
374 |
-
}
|
375 |
-
|
376 |
-
/**
|
377 |
-
* Initialize class object with 'get_instance()' method
|
378 |
-
*/
|
379 |
-
CartFlows_API::get_instance();
|
380 |
-
|
381 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows API
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_API' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows API
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class CartFlows_API {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @access private
|
22 |
+
* @var object Class object.
|
23 |
+
* @since 1.0.0
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initiator
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @return object initialized object of class.
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self();
|
36 |
+
}
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor
|
42 |
+
*
|
43 |
+
* @since 1.0.0
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get site URL.
|
50 |
+
*
|
51 |
+
* @since 1.0.0
|
52 |
+
*
|
53 |
+
* @return string Site URL.
|
54 |
+
*/
|
55 |
+
public static function get_site_url() {
|
56 |
+
return apply_filters( 'cartflows_templates_url', CARTFLOWS_TEMPLATES_URL );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Get Client Site Templates Rest API URL.
|
61 |
+
*
|
62 |
+
* @since 1.0.0
|
63 |
+
*
|
64 |
+
* @return string API site URL.
|
65 |
+
*/
|
66 |
+
public static function get_step_endpoint_url() {
|
67 |
+
return self::get_site_url() . 'wp-json/wp/v2/' . CARTFLOWS_STEP_POST_TYPE . '/';
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get Client Site Category Rest API URL.
|
72 |
+
*
|
73 |
+
* @since 1.0.0
|
74 |
+
*
|
75 |
+
* @return string API site URL.
|
76 |
+
*/
|
77 |
+
public static function get_category_endpoint_url() {
|
78 |
+
return self::get_site_url() . 'wp-json/wp/v2/' . CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER . '/';
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Get API request URL.
|
83 |
+
*
|
84 |
+
* @since 1.0.0
|
85 |
+
*
|
86 |
+
* @param string $api_base base of api request.
|
87 |
+
* @return string API site URL.
|
88 |
+
*/
|
89 |
+
public static function get_request_api_url( $api_base = '' ) {
|
90 |
+
return self::get_site_url() . 'wp-json/' . CARTFLOWS_STEP_POST_TYPE . '/v1/' . $api_base;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* License Args.
|
95 |
+
*
|
96 |
+
* @return array License arguments.
|
97 |
+
*/
|
98 |
+
public static function get_licence_args() {
|
99 |
+
return apply_filters( 'cartflows_licence_args', array() );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get single demo.
|
104 |
+
*
|
105 |
+
* @since 1.0.0
|
106 |
+
*
|
107 |
+
* @param string $site_id Template ID of the site.
|
108 |
+
* @return array Template data.
|
109 |
+
*/
|
110 |
+
public static function get_template( $site_id ) {
|
111 |
+
// @codingStandardsIgnoreStart
|
112 |
+
$request_params = array(
|
113 |
+
'licence_args' => self::get_licence_args(),
|
114 |
+
'_fields' => 'id,slug,status,type,link,title,featured_media,template,cartflows_step_page_builder,cartflows_step_type,cartflows_step_flow,featured_image_url,licence_status,flow_type,step_type,page_builder,divi_content,post_meta',
|
115 |
+
);
|
116 |
+
// @codingStandardsIgnoreEnd
|
117 |
+
|
118 |
+
$url = add_query_arg( $request_params, self::get_step_endpoint_url() . $site_id );
|
119 |
+
|
120 |
+
$api_args = array(
|
121 |
+
'timeout' => 15,
|
122 |
+
);
|
123 |
+
|
124 |
+
$response = self::remote_get( $url, $api_args );
|
125 |
+
|
126 |
+
if ( $response['success'] ) {
|
127 |
+
$template = $response['data'];
|
128 |
+
return array(
|
129 |
+
'title' => ( isset( $template['title']->rendered ) ) ? $template['title']->rendered : '',
|
130 |
+
'post_meta' => ( isset( $template['post_meta'] ) ) ? $template['post_meta'] : '',
|
131 |
+
'data' => $template,
|
132 |
+
'divi_content' => isset( $response['data']['divi_content'] ) ? $response['data']['divi_content'] : '',
|
133 |
+
'message' => $response['message'], // Your API Key is not valid. Please add valid API Key.
|
134 |
+
'success' => $response['success'],
|
135 |
+
);
|
136 |
+
}
|
137 |
+
|
138 |
+
return array(
|
139 |
+
'title' => '',
|
140 |
+
'post_meta' => array(),
|
141 |
+
'message' => $response['message'],
|
142 |
+
'data' => $response['data'],
|
143 |
+
'divi_content' => '',
|
144 |
+
'success' => $response['success'],
|
145 |
+
);
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Get Cloud Templates
|
150 |
+
*
|
151 |
+
* @since 1.0.0
|
152 |
+
*
|
153 |
+
* @param array $args For selecting the demos (Search terms, pagination etc).
|
154 |
+
* @return array CartFlows list.
|
155 |
+
*/
|
156 |
+
public static function get_templates( $args = array() ) {
|
157 |
+
|
158 |
+
$request_params = wp_parse_args(
|
159 |
+
$args,
|
160 |
+
array(
|
161 |
+
'page' => '1',
|
162 |
+
'per_page' => '15',
|
163 |
+
)
|
164 |
+
);
|
165 |
+
|
166 |
+
$url = add_query_arg( $request_params, self::get_step_endpoint_url() );
|
167 |
+
|
168 |
+
$api_args = array(
|
169 |
+
'timeout' => 15,
|
170 |
+
);
|
171 |
+
|
172 |
+
$response = self::remote_get( $url, $api_args );
|
173 |
+
|
174 |
+
if ( $response['success'] ) {
|
175 |
+
$templates_data = $response['data'];
|
176 |
+
$templates = array();
|
177 |
+
foreach ( $templates_data as $key => $template ) {
|
178 |
+
|
179 |
+
if ( ! isset( $template->id ) ) {
|
180 |
+
continue;
|
181 |
+
}
|
182 |
+
|
183 |
+
$templates[ $key ]['id'] = isset( $template->id ) ? esc_attr( $template->id ) : '';
|
184 |
+
$templates[ $key ]['slug'] = isset( $template->slug ) ? esc_attr( $template->slug ) : '';
|
185 |
+
$templates[ $key ]['link'] = isset( $template->link ) ? esc_url( $template->link ) : '';
|
186 |
+
$templates[ $key ]['date'] = isset( $template->date ) ? esc_attr( $template->date ) : '';
|
187 |
+
$templates[ $key ]['title'] = isset( $template->title->rendered ) ? esc_attr( $template->title->rendered ) : '';
|
188 |
+
$templates[ $key ]['featured_image_url'] = isset( $template->featured_image_url ) ? esc_url( $template->featured_image_url ) : '';
|
189 |
+
$templates[ $key ]['content'] = isset( $template->content->rendered ) ? $template->content->rendered : '';
|
190 |
+
$templates[ $key ]['divi_content'] = isset( $template->divi_content ) ? $template->divi_content : '';
|
191 |
+
$templates[ $key ]['post_meta'] = isset( $template->post_meta ) ? $template->post_meta : '';
|
192 |
+
}
|
193 |
+
|
194 |
+
return array(
|
195 |
+
'templates' => $templates,
|
196 |
+
'templates_count' => $response['count'],
|
197 |
+
'data' => $response,
|
198 |
+
);
|
199 |
+
}
|
200 |
+
|
201 |
+
return array(
|
202 |
+
'templates' => array(),
|
203 |
+
'templates_count' => 0,
|
204 |
+
'data' => $response,
|
205 |
+
);
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Get categories.
|
211 |
+
*
|
212 |
+
* @since 1.0.0
|
213 |
+
* @param array $args Arguments.
|
214 |
+
* @return array Category data.
|
215 |
+
*/
|
216 |
+
public static function get_categories( $args = array() ) {
|
217 |
+
|
218 |
+
$request_params = apply_filters(
|
219 |
+
'cartflows_categories_api_params',
|
220 |
+
wp_parse_args(
|
221 |
+
$args,
|
222 |
+
array(
|
223 |
+
'page' => '1',
|
224 |
+
'per_page' => '15',
|
225 |
+
)
|
226 |
+
)
|
227 |
+
);
|
228 |
+
|
229 |
+
$url = add_query_arg( $request_params, self::get_category_endpoint_url() );
|
230 |
+
|
231 |
+
$api_args = apply_filters(
|
232 |
+
'cartflows_api_args',
|
233 |
+
array(
|
234 |
+
'timeout' => 15,
|
235 |
+
)
|
236 |
+
);
|
237 |
+
|
238 |
+
$response = self::remote_get( $url, $api_args );
|
239 |
+
|
240 |
+
if ( $response['success'] ) {
|
241 |
+
$categories_data = $response['data'];
|
242 |
+
$categories = array();
|
243 |
+
|
244 |
+
foreach ( $categories_data as $key => $category ) {
|
245 |
+
if ( isset( $category->count ) && ! empty( $category->count ) ) {
|
246 |
+
$categories[] = array(
|
247 |
+
'id' => isset( $category->id ) ? absint( $category->id ) : 0,
|
248 |
+
'count' => isset( $category->count ) ? absint( $category->count ) : 0,
|
249 |
+
'description' => isset( $category->description ) ? $category->description : '',
|
250 |
+
'link' => isset( $category->link ) ? esc_url( $category->link ) : '',
|
251 |
+
'name' => isset( $category->name ) ? $category->name : '',
|
252 |
+
'slug' => isset( $category->slug ) ? sanitize_text_field( $category->slug ) : '',
|
253 |
+
'taxonomy' => isset( $category->taxonomy ) ? $category->taxonomy : '',
|
254 |
+
'parent' => isset( $category->parent ) ? $category->parent : '',
|
255 |
+
);
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
return array(
|
260 |
+
'categories' => $categories,
|
261 |
+
'categories_count' => $response['count'],
|
262 |
+
'data' => $response,
|
263 |
+
);
|
264 |
+
}
|
265 |
+
|
266 |
+
return array(
|
267 |
+
'categories' => array(),
|
268 |
+
'categories_count' => 0,
|
269 |
+
'data' => $response,
|
270 |
+
);
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Remote GET API Request
|
275 |
+
*
|
276 |
+
* @since 1.0.0
|
277 |
+
*
|
278 |
+
* @param string $url Target server API URL.
|
279 |
+
* @param array $args Array of arguments for the API request.
|
280 |
+
* @return mixed Return the API request result.
|
281 |
+
*/
|
282 |
+
public static function remote_get( $url = '', $args = array() ) {
|
283 |
+
$request = wp_remote_get( $url, $args );
|
284 |
+
return self::request( $request );
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Remote POST API Request
|
289 |
+
*
|
290 |
+
* @since 1.0.0
|
291 |
+
*
|
292 |
+
* @param string $url Target server API URL.
|
293 |
+
* @param array $args Array of arguments for the API request.
|
294 |
+
* @return mixed Return the API request result.
|
295 |
+
*/
|
296 |
+
public static function remote_post( $url = '', $args = array() ) {
|
297 |
+
$request = wp_remote_post( $url, $args );
|
298 |
+
|
299 |
+
return self::request( $request );
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Site API Request
|
304 |
+
*
|
305 |
+
* @since 1.0.0
|
306 |
+
*
|
307 |
+
* @param boolean $api_base Target server API URL.
|
308 |
+
* @param array $args Array of arguments for the API request.
|
309 |
+
* @return mixed Return the API request result.
|
310 |
+
*/
|
311 |
+
public static function site_request( $api_base = '', $args = array() ) {
|
312 |
+
|
313 |
+
$api_url = self::get_request_api_url( $api_base );
|
314 |
+
|
315 |
+
return self::remote_post( $api_url, $args );
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* API Request
|
320 |
+
*
|
321 |
+
* Handle the API request and return the result.
|
322 |
+
*
|
323 |
+
* @since 1.0.0
|
324 |
+
*
|
325 |
+
* @param array $request Array of arguments for the API request.
|
326 |
+
* @return mixed Return the API request result.
|
327 |
+
*/
|
328 |
+
public static function request( $request ) {
|
329 |
+
|
330 |
+
// Is WP Error?
|
331 |
+
if ( is_wp_error( $request ) ) {
|
332 |
+
return array(
|
333 |
+
'success' => false,
|
334 |
+
'message' => $request->get_error_message(),
|
335 |
+
'data' => $request,
|
336 |
+
'count' => 0,
|
337 |
+
);
|
338 |
+
}
|
339 |
+
|
340 |
+
// Invalid response code.
|
341 |
+
if ( wp_remote_retrieve_response_code( $request ) != 200 ) {
|
342 |
+
return array(
|
343 |
+
'success' => false,
|
344 |
+
'message' => $request['response'],
|
345 |
+
'data' => $request,
|
346 |
+
'count' => 0,
|
347 |
+
);
|
348 |
+
}
|
349 |
+
|
350 |
+
// Get body data.
|
351 |
+
$body = wp_remote_retrieve_body( $request );
|
352 |
+
|
353 |
+
// Is WP Error?
|
354 |
+
if ( is_wp_error( $body ) ) {
|
355 |
+
return array(
|
356 |
+
'success' => false,
|
357 |
+
'message' => $body->get_error_message(),
|
358 |
+
'data' => $request,
|
359 |
+
'count' => 0,
|
360 |
+
);
|
361 |
+
}
|
362 |
+
|
363 |
+
// Decode body content.
|
364 |
+
$body_decoded = json_decode( $body );
|
365 |
+
|
366 |
+
return array(
|
367 |
+
'success' => true,
|
368 |
+
'message' => __( 'Request successfully processed!', 'cartflows' ),
|
369 |
+
'data' => (array) $body_decoded,
|
370 |
+
'count' => wp_remote_retrieve_header( $request, 'x-wp-total' ),
|
371 |
+
);
|
372 |
+
}
|
373 |
+
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Initialize class object with 'get_instance()' method
|
378 |
+
*/
|
379 |
+
CartFlows_API::get_instance();
|
380 |
+
|
381 |
+
endif;
|
classes/class-cartflows-bb-compatibility.php
CHANGED
@@ -1,76 +1,76 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Beaver Builder page builder compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! class_exists( 'Cartflows_BB_Compatibility' ) ) :
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class for Beaver Builder page builder compatibility
|
12 |
-
*/
|
13 |
-
class Cartflows_BB_Compatibility {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Member Variable
|
17 |
-
*
|
18 |
-
* @var instance
|
19 |
-
*/
|
20 |
-
private static $instance;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Initiator
|
24 |
-
*
|
25 |
-
* @since 1.1.4
|
26 |
-
*/
|
27 |
-
public static function get_instance() {
|
28 |
-
if ( ! isset( self::$instance ) ) {
|
29 |
-
self::$instance = new self();
|
30 |
-
}
|
31 |
-
return self::$instance;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Constructor
|
36 |
-
*
|
37 |
-
* @since 1.1.4
|
38 |
-
*/
|
39 |
-
public function __construct() {
|
40 |
-
add_filter( 'fl_builder_post_types', array( $this, 'post_types' ) );
|
41 |
-
add_action( 'admin_init', array( $this, 'disable_rediraction' ), 99 );
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Disable Beaver Builder Redirection after plugin install.
|
46 |
-
*
|
47 |
-
* @since 1.1.4
|
48 |
-
*
|
49 |
-
* @return void
|
50 |
-
*/
|
51 |
-
function disable_rediraction() {
|
52 |
-
delete_transient( '_fl_builder_activation_admin_notice' );
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Add beaver builder support for step post type.
|
57 |
-
*
|
58 |
-
* @since 1.1.4
|
59 |
-
*
|
60 |
-
* @param array $post_types container Post types.
|
61 |
-
* @return array
|
62 |
-
*/
|
63 |
-
public function post_types( $post_types ) {
|
64 |
-
|
65 |
-
$post_types[] = 'cartflows_step';
|
66 |
-
|
67 |
-
return $post_types;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Kicking this off by calling 'get_instance()' method
|
73 |
-
*/
|
74 |
-
Cartflows_BB_Compatibility::get_instance();
|
75 |
-
|
76 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Beaver Builder page builder compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! class_exists( 'Cartflows_BB_Compatibility' ) ) :
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class for Beaver Builder page builder compatibility
|
12 |
+
*/
|
13 |
+
class Cartflows_BB_Compatibility {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Member Variable
|
17 |
+
*
|
18 |
+
* @var instance
|
19 |
+
*/
|
20 |
+
private static $instance;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Initiator
|
24 |
+
*
|
25 |
+
* @since 1.1.4
|
26 |
+
*/
|
27 |
+
public static function get_instance() {
|
28 |
+
if ( ! isset( self::$instance ) ) {
|
29 |
+
self::$instance = new self();
|
30 |
+
}
|
31 |
+
return self::$instance;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Constructor
|
36 |
+
*
|
37 |
+
* @since 1.1.4
|
38 |
+
*/
|
39 |
+
public function __construct() {
|
40 |
+
add_filter( 'fl_builder_post_types', array( $this, 'post_types' ) );
|
41 |
+
add_action( 'admin_init', array( $this, 'disable_rediraction' ), 99 );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Disable Beaver Builder Redirection after plugin install.
|
46 |
+
*
|
47 |
+
* @since 1.1.4
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function disable_rediraction() {
|
52 |
+
delete_transient( '_fl_builder_activation_admin_notice' );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add beaver builder support for step post type.
|
57 |
+
*
|
58 |
+
* @since 1.1.4
|
59 |
+
*
|
60 |
+
* @param array $post_types container Post types.
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function post_types( $post_types ) {
|
64 |
+
|
65 |
+
$post_types[] = 'cartflows_step';
|
66 |
+
|
67 |
+
return $post_types;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Kicking this off by calling 'get_instance()' method
|
73 |
+
*/
|
74 |
+
Cartflows_BB_Compatibility::get_instance();
|
75 |
+
|
76 |
+
endif;
|
classes/class-cartflows-cloning.php
CHANGED
@@ -1,445 +1,445 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Cloning.
|
4 |
-
*
|
5 |
-
* @package cartflows-pro
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Cloning {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
add_filter( 'post_row_actions', array( $this, 'clone_link' ), 99, 2 );
|
39 |
-
add_action( 'admin_action_cartflows_clone_flow', array( $this, 'clone_flow' ) );
|
40 |
-
add_action( 'admin_action_cartflows_clone_step', array( $this, 'clone_step' ) );
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Clone flow with steps and its meta.
|
45 |
-
*/
|
46 |
-
function clone_flow() {
|
47 |
-
|
48 |
-
global $wpdb;
|
49 |
-
|
50 |
-
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_clone_flow'
|
51 |
-
wp_die( 'No post to duplicate has been supplied!' );
|
52 |
-
}
|
53 |
-
|
54 |
-
/*
|
55 |
-
* Nonce verification
|
56 |
-
*/
|
57 |
-
if ( ! isset( $_GET['flow_clone_nonce'] ) || ! wp_verify_nonce( $_GET['flow_clone_nonce'], basename( __FILE__ ) ) ) {
|
58 |
-
return;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Get the original post id
|
63 |
-
*/
|
64 |
-
$post_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
|
65 |
-
|
66 |
-
/**
|
67 |
-
* And all the original post data then
|
68 |
-
*/
|
69 |
-
$post = get_post( $post_id );
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Assign current user to be the new post author
|
73 |
-
*/
|
74 |
-
$current_user = wp_get_current_user();
|
75 |
-
$new_post_author = $current_user->ID;
|
76 |
-
|
77 |
-
/**
|
78 |
-
* If post data exists, create the post duplicate
|
79 |
-
*/
|
80 |
-
if ( isset( $post ) && null !== $post ) {
|
81 |
-
|
82 |
-
/**
|
83 |
-
* New post data array
|
84 |
-
*/
|
85 |
-
|
86 |
-
$args = array(
|
87 |
-
'comment_status' => $post->comment_status,
|
88 |
-
'ping_status' => $post->ping_status,
|
89 |
-
'post_author' => $new_post_author,
|
90 |
-
'post_content' => $post->post_content,
|
91 |
-
'post_excerpt' => $post->post_excerpt,
|
92 |
-
'post_name' => $post->post_name,
|
93 |
-
'post_parent' => $post->post_parent,
|
94 |
-
'post_password' => $post->post_password,
|
95 |
-
'post_status' => $post->post_status,
|
96 |
-
'post_title' => $post->post_title . ' Clone',
|
97 |
-
'post_type' => $post->post_type,
|
98 |
-
'to_ping' => $post->to_ping,
|
99 |
-
'menu_order' => $post->menu_order,
|
100 |
-
);
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Insert the post
|
104 |
-
*/
|
105 |
-
$new_flow_id = wp_insert_post( $args );
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Get all current post terms ad set them to the new post
|
109 |
-
*/
|
110 |
-
// returns array of taxonomy names for post type, ex array("category", "post_tag");.
|
111 |
-
$taxonomies = get_object_taxonomies( $post->post_type );
|
112 |
-
|
113 |
-
foreach ( $taxonomies as $taxonomy ) {
|
114 |
-
|
115 |
-
$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) );
|
116 |
-
|
117 |
-
wp_set_object_terms( $new_flow_id, $post_terms, $taxonomy, false );
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Duplicate all post meta just in two SQL queries
|
122 |
-
*/
|
123 |
-
// @codingStandardsIgnoreStart
|
124 |
-
$post_meta_infos = $wpdb->get_results(
|
125 |
-
"SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id"
|
126 |
-
);
|
127 |
-
// @codingStandardsIgnoreEnd
|
128 |
-
|
129 |
-
if ( ! empty( $post_meta_infos ) ) {
|
130 |
-
|
131 |
-
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
132 |
-
|
133 |
-
$sql_query_sel = array();
|
134 |
-
|
135 |
-
foreach ( $post_meta_infos as $meta_info ) {
|
136 |
-
|
137 |
-
$meta_key = $meta_info->meta_key;
|
138 |
-
|
139 |
-
if ( '_wp_old_slug' === $meta_key ) {
|
140 |
-
continue;
|
141 |
-
}
|
142 |
-
|
143 |
-
$meta_value = addslashes( $meta_info->meta_value );
|
144 |
-
|
145 |
-
$sql_query_sel[] = "($new_flow_id, '$meta_key', '$meta_value')";
|
146 |
-
}
|
147 |
-
|
148 |
-
$sql_query .= implode( ',', $sql_query_sel );
|
149 |
-
|
150 |
-
// @codingStandardsIgnoreStart
|
151 |
-
$wpdb->query( $sql_query );
|
152 |
-
// @codingStandardsIgnoreEnd
|
153 |
-
}
|
154 |
-
|
155 |
-
/* Steps Cloning */
|
156 |
-
$flow_steps = get_post_meta( $post_id, 'wcf-steps', true );
|
157 |
-
$new_flow_steps = array();
|
158 |
-
|
159 |
-
/* Set Steps Empty */
|
160 |
-
update_post_meta( $new_flow_id, 'wcf-steps', $new_flow_steps );
|
161 |
-
|
162 |
-
if ( is_array( $flow_steps ) && ! empty( $flow_steps ) ) {
|
163 |
-
|
164 |
-
foreach ( $flow_steps as $index => $step_data ) {
|
165 |
-
|
166 |
-
$step_id = $step_data['id'];
|
167 |
-
$step_type = get_post_meta( $step_id, 'wcf-step-type', true );
|
168 |
-
|
169 |
-
$step_object = get_post( $step_id );
|
170 |
-
|
171 |
-
/**
|
172 |
-
* New step post data array
|
173 |
-
*/
|
174 |
-
$step_args = array(
|
175 |
-
'comment_status' => $step_object->comment_status,
|
176 |
-
'ping_status' => $step_object->ping_status,
|
177 |
-
'post_author' => $new_post_author,
|
178 |
-
'post_content' => $step_object->post_content,
|
179 |
-
'post_excerpt' => $step_object->post_excerpt,
|
180 |
-
'post_name' => $step_object->post_name,
|
181 |
-
'post_parent' => $step_object->post_parent,
|
182 |
-
'post_password' => $step_object->post_password,
|
183 |
-
'post_status' => $step_object->post_status,
|
184 |
-
'post_title' => $step_object->post_title,
|
185 |
-
'post_type' => $step_object->post_type,
|
186 |
-
'to_ping' => $step_object->to_ping,
|
187 |
-
'menu_order' => $step_object->menu_order,
|
188 |
-
);
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Insert the post
|
192 |
-
*/
|
193 |
-
$new_step_id = wp_insert_post( $step_args );
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Duplicate all step meta
|
197 |
-
*/
|
198 |
-
// @codingStandardsIgnoreStart
|
199 |
-
$post_meta_infos = $wpdb->get_results(
|
200 |
-
"SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$step_id"
|
201 |
-
);
|
202 |
-
// @codingStandardsIgnoreEnd
|
203 |
-
|
204 |
-
if ( ! empty( $post_meta_infos ) ) {
|
205 |
-
|
206 |
-
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
207 |
-
|
208 |
-
$sql_query_sel = array();
|
209 |
-
|
210 |
-
foreach ( $post_meta_infos as $meta_info ) {
|
211 |
-
|
212 |
-
$meta_key = $meta_info->meta_key;
|
213 |
-
|
214 |
-
if ( '_wp_old_slug' === $meta_key ) {
|
215 |
-
continue;
|
216 |
-
}
|
217 |
-
|
218 |
-
$meta_value = addslashes( $meta_info->meta_value );
|
219 |
-
|
220 |
-
$sql_query_sel[] = "($new_step_id, '$meta_key', '$meta_value')";
|
221 |
-
}
|
222 |
-
|
223 |
-
$sql_query .= implode( ',', $sql_query_sel );
|
224 |
-
|
225 |
-
// @codingStandardsIgnoreStart
|
226 |
-
$wpdb->query( $sql_query );
|
227 |
-
// @codingStandardsIgnoreEnd
|
228 |
-
}
|
229 |
-
|
230 |
-
// insert post meta.
|
231 |
-
update_post_meta( $new_step_id, 'wcf-flow-id', $new_flow_id );
|
232 |
-
update_post_meta( $new_step_id, 'wcf-step-type', $step_type );
|
233 |
-
|
234 |
-
wp_set_object_terms( $new_step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
235 |
-
wp_set_object_terms( $new_step_id, 'flow-' . $new_flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
236 |
-
|
237 |
-
/* Add New Flow Steps */
|
238 |
-
$new_flow_steps[] = array(
|
239 |
-
'id' => $new_step_id,
|
240 |
-
'title' => $step_object->post_title,
|
241 |
-
'type' => $step_type,
|
242 |
-
);
|
243 |
-
}
|
244 |
-
}
|
245 |
-
|
246 |
-
/* Update New Flow Step Post Meta */
|
247 |
-
update_post_meta( $new_flow_id, 'wcf-steps', $new_flow_steps );
|
248 |
-
|
249 |
-
/* Clear Page Builder Cache */
|
250 |
-
$this->clear_cache();
|
251 |
-
|
252 |
-
/**
|
253 |
-
* Redirect to the new flow edit screen
|
254 |
-
*/
|
255 |
-
|
256 |
-
exit;
|
257 |
-
} else {
|
258 |
-
wp_die( 'Post creation failed, could not find original post: ' . $post_id );
|
259 |
-
}
|
260 |
-
}
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Clone step with its meta.
|
264 |
-
*/
|
265 |
-
function clone_step() {
|
266 |
-
|
267 |
-
global $wpdb;
|
268 |
-
|
269 |
-
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_clone_step' === $_REQUEST['action'] ) ) ) {
|
270 |
-
wp_die( 'No post to duplicate has been supplied!' );
|
271 |
-
}
|
272 |
-
|
273 |
-
/*
|
274 |
-
* Nonce verification
|
275 |
-
*/
|
276 |
-
if ( ! isset( $_GET['step_clone_nonce'] ) || ! wp_verify_nonce( $_GET['step_clone_nonce'], 'step_clone' ) ) {
|
277 |
-
return;
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Get the original post id
|
282 |
-
*/
|
283 |
-
$post_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
|
284 |
-
|
285 |
-
/**
|
286 |
-
* And all the original post data then
|
287 |
-
*/
|
288 |
-
$post = get_post( $post_id );
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Assign current user to be the new post author
|
292 |
-
*/
|
293 |
-
$current_user = wp_get_current_user();
|
294 |
-
$new_post_author = $current_user->ID;
|
295 |
-
|
296 |
-
/**
|
297 |
-
* If post data exists, create the post duplicate
|
298 |
-
*/
|
299 |
-
if ( isset( $post ) && null !== $post ) {
|
300 |
-
|
301 |
-
/**
|
302 |
-
* New post data array
|
303 |
-
*/
|
304 |
-
$args = array(
|
305 |
-
'comment_status' => $post->comment_status,
|
306 |
-
'ping_status' => $post->ping_status,
|
307 |
-
'post_author' => $new_post_author,
|
308 |
-
'post_content' => $post->post_content,
|
309 |
-
'post_excerpt' => $post->post_excerpt,
|
310 |
-
'post_name' => $post->post_name,
|
311 |
-
'post_parent' => $post->post_parent,
|
312 |
-
'post_password' => $post->post_password,
|
313 |
-
'post_status' => $post->post_status,
|
314 |
-
'post_title' => $post->post_title . ' Clone',
|
315 |
-
'post_type' => $post->post_type,
|
316 |
-
'to_ping' => $post->to_ping,
|
317 |
-
'menu_order' => $post->menu_order,
|
318 |
-
);
|
319 |
-
|
320 |
-
/**
|
321 |
-
* Insert the post
|
322 |
-
*/
|
323 |
-
$new_step_id = wp_insert_post( $args );
|
324 |
-
|
325 |
-
/**
|
326 |
-
* Get all current post terms ad set them to the new post
|
327 |
-
*/
|
328 |
-
// returns array of taxonomy names for post type, ex array("category", "post_tag");.
|
329 |
-
$taxonomies = get_object_taxonomies( $post->post_type );
|
330 |
-
|
331 |
-
foreach ( $taxonomies as $taxonomy ) {
|
332 |
-
|
333 |
-
$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) );
|
334 |
-
|
335 |
-
wp_set_object_terms( $new_step_id, $post_terms, $taxonomy, false );
|
336 |
-
}
|
337 |
-
|
338 |
-
/**
|
339 |
-
* Duplicate all post meta just in two SQL queries
|
340 |
-
*/
|
341 |
-
// @codingStandardsIgnoreStart
|
342 |
-
$post_meta_infos = $wpdb->get_results(
|
343 |
-
"SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id"
|
344 |
-
);
|
345 |
-
// @codingStandardsIgnoreEnd
|
346 |
-
|
347 |
-
if ( ! empty( $post_meta_infos ) ) {
|
348 |
-
|
349 |
-
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
350 |
-
|
351 |
-
$sql_query_sel = array();
|
352 |
-
|
353 |
-
foreach ( $post_meta_infos as $meta_info ) {
|
354 |
-
|
355 |
-
$meta_key = $meta_info->meta_key;
|
356 |
-
|
357 |
-
if ( '_wp_old_slug' === $meta_key ) {
|
358 |
-
continue;
|
359 |
-
}
|
360 |
-
|
361 |
-
$meta_value = addslashes( $meta_info->meta_value );
|
362 |
-
|
363 |
-
$sql_query_sel[] = "($new_step_id, '$meta_key', '$meta_value')";
|
364 |
-
}
|
365 |
-
|
366 |
-
$sql_query .= implode( ',', $sql_query_sel );
|
367 |
-
|
368 |
-
// @codingStandardsIgnoreStart
|
369 |
-
$wpdb->query( $sql_query );
|
370 |
-
// @codingStandardsIgnoreEnd
|
371 |
-
}
|
372 |
-
|
373 |
-
$flow_id = get_post_meta( $post_id, 'wcf-flow-id', true );
|
374 |
-
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
375 |
-
$step_type = get_post_meta( $post_id, 'wcf-step-type', true );
|
376 |
-
|
377 |
-
if ( ! is_array( $flow_steps ) ) {
|
378 |
-
$flow_steps = array();
|
379 |
-
}
|
380 |
-
|
381 |
-
$flow_steps[] = array(
|
382 |
-
'id' => $new_step_id,
|
383 |
-
'title' => $post->post_title,
|
384 |
-
'type' => $step_type,
|
385 |
-
);
|
386 |
-
|
387 |
-
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
388 |
-
|
389 |
-
/* Clear Page Builder Cache */
|
390 |
-
$this->clear_cache();
|
391 |
-
|
392 |
-
/**
|
393 |
-
* Redirect to the new flow edit screen
|
394 |
-
*/
|
395 |
-
$redirect_url = add_query_arg( 'highlight-step-id', $new_step_id, get_edit_post_link( $flow_id, 'default' ) );
|
396 |
-
|
397 |
-
|
398 |
-
exit;
|
399 |
-
} else {
|
400 |
-
wp_die( 'Post creation failed, could not find original post: ' . $post_id );
|
401 |
-
}
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Add the clone link to action list for flows row actions
|
406 |
-
*
|
407 |
-
* @param array $actions Actions array.
|
408 |
-
* @param object $post Post object.
|
409 |
-
*
|
410 |
-
* @return array
|
411 |
-
*/
|
412 |
-
function clone_link( $actions, $post ) {
|
413 |
-
|
414 |
-
if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
415 |
-
|
416 |
-
if ( isset( $actions['duplicate'] ) ) { // Duplicate page plugin remove.
|
417 |
-
unset( $actions['duplicate'] );
|
418 |
-
}
|
419 |
-
if ( isset( $actions['edit_as_new_draft'] ) ) { // Duplicate post plugin remove.
|
420 |
-
unset( $actions['edit_as_new_draft'] );
|
421 |
-
}
|
422 |
-
|
423 |
-
$actions['clone'] = '<a href="' . wp_nonce_url( 'admin.php?action=cartflows_clone_flow&post=' . $post->ID, basename( __FILE__ ), 'flow_clone_nonce' ) . '" title="' . __( 'Clone this flow', 'cartflows' ) . '" rel="permalink">' . __( 'Clone', 'cartflows' ) . '</a>';
|
424 |
-
}
|
425 |
-
|
426 |
-
return $actions;
|
427 |
-
}
|
428 |
-
|
429 |
-
/**
|
430 |
-
* Clear Page Builder Cache
|
431 |
-
*/
|
432 |
-
function clear_cache() {
|
433 |
-
|
434 |
-
// Clear 'Elementor' file cache.
|
435 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
436 |
-
Elementor\Plugin::$instance->files_manager->clear_cache();
|
437 |
-
}
|
438 |
-
}
|
439 |
-
|
440 |
-
}
|
441 |
-
|
442 |
-
/**
|
443 |
-
* Kicking this off by calling 'get_instance()' method
|
444 |
-
*/
|
445 |
-
Cartflows_Cloning::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cloning.
|
4 |
+
*
|
5 |
+
* @package cartflows-pro
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Cloning {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
add_filter( 'post_row_actions', array( $this, 'clone_link' ), 99, 2 );
|
39 |
+
add_action( 'admin_action_cartflows_clone_flow', array( $this, 'clone_flow' ) );
|
40 |
+
add_action( 'admin_action_cartflows_clone_step', array( $this, 'clone_step' ) );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Clone flow with steps and its meta.
|
45 |
+
*/
|
46 |
+
public function clone_flow() {
|
47 |
+
|
48 |
+
global $wpdb;
|
49 |
+
|
50 |
+
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_clone_flow' === $_REQUEST['action'] ) ) ) {
|
51 |
+
wp_die( 'No post to duplicate has been supplied!' );
|
52 |
+
}
|
53 |
+
|
54 |
+
/*
|
55 |
+
* Nonce verification
|
56 |
+
*/
|
57 |
+
if ( ! isset( $_GET['flow_clone_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['flow_clone_nonce'] ), basename( __FILE__ ) ) ) {
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get the original post id
|
63 |
+
*/
|
64 |
+
$post_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
|
65 |
+
|
66 |
+
/**
|
67 |
+
* And all the original post data then
|
68 |
+
*/
|
69 |
+
$post = get_post( $post_id );
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Assign current user to be the new post author
|
73 |
+
*/
|
74 |
+
$current_user = wp_get_current_user();
|
75 |
+
$new_post_author = $current_user->ID;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* If post data exists, create the post duplicate
|
79 |
+
*/
|
80 |
+
if ( isset( $post ) && null !== $post ) {
|
81 |
+
|
82 |
+
/**
|
83 |
+
* New post data array
|
84 |
+
*/
|
85 |
+
|
86 |
+
$args = array(
|
87 |
+
'comment_status' => $post->comment_status,
|
88 |
+
'ping_status' => $post->ping_status,
|
89 |
+
'post_author' => $new_post_author,
|
90 |
+
'post_content' => $post->post_content,
|
91 |
+
'post_excerpt' => $post->post_excerpt,
|
92 |
+
'post_name' => $post->post_name,
|
93 |
+
'post_parent' => $post->post_parent,
|
94 |
+
'post_password' => $post->post_password,
|
95 |
+
'post_status' => $post->post_status,
|
96 |
+
'post_title' => $post->post_title . ' Clone',
|
97 |
+
'post_type' => $post->post_type,
|
98 |
+
'to_ping' => $post->to_ping,
|
99 |
+
'menu_order' => $post->menu_order,
|
100 |
+
);
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Insert the post
|
104 |
+
*/
|
105 |
+
$new_flow_id = wp_insert_post( $args );
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get all current post terms ad set them to the new post
|
109 |
+
*/
|
110 |
+
// returns array of taxonomy names for post type, ex array("category", "post_tag");.
|
111 |
+
$taxonomies = get_object_taxonomies( $post->post_type );
|
112 |
+
|
113 |
+
foreach ( $taxonomies as $taxonomy ) {
|
114 |
+
|
115 |
+
$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) );
|
116 |
+
|
117 |
+
wp_set_object_terms( $new_flow_id, $post_terms, $taxonomy, false );
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Duplicate all post meta just in two SQL queries
|
122 |
+
*/
|
123 |
+
// @codingStandardsIgnoreStart
|
124 |
+
$post_meta_infos = $wpdb->get_results(
|
125 |
+
"SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id"
|
126 |
+
);
|
127 |
+
// @codingStandardsIgnoreEnd
|
128 |
+
|
129 |
+
if ( ! empty( $post_meta_infos ) ) {
|
130 |
+
|
131 |
+
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
132 |
+
|
133 |
+
$sql_query_sel = array();
|
134 |
+
|
135 |
+
foreach ( $post_meta_infos as $meta_info ) {
|
136 |
+
|
137 |
+
$meta_key = $meta_info->meta_key;
|
138 |
+
|
139 |
+
if ( '_wp_old_slug' === $meta_key ) {
|
140 |
+
continue;
|
141 |
+
}
|
142 |
+
|
143 |
+
$meta_value = addslashes( $meta_info->meta_value );
|
144 |
+
|
145 |
+
$sql_query_sel[] = "($new_flow_id, '$meta_key', '$meta_value')";
|
146 |
+
}
|
147 |
+
|
148 |
+
$sql_query .= implode( ',', $sql_query_sel );
|
149 |
+
|
150 |
+
// @codingStandardsIgnoreStart
|
151 |
+
$wpdb->query( $sql_query );
|
152 |
+
// @codingStandardsIgnoreEnd
|
153 |
+
}
|
154 |
+
|
155 |
+
/* Steps Cloning */
|
156 |
+
$flow_steps = get_post_meta( $post_id, 'wcf-steps', true );
|
157 |
+
$new_flow_steps = array();
|
158 |
+
|
159 |
+
/* Set Steps Empty */
|
160 |
+
update_post_meta( $new_flow_id, 'wcf-steps', $new_flow_steps );
|
161 |
+
|
162 |
+
if ( is_array( $flow_steps ) && ! empty( $flow_steps ) ) {
|
163 |
+
|
164 |
+
foreach ( $flow_steps as $index => $step_data ) {
|
165 |
+
|
166 |
+
$step_id = $step_data['id'];
|
167 |
+
$step_type = get_post_meta( $step_id, 'wcf-step-type', true );
|
168 |
+
|
169 |
+
$step_object = get_post( $step_id );
|
170 |
+
|
171 |
+
/**
|
172 |
+
* New step post data array
|
173 |
+
*/
|
174 |
+
$step_args = array(
|
175 |
+
'comment_status' => $step_object->comment_status,
|
176 |
+
'ping_status' => $step_object->ping_status,
|
177 |
+
'post_author' => $new_post_author,
|
178 |
+
'post_content' => $step_object->post_content,
|
179 |
+
'post_excerpt' => $step_object->post_excerpt,
|
180 |
+
'post_name' => $step_object->post_name,
|
181 |
+
'post_parent' => $step_object->post_parent,
|
182 |
+
'post_password' => $step_object->post_password,
|
183 |
+
'post_status' => $step_object->post_status,
|
184 |
+
'post_title' => $step_object->post_title,
|
185 |
+
'post_type' => $step_object->post_type,
|
186 |
+
'to_ping' => $step_object->to_ping,
|
187 |
+
'menu_order' => $step_object->menu_order,
|
188 |
+
);
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Insert the post
|
192 |
+
*/
|
193 |
+
$new_step_id = wp_insert_post( $step_args );
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Duplicate all step meta
|
197 |
+
*/
|
198 |
+
// @codingStandardsIgnoreStart
|
199 |
+
$post_meta_infos = $wpdb->get_results(
|
200 |
+
"SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$step_id"
|
201 |
+
);
|
202 |
+
// @codingStandardsIgnoreEnd
|
203 |
+
|
204 |
+
if ( ! empty( $post_meta_infos ) ) {
|
205 |
+
|
206 |
+
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
207 |
+
|
208 |
+
$sql_query_sel = array();
|
209 |
+
|
210 |
+
foreach ( $post_meta_infos as $meta_info ) {
|
211 |
+
|
212 |
+
$meta_key = $meta_info->meta_key;
|
213 |
+
|
214 |
+
if ( '_wp_old_slug' === $meta_key ) {
|
215 |
+
continue;
|
216 |
+
}
|
217 |
+
|
218 |
+
$meta_value = addslashes( $meta_info->meta_value );
|
219 |
+
|
220 |
+
$sql_query_sel[] = "($new_step_id, '$meta_key', '$meta_value')";
|
221 |
+
}
|
222 |
+
|
223 |
+
$sql_query .= implode( ',', $sql_query_sel );
|
224 |
+
|
225 |
+
// @codingStandardsIgnoreStart
|
226 |
+
$wpdb->query( $sql_query );
|
227 |
+
// @codingStandardsIgnoreEnd
|
228 |
+
}
|
229 |
+
|
230 |
+
// insert post meta.
|
231 |
+
update_post_meta( $new_step_id, 'wcf-flow-id', $new_flow_id );
|
232 |
+
update_post_meta( $new_step_id, 'wcf-step-type', $step_type );
|
233 |
+
|
234 |
+
wp_set_object_terms( $new_step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
235 |
+
wp_set_object_terms( $new_step_id, 'flow-' . $new_flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
236 |
+
|
237 |
+
/* Add New Flow Steps */
|
238 |
+
$new_flow_steps[] = array(
|
239 |
+
'id' => $new_step_id,
|
240 |
+
'title' => $step_object->post_title,
|
241 |
+
'type' => $step_type,
|
242 |
+
);
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
/* Update New Flow Step Post Meta */
|
247 |
+
update_post_meta( $new_flow_id, 'wcf-steps', $new_flow_steps );
|
248 |
+
|
249 |
+
/* Clear Page Builder Cache */
|
250 |
+
$this->clear_cache();
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Redirect to the new flow edit screen
|
254 |
+
*/
|
255 |
+
wp_safe_redirect( admin_url( 'post.php?action=edit&post=' . $new_flow_id ) );
|
256 |
+
exit;
|
257 |
+
} else {
|
258 |
+
wp_die( 'Post creation failed, could not find original post: ' . $post_id );
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Clone step with its meta.
|
264 |
+
*/
|
265 |
+
public function clone_step() {
|
266 |
+
|
267 |
+
global $wpdb;
|
268 |
+
|
269 |
+
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_clone_step' === $_REQUEST['action'] ) ) ) {
|
270 |
+
wp_die( 'No post to duplicate has been supplied!' );
|
271 |
+
}
|
272 |
+
|
273 |
+
/*
|
274 |
+
* Nonce verification
|
275 |
+
*/
|
276 |
+
if ( ! isset( $_GET['step_clone_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['step_clone_nonce'] ), 'step_clone' ) ) {
|
277 |
+
return;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Get the original post id
|
282 |
+
*/
|
283 |
+
$post_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
|
284 |
+
|
285 |
+
/**
|
286 |
+
* And all the original post data then
|
287 |
+
*/
|
288 |
+
$post = get_post( $post_id );
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Assign current user to be the new post author
|
292 |
+
*/
|
293 |
+
$current_user = wp_get_current_user();
|
294 |
+
$new_post_author = $current_user->ID;
|
295 |
+
|
296 |
+
/**
|
297 |
+
* If post data exists, create the post duplicate
|
298 |
+
*/
|
299 |
+
if ( isset( $post ) && null !== $post ) {
|
300 |
+
|
301 |
+
/**
|
302 |
+
* New post data array
|
303 |
+
*/
|
304 |
+
$args = array(
|
305 |
+
'comment_status' => $post->comment_status,
|
306 |
+
'ping_status' => $post->ping_status,
|
307 |
+
'post_author' => $new_post_author,
|
308 |
+
'post_content' => $post->post_content,
|
309 |
+
'post_excerpt' => $post->post_excerpt,
|
310 |
+
'post_name' => $post->post_name,
|
311 |
+
'post_parent' => $post->post_parent,
|
312 |
+
'post_password' => $post->post_password,
|
313 |
+
'post_status' => $post->post_status,
|
314 |
+
'post_title' => $post->post_title . ' Clone',
|
315 |
+
'post_type' => $post->post_type,
|
316 |
+
'to_ping' => $post->to_ping,
|
317 |
+
'menu_order' => $post->menu_order,
|
318 |
+
);
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Insert the post
|
322 |
+
*/
|
323 |
+
$new_step_id = wp_insert_post( $args );
|
324 |
+
|
325 |
+
/**
|
326 |
+
* Get all current post terms ad set them to the new post
|
327 |
+
*/
|
328 |
+
// returns array of taxonomy names for post type, ex array("category", "post_tag");.
|
329 |
+
$taxonomies = get_object_taxonomies( $post->post_type );
|
330 |
+
|
331 |
+
foreach ( $taxonomies as $taxonomy ) {
|
332 |
+
|
333 |
+
$post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) );
|
334 |
+
|
335 |
+
wp_set_object_terms( $new_step_id, $post_terms, $taxonomy, false );
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Duplicate all post meta just in two SQL queries
|
340 |
+
*/
|
341 |
+
// @codingStandardsIgnoreStart
|
342 |
+
$post_meta_infos = $wpdb->get_results(
|
343 |
+
"SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id"
|
344 |
+
);
|
345 |
+
// @codingStandardsIgnoreEnd
|
346 |
+
|
347 |
+
if ( ! empty( $post_meta_infos ) ) {
|
348 |
+
|
349 |
+
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES ";
|
350 |
+
|
351 |
+
$sql_query_sel = array();
|
352 |
+
|
353 |
+
foreach ( $post_meta_infos as $meta_info ) {
|
354 |
+
|
355 |
+
$meta_key = $meta_info->meta_key;
|
356 |
+
|
357 |
+
if ( '_wp_old_slug' === $meta_key ) {
|
358 |
+
continue;
|
359 |
+
}
|
360 |
+
|
361 |
+
$meta_value = addslashes( $meta_info->meta_value );
|
362 |
+
|
363 |
+
$sql_query_sel[] = "($new_step_id, '$meta_key', '$meta_value')";
|
364 |
+
}
|
365 |
+
|
366 |
+
$sql_query .= implode( ',', $sql_query_sel );
|
367 |
+
|
368 |
+
// @codingStandardsIgnoreStart
|
369 |
+
$wpdb->query( $sql_query );
|
370 |
+
// @codingStandardsIgnoreEnd
|
371 |
+
}
|
372 |
+
|
373 |
+
$flow_id = get_post_meta( $post_id, 'wcf-flow-id', true );
|
374 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
375 |
+
$step_type = get_post_meta( $post_id, 'wcf-step-type', true );
|
376 |
+
|
377 |
+
if ( ! is_array( $flow_steps ) ) {
|
378 |
+
$flow_steps = array();
|
379 |
+
}
|
380 |
+
|
381 |
+
$flow_steps[] = array(
|
382 |
+
'id' => $new_step_id,
|
383 |
+
'title' => $post->post_title,
|
384 |
+
'type' => $step_type,
|
385 |
+
);
|
386 |
+
|
387 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
388 |
+
|
389 |
+
/* Clear Page Builder Cache */
|
390 |
+
$this->clear_cache();
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Redirect to the new flow edit screen
|
394 |
+
*/
|
395 |
+
$redirect_url = add_query_arg( 'highlight-step-id', $new_step_id, get_edit_post_link( $flow_id, 'default' ) );
|
396 |
+
|
397 |
+
wp_safe_redirect( $redirect_url );
|
398 |
+
exit;
|
399 |
+
} else {
|
400 |
+
wp_die( 'Post creation failed, could not find original post: ' . $post_id );
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Add the clone link to action list for flows row actions
|
406 |
+
*
|
407 |
+
* @param array $actions Actions array.
|
408 |
+
* @param object $post Post object.
|
409 |
+
*
|
410 |
+
* @return array
|
411 |
+
*/
|
412 |
+
public function clone_link( $actions, $post ) {
|
413 |
+
|
414 |
+
if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
415 |
+
|
416 |
+
if ( isset( $actions['duplicate'] ) ) { // Duplicate page plugin remove.
|
417 |
+
unset( $actions['duplicate'] );
|
418 |
+
}
|
419 |
+
if ( isset( $actions['edit_as_new_draft'] ) ) { // Duplicate post plugin remove.
|
420 |
+
unset( $actions['edit_as_new_draft'] );
|
421 |
+
}
|
422 |
+
|
423 |
+
$actions['clone'] = '<a href="' . wp_nonce_url( 'admin.php?action=cartflows_clone_flow&post=' . $post->ID, basename( __FILE__ ), 'flow_clone_nonce' ) . '" title="' . __( 'Clone this flow', 'cartflows' ) . '" rel="permalink">' . __( 'Clone', 'cartflows' ) . '</a>';
|
424 |
+
}
|
425 |
+
|
426 |
+
return $actions;
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Clear Page Builder Cache
|
431 |
+
*/
|
432 |
+
public function clear_cache() {
|
433 |
+
|
434 |
+
// Clear 'Elementor' file cache.
|
435 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
436 |
+
Elementor\Plugin::$instance->files_manager->clear_cache();
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* Kicking this off by calling 'get_instance()' method
|
444 |
+
*/
|
445 |
+
Cartflows_Cloning::get_instance();
|
classes/class-cartflows-compatibility.php
CHANGED
@@ -1,404 +1,410 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Page builder compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! class_exists( 'Cartflows_Compatibility' ) ) {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class for page builder compatibility
|
12 |
-
*/
|
13 |
-
class Cartflows_Compatibility {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Member Variable
|
17 |
-
*
|
18 |
-
* @var object instance
|
19 |
-
*/
|
20 |
-
private static $instance;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Initiator
|
24 |
-
*/
|
25 |
-
public static function get_instance() {
|
26 |
-
if ( ! isset( self::$instance ) ) {
|
27 |
-
self::$instance = new self();
|
28 |
-
}
|
29 |
-
return self::$instance;
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Constructor
|
34 |
-
*/
|
35 |
-
public function __construct() {
|
36 |
-
|
37 |
-
$this->load_files();
|
38 |
-
|
39 |
-
// Override post meta.
|
40 |
-
add_action( 'wp', array( $this, 'override_meta' ), 0 );
|
41 |
-
|
42 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'load_fontawesome' ), 10000 );
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Load page builder compatibility files
|
47 |
-
*/
|
48 |
-
public function load_files() {
|
49 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
50 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-elementor-compatibility.php';
|
51 |
-
}
|
52 |
-
|
53 |
-
if ( $this->is_divi_enabled() ) {
|
54 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-divi-compatibility.php';
|
55 |
-
}
|
56 |
-
|
57 |
-
if ( $this->is_bb_enabled() ) {
|
58 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-bb-compatibility.php';
|
59 |
-
}
|
60 |
-
|
61 |
-
if ( class_exists( 'TCB_Post' ) ) {
|
62 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-thrive-compatibility.php';
|
63 |
-
}
|
64 |
-
|
65 |
-
if ( defined( 'LEARNDASH_VERSION' ) ) {
|
66 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-learndash-compatibility.php';
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Check if it is beaver builder enabled.
|
72 |
-
*
|
73 |
-
* @since 1.1.4
|
74 |
-
*/
|
75 |
-
public function is_bb_enabled() {
|
76 |
-
|
77 |
-
if ( class_exists( 'FLBuilderModel' ) ) {
|
78 |
-
return true;
|
79 |
-
}
|
80 |
-
|
81 |
-
return false;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Check if elementor preview mode is on.
|
86 |
-
*/
|
87 |
-
public function is_elementor_preview_mode() {
|
88 |
-
|
89 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
90 |
-
|
91 |
-
if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
|
92 |
-
return true;
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
return false;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Get Current Theme.
|
101 |
-
*/
|
102 |
-
public function get_current_theme() {
|
103 |
-
|
104 |
-
$theme_name = '';
|
105 |
-
$theme = wp_get_theme();
|
106 |
-
|
107 |
-
if ( isset( $theme->parent_theme ) && '' != $theme->parent_theme || null != $theme->parent_theme ) {
|
108 |
-
$theme_name = $theme->parent_theme;
|
109 |
-
} else {
|
110 |
-
$theme_name = $theme->name;
|
111 |
-
}
|
112 |
-
|
113 |
-
return $theme_name;
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Check if it is beaver builder preview mode
|
118 |
-
*/
|
119 |
-
public function is_bb_preview_mode() {
|
120 |
-
|
121 |
-
if ( class_exists( 'FLBuilderModel' ) ) {
|
122 |
-
if ( FLBuilderModel::is_builder_active() ) {
|
123 |
-
return true;
|
124 |
-
} else {
|
125 |
-
return false;
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
return false;
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Check for page builder preview mode.
|
134 |
-
*/
|
135 |
-
public function is_page_builder_preview() {
|
136 |
-
|
137 |
-
if ( $this->is_elementor_preview_mode() || $this->is_bb_preview_mode() || $this->is_divi_builder_preview() ) {
|
138 |
-
return true;
|
139 |
-
}
|
140 |
-
|
141 |
-
return false;
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Check if divi builder enabled for post id.
|
146 |
-
*/
|
147 |
-
public function is_divi_builder_preview() {
|
148 |
-
|
149 |
-
if ( isset( $_GET['et_fb'] ) && '1' === $_GET['et_fb'] ) {
|
150 |
-
return true;
|
151 |
-
}
|
152 |
-
|
153 |
-
return false;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Check if divi builder enabled for post id.
|
158 |
-
*
|
159 |
-
* @param int $post_id post id.
|
160 |
-
*/
|
161 |
-
public function is_divi_builder_enabled( $post_id ) {
|
162 |
-
|
163 |
-
if ( function_exists( 'et_pb_is_pagebuilder_used' ) && et_pb_is_pagebuilder_used( $post_id ) ) {
|
164 |
-
return true;
|
165 |
-
}
|
166 |
-
|
167 |
-
return false;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Check if compatibility theme enabled.
|
172 |
-
*/
|
173 |
-
function is_compatibility_theme_enabled() {
|
174 |
-
|
175 |
-
$theme = wp_get_theme();
|
176 |
-
|
177 |
-
$is_compatibility = false;
|
178 |
-
|
179 |
-
if ( $this->is_divi_enabled( $theme ) || $this->is_flatsome_enabled( $theme ) ) {
|
180 |
-
|
181 |
-
$is_compatibility = true;
|
182 |
-
}
|
183 |
-
|
184 |
-
return apply_filters( 'cartflows_is_compatibility_theme', $is_compatibility );
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Check if divi builder enabled for post id.
|
189 |
-
*
|
190 |
-
* @param object $theme theme data.
|
191 |
-
* @return boolean
|
192 |
-
*/
|
193 |
-
function is_divi_enabled( $theme = false ) {
|
194 |
-
|
195 |
-
if ( ! $theme ) {
|
196 |
-
$theme = wp_get_theme();
|
197 |
-
}
|
198 |
-
|
199 |
-
if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme || 'Extra' == $theme->name || 'Extra' == $theme->parent_theme ) {
|
200 |
-
return true;
|
201 |
-
}
|
202 |
-
|
203 |
-
return false;
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Check if Divi theme is install status.
|
208 |
-
*
|
209 |
-
* @return boolean
|
210 |
-
*/
|
211 |
-
function is_divi_theme_installed() {
|
212 |
-
foreach ( (array) wp_get_themes() as $theme_dir => $theme ) {
|
213 |
-
if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme || 'Extra' == $theme->name || 'Extra' == $theme->parent_theme ) {
|
214 |
-
return true;
|
215 |
-
}
|
216 |
-
}
|
217 |
-
return false;
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Check if Flatsome enabled for post id.
|
222 |
-
*
|
223 |
-
* @param object $theme theme data.
|
224 |
-
* @return boolean
|
225 |
-
*/
|
226 |
-
function is_flatsome_enabled( $theme = false ) {
|
227 |
-
|
228 |
-
if ( ! $theme ) {
|
229 |
-
$theme = wp_get_theme();
|
230 |
-
}
|
231 |
-
|
232 |
-
if ( 'Flatsome' == $theme->name || 'Flatsome' == $theme->parent_theme ) {
|
233 |
-
return true;
|
234 |
-
}
|
235 |
-
|
236 |
-
return false;
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Check if The7 enabled for post id.
|
241 |
-
*
|
242 |
-
* @param object $theme theme data.
|
243 |
-
* @return boolean
|
244 |
-
*/
|
245 |
-
function is_the_seven_enabled( $theme = false ) {
|
246 |
-
|
247 |
-
if ( ! $theme ) {
|
248 |
-
$theme = wp_get_theme();
|
249 |
-
}
|
250 |
-
|
251 |
-
if ( 'The7' == $theme->name || 'The7' == $theme->parent_theme ) {
|
252 |
-
return true;
|
253 |
-
}
|
254 |
-
|
255 |
-
return false;
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Check if OceanWp enabled for post id.
|
260 |
-
*
|
261 |
-
* @param object $theme theme data.
|
262 |
-
* @return boolean
|
263 |
-
*/
|
264 |
-
function is_oceanwp_enabled( $theme = false ) {
|
265 |
-
|
266 |
-
if ( ! $theme ) {
|
267 |
-
$theme = wp_get_theme();
|
268 |
-
}
|
269 |
-
|
270 |
-
if ( 'OceanWP' == $theme->name || 'OceanWP' == $theme->parent_theme ) {
|
271 |
-
return true;
|
272 |
-
}
|
273 |
-
|
274 |
-
return false;
|
275 |
-
}
|
276 |
-
|
277 |
-
/**
|
278 |
-
* Check for thrive architect edit page.
|
279 |
-
*
|
280 |
-
* @param int $post_id post id.
|
281 |
-
*/
|
282 |
-
public function is_thrive_edit_page( $post_id ) {
|
283 |
-
|
284 |
-
if ( true === $this->is_thrive_builder_page( $post_id ) ) {
|
285 |
-
return true;
|
286 |
-
} else {
|
287 |
-
return false;
|
288 |
-
}
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Check if the page being rendered is the main ID on the editor page.
|
293 |
-
*
|
294 |
-
* @since 1.0.0
|
295 |
-
* @param String $post_id Post ID which is to be rendered.
|
296 |
-
* @return boolean True if current if is being rendered is not being edited.
|
297 |
-
*/
|
298 |
-
private function is_thrive_builder_page( $post_id ) {
|
299 |
-
$tve = ( isset( $_GET['tve'] ) && 'true' == $_GET['tve'] ) ? true : false;
|
300 |
-
$post = isset( $_GET['post'] ) ? sanitize_text_field( $_GET['post'] ) : false;
|
301 |
-
|
302 |
-
return ( true == $tve && $post_id !== $post );
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Overwrite meta for page
|
307 |
-
*/
|
308 |
-
public function override_meta() {
|
309 |
-
|
310 |
-
// don't override meta for `elementor_library` post type.
|
311 |
-
if ( 'elementor_library' == get_post_type() ) {
|
312 |
-
return;
|
313 |
-
}
|
314 |
-
|
315 |
-
if ( ! is_singular() ) {
|
316 |
-
return;
|
317 |
-
}
|
318 |
-
|
319 |
-
global $post;
|
320 |
-
$post_id = $post->ID;
|
321 |
-
$post_type = get_post_type();
|
322 |
-
|
323 |
-
if ( 'cartflows_step' == $post_type && ( $this->is_elementor_preview_mode()
|
324 |
-
|| $this->is_bb_preview_mode() || $this->is_thrive_edit_page( $post_id )
|
325 |
-
|| $this->is_divi_builder_enabled( $post_id ) ) ) {
|
326 |
-
|
327 |
-
if ( '' == $post->post_content ) {
|
328 |
-
|
329 |
-
$this->overwrite_template( $post_id );
|
330 |
-
}
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
/**
|
335 |
-
* Assign cartflow canvas template to page.
|
336 |
-
*
|
337 |
-
* @param int $post_id post ID.
|
338 |
-
*/
|
339 |
-
public function overwrite_template( $post_id ) {
|
340 |
-
|
341 |
-
$template = 'cartflows-canvas';
|
342 |
-
$key = '_wp_page_template';
|
343 |
-
|
344 |
-
$record_exists = get_post_meta( $post_id, $key, true );
|
345 |
-
|
346 |
-
if ( 'cartflows-canvas' == $record_exists ) {
|
347 |
-
return;
|
348 |
-
}
|
349 |
-
|
350 |
-
// As elementor doesn't allow update post meta using update_post_meta, run wpdb query to update post meta.
|
351 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
352 |
-
|
353 |
-
global $wpdb;
|
354 |
-
|
355 |
-
if ( '' == $record_exists || ! $record_exists ) {
|
356 |
-
|
357 |
-
$wpdb->insert(
|
358 |
-
$wpdb->prefix . 'postmeta',
|
359 |
-
array(
|
360 |
-
'post_id' => $post_id,
|
361 |
-
'meta_key' => $key
|
362 |
-
'meta_value' => $template, //
|
363 |
-
)
|
364 |
-
)
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
}
|
402 |
-
|
403 |
-
|
404 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Page builder compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! class_exists( 'Cartflows_Compatibility' ) ) {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class for page builder compatibility
|
12 |
+
*/
|
13 |
+
class Cartflows_Compatibility {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Member Variable
|
17 |
+
*
|
18 |
+
* @var object instance
|
19 |
+
*/
|
20 |
+
private static $instance;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Initiator
|
24 |
+
*/
|
25 |
+
public static function get_instance() {
|
26 |
+
if ( ! isset( self::$instance ) ) {
|
27 |
+
self::$instance = new self();
|
28 |
+
}
|
29 |
+
return self::$instance;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Constructor
|
34 |
+
*/
|
35 |
+
public function __construct() {
|
36 |
+
|
37 |
+
$this->load_files();
|
38 |
+
|
39 |
+
// Override post meta.
|
40 |
+
add_action( 'wp', array( $this, 'override_meta' ), 0 );
|
41 |
+
|
42 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'load_fontawesome' ), 10000 );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Load page builder compatibility files
|
47 |
+
*/
|
48 |
+
public function load_files() {
|
49 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
50 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-elementor-compatibility.php';
|
51 |
+
}
|
52 |
+
|
53 |
+
if ( $this->is_divi_enabled() ) {
|
54 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-divi-compatibility.php';
|
55 |
+
}
|
56 |
+
|
57 |
+
if ( $this->is_bb_enabled() ) {
|
58 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-bb-compatibility.php';
|
59 |
+
}
|
60 |
+
|
61 |
+
if ( class_exists( 'TCB_Post' ) ) {
|
62 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-thrive-compatibility.php';
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( defined( 'LEARNDASH_VERSION' ) ) {
|
66 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-learndash-compatibility.php';
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Check if it is beaver builder enabled.
|
72 |
+
*
|
73 |
+
* @since 1.1.4
|
74 |
+
*/
|
75 |
+
public function is_bb_enabled() {
|
76 |
+
|
77 |
+
if ( class_exists( 'FLBuilderModel' ) ) {
|
78 |
+
return true;
|
79 |
+
}
|
80 |
+
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Check if elementor preview mode is on.
|
86 |
+
*/
|
87 |
+
public function is_elementor_preview_mode() {
|
88 |
+
|
89 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
90 |
+
|
91 |
+
if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
|
92 |
+
return true;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Get Current Theme.
|
101 |
+
*/
|
102 |
+
public function get_current_theme() {
|
103 |
+
|
104 |
+
$theme_name = '';
|
105 |
+
$theme = wp_get_theme();
|
106 |
+
|
107 |
+
if ( isset( $theme->parent_theme ) && '' != $theme->parent_theme || null != $theme->parent_theme ) {
|
108 |
+
$theme_name = $theme->parent_theme;
|
109 |
+
} else {
|
110 |
+
$theme_name = $theme->name;
|
111 |
+
}
|
112 |
+
|
113 |
+
return $theme_name;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Check if it is beaver builder preview mode
|
118 |
+
*/
|
119 |
+
public function is_bb_preview_mode() {
|
120 |
+
|
121 |
+
if ( class_exists( 'FLBuilderModel' ) ) {
|
122 |
+
if ( FLBuilderModel::is_builder_active() ) {
|
123 |
+
return true;
|
124 |
+
} else {
|
125 |
+
return false;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Check for page builder preview mode.
|
134 |
+
*/
|
135 |
+
public function is_page_builder_preview() {
|
136 |
+
|
137 |
+
if ( $this->is_elementor_preview_mode() || $this->is_bb_preview_mode() || $this->is_divi_builder_preview() ) {
|
138 |
+
return true;
|
139 |
+
}
|
140 |
+
|
141 |
+
return false;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Check if divi builder enabled for post id.
|
146 |
+
*/
|
147 |
+
public function is_divi_builder_preview() {
|
148 |
+
|
149 |
+
if ( isset( $_GET['et_fb'] ) && '1' === $_GET['et_fb'] ) {
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
|
153 |
+
return false;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Check if divi builder enabled for post id.
|
158 |
+
*
|
159 |
+
* @param int $post_id post id.
|
160 |
+
*/
|
161 |
+
public function is_divi_builder_enabled( $post_id ) {
|
162 |
+
|
163 |
+
if ( function_exists( 'et_pb_is_pagebuilder_used' ) && et_pb_is_pagebuilder_used( $post_id ) ) {
|
164 |
+
return true;
|
165 |
+
}
|
166 |
+
|
167 |
+
return false;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Check if compatibility theme enabled.
|
172 |
+
*/
|
173 |
+
public function is_compatibility_theme_enabled() {
|
174 |
+
|
175 |
+
$theme = wp_get_theme();
|
176 |
+
|
177 |
+
$is_compatibility = false;
|
178 |
+
|
179 |
+
if ( $this->is_divi_enabled( $theme ) || $this->is_flatsome_enabled( $theme ) ) {
|
180 |
+
|
181 |
+
$is_compatibility = true;
|
182 |
+
}
|
183 |
+
|
184 |
+
return apply_filters( 'cartflows_is_compatibility_theme', $is_compatibility );
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Check if divi builder enabled for post id.
|
189 |
+
*
|
190 |
+
* @param object $theme theme data.
|
191 |
+
* @return boolean
|
192 |
+
*/
|
193 |
+
public function is_divi_enabled( $theme = false ) {
|
194 |
+
|
195 |
+
if ( ! $theme ) {
|
196 |
+
$theme = wp_get_theme();
|
197 |
+
}
|
198 |
+
|
199 |
+
if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme || 'Extra' == $theme->name || 'Extra' == $theme->parent_theme ) {
|
200 |
+
return true;
|
201 |
+
}
|
202 |
+
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Check if Divi theme is install status.
|
208 |
+
*
|
209 |
+
* @return boolean
|
210 |
+
*/
|
211 |
+
public function is_divi_theme_installed() {
|
212 |
+
foreach ( (array) wp_get_themes() as $theme_dir => $theme ) {
|
213 |
+
if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme || 'Extra' == $theme->name || 'Extra' == $theme->parent_theme ) {
|
214 |
+
return true;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Check if Flatsome enabled for post id.
|
222 |
+
*
|
223 |
+
* @param object $theme theme data.
|
224 |
+
* @return boolean
|
225 |
+
*/
|
226 |
+
public function is_flatsome_enabled( $theme = false ) {
|
227 |
+
|
228 |
+
if ( ! $theme ) {
|
229 |
+
$theme = wp_get_theme();
|
230 |
+
}
|
231 |
+
|
232 |
+
if ( 'Flatsome' == $theme->name || 'Flatsome' == $theme->parent_theme ) {
|
233 |
+
return true;
|
234 |
+
}
|
235 |
+
|
236 |
+
return false;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Check if The7 enabled for post id.
|
241 |
+
*
|
242 |
+
* @param object $theme theme data.
|
243 |
+
* @return boolean
|
244 |
+
*/
|
245 |
+
public function is_the_seven_enabled( $theme = false ) {
|
246 |
+
|
247 |
+
if ( ! $theme ) {
|
248 |
+
$theme = wp_get_theme();
|
249 |
+
}
|
250 |
+
|
251 |
+
if ( 'The7' == $theme->name || 'The7' == $theme->parent_theme ) {
|
252 |
+
return true;
|
253 |
+
}
|
254 |
+
|
255 |
+
return false;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Check if OceanWp enabled for post id.
|
260 |
+
*
|
261 |
+
* @param object $theme theme data.
|
262 |
+
* @return boolean
|
263 |
+
*/
|
264 |
+
public function is_oceanwp_enabled( $theme = false ) {
|
265 |
+
|
266 |
+
if ( ! $theme ) {
|
267 |
+
$theme = wp_get_theme();
|
268 |
+
}
|
269 |
+
|
270 |
+
if ( 'OceanWP' == $theme->name || 'OceanWP' == $theme->parent_theme ) {
|
271 |
+
return true;
|
272 |
+
}
|
273 |
+
|
274 |
+
return false;
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Check for thrive architect edit page.
|
279 |
+
*
|
280 |
+
* @param int $post_id post id.
|
281 |
+
*/
|
282 |
+
public function is_thrive_edit_page( $post_id ) {
|
283 |
+
|
284 |
+
if ( true === $this->is_thrive_builder_page( $post_id ) ) {
|
285 |
+
return true;
|
286 |
+
} else {
|
287 |
+
return false;
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Check if the page being rendered is the main ID on the editor page.
|
293 |
+
*
|
294 |
+
* @since 1.0.0
|
295 |
+
* @param String $post_id Post ID which is to be rendered.
|
296 |
+
* @return boolean True if current if is being rendered is not being edited.
|
297 |
+
*/
|
298 |
+
private function is_thrive_builder_page( $post_id ) {
|
299 |
+
$tve = ( isset( $_GET['tve'] ) && 'true' == $_GET['tve'] ) ? true : false;
|
300 |
+
$post = isset( $_GET['post'] ) ? sanitize_text_field( wp_unslash( $_GET['post'] ) ) : false;
|
301 |
+
|
302 |
+
return ( true == $tve && $post_id !== $post );
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Overwrite meta for page
|
307 |
+
*/
|
308 |
+
public function override_meta() {
|
309 |
+
|
310 |
+
// don't override meta for `elementor_library` post type.
|
311 |
+
if ( 'elementor_library' == get_post_type() ) {
|
312 |
+
return;
|
313 |
+
}
|
314 |
+
|
315 |
+
if ( ! is_singular() ) {
|
316 |
+
return;
|
317 |
+
}
|
318 |
+
|
319 |
+
global $post;
|
320 |
+
$post_id = $post->ID;
|
321 |
+
$post_type = get_post_type();
|
322 |
+
|
323 |
+
if ( 'cartflows_step' == $post_type && ( $this->is_elementor_preview_mode()
|
324 |
+
|| $this->is_bb_preview_mode() || $this->is_thrive_edit_page( $post_id )
|
325 |
+
|| $this->is_divi_builder_enabled( $post_id ) ) ) {
|
326 |
+
|
327 |
+
if ( '' == $post->post_content ) {
|
328 |
+
|
329 |
+
$this->overwrite_template( $post_id );
|
330 |
+
}
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Assign cartflow canvas template to page.
|
336 |
+
*
|
337 |
+
* @param int $post_id post ID.
|
338 |
+
*/
|
339 |
+
public function overwrite_template( $post_id ) {
|
340 |
+
|
341 |
+
$template = 'cartflows-canvas';
|
342 |
+
$key = '_wp_page_template';
|
343 |
+
|
344 |
+
$record_exists = get_post_meta( $post_id, $key, true );
|
345 |
+
|
346 |
+
if ( 'cartflows-canvas' == $record_exists ) {
|
347 |
+
return;
|
348 |
+
}
|
349 |
+
|
350 |
+
// As elementor doesn't allow update post meta using update_post_meta, run wpdb query to update post meta.
|
351 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
352 |
+
|
353 |
+
global $wpdb;
|
354 |
+
|
355 |
+
if ( '' == $record_exists || ! $record_exists ) {
|
356 |
+
|
357 |
+
$wpdb->insert(
|
358 |
+
$wpdb->prefix . 'postmeta',
|
359 |
+
array(
|
360 |
+
'post_id' => $post_id,
|
361 |
+
'meta_key' => $key,//phpcs:ignore
|
362 |
+
'meta_value' => $template, //phpcs:ignore
|
363 |
+
)
|
364 |
+
);// db call ok;.
|
365 |
+
|
366 |
+
// alternative query to above query.
|
367 |
+
// $table = $wpdb->prefix . 'postmeta';
|
368 |
+
// $wpdb->query($wpdb->prepare( "INSERT INTO { $table } ( `post_id`, `meta_key`, 'meta_value' )
|
369 |
+
// VALUES ( '$post_id', '$key', '$template' )" ) );// db call ok; no-cache ok.
|
370 |
+
|
371 |
+
} else {
|
372 |
+
|
373 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND post_id = %s;", $template, $key, $post_id ) ); // db call ok; no-cache ok.
|
374 |
+
}
|
375 |
+
} else {
|
376 |
+
|
377 |
+
update_post_meta( $post_id, $key, $template );
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Load font awesome style from oceanwp on checkout page.
|
383 |
+
*/
|
384 |
+
public function load_fontawesome() {
|
385 |
+
|
386 |
+
$theme = get_template();
|
387 |
+
|
388 |
+
if ( 'oceanwp' == strtolower( $theme ) && wcf()->utils->is_step_post_type() ) {
|
389 |
+
|
390 |
+
$load_fa = apply_filters( 'cartflows_maybe_load_font_awesome', true );
|
391 |
+
|
392 |
+
if ( $load_fa ) {
|
393 |
+
|
394 |
+
wp_enqueue_style( 'font-awesome', OCEANWP_CSS_DIR_URI . 'third/font-awesome.min.css', false );//phpcs:ignore
|
395 |
+
}
|
396 |
+
|
397 |
+
$custom_css = '
|
398 |
+
#oceanwp-cart-sidebar-wrap,
|
399 |
+
#owp-qv-wrap{
|
400 |
+
display: none;
|
401 |
+
}';
|
402 |
+
|
403 |
+
wp_add_inline_style( 'wcf-frontend-global', $custom_css );
|
404 |
+
}
|
405 |
+
}
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
Cartflows_Compatibility::get_instance();
|
410 |
+
|
classes/class-cartflows-default-meta.php
CHANGED
@@ -1,875 +1,879 @@
|
|
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 |
-
/**
|
18 |
-
* Member Variable
|
19 |
-
*
|
20 |
-
* @var instance
|
21 |
-
*/
|
22 |
-
private static $instance;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Member Variable
|
26 |
-
*
|
27 |
-
* @var checkout_fields
|
28 |
-
*/
|
29 |
-
private static $checkout_fields = null;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Member Variable
|
33 |
-
*
|
34 |
-
* @var checkout_fields
|
35 |
-
*/
|
36 |
-
private static $thankyou_fields = null;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Member Variable
|
40 |
-
*
|
41 |
-
* @var flow_fields
|
42 |
-
*/
|
43 |
-
private static $flow_fields = null;
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Member Variable
|
47 |
-
*
|
48 |
-
* @var landing_fields
|
49 |
-
*/
|
50 |
-
private static $landing_fields = null;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Initiator
|
54 |
-
*/
|
55 |
-
public static function get_instance() {
|
56 |
-
if ( ! isset( self::$instance ) ) {
|
57 |
-
self::$instance = new self();
|
58 |
-
}
|
59 |
-
return self::$instance;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Constructor
|
64 |
-
*/
|
65 |
-
public function __construct() {
|
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 |
-
self::$checkout_fields = array(
|
78 |
-
'wcf-field-google-font-url' => array(
|
79 |
-
'default' => '',
|
80 |
-
'sanitize' => 'FILTER_DEFAULT',
|
81 |
-
),
|
82 |
-
'wcf-checkout-products' => array(
|
83 |
-
'default' => array(),
|
84 |
-
'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS',
|
85 |
-
),
|
86 |
-
'wcf-checkout-layout' => array(
|
87 |
-
'default' => 'two-column',
|
88 |
-
'sanitize' => 'FILTER_DEFAULT',
|
89 |
-
),
|
90 |
-
'wcf-input-font-family' => array(
|
91 |
-
'default' => '',
|
92 |
-
'sanitize' => 'FILTER_DEFAULT',
|
93 |
-
),
|
94 |
-
'wcf-input-font-weight' => array(
|
95 |
-
'default' => '',
|
96 |
-
'sanitize' => 'FILTER_DEFAULT',
|
97 |
-
),
|
98 |
-
'wcf-heading-font-family' => array(
|
99 |
-
'default' => '',
|
100 |
-
'sanitize' => 'FILTER_DEFAULT',
|
101 |
-
),
|
102 |
-
'wcf-heading-font-weight' => array(
|
103 |
-
'default' => '',
|
104 |
-
'sanitize' => 'FILTER_DEFAULT',
|
105 |
-
),
|
106 |
-
'wcf-base-font-family' => array(
|
107 |
-
'default' => '',
|
108 |
-
'sanitize' => 'FILTER_DEFAULT',
|
109 |
-
),
|
110 |
-
'wcf-advance-options-fields' => array(
|
111 |
-
'default' => '',
|
112 |
-
'sanitize' => 'FILTER_DEFAULT',
|
113 |
-
),
|
114 |
-
'wcf-
|
115 |
-
'default' => '',
|
116 |
-
'sanitize' => 'FILTER_DEFAULT',
|
117 |
-
),
|
118 |
-
'wcf-
|
119 |
-
'default' => '',
|
120 |
-
'sanitize' => 'FILTER_DEFAULT',
|
121 |
-
),
|
122 |
-
'wcf-button-font-
|
123 |
-
'default' => '',
|
124 |
-
'sanitize' => 'FILTER_DEFAULT',
|
125 |
-
),
|
126 |
-
'wcf-
|
127 |
-
'default' => '',
|
128 |
-
'sanitize' => 'FILTER_DEFAULT',
|
129 |
-
),
|
130 |
-
'wcf-
|
131 |
-
'default' => '',
|
132 |
-
'sanitize' => 'FILTER_DEFAULT',
|
133 |
-
),
|
134 |
-
'wcf-
|
135 |
-
'default' => '',
|
136 |
-
'sanitize' => 'FILTER_DEFAULT',
|
137 |
-
),
|
138 |
-
'wcf-
|
139 |
-
'default' => '',
|
140 |
-
'sanitize' => 'FILTER_DEFAULT',
|
141 |
-
),
|
142 |
-
'wcf-
|
143 |
-
'default' => '',
|
144 |
-
'sanitize' => 'FILTER_DEFAULT',
|
145 |
-
),
|
146 |
-
'wcf-field-
|
147 |
-
'default' => '',
|
148 |
-
'sanitize' => 'FILTER_DEFAULT',
|
149 |
-
),
|
150 |
-
'wcf-
|
151 |
-
'default' => '',
|
152 |
-
'sanitize' => 'FILTER_DEFAULT',
|
153 |
-
),
|
154 |
-
'wcf-
|
155 |
-
'default' => '
|
156 |
-
'sanitize' => 'FILTER_DEFAULT',
|
157 |
-
),
|
158 |
-
'wcf-field-
|
159 |
-
'default' => '',
|
160 |
-
'sanitize' => 'FILTER_DEFAULT',
|
161 |
-
),
|
162 |
-
'wcf-field-
|
163 |
-
'default' => '',
|
164 |
-
'sanitize' => 'FILTER_DEFAULT',
|
165 |
-
),
|
166 |
-
'wcf-field-
|
167 |
-
'default' => '',
|
168 |
-
'sanitize' => 'FILTER_DEFAULT',
|
169 |
-
),
|
170 |
-
'wcf-
|
171 |
-
'default' => '',
|
172 |
-
'sanitize' => 'FILTER_DEFAULT',
|
173 |
-
),
|
174 |
-
'wcf-
|
175 |
-
'default' => '',
|
176 |
-
'sanitize' => 'FILTER_DEFAULT',
|
177 |
-
),
|
178 |
-
'wcf-
|
179 |
-
'default' => '',
|
180 |
-
'sanitize' => 'FILTER_DEFAULT',
|
181 |
-
),
|
182 |
-
'wcf-submit-
|
183 |
-
'default' => '',
|
184 |
-
'sanitize' => 'FILTER_DEFAULT',
|
185 |
-
),
|
186 |
-
'wcf-
|
187 |
-
'default' => '
|
188 |
-
'sanitize' => 'FILTER_DEFAULT',
|
189 |
-
),
|
190 |
-
'wcf-
|
191 |
-
'default' => '',
|
192 |
-
'sanitize' => 'FILTER_DEFAULT',
|
193 |
-
),
|
194 |
-
'wcf-submit-
|
195 |
-
'default' => '',
|
196 |
-
'sanitize' => 'FILTER_DEFAULT',
|
197 |
-
),
|
198 |
-
'wcf-submit-
|
199 |
-
'default' => '',
|
200 |
-
'sanitize' => 'FILTER_DEFAULT',
|
201 |
-
),
|
202 |
-
'wcf-submit-bg-
|
203 |
-
'default' => '',
|
204 |
-
'sanitize' => 'FILTER_DEFAULT',
|
205 |
-
),
|
206 |
-
'wcf-submit-
|
207 |
-
'default' => '',
|
208 |
-
'sanitize' => 'FILTER_DEFAULT',
|
209 |
-
),
|
210 |
-
'wcf-submit-border-
|
211 |
-
'default' => '',
|
212 |
-
'sanitize' => 'FILTER_DEFAULT',
|
213 |
-
),
|
214 |
-
'wcf-
|
215 |
-
'default' => '',
|
216 |
-
'sanitize' => 'FILTER_DEFAULT',
|
217 |
-
),
|
218 |
-
'wcf-
|
219 |
-
'default' => '',
|
220 |
-
'sanitize' => 'FILTER_DEFAULT',
|
221 |
-
),
|
222 |
-
'wcf-header-logo-
|
223 |
-
'default' => '',
|
224 |
-
'sanitize' => 'FILTER_DEFAULT',
|
225 |
-
),
|
226 |
-
'wcf-
|
227 |
-
'default' => '',
|
228 |
-
'sanitize' => 'FILTER_DEFAULT',
|
229 |
-
),
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
'
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
*
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
case '
|
344 |
-
$meta_value = filter_input( INPUT_POST, $key,
|
345 |
-
break;
|
346 |
-
|
347 |
-
case '
|
348 |
-
$meta_value = filter_input( INPUT_POST, $key,
|
349 |
-
break;
|
350 |
-
|
351 |
-
case '
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
$
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
$
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
$
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
$
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
$
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
$
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
$
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
$
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
$
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
$
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
$
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
$
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
$
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
}
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
*
|
661 |
-
*
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
*
|
688 |
-
*
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
*
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
'wcf-
|
738 |
-
'default' => '',
|
739 |
-
'sanitize' => 'FILTER_DEFAULT',
|
740 |
-
),
|
741 |
-
'wcf-
|
742 |
-
'default' => '',
|
743 |
-
'sanitize' => 'FILTER_DEFAULT',
|
744 |
-
),
|
745 |
-
'wcf-tq-
|
746 |
-
'default' => '',
|
747 |
-
'sanitize' => 'FILTER_DEFAULT',
|
748 |
-
),
|
749 |
-
'wcf-tq-
|
750 |
-
'default' => '',
|
751 |
-
'sanitize' => 'FILTER_DEFAULT',
|
752 |
-
),
|
753 |
-
'wcf-tq-heading-
|
754 |
-
'default' => '',
|
755 |
-
'sanitize' => 'FILTER_DEFAULT',
|
756 |
-
),
|
757 |
-
'wcf-tq-heading-font-
|
758 |
-
'default' => '',
|
759 |
-
'sanitize' => 'FILTER_DEFAULT',
|
760 |
-
),
|
761 |
-
'wcf-tq-
|
762 |
-
'default' => '',
|
763 |
-
'sanitize' => 'FILTER_DEFAULT',
|
764 |
-
),
|
765 |
-
'wcf-tq-
|
766 |
-
'default' => '',
|
767 |
-
'sanitize' => 'FILTER_DEFAULT',
|
768 |
-
),
|
769 |
-
'wcf-tq-
|
770 |
-
'default' => '',
|
771 |
-
'sanitize' => 'FILTER_DEFAULT',
|
772 |
-
),
|
773 |
-
'wcf-
|
774 |
-
'default' => '
|
775 |
-
'sanitize' => 'FILTER_DEFAULT',
|
776 |
-
),
|
777 |
-
'wcf-show-
|
778 |
-
'default' => 'yes',
|
779 |
-
'sanitize' => 'FILTER_DEFAULT',
|
780 |
-
),
|
781 |
-
'wcf-show-
|
782 |
-
'default' => 'yes',
|
783 |
-
'sanitize' => 'FILTER_DEFAULT',
|
784 |
-
),
|
785 |
-
'wcf-show-
|
786 |
-
'default' => 'yes',
|
787 |
-
'sanitize' => 'FILTER_DEFAULT',
|
788 |
-
),
|
789 |
-
'wcf-
|
790 |
-
'default' => '',
|
791 |
-
'sanitize' => 'FILTER_DEFAULT',
|
792 |
-
),
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
*
|
805 |
-
*
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
*
|
832 |
-
*
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
|
|
|
|
|
|
|
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 |
+
/**
|
18 |
+
* Member Variable
|
19 |
+
*
|
20 |
+
* @var instance
|
21 |
+
*/
|
22 |
+
private static $instance;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Member Variable
|
26 |
+
*
|
27 |
+
* @var checkout_fields
|
28 |
+
*/
|
29 |
+
private static $checkout_fields = null;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Member Variable
|
33 |
+
*
|
34 |
+
* @var checkout_fields
|
35 |
+
*/
|
36 |
+
private static $thankyou_fields = null;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Member Variable
|
40 |
+
*
|
41 |
+
* @var flow_fields
|
42 |
+
*/
|
43 |
+
private static $flow_fields = null;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Member Variable
|
47 |
+
*
|
48 |
+
* @var landing_fields
|
49 |
+
*/
|
50 |
+
private static $landing_fields = null;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Initiator
|
54 |
+
*/
|
55 |
+
public static function get_instance() {
|
56 |
+
if ( ! isset( self::$instance ) ) {
|
57 |
+
self::$instance = new self();
|
58 |
+
}
|
59 |
+
return self::$instance;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Constructor
|
64 |
+
*/
|
65 |
+
public function __construct() {
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Checkout Default fields.
|
70 |
+
*
|
71 |
+
* @param int $post_id post id.
|
72 |
+
* @return array
|
73 |
+
*/
|
74 |
+
public function get_checkout_fields( $post_id ) {
|
75 |
+
|
76 |
+
if ( null === self::$checkout_fields ) {
|
77 |
+
self::$checkout_fields = array(
|
78 |
+
'wcf-field-google-font-url' => array(
|
79 |
+
'default' => '',
|
80 |
+
'sanitize' => 'FILTER_DEFAULT',
|
81 |
+
),
|
82 |
+
'wcf-checkout-products' => array(
|
83 |
+
'default' => array(),
|
84 |
+
'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS',
|
85 |
+
),
|
86 |
+
'wcf-checkout-layout' => array(
|
87 |
+
'default' => 'two-column',
|
88 |
+
'sanitize' => 'FILTER_DEFAULT',
|
89 |
+
),
|
90 |
+
'wcf-input-font-family' => array(
|
91 |
+
'default' => '',
|
92 |
+
'sanitize' => 'FILTER_DEFAULT',
|
93 |
+
),
|
94 |
+
'wcf-input-font-weight' => array(
|
95 |
+
'default' => '',
|
96 |
+
'sanitize' => 'FILTER_DEFAULT',
|
97 |
+
),
|
98 |
+
'wcf-heading-font-family' => array(
|
99 |
+
'default' => '',
|
100 |
+
'sanitize' => 'FILTER_DEFAULT',
|
101 |
+
),
|
102 |
+
'wcf-heading-font-weight' => array(
|
103 |
+
'default' => '',
|
104 |
+
'sanitize' => 'FILTER_DEFAULT',
|
105 |
+
),
|
106 |
+
'wcf-base-font-family' => array(
|
107 |
+
'default' => '',
|
108 |
+
'sanitize' => 'FILTER_DEFAULT',
|
109 |
+
),
|
110 |
+
'wcf-advance-options-fields' => array(
|
111 |
+
'default' => '',
|
112 |
+
'sanitize' => 'FILTER_DEFAULT',
|
113 |
+
),
|
114 |
+
'wcf-remove-product-field' => array(
|
115 |
+
'default' => '',
|
116 |
+
'sanitize' => 'FILTER_DEFAULT',
|
117 |
+
),
|
118 |
+
'wcf-base-font-weight' => array(
|
119 |
+
'default' => '',
|
120 |
+
'sanitize' => 'FILTER_DEFAULT',
|
121 |
+
),
|
122 |
+
'wcf-button-font-family' => array(
|
123 |
+
'default' => '',
|
124 |
+
'sanitize' => 'FILTER_DEFAULT',
|
125 |
+
),
|
126 |
+
'wcf-button-font-weight' => array(
|
127 |
+
'default' => '',
|
128 |
+
'sanitize' => 'FILTER_DEFAULT',
|
129 |
+
),
|
130 |
+
'wcf-primary-color' => array(
|
131 |
+
'default' => '',
|
132 |
+
'sanitize' => 'FILTER_DEFAULT',
|
133 |
+
),
|
134 |
+
'wcf-heading-color' => array(
|
135 |
+
'default' => '',
|
136 |
+
'sanitize' => 'FILTER_DEFAULT',
|
137 |
+
),
|
138 |
+
'wcf-section-bg-color' => array(
|
139 |
+
'default' => '',
|
140 |
+
'sanitize' => 'FILTER_DEFAULT',
|
141 |
+
),
|
142 |
+
'wcf-hl-bg-color' => array(
|
143 |
+
'default' => '',
|
144 |
+
'sanitize' => 'FILTER_DEFAULT',
|
145 |
+
),
|
146 |
+
'wcf-field-tb-padding' => array(
|
147 |
+
'default' => '',
|
148 |
+
'sanitize' => 'FILTER_DEFAULT',
|
149 |
+
),
|
150 |
+
'wcf-field-lr-padding' => array(
|
151 |
+
'default' => '',
|
152 |
+
'sanitize' => 'FILTER_DEFAULT',
|
153 |
+
),
|
154 |
+
'wcf-fields-skins' => array(
|
155 |
+
'default' => '',
|
156 |
+
'sanitize' => 'FILTER_DEFAULT',
|
157 |
+
),
|
158 |
+
'wcf-input-field-size' => array(
|
159 |
+
'default' => '33px',
|
160 |
+
'sanitize' => 'FILTER_DEFAULT',
|
161 |
+
),
|
162 |
+
'wcf-field-color' => array(
|
163 |
+
'default' => '',
|
164 |
+
'sanitize' => 'FILTER_DEFAULT',
|
165 |
+
),
|
166 |
+
'wcf-field-bg-color' => array(
|
167 |
+
'default' => '',
|
168 |
+
'sanitize' => 'FILTER_DEFAULT',
|
169 |
+
),
|
170 |
+
'wcf-field-border-color' => array(
|
171 |
+
'default' => '',
|
172 |
+
'sanitize' => 'FILTER_DEFAULT',
|
173 |
+
),
|
174 |
+
'wcf-box-border-color' => array(
|
175 |
+
'default' => '',
|
176 |
+
'sanitize' => 'FILTER_DEFAULT',
|
177 |
+
),
|
178 |
+
'wcf-field-label-color' => array(
|
179 |
+
'default' => '',
|
180 |
+
'sanitize' => 'FILTER_DEFAULT',
|
181 |
+
),
|
182 |
+
'wcf-submit-tb-padding' => array(
|
183 |
+
'default' => '',
|
184 |
+
'sanitize' => 'FILTER_DEFAULT',
|
185 |
+
),
|
186 |
+
'wcf-submit-lr-padding' => array(
|
187 |
+
'default' => '',
|
188 |
+
'sanitize' => 'FILTER_DEFAULT',
|
189 |
+
),
|
190 |
+
'wcf-input-button-size' => array(
|
191 |
+
'default' => '33px',
|
192 |
+
'sanitize' => 'FILTER_DEFAULT',
|
193 |
+
),
|
194 |
+
'wcf-submit-color' => array(
|
195 |
+
'default' => '',
|
196 |
+
'sanitize' => 'FILTER_DEFAULT',
|
197 |
+
),
|
198 |
+
'wcf-submit-hover-color' => array(
|
199 |
+
'default' => '',
|
200 |
+
'sanitize' => 'FILTER_DEFAULT',
|
201 |
+
),
|
202 |
+
'wcf-submit-bg-color' => array(
|
203 |
+
'default' => '',
|
204 |
+
'sanitize' => 'FILTER_DEFAULT',
|
205 |
+
),
|
206 |
+
'wcf-submit-bg-hover-color' => array(
|
207 |
+
'default' => '',
|
208 |
+
'sanitize' => 'FILTER_DEFAULT',
|
209 |
+
),
|
210 |
+
'wcf-submit-border-color' => array(
|
211 |
+
'default' => '',
|
212 |
+
'sanitize' => 'FILTER_DEFAULT',
|
213 |
+
),
|
214 |
+
'wcf-submit-border-hover-color' => array(
|
215 |
+
'default' => '',
|
216 |
+
'sanitize' => 'FILTER_DEFAULT',
|
217 |
+
),
|
218 |
+
'wcf-active-tab' => array(
|
219 |
+
'default' => '',
|
220 |
+
'sanitize' => 'FILTER_DEFAULT',
|
221 |
+
),
|
222 |
+
'wcf-header-logo-image' => array(
|
223 |
+
'default' => '',
|
224 |
+
'sanitize' => 'FILTER_DEFAULT',
|
225 |
+
),
|
226 |
+
'wcf-header-logo-width' => array(
|
227 |
+
'default' => '',
|
228 |
+
'sanitize' => 'FILTER_DEFAULT',
|
229 |
+
),
|
230 |
+
'wcf-custom-script' => array(
|
231 |
+
'default' => '',
|
232 |
+
'sanitize' => 'FILTER_DEFAULT',
|
233 |
+
),
|
234 |
+
);
|
235 |
+
|
236 |
+
self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id );
|
237 |
+
}
|
238 |
+
|
239 |
+
return self::$checkout_fields;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Save Checkout Meta fields.
|
244 |
+
*
|
245 |
+
* @param int $post_id post id.
|
246 |
+
* @return void
|
247 |
+
*/
|
248 |
+
public function save_checkout_fields( $post_id ) {
|
249 |
+
|
250 |
+
$post_meta = $this->get_checkout_fields( $post_id );
|
251 |
+
|
252 |
+
$this->save_meta_fields( $post_id, $post_meta );
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Save Landing Meta fields.
|
257 |
+
*
|
258 |
+
* @param int $post_id post id.
|
259 |
+
* @return void
|
260 |
+
*/
|
261 |
+
public function save_landing_fields( $post_id ) {
|
262 |
+
|
263 |
+
$post_meta = $this->get_landing_fields( $post_id );
|
264 |
+
|
265 |
+
$this->save_meta_fields( $post_id, $post_meta );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Save ThankYou Meta fields.
|
270 |
+
*
|
271 |
+
* @param int $post_id post id.
|
272 |
+
* @return void
|
273 |
+
*/
|
274 |
+
public function save_thankyou_fields( $post_id ) {
|
275 |
+
|
276 |
+
$post_meta = $this->get_thankyou_fields( $post_id );
|
277 |
+
|
278 |
+
$this->save_meta_fields( $post_id, $post_meta );
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Flow Default fields.
|
283 |
+
*
|
284 |
+
* @param int $post_id post id.
|
285 |
+
* @return array
|
286 |
+
*/
|
287 |
+
public function get_flow_fields( $post_id ) {
|
288 |
+
|
289 |
+
if ( null === self::$flow_fields ) {
|
290 |
+
self::$flow_fields = array(
|
291 |
+
'wcf-steps' => array(
|
292 |
+
'default' => array(),
|
293 |
+
'sanitize' => 'FILTER_DEFAULT',
|
294 |
+
),
|
295 |
+
|
296 |
+
'wcf-testing' => array(
|
297 |
+
'default' => 'no',
|
298 |
+
'sanitize' => 'FILTER_DEFAULT',
|
299 |
+
),
|
300 |
+
);
|
301 |
+
}
|
302 |
+
|
303 |
+
return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields );
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Save Flow Meta fields.
|
308 |
+
*
|
309 |
+
* @param int $post_id post id.
|
310 |
+
* @return void
|
311 |
+
*/
|
312 |
+
public function save_flow_fields( $post_id ) {
|
313 |
+
|
314 |
+
$post_meta = $this->get_flow_fields( $post_id );
|
315 |
+
|
316 |
+
if ( isset( $post_meta['wcf-steps'] ) ) {
|
317 |
+
unset( $post_meta['wcf-steps'] );
|
318 |
+
}
|
319 |
+
|
320 |
+
$this->save_meta_fields( $post_id, $post_meta );
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Save Meta fields - Common Function.
|
325 |
+
*
|
326 |
+
* @param int $post_id post id.
|
327 |
+
* @param array $post_meta options to store.
|
328 |
+
* @return void
|
329 |
+
*/
|
330 |
+
public function save_meta_fields( $post_id, $post_meta ) {
|
331 |
+
|
332 |
+
if ( ! ( $post_id && is_array( $post_meta ) ) ) {
|
333 |
+
return;
|
334 |
+
}
|
335 |
+
|
336 |
+
foreach ( $post_meta as $key => $data ) {
|
337 |
+
$meta_value = false;
|
338 |
+
|
339 |
+
// Sanitize values.
|
340 |
+
$sanitize_filter = ( isset( $data['sanitize'] ) ) ? $data['sanitize'] : 'FILTER_DEFAULT';
|
341 |
+
|
342 |
+
switch ( $sanitize_filter ) {
|
343 |
+
case 'FILTER_SANITIZE_STRING':
|
344 |
+
$meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING );
|
345 |
+
break;
|
346 |
+
|
347 |
+
case 'FILTER_SANITIZE_URL':
|
348 |
+
$meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_URL );
|
349 |
+
break;
|
350 |
+
|
351 |
+
case 'FILTER_SANITIZE_NUMBER_INT':
|
352 |
+
$meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT );
|
353 |
+
break;
|
354 |
+
|
355 |
+
case 'FILTER_CARTFLOWS_ARRAY':
|
356 |
+
if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
|
357 |
+
$meta_value = array_map( 'sanitize_text_field', wp_unslash( $_POST[ $key ] ) );
|
358 |
+
}
|
359 |
+
break;
|
360 |
+
|
361 |
+
case 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS':
|
362 |
+
if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
|
363 |
+
$i = 0;
|
364 |
+
$q = 0;
|
365 |
+
|
366 |
+
foreach ( $_POST[ $key ] as $p_index => $p_data ) { // phpcs:ignore
|
367 |
+
foreach ( $p_data as $i_key => $i_value ) {
|
368 |
+
if ( is_array( $i_value ) ) {
|
369 |
+
foreach ( $i_value as $q_key => $q_value ) {
|
370 |
+
$meta_value[ $i ][ $i_key ][ $q ] = array_map( 'sanitize_text_field', $q_value );
|
371 |
+
|
372 |
+
$q++;
|
373 |
+
}
|
374 |
+
} else {
|
375 |
+
$meta_value[ $i ][ $i_key ] = sanitize_text_field( $i_value );
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
$i++;
|
380 |
+
}
|
381 |
+
}
|
382 |
+
break;
|
383 |
+
case 'FILTER_CARTFLOWS_CHECKOUT_FIELDS':
|
384 |
+
$count = 10;
|
385 |
+
$ordered_fields = array();
|
386 |
+
$billing_fields = array();
|
387 |
+
|
388 |
+
if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
|
389 |
+
$post_data = wp_unslash( $_POST[ $key ] );
|
390 |
+
|
391 |
+
if ( 'wcf_field_order_billing' == $key ) {
|
392 |
+
$billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
|
393 |
+
|
394 |
+
foreach ( $post_data as $index => $value ) {
|
395 |
+
if ( isset( $billing_fields[ $value ] ) ) {
|
396 |
+
$ordered_fields[ $value ] = $billing_fields[ $value ];
|
397 |
+
$ordered_fields[ $value ]['priority'] = $count;
|
398 |
+
$count += 10;
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
$meta_value = $ordered_fields;
|
403 |
+
}
|
404 |
+
|
405 |
+
if ( 'wcf_field_order_shipping' == $key ) {
|
406 |
+
$shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
|
407 |
+
foreach ( $post_data as $index => $value ) {
|
408 |
+
if ( isset( $shipping_fields[ $value ] ) ) {
|
409 |
+
$ordered_fields[ $value ] = $shipping_fields[ $value ];
|
410 |
+
$ordered_fields[ $value ]['priority'] = $count;
|
411 |
+
$count += 10;
|
412 |
+
}
|
413 |
+
}
|
414 |
+
$meta_value = $ordered_fields;
|
415 |
+
}
|
416 |
+
|
417 |
+
if ( 'wcf_label_text_field_billing' == $key ) {
|
418 |
+
$get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
|
419 |
+
|
420 |
+
if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
|
421 |
+
echo 'con 1';
|
422 |
+
$billing_fields = $get_ordered_billing_fields;
|
423 |
+
} else {
|
424 |
+
echo 'con 2';
|
425 |
+
$billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
|
426 |
+
}
|
427 |
+
|
428 |
+
foreach ( $post_data as $index => $value ) {
|
429 |
+
if ( isset( $billing_fields[ $index ] ) ) {
|
430 |
+
$ordered_fields[ $index ] = $billing_fields[ $index ];
|
431 |
+
$ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) );
|
432 |
+
}
|
433 |
+
}
|
434 |
+
$key = 'wcf_field_order_billing';
|
435 |
+
$meta_value = $ordered_fields;
|
436 |
+
}
|
437 |
+
|
438 |
+
if ( 'wcf_label_text_field_shipping' == $key ) {
|
439 |
+
$get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
|
440 |
+
|
441 |
+
if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
|
442 |
+
$shipping_fields = $get_ordered_shipping_fields;
|
443 |
+
} else {
|
444 |
+
$shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
|
445 |
+
}
|
446 |
+
|
447 |
+
foreach ( $post_data as $index => $value ) {
|
448 |
+
if ( isset( $shipping_fields[ $index ] ) ) {
|
449 |
+
$ordered_fields[ $index ] = $shipping_fields[ $index ];
|
450 |
+
$ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) );
|
451 |
+
}
|
452 |
+
}
|
453 |
+
$key = 'wcf_field_order_shipping';
|
454 |
+
$meta_value = $ordered_fields;
|
455 |
+
}
|
456 |
+
|
457 |
+
if ( 'wcf_label_placeholder_field_billing' == $key ) {
|
458 |
+
$get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
|
459 |
+
|
460 |
+
if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
|
461 |
+
$billing_fields = $get_ordered_billing_fields;
|
462 |
+
} else {
|
463 |
+
$billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
|
464 |
+
}
|
465 |
+
foreach ( $post_data as $index => $value ) {
|
466 |
+
if ( isset( $billing_fields[ $index ] ) ) {
|
467 |
+
$ordered_fields[ $index ] = $billing_fields[ $index ];
|
468 |
+
$ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) );
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
$key = 'wcf_field_order_billing';
|
473 |
+
$meta_value = $ordered_fields;
|
474 |
+
}
|
475 |
+
|
476 |
+
if ( 'wcf_label_placeholder_field_shipping' == $key ) {
|
477 |
+
$get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
|
478 |
+
|
479 |
+
if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
|
480 |
+
$shipping_fields = $get_ordered_shipping_fields;
|
481 |
+
} else {
|
482 |
+
$shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
|
483 |
+
}
|
484 |
+
|
485 |
+
foreach ( $post_data as $index => $value ) {
|
486 |
+
if ( isset( $shipping_fields[ $index ] ) ) {
|
487 |
+
$ordered_fields[ $index ] = $shipping_fields[ $index ];
|
488 |
+
$ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) );
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
$key = 'wcf_field_order_shipping';
|
493 |
+
$meta_value = $ordered_fields;
|
494 |
+
}
|
495 |
+
|
496 |
+
if ( 'wcf_label_default_field_billing' == $key ) {
|
497 |
+
$get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
|
498 |
+
|
499 |
+
if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
|
500 |
+
$billing_fields = $get_ordered_billing_fields;
|
501 |
+
} else {
|
502 |
+
$billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
|
503 |
+
}
|
504 |
+
|
505 |
+
foreach ( $post_data as $index => $value ) {
|
506 |
+
if ( isset( $billing_fields[ $index ] ) ) {
|
507 |
+
$ordered_fields[ $index ] = $billing_fields[ $index ];
|
508 |
+
$ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) );
|
509 |
+
}
|
510 |
+
}
|
511 |
+
|
512 |
+
$key = 'wcf_field_order_billing';
|
513 |
+
$meta_value = $ordered_fields;
|
514 |
+
}
|
515 |
+
|
516 |
+
if ( 'wcf_label_default_field_shipping' == $key ) {
|
517 |
+
$get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
|
518 |
+
|
519 |
+
if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
|
520 |
+
$shipping_fields = $get_ordered_shipping_fields;
|
521 |
+
} else {
|
522 |
+
$shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
|
523 |
+
}
|
524 |
+
|
525 |
+
foreach ( $post_data as $index => $value ) {
|
526 |
+
if ( isset( $shipping_fields[ $index ] ) ) {
|
527 |
+
$ordered_fields[ $index ] = $shipping_fields[ $index ];
|
528 |
+
$ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) );
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
+
$key = 'wcf_field_order_shipping';
|
533 |
+
$meta_value = $ordered_fields;
|
534 |
+
}
|
535 |
+
|
536 |
+
if ( 'wcf_is_required_field_billing' == $key ) {
|
537 |
+
$get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
|
538 |
+
|
539 |
+
if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
|
540 |
+
$billing_fields = $get_ordered_billing_fields;
|
541 |
+
} else {
|
542 |
+
$billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
|
543 |
+
}
|
544 |
+
|
545 |
+
foreach ( $post_data as $index => $value ) {
|
546 |
+
if ( isset( $billing_fields[ $index ] ) ) {
|
547 |
+
$ordered_fields[ $index ] = $billing_fields[ $index ];
|
548 |
+
if ( 'yes' == $value ) {
|
549 |
+
$ordered_fields[ $index ]['required'] = true;
|
550 |
+
} else {
|
551 |
+
$ordered_fields[ $index ]['required'] = false;
|
552 |
+
}
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
$key = 'wcf_field_order_billing';
|
557 |
+
$meta_value = $ordered_fields;
|
558 |
+
}
|
559 |
+
|
560 |
+
if ( 'wcf_is_required_field_shipping' == $key ) {
|
561 |
+
$get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
|
562 |
+
|
563 |
+
if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
|
564 |
+
$shipping_fields = $get_ordered_shipping_fields;
|
565 |
+
} else {
|
566 |
+
$shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
|
567 |
+
}
|
568 |
+
|
569 |
+
foreach ( $post_data as $index => $value ) {
|
570 |
+
if ( isset( $shipping_fields[ $index ] ) ) {
|
571 |
+
$ordered_fields[ $index ] = $shipping_fields[ $index ];
|
572 |
+
|
573 |
+
if ( 'yes' == $value ) {
|
574 |
+
$ordered_fields[ $index ]['required'] = true;
|
575 |
+
} else {
|
576 |
+
$ordered_fields[ $index ]['required'] = false;
|
577 |
+
}
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
$key = 'wcf_field_order_shipping';
|
582 |
+
$meta_value = $ordered_fields;
|
583 |
+
}
|
584 |
+
|
585 |
+
if ( 'wcf_select_option_field_billing' == $key ) {
|
586 |
+
$get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
|
587 |
+
|
588 |
+
if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
|
589 |
+
$billing_fields = $get_ordered_billing_fields;
|
590 |
+
} else {
|
591 |
+
$billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
|
592 |
+
}
|
593 |
+
|
594 |
+
foreach ( $post_data as $index => $value ) {
|
595 |
+
$options = explode( ',', $value );
|
596 |
+
|
597 |
+
if ( isset( $billing_fields[ $index ] ) ) {
|
598 |
+
$ordered_fields[ $index ] = $billing_fields[ $index ];
|
599 |
+
|
600 |
+
$ordered_fields[ $index ]['options'] = array();
|
601 |
+
|
602 |
+
foreach ( $options as $key => $option ) {
|
603 |
+
$ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) );
|
604 |
+
}
|
605 |
+
}
|
606 |
+
}
|
607 |
+
|
608 |
+
$key = 'wcf_field_order_billing';
|
609 |
+
$meta_value = $ordered_fields;
|
610 |
+
}
|
611 |
+
|
612 |
+
if ( 'wcf_select_option_field_shipping' == $key ) {
|
613 |
+
$get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
|
614 |
+
|
615 |
+
if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
|
616 |
+
$shipping_fields = $get_ordered_shipping_fields;
|
617 |
+
} else {
|
618 |
+
$shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
|
619 |
+
}
|
620 |
+
|
621 |
+
foreach ( $post_data as $index => $value ) {
|
622 |
+
$options = explode( ',', $value );
|
623 |
+
|
624 |
+
if ( isset( $shipping_fields[ $index ] ) ) {
|
625 |
+
$ordered_fields[ $index ] = $shipping_fields[ $index ];
|
626 |
+
|
627 |
+
$ordered_fields[ $index ]['options'] = array();
|
628 |
+
|
629 |
+
foreach ( $options as $key => $option ) {
|
630 |
+
$ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) );
|
631 |
+
}
|
632 |
+
}
|
633 |
+
}
|
634 |
+
|
635 |
+
$key = 'wcf_field_order_shipping';
|
636 |
+
$meta_value = $ordered_fields;
|
637 |
+
}
|
638 |
+
}
|
639 |
+
break;
|
640 |
+
|
641 |
+
default:
|
642 |
+
if ( 'FILTER_DEFAULT' === $sanitize_filter ) {
|
643 |
+
$meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT );
|
644 |
+
} else {
|
645 |
+
$meta_value = apply_filters( 'cartflows_save_meta_field_values', $meta_value, $post_id, $key, $sanitize_filter );
|
646 |
+
}
|
647 |
+
|
648 |
+
break;
|
649 |
+
}
|
650 |
+
|
651 |
+
if ( false !== $meta_value ) {
|
652 |
+
update_post_meta( $post_id, $key, $meta_value );
|
653 |
+
} else {
|
654 |
+
delete_post_meta( $post_id, $key );
|
655 |
+
}
|
656 |
+
}
|
657 |
+
}
|
658 |
+
|
659 |
+
/**
|
660 |
+
* Get checkout meta.
|
661 |
+
*
|
662 |
+
* @param int $post_id post id.
|
663 |
+
* @param string $key options key.
|
664 |
+
* @param mix $default options default value.
|
665 |
+
* @return string
|
666 |
+
*/
|
667 |
+
public function get_flow_meta_value( $post_id, $key, $default = false ) {
|
668 |
+
|
669 |
+
$value = $this->get_save_meta( $post_id, $key );
|
670 |
+
|
671 |
+
if ( ! $value ) {
|
672 |
+
if ( $default ) {
|
673 |
+
$value = $default;
|
674 |
+
} else {
|
675 |
+
$fields = $this->get_flow_fields( $post_id );
|
676 |
+
|
677 |
+
if ( isset( $fields[ $key ]['default'] ) ) {
|
678 |
+
$value = $fields[ $key ]['default'];
|
679 |
+
}
|
680 |
+
}
|
681 |
+
}
|
682 |
+
|
683 |
+
return $value;
|
684 |
+
}
|
685 |
+
|
686 |
+
/**
|
687 |
+
* Get checkout meta.
|
688 |
+
*
|
689 |
+
* @param int $post_id post id.
|
690 |
+
* @param string $key options key.
|
691 |
+
* @param mix $default options default value.
|
692 |
+
* @return string
|
693 |
+
*/
|
694 |
+
public function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) {
|
695 |
+
|
696 |
+
$value = $this->get_save_meta( $post_id, $key );
|
697 |
+
|
698 |
+
if ( ! $value ) {
|
699 |
+
if ( false !== $default ) {
|
700 |
+
$value = $default;
|
701 |
+
} else {
|
702 |
+
$fields = $this->get_checkout_fields( $post_id );
|
703 |
+
|
704 |
+
if ( isset( $fields[ $key ]['default'] ) ) {
|
705 |
+
$value = $fields[ $key ]['default'];
|
706 |
+
}
|
707 |
+
}
|
708 |
+
}
|
709 |
+
|
710 |
+
return $value;
|
711 |
+
}
|
712 |
+
|
713 |
+
/**
|
714 |
+
* Get post meta.
|
715 |
+
*
|
716 |
+
* @param int $post_id post id.
|
717 |
+
* @param string $key options key.
|
718 |
+
* @return string
|
719 |
+
*/
|
720 |
+
public function get_save_meta( $post_id, $key ) {
|
721 |
+
|
722 |
+
$value = get_post_meta( $post_id, $key, true );
|
723 |
+
|
724 |
+
return $value;
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Thank You Default fields.
|
729 |
+
*
|
730 |
+
* @param int $post_id post id.
|
731 |
+
* @return array
|
732 |
+
*/
|
733 |
+
public function get_thankyou_fields( $post_id ) {
|
734 |
+
|
735 |
+
if ( null === self::$thankyou_fields ) {
|
736 |
+
self::$thankyou_fields = array(
|
737 |
+
'wcf-field-google-font-url' => array(
|
738 |
+
'default' => '',
|
739 |
+
'sanitize' => 'FILTER_DEFAULT',
|
740 |
+
),
|
741 |
+
'wcf-active-tab' => array(
|
742 |
+
'default' => '',
|
743 |
+
'sanitize' => 'FILTER_DEFAULT',
|
744 |
+
),
|
745 |
+
'wcf-tq-text-color' => array(
|
746 |
+
'default' => '',
|
747 |
+
'sanitize' => 'FILTER_DEFAULT',
|
748 |
+
),
|
749 |
+
'wcf-tq-font-family' => array(
|
750 |
+
'default' => '',
|
751 |
+
'sanitize' => 'FILTER_DEFAULT',
|
752 |
+
),
|
753 |
+
'wcf-tq-heading-color' => array(
|
754 |
+
'default' => '',
|
755 |
+
'sanitize' => 'FILTER_DEFAULT',
|
756 |
+
),
|
757 |
+
'wcf-tq-heading-font-family' => array(
|
758 |
+
'default' => '',
|
759 |
+
'sanitize' => 'FILTER_DEFAULT',
|
760 |
+
),
|
761 |
+
'wcf-tq-heading-font-wt' => array(
|
762 |
+
'default' => '',
|
763 |
+
'sanitize' => 'FILTER_DEFAULT',
|
764 |
+
),
|
765 |
+
'wcf-tq-container-width' => array(
|
766 |
+
'default' => '',
|
767 |
+
'sanitize' => 'FILTER_DEFAULT',
|
768 |
+
),
|
769 |
+
'wcf-tq-section-bg-color' => array(
|
770 |
+
'default' => '',
|
771 |
+
'sanitize' => 'FILTER_DEFAULT',
|
772 |
+
),
|
773 |
+
'wcf-tq-advance-options-fields' => array(
|
774 |
+
'default' => '',
|
775 |
+
'sanitize' => 'FILTER_DEFAULT',
|
776 |
+
),
|
777 |
+
'wcf-show-overview-section' => array(
|
778 |
+
'default' => 'yes',
|
779 |
+
'sanitize' => 'FILTER_DEFAULT',
|
780 |
+
),
|
781 |
+
'wcf-show-details-section' => array(
|
782 |
+
'default' => 'yes',
|
783 |
+
'sanitize' => 'FILTER_DEFAULT',
|
784 |
+
),
|
785 |
+
'wcf-show-billing-section' => array(
|
786 |
+
'default' => 'yes',
|
787 |
+
'sanitize' => 'FILTER_DEFAULT',
|
788 |
+
),
|
789 |
+
'wcf-show-shipping-section' => array(
|
790 |
+
'default' => 'yes',
|
791 |
+
'sanitize' => 'FILTER_DEFAULT',
|
792 |
+
),
|
793 |
+
'wcf-custom-script' => array(
|
794 |
+
'default' => '',
|
795 |
+
'sanitize' => 'FILTER_DEFAULT',
|
796 |
+
),
|
797 |
+
);
|
798 |
+
}
|
799 |
+
|
800 |
+
return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id );
|
801 |
+
}
|
802 |
+
|
803 |
+
/**
|
804 |
+
* Get Thank you section meta.
|
805 |
+
*
|
806 |
+
* @param int $post_id post id.
|
807 |
+
* @param string $key options key.
|
808 |
+
* @param mix $default options default value.
|
809 |
+
* @return string
|
810 |
+
*/
|
811 |
+
public function get_thankyou_meta_value( $post_id, $key, $default = false ) {
|
812 |
+
|
813 |
+
$value = $this->get_save_meta( $post_id, $key );
|
814 |
+
|
815 |
+
if ( ! $value ) {
|
816 |
+
if ( $default ) {
|
817 |
+
$value = $default;
|
818 |
+
} else {
|
819 |
+
$fields = $this->get_thankyou_fields( $post_id );
|
820 |
+
|
821 |
+
if ( isset( $fields[ $key ]['default'] ) ) {
|
822 |
+
$value = $fields[ $key ]['default'];
|
823 |
+
}
|
824 |
+
}
|
825 |
+
}
|
826 |
+
|
827 |
+
return $value;
|
828 |
+
}
|
829 |
+
|
830 |
+
/**
|
831 |
+
* Get Landing section meta.
|
832 |
+
*
|
833 |
+
* @param int $post_id post id.
|
834 |
+
* @param string $key options key.
|
835 |
+
* @param mix $default options default value.
|
836 |
+
* @return string
|
837 |
+
*/
|
838 |
+
public function get_landing_meta_value( $post_id, $key, $default = false ) {
|
839 |
+
|
840 |
+
$value = $this->get_save_meta( $post_id, $key );
|
841 |
+
if ( ! $value ) {
|
842 |
+
if ( $default ) {
|
843 |
+
$value = $default;
|
844 |
+
} else {
|
845 |
+
$fields = $this->get_landing_fields( $post_id );
|
846 |
+
|
847 |
+
if ( isset( $fields[ $key ]['default'] ) ) {
|
848 |
+
$value = $fields[ $key ]['default'];
|
849 |
+
}
|
850 |
+
}
|
851 |
+
}
|
852 |
+
|
853 |
+
return $value;
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Thank You Default fields.
|
858 |
+
*
|
859 |
+
* @param int $post_id post id.
|
860 |
+
* @return array
|
861 |
+
*/
|
862 |
+
public function get_landing_fields( $post_id ) {
|
863 |
+
|
864 |
+
if ( null === self::$landing_fields ) {
|
865 |
+
self::$landing_fields = array(
|
866 |
+
'wcf-custom-script' => array(
|
867 |
+
'default' => '',
|
868 |
+
'sanitize' => 'FILTER_DEFAULT',
|
869 |
+
),
|
870 |
+
);
|
871 |
+
}
|
872 |
+
return apply_filters( 'cartflows_landing_meta_options', self::$landing_fields, $post_id );
|
873 |
+
}
|
874 |
+
}
|
875 |
+
|
876 |
+
/**
|
877 |
+
* Kicking this off by calling 'get_instance()' method
|
878 |
+
*/
|
879 |
+
Cartflows_Default_Meta::get_instance();
|
classes/class-cartflows-flow-frontend.php
CHANGED
@@ -1,206 +1,206 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Frontend & Markup
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Flow Markup
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Flow_Frontend {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var object instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
/* Analytics */
|
39 |
-
add_action( 'cartflows_wp_footer', array( $this, 'footer_markup' ) );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Footer markup
|
44 |
-
*/
|
45 |
-
function footer_markup() {
|
46 |
-
|
47 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
48 |
-
// @codingStandardsIgnoreStart
|
49 |
-
$flow_id = wcf()->utils->get_flow_id();
|
50 |
-
?>
|
51 |
-
<?php if( $this->is_flow_testmode( $flow_id ) ) { ?>
|
52 |
-
<div class="wcf-preview-mode">
|
53 |
-
<span><?php _e( 'Test mode is active — which displays random products for previewing. It can be deactivated from the flow settings in the admin dashboard.', 'cartflows' ); ?></span>
|
54 |
-
<?php if ( current_user_can( 'manage_options' ) ) { ?>
|
55 |
-
<?php
|
56 |
-
$flow_edit_link = add_query_arg( 'edit_test_mode', 'yes', get_edit_post_link( $flow_id ) );
|
57 |
-
?>
|
58 |
-
<a href="<?php echo $flow_edit_link; ?>"><?php _e( 'Click here to disable it', 'cartflows'); ?></a>
|
59 |
-
<?php } ?>
|
60 |
-
</div>
|
61 |
-
<?php } ?>
|
62 |
-
<?php
|
63 |
-
// @codingStandardsIgnoreEnd
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Check if flow test mode is enable.
|
69 |
-
*
|
70 |
-
* @since 1.0.0
|
71 |
-
* @param int $flow_id flow ID.
|
72 |
-
*
|
73 |
-
* @return boolean
|
74 |
-
*/
|
75 |
-
function is_flow_testmode( $flow_id = '' ) {
|
76 |
-
|
77 |
-
if ( ! $flow_id ) {
|
78 |
-
$flow_id = wcf()->utils->get_flow_id();
|
79 |
-
}
|
80 |
-
|
81 |
-
$test_mode = wcf()->options->get_flow_meta_value( $flow_id, 'wcf-testing' );
|
82 |
-
|
83 |
-
if ( 'no' === $test_mode ) {
|
84 |
-
return false;
|
85 |
-
}
|
86 |
-
|
87 |
-
return true;
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Get steps data.
|
92 |
-
*
|
93 |
-
* @since 1.0.0
|
94 |
-
* @param int $flow_id flow ID.
|
95 |
-
*
|
96 |
-
* @return array
|
97 |
-
*/
|
98 |
-
function get_steps( $flow_id ) {
|
99 |
-
|
100 |
-
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
101 |
-
|
102 |
-
if ( ! is_array( $steps ) ) {
|
103 |
-
|
104 |
-
$steps = array();
|
105 |
-
}
|
106 |
-
|
107 |
-
return $steps;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Check thank you page exists.
|
112 |
-
*
|
113 |
-
* @since 1.0.0
|
114 |
-
* @param array $order order data.
|
115 |
-
*
|
116 |
-
* @return bool
|
117 |
-
*/
|
118 |
-
function is_thankyou_page_exists( $order ) {
|
119 |
-
|
120 |
-
$thankyou_step_exist = false;
|
121 |
-
|
122 |
-
$flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
|
123 |
-
|
124 |
-
if ( $flow_id ) {
|
125 |
-
|
126 |
-
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
127 |
-
$step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
128 |
-
|
129 |
-
if ( is_array( $flow_steps ) ) {
|
130 |
-
|
131 |
-
$current_step_found = false;
|
132 |
-
|
133 |
-
foreach ( $flow_steps as $index => $data ) {
|
134 |
-
|
135 |
-
if ( $current_step_found ) {
|
136 |
-
|
137 |
-
if ( 'thankyou' === $data['type'] ) {
|
138 |
-
|
139 |
-
$thankyou_step_exist = true;
|
140 |
-
break;
|
141 |
-
}
|
142 |
-
} else {
|
143 |
-
|
144 |
-
if ( intval( $data['id'] ) === $step_id ) {
|
145 |
-
|
146 |
-
$current_step_found = true;
|
147 |
-
}
|
148 |
-
}
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
return $thankyou_step_exist;
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Check thank you page exists.
|
158 |
-
*
|
159 |
-
* @since 1.0.0
|
160 |
-
* @param array $order order data.
|
161 |
-
*
|
162 |
-
* @return bool
|
163 |
-
*/
|
164 |
-
function get_thankyou_page_id( $order ) {
|
165 |
-
|
166 |
-
$thankyou_step_id = false;
|
167 |
-
|
168 |
-
$flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
|
169 |
-
|
170 |
-
if ( $flow_id ) {
|
171 |
-
|
172 |
-
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
173 |
-
$step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
174 |
-
|
175 |
-
if ( is_array( $flow_steps ) ) {
|
176 |
-
|
177 |
-
$current_step_found = false;
|
178 |
-
|
179 |
-
foreach ( $flow_steps as $index => $data ) {
|
180 |
-
|
181 |
-
if ( $current_step_found ) {
|
182 |
-
|
183 |
-
if ( 'thankyou' === $data['type'] ) {
|
184 |
-
|
185 |
-
$thankyou_step_id = intval( $data['id'] );
|
186 |
-
break;
|
187 |
-
}
|
188 |
-
} else {
|
189 |
-
|
190 |
-
if ( intval( $data['id'] ) === $step_id ) {
|
191 |
-
|
192 |
-
$current_step_found = true;
|
193 |
-
}
|
194 |
-
}
|
195 |
-
}
|
196 |
-
}
|
197 |
-
}
|
198 |
-
|
199 |
-
return $thankyou_step_id;
|
200 |
-
}
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Kicking this off by calling 'get_instance()' method
|
205 |
-
*/
|
206 |
-
Cartflows_Flow_Frontend::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Frontend & Markup
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Flow Markup
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Flow_Frontend {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var object instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
/* Analytics */
|
39 |
+
add_action( 'cartflows_wp_footer', array( $this, 'footer_markup' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Footer markup
|
44 |
+
*/
|
45 |
+
public function footer_markup() {
|
46 |
+
|
47 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
48 |
+
// @codingStandardsIgnoreStart
|
49 |
+
$flow_id = wcf()->utils->get_flow_id();
|
50 |
+
?>
|
51 |
+
<?php if( $this->is_flow_testmode( $flow_id ) ) { ?>
|
52 |
+
<div class="wcf-preview-mode">
|
53 |
+
<span><?php _e( 'Test mode is active — which displays random products for previewing. It can be deactivated from the flow settings in the admin dashboard.', 'cartflows' ); ?></span>
|
54 |
+
<?php if ( current_user_can( 'manage_options' ) ) { ?>
|
55 |
+
<?php
|
56 |
+
$flow_edit_link = add_query_arg( 'edit_test_mode', 'yes', get_edit_post_link( $flow_id ) );
|
57 |
+
?>
|
58 |
+
<a href="<?php echo $flow_edit_link; ?>"><?php _e( 'Click here to disable it', 'cartflows'); ?></a>
|
59 |
+
<?php } ?>
|
60 |
+
</div>
|
61 |
+
<?php } ?>
|
62 |
+
<?php
|
63 |
+
// @codingStandardsIgnoreEnd
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Check if flow test mode is enable.
|
69 |
+
*
|
70 |
+
* @since 1.0.0
|
71 |
+
* @param int $flow_id flow ID.
|
72 |
+
*
|
73 |
+
* @return boolean
|
74 |
+
*/
|
75 |
+
public function is_flow_testmode( $flow_id = '' ) {
|
76 |
+
|
77 |
+
if ( ! $flow_id ) {
|
78 |
+
$flow_id = wcf()->utils->get_flow_id();
|
79 |
+
}
|
80 |
+
|
81 |
+
$test_mode = wcf()->options->get_flow_meta_value( $flow_id, 'wcf-testing' );
|
82 |
+
|
83 |
+
if ( 'no' === $test_mode ) {
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
return true;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get steps data.
|
92 |
+
*
|
93 |
+
* @since 1.0.0
|
94 |
+
* @param int $flow_id flow ID.
|
95 |
+
*
|
96 |
+
* @return array
|
97 |
+
*/
|
98 |
+
public function get_steps( $flow_id ) {
|
99 |
+
|
100 |
+
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
101 |
+
|
102 |
+
if ( ! is_array( $steps ) ) {
|
103 |
+
|
104 |
+
$steps = array();
|
105 |
+
}
|
106 |
+
|
107 |
+
return $steps;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Check thank you page exists.
|
112 |
+
*
|
113 |
+
* @since 1.0.0
|
114 |
+
* @param array $order order data.
|
115 |
+
*
|
116 |
+
* @return bool
|
117 |
+
*/
|
118 |
+
public function is_thankyou_page_exists( $order ) {
|
119 |
+
|
120 |
+
$thankyou_step_exist = false;
|
121 |
+
|
122 |
+
$flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
|
123 |
+
|
124 |
+
if ( $flow_id ) {
|
125 |
+
|
126 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
127 |
+
$step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
128 |
+
|
129 |
+
if ( is_array( $flow_steps ) ) {
|
130 |
+
|
131 |
+
$current_step_found = false;
|
132 |
+
|
133 |
+
foreach ( $flow_steps as $index => $data ) {
|
134 |
+
|
135 |
+
if ( $current_step_found ) {
|
136 |
+
|
137 |
+
if ( 'thankyou' === $data['type'] ) {
|
138 |
+
|
139 |
+
$thankyou_step_exist = true;
|
140 |
+
break;
|
141 |
+
}
|
142 |
+
} else {
|
143 |
+
|
144 |
+
if ( intval( $data['id'] ) === $step_id ) {
|
145 |
+
|
146 |
+
$current_step_found = true;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
return $thankyou_step_exist;
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Check thank you page exists.
|
158 |
+
*
|
159 |
+
* @since 1.0.0
|
160 |
+
* @param array $order order data.
|
161 |
+
*
|
162 |
+
* @return bool
|
163 |
+
*/
|
164 |
+
public function get_thankyou_page_id( $order ) {
|
165 |
+
|
166 |
+
$thankyou_step_id = false;
|
167 |
+
|
168 |
+
$flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
|
169 |
+
|
170 |
+
if ( $flow_id ) {
|
171 |
+
|
172 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
173 |
+
$step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
174 |
+
|
175 |
+
if ( is_array( $flow_steps ) ) {
|
176 |
+
|
177 |
+
$current_step_found = false;
|
178 |
+
|
179 |
+
foreach ( $flow_steps as $index => $data ) {
|
180 |
+
|
181 |
+
if ( $current_step_found ) {
|
182 |
+
|
183 |
+
if ( 'thankyou' === $data['type'] ) {
|
184 |
+
|
185 |
+
$thankyou_step_id = intval( $data['id'] );
|
186 |
+
break;
|
187 |
+
}
|
188 |
+
} else {
|
189 |
+
|
190 |
+
if ( intval( $data['id'] ) === $step_id ) {
|
191 |
+
|
192 |
+
$current_step_found = true;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
return $thankyou_step_id;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Kicking this off by calling 'get_instance()' method
|
205 |
+
*/
|
206 |
+
Cartflows_Flow_Frontend::get_instance();
|
classes/class-cartflows-frontend.php
CHANGED
@@ -1,530 +1,530 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Frontend.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Cartflows_Frontend.
|
10 |
-
*/
|
11 |
-
class Cartflows_Frontend {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Member Variable
|
15 |
-
*
|
16 |
-
* @var instance
|
17 |
-
*/
|
18 |
-
private static $instance;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Initiator
|
22 |
-
*/
|
23 |
-
public static function get_instance() {
|
24 |
-
if ( ! isset( self::$instance ) ) {
|
25 |
-
self::$instance = new self();
|
26 |
-
}
|
27 |
-
return self::$instance;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Constructor
|
32 |
-
*/
|
33 |
-
public function __construct() {
|
34 |
-
|
35 |
-
/* Set / Destroy Flow Sessions. Set data */
|
36 |
-
add_action( 'wp', array( $this, 'init_actions' ), 1 );
|
37 |
-
|
38 |
-
add_action( 'init', array( $this, 'debug_data_setting_actions' ) );
|
39 |
-
/* Enqueue global required scripts */
|
40 |
-
add_action( 'wp', array( $this, 'wp_actions' ), 55 );
|
41 |
-
|
42 |
-
/* Modify the checkout order received url to go thank you page in our flow */
|
43 |
-
add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 );
|
44 |
-
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Redirect to thank page if upsell not exists
|
49 |
-
*
|
50 |
-
* @param string $order_recieve_url url.
|
51 |
-
* @param object $order order object.
|
52 |
-
* @since 1.0.0
|
53 |
-
*/
|
54 |
-
function redirect_to_thankyou_page( $order_recieve_url, $order ) {
|
55 |
-
|
56 |
-
/* Only for thank you page */
|
57 |
-
wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ );
|
58 |
-
wcf()->logger->log( 'Only for thank you page' );
|
59 |
-
|
60 |
-
if ( wcf()->flow->is_thankyou_page_exists( $order ) ) {
|
61 |
-
|
62 |
-
if ( _is_wcf_doing_checkout_ajax() ) {
|
63 |
-
|
64 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_post_data();
|
65 |
-
|
66 |
-
if ( ! $checkout_id ) {
|
67 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
68 |
-
}
|
69 |
-
} else {
|
70 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
71 |
-
}
|
72 |
-
|
73 |
-
wcf()->logger->log( 'Checkout ID : ' . $checkout_id );
|
74 |
-
|
75 |
-
if ( $checkout_id ) {
|
76 |
-
|
77 |
-
$thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order );
|
78 |
-
|
79 |
-
if ( $thankyou_step_id ) {
|
80 |
-
|
81 |
-
$order_recieve_url = get_permalink( $thankyou_step_id );
|
82 |
-
|
83 |
-
$order_recieve_url = add_query_arg(
|
84 |
-
array(
|
85 |
-
'wcf-key' => $order->get_order_key(),
|
86 |
-
'wcf-order' => $order->get_id(),
|
87 |
-
),
|
88 |
-
$order_recieve_url
|
89 |
-
);
|
90 |
-
}
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ );
|
95 |
-
|
96 |
-
Cartflows_Helper::send_fb_response_if_enabled( $order->get_id() );
|
97 |
-
|
98 |
-
return $order_recieve_url;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Cancel and redirect to checkout
|
103 |
-
*
|
104 |
-
* @param string $return_url url.
|
105 |
-
* @since 1.0.0
|
106 |
-
*/
|
107 |
-
function redirect_to_checkout_on_cancel( $return_url ) {
|
108 |
-
|
109 |
-
if ( _is_wcf_doing_checkout_ajax() ) {
|
110 |
-
|
111 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_post_data();
|
112 |
-
|
113 |
-
if ( ! $checkout_id ) {
|
114 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
115 |
-
}
|
116 |
-
} else {
|
117 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
118 |
-
}
|
119 |
-
|
120 |
-
if ( $checkout_id ) {
|
121 |
-
|
122 |
-
$return_url = add_query_arg(
|
123 |
-
array(
|
124 |
-
'cancel_order' => 'true',
|
125 |
-
'_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
|
126 |
-
),
|
127 |
-
get_permalink( $checkout_id )
|
128 |
-
);
|
129 |
-
}
|
130 |
-
|
131 |
-
return $return_url;
|
132 |
-
}
|
133 |
-
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Remove theme styles.
|
137 |
-
*
|
138 |
-
* @since 1.0.0
|
139 |
-
*/
|
140 |
-
function remove_theme_styles() {
|
141 |
-
|
142 |
-
if ( Cartflows_Compatibility::get_instance()->is_compatibility_theme_enabled() ) {
|
143 |
-
return;
|
144 |
-
}
|
145 |
-
|
146 |
-
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
147 |
-
|
148 |
-
$page_template = apply_filters( 'cartflows_page_template', $page_template );
|
149 |
-
|
150 |
-
if ( 'default' === $page_template ) {
|
151 |
-
return;
|
152 |
-
}
|
153 |
-
|
154 |
-
// get all styles data.
|
155 |
-
global $wp_styles;
|
156 |
-
global $wp_scripts;
|
157 |
-
|
158 |
-
$get_stylesheet = 'themes/' . get_stylesheet() . '/';
|
159 |
-
$get_template = 'themes/' . get_template() . '/';
|
160 |
-
|
161 |
-
$remove_styles = apply_filters( 'cartflows_remove_theme_styles', true );
|
162 |
-
|
163 |
-
if ( $remove_styles ) {
|
164 |
-
|
165 |
-
// loop over all of the registered scripts..
|
166 |
-
foreach ( $wp_styles->registered as $handle => $data ) {
|
167 |
-
|
168 |
-
if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
|
169 |
-
|
170 |
-
// remove it.
|
171 |
-
wp_deregister_style( $handle );
|
172 |
-
wp_dequeue_style( $handle );
|
173 |
-
}
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
$remove_scripts = apply_filters( 'cartflows_remove_theme_scripts', true );
|
178 |
-
|
179 |
-
if ( $remove_scripts ) {
|
180 |
-
|
181 |
-
// loop over all of the registered scripts.
|
182 |
-
foreach ( $wp_scripts->registered as $handle => $data ) {
|
183 |
-
|
184 |
-
if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
|
185 |
-
|
186 |
-
// remove it.
|
187 |
-
wp_deregister_script( $handle );
|
188 |
-
wp_dequeue_script( $handle );
|
189 |
-
}
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Update main order data in transient.
|
197 |
-
*
|
198 |
-
* @param array $woo_styles new styles array.
|
199 |
-
* @since 1.0.0
|
200 |
-
* @return array.
|
201 |
-
*/
|
202 |
-
function woo_default_css( $woo_styles ) {
|
203 |
-
|
204 |
-
$woo_styles = array(
|
205 |
-
'woocommerce-layout' => array(
|
206 |
-
'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ),
|
207 |
-
'deps' => '',
|
208 |
-
'version' => WC_VERSION,
|
209 |
-
'media' => 'all',
|
210 |
-
'has_rtl' => true,
|
211 |
-
),
|
212 |
-
'woocommerce-smallscreen' => array(
|
213 |
-
'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ),
|
214 |
-
'deps' => 'woocommerce-layout',
|
215 |
-
'version' => WC_VERSION,
|
216 |
-
'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
|
217 |
-
'has_rtl' => true,
|
218 |
-
),
|
219 |
-
'woocommerce-general' => array(
|
220 |
-
'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ),
|
221 |
-
'deps' => '',
|
222 |
-
'version' => WC_VERSION,
|
223 |
-
'media' => 'all',
|
224 |
-
'has_rtl' => true,
|
225 |
-
),
|
226 |
-
);
|
227 |
-
|
228 |
-
return $woo_styles;
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Init Actions.
|
233 |
-
*
|
234 |
-
* @since 1.0.0
|
235 |
-
*/
|
236 |
-
function init_actions() {
|
237 |
-
|
238 |
-
$this->set_flow_session();
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Set flow session.
|
243 |
-
*
|
244 |
-
* @since 1.0.0
|
245 |
-
*/
|
246 |
-
function set_flow_session() {
|
247 |
-
|
248 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
249 |
-
|
250 |
-
add_action( 'wp_head', array( $this, 'noindex_flow' ) );
|
251 |
-
|
252 |
-
wcf()->utils->do_not_cache();
|
253 |
-
|
254 |
-
/* Set key to support pixel */
|
255 |
-
if ( isset( $_GET['wcf-key'] ) ) {
|
256 |
-
$_GET['key'] = $_GET['wcf-key'];
|
257 |
-
$_REQUEST['key'] = $_GET['wcf-key'];
|
258 |
-
}
|
259 |
-
|
260 |
-
if ( isset( $_GET['wcf-order'] ) ) {
|
261 |
-
$_GET['order'] = $_GET['wcf-order'];
|
262 |
-
$_REQUEST['order'] = $_GET['wcf-order'];
|
263 |
-
$_GET['order-received'] = $_GET['wcf-order'];
|
264 |
-
$_REQUEST['order-received'] = $_GET['wcf-order'];
|
265 |
-
}
|
266 |
-
}
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Add noindex, nofollow.
|
271 |
-
*
|
272 |
-
* @since 1.0.0
|
273 |
-
*/
|
274 |
-
function noindex_flow() {
|
275 |
-
|
276 |
-
$common = Cartflows_Helper::get_common_settings();
|
277 |
-
|
278 |
-
if ( 'enable' === $common['disallow_indexing'] ) {
|
279 |
-
echo '<meta name="robots" content="noindex,nofollow">';
|
280 |
-
}
|
281 |
-
}
|
282 |
-
|
283 |
-
/**
|
284 |
-
* WP Actions.
|
285 |
-
*
|
286 |
-
* @since 1.0.0
|
287 |
-
*/
|
288 |
-
function wp_actions() {
|
289 |
-
|
290 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
291 |
-
|
292 |
-
if ( ! wcf()->is_woo_active && wcf()->utils->check_is_woo_required_page() ) {
|
293 |
-
wp_die( ' This page requires WooCommerce plugin installed and activated!', 'WooCommerce Required' );
|
294 |
-
}
|
295 |
-
|
296 |
-
/* CSS Compatibility for All theme */
|
297 |
-
add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 );
|
298 |
-
|
299 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 );
|
300 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 );
|
301 |
-
|
302 |
-
/* Load woo templates from plugin */
|
303 |
-
add_filter( 'woocommerce_locate_template', array( $this, 'override_woo_template' ), 20, 3 );
|
304 |
-
|
305 |
-
/* Add version class to body in frontend. */
|
306 |
-
add_filter( 'body_class', array( $this, 'add_cartflows_lite_version_to_body' ) );
|
307 |
-
|
308 |
-
/* Custom Script Option */
|
309 |
-
add_action( 'wp_head', array( $this, 'custom_script_option' ) );
|
310 |
-
|
311 |
-
/* Remove the action applied by the Flatsome theme */
|
312 |
-
if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
|
313 |
-
$this->remove_flatsome_action();
|
314 |
-
}
|
315 |
-
|
316 |
-
add_action( 'wp_head', array( $this, 'facebook_pixel_init' ) );
|
317 |
-
}
|
318 |
-
}
|
319 |
-
|
320 |
-
/**
|
321 |
-
* Function for facebook pixel.
|
322 |
-
*/
|
323 |
-
function facebook_pixel_init() {
|
324 |
-
|
325 |
-
$facebook_settings = Cartflows_Helper::get_facebook_settings();
|
326 |
-
if ( 'enable' === $facebook_settings['facebook_pixel_tracking'] ) {
|
327 |
-
|
328 |
-
$facebook_id = $facebook_settings['facebook_pixel_id'];
|
329 |
-
echo '<!-- Facebook Pixel Script By CartFlows -->';
|
330 |
-
echo "<script type='text/javascript'>
|
331 |
-
!function(f,b,e,v,n,t,s)
|
332 |
-
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
333 |
-
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
|
334 |
-
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
|
335 |
-
n.queue=[];t=b.createElement(e);t.async=!0;
|
336 |
-
t.src=v;s=b.getElementsByTagName(e)[0];
|
337 |
-
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
338 |
-
'https://connect.facebook.net/en_US/fbevents.js');
|
339 |
-
</script>
|
340 |
-
<noscript><img height='1' width='1' style='display:none' src='https://www.facebook.com/tr?id=<?php echo $facebook_id; ?>&ev=PageView&noscript=1'/></noscript>";
|
341 |
-
echo '<!-- End Facebook Pixel Script By CartFlows -->';
|
342 |
-
}
|
343 |
-
|
344 |
-
}
|
345 |
-
|
346 |
-
/**
|
347 |
-
* Debug Data Setting Actions.
|
348 |
-
*
|
349 |
-
* @since 1.1.14
|
350 |
-
*/
|
351 |
-
function debug_data_setting_actions() {
|
352 |
-
|
353 |
-
add_filter( 'cartflows_load_min_assets', array( $this, 'allow_load_minify' ) );
|
354 |
-
}
|
355 |
-
|
356 |
-
/**
|
357 |
-
* Get/Set the allow minify option.
|
358 |
-
*
|
359 |
-
* @since 1.1.14
|
360 |
-
*/
|
361 |
-
function allow_load_minify() {
|
362 |
-
$debug_data = Cartflows_Helper::get_debug_settings();
|
363 |
-
$allow_minified = $debug_data['allow_minified_files'];
|
364 |
-
$allow_minify = false;
|
365 |
-
|
366 |
-
if ( 'enable' === $allow_minified ) {
|
367 |
-
$allow_minify = true;
|
368 |
-
}
|
369 |
-
|
370 |
-
return $allow_minify;
|
371 |
-
}
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Global flow scripts.
|
375 |
-
*
|
376 |
-
* @since 1.0.0
|
377 |
-
*/
|
378 |
-
function global_flow_scripts() {
|
379 |
-
|
380 |
-
global $post;
|
381 |
-
|
382 |
-
$flow = get_post_meta( $post->ID, 'wcf-flow-id', true );
|
383 |
-
$current_step = $post->ID;
|
384 |
-
$next_step_link = '';
|
385 |
-
$compatibility = Cartflows_Compatibility::get_instance();
|
386 |
-
|
387 |
-
if ( _is_wcf_landing_type() ) {
|
388 |
-
|
389 |
-
$next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step );
|
390 |
-
$next_step_link = get_permalink( $next_step_id );
|
391 |
-
}
|
392 |
-
|
393 |
-
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
394 |
-
|
395 |
-
$fb_active = get_option( '_cartflows_facebook' );
|
396 |
-
$params = array();
|
397 |
-
$is_thankyou_page = _is_wcf_thankyou_type();
|
398 |
-
|
399 |
-
if ( 'enable' === $fb_active['facebook_pixel_tracking'] ) {
|
400 |
-
|
401 |
-
$params = Cartflows_Helper::prepare_cart_data_fb_response();
|
402 |
-
}
|
403 |
-
|
404 |
-
$localize = array(
|
405 |
-
'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ),
|
406 |
-
'is_pb_preview' => $compatibility->is_page_builder_preview(),
|
407 |
-
'current_theme' => $compatibility->get_current_theme(),
|
408 |
-
'current_flow' => $flow,
|
409 |
-
'current_step' => $current_step,
|
410 |
-
'next_step' => $next_step_link,
|
411 |
-
'page_template' => $page_template,
|
412 |
-
'is_checkout_page' => _is_wcf_checkout_type(),
|
413 |
-
'is_thankyou_page' => $is_thankyou_page,
|
414 |
-
'params' => $params,
|
415 |
-
'fb_active' => $fb_active,
|
416 |
-
);
|
417 |
-
|
418 |
-
wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
|
419 |
-
|
420 |
-
if ( 'default' !== $page_template ) {
|
421 |
-
|
422 |
-
wp_enqueue_style( 'wcf-normalize-frontend-global', wcf()->utils->get_css_url( 'cartflows-normalize' ), array(), CARTFLOWS_VER );
|
423 |
-
}
|
424 |
-
|
425 |
-
wp_enqueue_style( 'wcf-frontend-global', wcf()->utils->get_css_url( 'frontend' ), array(), CARTFLOWS_VER );
|
426 |
-
|
427 |
-
wp_enqueue_script(
|
428 |
-
'wcf-frontend-global',
|
429 |
-
wcf()->utils->get_js_url( 'frontend' ),
|
430 |
-
array( 'jquery', 'jquery-cookie' ),
|
431 |
-
CARTFLOWS_VER,
|
432 |
-
false
|
433 |
-
);
|
434 |
-
}
|
435 |
-
|
436 |
-
/**
|
437 |
-
* Custom Script in head.
|
438 |
-
*
|
439 |
-
* @since 1.0.0
|
440 |
-
*/
|
441 |
-
function custom_script_option() {
|
442 |
-
|
443 |
-
/* Add custom script to header in frontend. */
|
444 |
-
$script = $this->get_custom_script();
|
445 |
-
if ( '' !== $script ) {
|
446 |
-
if ( false === strpos( $script, '<script' ) ) {
|
447 |
-
$script = '<script>' . $script . '</script>';
|
448 |
-
}
|
449 |
-
echo '<!-- Custom CartFlows Script -->';
|
450 |
-
echo $script;
|
451 |
-
echo '<!-- End Custom CartFlows Script -->';
|
452 |
-
}
|
453 |
-
}
|
454 |
-
|
455 |
-
/**
|
456 |
-
* Override woo templates.
|
457 |
-
*
|
458 |
-
* @param string $template new Template full path.
|
459 |
-
* @param string $template_name Template name.
|
460 |
-
* @param string $template_path Template Path.
|
461 |
-
* @since 1.1.5
|
462 |
-
* @return string.
|
463 |
-
*/
|
464 |
-
function override_woo_template( $template, $template_name, $template_path ) {
|
465 |
-
|
466 |
-
global $woocommerce;
|
467 |
-
|
468 |
-
$_template = $template;
|
469 |
-
|
470 |
-
$plugin_path = CARTFLOWS_DIR . 'woocommerce/template/';
|
471 |
-
|
472 |
-
if ( file_exists( $plugin_path . $template_name ) ) {
|
473 |
-
$template = $plugin_path . $template_name;
|
474 |
-
}
|
475 |
-
|
476 |
-
if ( ! $template ) {
|
477 |
-
$template = $_template;
|
478 |
-
}
|
479 |
-
|
480 |
-
return $template;
|
481 |
-
}
|
482 |
-
|
483 |
-
/**
|
484 |
-
* Remove the action applied by the Flatsome theme.
|
485 |
-
*
|
486 |
-
* @since 1.1.5
|
487 |
-
* @return void.
|
488 |
-
*/
|
489 |
-
function remove_flatsome_action() {
|
490 |
-
|
491 |
-
// Remove action where flatsome dequeued the woocommerce's default styles.
|
492 |
-
remove_action( 'wp_enqueue_scripts', 'flatsome_woocommerce_scripts_styles', 98 );
|
493 |
-
}
|
494 |
-
|
495 |
-
/**
|
496 |
-
* Add version class to body in frontend.
|
497 |
-
*
|
498 |
-
* @since 1.1.5
|
499 |
-
* @param array $classes classes.
|
500 |
-
* @return array $classes classes.
|
501 |
-
*/
|
502 |
-
function add_cartflows_lite_version_to_body( $classes ) {
|
503 |
-
|
504 |
-
$classes[] = 'cartflows-' . CARTFLOWS_VER;
|
505 |
-
|
506 |
-
return $classes;
|
507 |
-
|
508 |
-
}
|
509 |
-
|
510 |
-
/**
|
511 |
-
* Get custom script data.
|
512 |
-
*
|
513 |
-
* @since 1.0.0
|
514 |
-
*/
|
515 |
-
function get_custom_script() {
|
516 |
-
|
517 |
-
global $post;
|
518 |
-
|
519 |
-
$script = get_post_meta( $post->ID, 'wcf-custom-script', true );
|
520 |
-
|
521 |
-
return $script;
|
522 |
-
}
|
523 |
-
|
524 |
-
}
|
525 |
-
|
526 |
-
/**
|
527 |
-
* Prepare if class 'Cartflows_Frontend' exist.
|
528 |
-
* Kicking this off by calling 'get_instance()' method
|
529 |
-
*/
|
530 |
-
Cartflows_Frontend::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Frontend.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Cartflows_Frontend.
|
10 |
+
*/
|
11 |
+
class Cartflows_Frontend {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Member Variable
|
15 |
+
*
|
16 |
+
* @var instance
|
17 |
+
*/
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Initiator
|
22 |
+
*/
|
23 |
+
public static function get_instance() {
|
24 |
+
if ( ! isset( self::$instance ) ) {
|
25 |
+
self::$instance = new self();
|
26 |
+
}
|
27 |
+
return self::$instance;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Constructor
|
32 |
+
*/
|
33 |
+
public function __construct() {
|
34 |
+
|
35 |
+
/* Set / Destroy Flow Sessions. Set data */
|
36 |
+
add_action( 'wp', array( $this, 'init_actions' ), 1 );
|
37 |
+
|
38 |
+
add_action( 'init', array( $this, 'debug_data_setting_actions' ) );
|
39 |
+
/* Enqueue global required scripts */
|
40 |
+
add_action( 'wp', array( $this, 'wp_actions' ), 55 );
|
41 |
+
|
42 |
+
/* Modify the checkout order received url to go thank you page in our flow */
|
43 |
+
add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 );
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Redirect to thank page if upsell not exists
|
49 |
+
*
|
50 |
+
* @param string $order_recieve_url url.
|
51 |
+
* @param object $order order object.
|
52 |
+
* @since 1.0.0
|
53 |
+
*/
|
54 |
+
public function redirect_to_thankyou_page( $order_recieve_url, $order ) {
|
55 |
+
|
56 |
+
/* Only for thank you page */
|
57 |
+
wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ );
|
58 |
+
wcf()->logger->log( 'Only for thank you page' );
|
59 |
+
|
60 |
+
if ( wcf()->flow->is_thankyou_page_exists( $order ) ) {
|
61 |
+
|
62 |
+
if ( _is_wcf_doing_checkout_ajax() ) {
|
63 |
+
|
64 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_post_data();
|
65 |
+
|
66 |
+
if ( ! $checkout_id ) {
|
67 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
68 |
+
}
|
69 |
+
} else {
|
70 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
71 |
+
}
|
72 |
+
|
73 |
+
wcf()->logger->log( 'Checkout ID : ' . $checkout_id );
|
74 |
+
|
75 |
+
if ( $checkout_id ) {
|
76 |
+
|
77 |
+
$thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order );
|
78 |
+
|
79 |
+
if ( $thankyou_step_id ) {
|
80 |
+
|
81 |
+
$order_recieve_url = get_permalink( $thankyou_step_id );
|
82 |
+
|
83 |
+
$order_recieve_url = add_query_arg(
|
84 |
+
array(
|
85 |
+
'wcf-key' => $order->get_order_key(),
|
86 |
+
'wcf-order' => $order->get_id(),
|
87 |
+
),
|
88 |
+
$order_recieve_url
|
89 |
+
);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ );
|
95 |
+
|
96 |
+
Cartflows_Helper::send_fb_response_if_enabled( $order->get_id() );
|
97 |
+
|
98 |
+
return $order_recieve_url;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Cancel and redirect to checkout
|
103 |
+
*
|
104 |
+
* @param string $return_url url.
|
105 |
+
* @since 1.0.0
|
106 |
+
*/
|
107 |
+
public function redirect_to_checkout_on_cancel( $return_url ) {
|
108 |
+
|
109 |
+
if ( _is_wcf_doing_checkout_ajax() ) {
|
110 |
+
|
111 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_post_data();
|
112 |
+
|
113 |
+
if ( ! $checkout_id ) {
|
114 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
115 |
+
}
|
116 |
+
} else {
|
117 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
118 |
+
}
|
119 |
+
|
120 |
+
if ( $checkout_id ) {
|
121 |
+
|
122 |
+
$return_url = add_query_arg(
|
123 |
+
array(
|
124 |
+
'cancel_order' => 'true',
|
125 |
+
'_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
|
126 |
+
),
|
127 |
+
get_permalink( $checkout_id )
|
128 |
+
);
|
129 |
+
}
|
130 |
+
|
131 |
+
return $return_url;
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Remove theme styles.
|
137 |
+
*
|
138 |
+
* @since 1.0.0
|
139 |
+
*/
|
140 |
+
public function remove_theme_styles() {
|
141 |
+
|
142 |
+
if ( Cartflows_Compatibility::get_instance()->is_compatibility_theme_enabled() ) {
|
143 |
+
return;
|
144 |
+
}
|
145 |
+
|
146 |
+
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
147 |
+
|
148 |
+
$page_template = apply_filters( 'cartflows_page_template', $page_template );
|
149 |
+
|
150 |
+
if ( 'default' === $page_template ) {
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
// get all styles data.
|
155 |
+
global $wp_styles;
|
156 |
+
global $wp_scripts;
|
157 |
+
|
158 |
+
$get_stylesheet = 'themes/' . get_stylesheet() . '/';
|
159 |
+
$get_template = 'themes/' . get_template() . '/';
|
160 |
+
|
161 |
+
$remove_styles = apply_filters( 'cartflows_remove_theme_styles', true );
|
162 |
+
|
163 |
+
if ( $remove_styles ) {
|
164 |
+
|
165 |
+
// loop over all of the registered scripts..
|
166 |
+
foreach ( $wp_styles->registered as $handle => $data ) {
|
167 |
+
|
168 |
+
if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
|
169 |
+
|
170 |
+
// remove it.
|
171 |
+
wp_deregister_style( $handle );
|
172 |
+
wp_dequeue_style( $handle );
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
$remove_scripts = apply_filters( 'cartflows_remove_theme_scripts', true );
|
178 |
+
|
179 |
+
if ( $remove_scripts ) {
|
180 |
+
|
181 |
+
// loop over all of the registered scripts.
|
182 |
+
foreach ( $wp_scripts->registered as $handle => $data ) {
|
183 |
+
|
184 |
+
if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
|
185 |
+
|
186 |
+
// remove it.
|
187 |
+
wp_deregister_script( $handle );
|
188 |
+
wp_dequeue_script( $handle );
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Update main order data in transient.
|
197 |
+
*
|
198 |
+
* @param array $woo_styles new styles array.
|
199 |
+
* @since 1.0.0
|
200 |
+
* @return array.
|
201 |
+
*/
|
202 |
+
public function woo_default_css( $woo_styles ) {
|
203 |
+
|
204 |
+
$woo_styles = array(
|
205 |
+
'woocommerce-layout' => array(
|
206 |
+
'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ),
|
207 |
+
'deps' => '',
|
208 |
+
'version' => WC_VERSION,
|
209 |
+
'media' => 'all',
|
210 |
+
'has_rtl' => true,
|
211 |
+
),
|
212 |
+
'woocommerce-smallscreen' => array(
|
213 |
+
'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ),
|
214 |
+
'deps' => 'woocommerce-layout',
|
215 |
+
'version' => WC_VERSION,
|
216 |
+
'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
|
217 |
+
'has_rtl' => true,
|
218 |
+
),
|
219 |
+
'woocommerce-general' => array(
|
220 |
+
'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ),
|
221 |
+
'deps' => '',
|
222 |
+
'version' => WC_VERSION,
|
223 |
+
'media' => 'all',
|
224 |
+
'has_rtl' => true,
|
225 |
+
),
|
226 |
+
);
|
227 |
+
|
228 |
+
return $woo_styles;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Init Actions.
|
233 |
+
*
|
234 |
+
* @since 1.0.0
|
235 |
+
*/
|
236 |
+
public function init_actions() {
|
237 |
+
|
238 |
+
$this->set_flow_session();
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Set flow session.
|
243 |
+
*
|
244 |
+
* @since 1.0.0
|
245 |
+
*/
|
246 |
+
public function set_flow_session() {
|
247 |
+
|
248 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
249 |
+
|
250 |
+
add_action( 'wp_head', array( $this, 'noindex_flow' ) );
|
251 |
+
|
252 |
+
wcf()->utils->do_not_cache();
|
253 |
+
|
254 |
+
/* Set key to support pixel */
|
255 |
+
if ( isset( $_GET['wcf-key'] ) ) {
|
256 |
+
$_GET['key'] = wp_unslash( $_GET['wcf-key'] );
|
257 |
+
$_REQUEST['key'] = wp_unslash( $_GET['wcf-key'] );
|
258 |
+
}
|
259 |
+
|
260 |
+
if ( isset( $_GET['wcf-order'] ) ) {
|
261 |
+
$_GET['order'] = wp_unslash( $_GET['wcf-order'] );
|
262 |
+
$_REQUEST['order'] = wp_unslash( $_GET['wcf-order'] );
|
263 |
+
$_GET['order-received'] = wp_unslash( $_GET['wcf-order'] );
|
264 |
+
$_REQUEST['order-received'] = wp_unslash( $_GET['wcf-order'] );
|
265 |
+
}
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Add noindex, nofollow.
|
271 |
+
*
|
272 |
+
* @since 1.0.0
|
273 |
+
*/
|
274 |
+
public function noindex_flow() {
|
275 |
+
|
276 |
+
$common = Cartflows_Helper::get_common_settings();
|
277 |
+
|
278 |
+
if ( 'enable' === $common['disallow_indexing'] ) {
|
279 |
+
echo '<meta name="robots" content="noindex,nofollow">';
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* WP Actions.
|
285 |
+
*
|
286 |
+
* @since 1.0.0
|
287 |
+
*/
|
288 |
+
public function wp_actions() {
|
289 |
+
|
290 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
291 |
+
|
292 |
+
if ( ! wcf()->is_woo_active && wcf()->utils->check_is_woo_required_page() ) {
|
293 |
+
wp_die( ' This page requires WooCommerce plugin installed and activated!', 'WooCommerce Required' );
|
294 |
+
}
|
295 |
+
|
296 |
+
/* CSS Compatibility for All theme */
|
297 |
+
add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 );
|
298 |
+
|
299 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 );
|
300 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 );
|
301 |
+
|
302 |
+
/* Load woo templates from plugin */
|
303 |
+
add_filter( 'woocommerce_locate_template', array( $this, 'override_woo_template' ), 20, 3 );
|
304 |
+
|
305 |
+
/* Add version class to body in frontend. */
|
306 |
+
add_filter( 'body_class', array( $this, 'add_cartflows_lite_version_to_body' ) );
|
307 |
+
|
308 |
+
/* Custom Script Option */
|
309 |
+
add_action( 'wp_head', array( $this, 'custom_script_option' ) );
|
310 |
+
|
311 |
+
/* Remove the action applied by the Flatsome theme */
|
312 |
+
if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
|
313 |
+
$this->remove_flatsome_action();
|
314 |
+
}
|
315 |
+
|
316 |
+
add_action( 'wp_head', array( $this, 'facebook_pixel_init' ) );
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Function for facebook pixel.
|
322 |
+
*/
|
323 |
+
public function facebook_pixel_init() {
|
324 |
+
|
325 |
+
$facebook_settings = Cartflows_Helper::get_facebook_settings();
|
326 |
+
if ( 'enable' === $facebook_settings['facebook_pixel_tracking'] ) {
|
327 |
+
|
328 |
+
$facebook_id = $facebook_settings['facebook_pixel_id'];
|
329 |
+
echo '<!-- Facebook Pixel Script By CartFlows -->';
|
330 |
+
echo "<script type='text/javascript'>
|
331 |
+
!function(f,b,e,v,n,t,s)
|
332 |
+
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
333 |
+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
|
334 |
+
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
|
335 |
+
n.queue=[];t=b.createElement(e);t.async=!0;
|
336 |
+
t.src=v;s=b.getElementsByTagName(e)[0];
|
337 |
+
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
338 |
+
'https://connect.facebook.net/en_US/fbevents.js');
|
339 |
+
</script>
|
340 |
+
<noscript><img height='1' width='1' style='display:none' src='https://www.facebook.com/tr?id=<?php echo $facebook_id; ?>&ev=PageView&noscript=1'/></noscript>";
|
341 |
+
echo '<!-- End Facebook Pixel Script By CartFlows -->';
|
342 |
+
}
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
* Debug Data Setting Actions.
|
348 |
+
*
|
349 |
+
* @since 1.1.14
|
350 |
+
*/
|
351 |
+
public function debug_data_setting_actions() {
|
352 |
+
|
353 |
+
add_filter( 'cartflows_load_min_assets', array( $this, 'allow_load_minify' ) );
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Get/Set the allow minify option.
|
358 |
+
*
|
359 |
+
* @since 1.1.14
|
360 |
+
*/
|
361 |
+
public function allow_load_minify() {
|
362 |
+
$debug_data = Cartflows_Helper::get_debug_settings();
|
363 |
+
$allow_minified = $debug_data['allow_minified_files'];
|
364 |
+
$allow_minify = false;
|
365 |
+
|
366 |
+
if ( 'enable' === $allow_minified ) {
|
367 |
+
$allow_minify = true;
|
368 |
+
}
|
369 |
+
|
370 |
+
return $allow_minify;
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Global flow scripts.
|
375 |
+
*
|
376 |
+
* @since 1.0.0
|
377 |
+
*/
|
378 |
+
public function global_flow_scripts() {
|
379 |
+
|
380 |
+
global $post;
|
381 |
+
|
382 |
+
$flow = get_post_meta( $post->ID, 'wcf-flow-id', true );
|
383 |
+
$current_step = $post->ID;
|
384 |
+
$next_step_link = '';
|
385 |
+
$compatibility = Cartflows_Compatibility::get_instance();
|
386 |
+
|
387 |
+
if ( _is_wcf_landing_type() ) {
|
388 |
+
|
389 |
+
$next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step );
|
390 |
+
$next_step_link = get_permalink( $next_step_id );
|
391 |
+
}
|
392 |
+
|
393 |
+
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
394 |
+
|
395 |
+
$fb_active = get_option( '_cartflows_facebook' );
|
396 |
+
$params = array();
|
397 |
+
$is_thankyou_page = _is_wcf_thankyou_type();
|
398 |
+
|
399 |
+
if ( 'enable' === $fb_active['facebook_pixel_tracking'] ) {
|
400 |
+
|
401 |
+
$params = Cartflows_Helper::prepare_cart_data_fb_response();
|
402 |
+
}
|
403 |
+
|
404 |
+
$localize = array(
|
405 |
+
'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ),
|
406 |
+
'is_pb_preview' => $compatibility->is_page_builder_preview(),
|
407 |
+
'current_theme' => $compatibility->get_current_theme(),
|
408 |
+
'current_flow' => $flow,
|
409 |
+
'current_step' => $current_step,
|
410 |
+
'next_step' => $next_step_link,
|
411 |
+
'page_template' => $page_template,
|
412 |
+
'is_checkout_page' => _is_wcf_checkout_type(),
|
413 |
+
'is_thankyou_page' => $is_thankyou_page,
|
414 |
+
'params' => $params,
|
415 |
+
'fb_active' => $fb_active,
|
416 |
+
);
|
417 |
+
|
418 |
+
wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
|
419 |
+
|
420 |
+
if ( 'default' !== $page_template ) {
|
421 |
+
|
422 |
+
wp_enqueue_style( 'wcf-normalize-frontend-global', wcf()->utils->get_css_url( 'cartflows-normalize' ), array(), CARTFLOWS_VER );
|
423 |
+
}
|
424 |
+
|
425 |
+
wp_enqueue_style( 'wcf-frontend-global', wcf()->utils->get_css_url( 'frontend' ), array(), CARTFLOWS_VER );
|
426 |
+
|
427 |
+
wp_enqueue_script(
|
428 |
+
'wcf-frontend-global',
|
429 |
+
wcf()->utils->get_js_url( 'frontend' ),
|
430 |
+
array( 'jquery', 'jquery-cookie' ),
|
431 |
+
CARTFLOWS_VER,
|
432 |
+
false
|
433 |
+
);
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Custom Script in head.
|
438 |
+
*
|
439 |
+
* @since 1.0.0
|
440 |
+
*/
|
441 |
+
public function custom_script_option() {
|
442 |
+
|
443 |
+
/* Add custom script to header in frontend. */
|
444 |
+
$script = $this->get_custom_script();
|
445 |
+
if ( '' !== $script ) {
|
446 |
+
if ( false === strpos( $script, '<script' ) ) {
|
447 |
+
$script = '<script>' . $script . '</script>';
|
448 |
+
}
|
449 |
+
echo '<!-- Custom CartFlows Script -->';
|
450 |
+
echo $script;
|
451 |
+
echo '<!-- End Custom CartFlows Script -->';
|
452 |
+
}
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Override woo templates.
|
457 |
+
*
|
458 |
+
* @param string $template new Template full path.
|
459 |
+
* @param string $template_name Template name.
|
460 |
+
* @param string $template_path Template Path.
|
461 |
+
* @since 1.1.5
|
462 |
+
* @return string.
|
463 |
+
*/
|
464 |
+
public function override_woo_template( $template, $template_name, $template_path ) {
|
465 |
+
|
466 |
+
global $woocommerce;
|
467 |
+
|
468 |
+
$_template = $template;
|
469 |
+
|
470 |
+
$plugin_path = CARTFLOWS_DIR . 'woocommerce/template/';
|
471 |
+
|
472 |
+
if ( file_exists( $plugin_path . $template_name ) ) {
|
473 |
+
$template = $plugin_path . $template_name;
|
474 |
+
}
|
475 |
+
|
476 |
+
if ( ! $template ) {
|
477 |
+
$template = $_template;
|
478 |
+
}
|
479 |
+
|
480 |
+
return $template;
|
481 |
+
}
|
482 |
+
|
483 |
+
/**
|
484 |
+
* Remove the action applied by the Flatsome theme.
|
485 |
+
*
|
486 |
+
* @since 1.1.5
|
487 |
+
* @return void.
|
488 |
+
*/
|
489 |
+
public function remove_flatsome_action() {
|
490 |
+
|
491 |
+
// Remove action where flatsome dequeued the woocommerce's default styles.
|
492 |
+
remove_action( 'wp_enqueue_scripts', 'flatsome_woocommerce_scripts_styles', 98 );
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Add version class to body in frontend.
|
497 |
+
*
|
498 |
+
* @since 1.1.5
|
499 |
+
* @param array $classes classes.
|
500 |
+
* @return array $classes classes.
|
501 |
+
*/
|
502 |
+
public function add_cartflows_lite_version_to_body( $classes ) {
|
503 |
+
|
504 |
+
$classes[] = 'cartflows-' . CARTFLOWS_VER;
|
505 |
+
|
506 |
+
return $classes;
|
507 |
+
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* Get custom script data.
|
512 |
+
*
|
513 |
+
* @since 1.0.0
|
514 |
+
*/
|
515 |
+
public function get_custom_script() {
|
516 |
+
|
517 |
+
global $post;
|
518 |
+
|
519 |
+
$script = get_post_meta( $post->ID, 'wcf-custom-script', true );
|
520 |
+
|
521 |
+
return $script;
|
522 |
+
}
|
523 |
+
|
524 |
+
}
|
525 |
+
|
526 |
+
/**
|
527 |
+
* Prepare if class 'Cartflows_Frontend' exist.
|
528 |
+
* Kicking this off by calling 'get_instance()' method
|
529 |
+
*/
|
530 |
+
Cartflows_Frontend::get_instance();
|
classes/class-cartflows-functions.php
CHANGED
@@ -1,447 +1,447 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Functions.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit; // Exit if accessed directly.
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Fatal error mb_strpos fallback.
|
14 |
-
*
|
15 |
-
* @param string $string string where to find.
|
16 |
-
* @param string $search string to search.
|
17 |
-
* @since 1.0.0
|
18 |
-
*/
|
19 |
-
function wcf_mb_strpos( $string, $search ) {
|
20 |
-
|
21 |
-
if ( function_exists( 'mb_strpos' ) ) {
|
22 |
-
return mb_strpos( $string, $search );
|
23 |
-
} else {
|
24 |
-
return strpos( $string, $search );
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Check if cartflows pro activated.
|
30 |
-
*
|
31 |
-
* @since 1.0.0
|
32 |
-
*/
|
33 |
-
function _is_cartflows_pro() {
|
34 |
-
|
35 |
-
if ( defined( 'CARTFLOWS_PRO_FILE' ) ) {
|
36 |
-
return true;
|
37 |
-
}
|
38 |
-
|
39 |
-
return false;
|
40 |
-
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Returns pro version number.
|
45 |
-
*
|
46 |
-
* @param int $version version number.
|
47 |
-
* @since 1.0.0
|
48 |
-
*/
|
49 |
-
function _is_cartflows_pro_ver_less_than( $version ) {
|
50 |
-
|
51 |
-
if ( defined( 'CARTFLOWS_PRO_VER' ) && version_compare( CARTFLOWS_PRO_VER, $version, '<' ) ) {
|
52 |
-
return true;
|
53 |
-
}
|
54 |
-
|
55 |
-
return false;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Returns step id.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
*/
|
63 |
-
function _get_wcf_post_id() {
|
64 |
-
|
65 |
-
global $post;
|
66 |
-
|
67 |
-
if ( isset( $post->ID ) ) {
|
68 |
-
return $post->ID;
|
69 |
-
}
|
70 |
-
|
71 |
-
return 0;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Returns step id.
|
76 |
-
*
|
77 |
-
* @since 1.0.0
|
78 |
-
*/
|
79 |
-
function _get_wcf_step_id() {
|
80 |
-
|
81 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
82 |
-
|
83 |
-
global $post;
|
84 |
-
|
85 |
-
return $post->ID;
|
86 |
-
}
|
87 |
-
|
88 |
-
return false;
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Check if it is a landing page?
|
93 |
-
*
|
94 |
-
* @since 1.0.0
|
95 |
-
*/
|
96 |
-
function _is_wcf_landing_type() {
|
97 |
-
|
98 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
99 |
-
|
100 |
-
global $post;
|
101 |
-
|
102 |
-
if ( 'landing' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
103 |
-
|
104 |
-
return true;
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
return false;
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Returns landing id.
|
113 |
-
*
|
114 |
-
* @since 1.0.0
|
115 |
-
*/
|
116 |
-
function _get_wcf_landing_id() {
|
117 |
-
|
118 |
-
if ( _is_wcf_landing_type() ) {
|
119 |
-
|
120 |
-
global $post;
|
121 |
-
|
122 |
-
return $post->ID;
|
123 |
-
}
|
124 |
-
|
125 |
-
return false;
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Is custom checkout?
|
130 |
-
*
|
131 |
-
* @param int $checkout_id checkout ID.
|
132 |
-
* @since 1.0.0
|
133 |
-
*/
|
134 |
-
function _is_wcf_meta_custom_checkout( $checkout_id ) {
|
135 |
-
|
136 |
-
$is_custom = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-custom-checkout-fields' );
|
137 |
-
|
138 |
-
if ( 'yes' === $is_custom ) {
|
139 |
-
|
140 |
-
return true;
|
141 |
-
}
|
142 |
-
|
143 |
-
return false;
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Check if page is cartflow checkout.
|
148 |
-
*
|
149 |
-
* @since 1.0.0
|
150 |
-
* @return bool
|
151 |
-
*/
|
152 |
-
function _is_wcf_checkout_type() {
|
153 |
-
|
154 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
155 |
-
|
156 |
-
global $post;
|
157 |
-
|
158 |
-
if ( 'checkout' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
159 |
-
|
160 |
-
return true;
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
return false;
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Check if AJAX call is in progress.
|
169 |
-
*
|
170 |
-
* @since 1.0.0
|
171 |
-
* @return bool
|
172 |
-
*/
|
173 |
-
function _is_wcf_doing_checkout_ajax() {
|
174 |
-
|
175 |
-
if ( wp_doing_ajax() ) {
|
176 |
-
|
177 |
-
if ( isset( $_GET['wc-ajax'] ) &&
|
178 |
-
'checkout' === $_GET['wc-ajax'] &&
|
179 |
-
isset( $_POST['_wcf_checkout_id'] )
|
180 |
-
) {
|
181 |
-
return true;
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
-
return false;
|
186 |
-
}
|
187 |
-
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Returns checkout ID.
|
191 |
-
*
|
192 |
-
* @since 1.0.0
|
193 |
-
* @return int/bool
|
194 |
-
*/
|
195 |
-
function _get_wcf_checkout_id() {
|
196 |
-
|
197 |
-
if ( _is_wcf_checkout_type() ) {
|
198 |
-
|
199 |
-
global $post;
|
200 |
-
|
201 |
-
return $post->ID;
|
202 |
-
}
|
203 |
-
|
204 |
-
return false;
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Check if it is checkout shortcode.
|
209 |
-
*
|
210 |
-
* @since 1.0.0
|
211 |
-
* @return bool
|
212 |
-
*/
|
213 |
-
function _is_wcf_checkout_shortcode() {
|
214 |
-
|
215 |
-
global $post;
|
216 |
-
|
217 |
-
if ( ! empty( $post ) && has_shortcode( $post->post_content, 'cartflows_checkout' ) ) {
|
218 |
-
|
219 |
-
return true;
|
220 |
-
}
|
221 |
-
|
222 |
-
return false;
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Check if it is checkout shortcode.
|
227 |
-
*
|
228 |
-
* @since 1.0.0
|
229 |
-
* @param string $content shortcode content.
|
230 |
-
* @return bool
|
231 |
-
*/
|
232 |
-
function _get_wcf_checkout_id_from_shortcode( $content = '' ) {
|
233 |
-
|
234 |
-
$checkout_id = 0;
|
235 |
-
|
236 |
-
if ( ! empty( $content ) ) {
|
237 |
-
|
238 |
-
$regex_pattern = get_shortcode_regex( array( 'cartflows_checkout' ) );
|
239 |
-
|
240 |
-
preg_match( '/' . $regex_pattern . '/s', $content, $regex_matches );
|
241 |
-
|
242 |
-
if ( ! empty( $regex_matches ) ) {
|
243 |
-
|
244 |
-
if ( 'cartflows_checkout' == $regex_matches[2] ) {
|
245 |
-
|
246 |
-
$attribure_str = str_replace( ' ', '&', trim( $regex_matches[3] ) );
|
247 |
-
$attribure_str = str_replace( '"', '', $attribure_str );
|
248 |
-
|
249 |
-
$attributes = wp_parse_args( $attribure_str );
|
250 |
-
|
251 |
-
if ( isset( $attributes['id'] ) ) {
|
252 |
-
$checkout_id = $attributes['id'];
|
253 |
-
}
|
254 |
-
}
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
return $checkout_id;
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* Check if post type is upsell.
|
263 |
-
*
|
264 |
-
* @since 1.0.0
|
265 |
-
* @return bool
|
266 |
-
*/
|
267 |
-
function _is_wcf_upsell_type() {
|
268 |
-
|
269 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
270 |
-
|
271 |
-
global $post;
|
272 |
-
|
273 |
-
if ( 'upsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
274 |
-
|
275 |
-
return true;
|
276 |
-
}
|
277 |
-
}
|
278 |
-
|
279 |
-
return false;
|
280 |
-
}
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Returns upsell ID.
|
284 |
-
*
|
285 |
-
* @since 1.0.0
|
286 |
-
* @return int/bool
|
287 |
-
*/
|
288 |
-
function _get_wcf_upsell_id() {
|
289 |
-
|
290 |
-
if ( _is_wcf_upsell_type() ) {
|
291 |
-
|
292 |
-
global $post;
|
293 |
-
|
294 |
-
return $post->ID;
|
295 |
-
}
|
296 |
-
|
297 |
-
return false;
|
298 |
-
}
|
299 |
-
|
300 |
-
/**
|
301 |
-
* Check if post is of type downsell.
|
302 |
-
*
|
303 |
-
* @since 1.0.0
|
304 |
-
* @return int/bool
|
305 |
-
*/
|
306 |
-
function _is_wcf_downsell_type() {
|
307 |
-
|
308 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
309 |
-
|
310 |
-
global $post;
|
311 |
-
|
312 |
-
if ( 'downsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
313 |
-
|
314 |
-
return true;
|
315 |
-
}
|
316 |
-
}
|
317 |
-
|
318 |
-
return false;
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Get downsell page ID.
|
323 |
-
*
|
324 |
-
* @since 1.0.0
|
325 |
-
* @return int/bool
|
326 |
-
*/
|
327 |
-
function _get_wcf_downsell_id() {
|
328 |
-
|
329 |
-
if ( _is_wcf_downsell_type() ) {
|
330 |
-
|
331 |
-
global $post;
|
332 |
-
|
333 |
-
return $post->ID;
|
334 |
-
}
|
335 |
-
|
336 |
-
return false;
|
337 |
-
}
|
338 |
-
|
339 |
-
/**
|
340 |
-
* Check if page is of thank you type.
|
341 |
-
*
|
342 |
-
* @since 1.0.0
|
343 |
-
* @return int/bool
|
344 |
-
*/
|
345 |
-
function _is_wcf_thankyou_type() {
|
346 |
-
|
347 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
348 |
-
|
349 |
-
global $post;
|
350 |
-
|
351 |
-
if ( 'thankyou' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
352 |
-
|
353 |
-
return true;
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
return false;
|
358 |
-
}
|
359 |
-
|
360 |
-
/**
|
361 |
-
* Get thank you page ID.
|
362 |
-
*
|
363 |
-
* @since 1.0.0
|
364 |
-
* @return int/bool
|
365 |
-
*/
|
366 |
-
function _get_wcf_thankyou_id() {
|
367 |
-
|
368 |
-
if ( _is_wcf_thankyou_type() ) {
|
369 |
-
|
370 |
-
global $post;
|
371 |
-
|
372 |
-
return $post->ID;
|
373 |
-
}
|
374 |
-
|
375 |
-
return false;
|
376 |
-
}
|
377 |
-
|
378 |
-
|
379 |
-
/**
|
380 |
-
* Check if post type is upsell.
|
381 |
-
*
|
382 |
-
* @since 1.0.0
|
383 |
-
* @return bool
|
384 |
-
*/
|
385 |
-
function _is_wcf_base_offer_type() {
|
386 |
-
|
387 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
388 |
-
|
389 |
-
global $post;
|
390 |
-
|
391 |
-
$step_type = get_post_meta( $post->ID, 'wcf-step-type', true );
|
392 |
-
|
393 |
-
if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
|
394 |
-
|
395 |
-
return true;
|
396 |
-
}
|
397 |
-
}
|
398 |
-
|
399 |
-
return false;
|
400 |
-
}
|
401 |
-
|
402 |
-
/**
|
403 |
-
* Returns upsell ID.
|
404 |
-
*
|
405 |
-
* @since 1.0.0
|
406 |
-
* @return int/bool
|
407 |
-
*/
|
408 |
-
function _get_wcf_base_offer_id() {
|
409 |
-
|
410 |
-
if ( _is_wcf_base_offer_type() ) {
|
411 |
-
|
412 |
-
global $post;
|
413 |
-
|
414 |
-
return $post->ID;
|
415 |
-
}
|
416 |
-
|
417 |
-
return false;
|
418 |
-
}
|
419 |
-
|
420 |
-
|
421 |
-
/**
|
422 |
-
* Define a constant if it is not already defined.
|
423 |
-
*
|
424 |
-
* @since 3.0.0
|
425 |
-
* @param string $name Constant name.
|
426 |
-
* @param mixed $value Value.
|
427 |
-
*/
|
428 |
-
function wcf_maybe_define_constant( $name, $value ) {
|
429 |
-
if ( ! defined( $name ) ) {
|
430 |
-
define( $name, $value );
|
431 |
-
}
|
432 |
-
}
|
433 |
-
|
434 |
-
|
435 |
-
if ( ! function_exists( 'wp_body_open' ) ) {
|
436 |
-
/**
|
437 |
-
* Fire the wp_body_open action.
|
438 |
-
*
|
439 |
-
* Added for backwards compatibility to support WordPress versions prior to 5.2.0.
|
440 |
-
*/
|
441 |
-
function wp_body_open() {
|
442 |
-
/**
|
443 |
-
* Triggered after the opening <body> tag.
|
444 |
-
*/
|
445 |
-
do_action( 'wp_body_open' );
|
446 |
-
}
|
447 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Functions.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Fatal error mb_strpos fallback.
|
14 |
+
*
|
15 |
+
* @param string $string string where to find.
|
16 |
+
* @param string $search string to search.
|
17 |
+
* @since 1.0.0
|
18 |
+
*/
|
19 |
+
function wcf_mb_strpos( $string, $search ) {
|
20 |
+
|
21 |
+
if ( function_exists( 'mb_strpos' ) ) {
|
22 |
+
return mb_strpos( $string, $search, 0, 'utf-8' );
|
23 |
+
} else {
|
24 |
+
return strpos( $string, $search );
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Check if cartflows pro activated.
|
30 |
+
*
|
31 |
+
* @since 1.0.0
|
32 |
+
*/
|
33 |
+
function _is_cartflows_pro() {
|
34 |
+
|
35 |
+
if ( defined( 'CARTFLOWS_PRO_FILE' ) ) {
|
36 |
+
return true;
|
37 |
+
}
|
38 |
+
|
39 |
+
return false;
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns pro version number.
|
45 |
+
*
|
46 |
+
* @param int $version version number.
|
47 |
+
* @since 1.0.0
|
48 |
+
*/
|
49 |
+
function _is_cartflows_pro_ver_less_than( $version ) {
|
50 |
+
|
51 |
+
if ( defined( 'CARTFLOWS_PRO_VER' ) && version_compare( CARTFLOWS_PRO_VER, $version, '<' ) ) {
|
52 |
+
return true;
|
53 |
+
}
|
54 |
+
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Returns step id.
|
60 |
+
*
|
61 |
+
* @since 1.0.0
|
62 |
+
*/
|
63 |
+
function _get_wcf_post_id() {
|
64 |
+
|
65 |
+
global $post;
|
66 |
+
|
67 |
+
if ( isset( $post->ID ) ) {
|
68 |
+
return $post->ID;
|
69 |
+
}
|
70 |
+
|
71 |
+
return 0;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Returns step id.
|
76 |
+
*
|
77 |
+
* @since 1.0.0
|
78 |
+
*/
|
79 |
+
function _get_wcf_step_id() {
|
80 |
+
|
81 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
82 |
+
|
83 |
+
global $post;
|
84 |
+
|
85 |
+
return $post->ID;
|
86 |
+
}
|
87 |
+
|
88 |
+
return false;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Check if it is a landing page?
|
93 |
+
*
|
94 |
+
* @since 1.0.0
|
95 |
+
*/
|
96 |
+
function _is_wcf_landing_type() {
|
97 |
+
|
98 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
99 |
+
|
100 |
+
global $post;
|
101 |
+
|
102 |
+
if ( 'landing' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
103 |
+
|
104 |
+
return true;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
return false;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Returns landing id.
|
113 |
+
*
|
114 |
+
* @since 1.0.0
|
115 |
+
*/
|
116 |
+
function _get_wcf_landing_id() {
|
117 |
+
|
118 |
+
if ( _is_wcf_landing_type() ) {
|
119 |
+
|
120 |
+
global $post;
|
121 |
+
|
122 |
+
return $post->ID;
|
123 |
+
}
|
124 |
+
|
125 |
+
return false;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Is custom checkout?
|
130 |
+
*
|
131 |
+
* @param int $checkout_id checkout ID.
|
132 |
+
* @since 1.0.0
|
133 |
+
*/
|
134 |
+
function _is_wcf_meta_custom_checkout( $checkout_id ) {
|
135 |
+
|
136 |
+
$is_custom = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-custom-checkout-fields' );
|
137 |
+
|
138 |
+
if ( 'yes' === $is_custom ) {
|
139 |
+
|
140 |
+
return true;
|
141 |
+
}
|
142 |
+
|
143 |
+
return false;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Check if page is cartflow checkout.
|
148 |
+
*
|
149 |
+
* @since 1.0.0
|
150 |
+
* @return bool
|
151 |
+
*/
|
152 |
+
function _is_wcf_checkout_type() {
|
153 |
+
|
154 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
155 |
+
|
156 |
+
global $post;
|
157 |
+
|
158 |
+
if ( 'checkout' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
159 |
+
|
160 |
+
return true;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
return false;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Check if AJAX call is in progress.
|
169 |
+
*
|
170 |
+
* @since 1.0.0
|
171 |
+
* @return bool
|
172 |
+
*/
|
173 |
+
function _is_wcf_doing_checkout_ajax() {
|
174 |
+
|
175 |
+
if ( wp_doing_ajax() ) {
|
176 |
+
|
177 |
+
if ( isset( $_GET['wc-ajax'] ) &&
|
178 |
+
'checkout' === $_GET['wc-ajax'] &&
|
179 |
+
isset( $_POST['_wcf_checkout_id'] )
|
180 |
+
) {
|
181 |
+
return true;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
return false;
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Returns checkout ID.
|
191 |
+
*
|
192 |
+
* @since 1.0.0
|
193 |
+
* @return int/bool
|
194 |
+
*/
|
195 |
+
function _get_wcf_checkout_id() {
|
196 |
+
|
197 |
+
if ( _is_wcf_checkout_type() ) {
|
198 |
+
|
199 |
+
global $post;
|
200 |
+
|
201 |
+
return $post->ID;
|
202 |
+
}
|
203 |
+
|
204 |
+
return false;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Check if it is checkout shortcode.
|
209 |
+
*
|
210 |
+
* @since 1.0.0
|
211 |
+
* @return bool
|
212 |
+
*/
|
213 |
+
function _is_wcf_checkout_shortcode() {
|
214 |
+
|
215 |
+
global $post;
|
216 |
+
|
217 |
+
if ( ! empty( $post ) && has_shortcode( $post->post_content, 'cartflows_checkout' ) ) {
|
218 |
+
|
219 |
+
return true;
|
220 |
+
}
|
221 |
+
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Check if it is checkout shortcode.
|
227 |
+
*
|
228 |
+
* @since 1.0.0
|
229 |
+
* @param string $content shortcode content.
|
230 |
+
* @return bool
|
231 |
+
*/
|
232 |
+
function _get_wcf_checkout_id_from_shortcode( $content = '' ) {
|
233 |
+
|
234 |
+
$checkout_id = 0;
|
235 |
+
|
236 |
+
if ( ! empty( $content ) ) {
|
237 |
+
|
238 |
+
$regex_pattern = get_shortcode_regex( array( 'cartflows_checkout' ) );
|
239 |
+
|
240 |
+
preg_match( '/' . $regex_pattern . '/s', $content, $regex_matches );
|
241 |
+
|
242 |
+
if ( ! empty( $regex_matches ) ) {
|
243 |
+
|
244 |
+
if ( 'cartflows_checkout' == $regex_matches[2] ) {
|
245 |
+
|
246 |
+
$attribure_str = str_replace( ' ', '&', trim( $regex_matches[3] ) );
|
247 |
+
$attribure_str = str_replace( '"', '', $attribure_str );
|
248 |
+
|
249 |
+
$attributes = wp_parse_args( $attribure_str );
|
250 |
+
|
251 |
+
if ( isset( $attributes['id'] ) ) {
|
252 |
+
$checkout_id = $attributes['id'];
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
return $checkout_id;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Check if post type is upsell.
|
263 |
+
*
|
264 |
+
* @since 1.0.0
|
265 |
+
* @return bool
|
266 |
+
*/
|
267 |
+
function _is_wcf_upsell_type() {
|
268 |
+
|
269 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
270 |
+
|
271 |
+
global $post;
|
272 |
+
|
273 |
+
if ( 'upsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
274 |
+
|
275 |
+
return true;
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
return false;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Returns upsell ID.
|
284 |
+
*
|
285 |
+
* @since 1.0.0
|
286 |
+
* @return int/bool
|
287 |
+
*/
|
288 |
+
function _get_wcf_upsell_id() {
|
289 |
+
|
290 |
+
if ( _is_wcf_upsell_type() ) {
|
291 |
+
|
292 |
+
global $post;
|
293 |
+
|
294 |
+
return $post->ID;
|
295 |
+
}
|
296 |
+
|
297 |
+
return false;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Check if post is of type downsell.
|
302 |
+
*
|
303 |
+
* @since 1.0.0
|
304 |
+
* @return int/bool
|
305 |
+
*/
|
306 |
+
function _is_wcf_downsell_type() {
|
307 |
+
|
308 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
309 |
+
|
310 |
+
global $post;
|
311 |
+
|
312 |
+
if ( 'downsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
313 |
+
|
314 |
+
return true;
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
return false;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Get downsell page ID.
|
323 |
+
*
|
324 |
+
* @since 1.0.0
|
325 |
+
* @return int/bool
|
326 |
+
*/
|
327 |
+
function _get_wcf_downsell_id() {
|
328 |
+
|
329 |
+
if ( _is_wcf_downsell_type() ) {
|
330 |
+
|
331 |
+
global $post;
|
332 |
+
|
333 |
+
return $post->ID;
|
334 |
+
}
|
335 |
+
|
336 |
+
return false;
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Check if page is of thank you type.
|
341 |
+
*
|
342 |
+
* @since 1.0.0
|
343 |
+
* @return int/bool
|
344 |
+
*/
|
345 |
+
function _is_wcf_thankyou_type() {
|
346 |
+
|
347 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
348 |
+
|
349 |
+
global $post;
|
350 |
+
|
351 |
+
if ( 'thankyou' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
352 |
+
|
353 |
+
return true;
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Get thank you page ID.
|
362 |
+
*
|
363 |
+
* @since 1.0.0
|
364 |
+
* @return int/bool
|
365 |
+
*/
|
366 |
+
function _get_wcf_thankyou_id() {
|
367 |
+
|
368 |
+
if ( _is_wcf_thankyou_type() ) {
|
369 |
+
|
370 |
+
global $post;
|
371 |
+
|
372 |
+
return $post->ID;
|
373 |
+
}
|
374 |
+
|
375 |
+
return false;
|
376 |
+
}
|
377 |
+
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Check if post type is upsell.
|
381 |
+
*
|
382 |
+
* @since 1.0.0
|
383 |
+
* @return bool
|
384 |
+
*/
|
385 |
+
function _is_wcf_base_offer_type() {
|
386 |
+
|
387 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
388 |
+
|
389 |
+
global $post;
|
390 |
+
|
391 |
+
$step_type = get_post_meta( $post->ID, 'wcf-step-type', true );
|
392 |
+
|
393 |
+
if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
|
394 |
+
|
395 |
+
return true;
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
return false;
|
400 |
+
}
|
401 |
+
|
402 |
+
/**
|
403 |
+
* Returns upsell ID.
|
404 |
+
*
|
405 |
+
* @since 1.0.0
|
406 |
+
* @return int/bool
|
407 |
+
*/
|
408 |
+
function _get_wcf_base_offer_id() {
|
409 |
+
|
410 |
+
if ( _is_wcf_base_offer_type() ) {
|
411 |
+
|
412 |
+
global $post;
|
413 |
+
|
414 |
+
return $post->ID;
|
415 |
+
}
|
416 |
+
|
417 |
+
return false;
|
418 |
+
}
|
419 |
+
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Define a constant if it is not already defined.
|
423 |
+
*
|
424 |
+
* @since 3.0.0
|
425 |
+
* @param string $name Constant name.
|
426 |
+
* @param mixed $value Value.
|
427 |
+
*/
|
428 |
+
function wcf_maybe_define_constant( $name, $value ) {
|
429 |
+
if ( ! defined( $name ) ) {
|
430 |
+
define( $name, $value );
|
431 |
+
}
|
432 |
+
}
|
433 |
+
|
434 |
+
|
435 |
+
if ( ! function_exists( 'wp_body_open' ) ) {
|
436 |
+
/**
|
437 |
+
* Fire the wp_body_open action.
|
438 |
+
*
|
439 |
+
* Added for backwards compatibility to support WordPress versions prior to 5.2.0.
|
440 |
+
*/
|
441 |
+
function wp_body_open() {
|
442 |
+
/**
|
443 |
+
* Triggered after the opening <body> tag.
|
444 |
+
*/
|
445 |
+
do_action( 'wp_body_open' );
|
446 |
+
}
|
447 |
+
}
|
classes/class-cartflows-helper.php
CHANGED
@@ -1,694 +1,694 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CARTFLOWS Helper.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit; // Exit if accessed directly.
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Cartflows_Helper.
|
14 |
-
*/
|
15 |
-
class Cartflows_Helper {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Common global data
|
19 |
-
*
|
20 |
-
* @var zapier
|
21 |
-
*/
|
22 |
-
private static $common = null;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Common Debug data
|
26 |
-
*
|
27 |
-
* @var zapier
|
28 |
-
*/
|
29 |
-
private static $debug_data = null;
|
30 |
-
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Permalink settings
|
34 |
-
*
|
35 |
-
* @var permalink_setting
|
36 |
-
*/
|
37 |
-
private static $permalink_setting = null;
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Installed Plugins
|
41 |
-
*
|
42 |
-
* @since 1.1.4
|
43 |
-
*
|
44 |
-
* @access private
|
45 |
-
* @var array Installed plugins list.
|
46 |
-
*/
|
47 |
-
private static $installed_plugins = null;
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Checkout Fields
|
51 |
-
*
|
52 |
-
* @var checkout_fields
|
53 |
-
*/
|
54 |
-
private static $checkout_fields = null;
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Facebook pixel global data
|
58 |
-
*
|
59 |
-
* @var faceboook
|
60 |
-
*/
|
61 |
-
private static $facebook = null;
|
62 |
-
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Returns an option from the database for
|
66 |
-
* the admin settings page.
|
67 |
-
*
|
68 |
-
* @param string $key The option key.
|
69 |
-
* @param mixed $default Option default value if option is not available.
|
70 |
-
* @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
|
71 |
-
* @return string Return the option value
|
72 |
-
*/
|
73 |
-
public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
|
74 |
-
|
75 |
-
// Get the site-wide option if we're in the network admin.
|
76 |
-
if ( $network_override && is_multisite() ) {
|
77 |
-
$value = get_site_option( $key, $default );
|
78 |
-
} else {
|
79 |
-
$value = get_option( $key, $default );
|
80 |
-
}
|
81 |
-
|
82 |
-
return $value;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Updates an option from the admin settings page.
|
87 |
-
*
|
88 |
-
* @param string $key The option key.
|
89 |
-
* @param mixed $value The value to update.
|
90 |
-
* @param bool $network Whether to allow the network admin setting to be overridden on subsites.
|
91 |
-
* @return mixed
|
92 |
-
*/
|
93 |
-
public static function update_admin_settings_option( $key, $value, $network = false ) {
|
94 |
-
|
95 |
-
// Update the site-wide option since we're in the network admin.
|
96 |
-
if ( $network && is_multisite() ) {
|
97 |
-
update_site_option( $key, $value );
|
98 |
-
} else {
|
99 |
-
update_option( $key, $value );
|
100 |
-
}
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Get single setting
|
106 |
-
*
|
107 |
-
* @since 1.1.4
|
108 |
-
*
|
109 |
-
* @param string $key Option key.
|
110 |
-
* @param string $default Option default value if not exist.
|
111 |
-
* @return mixed
|
112 |
-
*/
|
113 |
-
public static function get_common_setting( $key = '', $default = '' ) {
|
114 |
-
$settings = self::get_common_settings();
|
115 |
-
|
116 |
-
if ( $settings && array_key_exists( $key, $settings ) ) {
|
117 |
-
return $settings[ $key ];
|
118 |
-
}
|
119 |
-
|
120 |
-
return $default;
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Get single debug options
|
125 |
-
*
|
126 |
-
* @since 1.1.4
|
127 |
-
*
|
128 |
-
* @param string $key Option key.
|
129 |
-
* @param string $default Option default value if not exist.
|
130 |
-
* @return mixed
|
131 |
-
*/
|
132 |
-
public static function get_debug_setting( $key = '', $default = '' ) {
|
133 |
-
$debug_data = self::get_debug_settings();
|
134 |
-
|
135 |
-
if ( $debug_data && array_key_exists( $key, $debug_data ) ) {
|
136 |
-
return $debug_data[ $key ];
|
137 |
-
}
|
138 |
-
|
139 |
-
return $default;
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Get required plugins for page builder
|
144 |
-
*
|
145 |
-
* @since 1.1.4
|
146 |
-
*
|
147 |
-
* @param string $page_builder_slug Page builder slug.
|
148 |
-
* @param string $default Default page builder.
|
149 |
-
* @return array selected page builder required plugins list.
|
150 |
-
*/
|
151 |
-
public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
|
152 |
-
$plugins = self::get_plugins_groupby_page_builders();
|
153 |
-
|
154 |
-
if ( array_key_exists( $page_builder_slug, $plugins ) ) {
|
155 |
-
return $plugins[ $page_builder_slug ];
|
156 |
-
}
|
157 |
-
|
158 |
-
return $plugins[ $default ];
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Get Plugins list by page builder.
|
163 |
-
*
|
164 |
-
* @since 1.1.4
|
165 |
-
*
|
166 |
-
* @return array Required Plugins list.
|
167 |
-
*/
|
168 |
-
public static function get_plugins_groupby_page_builders() {
|
169 |
-
|
170 |
-
$divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
|
171 |
-
$theme_status = 'not-installed';
|
172 |
-
if ( $divi_status ) {
|
173 |
-
if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
|
174 |
-
$theme_status = 'installed';
|
175 |
-
if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
|
176 |
-
$theme_status = 'deactivate';
|
177 |
-
$divi_status = 'activate';
|
178 |
-
} else {
|
179 |
-
$divi_status = '';
|
180 |
-
}
|
181 |
-
}
|
182 |
-
}
|
183 |
-
|
184 |
-
$plugins = array(
|
185 |
-
'elementor' => array(
|
186 |
-
'title' => 'Elementor',
|
187 |
-
'plugins' => array(
|
188 |
-
array(
|
189 |
-
'slug' => 'elementor', // For download from wp.org.
|
190 |
-
'init' => 'elementor/elementor.php',
|
191 |
-
'status' => self::get_plugin_status( 'elementor/elementor.php' ),
|
192 |
-
),
|
193 |
-
),
|
194 |
-
),
|
195 |
-
'divi' => array(
|
196 |
-
'title' => 'Divi',
|
197 |
-
'theme-status' => $theme_status,
|
198 |
-
'plugin-status' => $divi_status,
|
199 |
-
'plugins' => array(
|
200 |
-
array(
|
201 |
-
'slug' => 'divi-builder', // For download from wp.org.
|
202 |
-
'init' => 'divi-builder/divi-builder.php',
|
203 |
-
'status' => $divi_status,
|
204 |
-
),
|
205 |
-
),
|
206 |
-
),
|
207 |
-
);
|
208 |
-
|
209 |
-
$plugins['beaver-builder'] = array(
|
210 |
-
'title' => 'Beaver Builder',
|
211 |
-
'plugins' => array(),
|
212 |
-
);
|
213 |
-
|
214 |
-
// Check Pro Exist.
|
215 |
-
if ( file_exists( WP_PLUGIN_DIR . '/
|
216 |
-
$plugins['beaver-builder']['plugins'][] = array(
|
217 |
-
'slug' => 'bb-plugin',
|
218 |
-
'init' => 'bb-plugin/fl-builder.php',
|
219 |
-
'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
|
220 |
-
);
|
221 |
-
} else {
|
222 |
-
$plugins['beaver-builder']['plugins'][] = array(
|
223 |
-
'slug' => 'beaver-builder-lite-version', // For download from wp.org.
|
224 |
-
'init' => 'beaver-builder-lite-version/fl-builder.php',
|
225 |
-
'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
|
226 |
-
);
|
227 |
-
}
|
228 |
-
|
229 |
-
if ( file_exists( WP_PLUGIN_DIR . '/
|
230 |
-
$plugins['beaver-builder']['plugins'][] = array(
|
231 |
-
'slug' => 'bb-ultimate-addon',
|
232 |
-
'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
233 |
-
'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
|
234 |
-
);
|
235 |
-
} else {
|
236 |
-
$plugins['beaver-builder']['plugins'][] = array(
|
237 |
-
'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
|
238 |
-
'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
|
239 |
-
'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
|
240 |
-
);
|
241 |
-
}
|
242 |
-
|
243 |
-
return $plugins;
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Get plugin status
|
248 |
-
*
|
249 |
-
* @since 1.1.4
|
250 |
-
*
|
251 |
-
* @param string $plugin_init_file Plguin init file.
|
252 |
-
* @return mixed
|
253 |
-
*/
|
254 |
-
public static function get_plugin_status( $plugin_init_file ) {
|
255 |
-
|
256 |
-
if ( null == self::$installed_plugins ) {
|
257 |
-
self::$installed_plugins = get_plugins();
|
258 |
-
}
|
259 |
-
|
260 |
-
if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
|
261 |
-
return 'install';
|
262 |
-
} elseif ( ! is_plugin_active( $plugin_init_file ) ) {
|
263 |
-
return 'activate';
|
264 |
-
}
|
265 |
-
|
266 |
-
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Get zapier settings.
|
271 |
-
*
|
272 |
-
* @return array.
|
273 |
-
*/
|
274 |
-
public static function get_common_settings() {
|
275 |
-
|
276 |
-
if ( null === self::$common ) {
|
277 |
-
|
278 |
-
$common_default = apply_filters(
|
279 |
-
'cartflows_common_settings_default',
|
280 |
-
array(
|
281 |
-
'disallow_indexing' => 'disable',
|
282 |
-
'global_checkout' => '',
|
283 |
-
'default_page_builder' => 'elementor',
|
284 |
-
)
|
285 |
-
);
|
286 |
-
|
287 |
-
$common = self::get_admin_settings_option( '_cartflows_common', false, false );
|
288 |
-
|
289 |
-
$common = wp_parse_args( $common, $common_default );
|
290 |
-
|
291 |
-
if ( ! did_action( 'wp' ) ) {
|
292 |
-
return $common;
|
293 |
-
} else {
|
294 |
-
self::$common = $common;
|
295 |
-
}
|
296 |
-
}
|
297 |
-
|
298 |
-
return self::$common;
|
299 |
-
}
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Get debug settings data.
|
303 |
-
*
|
304 |
-
* @return array.
|
305 |
-
*/
|
306 |
-
public static function get_debug_settings() {
|
307 |
-
|
308 |
-
if ( null === self::$debug_data ) {
|
309 |
-
|
310 |
-
$debug_data_default = apply_filters(
|
311 |
-
'cartflows_debug_settings_default',
|
312 |
-
array(
|
313 |
-
'allow_minified_files' => 'disable',
|
314 |
-
)
|
315 |
-
);
|
316 |
-
|
317 |
-
$debug_data = self::get_admin_settings_option( '_cartflows_debug_data', false, false );
|
318 |
-
|
319 |
-
$debug_data = wp_parse_args( $debug_data, $debug_data_default );
|
320 |
-
|
321 |
-
if ( ! did_action( 'wp' ) ) {
|
322 |
-
return $debug_data;
|
323 |
-
} else {
|
324 |
-
self::$debug_data = $debug_data;
|
325 |
-
}
|
326 |
-
}
|
327 |
-
|
328 |
-
return self::$debug_data;
|
329 |
-
}
|
330 |
-
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Get debug settings data.
|
334 |
-
*
|
335 |
-
* @return array.
|
336 |
-
*/
|
337 |
-
public static function get_permalink_settings() {
|
338 |
-
|
339 |
-
if ( null === self::$permalink_setting ) {
|
340 |
-
|
341 |
-
$permalink_default = apply_filters(
|
342 |
-
'cartflows_permalink_settings_default',
|
343 |
-
array(
|
344 |
-
'permalink' => CARTFLOWS_STEP_POST_TYPE,
|
345 |
-
'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE,
|
346 |
-
'permalink_structure' => '',
|
347 |
-
|
348 |
-
)
|
349 |
-
);
|
350 |
-
|
351 |
-
$permalink_data = self::get_admin_settings_option( '_cartflows_permalink', false, false );
|
352 |
-
|
353 |
-
$permalink_data = wp_parse_args( $permalink_data, $permalink_default );
|
354 |
-
|
355 |
-
if ( ! did_action( 'wp' ) ) {
|
356 |
-
return $permalink_data;
|
357 |
-
} else {
|
358 |
-
self::$permalink_setting = $permalink_data;
|
359 |
-
}
|
360 |
-
}
|
361 |
-
|
362 |
-
return self::$permalink_setting;
|
363 |
-
}
|
364 |
-
|
365 |
-
/**
|
366 |
-
* Get Checkout field.
|
367 |
-
*
|
368 |
-
* @param string $key Field key.
|
369 |
-
* @param int $post_id Post id.
|
370 |
-
* @return array.
|
371 |
-
*/
|
372 |
-
public static function get_checkout_fields( $key, $post_id ) {
|
373 |
-
|
374 |
-
$saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
|
375 |
-
|
376 |
-
if ( ! $saved_fields ) {
|
377 |
-
$saved_fields = array();
|
378 |
-
}
|
379 |
-
|
380 |
-
$fields = array_filter( $saved_fields );
|
381 |
-
|
382 |
-
if ( empty( $fields ) ) {
|
383 |
-
if ( 'billing' === $key || 'shipping' === $key ) {
|
384 |
-
|
385 |
-
$fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
|
386 |
-
|
387 |
-
update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
|
388 |
-
}
|
389 |
-
}
|
390 |
-
|
391 |
-
return $fields;
|
392 |
-
}
|
393 |
-
|
394 |
-
/**
|
395 |
-
* Add Checkout field.
|
396 |
-
*
|
397 |
-
* @param string $type Field type.
|
398 |
-
* @param string $field_key Field key.
|
399 |
-
* @param array $field_data Field data.
|
400 |
-
* @param int $post_id Post id.
|
401 |
-
* @return boolean.
|
402 |
-
*/
|
403 |
-
public static function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
|
404 |
-
|
405 |
-
$fields = self::get_checkout_fields( $type, $post_id );
|
406 |
-
|
407 |
-
$fields[ $field_key ] = $field_data;
|
408 |
-
|
409 |
-
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
410 |
-
|
411 |
-
return true;
|
412 |
-
}
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Get checkout fields settings.
|
416 |
-
*
|
417 |
-
* @param string $type Field type.
|
418 |
-
* @param string $field_key Field key.
|
419 |
-
* @param int $post_id Post id.
|
420 |
-
* @return array.
|
421 |
-
*/
|
422 |
-
public static function delete_checkout_field( $type, $field_key, $post_id ) {
|
423 |
-
|
424 |
-
$fields = self::get_checkout_fields( $type, $post_id );
|
425 |
-
|
426 |
-
if ( isset( $fields[ $field_key ] ) ) {
|
427 |
-
unset( $fields[ $field_key ] );
|
428 |
-
}
|
429 |
-
|
430 |
-
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
431 |
-
|
432 |
-
return true;
|
433 |
-
}
|
434 |
-
|
435 |
-
/**
|
436 |
-
* Get checkout fields settings.
|
437 |
-
*
|
438 |
-
* @return array.
|
439 |
-
*/
|
440 |
-
public static function get_checkout_fields_settings() {
|
441 |
-
|
442 |
-
if ( null === self::$checkout_fields ) {
|
443 |
-
$checkout_fields_default = array(
|
444 |
-
'enable_customization' => 'disable',
|
445 |
-
'enable_billing_fields' => 'disable',
|
446 |
-
);
|
447 |
-
|
448 |
-
$billing_fields = self::get_checkout_fields( 'billing' );
|
449 |
-
|
450 |
-
if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
|
451 |
-
|
452 |
-
foreach ( $billing_fields as $key => $value ) {
|
453 |
-
|
454 |
-
$checkout_fields_default[ $key ] = 'enable';
|
455 |
-
}
|
456 |
-
}
|
457 |
-
|
458 |
-
$checkout_fields = self::get_admin_settings_option( '_wcf_checkout_fields', false, false );
|
459 |
-
|
460 |
-
self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
|
461 |
-
}
|
462 |
-
|
463 |
-
return self::$checkout_fields;
|
464 |
-
}
|
465 |
-
|
466 |
-
/**
|
467 |
-
* Get meta options
|
468 |
-
*
|
469 |
-
* @since 1.0.0
|
470 |
-
* @param int $post_id Product ID.
|
471 |
-
* @param string $key Meta Key.
|
472 |
-
* @param string $default Default value.
|
473 |
-
* @return string Meta Value.
|
474 |
-
*/
|
475 |
-
public static function get_meta_option( $post_id, $key, $default = '' ) {
|
476 |
-
|
477 |
-
$value = get_post_meta( $post_id, $key, true );
|
478 |
-
|
479 |
-
if ( ! $value ) {
|
480 |
-
$value = $default;
|
481 |
-
}
|
482 |
-
|
483 |
-
return $value;
|
484 |
-
}
|
485 |
-
|
486 |
-
/**
|
487 |
-
* Save meta option
|
488 |
-
*
|
489 |
-
* @since 1.0.0
|
490 |
-
* @param int $post_id Product ID.
|
491 |
-
* @param array $args Arguments array.
|
492 |
-
*/
|
493 |
-
public static function save_meta_option( $post_id, $args = array() ) {
|
494 |
-
|
495 |
-
if ( is_array( $args ) && ! empty( $args ) ) {
|
496 |
-
|
497 |
-
foreach ( $args as $key => $value ) {
|
498 |
-
|
499 |
-
update_post_meta( $post_id, $key, $value );
|
500 |
-
}
|
501 |
-
}
|
502 |
-
}
|
503 |
-
|
504 |
-
/**
|
505 |
-
* Check if Elementor page builder is installed
|
506 |
-
*
|
507 |
-
* @since 1.0.0
|
508 |
-
*
|
509 |
-
* @access public
|
510 |
-
*/
|
511 |
-
public static function
|
512 |
-
$path = 'elementor/elementor.php';
|
513 |
-
$plugins = get_plugins();
|
514 |
-
|
515 |
-
return isset( $plugins[ $path ] );
|
516 |
-
}
|
517 |
-
|
518 |
-
/**
|
519 |
-
* Check if Step has product assigned.
|
520 |
-
*
|
521 |
-
* @since 1.0.0
|
522 |
-
* @param int $step_id step ID.
|
523 |
-
*
|
524 |
-
* @access public
|
525 |
-
*/
|
526 |
-
public static function has_product_assigned( $step_id ) {
|
527 |
-
|
528 |
-
$step_type = get_post_meta( $step_id, 'wcf-step-type', true );
|
529 |
-
|
530 |
-
if ( 'checkout' == $step_type ) {
|
531 |
-
$product = get_post_meta( $step_id, 'wcf-checkout-products', true );
|
532 |
-
} else {
|
533 |
-
$product = get_post_meta( $step_id, 'wcf-offer-product', true );
|
534 |
-
}
|
535 |
-
|
536 |
-
if ( ! empty( $product ) ) {
|
537 |
-
return true;
|
538 |
-
}
|
539 |
-
return false;
|
540 |
-
|
541 |
-
}
|
542 |
-
|
543 |
-
/**
|
544 |
-
* Get attributes for cartflows wrap.
|
545 |
-
*
|
546 |
-
* @since 1.1.4
|
547 |
-
*
|
548 |
-
* @access public
|
549 |
-
*/
|
550 |
-
public static function get_cartflows_container_atts() {
|
551 |
-
|
552 |
-
$attributes = apply_filters( 'cartflows_container_atts', array() );
|
553 |
-
$atts_string = '';
|
554 |
-
|
555 |
-
foreach ( $attributes as $key => $value ) {
|
556 |
-
|
557 |
-
if ( ! $value ) {
|
558 |
-
continue;
|
559 |
-
}
|
560 |
-
|
561 |
-
if ( true === $value ) {
|
562 |
-
$atts_string .= esc_html( $key ) . ' ';
|
563 |
-
} else {
|
564 |
-
$atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
|
565 |
-
}
|
566 |
-
}
|
567 |
-
|
568 |
-
return $atts_string;
|
569 |
-
}
|
570 |
-
|
571 |
-
/**
|
572 |
-
* Get facebook pixel settings.
|
573 |
-
*
|
574 |
-
* @return facebook array.
|
575 |
-
*/
|
576 |
-
public static function get_facebook_settings() {
|
577 |
-
|
578 |
-
if ( null === self::$facebook ) {
|
579 |
-
|
580 |
-
$facebook_default = array(
|
581 |
-
'facebook_pixel_id' => '',
|
582 |
-
'facebook_pixel_add_to_cart' => 'enable',
|
583 |
-
'facebook_pixel_initiate_checkout' => 'enable',
|
584 |
-
'facebook_pixel_add_payment_info' => 'enable',
|
585 |
-
'facebook_pixel_purchase_complete' => 'enable',
|
586 |
-
'facebook_pixel_tracking' => 'disable',
|
587 |
-
);
|
588 |
-
|
589 |
-
$facebook = self::get_admin_settings_option( '_cartflows_facebook', false, false );
|
590 |
-
|
591 |
-
$facebook = wp_parse_args( $facebook, $facebook_default );
|
592 |
-
|
593 |
-
self::$facebook = apply_filters( 'cartflows_facebook_settings_default', $facebook );
|
594 |
-
|
595 |
-
}
|
596 |
-
|
597 |
-
return self::$facebook;
|
598 |
-
}
|
599 |
-
|
600 |
-
|
601 |
-
/**
|
602 |
-
* Prepare response data for facebook.
|
603 |
-
*
|
604 |
-
* @param int $order_id order_id.
|
605 |
-
* @param array $offer_data offer data.
|
606 |
-
*/
|
607 |
-
public static function send_fb_response_if_enabled( $order_id, $offer_data = array() ) {
|
608 |
-
|
609 |
-
$fb_settings = self::get_facebook_settings();
|
610 |
-
if ( 'enable' === $fb_settings['facebook_pixel_tracking'] ) {
|
611 |
-
setcookie( 'wcf_order_details',
|
612 |
-
}
|
613 |
-
|
614 |
-
}
|
615 |
-
|
616 |
-
/**
|
617 |
-
* Prepare purchase response for facebook purcase event.
|
618 |
-
*
|
619 |
-
* @param integer $order_id order id.
|
620 |
-
* @param array $offer_data offer data.
|
621 |
-
* @return mixed
|
622 |
-
*/
|
623 |
-
public static function prepare_purchase_data_fb_response( $order_id, $offer_data = array() ) {
|
624 |
-
|
625 |
-
$thankyou['order_id'] = $order_id;
|
626 |
-
$thankyou['content_type'] = 'product';
|
627 |
-
$thankyou['currency'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_currency' );
|
628 |
-
$thankyou['userAgent'] = wcf()->options->get_checkout_meta_value( $order_id, '_customer_user_agent' );
|
629 |
-
$thankyou['plugin'] = 'CartFlows';
|
630 |
-
$order = wc_get_order( $order_id );
|
631 |
-
if ( empty( $offer_data ) ) {
|
632 |
-
// Iterating through each WC_Order_Item_Product objects.
|
633 |
-
foreach ( $order->get_items() as $item_key => $item ) {
|
634 |
-
$product = $item->get_product(); // Get the WC_Product object.
|
635 |
-
$thankyou['content_ids'][] = (string) $product->get_id();
|
636 |
-
}
|
637 |
-
$thankyou['value'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_total' );
|
638 |
-
} else {
|
639 |
-
$thankyou['content_ids'][] = (string) $offer_data['id'];
|
640 |
-
$thankyou['value'] = $offer_data['total'];
|
641 |
-
}
|
642 |
-
|
643 |
-
return $thankyou;
|
644 |
-
}
|
645 |
-
|
646 |
-
/**
|
647 |
-
* Prepare cart data for fb response.
|
648 |
-
*
|
649 |
-
* @return array
|
650 |
-
*/
|
651 |
-
public static function prepare_cart_data_fb_response() {
|
652 |
-
$params = array();
|
653 |
-
$cart_total = WC()->cart->get_cart_contents_total();
|
654 |
-
$cart_items_count = WC()->cart->get_cart_contents_count();
|
655 |
-
$items = WC()->cart->get_cart();
|
656 |
-
$product_names = '';
|
657 |
-
$category_names = '';
|
658 |
-
$cart_contents = array();
|
659 |
-
foreach ( $items as $item => $value ) {
|
660 |
-
|
661 |
-
$_product = wc_get_product( $value['product_id'] );
|
662 |
-
$params['content_ids'][] = (string) $_product->get_id();
|
663 |
-
$product_names = $product_names . ', ' . $_product->get_title();
|
664 |
-
$category_names = $category_names . ', ' .
|
665 |
-
array_push(
|
666 |
-
$cart_contents,
|
667 |
-
array(
|
668 |
-
'id' => $_product->get_id(),
|
669 |
-
'name' => $_product->get_title(),
|
670 |
-
'quantity' => $value['quantity'],
|
671 |
-
'item_price' => $_product->get_price(),
|
672 |
-
)
|
673 |
-
);
|
674 |
-
}
|
675 |
-
|
676 |
-
$user = wp_get_current_user();
|
677 |
-
$roles = implode( ', ', $user->roles );
|
678 |
-
$params['content_name'] = substr( $product_names, 2 );
|
679 |
-
$params['categoey_name'] = substr( $category_names, 2 );
|
680 |
-
$params['user_roles'] = $roles;
|
681 |
-
$params['plugin'] = 'CartFlows';
|
682 |
-
$params['contents'] =
|
683 |
-
$params['content_type'] = 'product';
|
684 |
-
$params['value'] = $cart_total;
|
685 |
-
$params['num_items'] = $cart_items_count;
|
686 |
-
$params['currency'] = get_woocommerce_currency();
|
687 |
-
$params['language'] = get_bloginfo( 'language' );
|
688 |
-
$params['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
|
689 |
-
$params['product_catalog_id'] = '';
|
690 |
-
$params['domain'] = get_site_url();
|
691 |
-
return $params;
|
692 |
-
}
|
693 |
-
|
694 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CARTFLOWS Helper.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Cartflows_Helper.
|
14 |
+
*/
|
15 |
+
class Cartflows_Helper {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Common global data
|
19 |
+
*
|
20 |
+
* @var zapier
|
21 |
+
*/
|
22 |
+
private static $common = null;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Common Debug data
|
26 |
+
*
|
27 |
+
* @var zapier
|
28 |
+
*/
|
29 |
+
private static $debug_data = null;
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Permalink settings
|
34 |
+
*
|
35 |
+
* @var permalink_setting
|
36 |
+
*/
|
37 |
+
private static $permalink_setting = null;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Installed Plugins
|
41 |
+
*
|
42 |
+
* @since 1.1.4
|
43 |
+
*
|
44 |
+
* @access private
|
45 |
+
* @var array Installed plugins list.
|
46 |
+
*/
|
47 |
+
private static $installed_plugins = null;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Checkout Fields
|
51 |
+
*
|
52 |
+
* @var checkout_fields
|
53 |
+
*/
|
54 |
+
private static $checkout_fields = null;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Facebook pixel global data
|
58 |
+
*
|
59 |
+
* @var faceboook
|
60 |
+
*/
|
61 |
+
private static $facebook = null;
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Returns an option from the database for
|
66 |
+
* the admin settings page.
|
67 |
+
*
|
68 |
+
* @param string $key The option key.
|
69 |
+
* @param mixed $default Option default value if option is not available.
|
70 |
+
* @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
|
71 |
+
* @return string Return the option value
|
72 |
+
*/
|
73 |
+
public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
|
74 |
+
|
75 |
+
// Get the site-wide option if we're in the network admin.
|
76 |
+
if ( $network_override && is_multisite() ) {
|
77 |
+
$value = get_site_option( $key, $default );
|
78 |
+
} else {
|
79 |
+
$value = get_option( $key, $default );
|
80 |
+
}
|
81 |
+
|
82 |
+
return $value;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Updates an option from the admin settings page.
|
87 |
+
*
|
88 |
+
* @param string $key The option key.
|
89 |
+
* @param mixed $value The value to update.
|
90 |
+
* @param bool $network Whether to allow the network admin setting to be overridden on subsites.
|
91 |
+
* @return mixed
|
92 |
+
*/
|
93 |
+
public static function update_admin_settings_option( $key, $value, $network = false ) {
|
94 |
+
|
95 |
+
// Update the site-wide option since we're in the network admin.
|
96 |
+
if ( $network && is_multisite() ) {
|
97 |
+
update_site_option( $key, $value );
|
98 |
+
} else {
|
99 |
+
update_option( $key, $value );
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get single setting
|
106 |
+
*
|
107 |
+
* @since 1.1.4
|
108 |
+
*
|
109 |
+
* @param string $key Option key.
|
110 |
+
* @param string $default Option default value if not exist.
|
111 |
+
* @return mixed
|
112 |
+
*/
|
113 |
+
public static function get_common_setting( $key = '', $default = '' ) {
|
114 |
+
$settings = self::get_common_settings();
|
115 |
+
|
116 |
+
if ( $settings && array_key_exists( $key, $settings ) ) {
|
117 |
+
return $settings[ $key ];
|
118 |
+
}
|
119 |
+
|
120 |
+
return $default;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Get single debug options
|
125 |
+
*
|
126 |
+
* @since 1.1.4
|
127 |
+
*
|
128 |
+
* @param string $key Option key.
|
129 |
+
* @param string $default Option default value if not exist.
|
130 |
+
* @return mixed
|
131 |
+
*/
|
132 |
+
public static function get_debug_setting( $key = '', $default = '' ) {
|
133 |
+
$debug_data = self::get_debug_settings();
|
134 |
+
|
135 |
+
if ( $debug_data && array_key_exists( $key, $debug_data ) ) {
|
136 |
+
return $debug_data[ $key ];
|
137 |
+
}
|
138 |
+
|
139 |
+
return $default;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Get required plugins for page builder
|
144 |
+
*
|
145 |
+
* @since 1.1.4
|
146 |
+
*
|
147 |
+
* @param string $page_builder_slug Page builder slug.
|
148 |
+
* @param string $default Default page builder.
|
149 |
+
* @return array selected page builder required plugins list.
|
150 |
+
*/
|
151 |
+
public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
|
152 |
+
$plugins = self::get_plugins_groupby_page_builders();
|
153 |
+
|
154 |
+
if ( array_key_exists( $page_builder_slug, $plugins ) ) {
|
155 |
+
return $plugins[ $page_builder_slug ];
|
156 |
+
}
|
157 |
+
|
158 |
+
return $plugins[ $default ];
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Get Plugins list by page builder.
|
163 |
+
*
|
164 |
+
* @since 1.1.4
|
165 |
+
*
|
166 |
+
* @return array Required Plugins list.
|
167 |
+
*/
|
168 |
+
public static function get_plugins_groupby_page_builders() {
|
169 |
+
|
170 |
+
$divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
|
171 |
+
$theme_status = 'not-installed';
|
172 |
+
if ( $divi_status ) {
|
173 |
+
if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
|
174 |
+
$theme_status = 'installed';
|
175 |
+
if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
|
176 |
+
$theme_status = 'deactivate';
|
177 |
+
$divi_status = 'activate';
|
178 |
+
} else {
|
179 |
+
$divi_status = '';
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
$plugins = array(
|
185 |
+
'elementor' => array(
|
186 |
+
'title' => 'Elementor',
|
187 |
+
'plugins' => array(
|
188 |
+
array(
|
189 |
+
'slug' => 'elementor', // For download from wp.org.
|
190 |
+
'init' => 'elementor/elementor.php',
|
191 |
+
'status' => self::get_plugin_status( 'elementor/elementor.php' ),
|
192 |
+
),
|
193 |
+
),
|
194 |
+
),
|
195 |
+
'divi' => array(
|
196 |
+
'title' => 'Divi',
|
197 |
+
'theme-status' => $theme_status,
|
198 |
+
'plugin-status' => $divi_status,
|
199 |
+
'plugins' => array(
|
200 |
+
array(
|
201 |
+
'slug' => 'divi-builder', // For download from wp.org.
|
202 |
+
'init' => 'divi-builder/divi-builder.php',
|
203 |
+
'status' => $divi_status,
|
204 |
+
),
|
205 |
+
),
|
206 |
+
),
|
207 |
+
);
|
208 |
+
|
209 |
+
$plugins['beaver-builder'] = array(
|
210 |
+
'title' => 'Beaver Builder',
|
211 |
+
'plugins' => array(),
|
212 |
+
);
|
213 |
+
|
214 |
+
// Check Pro Exist.
|
215 |
+
if ( file_exists( WP_PLUGIN_DIR . '/bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
|
216 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
217 |
+
'slug' => 'bb-plugin',
|
218 |
+
'init' => 'bb-plugin/fl-builder.php',
|
219 |
+
'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
|
220 |
+
);
|
221 |
+
} else {
|
222 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
223 |
+
'slug' => 'beaver-builder-lite-version', // For download from wp.org.
|
224 |
+
'init' => 'beaver-builder-lite-version/fl-builder.php',
|
225 |
+
'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
|
226 |
+
);
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( file_exists( WP_PLUGIN_DIR . '/bb-ultimate-addon/bb-ultimate-addon.php' ) && ! is_plugin_active( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) {
|
230 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
231 |
+
'slug' => 'bb-ultimate-addon',
|
232 |
+
'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
233 |
+
'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
|
234 |
+
);
|
235 |
+
} else {
|
236 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
237 |
+
'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
|
238 |
+
'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
|
239 |
+
'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
|
240 |
+
);
|
241 |
+
}
|
242 |
+
|
243 |
+
return $plugins;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Get plugin status
|
248 |
+
*
|
249 |
+
* @since 1.1.4
|
250 |
+
*
|
251 |
+
* @param string $plugin_init_file Plguin init file.
|
252 |
+
* @return mixed
|
253 |
+
*/
|
254 |
+
public static function get_plugin_status( $plugin_init_file ) {
|
255 |
+
|
256 |
+
if ( null == self::$installed_plugins ) {
|
257 |
+
self::$installed_plugins = get_plugins();
|
258 |
+
}
|
259 |
+
|
260 |
+
if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
|
261 |
+
return 'install';
|
262 |
+
} elseif ( ! is_plugin_active( $plugin_init_file ) ) {
|
263 |
+
return 'activate';
|
264 |
+
} else {
|
265 |
+
return;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Get zapier settings.
|
271 |
+
*
|
272 |
+
* @return array.
|
273 |
+
*/
|
274 |
+
public static function get_common_settings() {
|
275 |
+
|
276 |
+
if ( null === self::$common ) {
|
277 |
+
|
278 |
+
$common_default = apply_filters(
|
279 |
+
'cartflows_common_settings_default',
|
280 |
+
array(
|
281 |
+
'disallow_indexing' => 'disable',
|
282 |
+
'global_checkout' => '',
|
283 |
+
'default_page_builder' => 'elementor',
|
284 |
+
)
|
285 |
+
);
|
286 |
+
|
287 |
+
$common = self::get_admin_settings_option( '_cartflows_common', false, false );
|
288 |
+
|
289 |
+
$common = wp_parse_args( $common, $common_default );
|
290 |
+
|
291 |
+
if ( ! did_action( 'wp' ) ) {
|
292 |
+
return $common;
|
293 |
+
} else {
|
294 |
+
self::$common = $common;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
return self::$common;
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Get debug settings data.
|
303 |
+
*
|
304 |
+
* @return array.
|
305 |
+
*/
|
306 |
+
public static function get_debug_settings() {
|
307 |
+
|
308 |
+
if ( null === self::$debug_data ) {
|
309 |
+
|
310 |
+
$debug_data_default = apply_filters(
|
311 |
+
'cartflows_debug_settings_default',
|
312 |
+
array(
|
313 |
+
'allow_minified_files' => 'disable',
|
314 |
+
)
|
315 |
+
);
|
316 |
+
|
317 |
+
$debug_data = self::get_admin_settings_option( '_cartflows_debug_data', false, false );
|
318 |
+
|
319 |
+
$debug_data = wp_parse_args( $debug_data, $debug_data_default );
|
320 |
+
|
321 |
+
if ( ! did_action( 'wp' ) ) {
|
322 |
+
return $debug_data;
|
323 |
+
} else {
|
324 |
+
self::$debug_data = $debug_data;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
return self::$debug_data;
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Get debug settings data.
|
334 |
+
*
|
335 |
+
* @return array.
|
336 |
+
*/
|
337 |
+
public static function get_permalink_settings() {
|
338 |
+
|
339 |
+
if ( null === self::$permalink_setting ) {
|
340 |
+
|
341 |
+
$permalink_default = apply_filters(
|
342 |
+
'cartflows_permalink_settings_default',
|
343 |
+
array(
|
344 |
+
'permalink' => CARTFLOWS_STEP_POST_TYPE,
|
345 |
+
'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE,
|
346 |
+
'permalink_structure' => '',
|
347 |
+
|
348 |
+
)
|
349 |
+
);
|
350 |
+
|
351 |
+
$permalink_data = self::get_admin_settings_option( '_cartflows_permalink', false, false );
|
352 |
+
|
353 |
+
$permalink_data = wp_parse_args( $permalink_data, $permalink_default );
|
354 |
+
|
355 |
+
if ( ! did_action( 'wp' ) ) {
|
356 |
+
return $permalink_data;
|
357 |
+
} else {
|
358 |
+
self::$permalink_setting = $permalink_data;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
return self::$permalink_setting;
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Get Checkout field.
|
367 |
+
*
|
368 |
+
* @param string $key Field key.
|
369 |
+
* @param int $post_id Post id.
|
370 |
+
* @return array.
|
371 |
+
*/
|
372 |
+
public static function get_checkout_fields( $key, $post_id ) {
|
373 |
+
|
374 |
+
$saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
|
375 |
+
|
376 |
+
if ( ! $saved_fields ) {
|
377 |
+
$saved_fields = array();
|
378 |
+
}
|
379 |
+
|
380 |
+
$fields = array_filter( $saved_fields );
|
381 |
+
|
382 |
+
if ( empty( $fields ) ) {
|
383 |
+
if ( 'billing' === $key || 'shipping' === $key ) {
|
384 |
+
|
385 |
+
$fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
|
386 |
+
|
387 |
+
update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
return $fields;
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Add Checkout field.
|
396 |
+
*
|
397 |
+
* @param string $type Field type.
|
398 |
+
* @param string $field_key Field key.
|
399 |
+
* @param array $field_data Field data.
|
400 |
+
* @param int $post_id Post id.
|
401 |
+
* @return boolean.
|
402 |
+
*/
|
403 |
+
public static function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
|
404 |
+
|
405 |
+
$fields = self::get_checkout_fields( $type, $post_id );
|
406 |
+
|
407 |
+
$fields[ $field_key ] = $field_data;
|
408 |
+
|
409 |
+
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
410 |
+
|
411 |
+
return true;
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Get checkout fields settings.
|
416 |
+
*
|
417 |
+
* @param string $type Field type.
|
418 |
+
* @param string $field_key Field key.
|
419 |
+
* @param int $post_id Post id.
|
420 |
+
* @return array.
|
421 |
+
*/
|
422 |
+
public static function delete_checkout_field( $type, $field_key, $post_id ) {
|
423 |
+
|
424 |
+
$fields = self::get_checkout_fields( $type, $post_id );
|
425 |
+
|
426 |
+
if ( isset( $fields[ $field_key ] ) ) {
|
427 |
+
unset( $fields[ $field_key ] );
|
428 |
+
}
|
429 |
+
|
430 |
+
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
431 |
+
|
432 |
+
return true;
|
433 |
+
}
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Get checkout fields settings.
|
437 |
+
*
|
438 |
+
* @return array.
|
439 |
+
*/
|
440 |
+
public static function get_checkout_fields_settings() {
|
441 |
+
|
442 |
+
if ( null === self::$checkout_fields ) {
|
443 |
+
$checkout_fields_default = array(
|
444 |
+
'enable_customization' => 'disable',
|
445 |
+
'enable_billing_fields' => 'disable',
|
446 |
+
);
|
447 |
+
|
448 |
+
$billing_fields = self::get_checkout_fields( 'billing' );
|
449 |
+
|
450 |
+
if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
|
451 |
+
|
452 |
+
foreach ( $billing_fields as $key => $value ) {
|
453 |
+
|
454 |
+
$checkout_fields_default[ $key ] = 'enable';
|
455 |
+
}
|
456 |
+
}
|
457 |
+
|
458 |
+
$checkout_fields = self::get_admin_settings_option( '_wcf_checkout_fields', false, false );
|
459 |
+
|
460 |
+
self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
|
461 |
+
}
|
462 |
+
|
463 |
+
return self::$checkout_fields;
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* Get meta options
|
468 |
+
*
|
469 |
+
* @since 1.0.0
|
470 |
+
* @param int $post_id Product ID.
|
471 |
+
* @param string $key Meta Key.
|
472 |
+
* @param string $default Default value.
|
473 |
+
* @return string Meta Value.
|
474 |
+
*/
|
475 |
+
public static function get_meta_option( $post_id, $key, $default = '' ) {
|
476 |
+
|
477 |
+
$value = get_post_meta( $post_id, $key, true );
|
478 |
+
|
479 |
+
if ( ! $value ) {
|
480 |
+
$value = $default;
|
481 |
+
}
|
482 |
+
|
483 |
+
return $value;
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Save meta option
|
488 |
+
*
|
489 |
+
* @since 1.0.0
|
490 |
+
* @param int $post_id Product ID.
|
491 |
+
* @param array $args Arguments array.
|
492 |
+
*/
|
493 |
+
public static function save_meta_option( $post_id, $args = array() ) {
|
494 |
+
|
495 |
+
if ( is_array( $args ) && ! empty( $args ) ) {
|
496 |
+
|
497 |
+
foreach ( $args as $key => $value ) {
|
498 |
+
|
499 |
+
update_post_meta( $post_id, $key, $value );
|
500 |
+
}
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Check if Elementor page builder is installed
|
506 |
+
*
|
507 |
+
* @since 1.0.0
|
508 |
+
*
|
509 |
+
* @access public
|
510 |
+
*/
|
511 |
+
public static function is_elementor_installed() {
|
512 |
+
$path = 'elementor/elementor.php';
|
513 |
+
$plugins = get_plugins();
|
514 |
+
|
515 |
+
return isset( $plugins[ $path ] );
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Check if Step has product assigned.
|
520 |
+
*
|
521 |
+
* @since 1.0.0
|
522 |
+
* @param int $step_id step ID.
|
523 |
+
*
|
524 |
+
* @access public
|
525 |
+
*/
|
526 |
+
public static function has_product_assigned( $step_id ) {
|
527 |
+
|
528 |
+
$step_type = get_post_meta( $step_id, 'wcf-step-type', true );
|
529 |
+
|
530 |
+
if ( 'checkout' == $step_type ) {
|
531 |
+
$product = get_post_meta( $step_id, 'wcf-checkout-products', true );
|
532 |
+
} else {
|
533 |
+
$product = get_post_meta( $step_id, 'wcf-offer-product', true );
|
534 |
+
}
|
535 |
+
|
536 |
+
if ( ! empty( $product ) ) {
|
537 |
+
return true;
|
538 |
+
}
|
539 |
+
return false;
|
540 |
+
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* Get attributes for cartflows wrap.
|
545 |
+
*
|
546 |
+
* @since 1.1.4
|
547 |
+
*
|
548 |
+
* @access public
|
549 |
+
*/
|
550 |
+
public static function get_cartflows_container_atts() {
|
551 |
+
|
552 |
+
$attributes = apply_filters( 'cartflows_container_atts', array() );
|
553 |
+
$atts_string = '';
|
554 |
+
|
555 |
+
foreach ( $attributes as $key => $value ) {
|
556 |
+
|
557 |
+
if ( ! $value ) {
|
558 |
+
continue;
|
559 |
+
}
|
560 |
+
|
561 |
+
if ( true === $value ) {
|
562 |
+
$atts_string .= esc_html( $key ) . ' ';
|
563 |
+
} else {
|
564 |
+
$atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
|
565 |
+
}
|
566 |
+
}
|
567 |
+
|
568 |
+
return $atts_string;
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Get facebook pixel settings.
|
573 |
+
*
|
574 |
+
* @return facebook array.
|
575 |
+
*/
|
576 |
+
public static function get_facebook_settings() {
|
577 |
+
|
578 |
+
if ( null === self::$facebook ) {
|
579 |
+
|
580 |
+
$facebook_default = array(
|
581 |
+
'facebook_pixel_id' => '',
|
582 |
+
'facebook_pixel_add_to_cart' => 'enable',
|
583 |
+
'facebook_pixel_initiate_checkout' => 'enable',
|
584 |
+
'facebook_pixel_add_payment_info' => 'enable',
|
585 |
+
'facebook_pixel_purchase_complete' => 'enable',
|
586 |
+
'facebook_pixel_tracking' => 'disable',
|
587 |
+
);
|
588 |
+
|
589 |
+
$facebook = self::get_admin_settings_option( '_cartflows_facebook', false, false );
|
590 |
+
|
591 |
+
$facebook = wp_parse_args( $facebook, $facebook_default );
|
592 |
+
|
593 |
+
self::$facebook = apply_filters( 'cartflows_facebook_settings_default', $facebook );
|
594 |
+
|
595 |
+
}
|
596 |
+
|
597 |
+
return self::$facebook;
|
598 |
+
}
|
599 |
+
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Prepare response data for facebook.
|
603 |
+
*
|
604 |
+
* @param int $order_id order_id.
|
605 |
+
* @param array $offer_data offer data.
|
606 |
+
*/
|
607 |
+
public static function send_fb_response_if_enabled( $order_id, $offer_data = array() ) {
|
608 |
+
|
609 |
+
$fb_settings = self::get_facebook_settings();
|
610 |
+
if ( 'enable' === $fb_settings['facebook_pixel_tracking'] ) {
|
611 |
+
setcookie( 'wcf_order_details', wp_json_encode( self::prepare_purchase_data_fb_response( $order_id, $offer_data ) ), strtotime( '+1 year' ), '/' );
|
612 |
+
}
|
613 |
+
|
614 |
+
}
|
615 |
+
|
616 |
+
/**
|
617 |
+
* Prepare purchase response for facebook purcase event.
|
618 |
+
*
|
619 |
+
* @param integer $order_id order id.
|
620 |
+
* @param array $offer_data offer data.
|
621 |
+
* @return mixed
|
622 |
+
*/
|
623 |
+
public static function prepare_purchase_data_fb_response( $order_id, $offer_data = array() ) {
|
624 |
+
|
625 |
+
$thankyou['order_id'] = $order_id;
|
626 |
+
$thankyou['content_type'] = 'product';
|
627 |
+
$thankyou['currency'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_currency' );
|
628 |
+
$thankyou['userAgent'] = wcf()->options->get_checkout_meta_value( $order_id, '_customer_user_agent' );
|
629 |
+
$thankyou['plugin'] = 'CartFlows';
|
630 |
+
$order = wc_get_order( $order_id );
|
631 |
+
if ( empty( $offer_data ) ) {
|
632 |
+
// Iterating through each WC_Order_Item_Product objects.
|
633 |
+
foreach ( $order->get_items() as $item_key => $item ) {
|
634 |
+
$product = $item->get_product(); // Get the WC_Product object.
|
635 |
+
$thankyou['content_ids'][] = (string) $product->get_id();
|
636 |
+
}
|
637 |
+
$thankyou['value'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_total' );
|
638 |
+
} else {
|
639 |
+
$thankyou['content_ids'][] = (string) $offer_data['id'];
|
640 |
+
$thankyou['value'] = $offer_data['total'];
|
641 |
+
}
|
642 |
+
|
643 |
+
return $thankyou;
|
644 |
+
}
|
645 |
+
|
646 |
+
/**
|
647 |
+
* Prepare cart data for fb response.
|
648 |
+
*
|
649 |
+
* @return array
|
650 |
+
*/
|
651 |
+
public static function prepare_cart_data_fb_response() {
|
652 |
+
$params = array();
|
653 |
+
$cart_total = WC()->cart->get_cart_contents_total();
|
654 |
+
$cart_items_count = WC()->cart->get_cart_contents_count();
|
655 |
+
$items = WC()->cart->get_cart();
|
656 |
+
$product_names = '';
|
657 |
+
$category_names = '';
|
658 |
+
$cart_contents = array();
|
659 |
+
foreach ( $items as $item => $value ) {
|
660 |
+
|
661 |
+
$_product = wc_get_product( $value['product_id'] );
|
662 |
+
$params['content_ids'][] = (string) $_product->get_id();
|
663 |
+
$product_names = $product_names . ', ' . $_product->get_title();
|
664 |
+
$category_names = $category_names . ', ' . wp_strip_all_tags( wc_get_product_category_list( $_product->get_id() ) );
|
665 |
+
array_push(
|
666 |
+
$cart_contents,
|
667 |
+
array(
|
668 |
+
'id' => $_product->get_id(),
|
669 |
+
'name' => $_product->get_title(),
|
670 |
+
'quantity' => $value['quantity'],
|
671 |
+
'item_price' => $_product->get_price(),
|
672 |
+
)
|
673 |
+
);
|
674 |
+
}
|
675 |
+
|
676 |
+
$user = wp_get_current_user();
|
677 |
+
$roles = implode( ', ', $user->roles );
|
678 |
+
$params['content_name'] = substr( $product_names, 2 );
|
679 |
+
$params['categoey_name'] = substr( $category_names, 2 );
|
680 |
+
$params['user_roles'] = $roles;
|
681 |
+
$params['plugin'] = 'CartFlows';
|
682 |
+
$params['contents'] = wp_json_encode( $cart_contents );
|
683 |
+
$params['content_type'] = 'product';
|
684 |
+
$params['value'] = $cart_total;
|
685 |
+
$params['num_items'] = $cart_items_count;
|
686 |
+
$params['currency'] = get_woocommerce_currency();
|
687 |
+
$params['language'] = get_bloginfo( 'language' );
|
688 |
+
$params['userAgent'] = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); //phpcs:ignore
|
689 |
+
$params['product_catalog_id'] = '';
|
690 |
+
$params['domain'] = get_site_url();
|
691 |
+
return $params;
|
692 |
+
}
|
693 |
+
|
694 |
+
}
|
classes/class-cartflows-importer-core.php
CHANGED
@@ -1,272 +1,272 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Image Importer
|
4 |
-
*
|
5 |
-
* => How to use?
|
6 |
-
*
|
7 |
-
* $image = array(
|
8 |
-
* 'url' => '<image-url>',
|
9 |
-
* 'id' => '<image-id>',
|
10 |
-
* );
|
11 |
-
*
|
12 |
-
* $downloaded_image = CartFlows_Importer_Core::get_instance()->import( $image );
|
13 |
-
*
|
14 |
-
* @package CartFlows
|
15 |
-
* @since 1.0.0
|
16 |
-
*/
|
17 |
-
|
18 |
-
if ( ! class_exists( 'CartFlows_Importer_Core' ) ) :
|
19 |
-
|
20 |
-
/**
|
21 |
-
* CartFlows Importer
|
22 |
-
*
|
23 |
-
* @since 1.0.0
|
24 |
-
*/
|
25 |
-
class CartFlows_Importer_Core {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Instance
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
* @var object Class object.
|
32 |
-
* @access private
|
33 |
-
*/
|
34 |
-
private static $instance;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Images IDs
|
38 |
-
*
|
39 |
-
* @var array The Array of already image IDs.
|
40 |
-
* @since 1.0.0
|
41 |
-
*/
|
42 |
-
private $already_imported_ids = array();
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Initiator
|
46 |
-
*
|
47 |
-
* @since 1.0.0
|
48 |
-
* @return object initialized object of class.
|
49 |
-
*/
|
50 |
-
public static function get_instance() {
|
51 |
-
if ( ! isset( self::$instance ) ) {
|
52 |
-
self::$instance = new self();
|
53 |
-
}
|
54 |
-
return self::$instance;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Constructor
|
59 |
-
*
|
60 |
-
* @since 1.0.0
|
61 |
-
*/
|
62 |
-
public function __construct() {
|
63 |
-
|
64 |
-
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
65 |
-
require_once ABSPATH . 'wp-admin/includes/file.php';
|
66 |
-
}
|
67 |
-
|
68 |
-
WP_Filesystem();
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Process Image Download
|
73 |
-
*
|
74 |
-
* @since 1.0.0
|
75 |
-
* @param array $attachments Attachment array.
|
76 |
-
* @return array Attachment array.
|
77 |
-
*/
|
78 |
-
public function process( $attachments ) {
|
79 |
-
|
80 |
-
$downloaded_images = array();
|
81 |
-
|
82 |
-
foreach ( $attachments as $key => $attachment ) {
|
83 |
-
$downloaded_images[] = $this->import( $attachment );
|
84 |
-
}
|
85 |
-
|
86 |
-
return $downloaded_images;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Get Hash Image.
|
91 |
-
*
|
92 |
-
* @since 1.0.0
|
93 |
-
* @param string $attachment_url Attachment URL.
|
94 |
-
* @return string Hash string.
|
95 |
-
*/
|
96 |
-
private function get_hash_image( $attachment_url ) {
|
97 |
-
return sha1( $attachment_url );
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Get Saved Image.
|
102 |
-
*
|
103 |
-
* @since 1.0.0
|
104 |
-
* @param string $attachment Attachment Data.
|
105 |
-
* @return string Hash string.
|
106 |
-
*/
|
107 |
-
private function get_saved_image( $attachment ) {
|
108 |
-
|
109 |
-
wcf()->logger->import_log( 'importer-core.php File' );
|
110 |
-
|
111 |
-
if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) {
|
112 |
-
|
113 |
-
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
114 |
-
|
115 |
-
return $attachment;
|
116 |
-
}
|
117 |
-
|
118 |
-
global $wpdb;
|
119 |
-
|
120 |
-
// Already imported? Then return!
|
121 |
-
if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
|
122 |
-
|
123 |
-
self::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
|
124 |
-
|
125 |
-
return $this->already_imported_ids[ $attachment['id'] ];
|
126 |
-
}
|
127 |
-
|
128 |
-
// 1. Is already imported in Batch Import Process?
|
129 |
-
$post_id = $wpdb->get_var(
|
130 |
-
$wpdb->prepare(
|
131 |
-
'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
|
132 |
-
WHERE `meta_key` = \'_cartflows_image_hash\'
|
133 |
-
AND `meta_value` = %s
|
134 |
-
;',
|
135 |
-
$this->get_hash_image( $attachment['url'] )
|
136 |
-
)
|
137 |
-
);
|
138 |
-
|
139 |
-
// 2. Is image already imported though XML?
|
140 |
-
if ( empty( $post_id ) ) {
|
141 |
-
|
142 |
-
// Get file name without extension.
|
143 |
-
// To check it exist in attachment.
|
144 |
-
$filename = preg_replace( '/\\.[^.\\s]{3,4}$/', '', basename( $attachment['url'] ) );
|
145 |
-
|
146 |
-
$post_id = $wpdb->get_var(
|
147 |
-
$wpdb->prepare(
|
148 |
-
'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
|
149 |
-
WHERE `meta_key` = \'_wp_attached_file\'
|
150 |
-
AND `meta_value` LIKE %s
|
151 |
-
;',
|
152 |
-
'%' . $filename . '%'
|
153 |
-
)
|
154 |
-
);
|
155 |
-
|
156 |
-
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
157 |
-
}
|
158 |
-
|
159 |
-
if ( $post_id ) {
|
160 |
-
|
161 |
-
$new_imgage_url = wp_get_attachment_url( $post_id );
|
162 |
-
$new_attachment = array(
|
163 |
-
'id' => $post_id,
|
164 |
-
'url' => $new_imgage_url,
|
165 |
-
);
|
166 |
-
$this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
|
167 |
-
|
168 |
-
self::log( 'Download (✓) Replace (✓) - ' . $new_imgage_url );
|
169 |
-
return $new_attachment;
|
170 |
-
}
|
171 |
-
|
172 |
-
return false;
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Import Image
|
177 |
-
*
|
178 |
-
* @since 1.0.0
|
179 |
-
* @param array $attachment Attachment array.
|
180 |
-
* @return array Attachment array.
|
181 |
-
*/
|
182 |
-
public function import( $attachment ) {
|
183 |
-
|
184 |
-
$saved_image = $this->get_saved_image( $attachment );
|
185 |
-
if ( $saved_image ) {
|
186 |
-
return $saved_image;
|
187 |
-
}
|
188 |
-
|
189 |
-
$args = array(
|
190 |
-
'timeout' => 300,
|
191 |
-
);
|
192 |
-
|
193 |
-
$file_content = wp_remote_retrieve_body( wp_safe_remote_get( $attachment['url'], $args ) );
|
194 |
-
|
195 |
-
// Empty file content?
|
196 |
-
if ( empty( $file_content ) ) {
|
197 |
-
|
198 |
-
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
199 |
-
self::log( 'Error: Failed wp_remote_retrieve_body().' );
|
200 |
-
|
201 |
-
return $attachment;
|
202 |
-
}
|
203 |
-
|
204 |
-
// Extract the file name and extension from the URL.
|
205 |
-
$filename = basename( $attachment['url'] );
|
206 |
-
|
207 |
-
$upload = wp_upload_bits(
|
208 |
-
$filename,
|
209 |
-
null,
|
210 |
-
$file_content
|
211 |
-
);
|
212 |
-
|
213 |
-
$post = array(
|
214 |
-
'post_title' => $filename,
|
215 |
-
'guid' => $upload['url'],
|
216 |
-
);
|
217 |
-
|
218 |
-
$info = wp_check_filetype( $upload['file'] );
|
219 |
-
if ( $info ) {
|
220 |
-
$post['post_mime_type'] = $info['type'];
|
221 |
-
} else {
|
222 |
-
// For now just return the origin attachment.
|
223 |
-
return $attachment;
|
224 |
-
}
|
225 |
-
|
226 |
-
$post_id = wp_insert_attachment( $post, $upload['file'] );
|
227 |
-
wp_update_attachment_metadata(
|
228 |
-
$post_id,
|
229 |
-
wp_generate_attachment_metadata( $post_id, $upload['file'] )
|
230 |
-
);
|
231 |
-
update_post_meta( $post_id, '_cartflows_image_hash', $this->get_hash_image( $attachment['url'] ) );
|
232 |
-
|
233 |
-
$new_attachment = array(
|
234 |
-
'id' => $post_id,
|
235 |
-
'url' => $upload['url'],
|
236 |
-
);
|
237 |
-
|
238 |
-
self::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
|
239 |
-
|
240 |
-
$this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
|
241 |
-
|
242 |
-
return $new_attachment;
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Debugging Log.
|
247 |
-
*
|
248 |
-
* @since 1.0.0
|
249 |
-
* @param mixed $log Log data.
|
250 |
-
* @return void
|
251 |
-
*/
|
252 |
-
public static function log( $log ) {
|
253 |
-
|
254 |
-
if ( ! WP_DEBUG_LOG ) {
|
255 |
-
return;
|
256 |
-
}
|
257 |
-
|
258 |
-
if ( is_array( $log ) || is_object( $log ) ) {
|
259 |
-
wcf()->logger->import_log( print_r( $log, true ) )
|
260 |
-
} else {
|
261 |
-
wcf()->logger->import_log( $log );
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Initialize class object with 'get_instance()' method
|
269 |
-
*/
|
270 |
-
CartFlows_Importer_Core::get_instance();
|
271 |
-
|
272 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Image Importer
|
4 |
+
*
|
5 |
+
* => How to use?
|
6 |
+
*
|
7 |
+
* $image = array(
|
8 |
+
* 'url' => '<image-url>',
|
9 |
+
* 'id' => '<image-id>',
|
10 |
+
* );
|
11 |
+
*
|
12 |
+
* $downloaded_image = CartFlows_Importer_Core::get_instance()->import( $image );
|
13 |
+
*
|
14 |
+
* @package CartFlows
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
|
18 |
+
if ( ! class_exists( 'CartFlows_Importer_Core' ) ) :
|
19 |
+
|
20 |
+
/**
|
21 |
+
* CartFlows Importer
|
22 |
+
*
|
23 |
+
* @since 1.0.0
|
24 |
+
*/
|
25 |
+
class CartFlows_Importer_Core {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Instance
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @var object Class object.
|
32 |
+
* @access private
|
33 |
+
*/
|
34 |
+
private static $instance;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Images IDs
|
38 |
+
*
|
39 |
+
* @var array The Array of already image IDs.
|
40 |
+
* @since 1.0.0
|
41 |
+
*/
|
42 |
+
private $already_imported_ids = array();
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initiator
|
46 |
+
*
|
47 |
+
* @since 1.0.0
|
48 |
+
* @return object initialized object of class.
|
49 |
+
*/
|
50 |
+
public static function get_instance() {
|
51 |
+
if ( ! isset( self::$instance ) ) {
|
52 |
+
self::$instance = new self();
|
53 |
+
}
|
54 |
+
return self::$instance;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Constructor
|
59 |
+
*
|
60 |
+
* @since 1.0.0
|
61 |
+
*/
|
62 |
+
public function __construct() {
|
63 |
+
|
64 |
+
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
65 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
66 |
+
}
|
67 |
+
|
68 |
+
WP_Filesystem();
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Process Image Download
|
73 |
+
*
|
74 |
+
* @since 1.0.0
|
75 |
+
* @param array $attachments Attachment array.
|
76 |
+
* @return array Attachment array.
|
77 |
+
*/
|
78 |
+
public function process( $attachments ) {
|
79 |
+
|
80 |
+
$downloaded_images = array();
|
81 |
+
|
82 |
+
foreach ( $attachments as $key => $attachment ) {
|
83 |
+
$downloaded_images[] = $this->import( $attachment );
|
84 |
+
}
|
85 |
+
|
86 |
+
return $downloaded_images;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get Hash Image.
|
91 |
+
*
|
92 |
+
* @since 1.0.0
|
93 |
+
* @param string $attachment_url Attachment URL.
|
94 |
+
* @return string Hash string.
|
95 |
+
*/
|
96 |
+
private function get_hash_image( $attachment_url ) {
|
97 |
+
return sha1( $attachment_url );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get Saved Image.
|
102 |
+
*
|
103 |
+
* @since 1.0.0
|
104 |
+
* @param string $attachment Attachment Data.
|
105 |
+
* @return string Hash string.
|
106 |
+
*/
|
107 |
+
private function get_saved_image( $attachment ) {
|
108 |
+
|
109 |
+
wcf()->logger->import_log( 'importer-core.php File' );
|
110 |
+
|
111 |
+
if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) {
|
112 |
+
|
113 |
+
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
114 |
+
|
115 |
+
return $attachment;
|
116 |
+
}
|
117 |
+
|
118 |
+
global $wpdb;
|
119 |
+
|
120 |
+
// Already imported? Then return!
|
121 |
+
if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
|
122 |
+
|
123 |
+
self::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
|
124 |
+
|
125 |
+
return $this->already_imported_ids[ $attachment['id'] ];
|
126 |
+
}
|
127 |
+
|
128 |
+
// 1. Is already imported in Batch Import Process?
|
129 |
+
$post_id = $wpdb->get_var(
|
130 |
+
$wpdb->prepare(
|
131 |
+
'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
|
132 |
+
WHERE `meta_key` = \'_cartflows_image_hash\'
|
133 |
+
AND `meta_value` = %s
|
134 |
+
;',
|
135 |
+
$this->get_hash_image( $attachment['url'] )
|
136 |
+
)
|
137 |
+
); // db call ok; no-cache ok.
|
138 |
+
|
139 |
+
// 2. Is image already imported though XML?
|
140 |
+
if ( empty( $post_id ) ) {
|
141 |
+
|
142 |
+
// Get file name without extension.
|
143 |
+
// To check it exist in attachment.
|
144 |
+
$filename = preg_replace( '/\\.[^.\\s]{3,4}$/', '', basename( $attachment['url'] ) );
|
145 |
+
|
146 |
+
$post_id = $wpdb->get_var(
|
147 |
+
$wpdb->prepare(
|
148 |
+
'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
|
149 |
+
WHERE `meta_key` = \'_wp_attached_file\'
|
150 |
+
AND `meta_value` LIKE %s
|
151 |
+
;',
|
152 |
+
'%' . $filename . '%'
|
153 |
+
)
|
154 |
+
); // db call ok; no-cache ok.
|
155 |
+
|
156 |
+
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( $post_id ) {
|
160 |
+
|
161 |
+
$new_imgage_url = wp_get_attachment_url( $post_id );
|
162 |
+
$new_attachment = array(
|
163 |
+
'id' => $post_id,
|
164 |
+
'url' => $new_imgage_url,
|
165 |
+
);
|
166 |
+
$this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
|
167 |
+
|
168 |
+
self::log( 'Download (✓) Replace (✓) - ' . $new_imgage_url );
|
169 |
+
return $new_attachment;
|
170 |
+
}
|
171 |
+
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Import Image
|
177 |
+
*
|
178 |
+
* @since 1.0.0
|
179 |
+
* @param array $attachment Attachment array.
|
180 |
+
* @return array Attachment array.
|
181 |
+
*/
|
182 |
+
public function import( $attachment ) {
|
183 |
+
|
184 |
+
$saved_image = $this->get_saved_image( $attachment );
|
185 |
+
if ( $saved_image ) {
|
186 |
+
return $saved_image;
|
187 |
+
}
|
188 |
+
|
189 |
+
$args = array(
|
190 |
+
'timeout' => 300,
|
191 |
+
);
|
192 |
+
|
193 |
+
$file_content = wp_remote_retrieve_body( wp_safe_remote_get( $attachment['url'], $args ) );
|
194 |
+
|
195 |
+
// Empty file content?
|
196 |
+
if ( empty( $file_content ) ) {
|
197 |
+
|
198 |
+
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
199 |
+
self::log( 'Error: Failed wp_remote_retrieve_body().' );
|
200 |
+
|
201 |
+
return $attachment;
|
202 |
+
}
|
203 |
+
|
204 |
+
// Extract the file name and extension from the URL.
|
205 |
+
$filename = basename( $attachment['url'] );
|
206 |
+
|
207 |
+
$upload = wp_upload_bits(
|
208 |
+
$filename,
|
209 |
+
null,
|
210 |
+
$file_content
|
211 |
+
);
|
212 |
+
|
213 |
+
$post = array(
|
214 |
+
'post_title' => $filename,
|
215 |
+
'guid' => $upload['url'],
|
216 |
+
);
|
217 |
+
|
218 |
+
$info = wp_check_filetype( $upload['file'] );
|
219 |
+
if ( $info ) {
|
220 |
+
$post['post_mime_type'] = $info['type'];
|
221 |
+
} else {
|
222 |
+
// For now just return the origin attachment.
|
223 |
+
return $attachment;
|
224 |
+
}
|
225 |
+
|
226 |
+
$post_id = wp_insert_attachment( $post, $upload['file'] );
|
227 |
+
wp_update_attachment_metadata(
|
228 |
+
$post_id,
|
229 |
+
wp_generate_attachment_metadata( $post_id, $upload['file'] )
|
230 |
+
);
|
231 |
+
update_post_meta( $post_id, '_cartflows_image_hash', $this->get_hash_image( $attachment['url'] ) );
|
232 |
+
|
233 |
+
$new_attachment = array(
|
234 |
+
'id' => $post_id,
|
235 |
+
'url' => $upload['url'],
|
236 |
+
);
|
237 |
+
|
238 |
+
self::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
|
239 |
+
|
240 |
+
$this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
|
241 |
+
|
242 |
+
return $new_attachment;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Debugging Log.
|
247 |
+
*
|
248 |
+
* @since 1.0.0
|
249 |
+
* @param mixed $log Log data.
|
250 |
+
* @return void
|
251 |
+
*/
|
252 |
+
public static function log( $log ) {
|
253 |
+
|
254 |
+
if ( ! WP_DEBUG_LOG ) {
|
255 |
+
return;
|
256 |
+
}
|
257 |
+
|
258 |
+
if ( is_array( $log ) || is_object( $log ) ) {
|
259 |
+
wcf()->logger->import_log( print_r( $log, true ) );//phpcs:ignore
|
260 |
+
} else {
|
261 |
+
wcf()->logger->import_log( $log );
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Initialize class object with 'get_instance()' method
|
269 |
+
*/
|
270 |
+
CartFlows_Importer_Core::get_instance();
|
271 |
+
|
272 |
+
endif;
|
classes/class-cartflows-importer.php
CHANGED
@@ -75,7 +75,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
75 |
*
|
76 |
* @return array
|
77 |
*/
|
78 |
-
function export_link( $actions, $post ) {
|
79 |
if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
80 |
$actions['export'] = '<a href="' . wp_nonce_url( 'admin.php?action=cartflows_export_flow&post=' . $post->ID, basename( __FILE__ ), 'flow_export_nonce' ) . '" title="' . __( 'Export this flow', 'cartflows' ) . '" rel="permalink">' . __( 'Export', 'cartflows' ) . '</a>';
|
81 |
}
|
@@ -87,7 +87,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
87 |
*
|
88 |
* @since 1.1.4
|
89 |
*/
|
90 |
-
function add_to_menus() {
|
91 |
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Export', 'cartflows' ), __( 'Flow Export', 'cartflows' ), 'export', 'flow_exporter', array( $this, 'exporter_markup' ) );
|
92 |
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Import', 'cartflows' ), __( 'Flow Import', 'cartflows' ), 'import', 'flow_importer', array( $this, 'importer_markup' ) );
|
93 |
}
|
@@ -97,13 +97,13 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
97 |
*
|
98 |
* @since 1.1.4
|
99 |
*/
|
100 |
-
function export_flow() {
|
101 |
|
102 |
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_export_flow' == $_REQUEST['action'] ) ) ) {
|
103 |
wp_die( __( 'No post to export has been supplied!', 'cartflows' ) );
|
104 |
}
|
105 |
|
106 |
-
if ( ! isset( $_GET['flow_export_nonce'] ) || ! wp_verify_nonce( $_GET['flow_export_nonce'], basename( __FILE__ ) ) ) {
|
107 |
return;
|
108 |
}
|
109 |
|
@@ -116,10 +116,10 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
116 |
|
117 |
nocache_headers();
|
118 |
header( 'Content-Type: application/json; charset=utf-8' );
|
119 |
-
header( 'Content-Disposition: attachment; filename=cartflows-flow-' . $flow_id . '-' .
|
120 |
header( 'Expires: 0' );
|
121 |
|
122 |
-
echo
|
123 |
exit;
|
124 |
}
|
125 |
|
@@ -128,7 +128,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
128 |
*
|
129 |
* @since 1.1.4
|
130 |
*/
|
131 |
-
function exporter_markup() {
|
132 |
include_once CARTFLOWS_DIR . 'includes/exporter.php';
|
133 |
}
|
134 |
|
@@ -137,7 +137,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
137 |
*
|
138 |
* @since 1.1.4
|
139 |
*/
|
140 |
-
function importer_markup() {
|
141 |
include_once CARTFLOWS_DIR . 'includes/importer.php';
|
142 |
}
|
143 |
|
@@ -146,12 +146,12 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
146 |
*
|
147 |
* @since 1.1.4
|
148 |
*/
|
149 |
-
function export_json() {
|
150 |
if ( empty( $_POST['cartflows-action'] ) || 'export' != $_POST['cartflows-action'] ) {
|
151 |
return;
|
152 |
}
|
153 |
|
154 |
-
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
155 |
return;
|
156 |
}
|
157 |
|
@@ -164,10 +164,10 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
164 |
|
165 |
nocache_headers();
|
166 |
header( 'Content-Type: application/json; charset=utf-8' );
|
167 |
-
header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' .
|
168 |
header( 'Expires: 0' );
|
169 |
|
170 |
-
echo
|
171 |
exit;
|
172 |
}
|
173 |
|
@@ -179,7 +179,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
179 |
* @param integer $flow_id Flow ID.
|
180 |
* @return array
|
181 |
*/
|
182 |
-
function get_flow_export_data( $flow_id ) {
|
183 |
|
184 |
$export_all = apply_filters( 'cartflows_export_all', false );
|
185 |
|
@@ -208,7 +208,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
208 |
foreach ( $all_meta as $meta_key => $value ) {
|
209 |
if ( substr( $meta_key, 0, strlen( 'wcf' ) ) === 'wcf' ) {
|
210 |
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
211 |
-
} elseif ( in_array( $meta_key, $valid_step_meta_keys ) ) {
|
212 |
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
213 |
}
|
214 |
}
|
@@ -246,7 +246,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
246 |
*
|
247 |
* @since 1.1.4
|
248 |
*/
|
249 |
-
function get_all_flow_export_data() {
|
250 |
|
251 |
$query_args = array(
|
252 |
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
@@ -273,12 +273,12 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
273 |
*
|
274 |
* @since 1.1.4
|
275 |
*/
|
276 |
-
function import_json() {
|
277 |
if ( empty( $_POST['cartflows-action'] ) || 'import' != $_POST['cartflows-action'] ) {
|
278 |
return;
|
279 |
}
|
280 |
|
281 |
-
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
282 |
return;
|
283 |
}
|
284 |
|
@@ -286,7 +286,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
286 |
return;
|
287 |
}
|
288 |
|
289 |
-
$filename = $_FILES['file']['name'];
|
290 |
$file_info = explode( '.', $filename );
|
291 |
$extension = end( $file_info );
|
292 |
|
@@ -294,14 +294,14 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
294 |
wp_die( __( 'Please upload a valid .json file', 'cartflows' ) );
|
295 |
}
|
296 |
|
297 |
-
$file = $_FILES['file']['tmp_name'];
|
298 |
|
299 |
if ( empty( $file ) ) {
|
300 |
wp_die( __( 'Please upload a file to import', 'cartflows' ) );
|
301 |
}
|
302 |
|
303 |
// Retrieve the settings from the file and convert the JSON object to an array.
|
304 |
-
$flows = json_decode( file_get_contents( $file ), true )
|
305 |
|
306 |
$this->import_from_json_data( $flows );
|
307 |
|
@@ -315,7 +315,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
315 |
* @param array $flows JSON array.
|
316 |
* @return void
|
317 |
*/
|
318 |
-
function import_from_json_data( $flows ) {
|
319 |
if ( $flows ) {
|
320 |
|
321 |
foreach ( $flows as $key => $flow ) {
|
@@ -422,7 +422,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
422 |
* @param string $content Mixed post content.
|
423 |
* @return array Hotlink image array.
|
424 |
*/
|
425 |
-
function get_content( $content = '' ) {
|
426 |
|
427 |
$all_links = wp_extract_urls( $content );
|
428 |
$image_links = array();
|
@@ -449,7 +449,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
449 |
// Download remote image.
|
450 |
$image = array(
|
451 |
'url' => $image_url,
|
452 |
-
'id' =>
|
453 |
);
|
454 |
$downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
|
455 |
|
@@ -471,7 +471,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
471 |
*
|
472 |
* @since 1.1.4
|
473 |
*/
|
474 |
-
function imported_successfully() {
|
475 |
?>
|
476 |
<div class="notice notice-success">
|
477 |
<p><?php _e( 'Successfully imported flows.', 'cartflows' ); ?></p>
|
@@ -498,7 +498,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
498 |
*
|
499 |
* @return void
|
500 |
*/
|
501 |
-
function js_templates() {
|
502 |
|
503 |
// Loading Templates.
|
504 |
?>
|
@@ -932,7 +932,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
932 |
* @hook admin_enqueue_scripts
|
933 |
* @param string $hook Current page hook.
|
934 |
*/
|
935 |
-
function scripts( $hook = '' ) {
|
936 |
|
937 |
if ( ! self::is_supported_post( get_current_screen()->post_type ) ) {
|
938 |
return;
|
@@ -1045,11 +1045,11 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1045 |
* @hook cartflows_load_steps
|
1046 |
* @return void
|
1047 |
*/
|
1048 |
-
function load_templates() {
|
1049 |
|
1050 |
check_ajax_referer( 'cf-load-steps', 'security' );
|
1051 |
|
1052 |
-
$args = ( isset( $_POST['args'] ) ) ? array_map( 'sanitize_text_field', $_POST['args'] ) : array();
|
1053 |
$templates = CartFlows_API::get_instance()->get_templates( $args );
|
1054 |
|
1055 |
if ( $templates['templates_count'] ) {
|
@@ -1068,7 +1068,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1068 |
* @hook wp_ajax_cartflows_import_flow_step
|
1069 |
* @return void
|
1070 |
*/
|
1071 |
-
function import_flow() {
|
1072 |
|
1073 |
check_ajax_referer( 'cf-import-flow-step', 'security' );
|
1074 |
|
@@ -1094,7 +1094,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1094 |
wp_send_json_error( $response );
|
1095 |
}
|
1096 |
|
1097 |
-
wcf()->logger->import_log( '(✓) Successfully getting remote step response ' .
|
1098 |
|
1099 |
$new_step_id = wp_insert_post(
|
1100 |
array(
|
@@ -1119,7 +1119,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1119 |
/* Imported Step */
|
1120 |
update_post_meta( $new_step_id, 'cartflows_imported_step', 'yes' );
|
1121 |
|
1122 |
-
wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id )
|
1123 |
// insert post meta.
|
1124 |
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
1125 |
wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' );
|
@@ -1180,7 +1180,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1180 |
'type' => $term_slug,
|
1181 |
);
|
1182 |
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1183 |
-
wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' .
|
1184 |
|
1185 |
// Import Post Meta.
|
1186 |
self::import_post_meta( $new_step_id, $response );
|
@@ -1210,7 +1210,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1210 |
*
|
1211 |
* @return void
|
1212 |
*/
|
1213 |
-
function create_default_flow() {
|
1214 |
|
1215 |
check_ajax_referer( 'cf-default-flow', 'security' );
|
1216 |
|
@@ -1306,7 +1306,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1306 |
*
|
1307 |
* @return void
|
1308 |
*/
|
1309 |
-
function create_flow() {
|
1310 |
|
1311 |
check_ajax_referer( 'cf-create-flow', 'security' );
|
1312 |
|
@@ -1335,15 +1335,15 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1335 |
*
|
1336 |
* @return void
|
1337 |
*/
|
1338 |
-
function import_step() {
|
1339 |
|
1340 |
check_ajax_referer( 'cf-step-import', 'security' );
|
1341 |
|
1342 |
$template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
|
1343 |
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1344 |
-
$step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
|
1345 |
-
$step_type = isset( $_POST['step_type'] ) ? sanitize_title( $_POST['step_type'] ) : '';
|
1346 |
-
$step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( $_POST['step_custom_title'] ) : $step_title;
|
1347 |
|
1348 |
$cartflow_meta = Cartflows_Flow_Meta::get_instance();
|
1349 |
|
@@ -1403,13 +1403,13 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1403 |
*
|
1404 |
* @return void
|
1405 |
*/
|
1406 |
-
function step_create_blank() {
|
1407 |
|
1408 |
check_ajax_referer( 'cf-step-create-blank', 'security' );
|
1409 |
|
1410 |
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1411 |
-
$step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( $_POST['step_type'] ) : '';
|
1412 |
-
$step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
|
1413 |
|
1414 |
if ( empty( $flow_id ) || empty( $step_type ) ) {
|
1415 |
/* translators: %s: flow ID */
|
@@ -1506,14 +1506,14 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1506 |
|
1507 |
if ( '_elementor_data' === $meta_key ) {
|
1508 |
if ( is_array( $raw_data ) ) {
|
1509 |
-
$raw_data = wp_slash(
|
1510 |
} else {
|
1511 |
$raw_data = wp_slash( $raw_data );
|
1512 |
}
|
1513 |
}
|
1514 |
if ( '_elementor_data' !== $meta_key && '_elementor_draft' !== $meta_key && '_fl_builder_data' !== $meta_key && '_fl_builder_draft' !== $meta_key ) {
|
1515 |
if ( is_array( $raw_data ) ) {
|
1516 |
-
wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' .
|
1517 |
} else {
|
1518 |
if ( ! is_object( $raw_data ) ) {
|
1519 |
wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data );
|
@@ -1578,7 +1578,8 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1578 |
* @return boolean Supported post type status.
|
1579 |
*/
|
1580 |
public static function is_supported_post( $post_type = '' ) {
|
1581 |
-
|
|
|
1582 |
return true;
|
1583 |
}
|
1584 |
|
@@ -1593,7 +1594,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1593 |
* @param string $step_title Flow Type.
|
1594 |
* @param string $step_slug Flow Type.
|
1595 |
*/
|
1596 |
-
function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) {
|
1597 |
// Update steps for the current flow.
|
1598 |
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
1599 |
|
@@ -1607,7 +1608,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1607 |
'type' => $step_slug,
|
1608 |
);
|
1609 |
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1610 |
-
wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' .
|
1611 |
}
|
1612 |
|
1613 |
/**
|
@@ -1615,7 +1616,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1615 |
*
|
1616 |
* @param array $vars variables.
|
1617 |
*/
|
1618 |
-
function localize_vars( $vars ) {
|
1619 |
|
1620 |
$ajax_actions = array(
|
1621 |
'cf_step_import',
|
@@ -1652,7 +1653,7 @@ if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
|
1652 |
);
|
1653 |
}
|
1654 |
|
1655 |
-
$plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( $_POST['plugin_init'] ) : '';
|
1656 |
|
1657 |
$activate = activate_plugin( $plugin_init, '', false, true );
|
1658 |
|
75 |
*
|
76 |
* @return array
|
77 |
*/
|
78 |
+
public function export_link( $actions, $post ) {
|
79 |
if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
80 |
$actions['export'] = '<a href="' . wp_nonce_url( 'admin.php?action=cartflows_export_flow&post=' . $post->ID, basename( __FILE__ ), 'flow_export_nonce' ) . '" title="' . __( 'Export this flow', 'cartflows' ) . '" rel="permalink">' . __( 'Export', 'cartflows' ) . '</a>';
|
81 |
}
|
87 |
*
|
88 |
* @since 1.1.4
|
89 |
*/
|
90 |
+
public function add_to_menus() {
|
91 |
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Export', 'cartflows' ), __( 'Flow Export', 'cartflows' ), 'export', 'flow_exporter', array( $this, 'exporter_markup' ) );
|
92 |
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Import', 'cartflows' ), __( 'Flow Import', 'cartflows' ), 'import', 'flow_importer', array( $this, 'importer_markup' ) );
|
93 |
}
|
97 |
*
|
98 |
* @since 1.1.4
|
99 |
*/
|
100 |
+
public function export_flow() {
|
101 |
|
102 |
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_export_flow' == $_REQUEST['action'] ) ) ) {
|
103 |
wp_die( __( 'No post to export has been supplied!', 'cartflows' ) );
|
104 |
}
|
105 |
|
106 |
+
if ( ! isset( $_GET['flow_export_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['flow_export_nonce'] ), basename( __FILE__ ) ) ) {
|
107 |
return;
|
108 |
}
|
109 |
|
116 |
|
117 |
nocache_headers();
|
118 |
header( 'Content-Type: application/json; charset=utf-8' );
|
119 |
+
header( 'Content-Disposition: attachment; filename=cartflows-flow-' . $flow_id . '-' . gmdate( 'm-d-Y' ) . '.json' );
|
120 |
header( 'Expires: 0' );
|
121 |
|
122 |
+
echo wp_json_encode( $flows );
|
123 |
exit;
|
124 |
}
|
125 |
|
128 |
*
|
129 |
* @since 1.1.4
|
130 |
*/
|
131 |
+
public function exporter_markup() {
|
132 |
include_once CARTFLOWS_DIR . 'includes/exporter.php';
|
133 |
}
|
134 |
|
137 |
*
|
138 |
* @since 1.1.4
|
139 |
*/
|
140 |
+
public function importer_markup() {
|
141 |
include_once CARTFLOWS_DIR . 'includes/importer.php';
|
142 |
}
|
143 |
|
146 |
*
|
147 |
* @since 1.1.4
|
148 |
*/
|
149 |
+
public function export_json() {
|
150 |
if ( empty( $_POST['cartflows-action'] ) || 'export' != $_POST['cartflows-action'] ) {
|
151 |
return;
|
152 |
}
|
153 |
|
154 |
+
if ( isset( $_POST['cartflows-action-nonce'] ) && ! wp_verify_nonce( wp_unslash( $_POST['cartflows-action-nonce'] ), 'cartflows-action-nonce' ) ) {
|
155 |
return;
|
156 |
}
|
157 |
|
164 |
|
165 |
nocache_headers();
|
166 |
header( 'Content-Type: application/json; charset=utf-8' );
|
167 |
+
header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . gmdate( 'm-d-Y' ) . '.json' );
|
168 |
header( 'Expires: 0' );
|
169 |
|
170 |
+
echo wp_json_encode( $flows );
|
171 |
exit;
|
172 |
}
|
173 |
|
179 |
* @param integer $flow_id Flow ID.
|
180 |
* @return array
|
181 |
*/
|
182 |
+
public function get_flow_export_data( $flow_id ) {
|
183 |
|
184 |
$export_all = apply_filters( 'cartflows_export_all', false );
|
185 |
|
208 |
foreach ( $all_meta as $meta_key => $value ) {
|
209 |
if ( substr( $meta_key, 0, strlen( 'wcf' ) ) === 'wcf' ) {
|
210 |
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
211 |
+
} elseif ( in_array( $meta_key, $valid_step_meta_keys, true ) ) {
|
212 |
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
213 |
}
|
214 |
}
|
246 |
*
|
247 |
* @since 1.1.4
|
248 |
*/
|
249 |
+
public function get_all_flow_export_data() {
|
250 |
|
251 |
$query_args = array(
|
252 |
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
273 |
*
|
274 |
* @since 1.1.4
|
275 |
*/
|
276 |
+
public function import_json() {
|
277 |
if ( empty( $_POST['cartflows-action'] ) || 'import' != $_POST['cartflows-action'] ) {
|
278 |
return;
|
279 |
}
|
280 |
|
281 |
+
if ( isset( $_POST['cartflows-action-nonce'] ) && ! wp_verify_nonce( wp_unslash( $_POST['cartflows-action-nonce'] ), 'cartflows-action-nonce' ) ) {
|
282 |
return;
|
283 |
}
|
284 |
|
286 |
return;
|
287 |
}
|
288 |
|
289 |
+
$filename = $_FILES['file']['name']; //phpcs:ignore
|
290 |
$file_info = explode( '.', $filename );
|
291 |
$extension = end( $file_info );
|
292 |
|
294 |
wp_die( __( 'Please upload a valid .json file', 'cartflows' ) );
|
295 |
}
|
296 |
|
297 |
+
$file = $_FILES['file']['tmp_name']; //phpcs:ignore
|
298 |
|
299 |
if ( empty( $file ) ) {
|
300 |
wp_die( __( 'Please upload a file to import', 'cartflows' ) );
|
301 |
}
|
302 |
|
303 |
// Retrieve the settings from the file and convert the JSON object to an array.
|
304 |
+
$flows = json_decode( file_get_contents( $file ), true );//phpcs:ignore
|
305 |
|
306 |
$this->import_from_json_data( $flows );
|
307 |
|
315 |
* @param array $flows JSON array.
|
316 |
* @return void
|
317 |
*/
|
318 |
+
public function import_from_json_data( $flows ) {
|
319 |
if ( $flows ) {
|
320 |
|
321 |
foreach ( $flows as $key => $flow ) {
|
422 |
* @param string $content Mixed post content.
|
423 |
* @return array Hotlink image array.
|
424 |
*/
|
425 |
+
public function get_content( $content = '' ) {
|
426 |
|
427 |
$all_links = wp_extract_urls( $content );
|
428 |
$image_links = array();
|
449 |
// Download remote image.
|
450 |
$image = array(
|
451 |
'url' => $image_url,
|
452 |
+
'id' => wp_rand( 000, 999 ),
|
453 |
);
|
454 |
$downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
|
455 |
|
471 |
*
|
472 |
* @since 1.1.4
|
473 |
*/
|
474 |
+
public function imported_successfully() {
|
475 |
?>
|
476 |
<div class="notice notice-success">
|
477 |
<p><?php _e( 'Successfully imported flows.', 'cartflows' ); ?></p>
|
498 |
*
|
499 |
* @return void
|
500 |
*/
|
501 |
+
public function js_templates() {
|
502 |
|
503 |
// Loading Templates.
|
504 |
?>
|
932 |
* @hook admin_enqueue_scripts
|
933 |
* @param string $hook Current page hook.
|
934 |
*/
|
935 |
+
public function scripts( $hook = '' ) {
|
936 |
|
937 |
if ( ! self::is_supported_post( get_current_screen()->post_type ) ) {
|
938 |
return;
|
1045 |
* @hook cartflows_load_steps
|
1046 |
* @return void
|
1047 |
*/
|
1048 |
+
public function load_templates() {
|
1049 |
|
1050 |
check_ajax_referer( 'cf-load-steps', 'security' );
|
1051 |
|
1052 |
+
$args = ( isset( $_POST['args'] ) ) ? array_map( 'sanitize_text_field', $_POST['args'] ) : array(); //phpcs:ignore
|
1053 |
$templates = CartFlows_API::get_instance()->get_templates( $args );
|
1054 |
|
1055 |
if ( $templates['templates_count'] ) {
|
1068 |
* @hook wp_ajax_cartflows_import_flow_step
|
1069 |
* @return void
|
1070 |
*/
|
1071 |
+
public function import_flow() {
|
1072 |
|
1073 |
check_ajax_referer( 'cf-import-flow-step', 'security' );
|
1074 |
|
1094 |
wp_send_json_error( $response );
|
1095 |
}
|
1096 |
|
1097 |
+
wcf()->logger->import_log( '(✓) Successfully getting remote step response ' . wp_json_encode( $response ) );
|
1098 |
|
1099 |
$new_step_id = wp_insert_post(
|
1100 |
array(
|
1119 |
/* Imported Step */
|
1120 |
update_post_meta( $new_step_id, 'cartflows_imported_step', 'yes' );
|
1121 |
|
1122 |
+
wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id );//phpcs:ignore
|
1123 |
// insert post meta.
|
1124 |
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
1125 |
wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' );
|
1180 |
'type' => $term_slug,
|
1181 |
);
|
1182 |
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1183 |
+
wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . wp_json_encode( $flow_steps ) );
|
1184 |
|
1185 |
// Import Post Meta.
|
1186 |
self::import_post_meta( $new_step_id, $response );
|
1210 |
*
|
1211 |
* @return void
|
1212 |
*/
|
1213 |
+
public function create_default_flow() {
|
1214 |
|
1215 |
check_ajax_referer( 'cf-default-flow', 'security' );
|
1216 |
|
1306 |
*
|
1307 |
* @return void
|
1308 |
*/
|
1309 |
+
public function create_flow() {
|
1310 |
|
1311 |
check_ajax_referer( 'cf-create-flow', 'security' );
|
1312 |
|
1335 |
*
|
1336 |
* @return void
|
1337 |
*/
|
1338 |
+
public function import_step() {
|
1339 |
|
1340 |
check_ajax_referer( 'cf-step-import', 'security' );
|
1341 |
|
1342 |
$template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
|
1343 |
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1344 |
+
$step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( wp_unslash( $_POST['step_title'] ) ) : '';
|
1345 |
+
$step_type = isset( $_POST['step_type'] ) ? sanitize_title( wp_unslash( $_POST['step_type'] ) ) : '';
|
1346 |
+
$step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( wp_unslash( $_POST['step_custom_title'] ) ) : $step_title;
|
1347 |
|
1348 |
$cartflow_meta = Cartflows_Flow_Meta::get_instance();
|
1349 |
|
1403 |
*
|
1404 |
* @return void
|
1405 |
*/
|
1406 |
+
public function step_create_blank() {
|
1407 |
|
1408 |
check_ajax_referer( 'cf-step-create-blank', 'security' );
|
1409 |
|
1410 |
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1411 |
+
$step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( wp_unslash( $_POST['step_type'] ) ) : '';
|
1412 |
+
$step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( wp_unslash( $_POST['step_title'] ) ) : '';
|
1413 |
|
1414 |
if ( empty( $flow_id ) || empty( $step_type ) ) {
|
1415 |
/* translators: %s: flow ID */
|
1506 |
|
1507 |
if ( '_elementor_data' === $meta_key ) {
|
1508 |
if ( is_array( $raw_data ) ) {
|
1509 |
+
$raw_data = wp_slash( wp_json_encode( $raw_data ) );
|
1510 |
} else {
|
1511 |
$raw_data = wp_slash( $raw_data );
|
1512 |
}
|
1513 |
}
|
1514 |
if ( '_elementor_data' !== $meta_key && '_elementor_draft' !== $meta_key && '_fl_builder_data' !== $meta_key && '_fl_builder_draft' !== $meta_key ) {
|
1515 |
if ( is_array( $raw_data ) ) {
|
1516 |
+
wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . wp_json_encode( $raw_data ) );
|
1517 |
} else {
|
1518 |
if ( ! is_object( $raw_data ) ) {
|
1519 |
wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data );
|
1578 |
* @return boolean Supported post type status.
|
1579 |
*/
|
1580 |
public static function is_supported_post( $post_type = '' ) {
|
1581 |
+
|
1582 |
+
if ( in_array( $post_type, self::supported_post_types(), true ) ) {
|
1583 |
return true;
|
1584 |
}
|
1585 |
|
1594 |
* @param string $step_title Flow Type.
|
1595 |
* @param string $step_slug Flow Type.
|
1596 |
*/
|
1597 |
+
public function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) {
|
1598 |
// Update steps for the current flow.
|
1599 |
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
1600 |
|
1608 |
'type' => $step_slug,
|
1609 |
);
|
1610 |
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1611 |
+
wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . wp_json_encode( $flow_steps ) );
|
1612 |
}
|
1613 |
|
1614 |
/**
|
1616 |
*
|
1617 |
* @param array $vars variables.
|
1618 |
*/
|
1619 |
+
public function localize_vars( $vars ) {
|
1620 |
|
1621 |
$ajax_actions = array(
|
1622 |
'cf_step_import',
|
1653 |
);
|
1654 |
}
|
1655 |
|
1656 |
+
$plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin_init'] ) ) : '';
|
1657 |
|
1658 |
$activate = activate_plugin( $plugin_init, '', false, true );
|
1659 |
|
classes/class-cartflows-learndash-compatibility.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* LearnDash compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class for LearnDash compatibility
|
10 |
-
*/
|
11 |
-
class Cartflows_Learndash_Compatibility {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Member Variable
|
15 |
-
*
|
16 |
-
* @var instance
|
17 |
-
*/
|
18 |
-
private static $instance;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Initiator
|
22 |
-
*/
|
23 |
-
public static function get_instance() {
|
24 |
-
if ( ! isset( self::$instance ) ) {
|
25 |
-
self::$instance = new self();
|
26 |
-
}
|
27 |
-
return self::$instance;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Constructor
|
32 |
-
*/
|
33 |
-
public function __construct() {
|
34 |
-
add_filter( 'learndash_post_args', array( $this, 'cartflows_course_setting_fields' ) );
|
35 |
-
add_action( 'template_redirect', array( $this, 'cartflows_override_course_template' ) );
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Override course cartflows template.
|
41 |
-
*
|
42 |
-
* @return bool
|
43 |
-
*/
|
44 |
-
public function cartflows_override_course_template() {
|
45 |
-
|
46 |
-
// Don't run any code in admin area.
|
47 |
-
if ( is_admin() ) {
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
|
51 |
-
// Don't override the template if the post type is not `course`.
|
52 |
-
if ( ! is_singular( 'sfwd-courses' ) ) {
|
53 |
-
return false;
|
54 |
-
}
|
55 |
-
|
56 |
-
$course_id = learndash_get_course_id();
|
57 |
-
$user_id = get_current_user_id();
|
58 |
-
if ( is_user_logged_in() && sfwd_lms_has_access( $course_id, $user_id ) ) {
|
59 |
-
return false;
|
60 |
-
}
|
61 |
-
|
62 |
-
$template = get_course_meta_setting( get_the_id(), 'wcf_course_template' );
|
63 |
-
if ( 'none' !== $template && $template ) {
|
64 |
-
$link = get_permalink( $template );
|
65 |
-
wp_safe_redirect( $link );
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Add settings inside learndash settings.
|
71 |
-
*
|
72 |
-
* @param array $fields fields.
|
73 |
-
* @return mixed
|
74 |
-
*/
|
75 |
-
public function cartflows_course_setting_fields( $fields ) {
|
76 |
-
global $post;
|
77 |
-
|
78 |
-
$all_posts = array(
|
79 |
-
'none' => __( 'None', 'cartflows' ),
|
80 |
-
);
|
81 |
-
|
82 |
-
$landing_steps = get_posts(
|
83 |
-
array(
|
84 |
-
'posts_per_page' => -1,
|
85 |
-
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
86 |
-
'post_status' => 'publish',
|
87 |
-
'orderby' => 'ID',
|
88 |
-
'order' => 'DESC',
|
89 |
-
'meta_query' => array(
|
90 |
-
array(
|
91 |
-
'key' => 'wcf-step-type',
|
92 |
-
'value' => array( 'landing', 'checkout' ),
|
93 |
-
'compare' => 'IN',
|
94 |
-
),
|
95 |
-
),
|
96 |
-
)
|
97 |
-
);
|
98 |
-
|
99 |
-
foreach ( $landing_steps as $landing_step ) {
|
100 |
-
$all_posts[ $landing_step->ID ] = get_the_title( $landing_step->ID ) . ' ( #' . $landing_step->ID . ')';
|
101 |
-
}
|
102 |
-
|
103 |
-
$selected = get_post_meta( get_the_ID(), 'wcf_course_template', true );
|
104 |
-
$description = sprintf(
|
105 |
-
/* translators: 1: anchor start, 2: anchor close */
|
106 |
-
__( 'Non-enrolled students will redirect to the selected CartFlows template. If you have not created any Flow already, add new Flow from %1$shere%2$s.', 'cartflows' ),
|
107 |
-
'<a href="' . esc_url( admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&add-new-flow' ) ) . '">',
|
108 |
-
'</a>'
|
109 |
-
);
|
110 |
-
|
111 |
-
$fields['sfwd-courses']['fields']['wcf_course_template'] = array(
|
112 |
-
'name' => __( 'Select CartFlows Template for this Course', 'cartflows' ),
|
113 |
-
'type' => 'select',
|
114 |
-
'initial_options' => $all_posts,
|
115 |
-
'default' => 'none',
|
116 |
-
'help_text' => $description,
|
117 |
-
'show_in_rest' => true,
|
118 |
-
'rest_args' => array(
|
119 |
-
'schema' => array(
|
120 |
-
'type' => 'string',
|
121 |
-
),
|
122 |
-
),
|
123 |
-
);
|
124 |
-
|
125 |
-
return $fields;
|
126 |
-
}
|
127 |
-
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Kicking this off by calling 'get_instance()' method
|
132 |
-
*/
|
133 |
-
Cartflows_Learndash_Compatibility::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LearnDash compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class for LearnDash compatibility
|
10 |
+
*/
|
11 |
+
class Cartflows_Learndash_Compatibility {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Member Variable
|
15 |
+
*
|
16 |
+
* @var instance
|
17 |
+
*/
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Initiator
|
22 |
+
*/
|
23 |
+
public static function get_instance() {
|
24 |
+
if ( ! isset( self::$instance ) ) {
|
25 |
+
self::$instance = new self();
|
26 |
+
}
|
27 |
+
return self::$instance;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Constructor
|
32 |
+
*/
|
33 |
+
public function __construct() {
|
34 |
+
add_filter( 'learndash_post_args', array( $this, 'cartflows_course_setting_fields' ) );
|
35 |
+
add_action( 'template_redirect', array( $this, 'cartflows_override_course_template' ) );
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Override course cartflows template.
|
41 |
+
*
|
42 |
+
* @return bool
|
43 |
+
*/
|
44 |
+
public function cartflows_override_course_template() {
|
45 |
+
|
46 |
+
// Don't run any code in admin area.
|
47 |
+
if ( is_admin() ) {
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
// Don't override the template if the post type is not `course`.
|
52 |
+
if ( ! is_singular( 'sfwd-courses' ) ) {
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
|
56 |
+
$course_id = learndash_get_course_id();
|
57 |
+
$user_id = get_current_user_id();
|
58 |
+
if ( is_user_logged_in() && sfwd_lms_has_access( $course_id, $user_id ) ) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
$template = get_course_meta_setting( get_the_id(), 'wcf_course_template' );
|
63 |
+
if ( 'none' !== $template && $template ) {
|
64 |
+
$link = get_permalink( $template );
|
65 |
+
wp_safe_redirect( $link );
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Add settings inside learndash settings.
|
71 |
+
*
|
72 |
+
* @param array $fields fields.
|
73 |
+
* @return mixed
|
74 |
+
*/
|
75 |
+
public function cartflows_course_setting_fields( $fields ) {
|
76 |
+
global $post;
|
77 |
+
|
78 |
+
$all_posts = array(
|
79 |
+
'none' => __( 'None', 'cartflows' ),
|
80 |
+
);
|
81 |
+
|
82 |
+
$landing_steps = get_posts(
|
83 |
+
array(
|
84 |
+
'posts_per_page' => -1,
|
85 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
86 |
+
'post_status' => 'publish',
|
87 |
+
'orderby' => 'ID',
|
88 |
+
'order' => 'DESC',
|
89 |
+
'meta_query' => array( //phpcs:ignore
|
90 |
+
array(
|
91 |
+
'key' => 'wcf-step-type',
|
92 |
+
'value' => array( 'landing', 'checkout' ),
|
93 |
+
'compare' => 'IN',
|
94 |
+
),
|
95 |
+
),
|
96 |
+
)
|
97 |
+
);
|
98 |
+
|
99 |
+
foreach ( $landing_steps as $landing_step ) {
|
100 |
+
$all_posts[ $landing_step->ID ] = get_the_title( $landing_step->ID ) . ' ( #' . $landing_step->ID . ')';
|
101 |
+
}
|
102 |
+
|
103 |
+
$selected = get_post_meta( get_the_ID(), 'wcf_course_template', true );
|
104 |
+
$description = sprintf(
|
105 |
+
/* translators: 1: anchor start, 2: anchor close */
|
106 |
+
__( 'Non-enrolled students will redirect to the selected CartFlows template. If you have not created any Flow already, add new Flow from %1$shere%2$s.', 'cartflows' ),
|
107 |
+
'<a href="' . esc_url( admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&add-new-flow' ) ) . '">',
|
108 |
+
'</a>'
|
109 |
+
);
|
110 |
+
|
111 |
+
$fields['sfwd-courses']['fields']['wcf_course_template'] = array(
|
112 |
+
'name' => __( 'Select CartFlows Template for this Course', 'cartflows' ),
|
113 |
+
'type' => 'select',
|
114 |
+
'initial_options' => $all_posts,
|
115 |
+
'default' => 'none',
|
116 |
+
'help_text' => $description,
|
117 |
+
'show_in_rest' => true,
|
118 |
+
'rest_args' => array(
|
119 |
+
'schema' => array(
|
120 |
+
'type' => 'string',
|
121 |
+
),
|
122 |
+
),
|
123 |
+
);
|
124 |
+
|
125 |
+
return $fields;
|
126 |
+
}
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Kicking this off by calling 'get_instance()' method
|
132 |
+
*/
|
133 |
+
Cartflows_Learndash_Compatibility::get_instance();
|
classes/class-cartflows-loader.php
CHANGED
@@ -126,7 +126,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
126 |
define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
|
127 |
define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
|
128 |
define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
|
129 |
-
define( 'CARTFLOWS_VER', '1.3.
|
130 |
define( 'CARTFLOWS_SLUG', 'cartflows' );
|
131 |
define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
|
132 |
|
@@ -166,12 +166,8 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
166 |
*
|
167 |
* @return void
|
168 |
*/
|
169 |
-
function load_plugin() {
|
170 |
|
171 |
-
// if ( ! function_exists( 'WC' ) ) {.
|
172 |
-
// add_action( 'admin_notices', array( $this, 'fails_to_load' ) );.
|
173 |
-
// return;.
|
174 |
-
// }.
|
175 |
$this->load_helper_files_components();
|
176 |
$this->load_core_files();
|
177 |
$this->load_core_components();
|
@@ -200,7 +196,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
200 |
*
|
201 |
* @return void
|
202 |
*/
|
203 |
-
function after_cartflows_pro_init() {
|
204 |
|
205 |
if ( ! is_admin() ) {
|
206 |
return;
|
@@ -220,7 +216,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
220 |
*
|
221 |
* @return void
|
222 |
*/
|
223 |
-
function required_cartflows_pro_notice() {
|
224 |
|
225 |
$required_pro_version = '1.2.0';
|
226 |
|
@@ -238,7 +234,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
238 |
*
|
239 |
* @return void
|
240 |
*/
|
241 |
-
function licence_setup() {
|
242 |
|
243 |
if ( version_compare( CARTFLOWS_PRO_VER, '1.1.13', '<' ) ) {
|
244 |
|
@@ -255,7 +251,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
255 |
*
|
256 |
* @return void
|
257 |
*/
|
258 |
-
function load_helper_files_components() {
|
259 |
|
260 |
$this->is_woo_active = function_exists( 'WC' );
|
261 |
|
@@ -265,7 +261,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
265 |
/* Public Session */
|
266 |
include_once CARTFLOWS_DIR . 'classes/class-cartflows-session.php';
|
267 |
|
268 |
-
/* Public Global
|
269 |
include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
|
270 |
|
271 |
/* Admin Helper */
|
@@ -286,7 +282,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
286 |
*
|
287 |
* @return void
|
288 |
*/
|
289 |
-
function initialize() {
|
290 |
$this->assets_vars = $this->utils->get_assets_path();
|
291 |
}
|
292 |
|
@@ -297,7 +293,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
297 |
*
|
298 |
* @return void
|
299 |
*/
|
300 |
-
function load_core_files() {
|
301 |
|
302 |
/* Update compatibility. */
|
303 |
require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
|
@@ -364,7 +360,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
364 |
*
|
365 |
* @return void
|
366 |
*/
|
367 |
-
function load_core_components() {
|
368 |
|
369 |
$this->meta = Cartflows_Meta_Fields::get_instance();
|
370 |
$this->logger = Cartflows_Logger::get_instance();
|
@@ -374,7 +370,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
374 |
/**
|
375 |
* Create files/directories.
|
376 |
*/
|
377 |
-
function create_files() {
|
378 |
|
379 |
// Install files and folders for uploading files and prevent hotlinking.
|
380 |
$upload_dir = wp_upload_dir();
|
@@ -394,7 +390,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
394 |
|
395 |
foreach ( $files as $file ) {
|
396 |
if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
|
397 |
-
$file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore
|
398 |
if ( $file_handle ) {
|
399 |
fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
|
400 |
fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
|
@@ -512,7 +508,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
512 |
/**
|
513 |
* Activation Reset
|
514 |
*/
|
515 |
-
function activation_reset() {
|
516 |
|
517 |
if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) {
|
518 |
|
@@ -534,13 +530,13 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
534 |
/**
|
535 |
* Deactivation Reset
|
536 |
*/
|
537 |
-
function deactivation_reset() {
|
538 |
}
|
539 |
|
540 |
/**
|
541 |
* Logger Class Instance
|
542 |
*/
|
543 |
-
function logger() {
|
544 |
return Cartflows_Logger::get_instance();
|
545 |
}
|
546 |
|
126 |
define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
|
127 |
define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
|
128 |
define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
|
129 |
+
define( 'CARTFLOWS_VER', '1.3.2' );
|
130 |
define( 'CARTFLOWS_SLUG', 'cartflows' );
|
131 |
define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
|
132 |
|
166 |
*
|
167 |
* @return void
|
168 |
*/
|
169 |
+
public function load_plugin() {
|
170 |
|
|
|
|
|
|
|
|
|
171 |
$this->load_helper_files_components();
|
172 |
$this->load_core_files();
|
173 |
$this->load_core_components();
|
196 |
*
|
197 |
* @return void
|
198 |
*/
|
199 |
+
public function after_cartflows_pro_init() {
|
200 |
|
201 |
if ( ! is_admin() ) {
|
202 |
return;
|
216 |
*
|
217 |
* @return void
|
218 |
*/
|
219 |
+
public function required_cartflows_pro_notice() {
|
220 |
|
221 |
$required_pro_version = '1.2.0';
|
222 |
|
234 |
*
|
235 |
* @return void
|
236 |
*/
|
237 |
+
public function licence_setup() {
|
238 |
|
239 |
if ( version_compare( CARTFLOWS_PRO_VER, '1.1.13', '<' ) ) {
|
240 |
|
251 |
*
|
252 |
* @return void
|
253 |
*/
|
254 |
+
public function load_helper_files_components() {
|
255 |
|
256 |
$this->is_woo_active = function_exists( 'WC' );
|
257 |
|
261 |
/* Public Session */
|
262 |
include_once CARTFLOWS_DIR . 'classes/class-cartflows-session.php';
|
263 |
|
264 |
+
/* Public Global Namespace Function */
|
265 |
include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
|
266 |
|
267 |
/* Admin Helper */
|
282 |
*
|
283 |
* @return void
|
284 |
*/
|
285 |
+
public function initialize() {
|
286 |
$this->assets_vars = $this->utils->get_assets_path();
|
287 |
}
|
288 |
|
293 |
*
|
294 |
* @return void
|
295 |
*/
|
296 |
+
public function load_core_files() {
|
297 |
|
298 |
/* Update compatibility. */
|
299 |
require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
|
360 |
*
|
361 |
* @return void
|
362 |
*/
|
363 |
+
public function load_core_components() {
|
364 |
|
365 |
$this->meta = Cartflows_Meta_Fields::get_instance();
|
366 |
$this->logger = Cartflows_Logger::get_instance();
|
370 |
/**
|
371 |
* Create files/directories.
|
372 |
*/
|
373 |
+
public function create_files() {
|
374 |
|
375 |
// Install files and folders for uploading files and prevent hotlinking.
|
376 |
$upload_dir = wp_upload_dir();
|
390 |
|
391 |
foreach ( $files as $file ) {
|
392 |
if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
|
393 |
+
$file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore
|
394 |
if ( $file_handle ) {
|
395 |
fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
|
396 |
fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
|
508 |
/**
|
509 |
* Activation Reset
|
510 |
*/
|
511 |
+
public function activation_reset() {
|
512 |
|
513 |
if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) {
|
514 |
|
530 |
/**
|
531 |
* Deactivation Reset
|
532 |
*/
|
533 |
+
public function deactivation_reset() {
|
534 |
}
|
535 |
|
536 |
/**
|
537 |
* Logger Class Instance
|
538 |
*/
|
539 |
+
public function logger() {
|
540 |
return Cartflows_Logger::get_instance();
|
541 |
}
|
542 |
|
classes/class-cartflows-logger.php
CHANGED
@@ -1,183 +1,183 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Logger.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Logger {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Member Variable
|
25 |
-
*
|
26 |
-
* @var logger
|
27 |
-
*/
|
28 |
-
public $logger;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Initiator
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
if ( ! isset( self::$instance ) ) {
|
35 |
-
self::$instance = new self();
|
36 |
-
}
|
37 |
-
return self::$instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor
|
42 |
-
*/
|
43 |
-
public function __construct() {
|
44 |
-
|
45 |
-
/* Load WC Logger */
|
46 |
-
add_action( 'init', array( $this, 'init_wc_logger' ), 99 );
|
47 |
-
|
48 |
-
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
49 |
-
|
50 |
-
if ( CARTFLOWS_SETTINGS === $page ) {
|
51 |
-
add_filter( 'admin_footer_text', array( $this, 'add_footer_link' ), 99 );
|
52 |
-
}
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Add footer link.
|
58 |
-
*/
|
59 |
-
function add_footer_link() {
|
60 |
-
$settings_url = add_query_arg(
|
61 |
-
array(
|
62 |
-
'page' => CARTFLOWS_SETTINGS,
|
63 |
-
'cartflows-error-log' => 1,
|
64 |
-
),
|
65 |
-
admin_url( '/admin.php' )
|
66 |
-
);
|
67 |
-
|
68 |
-
echo '<span id="footer-thankyou"> Thank you for using <a href="https://cartflows.com/">CartFlows</a></span> | <a href="' . $settings_url . '"> View Logs </a>';
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Inint Logger.
|
73 |
-
*
|
74 |
-
* @since 1.0.0
|
75 |
-
*/
|
76 |
-
function init_wc_logger() {
|
77 |
-
if ( class_exists( 'CartFlows_WC_Logger' ) ) {
|
78 |
-
$this->logger = new CartFlows_WC_Logger();
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Write log
|
84 |
-
*
|
85 |
-
* @param string $message log message.
|
86 |
-
* @param string $level type of log.
|
87 |
-
* @since 1.0.0
|
88 |
-
*/
|
89 |
-
function log( $message, $level = 'info' ) {
|
90 |
-
|
91 |
-
$enable_log = apply_filters( 'cartflows_enable_log', 'enable' );
|
92 |
-
|
93 |
-
if ( 'enable' === $enable_log &&
|
94 |
-
is_a( $this->logger, 'CartFlows_WC_Logger' ) &&
|
95 |
-
did_action( 'plugins_loaded' )
|
96 |
-
) {
|
97 |
-
|
98 |
-
$this->logger->log( $level, $message, array( 'source' => 'cartflows' ) );
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Write log
|
104 |
-
*
|
105 |
-
* @param string $message log message.
|
106 |
-
* @param string $level type of log.
|
107 |
-
* @since 1.0.0
|
108 |
-
*/
|
109 |
-
function import_log( $message, $level = 'info' ) {
|
110 |
-
|
111 |
-
if ( defined( 'WP_DEBUG' ) &&
|
112 |
-
WP_DEBUG &&
|
113 |
-
is_a( $this->logger, 'CartFlows_WC_Logger' ) &&
|
114 |
-
did_action( 'plugins_loaded' )
|
115 |
-
) {
|
116 |
-
|
117 |
-
$this->logger->log( $level, $message, array( 'source' => 'cartflows-import' ) );
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Get all log files in the log directory.
|
123 |
-
*
|
124 |
-
* @return array
|
125 |
-
*/
|
126 |
-
public static function get_log_files() {
|
127 |
-
$files = scandir( CARTFLOWS_LOG_DIR );
|
128 |
-
$result = array();
|
129 |
-
|
130 |
-
if ( ! empty( $files ) ) {
|
131 |
-
foreach ( $files as $key => $value ) {
|
132 |
-
if ( ! in_array( $value, array( '.', '..' ), true ) ) {
|
133 |
-
if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) {
|
134 |
-
$result[ sanitize_title( $value ) ] = $value;
|
135 |
-
}
|
136 |
-
}
|
137 |
-
}
|
138 |
-
}
|
139 |
-
|
140 |
-
return $result;
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Return the log file handle.
|
145 |
-
*
|
146 |
-
* @param string $filename Filename to get the handle for.
|
147 |
-
* @return string
|
148 |
-
*/
|
149 |
-
public static function get_log_file_handle( $filename ) {
|
150 |
-
return substr( $filename, 0, strlen( $filename ) > 48 ? strlen( $filename ) - 48 : strlen( $filename ) - 4 );
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Show the log page contents for file log handler.
|
155 |
-
*/
|
156 |
-
public static function status_logs_file() {
|
157 |
-
|
158 |
-
if ( ! empty( $_REQUEST['handle'] ) ) {
|
159 |
-
|
160 |
-
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'remove_log' ) ) {
|
161 |
-
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'cartflows' ) );
|
162 |
-
}
|
163 |
-
wp_delete_file( CARTFLOWS_LOG_DIR . rtrim( $_REQUEST['handle'], '-log' ) . '.log' );
|
164 |
-
echo "<div style='padding: 15px;' class='updated inline'> Log deleted successfully! </div>";
|
165 |
-
}
|
166 |
-
|
167 |
-
$logs = self::get_log_files();
|
168 |
-
if ( ! empty( $_REQUEST['log_file'] ) && isset( $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ] ) ) {
|
169 |
-
$viewed_log = $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ];
|
170 |
-
} elseif ( ! empty( $logs ) ) {
|
171 |
-
$viewed_log = current( $logs );
|
172 |
-
}
|
173 |
-
$handle = ! empty( $viewed_log ) ? self::get_log_file_handle( $viewed_log ) : '';
|
174 |
-
|
175 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-error-log.php';
|
176 |
-
}
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
/**
|
181 |
-
* Kicking this off by calling 'get_instance()' method
|
182 |
-
*/
|
183 |
-
Cartflows_Logger::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Logger.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Logger {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Member Variable
|
25 |
+
*
|
26 |
+
* @var logger
|
27 |
+
*/
|
28 |
+
public $logger;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Initiator
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self();
|
36 |
+
}
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor
|
42 |
+
*/
|
43 |
+
public function __construct() {
|
44 |
+
|
45 |
+
/* Load WC Logger */
|
46 |
+
add_action( 'init', array( $this, 'init_wc_logger' ), 99 );
|
47 |
+
|
48 |
+
$page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING );
|
49 |
+
|
50 |
+
if ( CARTFLOWS_SETTINGS === $page ) {
|
51 |
+
add_filter( 'admin_footer_text', array( $this, 'add_footer_link' ), 99 );
|
52 |
+
}
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Add footer link.
|
58 |
+
*/
|
59 |
+
public function add_footer_link() {
|
60 |
+
$settings_url = add_query_arg(
|
61 |
+
array(
|
62 |
+
'page' => CARTFLOWS_SETTINGS,
|
63 |
+
'cartflows-error-log' => 1,
|
64 |
+
),
|
65 |
+
admin_url( '/admin.php' )
|
66 |
+
);
|
67 |
+
|
68 |
+
echo '<span id="footer-thankyou"> Thank you for using <a href="https://cartflows.com/">CartFlows</a></span> | <a href="' . $settings_url . '"> View Logs </a>';
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Inint Logger.
|
73 |
+
*
|
74 |
+
* @since 1.0.0
|
75 |
+
*/
|
76 |
+
public function init_wc_logger() {
|
77 |
+
if ( class_exists( 'CartFlows_WC_Logger' ) ) {
|
78 |
+
$this->logger = new CartFlows_WC_Logger();
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Write log
|
84 |
+
*
|
85 |
+
* @param string $message log message.
|
86 |
+
* @param string $level type of log.
|
87 |
+
* @since 1.0.0
|
88 |
+
*/
|
89 |
+
public function log( $message, $level = 'info' ) {
|
90 |
+
|
91 |
+
$enable_log = apply_filters( 'cartflows_enable_log', 'enable' );
|
92 |
+
|
93 |
+
if ( 'enable' === $enable_log &&
|
94 |
+
is_a( $this->logger, 'CartFlows_WC_Logger' ) &&
|
95 |
+
did_action( 'plugins_loaded' )
|
96 |
+
) {
|
97 |
+
|
98 |
+
$this->logger->log( $level, $message, array( 'source' => 'cartflows' ) );
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Write log
|
104 |
+
*
|
105 |
+
* @param string $message log message.
|
106 |
+
* @param string $level type of log.
|
107 |
+
* @since 1.0.0
|
108 |
+
*/
|
109 |
+
public function import_log( $message, $level = 'info' ) {
|
110 |
+
|
111 |
+
if ( defined( 'WP_DEBUG' ) &&
|
112 |
+
WP_DEBUG &&
|
113 |
+
is_a( $this->logger, 'CartFlows_WC_Logger' ) &&
|
114 |
+
did_action( 'plugins_loaded' )
|
115 |
+
) {
|
116 |
+
|
117 |
+
$this->logger->log( $level, $message, array( 'source' => 'cartflows-import' ) );
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Get all log files in the log directory.
|
123 |
+
*
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
+
public static function get_log_files() {
|
127 |
+
$files = scandir( CARTFLOWS_LOG_DIR );
|
128 |
+
$result = array();
|
129 |
+
|
130 |
+
if ( ! empty( $files ) ) {
|
131 |
+
foreach ( $files as $key => $value ) {
|
132 |
+
if ( ! in_array( $value, array( '.', '..' ), true ) ) {
|
133 |
+
if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) {
|
134 |
+
$result[ sanitize_title( $value ) ] = $value;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
return $result;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Return the log file handle.
|
145 |
+
*
|
146 |
+
* @param string $filename Filename to get the handle for.
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public static function get_log_file_handle( $filename ) {
|
150 |
+
return substr( $filename, 0, strlen( $filename ) > 48 ? strlen( $filename ) - 48 : strlen( $filename ) - 4 );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Show the log page contents for file log handler.
|
155 |
+
*/
|
156 |
+
public static function status_logs_file() {
|
157 |
+
|
158 |
+
if ( ! empty( $_REQUEST['handle'] ) ) {
|
159 |
+
|
160 |
+
if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'remove_log' ) ) {
|
161 |
+
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'cartflows' ) );
|
162 |
+
}
|
163 |
+
wp_delete_file( CARTFLOWS_LOG_DIR . rtrim( $_REQUEST['handle'], '-log' ) . '.log' ); //phpcs:ignore
|
164 |
+
echo "<div style='padding: 15px;' class='updated inline'> Log deleted successfully! </div>";
|
165 |
+
}
|
166 |
+
|
167 |
+
$logs = self::get_log_files();
|
168 |
+
if ( ! empty( $_REQUEST['log_file'] ) && isset( $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ] ) ) {
|
169 |
+
$viewed_log = $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ];
|
170 |
+
} elseif ( ! empty( $logs ) ) {
|
171 |
+
$viewed_log = current( $logs );
|
172 |
+
}
|
173 |
+
$handle = ! empty( $viewed_log ) ? self::get_log_file_handle( $viewed_log ) : '';
|
174 |
+
|
175 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-error-log.php';
|
176 |
+
}
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Kicking this off by calling 'get_instance()' method
|
182 |
+
*/
|
183 |
+
Cartflows_Logger::get_instance();
|
classes/class-cartflows-meta.php
CHANGED
@@ -1,75 +1,75 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Meta
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'Cartflows_Meta' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows_Meta
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class Cartflows_Meta {
|
17 |
-
/**
|
18 |
-
* Constructor
|
19 |
-
*
|
20 |
-
* @since 1.0.0
|
21 |
-
*/
|
22 |
-
public function __construct() {
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Flow & Step Actions
|
27 |
-
*
|
28 |
-
* @param array $options options.
|
29 |
-
* @param int $post_id post ID.
|
30 |
-
*/
|
31 |
-
function right_column_footer( $options, $post_id ) {
|
32 |
-
?>
|
33 |
-
<div class="wcf-column-right-footer">
|
34 |
-
<?php submit_button( __( 'Update', 'cartflows' ), 'primary', 'save', false ); ?>
|
35 |
-
|
36 |
-
<?php
|
37 |
-
$flow_id = get_post_meta( $post_id, 'wcf-flow-id', true );
|
38 |
-
if ( $flow_id ) {
|
39 |
-
?>
|
40 |
-
<a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button pull-right wcf-back-to-flow-edit">
|
41 |
-
<i class="dashicons dashicons-arrow-left-alt"></i>
|
42 |
-
<?php _e( 'Back to edit Flow', 'cartflows' ); ?>
|
43 |
-
</a>
|
44 |
-
<?php } ?>
|
45 |
-
|
46 |
-
</div>
|
47 |
-
<?php
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Script Header (Used for add script into header)
|
52 |
-
*
|
53 |
-
* @param array $options options.
|
54 |
-
* @param int $post_id post ID.
|
55 |
-
*/
|
56 |
-
function tab_custom_script( $options, $post_id ) {
|
57 |
-
?>
|
58 |
-
<div class="wcf-<?php echo wcf()->utils->get_step_type( $post_id ); ?>-custom-script-header wcf-tab-content widefat">
|
59 |
-
<?php
|
60 |
-
/* Script added onto the header */
|
61 |
-
echo wcf()->meta->get_area_field(
|
62 |
-
array(
|
63 |
-
'label' => __( 'Custom Script', 'cartflows' ),
|
64 |
-
'name' => 'wcf-custom-script',
|
65 |
-
'value' => htmlspecialchars( $options['wcf-custom-script'] ),
|
66 |
-
'help' => __( 'Custom script lets you add your own custom script on front end of this flow page.', 'cartflows' ),
|
67 |
-
)
|
68 |
-
);
|
69 |
-
?>
|
70 |
-
</div>
|
71 |
-
<?php
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Meta
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'Cartflows_Meta' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows_Meta
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class Cartflows_Meta {
|
17 |
+
/**
|
18 |
+
* Constructor
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
*/
|
22 |
+
public function __construct() {
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Flow & Step Actions
|
27 |
+
*
|
28 |
+
* @param array $options options.
|
29 |
+
* @param int $post_id post ID.
|
30 |
+
*/
|
31 |
+
public function right_column_footer( $options, $post_id ) {
|
32 |
+
?>
|
33 |
+
<div class="wcf-column-right-footer">
|
34 |
+
<?php submit_button( __( 'Update', 'cartflows' ), 'primary', 'save', false ); ?>
|
35 |
+
|
36 |
+
<?php
|
37 |
+
$flow_id = get_post_meta( $post_id, 'wcf-flow-id', true );
|
38 |
+
if ( $flow_id ) {
|
39 |
+
?>
|
40 |
+
<a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button pull-right wcf-back-to-flow-edit">
|
41 |
+
<i class="dashicons dashicons-arrow-left-alt"></i>
|
42 |
+
<?php _e( 'Back to edit Flow', 'cartflows' ); ?>
|
43 |
+
</a>
|
44 |
+
<?php } ?>
|
45 |
+
|
46 |
+
</div>
|
47 |
+
<?php
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Script Header (Used for add script into header)
|
52 |
+
*
|
53 |
+
* @param array $options options.
|
54 |
+
* @param int $post_id post ID.
|
55 |
+
*/
|
56 |
+
public function tab_custom_script( $options, $post_id ) {
|
57 |
+
?>
|
58 |
+
<div class="wcf-<?php echo wcf()->utils->get_step_type( $post_id ); ?>-custom-script-header wcf-tab-content widefat">
|
59 |
+
<?php
|
60 |
+
/* Script added onto the header */
|
61 |
+
echo wcf()->meta->get_area_field(
|
62 |
+
array(
|
63 |
+
'label' => __( 'Custom Script', 'cartflows' ),
|
64 |
+
'name' => 'wcf-custom-script',
|
65 |
+
'value' => htmlspecialchars( $options['wcf-custom-script'], ENT_COMPAT, 'utf-8' ),
|
66 |
+
'help' => __( 'Custom script lets you add your own custom script on front end of this flow page.', 'cartflows' ),
|
67 |
+
)
|
68 |
+
);
|
69 |
+
?>
|
70 |
+
</div>
|
71 |
+
<?php
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
endif;
|
classes/class-cartflows-metabox.php
CHANGED
@@ -1,97 +1,97 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Update Compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! class_exists( 'Cartflows_Metabox' ) ) :
|
9 |
-
|
10 |
-
/**
|
11 |
-
* CartFlows Update initial setup
|
12 |
-
*
|
13 |
-
* @since 1.0.0
|
14 |
-
*/
|
15 |
-
class Cartflows_Metabox {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Class instance.
|
19 |
-
*
|
20 |
-
* @access private
|
21 |
-
* @var $instance Class instance.
|
22 |
-
*/
|
23 |
-
private static $instance;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Initiator
|
27 |
-
*/
|
28 |
-
public static function get_instance() {
|
29 |
-
if ( ! isset( self::$instance ) ) {
|
30 |
-
self::$instance = new self();
|
31 |
-
}
|
32 |
-
return self::$instance;
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Constructor
|
37 |
-
*/
|
38 |
-
public function __construct() {
|
39 |
-
add_action( 'admin_init', array( $this, 'add_wcf_order_metabox' ) );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
*
|
44 |
-
* Add Analytics Metabox
|
45 |
-
*
|
46 |
-
* @return void
|
47 |
-
*/
|
48 |
-
function add_wcf_order_metabox() {
|
49 |
-
|
50 |
-
if ( ! isset( $_GET['cartflows_debug'] ) ) {
|
51 |
-
return;
|
52 |
-
}
|
53 |
-
|
54 |
-
$debug = filter_input( INPUT_GET, 'cartflows_debug', FILTER_SANITIZE_STRING );
|
55 |
-
|
56 |
-
if ( $debug ) {
|
57 |
-
add_meta_box(
|
58 |
-
'wcf-order-details',
|
59 |
-
__( 'Flow Details', 'cartflows' ),
|
60 |
-
array( $this, 'flow_metabox_markup' ),
|
61 |
-
'shop_order',
|
62 |
-
'side',
|
63 |
-
'low'
|
64 |
-
);
|
65 |
-
}
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Flow metabox markup.
|
72 |
-
*/
|
73 |
-
function flow_metabox_markup() {
|
74 |
-
global $post;
|
75 |
-
$flow_id = wcf()->utils->get_flow_id_from_order( $post->ID );
|
76 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $post->ID );
|
77 |
-
|
78 |
-
$html_data = "
|
79 |
-
<div>
|
80 |
-
<p> This is for debugging only. </p>
|
81 |
-
<p> <strong>Flow ID:</strong>: <a href='" . admin_url( 'post.php?post=' . $flow_id . '&action=edit' ) . "'> " . $flow_id . " </a> </p>
|
82 |
-
<p> <strong>Checkout ID:</strong> <a href='" . admin_url( 'post.php?post=' . $checkout_id . '&action=edit' ) . "'> " . $checkout_id . ' </a></p>
|
83 |
-
</div>
|
84 |
-
';
|
85 |
-
|
86 |
-
echo $html_data;
|
87 |
-
}
|
88 |
-
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Kicking this off by calling 'get_instance()' method
|
94 |
-
*/
|
95 |
-
Cartflows_Metabox::get_instance();
|
96 |
-
|
97 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Update Compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! class_exists( 'Cartflows_Metabox' ) ) :
|
9 |
+
|
10 |
+
/**
|
11 |
+
* CartFlows Update initial setup
|
12 |
+
*
|
13 |
+
* @since 1.0.0
|
14 |
+
*/
|
15 |
+
class Cartflows_Metabox {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class instance.
|
19 |
+
*
|
20 |
+
* @access private
|
21 |
+
* @var $instance Class instance.
|
22 |
+
*/
|
23 |
+
private static $instance;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Initiator
|
27 |
+
*/
|
28 |
+
public static function get_instance() {
|
29 |
+
if ( ! isset( self::$instance ) ) {
|
30 |
+
self::$instance = new self();
|
31 |
+
}
|
32 |
+
return self::$instance;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Constructor
|
37 |
+
*/
|
38 |
+
public function __construct() {
|
39 |
+
add_action( 'admin_init', array( $this, 'add_wcf_order_metabox' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
*
|
44 |
+
* Add Analytics Metabox
|
45 |
+
*
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
public function add_wcf_order_metabox() {
|
49 |
+
|
50 |
+
if ( ! isset( $_GET['cartflows_debug'] ) ) {
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
|
54 |
+
$debug = filter_input( INPUT_GET, 'cartflows_debug', FILTER_SANITIZE_STRING );
|
55 |
+
|
56 |
+
if ( $debug ) {
|
57 |
+
add_meta_box(
|
58 |
+
'wcf-order-details',
|
59 |
+
__( 'Flow Details', 'cartflows' ),
|
60 |
+
array( $this, 'flow_metabox_markup' ),
|
61 |
+
'shop_order',
|
62 |
+
'side',
|
63 |
+
'low'
|
64 |
+
);
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Flow metabox markup.
|
72 |
+
*/
|
73 |
+
public function flow_metabox_markup() {
|
74 |
+
global $post;
|
75 |
+
$flow_id = wcf()->utils->get_flow_id_from_order( $post->ID );
|
76 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $post->ID );
|
77 |
+
|
78 |
+
$html_data = "
|
79 |
+
<div>
|
80 |
+
<p> This is for debugging only. </p>
|
81 |
+
<p> <strong>Flow ID:</strong>: <a href='" . admin_url( 'post.php?post=' . $flow_id . '&action=edit' ) . "'> " . $flow_id . " </a> </p>
|
82 |
+
<p> <strong>Checkout ID:</strong> <a href='" . admin_url( 'post.php?post=' . $checkout_id . '&action=edit' ) . "'> " . $checkout_id . ' </a></p>
|
83 |
+
</div>
|
84 |
+
';
|
85 |
+
|
86 |
+
echo $html_data;
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Kicking this off by calling 'get_instance()' method
|
94 |
+
*/
|
95 |
+
Cartflows_Metabox::get_instance();
|
96 |
+
|
97 |
+
endif;
|
classes/class-cartflows-session.php
CHANGED
@@ -1,245 +1,245 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Session
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Session {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Set session
|
42 |
-
*
|
43 |
-
* @param int $flow_id flow ID.
|
44 |
-
* @param array $data trasient data.
|
45 |
-
*/
|
46 |
-
function set_session( $flow_id, $data = array() ) {
|
47 |
-
|
48 |
-
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
49 |
-
$key = (string) $_COOKIE[ 'cartflows_session_' . $flow_id ];
|
50 |
-
} else {
|
51 |
-
$key = $flow_id . '_' . md5( time() .
|
52 |
-
}
|
53 |
-
|
54 |
-
// Set the browser cookie to expire in 30 minutes.
|
55 |
-
setcookie( 'cartflows_session_' . $flow_id, $key, time() + 30 * MINUTE_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
|
56 |
-
|
57 |
-
// Try to grab the transient from the database, if it exists.
|
58 |
-
$transient = $data;
|
59 |
-
|
60 |
-
// Store the transient, but expire in 30 minutes.
|
61 |
-
set_transient( 'cartflows_data_' . $key, $transient, 30 * MINUTE_IN_SECONDS );
|
62 |
-
|
63 |
-
wp_cache_set( 'cartflows_data_' . $key, $transient );
|
64 |
-
|
65 |
-
wcf()->logger->log( 'Flow-' . $flow_id . ' Session Set : ' . $key . ' ' .
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Update session
|
70 |
-
*
|
71 |
-
* @param int $flow_id flow ID.
|
72 |
-
* @param array $data trasient data.
|
73 |
-
*/
|
74 |
-
function update_session( $flow_id, $data = array() ) {
|
75 |
-
|
76 |
-
if ( ! isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
77 |
-
|
78 |
-
$this->set_session( $flow_id, $data );
|
79 |
-
}
|
80 |
-
|
81 |
-
$key = (string) $_COOKIE[ 'cartflows_session_' . $flow_id ];
|
82 |
-
|
83 |
-
// Try to grab the transient from the database, if it exists.
|
84 |
-
$transient = get_transient( 'cartflows_data_' . $key );
|
85 |
-
|
86 |
-
// Set the browser cookie to expire in 30 minutes.
|
87 |
-
setcookie( 'cartflows_session_' . $flow_id, $key, time() + 30 * MINUTE_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
|
88 |
-
|
89 |
-
// Store the transient, but expire in 30 minutes.
|
90 |
-
set_transient( 'cartflows_data_' . $key, $transient, 30 * MINUTE_IN_SECONDS );
|
91 |
-
|
92 |
-
wp_cache_set( 'cartflows_data_' . $key, $transient );
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Destroy session
|
97 |
-
*
|
98 |
-
* @param int $flow_id flow ID.
|
99 |
-
*/
|
100 |
-
function destroy_session( $flow_id ) {
|
101 |
-
|
102 |
-
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
103 |
-
|
104 |
-
$key = (string) $_COOKIE[ 'cartflows_session_' . $flow_id ];
|
105 |
-
|
106 |
-
// Delete Transient.
|
107 |
-
delete_transient( 'cartflows_data_' . $key );
|
108 |
-
|
109 |
-
wp_cache_delete( 'cartflows_data_' . $key );
|
110 |
-
|
111 |
-
unset( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
112 |
-
|
113 |
-
// empty value and expiration one hour before.
|
114 |
-
setcookie( 'cartflows_session_' . $flow_id, $key, time() - 3600, COOKIEPATH, COOKIE_DOMAIN );
|
115 |
-
|
116 |
-
wcf()->logger->log( 'Flow-' . $flow_id . ' Session Destroyed : ' . $key );
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Get session
|
122 |
-
*/
|
123 |
-
function get_session() {
|
124 |
-
|
125 |
-
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
126 |
-
|
127 |
-
$key = (string) $_COOKIE[ 'cartflows_session_' . $flow_id ];
|
128 |
-
|
129 |
-
$data = get_transient( 'cartflows_data_' . $key );
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Update transient data for cart flows.
|
135 |
-
*
|
136 |
-
* @param int $flow_id flow ID.
|
137 |
-
* @param array $data data.
|
138 |
-
*/
|
139 |
-
function update_data( $flow_id, $data = array() ) {
|
140 |
-
|
141 |
-
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
142 |
-
|
143 |
-
$key = (string) $_COOKIE[ 'cartflows_session_' . $flow_id ];
|
144 |
-
|
145 |
-
// Try to grab the transient from the database, if it exists.
|
146 |
-
$transient = get_transient( 'cartflows_data_' . $key );
|
147 |
-
|
148 |
-
if ( ! is_array( $transient ) ) {
|
149 |
-
$transient = array();
|
150 |
-
}
|
151 |
-
|
152 |
-
$transient = array_merge( $transient, $data );
|
153 |
-
|
154 |
-
// Store the transient, but expire in 30 minutes.
|
155 |
-
set_transient( 'cartflows_data_' . $key, $transient, 30 * MINUTE_IN_SECONDS );
|
156 |
-
|
157 |
-
wp_cache_set( 'cartflows_data_' . $key, $transient );
|
158 |
-
}
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Update transient data for cart flows.
|
163 |
-
*
|
164 |
-
* @param int $flow_id flow ID.
|
165 |
-
* @return bool
|
166 |
-
*/
|
167 |
-
function get_data( $flow_id ) {
|
168 |
-
|
169 |
-
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
170 |
-
|
171 |
-
$key = (string) $_COOKIE[ 'cartflows_session_' . $flow_id ];
|
172 |
-
|
173 |
-
// Try to grab the transient from the database, if it exists.
|
174 |
-
$transient = get_transient( 'cartflows_data_' . $key );
|
175 |
-
|
176 |
-
if ( is_array( $transient ) ) {
|
177 |
-
return $transient;
|
178 |
-
}
|
179 |
-
}
|
180 |
-
|
181 |
-
return false;
|
182 |
-
}
|
183 |
-
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Check if session is active.
|
187 |
-
*
|
188 |
-
* @param int $flow_id flow ID.
|
189 |
-
* @return bool
|
190 |
-
*/
|
191 |
-
function is_active_session( $flow_id ) {
|
192 |
-
|
193 |
-
$is_active = false;
|
194 |
-
|
195 |
-
if ( isset( $_GET['wcf-sk'] ) && isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
196 |
-
|
197 |
-
$sk = sanitize_text_field( $_GET['wcf-sk'] );
|
198 |
-
$key = (string) $_COOKIE[ 'cartflows_session_' . $flow_id ];
|
199 |
-
|
200 |
-
if ( $sk === $key ) {
|
201 |
-
|
202 |
-
if ( isset( $_GET['wcf-order'] ) && isset( $_GET['wcf-key'] ) ) {
|
203 |
-
|
204 |
-
// Get the order.
|
205 |
-
$order_id = empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] );
|
206 |
-
$order_key = empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) );
|
207 |
-
|
208 |
-
if ( $order_id > 0 ) {
|
209 |
-
|
210 |
-
$order = wc_get_order( $order_id );
|
211 |
-
|
212 |
-
if ( $order && $order->get_order_key() === $order_key ) {
|
213 |
-
$is_active = true;
|
214 |
-
}
|
215 |
-
}
|
216 |
-
}
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
return $is_active;
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Get session key for flow
|
225 |
-
*
|
226 |
-
* @param int $flow_id flow ID.
|
227 |
-
* @return bool
|
228 |
-
*/
|
229 |
-
function get_session_key( $flow_id ) {
|
230 |
-
|
231 |
-
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
232 |
-
|
233 |
-
$key = (string) $_COOKIE[ 'cartflows_session_' . $flow_id ];
|
234 |
-
|
235 |
-
return $key;
|
236 |
-
}
|
237 |
-
|
238 |
-
return false;
|
239 |
-
}
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Kicking this off by calling 'get_instance()' method
|
244 |
-
*/
|
245 |
-
Cartflows_Session::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Session
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Session {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Set session
|
42 |
+
*
|
43 |
+
* @param int $flow_id flow ID.
|
44 |
+
* @param array $data trasient data.
|
45 |
+
*/
|
46 |
+
public function set_session( $flow_id, $data = array() ) {
|
47 |
+
|
48 |
+
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
49 |
+
$key = (string) wp_unslash( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
50 |
+
} else {
|
51 |
+
$key = $flow_id . '_' . md5( time() . wp_rand() );
|
52 |
+
}
|
53 |
+
|
54 |
+
// Set the browser cookie to expire in 30 minutes.
|
55 |
+
setcookie( 'cartflows_session_' . $flow_id, $key, time() + 30 * MINUTE_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
|
56 |
+
|
57 |
+
// Try to grab the transient from the database, if it exists.
|
58 |
+
$transient = $data;
|
59 |
+
|
60 |
+
// Store the transient, but expire in 30 minutes.
|
61 |
+
set_transient( 'cartflows_data_' . $key, $transient, 30 * MINUTE_IN_SECONDS );
|
62 |
+
|
63 |
+
wp_cache_set( 'cartflows_data_' . $key, $transient );
|
64 |
+
|
65 |
+
wcf()->logger->log( 'Flow-' . $flow_id . ' Session Set : ' . $key . ' ' . wp_json_encode( $transient ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Update session
|
70 |
+
*
|
71 |
+
* @param int $flow_id flow ID.
|
72 |
+
* @param array $data trasient data.
|
73 |
+
*/
|
74 |
+
public function update_session( $flow_id, $data = array() ) {
|
75 |
+
|
76 |
+
if ( ! isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
77 |
+
|
78 |
+
$this->set_session( $flow_id, $data );
|
79 |
+
}
|
80 |
+
|
81 |
+
$key = (string) wp_unslash( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
82 |
+
|
83 |
+
// Try to grab the transient from the database, if it exists.
|
84 |
+
$transient = get_transient( 'cartflows_data_' . $key );
|
85 |
+
|
86 |
+
// Set the browser cookie to expire in 30 minutes.
|
87 |
+
setcookie( 'cartflows_session_' . $flow_id, $key, time() + 30 * MINUTE_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
|
88 |
+
|
89 |
+
// Store the transient, but expire in 30 minutes.
|
90 |
+
set_transient( 'cartflows_data_' . $key, $transient, 30 * MINUTE_IN_SECONDS );
|
91 |
+
|
92 |
+
wp_cache_set( 'cartflows_data_' . $key, $transient );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Destroy session
|
97 |
+
*
|
98 |
+
* @param int $flow_id flow ID.
|
99 |
+
*/
|
100 |
+
public function destroy_session( $flow_id ) {
|
101 |
+
|
102 |
+
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
103 |
+
|
104 |
+
$key = (string) wp_unslash( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
105 |
+
|
106 |
+
// Delete Transient.
|
107 |
+
delete_transient( 'cartflows_data_' . $key );
|
108 |
+
|
109 |
+
wp_cache_delete( 'cartflows_data_' . $key );
|
110 |
+
|
111 |
+
unset( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
112 |
+
|
113 |
+
// empty value and expiration one hour before.
|
114 |
+
setcookie( 'cartflows_session_' . $flow_id, $key, time() - 3600, COOKIEPATH, COOKIE_DOMAIN );
|
115 |
+
|
116 |
+
wcf()->logger->log( 'Flow-' . $flow_id . ' Session Destroyed : ' . $key );
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Get session
|
122 |
+
*/
|
123 |
+
public function get_session() {
|
124 |
+
|
125 |
+
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
126 |
+
|
127 |
+
$key = (string) wp_unslash( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
128 |
+
|
129 |
+
$data = get_transient( 'cartflows_data_' . $key );
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Update transient data for cart flows.
|
135 |
+
*
|
136 |
+
* @param int $flow_id flow ID.
|
137 |
+
* @param array $data data.
|
138 |
+
*/
|
139 |
+
public function update_data( $flow_id, $data = array() ) {
|
140 |
+
|
141 |
+
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
142 |
+
|
143 |
+
$key = (string) wp_unslash( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
144 |
+
|
145 |
+
// Try to grab the transient from the database, if it exists.
|
146 |
+
$transient = get_transient( 'cartflows_data_' . $key );
|
147 |
+
|
148 |
+
if ( ! is_array( $transient ) ) {
|
149 |
+
$transient = array();
|
150 |
+
}
|
151 |
+
|
152 |
+
$transient = array_merge( $transient, $data );
|
153 |
+
|
154 |
+
// Store the transient, but expire in 30 minutes.
|
155 |
+
set_transient( 'cartflows_data_' . $key, $transient, 30 * MINUTE_IN_SECONDS );
|
156 |
+
|
157 |
+
wp_cache_set( 'cartflows_data_' . $key, $transient );
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Update transient data for cart flows.
|
163 |
+
*
|
164 |
+
* @param int $flow_id flow ID.
|
165 |
+
* @return bool
|
166 |
+
*/
|
167 |
+
public function get_data( $flow_id ) {
|
168 |
+
|
169 |
+
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
170 |
+
|
171 |
+
$key = (string) wp_unslash( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
172 |
+
|
173 |
+
// Try to grab the transient from the database, if it exists.
|
174 |
+
$transient = get_transient( 'cartflows_data_' . $key );
|
175 |
+
|
176 |
+
if ( is_array( $transient ) ) {
|
177 |
+
return $transient;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
return false;
|
182 |
+
}
|
183 |
+
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Check if session is active.
|
187 |
+
*
|
188 |
+
* @param int $flow_id flow ID.
|
189 |
+
* @return bool
|
190 |
+
*/
|
191 |
+
public function is_active_session( $flow_id ) {
|
192 |
+
|
193 |
+
$is_active = false;
|
194 |
+
|
195 |
+
if ( isset( $_GET['wcf-sk'] ) && isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
196 |
+
|
197 |
+
$sk = sanitize_text_field( wp_unslash( $_GET['wcf-sk'] ) );
|
198 |
+
$key = (string) wp_unslash( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
199 |
+
|
200 |
+
if ( $sk === $key ) {
|
201 |
+
|
202 |
+
if ( isset( $_GET['wcf-order'] ) && isset( $_GET['wcf-key'] ) ) {
|
203 |
+
|
204 |
+
// Get the order.
|
205 |
+
$order_id = empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] );
|
206 |
+
$order_key = empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) );
|
207 |
+
|
208 |
+
if ( $order_id > 0 ) {
|
209 |
+
|
210 |
+
$order = wc_get_order( $order_id );
|
211 |
+
|
212 |
+
if ( $order && $order->get_order_key() === $order_key ) {
|
213 |
+
$is_active = true;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
return $is_active;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Get session key for flow
|
225 |
+
*
|
226 |
+
* @param int $flow_id flow ID.
|
227 |
+
* @return bool
|
228 |
+
*/
|
229 |
+
public function get_session_key( $flow_id ) {
|
230 |
+
|
231 |
+
if ( isset( $_COOKIE[ 'cartflows_session_' . $flow_id ] ) ) {
|
232 |
+
|
233 |
+
$key = (string) wp_unslash( $_COOKIE[ 'cartflows_session_' . $flow_id ] );
|
234 |
+
|
235 |
+
return $key;
|
236 |
+
}
|
237 |
+
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Kicking this off by calling 'get_instance()' method
|
244 |
+
*/
|
245 |
+
Cartflows_Session::get_instance();
|
classes/class-cartflows-thrive-compatibility.php
CHANGED
@@ -1,77 +1,77 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Thrive Visual Editor Compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class for Thrive Visual Editor Compatibility
|
10 |
-
*/
|
11 |
-
class Cartflows_Thrive_Compatibility {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Member Variable
|
15 |
-
*
|
16 |
-
* @var instance
|
17 |
-
*/
|
18 |
-
private static $instance;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Initiator
|
22 |
-
*/
|
23 |
-
public static function get_instance() {
|
24 |
-
if ( ! isset( self::$instance ) ) {
|
25 |
-
self::$instance = new self();
|
26 |
-
}
|
27 |
-
return self::$instance;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Constructor
|
32 |
-
*/
|
33 |
-
public function __construct() {
|
34 |
-
|
35 |
-
// Add CartFlows post type in the thrive page editor.
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
add_filter( 'tcb_can_use_landing_pages', array( $this, 'display_change_template_option' ) );
|
40 |
-
|
41 |
-
add_filter( 'tcb_has_templates_tab', array( $this, 'display_change_template_option' ) );
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Return step post type for Thrive Architect.
|
46 |
-
*
|
47 |
-
* @since 1.0.0
|
48 |
-
* @param array $post_type_pt the current step post type.
|
49 |
-
* @return array $post_type_pt current step post type.
|
50 |
-
*/
|
51 |
-
function send_post_type_to_thrive( $post_type_pt ) {
|
52 |
-
|
53 |
-
$post_type_pt[] = CARTFLOWS_STEP_POST_TYPE;
|
54 |
-
|
55 |
-
return $post_type_pt;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Return true/false to show change template option.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
* @param array $bool true/false.
|
63 |
-
* @return array $bool true/false.
|
64 |
-
*/
|
65 |
-
function display_change_template_option( $bool ) {
|
66 |
-
|
67 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
68 |
-
$bool = true;
|
69 |
-
}
|
70 |
-
return $bool;
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Kicking this off by calling 'get_instance()' method
|
76 |
-
*/
|
77 |
-
Cartflows_Thrive_Compatibility::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Thrive Visual Editor Compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class for Thrive Visual Editor Compatibility
|
10 |
+
*/
|
11 |
+
class Cartflows_Thrive_Compatibility {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Member Variable
|
15 |
+
*
|
16 |
+
* @var instance
|
17 |
+
*/
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Initiator
|
22 |
+
*/
|
23 |
+
public static function get_instance() {
|
24 |
+
if ( ! isset( self::$instance ) ) {
|
25 |
+
self::$instance = new self();
|
26 |
+
}
|
27 |
+
return self::$instance;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Constructor
|
32 |
+
*/
|
33 |
+
public function __construct() {
|
34 |
+
|
35 |
+
// Add CartFlows post type in the thrive page editor.
|
36 |
+
// tve_landing_page_post_types.
|
37 |
+
add_filter( 'tve_post_type_can_use_landing_page', array( $this, 'send_post_type_to_thrive' ) );
|
38 |
+
|
39 |
+
add_filter( 'tcb_can_use_landing_pages', array( $this, 'display_change_template_option' ) );
|
40 |
+
|
41 |
+
add_filter( 'tcb_has_templates_tab', array( $this, 'display_change_template_option' ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Return step post type for Thrive Architect.
|
46 |
+
*
|
47 |
+
* @since 1.0.0
|
48 |
+
* @param array $post_type_pt the current step post type.
|
49 |
+
* @return array $post_type_pt current step post type.
|
50 |
+
*/
|
51 |
+
public function send_post_type_to_thrive( $post_type_pt ) {
|
52 |
+
|
53 |
+
$post_type_pt[] = CARTFLOWS_STEP_POST_TYPE;
|
54 |
+
|
55 |
+
return $post_type_pt;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Return true/false to show change template option.
|
60 |
+
*
|
61 |
+
* @since 1.0.0
|
62 |
+
* @param array $bool true/false.
|
63 |
+
* @return array $bool true/false.
|
64 |
+
*/
|
65 |
+
public function display_change_template_option( $bool ) {
|
66 |
+
|
67 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
68 |
+
$bool = true;
|
69 |
+
}
|
70 |
+
return $bool;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Kicking this off by calling 'get_instance()' method
|
76 |
+
*/
|
77 |
+
Cartflows_Thrive_Compatibility::get_instance();
|
classes/class-cartflows-update.php
CHANGED
@@ -1,146 +1,146 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Update Compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! class_exists( 'Cartflows_Update' ) ) :
|
9 |
-
|
10 |
-
/**
|
11 |
-
* CartFlows Update initial setup
|
12 |
-
*
|
13 |
-
* @since 1.0.0
|
14 |
-
*/
|
15 |
-
class Cartflows_Update {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Class instance.
|
19 |
-
*
|
20 |
-
* @access private
|
21 |
-
* @var $instance Class instance.
|
22 |
-
*/
|
23 |
-
private static $instance;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Initiator
|
27 |
-
*/
|
28 |
-
public static function get_instance() {
|
29 |
-
if ( ! isset( self::$instance ) ) {
|
30 |
-
self::$instance = new self();
|
31 |
-
}
|
32 |
-
return self::$instance;
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Constructor
|
37 |
-
*/
|
38 |
-
public function __construct() {
|
39 |
-
add_action( 'admin_init', array( $this, 'init' ) );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Init
|
44 |
-
*
|
45 |
-
* @since 1.0.0
|
46 |
-
* @return void
|
47 |
-
*/
|
48 |
-
function init() {
|
49 |
-
|
50 |
-
do_action( 'cartflows_update_before' );
|
51 |
-
|
52 |
-
// Get auto saved version number.
|
53 |
-
$saved_version = get_option( 'cartflows-version', false );
|
54 |
-
|
55 |
-
// Update auto saved version number.
|
56 |
-
if ( ! $saved_version ) {
|
57 |
-
update_option( 'cartflows-version', CARTFLOWS_VER );
|
58 |
-
return;
|
59 |
-
}
|
60 |
-
|
61 |
-
// If equals then return.
|
62 |
-
if ( version_compare( $saved_version, CARTFLOWS_VER, '=' ) ) {
|
63 |
-
return;
|
64 |
-
}
|
65 |
-
|
66 |
-
$this->logger_files();
|
67 |
-
|
68 |
-
if ( version_compare( $saved_version, '1.1.22', '<' ) ) {
|
69 |
-
update_option( 'wcf_setup_skipped', true );
|
70 |
-
}
|
71 |
-
|
72 |
-
if ( version_compare( $saved_version, '1.2.0', '<' ) ) {
|
73 |
-
|
74 |
-
$this->changed_wp_templates();
|
75 |
-
}
|
76 |
-
|
77 |
-
// Update auto saved version number.
|
78 |
-
update_option( 'cartflows-version', CARTFLOWS_VER );
|
79 |
-
|
80 |
-
do_action( 'cartflows_update_after' );
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Loading logger files.
|
86 |
-
*
|
87 |
-
* @since 1.0.0
|
88 |
-
* @return void
|
89 |
-
*/
|
90 |
-
function logger_files() {
|
91 |
-
|
92 |
-
if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) {
|
93 |
-
|
94 |
-
$upload_dir = wp_upload_dir( null, false );
|
95 |
-
|
96 |
-
define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' );
|
97 |
-
}
|
98 |
-
|
99 |
-
wcf()->create_files();
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Init
|
104 |
-
*
|
105 |
-
* @since 1.0.0
|
106 |
-
* @return void
|
107 |
-
*/
|
108 |
-
function changed_wp_templates() {
|
109 |
-
|
110 |
-
global $wpdb;
|
111 |
-
|
112 |
-
$query_results = $wpdb->get_results(
|
113 |
-
$wpdb->prepare(
|
114 |
-
"SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id )
|
115 |
-
where {$wpdb->posts}.post_type = %s AND {$wpdb->postmeta}.meta_key = %s AND {$wpdb->postmeta}.meta_value != %s AND {$wpdb->postmeta}.meta_value != %s",
|
116 |
-
'cartflows_step',
|
117 |
-
'_wp_page_template',
|
118 |
-
'cartflows-canvas',
|
119 |
-
'cartflows-default'
|
120 |
-
)
|
121 |
-
);
|
122 |
-
|
123 |
-
if ( is_array( $query_results ) && ! empty( $query_results ) ) {
|
124 |
-
|
125 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-change-template-batch.php';
|
126 |
-
|
127 |
-
wcf()->logger->log( '(✓) Update Templates BATCH Started!' );
|
128 |
-
|
129 |
-
$change_template_batch = new Cartflows_Change_Template_Batch();
|
130 |
-
|
131 |
-
foreach ( $query_results as $query_result ) {
|
132 |
-
|
133 |
-
wcf()->logger->log( '(✓) POST ID ' . $query_result->ID );
|
134 |
-
$change_template_batch->push_to_queue( $query_result->ID );
|
135 |
-
}
|
136 |
-
|
137 |
-
$change_template_batch->save()->dispatch();
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
/**
|
142 |
-
* Kicking this off by calling 'get_instance()' method
|
143 |
-
*/
|
144 |
-
Cartflows_Update::get_instance();
|
145 |
-
|
146 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Update Compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! class_exists( 'Cartflows_Update' ) ) :
|
9 |
+
|
10 |
+
/**
|
11 |
+
* CartFlows Update initial setup
|
12 |
+
*
|
13 |
+
* @since 1.0.0
|
14 |
+
*/
|
15 |
+
class Cartflows_Update {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class instance.
|
19 |
+
*
|
20 |
+
* @access private
|
21 |
+
* @var $instance Class instance.
|
22 |
+
*/
|
23 |
+
private static $instance;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Initiator
|
27 |
+
*/
|
28 |
+
public static function get_instance() {
|
29 |
+
if ( ! isset( self::$instance ) ) {
|
30 |
+
self::$instance = new self();
|
31 |
+
}
|
32 |
+
return self::$instance;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Constructor
|
37 |
+
*/
|
38 |
+
public function __construct() {
|
39 |
+
add_action( 'admin_init', array( $this, 'init' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Init
|
44 |
+
*
|
45 |
+
* @since 1.0.0
|
46 |
+
* @return void
|
47 |
+
*/
|
48 |
+
public function init() {
|
49 |
+
|
50 |
+
do_action( 'cartflows_update_before' );
|
51 |
+
|
52 |
+
// Get auto saved version number.
|
53 |
+
$saved_version = get_option( 'cartflows-version', false );
|
54 |
+
|
55 |
+
// Update auto saved version number.
|
56 |
+
if ( ! $saved_version ) {
|
57 |
+
update_option( 'cartflows-version', CARTFLOWS_VER );
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
|
61 |
+
// If equals then return.
|
62 |
+
if ( version_compare( $saved_version, CARTFLOWS_VER, '=' ) ) {
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
|
66 |
+
$this->logger_files();
|
67 |
+
|
68 |
+
if ( version_compare( $saved_version, '1.1.22', '<' ) ) {
|
69 |
+
update_option( 'wcf_setup_skipped', true );
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( version_compare( $saved_version, '1.2.0', '<' ) ) {
|
73 |
+
|
74 |
+
$this->changed_wp_templates();
|
75 |
+
}
|
76 |
+
|
77 |
+
// Update auto saved version number.
|
78 |
+
update_option( 'cartflows-version', CARTFLOWS_VER );
|
79 |
+
|
80 |
+
do_action( 'cartflows_update_after' );
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Loading logger files.
|
86 |
+
*
|
87 |
+
* @since 1.0.0
|
88 |
+
* @return void
|
89 |
+
*/
|
90 |
+
public function logger_files() {
|
91 |
+
|
92 |
+
if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) {
|
93 |
+
|
94 |
+
$upload_dir = wp_upload_dir( null, false );
|
95 |
+
|
96 |
+
define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' );
|
97 |
+
}
|
98 |
+
|
99 |
+
wcf()->create_files();
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Init
|
104 |
+
*
|
105 |
+
* @since 1.0.0
|
106 |
+
* @return void
|
107 |
+
*/
|
108 |
+
public function changed_wp_templates() {
|
109 |
+
|
110 |
+
global $wpdb;
|
111 |
+
|
112 |
+
$query_results = $wpdb->get_results(
|
113 |
+
$wpdb->prepare(
|
114 |
+
"SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id )
|
115 |
+
where {$wpdb->posts}.post_type = %s AND {$wpdb->postmeta}.meta_key = %s AND {$wpdb->postmeta}.meta_value != %s AND {$wpdb->postmeta}.meta_value != %s",
|
116 |
+
'cartflows_step',
|
117 |
+
'_wp_page_template',
|
118 |
+
'cartflows-canvas',
|
119 |
+
'cartflows-default'
|
120 |
+
)
|
121 |
+
); // db call ok; no-cache ok.
|
122 |
+
|
123 |
+
if ( is_array( $query_results ) && ! empty( $query_results ) ) {
|
124 |
+
|
125 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-change-template-batch.php';
|
126 |
+
|
127 |
+
wcf()->logger->log( '(✓) Update Templates BATCH Started!' );
|
128 |
+
|
129 |
+
$change_template_batch = new Cartflows_Change_Template_Batch();
|
130 |
+
|
131 |
+
foreach ( $query_results as $query_result ) {
|
132 |
+
|
133 |
+
wcf()->logger->log( '(✓) POST ID ' . $query_result->ID );
|
134 |
+
$change_template_batch->push_to_queue( $query_result->ID );
|
135 |
+
}
|
136 |
+
|
137 |
+
$change_template_batch->save()->dispatch();
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
/**
|
142 |
+
* Kicking this off by calling 'get_instance()' method
|
143 |
+
*/
|
144 |
+
Cartflows_Update::get_instance();
|
145 |
+
|
146 |
+
endif;
|
classes/class-cartflows-utils.php
CHANGED
@@ -1,426 +1,425 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Utils.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit; // Exit if accessed directly.
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Cartflows_Utils.
|
14 |
-
*/
|
15 |
-
class Cartflows_Utils {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Member Variable
|
19 |
-
*
|
20 |
-
* @var instance
|
21 |
-
*/
|
22 |
-
private static $instance;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Initiator
|
26 |
-
*/
|
27 |
-
public static function get_instance() {
|
28 |
-
if ( ! isset( self::$instance ) ) {
|
29 |
-
self::$instance = new self();
|
30 |
-
}
|
31 |
-
return self::$instance;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Constructor
|
36 |
-
*/
|
37 |
-
function __construct() {
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Get current post type
|
42 |
-
*
|
43 |
-
* @param string $post_type post type.
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
function current_post_type( $post_type = '' ) {
|
47 |
-
|
48 |
-
if ( '' === $post_type ) {
|
49 |
-
$post_type = get_post_type();
|
50 |
-
}
|
51 |
-
|
52 |
-
return $post_type;
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Check if post type is of step.
|
57 |
-
*
|
58 |
-
* @param string $post_type post type.
|
59 |
-
* @return bool
|
60 |
-
*/
|
61 |
-
function is_step_post_type( $post_type = '' ) {
|
62 |
-
|
63 |
-
if ( $this->get_step_post_type() === $this->current_post_type( $post_type ) ) {
|
64 |
-
|
65 |
-
return true;
|
66 |
-
}
|
67 |
-
|
68 |
-
return false;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Check if post type is of flow.
|
73 |
-
*
|
74 |
-
* @param string $post_type post type.
|
75 |
-
* @return bool
|
76 |
-
*/
|
77 |
-
function is_flow_post_type( $post_type = '' ) {
|
78 |
-
|
79 |
-
if ( $this->get_flow_post_type() === $this->current_post_type( $post_type ) ) {
|
80 |
-
|
81 |
-
return true;
|
82 |
-
}
|
83 |
-
|
84 |
-
return false;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Get post type of step.
|
89 |
-
*
|
90 |
-
* @return string
|
91 |
-
*/
|
92 |
-
function get_step_post_type() {
|
93 |
-
|
94 |
-
return CARTFLOWS_STEP_POST_TYPE;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Get post type of flow.
|
99 |
-
*
|
100 |
-
* @return string
|
101 |
-
*/
|
102 |
-
function get_flow_post_type() {
|
103 |
-
|
104 |
-
return CARTFLOWS_FLOW_POST_TYPE;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Get flow id
|
109 |
-
*
|
110 |
-
* @return int
|
111 |
-
*/
|
112 |
-
function get_flow_id() {
|
113 |
-
|
114 |
-
global $post;
|
115 |
-
|
116 |
-
return get_post_meta( $post->ID, 'wcf-flow-id', true );
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Get flow id by step
|
121 |
-
*
|
122 |
-
* @param int $step_id step ID.
|
123 |
-
* @return int
|
124 |
-
*/
|
125 |
-
function get_flow_id_from_step_id( $step_id ) {
|
126 |
-
|
127 |
-
return get_post_meta( $step_id, 'wcf-flow-id', true );
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Get flow steps by id
|
132 |
-
*
|
133 |
-
* @param int $flow_id flow ID.
|
134 |
-
* @return int
|
135 |
-
*/
|
136 |
-
function get_flow_steps( $flow_id ) {
|
137 |
-
|
138 |
-
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
139 |
-
|
140 |
-
if ( is_array( $steps ) && ! empty( $steps ) ) {
|
141 |
-
return $steps;
|
142 |
-
}
|
143 |
-
|
144 |
-
return false;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Get template type of step
|
149 |
-
*
|
150 |
-
* @param int $step_id step ID.
|
151 |
-
* @return int
|
152 |
-
*/
|
153 |
-
function get_step_type( $step_id ) {
|
154 |
-
|
155 |
-
return get_post_meta( $step_id, 'wcf-step-type', true );
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Get next id for step
|
160 |
-
*
|
161 |
-
* @param int $flow_id flow ID.
|
162 |
-
* @param int $step_id step ID.
|
163 |
-
* @return bool
|
164 |
-
*/
|
165 |
-
function get_next_step_id( $flow_id, $step_id ) {
|
166 |
-
|
167 |
-
$steps = $this->get_flow_steps( $flow_id );
|
168 |
-
$step_id = intval( $step_id );
|
169 |
-
|
170 |
-
if ( ! $steps ) {
|
171 |
-
return false;
|
172 |
-
}
|
173 |
-
|
174 |
-
foreach ( $steps as $i => $step ) {
|
175 |
-
|
176 |
-
if ( intval( $step['id'] ) === $step_id ) {
|
177 |
-
|
178 |
-
$next_i = $i + 1;
|
179 |
-
|
180 |
-
if ( isset( $steps[ $next_i ] ) ) {
|
181 |
-
|
182 |
-
$navigation = $steps[ $next_i ];
|
183 |
-
|
184 |
-
return intval( $navigation['id'] );
|
185 |
-
}
|
186 |
-
|
187 |
-
break;
|
188 |
-
}
|
189 |
-
}
|
190 |
-
|
191 |
-
return false;
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Get next id for step
|
196 |
-
*
|
197 |
-
* @param int $order_id order ID.
|
198 |
-
* @return int
|
199 |
-
*/
|
200 |
-
function get_flow_id_from_order( $order_id ) {
|
201 |
-
|
202 |
-
$flow_id = get_post_meta( $order_id, '_wcf_flow_id', true );
|
203 |
-
|
204 |
-
return intval( $flow_id );
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Get checkout id for order
|
209 |
-
*
|
210 |
-
* @param int $order_id order ID.
|
211 |
-
* @return int
|
212 |
-
*/
|
213 |
-
function get_checkout_id_from_order( $order_id ) {
|
214 |
-
|
215 |
-
$checkout_id = get_post_meta( $order_id, '_wcf_checkout_id', true );
|
216 |
-
|
217 |
-
return intval( $checkout_id );
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* We are using this function mostly in ajax on checkout page
|
222 |
-
*
|
223 |
-
* @return bool
|
224 |
-
*/
|
225 |
-
function get_checkout_id_from_post_data() {
|
226 |
-
|
227 |
-
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
228 |
-
|
229 |
-
$checkout_id = filter_var( $_POST['_wcf_checkout_id'], FILTER_SANITIZE_NUMBER_INT );
|
230 |
-
|
231 |
-
return intval( $checkout_id );
|
232 |
-
}
|
233 |
-
|
234 |
-
return false;
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* We are using this function mostly in ajax on checkout page
|
239 |
-
*
|
240 |
-
* @return bool
|
241 |
-
*/
|
242 |
-
function get_flow_id_from_post_data() {
|
243 |
-
|
244 |
-
if ( isset( $_POST['_wcf_flow_id'] ) ) {
|
245 |
-
|
246 |
-
$flow_id = filter_var( $_POST['_wcf_flow_id'], FILTER_SANITIZE_NUMBER_INT );
|
247 |
-
|
248 |
-
return intval( $flow_id );
|
249 |
-
}
|
250 |
-
|
251 |
-
return false;
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Check for thank you page
|
256 |
-
*
|
257 |
-
* @param int $step_id step ID.
|
258 |
-
* @return bool
|
259 |
-
*/
|
260 |
-
function check_is_thankyou_page( $step_id ) {
|
261 |
-
|
262 |
-
$step_type = $this->get_step_type( $step_id );
|
263 |
-
|
264 |
-
if ( 'thankyou' === $step_type ) {
|
265 |
-
|
266 |
-
return true;
|
267 |
-
}
|
268 |
-
|
269 |
-
return false;
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Check for offer page
|
274 |
-
*
|
275 |
-
* @param int $step_id step ID.
|
276 |
-
* @return bool
|
277 |
-
*/
|
278 |
-
function check_is_offer_page( $step_id ) {
|
279 |
-
|
280 |
-
$step_type = $this->get_step_type( $step_id );
|
281 |
-
|
282 |
-
if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
|
283 |
-
|
284 |
-
return true;
|
285 |
-
}
|
286 |
-
|
287 |
-
return false;
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Check if loaded page requires woo.
|
292 |
-
*
|
293 |
-
* @return bool
|
294 |
-
*/
|
295 |
-
function check_is_woo_required_page() {
|
296 |
-
|
297 |
-
global $post;
|
298 |
-
$step_id = $post->ID;
|
299 |
-
$woo_not_required_type = array( 'landing' );
|
300 |
-
$step_type = $this->get_step_type( $step_id );
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
*
|
307 |
-
*
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
wcf_maybe_define_constant( '
|
313 |
-
wcf_maybe_define_constant( '
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
*
|
321 |
-
*
|
322 |
-
* @
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
*
|
336 |
-
*
|
337 |
-
* @
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
$
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
$
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
$
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
'
|
363 |
-
'
|
364 |
-
'
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
*
|
371 |
-
*
|
372 |
-
* @
|
373 |
-
* @
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
*
|
387 |
-
*
|
388 |
-
* @
|
389 |
-
* @
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
*
|
404 |
-
*
|
405 |
-
*
|
406 |
-
*
|
407 |
-
* @param
|
408 |
-
* @param string $
|
409 |
-
*
|
410 |
-
*
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Utils.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Cartflows_Utils.
|
14 |
+
*/
|
15 |
+
class Cartflows_Utils {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Member Variable
|
19 |
+
*
|
20 |
+
* @var instance
|
21 |
+
*/
|
22 |
+
private static $instance;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Initiator
|
26 |
+
*/
|
27 |
+
public static function get_instance() {
|
28 |
+
if ( ! isset( self::$instance ) ) {
|
29 |
+
self::$instance = new self();
|
30 |
+
}
|
31 |
+
return self::$instance;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Constructor
|
36 |
+
*/
|
37 |
+
public function __construct() {
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get current post type
|
42 |
+
*
|
43 |
+
* @param string $post_type post type.
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function current_post_type( $post_type = '' ) {
|
47 |
+
|
48 |
+
if ( '' === $post_type ) {
|
49 |
+
$post_type = get_post_type();
|
50 |
+
}
|
51 |
+
|
52 |
+
return $post_type;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Check if post type is of step.
|
57 |
+
*
|
58 |
+
* @param string $post_type post type.
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
public function is_step_post_type( $post_type = '' ) {
|
62 |
+
|
63 |
+
if ( $this->get_step_post_type() === $this->current_post_type( $post_type ) ) {
|
64 |
+
|
65 |
+
return true;
|
66 |
+
}
|
67 |
+
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Check if post type is of flow.
|
73 |
+
*
|
74 |
+
* @param string $post_type post type.
|
75 |
+
* @return bool
|
76 |
+
*/
|
77 |
+
public function is_flow_post_type( $post_type = '' ) {
|
78 |
+
|
79 |
+
if ( $this->get_flow_post_type() === $this->current_post_type( $post_type ) ) {
|
80 |
+
|
81 |
+
return true;
|
82 |
+
}
|
83 |
+
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Get post type of step.
|
89 |
+
*
|
90 |
+
* @return string
|
91 |
+
*/
|
92 |
+
public function get_step_post_type() {
|
93 |
+
|
94 |
+
return CARTFLOWS_STEP_POST_TYPE;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Get post type of flow.
|
99 |
+
*
|
100 |
+
* @return string
|
101 |
+
*/
|
102 |
+
public function get_flow_post_type() {
|
103 |
+
|
104 |
+
return CARTFLOWS_FLOW_POST_TYPE;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get flow id
|
109 |
+
*
|
110 |
+
* @return int
|
111 |
+
*/
|
112 |
+
public function get_flow_id() {
|
113 |
+
|
114 |
+
global $post;
|
115 |
+
|
116 |
+
return get_post_meta( $post->ID, 'wcf-flow-id', true );
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get flow id by step
|
121 |
+
*
|
122 |
+
* @param int $step_id step ID.
|
123 |
+
* @return int
|
124 |
+
*/
|
125 |
+
public function get_flow_id_from_step_id( $step_id ) {
|
126 |
+
|
127 |
+
return get_post_meta( $step_id, 'wcf-flow-id', true );
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Get flow steps by id
|
132 |
+
*
|
133 |
+
* @param int $flow_id flow ID.
|
134 |
+
* @return int
|
135 |
+
*/
|
136 |
+
public function get_flow_steps( $flow_id ) {
|
137 |
+
|
138 |
+
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
139 |
+
|
140 |
+
if ( is_array( $steps ) && ! empty( $steps ) ) {
|
141 |
+
return $steps;
|
142 |
+
}
|
143 |
+
|
144 |
+
return false;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Get template type of step
|
149 |
+
*
|
150 |
+
* @param int $step_id step ID.
|
151 |
+
* @return int
|
152 |
+
*/
|
153 |
+
public function get_step_type( $step_id ) {
|
154 |
+
|
155 |
+
return get_post_meta( $step_id, 'wcf-step-type', true );
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Get next id for step
|
160 |
+
*
|
161 |
+
* @param int $flow_id flow ID.
|
162 |
+
* @param int $step_id step ID.
|
163 |
+
* @return bool
|
164 |
+
*/
|
165 |
+
public function get_next_step_id( $flow_id, $step_id ) {
|
166 |
+
|
167 |
+
$steps = $this->get_flow_steps( $flow_id );
|
168 |
+
$step_id = intval( $step_id );
|
169 |
+
|
170 |
+
if ( ! $steps ) {
|
171 |
+
return false;
|
172 |
+
}
|
173 |
+
|
174 |
+
foreach ( $steps as $i => $step ) {
|
175 |
+
|
176 |
+
if ( intval( $step['id'] ) === $step_id ) {
|
177 |
+
|
178 |
+
$next_i = $i + 1;
|
179 |
+
|
180 |
+
if ( isset( $steps[ $next_i ] ) ) {
|
181 |
+
|
182 |
+
$navigation = $steps[ $next_i ];
|
183 |
+
|
184 |
+
return intval( $navigation['id'] );
|
185 |
+
}
|
186 |
+
|
187 |
+
break;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
return false;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Get next id for step
|
196 |
+
*
|
197 |
+
* @param int $order_id order ID.
|
198 |
+
* @return int
|
199 |
+
*/
|
200 |
+
public function get_flow_id_from_order( $order_id ) {
|
201 |
+
|
202 |
+
$flow_id = get_post_meta( $order_id, '_wcf_flow_id', true );
|
203 |
+
|
204 |
+
return intval( $flow_id );
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Get checkout id for order
|
209 |
+
*
|
210 |
+
* @param int $order_id order ID.
|
211 |
+
* @return int
|
212 |
+
*/
|
213 |
+
public function get_checkout_id_from_order( $order_id ) {
|
214 |
+
|
215 |
+
$checkout_id = get_post_meta( $order_id, '_wcf_checkout_id', true );
|
216 |
+
|
217 |
+
return intval( $checkout_id );
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* We are using this function mostly in ajax on checkout page
|
222 |
+
*
|
223 |
+
* @return bool
|
224 |
+
*/
|
225 |
+
public function get_checkout_id_from_post_data() {
|
226 |
+
|
227 |
+
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
228 |
+
|
229 |
+
$checkout_id = filter_var( wp_unslash( $_POST['_wcf_checkout_id'] ), FILTER_SANITIZE_NUMBER_INT );
|
230 |
+
|
231 |
+
return intval( $checkout_id );
|
232 |
+
}
|
233 |
+
|
234 |
+
return false;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* We are using this function mostly in ajax on checkout page
|
239 |
+
*
|
240 |
+
* @return bool
|
241 |
+
*/
|
242 |
+
public function get_flow_id_from_post_data() {
|
243 |
+
|
244 |
+
if ( isset( $_POST['_wcf_flow_id'] ) ) {
|
245 |
+
|
246 |
+
$flow_id = filter_var( wp_unslash( $_POST['_wcf_flow_id'] ), FILTER_SANITIZE_NUMBER_INT );
|
247 |
+
|
248 |
+
return intval( $flow_id );
|
249 |
+
}
|
250 |
+
|
251 |
+
return false;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Check for thank you page
|
256 |
+
*
|
257 |
+
* @param int $step_id step ID.
|
258 |
+
* @return bool
|
259 |
+
*/
|
260 |
+
public function check_is_thankyou_page( $step_id ) {
|
261 |
+
|
262 |
+
$step_type = $this->get_step_type( $step_id );
|
263 |
+
|
264 |
+
if ( 'thankyou' === $step_type ) {
|
265 |
+
|
266 |
+
return true;
|
267 |
+
}
|
268 |
+
|
269 |
+
return false;
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Check for offer page
|
274 |
+
*
|
275 |
+
* @param int $step_id step ID.
|
276 |
+
* @return bool
|
277 |
+
*/
|
278 |
+
public function check_is_offer_page( $step_id ) {
|
279 |
+
|
280 |
+
$step_type = $this->get_step_type( $step_id );
|
281 |
+
|
282 |
+
if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
|
283 |
+
|
284 |
+
return true;
|
285 |
+
}
|
286 |
+
|
287 |
+
return false;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Check if loaded page requires woo.
|
292 |
+
*
|
293 |
+
* @return bool
|
294 |
+
*/
|
295 |
+
public function check_is_woo_required_page() {
|
296 |
+
|
297 |
+
global $post;
|
298 |
+
$step_id = $post->ID;
|
299 |
+
$woo_not_required_type = array( 'landing' );
|
300 |
+
$step_type = $this->get_step_type( $step_id );
|
301 |
+
return ( ! in_array( $step_type, $woo_not_required_type, true ) );
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Define constant for cache
|
306 |
+
*
|
307 |
+
* @return void
|
308 |
+
*/
|
309 |
+
public function do_not_cache() {
|
310 |
+
|
311 |
+
wcf_maybe_define_constant( 'DONOTCACHEPAGE', true );
|
312 |
+
wcf_maybe_define_constant( 'DONOTCACHEOBJECT', true );
|
313 |
+
wcf_maybe_define_constant( 'DONOTCACHEDB', true );
|
314 |
+
|
315 |
+
nocache_headers();
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Get linking url
|
320 |
+
*
|
321 |
+
* @param array $args query args.
|
322 |
+
* @return string
|
323 |
+
*/
|
324 |
+
public function get_linking_url( $args = array() ) {
|
325 |
+
|
326 |
+
$url = get_home_url();
|
327 |
+
|
328 |
+
$url = add_query_arg( $args, $url );
|
329 |
+
|
330 |
+
return $url;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Get assets urls
|
335 |
+
*
|
336 |
+
* @return array
|
337 |
+
* @since 1.1.6
|
338 |
+
*/
|
339 |
+
public function get_assets_path() {
|
340 |
+
|
341 |
+
$rtl = '';
|
342 |
+
|
343 |
+
if ( is_rtl() ) {
|
344 |
+
$rtl = '-rtl';
|
345 |
+
}
|
346 |
+
|
347 |
+
$file_prefix = '';
|
348 |
+
$dir_name = '';
|
349 |
+
|
350 |
+
$is_min = apply_filters( 'cartflows_load_min_assets', false );
|
351 |
+
|
352 |
+
if ( $is_min ) {
|
353 |
+
$file_prefix = '.min';
|
354 |
+
$dir_name = 'min-';
|
355 |
+
}
|
356 |
+
|
357 |
+
$js_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'js/';
|
358 |
+
$css_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'css/';
|
359 |
+
|
360 |
+
return array(
|
361 |
+
'css' => $css_gen_path,
|
362 |
+
'js' => $js_gen_path,
|
363 |
+
'file_prefix' => $file_prefix,
|
364 |
+
'rtl' => $rtl,
|
365 |
+
);
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Get assets css url
|
370 |
+
*
|
371 |
+
* @param string $file file name.
|
372 |
+
* @return string
|
373 |
+
* @since 1.1.6
|
374 |
+
*/
|
375 |
+
public function get_css_url( $file ) {
|
376 |
+
|
377 |
+
$assets_vars = wcf()->assets_vars;
|
378 |
+
|
379 |
+
$url = $assets_vars['css'] . $file . $assets_vars['rtl'] . $assets_vars['file_prefix'] . '.css';
|
380 |
+
|
381 |
+
return $url;
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
* Get assets js url
|
386 |
+
*
|
387 |
+
* @param string $file file name.
|
388 |
+
* @return string
|
389 |
+
* @since 1.1.6
|
390 |
+
*/
|
391 |
+
public function get_js_url( $file ) {
|
392 |
+
|
393 |
+
$assets_vars = wcf()->assets_vars;
|
394 |
+
|
395 |
+
$url = $assets_vars['js'] . $file . $assets_vars['file_prefix'] . '.js';
|
396 |
+
|
397 |
+
return $url;
|
398 |
+
}
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Get a specific property of an array without needing to check if that property exists.
|
403 |
+
*
|
404 |
+
* Provide a default value if you want to return a specific value if the property is not set.
|
405 |
+
*
|
406 |
+
* @param array $array Array from which the property's value should be retrieved.
|
407 |
+
* @param string $prop Name of the property to be retrieved.
|
408 |
+
* @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null.
|
409 |
+
*
|
410 |
+
* @return null|string|mixed The value
|
411 |
+
*/
|
412 |
+
function wcf_get_prop( $array, $prop, $default = null ) {
|
413 |
+
|
414 |
+
if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) {
|
415 |
+
return $default;
|
416 |
+
}
|
417 |
+
|
418 |
+
if ( isset( $array[ $prop ] ) ) {
|
419 |
+
$value = $array[ $prop ];
|
420 |
+
} else {
|
421 |
+
$value = '';
|
422 |
+
}
|
423 |
+
|
424 |
+
return empty( $value ) && null !== $default ? $default : $value;
|
425 |
+
}
|
|
classes/class-cartflows-wizard.php
CHANGED
@@ -1,679 +1,679 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows- Onboarding Wizard
|
4 |
-
*
|
5 |
-
* @package cartflows
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit;
|
10 |
-
}
|
11 |
-
|
12 |
-
if ( ! class_exists( 'CartFlows_Wizard' ) ) :
|
13 |
-
|
14 |
-
/**
|
15 |
-
* CartFlows_Wizard class.
|
16 |
-
*/
|
17 |
-
class CartFlows_Wizard {
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Hook in tabs.
|
21 |
-
*/
|
22 |
-
public function __construct() {
|
23 |
-
|
24 |
-
if ( apply_filters( 'cartflows_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) {
|
25 |
-
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
|
26 |
-
add_action( 'admin_init', array( $this, 'setup_wizard' ) );
|
27 |
-
add_action( 'admin_notices', array( $this, 'show_setup_wizard' ) );
|
28 |
-
add_action( 'wp_ajax_page_builder_step_save', array( $this, 'page_builder_step_save' ) );
|
29 |
-
add_action( 'wp_ajax_page_builder_save_option', array( $this, 'save_page_builder_option' ) );
|
30 |
-
add_action( 'admin_head', array( $this, 'add_mautic_form_script' ) );
|
31 |
-
add_action( 'woocommerce_installed', array( $this, 'disable_woo_setup_redirect' ) );
|
32 |
-
|
33 |
-
add_action( 'wp_ajax_wcf_activate_wc_plugins', array( $this, 'activate_wc_plugins' ) );
|
34 |
-
|
35 |
-
add_action( 'admin_init', array( $this, 'hide_notices' ) );
|
36 |
-
|
37 |
-
}
|
38 |
-
}
|
39 |
-
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Hide a notice if the GET variable is set.
|
43 |
-
*/
|
44 |
-
public function hide_notices() {
|
45 |
-
|
46 |
-
if ( ! isset( $_GET['wcf-hide-notice'] ) ) {
|
47 |
-
return;
|
48 |
-
}
|
49 |
-
|
50 |
-
$wcf_hide_notice = filter_input( INPUT_GET, 'wcf-hide-notice', FILTER_SANITIZE_STRING );
|
51 |
-
$_wcf_notice_nonce = filter_input( INPUT_GET, '_wcf_notice_nonce', FILTER_SANITIZE_STRING );
|
52 |
-
|
53 |
-
if ( $wcf_hide_notice && $_wcf_notice_nonce && wp_verify_nonce( sanitize_key( wp_unslash( $_wcf_notice_nonce ) ), 'wcf_hide_notices_nonce' ) ) {
|
54 |
-
update_option( 'wcf_setup_skipped', true );
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Disable the woo redirect for new setup.
|
60 |
-
*/
|
61 |
-
function disable_woo_setup_redirect() {
|
62 |
-
|
63 |
-
if ( empty( $_GET['page'] ) || 'cartflow-setup' !== $_GET['page'] ) {
|
64 |
-
return;
|
65 |
-
}
|
66 |
-
|
67 |
-
delete_transient( '_wc_activation_redirect' );
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Show action links on the plugin screen.
|
72 |
-
*
|
73 |
-
* @since 1.0.0
|
74 |
-
* @return void
|
75 |
-
*/
|
76 |
-
function show_setup_wizard() {
|
77 |
-
|
78 |
-
$status = get_option( 'wcf_setup_complete', false );
|
79 |
-
$skip_setup = get_option( 'wcf_setup_skipped', false );
|
80 |
-
|
81 |
-
if ( false === $status && ! $skip_setup ) { ?>
|
82 |
-
<div class="notice notice-info">
|
83 |
-
<p><b><?php _e( 'Thanks for installing and using CartFlows!', 'cartflows' ); ?></b></p>
|
84 |
-
<p><?php _e( 'It is easy to use the CartFlows. Please use the setup wizard to quick start setup.', 'cartflows' ); ?></p>
|
85 |
-
<p>
|
86 |
-
<a href="<?php echo esc_url( admin_url( 'index.php?page=cartflow-setup' ) ); ?>" class="button button-primary"> <?php _e( 'Start Wizard', 'cartflows' ); ?></a>
|
87 |
-
<a class="button-secondary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcf-hide-notice', 'install' ), 'wcf_hide_notices_nonce', '_wcf_notice_nonce' ) ); ?>"><?php _e( 'Skip Setup', 'cartflows' ); ?></a>
|
88 |
-
</p>
|
89 |
-
</div>
|
90 |
-
<?php
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Add admin menus/screens.
|
96 |
-
*/
|
97 |
-
public function admin_menus() {
|
98 |
-
|
99 |
-
if ( empty( $_GET['page'] ) || 'cartflow-setup' !== $_GET['page'] ) {
|
100 |
-
return;
|
101 |
-
}
|
102 |
-
|
103 |
-
add_dashboard_page( '', '', 'manage_options', 'cartflow-setup', '' );
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Show the setup wizard.
|
108 |
-
*/
|
109 |
-
public function setup_wizard() {
|
110 |
-
|
111 |
-
if ( empty( $_GET['page'] ) || 'cartflow-setup' !== $_GET['page'] ) {
|
112 |
-
return;
|
113 |
-
}
|
114 |
-
|
115 |
-
$this->steps = array(
|
116 |
-
'basic-config' => array(
|
117 |
-
'name' => __( 'Welcome', 'cartflows' ),
|
118 |
-
'view' => array( $this, 'welcome_step' ),
|
119 |
-
'handler' => array( $this, 'welcome_step_save' ),
|
120 |
-
),
|
121 |
-
'page-builder' => array(
|
122 |
-
'name' => __( 'Page Builder', 'cartflows' ),
|
123 |
-
'view' => array( $this, 'page_builder_step' ),
|
124 |
-
),
|
125 |
-
'checkout' => array(
|
126 |
-
'name' => __( 'Checkout', 'cartflows' ),
|
127 |
-
'view' => array( $this, 'checkout_step' ),
|
128 |
-
),
|
129 |
-
'training' => array(
|
130 |
-
'name' => __( 'Training', 'cartflows' ),
|
131 |
-
'view' => array( $this, 'training_step' ),
|
132 |
-
),
|
133 |
-
'setup-ready' => array(
|
134 |
-
'name' => __( 'Ready!', 'cartflows' ),
|
135 |
-
'view' => array( $this, 'ready_step' ),
|
136 |
-
'handler' => '',
|
137 |
-
),
|
138 |
-
);
|
139 |
-
|
140 |
-
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
|
141 |
-
|
142 |
-
wp_enqueue_style( 'cartflows-setup', CARTFLOWS_URL . 'admin/assets/css/setup-wizard.css', array( 'dashicons' ), CARTFLOWS_VER );
|
143 |
-
wp_style_add_data( 'cartflows-setup', 'rtl', 'replace' );
|
144 |
-
|
145 |
-
wp_enqueue_script( 'cartflows-setup', CARTFLOWS_URL . 'admin/assets/js/setup-wizard.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
|
146 |
-
|
147 |
-
wp_localize_script( 'cartflows-setup', 'cartflows_setup_vars', self::localize_vars() );
|
148 |
-
|
149 |
-
wp_enqueue_media();
|
150 |
-
|
151 |
-
if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
|
152 |
-
call_user_func( $this->steps[ $this->step ]['handler'] );
|
153 |
-
}
|
154 |
-
|
155 |
-
ob_start();
|
156 |
-
$this->setup_wizard_header();
|
157 |
-
$this->setup_wizard_steps();
|
158 |
-
$this->setup_wizard_content();
|
159 |
-
$this->setup_wizard_footer();
|
160 |
-
exit;
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Get current step slug
|
165 |
-
*/
|
166 |
-
public function get_current_step_slug() {
|
167 |
-
$keys = array_keys( $this->steps );
|
168 |
-
return $keys[ array_search( $this->step, array_keys( $this->steps ) ) ];
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Get previous step link
|
173 |
-
*/
|
174 |
-
public function get_prev_step_link() {
|
175 |
-
$keys = array_keys( $this->steps );
|
176 |
-
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) - 1 ] );
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Get next step link
|
181 |
-
*/
|
182 |
-
public function get_next_step_link() {
|
183 |
-
$keys = array_keys( $this->steps );
|
184 |
-
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) + 1 ] );
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Get next step link
|
189 |
-
*/
|
190 |
-
public function get_next_step_plain_link() {
|
191 |
-
$keys = array_keys( $this->steps );
|
192 |
-
$step_index = array_search( $this->step, $keys );
|
193 |
-
$step_index = ( count( $keys ) == $step_index + 1 ) ? $step_index : $step_index + 1;
|
194 |
-
$step = $keys[
|
195 |
-
return admin_url( 'index.php?page=cartflow-setup&step=' . $step );
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Setup Wizard Header.
|
200 |
-
*/
|
201 |
-
public function setup_wizard_header() {
|
202 |
-
?>
|
203 |
-
<!DOCTYPE html>
|
204 |
-
<html>
|
205 |
-
<head>
|
206 |
-
<meta name="viewport" content="width=device-width" />
|
207 |
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
208 |
-
<title><?php _e( 'CartFlows Setup', 'cartflows' ); ?></title>
|
209 |
-
|
210 |
-
<script type="text/javascript">
|
211 |
-
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
212 |
-
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>';
|
213 |
-
var pagenow = '';
|
214 |
-
</script>
|
215 |
-
<?php wp_print_scripts( array( 'cartflows-setup' ) ); ?>
|
216 |
-
<?php do_action( 'admin_print_styles' ); ?>
|
217 |
-
<?php do_action( 'admin_head' ); ?>
|
218 |
-
</head>
|
219 |
-
<body class="cartflows-setup wp-core-ui cartflows-step-<?php echo esc_attr( $this->get_current_step_slug() ); ?>">
|
220 |
-
<div id="cartflows-logo">
|
221 |
-
<img height="40" class="wcf-logo" src="<?php echo CARTFLOWS_URL . 'assets/images/cartflows-logo.svg'; ?>" />
|
222 |
-
</div>
|
223 |
-
<?php
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Setup Wizard Footer.
|
228 |
-
*/
|
229 |
-
public function setup_wizard_footer() {
|
230 |
-
|
231 |
-
$admin_url = admin_url( 'admin.php?page=cartflows_settings' );
|
232 |
-
?>
|
233 |
-
<div class="close-button-wrapper">
|
234 |
-
<a href="<?php echo esc_url( $admin_url ); ?>" class="wizard-close-link" ><?php _e( 'Exit Setup Wizard', 'cartflows' ); ?></a>
|
235 |
-
</div>
|
236 |
-
</body>
|
237 |
-
</html>
|
238 |
-
<?php
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Output the steps.
|
243 |
-
*/
|
244 |
-
public function setup_wizard_steps() {
|
245 |
-
|
246 |
-
$ouput_steps = $this->steps;
|
247 |
-
?>
|
248 |
-
<ol class="cartflows-setup-steps">
|
249 |
-
<?php
|
250 |
-
foreach ( $ouput_steps as $step_key => $step ) :
|
251 |
-
$classes = '';
|
252 |
-
$activated = false;
|
253 |
-
if ( $step_key === $this->step ) {
|
254 |
-
$classes = 'active';
|
255 |
-
$activated = true;
|
256 |
-
} elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
|
257 |
-
$classes = 'done';
|
258 |
-
$activated = true;
|
259 |
-
}
|
260 |
-
?>
|
261 |
-
<li class="<?php echo esc_attr( $classes ); ?>">
|
262 |
-
<span><?php echo esc_html( $step['name'] ); ?></span>
|
263 |
-
</li>
|
264 |
-
<?php endforeach; ?>
|
265 |
-
</ol>
|
266 |
-
<?php
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Output the content for the current step.
|
271 |
-
*/
|
272 |
-
public function setup_wizard_content() {
|
273 |
-
?>
|
274 |
-
<input type="hidden" class="wcf-redirect-link" data-redirect-link="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>" >
|
275 |
-
<?php
|
276 |
-
|
277 |
-
echo '<div class="cartflows-setup-content">';
|
278 |
-
call_user_func( $this->steps[ $this->step ]['view'] );
|
279 |
-
echo '</div>';
|
280 |
-
}
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Introduction step.
|
284 |
-
*/
|
285 |
-
public function welcome_step() {
|
286 |
-
?>
|
287 |
-
<h1><?php _e( 'Welcome to CartFlows!', 'cartflows' ); ?></h1>
|
288 |
-
<p><?php _e( 'Thank you for choosing CartFlows to get more leads, increase conversions, & maximize profits. This short setup wizard will guide you though configuring CartFlows and creating your first funnel.', 'cartflows' ); ?></p>
|
289 |
-
<form method="post">
|
290 |
-
<div class="cartflows-setup-actions step">
|
291 |
-
<div class="button-prev-wrap">
|
292 |
-
</div>
|
293 |
-
<div class="button-next-wrap">
|
294 |
-
<input type="submit" class="uct-activate button-primary button button-large " value="<?php _e( 'Lets Go »', 'cartflows' ); ?>" name="save_step" />
|
295 |
-
</div>
|
296 |
-
<?php wp_nonce_field( 'cartflow-setup' ); ?>
|
297 |
-
</div>
|
298 |
-
</form>
|
299 |
-
<?php
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Save Locale Settings.
|
304 |
-
*/
|
305 |
-
public function welcome_step_save() {
|
306 |
-
check_admin_referer( 'cartflow-setup' );
|
307 |
-
|
308 |
-
// Update site title & tagline.
|
309 |
-
$redirect_url = $this->get_next_step_link();
|
310 |
-
|
311 |
-
|
312 |
-
exit;
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Locale settings
|
317 |
-
*/
|
318 |
-
public function page_builder_step() {
|
319 |
-
?>
|
320 |
-
|
321 |
-
<h1><?php _e( 'Page Builder Setup', 'cartflows' ); ?></h1>
|
322 |
-
<p class="description"><?php _e( 'Please select a page builder you would like to use with CartFlows.', 'cartflows' ); ?></p>
|
323 |
-
<form method="post">
|
324 |
-
<table class="cartflows-table widefat">
|
325 |
-
<tr class="cartflows-row">
|
326 |
-
<td class="cartflows-row-heading">
|
327 |
-
<label><?php esc_html_e( 'Select Page Builder', 'cartflows' ); ?></label>
|
328 |
-
</td>
|
329 |
-
<td class="cartflows-row-content">
|
330 |
-
<?php
|
331 |
-
$installed_plugins = get_plugins();
|
332 |
-
$plugins = array(
|
333 |
-
array(
|
334 |
-
'title' => __( 'Elementor', 'cartflows' ),
|
335 |
-
'value' => 'elementor',
|
336 |
-
'data' => array(
|
337 |
-
'slug' => 'elementor',
|
338 |
-
'init' => 'elementor/elementor.php',
|
339 |
-
'active' => is_plugin_active( 'elementor/elementor.php' ) ? 'yes' : 'no',
|
340 |
-
'install' => isset( $installed_plugins['elementor/elementor.php'] ) ? 'yes' : 'no',
|
341 |
-
),
|
342 |
-
),
|
343 |
-
array(
|
344 |
-
'title' => __( 'Beaver Builder Plugin (Lite Version)', 'cartflows' ),
|
345 |
-
'value' => 'beaver-builder',
|
346 |
-
'data' => array(
|
347 |
-
'slug' => 'beaver-builder-lite-version',
|
348 |
-
'init' => 'beaver-builder-lite-version/fl-builder.php',
|
349 |
-
'active' => is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ? 'yes' : 'no',
|
350 |
-
'install' => isset( $installed_plugins['beaver-builder-lite-version/fl-builder.php'] ) ? 'yes' : 'no',
|
351 |
-
),
|
352 |
-
),
|
353 |
-
array(
|
354 |
-
'title' => __( 'Divi', 'cartflows' ),
|
355 |
-
'value' => 'divi',
|
356 |
-
'data' => array(
|
357 |
-
'slug' => 'divi',
|
358 |
-
'init' => 'divi',
|
359 |
-
'active' => 'yes',
|
360 |
-
'install' => 'NA',
|
361 |
-
),
|
362 |
-
),
|
363 |
-
array(
|
364 |
-
'title' => __( 'Other', 'cartflows' ),
|
365 |
-
'value' => 'other',
|
366 |
-
'data' => array(
|
367 |
-
'slug' => 'other',
|
368 |
-
'init' => false,
|
369 |
-
'active' => 'yes',
|
370 |
-
'install' => 'NA',
|
371 |
-
),
|
372 |
-
),
|
373 |
-
);
|
374 |
-
?>
|
375 |
-
<input type="hidden" name="save-pb-input" id="save-pb-option" value="1" />
|
376 |
-
<select name="page-builder" class="page-builder-list" data-redirect-link="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>">
|
377 |
-
<?php
|
378 |
-
foreach ( $plugins as $key => $plugin ) {
|
379 |
-
echo '<option value="' . esc_attr( $plugin['value'] ) . '" data-install="' . esc_attr( $plugin['data']['install'] ) . '" data-active="' . esc_attr( $plugin['data']['active'] ) . '" data-slug="' . esc_attr( $plugin['data']['slug'] ) . '" data-init="' . esc_attr( $plugin['data']['init'] ) . '">' . esc_html( $plugin['title'] ) . '</option>';
|
380 |
-
}
|
381 |
-
?>
|
382 |
-
</select>
|
383 |
-
</td>
|
384 |
-
</tr>
|
385 |
-
</table>
|
386 |
-
<p><?php _e( 'While CartFlows Should work with most page builders, we offer templates for the above page builders.', 'cartflows' ); ?></p>
|
387 |
-
<div class="cartflows-setup-actions step">
|
388 |
-
<div class="button-prev-wrap">
|
389 |
-
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" ><?php _e( '« Previous', 'cartflows' ); ?></a>
|
390 |
-
</div>
|
391 |
-
<div class="button-next-wrap">
|
392 |
-
<a href="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>" class="button button-large button-next" ><?php _e( 'Skip this step', 'cartflows' ); ?></a>
|
393 |
-
<a href="#" class="button button-primary wcf-install-plugins"><?php _e( 'Next »', 'cartflows' ); ?></a>
|
394 |
-
</div>
|
395 |
-
<?php wp_nonce_field( 'cartflow-setup' ); ?>
|
396 |
-
</div>
|
397 |
-
</form>
|
398 |
-
<?php
|
399 |
-
}
|
400 |
-
|
401 |
-
/**
|
402 |
-
* Render checkout step.
|
403 |
-
*/
|
404 |
-
public function checkout_step() {
|
405 |
-
|
406 |
-
$installed_plugins = get_plugins();
|
407 |
-
$is_wc_installed = isset( $installed_plugins['woocommerce/woocommerce.php'] ) ? 'yes' : 'no';
|
408 |
-
$is_wcf_ca_installed = isset( $installed_plugins['woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php'] ) ? 'yes' : 'no';
|
409 |
-
$is_active = class_exists( 'WooCommerce' ) ? 'yes' : 'no';
|
410 |
-
$is_wcf_ca_active = class_exists( 'CARTFLOWS_CA_Loader' ) ? 'yes' : 'no';
|
411 |
-
?>
|
412 |
-
<h1><?php _e( 'Choose a checkout', 'cartflows' ); ?></h1>
|
413 |
-
<div class="cartflows-setup-message">
|
414 |
-
<p>
|
415 |
-
<?php _e( 'While CartFlows is designed to use WooCommerce sell digital and physical products, not all funnels need a checkout system.', 'cartflows' ); ?>
|
416 |
-
</p>
|
417 |
-
<h4 class="cartflows-setup-message-title"><?php _e( 'Would you like to install WooCommerce to sell digital and physical products in your funnels?', 'cartflows' ); ?></h4>
|
418 |
-
<span><input data-wcf-ca-active="<?php echo esc_attr( $is_wcf_ca_active ); ?>" data-wcf-ca-install="<?php echo esc_attr( $is_wcf_ca_installed ); ?>" data-woo-active="<?php echo esc_attr( $is_active ); ?>" data-woo-install="<?php echo esc_attr( $is_wc_installed ); ?>" type="hidden" class="wcf-install-wc-input" name="installl-woocommerce" value="" checked></span>
|
419 |
-
</div>
|
420 |
-
|
421 |
-
<div class="cartflows-setup-extra-notice">
|
422 |
-
|
423 |
-
<span>
|
424 |
-
<?php _e( 'The following plugin will be installed and activated for you:', 'cartflows' ); ?>
|
425 |
-
<a target="_blank" href="https://wordpress.org/plugins/woo-cart-abandonment-recovery/"> <?php _e( 'WooCommerce', 'cartflows' ); ?></a>,
|
426 |
-
<a target="_blank" href="https://wordpress.org/plugins/woo-cart-abandonment-recovery/"> <?php _e( 'WooCommerce Cart Abandonment Recovery', 'cartflows' ); ?></a>
|
427 |
-
|
428 |
-
</span>
|
429 |
-
|
430 |
-
</div>
|
431 |
-
|
432 |
-
<div class="cartflows-setup-actions step">
|
433 |
-
<div class="button-prev-wrap">
|
434 |
-
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" ><?php _e( '« Previous', 'cartflows' ); ?></a>
|
435 |
-
</div>
|
436 |
-
<div class="button-next-wrap">
|
437 |
-
<a href="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>" class="button button-large button-next"><?php _e( 'No thanks', 'cartflows' ); ?></a>
|
438 |
-
<a class="wcf-install-wc button-primary button button-large" name="save_step" > <?php _e( 'Yes', 'cartflows' ); ?> </a>
|
439 |
-
</div>
|
440 |
-
</div>
|
441 |
-
|
442 |
-
<?php
|
443 |
-
}
|
444 |
-
|
445 |
-
/**
|
446 |
-
* Save Locale Settings.
|
447 |
-
*/
|
448 |
-
function activate_wc_plugins() {
|
449 |
-
|
450 |
-
check_ajax_referer( 'wcf-wc-plugins-activate', 'security' );
|
451 |
-
|
452 |
-
$plugin_slug_arr = array(
|
453 |
-
'woocommerce/woocommerce.php' => true,
|
454 |
-
'woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php' => false,
|
455 |
-
);
|
456 |
-
|
457 |
-
$activate = array(
|
458 |
-
'woocommerce/woocommerce.php' => false,
|
459 |
-
'woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php' => false,
|
460 |
-
);
|
461 |
-
|
462 |
-
foreach ( $plugin_slug_arr as $slug => $do_silently ) {
|
463 |
-
|
464 |
-
$activate[ $slug ] = activate_plugin( $slug, '', false, $do_silently );
|
465 |
-
}
|
466 |
-
|
467 |
-
foreach ( $activate as $slug => $data ) {
|
468 |
-
|
469 |
-
if ( is_wp_error( $data ) ) {
|
470 |
-
wp_send_json_error(
|
471 |
-
array(
|
472 |
-
'success' => false,
|
473 |
-
'message' => $data->get_error_message(),
|
474 |
-
)
|
475 |
-
);
|
476 |
-
}
|
477 |
-
}
|
478 |
-
|
479 |
-
wp_send_json_success();
|
480 |
-
}
|
481 |
-
|
482 |
-
/**
|
483 |
-
* Save Locale Settings.
|
484 |
-
*/
|
485 |
-
function page_builder_step_save() {
|
486 |
-
|
487 |
-
check_ajax_referer( 'wcf-page-builder-step-save', 'security' );
|
488 |
-
|
489 |
-
$plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( $_POST['plugin_init'] ) : '';
|
490 |
-
$save_option = ( isset( $_POST['save_builder_option'] ) && 'true' == $_POST['save_builder_option'] ) ? true : false;
|
491 |
-
$plugin_slug = filter_input( INPUT_POST, 'page_builder', FILTER_SANITIZE_STRING );
|
492 |
-
|
493 |
-
$do_sliently = true;
|
494 |
-
if ( 'woo-cart-abandonment-recovery' === $plugin_slug ) {
|
495 |
-
$do_sliently = false;
|
496 |
-
}
|
497 |
-
|
498 |
-
$activate = activate_plugin( $plugin_init, '', false, $do_sliently );
|
499 |
-
|
500 |
-
if ( $save_option ) {
|
501 |
-
$this->save_page_builder_option();
|
502 |
-
}
|
503 |
-
|
504 |
-
if ( is_wp_error( $activate ) ) {
|
505 |
-
wp_send_json_error(
|
506 |
-
array(
|
507 |
-
'success' => false,
|
508 |
-
'message' => $activate->get_error_message(),
|
509 |
-
)
|
510 |
-
);
|
511 |
-
}
|
512 |
-
|
513 |
-
wp_send_json_success(
|
514 |
-
array( 'plugin' => $plugin_slug )
|
515 |
-
);
|
516 |
-
}
|
517 |
-
|
518 |
-
/**
|
519 |
-
* Save selected page builder in options database.
|
520 |
-
*/
|
521 |
-
public function save_page_builder_option() {
|
522 |
-
|
523 |
-
$page_builder = isset( $_POST['page_builder'] ) ? sanitize_text_field( $_POST['page_builder'] ) : '';
|
524 |
-
|
525 |
-
$wcf_settings = get_option( '_cartflows_common', array() );
|
526 |
-
|
527 |
-
if ( false !== strpos( $page_builder, 'beaver-builder' ) ) {
|
528 |
-
$page_builder = 'beaver-builder';
|
529 |
-
}
|
530 |
-
|
531 |
-
$wcf_settings['default_page_builder'] = $page_builder;
|
532 |
-
|
533 |
-
update_option( '_cartflows_common', $wcf_settings );
|
534 |
-
|
535 |
-
wp_send_json_success(
|
536 |
-
array( 'plugin' => $page_builder )
|
537 |
-
);
|
538 |
-
|
539 |
-
}
|
540 |
-
|
541 |
-
/**
|
542 |
-
* Final step.
|
543 |
-
*/
|
544 |
-
public function ready_step() {
|
545 |
-
|
546 |
-
// Set setup wizard status to complete.
|
547 |
-
update_option( 'wcf_setup_complete', true );
|
548 |
-
?>
|
549 |
-
<h1><?php _e( 'Congratulations, You Did It!', 'cartflows' ); ?></h1>
|
550 |
-
|
551 |
-
<div class="cartflows-setup-next-steps">
|
552 |
-
<div class="cartflows-setup-next-steps-last">
|
553 |
-
|
554 |
-
<p class="success">
|
555 |
-
<?php
|
556 |
-
_e( 'CartFlows is ready to use on your website. You\'ve successfully completed the setup process and all that is left for you to do is create your first flow.', 'cartflows' )
|
557 |
-
?>
|
558 |
-
</p>
|
559 |
-
|
560 |
-
|
561 |
-
<ul class="wcf-wizard-next-steps">
|
562 |
-
<li class="wcf-wizard-next-step-item">
|
563 |
-
<div class="wcf-wizard-next-step-description">
|
564 |
-
<p class="next-step-heading">Next step</p>
|
565 |
-
<h3 class="next-step-description">Create First Flow</h3>
|
566 |
-
<p class="next-step-extra-info">You're ready to add flows to your website.</p>
|
567 |
-
</div>
|
568 |
-
<div class="wcf-wizard-next-step-action">
|
569 |
-
<p class="wc-setup-actions step">
|
570 |
-
<a href="<?php echo esc_url( admin_url( 'edit.php?post_type=cartflows_flow&add-new-flow' ) ); ?>" type="button" class="button button-primary button-hero" ><?php _e( 'Create a flow', 'cartflows' ); ?></a>
|
571 |
-
</p>
|
572 |
-
</div>
|
573 |
-
</li>
|
574 |
-
</ul>
|
575 |
-
|
576 |
-
</div>
|
577 |
-
</div>
|
578 |
-
<?php
|
579 |
-
}
|
580 |
-
|
581 |
-
/**
|
582 |
-
* Training course step.
|
583 |
-
*/
|
584 |
-
public function training_step() {
|
585 |
-
$current_user = wp_get_current_user();
|
586 |
-
?>
|
587 |
-
<h1><?php _e( 'Exclusive CartFlows Training Course Offer', 'cartflows' ); ?></h1>
|
588 |
-
|
589 |
-
<div id="mauticform_wrapper_cartflowsonboarding" class="mauticform_wrapper">
|
590 |
-
<form autocomplete="false" role="form" method="post" action="https://go.cartflows.com/form/submit?formId=2" id="mauticform_cartflowsonboarding" data-mautic-form="cartflowsonboarding" enctype="multipart/form-data">
|
591 |
-
<div class="mauticform-error" id="mauticform_cartflowsonboarding_error"></div>
|
592 |
-
<div class="mauticform-message" id="mauticform_cartflowsonboarding_message"></div>
|
593 |
-
<div class="mauticform-innerform">
|
594 |
-
<div class="mauticform-page-wrapper mauticform-page-1" data-mautic-form-page="1">
|
595 |
-
<div id="mauticform_cartflowsonboarding_enter_your_email" class="mauticform-row mauticform-email mauticform-field-1">
|
596 |
-
<div class="cartflows-setup-message">
|
597 |
-
<p>
|
598 |
-
<?php _e( 'We want you to get off to a great start using CartFlows, so we would like to give access to our exclusive training course.', 'cartflows' ); ?>
|
599 |
-
<?php _e( 'Get access to this couse, for free, by entering your email below.', 'cartflows' ); ?>
|
600 |
-
</p>
|
601 |
-
<input id="mauticform_input_cartflowsonboarding_enter_your_email" name="mauticform[enter_your_email]" placeholder="<?php _e( 'Enter Email address', 'cartflows' ); ?>" value="<?php echo $current_user->user_email; ?>" class="mauticform-input" type="email">
|
602 |
-
</div>
|
603 |
-
<span class="mauticform-errormsg" style="display: none;"></span>
|
604 |
-
</div>
|
605 |
-
</div>
|
606 |
-
</div>
|
607 |
-
|
608 |
-
<input type="hidden" name="mauticform[formId]" id="mauticform_cartflowsonboarding_id" value="2">
|
609 |
-
<input type="hidden" name="mauticform[return]" id="mauticform_cartflowsonboarding_return" value="">
|
610 |
-
<input type="hidden" name="mauticform[formName]" id="mauticform_cartflowsonboarding_name" value="cartflowsonboarding">
|
611 |
-
<div class="cartflows-setup-actions step">
|
612 |
-
<div class="button-prev-wrap">
|
613 |
-
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" ><?php _e( '« Previous', 'cartflows' ); ?></a>
|
614 |
-
</div>
|
615 |
-
<div class="button-next-wrap">
|
616 |
-
<a href="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>" class="button button-large button-next"><?php _e( 'No thanks', 'cartflows' ); ?></a>
|
617 |
-
<button type="submit" name="mauticform[submit]" id="mauticform_input_cartflowsonboarding_submit" value="<?php _e( 'Allow', 'cartflows' ); ?>" class="mautic-form-submit btn btn-default button-primary button button-large button-next" name="save_step"><?php _e( 'Allow', 'cartflows' ); ?></button>
|
618 |
-
</div>
|
619 |
-
</div>
|
620 |
-
</form>
|
621 |
-
</div>
|
622 |
-
<?php
|
623 |
-
}
|
624 |
-
|
625 |
-
/**
|
626 |
-
* Localize variables in admin
|
627 |
-
*/
|
628 |
-
function localize_vars() {
|
629 |
-
|
630 |
-
$vars = array();
|
631 |
-
|
632 |
-
$ajax_actions = array(
|
633 |
-
'wcf_page_builder_step_save',
|
634 |
-
'wcf_wc_plugins_activate',
|
635 |
-
);
|
636 |
-
|
637 |
-
foreach ( $ajax_actions as $action ) {
|
638 |
-
|
639 |
-
$vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
|
640 |
-
}
|
641 |
-
|
642 |
-
return $vars;
|
643 |
-
}
|
644 |
-
|
645 |
-
/**
|
646 |
-
* Add JS script for mautic form
|
647 |
-
*/
|
648 |
-
function add_mautic_form_script() {
|
649 |
-
|
650 |
-
if ( ! isset( $_REQUEST['page'] ) || ( isset( $_REQUEST['page'] ) && 'cartflow-setup' != $_REQUEST['page'] ) ) {
|
651 |
-
return;
|
652 |
-
}
|
653 |
-
?>
|
654 |
-
|
655 |
-
<script type="text/javascript">
|
656 |
-
/** This section is only needed once per page if manually copying **/
|
657 |
-
if (typeof MauticSDKLoaded == 'undefined') {
|
658 |
-
var MauticSDKLoaded = true;
|
659 |
-
var head = document.getElementsByTagName('head')[0];
|
660 |
-
var script = document.createElement('script');
|
661 |
-
script.type = 'text/javascript';
|
662 |
-
script.src = 'https://go.cartflows.com/media/js/mautic-form.js';
|
663 |
-
script.onload = function() {
|
664 |
-
MauticSDK.onLoad();
|
665 |
-
};
|
666 |
-
head.appendChild(script);
|
667 |
-
var MauticDomain = 'https://go.cartflows.com';
|
668 |
-
var MauticLang = {
|
669 |
-
'submittingMessage': "Please wait..."
|
670 |
-
};
|
671 |
-
}
|
672 |
-
</script>
|
673 |
-
<?php
|
674 |
-
}
|
675 |
-
}
|
676 |
-
|
677 |
-
new CartFlows_Wizard();
|
678 |
-
|
679 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows- Onboarding Wizard
|
4 |
+
*
|
5 |
+
* @package cartflows
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
if ( ! class_exists( 'CartFlows_Wizard' ) ) :
|
13 |
+
|
14 |
+
/**
|
15 |
+
* CartFlows_Wizard class.
|
16 |
+
*/
|
17 |
+
class CartFlows_Wizard {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Hook in tabs.
|
21 |
+
*/
|
22 |
+
public function __construct() {
|
23 |
+
|
24 |
+
if ( apply_filters( 'cartflows_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) {
|
25 |
+
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
|
26 |
+
add_action( 'admin_init', array( $this, 'setup_wizard' ) );
|
27 |
+
add_action( 'admin_notices', array( $this, 'show_setup_wizard' ) );
|
28 |
+
add_action( 'wp_ajax_page_builder_step_save', array( $this, 'page_builder_step_save' ) );
|
29 |
+
add_action( 'wp_ajax_page_builder_save_option', array( $this, 'save_page_builder_option' ) );
|
30 |
+
add_action( 'admin_head', array( $this, 'add_mautic_form_script' ) );
|
31 |
+
add_action( 'woocommerce_installed', array( $this, 'disable_woo_setup_redirect' ) );
|
32 |
+
|
33 |
+
add_action( 'wp_ajax_wcf_activate_wc_plugins', array( $this, 'activate_wc_plugins' ) );
|
34 |
+
|
35 |
+
add_action( 'admin_init', array( $this, 'hide_notices' ) );
|
36 |
+
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Hide a notice if the GET variable is set.
|
43 |
+
*/
|
44 |
+
public function hide_notices() {
|
45 |
+
|
46 |
+
if ( ! isset( $_GET['wcf-hide-notice'] ) ) {
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
|
50 |
+
$wcf_hide_notice = filter_input( INPUT_GET, 'wcf-hide-notice', FILTER_SANITIZE_STRING );
|
51 |
+
$_wcf_notice_nonce = filter_input( INPUT_GET, '_wcf_notice_nonce', FILTER_SANITIZE_STRING );
|
52 |
+
|
53 |
+
if ( $wcf_hide_notice && $_wcf_notice_nonce && wp_verify_nonce( sanitize_key( wp_unslash( $_wcf_notice_nonce ) ), 'wcf_hide_notices_nonce' ) ) {
|
54 |
+
update_option( 'wcf_setup_skipped', true );
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Disable the woo redirect for new setup.
|
60 |
+
*/
|
61 |
+
public function disable_woo_setup_redirect() {
|
62 |
+
|
63 |
+
if ( empty( $_GET['page'] ) || 'cartflow-setup' !== $_GET['page'] ) {
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
delete_transient( '_wc_activation_redirect' );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Show action links on the plugin screen.
|
72 |
+
*
|
73 |
+
* @since 1.0.0
|
74 |
+
* @return void
|
75 |
+
*/
|
76 |
+
public function show_setup_wizard() {
|
77 |
+
|
78 |
+
$status = get_option( 'wcf_setup_complete', false );
|
79 |
+
$skip_setup = get_option( 'wcf_setup_skipped', false );
|
80 |
+
|
81 |
+
if ( false === $status && ! $skip_setup ) { ?>
|
82 |
+
<div class="notice notice-info">
|
83 |
+
<p><b><?php _e( 'Thanks for installing and using CartFlows!', 'cartflows' ); ?></b></p>
|
84 |
+
<p><?php _e( 'It is easy to use the CartFlows. Please use the setup wizard to quick start setup.', 'cartflows' ); ?></p>
|
85 |
+
<p>
|
86 |
+
<a href="<?php echo esc_url( admin_url( 'index.php?page=cartflow-setup' ) ); ?>" class="button button-primary"> <?php _e( 'Start Wizard', 'cartflows' ); ?></a>
|
87 |
+
<a class="button-secondary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcf-hide-notice', 'install' ), 'wcf_hide_notices_nonce', '_wcf_notice_nonce' ) ); ?>"><?php _e( 'Skip Setup', 'cartflows' ); ?></a>
|
88 |
+
</p>
|
89 |
+
</div>
|
90 |
+
<?php
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Add admin menus/screens.
|
96 |
+
*/
|
97 |
+
public function admin_menus() {
|
98 |
+
|
99 |
+
if ( empty( $_GET['page'] ) || 'cartflow-setup' !== $_GET['page'] ) {
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
add_dashboard_page( '', '', 'manage_options', 'cartflow-setup', '' );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Show the setup wizard.
|
108 |
+
*/
|
109 |
+
public function setup_wizard() {
|
110 |
+
|
111 |
+
if ( empty( $_GET['page'] ) || 'cartflow-setup' !== $_GET['page'] ) {
|
112 |
+
return;
|
113 |
+
}
|
114 |
+
|
115 |
+
$this->steps = array(
|
116 |
+
'basic-config' => array(
|
117 |
+
'name' => __( 'Welcome', 'cartflows' ),
|
118 |
+
'view' => array( $this, 'welcome_step' ),
|
119 |
+
'handler' => array( $this, 'welcome_step_save' ),
|
120 |
+
),
|
121 |
+
'page-builder' => array(
|
122 |
+
'name' => __( 'Page Builder', 'cartflows' ),
|
123 |
+
'view' => array( $this, 'page_builder_step' ),
|
124 |
+
),
|
125 |
+
'checkout' => array(
|
126 |
+
'name' => __( 'Checkout', 'cartflows' ),
|
127 |
+
'view' => array( $this, 'checkout_step' ),
|
128 |
+
),
|
129 |
+
'training' => array(
|
130 |
+
'name' => __( 'Training', 'cartflows' ),
|
131 |
+
'view' => array( $this, 'training_step' ),
|
132 |
+
),
|
133 |
+
'setup-ready' => array(
|
134 |
+
'name' => __( 'Ready!', 'cartflows' ),
|
135 |
+
'view' => array( $this, 'ready_step' ),
|
136 |
+
'handler' => '',
|
137 |
+
),
|
138 |
+
);
|
139 |
+
|
140 |
+
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
|
141 |
+
|
142 |
+
wp_enqueue_style( 'cartflows-setup', CARTFLOWS_URL . 'admin/assets/css/setup-wizard.css', array( 'dashicons' ), CARTFLOWS_VER );
|
143 |
+
wp_style_add_data( 'cartflows-setup', 'rtl', 'replace' );
|
144 |
+
|
145 |
+
wp_enqueue_script( 'cartflows-setup', CARTFLOWS_URL . 'admin/assets/js/setup-wizard.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER, false );
|
146 |
+
|
147 |
+
wp_localize_script( 'cartflows-setup', 'cartflows_setup_vars', self::localize_vars() );
|
148 |
+
|
149 |
+
wp_enqueue_media();
|
150 |
+
|
151 |
+
if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
|
152 |
+
call_user_func( $this->steps[ $this->step ]['handler'] );
|
153 |
+
}
|
154 |
+
|
155 |
+
ob_start();
|
156 |
+
$this->setup_wizard_header();
|
157 |
+
$this->setup_wizard_steps();
|
158 |
+
$this->setup_wizard_content();
|
159 |
+
$this->setup_wizard_footer();
|
160 |
+
exit;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Get current step slug
|
165 |
+
*/
|
166 |
+
public function get_current_step_slug() {
|
167 |
+
$keys = array_keys( $this->steps );
|
168 |
+
return $keys[ array_search( $this->step, array_keys( $this->steps ), true ) ];
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Get previous step link
|
173 |
+
*/
|
174 |
+
public function get_prev_step_link() {
|
175 |
+
$keys = array_keys( $this->steps );
|
176 |
+
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) - 1 ] );
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Get next step link
|
181 |
+
*/
|
182 |
+
public function get_next_step_link() {
|
183 |
+
$keys = array_keys( $this->steps );
|
184 |
+
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ] );
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Get next step link
|
189 |
+
*/
|
190 |
+
public function get_next_step_plain_link() {
|
191 |
+
$keys = array_keys( $this->steps );
|
192 |
+
$step_index = array_search( $this->step, $keys, true );
|
193 |
+
$step_index = ( count( $keys ) == $step_index + 1 ) ? $step_index : $step_index + 1;
|
194 |
+
$step = $keys[ $step_index ];
|
195 |
+
return admin_url( 'index.php?page=cartflow-setup&step=' . $step );
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Setup Wizard Header.
|
200 |
+
*/
|
201 |
+
public function setup_wizard_header() {
|
202 |
+
?>
|
203 |
+
<!DOCTYPE html>
|
204 |
+
<html>
|
205 |
+
<head>
|
206 |
+
<meta name="viewport" content="width=device-width" />
|
207 |
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
208 |
+
<title><?php _e( 'CartFlows Setup', 'cartflows' ); ?></title>
|
209 |
+
|
210 |
+
<script type="text/javascript">
|
211 |
+
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
212 |
+
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>';
|
213 |
+
var pagenow = '';
|
214 |
+
</script>
|
215 |
+
<?php wp_print_scripts( array( 'cartflows-setup' ) ); ?>
|
216 |
+
<?php do_action( 'admin_print_styles' ); ?>
|
217 |
+
<?php do_action( 'admin_head' ); ?>
|
218 |
+
</head>
|
219 |
+
<body class="cartflows-setup wp-core-ui cartflows-step-<?php echo esc_attr( $this->get_current_step_slug() ); ?>">
|
220 |
+
<div id="cartflows-logo">
|
221 |
+
<img height="40" class="wcf-logo" src="<?php echo CARTFLOWS_URL . 'assets/images/cartflows-logo.svg'; ?>" />
|
222 |
+
</div>
|
223 |
+
<?php
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Setup Wizard Footer.
|
228 |
+
*/
|
229 |
+
public function setup_wizard_footer() {
|
230 |
+
|
231 |
+
$admin_url = admin_url( 'admin.php?page=cartflows_settings' );
|
232 |
+
?>
|
233 |
+
<div class="close-button-wrapper">
|
234 |
+
<a href="<?php echo esc_url( $admin_url ); ?>" class="wizard-close-link" ><?php _e( 'Exit Setup Wizard', 'cartflows' ); ?></a>
|
235 |
+
</div>
|
236 |
+
</body>
|
237 |
+
</html>
|
238 |
+
<?php
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Output the steps.
|
243 |
+
*/
|
244 |
+
public function setup_wizard_steps() {
|
245 |
+
|
246 |
+
$ouput_steps = $this->steps;
|
247 |
+
?>
|
248 |
+
<ol class="cartflows-setup-steps">
|
249 |
+
<?php
|
250 |
+
foreach ( $ouput_steps as $step_key => $step ) :
|
251 |
+
$classes = '';
|
252 |
+
$activated = false;
|
253 |
+
if ( $step_key === $this->step ) {
|
254 |
+
$classes = 'active';
|
255 |
+
$activated = true;
|
256 |
+
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) {
|
257 |
+
$classes = 'done';
|
258 |
+
$activated = true;
|
259 |
+
}
|
260 |
+
?>
|
261 |
+
<li class="<?php echo esc_attr( $classes ); ?>">
|
262 |
+
<span><?php echo esc_html( $step['name'] ); ?></span>
|
263 |
+
</li>
|
264 |
+
<?php endforeach; ?>
|
265 |
+
</ol>
|
266 |
+
<?php
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Output the content for the current step.
|
271 |
+
*/
|
272 |
+
public function setup_wizard_content() {
|
273 |
+
?>
|
274 |
+
<input type="hidden" class="wcf-redirect-link" data-redirect-link="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>" >
|
275 |
+
<?php
|
276 |
+
|
277 |
+
echo '<div class="cartflows-setup-content">';
|
278 |
+
call_user_func( $this->steps[ $this->step ]['view'] );
|
279 |
+
echo '</div>';
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Introduction step.
|
284 |
+
*/
|
285 |
+
public function welcome_step() {
|
286 |
+
?>
|
287 |
+
<h1><?php _e( 'Welcome to CartFlows!', 'cartflows' ); ?></h1>
|
288 |
+
<p><?php _e( 'Thank you for choosing CartFlows to get more leads, increase conversions, & maximize profits. This short setup wizard will guide you though configuring CartFlows and creating your first funnel.', 'cartflows' ); ?></p>
|
289 |
+
<form method="post">
|
290 |
+
<div class="cartflows-setup-actions step">
|
291 |
+
<div class="button-prev-wrap">
|
292 |
+
</div>
|
293 |
+
<div class="button-next-wrap">
|
294 |
+
<input type="submit" class="uct-activate button-primary button button-large " value="<?php _e( 'Lets Go »', 'cartflows' ); ?>" name="save_step" />
|
295 |
+
</div>
|
296 |
+
<?php wp_nonce_field( 'cartflow-setup' ); ?>
|
297 |
+
</div>
|
298 |
+
</form>
|
299 |
+
<?php
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Save Locale Settings.
|
304 |
+
*/
|
305 |
+
public function welcome_step_save() {
|
306 |
+
check_admin_referer( 'cartflow-setup' );
|
307 |
+
|
308 |
+
// Update site title & tagline.
|
309 |
+
$redirect_url = $this->get_next_step_link();
|
310 |
+
|
311 |
+
wp_safe_redirect( esc_url_raw( $redirect_url ) );
|
312 |
+
exit;
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Locale settings
|
317 |
+
*/
|
318 |
+
public function page_builder_step() {
|
319 |
+
?>
|
320 |
+
|
321 |
+
<h1><?php _e( 'Page Builder Setup', 'cartflows' ); ?></h1>
|
322 |
+
<p class="description"><?php _e( 'Please select a page builder you would like to use with CartFlows.', 'cartflows' ); ?></p>
|
323 |
+
<form method="post">
|
324 |
+
<table class="cartflows-table widefat">
|
325 |
+
<tr class="cartflows-row">
|
326 |
+
<td class="cartflows-row-heading">
|
327 |
+
<label><?php esc_html_e( 'Select Page Builder', 'cartflows' ); ?></label>
|
328 |
+
</td>
|
329 |
+
<td class="cartflows-row-content">
|
330 |
+
<?php
|
331 |
+
$installed_plugins = get_plugins();
|
332 |
+
$plugins = array(
|
333 |
+
array(
|
334 |
+
'title' => __( 'Elementor', 'cartflows' ),
|
335 |
+
'value' => 'elementor',
|
336 |
+
'data' => array(
|
337 |
+
'slug' => 'elementor',
|
338 |
+
'init' => 'elementor/elementor.php',
|
339 |
+
'active' => is_plugin_active( 'elementor/elementor.php' ) ? 'yes' : 'no',
|
340 |
+
'install' => isset( $installed_plugins['elementor/elementor.php'] ) ? 'yes' : 'no',
|
341 |
+
),
|
342 |
+
),
|
343 |
+
array(
|
344 |
+
'title' => __( 'Beaver Builder Plugin (Lite Version)', 'cartflows' ),
|
345 |
+
'value' => 'beaver-builder',
|
346 |
+
'data' => array(
|
347 |
+
'slug' => 'beaver-builder-lite-version',
|
348 |
+
'init' => 'beaver-builder-lite-version/fl-builder.php',
|
349 |
+
'active' => is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ? 'yes' : 'no',
|
350 |
+
'install' => isset( $installed_plugins['beaver-builder-lite-version/fl-builder.php'] ) ? 'yes' : 'no',
|
351 |
+
),
|
352 |
+
),
|
353 |
+
array(
|
354 |
+
'title' => __( 'Divi', 'cartflows' ),
|
355 |
+
'value' => 'divi',
|
356 |
+
'data' => array(
|
357 |
+
'slug' => 'divi',
|
358 |
+
'init' => 'divi',
|
359 |
+
'active' => 'yes',
|
360 |
+
'install' => 'NA',
|
361 |
+
),
|
362 |
+
),
|
363 |
+
array(
|
364 |
+
'title' => __( 'Other', 'cartflows' ),
|
365 |
+
'value' => 'other',
|
366 |
+
'data' => array(
|
367 |
+
'slug' => 'other',
|
368 |
+
'init' => false,
|
369 |
+
'active' => 'yes',
|
370 |
+
'install' => 'NA',
|
371 |
+
),
|
372 |
+
),
|
373 |
+
);
|
374 |
+
?>
|
375 |
+
<input type="hidden" name="save-pb-input" id="save-pb-option" value="1" />
|
376 |
+
<select name="page-builder" class="page-builder-list" data-redirect-link="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>">
|
377 |
+
<?php
|
378 |
+
foreach ( $plugins as $key => $plugin ) {
|
379 |
+
echo '<option value="' . esc_attr( $plugin['value'] ) . '" data-install="' . esc_attr( $plugin['data']['install'] ) . '" data-active="' . esc_attr( $plugin['data']['active'] ) . '" data-slug="' . esc_attr( $plugin['data']['slug'] ) . '" data-init="' . esc_attr( $plugin['data']['init'] ) . '">' . esc_html( $plugin['title'] ) . '</option>';
|
380 |
+
}
|
381 |
+
?>
|
382 |
+
</select>
|
383 |
+
</td>
|
384 |
+
</tr>
|
385 |
+
</table>
|
386 |
+
<p><?php _e( 'While CartFlows Should work with most page builders, we offer templates for the above page builders.', 'cartflows' ); ?></p>
|
387 |
+
<div class="cartflows-setup-actions step">
|
388 |
+
<div class="button-prev-wrap">
|
389 |
+
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" ><?php _e( '« Previous', 'cartflows' ); ?></a>
|
390 |
+
</div>
|
391 |
+
<div class="button-next-wrap">
|
392 |
+
<a href="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>" class="button button-large button-next" ><?php _e( 'Skip this step', 'cartflows' ); ?></a>
|
393 |
+
<a href="#" class="button button-primary wcf-install-plugins"><?php _e( 'Next »', 'cartflows' ); ?></a>
|
394 |
+
</div>
|
395 |
+
<?php wp_nonce_field( 'cartflow-setup' ); ?>
|
396 |
+
</div>
|
397 |
+
</form>
|
398 |
+
<?php
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Render checkout step.
|
403 |
+
*/
|
404 |
+
public function checkout_step() {
|
405 |
+
|
406 |
+
$installed_plugins = get_plugins();
|
407 |
+
$is_wc_installed = isset( $installed_plugins['woocommerce/woocommerce.php'] ) ? 'yes' : 'no';
|
408 |
+
$is_wcf_ca_installed = isset( $installed_plugins['woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php'] ) ? 'yes' : 'no';
|
409 |
+
$is_active = class_exists( 'WooCommerce' ) ? 'yes' : 'no';
|
410 |
+
$is_wcf_ca_active = class_exists( 'CARTFLOWS_CA_Loader' ) ? 'yes' : 'no';
|
411 |
+
?>
|
412 |
+
<h1><?php _e( 'Choose a checkout', 'cartflows' ); ?></h1>
|
413 |
+
<div class="cartflows-setup-message">
|
414 |
+
<p>
|
415 |
+
<?php _e( 'While CartFlows is designed to use WooCommerce sell digital and physical products, not all funnels need a checkout system.', 'cartflows' ); ?>
|
416 |
+
</p>
|
417 |
+
<h4 class="cartflows-setup-message-title"><?php _e( 'Would you like to install WooCommerce to sell digital and physical products in your funnels?', 'cartflows' ); ?></h4>
|
418 |
+
<span><input data-wcf-ca-active="<?php echo esc_attr( $is_wcf_ca_active ); ?>" data-wcf-ca-install="<?php echo esc_attr( $is_wcf_ca_installed ); ?>" data-woo-active="<?php echo esc_attr( $is_active ); ?>" data-woo-install="<?php echo esc_attr( $is_wc_installed ); ?>" type="hidden" class="wcf-install-wc-input" name="installl-woocommerce" value="" checked></span>
|
419 |
+
</div>
|
420 |
+
|
421 |
+
<div class="cartflows-setup-extra-notice">
|
422 |
+
|
423 |
+
<span>
|
424 |
+
<?php _e( 'The following plugin will be installed and activated for you:', 'cartflows' ); ?>
|
425 |
+
<a target="_blank" href="https://wordpress.org/plugins/woo-cart-abandonment-recovery/"> <?php _e( 'WooCommerce', 'cartflows' ); ?></a>,
|
426 |
+
<a target="_blank" href="https://wordpress.org/plugins/woo-cart-abandonment-recovery/"> <?php _e( 'WooCommerce Cart Abandonment Recovery', 'cartflows' ); ?></a>
|
427 |
+
|
428 |
+
</span>
|
429 |
+
|
430 |
+
</div>
|
431 |
+
|
432 |
+
<div class="cartflows-setup-actions step">
|
433 |
+
<div class="button-prev-wrap">
|
434 |
+
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" ><?php _e( '« Previous', 'cartflows' ); ?></a>
|
435 |
+
</div>
|
436 |
+
<div class="button-next-wrap">
|
437 |
+
<a href="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>" class="button button-large button-next"><?php _e( 'No thanks', 'cartflows' ); ?></a>
|
438 |
+
<a class="wcf-install-wc button-primary button button-large" name="save_step" > <?php _e( 'Yes', 'cartflows' ); ?> </a>
|
439 |
+
</div>
|
440 |
+
</div>
|
441 |
+
|
442 |
+
<?php
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Save Locale Settings.
|
447 |
+
*/
|
448 |
+
public function activate_wc_plugins() {
|
449 |
+
|
450 |
+
check_ajax_referer( 'wcf-wc-plugins-activate', 'security' );
|
451 |
+
|
452 |
+
$plugin_slug_arr = array(
|
453 |
+
'woocommerce/woocommerce.php' => true,
|
454 |
+
'woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php' => false,
|
455 |
+
);
|
456 |
+
|
457 |
+
$activate = array(
|
458 |
+
'woocommerce/woocommerce.php' => false,
|
459 |
+
'woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php' => false,
|
460 |
+
);
|
461 |
+
|
462 |
+
foreach ( $plugin_slug_arr as $slug => $do_silently ) {
|
463 |
+
|
464 |
+
$activate[ $slug ] = activate_plugin( $slug, '', false, $do_silently );
|
465 |
+
}
|
466 |
+
|
467 |
+
foreach ( $activate as $slug => $data ) {
|
468 |
+
|
469 |
+
if ( is_wp_error( $data ) ) {
|
470 |
+
wp_send_json_error(
|
471 |
+
array(
|
472 |
+
'success' => false,
|
473 |
+
'message' => $data->get_error_message(),
|
474 |
+
)
|
475 |
+
);
|
476 |
+
}
|
477 |
+
}
|
478 |
+
|
479 |
+
wp_send_json_success();
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Save Locale Settings.
|
484 |
+
*/
|
485 |
+
public function page_builder_step_save() {
|
486 |
+
|
487 |
+
check_ajax_referer( 'wcf-page-builder-step-save', 'security' );
|
488 |
+
|
489 |
+
$plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin_init'] ) ) : '';
|
490 |
+
$save_option = ( isset( $_POST['save_builder_option'] ) && 'true' == $_POST['save_builder_option'] ) ? true : false;
|
491 |
+
$plugin_slug = filter_input( INPUT_POST, 'page_builder', FILTER_SANITIZE_STRING );
|
492 |
+
|
493 |
+
$do_sliently = true;
|
494 |
+
if ( 'woo-cart-abandonment-recovery' === $plugin_slug ) {
|
495 |
+
$do_sliently = false;
|
496 |
+
}
|
497 |
+
|
498 |
+
$activate = activate_plugin( $plugin_init, '', false, $do_sliently );
|
499 |
+
|
500 |
+
if ( $save_option ) {
|
501 |
+
$this->save_page_builder_option();
|
502 |
+
}
|
503 |
+
|
504 |
+
if ( is_wp_error( $activate ) ) {
|
505 |
+
wp_send_json_error(
|
506 |
+
array(
|
507 |
+
'success' => false,
|
508 |
+
'message' => $activate->get_error_message(),
|
509 |
+
)
|
510 |
+
);
|
511 |
+
}
|
512 |
+
|
513 |
+
wp_send_json_success(
|
514 |
+
array( 'plugin' => $plugin_slug )
|
515 |
+
);
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Save selected page builder in options database.
|
520 |
+
*/
|
521 |
+
public function save_page_builder_option() {
|
522 |
+
|
523 |
+
$page_builder = isset( $_POST['page_builder'] ) ? sanitize_text_field( wp_unslash( $_POST['page_builder'] ) ) : '';
|
524 |
+
|
525 |
+
$wcf_settings = get_option( '_cartflows_common', array() );
|
526 |
+
|
527 |
+
if ( false !== strpos( $page_builder, 'beaver-builder' ) ) {
|
528 |
+
$page_builder = 'beaver-builder';
|
529 |
+
}
|
530 |
+
|
531 |
+
$wcf_settings['default_page_builder'] = $page_builder;
|
532 |
+
|
533 |
+
update_option( '_cartflows_common', $wcf_settings );
|
534 |
+
|
535 |
+
wp_send_json_success(
|
536 |
+
array( 'plugin' => $page_builder )
|
537 |
+
);
|
538 |
+
|
539 |
+
}
|
540 |
+
|
541 |
+
/**
|
542 |
+
* Final step.
|
543 |
+
*/
|
544 |
+
public function ready_step() {
|
545 |
+
|
546 |
+
// Set setup wizard status to complete.
|
547 |
+
update_option( 'wcf_setup_complete', true );
|
548 |
+
?>
|
549 |
+
<h1><?php _e( 'Congratulations, You Did It!', 'cartflows' ); ?></h1>
|
550 |
+
|
551 |
+
<div class="cartflows-setup-next-steps">
|
552 |
+
<div class="cartflows-setup-next-steps-last">
|
553 |
+
|
554 |
+
<p class="success">
|
555 |
+
<?php
|
556 |
+
_e( 'CartFlows is ready to use on your website. You\'ve successfully completed the setup process and all that is left for you to do is create your first flow.', 'cartflows' )
|
557 |
+
?>
|
558 |
+
</p>
|
559 |
+
|
560 |
+
|
561 |
+
<ul class="wcf-wizard-next-steps">
|
562 |
+
<li class="wcf-wizard-next-step-item">
|
563 |
+
<div class="wcf-wizard-next-step-description">
|
564 |
+
<p class="next-step-heading">Next step</p>
|
565 |
+
<h3 class="next-step-description">Create First Flow</h3>
|
566 |
+
<p class="next-step-extra-info">You're ready to add flows to your website.</p>
|
567 |
+
</div>
|
568 |
+
<div class="wcf-wizard-next-step-action">
|
569 |
+
<p class="wc-setup-actions step">
|
570 |
+
<a href="<?php echo esc_url( admin_url( 'edit.php?post_type=cartflows_flow&add-new-flow' ) ); ?>" type="button" class="button button-primary button-hero" ><?php _e( 'Create a flow', 'cartflows' ); ?></a>
|
571 |
+
</p>
|
572 |
+
</div>
|
573 |
+
</li>
|
574 |
+
</ul>
|
575 |
+
|
576 |
+
</div>
|
577 |
+
</div>
|
578 |
+
<?php
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Training course step.
|
583 |
+
*/
|
584 |
+
public function training_step() {
|
585 |
+
$current_user = wp_get_current_user();
|
586 |
+
?>
|
587 |
+
<h1><?php _e( 'Exclusive CartFlows Training Course Offer', 'cartflows' ); ?></h1>
|
588 |
+
|
589 |
+
<div id="mauticform_wrapper_cartflowsonboarding" class="mauticform_wrapper">
|
590 |
+
<form autocomplete="false" role="form" method="post" action="https://go.cartflows.com/form/submit?formId=2" id="mauticform_cartflowsonboarding" data-mautic-form="cartflowsonboarding" enctype="multipart/form-data">
|
591 |
+
<div class="mauticform-error" id="mauticform_cartflowsonboarding_error"></div>
|
592 |
+
<div class="mauticform-message" id="mauticform_cartflowsonboarding_message"></div>
|
593 |
+
<div class="mauticform-innerform">
|
594 |
+
<div class="mauticform-page-wrapper mauticform-page-1" data-mautic-form-page="1">
|
595 |
+
<div id="mauticform_cartflowsonboarding_enter_your_email" class="mauticform-row mauticform-email mauticform-field-1">
|
596 |
+
<div class="cartflows-setup-message">
|
597 |
+
<p>
|
598 |
+
<?php _e( 'We want you to get off to a great start using CartFlows, so we would like to give access to our exclusive training course.', 'cartflows' ); ?>
|
599 |
+
<?php _e( 'Get access to this couse, for free, by entering your email below.', 'cartflows' ); ?>
|
600 |
+
</p>
|
601 |
+
<input id="mauticform_input_cartflowsonboarding_enter_your_email" name="mauticform[enter_your_email]" placeholder="<?php _e( 'Enter Email address', 'cartflows' ); ?>" value="<?php echo $current_user->user_email; ?>" class="mauticform-input" type="email">
|
602 |
+
</div>
|
603 |
+
<span class="mauticform-errormsg" style="display: none;"></span>
|
604 |
+
</div>
|
605 |
+
</div>
|
606 |
+
</div>
|
607 |
+
|
608 |
+
<input type="hidden" name="mauticform[formId]" id="mauticform_cartflowsonboarding_id" value="2">
|
609 |
+
<input type="hidden" name="mauticform[return]" id="mauticform_cartflowsonboarding_return" value="">
|
610 |
+
<input type="hidden" name="mauticform[formName]" id="mauticform_cartflowsonboarding_name" value="cartflowsonboarding">
|
611 |
+
<div class="cartflows-setup-actions step">
|
612 |
+
<div class="button-prev-wrap">
|
613 |
+
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" ><?php _e( '« Previous', 'cartflows' ); ?></a>
|
614 |
+
</div>
|
615 |
+
<div class="button-next-wrap">
|
616 |
+
<a href="<?php echo esc_url_raw( $this->get_next_step_plain_link() ); ?>" class="button button-large button-next"><?php _e( 'No thanks', 'cartflows' ); ?></a>
|
617 |
+
<button type="submit" name="mauticform[submit]" id="mauticform_input_cartflowsonboarding_submit" value="<?php _e( 'Allow', 'cartflows' ); ?>" class="mautic-form-submit btn btn-default button-primary button button-large button-next" name="save_step"><?php _e( 'Allow', 'cartflows' ); ?></button>
|
618 |
+
</div>
|
619 |
+
</div>
|
620 |
+
</form>
|
621 |
+
</div>
|
622 |
+
<?php
|
623 |
+
}
|
624 |
+
|
625 |
+
/**
|
626 |
+
* Localize variables in admin
|
627 |
+
*/
|
628 |
+
public function localize_vars() {
|
629 |
+
|
630 |
+
$vars = array();
|
631 |
+
|
632 |
+
$ajax_actions = array(
|
633 |
+
'wcf_page_builder_step_save',
|
634 |
+
'wcf_wc_plugins_activate',
|
635 |
+
);
|
636 |
+
|
637 |
+
foreach ( $ajax_actions as $action ) {
|
638 |
+
|
639 |
+
$vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
|
640 |
+
}
|
641 |
+
|
642 |
+
return $vars;
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
* Add JS script for mautic form
|
647 |
+
*/
|
648 |
+
public function add_mautic_form_script() {
|
649 |
+
|
650 |
+
if ( ! isset( $_REQUEST['page'] ) || ( isset( $_REQUEST['page'] ) && 'cartflow-setup' != $_REQUEST['page'] ) ) {
|
651 |
+
return;
|
652 |
+
}
|
653 |
+
?>
|
654 |
+
|
655 |
+
<script type="text/javascript">
|
656 |
+
/** This section is only needed once per page if manually copying **/
|
657 |
+
if (typeof MauticSDKLoaded == 'undefined') {
|
658 |
+
var MauticSDKLoaded = true;
|
659 |
+
var head = document.getElementsByTagName('head')[0];
|
660 |
+
var script = document.createElement('script');
|
661 |
+
script.type = 'text/javascript';
|
662 |
+
script.src = 'https://go.cartflows.com/media/js/mautic-form.js';
|
663 |
+
script.onload = function() {
|
664 |
+
MauticSDK.onLoad();
|
665 |
+
};
|
666 |
+
head.appendChild(script);
|
667 |
+
var MauticDomain = 'https://go.cartflows.com';
|
668 |
+
var MauticLang = {
|
669 |
+
'submittingMessage': "Please wait..."
|
670 |
+
};
|
671 |
+
}
|
672 |
+
</script>
|
673 |
+
<?php
|
674 |
+
}
|
675 |
+
}
|
676 |
+
|
677 |
+
new CartFlows_Wizard();
|
678 |
+
|
679 |
+
endif;
|
classes/fields/typography/class-cartflows-font-families.php
CHANGED
@@ -1,315 +1,315 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Helper class for font settings.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @author CartFlows
|
7 |
-
* @copyright Copyright (c) 2018, CartFlows
|
8 |
-
* @link https://cartflows.com/
|
9 |
-
* @since 1.0.0
|
10 |
-
*/
|
11 |
-
|
12 |
-
// Exit if accessed directly.
|
13 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
-
exit;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Font info class for System and Google fonts.
|
19 |
-
*/
|
20 |
-
if ( ! class_exists( 'CartFlows_Font_Families' ) ) :
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Font info class for System and Google fonts.
|
24 |
-
*/
|
25 |
-
final class CartFlows_Font_Families {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* System Fonts
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
* @var array
|
32 |
-
*/
|
33 |
-
public static $system_fonts = array();
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Google Fonts
|
37 |
-
*
|
38 |
-
* @since 1.0.0
|
39 |
-
* @var array
|
40 |
-
*/
|
41 |
-
public static $google_fonts = array();
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Get System Fonts
|
45 |
-
*
|
46 |
-
* @since 1.0.0
|
47 |
-
*
|
48 |
-
* @return Array All the system fonts in CartFlows
|
49 |
-
*/
|
50 |
-
public static function get_system_fonts() {
|
51 |
-
if ( empty( self::$system_fonts ) ) {
|
52 |
-
self::$system_fonts = array(
|
53 |
-
'Helvetica' => array(
|
54 |
-
'fallback' => 'Verdana, Arial, sans-serif',
|
55 |
-
'variants' => array(
|
56 |
-
'300',
|
57 |
-
'400',
|
58 |
-
'700',
|
59 |
-
),
|
60 |
-
),
|
61 |
-
'Verdana' => array(
|
62 |
-
'fallback' => 'Helvetica, Arial, sans-serif',
|
63 |
-
'variants' => array(
|
64 |
-
'300',
|
65 |
-
'400',
|
66 |
-
'700',
|
67 |
-
),
|
68 |
-
),
|
69 |
-
'Arial' => array(
|
70 |
-
'fallback' => 'Helvetica, Verdana, sans-serif',
|
71 |
-
'variants' => array(
|
72 |
-
'300',
|
73 |
-
'400',
|
74 |
-
'700',
|
75 |
-
),
|
76 |
-
),
|
77 |
-
'Times' => array(
|
78 |
-
'fallback' => 'Georgia, serif',
|
79 |
-
'variants' => array(
|
80 |
-
'300',
|
81 |
-
'400',
|
82 |
-
'700',
|
83 |
-
),
|
84 |
-
),
|
85 |
-
'Georgia' => array(
|
86 |
-
'fallback' => 'Times, serif',
|
87 |
-
'variants' => array(
|
88 |
-
'300',
|
89 |
-
'400',
|
90 |
-
'700',
|
91 |
-
),
|
92 |
-
),
|
93 |
-
'Courier' => array(
|
94 |
-
'fallback' => 'monospace',
|
95 |
-
'variants' => array(
|
96 |
-
'300',
|
97 |
-
'400',
|
98 |
-
'700',
|
99 |
-
),
|
100 |
-
),
|
101 |
-
);
|
102 |
-
}
|
103 |
-
|
104 |
-
return apply_filters( 'cartflows_system_fonts', self::$system_fonts );
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Custom Fonts
|
109 |
-
*
|
110 |
-
* @since 1.0.0
|
111 |
-
*
|
112 |
-
* @return Array All the custom fonts in CartFlows
|
113 |
-
*/
|
114 |
-
public static function get_custom_fonts() {
|
115 |
-
$custom_fonts = array();
|
116 |
-
|
117 |
-
return apply_filters( 'cartflows_custom_fonts', $custom_fonts );
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Google Fonts used in CartFlows.
|
122 |
-
* Array is generated from the google-fonts.json file.
|
123 |
-
*
|
124 |
-
* @since 1.0.0
|
125 |
-
*
|
126 |
-
* @return Array Array of Google Fonts.
|
127 |
-
*/
|
128 |
-
public static function get_google_fonts() {
|
129 |
-
|
130 |
-
if ( empty( self::$google_fonts ) ) {
|
131 |
-
|
132 |
-
$google_fonts_file = CARTFLOWS_DIR . 'classes/fields/typography/google-fonts.json';
|
133 |
-
|
134 |
-
if ( ! file_exists( $google_fonts_file ) ) {
|
135 |
-
return array();
|
136 |
-
}
|
137 |
-
|
138 |
-
global $wp_filesystem;
|
139 |
-
if ( empty( $wp_filesystem ) ) {
|
140 |
-
require_once ABSPATH . '/wp-admin/includes/file.php';
|
141 |
-
WP_Filesystem();
|
142 |
-
}
|
143 |
-
|
144 |
-
$file_contants = $wp_filesystem->get_contents( $google_fonts_file );
|
145 |
-
$google_fonts_json = json_decode( $file_contants, 1 );
|
146 |
-
|
147 |
-
if ( is_array( $google_fonts_json ) || is_object( $google_fonts_json ) ) {
|
148 |
-
|
149 |
-
foreach ( $google_fonts_json as $key => $font ) {
|
150 |
-
$name = key( $font );
|
151 |
-
foreach ( $font[ $name ] as $font_key => $single_font ) {
|
152 |
-
|
153 |
-
if ( 'variants' === $font_key ) {
|
154 |
-
|
155 |
-
foreach ( $single_font as $variant_key => $variant ) {
|
156 |
-
|
157 |
-
if ( 'regular' == $variant ) {
|
158 |
-
$font[ $name ][ $font_key ][ $variant_key ] = '400';
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
self::$google_fonts[ $name ] = array_values( $font[ $name ] );
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
}
|
168 |
-
|
169 |
-
return apply_filters( 'cartflows_google_fonts', self::$google_fonts );
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Render Fonts
|
174 |
-
*
|
175 |
-
* @param array $post_id post ID.
|
176 |
-
* @return void
|
177 |
-
*/
|
178 |
-
public static function render_fonts( $post_id ) {
|
179 |
-
|
180 |
-
$google_font_url = get_post_meta( $post_id, 'wcf-field-google-font-url', true );
|
181 |
-
|
182 |
-
// @todo Avoid the URL generator from the JS and remove the below static URL check condition.
|
183 |
-
if ( empty( $google_font_url ) || '//fonts.googleapis.com/css?family=' == $google_font_url ) {
|
184 |
-
return;
|
185 |
-
}
|
186 |
-
|
187 |
-
wp_enqueue_style( 'cartflows-google-fonts', esc_url( $google_font_url ), array(), CARTFLOWS_VER, 'all' );
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Get string between
|
192 |
-
*
|
193 |
-
* @param string $string Input string.
|
194 |
-
* @param string $start First string.
|
195 |
-
* @param string $end Last string.
|
196 |
-
* @return string string.
|
197 |
-
*/
|
198 |
-
public static function get_string_between( $string, $start, $end ) {
|
199 |
-
$string = ' ' . $string;
|
200 |
-
$ini = strpos( $string, $start );
|
201 |
-
if ( 0 == $ini ) {
|
202 |
-
return '';
|
203 |
-
}
|
204 |
-
$ini += strlen( $start );
|
205 |
-
$len = strpos( $string, $end, $ini ) - $ini;
|
206 |
-
return substr( $string, $ini, $len );
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Google Font URL
|
211 |
-
* Combine multiple google font in one URL
|
212 |
-
*
|
213 |
-
* @link https://shellcreeper.com/?p=1476
|
214 |
-
* @param array $fonts Google Fonts array.
|
215 |
-
* @param array $subsets Font's Subsets array.
|
216 |
-
*
|
217 |
-
* @return string
|
218 |
-
*/
|
219 |
-
public static function google_fonts_url( $fonts, $subsets = array() ) {
|
220 |
-
|
221 |
-
/* URL */
|
222 |
-
$base_url = '//fonts.googleapis.com/css';
|
223 |
-
$font_args = array();
|
224 |
-
$family = array();
|
225 |
-
|
226 |
-
$fonts = apply_filters( 'cartflows_google_fonts', $fonts );
|
227 |
-
|
228 |
-
/* Format Each Font Family in Array */
|
229 |
-
foreach ( $fonts as $font_name => $font_weight ) {
|
230 |
-
$font_name = str_replace( ' ', '+', $font_name );
|
231 |
-
if ( ! empty( $font_weight ) ) {
|
232 |
-
if ( is_array( $font_weight ) ) {
|
233 |
-
$font_weight = implode( ',', $font_weight );
|
234 |
-
}
|
235 |
-
$font_family = explode( ',', $font_name );
|
236 |
-
$font_family = str_replace( "'", '', wcf_get_prop( $font_family, 0 ) );
|
237 |
-
$family[] = trim( $font_family . ':' . urlencode( trim( $font_weight ) ) )
|
238 |
-
} else {
|
239 |
-
$family[] = trim( $font_name );
|
240 |
-
}
|
241 |
-
}
|
242 |
-
|
243 |
-
/* Only return URL if font family defined. */
|
244 |
-
if ( ! empty( $family ) ) {
|
245 |
-
|
246 |
-
/* Make Font Family a String */
|
247 |
-
$family = implode( '|', $family );
|
248 |
-
|
249 |
-
/* Add font family in args */
|
250 |
-
$font_args['family'] = $family;
|
251 |
-
|
252 |
-
/* Add font subsets in args */
|
253 |
-
if ( ! empty( $subsets ) ) {
|
254 |
-
|
255 |
-
/* format subsets to string */
|
256 |
-
if ( is_array( $subsets ) ) {
|
257 |
-
$subsets = implode( ',', $subsets );
|
258 |
-
}
|
259 |
-
|
260 |
-
$font_args['subset'] = urlencode( trim( $subsets ) )
|
261 |
-
}
|
262 |
-
return add_query_arg( $font_args, $base_url );
|
263 |
-
}
|
264 |
-
|
265 |
-
return '';
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Generate Google Font URL from the post meta.
|
270 |
-
*
|
271 |
-
* @param integer $post_id Post ID.
|
272 |
-
* @return string Google URL if post meta is set.
|
273 |
-
*/
|
274 |
-
function generate_google_url( $post_id ) {
|
275 |
-
|
276 |
-
$font_weight = array();
|
277 |
-
$fields = get_post_meta( $post_id );
|
278 |
-
|
279 |
-
foreach ( $fields as $key => $value ) {
|
280 |
-
if ( false !== strpos( $key, 'font-family' ) ) {
|
281 |
-
$font_family = ! empty( $value[0] ) ? self::get_string_between( $value[0], '\'', '\'' ) : '';
|
282 |
-
$font_list[ $font_family ] = array();
|
283 |
-
}
|
284 |
-
}
|
285 |
-
|
286 |
-
$google_fonts = array();
|
287 |
-
$font_subset = array();
|
288 |
-
|
289 |
-
$system_fonts = self::get_system_fonts();
|
290 |
-
$get_google_fonts = self::get_google_fonts();
|
291 |
-
|
292 |
-
$variants = array( 'variants' => array( 400 ) );
|
293 |
-
foreach ( $font_list as $name => $font ) {
|
294 |
-
if ( ! empty( $name ) && ! isset( $system_fonts[ $name ] ) ) {
|
295 |
-
|
296 |
-
if ( isset( $get_google_fonts[ $name ] ) ) {
|
297 |
-
$variants = $get_google_fonts[ $name ][0];
|
298 |
-
}
|
299 |
-
|
300 |
-
// Add font variants.
|
301 |
-
$google_fonts[ $name ] = $variants;
|
302 |
-
|
303 |
-
// Add Subset.
|
304 |
-
$subset = apply_filters( 'cartflows_font_subset', '', $name );
|
305 |
-
if ( ! empty( $subset ) ) {
|
306 |
-
$font_subset[] = $subset;
|
307 |
-
}
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
311 |
-
return self::google_fonts_url( $google_fonts, $font_subset );
|
312 |
-
}
|
313 |
-
}
|
314 |
-
|
315 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Helper class for font settings.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @author CartFlows
|
7 |
+
* @copyright Copyright (c) 2018, CartFlows
|
8 |
+
* @link https://cartflows.com/
|
9 |
+
* @since 1.0.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly.
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
exit;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Font info class for System and Google fonts.
|
19 |
+
*/
|
20 |
+
if ( ! class_exists( 'CartFlows_Font_Families' ) ) :
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Font info class for System and Google fonts.
|
24 |
+
*/
|
25 |
+
final class CartFlows_Font_Families {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* System Fonts
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @var array
|
32 |
+
*/
|
33 |
+
public static $system_fonts = array();
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Google Fonts
|
37 |
+
*
|
38 |
+
* @since 1.0.0
|
39 |
+
* @var array
|
40 |
+
*/
|
41 |
+
public static $google_fonts = array();
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Get System Fonts
|
45 |
+
*
|
46 |
+
* @since 1.0.0
|
47 |
+
*
|
48 |
+
* @return Array All the system fonts in CartFlows
|
49 |
+
*/
|
50 |
+
public static function get_system_fonts() {
|
51 |
+
if ( empty( self::$system_fonts ) ) {
|
52 |
+
self::$system_fonts = array(
|
53 |
+
'Helvetica' => array(
|
54 |
+
'fallback' => 'Verdana, Arial, sans-serif',
|
55 |
+
'variants' => array(
|
56 |
+
'300',
|
57 |
+
'400',
|
58 |
+
'700',
|
59 |
+
),
|
60 |
+
),
|
61 |
+
'Verdana' => array(
|
62 |
+
'fallback' => 'Helvetica, Arial, sans-serif',
|
63 |
+
'variants' => array(
|
64 |
+
'300',
|
65 |
+
'400',
|
66 |
+
'700',
|
67 |
+
),
|
68 |
+
),
|
69 |
+
'Arial' => array(
|
70 |
+
'fallback' => 'Helvetica, Verdana, sans-serif',
|
71 |
+
'variants' => array(
|
72 |
+
'300',
|
73 |
+
'400',
|
74 |
+
'700',
|
75 |
+
),
|
76 |
+
),
|
77 |
+
'Times' => array(
|
78 |
+
'fallback' => 'Georgia, serif',
|
79 |
+
'variants' => array(
|
80 |
+
'300',
|
81 |
+
'400',
|
82 |
+
'700',
|
83 |
+
),
|
84 |
+
),
|
85 |
+
'Georgia' => array(
|
86 |
+
'fallback' => 'Times, serif',
|
87 |
+
'variants' => array(
|
88 |
+
'300',
|
89 |
+
'400',
|
90 |
+
'700',
|
91 |
+
),
|
92 |
+
),
|
93 |
+
'Courier' => array(
|
94 |
+
'fallback' => 'monospace',
|
95 |
+
'variants' => array(
|
96 |
+
'300',
|
97 |
+
'400',
|
98 |
+
'700',
|
99 |
+
),
|
100 |
+
),
|
101 |
+
);
|
102 |
+
}
|
103 |
+
|
104 |
+
return apply_filters( 'cartflows_system_fonts', self::$system_fonts );
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Custom Fonts
|
109 |
+
*
|
110 |
+
* @since 1.0.0
|
111 |
+
*
|
112 |
+
* @return Array All the custom fonts in CartFlows
|
113 |
+
*/
|
114 |
+
public static function get_custom_fonts() {
|
115 |
+
$custom_fonts = array();
|
116 |
+
|
117 |
+
return apply_filters( 'cartflows_custom_fonts', $custom_fonts );
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Google Fonts used in CartFlows.
|
122 |
+
* Array is generated from the google-fonts.json file.
|
123 |
+
*
|
124 |
+
* @since 1.0.0
|
125 |
+
*
|
126 |
+
* @return Array Array of Google Fonts.
|
127 |
+
*/
|
128 |
+
public static function get_google_fonts() {
|
129 |
+
|
130 |
+
if ( empty( self::$google_fonts ) ) {
|
131 |
+
|
132 |
+
$google_fonts_file = CARTFLOWS_DIR . 'classes/fields/typography/google-fonts.json';
|
133 |
+
|
134 |
+
if ( ! file_exists( $google_fonts_file ) ) {
|
135 |
+
return array();
|
136 |
+
}
|
137 |
+
|
138 |
+
global $wp_filesystem;
|
139 |
+
if ( empty( $wp_filesystem ) ) {
|
140 |
+
require_once ABSPATH . '/wp-admin/includes/file.php';
|
141 |
+
WP_Filesystem();
|
142 |
+
}
|
143 |
+
|
144 |
+
$file_contants = $wp_filesystem->get_contents( $google_fonts_file );
|
145 |
+
$google_fonts_json = json_decode( $file_contants, 1 );
|
146 |
+
|
147 |
+
if ( is_array( $google_fonts_json ) || is_object( $google_fonts_json ) ) {
|
148 |
+
|
149 |
+
foreach ( $google_fonts_json as $key => $font ) {
|
150 |
+
$name = key( $font );
|
151 |
+
foreach ( $font[ $name ] as $font_key => $single_font ) {
|
152 |
+
|
153 |
+
if ( 'variants' === $font_key ) {
|
154 |
+
|
155 |
+
foreach ( $single_font as $variant_key => $variant ) {
|
156 |
+
|
157 |
+
if ( 'regular' == $variant ) {
|
158 |
+
$font[ $name ][ $font_key ][ $variant_key ] = '400';
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
self::$google_fonts[ $name ] = array_values( $font[ $name ] );
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
return apply_filters( 'cartflows_google_fonts', self::$google_fonts );
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Render Fonts
|
174 |
+
*
|
175 |
+
* @param array $post_id post ID.
|
176 |
+
* @return void
|
177 |
+
*/
|
178 |
+
public static function render_fonts( $post_id ) {
|
179 |
+
|
180 |
+
$google_font_url = get_post_meta( $post_id, 'wcf-field-google-font-url', true );
|
181 |
+
|
182 |
+
// @todo Avoid the URL generator from the JS and remove the below static URL check condition.
|
183 |
+
if ( empty( $google_font_url ) || '//fonts.googleapis.com/css?family=' == $google_font_url ) {
|
184 |
+
return;
|
185 |
+
}
|
186 |
+
|
187 |
+
wp_enqueue_style( 'cartflows-google-fonts', esc_url( $google_font_url ), array(), CARTFLOWS_VER, 'all' );
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Get string between
|
192 |
+
*
|
193 |
+
* @param string $string Input string.
|
194 |
+
* @param string $start First string.
|
195 |
+
* @param string $end Last string.
|
196 |
+
* @return string string.
|
197 |
+
*/
|
198 |
+
public static function get_string_between( $string, $start, $end ) {
|
199 |
+
$string = ' ' . $string;
|
200 |
+
$ini = strpos( $string, $start );
|
201 |
+
if ( 0 == $ini ) {
|
202 |
+
return '';
|
203 |
+
}
|
204 |
+
$ini += strlen( $start );
|
205 |
+
$len = strpos( $string, $end, $ini ) - $ini;
|
206 |
+
return substr( $string, $ini, $len );
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Google Font URL
|
211 |
+
* Combine multiple google font in one URL
|
212 |
+
*
|
213 |
+
* @link https://shellcreeper.com/?p=1476
|
214 |
+
* @param array $fonts Google Fonts array.
|
215 |
+
* @param array $subsets Font's Subsets array.
|
216 |
+
*
|
217 |
+
* @return string
|
218 |
+
*/
|
219 |
+
public static function google_fonts_url( $fonts, $subsets = array() ) {
|
220 |
+
|
221 |
+
/* URL */
|
222 |
+
$base_url = '//fonts.googleapis.com/css';
|
223 |
+
$font_args = array();
|
224 |
+
$family = array();
|
225 |
+
|
226 |
+
$fonts = apply_filters( 'cartflows_google_fonts', $fonts );
|
227 |
+
|
228 |
+
/* Format Each Font Family in Array */
|
229 |
+
foreach ( $fonts as $font_name => $font_weight ) {
|
230 |
+
$font_name = str_replace( ' ', '+', $font_name );
|
231 |
+
if ( ! empty( $font_weight ) ) {
|
232 |
+
if ( is_array( $font_weight ) ) {
|
233 |
+
$font_weight = implode( ',', $font_weight );
|
234 |
+
}
|
235 |
+
$font_family = explode( ',', $font_name );
|
236 |
+
$font_family = str_replace( "'", '', wcf_get_prop( $font_family, 0 ) );
|
237 |
+
$family[] = trim( $font_family . ':' . urlencode( trim( $font_weight ) ) );//phpcs:ignore
|
238 |
+
} else {
|
239 |
+
$family[] = trim( $font_name );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
/* Only return URL if font family defined. */
|
244 |
+
if ( ! empty( $family ) ) {
|
245 |
+
|
246 |
+
/* Make Font Family a String */
|
247 |
+
$family = implode( '|', $family );
|
248 |
+
|
249 |
+
/* Add font family in args */
|
250 |
+
$font_args['family'] = $family;
|
251 |
+
|
252 |
+
/* Add font subsets in args */
|
253 |
+
if ( ! empty( $subsets ) ) {
|
254 |
+
|
255 |
+
/* format subsets to string */
|
256 |
+
if ( is_array( $subsets ) ) {
|
257 |
+
$subsets = implode( ',', $subsets );
|
258 |
+
}
|
259 |
+
|
260 |
+
$font_args['subset'] = urlencode( trim( $subsets ) );//phpcs:ignore
|
261 |
+
}
|
262 |
+
return add_query_arg( $font_args, $base_url );
|
263 |
+
}
|
264 |
+
|
265 |
+
return '';
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Generate Google Font URL from the post meta.
|
270 |
+
*
|
271 |
+
* @param integer $post_id Post ID.
|
272 |
+
* @return string Google URL if post meta is set.
|
273 |
+
*/
|
274 |
+
public function generate_google_url( $post_id ) {
|
275 |
+
|
276 |
+
$font_weight = array();
|
277 |
+
$fields = get_post_meta( $post_id );
|
278 |
+
|
279 |
+
foreach ( $fields as $key => $value ) {
|
280 |
+
if ( false !== strpos( $key, 'font-family' ) ) {
|
281 |
+
$font_family = ! empty( $value[0] ) ? self::get_string_between( $value[0], '\'', '\'' ) : '';
|
282 |
+
$font_list[ $font_family ] = array();
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
$google_fonts = array();
|
287 |
+
$font_subset = array();
|
288 |
+
|
289 |
+
$system_fonts = self::get_system_fonts();
|
290 |
+
$get_google_fonts = self::get_google_fonts();
|
291 |
+
|
292 |
+
$variants = array( 'variants' => array( 400 ) );
|
293 |
+
foreach ( $font_list as $name => $font ) {
|
294 |
+
if ( ! empty( $name ) && ! isset( $system_fonts[ $name ] ) ) {
|
295 |
+
|
296 |
+
if ( isset( $get_google_fonts[ $name ] ) ) {
|
297 |
+
$variants = $get_google_fonts[ $name ][0];
|
298 |
+
}
|
299 |
+
|
300 |
+
// Add font variants.
|
301 |
+
$google_fonts[ $name ] = $variants;
|
302 |
+
|
303 |
+
// Add Subset.
|
304 |
+
$subset = apply_filters( 'cartflows_font_subset', '', $name );
|
305 |
+
if ( ! empty( $subset ) ) {
|
306 |
+
$font_subset[] = $subset;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
return self::google_fonts_url( $google_fonts, $font_subset );
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
endif;
|
classes/logger/class-cartflows-log-handler-file.php
CHANGED
@@ -1,442 +1,442 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Class Cartflows_Log_Handler_File file.
|
4 |
-
*
|
5 |
-
* @package WooCommerce\Log Handlers
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit; // Exit if accessed directly.
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Handles log entries by writing to a file.
|
14 |
-
*
|
15 |
-
* @class Cartflows_Log_Handler_File
|
16 |
-
* @version 1.0.0
|
17 |
-
* @package WooCommerce/Classes/Log_Handlers
|
18 |
-
*/
|
19 |
-
class Cartflows_Log_Handler_File extends Cartflows_Log_Handler {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Stores open file handles.
|
23 |
-
*
|
24 |
-
* @var array
|
25 |
-
*/
|
26 |
-
protected $handles = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* File size limit for log files in bytes.
|
30 |
-
*
|
31 |
-
* @var int
|
32 |
-
*/
|
33 |
-
protected $log_size_limit;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Cache logs that could not be written.
|
37 |
-
*
|
38 |
-
* If a log is written too early in the request, pluggable functions may be unavailable. These
|
39 |
-
* logs will be cached and written on 'plugins_loaded' action.
|
40 |
-
*
|
41 |
-
* @var array
|
42 |
-
*/
|
43 |
-
protected $cached_logs = array();
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Constructor for the logger.
|
47 |
-
*
|
48 |
-
* @param int $log_size_limit Optional. Size limit for log files. Default 5mb.
|
49 |
-
*/
|
50 |
-
public function __construct( $log_size_limit = null ) {
|
51 |
-
if ( null === $log_size_limit ) {
|
52 |
-
$log_size_limit = 5 * 1024 * 1024;
|
53 |
-
}
|
54 |
-
|
55 |
-
$this->log_size_limit = apply_filters( 'cartflows_log_file_size_limit', $log_size_limit );
|
56 |
-
|
57 |
-
add_action( 'plugins_loaded', array( $this, 'write_cached_logs' ) );
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Destructor.
|
62 |
-
*
|
63 |
-
* Cleans up open file handles.
|
64 |
-
*/
|
65 |
-
public function __destruct() {
|
66 |
-
foreach ( $this->handles as $handle ) {
|
67 |
-
if ( is_resource( $handle ) ) {
|
68 |
-
fclose( $handle ); // @codingStandardsIgnoreLine.
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Handle a log entry.
|
75 |
-
*
|
76 |
-
* @param int $timestamp Log timestamp.
|
77 |
-
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
78 |
-
* @param string $message Log message.
|
79 |
-
* @param array $context {
|
80 |
-
* Additional information for log handlers.
|
81 |
-
*
|
82 |
-
* @type string $source Optional. Determines log file to write to. Default 'log'.
|
83 |
-
* @type bool $_legacy Optional. Default false. True to use outdated log format
|
84 |
-
* originally used in deprecated Cartflows_WC_Logger::add calls.
|
85 |
-
* }
|
86 |
-
*
|
87 |
-
* @return bool False if value was not handled and true if value was handled.
|
88 |
-
*/
|
89 |
-
public function handle( $timestamp, $level, $message, $context ) {
|
90 |
-
|
91 |
-
if ( isset( $context['source'] ) && $context['source'] ) {
|
92 |
-
$handle = $context['source'];
|
93 |
-
} else {
|
94 |
-
$handle = 'log';
|
95 |
-
}
|
96 |
-
|
97 |
-
$entry = self::format_entry( $timestamp, $level, $message, $context );
|
98 |
-
|
99 |
-
return $this->add( $entry, $handle );
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Builds a log entry text from timestamp, level and message.
|
104 |
-
*
|
105 |
-
* @param int $timestamp Log timestamp.
|
106 |
-
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
107 |
-
* @param string $message Log message.
|
108 |
-
* @param array $context Additional information for log handlers.
|
109 |
-
*
|
110 |
-
* @return string Formatted log entry.
|
111 |
-
*/
|
112 |
-
protected static function format_entry( $timestamp, $level, $message, $context ) {
|
113 |
-
|
114 |
-
if ( isset( $context['_legacy'] ) && true === $context['_legacy'] ) {
|
115 |
-
if ( isset( $context['source'] ) && $context['source'] ) {
|
116 |
-
$handle = $context['source'];
|
117 |
-
} else {
|
118 |
-
$handle = 'log';
|
119 |
-
}
|
120 |
-
$message = apply_filters( 'cartflows_logger_add_message', $message, $handle );
|
121 |
-
$time = date_i18n( 'm-d-Y @ H:i:s' );
|
122 |
-
$entry = "{$time} - {$message}";
|
123 |
-
} else {
|
124 |
-
$entry = parent::format_entry( $timestamp, $level, $message, $context );
|
125 |
-
}
|
126 |
-
|
127 |
-
return $entry;
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Open log file for writing.
|
132 |
-
*
|
133 |
-
* @param string $handle Log handle.
|
134 |
-
* @param string $mode Optional. File mode. Default 'a'.
|
135 |
-
* @return bool Success.
|
136 |
-
*/
|
137 |
-
protected function open( $handle, $mode = 'a' ) {
|
138 |
-
if ( $this->is_open( $handle ) ) {
|
139 |
-
return true;
|
140 |
-
}
|
141 |
-
|
142 |
-
$file = self::get_log_file_path( $handle );
|
143 |
-
|
144 |
-
if ( $file ) {
|
145 |
-
if ( ! file_exists( $file ) ) {
|
146 |
-
$temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine.
|
147 |
-
@fclose( $temphandle ); // @codingStandardsIgnoreLine.
|
148 |
-
|
149 |
-
if ( defined( 'FS_CHMOD_FILE' ) ) {
|
150 |
-
@chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine.
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
$resource = @fopen( $file, $mode ); // @codingStandardsIgnoreLine.
|
155 |
-
|
156 |
-
if ( $resource ) {
|
157 |
-
$this->handles[ $handle ] = $resource;
|
158 |
-
return true;
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
return false;
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Check if a handle is open.
|
167 |
-
*
|
168 |
-
* @param string $handle Log handle.
|
169 |
-
* @return bool True if $handle is open.
|
170 |
-
*/
|
171 |
-
protected function is_open( $handle ) {
|
172 |
-
return array_key_exists( $handle, $this->handles ) && is_resource( $this->handles[ $handle ] );
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Close a handle.
|
177 |
-
*
|
178 |
-
* @param string $handle Log handle.
|
179 |
-
* @return bool success
|
180 |
-
*/
|
181 |
-
protected function close( $handle ) {
|
182 |
-
$result = false;
|
183 |
-
|
184 |
-
if ( $this->is_open( $handle ) ) {
|
185 |
-
$result = fclose( $this->handles[ $handle ] ); // @codingStandardsIgnoreLine.
|
186 |
-
unset( $this->handles[ $handle ] );
|
187 |
-
}
|
188 |
-
|
189 |
-
return $result;
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Add a log entry to chosen file.
|
194 |
-
*
|
195 |
-
* @param string $entry Log entry text.
|
196 |
-
* @param string $handle Log entry handle.
|
197 |
-
*
|
198 |
-
* @return bool True if write was successful.
|
199 |
-
*/
|
200 |
-
protected function add( $entry, $handle ) {
|
201 |
-
$result = false;
|
202 |
-
|
203 |
-
if ( $this->should_rotate( $handle ) ) {
|
204 |
-
$this->log_rotate( $handle );
|
205 |
-
}
|
206 |
-
|
207 |
-
if ( $this->open( $handle ) && is_resource( $this->handles[ $handle ] ) ) {
|
208 |
-
$result = fwrite( $this->handles[ $handle ], $entry . PHP_EOL ); // @codingStandardsIgnoreLine.
|
209 |
-
} else {
|
210 |
-
$this->cache_log( $entry, $handle );
|
211 |
-
}
|
212 |
-
|
213 |
-
return false !== $result;
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Clear entries from chosen file.
|
218 |
-
*
|
219 |
-
* @param string $handle Log handle.
|
220 |
-
*
|
221 |
-
* @return bool
|
222 |
-
*/
|
223 |
-
public function clear( $handle ) {
|
224 |
-
$result = false;
|
225 |
-
|
226 |
-
// Close the file if it's already open.
|
227 |
-
$this->close( $handle );
|
228 |
-
|
229 |
-
/**
|
230 |
-
* $this->open( $handle, 'w' ) == Open the file for writing only. Place the file pointer at
|
231 |
-
* the beginning of the file, and truncate the file to zero length.
|
232 |
-
*/
|
233 |
-
if ( $this->open( $handle, 'w' ) && is_resource( $this->handles[ $handle ] ) ) {
|
234 |
-
$result = true;
|
235 |
-
}
|
236 |
-
|
237 |
-
do_action( 'cartflows_log_clear', $handle );
|
238 |
-
|
239 |
-
return $result;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Remove/delete the chosen file.
|
244 |
-
*
|
245 |
-
* @param string $handle Log handle.
|
246 |
-
*
|
247 |
-
* @return bool
|
248 |
-
*/
|
249 |
-
public function remove( $handle ) {
|
250 |
-
$removed = false;
|
251 |
-
$logs = $this->get_log_files();
|
252 |
-
$handle = sanitize_title( $handle );
|
253 |
-
|
254 |
-
if ( isset( $logs[ $handle ] ) && $logs[ $handle ] ) {
|
255 |
-
$file = realpath( trailingslashit( CARTFLOWS_LOG_DIR ) . $logs[ $handle ] );
|
256 |
-
if ( 0 === stripos( $file, realpath( trailingslashit( CARTFLOWS_LOG_DIR ) ) ) && is_file( $file ) && is_writable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
|
257 |
-
$this->close( $file ); // Close first to be certain no processes keep it alive after it is unlinked.
|
258 |
-
$removed = unlink( $file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink
|
259 |
-
}
|
260 |
-
do_action( 'cartflows_log_remove', $handle, $removed );
|
261 |
-
}
|
262 |
-
return $removed;
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Check if log file should be rotated.
|
267 |
-
*
|
268 |
-
* Compares the size of the log file to determine whether it is over the size limit.
|
269 |
-
*
|
270 |
-
* @param string $handle Log handle.
|
271 |
-
* @return bool True if if should be rotated.
|
272 |
-
*/
|
273 |
-
protected function should_rotate( $handle ) {
|
274 |
-
$file = self::get_log_file_path( $handle );
|
275 |
-
if ( $file ) {
|
276 |
-
if ( $this->is_open( $handle ) ) {
|
277 |
-
$file_stat = fstat( $this->handles[ $handle ] );
|
278 |
-
return $file_stat['size'] > $this->log_size_limit;
|
279 |
-
} elseif ( file_exists( $file ) ) {
|
280 |
-
return filesize( $file ) > $this->log_size_limit;
|
281 |
-
} else {
|
282 |
-
return false;
|
283 |
-
}
|
284 |
-
} else {
|
285 |
-
return false;
|
286 |
-
}
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Rotate log files.
|
291 |
-
*
|
292 |
-
* Logs are rotated by prepending '.x' to the '.log' suffix.
|
293 |
-
* The current log plus 10 historical logs are maintained.
|
294 |
-
* For example:
|
295 |
-
* base.9.log -> [ REMOVED ]
|
296 |
-
* base.8.log -> base.9.log
|
297 |
-
* ...
|
298 |
-
* base.0.log -> base.1.log
|
299 |
-
* base.log -> base.0.log
|
300 |
-
*
|
301 |
-
* @param string $handle Log handle.
|
302 |
-
*/
|
303 |
-
protected function log_rotate( $handle ) {
|
304 |
-
for ( $i = 8; $i >= 0; $i-- ) {
|
305 |
-
$this->increment_log_infix( $handle, $i );
|
306 |
-
}
|
307 |
-
$this->increment_log_infix( $handle );
|
308 |
-
}
|
309 |
-
|
310 |
-
/**
|
311 |
-
* Increment a log file suffix.
|
312 |
-
*
|
313 |
-
* @param string $handle Log handle.
|
314 |
-
* @param null|int $number Optional. Default null. Log suffix number to be incremented.
|
315 |
-
* @return bool True if increment was successful, otherwise false.
|
316 |
-
*/
|
317 |
-
protected function increment_log_infix( $handle, $number = null ) {
|
318 |
-
if ( null === $number ) {
|
319 |
-
$suffix = '';
|
320 |
-
$next_suffix = '.0';
|
321 |
-
} else {
|
322 |
-
$suffix = '.' . $number;
|
323 |
-
$next_suffix = '.' . ( $number + 1 );
|
324 |
-
}
|
325 |
-
|
326 |
-
$rename_from = self::get_log_file_path( "{$handle}{$suffix}" );
|
327 |
-
$rename_to = self::get_log_file_path( "{$handle}{$next_suffix}" );
|
328 |
-
|
329 |
-
if ( $this->is_open( $rename_from ) ) {
|
330 |
-
$this->close( $rename_from );
|
331 |
-
}
|
332 |
-
|
333 |
-
if ( is_writable( $rename_from ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
|
334 |
-
return rename( $rename_from, $rename_to ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_rename
|
335 |
-
} else {
|
336 |
-
return false;
|
337 |
-
}
|
338 |
-
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Get a log file path.
|
343 |
-
*
|
344 |
-
* @param string $handle Log name.
|
345 |
-
* @return bool|string The log file path or false if path cannot be determined.
|
346 |
-
*/
|
347 |
-
public static function get_log_file_path( $handle ) {
|
348 |
-
if ( function_exists( 'wp_hash' ) ) {
|
349 |
-
return trailingslashit( CARTFLOWS_LOG_DIR ) . self::get_log_file_name( $handle );
|
350 |
-
} else {
|
351 |
-
wc_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'cartflows' ), '3.0' );
|
352 |
-
return false;
|
353 |
-
}
|
354 |
-
}
|
355 |
-
|
356 |
-
/**
|
357 |
-
* Get a log file name.
|
358 |
-
*
|
359 |
-
* File names consist of the handle, followed by the date, followed by a hash, .log.
|
360 |
-
*
|
361 |
-
* @since 3.3
|
362 |
-
* @param string $handle Log name.
|
363 |
-
* @return bool|string The log file name or false if cannot be determined.
|
364 |
-
*/
|
365 |
-
public static function get_log_file_name( $handle ) {
|
366 |
-
if ( function_exists( 'wp_hash' ) ) {
|
367 |
-
$date_suffix =
|
368 |
-
$hash_suffix = wp_hash( $handle );
|
369 |
-
return sanitize_file_name( implode( '-', array( $handle, $date_suffix, $hash_suffix ) ) . '.log' );
|
370 |
-
} else {
|
371 |
-
wc_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'cartflows' ), '3.3' );
|
372 |
-
return false;
|
373 |
-
}
|
374 |
-
}
|
375 |
-
|
376 |
-
/**
|
377 |
-
* Cache log to write later.
|
378 |
-
*
|
379 |
-
* @param string $entry Log entry text.
|
380 |
-
* @param string $handle Log entry handle.
|
381 |
-
*/
|
382 |
-
protected function cache_log( $entry, $handle ) {
|
383 |
-
$this->cached_logs[] = array(
|
384 |
-
'entry' => $entry,
|
385 |
-
'handle' => $handle,
|
386 |
-
);
|
387 |
-
}
|
388 |
-
|
389 |
-
/**
|
390 |
-
* Write cached logs.
|
391 |
-
*/
|
392 |
-
public function write_cached_logs() {
|
393 |
-
foreach ( $this->cached_logs as $log ) {
|
394 |
-
$this->add( $log['entry'], $log['handle'] );
|
395 |
-
}
|
396 |
-
}
|
397 |
-
|
398 |
-
/**
|
399 |
-
* Delete all logs older than a defined timestamp.
|
400 |
-
*
|
401 |
-
* @since 3.4.0
|
402 |
-
* @param integer $timestamp Timestamp to delete logs before.
|
403 |
-
*/
|
404 |
-
public static function delete_logs_before_timestamp( $timestamp = 0 ) {
|
405 |
-
if ( ! $timestamp ) {
|
406 |
-
return;
|
407 |
-
}
|
408 |
-
|
409 |
-
$log_files = self::get_log_files();
|
410 |
-
|
411 |
-
foreach ( $log_files as $log_file ) {
|
412 |
-
$last_modified = filemtime( trailingslashit( CARTFLOWS_LOG_DIR ) . $log_file );
|
413 |
-
|
414 |
-
if ( $last_modified < $timestamp ) {
|
415 |
-
@unlink( trailingslashit( CARTFLOWS_LOG_DIR ) . $log_file ); // @codingStandardsIgnoreLine.
|
416 |
-
}
|
417 |
-
}
|
418 |
-
}
|
419 |
-
|
420 |
-
/**
|
421 |
-
* Get all log files in the log directory.
|
422 |
-
*
|
423 |
-
* @since 3.4.0
|
424 |
-
* @return array
|
425 |
-
*/
|
426 |
-
public static function get_log_files() {
|
427 |
-
$files = @scandir( CARTFLOWS_LOG_DIR ); // @codingStandardsIgnoreLine.
|
428 |
-
$result = array();
|
429 |
-
|
430 |
-
if ( ! empty( $files ) ) {
|
431 |
-
foreach ( $files as $key => $value ) {
|
432 |
-
if ( ! in_array( $value, array( '.', '..' ), true ) ) {
|
433 |
-
if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) {
|
434 |
-
$result[ sanitize_title( $value ) ] = $value;
|
435 |
-
}
|
436 |
-
}
|
437 |
-
}
|
438 |
-
}
|
439 |
-
|
440 |
-
return $result;
|
441 |
-
}
|
442 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Cartflows_Log_Handler_File file.
|
4 |
+
*
|
5 |
+
* @package WooCommerce\Log Handlers
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Handles log entries by writing to a file.
|
14 |
+
*
|
15 |
+
* @class Cartflows_Log_Handler_File
|
16 |
+
* @version 1.0.0
|
17 |
+
* @package WooCommerce/Classes/Log_Handlers
|
18 |
+
*/
|
19 |
+
class Cartflows_Log_Handler_File extends Cartflows_Log_Handler {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Stores open file handles.
|
23 |
+
*
|
24 |
+
* @var array
|
25 |
+
*/
|
26 |
+
protected $handles = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* File size limit for log files in bytes.
|
30 |
+
*
|
31 |
+
* @var int
|
32 |
+
*/
|
33 |
+
protected $log_size_limit;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Cache logs that could not be written.
|
37 |
+
*
|
38 |
+
* If a log is written too early in the request, pluggable functions may be unavailable. These
|
39 |
+
* logs will be cached and written on 'plugins_loaded' action.
|
40 |
+
*
|
41 |
+
* @var array
|
42 |
+
*/
|
43 |
+
protected $cached_logs = array();
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Constructor for the logger.
|
47 |
+
*
|
48 |
+
* @param int $log_size_limit Optional. Size limit for log files. Default 5mb.
|
49 |
+
*/
|
50 |
+
public function __construct( $log_size_limit = null ) {
|
51 |
+
if ( null === $log_size_limit ) {
|
52 |
+
$log_size_limit = 5 * 1024 * 1024;
|
53 |
+
}
|
54 |
+
|
55 |
+
$this->log_size_limit = apply_filters( 'cartflows_log_file_size_limit', $log_size_limit );
|
56 |
+
|
57 |
+
add_action( 'plugins_loaded', array( $this, 'write_cached_logs' ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Destructor.
|
62 |
+
*
|
63 |
+
* Cleans up open file handles.
|
64 |
+
*/
|
65 |
+
public function __destruct() {
|
66 |
+
foreach ( $this->handles as $handle ) {
|
67 |
+
if ( is_resource( $handle ) ) {
|
68 |
+
fclose( $handle ); // @codingStandardsIgnoreLine.
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Handle a log entry.
|
75 |
+
*
|
76 |
+
* @param int $timestamp Log timestamp.
|
77 |
+
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
78 |
+
* @param string $message Log message.
|
79 |
+
* @param array $context {
|
80 |
+
* Additional information for log handlers.
|
81 |
+
*
|
82 |
+
* @type string $source Optional. Determines log file to write to. Default 'log'.
|
83 |
+
* @type bool $_legacy Optional. Default false. True to use outdated log format
|
84 |
+
* originally used in deprecated Cartflows_WC_Logger::add calls.
|
85 |
+
* }
|
86 |
+
*
|
87 |
+
* @return bool False if value was not handled and true if value was handled.
|
88 |
+
*/
|
89 |
+
public function handle( $timestamp, $level, $message, $context ) {
|
90 |
+
|
91 |
+
if ( isset( $context['source'] ) && $context['source'] ) {
|
92 |
+
$handle = $context['source'];
|
93 |
+
} else {
|
94 |
+
$handle = 'log';
|
95 |
+
}
|
96 |
+
|
97 |
+
$entry = self::format_entry( $timestamp, $level, $message, $context );
|
98 |
+
|
99 |
+
return $this->add( $entry, $handle );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Builds a log entry text from timestamp, level and message.
|
104 |
+
*
|
105 |
+
* @param int $timestamp Log timestamp.
|
106 |
+
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
107 |
+
* @param string $message Log message.
|
108 |
+
* @param array $context Additional information for log handlers.
|
109 |
+
*
|
110 |
+
* @return string Formatted log entry.
|
111 |
+
*/
|
112 |
+
protected static function format_entry( $timestamp, $level, $message, $context ) {
|
113 |
+
|
114 |
+
if ( isset( $context['_legacy'] ) && true === $context['_legacy'] ) {
|
115 |
+
if ( isset( $context['source'] ) && $context['source'] ) {
|
116 |
+
$handle = $context['source'];
|
117 |
+
} else {
|
118 |
+
$handle = 'log';
|
119 |
+
}
|
120 |
+
$message = apply_filters( 'cartflows_logger_add_message', $message, $handle );
|
121 |
+
$time = date_i18n( 'm-d-Y @ H:i:s' );
|
122 |
+
$entry = "{$time} - {$message}";
|
123 |
+
} else {
|
124 |
+
$entry = parent::format_entry( $timestamp, $level, $message, $context );
|
125 |
+
}
|
126 |
+
|
127 |
+
return $entry;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Open log file for writing.
|
132 |
+
*
|
133 |
+
* @param string $handle Log handle.
|
134 |
+
* @param string $mode Optional. File mode. Default 'a'.
|
135 |
+
* @return bool Success.
|
136 |
+
*/
|
137 |
+
protected function open( $handle, $mode = 'a' ) {
|
138 |
+
if ( $this->is_open( $handle ) ) {
|
139 |
+
return true;
|
140 |
+
}
|
141 |
+
|
142 |
+
$file = self::get_log_file_path( $handle );
|
143 |
+
|
144 |
+
if ( $file ) {
|
145 |
+
if ( ! file_exists( $file ) ) {
|
146 |
+
$temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine.
|
147 |
+
@fclose( $temphandle ); // @codingStandardsIgnoreLine.
|
148 |
+
|
149 |
+
if ( defined( 'FS_CHMOD_FILE' ) ) {
|
150 |
+
@chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine.
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
$resource = @fopen( $file, $mode ); // @codingStandardsIgnoreLine.
|
155 |
+
|
156 |
+
if ( $resource ) {
|
157 |
+
$this->handles[ $handle ] = $resource;
|
158 |
+
return true;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
return false;
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Check if a handle is open.
|
167 |
+
*
|
168 |
+
* @param string $handle Log handle.
|
169 |
+
* @return bool True if $handle is open.
|
170 |
+
*/
|
171 |
+
protected function is_open( $handle ) {
|
172 |
+
return array_key_exists( $handle, $this->handles ) && is_resource( $this->handles[ $handle ] );
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Close a handle.
|
177 |
+
*
|
178 |
+
* @param string $handle Log handle.
|
179 |
+
* @return bool success
|
180 |
+
*/
|
181 |
+
protected function close( $handle ) {
|
182 |
+
$result = false;
|
183 |
+
|
184 |
+
if ( $this->is_open( $handle ) ) {
|
185 |
+
$result = fclose( $this->handles[ $handle ] ); // @codingStandardsIgnoreLine.
|
186 |
+
unset( $this->handles[ $handle ] );
|
187 |
+
}
|
188 |
+
|
189 |
+
return $result;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Add a log entry to chosen file.
|
194 |
+
*
|
195 |
+
* @param string $entry Log entry text.
|
196 |
+
* @param string $handle Log entry handle.
|
197 |
+
*
|
198 |
+
* @return bool True if write was successful.
|
199 |
+
*/
|
200 |
+
protected function add( $entry, $handle ) {
|
201 |
+
$result = false;
|
202 |
+
|
203 |
+
if ( $this->should_rotate( $handle ) ) {
|
204 |
+
$this->log_rotate( $handle );
|
205 |
+
}
|
206 |
+
|
207 |
+
if ( $this->open( $handle ) && is_resource( $this->handles[ $handle ] ) ) {
|
208 |
+
$result = fwrite( $this->handles[ $handle ], $entry . PHP_EOL ); // @codingStandardsIgnoreLine.
|
209 |
+
} else {
|
210 |
+
$this->cache_log( $entry, $handle );
|
211 |
+
}
|
212 |
+
|
213 |
+
return false !== $result;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Clear entries from chosen file.
|
218 |
+
*
|
219 |
+
* @param string $handle Log handle.
|
220 |
+
*
|
221 |
+
* @return bool
|
222 |
+
*/
|
223 |
+
public function clear( $handle ) {
|
224 |
+
$result = false;
|
225 |
+
|
226 |
+
// Close the file if it's already open.
|
227 |
+
$this->close( $handle );
|
228 |
+
|
229 |
+
/**
|
230 |
+
* $this->open( $handle, 'w' ) == Open the file for writing only. Place the file pointer at
|
231 |
+
* the beginning of the file, and truncate the file to zero length.
|
232 |
+
*/
|
233 |
+
if ( $this->open( $handle, 'w' ) && is_resource( $this->handles[ $handle ] ) ) {
|
234 |
+
$result = true;
|
235 |
+
}
|
236 |
+
|
237 |
+
do_action( 'cartflows_log_clear', $handle );
|
238 |
+
|
239 |
+
return $result;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Remove/delete the chosen file.
|
244 |
+
*
|
245 |
+
* @param string $handle Log handle.
|
246 |
+
*
|
247 |
+
* @return bool
|
248 |
+
*/
|
249 |
+
public function remove( $handle ) {
|
250 |
+
$removed = false;
|
251 |
+
$logs = $this->get_log_files();
|
252 |
+
$handle = sanitize_title( $handle );
|
253 |
+
|
254 |
+
if ( isset( $logs[ $handle ] ) && $logs[ $handle ] ) {
|
255 |
+
$file = realpath( trailingslashit( CARTFLOWS_LOG_DIR ) . $logs[ $handle ] );
|
256 |
+
if ( 0 === stripos( $file, realpath( trailingslashit( CARTFLOWS_LOG_DIR ) ) ) && is_file( $file ) && is_writable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
|
257 |
+
$this->close( $file ); // Close first to be certain no processes keep it alive after it is unlinked.
|
258 |
+
$removed = unlink( $file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink
|
259 |
+
}
|
260 |
+
do_action( 'cartflows_log_remove', $handle, $removed );
|
261 |
+
}
|
262 |
+
return $removed;
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Check if log file should be rotated.
|
267 |
+
*
|
268 |
+
* Compares the size of the log file to determine whether it is over the size limit.
|
269 |
+
*
|
270 |
+
* @param string $handle Log handle.
|
271 |
+
* @return bool True if if should be rotated.
|
272 |
+
*/
|
273 |
+
protected function should_rotate( $handle ) {
|
274 |
+
$file = self::get_log_file_path( $handle );
|
275 |
+
if ( $file ) {
|
276 |
+
if ( $this->is_open( $handle ) ) {
|
277 |
+
$file_stat = fstat( $this->handles[ $handle ] );
|
278 |
+
return $file_stat['size'] > $this->log_size_limit;
|
279 |
+
} elseif ( file_exists( $file ) ) {
|
280 |
+
return filesize( $file ) > $this->log_size_limit;
|
281 |
+
} else {
|
282 |
+
return false;
|
283 |
+
}
|
284 |
+
} else {
|
285 |
+
return false;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Rotate log files.
|
291 |
+
*
|
292 |
+
* Logs are rotated by prepending '.x' to the '.log' suffix.
|
293 |
+
* The current log plus 10 historical logs are maintained.
|
294 |
+
* For example:
|
295 |
+
* base.9.log -> [ REMOVED ]
|
296 |
+
* base.8.log -> base.9.log
|
297 |
+
* ...
|
298 |
+
* base.0.log -> base.1.log
|
299 |
+
* base.log -> base.0.log
|
300 |
+
*
|
301 |
+
* @param string $handle Log handle.
|
302 |
+
*/
|
303 |
+
protected function log_rotate( $handle ) {
|
304 |
+
for ( $i = 8; $i >= 0; $i-- ) {
|
305 |
+
$this->increment_log_infix( $handle, $i );
|
306 |
+
}
|
307 |
+
$this->increment_log_infix( $handle );
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Increment a log file suffix.
|
312 |
+
*
|
313 |
+
* @param string $handle Log handle.
|
314 |
+
* @param null|int $number Optional. Default null. Log suffix number to be incremented.
|
315 |
+
* @return bool True if increment was successful, otherwise false.
|
316 |
+
*/
|
317 |
+
protected function increment_log_infix( $handle, $number = null ) {
|
318 |
+
if ( null === $number ) {
|
319 |
+
$suffix = '';
|
320 |
+
$next_suffix = '.0';
|
321 |
+
} else {
|
322 |
+
$suffix = '.' . $number;
|
323 |
+
$next_suffix = '.' . ( $number + 1 );
|
324 |
+
}
|
325 |
+
|
326 |
+
$rename_from = self::get_log_file_path( "{$handle}{$suffix}" );
|
327 |
+
$rename_to = self::get_log_file_path( "{$handle}{$next_suffix}" );
|
328 |
+
|
329 |
+
if ( $this->is_open( $rename_from ) ) {
|
330 |
+
$this->close( $rename_from );
|
331 |
+
}
|
332 |
+
|
333 |
+
if ( is_writable( $rename_from ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
|
334 |
+
return rename( $rename_from, $rename_to ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_rename
|
335 |
+
} else {
|
336 |
+
return false;
|
337 |
+
}
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Get a log file path.
|
343 |
+
*
|
344 |
+
* @param string $handle Log name.
|
345 |
+
* @return bool|string The log file path or false if path cannot be determined.
|
346 |
+
*/
|
347 |
+
public static function get_log_file_path( $handle ) {
|
348 |
+
if ( function_exists( 'wp_hash' ) ) {
|
349 |
+
return trailingslashit( CARTFLOWS_LOG_DIR ) . self::get_log_file_name( $handle );
|
350 |
+
} else {
|
351 |
+
wc_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'cartflows' ), '3.0' );
|
352 |
+
return false;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Get a log file name.
|
358 |
+
*
|
359 |
+
* File names consist of the handle, followed by the date, followed by a hash, .log.
|
360 |
+
*
|
361 |
+
* @since 3.3
|
362 |
+
* @param string $handle Log name.
|
363 |
+
* @return bool|string The log file name or false if cannot be determined.
|
364 |
+
*/
|
365 |
+
public static function get_log_file_name( $handle ) {
|
366 |
+
if ( function_exists( 'wp_hash' ) ) {
|
367 |
+
$date_suffix = gmdate( 'Y-m-d', time() );
|
368 |
+
$hash_suffix = wp_hash( $handle );
|
369 |
+
return sanitize_file_name( implode( '-', array( $handle, $date_suffix, $hash_suffix ) ) . '.log' );
|
370 |
+
} else {
|
371 |
+
wc_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'cartflows' ), '3.3' );
|
372 |
+
return false;
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Cache log to write later.
|
378 |
+
*
|
379 |
+
* @param string $entry Log entry text.
|
380 |
+
* @param string $handle Log entry handle.
|
381 |
+
*/
|
382 |
+
protected function cache_log( $entry, $handle ) {
|
383 |
+
$this->cached_logs[] = array(
|
384 |
+
'entry' => $entry,
|
385 |
+
'handle' => $handle,
|
386 |
+
);
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Write cached logs.
|
391 |
+
*/
|
392 |
+
public function write_cached_logs() {
|
393 |
+
foreach ( $this->cached_logs as $log ) {
|
394 |
+
$this->add( $log['entry'], $log['handle'] );
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Delete all logs older than a defined timestamp.
|
400 |
+
*
|
401 |
+
* @since 3.4.0
|
402 |
+
* @param integer $timestamp Timestamp to delete logs before.
|
403 |
+
*/
|
404 |
+
public static function delete_logs_before_timestamp( $timestamp = 0 ) {
|
405 |
+
if ( ! $timestamp ) {
|
406 |
+
return;
|
407 |
+
}
|
408 |
+
|
409 |
+
$log_files = self::get_log_files();
|
410 |
+
|
411 |
+
foreach ( $log_files as $log_file ) {
|
412 |
+
$last_modified = filemtime( trailingslashit( CARTFLOWS_LOG_DIR ) . $log_file );
|
413 |
+
|
414 |
+
if ( $last_modified < $timestamp ) {
|
415 |
+
@unlink( trailingslashit( CARTFLOWS_LOG_DIR ) . $log_file ); // @codingStandardsIgnoreLine.
|
416 |
+
}
|
417 |
+
}
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Get all log files in the log directory.
|
422 |
+
*
|
423 |
+
* @since 3.4.0
|
424 |
+
* @return array
|
425 |
+
*/
|
426 |
+
public static function get_log_files() {
|
427 |
+
$files = @scandir( CARTFLOWS_LOG_DIR ); // @codingStandardsIgnoreLine.
|
428 |
+
$result = array();
|
429 |
+
|
430 |
+
if ( ! empty( $files ) ) {
|
431 |
+
foreach ( $files as $key => $value ) {
|
432 |
+
if ( ! in_array( $value, array( '.', '..' ), true ) ) {
|
433 |
+
if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) {
|
434 |
+
$result[ sanitize_title( $value ) ] = $value;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
return $result;
|
441 |
+
}
|
442 |
+
}
|
classes/logger/class-cartflows-log-handler.php
CHANGED
@@ -1,57 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Log handling functionality.
|
4 |
-
*
|
5 |
-
* @class Cartflows_Log_Handler
|
6 |
-
* @package WooCommerce/Abstracts
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit; // Exit if accessed directly.
|
11 |
-
}
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Abstract WC Log Handler Class
|
15 |
-
*
|
16 |
-
* @version 1.0.0
|
17 |
-
* @package WooCommerce/Abstracts
|
18 |
-
*/
|
19 |
-
abstract class Cartflows_Log_Handler implements Cartflows_Log_Handler_Interface {
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Formats a timestamp for use in log messages.
|
23 |
-
*
|
24 |
-
* @param int $timestamp Log timestamp.
|
25 |
-
* @return string Formatted time for use in log entry.
|
26 |
-
*/
|
27 |
-
protected static function format_time( $timestamp ) {
|
28 |
-
return
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Builds a log entry text from level, timestamp and message.
|
33 |
-
*
|
34 |
-
* @param int $timestamp Log timestamp.
|
35 |
-
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
36 |
-
* @param string $message Log message.
|
37 |
-
* @param array $context Additional information for log handlers.
|
38 |
-
*
|
39 |
-
* @return string Formatted log entry.
|
40 |
-
*/
|
41 |
-
protected static function format_entry( $timestamp, $level, $message, $context ) {
|
42 |
-
$time_string = self::format_time( $timestamp );
|
43 |
-
$level_string = strtoupper( $level );
|
44 |
-
$entry = "{$time_string} {$level_string} {$message}";
|
45 |
-
|
46 |
-
return apply_filters(
|
47 |
-
'cartflows_format_log_entry',
|
48 |
-
$entry,
|
49 |
-
array(
|
50 |
-
'timestamp' => $timestamp,
|
51 |
-
'level' => $level,
|
52 |
-
'message' => $message,
|
53 |
-
'context' => $context,
|
54 |
-
)
|
55 |
-
);
|
56 |
-
}
|
57 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Log handling functionality.
|
4 |
+
*
|
5 |
+
* @class Cartflows_Log_Handler
|
6 |
+
* @package WooCommerce/Abstracts
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit; // Exit if accessed directly.
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Abstract WC Log Handler Class
|
15 |
+
*
|
16 |
+
* @version 1.0.0
|
17 |
+
* @package WooCommerce/Abstracts
|
18 |
+
*/
|
19 |
+
abstract class Cartflows_Log_Handler implements Cartflows_Log_Handler_Interface {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Formats a timestamp for use in log messages.
|
23 |
+
*
|
24 |
+
* @param int $timestamp Log timestamp.
|
25 |
+
* @return string Formatted time for use in log entry.
|
26 |
+
*/
|
27 |
+
protected static function format_time( $timestamp ) {
|
28 |
+
return gmdate( 'c', $timestamp );
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Builds a log entry text from level, timestamp and message.
|
33 |
+
*
|
34 |
+
* @param int $timestamp Log timestamp.
|
35 |
+
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
36 |
+
* @param string $message Log message.
|
37 |
+
* @param array $context Additional information for log handlers.
|
38 |
+
*
|
39 |
+
* @return string Formatted log entry.
|
40 |
+
*/
|
41 |
+
protected static function format_entry( $timestamp, $level, $message, $context ) {
|
42 |
+
$time_string = self::format_time( $timestamp );
|
43 |
+
$level_string = strtoupper( $level );
|
44 |
+
$entry = "{$time_string} {$level_string} {$message}";
|
45 |
+
|
46 |
+
return apply_filters(
|
47 |
+
'cartflows_format_log_entry',
|
48 |
+
$entry,
|
49 |
+
array(
|
50 |
+
'timestamp' => $timestamp,
|
51 |
+
'level' => $level,
|
52 |
+
'message' => $message,
|
53 |
+
'context' => $context,
|
54 |
+
)
|
55 |
+
);
|
56 |
+
}
|
57 |
+
}
|
classes/logger/class-cartflows-wc-logger.php
CHANGED
@@ -1,301 +1,301 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Provides logging capabilities for debugging purposes.
|
4 |
-
*
|
5 |
-
* @class Cartflows_WC_Logger
|
6 |
-
* @version 2.0.0
|
7 |
-
* @package WooCommerce/Classes
|
8 |
-
*/
|
9 |
-
|
10 |
-
defined( 'ABSPATH' ) || exit;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Cartflows_WC_Logger class.
|
14 |
-
*/
|
15 |
-
class Cartflows_WC_Logger implements Cartflows_WC_Logger_Interface {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Stores registered log handlers.
|
19 |
-
*
|
20 |
-
* @var array
|
21 |
-
*/
|
22 |
-
protected $handlers;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Minimum log level this handler will process.
|
26 |
-
*
|
27 |
-
* @var int Integer representation of minimum log level to handle.
|
28 |
-
*/
|
29 |
-
protected $threshold;
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Constructor for the logger.
|
33 |
-
*
|
34 |
-
* @param array $handlers Optional. Array of log handlers. If $handlers is not provided, the filter 'woocommerce_register_log_handlers' will be used to define the handlers. If $handlers is provided, the filter will not be applied and the handlers will be used directly.
|
35 |
-
* @param string $threshold Optional. Define an explicit threshold. May be configured via WC_LOG_THRESHOLD. By default, all logs will be processed.
|
36 |
-
*/
|
37 |
-
public function __construct( $handlers = null, $threshold = null ) {
|
38 |
-
if ( null === $handlers ) {
|
39 |
-
$handlers = apply_filters( 'cartflows_register_log_handlers', array() );
|
40 |
-
|
41 |
-
$default_handler = new Cartflows_Log_Handler_File();
|
42 |
-
|
43 |
-
array_push( $handlers, $default_handler );
|
44 |
-
}
|
45 |
-
|
46 |
-
$register_handlers = array();
|
47 |
-
|
48 |
-
if ( ! empty( $handlers ) && is_array( $handlers ) ) {
|
49 |
-
foreach ( $handlers as $handler ) {
|
50 |
-
$implements = class_implements( $handler );
|
51 |
-
if ( is_object( $handler ) && is_array( $implements ) && in_array( 'Cartflows_Log_Handler_Interface', $implements, true ) ) {
|
52 |
-
$register_handlers[] = $handler;
|
53 |
-
} else {
|
54 |
-
wc_doing_it_wrong(
|
55 |
-
__METHOD__,
|
56 |
-
sprintf(
|
57 |
-
/* translators: 1: class name 2: Cartflows_Log_Handler_Interface */
|
58 |
-
__( 'The provided handler %1$s does not implement %2$s.', 'cartflows' ),
|
59 |
-
'<code>' . esc_html( is_object( $handler ) ? get_class( $handler ) : $handler ) . '</code>',
|
60 |
-
'<code>Cartflows_Log_Handler_Interface</code>'
|
61 |
-
),
|
62 |
-
'3.0'
|
63 |
-
);
|
64 |
-
}
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
if ( null !== $threshold ) {
|
69 |
-
$threshold = Cartflows_Log_Levels::get_level_severity( $threshold );
|
70 |
-
} elseif ( defined( 'WC_LOG_THRESHOLD' ) && Cartflows_Log_Levels::is_valid_level( WC_LOG_THRESHOLD ) ) {
|
71 |
-
$threshold = Cartflows_Log_Levels::get_level_severity( WC_LOG_THRESHOLD );
|
72 |
-
} else {
|
73 |
-
$threshold = null;
|
74 |
-
}
|
75 |
-
|
76 |
-
$this->handlers = $register_handlers;
|
77 |
-
$this->threshold = $threshold;
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Determine whether to handle or ignore log.
|
82 |
-
*
|
83 |
-
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
84 |
-
* @return bool True if the log should be handled.
|
85 |
-
*/
|
86 |
-
protected function should_handle( $level ) {
|
87 |
-
if ( null === $this->threshold ) {
|
88 |
-
return true;
|
89 |
-
}
|
90 |
-
return $this->threshold <= Cartflows_Log_Levels::get_level_severity( $level );
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Add a log entry.
|
95 |
-
*
|
96 |
-
* This is not the preferred method for adding log messages. Please use log() or any one of
|
97 |
-
* the level methods (debug(), info(), etc.). This method may be deprecated in the future.
|
98 |
-
*
|
99 |
-
* @param string $handle File handle.
|
100 |
-
* @param string $message Message to log.
|
101 |
-
* @param string $level Logging level.
|
102 |
-
* @return bool
|
103 |
-
*/
|
104 |
-
public function add( $handle, $message, $level = Cartflows_Log_Levels::NOTICE ) {
|
105 |
-
$message = apply_filters( 'cartflows_logger_add_message', $message, $handle );
|
106 |
-
$this->log(
|
107 |
-
$level,
|
108 |
-
$message,
|
109 |
-
array(
|
110 |
-
'source' => $handle,
|
111 |
-
'_legacy' => true,
|
112 |
-
)
|
113 |
-
);
|
114 |
-
wc_do_deprecated_action( 'cartflows_log_add', array( $handle, $message ), '3.0', 'This action has been deprecated with no alternative.' );
|
115 |
-
return true;
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Add a log entry.
|
120 |
-
*
|
121 |
-
* @param string $level One of the following:
|
122 |
-
* 'emergency': System is unusable.
|
123 |
-
* 'alert': Action must be taken immediately.
|
124 |
-
* 'critical': Critical conditions.
|
125 |
-
* 'error': Error conditions.
|
126 |
-
* 'warning': Warning conditions.
|
127 |
-
* 'notice': Normal but significant condition.
|
128 |
-
* 'info': Informational messages.
|
129 |
-
* 'debug': Debug-level messages.
|
130 |
-
* @param string $message Log message.
|
131 |
-
* @param array $context Optional. Additional information for log handlers.
|
132 |
-
*/
|
133 |
-
public function log( $level, $message, $context = array() ) {
|
134 |
-
if ( ! Cartflows_Log_Levels::is_valid_level( $level ) ) {
|
135 |
-
/* translators: 1: Cartflows_WC_Logger::log 2: level */
|
136 |
-
wc_doing_it_wrong( __METHOD__, sprintf( __( '%1$s was called with an invalid level "%2$s".', 'cartflows' ), '<code>Cartflows_WC_Logger::log</code>', $level ), '3.0' );
|
137 |
-
}
|
138 |
-
|
139 |
-
if ( $this->should_handle( $level ) ) {
|
140 |
-
$timestamp =
|
141 |
-
$message = apply_filters( 'cartflows_logger_log_message', $message, $level, $context );
|
142 |
-
|
143 |
-
foreach ( $this->handlers as $handler ) {
|
144 |
-
$handler->handle( $timestamp, $level, $message, $context );
|
145 |
-
}
|
146 |
-
}
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Adds an emergency level message.
|
151 |
-
*
|
152 |
-
* System is unusable.
|
153 |
-
*
|
154 |
-
* @see Cartflows_WC_Logger::log
|
155 |
-
*
|
156 |
-
* @param string $message Message to log.
|
157 |
-
* @param array $context Log context.
|
158 |
-
*/
|
159 |
-
public function emergency( $message, $context = array() ) {
|
160 |
-
$this->log( Cartflows_Log_Levels::EMERGENCY, $message, $context );
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Adds an alert level message.
|
165 |
-
*
|
166 |
-
* Action must be taken immediately.
|
167 |
-
* Example: Entire website down, database unavailable, etc.
|
168 |
-
*
|
169 |
-
* @see Cartflows_WC_Logger::log
|
170 |
-
*
|
171 |
-
* @param string $message Message to log.
|
172 |
-
* @param array $context Log context.
|
173 |
-
*/
|
174 |
-
public function alert( $message, $context = array() ) {
|
175 |
-
$this->log( Cartflows_Log_Levels::ALERT, $message, $context );
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Adds a critical level message.
|
180 |
-
*
|
181 |
-
* Critical conditions.
|
182 |
-
* Example: Application component unavailable, unexpected exception.
|
183 |
-
*
|
184 |
-
* @see Cartflows_WC_Logger::log
|
185 |
-
*
|
186 |
-
* @param string $message Message to log.
|
187 |
-
* @param array $context Log context.
|
188 |
-
*/
|
189 |
-
public function critical( $message, $context = array() ) {
|
190 |
-
$this->log( Cartflows_Log_Levels::CRITICAL, $message, $context );
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Adds an error level message.
|
195 |
-
*
|
196 |
-
* Runtime errors that do not require immediate action but should typically be logged
|
197 |
-
* and monitored.
|
198 |
-
*
|
199 |
-
* @see Cartflows_WC_Logger::log
|
200 |
-
*
|
201 |
-
* @param string $message Message to log.
|
202 |
-
* @param array $context Log context.
|
203 |
-
*/
|
204 |
-
public function error( $message, $context = array() ) {
|
205 |
-
$this->log( Cartflows_Log_Levels::ERROR, $message, $context );
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Adds a warning level message.
|
210 |
-
*
|
211 |
-
* Exceptional occurrences that are not errors.
|
212 |
-
*
|
213 |
-
* Example: Use of deprecated APIs, poor use of an API, undesirable things that are not
|
214 |
-
* necessarily wrong.
|
215 |
-
*
|
216 |
-
* @see Cartflows_WC_Logger::log
|
217 |
-
*
|
218 |
-
* @param string $message Message to log.
|
219 |
-
* @param array $context Log context.
|
220 |
-
*/
|
221 |
-
public function warning( $message, $context = array() ) {
|
222 |
-
$this->log( Cartflows_Log_Levels::WARNING, $message, $context );
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Adds a notice level message.
|
227 |
-
*
|
228 |
-
* Normal but significant events.
|
229 |
-
*
|
230 |
-
* @see Cartflows_WC_Logger::log
|
231 |
-
*
|
232 |
-
* @param string $message Message to log.
|
233 |
-
* @param array $context Log context.
|
234 |
-
*/
|
235 |
-
public function notice( $message, $context = array() ) {
|
236 |
-
$this->log( Cartflows_Log_Levels::NOTICE, $message, $context );
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Adds a info level message.
|
241 |
-
*
|
242 |
-
* Interesting events.
|
243 |
-
* Example: User logs in, SQL logs.
|
244 |
-
*
|
245 |
-
* @see Cartflows_WC_Logger::log
|
246 |
-
*
|
247 |
-
* @param string $message Message to log.
|
248 |
-
* @param array $context Log context.
|
249 |
-
*/
|
250 |
-
public function info( $message, $context = array() ) {
|
251 |
-
$this->log( Cartflows_Log_Levels::INFO, $message, $context );
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Adds a debug level message.
|
256 |
-
*
|
257 |
-
* Detailed debug information.
|
258 |
-
*
|
259 |
-
* @see Cartflows_WC_Logger::log
|
260 |
-
*
|
261 |
-
* @param string $message Message to log.
|
262 |
-
* @param array $context Log context.
|
263 |
-
*/
|
264 |
-
public function debug( $message, $context = array() ) {
|
265 |
-
$this->log( Cartflows_Log_Levels::DEBUG, $message, $context );
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* Clear entries for a chosen file/source.
|
270 |
-
*
|
271 |
-
* @param string $source Source/handle to clear.
|
272 |
-
* @return bool
|
273 |
-
*/
|
274 |
-
public function clear( $source = '' ) {
|
275 |
-
if ( ! $source ) {
|
276 |
-
return false;
|
277 |
-
}
|
278 |
-
foreach ( $this->handlers as $handler ) {
|
279 |
-
if ( is_callable( array( $handler, 'clear' ) ) ) {
|
280 |
-
$handler->clear( $source );
|
281 |
-
}
|
282 |
-
}
|
283 |
-
return true;
|
284 |
-
}
|
285 |
-
|
286 |
-
/**
|
287 |
-
* Clear all logs older than a defined number of days. Defaults to 30 days.
|
288 |
-
*
|
289 |
-
* @since 3.4.0
|
290 |
-
*/
|
291 |
-
public function clear_expired_logs() {
|
292 |
-
$days = absint( apply_filters( 'cartflows_logger_days_to_retain_logs', 30 ) );
|
293 |
-
$timestamp = strtotime( "-{$days} days" );
|
294 |
-
|
295 |
-
foreach ( $this->handlers as $handler ) {
|
296 |
-
if ( is_callable( array( $handler, 'delete_logs_before_timestamp' ) ) ) {
|
297 |
-
$handler->delete_logs_before_timestamp( $timestamp );
|
298 |
-
}
|
299 |
-
}
|
300 |
-
}
|
301 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Provides logging capabilities for debugging purposes.
|
4 |
+
*
|
5 |
+
* @class Cartflows_WC_Logger
|
6 |
+
* @version 2.0.0
|
7 |
+
* @package WooCommerce/Classes
|
8 |
+
*/
|
9 |
+
|
10 |
+
defined( 'ABSPATH' ) || exit;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Cartflows_WC_Logger class.
|
14 |
+
*/
|
15 |
+
class Cartflows_WC_Logger implements Cartflows_WC_Logger_Interface {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Stores registered log handlers.
|
19 |
+
*
|
20 |
+
* @var array
|
21 |
+
*/
|
22 |
+
protected $handlers;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Minimum log level this handler will process.
|
26 |
+
*
|
27 |
+
* @var int Integer representation of minimum log level to handle.
|
28 |
+
*/
|
29 |
+
protected $threshold;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Constructor for the logger.
|
33 |
+
*
|
34 |
+
* @param array $handlers Optional. Array of log handlers. If $handlers is not provided, the filter 'woocommerce_register_log_handlers' will be used to define the handlers. If $handlers is provided, the filter will not be applied and the handlers will be used directly.
|
35 |
+
* @param string $threshold Optional. Define an explicit threshold. May be configured via WC_LOG_THRESHOLD. By default, all logs will be processed.
|
36 |
+
*/
|
37 |
+
public function __construct( $handlers = null, $threshold = null ) {
|
38 |
+
if ( null === $handlers ) {
|
39 |
+
$handlers = apply_filters( 'cartflows_register_log_handlers', array() );
|
40 |
+
|
41 |
+
$default_handler = new Cartflows_Log_Handler_File();
|
42 |
+
|
43 |
+
array_push( $handlers, $default_handler );
|
44 |
+
}
|
45 |
+
|
46 |
+
$register_handlers = array();
|
47 |
+
|
48 |
+
if ( ! empty( $handlers ) && is_array( $handlers ) ) {
|
49 |
+
foreach ( $handlers as $handler ) {
|
50 |
+
$implements = class_implements( $handler );
|
51 |
+
if ( is_object( $handler ) && is_array( $implements ) && in_array( 'Cartflows_Log_Handler_Interface', $implements, true ) ) {
|
52 |
+
$register_handlers[] = $handler;
|
53 |
+
} else {
|
54 |
+
wc_doing_it_wrong(
|
55 |
+
__METHOD__,
|
56 |
+
sprintf(
|
57 |
+
/* translators: 1: class name 2: Cartflows_Log_Handler_Interface */
|
58 |
+
__( 'The provided handler %1$s does not implement %2$s.', 'cartflows' ),
|
59 |
+
'<code>' . esc_html( is_object( $handler ) ? get_class( $handler ) : $handler ) . '</code>',
|
60 |
+
'<code>Cartflows_Log_Handler_Interface</code>'
|
61 |
+
),
|
62 |
+
'3.0'
|
63 |
+
);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
if ( null !== $threshold ) {
|
69 |
+
$threshold = Cartflows_Log_Levels::get_level_severity( $threshold );
|
70 |
+
} elseif ( defined( 'WC_LOG_THRESHOLD' ) && Cartflows_Log_Levels::is_valid_level( WC_LOG_THRESHOLD ) ) {
|
71 |
+
$threshold = Cartflows_Log_Levels::get_level_severity( WC_LOG_THRESHOLD );
|
72 |
+
} else {
|
73 |
+
$threshold = null;
|
74 |
+
}
|
75 |
+
|
76 |
+
$this->handlers = $register_handlers;
|
77 |
+
$this->threshold = $threshold;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Determine whether to handle or ignore log.
|
82 |
+
*
|
83 |
+
* @param string $level emergency|alert|critical|error|warning|notice|info|debug.
|
84 |
+
* @return bool True if the log should be handled.
|
85 |
+
*/
|
86 |
+
protected function should_handle( $level ) {
|
87 |
+
if ( null === $this->threshold ) {
|
88 |
+
return true;
|
89 |
+
}
|
90 |
+
return $this->threshold <= Cartflows_Log_Levels::get_level_severity( $level );
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Add a log entry.
|
95 |
+
*
|
96 |
+
* This is not the preferred method for adding log messages. Please use log() or any one of
|
97 |
+
* the level methods (debug(), info(), etc.). This method may be deprecated in the future.
|
98 |
+
*
|
99 |
+
* @param string $handle File handle.
|
100 |
+
* @param string $message Message to log.
|
101 |
+
* @param string $level Logging level.
|
102 |
+
* @return bool
|
103 |
+
*/
|
104 |
+
public function add( $handle, $message, $level = Cartflows_Log_Levels::NOTICE ) {
|
105 |
+
$message = apply_filters( 'cartflows_logger_add_message', $message, $handle );
|
106 |
+
$this->log(
|
107 |
+
$level,
|
108 |
+
$message,
|
109 |
+
array(
|
110 |
+
'source' => $handle,
|
111 |
+
'_legacy' => true,
|
112 |
+
)
|
113 |
+
);
|
114 |
+
wc_do_deprecated_action( 'cartflows_log_add', array( $handle, $message ), '3.0', 'This action has been deprecated with no alternative.' );
|
115 |
+
return true;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Add a log entry.
|
120 |
+
*
|
121 |
+
* @param string $level One of the following:
|
122 |
+
* 'emergency': System is unusable.
|
123 |
+
* 'alert': Action must be taken immediately.
|
124 |
+
* 'critical': Critical conditions.
|
125 |
+
* 'error': Error conditions.
|
126 |
+
* 'warning': Warning conditions.
|
127 |
+
* 'notice': Normal but significant condition.
|
128 |
+
* 'info': Informational messages.
|
129 |
+
* 'debug': Debug-level messages.
|
130 |
+
* @param string $message Log message.
|
131 |
+
* @param array $context Optional. Additional information for log handlers.
|
132 |
+
*/
|
133 |
+
public function log( $level, $message, $context = array() ) {
|
134 |
+
if ( ! Cartflows_Log_Levels::is_valid_level( $level ) ) {
|
135 |
+
/* translators: 1: Cartflows_WC_Logger::log 2: level */
|
136 |
+
wc_doing_it_wrong( __METHOD__, sprintf( __( '%1$s was called with an invalid level "%2$s".', 'cartflows' ), '<code>Cartflows_WC_Logger::log</code>', $level ), '3.0' );
|
137 |
+
}
|
138 |
+
|
139 |
+
if ( $this->should_handle( $level ) ) {
|
140 |
+
$timestamp = time();
|
141 |
+
$message = apply_filters( 'cartflows_logger_log_message', $message, $level, $context );
|
142 |
+
|
143 |
+
foreach ( $this->handlers as $handler ) {
|
144 |
+
$handler->handle( $timestamp, $level, $message, $context );
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Adds an emergency level message.
|
151 |
+
*
|
152 |
+
* System is unusable.
|
153 |
+
*
|
154 |
+
* @see Cartflows_WC_Logger::log
|
155 |
+
*
|
156 |
+
* @param string $message Message to log.
|
157 |
+
* @param array $context Log context.
|
158 |
+
*/
|
159 |
+
public function emergency( $message, $context = array() ) {
|
160 |
+
$this->log( Cartflows_Log_Levels::EMERGENCY, $message, $context );
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Adds an alert level message.
|
165 |
+
*
|
166 |
+
* Action must be taken immediately.
|
167 |
+
* Example: Entire website down, database unavailable, etc.
|
168 |
+
*
|
169 |
+
* @see Cartflows_WC_Logger::log
|
170 |
+
*
|
171 |
+
* @param string $message Message to log.
|
172 |
+
* @param array $context Log context.
|
173 |
+
*/
|
174 |
+
public function alert( $message, $context = array() ) {
|
175 |
+
$this->log( Cartflows_Log_Levels::ALERT, $message, $context );
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Adds a critical level message.
|
180 |
+
*
|
181 |
+
* Critical conditions.
|
182 |
+
* Example: Application component unavailable, unexpected exception.
|
183 |
+
*
|
184 |
+
* @see Cartflows_WC_Logger::log
|
185 |
+
*
|
186 |
+
* @param string $message Message to log.
|
187 |
+
* @param array $context Log context.
|
188 |
+
*/
|
189 |
+
public function critical( $message, $context = array() ) {
|
190 |
+
$this->log( Cartflows_Log_Levels::CRITICAL, $message, $context );
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Adds an error level message.
|
195 |
+
*
|
196 |
+
* Runtime errors that do not require immediate action but should typically be logged
|
197 |
+
* and monitored.
|
198 |
+
*
|
199 |
+
* @see Cartflows_WC_Logger::log
|
200 |
+
*
|
201 |
+
* @param string $message Message to log.
|
202 |
+
* @param array $context Log context.
|
203 |
+
*/
|
204 |
+
public function error( $message, $context = array() ) {
|
205 |
+
$this->log( Cartflows_Log_Levels::ERROR, $message, $context );
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Adds a warning level message.
|
210 |
+
*
|
211 |
+
* Exceptional occurrences that are not errors.
|
212 |
+
*
|
213 |
+
* Example: Use of deprecated APIs, poor use of an API, undesirable things that are not
|
214 |
+
* necessarily wrong.
|
215 |
+
*
|
216 |
+
* @see Cartflows_WC_Logger::log
|
217 |
+
*
|
218 |
+
* @param string $message Message to log.
|
219 |
+
* @param array $context Log context.
|
220 |
+
*/
|
221 |
+
public function warning( $message, $context = array() ) {
|
222 |
+
$this->log( Cartflows_Log_Levels::WARNING, $message, $context );
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Adds a notice level message.
|
227 |
+
*
|
228 |
+
* Normal but significant events.
|
229 |
+
*
|
230 |
+
* @see Cartflows_WC_Logger::log
|
231 |
+
*
|
232 |
+
* @param string $message Message to log.
|
233 |
+
* @param array $context Log context.
|
234 |
+
*/
|
235 |
+
public function notice( $message, $context = array() ) {
|
236 |
+
$this->log( Cartflows_Log_Levels::NOTICE, $message, $context );
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Adds a info level message.
|
241 |
+
*
|
242 |
+
* Interesting events.
|
243 |
+
* Example: User logs in, SQL logs.
|
244 |
+
*
|
245 |
+
* @see Cartflows_WC_Logger::log
|
246 |
+
*
|
247 |
+
* @param string $message Message to log.
|
248 |
+
* @param array $context Log context.
|
249 |
+
*/
|
250 |
+
public function info( $message, $context = array() ) {
|
251 |
+
$this->log( Cartflows_Log_Levels::INFO, $message, $context );
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Adds a debug level message.
|
256 |
+
*
|
257 |
+
* Detailed debug information.
|
258 |
+
*
|
259 |
+
* @see Cartflows_WC_Logger::log
|
260 |
+
*
|
261 |
+
* @param string $message Message to log.
|
262 |
+
* @param array $context Log context.
|
263 |
+
*/
|
264 |
+
public function debug( $message, $context = array() ) {
|
265 |
+
$this->log( Cartflows_Log_Levels::DEBUG, $message, $context );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Clear entries for a chosen file/source.
|
270 |
+
*
|
271 |
+
* @param string $source Source/handle to clear.
|
272 |
+
* @return bool
|
273 |
+
*/
|
274 |
+
public function clear( $source = '' ) {
|
275 |
+
if ( ! $source ) {
|
276 |
+
return false;
|
277 |
+
}
|
278 |
+
foreach ( $this->handlers as $handler ) {
|
279 |
+
if ( is_callable( array( $handler, 'clear' ) ) ) {
|
280 |
+
$handler->clear( $source );
|
281 |
+
}
|
282 |
+
}
|
283 |
+
return true;
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Clear all logs older than a defined number of days. Defaults to 30 days.
|
288 |
+
*
|
289 |
+
* @since 3.4.0
|
290 |
+
*/
|
291 |
+
public function clear_expired_logs() {
|
292 |
+
$days = absint( apply_filters( 'cartflows_logger_days_to_retain_logs', 30 ) );
|
293 |
+
$timestamp = strtotime( "-{$days} days" );
|
294 |
+
|
295 |
+
foreach ( $this->handlers as $handler ) {
|
296 |
+
if ( is_callable( array( $handler, 'delete_logs_before_timestamp' ) ) ) {
|
297 |
+
$handler->delete_logs_before_timestamp( $timestamp );
|
298 |
+
}
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
includes/admin/cartflows-admin.php
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CARTFLOWS Admin HTML.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
?>
|
9 |
-
<div class="wcf-menu-page-wrapper">
|
10 |
-
<div id="wcf-menu-page">
|
11 |
-
<div class="wcf-menu-page-header <?php echo esc_attr( implode( ' ', $header_wrapper_class ) ); ?>">
|
12 |
-
<div class="wcf-container wcf-flex">
|
13 |
-
<div class="wcf-title">
|
14 |
-
<span class="screen-reader-text"><?php echo CARTFLOWS_PLUGIN_NAME; ?></span>
|
15 |
-
<img class="wcf-logo" src="<?php echo CARTFLOWS_URL . 'assets/images/cartflows-logo.svg'; ?>" />
|
16 |
-
</div>
|
17 |
-
<div class="wcf-top-links">
|
18 |
-
<?php
|
19 |
-
esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
|
20 |
-
?>
|
21 |
-
</div>
|
22 |
-
</div>
|
23 |
-
</div>
|
24 |
-
|
25 |
-
<?php
|
26 |
-
// Settings update message.
|
27 |
-
if ( isset( $_REQUEST['message'] ) && ( 'saved' == $_REQUEST['message'] || 'saved_ext' == $_REQUEST['message'] ) ) {
|
28 |
-
?>
|
29 |
-
<div id="message" class="notice notice-success is-dismissive wcf-notice"><p> <?php esc_html_e( 'Settings saved successfully.', 'cartflows' ); ?> </p></div>
|
30 |
-
<?php
|
31 |
-
}
|
32 |
-
?>
|
33 |
-
<?php do_action( 'cartflows_render_admin_content' ); ?>
|
34 |
-
</div>
|
35 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CARTFLOWS Admin HTML.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
?>
|
9 |
+
<div class="wcf-menu-page-wrapper">
|
10 |
+
<div id="wcf-menu-page">
|
11 |
+
<div class="wcf-menu-page-header <?php echo esc_attr( implode( ' ', $header_wrapper_class ) ); ?>">
|
12 |
+
<div class="wcf-container wcf-flex">
|
13 |
+
<div class="wcf-title">
|
14 |
+
<span class="screen-reader-text"><?php echo esc_attr( CARTFLOWS_PLUGIN_NAME ); ?></span>
|
15 |
+
<img class="wcf-logo" src="<?php echo esc_attr( CARTFLOWS_URL ) . 'assets/images/cartflows-logo.svg'; ?>" />
|
16 |
+
</div>
|
17 |
+
<div class="wcf-top-links">
|
18 |
+
<?php
|
19 |
+
esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
|
20 |
+
?>
|
21 |
+
</div>
|
22 |
+
</div>
|
23 |
+
</div>
|
24 |
+
|
25 |
+
<?php
|
26 |
+
// Settings update message.
|
27 |
+
if ( isset( $_REQUEST['message'] ) && ( 'saved' == $_REQUEST['message'] || 'saved_ext' == $_REQUEST['message'] ) ) {
|
28 |
+
?>
|
29 |
+
<div id="message" class="notice notice-success is-dismissive wcf-notice"><p> <?php esc_html_e( 'Settings saved successfully.', 'cartflows' ); ?> </p></div>
|
30 |
+
<?php
|
31 |
+
}
|
32 |
+
?>
|
33 |
+
<?php do_action( 'cartflows_render_admin_content' ); ?>
|
34 |
+
</div>
|
35 |
+
</div>
|
includes/admin/cartflows-error-log.php
CHANGED
@@ -1,71 +1,71 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin View: Page - Status Logs
|
4 |
-
*
|
5 |
-
* @package WooCommerce/Admin/Logs
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit;
|
10 |
-
}
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
?>
|
15 |
-
<?php if ( $logs ) : ?>
|
16 |
-
<div id="log-viewer-select">
|
17 |
-
<div class="alignright">
|
18 |
-
<form action="
|
19 |
-
<?php
|
20 |
-
echo esc_url(
|
21 |
-
add_query_arg(
|
22 |
-
array(
|
23 |
-
'page' => 'cartflows_settings',
|
24 |
-
'cartflows-error-log' => 1,
|
25 |
-
'tab' => 'logs',
|
26 |
-
),
|
27 |
-
admin_url( '/admin.php' )
|
28 |
-
)
|
29 |
-
);
|
30 |
-
?>
|
31 |
-
" method="post">
|
32 |
-
<select name="log_file">
|
33 |
-
<?php foreach ( $logs as $log_key => $log_file ) : ?>
|
34 |
-
<?php
|
35 |
-
$timestamp = filemtime( CARTFLOWS_LOG_DIR . $log_file );
|
36 |
-
$date = sprintf( __( '%1$s at %2$s', 'cartflows' ), date_i18n( 'F j, Y', $timestamp ), date_i18n( 'g:i a', $timestamp ) ); // phpcs:ignore
|
37 |
-
?>
|
38 |
-
<option value="<?php echo esc_attr( $log_key ); ?>" <?php selected( sanitize_title( $viewed_log ), $log_key ); ?>><?php echo esc_html( $log_file ); ?> (<?php echo esc_html( $date ); ?>)</option>
|
39 |
-
<?php endforeach; ?>
|
40 |
-
</select>
|
41 |
-
<button type="submit" class="button" value="<?php esc_attr_e( 'View', 'cartflows' ); ?>"><?php esc_html_e( 'View', 'cartflows' ); ?></button>
|
42 |
-
</form>
|
43 |
-
</div>
|
44 |
-
<div class="clear"></div>
|
45 |
-
</div>
|
46 |
-
<div id="log-viewer">
|
47 |
-
<div class="wcf-log-container">
|
48 |
-
<pre><?php echo esc_html( file_get_contents( CARTFLOWS_LOG_DIR . $viewed_log ) )
|
49 |
-
</div>
|
50 |
-
<?php if ( ! empty( $viewed_log ) ) : ?>
|
51 |
-
<a onclick="return confirm('Are you sure to delete this log?');" style="float: right" href="
|
52 |
-
<?php
|
53 |
-
echo esc_url(
|
54 |
-
wp_nonce_url(
|
55 |
-
add_query_arg(
|
56 |
-
array(
|
57 |
-
'handle' => sanitize_title( $viewed_log ),
|
58 |
-
'tab' => 'logs',
|
59 |
-
)
|
60 |
-
),
|
61 |
-
'remove_log'
|
62 |
-
)
|
63 |
-
);
|
64 |
-
?>
|
65 |
-
"><?php esc_html_e( 'Delete log', 'cartflows' ); ?></a>
|
66 |
-
<?php endif; ?>
|
67 |
-
|
68 |
-
</div>
|
69 |
-
<?php else : ?>
|
70 |
-
<div class="updated woocommerce-message inline"><p><?php esc_html_e( 'There are currently no logs to view.', 'cartflows' ); ?></p></div>
|
71 |
-
<?php endif; ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin View: Page - Status Logs
|
4 |
+
*
|
5 |
+
* @package WooCommerce/Admin/Logs
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
?>
|
15 |
+
<?php if ( $logs ) : ?>
|
16 |
+
<div id="log-viewer-select">
|
17 |
+
<div class="alignright">
|
18 |
+
<form action="
|
19 |
+
<?php
|
20 |
+
echo esc_url(
|
21 |
+
add_query_arg(
|
22 |
+
array(
|
23 |
+
'page' => 'cartflows_settings',
|
24 |
+
'cartflows-error-log' => 1,
|
25 |
+
'tab' => 'logs',
|
26 |
+
),
|
27 |
+
admin_url( '/admin.php' )
|
28 |
+
)
|
29 |
+
);
|
30 |
+
?>
|
31 |
+
" method="post">
|
32 |
+
<select name="log_file">
|
33 |
+
<?php foreach ( $logs as $log_key => $log_file ) : ?>
|
34 |
+
<?php
|
35 |
+
$timestamp = filemtime( CARTFLOWS_LOG_DIR . $log_file );
|
36 |
+
$date = sprintf( __( '%1$s at %2$s', 'cartflows' ), date_i18n( 'F j, Y', $timestamp ), date_i18n( 'g:i a', $timestamp ) ); // phpcs:ignore
|
37 |
+
?>
|
38 |
+
<option value="<?php echo esc_attr( $log_key ); ?>" <?php selected( sanitize_title( $viewed_log ), $log_key ); ?>><?php echo esc_html( $log_file ); ?> (<?php echo esc_html( $date ); ?>)</option>
|
39 |
+
<?php endforeach; ?>
|
40 |
+
</select>
|
41 |
+
<button type="submit" class="button" value="<?php esc_attr_e( 'View', 'cartflows' ); ?>"><?php esc_html_e( 'View', 'cartflows' ); ?></button>
|
42 |
+
</form>
|
43 |
+
</div>
|
44 |
+
<div class="clear"></div>
|
45 |
+
</div>
|
46 |
+
<div id="log-viewer">
|
47 |
+
<div class="wcf-log-container">
|
48 |
+
<pre><?php echo esc_html( file_get_contents( CARTFLOWS_LOG_DIR . $viewed_log ) );//phpcs:ignore ?></pre>
|
49 |
+
</div>
|
50 |
+
<?php if ( ! empty( $viewed_log ) ) : ?>
|
51 |
+
<a onclick="return confirm('Are you sure to delete this log?');" style="float: right" href="
|
52 |
+
<?php
|
53 |
+
echo esc_url(
|
54 |
+
wp_nonce_url(
|
55 |
+
add_query_arg(
|
56 |
+
array(
|
57 |
+
'handle' => sanitize_title( $viewed_log ),
|
58 |
+
'tab' => 'logs',
|
59 |
+
)
|
60 |
+
),
|
61 |
+
'remove_log'
|
62 |
+
)
|
63 |
+
);
|
64 |
+
?>
|
65 |
+
"><?php esc_html_e( 'Delete log', 'cartflows' ); ?></a>
|
66 |
+
<?php endif; ?>
|
67 |
+
|
68 |
+
</div>
|
69 |
+
<?php else : ?>
|
70 |
+
<div class="updated woocommerce-message inline"><p><?php esc_html_e( 'There are currently no logs to view.', 'cartflows' ); ?></p></div>
|
71 |
+
<?php endif; ?>
|
includes/admin/cartflows-general.php
CHANGED
@@ -1,370 +1,370 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* General settings
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
$settings = Cartflows_Helper::get_common_settings();
|
9 |
-
|
10 |
-
$debug_data = Cartflows_Helper::get_debug_settings();
|
11 |
-
|
12 |
-
$permalink_settings = Cartflows_Helper::get_permalink_settings();
|
13 |
-
|
14 |
-
$facebook_settings = Cartflows_Helper::get_facebook_settings();
|
15 |
-
|
16 |
-
$debug_on = ( isset( $_GET['debug'] ) ) ? sanitize_text_field( $_GET['debug'] ) : 'false';
|
17 |
-
|
18 |
-
$error_log = filter_input( INPUT_GET, 'cartflows-error-log', FILTER_VALIDATE_BOOLEAN );
|
19 |
-
?>
|
20 |
-
|
21 |
-
|
22 |
-
<?php if ( $error_log ) : ?>
|
23 |
-
<div class="wrap wcf-addon-wrap wcf-clear wcf-container">
|
24 |
-
<?php Cartflows_Logger::status_logs_file(); ?>
|
25 |
-
</div>
|
26 |
-
<?php else : ?>
|
27 |
-
<div class="wrap wcf-addon-wrap wcf-clear wcf-container">
|
28 |
-
<input type="hidden" name="action" value="wcf_save_common_settings">
|
29 |
-
<h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
|
30 |
-
|
31 |
-
<div id="poststuff">
|
32 |
-
<div id="post-body" class="columns-2">
|
33 |
-
<div id="post-body-content">
|
34 |
-
<div class="postbox introduction">
|
35 |
-
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
36 |
-
<span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
|
37 |
-
</h2>
|
38 |
-
<div class="inside">
|
39 |
-
<div class="iframe-wrap">
|
40 |
-
<iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
41 |
-
</div>
|
42 |
-
<p>
|
43 |
-
<?php
|
44 |
-
esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
|
45 |
-
?>
|
46 |
-
</p>
|
47 |
-
</div>
|
48 |
-
</div>
|
49 |
-
|
50 |
-
<div class="general-settings-form postbox">
|
51 |
-
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
52 |
-
<span><?php _e( 'General Settings', 'cartflows' ); ?></span>
|
53 |
-
</h2>
|
54 |
-
<div class="inside">
|
55 |
-
<form method="post" class="wrap wcf-clear" action="" >
|
56 |
-
<div class="form-wrap">
|
57 |
-
<?php
|
58 |
-
|
59 |
-
do_action( 'cartflows_before_settings_fields', $settings );
|
60 |
-
|
61 |
-
echo Cartflows_Admin_Fields::checkobox_field(
|
62 |
-
array(
|
63 |
-
'id' => 'wcf_disallow_indexing',
|
64 |
-
'name' => '_cartflows_common[disallow_indexing]',
|
65 |
-
'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
|
66 |
-
'value' => $settings['disallow_indexing'],
|
67 |
-
)
|
68 |
-
);
|
69 |
-
|
70 |
-
if ( wcf()->is_woo_active ) {
|
71 |
-
echo Cartflows_Admin_Fields::flow_checkout_selection_field(
|
72 |
-
array(
|
73 |
-
'id' => 'wcf_global_checkout',
|
74 |
-
'name' => '_cartflows_common[global_checkout]',
|
75 |
-
'title' => __( 'Global Checkout', 'cartflows' ),
|
76 |
-
'value' => $settings['global_checkout'],
|
77 |
-
)
|
78 |
-
);
|
79 |
-
}
|
80 |
-
echo Cartflows_Admin_Fields::select_field(
|
81 |
-
array(
|
82 |
-
'id' => 'wcf_default_page_builder',
|
83 |
-
'name' => '_cartflows_common[default_page_builder]',
|
84 |
-
'title' => __( 'Show Templates designed with', 'cartflows' ),
|
85 |
-
'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
|
86 |
-
'value' => $settings['default_page_builder'],
|
87 |
-
'options' => array(
|
88 |
-
'elementor' => __( 'Elementor', 'cartflows' ),
|
89 |
-
'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
|
90 |
-
'divi' => __( 'Divi', 'cartflows' ),
|
91 |
-
'other' => __( 'Other', 'cartflows' ),
|
92 |
-
),
|
93 |
-
)
|
94 |
-
);
|
95 |
-
|
96 |
-
do_action( 'cartflows_after_settings_fields', $settings );
|
97 |
-
|
98 |
-
?>
|
99 |
-
</div>
|
100 |
-
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
|
101 |
-
<?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
|
102 |
-
</form>
|
103 |
-
</div>
|
104 |
-
</div>
|
105 |
-
|
106 |
-
<div class="general-settingss-form postbox">
|
107 |
-
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
108 |
-
<span><?php _e( 'Permalink Settings', 'cartflows' ); ?></span>
|
109 |
-
</h2>
|
110 |
-
<div class="inside">
|
111 |
-
<form method="post" class="wrap wcf-clear" action="" >
|
112 |
-
<div class="form-wrap wcf_permalink_settings">
|
113 |
-
<?php
|
114 |
-
|
115 |
-
echo Cartflows_Admin_Fields::radio_field(
|
116 |
-
array(
|
117 |
-
'id' => 'permalink_structure',
|
118 |
-
'name' => '_cartflows_permalink[permalink_structure]',
|
119 |
-
'value' => $permalink_settings['permalink_structure'],
|
120 |
-
'options' => array(
|
121 |
-
'' =>
|
122 |
-
array(
|
123 |
-
'label' => __( 'Default', 'cartflows' ),
|
124 |
-
'description' => 'Default WordPress Permalink',
|
125 |
-
),
|
126 |
-
|
127 |
-
'/' . CARTFLOWS_FLOW_POST_TYPE . '/%flowname%/' . CARTFLOWS_STEP_POST_TYPE =>
|
128 |
-
array(
|
129 |
-
'label' => __( 'Flow and Step Slug', 'cartflows' ),
|
130 |
-
'description' => '/<code>' . CARTFLOWS_FLOW_POST_TYPE . '</code>/%flowname%/<code>' . CARTFLOWS_STEP_POST_TYPE . '</code>/%stepname%/',
|
131 |
-
),
|
132 |
-
|
133 |
-
'/' . CARTFLOWS_FLOW_POST_TYPE . '/%flowname%' =>
|
134 |
-
array(
|
135 |
-
'label' => __( 'Flow Slug', 'cartflows' ),
|
136 |
-
'description' => '/<code>' . CARTFLOWS_FLOW_POST_TYPE . '</code>/%flowname%/%stepname%/',
|
137 |
-
),
|
138 |
-
|
139 |
-
'/%flowname%/' . CARTFLOWS_STEP_POST_TYPE =>
|
140 |
-
array(
|
141 |
-
'label' => __( 'Step Slug', 'cartflows' ),
|
142 |
-
'description' => '/%flowname%/<code>' . CARTFLOWS_STEP_POST_TYPE . '</code>/%stepname%/',
|
143 |
-
),
|
144 |
-
),
|
145 |
-
)
|
146 |
-
);
|
147 |
-
?>
|
148 |
-
<hr/>
|
149 |
-
<?php
|
150 |
-
|
151 |
-
echo Cartflows_Admin_Fields::title_field(
|
152 |
-
array(
|
153 |
-
'title' => __( 'Post Type Permalink Base', 'cartflows' ),
|
154 |
-
)
|
155 |
-
);
|
156 |
-
|
157 |
-
echo Cartflows_Admin_Fields::text_field(
|
158 |
-
array(
|
159 |
-
'id' => 'wcf_permalink_step_base',
|
160 |
-
'name' => '_cartflows_permalink[permalink]',
|
161 |
-
'title' => __( 'Step Base', 'cartflows' ),
|
162 |
-
'value' => $permalink_settings['permalink'],
|
163 |
-
'placeholder' => CARTFLOWS_STEP_POST_TYPE,
|
164 |
-
)
|
165 |
-
);
|
166 |
-
|
167 |
-
echo Cartflows_Admin_Fields::text_field(
|
168 |
-
array(
|
169 |
-
'id' => 'wcf_permalink_flow_base',
|
170 |
-
'name' => '_cartflows_permalink[permalink_flow_base]',
|
171 |
-
'title' => __( 'Flow Base', 'cartflows' ),
|
172 |
-
'value' => $permalink_settings['permalink_flow_base'],
|
173 |
-
'placeholder' => CARTFLOWS_FLOW_POST_TYPE,
|
174 |
-
)
|
175 |
-
);
|
176 |
-
|
177 |
-
?>
|
178 |
-
|
179 |
-
|
180 |
-
</div>
|
181 |
-
<p>
|
182 |
-
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
|
183 |
-
<?php submit_button( __( 'Set Default', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'reset', false ); ?>
|
184 |
-
<?php wp_nonce_field( 'cartflows-permalink-settings', 'cartflows-permalink-settings-nonce' ); ?>
|
185 |
-
</p>
|
186 |
-
|
187 |
-
|
188 |
-
</form>
|
189 |
-
</div>
|
190 |
-
</div>
|
191 |
-
|
192 |
-
|
193 |
-
<div class="general-settingss-form postbox">
|
194 |
-
<h2 class="wcf-facebook-hndle wcf-normal-cusror ui-sortable-handle hndle">
|
195 |
-
|
196 |
-
<span><?php _e( 'Facebook Pixel Settings', 'cartflows' ); ?></span>
|
197 |
-
</h2>
|
198 |
-
|
199 |
-
<form method="post" class="wrap wcf-clear" action="">
|
200 |
-
<div class="form-wrap">
|
201 |
-
<input type="hidden" name="action" value="wcf_save_facebook_pixel_settings">
|
202 |
-
<div id="post-body">
|
203 |
-
|
204 |
-
<div class="inside">
|
205 |
-
<div class="form-wrap">
|
206 |
-
<?php
|
207 |
-
echo Cartflows_Admin_Fields::checkobox_field(
|
208 |
-
array(
|
209 |
-
'id' => 'wcf_facebook_pixel_tracking',
|
210 |
-
'name' => '_cartflows_facebook[facebook_pixel_tracking]',
|
211 |
-
'title' => __( 'Enable Facebook Pixel Tracking', 'cartflows' ),
|
212 |
-
'value' => $facebook_settings['facebook_pixel_tracking'],
|
213 |
-
)
|
214 |
-
);
|
215 |
-
|
216 |
-
echo "<div class='wcf-fb-pixel-wrapper'>";
|
217 |
-
|
218 |
-
echo Cartflows_Admin_Fields::text_field(
|
219 |
-
array(
|
220 |
-
'id' => 'wcf_facebook_pixel_id',
|
221 |
-
'name' => '_cartflows_facebook[facebook_pixel_id]',
|
222 |
-
'title' => __( 'Enter Facebook pixel ID', 'cartflows' ),
|
223 |
-
'value' => $facebook_settings['facebook_pixel_id'],
|
224 |
-
)
|
225 |
-
);
|
226 |
-
|
227 |
-
|
228 |
-
echo Cartflows_Admin_Fields::title_field(
|
229 |
-
array(
|
230 |
-
'title' => __( 'Enable Events:', 'cartflows' ),
|
231 |
-
)
|
232 |
-
);
|
233 |
-
|
234 |
-
|
235 |
-
echo Cartflows_Admin_Fields::checkobox_field(
|
236 |
-
array(
|
237 |
-
'id' => 'wcf_facebook_pixel_initiate_checkout',
|
238 |
-
'name' => '_cartflows_facebook[facebook_pixel_initiate_checkout]',
|
239 |
-
'title' => __( 'Initiate Checkout', 'cartflows' ),
|
240 |
-
'value' => $facebook_settings['facebook_pixel_initiate_checkout'],
|
241 |
-
)
|
242 |
-
);
|
243 |
-
|
244 |
-
echo Cartflows_Admin_Fields::checkobox_field(
|
245 |
-
array(
|
246 |
-
'id' => 'wcf_facebook_pixel_add_payment_info',
|
247 |
-
'name' => '_cartflows_facebook[facebook_pixel_add_payment_info]',
|
248 |
-
'title' => __( 'Add Payment Info', 'cartflows' ),
|
249 |
-
'value' => $facebook_settings['facebook_pixel_add_payment_info'],
|
250 |
-
)
|
251 |
-
);
|
252 |
-
|
253 |
-
echo Cartflows_Admin_Fields::checkobox_field(
|
254 |
-
array(
|
255 |
-
'id' => 'wcf_facebook_pixel_purchase_complete',
|
256 |
-
'name' => '_cartflows_facebook[facebook_pixel_purchase_complete]',
|
257 |
-
'title' => __( 'Purchase Complete', 'cartflows' ),
|
258 |
-
'value' => $facebook_settings['facebook_pixel_purchase_complete'],
|
259 |
-
)
|
260 |
-
);
|
261 |
-
|
262 |
-
echo '</div>';
|
263 |
-
|
264 |
-
?>
|
265 |
-
</div>
|
266 |
-
|
267 |
-
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-facebook-setting-save-btn button-primary button', 'submit', false ); ?>
|
268 |
-
<?php wp_nonce_field( 'cartflows-facebook-settings', 'cartflows-facebook-settings-nonce' ); ?>
|
269 |
-
</div>
|
270 |
-
|
271 |
-
</div>
|
272 |
-
</div>
|
273 |
-
</form>
|
274 |
-
|
275 |
-
|
276 |
-
</div>
|
277 |
-
</div>
|
278 |
-
<div class="postbox-container" id="postbox-container-1">
|
279 |
-
<div id="side-sortables">
|
280 |
-
|
281 |
-
<div class="postbox">
|
282 |
-
<h2 class="hndle">
|
283 |
-
<span class="dashicons dashicons-book"></span>
|
284 |
-
<span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
|
285 |
-
</h2>
|
286 |
-
<div class="inside">
|
287 |
-
<p>
|
288 |
-
<?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
|
289 |
-
</p>
|
290 |
-
<p>
|
291 |
-
<a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
|
292 |
-
</p>
|
293 |
-
</div>
|
294 |
-
</div>
|
295 |
-
|
296 |
-
<div class="postbox">
|
297 |
-
<h2 class="hndle">
|
298 |
-
<span class="dashicons dashicons-groups"></span>
|
299 |
-
<span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
|
300 |
-
</h2>
|
301 |
-
<div class="inside">
|
302 |
-
<p>
|
303 |
-
<?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
|
304 |
-
</p>
|
305 |
-
<p>
|
306 |
-
<a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
|
307 |
-
</p>
|
308 |
-
</div>
|
309 |
-
</div>
|
310 |
-
|
311 |
-
<div class="postbox">
|
312 |
-
<h2 class="hndle">
|
313 |
-
<span class="dashicons dashicons-sos"></span>
|
314 |
-
<span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
|
315 |
-
</h2>
|
316 |
-
<div class="inside">
|
317 |
-
<p>
|
318 |
-
<?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
|
319 |
-
</p>
|
320 |
-
<p>
|
321 |
-
<a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
|
322 |
-
</p>
|
323 |
-
</div>
|
324 |
-
</div>
|
325 |
-
<?php
|
326 |
-
if ( 'true' == $debug_on ) {
|
327 |
-
?>
|
328 |
-
<div class="postbox">
|
329 |
-
<h2 class="hndle">
|
330 |
-
<span class="dashicons dashicons-editor-code"></span>
|
331 |
-
<span><?php esc_html_e( 'Load Minified CSS', 'cartflows' ); ?></span>
|
332 |
-
</h2>
|
333 |
-
<div class="inside">
|
334 |
-
<form method="post" class="wrap wcf-clear" action="">
|
335 |
-
<p>
|
336 |
-
<?php esc_html_e( 'Load the Minified CSS from here. Just Enable it by checking the below given checkbox.', 'cartflows' ); ?>
|
337 |
-
</p>
|
338 |
-
<?php
|
339 |
-
echo Cartflows_Admin_Fields::checkobox_field(
|
340 |
-
array(
|
341 |
-
'id' => 'allow_minified_files',
|
342 |
-
'name' => '_cartflows_debug_data[allow_minified_files]',
|
343 |
-
'title' => __( 'Load minified CSS & JS Files', 'cartflows' ),
|
344 |
-
'value' => $debug_data['allow_minified_files'],
|
345 |
-
)
|
346 |
-
);
|
347 |
-
?>
|
348 |
-
<?php submit_button( __( 'Save', 'cartflows' ), 'button-primary button', 'submit', false ); ?>
|
349 |
-
<?php wp_nonce_field( 'cartflows-debug-settings', 'cartflows-debug-settings-nonce' ); ?>
|
350 |
-
</form>
|
351 |
-
</div>
|
352 |
-
</div>
|
353 |
-
<?php
|
354 |
-
}
|
355 |
-
?>
|
356 |
-
</div>
|
357 |
-
</div>
|
358 |
-
</div>
|
359 |
-
<!-- /post-body -->
|
360 |
-
<br class="clear">
|
361 |
-
</div>
|
362 |
-
</div>
|
363 |
-
<?php endif; ?>
|
364 |
-
|
365 |
-
<?php
|
366 |
-
/**
|
367 |
-
* Loads Zapier settings admin view.
|
368 |
-
*/
|
369 |
-
do_action( 'cartflows_after_general_settings' );
|
370 |
-
?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* General settings
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
$settings = Cartflows_Helper::get_common_settings();
|
9 |
+
|
10 |
+
$debug_data = Cartflows_Helper::get_debug_settings();
|
11 |
+
|
12 |
+
$permalink_settings = Cartflows_Helper::get_permalink_settings();
|
13 |
+
|
14 |
+
$facebook_settings = Cartflows_Helper::get_facebook_settings();
|
15 |
+
|
16 |
+
$debug_on = ( isset( $_GET['debug'] ) ) ? sanitize_text_field( wp_unslash( $_GET['debug'] ) ) : 'false';
|
17 |
+
|
18 |
+
$error_log = filter_input( INPUT_GET, 'cartflows-error-log', FILTER_VALIDATE_BOOLEAN );
|
19 |
+
?>
|
20 |
+
|
21 |
+
|
22 |
+
<?php if ( $error_log ) : ?>
|
23 |
+
<div class="wrap wcf-addon-wrap wcf-clear wcf-container">
|
24 |
+
<?php Cartflows_Logger::status_logs_file(); ?>
|
25 |
+
</div>
|
26 |
+
<?php else : ?>
|
27 |
+
<div class="wrap wcf-addon-wrap wcf-clear wcf-container">
|
28 |
+
<input type="hidden" name="action" value="wcf_save_common_settings">
|
29 |
+
<h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
|
30 |
+
|
31 |
+
<div id="poststuff">
|
32 |
+
<div id="post-body" class="columns-2">
|
33 |
+
<div id="post-body-content">
|
34 |
+
<div class="postbox introduction">
|
35 |
+
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
36 |
+
<span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
|
37 |
+
</h2>
|
38 |
+
<div class="inside">
|
39 |
+
<div class="iframe-wrap">
|
40 |
+
<iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
41 |
+
</div>
|
42 |
+
<p>
|
43 |
+
<?php
|
44 |
+
esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
|
45 |
+
?>
|
46 |
+
</p>
|
47 |
+
</div>
|
48 |
+
</div>
|
49 |
+
|
50 |
+
<div class="general-settings-form postbox">
|
51 |
+
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
52 |
+
<span><?php _e( 'General Settings', 'cartflows' ); ?></span>
|
53 |
+
</h2>
|
54 |
+
<div class="inside">
|
55 |
+
<form method="post" class="wrap wcf-clear" action="" >
|
56 |
+
<div class="form-wrap">
|
57 |
+
<?php
|
58 |
+
|
59 |
+
do_action( 'cartflows_before_settings_fields', $settings );
|
60 |
+
|
61 |
+
echo Cartflows_Admin_Fields::checkobox_field(
|
62 |
+
array(
|
63 |
+
'id' => 'wcf_disallow_indexing',
|
64 |
+
'name' => '_cartflows_common[disallow_indexing]',
|
65 |
+
'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
|
66 |
+
'value' => $settings['disallow_indexing'],
|
67 |
+
)
|
68 |
+
);
|
69 |
+
|
70 |
+
if ( wcf()->is_woo_active ) {
|
71 |
+
echo Cartflows_Admin_Fields::flow_checkout_selection_field(
|
72 |
+
array(
|
73 |
+
'id' => 'wcf_global_checkout',
|
74 |
+
'name' => '_cartflows_common[global_checkout]',
|
75 |
+
'title' => __( 'Global Checkout', 'cartflows' ),
|
76 |
+
'value' => $settings['global_checkout'],
|
77 |
+
)
|
78 |
+
);
|
79 |
+
}
|
80 |
+
echo Cartflows_Admin_Fields::select_field(
|
81 |
+
array(
|
82 |
+
'id' => 'wcf_default_page_builder',
|
83 |
+
'name' => '_cartflows_common[default_page_builder]',
|
84 |
+
'title' => __( 'Show Templates designed with', 'cartflows' ),
|
85 |
+
'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
|
86 |
+
'value' => $settings['default_page_builder'],
|
87 |
+
'options' => array(
|
88 |
+
'elementor' => __( 'Elementor', 'cartflows' ),
|
89 |
+
'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
|
90 |
+
'divi' => __( 'Divi', 'cartflows' ),
|
91 |
+
'other' => __( 'Other', 'cartflows' ),
|
92 |
+
),
|
93 |
+
)
|
94 |
+
);
|
95 |
+
|
96 |
+
do_action( 'cartflows_after_settings_fields', $settings );
|
97 |
+
|
98 |
+
?>
|
99 |
+
</div>
|
100 |
+
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
|
101 |
+
<?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
|
102 |
+
</form>
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
+
|
106 |
+
<div class="general-settingss-form postbox">
|
107 |
+
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
108 |
+
<span><?php _e( 'Permalink Settings', 'cartflows' ); ?></span>
|
109 |
+
</h2>
|
110 |
+
<div class="inside">
|
111 |
+
<form method="post" class="wrap wcf-clear" action="" >
|
112 |
+
<div class="form-wrap wcf_permalink_settings">
|
113 |
+
<?php
|
114 |
+
|
115 |
+
echo Cartflows_Admin_Fields::radio_field(
|
116 |
+
array(
|
117 |
+
'id' => 'permalink_structure',
|
118 |
+
'name' => '_cartflows_permalink[permalink_structure]',
|
119 |
+
'value' => $permalink_settings['permalink_structure'],
|
120 |
+
'options' => array(
|
121 |
+
'' =>
|
122 |
+
array(
|
123 |
+
'label' => __( 'Default', 'cartflows' ),
|
124 |
+
'description' => 'Default WordPress Permalink',
|
125 |
+
),
|
126 |
+
|
127 |
+
'/' . CARTFLOWS_FLOW_POST_TYPE . '/%flowname%/' . CARTFLOWS_STEP_POST_TYPE =>
|
128 |
+
array(
|
129 |
+
'label' => __( 'Flow and Step Slug', 'cartflows' ),
|
130 |
+
'description' => '/<code>' . CARTFLOWS_FLOW_POST_TYPE . '</code>/%flowname%/<code>' . CARTFLOWS_STEP_POST_TYPE . '</code>/%stepname%/',
|
131 |
+
),
|
132 |
+
|
133 |
+
'/' . CARTFLOWS_FLOW_POST_TYPE . '/%flowname%' =>
|
134 |
+
array(
|
135 |
+
'label' => __( 'Flow Slug', 'cartflows' ),
|
136 |
+
'description' => '/<code>' . CARTFLOWS_FLOW_POST_TYPE . '</code>/%flowname%/%stepname%/',
|
137 |
+
),
|
138 |
+
|
139 |
+
'/%flowname%/' . CARTFLOWS_STEP_POST_TYPE =>
|
140 |
+
array(
|
141 |
+
'label' => __( 'Step Slug', 'cartflows' ),
|
142 |
+
'description' => '/%flowname%/<code>' . CARTFLOWS_STEP_POST_TYPE . '</code>/%stepname%/',
|
143 |
+
),
|
144 |
+
),
|
145 |
+
)
|
146 |
+
);
|
147 |
+
?>
|
148 |
+
<hr/>
|
149 |
+
<?php
|
150 |
+
|
151 |
+
echo Cartflows_Admin_Fields::title_field(
|
152 |
+
array(
|
153 |
+
'title' => __( 'Post Type Permalink Base', 'cartflows' ),
|
154 |
+
)
|
155 |
+
);
|
156 |
+
|
157 |
+
echo Cartflows_Admin_Fields::text_field(
|
158 |
+
array(
|
159 |
+
'id' => 'wcf_permalink_step_base',
|
160 |
+
'name' => '_cartflows_permalink[permalink]',
|
161 |
+
'title' => __( 'Step Base', 'cartflows' ),
|
162 |
+
'value' => $permalink_settings['permalink'],
|
163 |
+
'placeholder' => CARTFLOWS_STEP_POST_TYPE,
|
164 |
+
)
|
165 |
+
);
|
166 |
+
|
167 |
+
echo Cartflows_Admin_Fields::text_field(
|
168 |
+
array(
|
169 |
+
'id' => 'wcf_permalink_flow_base',
|
170 |
+
'name' => '_cartflows_permalink[permalink_flow_base]',
|
171 |
+
'title' => __( 'Flow Base', 'cartflows' ),
|
172 |
+
'value' => $permalink_settings['permalink_flow_base'],
|
173 |
+
'placeholder' => CARTFLOWS_FLOW_POST_TYPE,
|
174 |
+
)
|
175 |
+
);
|
176 |
+
|
177 |
+
?>
|
178 |
+
|
179 |
+
|
180 |
+
</div>
|
181 |
+
<p>
|
182 |
+
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
|
183 |
+
<?php submit_button( __( 'Set Default', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'reset', false ); ?>
|
184 |
+
<?php wp_nonce_field( 'cartflows-permalink-settings', 'cartflows-permalink-settings-nonce' ); ?>
|
185 |
+
</p>
|
186 |
+
|
187 |
+
|
188 |
+
</form>
|
189 |
+
</div>
|
190 |
+
</div>
|
191 |
+
|
192 |
+
|
193 |
+
<div class="general-settingss-form postbox">
|
194 |
+
<h2 class="wcf-facebook-hndle wcf-normal-cusror ui-sortable-handle hndle">
|
195 |
+
|
196 |
+
<span><?php _e( 'Facebook Pixel Settings', 'cartflows' ); ?></span>
|
197 |
+
</h2>
|
198 |
+
|
199 |
+
<form method="post" class="wrap wcf-clear" action="">
|
200 |
+
<div class="form-wrap">
|
201 |
+
<input type="hidden" name="action" value="wcf_save_facebook_pixel_settings">
|
202 |
+
<div id="post-body">
|
203 |
+
|
204 |
+
<div class="inside">
|
205 |
+
<div class="form-wrap">
|
206 |
+
<?php
|
207 |
+
echo Cartflows_Admin_Fields::checkobox_field(
|
208 |
+
array(
|
209 |
+
'id' => 'wcf_facebook_pixel_tracking',
|
210 |
+
'name' => '_cartflows_facebook[facebook_pixel_tracking]',
|
211 |
+
'title' => __( 'Enable Facebook Pixel Tracking', 'cartflows' ),
|
212 |
+
'value' => $facebook_settings['facebook_pixel_tracking'],
|
213 |
+
)
|
214 |
+
);
|
215 |
+
|
216 |
+
echo "<div class='wcf-fb-pixel-wrapper'>";
|
217 |
+
|
218 |
+
echo Cartflows_Admin_Fields::text_field(
|
219 |
+
array(
|
220 |
+
'id' => 'wcf_facebook_pixel_id',
|
221 |
+
'name' => '_cartflows_facebook[facebook_pixel_id]',
|
222 |
+
'title' => __( 'Enter Facebook pixel ID', 'cartflows' ),
|
223 |
+
'value' => $facebook_settings['facebook_pixel_id'],
|
224 |
+
)
|
225 |
+
);
|
226 |
+
|
227 |
+
|
228 |
+
echo Cartflows_Admin_Fields::title_field(
|
229 |
+
array(
|
230 |
+
'title' => __( 'Enable Events:', 'cartflows' ),
|
231 |
+
)
|
232 |
+
);
|
233 |
+
|
234 |
+
|
235 |
+
echo Cartflows_Admin_Fields::checkobox_field(
|
236 |
+
array(
|
237 |
+
'id' => 'wcf_facebook_pixel_initiate_checkout',
|
238 |
+
'name' => '_cartflows_facebook[facebook_pixel_initiate_checkout]',
|
239 |
+
'title' => __( 'Initiate Checkout', 'cartflows' ),
|
240 |
+
'value' => $facebook_settings['facebook_pixel_initiate_checkout'],
|
241 |
+
)
|
242 |
+
);
|
243 |
+
|
244 |
+
echo Cartflows_Admin_Fields::checkobox_field(
|
245 |
+
array(
|
246 |
+
'id' => 'wcf_facebook_pixel_add_payment_info',
|
247 |
+
'name' => '_cartflows_facebook[facebook_pixel_add_payment_info]',
|
248 |
+
'title' => __( 'Add Payment Info', 'cartflows' ),
|
249 |
+
'value' => $facebook_settings['facebook_pixel_add_payment_info'],
|
250 |
+
)
|
251 |
+
);
|
252 |
+
|
253 |
+
echo Cartflows_Admin_Fields::checkobox_field(
|
254 |
+
array(
|
255 |
+
'id' => 'wcf_facebook_pixel_purchase_complete',
|
256 |
+
'name' => '_cartflows_facebook[facebook_pixel_purchase_complete]',
|
257 |
+
'title' => __( 'Purchase Complete', 'cartflows' ),
|
258 |
+
'value' => $facebook_settings['facebook_pixel_purchase_complete'],
|
259 |
+
)
|
260 |
+
);
|
261 |
+
|
262 |
+
echo '</div>';
|
263 |
+
|
264 |
+
?>
|
265 |
+
</div>
|
266 |
+
|
267 |
+
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-facebook-setting-save-btn button-primary button', 'submit', false ); ?>
|
268 |
+
<?php wp_nonce_field( 'cartflows-facebook-settings', 'cartflows-facebook-settings-nonce' ); ?>
|
269 |
+
</div>
|
270 |
+
|
271 |
+
</div>
|
272 |
+
</div>
|
273 |
+
</form>
|
274 |
+
|
275 |
+
|
276 |
+
</div>
|
277 |
+
</div>
|
278 |
+
<div class="postbox-container" id="postbox-container-1">
|
279 |
+
<div id="side-sortables">
|
280 |
+
|
281 |
+
<div class="postbox">
|
282 |
+
<h2 class="hndle">
|
283 |
+
<span class="dashicons dashicons-book"></span>
|
284 |
+
<span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
|
285 |
+
</h2>
|
286 |
+
<div class="inside">
|
287 |
+
<p>
|
288 |
+
<?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
|
289 |
+
</p>
|
290 |
+
<p>
|
291 |
+
<a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
|
292 |
+
</p>
|
293 |
+
</div>
|
294 |
+
</div>
|
295 |
+
|
296 |
+
<div class="postbox">
|
297 |
+
<h2 class="hndle">
|
298 |
+
<span class="dashicons dashicons-groups"></span>
|
299 |
+
<span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
|
300 |
+
</h2>
|
301 |
+
<div class="inside">
|
302 |
+
<p>
|
303 |
+
<?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
|
304 |
+
</p>
|
305 |
+
<p>
|
306 |
+
<a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
|
307 |
+
</p>
|
308 |
+
</div>
|
309 |
+
</div>
|
310 |
+
|
311 |
+
<div class="postbox">
|
312 |
+
<h2 class="hndle">
|
313 |
+
<span class="dashicons dashicons-sos"></span>
|
314 |
+
<span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
|
315 |
+
</h2>
|
316 |
+
<div class="inside">
|
317 |
+
<p>
|
318 |
+
<?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
|
319 |
+
</p>
|
320 |
+
<p>
|
321 |
+
<a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
|
322 |
+
</p>
|
323 |
+
</div>
|
324 |
+
</div>
|
325 |
+
<?php
|
326 |
+
if ( 'true' == $debug_on ) {
|
327 |
+
?>
|
328 |
+
<div class="postbox">
|
329 |
+
<h2 class="hndle">
|
330 |
+
<span class="dashicons dashicons-editor-code"></span>
|
331 |
+
<span><?php esc_html_e( 'Load Minified CSS', 'cartflows' ); ?></span>
|
332 |
+
</h2>
|
333 |
+
<div class="inside">
|
334 |
+
<form method="post" class="wrap wcf-clear" action="">
|
335 |
+
<p>
|
336 |
+
<?php esc_html_e( 'Load the Minified CSS from here. Just Enable it by checking the below given checkbox.', 'cartflows' ); ?>
|
337 |
+
</p>
|
338 |
+
<?php
|
339 |
+
echo Cartflows_Admin_Fields::checkobox_field(
|
340 |
+
array(
|
341 |
+
'id' => 'allow_minified_files',
|
342 |
+
'name' => '_cartflows_debug_data[allow_minified_files]',
|
343 |
+
'title' => __( 'Load minified CSS & JS Files', 'cartflows' ),
|
344 |
+
'value' => $debug_data['allow_minified_files'],
|
345 |
+
)
|
346 |
+
);
|
347 |
+
?>
|
348 |
+
<?php submit_button( __( 'Save', 'cartflows' ), 'button-primary button', 'submit', false ); ?>
|
349 |
+
<?php wp_nonce_field( 'cartflows-debug-settings', 'cartflows-debug-settings-nonce' ); ?>
|
350 |
+
</form>
|
351 |
+
</div>
|
352 |
+
</div>
|
353 |
+
<?php
|
354 |
+
}
|
355 |
+
?>
|
356 |
+
</div>
|
357 |
+
</div>
|
358 |
+
</div>
|
359 |
+
<!-- /post-body -->
|
360 |
+
<br class="clear">
|
361 |
+
</div>
|
362 |
+
</div>
|
363 |
+
<?php endif; ?>
|
364 |
+
|
365 |
+
<?php
|
366 |
+
/**
|
367 |
+
* Loads Zapier settings admin view.
|
368 |
+
*/
|
369 |
+
do_action( 'cartflows_after_general_settings' );
|
370 |
+
?>
|
languages/cartflows.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the CartFlows package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: CartFlows 1.3.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
|
7 |
-
"POT-Creation-Date: 2019-11
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -205,7 +205,7 @@ msgstr ""
|
|
205 |
|
206 |
#: classes/class-cartflows-importer.php:672
|
207 |
#: classes/class-cartflows-importer.php:779
|
208 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
209 |
msgid "Get Pro"
|
210 |
msgstr ""
|
211 |
|
@@ -291,15 +291,15 @@ msgid ""
|
|
291 |
"to import the step."
|
292 |
msgstr ""
|
293 |
|
294 |
-
#: classes/class-cartflows-importer.php:
|
295 |
msgid "Action failed. Invalid Security Nonce."
|
296 |
msgstr ""
|
297 |
|
298 |
-
#: classes/class-cartflows-importer.php:
|
299 |
msgid "User have not plugin install permissions."
|
300 |
msgstr ""
|
301 |
|
302 |
-
#: classes/class-cartflows-importer.php:
|
303 |
msgid "Plugin Successfully Activated"
|
304 |
msgstr ""
|
305 |
|
@@ -318,25 +318,25 @@ msgstr ""
|
|
318 |
msgid "Select CartFlows Template for this Course"
|
319 |
msgstr ""
|
320 |
|
321 |
-
#: classes/class-cartflows-loader.php:
|
322 |
#. translators: %s: html tags
|
323 |
msgid ""
|
324 |
"You are using an older version of %1$sCartFlows Pro%2$s. Please update "
|
325 |
"%1$sCartFlows Pro%2$s plugin to version %1$s%3$s%2$s or higher."
|
326 |
msgstr ""
|
327 |
|
328 |
-
#: classes/class-cartflows-loader.php:
|
329 |
#. translators: %s: html tags
|
330 |
msgid ""
|
331 |
"This %1$sCartFlows%2$s page requires %1$sWooCommerce%2$s plugin installed & "
|
332 |
"activated."
|
333 |
msgstr ""
|
334 |
|
335 |
-
#: classes/class-cartflows-loader.php:
|
336 |
msgid "Activate WooCommerce"
|
337 |
msgstr ""
|
338 |
|
339 |
-
#: classes/class-cartflows-loader.php:
|
340 |
msgid "Install WooCommerce"
|
341 |
msgstr ""
|
342 |
|
@@ -413,7 +413,7 @@ msgstr ""
|
|
413 |
#: classes/class-cartflows-meta-fields.php:492
|
414 |
#: classes/class-cartflows-meta-fields.php:505
|
415 |
#: includes/admin/cartflows-general.php:123
|
416 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
417 |
msgid "Default"
|
418 |
msgstr ""
|
419 |
|
@@ -460,7 +460,7 @@ msgid "Back to edit Flow"
|
|
460 |
msgstr ""
|
461 |
|
462 |
#: classes/class-cartflows-meta.php:63
|
463 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
464 |
#: modules/landing/classes/class-cartflows-landing-meta.php:136
|
465 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:148
|
466 |
msgid "Custom Script"
|
@@ -891,286 +891,315 @@ msgstr ""
|
|
891 |
msgid "Import"
|
892 |
msgstr ""
|
893 |
|
894 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
895 |
#: modules/thankyou/classes/class-cartflows-thankyou-markup.php:65
|
896 |
msgid ""
|
897 |
"WooCommerce functions do not exist. If you are in an IFrame, please reload "
|
898 |
"it."
|
899 |
msgstr ""
|
900 |
|
901 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
902 |
#: modules/thankyou/classes/class-cartflows-thankyou-markup.php:66
|
903 |
msgid "Click Here to Reload"
|
904 |
msgstr ""
|
905 |
|
906 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
907 |
msgid "Checkout ID not found"
|
908 |
msgstr ""
|
909 |
|
910 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
911 |
#: modules/checkout/templates/embed/checkout-template-simple.php:25
|
912 |
#: modules/checkout/templates/wcf-template.php:36
|
913 |
msgid "Your cart is currently empty."
|
914 |
msgstr ""
|
915 |
|
916 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
917 |
msgid ""
|
918 |
"No product is selected. Please select products from the checkout meta "
|
919 |
"settings to continue."
|
920 |
msgstr ""
|
921 |
|
922 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
923 |
msgid "Variations Not set"
|
924 |
msgstr ""
|
925 |
|
926 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
927 |
msgid "This product can't be purchased"
|
928 |
msgstr ""
|
929 |
|
930 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
931 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
932 |
msgid "Coupon Code"
|
933 |
msgstr ""
|
934 |
|
935 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
936 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
937 |
msgid "Apply"
|
938 |
msgstr ""
|
939 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
940 |
#: modules/checkout/classes/class-cartflows-checkout-meta.php:66
|
941 |
msgid "Checkout Layout"
|
942 |
msgstr ""
|
943 |
|
944 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
945 |
#: modules/landing/classes/class-cartflows-landing-meta.php:130
|
946 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:130
|
947 |
msgid "Shortcodes"
|
948 |
msgstr ""
|
949 |
|
950 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
951 |
msgid "Select Product"
|
952 |
msgstr ""
|
953 |
|
954 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
955 |
msgid "Order Bump"
|
956 |
msgstr ""
|
957 |
|
958 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
959 |
msgid "Checkout Offer"
|
960 |
msgstr ""
|
961 |
|
962 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
963 |
msgid "Checkout Design"
|
964 |
msgstr ""
|
965 |
|
966 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
967 |
msgid "Checkout Fields"
|
968 |
msgstr ""
|
969 |
|
970 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
|
|
|
|
|
|
|
|
971 |
msgid "Logo (Optional)"
|
972 |
msgstr ""
|
973 |
|
974 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
975 |
msgid "Add this shortcode to your checkout page"
|
976 |
msgstr ""
|
977 |
|
978 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
979 |
#. translators: %s: link
|
980 |
msgid ""
|
981 |
"Upgrade to %1$sCartFlows Pro%2$s for Pre-applied Coupon, Product Variations "
|
982 |
"& Quantity Options."
|
983 |
msgstr ""
|
984 |
|
985 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
986 |
#. translators: %s: link
|
987 |
msgid "Upgrade to %1$sCartFlows Pro%2$s for Checkout Offer feature"
|
988 |
msgstr ""
|
989 |
|
990 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
991 |
#. translators: %s: link
|
992 |
msgid "Update to %1$sCartFlows Pro%2$s to %3$s or above for Checkout Offer feature"
|
993 |
msgstr ""
|
994 |
|
995 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
996 |
#. translators: %s: link
|
997 |
msgid "Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature."
|
998 |
msgstr ""
|
999 |
|
1000 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1001 |
#. translators: %s: link
|
1002 |
msgid "Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature."
|
1003 |
msgstr ""
|
1004 |
|
1005 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1006 |
msgid "One Column (Available in CartFlows Pro) "
|
1007 |
msgstr ""
|
1008 |
|
1009 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1010 |
msgid "Two Step (Available in CartFlows Pro) "
|
1011 |
msgstr ""
|
1012 |
|
1013 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1014 |
msgid "Checkout Skin"
|
1015 |
msgstr ""
|
1016 |
|
1017 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1018 |
msgid "One Column"
|
1019 |
msgstr ""
|
1020 |
|
1021 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1022 |
msgid "Two Column"
|
1023 |
msgstr ""
|
1024 |
|
1025 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1026 |
msgid "Two Step"
|
1027 |
msgstr ""
|
1028 |
|
1029 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1030 |
msgid "Primary Color"
|
1031 |
msgstr ""
|
1032 |
|
1033 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1034 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1035 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1036 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1037 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:203
|
1038 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:226
|
1039 |
msgid "Font Family"
|
1040 |
msgstr ""
|
1041 |
|
1042 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1043 |
msgid "Advance Options"
|
1044 |
msgstr ""
|
1045 |
|
1046 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1047 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:211
|
1048 |
msgid "Heading"
|
1049 |
msgstr ""
|
1050 |
|
1051 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1052 |
msgid "Heading Color"
|
1053 |
msgstr ""
|
1054 |
|
1055 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1056 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1057 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1058 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:235
|
1059 |
msgid "Font Weight"
|
1060 |
msgstr ""
|
1061 |
|
1062 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1063 |
msgid "Input Fields"
|
1064 |
msgstr ""
|
1065 |
|
1066 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1067 |
msgid "Floating Labels (Available in CartFlows Pro)"
|
1068 |
msgstr ""
|
1069 |
|
1070 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1071 |
msgid "Style"
|
1072 |
msgstr ""
|
1073 |
|
1074 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1075 |
msgid "Floating Labels"
|
1076 |
msgstr ""
|
1077 |
|
1078 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1079 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1080 |
msgid "Size"
|
1081 |
msgstr ""
|
1082 |
|
1083 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1084 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1085 |
msgid "Extra Small"
|
1086 |
msgstr ""
|
1087 |
|
1088 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1089 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1090 |
msgid "Small"
|
1091 |
msgstr ""
|
1092 |
|
1093 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1094 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1095 |
msgid "Medium"
|
1096 |
msgstr ""
|
1097 |
|
1098 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1099 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1100 |
msgid "Large"
|
1101 |
msgstr ""
|
1102 |
|
1103 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1104 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1105 |
msgid "Extra Large"
|
1106 |
msgstr ""
|
1107 |
|
1108 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1109 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1110 |
msgid "Custom"
|
1111 |
msgstr ""
|
1112 |
|
1113 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1114 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1115 |
msgid "Top Bottom Spacing"
|
1116 |
msgstr ""
|
1117 |
|
1118 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1119 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1120 |
msgid "Left Right Spacing"
|
1121 |
msgstr ""
|
1122 |
|
1123 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1124 |
msgid "Text / Placeholder Color"
|
1125 |
msgstr ""
|
1126 |
|
1127 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1128 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1129 |
msgid "Background Color"
|
1130 |
msgstr ""
|
1131 |
|
1132 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1133 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1134 |
msgid "Border Color"
|
1135 |
msgstr ""
|
1136 |
|
1137 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1138 |
msgid "Label Color"
|
1139 |
msgstr ""
|
1140 |
|
1141 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1142 |
msgid "Buttons"
|
1143 |
msgstr ""
|
1144 |
|
1145 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1146 |
msgid "Text Color"
|
1147 |
msgstr ""
|
1148 |
|
1149 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1150 |
msgid "Text Hover Color"
|
1151 |
msgstr ""
|
1152 |
|
1153 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1154 |
msgid "Background Hover Color"
|
1155 |
msgstr ""
|
1156 |
|
1157 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1158 |
msgid "Border Hover Color"
|
1159 |
msgstr ""
|
1160 |
|
1161 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1162 |
msgid "Sections"
|
1163 |
msgstr ""
|
1164 |
|
1165 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1166 |
msgid "Highlight Area Background Color"
|
1167 |
msgstr ""
|
1168 |
|
1169 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1170 |
msgid "Header Logo"
|
1171 |
msgstr ""
|
1172 |
|
1173 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
1174 |
msgid "Logo Width (In px)"
|
1175 |
msgstr ""
|
1176 |
|
@@ -1209,49 +1238,54 @@ msgstr ""
|
|
1209 |
msgid "Steps created for flow - %s"
|
1210 |
msgstr ""
|
1211 |
|
1212 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1213 |
#. translators: %s flow id
|
1214 |
msgid "Step not deleted for flow - %s"
|
1215 |
msgstr ""
|
1216 |
|
1217 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1218 |
#. translators: %s flow id
|
1219 |
msgid "Step deleted for flow - %s"
|
1220 |
msgstr ""
|
1221 |
|
1222 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1223 |
#. translators: %s flow id
|
1224 |
msgid "Steps not sorted for flow - %s"
|
1225 |
msgstr ""
|
1226 |
|
1227 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1228 |
#. translators: %s flow id
|
1229 |
msgid "Steps sorted for flow - %s"
|
1230 |
msgstr ""
|
1231 |
|
1232 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1233 |
msgid "Analytics"
|
1234 |
msgstr ""
|
1235 |
|
1236 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1237 |
#. translators: %s: link
|
1238 |
msgid "Upgrade to %1$sCartFlows Pro%2$s for Analytics feature"
|
1239 |
msgstr ""
|
1240 |
|
1241 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1242 |
msgid "Flow Settings"
|
1243 |
msgstr ""
|
1244 |
|
1245 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1246 |
msgid "Enable Test Mode"
|
1247 |
msgstr ""
|
1248 |
|
1249 |
-
#: modules/flow/classes/class-cartflows-flow-meta.php:
|
1250 |
msgid ""
|
1251 |
"If you are using WooCommerce plugin then test mode will add random products "
|
1252 |
"in your flow, so you can preview it easily while testing."
|
1253 |
msgstr ""
|
1254 |
|
|
|
|
|
|
|
|
|
|
|
1255 |
#: modules/flow/classes/class-cartflows-flow-post-type.php:69
|
1256 |
msgid "Flow: "
|
1257 |
msgstr ""
|
@@ -1429,10 +1463,6 @@ msgstr ""
|
|
1429 |
msgid "Delete"
|
1430 |
msgstr ""
|
1431 |
|
1432 |
-
#: modules/flow/view/meta-flow-steps.php:122
|
1433 |
-
msgid "Add New Step"
|
1434 |
-
msgstr ""
|
1435 |
-
|
1436 |
#: modules/flow/view/meta-flow-steps.php:138
|
1437 |
msgid "Steps Library"
|
1438 |
msgstr ""
|
@@ -1653,11 +1683,11 @@ msgid "Product"
|
|
1653 |
msgstr ""
|
1654 |
|
1655 |
#: woocommerce/template/checkout/review-order.php:27
|
1656 |
-
#: woocommerce/template/checkout/review-order.php:
|
1657 |
msgid "Total"
|
1658 |
msgstr ""
|
1659 |
|
1660 |
-
#: woocommerce/template/checkout/review-order.php:
|
1661 |
msgid "Subtotal"
|
1662 |
msgstr ""
|
1663 |
|
2 |
# This file is distributed under the same license as the CartFlows package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: CartFlows 1.3.2\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
|
7 |
+
"POT-Creation-Date: 2019-12-11 06:14:54+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
205 |
|
206 |
#: classes/class-cartflows-importer.php:672
|
207 |
#: classes/class-cartflows-importer.php:779
|
208 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:541
|
209 |
msgid "Get Pro"
|
210 |
msgstr ""
|
211 |
|
291 |
"to import the step."
|
292 |
msgstr ""
|
293 |
|
294 |
+
#: classes/class-cartflows-importer.php:1644
|
295 |
msgid "Action failed. Invalid Security Nonce."
|
296 |
msgstr ""
|
297 |
|
298 |
+
#: classes/class-cartflows-importer.php:1651
|
299 |
msgid "User have not plugin install permissions."
|
300 |
msgstr ""
|
301 |
|
302 |
+
#: classes/class-cartflows-importer.php:1673
|
303 |
msgid "Plugin Successfully Activated"
|
304 |
msgstr ""
|
305 |
|
318 |
msgid "Select CartFlows Template for this Course"
|
319 |
msgstr ""
|
320 |
|
321 |
+
#: classes/class-cartflows-loader.php:225
|
322 |
#. translators: %s: html tags
|
323 |
msgid ""
|
324 |
"You are using an older version of %1$sCartFlows Pro%2$s. Please update "
|
325 |
"%1$sCartFlows Pro%2$s plugin to version %1$s%3$s%2$s or higher."
|
326 |
msgstr ""
|
327 |
|
328 |
+
#: classes/class-cartflows-loader.php:482
|
329 |
#. translators: %s: html tags
|
330 |
msgid ""
|
331 |
"This %1$sCartFlows%2$s page requires %1$sWooCommerce%2$s plugin installed & "
|
332 |
"activated."
|
333 |
msgstr ""
|
334 |
|
335 |
+
#: classes/class-cartflows-loader.php:492
|
336 |
msgid "Activate WooCommerce"
|
337 |
msgstr ""
|
338 |
|
339 |
+
#: classes/class-cartflows-loader.php:500
|
340 |
msgid "Install WooCommerce"
|
341 |
msgstr ""
|
342 |
|
413 |
#: classes/class-cartflows-meta-fields.php:492
|
414 |
#: classes/class-cartflows-meta-fields.php:505
|
415 |
#: includes/admin/cartflows-general.php:123
|
416 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:555
|
417 |
msgid "Default"
|
418 |
msgstr ""
|
419 |
|
460 |
msgstr ""
|
461 |
|
462 |
#: classes/class-cartflows-meta.php:63
|
463 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:193
|
464 |
#: modules/landing/classes/class-cartflows-landing-meta.php:136
|
465 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:148
|
466 |
msgid "Custom Script"
|
891 |
msgid "Import"
|
892 |
msgstr ""
|
893 |
|
894 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:232
|
895 |
#: modules/thankyou/classes/class-cartflows-thankyou-markup.php:65
|
896 |
msgid ""
|
897 |
"WooCommerce functions do not exist. If you are in an IFrame, please reload "
|
898 |
"it."
|
899 |
msgstr ""
|
900 |
|
901 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:233
|
902 |
#: modules/thankyou/classes/class-cartflows-thankyou-markup.php:66
|
903 |
msgid "Click Here to Reload"
|
904 |
msgstr ""
|
905 |
|
906 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:251
|
907 |
msgid "Checkout ID not found"
|
908 |
msgstr ""
|
909 |
|
910 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:314
|
911 |
#: modules/checkout/templates/embed/checkout-template-simple.php:25
|
912 |
#: modules/checkout/templates/wcf-template.php:36
|
913 |
msgid "Your cart is currently empty."
|
914 |
msgstr ""
|
915 |
|
916 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:379
|
917 |
msgid ""
|
918 |
"No product is selected. Please select products from the checkout meta "
|
919 |
"settings to continue."
|
920 |
msgstr ""
|
921 |
|
922 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:432
|
923 |
msgid "Variations Not set"
|
924 |
msgstr ""
|
925 |
|
926 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:440
|
927 |
msgid "This product can't be purchased"
|
928 |
msgstr ""
|
929 |
|
930 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:1044
|
931 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:1087
|
932 |
msgid "Coupon Code"
|
933 |
msgstr ""
|
934 |
|
935 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:1045
|
936 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:1096
|
937 |
msgid "Apply"
|
938 |
msgstr ""
|
939 |
|
940 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:1252
|
941 |
+
msgid "Sorry there was a problem removing this coupon."
|
942 |
+
msgstr ""
|
943 |
+
|
944 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:1255
|
945 |
+
msgid "Coupon has been removed."
|
946 |
+
msgstr ""
|
947 |
+
|
948 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:1274
|
949 |
+
msgid "Sorry there was a problem removing "
|
950 |
+
msgstr ""
|
951 |
+
|
952 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:1277
|
953 |
+
msgid " has been removed."
|
954 |
+
msgstr ""
|
955 |
+
|
956 |
#: modules/checkout/classes/class-cartflows-checkout-meta.php:66
|
957 |
msgid "Checkout Layout"
|
958 |
msgstr ""
|
959 |
|
960 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:151
|
961 |
#: modules/landing/classes/class-cartflows-landing-meta.php:130
|
962 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:130
|
963 |
msgid "Shortcodes"
|
964 |
msgstr ""
|
965 |
|
966 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:157
|
967 |
msgid "Select Product"
|
968 |
msgstr ""
|
969 |
|
970 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:163
|
971 |
msgid "Order Bump"
|
972 |
msgstr ""
|
973 |
|
974 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:169
|
975 |
msgid "Checkout Offer"
|
976 |
msgstr ""
|
977 |
|
978 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:175
|
979 |
msgid "Checkout Design"
|
980 |
msgstr ""
|
981 |
|
982 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:181
|
983 |
msgid "Checkout Fields"
|
984 |
msgstr ""
|
985 |
|
986 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:187
|
987 |
+
msgid "Checkout Settings"
|
988 |
+
msgstr ""
|
989 |
+
|
990 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:204
|
991 |
msgid "Logo (Optional)"
|
992 |
msgstr ""
|
993 |
|
994 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:266
|
995 |
msgid "Add this shortcode to your checkout page"
|
996 |
msgstr ""
|
997 |
|
998 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:302
|
999 |
#. translators: %s: link
|
1000 |
msgid ""
|
1001 |
"Upgrade to %1$sCartFlows Pro%2$s for Pre-applied Coupon, Product Variations "
|
1002 |
"& Quantity Options."
|
1003 |
msgstr ""
|
1004 |
|
1005 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:329
|
1006 |
#. translators: %s: link
|
1007 |
msgid "Upgrade to %1$sCartFlows Pro%2$s for Checkout Offer feature"
|
1008 |
msgstr ""
|
1009 |
|
1010 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:339
|
1011 |
#. translators: %s: link
|
1012 |
msgid "Update to %1$sCartFlows Pro%2$s to %3$s or above for Checkout Offer feature"
|
1013 |
msgstr ""
|
1014 |
|
1015 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:367
|
1016 |
#. translators: %s: link
|
1017 |
msgid "Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature."
|
1018 |
msgstr ""
|
1019 |
|
1020 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:394
|
1021 |
#. translators: %s: link
|
1022 |
msgid "Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature."
|
1023 |
msgstr ""
|
1024 |
|
1025 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:418
|
1026 |
+
msgid "Enable cart editing on checkout"
|
1027 |
+
msgstr ""
|
1028 |
+
|
1029 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:426
|
1030 |
+
#. translators: %s: link
|
1031 |
+
msgid "Users will able to remove products from the checkout page."
|
1032 |
+
msgstr ""
|
1033 |
+
|
1034 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:454
|
1035 |
msgid "One Column (Available in CartFlows Pro) "
|
1036 |
msgstr ""
|
1037 |
|
1038 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:455
|
1039 |
msgid "Two Step (Available in CartFlows Pro) "
|
1040 |
msgstr ""
|
1041 |
|
1042 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:461
|
1043 |
msgid "Checkout Skin"
|
1044 |
msgstr ""
|
1045 |
|
1046 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:465
|
1047 |
msgid "One Column"
|
1048 |
msgstr ""
|
1049 |
|
1050 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:466
|
1051 |
msgid "Two Column"
|
1052 |
msgstr ""
|
1053 |
|
1054 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:467
|
1055 |
msgid "Two Step"
|
1056 |
msgstr ""
|
1057 |
|
1058 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:476
|
1059 |
msgid "Primary Color"
|
1060 |
msgstr ""
|
1061 |
|
1062 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:485
|
1063 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:520
|
1064 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:566
|
1065 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:658
|
1066 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:203
|
1067 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:226
|
1068 |
msgid "Font Family"
|
1069 |
msgstr ""
|
1070 |
|
1071 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:493
|
1072 |
msgid "Advance Options"
|
1073 |
msgstr ""
|
1074 |
|
1075 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:505
|
1076 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:211
|
1077 |
msgid "Heading"
|
1078 |
msgstr ""
|
1079 |
|
1080 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:511
|
1081 |
msgid "Heading Color"
|
1082 |
msgstr ""
|
1083 |
|
1084 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:529
|
1085 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:575
|
1086 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:667
|
1087 |
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:235
|
1088 |
msgid "Font Weight"
|
1089 |
msgstr ""
|
1090 |
|
1091 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:537
|
1092 |
msgid "Input Fields"
|
1093 |
msgstr ""
|
1094 |
|
1095 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:545
|
1096 |
msgid "Floating Labels (Available in CartFlows Pro)"
|
1097 |
msgstr ""
|
1098 |
|
1099 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:551
|
1100 |
msgid "Style"
|
1101 |
msgstr ""
|
1102 |
|
1103 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:556
|
1104 |
msgid "Floating Labels"
|
1105 |
msgstr ""
|
1106 |
|
1107 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:583
|
1108 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:675
|
1109 |
msgid "Size"
|
1110 |
msgstr ""
|
1111 |
|
1112 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:587
|
1113 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:679
|
1114 |
msgid "Extra Small"
|
1115 |
msgstr ""
|
1116 |
|
1117 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:588
|
1118 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:680
|
1119 |
msgid "Small"
|
1120 |
msgstr ""
|
1121 |
|
1122 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:589
|
1123 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:681
|
1124 |
msgid "Medium"
|
1125 |
msgstr ""
|
1126 |
|
1127 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:590
|
1128 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:682
|
1129 |
msgid "Large"
|
1130 |
msgstr ""
|
1131 |
|
1132 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:591
|
1133 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:683
|
1134 |
msgid "Extra Large"
|
1135 |
msgstr ""
|
1136 |
|
1137 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:592
|
1138 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:684
|
1139 |
msgid "Custom"
|
1140 |
msgstr ""
|
1141 |
|
1142 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:599
|
1143 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:691
|
1144 |
msgid "Top Bottom Spacing"
|
1145 |
msgstr ""
|
1146 |
|
1147 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:607
|
1148 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:699
|
1149 |
msgid "Left Right Spacing"
|
1150 |
msgstr ""
|
1151 |
|
1152 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:615
|
1153 |
msgid "Text / Placeholder Color"
|
1154 |
msgstr ""
|
1155 |
|
1156 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:623
|
1157 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:723
|
1158 |
msgid "Background Color"
|
1159 |
msgstr ""
|
1160 |
|
1161 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:631
|
1162 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:739
|
1163 |
msgid "Border Color"
|
1164 |
msgstr ""
|
1165 |
|
1166 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:638
|
1167 |
msgid "Label Color"
|
1168 |
msgstr ""
|
1169 |
|
1170 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:651
|
1171 |
msgid "Buttons"
|
1172 |
msgstr ""
|
1173 |
|
1174 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:707
|
1175 |
msgid "Text Color"
|
1176 |
msgstr ""
|
1177 |
|
1178 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:715
|
1179 |
msgid "Text Hover Color"
|
1180 |
msgstr ""
|
1181 |
|
1182 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:731
|
1183 |
msgid "Background Hover Color"
|
1184 |
msgstr ""
|
1185 |
|
1186 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:747
|
1187 |
msgid "Border Hover Color"
|
1188 |
msgstr ""
|
1189 |
|
1190 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:760
|
1191 |
msgid "Sections"
|
1192 |
msgstr ""
|
1193 |
|
1194 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:766
|
1195 |
msgid "Highlight Area Background Color"
|
1196 |
msgstr ""
|
1197 |
|
1198 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:805
|
1199 |
msgid "Header Logo"
|
1200 |
msgstr ""
|
1201 |
|
1202 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:813
|
1203 |
msgid "Logo Width (In px)"
|
1204 |
msgstr ""
|
1205 |
|
1238 |
msgid "Steps created for flow - %s"
|
1239 |
msgstr ""
|
1240 |
|
1241 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:334
|
1242 |
#. translators: %s flow id
|
1243 |
msgid "Step not deleted for flow - %s"
|
1244 |
msgstr ""
|
1245 |
|
1246 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:365
|
1247 |
#. translators: %s flow id
|
1248 |
msgid "Step deleted for flow - %s"
|
1249 |
msgstr ""
|
1250 |
|
1251 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:389
|
1252 |
#. translators: %s flow id
|
1253 |
msgid "Steps not sorted for flow - %s"
|
1254 |
msgstr ""
|
1255 |
|
1256 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:412
|
1257 |
#. translators: %s flow id
|
1258 |
msgid "Steps sorted for flow - %s"
|
1259 |
msgstr ""
|
1260 |
|
1261 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:523
|
1262 |
msgid "Analytics"
|
1263 |
msgstr ""
|
1264 |
|
1265 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:540
|
1266 |
#. translators: %s: link
|
1267 |
msgid "Upgrade to %1$sCartFlows Pro%2$s for Analytics feature"
|
1268 |
msgstr ""
|
1269 |
|
1270 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:558
|
1271 |
msgid "Flow Settings"
|
1272 |
msgstr ""
|
1273 |
|
1274 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:643
|
1275 |
msgid "Enable Test Mode"
|
1276 |
msgstr ""
|
1277 |
|
1278 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:650
|
1279 |
msgid ""
|
1280 |
"If you are using WooCommerce plugin then test mode will add random products "
|
1281 |
"in your flow, so you can preview it easily while testing."
|
1282 |
msgstr ""
|
1283 |
|
1284 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:769
|
1285 |
+
#: modules/flow/view/meta-flow-steps.php:122
|
1286 |
+
msgid "Add New Step"
|
1287 |
+
msgstr ""
|
1288 |
+
|
1289 |
#: modules/flow/classes/class-cartflows-flow-post-type.php:69
|
1290 |
msgid "Flow: "
|
1291 |
msgstr ""
|
1463 |
msgid "Delete"
|
1464 |
msgstr ""
|
1465 |
|
|
|
|
|
|
|
|
|
1466 |
#: modules/flow/view/meta-flow-steps.php:138
|
1467 |
msgid "Steps Library"
|
1468 |
msgstr ""
|
1683 |
msgstr ""
|
1684 |
|
1685 |
#: woocommerce/template/checkout/review-order.php:27
|
1686 |
+
#: woocommerce/template/checkout/review-order.php:107
|
1687 |
msgid "Total"
|
1688 |
msgstr ""
|
1689 |
|
1690 |
+
#: woocommerce/template/checkout/review-order.php:60
|
1691 |
msgid "Subtotal"
|
1692 |
msgstr ""
|
1693 |
|
modules/checkout/classes/class-cartflows-checkout-markup.php
CHANGED
@@ -71,8 +71,12 @@ class Cartflows_Checkout_Markup {
|
|
71 |
add_action( 'wp_ajax_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
|
72 |
add_action( 'wp_ajax_nopriv_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
|
73 |
|
|
|
|
|
|
|
74 |
add_filter( 'woocommerce_paypal_args', array( $this, 'modify_paypal_args' ), 10, 2 );
|
75 |
|
|
|
76 |
}
|
77 |
|
78 |
/**
|
@@ -96,12 +100,48 @@ class Cartflows_Checkout_Markup {
|
|
96 |
return $args;
|
97 |
}
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
/**
|
100 |
* Display all WooCommerce notices.
|
101 |
*
|
102 |
* @since 1.1.5
|
103 |
*/
|
104 |
-
function display_woo_notices() {
|
105 |
|
106 |
if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
|
107 |
woocommerce_output_all_notices();
|
@@ -114,7 +154,7 @@ class Cartflows_Checkout_Markup {
|
|
114 |
*
|
115 |
* @since 1.0.0
|
116 |
*/
|
117 |
-
function global_checkout_template_redirect() {
|
118 |
|
119 |
if ( ! is_checkout() ) {
|
120 |
return;
|
@@ -124,6 +164,11 @@ class Cartflows_Checkout_Markup {
|
|
124 |
return;
|
125 |
}
|
126 |
|
|
|
|
|
|
|
|
|
|
|
127 |
// redirect only for cartflows checkout pages.
|
128 |
$order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
|
129 |
$order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
|
@@ -133,12 +178,13 @@ class Cartflows_Checkout_Markup {
|
|
133 |
$global_checkout = $common['global_checkout'];
|
134 |
|
135 |
if (
|
|
|
136 |
// ignore on order-pay.
|
137 |
-
false === wcf_mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
|
138 |
// ignore on TY page.
|
139 |
-
false === wcf_mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' ) &&
|
140 |
// ignore if order-pay in query param.
|
141 |
-
false === wcf_mb_strpos( $_SERVER['REQUEST_URI'], $order_pay_endpoint . '=' )
|
142 |
) {
|
143 |
|
144 |
if ( '' !== $global_checkout ) {
|
@@ -147,7 +193,7 @@ class Cartflows_Checkout_Markup {
|
|
147 |
|
148 |
if ( ! empty( $link ) ) {
|
149 |
|
150 |
-
|
151 |
die();
|
152 |
}
|
153 |
}
|
@@ -161,7 +207,7 @@ class Cartflows_Checkout_Markup {
|
|
161 |
*
|
162 |
* @return bool
|
163 |
*/
|
164 |
-
function woo_checkout_flag( $is_checkout ) {
|
165 |
|
166 |
if ( ! is_admin() ) {
|
167 |
|
@@ -180,7 +226,7 @@ class Cartflows_Checkout_Markup {
|
|
180 |
* @param array $atts attributes.
|
181 |
* @return string
|
182 |
*/
|
183 |
-
function checkout_shortcode_markup( $atts ) {
|
184 |
|
185 |
if ( ! function_exists( 'wc_print_notices' ) ) {
|
186 |
$notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>';
|
@@ -240,7 +286,7 @@ class Cartflows_Checkout_Markup {
|
|
240 |
*
|
241 |
* @return void
|
242 |
*/
|
243 |
-
function preconfigured_cart_data() {
|
244 |
|
245 |
if ( is_admin() ) {
|
246 |
return;
|
@@ -293,7 +339,7 @@ class Cartflows_Checkout_Markup {
|
|
293 |
'posts_per_page' => 1,
|
294 |
'orderby' => 'rand',
|
295 |
'post_type' => 'product',
|
296 |
-
'meta_query' => array(
|
297 |
// Exclude out of stock products.
|
298 |
array(
|
299 |
'key' => '_stock_status',
|
@@ -301,7 +347,7 @@ class Cartflows_Checkout_Markup {
|
|
301 |
'compare' => 'NOT IN',
|
302 |
),
|
303 |
),
|
304 |
-
'tax_query' => array(
|
305 |
array(
|
306 |
'taxonomy' => 'product_type',
|
307 |
'field' => 'slug',
|
@@ -393,7 +439,9 @@ class Cartflows_Checkout_Markup {
|
|
393 |
} else {
|
394 |
$wrong_product_notice = __( 'This product can\'t be purchased', 'cartflows' );
|
395 |
wc_add_notice( $wrong_product_notice );
|
396 |
-
|
|
|
|
|
397 |
}
|
398 |
}
|
399 |
}
|
@@ -410,7 +458,7 @@ class Cartflows_Checkout_Markup {
|
|
410 |
*
|
411 |
* @return void
|
412 |
*/
|
413 |
-
function shortcode_load_data() {
|
414 |
|
415 |
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
416 |
|
@@ -462,7 +510,7 @@ class Cartflows_Checkout_Markup {
|
|
462 |
* @param array $checkout checkout session data.
|
463 |
* @return void
|
464 |
*/
|
465 |
-
function checkout_shortcode_post_id( $checkout ) {
|
466 |
|
467 |
global $post;
|
468 |
|
@@ -483,7 +531,7 @@ class Cartflows_Checkout_Markup {
|
|
483 |
*
|
484 |
* @return void
|
485 |
*/
|
486 |
-
function shortcode_scripts() {
|
487 |
|
488 |
wp_enqueue_style( 'wcf-checkout-template', wcf()->utils->get_css_url( 'checkout-template' ), '', CARTFLOWS_VER );
|
489 |
|
@@ -508,7 +556,7 @@ class Cartflows_Checkout_Markup {
|
|
508 |
*
|
509 |
* @return void
|
510 |
*/
|
511 |
-
function compatibility_scripts() {
|
512 |
|
513 |
global $post;
|
514 |
|
@@ -541,7 +589,7 @@ class Cartflows_Checkout_Markup {
|
|
541 |
*
|
542 |
* @return string
|
543 |
*/
|
544 |
-
function generate_style() {
|
545 |
|
546 |
global $post;
|
547 |
|
@@ -559,7 +607,8 @@ class Cartflows_Checkout_Markup {
|
|
559 |
|
560 |
$header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
|
561 |
|
562 |
-
|
|
|
563 |
$r = '';
|
564 |
$g = '';
|
565 |
$b = '';
|
@@ -598,7 +647,8 @@ class Cartflows_Checkout_Markup {
|
|
598 |
$heading_font_family = '';
|
599 |
$heading_font_weight = '';
|
600 |
$base_font_family = $base_font_family;
|
601 |
-
|
|
|
602 |
|
603 |
if ( 'yes' == $is_advance_option ) {
|
604 |
|
@@ -667,6 +717,10 @@ class Cartflows_Checkout_Markup {
|
|
667 |
list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
|
668 |
}
|
669 |
$output = "
|
|
|
|
|
|
|
|
|
670 |
.wcf-embed-checkout-form .wcf-checkout-header-image img{
|
671 |
width: {$header_logo_width}px;
|
672 |
}
|
@@ -826,7 +880,7 @@ class Cartflows_Checkout_Markup {
|
|
826 |
* @param string $endpoint_url end point URL.
|
827 |
* @return string
|
828 |
*/
|
829 |
-
function get_ajax_endpoint( $endpoint_url ) {
|
830 |
|
831 |
global $post;
|
832 |
|
@@ -834,13 +888,13 @@ class Cartflows_Checkout_Markup {
|
|
834 |
|
835 |
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
836 |
|
837 |
-
if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
|
838 |
|
839 |
$query_args = array(
|
840 |
'wc-ajax' => '%%endpoint%%',
|
841 |
);
|
842 |
|
843 |
-
$uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
|
844 |
$uri = $uri[0];
|
845 |
|
846 |
$endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
|
@@ -859,18 +913,19 @@ class Cartflows_Checkout_Markup {
|
|
859 |
* @param array $posted posted data.
|
860 |
* @return void
|
861 |
*/
|
862 |
-
function save_checkout_fields( $order_id, $posted ) {
|
863 |
|
864 |
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
865 |
|
866 |
-
$checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
|
867 |
|
868 |
update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
|
869 |
|
870 |
-
|
871 |
Custom Field To Do
|
872 |
$custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
|
873 |
|
|
|
874 |
if ( 'yes' === $custom_fields ) {
|
875 |
|
876 |
$billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
|
@@ -900,7 +955,7 @@ class Cartflows_Checkout_Markup {
|
|
900 |
*/
|
901 |
if ( isset( $_POST['_wcf_flow_id'] ) ) {
|
902 |
|
903 |
-
$checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
|
904 |
|
905 |
update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
|
906 |
}
|
@@ -913,7 +968,7 @@ class Cartflows_Checkout_Markup {
|
|
913 |
*
|
914 |
* @return void
|
915 |
*/
|
916 |
-
function enable_logo_in_header() {
|
917 |
global $post;
|
918 |
|
919 |
if ( _is_wcf_checkout_type() ) {
|
@@ -939,7 +994,7 @@ class Cartflows_Checkout_Markup {
|
|
939 |
*
|
940 |
* @return void
|
941 |
*/
|
942 |
-
function show_cartflows_copyright_message() {
|
943 |
$output_string = '';
|
944 |
|
945 |
$output_string .= '<div class="wcf-footer-primary">';
|
@@ -960,7 +1015,7 @@ class Cartflows_Checkout_Markup {
|
|
960 |
* @param object $user user.
|
961 |
* @return string
|
962 |
*/
|
963 |
-
function after_login_redirect( $redirect, $user ) {
|
964 |
|
965 |
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
966 |
|
@@ -975,7 +1030,7 @@ class Cartflows_Checkout_Markup {
|
|
975 |
/**
|
976 |
* Display coupon code field after review order fields.
|
977 |
*/
|
978 |
-
function display_custom_coupon_field() {
|
979 |
|
980 |
$coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
|
981 |
$show_coupon = apply_filters( 'cartflows_show_coupon_field', true );
|
@@ -1017,7 +1072,7 @@ class Cartflows_Checkout_Markup {
|
|
1017 |
* @param string $coupon coupon.
|
1018 |
* @return string
|
1019 |
*/
|
1020 |
-
function remove_coupon_text( $coupon ) {
|
1021 |
|
1022 |
$coupon = str_replace( 'woocommerce-remove-coupon', 'wcf-remove-coupon', $coupon );
|
1023 |
return $coupon;
|
@@ -1028,7 +1083,7 @@ class Cartflows_Checkout_Markup {
|
|
1028 |
*
|
1029 |
* @return string
|
1030 |
*/
|
1031 |
-
function coupon_field_placeholder() {
|
1032 |
return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
|
1033 |
}
|
1034 |
|
@@ -1037,20 +1092,20 @@ class Cartflows_Checkout_Markup {
|
|
1037 |
*
|
1038 |
* @return string
|
1039 |
*/
|
1040 |
-
function coupon_button_text() {
|
1041 |
return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
|
1042 |
}
|
1043 |
|
1044 |
/**
|
1045 |
* Apply coupon on submit of custom coupon form.
|
1046 |
*/
|
1047 |
-
function apply_coupon() {
|
1048 |
|
1049 |
$response = '';
|
1050 |
|
1051 |
check_ajax_referer( 'wcf-apply-coupon', 'security' );
|
1052 |
if ( ! empty( $_POST['coupon_code'] ) ) {
|
1053 |
-
$result = WC()->cart->add_discount( sanitize_text_field( $_POST['coupon_code'] ) );
|
1054 |
} else {
|
1055 |
wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' );
|
1056 |
}
|
@@ -1060,7 +1115,7 @@ class Cartflows_Checkout_Markup {
|
|
1060 |
'msg' => wc_print_notices( true ),
|
1061 |
);
|
1062 |
|
1063 |
-
echo
|
1064 |
|
1065 |
die();
|
1066 |
}
|
@@ -1071,12 +1126,14 @@ class Cartflows_Checkout_Markup {
|
|
1071 |
*
|
1072 |
* @param array $vars localize variables.
|
1073 |
*/
|
1074 |
-
function add_localize_vars( $vars ) {
|
1075 |
|
1076 |
$vars['wcf_validate_coupon_nonce'] = wp_create_nonce( 'wcf-apply-coupon' );
|
1077 |
|
1078 |
$vars['wcf_validate_remove_coupon_nonce'] = wp_create_nonce( 'wcf-remove-coupon' );
|
1079 |
|
|
|
|
|
1080 |
$vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
|
1081 |
|
1082 |
return $vars;
|
@@ -1087,7 +1144,7 @@ class Cartflows_Checkout_Markup {
|
|
1087 |
*
|
1088 |
* @param array $fields fields.
|
1089 |
*/
|
1090 |
-
function add_three_column_layout_fields( $fields ) {
|
1091 |
|
1092 |
if ( empty( $fields['billing']['billing_address_2'] ) ) {
|
1093 |
|
@@ -1169,7 +1226,7 @@ class Cartflows_Checkout_Markup {
|
|
1169 |
*
|
1170 |
* @since 1.0.0
|
1171 |
*/
|
1172 |
-
function order_wrap_div_start() {
|
1173 |
|
1174 |
echo "<div class='wcf-order-wrap'> ";
|
1175 |
}
|
@@ -1179,29 +1236,63 @@ class Cartflows_Checkout_Markup {
|
|
1179 |
*
|
1180 |
* @since 1.0.0
|
1181 |
*/
|
1182 |
-
function order_wrap_div_end() {
|
1183 |
|
1184 |
echo '</div> ';
|
1185 |
}
|
1186 |
-
|
1187 |
/**
|
1188 |
* Remove coupon.
|
1189 |
*/
|
1190 |
-
function remove_coupon() {
|
1191 |
|
1192 |
check_ajax_referer( 'wcf-remove-coupon', 'security' );
|
1193 |
-
$coupon = isset( $_POST['coupon_code'] ) ? wc_clean( $_POST['coupon_code'] ) : false;
|
1194 |
|
1195 |
if ( empty( $coupon ) ) {
|
1196 |
-
echo "<div class='woocommerce-error'>Sorry there was a problem removing this coupon.
|
1197 |
} else {
|
1198 |
WC()->cart->remove_coupon( $coupon );
|
1199 |
-
echo "<div class='woocommerce-error'>Coupon has been removed
|
1200 |
}
|
1201 |
wc_print_notices();
|
1202 |
wp_die();
|
1203 |
}
|
1204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1205 |
}
|
1206 |
|
1207 |
/**
|
71 |
add_action( 'wp_ajax_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
|
72 |
add_action( 'wp_ajax_nopriv_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
|
73 |
|
74 |
+
add_action( 'wp_ajax_wcf_woo_remove_cart_product', array( $this, 'wcf_woo_remove_cart_product' ) );
|
75 |
+
add_action( 'wp_ajax_nopriv_wcf_woo_remove_cart_product', array( $this, 'wcf_woo_remove_cart_product' ) );
|
76 |
+
|
77 |
add_filter( 'woocommerce_paypal_args', array( $this, 'modify_paypal_args' ), 10, 2 );
|
78 |
|
79 |
+
add_filter( 'woocommerce_cart_item_name', array( $this, 'wcf_add_remove_label' ), 10, 3 );
|
80 |
}
|
81 |
|
82 |
/**
|
100 |
return $args;
|
101 |
}
|
102 |
|
103 |
+
/**
|
104 |
+
* Modify WooCommerce paypal arguments.
|
105 |
+
*
|
106 |
+
* @param string $product_name product name.
|
107 |
+
* @param object $cart_item cart item.
|
108 |
+
* @param string $cart_item_key cart item key.
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
public function wcf_add_remove_label( $product_name, $cart_item, $cart_item_key ) {
|
112 |
+
|
113 |
+
$checkout_id = get_the_ID();
|
114 |
+
if ( ! $checkout_id ) {
|
115 |
+
$checkout_id = ( isset( $_POST['option']['checkout_id'] ) ) ? wp_unslash( $_POST['option']['checkout_id'] ) : '';
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( ! empty( $checkout_id ) ) {
|
119 |
+
$is_remove_product_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-remove-product-field' );
|
120 |
+
if ( 'checkout' === get_post_meta( $checkout_id, 'wcf-step-type', true ) && ( 'yes' === $is_remove_product_option ) ) {
|
121 |
+
$remove_label = apply_filters(
|
122 |
+
'woocommerce_cart_item_remove_link',
|
123 |
+
sprintf(
|
124 |
+
'<a href="#" rel="nofollow" class="remove cartflows-icon-close" data-id="%s" data-item-key="%s" ></a>',
|
125 |
+
esc_attr( $cart_item['product_id'] ),
|
126 |
+
$cart_item_key
|
127 |
+
),
|
128 |
+
$cart_item_key
|
129 |
+
);
|
130 |
+
|
131 |
+
$product_name = $remove_label . $product_name;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
return $product_name;
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
/**
|
140 |
* Display all WooCommerce notices.
|
141 |
*
|
142 |
* @since 1.1.5
|
143 |
*/
|
144 |
+
public function display_woo_notices() {
|
145 |
|
146 |
if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
|
147 |
woocommerce_output_all_notices();
|
154 |
*
|
155 |
* @since 1.0.0
|
156 |
*/
|
157 |
+
public function global_checkout_template_redirect() {
|
158 |
|
159 |
if ( ! is_checkout() ) {
|
160 |
return;
|
164 |
return;
|
165 |
}
|
166 |
|
167 |
+
// Return if the key OR Order paramater is found in the URL for certain Payment gateways.
|
168 |
+
if ( isset( $_GET['key'] ) || isset( $_GET['order'] ) ) {
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
|
172 |
// redirect only for cartflows checkout pages.
|
173 |
$order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
|
174 |
$order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
|
178 |
$global_checkout = $common['global_checkout'];
|
179 |
|
180 |
if (
|
181 |
+
isset( $_SERVER['REQUEST_URI'] ) &&
|
182 |
// ignore on order-pay.
|
183 |
+
false === wcf_mb_strpos( wp_unslash( $_SERVER['REQUEST_URI'] ), '/' . $order_pay_endpoint . '/' ) &&
|
184 |
// ignore on TY page.
|
185 |
+
false === wcf_mb_strpos( wp_unslash( $_SERVER['REQUEST_URI'] ), '/' . $order_received_endpoint . '/' ) &&
|
186 |
// ignore if order-pay in query param.
|
187 |
+
false === wcf_mb_strpos( wp_unslash( $_SERVER['REQUEST_URI'] ), $order_pay_endpoint . '=' )
|
188 |
) {
|
189 |
|
190 |
if ( '' !== $global_checkout ) {
|
193 |
|
194 |
if ( ! empty( $link ) ) {
|
195 |
|
196 |
+
wp_safe_redirect( $link );
|
197 |
die();
|
198 |
}
|
199 |
}
|
207 |
*
|
208 |
* @return bool
|
209 |
*/
|
210 |
+
public function woo_checkout_flag( $is_checkout ) {
|
211 |
|
212 |
if ( ! is_admin() ) {
|
213 |
|
226 |
* @param array $atts attributes.
|
227 |
* @return string
|
228 |
*/
|
229 |
+
public function checkout_shortcode_markup( $atts ) {
|
230 |
|
231 |
if ( ! function_exists( 'wc_print_notices' ) ) {
|
232 |
$notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>';
|
286 |
*
|
287 |
* @return void
|
288 |
*/
|
289 |
+
public function preconfigured_cart_data() {
|
290 |
|
291 |
if ( is_admin() ) {
|
292 |
return;
|
339 |
'posts_per_page' => 1,
|
340 |
'orderby' => 'rand',
|
341 |
'post_type' => 'product',
|
342 |
+
'meta_query' => array( //phpcs:ignore
|
343 |
// Exclude out of stock products.
|
344 |
array(
|
345 |
'key' => '_stock_status',
|
347 |
'compare' => 'NOT IN',
|
348 |
),
|
349 |
),
|
350 |
+
'tax_query' => array( //phpcs:ignore
|
351 |
array(
|
352 |
'taxonomy' => 'product_type',
|
353 |
'field' => 'slug',
|
439 |
} else {
|
440 |
$wrong_product_notice = __( 'This product can\'t be purchased', 'cartflows' );
|
441 |
wc_add_notice( $wrong_product_notice );
|
442 |
+
/**
|
443 |
+
WC()->cart->add_to_cart( $product_id, $quantity );.
|
444 |
+
*/
|
445 |
}
|
446 |
}
|
447 |
}
|
458 |
*
|
459 |
* @return void
|
460 |
*/
|
461 |
+
public function shortcode_load_data() {
|
462 |
|
463 |
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
464 |
|
510 |
* @param array $checkout checkout session data.
|
511 |
* @return void
|
512 |
*/
|
513 |
+
public function checkout_shortcode_post_id( $checkout ) {
|
514 |
|
515 |
global $post;
|
516 |
|
531 |
*
|
532 |
* @return void
|
533 |
*/
|
534 |
+
public function shortcode_scripts() {
|
535 |
|
536 |
wp_enqueue_style( 'wcf-checkout-template', wcf()->utils->get_css_url( 'checkout-template' ), '', CARTFLOWS_VER );
|
537 |
|
556 |
*
|
557 |
* @return void
|
558 |
*/
|
559 |
+
public function compatibility_scripts() {
|
560 |
|
561 |
global $post;
|
562 |
|
589 |
*
|
590 |
* @return string
|
591 |
*/
|
592 |
+
public function generate_style() {
|
593 |
|
594 |
global $post;
|
595 |
|
607 |
|
608 |
$header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
|
609 |
|
610 |
+
/**
|
611 |
+
$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
|
612 |
$r = '';
|
613 |
$g = '';
|
614 |
$b = '';
|
647 |
$heading_font_family = '';
|
648 |
$heading_font_weight = '';
|
649 |
$base_font_family = $base_font_family;
|
650 |
+
/**
|
651 |
+
$base_font_weight = $base_font_weight;*/
|
652 |
|
653 |
if ( 'yes' == $is_advance_option ) {
|
654 |
|
717 |
list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
|
718 |
}
|
719 |
$output = "
|
720 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{
|
721 |
+
color:$primary_color !important;
|
722 |
+
border:1px solid $primary_color !important;
|
723 |
+
}
|
724 |
.wcf-embed-checkout-form .wcf-checkout-header-image img{
|
725 |
width: {$header_logo_width}px;
|
726 |
}
|
880 |
* @param string $endpoint_url end point URL.
|
881 |
* @return string
|
882 |
*/
|
883 |
+
public function get_ajax_endpoint( $endpoint_url ) {
|
884 |
|
885 |
global $post;
|
886 |
|
888 |
|
889 |
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
890 |
|
891 |
+
if ( mb_strpos( $endpoint_url, 'checkout', 0, 'utf-8' ) === false ) {
|
892 |
|
893 |
$query_args = array(
|
894 |
'wc-ajax' => '%%endpoint%%',
|
895 |
);
|
896 |
|
897 |
+
$uri = explode( '?', $_SERVER['REQUEST_URI'], 2 ); //phpcs:ignore
|
898 |
$uri = $uri[0];
|
899 |
|
900 |
$endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
|
913 |
* @param array $posted posted data.
|
914 |
* @return void
|
915 |
*/
|
916 |
+
public function save_checkout_fields( $order_id, $posted ) {
|
917 |
|
918 |
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
919 |
|
920 |
+
$checkout_id = wc_clean( wp_unslash( $_POST['_wcf_checkout_id'] ) );
|
921 |
|
922 |
update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
|
923 |
|
924 |
+
/**
|
925 |
Custom Field To Do
|
926 |
$custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
|
927 |
|
928 |
+
//If condition
|
929 |
if ( 'yes' === $custom_fields ) {
|
930 |
|
931 |
$billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
|
955 |
*/
|
956 |
if ( isset( $_POST['_wcf_flow_id'] ) ) {
|
957 |
|
958 |
+
$checkout_id = wc_clean( wp_unslash( $_POST['_wcf_flow_id'] ) );
|
959 |
|
960 |
update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
|
961 |
}
|
968 |
*
|
969 |
* @return void
|
970 |
*/
|
971 |
+
public function enable_logo_in_header() {
|
972 |
global $post;
|
973 |
|
974 |
if ( _is_wcf_checkout_type() ) {
|
994 |
*
|
995 |
* @return void
|
996 |
*/
|
997 |
+
public function show_cartflows_copyright_message() {
|
998 |
$output_string = '';
|
999 |
|
1000 |
$output_string .= '<div class="wcf-footer-primary">';
|
1015 |
* @param object $user user.
|
1016 |
* @return string
|
1017 |
*/
|
1018 |
+
public function after_login_redirect( $redirect, $user ) {
|
1019 |
|
1020 |
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
1021 |
|
1030 |
/**
|
1031 |
* Display coupon code field after review order fields.
|
1032 |
*/
|
1033 |
+
public function display_custom_coupon_field() {
|
1034 |
|
1035 |
$coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
|
1036 |
$show_coupon = apply_filters( 'cartflows_show_coupon_field', true );
|
1072 |
* @param string $coupon coupon.
|
1073 |
* @return string
|
1074 |
*/
|
1075 |
+
public function remove_coupon_text( $coupon ) {
|
1076 |
|
1077 |
$coupon = str_replace( 'woocommerce-remove-coupon', 'wcf-remove-coupon', $coupon );
|
1078 |
return $coupon;
|
1083 |
*
|
1084 |
* @return string
|
1085 |
*/
|
1086 |
+
public function coupon_field_placeholder() {
|
1087 |
return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
|
1088 |
}
|
1089 |
|
1092 |
*
|
1093 |
* @return string
|
1094 |
*/
|
1095 |
+
public function coupon_button_text() {
|
1096 |
return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
|
1097 |
}
|
1098 |
|
1099 |
/**
|
1100 |
* Apply coupon on submit of custom coupon form.
|
1101 |
*/
|
1102 |
+
public function apply_coupon() {
|
1103 |
|
1104 |
$response = '';
|
1105 |
|
1106 |
check_ajax_referer( 'wcf-apply-coupon', 'security' );
|
1107 |
if ( ! empty( $_POST['coupon_code'] ) ) {
|
1108 |
+
$result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
|
1109 |
} else {
|
1110 |
wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' );
|
1111 |
}
|
1115 |
'msg' => wc_print_notices( true ),
|
1116 |
);
|
1117 |
|
1118 |
+
echo wp_json_encode( $response );
|
1119 |
|
1120 |
die();
|
1121 |
}
|
1126 |
*
|
1127 |
* @param array $vars localize variables.
|
1128 |
*/
|
1129 |
+
public function add_localize_vars( $vars ) {
|
1130 |
|
1131 |
$vars['wcf_validate_coupon_nonce'] = wp_create_nonce( 'wcf-apply-coupon' );
|
1132 |
|
1133 |
$vars['wcf_validate_remove_coupon_nonce'] = wp_create_nonce( 'wcf-remove-coupon' );
|
1134 |
|
1135 |
+
$vars['wcf_validate_remove_cart_product_nonce'] = wp_create_nonce( 'wcf-remove-cart-product' );
|
1136 |
+
|
1137 |
$vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
|
1138 |
|
1139 |
return $vars;
|
1144 |
*
|
1145 |
* @param array $fields fields.
|
1146 |
*/
|
1147 |
+
public function add_three_column_layout_fields( $fields ) {
|
1148 |
|
1149 |
if ( empty( $fields['billing']['billing_address_2'] ) ) {
|
1150 |
|
1226 |
*
|
1227 |
* @since 1.0.0
|
1228 |
*/
|
1229 |
+
public function order_wrap_div_start() {
|
1230 |
|
1231 |
echo "<div class='wcf-order-wrap'> ";
|
1232 |
}
|
1236 |
*
|
1237 |
* @since 1.0.0
|
1238 |
*/
|
1239 |
+
public function order_wrap_div_end() {
|
1240 |
|
1241 |
echo '</div> ';
|
1242 |
}
|
|
|
1243 |
/**
|
1244 |
* Remove coupon.
|
1245 |
*/
|
1246 |
+
public function remove_coupon() {
|
1247 |
|
1248 |
check_ajax_referer( 'wcf-remove-coupon', 'security' );
|
1249 |
+
$coupon = isset( $_POST['coupon_code'] ) ? wc_clean( wp_unslash( $_POST['coupon_code'] ) ) : false;
|
1250 |
|
1251 |
if ( empty( $coupon ) ) {
|
1252 |
+
echo "<div class='woocommerce-error'>" . __( 'Sorry there was a problem removing this coupon.', 'cartflows' );
|
1253 |
} else {
|
1254 |
WC()->cart->remove_coupon( $coupon );
|
1255 |
+
echo "<div class='woocommerce-error'>" . __( 'Coupon has been removed.', 'cartflows' ) . '</div>';
|
1256 |
}
|
1257 |
wc_print_notices();
|
1258 |
wp_die();
|
1259 |
}
|
1260 |
|
1261 |
+
/**
|
1262 |
+
* Remove cart item.
|
1263 |
+
*/
|
1264 |
+
public function wcf_woo_remove_cart_product() {
|
1265 |
+
|
1266 |
+
check_ajax_referer( 'wcf-remove-cart-product', 'security' );
|
1267 |
+
$product_key = isset( $_POST['p_key'] ) ? wc_clean( wp_unslash( $_POST['p_key'] ) ) : false;
|
1268 |
+
$product_id = isset( $_POST['p_id'] ) ? wc_clean( wp_unslash( $_POST['p_id'] ) ) : '';
|
1269 |
+
$product_title = get_the_title( $product_id );
|
1270 |
+
|
1271 |
+
$needs_shipping = false;
|
1272 |
+
|
1273 |
+
if ( empty( $product_key ) ) {
|
1274 |
+
$msg = "<div class='woocommerce-message'>" . __( 'Sorry there was a problem removing ', 'cartflows' ) . $product_title;
|
1275 |
+
} else {
|
1276 |
+
WC()->cart->remove_cart_item( $product_key );
|
1277 |
+
$msg = "<div class='woocommerce-message'>" . $product_title . __( ' has been removed.', 'cartflows' ) . '</div>';
|
1278 |
+
}
|
1279 |
+
|
1280 |
+
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
|
1281 |
+
if ( $values['data']->needs_shipping() ) {
|
1282 |
+
$needs_shipping = true;
|
1283 |
+
break;
|
1284 |
+
}
|
1285 |
+
}
|
1286 |
+
|
1287 |
+
$response = array(
|
1288 |
+
'need_shipping' => $needs_shipping,
|
1289 |
+
'msg' => $msg,
|
1290 |
+
);
|
1291 |
+
|
1292 |
+
echo wp_json_encode( $response );
|
1293 |
+
wp_die();
|
1294 |
+
}
|
1295 |
+
|
1296 |
}
|
1297 |
|
1298 |
/**
|
modules/checkout/classes/class-cartflows-checkout-meta.php
CHANGED
@@ -58,7 +58,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
58 |
/**
|
59 |
* Setup Metabox
|
60 |
*/
|
61 |
-
function setup_meta_box() {
|
62 |
|
63 |
if ( _is_wcf_checkout_type() ) {
|
64 |
add_meta_box(
|
@@ -78,7 +78,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
78 |
* @param object $post Post object.
|
79 |
* @return void
|
80 |
*/
|
81 |
-
function markup_meta_box( $post ) {
|
82 |
|
83 |
wp_nonce_field( 'save-nonce-checkout-step-meta', 'nonce-checkout-step-meta' );
|
84 |
|
@@ -103,9 +103,10 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
103 |
$checkout_data[ $key ] = $meta[ $key ]['default'];
|
104 |
}
|
105 |
|
106 |
-
|
107 |
$billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post->ID );
|
108 |
|
|
|
109 |
foreach ( $billing_fields as $key => $value ) {
|
110 |
|
111 |
$checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
|
@@ -137,7 +138,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
137 |
* @param array $options options.
|
138 |
* @param int $post_id post ID.
|
139 |
*/
|
140 |
-
function tabs_markup( $options, $post_id ) {
|
141 |
|
142 |
$active_tab = get_post_meta( $post_id, 'wcf-active-tab', true );
|
143 |
|
@@ -182,6 +183,12 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
182 |
'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
183 |
'icon' => 'dashicons-welcome-widgets-menus',
|
184 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
array(
|
186 |
'title' => __( 'Custom Script', 'cartflows' ),
|
187 |
'id' => 'wcf-checkout-custom-script-header',
|
@@ -227,6 +234,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
227 |
<?php $this->tab_pre_checkout_offer( $options, $post_id ); ?>
|
228 |
<?php $this->tab_product_bump( $options, $post_id ); ?>
|
229 |
<?php $this->tab_custom_fields( $options, $post_id ); ?>
|
|
|
230 |
<?php $this->tab_header_content( $options, $post_id ); ?>
|
231 |
<?php $this->tab_custom_script( $options, $post_id ); ?>
|
232 |
<?php do_action( 'cartflows_checkout_tabs_content', $options, $post_id ); ?>
|
@@ -244,7 +252,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
244 |
* @param array $options options.
|
245 |
* @param int $post_id post ID.
|
246 |
*/
|
247 |
-
function tab_shortcodes( $options, $post_id ) {
|
248 |
?>
|
249 |
<div class="wcf-checkout-shortcodes wcf-tab-content widefat">
|
250 |
|
@@ -270,7 +278,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
270 |
* @param array $options options.
|
271 |
* @param int $post_id post ID.
|
272 |
*/
|
273 |
-
function tab_general( $options, $post_id ) {
|
274 |
?>
|
275 |
<div class="wcf-checkout-general wcf-tab-content widefat">
|
276 |
|
@@ -309,7 +317,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
309 |
* @param array $options options.
|
310 |
* @param int $post_id post ID.
|
311 |
*/
|
312 |
-
function tab_pre_checkout_offer( $options, $post_id ) {
|
313 |
?>
|
314 |
<div class="wcf-pre-checkout-offer wcf-tab-content widefat">
|
315 |
<?php
|
@@ -347,7 +355,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
347 |
* @param array $options options.
|
348 |
* @param int $post_id post ID.
|
349 |
*/
|
350 |
-
function tab_product_bump( $options, $post_id ) {
|
351 |
?>
|
352 |
<div class="wcf-product-order-bump wcf-tab-content widefat">
|
353 |
<?php
|
@@ -372,7 +380,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
372 |
* @param array $options options.
|
373 |
* @param int $post_id post ID.
|
374 |
*/
|
375 |
-
function tab_custom_fields( $options, $post_id ) {
|
376 |
?>
|
377 |
<div class="wcf-checkout-custom-fields wcf-tab-content widefat">
|
378 |
<?php
|
@@ -392,6 +400,38 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
392 |
</div>
|
393 |
<?php
|
394 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
|
396 |
/**
|
397 |
* Tab style
|
@@ -399,7 +439,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
399 |
* @param array $options options.
|
400 |
* @param int $post_id post ID.
|
401 |
*/
|
402 |
-
function tab_style( $options, $post_id ) {
|
403 |
?>
|
404 |
|
405 |
<div class="wcf-checkout-style wcf-tab-content widefat">
|
@@ -502,7 +542,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
502 |
|
503 |
if ( ! _is_cartflows_pro() ) {
|
504 |
$fields_skin_pro_option = array(
|
505 |
-
'
|
506 |
);
|
507 |
}
|
508 |
|
@@ -750,7 +790,7 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
750 |
* @param array $options options.
|
751 |
* @param int $post_id post ID.
|
752 |
*/
|
753 |
-
function tab_header_content( $options, $post_id ) {
|
754 |
?>
|
755 |
|
756 |
<div class="wcf-checkout-header wcf-tab-content widefat">
|
@@ -804,13 +844,13 @@ class Cartflows_Checkout_Meta extends Cartflows_Meta {
|
|
804 |
* @param number $post_id Post ID.
|
805 |
* @return void
|
806 |
*/
|
807 |
-
function save_meta_box( $post_id ) {
|
808 |
|
809 |
// Checks save status.
|
810 |
$is_autosave = wp_is_post_autosave( $post_id );
|
811 |
$is_revision = wp_is_post_revision( $post_id );
|
812 |
|
813 |
-
$is_valid_nonce = ( isset( $_POST['nonce-checkout-step-meta'] ) && wp_verify_nonce( $_POST['nonce-checkout-step-meta'], 'save-nonce-checkout-step-meta' ) ) ? true : false;
|
814 |
|
815 |
// Exits script depending on save status.
|
816 |
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
58 |
/**
|
59 |
* Setup Metabox
|
60 |
*/
|
61 |
+
public function setup_meta_box() {
|
62 |
|
63 |
if ( _is_wcf_checkout_type() ) {
|
64 |
add_meta_box(
|
78 |
* @param object $post Post object.
|
79 |
* @return void
|
80 |
*/
|
81 |
+
public function markup_meta_box( $post ) {
|
82 |
|
83 |
wp_nonce_field( 'save-nonce-checkout-step-meta', 'nonce-checkout-step-meta' );
|
84 |
|
103 |
$checkout_data[ $key ] = $meta[ $key ]['default'];
|
104 |
}
|
105 |
|
106 |
+
/**
|
107 |
$billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post->ID );
|
108 |
|
109 |
+
// For loop
|
110 |
foreach ( $billing_fields as $key => $value ) {
|
111 |
|
112 |
$checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
|
138 |
* @param array $options options.
|
139 |
* @param int $post_id post ID.
|
140 |
*/
|
141 |
+
public function tabs_markup( $options, $post_id ) {
|
142 |
|
143 |
$active_tab = get_post_meta( $post_id, 'wcf-active-tab', true );
|
144 |
|
183 |
'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
184 |
'icon' => 'dashicons-welcome-widgets-menus',
|
185 |
),
|
186 |
+
array(
|
187 |
+
'title' => __( 'Checkout Settings', 'cartflows' ),
|
188 |
+
'id' => 'wcf-checkout-custom-settings',
|
189 |
+
'class' => 'wcf-checkout-custom-settings' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
190 |
+
'icon' => 'dashicons-admin-generic',
|
191 |
+
),
|
192 |
array(
|
193 |
'title' => __( 'Custom Script', 'cartflows' ),
|
194 |
'id' => 'wcf-checkout-custom-script-header',
|
234 |
<?php $this->tab_pre_checkout_offer( $options, $post_id ); ?>
|
235 |
<?php $this->tab_product_bump( $options, $post_id ); ?>
|
236 |
<?php $this->tab_custom_fields( $options, $post_id ); ?>
|
237 |
+
<?php $this->tab_custom_settings( $options, $post_id ); ?>
|
238 |
<?php $this->tab_header_content( $options, $post_id ); ?>
|
239 |
<?php $this->tab_custom_script( $options, $post_id ); ?>
|
240 |
<?php do_action( 'cartflows_checkout_tabs_content', $options, $post_id ); ?>
|
252 |
* @param array $options options.
|
253 |
* @param int $post_id post ID.
|
254 |
*/
|
255 |
+
public function tab_shortcodes( $options, $post_id ) {
|
256 |
?>
|
257 |
<div class="wcf-checkout-shortcodes wcf-tab-content widefat">
|
258 |
|
278 |
* @param array $options options.
|
279 |
* @param int $post_id post ID.
|
280 |
*/
|
281 |
+
public function tab_general( $options, $post_id ) {
|
282 |
?>
|
283 |
<div class="wcf-checkout-general wcf-tab-content widefat">
|
284 |
|
317 |
* @param array $options options.
|
318 |
* @param int $post_id post ID.
|
319 |
*/
|
320 |
+
public function tab_pre_checkout_offer( $options, $post_id ) {
|
321 |
?>
|
322 |
<div class="wcf-pre-checkout-offer wcf-tab-content widefat">
|
323 |
<?php
|
355 |
* @param array $options options.
|
356 |
* @param int $post_id post ID.
|
357 |
*/
|
358 |
+
public function tab_product_bump( $options, $post_id ) {
|
359 |
?>
|
360 |
<div class="wcf-product-order-bump wcf-tab-content widefat">
|
361 |
<?php
|
380 |
* @param array $options options.
|
381 |
* @param int $post_id post ID.
|
382 |
*/
|
383 |
+
public function tab_custom_fields( $options, $post_id ) {
|
384 |
?>
|
385 |
<div class="wcf-checkout-custom-fields wcf-tab-content widefat">
|
386 |
<?php
|
400 |
</div>
|
401 |
<?php
|
402 |
}
|
403 |
+
/**
|
404 |
+
* Tab custom settings
|
405 |
+
*
|
406 |
+
* @param array $options options.
|
407 |
+
* @param int $post_id post ID.
|
408 |
+
*/
|
409 |
+
public function tab_custom_settings( $options, $post_id ) {
|
410 |
+
?>
|
411 |
+
<div class="wcf-checkout-custom-settings wcf-tab-content widefat">
|
412 |
+
<div class="wcf-custom-settings-fields">
|
413 |
+
<?php
|
414 |
+
echo wcf()->meta->get_checkbox_field(
|
415 |
+
array(
|
416 |
+
'name' => 'wcf-remove-product-field',
|
417 |
+
'value' => $options['wcf-remove-product-field'],
|
418 |
+
'after' => __( 'Enable cart editing on checkout', 'cartflows' ),
|
419 |
+
)
|
420 |
+
);
|
421 |
+
|
422 |
+
echo wcf()->meta->get_description_field(
|
423 |
+
array(
|
424 |
+
'name' => '',
|
425 |
+
/* translators: %s: link */
|
426 |
+
'content' => '<i>' . sprintf( __( 'Users will able to remove products from the checkout page.', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
|
427 |
+
)
|
428 |
+
);
|
429 |
+
?>
|
430 |
+
</div>
|
431 |
+
<?php do_action( 'cartflows_custom_settings_tab_content', $options, $post_id ); ?>
|
432 |
+
</div>
|
433 |
+
<?php
|
434 |
+
}
|
435 |
|
436 |
/**
|
437 |
* Tab style
|
439 |
* @param array $options options.
|
440 |
* @param int $post_id post ID.
|
441 |
*/
|
442 |
+
public function tab_style( $options, $post_id ) {
|
443 |
?>
|
444 |
|
445 |
<div class="wcf-checkout-style wcf-tab-content widefat">
|
542 |
|
543 |
if ( ! _is_cartflows_pro() ) {
|
544 |
$fields_skin_pro_option = array(
|
545 |
+
'style-one' => __( 'Floating Labels (Available in CartFlows Pro)', 'cartflows' ),
|
546 |
);
|
547 |
}
|
548 |
|
790 |
* @param array $options options.
|
791 |
* @param int $post_id post ID.
|
792 |
*/
|
793 |
+
public function tab_header_content( $options, $post_id ) {
|
794 |
?>
|
795 |
|
796 |
<div class="wcf-checkout-header wcf-tab-content widefat">
|
844 |
* @param number $post_id Post ID.
|
845 |
* @return void
|
846 |
*/
|
847 |
+
public function save_meta_box( $post_id ) {
|
848 |
|
849 |
// Checks save status.
|
850 |
$is_autosave = wp_is_post_autosave( $post_id );
|
851 |
$is_revision = wp_is_post_revision( $post_id );
|
852 |
|
853 |
+
$is_valid_nonce = ( isset( $_POST['nonce-checkout-step-meta'] ) && wp_verify_nonce( wp_unslash( $_POST['nonce-checkout-step-meta'] ), 'save-nonce-checkout-step-meta' ) ) ? true : false;
|
854 |
|
855 |
// Exits script depending on save status.
|
856 |
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
modules/checkout/templates/wcf-template.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Flow
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
?>
|
9 |
-
<!DOCTYPE html>
|
10 |
-
<html <?php language_attributes(); ?>>
|
11 |
-
<head>
|
12 |
-
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>">
|
13 |
-
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
14 |
-
<meta name="robots" content="noindex">
|
15 |
-
<title><?php wp_title( '-', true, 'right' ); ?><?php bloginfo( 'name' ); ?></title>
|
16 |
-
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
17 |
-
|
18 |
-
<?php wp_head(); ?>
|
19 |
-
</head>
|
20 |
-
<body <?php body_class(); ?>>
|
21 |
-
<div class="wrapper">
|
22 |
-
<header class="header">
|
23 |
-
</header>
|
24 |
-
|
25 |
-
<div class="main-container">
|
26 |
-
<div class="checkout-forms">
|
27 |
-
<!-- CHECKOUT SHORTCODE -->
|
28 |
-
<?php
|
29 |
-
|
30 |
-
$checkout_html = do_shortcode( '[woocommerce_checkout]' );
|
31 |
-
|
32 |
-
if (
|
33 |
-
empty( $checkout_html ) ||
|
34 |
-
trim( $checkout_html ) == '<div class="woocommerce"></div>'
|
35 |
-
) {
|
36 |
-
echo __( 'Your cart is currently empty.', 'cartflows' );
|
37 |
-
} else {
|
38 |
-
echo $checkout_html;
|
39 |
-
}
|
40 |
-
?>
|
41 |
-
<!-- END CHECKOUT SHORTCODE -->
|
42 |
-
</div>
|
43 |
-
</div>
|
44 |
-
|
45 |
-
<footer class="footer">
|
46 |
-
<p><?php _e( 'Copyright ©', 'cartflows' ); ?> <?php
|
47 |
-
echo
|
48 |
-
echo ' ' . get_bloginfo( 'name' );
|
49 |
-
?>
|
50 |
-
- <?php _e( 'All Rights Reserved', 'cartflows' ); ?></p>
|
51 |
-
</footer>
|
52 |
-
</div>
|
53 |
-
|
54 |
-
<div class="wcf-hide">
|
55 |
-
<?php wp_footer(); ?>
|
56 |
-
</div>
|
57 |
-
</body>
|
58 |
-
</html>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Flow
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
?>
|
9 |
+
<!DOCTYPE html>
|
10 |
+
<html <?php language_attributes(); ?>>
|
11 |
+
<head>
|
12 |
+
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>">
|
13 |
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
14 |
+
<meta name="robots" content="noindex">
|
15 |
+
<title><?php wp_title( '-', true, 'right' ); ?><?php bloginfo( 'name' ); ?></title>
|
16 |
+
<link rel="profile" href="http://gmpg.org/xfn/11" />
|
17 |
+
|
18 |
+
<?php wp_head(); ?>
|
19 |
+
</head>
|
20 |
+
<body <?php body_class(); ?>>
|
21 |
+
<div class="wrapper">
|
22 |
+
<header class="header">
|
23 |
+
</header>
|
24 |
+
|
25 |
+
<div class="main-container">
|
26 |
+
<div class="checkout-forms">
|
27 |
+
<!-- CHECKOUT SHORTCODE -->
|
28 |
+
<?php
|
29 |
+
|
30 |
+
$checkout_html = do_shortcode( '[woocommerce_checkout]' );
|
31 |
+
|
32 |
+
if (
|
33 |
+
empty( $checkout_html ) ||
|
34 |
+
trim( $checkout_html ) == '<div class="woocommerce"></div>'
|
35 |
+
) {
|
36 |
+
echo __( 'Your cart is currently empty.', 'cartflows' );
|
37 |
+
} else {
|
38 |
+
echo $checkout_html;
|
39 |
+
}
|
40 |
+
?>
|
41 |
+
<!-- END CHECKOUT SHORTCODE -->
|
42 |
+
</div>
|
43 |
+
</div>
|
44 |
+
|
45 |
+
<footer class="footer">
|
46 |
+
<p><?php _e( 'Copyright ©', 'cartflows' ); ?> <?php
|
47 |
+
echo gmdate( 'Y' );
|
48 |
+
echo ' ' . get_bloginfo( 'name' );
|
49 |
+
?>
|
50 |
+
- <?php _e( 'All Rights Reserved', 'cartflows' ); ?></p>
|
51 |
+
</footer>
|
52 |
+
</div>
|
53 |
+
|
54 |
+
<div class="wcf-hide">
|
55 |
+
<?php wp_footer(); ?>
|
56 |
+
</div>
|
57 |
+
</body>
|
58 |
+
</html>
|
modules/flow/classes/class-cartflows-flow-loader.php
CHANGED
@@ -1,59 +1,59 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Flow loader
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Flow_Loader {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
$this->include_files();
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Load classes.
|
42 |
-
*
|
43 |
-
* @since 1.0.0
|
44 |
-
*
|
45 |
-
* @return void
|
46 |
-
*/
|
47 |
-
function include_files() {
|
48 |
-
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-flow-post-type.php';
|
49 |
-
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-step-post-type.php';
|
50 |
-
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-step-post-meta.php';
|
51 |
-
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-flow-shortcodes.php';
|
52 |
-
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-permalink.php';
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Kicking this off by calling 'get_instance()' method
|
58 |
-
*/
|
59 |
-
Cartflows_Flow_Loader::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Flow loader
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Flow_Loader {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
$this->include_files();
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Load classes.
|
42 |
+
*
|
43 |
+
* @since 1.0.0
|
44 |
+
*
|
45 |
+
* @return void
|
46 |
+
*/
|
47 |
+
public function include_files() {
|
48 |
+
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-flow-post-type.php';
|
49 |
+
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-step-post-type.php';
|
50 |
+
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-step-post-meta.php';
|
51 |
+
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-flow-shortcodes.php';
|
52 |
+
require_once CARTFLOWS_FLOW_DIR . 'classes/class-cartflows-permalink.php';
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Kicking this off by calling 'get_instance()' method
|
58 |
+
*/
|
59 |
+
Cartflows_Flow_Loader::get_instance();
|
modules/flow/classes/class-cartflows-flow-meta.php
CHANGED
@@ -1,778 +1,780 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Flow meta
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Meta Boxes setup
|
10 |
-
*/
|
11 |
-
class Cartflows_Flow_Meta {
|
12 |
-
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Instance
|
16 |
-
*
|
17 |
-
* @var $instance
|
18 |
-
*/
|
19 |
-
private static $instance;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Meta Option
|
23 |
-
*
|
24 |
-
* @var $meta_option
|
25 |
-
*/
|
26 |
-
private static $meta_option;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Initiator
|
30 |
-
*/
|
31 |
-
public static function get_instance() {
|
32 |
-
if ( ! isset( self::$instance ) ) {
|
33 |
-
self::$instance = new self();
|
34 |
-
}
|
35 |
-
|
36 |
-
return self::$instance;
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Constructor
|
41 |
-
*/
|
42 |
-
public function __construct() {
|
43 |
-
|
44 |
-
add_action( 'admin_head', array( $this, 'menu_highlight' ) );
|
45 |
-
|
46 |
-
add_action( 'admin_init', array( $this, 'admin_init_actions' ) );
|
47 |
-
|
48 |
-
/* Init Metabox */
|
49 |
-
add_action( 'load-post.php', array( $this, 'init_metabox' ) );
|
50 |
-
add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
|
51 |
-
|
52 |
-
/* Add Scripts */
|
53 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 20 );
|
54 |
-
|
55 |
-
add_action( 'wp_ajax_cartflows_setup_default_steps', array( $this, 'cartflows_setup_default_steps' ) );
|
56 |
-
add_action( 'wp_ajax_cartflows_delete_flow_step', array( $this, 'cartflows_delete_flow_step' ) );
|
57 |
-
|
58 |
-
add_action( 'wp_ajax_cartflows_reorder_flow_steps', array( $this, 'cartflows_reorder_flow_steps' ) );
|
59 |
-
|
60 |
-
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
61 |
-
|
62 |
-
add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Display admin notices.
|
67 |
-
*
|
68 |
-
* @since 1.0.0
|
69 |
-
*
|
70 |
-
* @return void
|
71 |
-
*/
|
72 |
-
function admin_notices() {
|
73 |
-
|
74 |
-
if ( CARTFLOWS_STEP_POST_TYPE !== get_post_type() ) {
|
75 |
-
return;
|
76 |
-
}
|
77 |
-
|
78 |
-
$flow_id = get_post_meta( get_the_id(), 'wcf-flow-id', true );
|
79 |
-
if ( $flow_id ) { ?>
|
80 |
-
<div class="wcf-notice-back-edit-flow">
|
81 |
-
<p>
|
82 |
-
<a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button button-primary button-hero" style="text-decoration: none;">
|
83 |
-
<i class="dashicons dashicons-arrow-left-alt"></i>
|
84 |
-
<?php _e( 'Back to edit Flow', 'cartflows' ); ?>
|
85 |
-
</a>
|
86 |
-
</p>
|
87 |
-
</div>
|
88 |
-
<?php
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Initialize admin actions.
|
94 |
-
*
|
95 |
-
* @since 1.0.0
|
96 |
-
*
|
97 |
-
* @return void
|
98 |
-
*/
|
99 |
-
function admin_init_actions() {
|
100 |
-
add_action( 'before_delete_post', array( $this, 'step_post_sync' ) );
|
101 |
-
add_action( 'wp_trash_post', array( $this, 'step_post_trash_sync' ) );
|
102 |
-
add_action( 'untrashed_post', array( $this, 'step_post_untrash_sync' ) );
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Delete term data and steps data after deleting flow.
|
107 |
-
*
|
108 |
-
* @since 1.0.0
|
109 |
-
* @param int $pid post id.
|
110 |
-
*
|
111 |
-
* @return void
|
112 |
-
*/
|
113 |
-
function step_post_sync( $pid ) {
|
114 |
-
|
115 |
-
global $post_type;
|
116 |
-
|
117 |
-
if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
|
118 |
-
|
119 |
-
$steps = get_post_meta( $pid, 'wcf-steps', true );
|
120 |
-
|
121 |
-
if ( $steps && is_array( $steps ) ) {
|
122 |
-
foreach ( $steps as $i => $step ) {
|
123 |
-
wp_delete_post( $step['id'], true );
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
$term_data = term_exists( 'flow-' . $pid, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
128 |
-
|
129 |
-
if ( is_array( $term_data ) ) {
|
130 |
-
wp_delete_term( $term_data['term_id'], CARTFLOWS_TAXONOMY_STEP_FLOW );
|
131 |
-
}
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Trash steps data after trashing flow.
|
137 |
-
*
|
138 |
-
* @since 1.0.0
|
139 |
-
* @param int $pid post id.
|
140 |
-
*
|
141 |
-
* @return void
|
142 |
-
*/
|
143 |
-
function step_post_trash_sync( $pid ) {
|
144 |
-
|
145 |
-
global $post_type;
|
146 |
-
|
147 |
-
if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
|
148 |
-
|
149 |
-
$steps = get_post_meta( $pid, 'wcf-steps', true );
|
150 |
-
|
151 |
-
if ( $steps && is_array( $steps ) ) {
|
152 |
-
foreach ( $steps as $i => $step ) {
|
153 |
-
wp_trash_post( $step['id'] );
|
154 |
-
}
|
155 |
-
}
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Untrash steps data after restoring flow.
|
161 |
-
*
|
162 |
-
* @since 1.0.0
|
163 |
-
* @param int $pid post id.
|
164 |
-
*
|
165 |
-
* @return void
|
166 |
-
*/
|
167 |
-
function step_post_untrash_sync( $pid ) {
|
168 |
-
|
169 |
-
global $post_type;
|
170 |
-
|
171 |
-
if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
|
172 |
-
|
173 |
-
$steps = get_post_meta( $pid, 'wcf-steps', true );
|
174 |
-
|
175 |
-
if ( $steps && is_array( $steps ) ) {
|
176 |
-
foreach ( $steps as $i => $step ) {
|
177 |
-
wp_untrash_post( $step['id'] );
|
178 |
-
}
|
179 |
-
}
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Setup default steps for flow
|
185 |
-
*
|
186 |
-
* @since 1.0.0
|
187 |
-
*
|
188 |
-
* @return void
|
189 |
-
*/
|
190 |
-
public function cartflows_setup_default_steps() {
|
191 |
-
|
192 |
-
check_ajax_referer( 'wcf-setup-default-steps', 'security' );
|
193 |
-
|
194 |
-
$flow_id = intval( $_POST['post_id'] );
|
195 |
-
|
196 |
-
$result = array(
|
197 |
-
'status' => false,
|
198 |
-
/* translators: %s flow id */
|
199 |
-
'text' => sprintf( __( 'Steps not created for flow - %s', 'cartflows' ), $flow_id ),
|
200 |
-
);
|
201 |
-
|
202 |
-
if ( ! $flow_id ) {
|
203 |
-
wp_send_json( $result );
|
204 |
-
}
|
205 |
-
|
206 |
-
$is_step_exists = get_post_meta( $flow_id, 'wcf-steps', true );
|
207 |
-
|
208 |
-
if ( $is_step_exists ) {
|
209 |
-
|
210 |
-
$result = array(
|
211 |
-
'status' => false,
|
212 |
-
/* translators: %s flow id */
|
213 |
-
'text' => sprintf( __( 'Steps already exists. Flow - %s', 'cartflows' ), $flow_id ),
|
214 |
-
);
|
215 |
-
|
216 |
-
wp_send_json( $result );
|
217 |
-
}
|
218 |
-
|
219 |
-
/* Start Creating */
|
220 |
-
|
221 |
-
$flow_steps = array();
|
222 |
-
|
223 |
-
$steps_data = array(
|
224 |
-
'landing' => __( 'Landing Page', 'cartflows' ),
|
225 |
-
'checkout' => __( 'Checkout Page', 'cartflows' ),
|
226 |
-
'thankyou' => __( 'Thank You Page', 'cartflows' ),
|
227 |
-
);
|
228 |
-
|
229 |
-
foreach ( $steps_data as $slug => $title ) {
|
230 |
-
|
231 |
-
$step_id = wp_insert_post(
|
232 |
-
array(
|
233 |
-
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
234 |
-
'post_title' => $title,
|
235 |
-
'post_content' => '[cartflows_navigation]',
|
236 |
-
'post_status' => 'publish',
|
237 |
-
)
|
238 |
-
);
|
239 |
-
|
240 |
-
if ( $step_id ) {
|
241 |
-
|
242 |
-
$flow_steps[] = array(
|
243 |
-
'id' => $step_id,
|
244 |
-
'title' => $title,
|
245 |
-
'type' => $slug,
|
246 |
-
);
|
247 |
-
|
248 |
-
// insert post meta.
|
249 |
-
update_post_meta( $step_id, 'wcf-flow-id', $flow_id );
|
250 |
-
update_post_meta( $step_id, 'wcf-step-type', $slug );
|
251 |
-
|
252 |
-
wp_set_object_terms( $step_id, $slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
253 |
-
wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
254 |
-
}
|
255 |
-
}
|
256 |
-
|
257 |
-
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
258 |
-
|
259 |
-
$result = array(
|
260 |
-
'status' => true,
|
261 |
-
/* translators: %s flow id */
|
262 |
-
'text' => sprintf( __( 'Steps created for flow - %s', 'cartflows' ), $flow_id ),
|
263 |
-
'redirect' => get_edit_post_link( $flow_id ),
|
264 |
-
);
|
265 |
-
|
266 |
-
wp_send_json( $result );
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Create step for given flow.
|
271 |
-
*
|
272 |
-
* @param int $flow_id flow ID.
|
273 |
-
* @param int $step_type step type.
|
274 |
-
* @param int $step_title step title.
|
275 |
-
* @since 1.0.0
|
276 |
-
*
|
277 |
-
* @return int
|
278 |
-
*/
|
279 |
-
public function create_step( $flow_id, $step_type, $step_title ) {
|
280 |
-
|
281 |
-
$new_step_id = wp_insert_post(
|
282 |
-
array(
|
283 |
-
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
284 |
-
'post_title' => $step_title,
|
285 |
-
'post_status' => 'publish',
|
286 |
-
)
|
287 |
-
);
|
288 |
-
|
289 |
-
if ( $new_step_id ) {
|
290 |
-
|
291 |
-
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
292 |
-
|
293 |
-
if ( ! is_array( $flow_steps ) ) {
|
294 |
-
$flow_steps = array();
|
295 |
-
}
|
296 |
-
|
297 |
-
$flow_steps[] = array(
|
298 |
-
'id' => $new_step_id,
|
299 |
-
'title' => $step_title,
|
300 |
-
'type' => $step_type,
|
301 |
-
);
|
302 |
-
|
303 |
-
// insert post meta.
|
304 |
-
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
305 |
-
update_post_meta( $new_step_id, 'wcf-step-type', $step_type );
|
306 |
-
|
307 |
-
wp_set_object_terms( $new_step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
308 |
-
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
309 |
-
}
|
310 |
-
|
311 |
-
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
312 |
-
|
313 |
-
return $new_step_id;
|
314 |
-
}
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Delete step for flow
|
318 |
-
*
|
319 |
-
* @since 1.0.0
|
320 |
-
*
|
321 |
-
* @return void
|
322 |
-
*/
|
323 |
-
public function cartflows_delete_flow_step() {
|
324 |
-
|
325 |
-
check_ajax_referer( 'wcf-delete-flow-step', 'security' );
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
*
|
373 |
-
*
|
374 |
-
*
|
375 |
-
*
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
'
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
'
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
$
|
408 |
-
|
409 |
-
|
410 |
-
'
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
*
|
421 |
-
*
|
422 |
-
* @
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
$
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
*
|
456 |
-
*
|
457 |
-
* @
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
*
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
add_action( '
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
*
|
475 |
-
*
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
*
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
$this->
|
508 |
-
|
509 |
-
$this->
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
'
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
*
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
'
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
*
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
do_action( '
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
*
|
596 |
-
*
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
do_action( '
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
*
|
619 |
-
*
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
*
|
630 |
-
*
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
'
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
*
|
662 |
-
*
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
*
|
676 |
-
*
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
*
|
694 |
-
*
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
$
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
|
708 |
-
}
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
*
|
718 |
-
*
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
$
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
*
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
'
|
747 |
-
'
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
*
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
$add_new_btn_markup .= '
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Flow meta
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Meta Boxes setup
|
10 |
+
*/
|
11 |
+
class Cartflows_Flow_Meta {
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Instance
|
16 |
+
*
|
17 |
+
* @var $instance
|
18 |
+
*/
|
19 |
+
private static $instance;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Meta Option
|
23 |
+
*
|
24 |
+
* @var $meta_option
|
25 |
+
*/
|
26 |
+
private static $meta_option;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Initiator
|
30 |
+
*/
|
31 |
+
public static function get_instance() {
|
32 |
+
if ( ! isset( self::$instance ) ) {
|
33 |
+
self::$instance = new self();
|
34 |
+
}
|
35 |
+
|
36 |
+
return self::$instance;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Constructor
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
|
44 |
+
add_action( 'admin_head', array( $this, 'menu_highlight' ) );
|
45 |
+
|
46 |
+
add_action( 'admin_init', array( $this, 'admin_init_actions' ) );
|
47 |
+
|
48 |
+
/* Init Metabox */
|
49 |
+
add_action( 'load-post.php', array( $this, 'init_metabox' ) );
|
50 |
+
add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
|
51 |
+
|
52 |
+
/* Add Scripts */
|
53 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 20 );
|
54 |
+
|
55 |
+
add_action( 'wp_ajax_cartflows_setup_default_steps', array( $this, 'cartflows_setup_default_steps' ) );
|
56 |
+
add_action( 'wp_ajax_cartflows_delete_flow_step', array( $this, 'cartflows_delete_flow_step' ) );
|
57 |
+
|
58 |
+
add_action( 'wp_ajax_cartflows_reorder_flow_steps', array( $this, 'cartflows_reorder_flow_steps' ) );
|
59 |
+
|
60 |
+
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
61 |
+
|
62 |
+
add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Display admin notices.
|
67 |
+
*
|
68 |
+
* @since 1.0.0
|
69 |
+
*
|
70 |
+
* @return void
|
71 |
+
*/
|
72 |
+
public function admin_notices() {
|
73 |
+
|
74 |
+
if ( CARTFLOWS_STEP_POST_TYPE !== get_post_type() ) {
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
$flow_id = get_post_meta( get_the_id(), 'wcf-flow-id', true );
|
79 |
+
if ( $flow_id ) { ?>
|
80 |
+
<div class="wcf-notice-back-edit-flow">
|
81 |
+
<p>
|
82 |
+
<a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button button-primary button-hero" style="text-decoration: none;">
|
83 |
+
<i class="dashicons dashicons-arrow-left-alt"></i>
|
84 |
+
<?php _e( 'Back to edit Flow', 'cartflows' ); ?>
|
85 |
+
</a>
|
86 |
+
</p>
|
87 |
+
</div>
|
88 |
+
<?php
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Initialize admin actions.
|
94 |
+
*
|
95 |
+
* @since 1.0.0
|
96 |
+
*
|
97 |
+
* @return void
|
98 |
+
*/
|
99 |
+
public function admin_init_actions() {
|
100 |
+
add_action( 'before_delete_post', array( $this, 'step_post_sync' ) );
|
101 |
+
add_action( 'wp_trash_post', array( $this, 'step_post_trash_sync' ) );
|
102 |
+
add_action( 'untrashed_post', array( $this, 'step_post_untrash_sync' ) );
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Delete term data and steps data after deleting flow.
|
107 |
+
*
|
108 |
+
* @since 1.0.0
|
109 |
+
* @param int $pid post id.
|
110 |
+
*
|
111 |
+
* @return void
|
112 |
+
*/
|
113 |
+
public function step_post_sync( $pid ) {
|
114 |
+
|
115 |
+
global $post_type;
|
116 |
+
|
117 |
+
if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
|
118 |
+
|
119 |
+
$steps = get_post_meta( $pid, 'wcf-steps', true );
|
120 |
+
|
121 |
+
if ( $steps && is_array( $steps ) ) {
|
122 |
+
foreach ( $steps as $i => $step ) {
|
123 |
+
wp_delete_post( $step['id'], true );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
$term_data = term_exists( 'flow-' . $pid, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
128 |
+
|
129 |
+
if ( is_array( $term_data ) ) {
|
130 |
+
wp_delete_term( $term_data['term_id'], CARTFLOWS_TAXONOMY_STEP_FLOW );
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Trash steps data after trashing flow.
|
137 |
+
*
|
138 |
+
* @since 1.0.0
|
139 |
+
* @param int $pid post id.
|
140 |
+
*
|
141 |
+
* @return void
|
142 |
+
*/
|
143 |
+
public function step_post_trash_sync( $pid ) {
|
144 |
+
|
145 |
+
global $post_type;
|
146 |
+
|
147 |
+
if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
|
148 |
+
|
149 |
+
$steps = get_post_meta( $pid, 'wcf-steps', true );
|
150 |
+
|
151 |
+
if ( $steps && is_array( $steps ) ) {
|
152 |
+
foreach ( $steps as $i => $step ) {
|
153 |
+
wp_trash_post( $step['id'] );
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Untrash steps data after restoring flow.
|
161 |
+
*
|
162 |
+
* @since 1.0.0
|
163 |
+
* @param int $pid post id.
|
164 |
+
*
|
165 |
+
* @return void
|
166 |
+
*/
|
167 |
+
public function step_post_untrash_sync( $pid ) {
|
168 |
+
|
169 |
+
global $post_type;
|
170 |
+
|
171 |
+
if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
|
172 |
+
|
173 |
+
$steps = get_post_meta( $pid, 'wcf-steps', true );
|
174 |
+
|
175 |
+
if ( $steps && is_array( $steps ) ) {
|
176 |
+
foreach ( $steps as $i => $step ) {
|
177 |
+
wp_untrash_post( $step['id'] );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Setup default steps for flow
|
185 |
+
*
|
186 |
+
* @since 1.0.0
|
187 |
+
*
|
188 |
+
* @return void
|
189 |
+
*/
|
190 |
+
public function cartflows_setup_default_steps() {
|
191 |
+
|
192 |
+
check_ajax_referer( 'wcf-setup-default-steps', 'security' );
|
193 |
+
|
194 |
+
$flow_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : '';
|
195 |
+
|
196 |
+
$result = array(
|
197 |
+
'status' => false,
|
198 |
+
/* translators: %s flow id */
|
199 |
+
'text' => sprintf( __( 'Steps not created for flow - %s', 'cartflows' ), $flow_id ),
|
200 |
+
);
|
201 |
+
|
202 |
+
if ( ! $flow_id ) {
|
203 |
+
wp_send_json( $result );
|
204 |
+
}
|
205 |
+
|
206 |
+
$is_step_exists = get_post_meta( $flow_id, 'wcf-steps', true );
|
207 |
+
|
208 |
+
if ( $is_step_exists ) {
|
209 |
+
|
210 |
+
$result = array(
|
211 |
+
'status' => false,
|
212 |
+
/* translators: %s flow id */
|
213 |
+
'text' => sprintf( __( 'Steps already exists. Flow - %s', 'cartflows' ), $flow_id ),
|
214 |
+
);
|
215 |
+
|
216 |
+
wp_send_json( $result );
|
217 |
+
}
|
218 |
+
|
219 |
+
/* Start Creating */
|
220 |
+
|
221 |
+
$flow_steps = array();
|
222 |
+
|
223 |
+
$steps_data = array(
|
224 |
+
'landing' => __( 'Landing Page', 'cartflows' ),
|
225 |
+
'checkout' => __( 'Checkout Page', 'cartflows' ),
|
226 |
+
'thankyou' => __( 'Thank You Page', 'cartflows' ),
|
227 |
+
);
|
228 |
+
|
229 |
+
foreach ( $steps_data as $slug => $title ) {
|
230 |
+
|
231 |
+
$step_id = wp_insert_post(
|
232 |
+
array(
|
233 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
234 |
+
'post_title' => $title,
|
235 |
+
'post_content' => '[cartflows_navigation]',
|
236 |
+
'post_status' => 'publish',
|
237 |
+
)
|
238 |
+
);
|
239 |
+
|
240 |
+
if ( $step_id ) {
|
241 |
+
|
242 |
+
$flow_steps[] = array(
|
243 |
+
'id' => $step_id,
|
244 |
+
'title' => $title,
|
245 |
+
'type' => $slug,
|
246 |
+
);
|
247 |
+
|
248 |
+
// insert post meta.
|
249 |
+
update_post_meta( $step_id, 'wcf-flow-id', $flow_id );
|
250 |
+
update_post_meta( $step_id, 'wcf-step-type', $slug );
|
251 |
+
|
252 |
+
wp_set_object_terms( $step_id, $slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
253 |
+
wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
258 |
+
|
259 |
+
$result = array(
|
260 |
+
'status' => true,
|
261 |
+
/* translators: %s flow id */
|
262 |
+
'text' => sprintf( __( 'Steps created for flow - %s', 'cartflows' ), $flow_id ),
|
263 |
+
'redirect' => get_edit_post_link( $flow_id ),
|
264 |
+
);
|
265 |
+
|
266 |
+
wp_send_json( $result );
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Create step for given flow.
|
271 |
+
*
|
272 |
+
* @param int $flow_id flow ID.
|
273 |
+
* @param int $step_type step type.
|
274 |
+
* @param int $step_title step title.
|
275 |
+
* @since 1.0.0
|
276 |
+
*
|
277 |
+
* @return int
|
278 |
+
*/
|
279 |
+
public function create_step( $flow_id, $step_type, $step_title ) {
|
280 |
+
|
281 |
+
$new_step_id = wp_insert_post(
|
282 |
+
array(
|
283 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
284 |
+
'post_title' => $step_title,
|
285 |
+
'post_status' => 'publish',
|
286 |
+
)
|
287 |
+
);
|
288 |
+
|
289 |
+
if ( $new_step_id ) {
|
290 |
+
|
291 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
292 |
+
|
293 |
+
if ( ! is_array( $flow_steps ) ) {
|
294 |
+
$flow_steps = array();
|
295 |
+
}
|
296 |
+
|
297 |
+
$flow_steps[] = array(
|
298 |
+
'id' => $new_step_id,
|
299 |
+
'title' => $step_title,
|
300 |
+
'type' => $step_type,
|
301 |
+
);
|
302 |
+
|
303 |
+
// insert post meta.
|
304 |
+
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
305 |
+
update_post_meta( $new_step_id, 'wcf-step-type', $step_type );
|
306 |
+
|
307 |
+
wp_set_object_terms( $new_step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
308 |
+
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
309 |
+
}
|
310 |
+
|
311 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
312 |
+
|
313 |
+
return $new_step_id;
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Delete step for flow
|
318 |
+
*
|
319 |
+
* @since 1.0.0
|
320 |
+
*
|
321 |
+
* @return void
|
322 |
+
*/
|
323 |
+
public function cartflows_delete_flow_step() {
|
324 |
+
|
325 |
+
check_ajax_referer( 'wcf-delete-flow-step', 'security' );
|
326 |
+
|
327 |
+
if ( isset( $_POST['post_id'] ) && isset( $_POST['step_id'] ) ) {
|
328 |
+
$flow_id = intval( $_POST['post_id'] );
|
329 |
+
$step_id = intval( $_POST['step_id'] );
|
330 |
+
}
|
331 |
+
$result = array(
|
332 |
+
'status' => false,
|
333 |
+
/* translators: %s flow id */
|
334 |
+
'text' => sprintf( __( 'Step not deleted for flow - %s', 'cartflows' ), $flow_id ),
|
335 |
+
);
|
336 |
+
|
337 |
+
if ( ! $flow_id || ! $step_id ) {
|
338 |
+
wp_send_json( $result );
|
339 |
+
}
|
340 |
+
|
341 |
+
wp_delete_post( $step_id, true );
|
342 |
+
|
343 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
344 |
+
|
345 |
+
if ( ! is_array( $flow_steps ) ) {
|
346 |
+
wp_send_json( $result );
|
347 |
+
}
|
348 |
+
|
349 |
+
foreach ( $flow_steps as $index => $data ) {
|
350 |
+
|
351 |
+
if ( intval( $data['id'] ) === $step_id ) {
|
352 |
+
unset( $flow_steps[ $index ] );
|
353 |
+
break;
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
/* Set index order properly */
|
358 |
+
$flow_steps = array_merge( $flow_steps );
|
359 |
+
|
360 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
361 |
+
|
362 |
+
$result = array(
|
363 |
+
'status' => true,
|
364 |
+
/* translators: %s flow id */
|
365 |
+
'text' => sprintf( __( 'Step deleted for flow - %s', 'cartflows' ), $flow_id ),
|
366 |
+
);
|
367 |
+
|
368 |
+
wp_send_json( $result );
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Reorder step flow
|
373 |
+
*
|
374 |
+
* @since 1.0.0
|
375 |
+
*
|
376 |
+
* @return void
|
377 |
+
*/
|
378 |
+
public function cartflows_reorder_flow_steps() {
|
379 |
+
|
380 |
+
check_ajax_referer( 'wcf-reorder-flow-steps', 'security' );
|
381 |
+
|
382 |
+
if ( isset( $_POST['post_id'] ) && isset( $_POST['step_ids'] ) ) {
|
383 |
+
$flow_id = intval( $_POST['post_id'] );
|
384 |
+
$step_ids = array_map( 'intval', $_POST['step_ids'] );
|
385 |
+
}
|
386 |
+
$result = array(
|
387 |
+
'status' => false,
|
388 |
+
/* translators: %s flow id */
|
389 |
+
'text' => sprintf( __( 'Steps not sorted for flow - %s', 'cartflows' ), $flow_id ),
|
390 |
+
);
|
391 |
+
|
392 |
+
if ( ! $flow_id || ! is_array( $step_ids ) ) {
|
393 |
+
wp_send_json( $result );
|
394 |
+
}
|
395 |
+
|
396 |
+
$new_flow_steps = array();
|
397 |
+
|
398 |
+
foreach ( $step_ids as $index => $step_id ) {
|
399 |
+
|
400 |
+
$new_flow_steps[] = array(
|
401 |
+
'id' => intval( $step_id ),
|
402 |
+
'title' => get_the_title( $step_id ),
|
403 |
+
'type' => get_post_meta( $step_id, 'wcf-step-type', true ),
|
404 |
+
);
|
405 |
+
}
|
406 |
+
|
407 |
+
update_post_meta( $flow_id, 'wcf-steps', $new_flow_steps );
|
408 |
+
|
409 |
+
$result = array(
|
410 |
+
'status' => true,
|
411 |
+
/* translators: %s flow id */
|
412 |
+
'text' => sprintf( __( 'Steps sorted for flow - %s', 'cartflows' ), $flow_id ),
|
413 |
+
);
|
414 |
+
|
415 |
+
wp_send_json( $result );
|
416 |
+
}
|
417 |
+
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Load admin scripts
|
421 |
+
*
|
422 |
+
* @since 1.0.0
|
423 |
+
*
|
424 |
+
* @return void
|
425 |
+
*/
|
426 |
+
public function admin_scripts() {
|
427 |
+
|
428 |
+
global $pagenow;
|
429 |
+
global $post;
|
430 |
+
|
431 |
+
$screen = get_current_screen();
|
432 |
+
|
433 |
+
if ( ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) && CARTFLOWS_FLOW_POST_TYPE == $screen->post_type ) {
|
434 |
+
|
435 |
+
wp_enqueue_script(
|
436 |
+
'wcf-flow-meta',
|
437 |
+
CARTFLOWS_URL . 'admin/assets/js/flow-admin-edit.js',
|
438 |
+
array( 'jquery', 'jquery-ui-sortable' ),
|
439 |
+
CARTFLOWS_VER,
|
440 |
+
true
|
441 |
+
);
|
442 |
+
|
443 |
+
wp_enqueue_style( 'wcf-flow-meta', CARTFLOWS_URL . 'admin/assets/css/flow-admin-edit.css', '', CARTFLOWS_VER );
|
444 |
+
wp_style_add_data( 'wcf-flow-meta', 'rtl', 'replace' );
|
445 |
+
|
446 |
+
$localize = array(
|
447 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
448 |
+
);
|
449 |
+
|
450 |
+
wp_localize_script( 'jquery', 'cartflows', apply_filters( 'wcf_js_localize', $localize ) );
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Initialize meta box
|
456 |
+
*
|
457 |
+
* @since 1.0.0
|
458 |
+
*
|
459 |
+
* @return void
|
460 |
+
*/
|
461 |
+
public function init_metabox() {
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Fires after the title field.
|
465 |
+
*
|
466 |
+
* @param WP_Post $post Post object.
|
467 |
+
*/
|
468 |
+
add_action( 'add_meta_boxes', array( $this, 'settings_meta_box' ) );
|
469 |
+
add_action( 'edit_form_after_title', array( $this, 'setup_meta_box' ) );
|
470 |
+
add_action( 'save_post', array( $this, 'save_meta_box' ) );
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Is first time import?
|
475 |
+
*
|
476 |
+
* @param integer $post_id post ID.
|
477 |
+
* @return bool
|
478 |
+
*/
|
479 |
+
public function is_flow_imported( $post_id = 0 ) {
|
480 |
+
|
481 |
+
if ( 0 === $post_id ) {
|
482 |
+
$post_id = get_the_ID();
|
483 |
+
}
|
484 |
+
|
485 |
+
$steps = get_post_meta( $post_id, 'wcf-steps', true );
|
486 |
+
$choice = get_post_meta( $post_id, 'wcf-flow-choise', true );
|
487 |
+
|
488 |
+
if ( empty( $steps ) && 'import' === $choice ) {
|
489 |
+
return true;
|
490 |
+
}
|
491 |
+
|
492 |
+
return false;
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Setup meta box.
|
497 |
+
*
|
498 |
+
* @return void
|
499 |
+
*/
|
500 |
+
public function setup_meta_box() {
|
501 |
+
if ( ! Cartflows_Admin::is_flow_edit_admin() ) {
|
502 |
+
return;
|
503 |
+
}
|
504 |
+
|
505 |
+
/**
|
506 |
+
* Adding Add new step button to the top*/
|
507 |
+
echo $this->add_add_new_step_button();
|
508 |
+
|
509 |
+
$this->markup_meta_box();
|
510 |
+
|
511 |
+
$this->add_upgrade_to_pro_metabox();
|
512 |
+
}
|
513 |
+
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Add metabox when cartflows pro is not enabled.
|
517 |
+
*/
|
518 |
+
public function add_upgrade_to_pro_metabox() {
|
519 |
+
|
520 |
+
if ( ! _is_cartflows_pro() ) {
|
521 |
+
add_meta_box(
|
522 |
+
'wcf-upgrade-pro',
|
523 |
+
__( 'Analytics', 'cartflows' ),
|
524 |
+
array( $this, 'upgrade_to_pro' ),
|
525 |
+
CARTFLOWS_FLOW_POST_TYPE,
|
526 |
+
'side',
|
527 |
+
'high'
|
528 |
+
);
|
529 |
+
}
|
530 |
+
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Show Upgrade To Pro markup.
|
535 |
+
*/
|
536 |
+
public function upgrade_to_pro() {
|
537 |
+
|
538 |
+
echo '<div>';
|
539 |
+
/* translators: %s: link */
|
540 |
+
echo '<p><i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Analytics feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i></p>';
|
541 |
+
echo '<p><a target="_blank" href="https://cartflows.com/" class="button button-primary">' . __( 'Get Pro', 'cartflows' ) . '</a></p>';
|
542 |
+
echo '</div>';
|
543 |
+
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Settings meta box.
|
548 |
+
*
|
549 |
+
* @return void
|
550 |
+
*/
|
551 |
+
public function settings_meta_box() {
|
552 |
+
|
553 |
+
if ( CARTFLOWS_FLOW_POST_TYPE === get_post_type() ) {
|
554 |
+
|
555 |
+
/* No need of sandbox will delete it later */
|
556 |
+
add_meta_box(
|
557 |
+
'wcf-sandbox-settings', // Id.
|
558 |
+
__( 'Flow Settings', 'cartflows' ), // Title.
|
559 |
+
array( $this, 'sandbox_meta_box' ), // Callback.
|
560 |
+
CARTFLOWS_FLOW_POST_TYPE, // Post_type.
|
561 |
+
'side', // Context.
|
562 |
+
'high' // Priority.
|
563 |
+
);
|
564 |
+
|
565 |
+
do_action( 'cartflows_add_flow_metabox' );
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Metabox Markup
|
571 |
+
*
|
572 |
+
* @return void
|
573 |
+
*/
|
574 |
+
public function markup_meta_box() {
|
575 |
+
global $post;
|
576 |
+
|
577 |
+
wp_nonce_field( 'save-nonce-flow-meta', 'nonce-flow-meta' );
|
578 |
+
|
579 |
+
// Get defaults.
|
580 |
+
$meta = self::get_current_post_meta( $post->ID );
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Get options
|
584 |
+
*/
|
585 |
+
$updated_data = array(
|
586 |
+
'steps' => $meta['wcf-steps']['default'],
|
587 |
+
);
|
588 |
+
|
589 |
+
do_action( 'wcf_flow_settings_markup_before', $meta );
|
590 |
+
$this->page_header_tab( $updated_data );
|
591 |
+
do_action( 'wcf_flow_settings_markup_after', $meta );
|
592 |
+
}
|
593 |
+
|
594 |
+
/**
|
595 |
+
* Metabox Markup
|
596 |
+
*
|
597 |
+
* @param object $post Post object.
|
598 |
+
* @return void
|
599 |
+
*/
|
600 |
+
public function sandbox_meta_box( $post ) {
|
601 |
+
|
602 |
+
// Get defaults.
|
603 |
+
$meta = self::get_current_post_meta( $post->ID );
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Get options
|
607 |
+
*/
|
608 |
+
foreach ( $meta as $key => $value ) {
|
609 |
+
$updated_data[ $key ] = $meta[ $key ]['default'];
|
610 |
+
}
|
611 |
+
|
612 |
+
do_action( 'wcf_flow_sandbox_markup_before', $meta );
|
613 |
+
$this->sandbox_markup( $updated_data );
|
614 |
+
do_action( 'wcf_flow_sandbox_markup_after', $meta );
|
615 |
+
}
|
616 |
+
|
617 |
+
/**
|
618 |
+
* Page Header Tabs
|
619 |
+
*
|
620 |
+
* @param array $options Post meta.
|
621 |
+
* @return void
|
622 |
+
*/
|
623 |
+
public function page_header_tab( $options ) {
|
624 |
+
|
625 |
+
include_once CARTFLOWS_FLOW_DIR . 'view/meta-flow-steps.php';
|
626 |
+
}
|
627 |
+
|
628 |
+
/**
|
629 |
+
* Sandbox Markup
|
630 |
+
*
|
631 |
+
* @param array $options Post meta.
|
632 |
+
* @return void
|
633 |
+
*/
|
634 |
+
public function sandbox_markup( $options ) {
|
635 |
+
?>
|
636 |
+
<div class="wcf-flow-sandbox-table wcf-general-metabox-wrap widefat">
|
637 |
+
<div class="wcf-flow-sandbox-table-container">
|
638 |
+
<?php
|
639 |
+
echo wcf()->meta->get_checkbox_field(
|
640 |
+
array(
|
641 |
+
'name' => 'wcf-testing',
|
642 |
+
'value' => $options['wcf-testing'],
|
643 |
+
'after' => __( 'Enable Test Mode', 'cartflows' ),
|
644 |
+
)
|
645 |
+
);
|
646 |
+
|
647 |
+
echo wcf()->meta->get_description_field(
|
648 |
+
array(
|
649 |
+
'name' => 'wcf-testing-note',
|
650 |
+
'content' => __( 'If you are using WooCommerce plugin then test mode will add random products in your flow, so you can preview it easily while testing.', 'cartflows' ),
|
651 |
+
)
|
652 |
+
);
|
653 |
+
|
654 |
+
?>
|
655 |
+
</div>
|
656 |
+
</div>
|
657 |
+
<?php
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Keep the menu open when editing the flows.
|
662 |
+
* Highlights the wanted admin (sub-) menu items for the CPT.
|
663 |
+
*
|
664 |
+
* @since 1.0.0
|
665 |
+
*/
|
666 |
+
public function menu_highlight() {
|
667 |
+
global $parent_file, $submenu_file, $post_type;
|
668 |
+
if ( CARTFLOWS_FLOW_POST_TYPE == $post_type ) :
|
669 |
+
$parent_file = CARTFLOWS_SLUG;//phpcs:ignore
|
670 |
+
$submenu_file = 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE;//phpcs:ignore
|
671 |
+
endif;
|
672 |
+
}
|
673 |
+
|
674 |
+
/**
|
675 |
+
* Get metabox options
|
676 |
+
*
|
677 |
+
* @param int $post_id post id.
|
678 |
+
* @return array
|
679 |
+
*/
|
680 |
+
public static function get_meta_option( $post_id ) {
|
681 |
+
|
682 |
+
if ( null === self::$meta_option ) {
|
683 |
+
/**
|
684 |
+
* Set metabox options
|
685 |
+
*/
|
686 |
+
self::$meta_option = wcf()->options->get_flow_fields( $post_id );
|
687 |
+
}
|
688 |
+
|
689 |
+
return self::$meta_option;
|
690 |
+
}
|
691 |
+
|
692 |
+
/**
|
693 |
+
* Get metabox options
|
694 |
+
*
|
695 |
+
* @param int $post_id post ID.
|
696 |
+
* @return array
|
697 |
+
*/
|
698 |
+
public static function get_current_post_meta( $post_id ) {
|
699 |
+
|
700 |
+
$stored = get_post_meta( $post_id );
|
701 |
+
|
702 |
+
$default_meta = self::get_meta_option( $post_id );
|
703 |
+
|
704 |
+
// Set stored and override defaults.
|
705 |
+
foreach ( $stored as $key => $value ) {
|
706 |
+
if ( array_key_exists( $key, $default_meta ) ) {
|
707 |
+
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
|
708 |
+
} else {
|
709 |
+
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
|
710 |
+
}
|
711 |
+
}
|
712 |
+
|
713 |
+
return self::get_meta_option( $post_id );
|
714 |
+
}
|
715 |
+
|
716 |
+
/**
|
717 |
+
* Metabox Save
|
718 |
+
*
|
719 |
+
* @param number $post_id Post ID.
|
720 |
+
* @return void
|
721 |
+
*/
|
722 |
+
public function save_meta_box( $post_id ) {
|
723 |
+
|
724 |
+
// Checks save status.
|
725 |
+
$is_autosave = wp_is_post_autosave( $post_id );
|
726 |
+
$is_revision = wp_is_post_revision( $post_id );
|
727 |
+
|
728 |
+
$is_valid_nonce = ( isset( $_POST['nonce-flow-meta'] ) && wp_verify_nonce( wp_unslash( $_POST['nonce-flow-meta'] ), 'save-nonce-flow-meta' ) ) ? true : false;
|
729 |
+
|
730 |
+
// Exits script depending on save status.
|
731 |
+
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
732 |
+
return;
|
733 |
+
}
|
734 |
+
|
735 |
+
wcf()->options->save_flow_fields( $post_id );
|
736 |
+
}
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Localize variables in admin
|
740 |
+
*
|
741 |
+
* @param array $vars variables.
|
742 |
+
*/
|
743 |
+
public function localize_vars( $vars ) {
|
744 |
+
|
745 |
+
$ajax_actions = array(
|
746 |
+
'wcf_setup_default_steps',
|
747 |
+
'wcf_add_flow_step',
|
748 |
+
'wcf_delete_flow_step',
|
749 |
+
'wcf_reorder_flow_steps',
|
750 |
+
);
|
751 |
+
|
752 |
+
foreach ( $ajax_actions as $action ) {
|
753 |
+
|
754 |
+
$vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
|
755 |
+
}
|
756 |
+
|
757 |
+
return $vars;
|
758 |
+
}
|
759 |
+
|
760 |
+
/**
|
761 |
+
* Add New Step Button
|
762 |
+
*
|
763 |
+
* @return string
|
764 |
+
*/
|
765 |
+
public function add_add_new_step_button() {
|
766 |
+
$add_new_btn_markup = '<style>.wrap{ position:relative;}</style>';
|
767 |
+
$add_new_btn_markup .= "<div class='wcf-button-wrap'>";
|
768 |
+
$add_new_btn_markup .= "<button class='wcf-trigger-popup page-title-action'>";
|
769 |
+
$add_new_btn_markup .= esc_html__( 'Add New Step', 'cartflows' );
|
770 |
+
$add_new_btn_markup .= '</button>';
|
771 |
+
$add_new_btn_markup .= '</div>';
|
772 |
+
|
773 |
+
return $add_new_btn_markup;
|
774 |
+
}
|
775 |
+
}
|
776 |
+
|
777 |
+
/**
|
778 |
+
* Kicking this off by calling 'get_instance()' method
|
779 |
+
*/
|
780 |
+
Cartflows_Flow_Meta::get_instance();
|
modules/flow/classes/class-cartflows-flow-post-type.php
CHANGED
@@ -1,334 +1,334 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Flow post type
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Flow_Post_Type {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
add_action( 'init', array( $this, 'flow_post_type' ) );
|
39 |
-
add_action( 'admin_menu', array( $this, 'register_as_submenu' ), 100 );
|
40 |
-
add_action( 'do_meta_boxes', array( $this, 'wcf_change_metabox_position' ) );
|
41 |
-
|
42 |
-
add_filter( 'post_updated_messages', array( $this, 'custom_post_type_post_update_messages' ) );
|
43 |
-
|
44 |
-
add_filter( 'display_post_states', array( $this, 'add_cartflows_post_state' ), 15, 1 );
|
45 |
-
|
46 |
-
add_filter( 'hidden_meta_boxes', array( $this, 'display_flow_slug_meta_box' ), 10, 2 );
|
47 |
-
|
48 |
-
/* View Post URL */
|
49 |
-
add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 );
|
50 |
-
add_filter( 'preview_post_link', array( $this, 'preview_post_link' ), 10, 2 );
|
51 |
-
add_action( 'template_redirect', array( $this, 'redirect_to_step' ), 10 );
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Add CartFlows post status.
|
56 |
-
*
|
57 |
-
* @param array $post_states post data.
|
58 |
-
* @return array
|
59 |
-
*/
|
60 |
-
function add_cartflows_post_state( $post_states ) {
|
61 |
-
|
62 |
-
if ( isset( $_GET['post_type'] ) && CARTFLOWS_STEP_POST_TYPE == $_GET['post_type'] ) {
|
63 |
-
|
64 |
-
global $post;
|
65 |
-
|
66 |
-
$flow_id = get_post_meta( $post->ID, 'wcf-flow-id', true );
|
67 |
-
$flow_title = get_the_title( $flow_id );
|
68 |
-
|
69 |
-
$post_states['cartflows_step'] = '( ' . __( 'Flow: ', 'cartflows' ) . $flow_id . ' | ' . __( 'Name: ', 'cartflows' ) . $flow_title . ')';
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
return $post_states;
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Display slugdiv.
|
78 |
-
*
|
79 |
-
* @param array $hidden metaboxes.
|
80 |
-
* @param obj $screen screen.
|
81 |
-
* @return array
|
82 |
-
*/
|
83 |
-
function display_flow_slug_meta_box( $hidden, $screen ) {
|
84 |
-
$post_type = $screen->id;
|
85 |
-
if ( ! empty( $post_type ) && CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
|
86 |
-
$pos = array_search( 'slugdiv', $hidden );
|
87 |
-
unset( $hidden[ $pos ] );
|
88 |
-
}
|
89 |
-
|
90 |
-
return $hidden;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Create custom post type
|
95 |
-
*/
|
96 |
-
function flow_post_type() {
|
97 |
-
|
98 |
-
$labels = array(
|
99 |
-
'name' => esc_html_x( 'Flows', 'flow general name', 'cartflows' ),
|
100 |
-
'singular_name' => esc_html_x( 'Flow', 'flow singular name', 'cartflows' ),
|
101 |
-
'search_items' => esc_html__( 'Search Flows', 'cartflows' ),
|
102 |
-
'all_items' => esc_html__( 'All Flows', 'cartflows' ),
|
103 |
-
'edit_item' => esc_html__( 'Edit Flow', 'cartflows' ),
|
104 |
-
'view_item' => esc_html__( 'View Flow', 'cartflows' ),
|
105 |
-
'add_new' => esc_html__( 'Add New', 'cartflows' ),
|
106 |
-
'update_item' => esc_html__( 'Update Flow', 'cartflows' ),
|
107 |
-
'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
|
108 |
-
'new_item_name' => esc_html__( 'New Flow Name', 'cartflows' ),
|
109 |
-
);
|
110 |
-
|
111 |
-
$args = array(
|
112 |
-
'labels' => $labels,
|
113 |
-
'show_in_menu' => false,
|
114 |
-
'public' => false, // it's not public, not own permalink.
|
115 |
-
'publicly_queryable' => true, // you should be able to query it.
|
116 |
-
'show_ui' => true,
|
117 |
-
'query_var' => true,
|
118 |
-
'can_export' => true,
|
119 |
-
'show_in_admin_bar' => true,
|
120 |
-
'exclude_from_search' => true,
|
121 |
-
'has_archive' => false, // it shouldn't have archive page.
|
122 |
-
'rewrite' => false, // it shouldn't have rewrite rules.
|
123 |
-
'supports' => array( 'title', 'thumbnail', 'slug' ),
|
124 |
-
'capability_type' => 'post',
|
125 |
-
);
|
126 |
-
|
127 |
-
if ( false && ! _is_cartflows_pro() ) {
|
128 |
-
|
129 |
-
$flow_posts = get_posts(
|
130 |
-
array(
|
131 |
-
'posts_per_page' => 4,
|
132 |
-
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
133 |
-
'post_status' => array( 'publish', 'pending', 'draft', 'future', 'private', 'inherit', 'trash' ),
|
134 |
-
)
|
135 |
-
);
|
136 |
-
|
137 |
-
if ( is_array( $flow_posts ) ) {
|
138 |
-
|
139 |
-
$flow_count = count( $flow_posts );
|
140 |
-
|
141 |
-
if ( $flow_count > 3 || 3 === $flow_count ) {
|
142 |
-
|
143 |
-
$args['capabilities'] = array(
|
144 |
-
'create_posts' => 'do_not_allow',
|
145 |
-
);
|
146 |
-
$args['map_meta_cap'] = true;
|
147 |
-
}
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
register_post_type( CARTFLOWS_FLOW_POST_TYPE, $args );
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Change metabox position.
|
156 |
-
*/
|
157 |
-
function wcf_change_metabox_position() {
|
158 |
-
|
159 |
-
remove_meta_box( 'slugdiv', CARTFLOWS_FLOW_POST_TYPE, 'normal' );
|
160 |
-
add_meta_box( 'slugdiv', __( 'Slug', 'cartflows' ), 'post_slug_meta_box', CARTFLOWS_FLOW_POST_TYPE, 'side', 'high' );
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Add post raw actions
|
165 |
-
*
|
166 |
-
* @param array $actions actions.
|
167 |
-
* @param array $post post data.
|
168 |
-
* @return array
|
169 |
-
*/
|
170 |
-
function post_row_actions( $actions, $post ) {
|
171 |
-
|
172 |
-
$first_step = $this->get_first_step_url( $post );
|
173 |
-
|
174 |
-
if ( $first_step && isset( $actions['view'] ) ) {
|
175 |
-
|
176 |
-
$actions['view'] = '<a href="' . $first_step . '">' . __( 'View', 'cartflows' ) . '</a>';
|
177 |
-
}
|
178 |
-
|
179 |
-
return $actions;
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Returns previous post link
|
184 |
-
*
|
185 |
-
* @param string $prev_link previous link.
|
186 |
-
* @param array $post post data.
|
187 |
-
* @return string
|
188 |
-
*/
|
189 |
-
function preview_post_link( $prev_link, $post ) {
|
190 |
-
|
191 |
-
if ( $this->is_flow_post_type( $post ) ) {
|
192 |
-
|
193 |
-
$first_step = $this->get_first_step_url( $post );
|
194 |
-
|
195 |
-
if ( $first_step ) {
|
196 |
-
|
197 |
-
return $first_step;
|
198 |
-
}
|
199 |
-
|
200 |
-
return '';
|
201 |
-
}
|
202 |
-
|
203 |
-
return $prev_link;
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Check if post type is flow
|
208 |
-
*
|
209 |
-
* @param array $post post data.
|
210 |
-
* @return bool
|
211 |
-
*/
|
212 |
-
function is_flow_post_type( $post ) {
|
213 |
-
|
214 |
-
if ( isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
215 |
-
|
216 |
-
return true;
|
217 |
-
}
|
218 |
-
|
219 |
-
return false;
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Redirect to first step
|
224 |
-
*
|
225 |
-
* @return void
|
226 |
-
*/
|
227 |
-
function redirect_to_step() {
|
228 |
-
|
229 |
-
global $post;
|
230 |
-
|
231 |
-
$first_step = $this->get_first_step_url( $post );
|
232 |
-
|
233 |
-
if ( $first_step ) {
|
234 |
-
|
235 |
-
|
236 |
-
die;
|
237 |
-
}
|
238 |
-
}
|
239 |
-
|
240 |
-
/**
|
241 |
-
* Return first step URL
|
242 |
-
*
|
243 |
-
* @param array $post post data.
|
244 |
-
* @return bool
|
245 |
-
*/
|
246 |
-
function get_first_step_url( $post ) {
|
247 |
-
|
248 |
-
if ( $this->is_flow_post_type( $post ) ) {
|
249 |
-
|
250 |
-
$flow_id = $post->ID;
|
251 |
-
$title = $post->post_title;
|
252 |
-
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
253 |
-
|
254 |
-
if ( is_array( $steps ) && ! empty( $steps ) && isset( $steps[0]['id'] ) ) {
|
255 |
-
|
256 |
-
return get_permalink( $steps[0]['id'] );
|
257 |
-
}
|
258 |
-
}
|
259 |
-
|
260 |
-
return false;
|
261 |
-
}
|
262 |
-
|
263 |
-
/**
|
264 |
-
* Register the admin menu for Custom Layouts
|
265 |
-
*
|
266 |
-
* @since 1.0.0
|
267 |
-
* Moved the menu under Appearance -> Custom Layouts
|
268 |
-
public function register_admin_menu() {
|
269 |
-
add_submenu_page(
|
270 |
-
CARTFLOWS_SLUG,
|
271 |
-
__( 'Flows', 'wcf' ),
|
272 |
-
__( 'Flows', 'wcf' ),
|
273 |
-
'edit_pages',
|
274 |
-
'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE
|
275 |
-
);
|
276 |
-
}
|
277 |
-
*/
|
278 |
-
public function register_as_submenu() {
|
279 |
-
|
280 |
-
global $submenu;
|
281 |
-
|
282 |
-
$submenu[ CARTFLOWS_SLUG ][0] = array(
|
283 |
-
__( 'Flows', 'cartflows' ),
|
284 |
-
'edit_pages',
|
285 |
-
'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE,
|
286 |
-
);
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Add Update messages for any custom post type
|
291 |
-
*
|
292 |
-
* @param array $messages Array of default messages.
|
293 |
-
*/
|
294 |
-
function custom_post_type_post_update_messages( $messages ) {
|
295 |
-
|
296 |
-
$custom_post_type = get_post_type( get_the_ID() );
|
297 |
-
|
298 |
-
if ( CARTFLOWS_FLOW_POST_TYPE == $custom_post_type ) {
|
299 |
-
|
300 |
-
$obj = get_post_type_object( $custom_post_type );
|
301 |
-
$singular_name = $obj->labels->singular_name;
|
302 |
-
$messages[ $custom_post_type ] = array(
|
303 |
-
0 => '', // Unused. Messages start at index 1.
|
304 |
-
/* translators: %s: singular custom post type name */
|
305 |
-
1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
306 |
-
/* translators: %s: singular custom post type name */
|
307 |
-
2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
|
308 |
-
/* translators: %s: singular custom post type name */
|
309 |
-
3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
|
310 |
-
/* translators: %s: singular custom post type name */
|
311 |
-
4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
312 |
-
/* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
|
313 |
-
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
314 |
-
/* translators: %s: singular custom post type name */
|
315 |
-
6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
|
316 |
-
/* translators: %s: singular custom post type name */
|
317 |
-
7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
|
318 |
-
/* translators: %s: singular custom post type name */
|
319 |
-
8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
|
320 |
-
/* translators: %s: singular custom post type name */
|
321 |
-
9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
|
322 |
-
/* translators: %s: singular custom post type name */
|
323 |
-
10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
|
324 |
-
);
|
325 |
-
}
|
326 |
-
|
327 |
-
return $messages;
|
328 |
-
}
|
329 |
-
}
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Kicking this off by calling 'get_instance()' method
|
333 |
-
*/
|
334 |
-
Cartflows_Flow_Post_Type::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Flow post type
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Flow_Post_Type {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
add_action( 'init', array( $this, 'flow_post_type' ) );
|
39 |
+
add_action( 'admin_menu', array( $this, 'register_as_submenu' ), 100 );
|
40 |
+
add_action( 'do_meta_boxes', array( $this, 'wcf_change_metabox_position' ) );
|
41 |
+
|
42 |
+
add_filter( 'post_updated_messages', array( $this, 'custom_post_type_post_update_messages' ) );
|
43 |
+
|
44 |
+
add_filter( 'display_post_states', array( $this, 'add_cartflows_post_state' ), 15, 1 );
|
45 |
+
|
46 |
+
add_filter( 'hidden_meta_boxes', array( $this, 'display_flow_slug_meta_box' ), 10, 2 );
|
47 |
+
|
48 |
+
/* View Post URL */
|
49 |
+
add_filter( 'post_row_actions', array( $this, 'post_row_actions' ), 10, 2 );
|
50 |
+
add_filter( 'preview_post_link', array( $this, 'preview_post_link' ), 10, 2 );
|
51 |
+
add_action( 'template_redirect', array( $this, 'redirect_to_step' ), 10 );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Add CartFlows post status.
|
56 |
+
*
|
57 |
+
* @param array $post_states post data.
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
public function add_cartflows_post_state( $post_states ) {
|
61 |
+
|
62 |
+
if ( isset( $_GET['post_type'] ) && CARTFLOWS_STEP_POST_TYPE == $_GET['post_type'] ) {
|
63 |
+
|
64 |
+
global $post;
|
65 |
+
|
66 |
+
$flow_id = get_post_meta( $post->ID, 'wcf-flow-id', true );
|
67 |
+
$flow_title = get_the_title( $flow_id );
|
68 |
+
|
69 |
+
$post_states['cartflows_step'] = '( ' . __( 'Flow: ', 'cartflows' ) . $flow_id . ' | ' . __( 'Name: ', 'cartflows' ) . $flow_title . ')';
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
return $post_states;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Display slugdiv.
|
78 |
+
*
|
79 |
+
* @param array $hidden metaboxes.
|
80 |
+
* @param obj $screen screen.
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
+
public function display_flow_slug_meta_box( $hidden, $screen ) {
|
84 |
+
$post_type = $screen->id;
|
85 |
+
if ( ! empty( $post_type ) && CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
|
86 |
+
$pos = array_search( 'slugdiv', $hidden, true );
|
87 |
+
unset( $hidden[ $pos ] );
|
88 |
+
}
|
89 |
+
|
90 |
+
return $hidden;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Create custom post type
|
95 |
+
*/
|
96 |
+
public function flow_post_type() {
|
97 |
+
|
98 |
+
$labels = array(
|
99 |
+
'name' => esc_html_x( 'Flows', 'flow general name', 'cartflows' ),
|
100 |
+
'singular_name' => esc_html_x( 'Flow', 'flow singular name', 'cartflows' ),
|
101 |
+
'search_items' => esc_html__( 'Search Flows', 'cartflows' ),
|
102 |
+
'all_items' => esc_html__( 'All Flows', 'cartflows' ),
|
103 |
+
'edit_item' => esc_html__( 'Edit Flow', 'cartflows' ),
|
104 |
+
'view_item' => esc_html__( 'View Flow', 'cartflows' ),
|
105 |
+
'add_new' => esc_html__( 'Add New', 'cartflows' ),
|
106 |
+
'update_item' => esc_html__( 'Update Flow', 'cartflows' ),
|
107 |
+
'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
|
108 |
+
'new_item_name' => esc_html__( 'New Flow Name', 'cartflows' ),
|
109 |
+
);
|
110 |
+
|
111 |
+
$args = array(
|
112 |
+
'labels' => $labels,
|
113 |
+
'show_in_menu' => false,
|
114 |
+
'public' => false, // it's not public, not own permalink.
|
115 |
+
'publicly_queryable' => true, // you should be able to query it.
|
116 |
+
'show_ui' => true,
|
117 |
+
'query_var' => true,
|
118 |
+
'can_export' => true,
|
119 |
+
'show_in_admin_bar' => true,
|
120 |
+
'exclude_from_search' => true,
|
121 |
+
'has_archive' => false, // it shouldn't have archive page.
|
122 |
+
'rewrite' => false, // it shouldn't have rewrite rules.
|
123 |
+
'supports' => array( 'title', 'thumbnail', 'slug' ),
|
124 |
+
'capability_type' => 'post',
|
125 |
+
);
|
126 |
+
|
127 |
+
if ( false && ! _is_cartflows_pro() ) {
|
128 |
+
|
129 |
+
$flow_posts = get_posts(
|
130 |
+
array(
|
131 |
+
'posts_per_page' => 4,
|
132 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
133 |
+
'post_status' => array( 'publish', 'pending', 'draft', 'future', 'private', 'inherit', 'trash' ),
|
134 |
+
)
|
135 |
+
);
|
136 |
+
|
137 |
+
if ( is_array( $flow_posts ) ) {
|
138 |
+
|
139 |
+
$flow_count = count( $flow_posts );
|
140 |
+
|
141 |
+
if ( $flow_count > 3 || 3 === $flow_count ) {
|
142 |
+
|
143 |
+
$args['capabilities'] = array(
|
144 |
+
'create_posts' => 'do_not_allow',
|
145 |
+
);
|
146 |
+
$args['map_meta_cap'] = true;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
register_post_type( CARTFLOWS_FLOW_POST_TYPE, $args );
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Change metabox position.
|
156 |
+
*/
|
157 |
+
public function wcf_change_metabox_position() {
|
158 |
+
|
159 |
+
remove_meta_box( 'slugdiv', CARTFLOWS_FLOW_POST_TYPE, 'normal' );
|
160 |
+
add_meta_box( 'slugdiv', __( 'Slug', 'cartflows' ), 'post_slug_meta_box', CARTFLOWS_FLOW_POST_TYPE, 'side', 'high' );
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Add post raw actions
|
165 |
+
*
|
166 |
+
* @param array $actions actions.
|
167 |
+
* @param array $post post data.
|
168 |
+
* @return array
|
169 |
+
*/
|
170 |
+
public function post_row_actions( $actions, $post ) {
|
171 |
+
|
172 |
+
$first_step = $this->get_first_step_url( $post );
|
173 |
+
|
174 |
+
if ( $first_step && isset( $actions['view'] ) ) {
|
175 |
+
|
176 |
+
$actions['view'] = '<a href="' . $first_step . '">' . __( 'View', 'cartflows' ) . '</a>';
|
177 |
+
}
|
178 |
+
|
179 |
+
return $actions;
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Returns previous post link
|
184 |
+
*
|
185 |
+
* @param string $prev_link previous link.
|
186 |
+
* @param array $post post data.
|
187 |
+
* @return string
|
188 |
+
*/
|
189 |
+
public function preview_post_link( $prev_link, $post ) {
|
190 |
+
|
191 |
+
if ( $this->is_flow_post_type( $post ) ) {
|
192 |
+
|
193 |
+
$first_step = $this->get_first_step_url( $post );
|
194 |
+
|
195 |
+
if ( $first_step ) {
|
196 |
+
|
197 |
+
return $first_step;
|
198 |
+
}
|
199 |
+
|
200 |
+
return '';
|
201 |
+
}
|
202 |
+
|
203 |
+
return $prev_link;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Check if post type is flow
|
208 |
+
*
|
209 |
+
* @param array $post post data.
|
210 |
+
* @return bool
|
211 |
+
*/
|
212 |
+
public function is_flow_post_type( $post ) {
|
213 |
+
|
214 |
+
if ( isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
215 |
+
|
216 |
+
return true;
|
217 |
+
}
|
218 |
+
|
219 |
+
return false;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Redirect to first step
|
224 |
+
*
|
225 |
+
* @return void
|
226 |
+
*/
|
227 |
+
public function redirect_to_step() {
|
228 |
+
|
229 |
+
global $post;
|
230 |
+
|
231 |
+
$first_step = $this->get_first_step_url( $post );
|
232 |
+
|
233 |
+
if ( $first_step ) {
|
234 |
+
|
235 |
+
wp_safe_redirect( $first_step );
|
236 |
+
die;
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Return first step URL
|
242 |
+
*
|
243 |
+
* @param array $post post data.
|
244 |
+
* @return bool
|
245 |
+
*/
|
246 |
+
public function get_first_step_url( $post ) {
|
247 |
+
|
248 |
+
if ( $this->is_flow_post_type( $post ) ) {
|
249 |
+
|
250 |
+
$flow_id = $post->ID;
|
251 |
+
$title = $post->post_title;
|
252 |
+
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
253 |
+
|
254 |
+
if ( is_array( $steps ) && ! empty( $steps ) && isset( $steps[0]['id'] ) ) {
|
255 |
+
|
256 |
+
return get_permalink( $steps[0]['id'] );
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
return false;
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Register the admin menu for Custom Layouts
|
265 |
+
*
|
266 |
+
* @since 1.0.0
|
267 |
+
* Moved the menu under Appearance -> Custom Layouts
|
268 |
+
public function register_admin_menu() {
|
269 |
+
add_submenu_page(
|
270 |
+
CARTFLOWS_SLUG,
|
271 |
+
__( 'Flows', 'wcf' ),
|
272 |
+
__( 'Flows', 'wcf' ),
|
273 |
+
'edit_pages',
|
274 |
+
'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE
|
275 |
+
);
|
276 |
+
}
|
277 |
+
*/
|
278 |
+
public function register_as_submenu() {
|
279 |
+
|
280 |
+
global $submenu;
|
281 |
+
|
282 |
+
$submenu[ CARTFLOWS_SLUG ][0] = array( //phpcs:ignore
|
283 |
+
__( 'Flows', 'cartflows' ),
|
284 |
+
'edit_pages',
|
285 |
+
'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE,
|
286 |
+
);
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Add Update messages for any custom post type
|
291 |
+
*
|
292 |
+
* @param array $messages Array of default messages.
|
293 |
+
*/
|
294 |
+
public function custom_post_type_post_update_messages( $messages ) {
|
295 |
+
|
296 |
+
$custom_post_type = get_post_type( get_the_ID() );
|
297 |
+
|
298 |
+
if ( CARTFLOWS_FLOW_POST_TYPE == $custom_post_type ) {
|
299 |
+
|
300 |
+
$obj = get_post_type_object( $custom_post_type );
|
301 |
+
$singular_name = $obj->labels->singular_name;
|
302 |
+
$messages[ $custom_post_type ] = array(
|
303 |
+
0 => '', // Unused. Messages start at index 1.
|
304 |
+
/* translators: %s: singular custom post type name */
|
305 |
+
1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
306 |
+
/* translators: %s: singular custom post type name */
|
307 |
+
2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
|
308 |
+
/* translators: %s: singular custom post type name */
|
309 |
+
3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
|
310 |
+
/* translators: %s: singular custom post type name */
|
311 |
+
4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
312 |
+
/* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
|
313 |
+
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
314 |
+
/* translators: %s: singular custom post type name */
|
315 |
+
6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
|
316 |
+
/* translators: %s: singular custom post type name */
|
317 |
+
7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
|
318 |
+
/* translators: %s: singular custom post type name */
|
319 |
+
8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
|
320 |
+
/* translators: %s: singular custom post type name */
|
321 |
+
9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
|
322 |
+
/* translators: %s: singular custom post type name */
|
323 |
+
10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
|
324 |
+
);
|
325 |
+
}
|
326 |
+
|
327 |
+
return $messages;
|
328 |
+
}
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Kicking this off by calling 'get_instance()' method
|
333 |
+
*/
|
334 |
+
Cartflows_Flow_Post_Type::get_instance();
|
modules/flow/classes/class-cartflows-flow-shortcodes.php
CHANGED
@@ -1,173 +1,173 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Flow shortcodes
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Flow_Shortcodes {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
add_shortcode( 'cartflows_next_step_link', array( $this, 'next_step_link' ) );
|
39 |
-
|
40 |
-
add_shortcode( 'cartflows_navigation', array( $this, 'navigation_shortcode' ) );
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Returns next step link
|
45 |
-
*
|
46 |
-
* @param array $atts attributes.
|
47 |
-
* @return string
|
48 |
-
*/
|
49 |
-
function next_step_link( $atts ) {
|
50 |
-
|
51 |
-
global $post;
|
52 |
-
|
53 |
-
$output = '#';
|
54 |
-
|
55 |
-
if ( $post && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
56 |
-
|
57 |
-
$navigation = false;
|
58 |
-
|
59 |
-
$step_id = intval( $post->ID );
|
60 |
-
$flow_id = get_post_meta( $step_id, 'wcf-flow-id', true );
|
61 |
-
|
62 |
-
if ( ! $flow_id ) {
|
63 |
-
return $output;
|
64 |
-
}
|
65 |
-
|
66 |
-
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
67 |
-
|
68 |
-
if ( ! is_array( $steps ) || ( is_array( $steps ) && empty( $steps ) ) ) {
|
69 |
-
return $output;
|
70 |
-
}
|
71 |
-
|
72 |
-
foreach ( $steps as $i => $step ) {
|
73 |
-
|
74 |
-
if ( intval( $step['id'] ) === $step_id ) {
|
75 |
-
|
76 |
-
$next_i = $i + 1;
|
77 |
-
|
78 |
-
if ( isset( $steps[ $next_i ] ) ) {
|
79 |
-
$navigation = $steps[ $next_i ];
|
80 |
-
}
|
81 |
-
|
82 |
-
break;
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
if ( $navigation && is_array( $navigation ) ) {
|
87 |
-
|
88 |
-
$output = get_permalink( $navigation['id'] );
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
return $output;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Navigation shortcode callback
|
97 |
-
*
|
98 |
-
* @param array $atts attributes for shortcode.
|
99 |
-
* @return string
|
100 |
-
*/
|
101 |
-
function navigation_shortcode( $atts ) {
|
102 |
-
$atts = shortcode_atts(
|
103 |
-
array(
|
104 |
-
'label' => '',
|
105 |
-
'icon' => '',
|
106 |
-
'icon_position' => '',
|
107 |
-
),
|
108 |
-
$atts
|
109 |
-
);
|
110 |
-
|
111 |
-
global $post;
|
112 |
-
|
113 |
-
$output = '';
|
114 |
-
|
115 |
-
if ( $post && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
116 |
-
|
117 |
-
$navigation = false;
|
118 |
-
|
119 |
-
$step_id = intval( $post->ID );
|
120 |
-
$flow_id = get_post_meta( $step_id, 'wcf-flow-id', true );
|
121 |
-
|
122 |
-
if ( ! $flow_id ) {
|
123 |
-
return $output;
|
124 |
-
}
|
125 |
-
|
126 |
-
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
127 |
-
|
128 |
-
if ( ! is_array( $steps ) || ( is_array( $steps ) && empty( $steps ) ) ) {
|
129 |
-
return $output;
|
130 |
-
}
|
131 |
-
|
132 |
-
foreach ( $steps as $i => $step ) {
|
133 |
-
|
134 |
-
if ( intval( $step['id'] ) === $step_id ) {
|
135 |
-
|
136 |
-
$next_i = $i + 1;
|
137 |
-
|
138 |
-
if ( isset( $steps[ $next_i ] ) ) {
|
139 |
-
$navigation = $steps[ $next_i ];
|
140 |
-
}
|
141 |
-
|
142 |
-
break;
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
if ( $navigation && is_array( $navigation ) ) {
|
147 |
-
|
148 |
-
$label = ( '' != $atts['label'] ) ? $atts['label'] : __( 'Next Step', 'cartflows' );
|
149 |
-
$before = '';
|
150 |
-
$after = '';
|
151 |
-
|
152 |
-
if ( '' != $atts['icon'] ) {
|
153 |
-
if ( '' != $atts['icon_position'] ) {
|
154 |
-
if ( 'before' == $atts['icon_position'] ) {
|
155 |
-
$before = '<span class="wcf-nextstep-icon wcf-nextstep-icon-before"><i class="' . $atts['icon'] . '" aria-hidden="true"></i></span>';
|
156 |
-
} else {
|
157 |
-
$after = '<span class="wcf-nextstep-icon wcf-nextstep-icon-after"><i class="' . $atts['icon'] . '" aria-hidden="true"></i></span>';
|
158 |
-
}
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
$output = '<div><a target="_self" href="' . get_permalink( $navigation['id'] ) . '">' . $before . $label . $after . '</a></div>';
|
163 |
-
}
|
164 |
-
}
|
165 |
-
|
166 |
-
return $output;
|
167 |
-
}
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Kicking this off by calling 'get_instance()' method
|
172 |
-
*/
|
173 |
-
Cartflows_Flow_Shortcodes::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Flow shortcodes
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Flow_Shortcodes {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
add_shortcode( 'cartflows_next_step_link', array( $this, 'next_step_link' ) );
|
39 |
+
|
40 |
+
add_shortcode( 'cartflows_navigation', array( $this, 'navigation_shortcode' ) );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns next step link
|
45 |
+
*
|
46 |
+
* @param array $atts attributes.
|
47 |
+
* @return string
|
48 |
+
*/
|
49 |
+
public function next_step_link( $atts ) {
|
50 |
+
|
51 |
+
global $post;
|
52 |
+
|
53 |
+
$output = '#';
|
54 |
+
|
55 |
+
if ( $post && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
56 |
+
|
57 |
+
$navigation = false;
|
58 |
+
|
59 |
+
$step_id = intval( $post->ID );
|
60 |
+
$flow_id = get_post_meta( $step_id, 'wcf-flow-id', true );
|
61 |
+
|
62 |
+
if ( ! $flow_id ) {
|
63 |
+
return $output;
|
64 |
+
}
|
65 |
+
|
66 |
+
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
67 |
+
|
68 |
+
if ( ! is_array( $steps ) || ( is_array( $steps ) && empty( $steps ) ) ) {
|
69 |
+
return $output;
|
70 |
+
}
|
71 |
+
|
72 |
+
foreach ( $steps as $i => $step ) {
|
73 |
+
|
74 |
+
if ( intval( $step['id'] ) === $step_id ) {
|
75 |
+
|
76 |
+
$next_i = $i + 1;
|
77 |
+
|
78 |
+
if ( isset( $steps[ $next_i ] ) ) {
|
79 |
+
$navigation = $steps[ $next_i ];
|
80 |
+
}
|
81 |
+
|
82 |
+
break;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( $navigation && is_array( $navigation ) ) {
|
87 |
+
|
88 |
+
$output = get_permalink( $navigation['id'] );
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
return $output;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Navigation shortcode callback
|
97 |
+
*
|
98 |
+
* @param array $atts attributes for shortcode.
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
public function navigation_shortcode( $atts ) {
|
102 |
+
$atts = shortcode_atts(
|
103 |
+
array(
|
104 |
+
'label' => '',
|
105 |
+
'icon' => '',
|
106 |
+
'icon_position' => '',
|
107 |
+
),
|
108 |
+
$atts
|
109 |
+
);
|
110 |
+
|
111 |
+
global $post;
|
112 |
+
|
113 |
+
$output = '';
|
114 |
+
|
115 |
+
if ( $post && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
116 |
+
|
117 |
+
$navigation = false;
|
118 |
+
|
119 |
+
$step_id = intval( $post->ID );
|
120 |
+
$flow_id = get_post_meta( $step_id, 'wcf-flow-id', true );
|
121 |
+
|
122 |
+
if ( ! $flow_id ) {
|
123 |
+
return $output;
|
124 |
+
}
|
125 |
+
|
126 |
+
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
127 |
+
|
128 |
+
if ( ! is_array( $steps ) || ( is_array( $steps ) && empty( $steps ) ) ) {
|
129 |
+
return $output;
|
130 |
+
}
|
131 |
+
|
132 |
+
foreach ( $steps as $i => $step ) {
|
133 |
+
|
134 |
+
if ( intval( $step['id'] ) === $step_id ) {
|
135 |
+
|
136 |
+
$next_i = $i + 1;
|
137 |
+
|
138 |
+
if ( isset( $steps[ $next_i ] ) ) {
|
139 |
+
$navigation = $steps[ $next_i ];
|
140 |
+
}
|
141 |
+
|
142 |
+
break;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( $navigation && is_array( $navigation ) ) {
|
147 |
+
|
148 |
+
$label = ( '' != $atts['label'] ) ? $atts['label'] : __( 'Next Step', 'cartflows' );
|
149 |
+
$before = '';
|
150 |
+
$after = '';
|
151 |
+
|
152 |
+
if ( '' != $atts['icon'] ) {
|
153 |
+
if ( '' != $atts['icon_position'] ) {
|
154 |
+
if ( 'before' == $atts['icon_position'] ) {
|
155 |
+
$before = '<span class="wcf-nextstep-icon wcf-nextstep-icon-before"><i class="' . $atts['icon'] . '" aria-hidden="true"></i></span>';
|
156 |
+
} else {
|
157 |
+
$after = '<span class="wcf-nextstep-icon wcf-nextstep-icon-after"><i class="' . $atts['icon'] . '" aria-hidden="true"></i></span>';
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
$output = '<div><a target="_self" href="' . get_permalink( $navigation['id'] ) . '">' . $before . $label . $after . '</a></div>';
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
return $output;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Kicking this off by calling 'get_instance()' method
|
172 |
+
*/
|
173 |
+
Cartflows_Flow_Shortcodes::get_instance();
|
modules/flow/classes/class-cartflows-permalink.php
CHANGED
@@ -1,159 +1,159 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Step post type.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Permalink {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 );
|
39 |
-
add_action( 'init', array( $this, 'rewrite_step_rule' ) );
|
40 |
-
|
41 |
-
add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ), 20 );
|
42 |
-
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Modify permalink
|
47 |
-
*
|
48 |
-
* @param string $post_link post link.
|
49 |
-
* @param array $post post data.
|
50 |
-
* @param string $leavename leave name.
|
51 |
-
* @return string
|
52 |
-
*/
|
53 |
-
function post_type_permalinks( $post_link, $post, $leavename ) {
|
54 |
-
|
55 |
-
if ( isset( $post->post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) {
|
56 |
-
|
57 |
-
$flow_id = get_post_meta( $post->ID, 'wcf-flow-id', true );
|
58 |
-
$flow_name = get_post_field( 'post_name', $flow_id );
|
59 |
-
$cf_permalink = Cartflows_Helper::get_permalink_settings();
|
60 |
-
|
61 |
-
if ( isset( $cf_permalink['permalink_structure'] ) && ! empty( $cf_permalink['permalink_structure'] ) ) {
|
62 |
-
|
63 |
-
$search = array( 'cartflows_flow', '%flowname%', 'cartflows_step' );
|
64 |
-
$replace = array( $cf_permalink['permalink_flow_base'], $flow_name, $cf_permalink['permalink'] );
|
65 |
-
$post_link = str_replace( $search, $replace, $post_link );
|
66 |
-
} else {
|
67 |
-
|
68 |
-
// If elementor page preview, return post link as it is.
|
69 |
-
if ( isset( $_REQUEST['elementor-preview'] ) ) {
|
70 |
-
return $post_link;
|
71 |
-
}
|
72 |
-
|
73 |
-
$structure = get_option( 'permalink_structure' );
|
74 |
-
|
75 |
-
if ( '/%postname%/' === $structure ) {
|
76 |
-
|
77 |
-
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
|
78 |
-
|
79 |
-
}
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
return $post_link;
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Reqrite rules for acrtflows step.
|
88 |
-
*/
|
89 |
-
function rewrite_step_rule() {
|
90 |
-
|
91 |
-
$cf_permalink = Cartflows_Helper::get_permalink_settings();
|
92 |
-
|
93 |
-
if ( isset( $cf_permalink['permalink_structure'] ) ) {
|
94 |
-
switch ( $cf_permalink['permalink_structure'] ) {
|
95 |
-
case '/cartflows_flow/%flowname%/cartflows_step':
|
96 |
-
add_rewrite_rule( '^' . $cf_permalink['permalink_flow_base'] . '/([^/]*)/' . $cf_permalink['permalink'] . '/([^\/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' );
|
97 |
-
break;
|
98 |
-
|
99 |
-
case '/cartflows_flow/%flowname%':
|
100 |
-
add_rewrite_rule( '^' . $cf_permalink['permalink_flow_base'] . '/([^/]*)/([^/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' );
|
101 |
-
break;
|
102 |
-
|
103 |
-
case '/%flowname%/cartflows_step':
|
104 |
-
add_rewrite_rule( '([^/]*)/' . $cf_permalink['permalink'] . '/([^\/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' );
|
105 |
-
|
106 |
-
break;
|
107 |
-
|
108 |
-
default:
|
109 |
-
break;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Have WordPress match postname to any of our public post types.
|
117 |
-
* All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
|
118 |
-
* By default, WordPress only accounts for posts and pages where the slug is /post-name/.
|
119 |
-
*
|
120 |
-
* @param string $query query statement.
|
121 |
-
*/
|
122 |
-
function add_cpt_post_names_to_main_query( $query ) {
|
123 |
-
|
124 |
-
// Bail if this is not the main query.
|
125 |
-
if ( ! $query->is_main_query() ) {
|
126 |
-
return;
|
127 |
-
}
|
128 |
-
|
129 |
-
// Bail if this query doesn't match our very specific rewrite rule.
|
130 |
-
if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) {
|
131 |
-
return;
|
132 |
-
}
|
133 |
-
|
134 |
-
// Bail if we're not querying based on the post name.
|
135 |
-
if ( empty( $query->query['name'] ) ) {
|
136 |
-
return;
|
137 |
-
}
|
138 |
-
|
139 |
-
// Add cartflows step post type to existing post type array.
|
140 |
-
if ( isset( $query->query_vars['post_type'] ) && is_array( $query->query_vars['post_type'] ) ) {
|
141 |
-
|
142 |
-
$post_types = $query->query_vars['post_type'];
|
143 |
-
|
144 |
-
$post_types[] = CARTFLOWS_STEP_POST_TYPE;
|
145 |
-
|
146 |
-
$query->set( 'post_type', $post_types );
|
147 |
-
|
148 |
-
} else {
|
149 |
-
|
150 |
-
// Add CPT to the list of post types WP will include when it queries based on the post name.
|
151 |
-
$query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) );
|
152 |
-
}
|
153 |
-
}
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Kicking this off by calling 'get_instance()' method
|
158 |
-
*/
|
159 |
-
Cartflows_Permalink::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Step post type.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Permalink {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 );
|
39 |
+
add_action( 'init', array( $this, 'rewrite_step_rule' ) );
|
40 |
+
|
41 |
+
add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ), 20 );
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Modify permalink
|
47 |
+
*
|
48 |
+
* @param string $post_link post link.
|
49 |
+
* @param array $post post data.
|
50 |
+
* @param string $leavename leave name.
|
51 |
+
* @return string
|
52 |
+
*/
|
53 |
+
public function post_type_permalinks( $post_link, $post, $leavename ) {
|
54 |
+
|
55 |
+
if ( isset( $post->post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) {
|
56 |
+
|
57 |
+
$flow_id = get_post_meta( $post->ID, 'wcf-flow-id', true );
|
58 |
+
$flow_name = get_post_field( 'post_name', $flow_id );
|
59 |
+
$cf_permalink = Cartflows_Helper::get_permalink_settings();
|
60 |
+
|
61 |
+
if ( isset( $cf_permalink['permalink_structure'] ) && ! empty( $cf_permalink['permalink_structure'] ) ) {
|
62 |
+
|
63 |
+
$search = array( 'cartflows_flow', '%flowname%', 'cartflows_step' );
|
64 |
+
$replace = array( $cf_permalink['permalink_flow_base'], $flow_name, $cf_permalink['permalink'] );
|
65 |
+
$post_link = str_replace( $search, $replace, $post_link );
|
66 |
+
} else {
|
67 |
+
|
68 |
+
// If elementor page preview, return post link as it is.
|
69 |
+
if ( isset( $_REQUEST['elementor-preview'] ) ) {
|
70 |
+
return $post_link;
|
71 |
+
}
|
72 |
+
|
73 |
+
$structure = get_option( 'permalink_structure' );
|
74 |
+
|
75 |
+
if ( '/%postname%/' === $structure ) {
|
76 |
+
|
77 |
+
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
|
78 |
+
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
return $post_link;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Reqrite rules for acrtflows step.
|
88 |
+
*/
|
89 |
+
public function rewrite_step_rule() {
|
90 |
+
|
91 |
+
$cf_permalink = Cartflows_Helper::get_permalink_settings();
|
92 |
+
|
93 |
+
if ( isset( $cf_permalink['permalink_structure'] ) ) {
|
94 |
+
switch ( $cf_permalink['permalink_structure'] ) {
|
95 |
+
case '/cartflows_flow/%flowname%/cartflows_step':
|
96 |
+
add_rewrite_rule( '^' . $cf_permalink['permalink_flow_base'] . '/([^/]*)/' . $cf_permalink['permalink'] . '/([^\/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' );
|
97 |
+
break;
|
98 |
+
|
99 |
+
case '/cartflows_flow/%flowname%':
|
100 |
+
add_rewrite_rule( '^' . $cf_permalink['permalink_flow_base'] . '/([^/]*)/([^/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' );
|
101 |
+
break;
|
102 |
+
|
103 |
+
case '/%flowname%/cartflows_step':
|
104 |
+
add_rewrite_rule( '([^/]*)/' . $cf_permalink['permalink'] . '/([^\/]*)/?', 'index.php?cartflows_step=$matches[2]', 'top' );
|
105 |
+
|
106 |
+
break;
|
107 |
+
|
108 |
+
default:
|
109 |
+
break;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Have WordPress match postname to any of our public post types.
|
117 |
+
* All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
|
118 |
+
* By default, WordPress only accounts for posts and pages where the slug is /post-name/.
|
119 |
+
*
|
120 |
+
* @param string $query query statement.
|
121 |
+
*/
|
122 |
+
public function add_cpt_post_names_to_main_query( $query ) {
|
123 |
+
|
124 |
+
// Bail if this is not the main query.
|
125 |
+
if ( ! $query->is_main_query() ) {
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
|
129 |
+
// Bail if this query doesn't match our very specific rewrite rule.
|
130 |
+
if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) {
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
|
134 |
+
// Bail if we're not querying based on the post name.
|
135 |
+
if ( empty( $query->query['name'] ) ) {
|
136 |
+
return;
|
137 |
+
}
|
138 |
+
|
139 |
+
// Add cartflows step post type to existing post type array.
|
140 |
+
if ( isset( $query->query_vars['post_type'] ) && is_array( $query->query_vars['post_type'] ) ) {
|
141 |
+
|
142 |
+
$post_types = $query->query_vars['post_type'];
|
143 |
+
|
144 |
+
$post_types[] = CARTFLOWS_STEP_POST_TYPE;
|
145 |
+
|
146 |
+
$query->set( 'post_type', $post_types );
|
147 |
+
|
148 |
+
} else {
|
149 |
+
|
150 |
+
// Add CPT to the list of post types WP will include when it queries based on the post name.
|
151 |
+
$query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) );
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Kicking this off by calling 'get_instance()' method
|
158 |
+
*/
|
159 |
+
Cartflows_Permalink::get_instance();
|
modules/flow/classes/class-cartflows-step-post-type.php
CHANGED
@@ -1,468 +1,468 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Step post type.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Step_Post_Type {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Member Variable
|
25 |
-
*
|
26 |
-
* @var body_classes
|
27 |
-
*/
|
28 |
-
private $body_classes = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Initiator
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
if ( ! isset( self::$instance ) ) {
|
35 |
-
self::$instance = new self();
|
36 |
-
}
|
37 |
-
return self::$instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor
|
42 |
-
*/
|
43 |
-
public function __construct() {
|
44 |
-
|
45 |
-
add_action( 'init', array( $this, 'step_post_type' ) );
|
46 |
-
add_action( 'init', array( $this, 'add_wp_templates_support' ) );
|
47 |
-
add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
|
48 |
-
|
49 |
-
add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
|
50 |
-
|
51 |
-
add_filter( 'template_include', array( $this, 'load_page_template' ), 90 );
|
52 |
-
add_filter( 'template_redirect', array( $this, 'query_fix' ), 3 );
|
53 |
-
}
|
54 |
-
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Trys to load page.php for a header, footer or part theme layout.
|
58 |
-
*
|
59 |
-
* @since 1.0.0
|
60 |
-
* @param string $template The current template to be loaded.
|
61 |
-
* @return string
|
62 |
-
*/
|
63 |
-
function load_page_template( $template ) {
|
64 |
-
|
65 |
-
global $post;
|
66 |
-
|
67 |
-
if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Remove Next/Prev Navigation
|
71 |
-
* add_filter('next_post_link', '__return_empty_string');
|
72 |
-
* add_filter('previous_post_link', '__return_empty_string');
|
73 |
-
*
|
74 |
-
* $page = locate_template( array( 'page.php' ) );
|
75 |
-
*
|
76 |
-
* if ( ! empty( $page ) ) {
|
77 |
-
* return $page;
|
78 |
-
* }
|
79 |
-
*/
|
80 |
-
|
81 |
-
/* Remove Next / Previous Rel Link */
|
82 |
-
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
83 |
-
add_filter( 'next_post_rel_link', '__return_empty_string' );
|
84 |
-
add_filter( 'previous_post_rel_link', '__return_empty_string' );
|
85 |
-
|
86 |
-
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
87 |
-
|
88 |
-
$page_template = apply_filters( 'cartflows_page_template', $page_template );
|
89 |
-
|
90 |
-
$file = '';
|
91 |
-
|
92 |
-
switch ( $page_template ) {
|
93 |
-
|
94 |
-
case 'cartflows-default':
|
95 |
-
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
96 |
-
$this->body_classes[] = $page_template;
|
97 |
-
break;
|
98 |
-
case 'cartflows-canvas':
|
99 |
-
$file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
|
100 |
-
$this->body_classes[] = $page_template;
|
101 |
-
break;
|
102 |
-
default:
|
103 |
-
/**
|
104 |
-
* Remove Next/Prev Navigation
|
105 |
-
*/
|
106 |
-
add_filter( 'next_post_link', '__return_empty_string' );
|
107 |
-
add_filter( 'previous_post_link', '__return_empty_string' );
|
108 |
-
|
109 |
-
$page = locate_template( array( 'page.php' ) );
|
110 |
-
|
111 |
-
if ( ! empty( $page ) ) {
|
112 |
-
$file = $page;
|
113 |
-
}
|
114 |
-
|
115 |
-
break;
|
116 |
-
|
117 |
-
|
118 |
-
*
|
119 |
-
* $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
120 |
-
* $this->body_classes[] = 'cartflows-default';
|
121 |
-
* break;
|
122 |
-
*/
|
123 |
-
}
|
124 |
-
|
125 |
-
// Just to be safe, we check if the file exist first.
|
126 |
-
if ( file_exists( $file ) ) {
|
127 |
-
|
128 |
-
/* Add Body Class */
|
129 |
-
add_filter( 'body_class',
|
130 |
-
|
131 |
-
return $file;
|
132 |
-
} else {
|
133 |
-
echo $file;
|
134 |
-
}
|
135 |
-
}
|
136 |
-
|
137 |
-
return $template;
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Body classes.
|
142 |
-
*
|
143 |
-
* @since 1.0.0
|
144 |
-
* @param array $classes Body classes.
|
145 |
-
* @return array
|
146 |
-
*/
|
147 |
-
function body_class( $classes =
|
148 |
-
|
149 |
-
$classes = array_merge( $classes, $this->body_classes );
|
150 |
-
|
151 |
-
return $classes;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Create custom post type
|
156 |
-
*/
|
157 |
-
function step_post_type() {
|
158 |
-
|
159 |
-
$labels = array(
|
160 |
-
'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
|
161 |
-
'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
|
162 |
-
'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
|
163 |
-
'all_items' => esc_html__( 'All Steps', 'cartflows' ),
|
164 |
-
'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
|
165 |
-
'view_item' => esc_html__( 'View Step', 'cartflows' ),
|
166 |
-
'add_new' => esc_html__( 'Add New', 'cartflows' ),
|
167 |
-
'update_item' => esc_html__( 'Update Step', 'cartflows' ),
|
168 |
-
'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
|
169 |
-
'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
|
170 |
-
);
|
171 |
-
|
172 |
-
$permalink_settings = Cartflows_Helper::get_permalink_settings();
|
173 |
-
|
174 |
-
$args = array(
|
175 |
-
'labels' => $labels,
|
176 |
-
'public' => true,
|
177 |
-
'query_var' => true,
|
178 |
-
'can_export' => true,
|
179 |
-
'exclude_from_search' => true,
|
180 |
-
'show_ui' => true,
|
181 |
-
'show_in_menu' => false,
|
182 |
-
'show_in_admin_bar' => true,
|
183 |
-
'supports' => array( 'title', 'editor', 'elementor', 'revisions' ),
|
184 |
-
'capability_type' => 'post',
|
185 |
-
'capabilities' => array(
|
186 |
-
'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
|
187 |
-
),
|
188 |
-
'map_meta_cap' => true,
|
189 |
-
);
|
190 |
-
|
191 |
-
if ( isset( $permalink_settings['permalink_structure'] ) && ! empty( $permalink_settings['permalink_structure'] ) ) {
|
192 |
-
$args['rewrite'] = array(
|
193 |
-
'slug' => $permalink_settings['permalink_structure'],
|
194 |
-
'with_front' => false,
|
195 |
-
);
|
196 |
-
|
197 |
-
} elseif ( isset( $permalink_settings['permalink'] ) && ! empty( $permalink_settings['permalink'] ) ) {
|
198 |
-
|
199 |
-
$args['rewrite'] = array(
|
200 |
-
'slug' => $permalink_settings['permalink'],
|
201 |
-
'with_front' => false,
|
202 |
-
);
|
203 |
-
}
|
204 |
-
|
205 |
-
register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
|
206 |
-
|
207 |
-
// Step Type.
|
208 |
-
$args = array(
|
209 |
-
'label' => __( 'Step Type', 'cartflows' ),
|
210 |
-
'public' => false,
|
211 |
-
'rewrite' => false,
|
212 |
-
'hierarchical' => false,
|
213 |
-
);
|
214 |
-
|
215 |
-
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
|
216 |
-
|
217 |
-
// Step Flow.
|
218 |
-
$args = array(
|
219 |
-
'label' => __( 'Step Flow', 'cartflows' ),
|
220 |
-
'public' => false,
|
221 |
-
'rewrite' => false,
|
222 |
-
'hierarchical' => false,
|
223 |
-
);
|
224 |
-
|
225 |
-
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
|
226 |
-
|
227 |
-
if ( is_admin() ) {
|
228 |
-
/**
|
229 |
-
* Register 'Elementor' & 'Beaver Builder' site types.
|
230 |
-
*
|
231 |
-
* @see self::add_terms();
|
232 |
-
*/
|
233 |
-
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
234 |
-
|
235 |
-
$terms = array(
|
236 |
-
array(
|
237 |
-
'name' => __( 'Landing', 'cartflows' ),
|
238 |
-
'slug' => 'landing',
|
239 |
-
'args' => array(
|
240 |
-
'slug' => 'landing',
|
241 |
-
),
|
242 |
-
),
|
243 |
-
array(
|
244 |
-
'name' => __( 'Checkout (Woo)', 'cartflows' ),
|
245 |
-
'slug' => 'checkout',
|
246 |
-
'args' => array(
|
247 |
-
'slug' => 'checkout',
|
248 |
-
),
|
249 |
-
),
|
250 |
-
array(
|
251 |
-
'name' => __( 'Thank You (Woo)', 'cartflows' ),
|
252 |
-
'slug' => 'thankyou',
|
253 |
-
'args' => array(
|
254 |
-
'slug' => 'thankyou',
|
255 |
-
),
|
256 |
-
),
|
257 |
-
array(
|
258 |
-
'name' => __( 'Upsell (Woo)', 'cartflows' ),
|
259 |
-
'slug' => 'upsell',
|
260 |
-
'args' => array(
|
261 |
-
'slug' => 'upsell',
|
262 |
-
),
|
263 |
-
),
|
264 |
-
array(
|
265 |
-
'name' => __( 'Downsell (Woo)', 'cartflows' ),
|
266 |
-
'slug' => 'downsell',
|
267 |
-
'args' => array(
|
268 |
-
'slug' => 'downsell',
|
269 |
-
),
|
270 |
-
),
|
271 |
-
);
|
272 |
-
|
273 |
-
$this->add_terms( $taxonomy, $terms );
|
274 |
-
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Add WordPress templates.
|
280 |
-
*
|
281 |
-
* Adds Cartflows templates to steps
|
282 |
-
*
|
283 |
-
* @since 1.0.0
|
284 |
-
* @access public
|
285 |
-
*/
|
286 |
-
function add_wp_templates_support() {
|
287 |
-
add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Add page templates.
|
292 |
-
*
|
293 |
-
* @since 1.0.0
|
294 |
-
* @access public
|
295 |
-
*
|
296 |
-
* @param array $page_templates Array of page templates.
|
297 |
-
*
|
298 |
-
* @param object $wp_theme wp theme.
|
299 |
-
* @param object $post post.
|
300 |
-
*
|
301 |
-
* @return array Page templates.
|
302 |
-
*/
|
303 |
-
function add_page_templates( $page_templates, $wp_theme, $post ) {
|
304 |
-
|
305 |
-
$page_templates = array(
|
306 |
-
'cartflows-default' => _x( 'CartFlows — Boxed', 'cartflows' ),
|
307 |
-
'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
|
308 |
-
);
|
309 |
-
|
310 |
-
return $page_templates;
|
311 |
-
}
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Query fixe throwing error on 404 page due our post type changes.
|
317 |
-
* We are setting post_type as empty array to fix the issue.
|
318 |
-
* Ther error was throwing due to redirect_canonical function
|
319 |
-
* This fix is apply for 404 page only
|
320 |
-
*/
|
321 |
-
function query_fix() {
|
322 |
-
|
323 |
-
global $wp_query;
|
324 |
-
|
325 |
-
if ( $wp_query->is_404() ) {
|
326 |
-
$wp_query->set( 'post_type', array() );
|
327 |
-
}
|
328 |
-
}
|
329 |
-
|
330 |
-
/**
|
331 |
-
* Prevent slug duplicated
|
332 |
-
*
|
333 |
-
* @param string $slug post slug.
|
334 |
-
* @param int $post_ID post id.
|
335 |
-
* @param string $post_status post status.
|
336 |
-
* @param string $post_type post type.
|
337 |
-
* @param int $post_parent post parent id.
|
338 |
-
* @param string $original_slug original slug.
|
339 |
-
* @return string
|
340 |
-
*/
|
341 |
-
function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
342 |
-
|
343 |
-
$check_post_types = array(
|
344 |
-
'post',
|
345 |
-
'page',
|
346 |
-
CARTFLOWS_STEP_POST_TYPE,
|
347 |
-
);
|
348 |
-
|
349 |
-
if ( ! in_array( $post_type, $check_post_types ) ) {
|
350 |
-
return $slug;
|
351 |
-
}
|
352 |
-
|
353 |
-
if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
|
354 |
-
// Saving a post, check for duplicates in POST or PAGE post types.
|
355 |
-
$post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
|
356 |
-
$page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
|
357 |
-
|
358 |
-
if ( $post_match || $page_match ) {
|
359 |
-
$slug .= '-2';
|
360 |
-
}
|
361 |
-
} else {
|
362 |
-
|
363 |
-
// Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
|
364 |
-
$custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
|
365 |
-
|
366 |
-
if ( $custom_post_type_match ) {
|
367 |
-
$slug .= '-2';
|
368 |
-
}
|
369 |
-
}
|
370 |
-
|
371 |
-
return $slug;
|
372 |
-
}
|
373 |
-
|
374 |
-
/**
|
375 |
-
* Add Update messages for any custom post type
|
376 |
-
*
|
377 |
-
* @param array $messages Array of default messages.
|
378 |
-
*/
|
379 |
-
function post_update_messages( $messages ) {
|
380 |
-
|
381 |
-
$custom_post_type = get_post_type( get_the_ID() );
|
382 |
-
|
383 |
-
if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
|
384 |
-
|
385 |
-
$obj = get_post_type_object( $custom_post_type );
|
386 |
-
$singular_name = $obj->labels->singular_name;
|
387 |
-
$messages[ $custom_post_type ] = array(
|
388 |
-
0 => '', // Unused. Messages start at index 1.
|
389 |
-
/* translators: %s: singular custom post type name */
|
390 |
-
1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
391 |
-
/* translators: %s: singular custom post type name */
|
392 |
-
2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
|
393 |
-
/* translators: %s: singular custom post type name */
|
394 |
-
3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
|
395 |
-
/* translators: %s: singular custom post type name */
|
396 |
-
4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
397 |
-
/* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
|
398 |
-
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
399 |
-
/* translators: %s: singular custom post type name */
|
400 |
-
6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
|
401 |
-
/* translators: %s: singular custom post type name */
|
402 |
-
7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
|
403 |
-
/* translators: %s: singular custom post type name */
|
404 |
-
8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
|
405 |
-
/* translators: %s: singular custom post type name */
|
406 |
-
9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
|
407 |
-
/* translators: %s: singular custom post type name */
|
408 |
-
10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
|
409 |
-
);
|
410 |
-
}
|
411 |
-
|
412 |
-
return $messages;
|
413 |
-
}
|
414 |
-
|
415 |
-
/**
|
416 |
-
* Add Terms for Taxonomy.
|
417 |
-
*
|
418 |
-
* => Example.
|
419 |
-
*
|
420 |
-
* $taxonomy = '{taxonomy}';
|
421 |
-
* $terms = array(
|
422 |
-
* array(
|
423 |
-
* 'name' => 'Landing',
|
424 |
-
* 'slug' => 'landing',
|
425 |
-
* ),
|
426 |
-
* array(
|
427 |
-
* 'name' => 'Checkout',
|
428 |
-
* 'slug' => 'checkout',
|
429 |
-
* ),
|
430 |
-
* );
|
431 |
-
*
|
432 |
-
* self::add_terms( $taxonomy, $terms );
|
433 |
-
*
|
434 |
-
* @since 1.0.0
|
435 |
-
* @param string $taxonomy Taxonomy Name.
|
436 |
-
* @param array $terms Terms list.
|
437 |
-
* @return void
|
438 |
-
*/
|
439 |
-
function add_terms( $taxonomy = '', $terms = array() ) {
|
440 |
-
|
441 |
-
foreach ( $terms as $key => $term ) {
|
442 |
-
|
443 |
-
$term_exist = term_exists( $term['slug'], $taxonomy );
|
444 |
-
|
445 |
-
if ( empty( $term_exist ) ) {
|
446 |
-
|
447 |
-
/**
|
448 |
-
* Add additional args if passed from request.
|
449 |
-
*
|
450 |
-
* @see https://codex.wordpress.org/Function_Reference/wp_insert_term
|
451 |
-
*/
|
452 |
-
if ( array_key_exists( 'args', $term ) ) {
|
453 |
-
wp_insert_term( $term['name'], $taxonomy, $term['args'] );
|
454 |
-
} else {
|
455 |
-
|
456 |
-
$term['args'] = array( $term['slug'] );
|
457 |
-
|
458 |
-
wp_insert_term( $term['name'], $taxonomy, $term['args'] );
|
459 |
-
}
|
460 |
-
}
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
|
465 |
-
/**
|
466 |
-
* Kicking this off by calling 'get_instance()' method
|
467 |
-
*/
|
468 |
-
Cartflows_Step_Post_Type::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Step post type.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Step_Post_Type {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Member Variable
|
25 |
+
*
|
26 |
+
* @var body_classes
|
27 |
+
*/
|
28 |
+
private $body_classes = array();
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Initiator
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self();
|
36 |
+
}
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor
|
42 |
+
*/
|
43 |
+
public function __construct() {
|
44 |
+
|
45 |
+
add_action( 'init', array( $this, 'step_post_type' ) );
|
46 |
+
add_action( 'init', array( $this, 'add_wp_templates_support' ) );
|
47 |
+
add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
|
48 |
+
|
49 |
+
add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
|
50 |
+
|
51 |
+
add_filter( 'template_include', array( $this, 'load_page_template' ), 90 );
|
52 |
+
add_filter( 'template_redirect', array( $this, 'query_fix' ), 3 );
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Trys to load page.php for a header, footer or part theme layout.
|
58 |
+
*
|
59 |
+
* @since 1.0.0
|
60 |
+
* @param string $template The current template to be loaded.
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function load_page_template( $template ) {
|
64 |
+
|
65 |
+
global $post;
|
66 |
+
|
67 |
+
if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Remove Next/Prev Navigation
|
71 |
+
* add_filter('next_post_link', '__return_empty_string');
|
72 |
+
* add_filter('previous_post_link', '__return_empty_string');
|
73 |
+
*
|
74 |
+
* $page = locate_template( array( 'page.php' ) );
|
75 |
+
*
|
76 |
+
* if ( ! empty( $page ) ) {
|
77 |
+
* return $page;
|
78 |
+
* }
|
79 |
+
*/
|
80 |
+
|
81 |
+
/* Remove Next / Previous Rel Link */
|
82 |
+
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
83 |
+
add_filter( 'next_post_rel_link', '__return_empty_string' );
|
84 |
+
add_filter( 'previous_post_rel_link', '__return_empty_string' );
|
85 |
+
|
86 |
+
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
87 |
+
|
88 |
+
$page_template = apply_filters( 'cartflows_page_template', $page_template );
|
89 |
+
|
90 |
+
$file = '';
|
91 |
+
|
92 |
+
switch ( $page_template ) {
|
93 |
+
|
94 |
+
case 'cartflows-default':
|
95 |
+
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
96 |
+
$this->body_classes[] = $page_template;
|
97 |
+
break;
|
98 |
+
case 'cartflows-canvas':
|
99 |
+
$file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
|
100 |
+
$this->body_classes[] = $page_template;
|
101 |
+
break;
|
102 |
+
default:
|
103 |
+
/**
|
104 |
+
* Remove Next/Prev Navigation
|
105 |
+
*/
|
106 |
+
add_filter( 'next_post_link', '__return_empty_string' );
|
107 |
+
add_filter( 'previous_post_link', '__return_empty_string' );
|
108 |
+
|
109 |
+
$page = locate_template( array( 'page.php' ) );
|
110 |
+
|
111 |
+
if ( ! empty( $page ) ) {
|
112 |
+
$file = $page;
|
113 |
+
}
|
114 |
+
|
115 |
+
break;
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Default:
|
119 |
+
* $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
120 |
+
* $this->body_classes[] = 'cartflows-default';
|
121 |
+
* break;
|
122 |
+
*/
|
123 |
+
}
|
124 |
+
|
125 |
+
// Just to be safe, we check if the file exist first.
|
126 |
+
if ( file_exists( $file ) ) {
|
127 |
+
|
128 |
+
/* Add Body Class */
|
129 |
+
add_filter( 'body_class', array( $this, 'body_class' ) );
|
130 |
+
|
131 |
+
return $file;
|
132 |
+
} else {
|
133 |
+
echo $file;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
return $template;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Body classes.
|
142 |
+
*
|
143 |
+
* @since 1.0.0
|
144 |
+
* @param array $classes Body classes.
|
145 |
+
* @return array
|
146 |
+
*/
|
147 |
+
public function body_class( $classes = array() ) {
|
148 |
+
|
149 |
+
$classes = array_merge( $classes, $this->body_classes );
|
150 |
+
|
151 |
+
return $classes;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Create custom post type
|
156 |
+
*/
|
157 |
+
public function step_post_type() {
|
158 |
+
|
159 |
+
$labels = array(
|
160 |
+
'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
|
161 |
+
'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
|
162 |
+
'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
|
163 |
+
'all_items' => esc_html__( 'All Steps', 'cartflows' ),
|
164 |
+
'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
|
165 |
+
'view_item' => esc_html__( 'View Step', 'cartflows' ),
|
166 |
+
'add_new' => esc_html__( 'Add New', 'cartflows' ),
|
167 |
+
'update_item' => esc_html__( 'Update Step', 'cartflows' ),
|
168 |
+
'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
|
169 |
+
'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
|
170 |
+
);
|
171 |
+
|
172 |
+
$permalink_settings = Cartflows_Helper::get_permalink_settings();
|
173 |
+
|
174 |
+
$args = array(
|
175 |
+
'labels' => $labels,
|
176 |
+
'public' => true,
|
177 |
+
'query_var' => true,
|
178 |
+
'can_export' => true,
|
179 |
+
'exclude_from_search' => true,
|
180 |
+
'show_ui' => true,
|
181 |
+
'show_in_menu' => false,
|
182 |
+
'show_in_admin_bar' => true,
|
183 |
+
'supports' => array( 'title', 'editor', 'elementor', 'revisions' ),
|
184 |
+
'capability_type' => 'post',
|
185 |
+
'capabilities' => array(
|
186 |
+
'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
|
187 |
+
),
|
188 |
+
'map_meta_cap' => true,
|
189 |
+
);
|
190 |
+
|
191 |
+
if ( isset( $permalink_settings['permalink_structure'] ) && ! empty( $permalink_settings['permalink_structure'] ) ) {
|
192 |
+
$args['rewrite'] = array(
|
193 |
+
'slug' => $permalink_settings['permalink_structure'],
|
194 |
+
'with_front' => false,
|
195 |
+
);
|
196 |
+
|
197 |
+
} elseif ( isset( $permalink_settings['permalink'] ) && ! empty( $permalink_settings['permalink'] ) ) {
|
198 |
+
|
199 |
+
$args['rewrite'] = array(
|
200 |
+
'slug' => $permalink_settings['permalink'],
|
201 |
+
'with_front' => false,
|
202 |
+
);
|
203 |
+
}
|
204 |
+
|
205 |
+
register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
|
206 |
+
|
207 |
+
// Step Type.
|
208 |
+
$args = array(
|
209 |
+
'label' => __( 'Step Type', 'cartflows' ),
|
210 |
+
'public' => false,
|
211 |
+
'rewrite' => false,
|
212 |
+
'hierarchical' => false,
|
213 |
+
);
|
214 |
+
|
215 |
+
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
|
216 |
+
|
217 |
+
// Step Flow.
|
218 |
+
$args = array(
|
219 |
+
'label' => __( 'Step Flow', 'cartflows' ),
|
220 |
+
'public' => false,
|
221 |
+
'rewrite' => false,
|
222 |
+
'hierarchical' => false,
|
223 |
+
);
|
224 |
+
|
225 |
+
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
|
226 |
+
|
227 |
+
if ( is_admin() ) {
|
228 |
+
/**
|
229 |
+
* Register 'Elementor' & 'Beaver Builder' site types.
|
230 |
+
*
|
231 |
+
* @see self::add_terms();
|
232 |
+
*/
|
233 |
+
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
234 |
+
|
235 |
+
$terms = array(
|
236 |
+
array(
|
237 |
+
'name' => __( 'Landing', 'cartflows' ),
|
238 |
+
'slug' => 'landing',
|
239 |
+
'args' => array(
|
240 |
+
'slug' => 'landing',
|
241 |
+
),
|
242 |
+
),
|
243 |
+
array(
|
244 |
+
'name' => __( 'Checkout (Woo)', 'cartflows' ),
|
245 |
+
'slug' => 'checkout',
|
246 |
+
'args' => array(
|
247 |
+
'slug' => 'checkout',
|
248 |
+
),
|
249 |
+
),
|
250 |
+
array(
|
251 |
+
'name' => __( 'Thank You (Woo)', 'cartflows' ),
|
252 |
+
'slug' => 'thankyou',
|
253 |
+
'args' => array(
|
254 |
+
'slug' => 'thankyou',
|
255 |
+
),
|
256 |
+
),
|
257 |
+
array(
|
258 |
+
'name' => __( 'Upsell (Woo)', 'cartflows' ),
|
259 |
+
'slug' => 'upsell',
|
260 |
+
'args' => array(
|
261 |
+
'slug' => 'upsell',
|
262 |
+
),
|
263 |
+
),
|
264 |
+
array(
|
265 |
+
'name' => __( 'Downsell (Woo)', 'cartflows' ),
|
266 |
+
'slug' => 'downsell',
|
267 |
+
'args' => array(
|
268 |
+
'slug' => 'downsell',
|
269 |
+
),
|
270 |
+
),
|
271 |
+
);
|
272 |
+
|
273 |
+
$this->add_terms( $taxonomy, $terms );
|
274 |
+
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Add WordPress templates.
|
280 |
+
*
|
281 |
+
* Adds Cartflows templates to steps
|
282 |
+
*
|
283 |
+
* @since 1.0.0
|
284 |
+
* @access public
|
285 |
+
*/
|
286 |
+
public function add_wp_templates_support() {
|
287 |
+
add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Add page templates.
|
292 |
+
*
|
293 |
+
* @since 1.0.0
|
294 |
+
* @access public
|
295 |
+
*
|
296 |
+
* @param array $page_templates Array of page templates.
|
297 |
+
*
|
298 |
+
* @param object $wp_theme wp theme.
|
299 |
+
* @param object $post post.
|
300 |
+
*
|
301 |
+
* @return array Page templates.
|
302 |
+
*/
|
303 |
+
public function add_page_templates( $page_templates, $wp_theme, $post ) {
|
304 |
+
|
305 |
+
$page_templates = array(
|
306 |
+
'cartflows-default' => _x( 'CartFlows — Boxed', 'cartflows' ),
|
307 |
+
'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
|
308 |
+
);
|
309 |
+
|
310 |
+
return $page_templates;
|
311 |
+
}
|
312 |
+
|
313 |
+
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Query fixe throwing error on 404 page due our post type changes.
|
317 |
+
* We are setting post_type as empty array to fix the issue.
|
318 |
+
* Ther error was throwing due to redirect_canonical function
|
319 |
+
* This fix is apply for 404 page only
|
320 |
+
*/
|
321 |
+
public function query_fix() {
|
322 |
+
|
323 |
+
global $wp_query;
|
324 |
+
|
325 |
+
if ( $wp_query->is_404() ) {
|
326 |
+
$wp_query->set( 'post_type', array() );
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Prevent slug duplicated
|
332 |
+
*
|
333 |
+
* @param string $slug post slug.
|
334 |
+
* @param int $post_ID post id.
|
335 |
+
* @param string $post_status post status.
|
336 |
+
* @param string $post_type post type.
|
337 |
+
* @param int $post_parent post parent id.
|
338 |
+
* @param string $original_slug original slug.
|
339 |
+
* @return string
|
340 |
+
*/
|
341 |
+
public function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
342 |
+
|
343 |
+
$check_post_types = array(
|
344 |
+
'post',
|
345 |
+
'page',
|
346 |
+
CARTFLOWS_STEP_POST_TYPE,
|
347 |
+
);
|
348 |
+
|
349 |
+
if ( ! in_array( $post_type, $check_post_types, true ) ) {
|
350 |
+
return $slug;
|
351 |
+
}
|
352 |
+
|
353 |
+
if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
|
354 |
+
// Saving a post, check for duplicates in POST or PAGE post types.
|
355 |
+
$post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
|
356 |
+
$page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
|
357 |
+
|
358 |
+
if ( $post_match || $page_match ) {
|
359 |
+
$slug .= '-2';
|
360 |
+
}
|
361 |
+
} else {
|
362 |
+
|
363 |
+
// Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
|
364 |
+
$custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
|
365 |
+
|
366 |
+
if ( $custom_post_type_match ) {
|
367 |
+
$slug .= '-2';
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
return $slug;
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Add Update messages for any custom post type
|
376 |
+
*
|
377 |
+
* @param array $messages Array of default messages.
|
378 |
+
*/
|
379 |
+
public function post_update_messages( $messages ) {
|
380 |
+
|
381 |
+
$custom_post_type = get_post_type( get_the_ID() );
|
382 |
+
|
383 |
+
if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
|
384 |
+
|
385 |
+
$obj = get_post_type_object( $custom_post_type );
|
386 |
+
$singular_name = $obj->labels->singular_name;
|
387 |
+
$messages[ $custom_post_type ] = array(
|
388 |
+
0 => '', // Unused. Messages start at index 1.
|
389 |
+
/* translators: %s: singular custom post type name */
|
390 |
+
1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
391 |
+
/* translators: %s: singular custom post type name */
|
392 |
+
2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
|
393 |
+
/* translators: %s: singular custom post type name */
|
394 |
+
3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
|
395 |
+
/* translators: %s: singular custom post type name */
|
396 |
+
4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
397 |
+
/* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
|
398 |
+
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
399 |
+
/* translators: %s: singular custom post type name */
|
400 |
+
6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
|
401 |
+
/* translators: %s: singular custom post type name */
|
402 |
+
7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
|
403 |
+
/* translators: %s: singular custom post type name */
|
404 |
+
8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
|
405 |
+
/* translators: %s: singular custom post type name */
|
406 |
+
9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
|
407 |
+
/* translators: %s: singular custom post type name */
|
408 |
+
10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
|
409 |
+
);
|
410 |
+
}
|
411 |
+
|
412 |
+
return $messages;
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Add Terms for Taxonomy.
|
417 |
+
*
|
418 |
+
* => Example.
|
419 |
+
*
|
420 |
+
* $taxonomy = '{taxonomy}';
|
421 |
+
* $terms = array(
|
422 |
+
* array(
|
423 |
+
* 'name' => 'Landing',
|
424 |
+
* 'slug' => 'landing',
|
425 |
+
* ),
|
426 |
+
* array(
|
427 |
+
* 'name' => 'Checkout',
|
428 |
+
* 'slug' => 'checkout',
|
429 |
+
* ),
|
430 |
+
* );
|
431 |
+
*
|
432 |
+
* self::add_terms( $taxonomy, $terms );
|
433 |
+
*
|
434 |
+
* @since 1.0.0
|
435 |
+
* @param string $taxonomy Taxonomy Name.
|
436 |
+
* @param array $terms Terms list.
|
437 |
+
* @return void
|
438 |
+
*/
|
439 |
+
public function add_terms( $taxonomy = '', $terms = array() ) {
|
440 |
+
|
441 |
+
foreach ( $terms as $key => $term ) {
|
442 |
+
|
443 |
+
$term_exist = term_exists( $term['slug'], $taxonomy );
|
444 |
+
|
445 |
+
if ( empty( $term_exist ) ) {
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Add additional args if passed from request.
|
449 |
+
*
|
450 |
+
* @see https://codex.wordpress.org/Function_Reference/wp_insert_term
|
451 |
+
*/
|
452 |
+
if ( array_key_exists( 'args', $term ) ) {
|
453 |
+
wp_insert_term( $term['name'], $taxonomy, $term['args'] );
|
454 |
+
} else {
|
455 |
+
|
456 |
+
$term['args'] = array( $term['slug'] );
|
457 |
+
|
458 |
+
wp_insert_term( $term['name'], $taxonomy, $term['args'] );
|
459 |
+
}
|
460 |
+
}
|
461 |
+
}
|
462 |
+
}
|
463 |
+
}
|
464 |
+
|
465 |
+
/**
|
466 |
+
* Kicking this off by calling 'get_instance()' method
|
467 |
+
*/
|
468 |
+
Cartflows_Step_Post_Type::get_instance();
|
modules/landing/classes/class-cartflows-landing-markup.php
CHANGED
@@ -48,7 +48,7 @@ class Cartflows_Landing_Markup {
|
|
48 |
*
|
49 |
* @param array $output output.
|
50 |
*/
|
51 |
-
function wp_dropdown_pages( $output ) {
|
52 |
|
53 |
global $pagenow;
|
54 |
|
@@ -57,7 +57,7 @@ class Cartflows_Landing_Markup {
|
|
57 |
$args = array(
|
58 |
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
59 |
'numberposts' => 100,
|
60 |
-
'meta_query' => array(
|
61 |
'relation' => 'OR',
|
62 |
array(
|
63 |
'key' => 'wcf-step-type',
|
@@ -99,7 +99,7 @@ class Cartflows_Landing_Markup {
|
|
99 |
*
|
100 |
* @param string $query post query.
|
101 |
*/
|
102 |
-
function wcf_pre_get_posts( $query ) {
|
103 |
|
104 |
if ( $query->is_main_query() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
105 |
|
@@ -116,7 +116,7 @@ class Cartflows_Landing_Markup {
|
|
116 |
/**
|
117 |
* Redirect to homepage if landing page set as home page.
|
118 |
*/
|
119 |
-
function template_redirect() {
|
120 |
|
121 |
$compatibiliy = Cartflows_Compatibility::get_instance();
|
122 |
|
48 |
*
|
49 |
* @param array $output output.
|
50 |
*/
|
51 |
+
public function wp_dropdown_pages( $output ) {
|
52 |
|
53 |
global $pagenow;
|
54 |
|
57 |
$args = array(
|
58 |
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
59 |
'numberposts' => 100,
|
60 |
+
'meta_query' => array( //phpcs:ignore
|
61 |
'relation' => 'OR',
|
62 |
array(
|
63 |
'key' => 'wcf-step-type',
|
99 |
*
|
100 |
* @param string $query post query.
|
101 |
*/
|
102 |
+
public function wcf_pre_get_posts( $query ) {
|
103 |
|
104 |
if ( $query->is_main_query() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
105 |
|
116 |
/**
|
117 |
* Redirect to homepage if landing page set as home page.
|
118 |
*/
|
119 |
+
public function template_redirect() {
|
120 |
|
121 |
$compatibiliy = Cartflows_Compatibility::get_instance();
|
122 |
|
modules/landing/classes/class-cartflows-landing-meta.php
CHANGED
@@ -1,236 +1,235 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Landing post meta box
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Meta Boxes setup
|
10 |
-
*/
|
11 |
-
class Cartflows_Landing_Meta extends Cartflows_Meta {
|
12 |
-
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Instance
|
16 |
-
*
|
17 |
-
* @var $instance
|
18 |
-
*/
|
19 |
-
private static $instance;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Meta Option
|
23 |
-
*
|
24 |
-
* @var $meta_option
|
25 |
-
*/
|
26 |
-
private static $meta_option = null;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Initiator
|
30 |
-
*/
|
31 |
-
public static function get_instance() {
|
32 |
-
if ( ! isset( self::$instance ) ) {
|
33 |
-
self::$instance = new self();
|
34 |
-
}
|
35 |
-
|
36 |
-
return self::$instance;
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Constructor
|
41 |
-
*/
|
42 |
-
public function __construct() {
|
43 |
-
|
44 |
-
/* Init Metabox */
|
45 |
-
add_action( 'load-post.php', array( $this, 'init_metabox' ) );
|
46 |
-
add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Init Metabox
|
51 |
-
*/
|
52 |
-
public function init_metabox() {
|
53 |
-
|
54 |
-
add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) );
|
55 |
-
add_action( 'save_post', array( $this, 'save_meta_box' ) );
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Setup Metabox
|
60 |
-
*/
|
61 |
-
function setup_meta_box() {
|
62 |
-
|
63 |
-
if ( _is_wcf_landing_type() ) {
|
64 |
-
add_meta_box(
|
65 |
-
'wcf-ladning-settings', // Id.
|
66 |
-
__( 'Landing Page Settings', 'cartflows' ), // Title.
|
67 |
-
array( $this, 'landing_meta_box' ), // Callback.
|
68 |
-
wcf()->utils->get_step_post_type(), // Post_type.
|
69 |
-
'normal', // Context.
|
70 |
-
'high' // Priority.
|
71 |
-
);
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Landing Metabox Markup
|
77 |
-
*
|
78 |
-
* @param object $post Post object.
|
79 |
-
* @return void
|
80 |
-
*/
|
81 |
-
function landing_meta_box( $post ) {
|
82 |
-
|
83 |
-
wp_nonce_field( 'save-nonce-landing-step-meta', 'nonce-landing-step-meta' );
|
84 |
-
$stored = get_post_meta( $post->ID );
|
85 |
-
|
86 |
-
$checkout_meta = self::get_meta_option( $post->ID );
|
87 |
-
|
88 |
-
// Set stored and override defaults.
|
89 |
-
foreach ( $stored as $key => $value ) {
|
90 |
-
if ( array_key_exists( $key, $checkout_meta ) ) {
|
91 |
-
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
|
92 |
-
} else {
|
93 |
-
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
// Get defaults.
|
98 |
-
$meta = self::get_meta_option( $post->ID );
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Get options
|
102 |
-
*/
|
103 |
-
$landing_data = array();
|
104 |
-
foreach ( $meta as $key => $value ) {
|
105 |
-
|
106 |
-
$landing_data[ $key ] = $meta[ $key ]['default'];
|
107 |
-
}
|
108 |
-
|
109 |
-
do_action( 'wcf_landing_settings_markup_before', $meta );
|
110 |
-
$this->page_header_tab( $landing_data, $post->ID );
|
111 |
-
do_action( 'wcf_landing_settings_markup_after', $meta );
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Page Header Tabs
|
116 |
-
*
|
117 |
-
* @param array $options Post meta.
|
118 |
-
* @param int $post_id Post ID.
|
119 |
-
*/
|
120 |
-
function page_header_tab( $options, $post_id ) {
|
121 |
-
|
122 |
-
$active_tab = get_post_meta( $post_id, 'wcf_active_tab', true );
|
123 |
-
|
124 |
-
if ( empty( $active_tab ) ) {
|
125 |
-
$active_tab = 'wcf-landing-shortcodes';
|
126 |
-
}
|
127 |
-
|
128 |
-
$tabs = array(
|
129 |
-
array(
|
130 |
-
'title' => __( 'Shortcodes', 'cartflows' ),
|
131 |
-
'id' => 'wcf-landing-shortcodes',
|
132 |
-
'class' => 'wcf-landing-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
133 |
-
'icon' => 'dashicons-info',
|
134 |
-
),
|
135 |
-
array(
|
136 |
-
'title' => __( 'Custom Script', 'cartflows' ),
|
137 |
-
'id' => 'wcf-landing-custom-script-header',
|
138 |
-
'class' => 'wcf-landing-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
139 |
-
'icon' => 'dashicons-format-aside',
|
140 |
-
),
|
141 |
-
);
|
142 |
-
|
143 |
-
?>
|
144 |
-
<div class="wcf-landing-table wcf-metabox-wrap widefat">
|
145 |
-
<div class="wcf-table-container">
|
146 |
-
<div class="wcf-column-left">
|
147 |
-
<div class="wcf-tab-wrapper">
|
148 |
-
|
149 |
-
<?php foreach ( $tabs as $key => $tab ) { ?>
|
150 |
-
<div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
|
151 |
-
<span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
|
152 |
-
<span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
|
153 |
-
</div>
|
154 |
-
<?php } ?>
|
155 |
-
<input type="hidden" id="wcf_active_tab" name="wcf_active_tab" value="<?php echo esc_attr( $active_tab ); ?>" />
|
156 |
-
|
157 |
-
</div>
|
158 |
-
</div>
|
159 |
-
<div class="wcf-column-right">
|
160 |
-
<div class="wcf-landing-shortcodes wcf-tab-content active widefat">
|
161 |
-
<?php
|
162 |
-
|
163 |
-
$next_step_link = wcf()->utils->get_linking_url(
|
164 |
-
array( 'class' => 'wcf-next-step' )
|
165 |
-
);
|
166 |
-
|
167 |
-
echo wcf()->meta->get_shortcode_field(
|
168 |
-
array(
|
169 |
-
'label' => __( 'Next Step Link', 'cartflows' ),
|
170 |
-
'name' => 'wcf-next-step-link',
|
171 |
-
'content' => $next_step_link,
|
172 |
-
)
|
173 |
-
);
|
174 |
-
|
175 |
-
?>
|
176 |
-
</div>
|
177 |
-
|
178 |
-
<?php $this->tab_custom_script( $options, $post_id ); ?>
|
179 |
-
|
180 |
-
<?php $this->right_column_footer( $options, $post_id ); ?>
|
181 |
-
</div>
|
182 |
-
</div>
|
183 |
-
</div>
|
184 |
-
|
185 |
-
<?php
|
186 |
-
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Get metabox options
|
191 |
-
*
|
192 |
-
* @param int $post_id post ID.
|
193 |
-
* @return array
|
194 |
-
*/
|
195 |
-
public static function get_meta_option( $post_id ) {
|
196 |
-
|
197 |
-
if ( null === self::$meta_option ) {
|
198 |
-
/**
|
199 |
-
* Set metabox options
|
200 |
-
*
|
201 |
-
* @see http://php.net/manual/en/filter.filters.sanitize.php
|
202 |
-
*/
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
*
|
212 |
-
*
|
213 |
-
* @
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
$
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
Cartflows_Landing_Meta::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Landing post meta box
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Meta Boxes setup
|
10 |
+
*/
|
11 |
+
class Cartflows_Landing_Meta extends Cartflows_Meta {
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Instance
|
16 |
+
*
|
17 |
+
* @var $instance
|
18 |
+
*/
|
19 |
+
private static $instance;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Meta Option
|
23 |
+
*
|
24 |
+
* @var $meta_option
|
25 |
+
*/
|
26 |
+
private static $meta_option = null;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Initiator
|
30 |
+
*/
|
31 |
+
public static function get_instance() {
|
32 |
+
if ( ! isset( self::$instance ) ) {
|
33 |
+
self::$instance = new self();
|
34 |
+
}
|
35 |
+
|
36 |
+
return self::$instance;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Constructor
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
|
44 |
+
/* Init Metabox */
|
45 |
+
add_action( 'load-post.php', array( $this, 'init_metabox' ) );
|
46 |
+
add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Init Metabox
|
51 |
+
*/
|
52 |
+
public function init_metabox() {
|
53 |
+
|
54 |
+
add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) );
|
55 |
+
add_action( 'save_post', array( $this, 'save_meta_box' ) );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Setup Metabox
|
60 |
+
*/
|
61 |
+
public function setup_meta_box() {
|
62 |
+
|
63 |
+
if ( _is_wcf_landing_type() ) {
|
64 |
+
add_meta_box(
|
65 |
+
'wcf-ladning-settings', // Id.
|
66 |
+
__( 'Landing Page Settings', 'cartflows' ), // Title.
|
67 |
+
array( $this, 'landing_meta_box' ), // Callback.
|
68 |
+
wcf()->utils->get_step_post_type(), // Post_type.
|
69 |
+
'normal', // Context.
|
70 |
+
'high' // Priority.
|
71 |
+
);
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Landing Metabox Markup
|
77 |
+
*
|
78 |
+
* @param object $post Post object.
|
79 |
+
* @return void
|
80 |
+
*/
|
81 |
+
public function landing_meta_box( $post ) {
|
82 |
+
|
83 |
+
wp_nonce_field( 'save-nonce-landing-step-meta', 'nonce-landing-step-meta' );
|
84 |
+
$stored = get_post_meta( $post->ID );
|
85 |
+
|
86 |
+
$checkout_meta = self::get_meta_option( $post->ID );
|
87 |
+
|
88 |
+
// Set stored and override defaults.
|
89 |
+
foreach ( $stored as $key => $value ) {
|
90 |
+
if ( array_key_exists( $key, $checkout_meta ) ) {
|
91 |
+
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
|
92 |
+
} else {
|
93 |
+
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
// Get defaults.
|
98 |
+
$meta = self::get_meta_option( $post->ID );
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get options
|
102 |
+
*/
|
103 |
+
$landing_data = array();
|
104 |
+
foreach ( $meta as $key => $value ) {
|
105 |
+
|
106 |
+
$landing_data[ $key ] = $meta[ $key ]['default'];
|
107 |
+
}
|
108 |
+
|
109 |
+
do_action( 'wcf_landing_settings_markup_before', $meta );
|
110 |
+
$this->page_header_tab( $landing_data, $post->ID );
|
111 |
+
do_action( 'wcf_landing_settings_markup_after', $meta );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Page Header Tabs
|
116 |
+
*
|
117 |
+
* @param array $options Post meta.
|
118 |
+
* @param int $post_id Post ID.
|
119 |
+
*/
|
120 |
+
public function page_header_tab( $options, $post_id ) {
|
121 |
+
|
122 |
+
$active_tab = get_post_meta( $post_id, 'wcf_active_tab', true );
|
123 |
+
|
124 |
+
if ( empty( $active_tab ) ) {
|
125 |
+
$active_tab = 'wcf-landing-shortcodes';
|
126 |
+
}
|
127 |
+
|
128 |
+
$tabs = array(
|
129 |
+
array(
|
130 |
+
'title' => __( 'Shortcodes', 'cartflows' ),
|
131 |
+
'id' => 'wcf-landing-shortcodes',
|
132 |
+
'class' => 'wcf-landing-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
133 |
+
'icon' => 'dashicons-info',
|
134 |
+
),
|
135 |
+
array(
|
136 |
+
'title' => __( 'Custom Script', 'cartflows' ),
|
137 |
+
'id' => 'wcf-landing-custom-script-header',
|
138 |
+
'class' => 'wcf-landing-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
139 |
+
'icon' => 'dashicons-format-aside',
|
140 |
+
),
|
141 |
+
);
|
142 |
+
|
143 |
+
?>
|
144 |
+
<div class="wcf-landing-table wcf-metabox-wrap widefat">
|
145 |
+
<div class="wcf-table-container">
|
146 |
+
<div class="wcf-column-left">
|
147 |
+
<div class="wcf-tab-wrapper">
|
148 |
+
|
149 |
+
<?php foreach ( $tabs as $key => $tab ) { ?>
|
150 |
+
<div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
|
151 |
+
<span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
|
152 |
+
<span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
|
153 |
+
</div>
|
154 |
+
<?php } ?>
|
155 |
+
<input type="hidden" id="wcf_active_tab" name="wcf_active_tab" value="<?php echo esc_attr( $active_tab ); ?>" />
|
156 |
+
|
157 |
+
</div>
|
158 |
+
</div>
|
159 |
+
<div class="wcf-column-right">
|
160 |
+
<div class="wcf-landing-shortcodes wcf-tab-content active widefat">
|
161 |
+
<?php
|
162 |
+
|
163 |
+
$next_step_link = wcf()->utils->get_linking_url(
|
164 |
+
array( 'class' => 'wcf-next-step' )
|
165 |
+
);
|
166 |
+
|
167 |
+
echo wcf()->meta->get_shortcode_field(
|
168 |
+
array(
|
169 |
+
'label' => __( 'Next Step Link', 'cartflows' ),
|
170 |
+
'name' => 'wcf-next-step-link',
|
171 |
+
'content' => $next_step_link,
|
172 |
+
)
|
173 |
+
);
|
174 |
+
|
175 |
+
?>
|
176 |
+
</div>
|
177 |
+
|
178 |
+
<?php $this->tab_custom_script( $options, $post_id ); ?>
|
179 |
+
|
180 |
+
<?php $this->right_column_footer( $options, $post_id ); ?>
|
181 |
+
</div>
|
182 |
+
</div>
|
183 |
+
</div>
|
184 |
+
|
185 |
+
<?php
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Get metabox options
|
191 |
+
*
|
192 |
+
* @param int $post_id post ID.
|
193 |
+
* @return array
|
194 |
+
*/
|
195 |
+
public static function get_meta_option( $post_id ) {
|
196 |
+
|
197 |
+
if ( null === self::$meta_option ) {
|
198 |
+
/**
|
199 |
+
* Set metabox options
|
200 |
+
*
|
201 |
+
* @see http://php.net/manual/en/filter.filters.sanitize.php
|
202 |
+
*/
|
203 |
+
self::$meta_option = wcf()->options->get_landing_fields( $post_id );
|
204 |
+
}
|
205 |
+
|
206 |
+
return self::$meta_option;
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Metabox Save
|
211 |
+
*
|
212 |
+
* @param number $post_id Post ID.
|
213 |
+
* @return void
|
214 |
+
*/
|
215 |
+
public function save_meta_box( $post_id ) {
|
216 |
+
|
217 |
+
// Checks save status.
|
218 |
+
$is_autosave = wp_is_post_autosave( $post_id );
|
219 |
+
$is_revision = wp_is_post_revision( $post_id );
|
220 |
+
|
221 |
+
$is_valid_nonce = ( isset( $_POST['nonce-landing-step-meta'] ) && wp_verify_nonce( wp_unslash( $_POST['nonce-landing-step-meta'] ), 'save-nonce-landing-step-meta' ) ) ? true : false;
|
222 |
+
|
223 |
+
// Exits script depending on save status.
|
224 |
+
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
225 |
+
return;
|
226 |
+
}
|
227 |
+
|
228 |
+
wcf()->options->save_landing_fields( $post_id );
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Kicking this off by calling 'get_instance()' method
|
234 |
+
*/
|
235 |
+
Cartflows_Landing_Meta::get_instance();
|
|
modules/thankyou/classes/class-cartflows-thankyou-markup.php
CHANGED
@@ -1,296 +1,296 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Front end and markup
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Checkout Markup
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Thankyou_Markup {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var object instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
/* Downsell Shortcode */
|
39 |
-
add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );
|
40 |
-
|
41 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'thank_you_scripts' ), 21 );
|
42 |
-
|
43 |
-
add_action( 'woocommerce_is_order_received_page', array( $this, 'set_order_received_page' ) );
|
44 |
-
|
45 |
-
/* Set is checkout flag */
|
46 |
-
add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 );
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Order shortcode markup
|
51 |
-
*
|
52 |
-
* @param array $atts attributes.
|
53 |
-
* @since 1.0.0
|
54 |
-
*/
|
55 |
-
function cartflows_order_details_shortcode_markup( $atts ) {
|
56 |
-
|
57 |
-
$output = '';
|
58 |
-
|
59 |
-
if ( _is_wcf_thankyou_type() ) {
|
60 |
-
/* Remove order item link */
|
61 |
-
add_filter( 'woocommerce_order_item_permalink', '__return_false' );
|
62 |
-
|
63 |
-
if ( ! function_exists( 'wc_print_notices' ) ) {
|
64 |
-
|
65 |
-
$notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>';
|
66 |
-
$notice_out .= '<button onClick="location.reload()">' . __( 'Click Here to Reload', 'cartflows' ) . '</button>';
|
67 |
-
|
68 |
-
return $notice_out;
|
69 |
-
}
|
70 |
-
|
71 |
-
$order = false;
|
72 |
-
|
73 |
-
if ( ! isset( $_GET['wcf-order'] ) && wcf()->flow->is_flow_testmode() ) {
|
74 |
-
$args = array(
|
75 |
-
'limit' => 1,
|
76 |
-
'order' => 'DESC',
|
77 |
-
'post_type' => 'shop_order',
|
78 |
-
'status' => array( 'completed', 'processing' ),
|
79 |
-
);
|
80 |
-
|
81 |
-
$latest_order = wc_get_orders( $args );
|
82 |
-
|
83 |
-
$order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;
|
84 |
-
|
85 |
-
if ( $order_id > 0 ) {
|
86 |
-
$order = wc_get_order( $order_id );
|
87 |
-
|
88 |
-
if ( ! $order ) {
|
89 |
-
$order = false;
|
90 |
-
}
|
91 |
-
}
|
92 |
-
} else {
|
93 |
-
if ( ! isset( $_GET['wcf-order'] ) ) {
|
94 |
-
return '<p class="woocommerce-notice">Order not found. You cannot access this page directly.</p>';
|
95 |
-
}
|
96 |
-
|
97 |
-
// Get the order.
|
98 |
-
$order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] ) );
|
99 |
-
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) ) );
|
100 |
-
|
101 |
-
if ( $order_id > 0 ) {
|
102 |
-
$order = wc_get_order( $order_id );
|
103 |
-
|
104 |
-
if ( ! $order || $order->get_order_key() !== $order_key ) {
|
105 |
-
$order = false;
|
106 |
-
}
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
-
// Empty awaiting payment session.
|
111 |
-
unset( WC()->session->order_awaiting_payment );
|
112 |
-
|
113 |
-
if ( null !== WC()->session ) {
|
114 |
-
if ( ! isset( WC()->cart ) || '' === WC()->cart ) {
|
115 |
-
WC()->cart = new WC_Cart();
|
116 |
-
}
|
117 |
-
|
118 |
-
if ( ! WC()->cart->is_empty() ) {
|
119 |
-
// wc_empty_cart();
|
120 |
-
// Empty current cart.
|
121 |
-
WC()->cart->empty_cart( true );
|
122 |
-
|
123 |
-
wc_clear_notices();
|
124 |
-
}
|
125 |
-
|
126 |
-
wc_print_notices();
|
127 |
-
}
|
128 |
-
|
129 |
-
ob_start();
|
130 |
-
echo "<div class='wcf-thankyou-wrap'>";
|
131 |
-
wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
|
132 |
-
echo '</div>';
|
133 |
-
$output = ob_get_clean();
|
134 |
-
}
|
135 |
-
|
136 |
-
return $output;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Load Thank You scripts.
|
141 |
-
*
|
142 |
-
* @return void
|
143 |
-
*/
|
144 |
-
function thank_you_scripts() {
|
145 |
-
|
146 |
-
if ( _is_wcf_thankyou_type() ) {
|
147 |
-
do_action( 'cartflows_thank_you_scripts' );
|
148 |
-
|
149 |
-
$style = $this->generate_thank_you_style();
|
150 |
-
|
151 |
-
wp_add_inline_style( 'wcf-frontend-global', $style );
|
152 |
-
}
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Set thank you as a order received page.
|
157 |
-
*
|
158 |
-
* @param boolean $is_order_page order page.
|
159 |
-
* @return boolean
|
160 |
-
*/
|
161 |
-
function set_order_received_page( $is_order_page ) {
|
162 |
-
|
163 |
-
if ( _is_wcf_thankyou_type() ) {
|
164 |
-
$is_order_page = true;
|
165 |
-
}
|
166 |
-
|
167 |
-
return $is_order_page;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Generate Thank You Styles.
|
172 |
-
*
|
173 |
-
* @return string
|
174 |
-
*/
|
175 |
-
function generate_thank_you_style() {
|
176 |
-
|
177 |
-
global $post;
|
178 |
-
|
179 |
-
if ( _is_wcf_thankyou_type() ) {
|
180 |
-
$thank_you_id = $post->ID;
|
181 |
-
} else {
|
182 |
-
$thank_you_id = _get_wcf_thankyou_id( $post->post_content );
|
183 |
-
}
|
184 |
-
|
185 |
-
CartFlows_Font_Families::render_fonts( $thank_you_id );
|
186 |
-
|
187 |
-
$text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text-color' );
|
188 |
-
$text_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-family' );
|
189 |
-
$heading_text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-color' );
|
190 |
-
$heading_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-family' );
|
191 |
-
$heading_font_weight = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-wt' );
|
192 |
-
$container_width = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-container-width' );
|
193 |
-
$section_bg_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-section-bg-color' );
|
194 |
-
|
195 |
-
$show_order_review = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-overview-section' );
|
196 |
-
|
197 |
-
$show_order_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-details-section' );
|
198 |
-
|
199 |
-
$show_billing_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-billing-section' );
|
200 |
-
|
201 |
-
$show_shipping_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-shipping-section' );
|
202 |
-
|
203 |
-
$output = "
|
204 |
-
.wcf-thankyou-wrap{
|
205 |
-
color: {$text_color};
|
206 |
-
font-family: {$text_font_family};
|
207 |
-
max-width:{$container_width}px;
|
208 |
-
}
|
209 |
-
|
210 |
-
.woocommerce-order h2.woocommerce-column__title,
|
211 |
-
.woocommerce-order h2.woocommerce-order-details__title,
|
212 |
-
.woocommerce-order .woocommerce-thankyou-order-received,
|
213 |
-
.woocommerce-order-details h2,
|
214 |
-
.woocommerce-order h2.wc-bacs-bank-details-heading {
|
215 |
-
color: {$heading_text_color};
|
216 |
-
font-family: {$heading_font_family};
|
217 |
-
font-weight: {$heading_font_weight};
|
218 |
-
}
|
219 |
-
|
220 |
-
.woocommerce-order ul.order_details,
|
221 |
-
.woocommerce-order .woocommerce-order-details,
|
222 |
-
.woocommerce-order .woocommerce-customer-details,
|
223 |
-
.woocommerce-order .woocommerce-bacs-bank-details{
|
224 |
-
background-color: {$section_bg_color}
|
225 |
-
}
|
226 |
-
img.emoji, img.wp-smiley {}
|
227 |
-
";
|
228 |
-
|
229 |
-
if ( 'no' == $show_order_review ) {
|
230 |
-
$output .= '
|
231 |
-
.woocommerce-order ul.order_details{
|
232 |
-
display: none;
|
233 |
-
}
|
234 |
-
';
|
235 |
-
}
|
236 |
-
|
237 |
-
if ( 'no' == $show_order_details ) {
|
238 |
-
$output .= '
|
239 |
-
.woocommerce-order .woocommerce-order-details{
|
240 |
-
display: none;
|
241 |
-
}
|
242 |
-
';
|
243 |
-
}
|
244 |
-
|
245 |
-
if ( 'no' == $show_billing_details ) {
|
246 |
-
$output .= '
|
247 |
-
.woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
|
248 |
-
display: none;
|
249 |
-
}
|
250 |
-
';
|
251 |
-
}
|
252 |
-
|
253 |
-
if ( 'no' == $show_shipping_details ) {
|
254 |
-
$output .= '
|
255 |
-
.woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
|
256 |
-
display: none;
|
257 |
-
}
|
258 |
-
';
|
259 |
-
}
|
260 |
-
|
261 |
-
if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
|
262 |
-
$output .= '
|
263 |
-
.woocommerce-order .woocommerce-customer-details{
|
264 |
-
display: none;
|
265 |
-
}
|
266 |
-
';
|
267 |
-
}
|
268 |
-
|
269 |
-
return $output;
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Set as a checkout page if it is thank you page.
|
274 |
-
* Thank you page need to be set as a checkout page.
|
275 |
-
* Becauye ayment gateways will not load if it is not checkout.
|
276 |
-
*
|
277 |
-
* @param bool $is_checkout is checkout.
|
278 |
-
*
|
279 |
-
* @return bool
|
280 |
-
*/
|
281 |
-
function woo_checkout_flag( $is_checkout ) {
|
282 |
-
|
283 |
-
if ( ! is_admin() ) {
|
284 |
-
if ( _is_wcf_thankyou_type() ) {
|
285 |
-
$is_checkout = true;
|
286 |
-
}
|
287 |
-
}
|
288 |
-
|
289 |
-
return $is_checkout;
|
290 |
-
}
|
291 |
-
}
|
292 |
-
|
293 |
-
/**
|
294 |
-
* Kicking this off by calling 'get_instance()' method
|
295 |
-
*/
|
296 |
-
Cartflows_Thankyou_Markup::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Front end and markup
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Checkout Markup
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Thankyou_Markup {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var object instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
/* Downsell Shortcode */
|
39 |
+
add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );
|
40 |
+
|
41 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'thank_you_scripts' ), 21 );
|
42 |
+
|
43 |
+
add_action( 'woocommerce_is_order_received_page', array( $this, 'set_order_received_page' ) );
|
44 |
+
|
45 |
+
/* Set is checkout flag */
|
46 |
+
add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Order shortcode markup
|
51 |
+
*
|
52 |
+
* @param array $atts attributes.
|
53 |
+
* @since 1.0.0
|
54 |
+
*/
|
55 |
+
public function cartflows_order_details_shortcode_markup( $atts ) {
|
56 |
+
|
57 |
+
$output = '';
|
58 |
+
|
59 |
+
if ( _is_wcf_thankyou_type() ) {
|
60 |
+
/* Remove order item link */
|
61 |
+
add_filter( 'woocommerce_order_item_permalink', '__return_false' );
|
62 |
+
|
63 |
+
if ( ! function_exists( 'wc_print_notices' ) ) {
|
64 |
+
|
65 |
+
$notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>';
|
66 |
+
$notice_out .= '<button onClick="location.reload()">' . __( 'Click Here to Reload', 'cartflows' ) . '</button>';
|
67 |
+
|
68 |
+
return $notice_out;
|
69 |
+
}
|
70 |
+
|
71 |
+
$order = false;
|
72 |
+
|
73 |
+
if ( ! isset( $_GET['wcf-order'] ) && wcf()->flow->is_flow_testmode() ) {
|
74 |
+
$args = array(
|
75 |
+
'limit' => 1,
|
76 |
+
'order' => 'DESC',
|
77 |
+
'post_type' => 'shop_order',
|
78 |
+
'status' => array( 'completed', 'processing' ),
|
79 |
+
);
|
80 |
+
|
81 |
+
$latest_order = wc_get_orders( $args );
|
82 |
+
|
83 |
+
$order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;
|
84 |
+
|
85 |
+
if ( $order_id > 0 ) {
|
86 |
+
$order = wc_get_order( $order_id );
|
87 |
+
|
88 |
+
if ( ! $order ) {
|
89 |
+
$order = false;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
} else {
|
93 |
+
if ( ! isset( $_GET['wcf-order'] ) ) {
|
94 |
+
return '<p class="woocommerce-notice">Order not found. You cannot access this page directly.</p>';
|
95 |
+
}
|
96 |
+
|
97 |
+
// Get the order.
|
98 |
+
$order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] ) );
|
99 |
+
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) ) );
|
100 |
+
|
101 |
+
if ( $order_id > 0 ) {
|
102 |
+
$order = wc_get_order( $order_id );
|
103 |
+
|
104 |
+
if ( ! $order || $order->get_order_key() !== $order_key ) {
|
105 |
+
$order = false;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
// Empty awaiting payment session.
|
111 |
+
unset( WC()->session->order_awaiting_payment );
|
112 |
+
|
113 |
+
if ( null !== WC()->session ) {
|
114 |
+
if ( ! isset( WC()->cart ) || '' === WC()->cart ) {
|
115 |
+
WC()->cart = new WC_Cart();
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( ! WC()->cart->is_empty() ) {
|
119 |
+
// wc_empty_cart();
|
120 |
+
// Empty current cart.
|
121 |
+
WC()->cart->empty_cart( true );
|
122 |
+
|
123 |
+
wc_clear_notices();
|
124 |
+
}
|
125 |
+
|
126 |
+
wc_print_notices();
|
127 |
+
}
|
128 |
+
|
129 |
+
ob_start();
|
130 |
+
echo "<div class='wcf-thankyou-wrap'>";
|
131 |
+
wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
|
132 |
+
echo '</div>';
|
133 |
+
$output = ob_get_clean();
|
134 |
+
}
|
135 |
+
|
136 |
+
return $output;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Load Thank You scripts.
|
141 |
+
*
|
142 |
+
* @return void
|
143 |
+
*/
|
144 |
+
public function thank_you_scripts() {
|
145 |
+
|
146 |
+
if ( _is_wcf_thankyou_type() ) {
|
147 |
+
do_action( 'cartflows_thank_you_scripts' );
|
148 |
+
|
149 |
+
$style = $this->generate_thank_you_style();
|
150 |
+
|
151 |
+
wp_add_inline_style( 'wcf-frontend-global', $style );
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Set thank you as a order received page.
|
157 |
+
*
|
158 |
+
* @param boolean $is_order_page order page.
|
159 |
+
* @return boolean
|
160 |
+
*/
|
161 |
+
public function set_order_received_page( $is_order_page ) {
|
162 |
+
|
163 |
+
if ( _is_wcf_thankyou_type() ) {
|
164 |
+
$is_order_page = true;
|
165 |
+
}
|
166 |
+
|
167 |
+
return $is_order_page;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Generate Thank You Styles.
|
172 |
+
*
|
173 |
+
* @return string
|
174 |
+
*/
|
175 |
+
public function generate_thank_you_style() {
|
176 |
+
|
177 |
+
global $post;
|
178 |
+
|
179 |
+
if ( _is_wcf_thankyou_type() ) {
|
180 |
+
$thank_you_id = $post->ID;
|
181 |
+
} else {
|
182 |
+
$thank_you_id = _get_wcf_thankyou_id( $post->post_content );
|
183 |
+
}
|
184 |
+
|
185 |
+
CartFlows_Font_Families::render_fonts( $thank_you_id );
|
186 |
+
|
187 |
+
$text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text-color' );
|
188 |
+
$text_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-family' );
|
189 |
+
$heading_text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-color' );
|
190 |
+
$heading_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-family' );
|
191 |
+
$heading_font_weight = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-wt' );
|
192 |
+
$container_width = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-container-width' );
|
193 |
+
$section_bg_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-section-bg-color' );
|
194 |
+
|
195 |
+
$show_order_review = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-overview-section' );
|
196 |
+
|
197 |
+
$show_order_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-details-section' );
|
198 |
+
|
199 |
+
$show_billing_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-billing-section' );
|
200 |
+
|
201 |
+
$show_shipping_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-shipping-section' );
|
202 |
+
|
203 |
+
$output = "
|
204 |
+
.wcf-thankyou-wrap{
|
205 |
+
color: {$text_color};
|
206 |
+
font-family: {$text_font_family};
|
207 |
+
max-width:{$container_width}px;
|
208 |
+
}
|
209 |
+
|
210 |
+
.woocommerce-order h2.woocommerce-column__title,
|
211 |
+
.woocommerce-order h2.woocommerce-order-details__title,
|
212 |
+
.woocommerce-order .woocommerce-thankyou-order-received,
|
213 |
+
.woocommerce-order-details h2,
|
214 |
+
.woocommerce-order h2.wc-bacs-bank-details-heading {
|
215 |
+
color: {$heading_text_color};
|
216 |
+
font-family: {$heading_font_family};
|
217 |
+
font-weight: {$heading_font_weight};
|
218 |
+
}
|
219 |
+
|
220 |
+
.woocommerce-order ul.order_details,
|
221 |
+
.woocommerce-order .woocommerce-order-details,
|
222 |
+
.woocommerce-order .woocommerce-customer-details,
|
223 |
+
.woocommerce-order .woocommerce-bacs-bank-details{
|
224 |
+
background-color: {$section_bg_color}
|
225 |
+
}
|
226 |
+
img.emoji, img.wp-smiley {}
|
227 |
+
";
|
228 |
+
|
229 |
+
if ( 'no' == $show_order_review ) {
|
230 |
+
$output .= '
|
231 |
+
.woocommerce-order ul.order_details{
|
232 |
+
display: none;
|
233 |
+
}
|
234 |
+
';
|
235 |
+
}
|
236 |
+
|
237 |
+
if ( 'no' == $show_order_details ) {
|
238 |
+
$output .= '
|
239 |
+
.woocommerce-order .woocommerce-order-details{
|
240 |
+
display: none;
|
241 |
+
}
|
242 |
+
';
|
243 |
+
}
|
244 |
+
|
245 |
+
if ( 'no' == $show_billing_details ) {
|
246 |
+
$output .= '
|
247 |
+
.woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
|
248 |
+
display: none;
|
249 |
+
}
|
250 |
+
';
|
251 |
+
}
|
252 |
+
|
253 |
+
if ( 'no' == $show_shipping_details ) {
|
254 |
+
$output .= '
|
255 |
+
.woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
|
256 |
+
display: none;
|
257 |
+
}
|
258 |
+
';
|
259 |
+
}
|
260 |
+
|
261 |
+
if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
|
262 |
+
$output .= '
|
263 |
+
.woocommerce-order .woocommerce-customer-details{
|
264 |
+
display: none;
|
265 |
+
}
|
266 |
+
';
|
267 |
+
}
|
268 |
+
|
269 |
+
return $output;
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Set as a checkout page if it is thank you page.
|
274 |
+
* Thank you page need to be set as a checkout page.
|
275 |
+
* Becauye ayment gateways will not load if it is not checkout.
|
276 |
+
*
|
277 |
+
* @param bool $is_checkout is checkout.
|
278 |
+
*
|
279 |
+
* @return bool
|
280 |
+
*/
|
281 |
+
public function woo_checkout_flag( $is_checkout ) {
|
282 |
+
|
283 |
+
if ( ! is_admin() ) {
|
284 |
+
if ( _is_wcf_thankyou_type() ) {
|
285 |
+
$is_checkout = true;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
return $is_checkout;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Kicking this off by calling 'get_instance()' method
|
295 |
+
*/
|
296 |
+
Cartflows_Thankyou_Markup::get_instance();
|
modules/thankyou/classes/class-cartflows-thankyou-meta.php
CHANGED
@@ -1,371 +1,371 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Checkout post meta box
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Meta Boxes setup
|
10 |
-
*/
|
11 |
-
class Cartflows_Thankyou_Meta extends Cartflows_Meta {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Instance
|
15 |
-
*
|
16 |
-
* @var $instance
|
17 |
-
*/
|
18 |
-
private static $instance;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Meta Option
|
22 |
-
*
|
23 |
-
* @var $meta_option
|
24 |
-
*/
|
25 |
-
private static $meta_option = null;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Initiator
|
29 |
-
*/
|
30 |
-
public static function get_instance() {
|
31 |
-
if ( ! isset( self::$instance ) ) {
|
32 |
-
self::$instance = new self();
|
33 |
-
}
|
34 |
-
|
35 |
-
return self::$instance;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Constructor
|
40 |
-
*/
|
41 |
-
public function __construct() {
|
42 |
-
|
43 |
-
/* Init Metabox */
|
44 |
-
add_action( 'load-post.php', array( $this, 'init_metabox' ) );
|
45 |
-
add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Init Metabox
|
50 |
-
*/
|
51 |
-
public function init_metabox() {
|
52 |
-
|
53 |
-
add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) );
|
54 |
-
add_action( 'save_post', array( $this, 'save_meta_box' ) );
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Setup Metabox
|
59 |
-
*/
|
60 |
-
function setup_meta_box() {
|
61 |
-
|
62 |
-
if ( _is_wcf_thankyou_type() ) {
|
63 |
-
add_meta_box(
|
64 |
-
'wcf-thankyou-settings', // Id.
|
65 |
-
__( 'Thank You Page Settings', 'cartflows' ), // Title.
|
66 |
-
array( $this, 'markup_meta_box' ), // Callback.
|
67 |
-
wcf()->utils->get_step_post_type(), // Post_type.
|
68 |
-
'normal', // Context.
|
69 |
-
'high' // Priority.
|
70 |
-
);
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Metabox Markup
|
76 |
-
*
|
77 |
-
* @param object $post Post object.
|
78 |
-
* @return void
|
79 |
-
*/
|
80 |
-
function markup_meta_box( $post ) {
|
81 |
-
|
82 |
-
wp_nonce_field( 'save-nonce-thankyou-step-meta', 'nonce-thankyou-step-meta' );
|
83 |
-
$stored = get_post_meta( $post->ID );
|
84 |
-
|
85 |
-
$checkout_meta = self::get_meta_option( $post->ID );
|
86 |
-
|
87 |
-
// Set stored and override defaults.
|
88 |
-
foreach ( $stored as $key => $value ) {
|
89 |
-
if ( array_key_exists( $key, $checkout_meta ) ) {
|
90 |
-
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
|
91 |
-
} else {
|
92 |
-
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
// Get defaults.
|
97 |
-
$meta = self::get_meta_option( $post->ID );
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Get options
|
101 |
-
*/
|
102 |
-
$thankyou_data = array();
|
103 |
-
|
104 |
-
foreach ( $meta as $key => $value ) {
|
105 |
-
|
106 |
-
$thankyou_data[ $key ] = $meta[ $key ]['default'];
|
107 |
-
}
|
108 |
-
|
109 |
-
do_action( 'wcf_thankyou_settings_markup_before', $meta );
|
110 |
-
$this->page_header_tab( $thankyou_data, $post->ID );
|
111 |
-
do_action( 'wcf_thankyou_settings_markup_after', $meta );
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Page Header Tabs
|
116 |
-
*
|
117 |
-
* @param array $options Post meta.
|
118 |
-
* @param int $post_id Post ID.
|
119 |
-
*/
|
120 |
-
function page_header_tab( $options, $post_id ) {
|
121 |
-
|
122 |
-
$active_tab = get_post_meta( $post_id, 'wcf-active-tab', true );
|
123 |
-
|
124 |
-
if ( empty( $active_tab ) ) {
|
125 |
-
$active_tab = 'wcf-thankyou-shortcodes';
|
126 |
-
}
|
127 |
-
|
128 |
-
$tabs = array(
|
129 |
-
array(
|
130 |
-
'title' => __( 'Shortcodes', 'cartflows' ),
|
131 |
-
'id' => 'wcf-thankyou-shortcodes',
|
132 |
-
'class' => 'wcf-thankyou-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
133 |
-
'icon' => 'dashicons-editor-code',
|
134 |
-
),
|
135 |
-
array(
|
136 |
-
'title' => __( 'Thank You Design', 'cartflows' ),
|
137 |
-
'id' => 'wcf-thankyou-design',
|
138 |
-
'class' => 'wcf-thankyou-design' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
139 |
-
'icon' => 'dashicons-admin-customizer',
|
140 |
-
),
|
141 |
-
array(
|
142 |
-
'title' => __( 'Thank You Fields', 'cartflows' ),
|
143 |
-
'id' => 'wcf-thankyou-fields',
|
144 |
-
'class' => 'wcf-thankyou-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
145 |
-
'icon' => 'dashicons-welcome-widgets-menus',
|
146 |
-
),
|
147 |
-
array(
|
148 |
-
'title' => __( 'Custom Script', 'cartflows' ),
|
149 |
-
'id' => 'wcf-thankyou-custom-script-header',
|
150 |
-
'class' => 'wcf-thankyou-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
151 |
-
'icon' => 'dashicons-format-aside',
|
152 |
-
),
|
153 |
-
);
|
154 |
-
|
155 |
-
?>
|
156 |
-
<div class="wcf-thankyou-table wcf-metabox-wrap widefat">
|
157 |
-
<div class="wcf-table-container">
|
158 |
-
<div class="wcf-column-left">
|
159 |
-
<div class="wcf-tab-wrapper">
|
160 |
-
|
161 |
-
<?php foreach ( $tabs as $key => $tab ) { ?>
|
162 |
-
<div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
|
163 |
-
<span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
|
164 |
-
<span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
|
165 |
-
</div>
|
166 |
-
<?php } ?>
|
167 |
-
<input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" />
|
168 |
-
|
169 |
-
</div>
|
170 |
-
</div>
|
171 |
-
<div class="wcf-column-right">
|
172 |
-
<div class="wcf-thankyou-shortcodes wcf-tab-content active widefat">
|
173 |
-
<?php
|
174 |
-
echo wcf()->meta->get_shortcode_field(
|
175 |
-
array(
|
176 |
-
'label' => __( 'Order Details', 'cartflows' ),
|
177 |
-
'name' => 'wcf-order-details',
|
178 |
-
'content' => esc_html( '[cartflows_order_details]' ),
|
179 |
-
)
|
180 |
-
);
|
181 |
-
?>
|
182 |
-
</div>
|
183 |
-
<div class="wcf-thankyou-design wcf-tab-content widefat">
|
184 |
-
<?php
|
185 |
-
|
186 |
-
echo wcf()->meta->get_section(
|
187 |
-
array(
|
188 |
-
'label' => __( 'Text', 'cartflows' ),
|
189 |
-
)
|
190 |
-
);
|
191 |
-
|
192 |
-
echo wcf()->meta->get_color_picker_field(
|
193 |
-
array(
|
194 |
-
'label' => __( 'Color', 'cartflows' ),
|
195 |
-
'name' => 'wcf-tq-text-color',
|
196 |
-
'value' => $options['wcf-tq-text-color'],
|
197 |
-
)
|
198 |
-
);
|
199 |
-
|
200 |
-
echo wcf()->meta->get_font_family_field(
|
201 |
-
array(
|
202 |
-
'for' => 'wcf-tq-font-family',
|
203 |
-
'label' => __( 'Font Family', 'cartflows' ),
|
204 |
-
'name' => 'wcf-tq-font-family',
|
205 |
-
'value' => $options['wcf-tq-font-family'],
|
206 |
-
)
|
207 |
-
);
|
208 |
-
|
209 |
-
echo wcf()->meta->get_section(
|
210 |
-
array(
|
211 |
-
'label' => __( 'Heading', 'cartflows' ),
|
212 |
-
)
|
213 |
-
);
|
214 |
-
|
215 |
-
echo wcf()->meta->get_color_picker_field(
|
216 |
-
array(
|
217 |
-
'label' => __( 'Color', 'cartflows' ),
|
218 |
-
'name' => 'wcf-tq-heading-color',
|
219 |
-
'value' => $options['wcf-tq-heading-color'],
|
220 |
-
)
|
221 |
-
);
|
222 |
-
|
223 |
-
echo wcf()->meta->get_font_family_field(
|
224 |
-
array(
|
225 |
-
'for' => 'wcf-tq-heading-font-family',
|
226 |
-
'label' => __( 'Font Family', 'cartflows' ),
|
227 |
-
'name' => 'wcf-tq-heading-font-family',
|
228 |
-
'value' => $options['wcf-tq-heading-font-family'],
|
229 |
-
)
|
230 |
-
);
|
231 |
-
|
232 |
-
echo wcf()->meta->get_font_weight_field(
|
233 |
-
array(
|
234 |
-
'for' => 'wcf-tq-heading-font-family',
|
235 |
-
'label' => __( 'Font Weight', 'cartflows' ),
|
236 |
-
'name' => 'wcf-tq-heading-font-wt',
|
237 |
-
'value' => $options['wcf-tq-heading-font-wt'],
|
238 |
-
)
|
239 |
-
);
|
240 |
-
|
241 |
-
echo wcf()->meta->get_checkbox_field(
|
242 |
-
array(
|
243 |
-
'label' => __( 'Advanced Options', 'cartflows' ),
|
244 |
-
'name' => 'wcf-tq-advance-options-fields',
|
245 |
-
'value' => $options['wcf-tq-advance-options-fields'],
|
246 |
-
'after' => 'Enable',
|
247 |
-
)
|
248 |
-
);
|
249 |
-
|
250 |
-
echo wcf()->meta->get_number_field(
|
251 |
-
array(
|
252 |
-
'for' => 'wcf-heading',
|
253 |
-
'label' => __( 'Container Width (In px)', 'cartflows' ),
|
254 |
-
'name' => 'wcf-tq-container-width',
|
255 |
-
'value' => $options['wcf-tq-container-width'],
|
256 |
-
)
|
257 |
-
);
|
258 |
-
|
259 |
-
echo wcf()->meta->get_color_picker_field(
|
260 |
-
array(
|
261 |
-
'label' => __( 'Section Background Color', 'cartflows' ),
|
262 |
-
'name' => 'wcf-tq-section-bg-color',
|
263 |
-
'value' => $options['wcf-tq-section-bg-color'],
|
264 |
-
)
|
265 |
-
);
|
266 |
-
|
267 |
-
?>
|
268 |
-
</div>
|
269 |
-
<div class="wcf-thankyou-fields wcf-tab-content widefat">
|
270 |
-
<?php
|
271 |
-
echo wcf()->meta->get_checkbox_field(
|
272 |
-
array(
|
273 |
-
'name' => 'wcf-show-overview-section',
|
274 |
-
'value' => $options['wcf-show-overview-section'],
|
275 |
-
'after' => __( 'Enable Order Overview ', 'cartflows' ),
|
276 |
-
)
|
277 |
-
);
|
278 |
-
|
279 |
-
echo wcf()->meta->get_checkbox_field(
|
280 |
-
array(
|
281 |
-
'name' => 'wcf-show-details-section',
|
282 |
-
'value' => $options['wcf-show-details-section'],
|
283 |
-
'after' => __( 'Enable Order Details ', 'cartflows' ),
|
284 |
-
)
|
285 |
-
);
|
286 |
-
|
287 |
-
echo wcf()->meta->get_checkbox_field(
|
288 |
-
array(
|
289 |
-
'name' => 'wcf-show-billing-section',
|
290 |
-
'value' => $options['wcf-show-billing-section'],
|
291 |
-
'after' => __( 'Enable Billing Details ', 'cartflows' ),
|
292 |
-
)
|
293 |
-
);
|
294 |
-
|
295 |
-
echo wcf()->meta->get_checkbox_field(
|
296 |
-
array(
|
297 |
-
'name' => 'wcf-show-shipping-section',
|
298 |
-
'value' => $options['wcf-show-shipping-section'],
|
299 |
-
'after' => __( 'Enable Shipping Details ', 'cartflows' ),
|
300 |
-
)
|
301 |
-
);
|
302 |
-
|
303 |
-
echo wcf()->meta->get_hidden_field(
|
304 |
-
array(
|
305 |
-
'name' => 'wcf-field-google-font-url',
|
306 |
-
'value' => $options['wcf-field-google-font-url'],
|
307 |
-
)
|
308 |
-
);
|
309 |
-
?>
|
310 |
-
</div>
|
311 |
-
|
312 |
-
<?php $this->tab_custom_script( $options, $post_id ); ?>
|
313 |
-
|
314 |
-
<?php $this->right_column_footer( $options, $post_id ); ?>
|
315 |
-
</div>
|
316 |
-
</div>
|
317 |
-
</div>
|
318 |
-
|
319 |
-
<?php
|
320 |
-
|
321 |
-
}
|
322 |
-
|
323 |
-
/**
|
324 |
-
* Get metabox options
|
325 |
-
*
|
326 |
-
* @param int $post_id post ID.
|
327 |
-
* @return array
|
328 |
-
*/
|
329 |
-
public static function get_meta_option( $post_id ) {
|
330 |
-
|
331 |
-
if ( null === self::$meta_option ) {
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Set metabox options
|
335 |
-
*
|
336 |
-
* @see http://php.net/manual/en/filter.filters.sanitize.php
|
337 |
-
*/
|
338 |
-
self::$meta_option = wcf()->options->get_thankyou_fields( $post_id );
|
339 |
-
}
|
340 |
-
|
341 |
-
return self::$meta_option;
|
342 |
-
|
343 |
-
}
|
344 |
-
|
345 |
-
/**
|
346 |
-
* Metabox Save
|
347 |
-
*
|
348 |
-
* @param number $post_id Post ID.
|
349 |
-
* @return void
|
350 |
-
*/
|
351 |
-
function save_meta_box( $post_id ) {
|
352 |
-
|
353 |
-
// Checks save status.
|
354 |
-
$is_autosave = wp_is_post_autosave( $post_id );
|
355 |
-
$is_revision = wp_is_post_revision( $post_id );
|
356 |
-
|
357 |
-
$is_valid_nonce = ( isset( $_POST['nonce-thankyou-step-meta'] ) && wp_verify_nonce( $_POST['nonce-thankyou-step-meta'], 'save-nonce-thankyou-step-meta' ) ) ? true : false;
|
358 |
-
|
359 |
-
// Exits script depending on save status.
|
360 |
-
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
361 |
-
return;
|
362 |
-
}
|
363 |
-
|
364 |
-
wcf()->options->save_thankyou_fields( $post_id );
|
365 |
-
}
|
366 |
-
}
|
367 |
-
|
368 |
-
/**
|
369 |
-
* Kicking this off by calling 'get_instance()' method
|
370 |
-
*/
|
371 |
-
Cartflows_Thankyou_Meta::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Checkout post meta box
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Meta Boxes setup
|
10 |
+
*/
|
11 |
+
class Cartflows_Thankyou_Meta extends Cartflows_Meta {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Instance
|
15 |
+
*
|
16 |
+
* @var $instance
|
17 |
+
*/
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Meta Option
|
22 |
+
*
|
23 |
+
* @var $meta_option
|
24 |
+
*/
|
25 |
+
private static $meta_option = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initiator
|
29 |
+
*/
|
30 |
+
public static function get_instance() {
|
31 |
+
if ( ! isset( self::$instance ) ) {
|
32 |
+
self::$instance = new self();
|
33 |
+
}
|
34 |
+
|
35 |
+
return self::$instance;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Constructor
|
40 |
+
*/
|
41 |
+
public function __construct() {
|
42 |
+
|
43 |
+
/* Init Metabox */
|
44 |
+
add_action( 'load-post.php', array( $this, 'init_metabox' ) );
|
45 |
+
add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Init Metabox
|
50 |
+
*/
|
51 |
+
public function init_metabox() {
|
52 |
+
|
53 |
+
add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) );
|
54 |
+
add_action( 'save_post', array( $this, 'save_meta_box' ) );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Setup Metabox
|
59 |
+
*/
|
60 |
+
public function setup_meta_box() {
|
61 |
+
|
62 |
+
if ( _is_wcf_thankyou_type() ) {
|
63 |
+
add_meta_box(
|
64 |
+
'wcf-thankyou-settings', // Id.
|
65 |
+
__( 'Thank You Page Settings', 'cartflows' ), // Title.
|
66 |
+
array( $this, 'markup_meta_box' ), // Callback.
|
67 |
+
wcf()->utils->get_step_post_type(), // Post_type.
|
68 |
+
'normal', // Context.
|
69 |
+
'high' // Priority.
|
70 |
+
);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Metabox Markup
|
76 |
+
*
|
77 |
+
* @param object $post Post object.
|
78 |
+
* @return void
|
79 |
+
*/
|
80 |
+
public function markup_meta_box( $post ) {
|
81 |
+
|
82 |
+
wp_nonce_field( 'save-nonce-thankyou-step-meta', 'nonce-thankyou-step-meta' );
|
83 |
+
$stored = get_post_meta( $post->ID );
|
84 |
+
|
85 |
+
$checkout_meta = self::get_meta_option( $post->ID );
|
86 |
+
|
87 |
+
// Set stored and override defaults.
|
88 |
+
foreach ( $stored as $key => $value ) {
|
89 |
+
if ( array_key_exists( $key, $checkout_meta ) ) {
|
90 |
+
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
|
91 |
+
} else {
|
92 |
+
self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
// Get defaults.
|
97 |
+
$meta = self::get_meta_option( $post->ID );
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Get options
|
101 |
+
*/
|
102 |
+
$thankyou_data = array();
|
103 |
+
|
104 |
+
foreach ( $meta as $key => $value ) {
|
105 |
+
|
106 |
+
$thankyou_data[ $key ] = $meta[ $key ]['default'];
|
107 |
+
}
|
108 |
+
|
109 |
+
do_action( 'wcf_thankyou_settings_markup_before', $meta );
|
110 |
+
$this->page_header_tab( $thankyou_data, $post->ID );
|
111 |
+
do_action( 'wcf_thankyou_settings_markup_after', $meta );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Page Header Tabs
|
116 |
+
*
|
117 |
+
* @param array $options Post meta.
|
118 |
+
* @param int $post_id Post ID.
|
119 |
+
*/
|
120 |
+
public function page_header_tab( $options, $post_id ) {
|
121 |
+
|
122 |
+
$active_tab = get_post_meta( $post_id, 'wcf-active-tab', true );
|
123 |
+
|
124 |
+
if ( empty( $active_tab ) ) {
|
125 |
+
$active_tab = 'wcf-thankyou-shortcodes';
|
126 |
+
}
|
127 |
+
|
128 |
+
$tabs = array(
|
129 |
+
array(
|
130 |
+
'title' => __( 'Shortcodes', 'cartflows' ),
|
131 |
+
'id' => 'wcf-thankyou-shortcodes',
|
132 |
+
'class' => 'wcf-thankyou-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
133 |
+
'icon' => 'dashicons-editor-code',
|
134 |
+
),
|
135 |
+
array(
|
136 |
+
'title' => __( 'Thank You Design', 'cartflows' ),
|
137 |
+
'id' => 'wcf-thankyou-design',
|
138 |
+
'class' => 'wcf-thankyou-design' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
139 |
+
'icon' => 'dashicons-admin-customizer',
|
140 |
+
),
|
141 |
+
array(
|
142 |
+
'title' => __( 'Thank You Fields', 'cartflows' ),
|
143 |
+
'id' => 'wcf-thankyou-fields',
|
144 |
+
'class' => 'wcf-thankyou-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
145 |
+
'icon' => 'dashicons-welcome-widgets-menus',
|
146 |
+
),
|
147 |
+
array(
|
148 |
+
'title' => __( 'Custom Script', 'cartflows' ),
|
149 |
+
'id' => 'wcf-thankyou-custom-script-header',
|
150 |
+
'class' => 'wcf-thankyou-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
151 |
+
'icon' => 'dashicons-format-aside',
|
152 |
+
),
|
153 |
+
);
|
154 |
+
|
155 |
+
?>
|
156 |
+
<div class="wcf-thankyou-table wcf-metabox-wrap widefat">
|
157 |
+
<div class="wcf-table-container">
|
158 |
+
<div class="wcf-column-left">
|
159 |
+
<div class="wcf-tab-wrapper">
|
160 |
+
|
161 |
+
<?php foreach ( $tabs as $key => $tab ) { ?>
|
162 |
+
<div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
|
163 |
+
<span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
|
164 |
+
<span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
|
165 |
+
</div>
|
166 |
+
<?php } ?>
|
167 |
+
<input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" />
|
168 |
+
|
169 |
+
</div>
|
170 |
+
</div>
|
171 |
+
<div class="wcf-column-right">
|
172 |
+
<div class="wcf-thankyou-shortcodes wcf-tab-content active widefat">
|
173 |
+
<?php
|
174 |
+
echo wcf()->meta->get_shortcode_field(
|
175 |
+
array(
|
176 |
+
'label' => __( 'Order Details', 'cartflows' ),
|
177 |
+
'name' => 'wcf-order-details',
|
178 |
+
'content' => esc_html( '[cartflows_order_details]' ),
|
179 |
+
)
|
180 |
+
);
|
181 |
+
?>
|
182 |
+
</div>
|
183 |
+
<div class="wcf-thankyou-design wcf-tab-content widefat">
|
184 |
+
<?php
|
185 |
+
|
186 |
+
echo wcf()->meta->get_section(
|
187 |
+
array(
|
188 |
+
'label' => __( 'Text', 'cartflows' ),
|
189 |
+
)
|
190 |
+
);
|
191 |
+
|
192 |
+
echo wcf()->meta->get_color_picker_field(
|
193 |
+
array(
|
194 |
+
'label' => __( 'Color', 'cartflows' ),
|
195 |
+
'name' => 'wcf-tq-text-color',
|
196 |
+
'value' => $options['wcf-tq-text-color'],
|
197 |
+
)
|
198 |
+
);
|
199 |
+
|
200 |
+
echo wcf()->meta->get_font_family_field(
|
201 |
+
array(
|
202 |
+
'for' => 'wcf-tq-font-family',
|
203 |
+
'label' => __( 'Font Family', 'cartflows' ),
|
204 |
+
'name' => 'wcf-tq-font-family',
|
205 |
+
'value' => $options['wcf-tq-font-family'],
|
206 |
+
)
|
207 |
+
);
|
208 |
+
|
209 |
+
echo wcf()->meta->get_section(
|
210 |
+
array(
|
211 |
+
'label' => __( 'Heading', 'cartflows' ),
|
212 |
+
)
|
213 |
+
);
|
214 |
+
|
215 |
+
echo wcf()->meta->get_color_picker_field(
|
216 |
+
array(
|
217 |
+
'label' => __( 'Color', 'cartflows' ),
|
218 |
+
'name' => 'wcf-tq-heading-color',
|
219 |
+
'value' => $options['wcf-tq-heading-color'],
|
220 |
+
)
|
221 |
+
);
|
222 |
+
|
223 |
+
echo wcf()->meta->get_font_family_field(
|
224 |
+
array(
|
225 |
+
'for' => 'wcf-tq-heading-font-family',
|
226 |
+
'label' => __( 'Font Family', 'cartflows' ),
|
227 |
+
'name' => 'wcf-tq-heading-font-family',
|
228 |
+
'value' => $options['wcf-tq-heading-font-family'],
|
229 |
+
)
|
230 |
+
);
|
231 |
+
|
232 |
+
echo wcf()->meta->get_font_weight_field(
|
233 |
+
array(
|
234 |
+
'for' => 'wcf-tq-heading-font-family',
|
235 |
+
'label' => __( 'Font Weight', 'cartflows' ),
|
236 |
+
'name' => 'wcf-tq-heading-font-wt',
|
237 |
+
'value' => $options['wcf-tq-heading-font-wt'],
|
238 |
+
)
|
239 |
+
);
|
240 |
+
|
241 |
+
echo wcf()->meta->get_checkbox_field(
|
242 |
+
array(
|
243 |
+
'label' => __( 'Advanced Options', 'cartflows' ),
|
244 |
+
'name' => 'wcf-tq-advance-options-fields',
|
245 |
+
'value' => $options['wcf-tq-advance-options-fields'],
|
246 |
+
'after' => 'Enable',
|
247 |
+
)
|
248 |
+
);
|
249 |
+
|
250 |
+
echo wcf()->meta->get_number_field(
|
251 |
+
array(
|
252 |
+
'for' => 'wcf-heading',
|
253 |
+
'label' => __( 'Container Width (In px)', 'cartflows' ),
|
254 |
+
'name' => 'wcf-tq-container-width',
|
255 |
+
'value' => $options['wcf-tq-container-width'],
|
256 |
+
)
|
257 |
+
);
|
258 |
+
|
259 |
+
echo wcf()->meta->get_color_picker_field(
|
260 |
+
array(
|
261 |
+
'label' => __( 'Section Background Color', 'cartflows' ),
|
262 |
+
'name' => 'wcf-tq-section-bg-color',
|
263 |
+
'value' => $options['wcf-tq-section-bg-color'],
|
264 |
+
)
|
265 |
+
);
|
266 |
+
|
267 |
+
?>
|
268 |
+
</div>
|
269 |
+
<div class="wcf-thankyou-fields wcf-tab-content widefat">
|
270 |
+
<?php
|
271 |
+
echo wcf()->meta->get_checkbox_field(
|
272 |
+
array(
|
273 |
+
'name' => 'wcf-show-overview-section',
|
274 |
+
'value' => $options['wcf-show-overview-section'],
|
275 |
+
'after' => __( 'Enable Order Overview ', 'cartflows' ),
|
276 |
+
)
|
277 |
+
);
|
278 |
+
|
279 |
+
echo wcf()->meta->get_checkbox_field(
|
280 |
+
array(
|
281 |
+
'name' => 'wcf-show-details-section',
|
282 |
+
'value' => $options['wcf-show-details-section'],
|
283 |
+
'after' => __( 'Enable Order Details ', 'cartflows' ),
|
284 |
+
)
|
285 |
+
);
|
286 |
+
|
287 |
+
echo wcf()->meta->get_checkbox_field(
|
288 |
+
array(
|
289 |
+
'name' => 'wcf-show-billing-section',
|
290 |
+
'value' => $options['wcf-show-billing-section'],
|
291 |
+
'after' => __( 'Enable Billing Details ', 'cartflows' ),
|
292 |
+
)
|
293 |
+
);
|
294 |
+
|
295 |
+
echo wcf()->meta->get_checkbox_field(
|
296 |
+
array(
|
297 |
+
'name' => 'wcf-show-shipping-section',
|
298 |
+
'value' => $options['wcf-show-shipping-section'],
|
299 |
+
'after' => __( 'Enable Shipping Details ', 'cartflows' ),
|
300 |
+
)
|
301 |
+
);
|
302 |
+
|
303 |
+
echo wcf()->meta->get_hidden_field(
|
304 |
+
array(
|
305 |
+
'name' => 'wcf-field-google-font-url',
|
306 |
+
'value' => $options['wcf-field-google-font-url'],
|
307 |
+
)
|
308 |
+
);
|
309 |
+
?>
|
310 |
+
</div>
|
311 |
+
|
312 |
+
<?php $this->tab_custom_script( $options, $post_id ); ?>
|
313 |
+
|
314 |
+
<?php $this->right_column_footer( $options, $post_id ); ?>
|
315 |
+
</div>
|
316 |
+
</div>
|
317 |
+
</div>
|
318 |
+
|
319 |
+
<?php
|
320 |
+
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Get metabox options
|
325 |
+
*
|
326 |
+
* @param int $post_id post ID.
|
327 |
+
* @return array
|
328 |
+
*/
|
329 |
+
public static function get_meta_option( $post_id ) {
|
330 |
+
|
331 |
+
if ( null === self::$meta_option ) {
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Set metabox options
|
335 |
+
*
|
336 |
+
* @see http://php.net/manual/en/filter.filters.sanitize.php
|
337 |
+
*/
|
338 |
+
self::$meta_option = wcf()->options->get_thankyou_fields( $post_id );
|
339 |
+
}
|
340 |
+
|
341 |
+
return self::$meta_option;
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Metabox Save
|
347 |
+
*
|
348 |
+
* @param number $post_id Post ID.
|
349 |
+
* @return void
|
350 |
+
*/
|
351 |
+
public function save_meta_box( $post_id ) {
|
352 |
+
|
353 |
+
// Checks save status.
|
354 |
+
$is_autosave = wp_is_post_autosave( $post_id );
|
355 |
+
$is_revision = wp_is_post_revision( $post_id );
|
356 |
+
|
357 |
+
$is_valid_nonce = ( isset( $_POST['nonce-thankyou-step-meta'] ) && wp_verify_nonce( wp_unslash( $_POST['nonce-thankyou-step-meta'] ), 'save-nonce-thankyou-step-meta' ) ) ? true : false;
|
358 |
+
|
359 |
+
// Exits script depending on save status.
|
360 |
+
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
361 |
+
return;
|
362 |
+
}
|
363 |
+
|
364 |
+
wcf()->options->save_thankyou_fields( $post_id );
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Kicking this off by calling 'get_instance()' method
|
370 |
+
*/
|
371 |
+
Cartflows_Thankyou_Meta::get_instance();
|
modules/widgets/class-cartflows-next-step.php
CHANGED
@@ -15,7 +15,7 @@ class Cartflows_Next_Step extends WP_Widget {
|
|
15 |
/**
|
16 |
* Constructor
|
17 |
*/
|
18 |
-
function __construct() {
|
19 |
|
20 |
parent::__construct(
|
21 |
// Base ID of your widget.
|
@@ -33,7 +33,7 @@ class Cartflows_Next_Step extends WP_Widget {
|
|
33 |
* @param array $args arguments array.
|
34 |
* @param array $instance widget instance.
|
35 |
*/
|
36 |
-
function widget( $args, $instance ) {
|
37 |
|
38 |
$title = apply_filters( 'widget_title', $instance['title'] );
|
39 |
|
@@ -98,7 +98,7 @@ class Cartflows_Next_Step extends WP_Widget {
|
|
98 |
*
|
99 |
* @param array $instance widget instance.
|
100 |
*/
|
101 |
-
function form( $instance ) {
|
102 |
|
103 |
if ( isset( $instance['title'] ) ) {
|
104 |
$title = $instance['title'];
|
@@ -141,13 +141,13 @@ class Cartflows_Next_Step extends WP_Widget {
|
|
141 |
* @param array $old_instance old widget instance.
|
142 |
* @return array
|
143 |
*/
|
144 |
-
function update( $new_instance, $old_instance ) {
|
145 |
|
146 |
$instance = array();
|
147 |
|
148 |
-
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ?
|
149 |
-
$instance['flow_id'] = ( ! empty( $new_instance['flow_id'] ) ) ?
|
150 |
-
$instance['step_id'] = ( ! empty( $new_instance['step_id'] ) ) ?
|
151 |
|
152 |
return $instance;
|
153 |
}
|
15 |
/**
|
16 |
* Constructor
|
17 |
*/
|
18 |
+
public function __construct() {
|
19 |
|
20 |
parent::__construct(
|
21 |
// Base ID of your widget.
|
33 |
* @param array $args arguments array.
|
34 |
* @param array $instance widget instance.
|
35 |
*/
|
36 |
+
public function widget( $args, $instance ) {
|
37 |
|
38 |
$title = apply_filters( 'widget_title', $instance['title'] );
|
39 |
|
98 |
*
|
99 |
* @param array $instance widget instance.
|
100 |
*/
|
101 |
+
public function form( $instance ) {
|
102 |
|
103 |
if ( isset( $instance['title'] ) ) {
|
104 |
$title = $instance['title'];
|
141 |
* @param array $old_instance old widget instance.
|
142 |
* @return array
|
143 |
*/
|
144 |
+
public function update( $new_instance, $old_instance ) {
|
145 |
|
146 |
$instance = array();
|
147 |
|
148 |
+
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
|
149 |
+
$instance['flow_id'] = ( ! empty( $new_instance['flow_id'] ) ) ? wp_strip_all_tags( $new_instance['flow_id'] ) : '';
|
150 |
+
$instance['step_id'] = ( ! empty( $new_instance['step_id'] ) ) ? wp_strip_all_tags( $new_instance['step_id'] ) : '';
|
151 |
|
152 |
return $instance;
|
153 |
}
|
modules/widgets/class-cartflows-widgets.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Widgets
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
define( 'CARTFLOWS_WIDGETS_DIR', CARTFLOWS_DIR . 'modules/widgets/' );
|
9 |
-
define( 'CARTFLOWS_WIDGETS_URL', CARTFLOWS_URL . 'modules/widgets/' );
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Initial Setup
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class Cartflows_Widgets {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Member Variable
|
21 |
-
*
|
22 |
-
* @var object instance
|
23 |
-
*/
|
24 |
-
private static $instance;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Initiator
|
28 |
-
*/
|
29 |
-
public static function get_instance() {
|
30 |
-
if ( ! isset( self::$instance ) ) {
|
31 |
-
self::$instance = new self();
|
32 |
-
}
|
33 |
-
return self::$instance;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Constructor function that initializes required actions and hooks
|
38 |
-
*/
|
39 |
-
public function __construct() {
|
40 |
-
|
41 |
-
require_once CARTFLOWS_WIDGETS_DIR . 'class-cartflows-next-step.php';
|
42 |
-
|
43 |
-
// Register and load the widget.
|
44 |
-
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Register widgets
|
49 |
-
*/
|
50 |
-
function register_widgets() {
|
51 |
-
register_widget( 'cartflows_next_step' );
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Kicking this off by calling 'get_instance()' method
|
57 |
-
*/
|
58 |
-
Cartflows_Widgets::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Widgets
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
define( 'CARTFLOWS_WIDGETS_DIR', CARTFLOWS_DIR . 'modules/widgets/' );
|
9 |
+
define( 'CARTFLOWS_WIDGETS_URL', CARTFLOWS_URL . 'modules/widgets/' );
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Initial Setup
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class Cartflows_Widgets {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Member Variable
|
21 |
+
*
|
22 |
+
* @var object instance
|
23 |
+
*/
|
24 |
+
private static $instance;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Initiator
|
28 |
+
*/
|
29 |
+
public static function get_instance() {
|
30 |
+
if ( ! isset( self::$instance ) ) {
|
31 |
+
self::$instance = new self();
|
32 |
+
}
|
33 |
+
return self::$instance;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Constructor function that initializes required actions and hooks
|
38 |
+
*/
|
39 |
+
public function __construct() {
|
40 |
+
|
41 |
+
require_once CARTFLOWS_WIDGETS_DIR . 'class-cartflows-next-step.php';
|
42 |
+
|
43 |
+
// Register and load the widget.
|
44 |
+
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Register widgets
|
49 |
+
*/
|
50 |
+
public function register_widgets() {
|
51 |
+
register_widget( 'cartflows_next_step' );
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Kicking this off by calling 'get_instance()' method
|
57 |
+
*/
|
58 |
+
Cartflows_Widgets::get_instance();
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
|
2 |
Contributors: brainstormforce, wpcrafter
|
3 |
Donate link: https://www.paypal.me/BrainstormForce
|
4 |
Tags: woocommerce, funnel builder, sales funnels, elementor, beaver builder
|
5 |
Requires at least: 4.4
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 1.3.
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
@@ -124,6 +124,12 @@ Glad you asked! CartFlows Pro is an optional add-on to CartFlows that adds addit
|
|
124 |
5. Easily edit anything with your page builder.
|
125 |
|
126 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
= Version 1.3.1 - Wednesday, 6th November 2019 =
|
128 |
* Improvement: Added compatibility for a future release of CartFlows Pro.
|
129 |
* Fix: Security issue fix & added user capability check.
|
1 |
+
=== Funnel Builder by CartFlows - Create High Converting Sales Funnels For WordPress ===
|
2 |
Contributors: brainstormforce, wpcrafter
|
3 |
Donate link: https://www.paypal.me/BrainstormForce
|
4 |
Tags: woocommerce, funnel builder, sales funnels, elementor, beaver builder
|
5 |
Requires at least: 4.4
|
6 |
+
Tested up to: 5.3
|
7 |
+
Stable tag: 1.3.2
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
124 |
5. Easily edit anything with your page builder.
|
125 |
|
126 |
== Changelog ==
|
127 |
+
|
128 |
+
= Version 1.3.2 - Wednesday, 11th December 2019 =
|
129 |
+
* New: Option added to remove products on the checkout page.
|
130 |
+
* Fix: Checkout page's login form text was not able to translate.
|
131 |
+
* Fix: 2Checkout & PayPlus payment gateway's compatibility issue with global checkout.
|
132 |
+
|
133 |
= Version 1.3.1 - Wednesday, 6th November 2019 =
|
134 |
* Improvement: Added compatibility for a future release of CartFlows Pro.
|
135 |
* Fix: Security issue fix & added user capability check.
|
woocommerce/template/checkout/form-login.php
CHANGED
@@ -29,7 +29,7 @@ if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_lo
|
|
29 |
|
30 |
woocommerce_login_form(
|
31 |
array(
|
32 |
-
'message' => __( 'If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing & Shipping section.', '
|
33 |
'redirect' => wc_get_page_permalink( 'checkout' ),
|
34 |
'hidden' => true,
|
35 |
)
|
29 |
|
30 |
woocommerce_login_form(
|
31 |
array(
|
32 |
+
'message' => __( 'If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing & Shipping section.', 'cartflows' ),
|
33 |
'redirect' => wc_get_page_permalink( 'checkout' ),
|
34 |
'hidden' => true,
|
35 |
)
|
woocommerce/template/checkout/review-order.php
CHANGED
@@ -30,13 +30,14 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
30 |
<tbody>
|
31 |
<?php
|
32 |
do_action( 'woocommerce_review_order_before_cart_contents' );
|
33 |
-
|
34 |
-
|
35 |
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
36 |
|
37 |
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
38 |
?>
|
39 |
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
|
|
40 |
<td class="product-name">
|
41 |
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; ?>
|
42 |
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); ?>
|
30 |
<tbody>
|
31 |
<?php
|
32 |
do_action( 'woocommerce_review_order_before_cart_contents' );
|
33 |
+
$checkout_id = get_the_ID();
|
34 |
+
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
35 |
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
36 |
|
37 |
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
38 |
?>
|
39 |
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
40 |
+
|
41 |
<td class="product-name">
|
42 |
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; ?>
|
43 |
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); ?>
|