Funnel Builder by CartFlows – Create High Converting Sales Funnels For WordPress - Version 1.1.4

Version Description

Download this release

Release Info

Developer Nikschavan
Plugin Icon Funnel Builder by CartFlows – Create High Converting Sales Funnels For WordPress
Version 1.1.4
Comparing to
See all releases

Code changes from version 1.1.3 to 1.1.4

admin/assets/css/global-admin-rtl.css CHANGED
@@ -460,10 +460,6 @@
460
  margin: 15px 0 10px;
461
  }
462
 
463
- body.post-php.post-type-cartflows_flow #postimagediv{
464
- display: none;
465
- }
466
-
467
  .wcf-general-metabox-wrap .wcf-field-row{
468
  display: inline-flex;
469
  width: 100%;
460
  margin: 15px 0 10px;
461
  }
462
 
 
 
 
 
463
  .wcf-general-metabox-wrap .wcf-field-row{
464
  display: inline-flex;
465
  width: 100%;
admin/assets/css/global-admin.css CHANGED
@@ -460,10 +460,6 @@
460
  margin: 15px 0 10px;
461
  }
462
 
463
- body.post-php.post-type-cartflows_flow #postimagediv{
464
- display: none;
465
- }
466
-
467
  .wcf-general-metabox-wrap .wcf-field-row{
468
  display: inline-flex;
469
  width: 100%;
460
  margin: 15px 0 10px;
461
  }
462
 
 
 
 
 
463
  .wcf-general-metabox-wrap .wcf-field-row{
464
  display: inline-flex;
465
  width: 100%;
assets/css/checkout-template-rtl.css CHANGED
@@ -10,7 +10,7 @@
10
  }
11
 
12
  .wcf-embed-checkout-form .wc-backward {
13
- display: none;
14
  }
15
 
16
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
@@ -125,115 +125,83 @@
125
  }
126
 
127
  /**
128
- * ************
129
- * Radio Button
130
- * ************
131
  */
132
-
133
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked,
134
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) {
135
- right: -9999px;
136
- position: absolute;
137
- }
138
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked + label,
139
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) + label
140
- {
141
- color: #666;
142
- cursor: pointer;
143
- display: inline;
144
- font-family: inherit;
145
- font-weight:inherit;
146
- line-height: 20px;
147
- position: relative;
148
- padding-right: 28px;
149
- }
150
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked + label:before,
151
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) + label:before {
152
- border: 1px solid #ddd;
153
- border-radius: 100%;
154
- background: #fff;
155
- content: '';
156
- height: 18px;
157
- right: 0;
158
- position: absolute;
159
- top: 0px;
160
- width: 18px;
161
- }
162
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked + label:after,
163
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) + label:after {
164
- background: #F16334;
165
- border-radius: 100%;
166
- content: '';
167
- height: 8px;
168
- right: 5px;
169
- position: absolute;
170
- top: 5px;
171
- width: 8px;
172
- -webkit-transition: all 0.2s ease;
173
- transition: all 0.2s ease;
174
- }
175
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) + label:after {
176
- opacity: 0;
177
- -webkit-transform: scale(0);
178
- transform: scale(0);
179
- }
180
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked + label:after {
181
- opacity: 1;
182
- -webkit-transform: scale(1);
183
- transform: scale(1);
184
  }
185
 
186
- /**
187
- * **********
188
- * Checkbox
189
- * **********
190
- */
191
-
192
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked,
193
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:not(:checked)
194
- {
195
- color: #666;
196
- cursor: pointer;
197
- display: inline;
198
- line-height: 20px;
199
- margin-left: 10px;
200
- position: relative;
201
- padding-right: 28px;
202
  }
203
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:before,
204
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:not(:checked):before {
 
 
 
205
  background: #fff;
206
- border: 1px solid #ddd;
207
- content: '';
208
- height: 18px;
209
- right: 0;
210
- position: absolute;
211
- top: -3px;
212
- width: 18px;
 
 
 
 
 
 
 
 
 
213
  }
214
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:after,
215
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:not(:checked):after {
216
- background: #F16334;
217
- content: '';
218
- height: 8px;
219
- right: 5px;
220
- position: absolute;
221
- top: 2px;
222
- width: 8px;
223
- -webkit-transition: all 0.2s ease;
224
- transition: all 0.2s ease;
225
  }
226
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:not(:checked):after {
227
- opacity: 0;
228
- -webkit-transform: scale(0);
229
- transform: scale(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:after {
232
- opacity: 1;
233
- -webkit-transform: scale(1);
234
- transform: scale(1);
235
  }
236
 
 
237
  .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
238
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
239
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
@@ -256,6 +224,7 @@
256
  font-size: 20px;
257
  text-transform: capitalize;
258
  margin:0 0 25px 0;
 
259
  }
260
 
261
  .wcf-embed-checkout-form .woocommerce-checkout #payment {
@@ -369,6 +338,10 @@
369
  box-shadow: none;
370
  }
371
 
 
 
 
 
372
  .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type="text"]{
373
  font-weight: normal;
374
  }
@@ -489,23 +462,13 @@
489
  border-radius: 3px;
490
  }
491
 
492
- /*.wcf-embed-checkout-form .woocommerce-checkout #order_review{
493
- display: inline-block;
494
- float: none;
495
- width: 45%;
496
- border: none;
497
- background-color: inherit/*#F6F6F6*;
498
- padding: 0 10px;
499
- border-radius: 3px;
500
- }*/
501
-
502
  .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
503
  display: inline-block;
504
  font-family: inherit;
505
  font-weight: 600;
506
  width: 100%;
507
  margin:20px 0 0;
508
- padding: 0px 0px 20px;
509
  border: none;
510
  border-bottom: none;
511
  }
@@ -549,11 +512,19 @@
549
  border-collapse: collapse;
550
  text-align: right;
551
  }
 
 
 
 
 
552
  .wcf-embed-checkout-form table.shop_table #shipping_method{
553
  margin: 0;
554
  padding: 0;
555
  list-style: none;
556
  }
 
 
 
557
  .wcf-embed-checkout-form table.shop_table th{
558
  border: none;
559
  font-weight: 400;
@@ -563,12 +534,19 @@
563
  .wcf-embed-checkout-form table.shop_table tfoot tr:last-child .woocommerce-Price-amount {
564
  font-size: 1em;
565
  }
 
566
  .wcf-embed-checkout-form table.shop_table td,
567
- .wcf-embed-checkout-form table.shop_table th {
 
 
568
  padding: 0.6em 0;
569
  line-height: 1.4em;
570
  border: none;
571
  }
 
 
 
 
572
  .wcf-embed-checkout-form table.shop_table tbody th,
573
  .wcf-embed-checkout-form table.shop_table tfoot td,
574
  .wcf-embed-checkout-form table.shop_table tfoot th {
@@ -735,8 +713,10 @@
735
  .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
736
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
737
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
738
- .wcf-embed-checkout-form .woocommerce-page .col2-set .col-2{
739
- padding: 15px;
 
 
740
  }
741
 
742
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
10
  }
11
 
12
  .wcf-embed-checkout-form .wc-backward {
13
+ display: none !important;
14
  }
15
 
16
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
125
  }
126
 
127
  /**
128
+ * ************************
129
+ * Radio Button & Checkbox
130
+ * ************************
131
  */
132
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]{
133
+ border-radius: 50%;
134
+ margin-left: 4px;
135
+ line-height: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
137
 
138
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
139
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:before{
140
+ content: "\f147";
141
+ margin: -3px -4px 0 0;
142
+ color: #F16334;
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
+
145
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox],
146
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"],
147
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]{
148
+ border: 1px solid #b4b9be;
149
  background: #fff;
150
+ color: #555;
151
+ clear: none;
152
+ cursor: pointer;
153
+ display: inline-block;
154
+ line-height: 0;
155
+ height: 16px;
156
+ margin: -4px 0 0 4px;
157
+ outline: 0;
158
+ padding: 0!important;
159
+ text-align: center;
160
+ vertical-align: middle;
161
+ width: 16px;
162
+ min-width: 16px;
163
+ -webkit-appearance: none;
164
+ box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
165
+ transition: .05s border-color ease-in-out;
166
  }
167
+
168
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
169
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:focus,
170
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:focus{
171
+ border-color: #F16334;
172
+ box-shadow: 0 0 2px rgba(241, 99, 52,.8);
 
 
 
 
 
173
  }
174
+
175
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
176
+ background-color: #F16334;
177
+ border-radius: 50px;
178
+ content: "\2022";
179
+ font-size: 24px;
180
+ height: 6px;
181
+ line-height: 16px;
182
+ margin: 4px;
183
+ text-indent: -9999px;
184
+ width: 6px;
185
+ }
186
+
187
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
188
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:before,
189
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
190
+ display: inline-block;
191
+ float: right;
192
+ font: normal 21px/1 dashicons;
193
+ speak: none;
194
+ vertical-align: middle;
195
+ width: 6px;
196
+ -webkit-font-smoothing: antialiased;
197
+ -moz-osx-font-smoothing: grayscale;
198
  }
199
+
200
+ .wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li input[type=checkbox]{
201
+ min-width: 16px;
 
202
  }
203
 
204
+
205
  .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
206
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
207
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
224
  font-size: 20px;
225
  text-transform: capitalize;
226
  margin:0 0 25px 0;
227
+ padding: 3px;
228
  }
229
 
230
  .wcf-embed-checkout-form .woocommerce-checkout #payment {
338
  box-shadow: none;
339
  }
340
 
341
+ .wcf-embed-checkout-form #order_review{
342
+ padding: 3px;
343
+ }
344
+
345
  .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type="text"]{
346
  font-weight: normal;
347
  }
462
  border-radius: 3px;
463
  }
464
 
 
 
 
 
 
 
 
 
 
 
465
  .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
466
  display: inline-block;
467
  font-family: inherit;
468
  font-weight: 600;
469
  width: 100%;
470
  margin:20px 0 0;
471
+ padding: 3px 3px 20px;
472
  border: none;
473
  border-bottom: none;
474
  }
512
  border-collapse: collapse;
513
  text-align: right;
514
  }
515
+
516
+ .wcf-embed-checkout-form table.shop_table td strong.product-quantity{
517
+ font-weight: normal;
518
+ }
519
+
520
  .wcf-embed-checkout-form table.shop_table #shipping_method{
521
  margin: 0;
522
  padding: 0;
523
  list-style: none;
524
  }
525
+ .wcf-embed-checkout-form table.shop_table #shipping_method .amount{
526
+ font-weight: normal;
527
+ }
528
  .wcf-embed-checkout-form table.shop_table th{
529
  border: none;
530
  font-weight: 400;
534
  .wcf-embed-checkout-form table.shop_table tfoot tr:last-child .woocommerce-Price-amount {
535
  font-size: 1em;
536
  }
537
+
538
  .wcf-embed-checkout-form table.shop_table td,
539
+ .wcf-embed-checkout-form table.shop_table th,
540
+ .wcf-embed-checkout-form table.shop_table td dl dt,
541
+ .wcf-embed-checkout-form table.shop_table td dl dd {
542
  padding: 0.6em 0;
543
  line-height: 1.4em;
544
  border: none;
545
  }
546
+ .wcf-embed-checkout-form table.shop_table td dl dd p{
547
+ margin-top: 0;
548
+ }
549
+
550
  .wcf-embed-checkout-form table.shop_table tbody th,
551
  .wcf-embed-checkout-form table.shop_table tfoot td,
552
  .wcf-embed-checkout-form table.shop_table tfoot th {
713
  .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
714
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
715
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
716
+ .wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,
717
+ .wcf-embed-checkout-form .woocommerce .wcf-order-wrap,
718
+ .wcf-embed-checkout-form .woocommerce-page .wcf-order-wrap{
719
+ padding: 15px 18px;
720
  }
721
 
722
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
assets/css/checkout-template.css CHANGED
@@ -10,7 +10,7 @@
10
  }
11
 
12
  .wcf-embed-checkout-form .wc-backward {
13
- display: none;
14
  }
15
 
16
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
@@ -125,115 +125,83 @@
125
  }
126
 
127
  /**
128
- * ************
129
- * Radio Button
130
- * ************
131
  */
132
-
133
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked,
134
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) {
135
- left: -9999px;
136
- position: absolute;
137
- }
138
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked + label,
139
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) + label
140
- {
141
- color: #666;
142
- cursor: pointer;
143
- display: inline;
144
- font-family: inherit;
145
- font-weight:inherit;
146
- line-height: 20px;
147
- position: relative;
148
- padding-left: 28px;
149
- }
150
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked + label:before,
151
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) + label:before {
152
- border: 1px solid #ddd;
153
- border-radius: 100%;
154
- background: #fff;
155
- content: '';
156
- height: 18px;
157
- left: 0;
158
- position: absolute;
159
- top: 0px;
160
- width: 18px;
161
- }
162
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked + label:after,
163
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) + label:after {
164
- background: #F16334;
165
- border-radius: 100%;
166
- content: '';
167
- height: 8px;
168
- left: 5px;
169
- position: absolute;
170
- top: 5px;
171
- width: 8px;
172
- -webkit-transition: all 0.2s ease;
173
- transition: all 0.2s ease;
174
- }
175
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:not(:checked) + label:after {
176
- opacity: 0;
177
- -webkit-transform: scale(0);
178
- transform: scale(0);
179
- }
180
- .wcf-embed-checkout-form .woocommerce #payment [type="radio"]:checked + label:after {
181
- opacity: 1;
182
- -webkit-transform: scale(1);
183
- transform: scale(1);
184
  }
185
 
186
- /**
187
- * **********
188
- * Checkbox
189
- * **********
190
- */
191
-
192
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked,
193
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:not(:checked)
194
- {
195
- color: #666;
196
- cursor: pointer;
197
- display: inline;
198
- line-height: 20px;
199
- margin-right: 10px;
200
- position: relative;
201
- padding-left: 28px;
202
  }
203
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:before,
204
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:not(:checked):before {
 
 
 
205
  background: #fff;
206
- border: 1px solid #ddd;
207
- content: '';
208
- height: 18px;
209
- left: 0;
210
- position: absolute;
211
- top: -3px;
212
- width: 18px;
 
 
 
 
 
 
 
 
 
213
  }
214
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:after,
215
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:not(:checked):after {
216
- background: #F16334;
217
- content: '';
218
- height: 8px;
219
- left: 5px;
220
- position: absolute;
221
- top: 2px;
222
- width: 8px;
223
- -webkit-transition: all 0.2s ease;
224
- transition: all 0.2s ease;
225
  }
226
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:not(:checked):after {
227
- opacity: 0;
228
- -webkit-transform: scale(0);
229
- transform: scale(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:after {
232
- opacity: 1;
233
- -webkit-transform: scale(1);
234
- transform: scale(1);
235
  }
236
 
 
237
  .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
238
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
239
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
@@ -256,6 +224,7 @@
256
  font-size: 20px;
257
  text-transform: capitalize;
258
  margin:0 0 25px 0;
 
259
  }
260
 
261
  .wcf-embed-checkout-form .woocommerce-checkout #payment {
@@ -369,6 +338,10 @@
369
  box-shadow: none;
370
  }
371
 
 
 
 
 
372
  .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type="text"]{
373
  font-weight: normal;
374
  }
@@ -489,23 +462,13 @@
489
  border-radius: 3px;
490
  }
491
 
492
- /*.wcf-embed-checkout-form .woocommerce-checkout #order_review{
493
- display: inline-block;
494
- float: none;
495
- width: 45%;
496
- border: none;
497
- background-color: inherit/*#F6F6F6*;
498
- padding: 0 10px;
499
- border-radius: 3px;
500
- }*/
501
-
502
  .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
503
  display: inline-block;
504
  font-family: inherit;
505
  font-weight: 600;
506
  width: 100%;
507
  margin:20px 0 0;
508
- padding: 0px 0px 20px;
509
  border: none;
510
  border-bottom: none;
511
  }
@@ -549,11 +512,19 @@
549
  border-collapse: collapse;
550
  text-align: left;
551
  }
 
 
 
 
 
552
  .wcf-embed-checkout-form table.shop_table #shipping_method{
553
  margin: 0;
554
  padding: 0;
555
  list-style: none;
556
  }
 
 
 
557
  .wcf-embed-checkout-form table.shop_table th{
558
  border: none;
559
  font-weight: 400;
@@ -563,12 +534,19 @@
563
  .wcf-embed-checkout-form table.shop_table tfoot tr:last-child .woocommerce-Price-amount {
564
  font-size: 1em;
565
  }
 
566
  .wcf-embed-checkout-form table.shop_table td,
567
- .wcf-embed-checkout-form table.shop_table th {
 
 
568
  padding: 0.6em 0;
569
  line-height: 1.4em;
570
  border: none;
571
  }
 
 
 
 
572
  .wcf-embed-checkout-form table.shop_table tbody th,
573
  .wcf-embed-checkout-form table.shop_table tfoot td,
574
  .wcf-embed-checkout-form table.shop_table tfoot th {
@@ -735,8 +713,10 @@
735
  .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
736
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
737
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
738
- .wcf-embed-checkout-form .woocommerce-page .col2-set .col-2{
739
- padding: 15px;
 
 
740
  }
741
 
742
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
10
  }
11
 
12
  .wcf-embed-checkout-form .wc-backward {
13
+ display: none !important;
14
  }
15
 
16
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
125
  }
126
 
127
  /**
128
+ * ************************
129
+ * Radio Button & Checkbox
130
+ * ************************
131
  */
132
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]{
133
+ border-radius: 50%;
134
+ margin-right: 4px;
135
+ line-height: 10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
137
 
138
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
139
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:before{
140
+ content: "\f147";
141
+ margin: -3px 0 0 -4px;
142
+ color: #F16334;
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
+
145
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox],
146
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"],
147
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]{
148
+ border: 1px solid #b4b9be;
149
  background: #fff;
150
+ color: #555;
151
+ clear: none;
152
+ cursor: pointer;
153
+ display: inline-block;
154
+ line-height: 0;
155
+ height: 16px;
156
+ margin: -4px 4px 0 0;
157
+ outline: 0;
158
+ padding: 0!important;
159
+ text-align: center;
160
+ vertical-align: middle;
161
+ width: 16px;
162
+ min-width: 16px;
163
+ -webkit-appearance: none;
164
+ box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
165
+ transition: .05s border-color ease-in-out;
166
  }
167
+
168
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
169
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:focus,
170
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:focus{
171
+ border-color: #F16334;
172
+ box-shadow: 0 0 2px rgba(241, 99, 52,.8);
 
 
 
 
 
173
  }
174
+
175
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
176
+ background-color: #F16334;
177
+ border-radius: 50px;
178
+ content: "\2022";
179
+ font-size: 24px;
180
+ height: 6px;
181
+ line-height: 16px;
182
+ margin: 4px;
183
+ text-indent: -9999px;
184
+ width: 6px;
185
+ }
186
+
187
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
188
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type="checkbox"]:checked:before,
189
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
190
+ display: inline-block;
191
+ float: left;
192
+ font: normal 21px/1 dashicons;
193
+ speak: none;
194
+ vertical-align: middle;
195
+ width: 6px;
196
+ -webkit-font-smoothing: antialiased;
197
+ -moz-osx-font-smoothing: grayscale;
198
  }
199
+
200
+ .wcf-embed-checkout-form .woocommerce-checkout #payment ul.payment_methods li input[type=checkbox]{
201
+ min-width: 16px;
 
202
  }
203
 
204
+
205
  .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
206
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
207
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
224
  font-size: 20px;
225
  text-transform: capitalize;
226
  margin:0 0 25px 0;
227
+ padding: 3px;
228
  }
229
 
230
  .wcf-embed-checkout-form .woocommerce-checkout #payment {
338
  box-shadow: none;
339
  }
340
 
341
+ .wcf-embed-checkout-form #order_review{
342
+ padding: 3px;
343
+ }
344
+
345
  .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type="text"]{
346
  font-weight: normal;
347
  }
462
  border-radius: 3px;
463
  }
464
 
 
 
 
 
 
 
 
 
 
 
465
  .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
466
  display: inline-block;
467
  font-family: inherit;
468
  font-weight: 600;
469
  width: 100%;
470
  margin:20px 0 0;
471
+ padding: 3px 3px 20px;
472
  border: none;
473
  border-bottom: none;
474
  }
512
  border-collapse: collapse;
513
  text-align: left;
514
  }
515
+
516
+ .wcf-embed-checkout-form table.shop_table td strong.product-quantity{
517
+ font-weight: normal;
518
+ }
519
+
520
  .wcf-embed-checkout-form table.shop_table #shipping_method{
521
  margin: 0;
522
  padding: 0;
523
  list-style: none;
524
  }
525
+ .wcf-embed-checkout-form table.shop_table #shipping_method .amount{
526
+ font-weight: normal;
527
+ }
528
  .wcf-embed-checkout-form table.shop_table th{
529
  border: none;
530
  font-weight: 400;
534
  .wcf-embed-checkout-form table.shop_table tfoot tr:last-child .woocommerce-Price-amount {
535
  font-size: 1em;
536
  }
537
+
538
  .wcf-embed-checkout-form table.shop_table td,
539
+ .wcf-embed-checkout-form table.shop_table th,
540
+ .wcf-embed-checkout-form table.shop_table td dl dt,
541
+ .wcf-embed-checkout-form table.shop_table td dl dd {
542
  padding: 0.6em 0;
543
  line-height: 1.4em;
544
  border: none;
545
  }
546
+ .wcf-embed-checkout-form table.shop_table td dl dd p{
547
+ margin-top: 0;
548
+ }
549
+
550
  .wcf-embed-checkout-form table.shop_table tbody th,
551
  .wcf-embed-checkout-form table.shop_table tfoot td,
552
  .wcf-embed-checkout-form table.shop_table tfoot th {
713
  .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
714
  .wcf-embed-checkout-form .woocommerce-page .col2-set .col-1,
715
  .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
716
+ .wcf-embed-checkout-form .woocommerce-page .col2-set .col-2,
717
+ .wcf-embed-checkout-form .woocommerce .wcf-order-wrap,
718
+ .wcf-embed-checkout-form .woocommerce-page .wcf-order-wrap{
719
+ padding: 15px 18px;
720
  }
721
 
722
  .wcf-embed-checkout-form .woocommerce form .form-row-first,
assets/css/import-rtl.css CHANGED
@@ -454,18 +454,14 @@ div#TB_window {
454
  .wcf-template-header .filter-count {
455
  line-height: normal;
456
  }
457
- #wcf-page-builders,
 
 
458
  #wcf-remote-flow-filters > div,
459
  #wcf-remote-step-filters > div {
460
  display: inline-block;
461
  }
462
- #wcf-categories .step-type-filter-links{
463
- background: transparent;
464
- box-shadow: none;
465
- border:1px solid;
466
- border-color: #9e9e9e;
467
- vertical-align: unset;
468
- }
469
  .wcf-template-header .filter-links {
470
  margin: 0;
471
  padding: 0;
@@ -506,8 +502,6 @@ div#TB_window {
506
 
507
  .wcf-template-notice {
508
  display: none;
509
- padding: 10px 20px 0 0;
510
- text-align: center;
511
  }
512
  #wcf-start-from-scratch {
513
  text-align: center;
@@ -603,15 +597,18 @@ div#TB_window {
603
  background: rgba(0, 0, 0, 0.7);
604
  transition: opacity 500ms;
605
  visibility: hidden;
 
606
  z-index: 9999;
607
  -webkit-user-select: none;
608
  -moz-user-select: none;
609
  -ms-user-select: none;
610
  user-select: none;
 
611
  }
612
 
613
  .wcf-templates-popup-overlay.open{
614
  visibility: visible;
 
615
  z-index: 9999;
616
  }
617
 
@@ -673,7 +670,6 @@ html.wcf-popup-open{
673
  right: 110px;
674
  }
675
 
676
- .wcf-steps-loading #wcf-start-from-scratch,
677
  .wcf-steps-loading #wcf-remote-step-list {
678
  display: none !important;
679
  }
@@ -880,13 +876,13 @@ html.wcf-popup-open{
880
  margin: 4em 0 0 0;
881
  text-align: center;
882
  }
883
- #wcf-categories {
884
- border-right: 1px #ddd dashed;
885
  display: inline-block;
886
- margin-right: 1em;
887
- padding-right: 1em;
888
  vertical-align: baseline;
889
- }
890
  .flow-type-filter-links {
891
  display: none;
892
  }
@@ -931,6 +927,47 @@ html.wcf-popup-open{
931
 
932
  .wcf-notice-wrap .notice {
933
  display: inline-block;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
934
  margin: 1.5em 0 0 0;
935
  }
936
 
454
  .wcf-template-header .filter-count {
455
  line-height: normal;
456
  }
457
+ #wcf-page-builders {
458
+ display: none;
459
+ }
460
  #wcf-remote-flow-filters > div,
461
  #wcf-remote-step-filters > div {
462
  display: inline-block;
463
  }
464
+
 
 
 
 
 
 
465
  .wcf-template-header .filter-links {
466
  margin: 0;
467
  padding: 0;
502
 
503
  .wcf-template-notice {
504
  display: none;
 
 
505
  }
506
  #wcf-start-from-scratch {
507
  text-align: center;
597
  background: rgba(0, 0, 0, 0.7);
598
  transition: opacity 500ms;
599
  visibility: hidden;
600
+ opacity: 0;
601
  z-index: 9999;
602
  -webkit-user-select: none;
603
  -moz-user-select: none;
604
  -ms-user-select: none;
605
  user-select: none;
606
+ transition: none;
607
  }
608
 
609
  .wcf-templates-popup-overlay.open{
610
  visibility: visible;
611
+ opacity: 1;
612
  z-index: 9999;
613
  }
614
 
670
  right: 110px;
671
  }
672
 
 
673
  .wcf-steps-loading #wcf-remote-step-list {
674
  display: none !important;
675
  }
876
  margin: 4em 0 0 0;
877
  text-align: center;
878
  }
879
+ /*#wcf-categories {
880
+ border-left: 1px #ddd dashed;
881
  display: inline-block;
882
+ margin-left: 1em;
883
+ padding-left: 1em;
884
  vertical-align: baseline;
885
+ }*/
886
  .flow-type-filter-links {
887
  display: none;
888
  }
927
 
928
  .wcf-notice-wrap .notice {
929
  display: inline-block;
930
+ }
931
+
932
+ .wcf-learn-how i {
933
+ font-size: 1rem;
934
+ vertical-align: middle;
935
+ }
936
+
937
+ .wcf-learn-how a {
938
+ text-decoration: none;
939
+ }
940
+
941
+ #wcf-remote-content .wcf-install-plugin::focus {
942
+ border-color: none;
943
+ box-shadow: none;
944
+ }
945
+
946
+ #wcf-remote-content .wcf-install-plugin.updating-message {
947
+ background: none;
948
+ padding: 0;
949
+ font-size: 1rem;
950
+ box-shadow: none;
951
+ border: none;
952
+ margin: 0 3px 0 0;
953
+ }
954
+
955
+ .wcf-page-builder-message {
956
+ margin: 5em auto 0 auto;
957
+ width: 700px;
958
+ }
959
+
960
+ .wcf-page-builder-message p {
961
+ font-size: 1rem;
962
+ }
963
+
964
+ .wcf-page-builder-message i {
965
+ font-size: 1rem;
966
+ vertical-align: middle;
967
+ }
968
+
969
+ .wcf-page-builder-message a {
970
+ text-decoration: none;
971
  margin: 1.5em 0 0 0;
972
  }
973
 
assets/css/import.css CHANGED
@@ -454,18 +454,14 @@ div#TB_window {
454
  .wcf-template-header .filter-count {
455
  line-height: normal;
456
  }
457
- #wcf-page-builders,
 
 
458
  #wcf-remote-flow-filters > div,
459
  #wcf-remote-step-filters > div {
460
  display: inline-block;
461
  }
462
- #wcf-categories .step-type-filter-links{
463
- background: transparent;
464
- box-shadow: none;
465
- border:1px solid;
466
- border-color: #9e9e9e;
467
- vertical-align: unset;
468
- }
469
  .wcf-template-header .filter-links {
470
  margin: 0;
471
  padding: 0;
@@ -506,8 +502,6 @@ div#TB_window {
506
 
507
  .wcf-template-notice {
508
  display: none;
509
- padding: 10px 0 0 20px;
510
- text-align: center;
511
  }
512
  #wcf-start-from-scratch {
513
  text-align: center;
@@ -603,15 +597,18 @@ div#TB_window {
603
  background: rgba(0, 0, 0, 0.7);
604
  transition: opacity 500ms;
605
  visibility: hidden;
 
606
  z-index: 9999;
607
  -webkit-user-select: none;
608
  -moz-user-select: none;
609
  -ms-user-select: none;
610
  user-select: none;
 
611
  }
612
 
613
  .wcf-templates-popup-overlay.open{
614
  visibility: visible;
 
615
  z-index: 9999;
616
  }
617
 
@@ -673,7 +670,6 @@ html.wcf-popup-open{
673
  left: 110px;
674
  }
675
 
676
- .wcf-steps-loading #wcf-start-from-scratch,
677
  .wcf-steps-loading #wcf-remote-step-list {
678
  display: none !important;
679
  }
@@ -880,13 +876,13 @@ html.wcf-popup-open{
880
  margin: 4em 0 0 0;
881
  text-align: center;
882
  }
883
- #wcf-categories {
884
  border-left: 1px #ddd dashed;
885
  display: inline-block;
886
  margin-left: 1em;
887
  padding-left: 1em;
888
  vertical-align: baseline;
889
- }
890
  .flow-type-filter-links {
891
  display: none;
892
  }
@@ -931,6 +927,47 @@ html.wcf-popup-open{
931
 
932
  .wcf-notice-wrap .notice {
933
  display: inline-block;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
934
  margin: 1.5em 0 0 0;
935
  }
936
 
454
  .wcf-template-header .filter-count {
455
  line-height: normal;
456
  }
457
+ #wcf-page-builders {
458
+ display: none;
459
+ }
460
  #wcf-remote-flow-filters > div,
461
  #wcf-remote-step-filters > div {
462
  display: inline-block;
463
  }
464
+
 
 
 
 
 
 
465
  .wcf-template-header .filter-links {
466
  margin: 0;
467
  padding: 0;
502
 
503
  .wcf-template-notice {
504
  display: none;
 
 
505
  }
506
  #wcf-start-from-scratch {
507
  text-align: center;
597
  background: rgba(0, 0, 0, 0.7);
598
  transition: opacity 500ms;
599
  visibility: hidden;
600
+ opacity: 0;
601
  z-index: 9999;
602
  -webkit-user-select: none;
603
  -moz-user-select: none;
604
  -ms-user-select: none;
605
  user-select: none;
606
+ transition: none;
607
  }
608
 
609
  .wcf-templates-popup-overlay.open{
610
  visibility: visible;
611
+ opacity: 1;
612
  z-index: 9999;
613
  }
614
 
670
  left: 110px;
671
  }
672
 
 
673
  .wcf-steps-loading #wcf-remote-step-list {
674
  display: none !important;
675
  }
876
  margin: 4em 0 0 0;
877
  text-align: center;
878
  }
879
+ /*#wcf-categories {
880
  border-left: 1px #ddd dashed;
881
  display: inline-block;
882
  margin-left: 1em;
883
  padding-left: 1em;
884
  vertical-align: baseline;
885
+ }*/
886
  .flow-type-filter-links {
887
  display: none;
888
  }
927
 
928
  .wcf-notice-wrap .notice {
929
  display: inline-block;
930
+ }
931
+
932
+ .wcf-learn-how i {
933
+ font-size: 1rem;
934
+ vertical-align: middle;
935
+ }
936
+
937
+ .wcf-learn-how a {
938
+ text-decoration: none;
939
+ }
940
+
941
+ #wcf-remote-content .wcf-install-plugin::focus {
942
+ border-color: none;
943
+ box-shadow: none;
944
+ }
945
+
946
+ #wcf-remote-content .wcf-install-plugin.updating-message {
947
+ background: none;
948
+ padding: 0;
949
+ font-size: 1rem;
950
+ box-shadow: none;
951
+ border: none;
952
+ margin: 0 0 0 3px;
953
+ }
954
+
955
+ .wcf-page-builder-message {
956
+ margin: 5em auto 0 auto;
957
+ width: 700px;
958
+ }
959
+
960
+ .wcf-page-builder-message p {
961
+ font-size: 1rem;
962
+ }
963
+
964
+ .wcf-page-builder-message i {
965
+ font-size: 1rem;
966
+ vertical-align: middle;
967
+ }
968
+
969
+ .wcf-page-builder-message a {
970
+ text-decoration: none;
971
  margin: 1.5em 0 0 0;
972
  }
973
 
assets/js/checkout-template.js CHANGED
@@ -20,7 +20,7 @@
20
  return !document[stateKey];
21
  }
22
  })();
23
-
24
  var visible = vis(); // gives current state
25
 
26
  vis(function(){
@@ -208,6 +208,10 @@
208
 
209
  });
210
 
 
 
 
 
211
 
212
  var cf_checkout_coupons = {
213
 
20
  return !document[stateKey];
21
  }
22
  })();
23
+
24
  var visible = vis(); // gives current state
25
 
26
  vis(function(){
208
 
209
  });
210
 
211
+ $(window).load(function(){
212
+ $( 'body' ).trigger( 'update_checkout' );
213
+ });
214
+
215
 
216
  var cf_checkout_coupons = {
217
 
assets/js/import.js CHANGED
@@ -93,6 +93,8 @@ var CartFlowsAjaxQueue = (function() {
93
 
94
  all_steps : 0,
95
  remaining_steps : 0,
 
 
96
 
97
  /**
98
  * Init
@@ -101,20 +103,18 @@ var CartFlowsAjaxQueue = (function() {
101
  {
102
  this._bind();
103
 
104
- if( $('.wcf-step-wrap').length ) {
105
- this._set_category_slugs();
 
 
 
 
 
106
  }
107
 
108
- if( $('.post-type-cartflows_flow').hasClass('edit-php') ) {
109
- this._cache_remote_flows();
110
- }
111
- if( $('.post-type-cartflows_flow').hasClass('post-php') ) {
112
- this._cache_remote_steps();
113
- }
114
  if( $('.post-type-cartflows_flow').hasClass('edit-php') && null !== this._getParamFromURL('add-new-flow') ) {
115
  this._render_remote_flows();
116
  }
117
-
118
  if( $('.post-type-cartflows_flow').hasClass('post-php') && null !== this._getParamFromURL('add-new-step') ) {
119
  this._render_remote_steps();
120
  }
@@ -152,25 +152,6 @@ var CartFlowsAjaxQueue = (function() {
152
  return decodeURIComponent(results[2].replace(/\+/g, " "));
153
  },
154
 
155
- _set_category_slugs: function() {
156
-
157
- // API Request.
158
- var api_params = {
159
- _fields : CartFlowsImportVars.step_type_fields.toString(),
160
- };
161
-
162
- var api_post = {
163
- remote_slug : CartFlowsImportVars.step_type,
164
- slug : CartFlowsImportVars.step_type + '?' + decodeURIComponent( $.param( api_params ) ),
165
- };
166
-
167
- CartFlowsAPI._api_request( api_post, function( data ) {
168
- if( parseInt( data.items_count ) && $.isEmptyObject( CartFlowsImport._api_step_type ) ) {
169
- CartFlowsImport._api_step_type = data.items;
170
- }
171
- } );
172
- },
173
-
174
  /**
175
  * Binds events
176
  */
@@ -178,17 +159,19 @@ var CartFlowsAjaxQueue = (function() {
178
  {
179
  var self = CartFlowsImport;
180
 
 
 
181
  self.doc.on( 'cartflows-api-request-fail', self._api_request_failed );
182
  self.doc.on('click', '#wcf-get-started-steps a, .wcf-create-from-scratch-link', self._toggle_ready_templates);
183
  self.doc.on('click', '.cartflows-flow-import-blank', self._create_default_flow);
184
  self.doc.on('click', '#wcf-remote-flow-importer .wcf-page-builder-links a', self._filterFlowPageBuilderClick);
185
- self.doc.on('change', '#wcf-remote-step-importer #wcf-categories .step-type-filter-links', self._filterBlankStepCategoryChange );
186
  self.doc.on('change', '#wcf-remote-step-importer #wcf-scratch-steps-categories .step-type-filter-links', self._filterBlankStepCategoryChange );
187
  self.doc.on('click', '#wcf-remote-step-importer .wcf-page-builder-links a', self._filterStepPageBuilderClick );
188
 
189
  self.doc.on('click' , '.cartflows-step-import-blank:not(.get-pro)', self._create_blank_step);
190
- self.doc.on('click' , '#wcf-remote-step-importer .cartflows-step-import', self._import_step);
191
- self.doc.on('click' , '#wcf-remote-flow-importer .cartflows-step-import', self._import_flow);
192
 
193
  self.doc.on('click' , '.cartflows-preview-flow-step', self._preview_individual);
194
 
@@ -207,7 +190,142 @@ var CartFlowsAjaxQueue = (function() {
207
  $( document ).on( 'click', '.wcf-templates-popup-overlay', self._close_template_popup );
208
  $( document ).on( 'click', '.wcf-popup-close-wrap .close-icon', self._close_template_popup );
209
 
210
- // $( document ).on( 'click', '.wcf-tab > li > a', self._switch_step_tab );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  },
212
 
213
  _api_request_failed: function( event, data, jqXHR, textStatus ) {
@@ -234,7 +352,7 @@ var CartFlowsAjaxQueue = (function() {
234
  $('#wcf-start-from-scratch').hide();
235
  }
236
 
237
- if( $('#wcf-remote-step-importer').length ) {
238
  CartFlowsImport._showSteps();
239
  }
240
  },
@@ -335,12 +453,54 @@ var CartFlowsAjaxQueue = (function() {
335
  CartFlowsImport._showSteps();
336
  },
337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  _filterBlankStepCategoryChange: function( event ) {
339
  event.preventDefault();
340
 
341
  var val = $(this).find('option:selected').val() || '';
342
  if( val ) {
343
  $('.step-type-filter-links').val( val );
 
 
344
  }
345
 
346
  $('.step-type-filter-links').find('option').removeClass('current');
@@ -350,7 +510,6 @@ var CartFlowsAjaxQueue = (function() {
350
 
351
  if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
352
  $( '.wcf-template-notice' ).show();
353
-
354
  }else{
355
  $( '.wcf-template-notice' ).hide();
356
  }
@@ -367,8 +526,10 @@ var CartFlowsAjaxQueue = (function() {
367
  $('.cartflows-step-import-blank').removeAttr( 'target' );
368
  }
369
 
370
- $('#wcf-remote-step-list').html( '<span class="spinner is-active"></span>' );
371
- CartFlowsImport._showSteps();
 
 
372
  },
373
 
374
  _showSteps: function() {
@@ -391,7 +552,6 @@ var CartFlowsAjaxQueue = (function() {
391
  var type = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('group') || '';
392
  var step_type = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('slug') || '';
393
  var title = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('title') || 'Page Builder';
394
-
395
  if( '' !== type && 'all' !== type ) {
396
  api_params[ CartFlowsImportVars.step_page_builder ] = type;
397
  }
@@ -414,7 +574,8 @@ var CartFlowsAjaxQueue = (function() {
414
  $('.cartflows-no-steps').find( '.description' ).html( 'We are working on ready templates designed with '+title+'.<br/>Meanwhile you can <a href="#" data-slug="canvas" class="wcf-create-from-scratch-link">create your own designs</a> easily.' );
415
  }
416
 
417
- CartFlowsImport._showPageBuilderNotice();
 
418
  } );
419
  },
420
 
@@ -457,10 +618,43 @@ var CartFlowsAjaxQueue = (function() {
457
  }
458
  },
459
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  _cache_remote_flows: function() {
461
 
 
 
462
  // Add Params for API request.
463
  var api_params = {
 
464
  licence_args : CartFlowsImportVars.licence_args,
465
  hide_empty : false,
466
  _fields : CartFlowsImportVars.flow_page_builder_fields.toString(),
@@ -475,6 +669,7 @@ var CartFlowsAjaxQueue = (function() {
475
  };
476
 
477
  CartFlowsAPI._api_request( api_post, function( data ) {
 
478
  var template = wp.template('cartflows-term-filters');
479
  $('#wcf-page-builders').html(template( data ));
480
  $('#wcf-page-builders').find('li:first a').addClass('current');
@@ -502,7 +697,6 @@ var CartFlowsAjaxQueue = (function() {
502
 
503
  // Step 3: Flows.
504
  CartFlowsImport._showFlows();
505
-
506
  } );
507
  } );
508
  },
@@ -517,16 +711,48 @@ var CartFlowsAjaxQueue = (function() {
517
 
518
  $("html").addClass('wcf-popup-open');
519
 
520
- $("#wcf-remote-flow-importer .spinner").css( 'visibility', 'hidden' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  },
522
 
523
  _cache_remote_steps: function() {
524
 
 
 
525
  // Disable the button until caching the data.
526
  $( 'html' ).addClass('wcf-steps-loading');
527
 
528
  // Add Params for API request.
529
  var api_params = {
 
530
  licence_args : CartFlowsImportVars.licence_args,
531
  hide_empty : false,
532
  _fields : CartFlowsImportVars.step_page_builder_fields.toString(),
@@ -578,11 +804,6 @@ var CartFlowsAjaxQueue = (function() {
578
 
579
  api_params[ CartFlowsImportVars.step_type ] = data.items[ key ].id;
580
 
581
- var page_builder = $('.wcf-page-builder-links').find('.current').data('group') || '';
582
- if( page_builder ) {
583
- api_params[ CartFlowsImportVars.flow_page_builder ] = page_builder;
584
- }
585
-
586
  // API Request.
587
  var api_post = {
588
  remote_slug : CartFlowsImportVars.step,
@@ -601,12 +822,14 @@ var CartFlowsAjaxQueue = (function() {
601
 
602
  if( 0 == step_types_count ) {
603
 
604
- var template = wp.template('cartflows-term-filters');
 
605
  $('#wcf-categories').html(template( step_type_response_data ));
606
- $('#wcf-scratch-steps-categories').html(template( step_type_response_data ));
607
  $('#wcf-categories, #wcf-scratch-steps-categories').find('option:first').addClass('current');
608
  $('#wcf-categories').find('li:first a').addClass('current');
609
 
 
610
  $('#wcf-remote-content').find( '.spinner' ).remove();
611
 
612
  CartFlowsImport._showSteps();
@@ -620,7 +843,6 @@ var CartFlowsAjaxQueue = (function() {
620
  },
621
 
622
  _render_remote_steps: function( event ) {
623
-
624
  if( event ) {
625
  event.preventDefault();
626
  }
@@ -628,13 +850,6 @@ var CartFlowsAjaxQueue = (function() {
628
  $("#wcf-remote-step-importer").addClass('open');
629
 
630
  $("html").addClass('wcf-popup-open');
631
-
632
- if( $( 'html' ).hasClass('wcf-steps-loading') ) {
633
- $('#wcf-remote-content').append( '<span class="spinner is-active"></span>' );
634
- } else {
635
- CartFlowsImport._showSteps();
636
- }
637
-
638
  },
639
 
640
  _categorize_data: function( items ) {
@@ -806,24 +1021,6 @@ var CartFlowsAjaxQueue = (function() {
806
  CartFlowsImport._showFlows();
807
  },
808
 
809
- _showPageBuilderNotice: function() {
810
-
811
- var status = '';
812
-
813
- var slug = $( '#wcf-page-builders' ).find('.current').data('slug') || '';
814
- var title = $( '#wcf-page-builders' ).find('.current').data('title') || '';
815
-
816
- if( slug && CartFlowsImportVars.required_plugins[slug] && CartFlowsImportVars.required_plugins[slug].status ) {
817
- status = CartFlowsImportVars.required_plugins[slug].status;
818
- }
819
-
820
- if( title && status ) {
821
- if( 'install' === status || 'activate' === status ) {
822
- $('.wcf-page-builder-notice').html( '<div class="notice notice-info no-elementor-notice"><p><span class="dashicons dashicons-warning"></span> '+title+' is not available on this website. Importing a template will install and activate it automatically.</p></div>' );
823
- }
824
- }
825
- },
826
-
827
  _showFlows: function() {
828
  // Add Params for API request.
829
  var api_params = {
@@ -852,10 +1049,11 @@ var CartFlowsAjaxQueue = (function() {
852
  $('#wcf-remote-flow-list').html( template( data ) );
853
  } else {
854
  $('#wcf-remote-flow-list').html( wp.template('cartflows-no-flows') );
855
- $('.cartflows-no-flows').find( '.description' ).html( 'We are working on ready templates designed with '+title+'.<br/>Meanwhile you can <a href="#" data-slug="canvas" class="wcf-create-from-scratch-link">create your own designs</a> easily.' );
856
  }
857
 
858
- CartFlowsImport._showPageBuilderNotice();
 
859
  } );
860
  },
861
 
@@ -884,8 +1082,8 @@ var CartFlowsAjaxQueue = (function() {
884
 
885
  if( data.request.success ) {
886
 
 
887
 
888
- var flow_id = data.request.data; // $( 'form#post #post_ID').val();
889
  // Created.
890
  setTimeout(function() {
891
  btn.removeClass('updating-message').text('Flow Created! Redirecting..');
@@ -897,40 +1095,38 @@ var CartFlowsAjaxQueue = (function() {
897
 
898
  },
899
 
900
- _activate_plugin: function( plugin_slug ) {
901
 
902
  var self = CartFlowsImport;
903
 
904
  var data = {
905
  action : 'cartflows_activate_plugin',
906
- plugin_slug : plugin_slug
907
  };
908
 
909
  self._ajax( data, function( data ) {
910
  });
911
  },
912
 
913
- _process_import_flow: function( response )
914
  {
915
- var self = CartFlowsImport;
916
- var btn = $( '#wcf-remote-flow-importer .cartflows-step-import.updating-message' );
917
-
918
- var plugin_slug = '';
919
- plugin = response.slug;
920
-
921
- switch ( plugin ) {
922
- case 'elementor':
923
- plugin_slug = 'elementor/elementor.php';
924
- break;
925
- case 'beaver-builder-lite-version':
926
- plugin_slug = 'beaver-builder-lite-version/fl-builder.php';
927
- break;
928
  }
929
 
930
- self._activate_plugin( plugin_slug );
 
 
931
 
932
  btn.text( 'Creating Flow..' );
933
 
 
 
 
934
  var flow_steps_string = btn.data('flow-steps') || '';
935
  var flow_steps = ( '' !== flow_steps_string ) ? JSON.parse("[" + flow_steps_string + "]") : [];
936
 
@@ -944,7 +1140,7 @@ var CartFlowsAjaxQueue = (function() {
944
 
945
  if( data.request.success ) {
946
 
947
- var flow_id = data.request.data; // $( 'form#post #post_ID').val();
948
 
949
  if( flow_steps ) {
950
 
@@ -1036,64 +1232,6 @@ var CartFlowsAjaxQueue = (function() {
1036
  });
1037
  },
1038
 
1039
- _import_flow: function()
1040
- {
1041
- var btn = $( this );
1042
- var plugins_group = btn.data('required-plugin-group');
1043
-
1044
- if( ! CartFlowsImportVars.required_plugins[plugins_group] ) {
1045
- btn.text( 'Invalid plugin ' + plugins_group + '!' );
1046
- return;
1047
- }
1048
-
1049
- var plugins = CartFlowsImportVars.required_plugins[plugins_group]['plugins'];
1050
-
1051
- if( btn.hasClass('updating-message') ) {
1052
- return;
1053
- }
1054
-
1055
- $('#wcf-remote-flow-importer').addClass('request-process');
1056
-
1057
- if( ! $.isEmptyObject( plugins ) ) {
1058
-
1059
- btn.addClass('updating-message');
1060
- btn.parents('.template').addClass('importing');
1061
-
1062
- if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
1063
- wp.updates.requestFilesystemCredentials( event );
1064
- }
1065
-
1066
- $.each( plugins, function( index, plugin ) {
1067
-
1068
- var plugin_slug = plugin.slug;
1069
- var plugin_status = plugin.status;
1070
-
1071
- if( 'install' == plugin_status ) {
1072
-
1073
- btn.text( 'Installing..' );
1074
-
1075
- wp.updates.installPlugin({
1076
- slug : plugin_slug,
1077
- success : CartFlowsImport._process_import_flow,
1078
- error : CartFlowsImport._handle_error
1079
- });
1080
-
1081
- } else {
1082
-
1083
- if( 'activate' == plugin_status ) {
1084
- btn.text( 'Activating..' );
1085
- }
1086
-
1087
- var data = {
1088
- slug: plugin_slug
1089
- };
1090
-
1091
- CartFlowsImport._process_import_flow( data );
1092
- }
1093
- });
1094
- }
1095
- },
1096
-
1097
  _handle_error: function( response )
1098
  {
1099
  var btn = $( '.cartflows-step-import.updating-message' );
@@ -1124,7 +1262,6 @@ var CartFlowsAjaxQueue = (function() {
1124
  if ( ! CartFlowsImportVars._is_pro_active && ( 'upsell' === step_type || 'downsell' === step_type )) {
1125
  return;
1126
  }
1127
-
1128
 
1129
  btn.parents('.template').addClass('importing');
1130
 
@@ -1192,9 +1329,11 @@ var CartFlowsAjaxQueue = (function() {
1192
  }
1193
  },
1194
 
1195
- _process_import_step: function( response ) {
 
 
1196
 
1197
- var btn = $('#wcf-remote-step-importer .cartflows-step-import.updating-message'),
1198
  step_slug = btn.data('slug') || '',
1199
  step_count = $('.wcf-step-wrap[data-term-slug="'+step_slug+'"]').length || 1;
1200
  step_title = btn.data('title') || '',
@@ -1209,7 +1348,7 @@ var CartFlowsAjaxQueue = (function() {
1209
 
1210
  if ( 0 < checkout_steps.length ) {
1211
 
1212
- var parent_template = btn.parents('.template.importing');
1213
 
1214
  btn.removeClass('importing updating-message')
1215
  .text('Import Failed!');
@@ -1227,20 +1366,31 @@ var CartFlowsAjaxQueue = (function() {
1227
  }
1228
  }
1229
  }
1230
-
1231
- var plugin_slug = '';
1232
- plugin = response.slug;
1233
-
1234
- switch ( plugin ) {
1235
- case 'elementor':
1236
- plugin_slug = 'elementor/elementor.php';
1237
- break;
1238
- case 'beaver-builder-lite-version':
1239
- plugin_slug = 'beaver-builder-lite-version/fl-builder.php';
1240
- break;
1241
  }
1242
 
1243
- self._activate_plugin( plugin_slug );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1244
 
1245
  var template_id = btn.data('template-id') || '';
1246
  var flow_id = $("#post_ID").val();
@@ -1266,6 +1416,7 @@ var CartFlowsAjaxQueue = (function() {
1266
  // Import Template AJAX.
1267
  self._ajax( data, function( data ) {
1268
 
 
1269
  var self = CartFlowsImport;
1270
  var template = btn.parents('.template.importing');
1271
 
@@ -1273,6 +1424,7 @@ var CartFlowsAjaxQueue = (function() {
1273
  btn.text('Imported. Reloading..');
1274
  setTimeout(function() {
1275
  window.location.href = window.location.href + '&highlight-step-id=' + data.request.data;
 
1276
  }, 3000);
1277
 
1278
  } else {
@@ -1292,67 +1444,6 @@ var CartFlowsAjaxQueue = (function() {
1292
  }
1293
  },
1294
 
1295
- _import_step: function( event )
1296
- {
1297
- event.preventDefault();
1298
-
1299
- var btn = $( this );
1300
- var plugins_group = btn.data('required-plugin-group');
1301
-
1302
- if( ! CartFlowsImportVars.required_plugins[plugins_group] ) {
1303
- btn.text( 'Invalid plugin ' + plugins_group + '!' );
1304
- return;
1305
- }
1306
-
1307
- var plugins = CartFlowsImportVars.required_plugins[plugins_group]['plugins'];
1308
-
1309
- if( btn.hasClass('updating-message') ) {
1310
- return;
1311
- }
1312
-
1313
- btn.parents('.template').addClass('importing');
1314
- btn.addClass('updating-message');
1315
-
1316
- if( ! $.isEmptyObject( plugins ) ) {
1317
-
1318
- if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) {
1319
- wp.updates.requestFilesystemCredentials( event );
1320
- }
1321
-
1322
- $('#wcf-remote-step-importer').addClass('request-process');
1323
-
1324
- $.each( plugins, function( index, plugin ) {
1325
-
1326
- var plugin_slug = plugin.slug;
1327
- var plugin_status = plugin.status;
1328
-
1329
- if( 'install' == plugin_status ) {
1330
-
1331
- btn.text( 'Installing..' );
1332
-
1333
- wp.updates.installPlugin({
1334
- slug : plugin_slug,
1335
- success : CartFlowsImport._process_import_step,
1336
- error : CartFlowsImport._handle_error
1337
- });
1338
-
1339
- } else {
1340
-
1341
- if( 'activate' == plugin_status ) {
1342
- btn.text( 'Activating..' );
1343
- }
1344
-
1345
- var data = {
1346
- slug: plugin_slug
1347
- };
1348
-
1349
- CartFlowsImport._process_import_step( data );
1350
- }
1351
- });
1352
- }
1353
-
1354
- },
1355
-
1356
  _add_template_to_page_fail: function( event, jqXHR, textStatus ) {
1357
  event.preventDefault();
1358
  var self = CartFlowsImport,
93
 
94
  all_steps : 0,
95
  remaining_steps : 0,
96
+ remaining_install_plugins : 0,
97
+ remaining_active_plugins : 0,
98
 
99
  /**
100
  * Init
103
  {
104
  this._bind();
105
 
106
+ if( 'other' !== CartFlowsImportVars.default_page_builder ) {
107
+ if( $('.post-type-cartflows_flow').hasClass('edit-php') ) {
108
+ this._process_cache_remote_flows();
109
+ }
110
+ if( $('.post-type-cartflows_flow').hasClass('post-php') ) {
111
+ this._process_cache_remote_steps();
112
+ }
113
  }
114
 
 
 
 
 
 
 
115
  if( $('.post-type-cartflows_flow').hasClass('edit-php') && null !== this._getParamFromURL('add-new-flow') ) {
116
  this._render_remote_flows();
117
  }
 
118
  if( $('.post-type-cartflows_flow').hasClass('post-php') && null !== this._getParamFromURL('add-new-step') ) {
119
  this._render_remote_steps();
120
  }
152
  return decodeURIComponent(results[2].replace(/\+/g, " "));
153
  },
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  /**
156
  * Binds events
157
  */
159
  {
160
  var self = CartFlowsImport;
161
 
162
+ self.doc.on('click', '.wcf-install-plugin', self._install_plugin);
163
+
164
  self.doc.on( 'cartflows-api-request-fail', self._api_request_failed );
165
  self.doc.on('click', '#wcf-get-started-steps a, .wcf-create-from-scratch-link', self._toggle_ready_templates);
166
  self.doc.on('click', '.cartflows-flow-import-blank', self._create_default_flow);
167
  self.doc.on('click', '#wcf-remote-flow-importer .wcf-page-builder-links a', self._filterFlowPageBuilderClick);
168
+ self.doc.on('click', '#wcf-remote-step-importer #wcf-categories .step-type-filter-links a', self._filterBlankStepCategoryClick );
169
  self.doc.on('change', '#wcf-remote-step-importer #wcf-scratch-steps-categories .step-type-filter-links', self._filterBlankStepCategoryChange );
170
  self.doc.on('click', '#wcf-remote-step-importer .wcf-page-builder-links a', self._filterStepPageBuilderClick );
171
 
172
  self.doc.on('click' , '.cartflows-step-import-blank:not(.get-pro)', self._create_blank_step);
173
+ self.doc.on('click' , '#wcf-remote-step-importer .cartflows-step-import', self._process_import_step);
174
+ self.doc.on('click' , '#wcf-remote-flow-importer .cartflows-step-import', self._process_import_flow);
175
 
176
  self.doc.on('click' , '.cartflows-preview-flow-step', self._preview_individual);
177
 
190
  $( document ).on( 'click', '.wcf-templates-popup-overlay', self._close_template_popup );
191
  $( document ).on( 'click', '.wcf-popup-close-wrap .close-icon', self._close_template_popup );
192
 
193
+ $( document ).on('wp-plugin-install-success' , self._installSuccess);
194
+ },
195
+
196
+ _install_plugin: function( event ) {
197
+ event.preventDefault();
198
+
199
+ var btn = $( this );
200
+
201
+ if( btn.hasClass('updating-message') ) {
202
+ return;
203
+ }
204
+
205
+ $('#wcf-remote-flow-importer').addClass('request-process');
206
+ $('#wcf-remote-step-importer').addClass('request-process');
207
+
208
+ btn.addClass('updating-message button');
209
+
210
+ var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
211
+
212
+ $.each( page_builder_plugins, function( index, plugin ) {
213
+ if( 'install' === plugin.status ) {
214
+ CartFlowsImport.remaining_install_plugins++;
215
+ }
216
+ if( 'activate' === plugin.status ) {
217
+ CartFlowsImport.remaining_active_plugins++;
218
+ }
219
+ });
220
+
221
+ // Have any plugin for install?
222
+ if( CartFlowsImport.remaining_install_plugins ) {
223
+ CartFlowsImport._install_all_plugins();
224
+ } else if( CartFlowsImport.remaining_active_plugins ) {
225
+ CartFlowsImport._activate_all_plugins();
226
+ } else {
227
+ if( $('#wcf-remote-flow-importer').length ) {
228
+ CartFlowsImport._cache_remote_flows();
229
+ } else if( $('#wcf-remote-step-importer').length ) {
230
+ CartFlowsImport._cache_remote_steps();
231
+ }
232
+ }
233
+ },
234
+
235
+ _install_all_plugins: function() {
236
+
237
+ var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
238
+
239
+ $.each( page_builder_plugins, function( index, plugin ) {
240
+ if( 'install' === plugin.status ) {
241
+ // Add each plugin activate request in Ajax queue.
242
+ // @see wp-admin/js/updates.js
243
+ wp.updates.queue.push( {
244
+ action: 'install-plugin', // Required action.
245
+ data: {
246
+ slug: plugin.slug
247
+ }
248
+ } );
249
+ }
250
+ });
251
+
252
+ // Required to set queue.
253
+ wp.updates.queueChecker();
254
+ },
255
+
256
+ _activate_all_plugins: function() {
257
+
258
+ if( ! CartFlowsImport.remaining_active_plugins && ! CartFlowsImport.remaining_install_plugins ) {
259
+ if( $('#wcf-remote-flow-importer').length ) {
260
+ CartFlowsImport._cache_remote_flows();
261
+ } else if( $('#wcf-remote-step-importer').length ) {
262
+ CartFlowsImport._cache_remote_steps();
263
+ }
264
+ } else {
265
+ var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
266
+
267
+ // Activate ALl Plugins.
268
+ CartFlowsAjaxQueue.stop();
269
+ CartFlowsAjaxQueue.run();
270
+
271
+ $.each( page_builder_plugins, function( index, plugin ) {
272
+ if( 'activate' === plugin.status ) {
273
+
274
+ CartFlowsAjaxQueue.add({
275
+ url: CartFlowsImportVars.ajaxurl,
276
+ type: 'POST',
277
+ data: {
278
+ action : 'cartflows_activate_plugin',
279
+ plugin_init : plugin.init
280
+ },
281
+ success: function( result ) {
282
+
283
+ CartFlowsImport.remaining_active_plugins--;
284
+
285
+ if( ! CartFlowsImport.remaining_active_plugins && ! CartFlowsImport.remaining_install_plugins ) {
286
+ if( $('#wcf-remote-flow-importer').length ) {
287
+ CartFlowsImport._cache_remote_flows();
288
+ } else if( $('#wcf-remote-step-importer').length ) {
289
+ CartFlowsImport._cache_remote_steps();
290
+ }
291
+ }
292
+
293
+ }
294
+ });
295
+ }
296
+ });
297
+ }
298
+
299
+ },
300
+
301
+ _installSuccess: function( event, response ) {
302
+
303
+ event.preventDefault();
304
+
305
+ var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
306
+
307
+ $.each( page_builder_plugins, function( index, plugin ) {
308
+ if( 'install' === plugin.status && response.slug === plugin.slug ) {
309
+
310
+ $.ajax({
311
+ url : ajaxurl,
312
+ type : 'POST',
313
+ data : {
314
+ action : 'cartflows_activate_plugin',
315
+ plugin_init : plugin.init
316
+ },
317
+ })
318
+ .done(function( request, status, XHR )
319
+ {
320
+ CartFlowsImport.remaining_install_plugins--;
321
+
322
+ if( ! CartFlowsImport.remaining_install_plugins ) {
323
+ CartFlowsImport._activate_all_plugins();
324
+ }
325
+ });
326
+ }
327
+ });
328
+
329
  },
330
 
331
  _api_request_failed: function( event, data, jqXHR, textStatus ) {
352
  $('#wcf-start-from-scratch').hide();
353
  }
354
 
355
+ if( ! $('.wcf-page-builder-notice').length && $('#wcf-remote-step-importer').length ) {
356
  CartFlowsImport._showSteps();
357
  }
358
  },
453
  CartFlowsImport._showSteps();
454
  },
455
 
456
+ _filterBlankStepCategoryClick: function( event ) {
457
+ event.preventDefault();
458
+
459
+ $('.wcf-page-builder-notice').html( '' );
460
+
461
+ var val = $(this).data('group') || '';
462
+ if( val ) {
463
+ $('#wcf-scratch-steps-categories .step-type-filter-links').val( val );
464
+ $('#wcf-scratch-steps-categories .step-type-filter-links option').removeClass('current');
465
+ $('#wcf-scratch-steps-categories .step-type-filter-links option[data-group="'+val+'"]').addClass('current');
466
+ }
467
+
468
+ $('.step-type-filter-links').find('a').removeClass('current');
469
+ $(this).addClass('current');
470
+
471
+ $step_type = $(this).data('slug');
472
+
473
+ if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
474
+ $( '.wcf-template-notice' ).show();
475
+
476
+ }else{
477
+ $( '.wcf-template-notice' ).hide();
478
+ }
479
+
480
+ if( '' == CartFlowsImportVars._is_pro_active && ( 'upsell' == $step_type || 'downsell' == $step_type ) ) {
481
+ $('.cartflows-step-import-blank').text( 'Get Pro' );
482
+ $('.cartflows-step-import-blank').attr( 'href', CartFlowsImportVars.domain_url );
483
+ $('.cartflows-step-import-blank').attr( 'target', '_blank' );
484
+ $('.cartflows-step-import-blank').addClass('get-pro');
485
+ // // $('#wcf-remote-step-list').find('.cartflows-step-import-blank').attr( 'class', 'button button-primary' );
486
+ } else {
487
+ $('.cartflows-step-import-blank').text( 'Create Step' );
488
+ $('.cartflows-step-import-blank').removeClass( 'get-pro' );
489
+ $('.cartflows-step-import-blank').removeAttr( 'target' );
490
+ }
491
+
492
+ $('#wcf-remote-step-list').html( '<span class="spinner is-active"></span>' );
493
+ CartFlowsImport._showSteps();
494
+ },
495
+
496
  _filterBlankStepCategoryChange: function( event ) {
497
  event.preventDefault();
498
 
499
  var val = $(this).find('option:selected').val() || '';
500
  if( val ) {
501
  $('.step-type-filter-links').val( val );
502
+ $('.step-type-filter-links').find('a').removeClass('current');
503
+ $('.step-type-filter-links').find('a[data-group="'+val+'"]').addClass('current');
504
  }
505
 
506
  $('.step-type-filter-links').find('option').removeClass('current');
510
 
511
  if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
512
  $( '.wcf-template-notice' ).show();
 
513
  }else{
514
  $( '.wcf-template-notice' ).hide();
515
  }
526
  $('.cartflows-step-import-blank').removeAttr( 'target' );
527
  }
528
 
529
+ if( ! $('.wcf-page-builder-notice').length && $('#wcf-remote-step-importer').length ) {
530
+ $('#wcf-remote-step-list').html( '<span class="spinner is-active"></span>' );
531
+ CartFlowsImport._showSteps();
532
+ }
533
  },
534
 
535
  _showSteps: function() {
552
  var type = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('group') || '';
553
  var step_type = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('slug') || '';
554
  var title = $('#wcf-page-builders .wcf-page-builder-links').find('.current').data('title') || 'Page Builder';
 
555
  if( '' !== type && 'all' !== type ) {
556
  api_params[ CartFlowsImportVars.step_page_builder ] = type;
557
  }
574
  $('.cartflows-no-steps').find( '.description' ).html( 'We are working on ready templates designed with '+title+'.<br/>Meanwhile you can <a href="#" data-slug="canvas" class="wcf-create-from-scratch-link">create your own designs</a> easily.' );
575
  }
576
 
577
+ $('.wcf-page-builder-notice').remove();
578
+ $('#wcf-remote-step-importer').removeClass('request-process');
579
  } );
580
  },
581
 
618
  }
619
  },
620
 
621
+ _process_cache_remote_flows: function() {
622
+
623
+
624
+ if( 'gutenberg' == CartFlowsImportVars.default_page_builder ) {
625
+ CartFlowsImport._cache_remote_flows();
626
+ } else {
627
+ var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
628
+
629
+ var anyInactive = true;
630
+
631
+ $.each( page_builder_plugins, function( index, plugin ) {
632
+
633
+ if( anyInactive ) {
634
+ if( 'install' === plugin.status || 'activate' === plugin.status ) {
635
+ anyInactive = false;
636
+ }
637
+ }
638
+ });
639
+
640
+ if( false === anyInactive ) {
641
+ $('.wcf-page-builder-notice').html( wp.template('cartflows-page-builder-notice') );
642
+ $('#wcf-remote-flow-list').find( '.spinner' ).remove();
643
+ } else {
644
+ CartFlowsImport._cache_remote_flows();
645
+ }
646
+ }
647
+
648
+
649
+ },
650
+
651
  _cache_remote_flows: function() {
652
 
653
+ var self = CartFlowsImport;
654
+
655
  // Add Params for API request.
656
  var api_params = {
657
+ search : CartFlowsImportVars.default_page_builder,
658
  licence_args : CartFlowsImportVars.licence_args,
659
  hide_empty : false,
660
  _fields : CartFlowsImportVars.flow_page_builder_fields.toString(),
669
  };
670
 
671
  CartFlowsAPI._api_request( api_post, function( data ) {
672
+
673
  var template = wp.template('cartflows-term-filters');
674
  $('#wcf-page-builders').html(template( data ));
675
  $('#wcf-page-builders').find('li:first a').addClass('current');
697
 
698
  // Step 3: Flows.
699
  CartFlowsImport._showFlows();
 
700
  } );
701
  } );
702
  },
711
 
712
  $("html").addClass('wcf-popup-open');
713
 
714
+ },
715
+
716
+ _process_cache_remote_steps: function() {
717
+
718
+ if( 'gutenberg' == CartFlowsImportVars.default_page_builder ) {
719
+ CartFlowsImport._cache_remote_steps();
720
+ } else {
721
+
722
+ var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
723
+
724
+
725
+ var anyInactive = true;
726
+
727
+ $.each( page_builder_plugins, function( index, plugin ) {
728
+
729
+ if( anyInactive ) {
730
+ if( 'install' === plugin.status || 'activate' === plugin.status ) {
731
+ anyInactive = false;
732
+ }
733
+ }
734
+ });
735
+
736
+ if( false === anyInactive ) {
737
+ $('.wcf-page-builder-notice').html( wp.template('cartflows-page-builder-notice') );
738
+ $('#wcf-remote-step-list').find( '.spinner' ).remove();
739
+ } else {
740
+ CartFlowsImport._cache_remote_steps();
741
+ }
742
+ }
743
+
744
  },
745
 
746
  _cache_remote_steps: function() {
747
 
748
+ var self = CartFlowsImport;
749
+
750
  // Disable the button until caching the data.
751
  $( 'html' ).addClass('wcf-steps-loading');
752
 
753
  // Add Params for API request.
754
  var api_params = {
755
+ search : CartFlowsImportVars.default_page_builder,
756
  licence_args : CartFlowsImportVars.licence_args,
757
  hide_empty : false,
758
  _fields : CartFlowsImportVars.step_page_builder_fields.toString(),
804
 
805
  api_params[ CartFlowsImportVars.step_type ] = data.items[ key ].id;
806
 
 
 
 
 
 
807
  // API Request.
808
  var api_post = {
809
  remote_slug : CartFlowsImportVars.step,
822
 
823
  if( 0 == step_types_count ) {
824
 
825
+ var template_dropdown = wp.template('cartflows-term-filters-dropdown');
826
+ var template = wp.template('cartflows-term-filters');
827
  $('#wcf-categories').html(template( step_type_response_data ));
828
+ $('#wcf-scratch-steps-categories').html(template_dropdown( step_type_response_data ));
829
  $('#wcf-categories, #wcf-scratch-steps-categories').find('option:first').addClass('current');
830
  $('#wcf-categories').find('li:first a').addClass('current');
831
 
832
+ $('.wcf-page-builder-notice').remove();
833
  $('#wcf-remote-content').find( '.spinner' ).remove();
834
 
835
  CartFlowsImport._showSteps();
843
  },
844
 
845
  _render_remote_steps: function( event ) {
 
846
  if( event ) {
847
  event.preventDefault();
848
  }
850
  $("#wcf-remote-step-importer").addClass('open');
851
 
852
  $("html").addClass('wcf-popup-open');
 
 
 
 
 
 
 
853
  },
854
 
855
  _categorize_data: function( items ) {
1021
  CartFlowsImport._showFlows();
1022
  },
1023
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1024
  _showFlows: function() {
1025
  // Add Params for API request.
1026
  var api_params = {
1049
  $('#wcf-remote-flow-list').html( template( data ) );
1050
  } else {
1051
  $('#wcf-remote-flow-list').html( wp.template('cartflows-no-flows') );
1052
+ // $('.cartflows-no-flows').find( '.description' ).html( 'We are working on ready templates designed with '+title+'.<br/>Meanwhile you can <a href="#" data-slug="canvas" class="wcf-create-from-scratch-link">create your own designs</a> easily.' );
1053
  }
1054
 
1055
+ $('.wcf-page-builder-notice').remove();
1056
+ $('#wcf-remote-flow-importer').removeClass('request-process');
1057
  } );
1058
  },
1059
 
1082
 
1083
  if( data.request.success ) {
1084
 
1085
+ var flow_id = data.request.data;
1086
 
 
1087
  // Created.
1088
  setTimeout(function() {
1089
  btn.removeClass('updating-message').text('Flow Created! Redirecting..');
1095
 
1096
  },
1097
 
1098
+ _activate_plugin: function( plugin_init ) {
1099
 
1100
  var self = CartFlowsImport;
1101
 
1102
  var data = {
1103
  action : 'cartflows_activate_plugin',
1104
+ plugin_init : plugin_init
1105
  };
1106
 
1107
  self._ajax( data, function( data ) {
1108
  });
1109
  },
1110
 
1111
+ _process_import_flow: function( event )
1112
  {
1113
+ event.preventDefault();
1114
+
1115
+ var btn = $( this );
1116
+
1117
+ if( btn.hasClass('updating-message') ) {
1118
+ return;
 
 
 
 
 
 
 
1119
  }
1120
 
1121
+ $('#wcf-remote-flow-importer').addClass('request-process');
1122
+
1123
+ var self = CartFlowsImport;
1124
 
1125
  btn.text( 'Creating Flow..' );
1126
 
1127
+ btn.addClass('updating-message');
1128
+ btn.parents('.template').addClass('importing');
1129
+
1130
  var flow_steps_string = btn.data('flow-steps') || '';
1131
  var flow_steps = ( '' !== flow_steps_string ) ? JSON.parse("[" + flow_steps_string + "]") : [];
1132
 
1140
 
1141
  if( data.request.success ) {
1142
 
1143
+ var flow_id = data.request.data;
1144
 
1145
  if( flow_steps ) {
1146
 
1232
  });
1233
  },
1234
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1235
  _handle_error: function( response )
1236
  {
1237
  var btn = $( '.cartflows-step-import.updating-message' );
1262
  if ( ! CartFlowsImportVars._is_pro_active && ( 'upsell' === step_type || 'downsell' === step_type )) {
1263
  return;
1264
  }
 
1265
 
1266
  btn.parents('.template').addClass('importing');
1267
 
1329
  }
1330
  },
1331
 
1332
+ _process_import_step: function( event ) {
1333
+
1334
+ event.preventDefault();
1335
 
1336
+ var btn = $( this ),
1337
  step_slug = btn.data('slug') || '',
1338
  step_count = $('.wcf-step-wrap[data-term-slug="'+step_slug+'"]').length || 1;
1339
  step_title = btn.data('title') || '',
1348
 
1349
  if ( 0 < checkout_steps.length ) {
1350
 
1351
+ var parent_template = btn.parents('.template');
1352
 
1353
  btn.removeClass('importing updating-message')
1354
  .text('Import Failed!');
1366
  }
1367
  }
1368
  }
1369
+
1370
+ if( btn.hasClass('updating-message') ) {
1371
+ return;
 
 
 
 
 
 
 
 
1372
  }
1373
 
1374
+ $('#wcf-remote-step-importer').addClass('request-process');
1375
+
1376
+ var self = CartFlowsImport;
1377
+
1378
+ btn.addClass('updating-message');
1379
+ btn.parents('.template').addClass('importing');
1380
+
1381
+ // var plugin_slug = '';
1382
+ // plugin = response.slug;
1383
+
1384
+ // switch ( plugin ) {
1385
+ // case 'elementor':
1386
+ // plugin_slug = 'elementor/elementor.php';
1387
+ // break;
1388
+ // case 'beaver-builder-lite-version':
1389
+ // plugin_slug = 'beaver-builder-lite-version/fl-builder.php';
1390
+ // break;
1391
+ // }
1392
+
1393
+ // self._activate_plugin( plugin_slug );
1394
 
1395
  var template_id = btn.data('template-id') || '';
1396
  var flow_id = $("#post_ID").val();
1416
  // Import Template AJAX.
1417
  self._ajax( data, function( data ) {
1418
 
1419
+
1420
  var self = CartFlowsImport;
1421
  var template = btn.parents('.template.importing');
1422
 
1424
  btn.text('Imported. Reloading..');
1425
  setTimeout(function() {
1426
  window.location.href = window.location.href + '&highlight-step-id=' + data.request.data;
1427
+
1428
  }, 3000);
1429
 
1430
  } else {
1444
  }
1445
  },
1446
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1447
  _add_template_to_page_fail: function( event, jqXHR, textStatus ) {
1448
  event.preventDefault();
1449
  var self = CartFlowsImport,
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.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.1.4
7
  * Author: CartFlows Inc
8
  * Author URI: https://cartflows.com/
9
  * Text Domain: cartflows
changelog.txt CHANGED
@@ -1,3 +1,9 @@
 
 
 
 
 
 
1
  Version 1.1.3 - Tuesday, 15th January 2019
2
  - New: Import / Export the flows
3
  - Improvement: Pixel Caffeine plugin pixel compatibility added.
1
+ Version 1.1.4 - Tuesday, 22nd January 2019
2
+ - New: Beaver Builder templates.
3
+ - Improvement: Better error handling on the checkout page.
4
+ - Fix: Product variants were not getting aligned properly in the order summary.
5
+ - Fix: Divi builder conflict.
6
+
7
  Version 1.1.3 - Tuesday, 15th January 2019
8
  - New: Import / Export the flows
9
  - Improvement: Pixel Caffeine plugin pixel compatibility added.
classes/batch-process/class-cartflows-batch-process.php CHANGED
@@ -1,156 +1,244 @@
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
- * Initiator
49
- *
50
- * @since 1.0.0
51
- * @return object initialized object of class.
52
- */
53
- public static function get_instance() {
54
- if ( ! isset( self::$instance ) ) {
55
- self::$instance = new self;
56
- }
57
- return self::$instance;
58
- }
59
-
60
- /**
61
- * Constructor
62
- *
63
- * @since 1.0.0
64
- */
65
- public function __construct() {
66
-
67
- // Not BB or Elementor then avoid importer.
68
- if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
69
- return;
70
- }
71
-
72
- // Core Helpers - Image.
73
- require_once ABSPATH . 'wp-admin/includes/image.php';
74
-
75
- // Core Helpers - Batch Processing.
76
- require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-cartflows-importer-image.php';
77
- require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
78
- require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';
79
-
80
- // Elementor.
81
- if ( class_exists( '\Elementor\Plugin' ) ) {
82
- // Add "elementor" in import [queue].
83
- // @todo Remove required `allow_url_fopen` support.
84
- if ( ini_get( 'allow_url_fopen' ) ) {
85
- require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
86
- require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor-batch.php';
87
- self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
88
- }
89
- }
90
-
91
- // Beaver Builder.
92
- if ( class_exists( 'FLBuilder' ) ) {
93
- require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder.php';
94
- require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder-batch.php';
95
- self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
96
- }
97
-
98
- // Start image importing after site import complete.
99
- add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
100
- add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
101
- }
102
-
103
- /**
104
- * Batch Process Complete.
105
- *
106
- * @return void
107
- */
108
- public function complete_batch_import() {
109
- wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
110
- }
111
-
112
- /**
113
- * Start Image Import
114
- *
115
- * @param integer $post_id Post Id.
116
- *
117
- * @return void
118
- */
119
- public function start_batch_process( $post_id = '' ) {
120
-
121
- wcf()->logger->import_log( '(✓) BATCH Started!' );
122
- wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
123
-
124
- // Add "elementor" in import [queue].
125
- if ( self::$batch_instance_bb ) {
126
-
127
- // Add to queue.
128
- self::$batch_instance_bb->push_to_queue( $post_id );
129
-
130
- // Dispatch Queue.
131
- self::$batch_instance_bb->save()->dispatch();
132
-
133
- wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
134
-
135
- } elseif ( self::$batch_instance_elementor ) {
136
-
137
- // Add to queue.
138
- self::$batch_instance_elementor->push_to_queue( $post_id );
139
-
140
- // Dispatch Queue.
141
- self::$batch_instance_elementor->save()->dispatch();
142
-
143
- wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
144
- } else {
145
- wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
146
- }
147
- }
148
-
149
- }
150
-
151
- /**
152
- * Kicking this off by calling 'get_instance()' method
153
- */
154
- CartFlows_Batch_Process::get_instance();
155
-
156
- 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
+ * Initiator
49
+ *
50
+ * @since 1.0.0
51
+ * @return object initialized object of class.
52
+ */
53
+ public static function get_instance() {
54
+ if ( ! isset( self::$instance ) ) {
55
+ self::$instance = new self;
56
+ }
57
+ return self::$instance;
58
+ }
59
+
60
+ /**
61
+ * Constructor
62
+ *
63
+ * @since 1.0.0
64
+ */
65
+ public function __construct() {
66
+
67
+ // Not BB or Elementor then avoid importer.
68
+ if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
69
+ return;
70
+ }
71
+
72
+ // Core Helpers - Image.
73
+ require_once ABSPATH . 'wp-admin/includes/image.php';
74
+
75
+ // Core Helpers - Batch Processing.
76
+ require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-cartflows-importer-image.php';
77
+ require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
78
+ require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';
79
+
80
+ // Elementor.
81
+ if ( class_exists( '\Elementor\Plugin' ) ) {
82
+ // Add "elementor" in import [queue].
83
+ // @todo Remove required `allow_url_fopen` support.
84
+ if ( ini_get( 'allow_url_fopen' ) ) {
85
+ require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
86
+ require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor-batch.php';
87
+ self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
88
+ }
89
+ }
90
+
91
+ // Beaver Builder.
92
+ if ( class_exists( 'FLBuilder' ) ) {
93
+ require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder.php';
94
+ require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder-batch.php';
95
+ self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
96
+ }
97
+
98
+ // Start image importing after site import complete.
99
+ add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
100
+ add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
101
+ add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
102
+ add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
103
+ }
104
+
105
+ /**
106
+ * Added .svg files as supported format in the uploader.
107
+ *
108
+ * @since 1.1.4
109
+ *
110
+ * @param array $mimes Already supported mime types.
111
+ */
112
+ public function custom_upload_mimes( $mimes ) {
113
+
114
+ // Allow SVG files.
115
+ $mimes['svg'] = 'image/svg+xml';
116
+ $mimes['svgz'] = 'image/svg+xml';
117
+
118
+ // Allow XML files.
119
+ $mimes['xml'] = 'text/xml';
120
+
121
+ return $mimes;
122
+ }
123
+
124
+ /**
125
+ * Add SVG image support
126
+ *
127
+ * @since 1.1.4
128
+ *
129
+ * @param array $response Attachment response.
130
+ * @param object $attachment Attachment object.
131
+ * @param array $meta Attachment meta data.
132
+ */
133
+ function add_svg_image_support( $response, $attachment, $meta ) {
134
+ if ( ! function_exists( 'simplexml_load_file' ) ) {
135
+ return $response;
136
+ }
137
+
138
+ if ( ! empty( $response['sizes'] ) ) {
139
+ return $response;
140
+ }
141
+
142
+ if ( 'image/svg+xml' !== $response['mime'] ) {
143
+ return $response;
144
+ }
145
+
146
+ $svg_path = get_attached_file( $attachment->ID );
147
+
148
+ $dimensions = self::get_svg_dimensions( $svg_path );
149
+
150
+ $response['sizes'] = array(
151
+ 'full' => array(
152
+ 'url' => $response['url'],
153
+ 'width' => $dimensions->width,
154
+ 'height' => $dimensions->height,
155
+ 'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
156
+ ),
157
+ );
158
+
159
+ return $response;
160
+ }
161
+
162
+ /**
163
+ * Get SVG Dimensions
164
+ *
165
+ * @since 1.1.4.
166
+ *
167
+ * @param string $svg SVG file path.
168
+ * @return array Return SVG file height & width for valid SVG file.
169
+ */
170
+ public static function get_svg_dimensions( $svg ) {
171
+
172
+ $svg = simplexml_load_file( $svg );
173
+
174
+ if ( false === $svg ) {
175
+ $width = '0';
176
+ $height = '0';
177
+ } else {
178
+ $attributes = $svg->attributes();
179
+ $width = (string) $attributes->width;
180
+ $height = (string) $attributes->height;
181
+ }
182
+
183
+ return (object) array(
184
+ 'width' => $width,
185
+ 'height' => $height,
186
+ );
187
+ }
188
+
189
+ /**
190
+ * Batch Process Complete.
191
+ *
192
+ * @return void
193
+ */
194
+ public function complete_batch_import() {
195
+ wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
196
+ }
197
+
198
+ /**
199
+ * Start Image Import
200
+ *
201
+ * @param integer $post_id Post Id.
202
+ *
203
+ * @return void
204
+ */
205
+ public function start_batch_process( $post_id = '' ) {
206
+
207
+ $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
208
+
209
+ wcf()->logger->import_log( '(✓) BATCH Started!' );
210
+ wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
211
+
212
+ // Add "elementor" in import [queue].
213
+ if ( 'beaver-builder' === $default_page_builder && self::$batch_instance_bb ) {
214
+
215
+ // Add to queue.
216
+ self::$batch_instance_bb->push_to_queue( $post_id );
217
+
218
+ // Dispatch Queue.
219
+ self::$batch_instance_bb->save()->dispatch();
220
+
221
+ wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
222
+
223
+ } elseif ( 'elementor' === $default_page_builder && self::$batch_instance_elementor ) {
224
+
225
+ // Add to queue.
226
+ self::$batch_instance_elementor->push_to_queue( $post_id );
227
+
228
+ // Dispatch Queue.
229
+ self::$batch_instance_elementor->save()->dispatch();
230
+
231
+ wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
232
+ } else {
233
+ wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
234
+ }
235
+ }
236
+
237
+ }
238
+
239
+ /**
240
+ * Kicking this off by calling 'get_instance()' method
241
+ */
242
+ CartFlows_Batch_Process::get_instance();
243
+
244
+ endif;
classes/batch-process/class-cartflows-importer-beaver-builder.php CHANGED
@@ -1,228 +1,229 @@
1
- <?php
2
- /**
3
- * Beaver Builder Importer
4
- *
5
- * @package CartFlows
6
- * @since 1.1.1
7
- */
8
-
9
- if ( ! class_exists( 'CartFlows_Importer_Beaver_Builder' ) ) :
10
-
11
- /**
12
- * CartFlows Import Beaver Builder
13
- *
14
- * @since 1.1.1
15
- */
16
- class CartFlows_Importer_Beaver_Builder {
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
- /**
50
- * Update post meta.
51
- *
52
- * @param integer $post_id Post ID.
53
- * @return void
54
- */
55
- public function import_single_post( $post_id = 0 ) {
56
-
57
- $data = get_post_meta( $post_id, '_fl_builder_data', true );
58
- if ( ! empty( $data ) ) {
59
-
60
- // Download Images.
61
- $data = $this->get_import_data( $data );
62
-
63
- // Update page builder data.
64
- update_post_meta( $post_id, '_fl_builder_data', $data );
65
- update_post_meta( $post_id, '_fl_builder_draft', $data );
66
-
67
- // Clear all cache.
68
- FLBuilderModel::delete_asset_cache_for_all_posts();
69
- }
70
- }
71
-
72
- /**
73
- * Update post meta.
74
- *
75
- * @param array $data Page builder data.
76
- * @return mixed
77
- */
78
- public function get_import_data( $data ) {
79
-
80
- if ( empty( $data ) ) {
81
- return array();
82
- }
83
-
84
- foreach ( $data as $key => $el ) {
85
-
86
- // Import 'row' images.
87
- if ( 'row' === $el->type ) {
88
- $data[ $key ]->settings = self::import_row_images( $el->settings );
89
- }
90
-
91
- // Import 'module' images.
92
- if ( 'module' === $el->type ) {
93
- $data[ $key ]->settings = self::import_module_images( $el->settings );
94
- }
95
-
96
- // Import 'column' images.
97
- if ( 'column' === $el->type ) {
98
- $data[ $key ]->settings = self::import_column_images( $el->settings );
99
- }
100
- }
101
-
102
- return $data;
103
- }
104
-
105
- /**
106
- * Import Module Images.
107
- *
108
- * @param object $settings Module settings object.
109
- * @return object
110
- */
111
- public static function import_module_images( $settings ) {
112
-
113
- /**
114
- * 1) Set photos.
115
- */
116
- $settings = self::import_photo( $settings );
117
-
118
- /**
119
- * 2) Set `$settings->data` for Only type 'image-icon'
120
- *
121
- * @todo Remove the condition `'image-icon' === $settings->type` if `$settings->data` is used only for the Image Icon.
122
- */
123
- if (
124
- isset( $settings->data ) &&
125
- isset( $settings->photo ) && ! empty( $settings->photo ) &&
126
- 'image-icon' === $settings->type
127
- ) {
128
- $settings->data = FLBuilderPhoto::get_attachment_data( $settings->photo );
129
- }
130
-
131
- /**
132
- * 3) Set `list item` module images
133
- */
134
- if ( isset( $settings->add_list_item ) ) {
135
- foreach ( $settings->add_list_item as $key => $value ) {
136
- $settings->add_list_item[ $key ] = self::import_photo( $value );
137
- }
138
- }
139
-
140
- return $settings;
141
- }
142
-
143
- /**
144
- * Import Column Images.
145
- *
146
- * @param object $settings Column settings object.
147
- * @return object
148
- */
149
- public static function import_column_images( $settings ) {
150
-
151
- // 1) Set BG Images.
152
- $settings = self::import_bg_image( $settings );
153
-
154
- return $settings;
155
- }
156
-
157
- /**
158
- * Import Row Images.
159
- *
160
- * @param object $settings Row settings object.
161
- * @return object
162
- */
163
- public static function import_row_images( $settings ) {
164
-
165
- // 1) Set BG Images.
166
- $settings = self::import_bg_image( $settings );
167
-
168
- return $settings;
169
- }
170
-
171
- /**
172
- * Helper: Import BG Images.
173
- *
174
- * @param object $settings Row settings object.
175
- * @return object
176
- */
177
- public static function import_bg_image( $settings ) {
178
-
179
- if (
180
- ( ! empty( $settings->bg_image ) && ! empty( $settings->bg_image_src ) )
181
- ) {
182
- $image = array(
183
- 'url' => $settings->bg_image_src,
184
- 'id' => $settings->bg_image,
185
- );
186
-
187
- $downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
188
-
189
- $settings->bg_image_src = $downloaded_image['url'];
190
- $settings->bg_image = $downloaded_image['id'];
191
- }
192
-
193
- return $settings;
194
- }
195
-
196
- /**
197
- * Helper: Import Photo.
198
- *
199
- * @param object $settings Row settings object.
200
- * @return object
201
- */
202
- public static function import_photo( $settings ) {
203
-
204
- if ( ! empty( $settings->photo ) && ! empty( $settings->photo_src ) ) {
205
-
206
- $image = array(
207
- 'url' => $settings->photo_src,
208
- 'id' => $settings->photo,
209
- );
210
-
211
- $downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
212
-
213
- $settings->photo_src = $downloaded_image['url'];
214
- $settings->photo = $downloaded_image['id'];
215
- }
216
-
217
- return $settings;
218
- }
219
-
220
-
221
- }
222
-
223
- /**
224
- * Initialize class object with 'get_instance()' method
225
- */
226
- CartFlows_Importer_Beaver_Builder::get_instance();
227
-
228
- endif;
 
1
+ <?php
2
+ /**
3
+ * Beaver Builder Importer
4
+ *
5
+ * @package CartFlows
6
+ * @since 1.1.1
7
+ */
8
+
9
+ if ( ! class_exists( 'CartFlows_Importer_Beaver_Builder' ) ) :
10
+
11
+ /**
12
+ * CartFlows Import Beaver Builder
13
+ *
14
+ * @since 1.1.1
15
+ */
16
+ class CartFlows_Importer_Beaver_Builder {
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
+ /**
50
+ * Update post meta.
51
+ *
52
+ * @param integer $post_id Post ID.
53
+ * @return void
54
+ */
55
+ public function import_single_post( $post_id = 0 ) {
56
+
57
+ $data = get_post_meta( $post_id, '_fl_builder_data', true );
58
+ if ( ! empty( $data ) ) {
59
+
60
+ $data = $this->get_import_data( $data );
61
+
62
+ // Update page builder data.
63
+ update_post_meta( $post_id, '_fl_builder_data', $data );
64
+ update_post_meta( $post_id, '_fl_builder_draft', $data );
65
+
66
+ // Clear all cache.
67
+ FLBuilderModel::delete_asset_cache_for_all_posts();
68
+ } else {
69
+ wcf()->logger->import_log( '(✕) Not have "Beaver Builder" Data. Post meta _fl_builder_data is empty!' );
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Update post meta.
75
+ *
76
+ * @param array $data Page builder data.
77
+ * @return mixed
78
+ */
79
+ public function get_import_data( $data ) {
80
+
81
+ if ( empty( $data ) ) {
82
+ return array();
83
+ }
84
+
85
+ foreach ( $data as $key => $el ) {
86
+
87
+ // Import 'row' images.
88
+ if ( 'row' === $el->type ) {
89
+ $data[ $key ]->settings = self::import_row_images( $el->settings );
90
+ }
91
+
92
+ // Import 'module' images.
93
+ if ( 'module' === $el->type ) {
94
+ $data[ $key ]->settings = self::import_module_images( $el->settings );
95
+ }
96
+
97
+ // Import 'column' images.
98
+ if ( 'column' === $el->type ) {
99
+ $data[ $key ]->settings = self::import_column_images( $el->settings );
100
+ }
101
+ }
102
+
103
+ return $data;
104
+ }
105
+
106
+ /**
107
+ * Import Module Images.
108
+ *
109
+ * @param object $settings Module settings object.
110
+ * @return object
111
+ */
112
+ public static function import_module_images( $settings ) {
113
+
114
+ /**
115
+ * 1) Set photos.
116
+ */
117
+ $settings = self::import_photo( $settings );
118
+
119
+ /**
120
+ * 2) Set `$settings->data` for Only type 'image-icon'
121
+ *
122
+ * @todo Remove the condition `'image-icon' === $settings->type` if `$settings->data` is used only for the Image Icon.
123
+ */
124
+ if (
125
+ isset( $settings->data ) &&
126
+ isset( $settings->photo ) && ! empty( $settings->photo ) &&
127
+ 'image-icon' === $settings->type
128
+ ) {
129
+ $settings->data = FLBuilderPhoto::get_attachment_data( $settings->photo );
130
+ }
131
+
132
+ /**
133
+ * 3) Set `list item` module images
134
+ */
135
+ if ( isset( $settings->add_list_item ) ) {
136
+ foreach ( $settings->add_list_item as $key => $value ) {
137
+ $settings->add_list_item[ $key ] = self::import_photo( $value );
138
+ }
139
+ }
140
+
141
+ return $settings;
142
+ }
143
+
144
+ /**
145
+ * Import Column Images.
146
+ *
147
+ * @param object $settings Column settings object.
148
+ * @return object
149
+ */
150
+ public static function import_column_images( $settings ) {
151
+
152
+ // 1) Set BG Images.
153
+ $settings = self::import_bg_image( $settings );
154
+
155
+ return $settings;
156
+ }
157
+
158
+ /**
159
+ * Import Row Images.
160
+ *
161
+ * @param object $settings Row settings object.
162
+ * @return object
163
+ */
164
+ public static function import_row_images( $settings ) {
165
+
166
+ // 1) Set BG Images.
167
+ $settings = self::import_bg_image( $settings );
168
+
169
+ return $settings;
170
+ }
171
+
172
+ /**
173
+ * Helper: Import BG Images.
174
+ *
175
+ * @param object $settings Row settings object.
176
+ * @return object
177
+ */
178
+ public static function import_bg_image( $settings ) {
179
+
180
+ if (
181
+ ( ! empty( $settings->bg_image ) && ! empty( $settings->bg_image_src ) )
182
+ ) {
183
+ $image = array(
184
+ 'url' => $settings->bg_image_src,
185
+ 'id' => $settings->bg_image,
186
+ );
187
+
188
+ $downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
189
+
190
+ $settings->bg_image_src = $downloaded_image['url'];
191
+ $settings->bg_image = $downloaded_image['id'];
192
+ }
193
+
194
+ return $settings;
195
+ }
196
+
197
+ /**
198
+ * Helper: Import Photo.
199
+ *
200
+ * @param object $settings Row settings object.
201
+ * @return object
202
+ */
203
+ public static function import_photo( $settings ) {
204
+
205
+ if ( ! empty( $settings->photo ) && ! empty( $settings->photo_src ) ) {
206
+
207
+ $image = array(
208
+ 'url' => $settings->photo_src,
209
+ 'id' => $settings->photo,
210
+ );
211
+
212
+ $downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
213
+
214
+ $settings->photo_src = $downloaded_image['url'];
215
+ $settings->photo = $downloaded_image['id'];
216
+ }
217
+
218
+ return $settings;
219
+ }
220
+
221
+
222
+ }
223
+
224
+ /**
225
+ * Initialize class object with 'get_instance()' method
226
+ */
227
+ CartFlows_Importer_Beaver_Builder::get_instance();
228
+
229
+ endif;
classes/batch-process/class-cartflows-importer-elementor.php CHANGED
@@ -1,70 +1,69 @@
1
- <?php
2
- /**
3
- * Elementor Importer
4
- *
5
- * @package CARTFLOWS
6
- */
7
-
8
- namespace Elementor\TemplateLibrary;
9
-
10
- use Elementor\Core\Base\Document;
11
- use Elementor\DB;
12
- use Elementor\Core\Settings\Page\Manager as PageSettingsManager;
13
- use Elementor\Core\Settings\Manager as SettingsManager;
14
- use Elementor\Core\Settings\Page\Model;
15
- use Elementor\Editor;
16
- use Elementor\Plugin;
17
- use Elementor\Settings;
18
- use Elementor\Utils;
19
-
20
- if ( ! defined( 'ABSPATH' ) ) {
21
- exit; // Exit if accessed directly.
22
- }
23
-
24
- /**
25
- * Elementor template library local source.
26
- *
27
- * Elementor template library local source handler class is responsible for
28
- * handling local Elementor templates saved by the user locally on his site.
29
- *
30
- * @since 1.0.0
31
- */
32
- class CartFlows_Importer_Elementor extends Source_Local {
33
-
34
- /**
35
- * Import single template
36
- *
37
- * @param int $post_id post ID.
38
- */
39
- public function import_single_template( $post_id ) {
40
-
41
- $rest_content = get_post_meta( $post_id, '_elementor_data', true );
42
-
43
- if ( empty( $rest_content ) ) {
44
- $data = __( 'Invalid content.', 'cartflows' );
45
- wcf()->logger->import_log( '(✕) ' . $data );
46
- }
47
-
48
- $rest_content = add_magic_quotes( $rest_content );
49
- $content = json_decode( $rest_content, true );
50
-
51
- if ( ! is_array( $content ) ) {
52
- $data = __( 'Invalid content. Expected an array.', 'cartflows' );
53
- wcf()->logger->import_log( '(✕) ' . $data );
54
- wcf()->logger->import_log( $content );
55
- } else {
56
-
57
- wcf()->logger->import_log( '(✓) Processing Request..' );
58
- wcf()->logger->import_log( '(✓) Data ' . json_encode( $content ) );
59
-
60
- // Import the data.
61
- $content = $this->process_export_import_content( $content, 'on_import' );
62
-
63
- // Update content.
64
- update_metadata( 'post', $post_id, '_elementor_data', $content );
65
-
66
- wcf()->logger->import_log( '(✓) Process Complete' );
67
- }
68
-
69
- }
70
- }
1
+ <?php
2
+ /**
3
+ * Elementor Importer
4
+ *
5
+ * @package CARTFLOWS
6
+ */
7
+
8
+ namespace Elementor\TemplateLibrary;
9
+
10
+ use Elementor\Core\Base\Document;
11
+ use Elementor\DB;
12
+ use Elementor\Core\Settings\Page\Manager as PageSettingsManager;
13
+ use Elementor\Core\Settings\Manager as SettingsManager;
14
+ use Elementor\Core\Settings\Page\Model;
15
+ use Elementor\Editor;
16
+ use Elementor\Plugin;
17
+ use Elementor\Settings;
18
+ use Elementor\Utils;
19
+
20
+ if ( ! defined( 'ABSPATH' ) ) {
21
+ exit; // Exit if accessed directly.
22
+ }
23
+
24
+ /**
25
+ * Elementor template library local source.
26
+ *
27
+ * Elementor template library local source handler class is responsible for
28
+ * handling local Elementor templates saved by the user locally on his site.
29
+ *
30
+ * @since 1.0.0
31
+ */
32
+ class CartFlows_Importer_Elementor extends Source_Local {
33
+
34
+ /**
35
+ * Import single template
36
+ *
37
+ * @param int $post_id post ID.
38
+ */
39
+ public function import_single_template( $post_id ) {
40
+
41
+ $rest_content = get_post_meta( $post_id, '_elementor_data', true );
42
+
43
+ if ( empty( $rest_content ) ) {
44
+ $data = __( 'Invalid content.', 'cartflows' );
45
+ wcf()->logger->import_log( '(✕) ' . $data );
46
+ }
47
+
48
+ $rest_content = add_magic_quotes( $rest_content );
49
+ $content = json_decode( $rest_content, true );
50
+
51
+ if ( ! is_array( $content ) ) {
52
+ $data = __( 'Invalid content. Expected an array.', 'cartflows' );
53
+ wcf()->logger->import_log( '(✕) ' . $data );
54
+ wcf()->logger->import_log( $content );
55
+ } else {
56
+
57
+ wcf()->logger->import_log( '(✓) Processing Request..' );
58
+
59
+ // Import the data.
60
+ $content = $this->process_export_import_content( $content, 'on_import' );
61
+
62
+ // Update content.
63
+ update_metadata( 'post', $post_id, '_elementor_data', $content );
64
+
65
+ wcf()->logger->import_log( '(✓) Process Complete' );
66
+ }
67
+
68
+ }
69
+ }
 
classes/batch-process/helpers/class-cartflows-importer-image.php CHANGED
@@ -106,19 +106,21 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
106
  * @return string Hash string.
107
  */
108
  private function get_saved_image( $attachment ) {
 
109
  if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) {
110
 
111
- CartFlows_Import_Image::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
112
 
113
  return $attachment;
114
  }
115
 
116
  global $wpdb;
117
 
 
118
  // Already imported? Then return!
119
  if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
120
 
121
- CartFlows_Import_Image::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
122
 
123
  return $this->already_imported_ids[ $attachment['id'] ];
124
  }
@@ -151,7 +153,7 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
151
  )
152
  );
153
 
154
- CartFlows_Import_Image::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
155
  }
156
 
157
  if ( $post_id ) {
@@ -177,6 +179,7 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
177
  public function import( $attachment ) {
178
 
179
  $saved_image = $this->get_saved_image( $attachment );
 
180
  if ( $saved_image ) {
181
  return $saved_image;
182
  }
@@ -186,8 +189,8 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
186
  // Empty file content?
187
  if ( empty( $file_content ) ) {
188
 
189
- CartFlows_Import_Image::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
190
- CartFlows_Import_Image::log( 'Error: Failed wp_remote_retrieve_body().' );
191
 
192
  return $attachment;
193
  }
@@ -226,33 +229,13 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
226
  'url' => $upload['url'],
227
  );
228
 
229
- CartFlows_Import_Image::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
230
 
231
  $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
232
 
233
  return $new_attachment;
234
  }
235
 
236
- /**
237
- * Debugging Log.
238
- *
239
- * @since 1.1.1
240
- * @param mixed $log Log data.
241
- * @return void
242
- */
243
- public static function log( $log ) {
244
-
245
- if ( ! WP_DEBUG_LOG ) {
246
- return;
247
- }
248
-
249
- if ( is_array( $log ) || is_object( $log ) ) {
250
- error_log( print_r( $log, true ) );
251
- } else {
252
- error_log( $log );
253
- }
254
- }
255
-
256
  }
257
 
258
  /**
@@ -260,4 +243,4 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
260
  */
261
  CartFlows_Import_Image::get_instance();
262
 
263
- endif;
106
  * @return string Hash string.
107
  */
108
  private function get_saved_image( $attachment ) {
109
+
110
  if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) {
111
 
112
+ wcf()->logger->import_log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
113
 
114
  return $attachment;
115
  }
116
 
117
  global $wpdb;
118
 
119
+
120
  // Already imported? Then return!
121
  if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
122
 
123
+ wcf()->logger->import_log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
124
 
125
  return $this->already_imported_ids[ $attachment['id'] ];
126
  }
153
  )
154
  );
155
 
156
+ wcf()->logger->import_log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
157
  }
158
 
159
  if ( $post_id ) {
179
  public function import( $attachment ) {
180
 
181
  $saved_image = $this->get_saved_image( $attachment );
182
+
183
  if ( $saved_image ) {
184
  return $saved_image;
185
  }
189
  // Empty file content?
190
  if ( empty( $file_content ) ) {
191
 
192
+ wcf()->logger->import_log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
193
+ wcf()->logger->import_log( 'Error: Failed wp_remote_retrieve_body().' );
194
 
195
  return $attachment;
196
  }
229
  'url' => $upload['url'],
230
  );
231
 
232
+ wcf()->logger->import_log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
233
 
234
  $this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
235
 
236
  return $new_attachment;
237
  }
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
  /**
243
  */
244
  CartFlows_Import_Image::get_instance();
245
 
246
+ endif;
classes/class-cartflows-admin-fields.php CHANGED
@@ -1,157 +1,198 @@
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
- * Text Field
15
- *
16
- * @param array $args Args.
17
- * @return string
18
- */
19
- static public function text_field( $args ) {
20
-
21
- $id = $args['id'];
22
- $name = $args['name'];
23
- $title = $args['title'];
24
- $value = $args['value'];
25
-
26
- $output = '<div class="form-field">';
27
- $output .= '<label for="' . $id . '">' . $title . '</label>';
28
- $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
29
- $output .= '</div>';
30
-
31
- return $output;
32
- }
33
-
34
- /**
35
- * URL Field
36
- *
37
- * @param array $args Args.
38
- * @return string
39
- */
40
- static public function url_field( $args ) {
41
-
42
- $id = $args['id'];
43
- $name = $args['name'];
44
- $title = $args['title'];
45
- $value = $args['value'];
46
-
47
- $output = '<div class="form-field">';
48
- $output .= '<label for="' . $id . '">' . $title . '</label>';
49
- $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
50
- $output .= '</div>';
51
-
52
- return $output;
53
- }
54
-
55
- /**
56
- * Checkbox Field
57
- *
58
- * @param array $args Args.
59
- * @return string
60
- */
61
- static public function checkobox_field( $args ) {
62
-
63
- $id = $args['id'];
64
- $name = $args['name'];
65
- $title = $args['title'];
66
- $value = $args['value'];
67
-
68
- $output = '<div class="form-field">';
69
- $output .= '<label for="' . $id . '">';
70
- $output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
71
- $output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
72
- $output .= $title;
73
- $output .= '</label>';
74
- $output .= '</div>';
75
-
76
- return $output;
77
- }
78
-
79
- /**
80
- * Checkout Selection Field
81
- *
82
- * @param array $args Args.
83
- * @return string
84
- */
85
- static public function flow_checkout_selection_field( $args ) {
86
-
87
- $id = $args['id'];
88
- $name = $args['name'];
89
- $title = $args['title'];
90
- $value = $args['value'];
91
-
92
- $checkout_steps = get_posts(
93
- array(
94
- 'posts_per_page' => -1,
95
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
96
- 'post_status' => 'publish',
97
- 'orderby' => 'ID',
98
- 'order' => 'ASC',
99
- 'tax_query' => array(
100
- array(
101
- 'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
102
- 'field' => 'slug',
103
- 'terms' => 'checkout',
104
- ),
105
- ),
106
- )
107
- );
108
-
109
- $output = '<div class="form-field">';
110
-
111
- $output .= '<div class="form-field-label">';
112
- $output .= '<label for="' . $id . '">';
113
- $output .= $title;
114
- $output .= '</label>';
115
- $output .= '</div>';
116
-
117
- $output .= '<div class="form-field-data">';
118
- $output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
119
-
120
- if ( ! empty( $checkout_steps ) ) {
121
- $output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
122
- } else {
123
-
124
- $output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
125
- }
126
-
127
- foreach ( $checkout_steps as $index => $step_data ) {
128
-
129
- $output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
130
- }
131
-
132
- $output .= '</select>';
133
- $output .= '</div>';
134
-
135
- if ( '' !== $value ) {
136
- $output .= '<div class="form-field-actions">';
137
- $output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
138
- $output .= '<span class="dashicons dashicons-edit"></span>';
139
- $output .= '<span class="">Edit</span>';
140
- $output .= '</a>';
141
- $output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
142
- $output .= '<span class="dashicons dashicons-visibility"></span>';
143
- $output .= '<span class="">View</span>';
144
- $output .= '</a>';
145
- $output .= '</div>';
146
- }
147
-
148
- $output .= '<div class="form-field-desc">';
149
- /* translators: %s: link */
150
- $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>';
151
- $output .= '</div>';
152
-
153
- $output .= '</div>';
154
-
155
- return $output;
156
- }
157
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Text Field
15
+ *
16
+ * @param array $args Args.
17
+ * @return string
18
+ */
19
+ static public function text_field( $args ) {
20
+
21
+ $id = $args['id'];
22
+ $name = $args['name'];
23
+ $title = $args['title'];
24
+ $value = $args['value'];
25
+
26
+ $output = '<div class="form-field" id="form-field-' . $id . '">';
27
+ $output .= '<label for="' . $id . '">' . $title . '</label>';
28
+ $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
29
+ $output .= '</div>';
30
+
31
+ return $output;
32
+ }
33
+
34
+ /**
35
+ * URL Field
36
+ *
37
+ * @param array $args Args.
38
+ * @return string
39
+ */
40
+ static public function url_field( $args ) {
41
+
42
+ $id = $args['id'];
43
+ $name = $args['name'];
44
+ $title = $args['title'];
45
+ $value = $args['value'];
46
+
47
+ $output = '<div class="form-field">';
48
+ $output .= '<label for="' . $id . '">' . $title . '</label>';
49
+ $output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
50
+ $output .= '</div>';
51
+
52
+ return $output;
53
+ }
54
+
55
+ /**
56
+ * Checkbox Field
57
+ *
58
+ * @param array $args Args.
59
+ * @return string
60
+ */
61
+ static public function checkobox_field( $args ) {
62
+
63
+ $id = $args['id'];
64
+ $name = $args['name'];
65
+ $title = $args['title'];
66
+ $value = $args['value'];
67
+
68
+ $output = '<div class="form-field" id="form-field-' . $id . '">';
69
+ $output .= '<label for="' . $id . '">';
70
+ $output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
71
+ $output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
72
+ $output .= $title;
73
+ $output .= '</label>';
74
+ $output .= '</div>';
75
+
76
+ return $output;
77
+ }
78
+
79
+ /**
80
+ * Select Field
81
+ *
82
+ * @since 1.1.4
83
+ *
84
+ * @param array $args Args.
85
+ * @return string
86
+ */
87
+ static public function select_field( $args ) {
88
+
89
+ $id = $args['id'];
90
+ $name = $args['name'];
91
+ $title = $args['title'];
92
+ $description = $args['description'];
93
+ $value = $args['value'];
94
+ $options = $args['options'];
95
+
96
+ $output = '<div class="form-field" id="form-field-' . $id . '">';
97
+
98
+ $output .= '<div class="form-field-label">';
99
+ $output .= $title;
100
+ $output .= '</div>';
101
+
102
+ $output .= '<div class="form-field-data">';
103
+ $output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
104
+ foreach ( $options as $option_value => $option_title ) {
105
+ $output .= '<option value="' . $option_value . '" ' . selected( $value, $option_value, false ) . '>' . $option_title . '</option>';
106
+ }
107
+ $output .= '</select>';
108
+ $output .= '</div>';
109
+
110
+ $output .= '<div class="form-field-desc">';
111
+ $output .= '<p>';
112
+ $output .= $description;
113
+ $output .= '</p>';
114
+ $output .= '</div>';
115
+ $output .= '</div>';
116
+
117
+ return $output;
118
+ }
119
+
120
+ /**
121
+ * Checkout Selection Field
122
+ *
123
+ * @param array $args Args.
124
+ * @return string
125
+ */
126
+ static public function flow_checkout_selection_field( $args ) {
127
+
128
+ $id = $args['id'];
129
+ $name = $args['name'];
130
+ $title = $args['title'];
131
+ $value = $args['value'];
132
+
133
+ $checkout_steps = get_posts(
134
+ array(
135
+ 'posts_per_page' => -1,
136
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
137
+ 'post_status' => 'publish',
138
+ 'orderby' => 'ID',
139
+ 'order' => 'ASC',
140
+ 'tax_query' => array(
141
+ array(
142
+ 'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
143
+ 'field' => 'slug',
144
+ 'terms' => 'checkout',
145
+ ),
146
+ ),
147
+ )
148
+ );
149
+
150
+ $output = '<div class="form-field" id="form-field-' . $id . '">';
151
+
152
+ $output .= '<div class="form-field-label">';
153
+ $output .= '<label for="' . $id . '">';
154
+ $output .= $title;
155
+ $output .= '</label>';
156
+ $output .= '</div>';
157
+
158
+ $output .= '<div class="form-field-data">';
159
+ $output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
160
+
161
+ if ( ! empty( $checkout_steps ) ) {
162
+ $output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
163
+ } else {
164
+
165
+ $output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
166
+ }
167
+
168
+ foreach ( $checkout_steps as $index => $step_data ) {
169
+
170
+ $output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
171
+ }
172
+
173
+ $output .= '</select>';
174
+ $output .= '</div>';
175
+
176
+ if ( '' !== $value ) {
177
+ $output .= '<div class="form-field-actions">';
178
+ $output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
179
+ $output .= '<span class="dashicons dashicons-edit"></span>';
180
+ $output .= '<span class="">Edit</span>';
181
+ $output .= '</a>';
182
+ $output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
183
+ $output .= '<span class="dashicons dashicons-visibility"></span>';
184
+ $output .= '<span class="">View</span>';
185
+ $output .= '</a>';
186
+ $output .= '</div>';
187
+ }
188
+
189
+ $output .= '<div class="form-field-desc">';
190
+ /* translators: %s: link */
191
+ $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>';
192
+ $output .= '</div>';
193
+
194
+ $output .= '</div>';
195
+
196
+ return $output;
197
+ }
198
+ }
classes/class-cartflows-admin.php CHANGED
@@ -1,410 +1,420 @@
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
- static public 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
- // Add CARTFLOWS menu option to admin.
39
- add_action( 'network_admin_menu', __CLASS__ . '::menu' );
40
- add_action( 'admin_menu', __CLASS__ . '::menu' );
41
- add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
42
-
43
- add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
44
-
45
- // Enqueue admin scripts.
46
- if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
47
-
48
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
49
-
50
- self::save_settings();
51
- }
52
-
53
- /* Global Addmin Script */
54
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
55
-
56
- add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
57
- }
58
-
59
- /**
60
- * Initialises the Plugin Name.
61
- *
62
- * @since 1.0.0
63
- * @return void
64
- */
65
- static public function initialise_plugin() {
66
-
67
- $name = 'Cartflows';
68
- $short_name = 'Cflows';
69
-
70
- define( 'CARTFLOWS_PLUGIN_NAME', $name );
71
- define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
72
- }
73
-
74
- /**
75
- * Renders the admin settings menu.
76
- *
77
- * @since 1.0.0
78
- * @return void
79
- */
80
- static public function menu() {
81
-
82
- if ( ! current_user_can( 'manage_options' ) ) {
83
- return;
84
- }
85
-
86
- add_menu_page(
87
- 'CartFlows',
88
- 'CartFlows',
89
- 'manage_options',
90
- CARTFLOWS_SLUG,
91
- __CLASS__ . '::render',
92
- 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
93
- 39.7
94
- );
95
-
96
- }
97
-
98
- /**
99
- * Add submenu to admin menu.
100
- *
101
- * @since 1.0.0
102
- */
103
- static function submenu() {
104
-
105
- $parent_slug = CARTFLOWS_SLUG;
106
- $page_title = __( 'Settings', 'cartflows' );
107
- $menu_title = __( 'Settings', 'cartflows' );
108
- $capability = 'manage_options';
109
- $menu_slug = 'cartflows_settings';
110
- $callback = __CLASS__ . '::render';
111
-
112
- add_submenu_page(
113
- $parent_slug,
114
- $page_title,
115
- $menu_title,
116
- $capability,
117
- $menu_slug,
118
- $callback
119
- );
120
- }
121
-
122
- /**
123
- * Renders the admin settings.
124
- *
125
- * @since 1.0.0
126
- * @return void
127
- */
128
- static public function render() {
129
- $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
130
- $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
131
- $action = str_replace( '_', '-', $action );
132
-
133
- // Enable header icon filter below.
134
- $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
135
-
136
- include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
137
- }
138
-
139
- /**
140
- * Renders the admin settings content.
141
- *
142
- * @since 1.0.0
143
- * @return void
144
- */
145
- static public function render_content() {
146
-
147
- $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
148
- $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
149
- $action = str_replace( '_', '-', $action );
150
- $action = 'general';
151
-
152
- $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
153
-
154
- include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
155
- }
156
-
157
- /**
158
- * Save Global Setting options.
159
- *
160
- * @since 1.0.0
161
- */
162
- static public function save_common_settings() {
163
-
164
- if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
165
-
166
- $url = $_SERVER['REQUEST_URI'];
167
- $input_settings = array();
168
- $new_settings = array();
169
-
170
- if ( isset( $_POST['_cartflows_common'] ) ) {
171
-
172
- $input_settings = $_POST['_cartflows_common'];
173
-
174
- // Loop through the input and sanitize each of the values.
175
- foreach ( $input_settings as $key => $val ) {
176
-
177
- if ( is_array( $val ) ) {
178
- foreach ( $val as $k => $v ) {
179
- $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
180
- }
181
- } else {
182
- $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
183
- }
184
- }
185
- }
186
-
187
- Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
188
-
189
- $query = array(
190
- 'message' => 'saved',
191
- );
192
-
193
- $redirect_to = add_query_arg( $query, $url );
194
-
195
- wp_redirect( $redirect_to );
196
- exit;
197
- } // End if statement.
198
- }
199
-
200
- /**
201
- * Check is cartflows admin.
202
- *
203
- * @since 1.0.0
204
- * @return boolean
205
- */
206
- static public function is_global_admin() {
207
-
208
- $current_screen = get_current_screen();
209
-
210
- if (
211
- is_object( $current_screen ) &&
212
- isset( $current_screen->post_type ) &&
213
- ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
214
- CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
215
- )
216
- ) {
217
- return true;
218
- }
219
- return false;
220
- }
221
-
222
- /**
223
- * Check is flow admin.
224
- *
225
- * @since 1.0.0
226
- * @return boolean
227
- */
228
- static public function is_flow_edit_admin() {
229
-
230
- $current_screen = get_current_screen();
231
-
232
- if (
233
- is_object( $current_screen ) &&
234
- isset( $current_screen->post_type ) &&
235
- ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
236
- isset( $current_screen->base ) &&
237
- ( 'post' === $current_screen->base )
238
- ) {
239
- return true;
240
- }
241
- return false;
242
- }
243
-
244
- /**
245
- * Global Admin Scripts.
246
- *
247
- * @since 1.0.0
248
- */
249
- static public function global_admin_scripts() {
250
-
251
- $localize = array(
252
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
253
- 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
254
- );
255
-
256
- wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
257
-
258
- if ( self::is_global_admin() ) {
259
-
260
- // Styles.
261
- wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
262
- wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
263
-
264
- wp_enqueue_script(
265
- 'wcf-global-admin',
266
- CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
267
- array( 'jquery' ),
268
- CARTFLOWS_VER,
269
- true
270
- );
271
-
272
- do_action( 'cartflows_global_admin_scripts' );
273
- }
274
- }
275
-
276
- /**
277
- * Global Admin Data.
278
- *
279
- * @since 1.0.0
280
- */
281
- static public function global_admin_data() {
282
-
283
- $current_screen = get_current_screen();
284
-
285
- if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
286
- return;
287
- }
288
-
289
- ?>
290
-
291
- <div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
292
- <div class="wcf-templates-popup-content">
293
- <div class="spinner"></div>
294
- <div class="wcf-templates-wrap wcf-templates-wrap-flows">
295
-
296
- <div id="wcf-remote-flow-actions" class="wcf-template-header">
297
- <div class="wcf-template-logo-wrap">
298
- <span class="wcf-cartflows-logo-img">
299
- <span class="cartflows-icon"></span>
300
- </span>
301
- <span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
302
- </div>
303
- <div class="wcf-tab-wrapper">
304
- <div id="wcf-get-started-steps">
305
- <ul class="filter-links ">
306
- <li>
307
- <a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
308
- </li>
309
- <li>
310
- <a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
311
- </li>
312
- </ul>
313
- </div>
314
- </div>
315
- <div class="wcf-popup-close-wrap">
316
- <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
317
- </div>
318
- </div>
319
- <!-- <div class="wcf-search-form">
320
- <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
321
- <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
322
- </div> -->
323
-
324
- <div id="wcf-remote-content">
325
- <div id="wcf-ready-templates">
326
- <div id="wcf-remote-filters">
327
- <div id="wcf-page-builders"></div>
328
- <div id="wcf-categories"></div>
329
- </div>
330
- <div class="wcf-page-builder-notice"></div>
331
- <div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"></div>
332
- <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
333
- </div>
334
- <div id="wcf-start-from-scratch" style="display: none;">
335
- <div class="inner">
336
- <a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
337
- </div>
338
- </div>
339
- </div>
340
- </div>
341
- </div>
342
- </div>
343
-
344
- <?php
345
- }
346
-
347
- /**
348
- * Enqueues the needed CSS/JS for the builder's admin settings page.
349
- *
350
- * @since 1.0.0
351
- */
352
- static public function styles_scripts() {
353
-
354
- // Styles.
355
- wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
356
- wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
357
-
358
- // Script.
359
- wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
360
-
361
- $localize = array(
362
- 'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
363
- );
364
-
365
- wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
366
- }
367
-
368
- /**
369
- * Save All admin settings here
370
- */
371
- static public function save_settings() {
372
-
373
- // Only admins can save settings.
374
- if ( ! current_user_can( 'manage_options' ) ) {
375
- return;
376
- }
377
-
378
- self::save_common_settings();
379
-
380
- // Let extensions hook into saving.
381
- do_action( 'cartflows_admin_settings_save' );
382
- }
383
-
384
- /**
385
- * Get and return page URL
386
- *
387
- * @param string $menu_slug Menu name.
388
- * @since 1.0.0
389
- * @return string page url
390
- */
391
- static public function get_page_url( $menu_slug ) {
392
-
393
- $parent_page = self::$default_menu_position;
394
-
395
- if ( strpos( $parent_page, '?' ) !== false ) {
396
- $query_var = '&page=' . self::$plugin_slug;
397
- } else {
398
- $query_var = '?page=' . self::$plugin_slug;
399
- }
400
-
401
- $parent_page_url = admin_url( $parent_page . $query_var );
402
-
403
- $url = $parent_page_url . '&action=' . $menu_slug;
404
-
405
- return esc_url( $url );
406
- }
407
-
408
- }
409
-
410
- 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
+ static public 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
+ // Add CARTFLOWS menu option to admin.
39
+ add_action( 'network_admin_menu', __CLASS__ . '::menu' );
40
+ add_action( 'admin_menu', __CLASS__ . '::menu' );
41
+ add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
42
+
43
+ add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
44
+
45
+ // Enqueue admin scripts.
46
+ if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
47
+
48
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
49
+
50
+ self::save_settings();
51
+ }
52
+
53
+ /* Global Addmin Script */
54
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
55
+
56
+ add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
57
+ }
58
+
59
+ /**
60
+ * Initialises the Plugin Name.
61
+ *
62
+ * @since 1.0.0
63
+ * @return void
64
+ */
65
+ static public function initialise_plugin() {
66
+
67
+ $name = 'Cartflows';
68
+ $short_name = 'Cflows';
69
+
70
+ define( 'CARTFLOWS_PLUGIN_NAME', $name );
71
+ define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
72
+ }
73
+
74
+ /**
75
+ * Renders the admin settings menu.
76
+ *
77
+ * @since 1.0.0
78
+ * @return void
79
+ */
80
+ static public function menu() {
81
+
82
+ if ( ! current_user_can( 'manage_options' ) ) {
83
+ return;
84
+ }
85
+
86
+ add_menu_page(
87
+ 'CartFlows',
88
+ 'CartFlows',
89
+ 'manage_options',
90
+ CARTFLOWS_SLUG,
91
+ __CLASS__ . '::render',
92
+ 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
93
+ 39.7
94
+ );
95
+
96
+ }
97
+
98
+ /**
99
+ * Add submenu to admin menu.
100
+ *
101
+ * @since 1.0.0
102
+ */
103
+ static function submenu() {
104
+
105
+ $parent_slug = CARTFLOWS_SLUG;
106
+ $page_title = __( 'Settings', 'cartflows' );
107
+ $menu_title = __( 'Settings', 'cartflows' );
108
+ $capability = 'manage_options';
109
+ $menu_slug = 'cartflows_settings';
110
+ $callback = __CLASS__ . '::render';
111
+
112
+ add_submenu_page(
113
+ $parent_slug,
114
+ $page_title,
115
+ $menu_title,
116
+ $capability,
117
+ $menu_slug,
118
+ $callback
119
+ );
120
+ }
121
+
122
+ /**
123
+ * Renders the admin settings.
124
+ *
125
+ * @since 1.0.0
126
+ * @return void
127
+ */
128
+ static public function render() {
129
+ $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
130
+ $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
131
+ $action = str_replace( '_', '-', $action );
132
+
133
+ // Enable header icon filter below.
134
+ $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
135
+
136
+ include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
137
+ }
138
+
139
+ /**
140
+ * Renders the admin settings content.
141
+ *
142
+ * @since 1.0.0
143
+ * @return void
144
+ */
145
+ static public function render_content() {
146
+
147
+ $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
148
+ $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
149
+ $action = str_replace( '_', '-', $action );
150
+ $action = 'general';
151
+
152
+ $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
153
+
154
+ include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
155
+ }
156
+
157
+ /**
158
+ * Save Global Setting options.
159
+ *
160
+ * @since 1.0.0
161
+ */
162
+ static public function save_common_settings() {
163
+
164
+ if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
165
+
166
+ $url = $_SERVER['REQUEST_URI'];
167
+ $input_settings = array();
168
+ $new_settings = array();
169
+
170
+ if ( isset( $_POST['_cartflows_common'] ) ) {
171
+
172
+ $input_settings = $_POST['_cartflows_common'];
173
+
174
+ // Loop through the input and sanitize each of the values.
175
+ foreach ( $input_settings as $key => $val ) {
176
+
177
+ if ( is_array( $val ) ) {
178
+ foreach ( $val as $k => $v ) {
179
+ $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
180
+ }
181
+ } else {
182
+ $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
183
+ }
184
+ }
185
+ }
186
+
187
+ Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
188
+
189
+ $query = array(
190
+ 'message' => 'saved',
191
+ );
192
+
193
+ $redirect_to = add_query_arg( $query, $url );
194
+
195
+ wp_redirect( $redirect_to );
196
+ exit;
197
+ } // End if statement.
198
+ }
199
+
200
+ /**
201
+ * Check is cartflows admin.
202
+ *
203
+ * @since 1.0.0
204
+ * @return boolean
205
+ */
206
+ static public function is_global_admin() {
207
+
208
+ $current_screen = get_current_screen();
209
+
210
+ if (
211
+ is_object( $current_screen ) &&
212
+ isset( $current_screen->post_type ) &&
213
+ ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
214
+ CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
215
+ )
216
+ ) {
217
+ return true;
218
+ }
219
+ return false;
220
+ }
221
+
222
+ /**
223
+ * Check is flow admin.
224
+ *
225
+ * @since 1.0.0
226
+ * @return boolean
227
+ */
228
+ static public function is_flow_edit_admin() {
229
+
230
+ $current_screen = get_current_screen();
231
+
232
+ if (
233
+ is_object( $current_screen ) &&
234
+ isset( $current_screen->post_type ) &&
235
+ ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
236
+ isset( $current_screen->base ) &&
237
+ ( 'post' === $current_screen->base )
238
+ ) {
239
+ return true;
240
+ }
241
+ return false;
242
+ }
243
+
244
+ /**
245
+ * Global Admin Scripts.
246
+ *
247
+ * @since 1.0.0
248
+ */
249
+ static public function global_admin_scripts() {
250
+
251
+ $localize = array(
252
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
253
+ 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
254
+ );
255
+
256
+ wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
257
+
258
+ if ( self::is_global_admin() ) {
259
+
260
+ // Styles.
261
+ wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
262
+ wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
263
+
264
+ wp_enqueue_script(
265
+ 'wcf-global-admin',
266
+ CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
267
+ array( 'jquery' ),
268
+ CARTFLOWS_VER,
269
+ true
270
+ );
271
+
272
+ do_action( 'cartflows_global_admin_scripts' );
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Global Admin Data.
278
+ *
279
+ * @since 1.0.0
280
+ */
281
+ static public function global_admin_data() {
282
+
283
+ $current_screen = get_current_screen();
284
+
285
+ if ( ! $current_screen ) {
286
+ return;
287
+ }
288
+
289
+ if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
290
+ return;
291
+ }
292
+
293
+ $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
294
+ ?>
295
+
296
+ <div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
297
+ <div class="wcf-templates-popup-content">
298
+ <div class="spinner"></div>
299
+ <div class="wcf-templates-wrap wcf-templates-wrap-flows">
300
+
301
+ <div id="wcf-remote-flow-actions" class="wcf-template-header">
302
+ <div class="wcf-template-logo-wrap">
303
+ <span class="wcf-cartflows-logo-img">
304
+ <span class="cartflows-icon"></span>
305
+ </span>
306
+ <span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
307
+ </div>
308
+ <div class="wcf-tab-wrapper">
309
+ <?php if ( 'other' !== $default_page_builder ) { ?>
310
+ <div id="wcf-get-started-steps">
311
+ <ul class="filter-links ">
312
+ <li>
313
+ <a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
314
+ </li>
315
+ <li>
316
+ <a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
317
+ </li>
318
+ </ul>
319
+ </div>
320
+ <?php } ?>
321
+ </div>
322
+ <div class="wcf-popup-close-wrap">
323
+ <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
324
+ </div>
325
+ </div>
326
+ <!-- <div class="wcf-search-form">
327
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
328
+ <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
329
+ </div> -->
330
+
331
+ <div id="wcf-remote-content">
332
+ <?php if ( 'other' !== $default_page_builder ) { ?>
333
+ <div id="wcf-ready-templates">
334
+ <div id="wcf-remote-filters">
335
+ <div id="wcf-page-builders"></div>
336
+ <div id="wcf-categories"></div>
337
+ </div>
338
+ <div class="wcf-page-builder-notice"></div>
339
+ <div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
340
+ <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
341
+ </div>
342
+ <?php } ?>
343
+ <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
344
+ <div class="inner">
345
+ <a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
346
+ <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>
347
+ </div>
348
+ </div>
349
+ </div>
350
+ </div>
351
+ </div>
352
+ </div>
353
+
354
+ <?php
355
+ }
356
+
357
+ /**
358
+ * Enqueues the needed CSS/JS for the builder's admin settings page.
359
+ *
360
+ * @since 1.0.0
361
+ */
362
+ static public function styles_scripts() {
363
+
364
+ // Styles.
365
+ wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
366
+ wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
367
+
368
+ // Script.
369
+ wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
370
+
371
+ $localize = array(
372
+ 'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
373
+ );
374
+
375
+ wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
376
+ }
377
+
378
+ /**
379
+ * Save All admin settings here
380
+ */
381
+ static public function save_settings() {
382
+
383
+ // Only admins can save settings.
384
+ if ( ! current_user_can( 'manage_options' ) ) {
385
+ return;
386
+ }
387
+
388
+ self::save_common_settings();
389
+
390
+ // Let extensions hook into saving.
391
+ do_action( 'cartflows_admin_settings_save' );
392
+ }
393
+
394
+ /**
395
+ * Get and return page URL
396
+ *
397
+ * @param string $menu_slug Menu name.
398
+ * @since 1.0.0
399
+ * @return string page url
400
+ */
401
+ static public function get_page_url( $menu_slug ) {
402
+
403
+ $parent_page = self::$default_menu_position;
404
+
405
+ if ( strpos( $parent_page, '?' ) !== false ) {
406
+ $query_var = '&page=' . self::$plugin_slug;
407
+ } else {
408
+ $query_var = '?page=' . self::$plugin_slug;
409
+ }
410
+
411
+ $parent_page_url = admin_url( $parent_page . $query_var );
412
+
413
+ $url = $parent_page_url . '&action=' . $menu_slug;
414
+
415
+ return esc_url( $url );
416
+ }
417
+
418
+ }
419
+
420
+ Cartflows_Admin::init();
classes/class-cartflows-bb-compatibility.php ADDED
@@ -0,0 +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;
classes/class-cartflows-compatibility.php CHANGED
@@ -54,11 +54,29 @@ if ( ! class_exists( 'Cartflows_Compatibility' ) ) {
54
  require_once CARTFLOWS_DIR . 'classes/class-cartflows-divi-compatibility.php';
55
  }
56
 
 
 
 
 
57
  if ( class_exists( 'TCB_Post' ) ) {
58
  require_once CARTFLOWS_DIR . 'classes/class-cartflows-thrive-compatibility.php';
59
  }
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**
63
  * Check if elementor preview mode is on.
64
  */
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
 
66
+ /**
67
+ * Check if it is beaver builder enabled.
68
+ *
69
+ * @since 1.1.4
70
+ */
71
+ public function is_bb_enabled() {
72
+
73
+ if ( class_exists( 'FLBuilderModel' ) ) {
74
+ return true;
75
+ }
76
+
77
+ return false;
78
+ }
79
+
80
  /**
81
  * Check if elementor preview mode is on.
82
  */
classes/class-cartflows-flow-frontend.php CHANGED
@@ -1,199 +1,199 @@
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
- ?>
50
- <?php if( $this->is_flow_testmode() ) { ?>
51
- <div class="wcf-preview-mode">
52
- <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>
53
- </div>
54
- <?php } ?>
55
- <?php
56
- // @codingStandardsIgnoreEnd
57
- }
58
- }
59
-
60
- /**
61
- * Check if flow test mode is enable.
62
- *
63
- * @since 1.0.0
64
- * @param int $flow_id flow ID.
65
- *
66
- * @return boolean
67
- */
68
- function is_flow_testmode( $flow_id = '' ) {
69
-
70
- if ( ! $flow_id ) {
71
- $flow_id = wcf()->utils->get_flow_id();
72
- }
73
-
74
- $test_mode = wcf()->options->get_flow_meta_value( $flow_id, 'wcf-testing' );
75
-
76
- if ( 'no' === $test_mode ) {
77
- return false;
78
- }
79
-
80
- return true;
81
- }
82
-
83
- /**
84
- * Get steps data.
85
- *
86
- * @since 1.0.0
87
- * @param int $flow_id flow ID.
88
- *
89
- * @return array
90
- */
91
- function get_steps( $flow_id ) {
92
-
93
- $steps = get_post_meta( $flow_id, 'wcf-steps', true );
94
-
95
- if ( ! is_array( $steps ) ) {
96
-
97
- $steps = array();
98
- }
99
-
100
- return $steps;
101
- }
102
-
103
- /**
104
- * Check thank you page exists.
105
- *
106
- * @since 1.0.0
107
- * @param array $order order data.
108
- *
109
- * @return bool
110
- */
111
- function is_thankyou_page_exists( $order ) {
112
-
113
- $thankyou_step_exist = false;
114
-
115
- $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
116
-
117
- if ( $flow_id ) {
118
-
119
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
120
- $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
121
-
122
- if ( is_array( $flow_steps ) ) {
123
-
124
- $current_step_found = false;
125
-
126
- foreach ( $flow_steps as $index => $data ) {
127
-
128
- if ( $current_step_found ) {
129
-
130
- if ( 'thankyou' === $data['type'] ) {
131
-
132
- $thankyou_step_exist = true;
133
- break;
134
- }
135
- } else {
136
-
137
- if ( intval( $data['id'] ) === $step_id ) {
138
-
139
- $current_step_found = true;
140
- }
141
- }
142
- }
143
- }
144
- }
145
-
146
- return $thankyou_step_exist;
147
- }
148
-
149
- /**
150
- * Check thank you page exists.
151
- *
152
- * @since 1.0.0
153
- * @param array $order order data.
154
- *
155
- * @return bool
156
- */
157
- function get_thankyou_page_id( $order ) {
158
-
159
- $thankyou_step_id = false;
160
-
161
- $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
162
-
163
- if ( $flow_id ) {
164
-
165
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
166
- $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
167
-
168
- if ( is_array( $flow_steps ) ) {
169
-
170
- $current_step_found = false;
171
-
172
- foreach ( $flow_steps as $index => $data ) {
173
-
174
- if ( $current_step_found ) {
175
-
176
- if ( 'thankyou' === $data['type'] ) {
177
-
178
- $thankyou_step_id = intval( $data['id'] );
179
- break;
180
- }
181
- } else {
182
-
183
- if ( intval( $data['id'] ) === $step_id ) {
184
-
185
- $current_step_found = true;
186
- }
187
- }
188
- }
189
- }
190
- }
191
-
192
- return $thankyou_step_id;
193
- }
194
- }
195
-
196
- /**
197
- * Kicking this off by calling 'get_instance()' method
198
- */
199
- 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
+ function footer_markup() {
46
+
47
+ if ( wcf()->utils->is_step_post_type() ) {
48
+ // @codingStandardsIgnoreStart
49
+ ?>
50
+ <?php if( $this->is_flow_testmode() ) { ?>
51
+ <div class="wcf-preview-mode">
52
+ <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>
53
+ </div>
54
+ <?php } ?>
55
+ <?php
56
+ // @codingStandardsIgnoreEnd
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Check if flow test mode is enable.
62
+ *
63
+ * @since 1.0.0
64
+ * @param int $flow_id flow ID.
65
+ *
66
+ * @return boolean
67
+ */
68
+ function is_flow_testmode( $flow_id = '' ) {
69
+
70
+ if ( ! $flow_id ) {
71
+ $flow_id = wcf()->utils->get_flow_id();
72
+ }
73
+
74
+ $test_mode = wcf()->options->get_flow_meta_value( $flow_id, 'wcf-testing' );
75
+
76
+ if ( 'no' === $test_mode ) {
77
+ return false;
78
+ }
79
+
80
+ return true;
81
+ }
82
+
83
+ /**
84
+ * Get steps data.
85
+ *
86
+ * @since 1.0.0
87
+ * @param int $flow_id flow ID.
88
+ *
89
+ * @return array
90
+ */
91
+ function get_steps( $flow_id ) {
92
+
93
+ $steps = get_post_meta( $flow_id, 'wcf-steps', true );
94
+
95
+ if ( ! is_array( $steps ) ) {
96
+
97
+ $steps = array();
98
+ }
99
+
100
+ return $steps;
101
+ }
102
+
103
+ /**
104
+ * Check thank you page exists.
105
+ *
106
+ * @since 1.0.0
107
+ * @param array $order order data.
108
+ *
109
+ * @return bool
110
+ */
111
+ function is_thankyou_page_exists( $order ) {
112
+
113
+ $thankyou_step_exist = false;
114
+
115
+ $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
116
+
117
+ if ( $flow_id ) {
118
+
119
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
120
+ $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
121
+
122
+ if ( is_array( $flow_steps ) ) {
123
+
124
+ $current_step_found = false;
125
+
126
+ foreach ( $flow_steps as $index => $data ) {
127
+
128
+ if ( $current_step_found ) {
129
+
130
+ if ( 'thankyou' === $data['type'] ) {
131
+
132
+ $thankyou_step_exist = true;
133
+ break;
134
+ }
135
+ } else {
136
+
137
+ if ( intval( $data['id'] ) === $step_id ) {
138
+
139
+ $current_step_found = true;
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+
146
+ return $thankyou_step_exist;
147
+ }
148
+
149
+ /**
150
+ * Check thank you page exists.
151
+ *
152
+ * @since 1.0.0
153
+ * @param array $order order data.
154
+ *
155
+ * @return bool
156
+ */
157
+ function get_thankyou_page_id( $order ) {
158
+
159
+ $thankyou_step_id = false;
160
+
161
+ $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
162
+
163
+ if ( $flow_id ) {
164
+
165
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
166
+ $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
167
+
168
+ if ( is_array( $flow_steps ) ) {
169
+
170
+ $current_step_found = false;
171
+
172
+ foreach ( $flow_steps as $index => $data ) {
173
+
174
+ if ( $current_step_found ) {
175
+
176
+ if ( 'thankyou' === $data['type'] ) {
177
+
178
+ $thankyou_step_id = intval( $data['id'] );
179
+ break;
180
+ }
181
+ } else {
182
+
183
+ if ( intval( $data['id'] ) === $step_id ) {
184
+
185
+ $current_step_found = true;
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+
192
+ return $thankyou_step_id;
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Kicking this off by calling 'get_instance()' method
198
+ */
199
+ Cartflows_Flow_Frontend::get_instance();
classes/class-cartflows-helper.php CHANGED
@@ -1,301 +1,410 @@
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
- * Checkout Fields
26
- *
27
- * @var checkout_fields
28
- */
29
- private static $checkout_fields = null;
30
-
31
- /**
32
- * Returns an option from the database for
33
- * the admin settings page.
34
- *
35
- * @param string $key The option key.
36
- * @param mixed $default Option default value if option is not available.
37
- * @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
38
- * @return string Return the option value
39
- */
40
- public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
41
-
42
- // Get the site-wide option if we're in the network admin.
43
- if ( $network_override && is_multisite() ) {
44
- $value = get_site_option( $key, $default );
45
- } else {
46
- $value = get_option( $key, $default );
47
- }
48
-
49
- return $value;
50
- }
51
-
52
- /**
53
- * Updates an option from the admin settings page.
54
- *
55
- * @param string $key The option key.
56
- * @param mixed $value The value to update.
57
- * @param bool $network Whether to allow the network admin setting to be overridden on subsites.
58
- * @return mixed
59
- */
60
- static public function update_admin_settings_option( $key, $value, $network = false ) {
61
-
62
- // Update the site-wide option since we're in the network admin.
63
- if ( $network && is_multisite() ) {
64
- update_site_option( $key, $value );
65
- } else {
66
- update_option( $key, $value );
67
- }
68
-
69
- }
70
-
71
- /**
72
- * Get zapier settings.
73
- *
74
- * @return array.
75
- */
76
- static public function get_common_settings() {
77
-
78
- if ( null === self::$common ) {
79
-
80
- $common_default = apply_filters(
81
- 'cartflows_common_settings_default',
82
- array(
83
- 'disallow_indexing' => 'disable',
84
- 'global_checkout' => '',
85
- )
86
- );
87
-
88
- $common = Cartflows_Helper::get_admin_settings_option( '_cartflows_common', false, true );
89
-
90
- self::$common = wp_parse_args( $common, $common_default );
91
- }
92
-
93
- return self::$common;
94
- }
95
-
96
- /**
97
- * Get Checkout field.
98
- *
99
- * @param string $key Field key.
100
- * @param int $post_id Post id.
101
- * @return array.
102
- */
103
- static public function get_checkout_fields( $key, $post_id ) {
104
-
105
- $saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
106
-
107
- if ( ! $saved_fields ) {
108
- $saved_fields = array();
109
- }
110
-
111
- $fields = array_filter( $saved_fields );
112
-
113
- if ( empty( $fields ) ) {
114
- if ( 'billing' === $key || 'shipping' === $key ) {
115
-
116
- $fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
117
-
118
- update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
119
- }
120
- }
121
-
122
- return $fields;
123
- }
124
-
125
- /**
126
- * Add Checkout field.
127
- *
128
- * @param string $type Field type.
129
- * @param string $field_key Field key.
130
- * @param array $field_data Field data.
131
- * @param int $post_id Post id.
132
- * @return boolean.
133
- */
134
- static public function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
135
-
136
- $fields = self::get_checkout_fields( $type, $post_id );
137
-
138
- $fields[ $field_key ] = $field_data;
139
-
140
- update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
141
-
142
- return true;
143
- }
144
-
145
- /**
146
- * Get checkout fields settings.
147
- *
148
- * @param string $type Field type.
149
- * @param string $field_key Field key.
150
- * @param int $post_id Post id.
151
- * @return array.
152
- */
153
- static public function delete_checkout_field( $type, $field_key, $post_id ) {
154
-
155
- $fields = self::get_checkout_fields( $type, $post_id );
156
-
157
- if ( isset( $fields[ $field_key ] ) ) {
158
- unset( $fields[ $field_key ] );
159
- }
160
-
161
- update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
162
-
163
- return true;
164
- }
165
-
166
- /**
167
- * Get checkout fields settings.
168
- *
169
- * @return array.
170
- */
171
- static public function get_checkout_fields_settings() {
172
-
173
- if ( null === self::$checkout_fields ) {
174
- $checkout_fields_default = array(
175
- 'enable_customization' => 'disable',
176
- 'enable_billing_fields' => 'disable',
177
- );
178
-
179
- $billing_fields = self::get_checkout_fields( 'billing' );
180
-
181
- if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
182
-
183
- foreach ( $billing_fields as $key => $value ) {
184
-
185
- $checkout_fields_default[ $key ] = 'enable';
186
- }
187
- }
188
-
189
- $checkout_fields = Cartflows_Helper::get_admin_settings_option( '_wcf_checkout_fields', false, true );
190
-
191
- self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
192
- }
193
-
194
- return self::$checkout_fields;
195
- }
196
-
197
- /**
198
- * Get meta options
199
- *
200
- * @since 1.0.0
201
- * @param int $post_id Product ID.
202
- * @param string $key Meta Key.
203
- * @param string $default Default value.
204
- * @return string Meta Value.
205
- */
206
- static public function get_meta_option( $post_id, $key, $default = '' ) {
207
-
208
- $value = get_post_meta( $post_id, $key, true );
209
-
210
- if ( ! $value ) {
211
- $value = $default;
212
- }
213
-
214
- return $value;
215
- }
216
-
217
- /**
218
- * Save meta option
219
- *
220
- * @since 1.0.0
221
- * @param int $post_id Product ID.
222
- * @param array $args Arguments array.
223
- */
224
- static public function save_meta_option( $post_id, $args = array() ) {
225
-
226
- if ( is_array( $args ) && ! empty( $args ) ) {
227
-
228
- foreach ( $args as $key => $value ) {
229
-
230
- update_post_meta( $post_id, $key, $value );
231
- }
232
- }
233
- }
234
-
235
- /**
236
- * Check if Elementor page builder is installed
237
- *
238
- * @since 1.0.0
239
- *
240
- * @access public
241
- */
242
- static public function _is_elementor_installed() {
243
- $path = 'elementor/elementor.php';
244
- $plugins = get_plugins();
245
-
246
- return isset( $plugins[ $path ] );
247
- }
248
-
249
- /**
250
- * Check if Step has product assigned.
251
- *
252
- * @since 1.0.0
253
- * @param int $step_id step ID.
254
- *
255
- * @access public
256
- */
257
- static public function has_product_assigned( $step_id ) {
258
-
259
- $step_type = get_post_meta( $step_id, 'wcf-step-type', true );
260
-
261
- if ( 'checkout' == $step_type ) {
262
- $product = get_post_meta( $step_id, 'wcf-checkout-products', true );
263
- } else {
264
- $product = get_post_meta( $step_id, 'wcf-offer-product', true );
265
- }
266
-
267
- if ( ! empty( $product ) ) {
268
- return true;
269
- }
270
- return false;
271
-
272
- }
273
-
274
- /**
275
- * Get attributes for cartflows wrap.
276
- *
277
- * @since x.x.x
278
- *
279
- * @access public
280
- */
281
- static public function get_cartflows_container_atts() {
282
-
283
- $attributes = apply_filters( 'cartflows_container_atts', array() );
284
- $atts_string = '';
285
-
286
- foreach ( $attributes as $key => $value ) {
287
-
288
- if ( ! $value ) {
289
- continue;
290
- }
291
-
292
- if ( true === $value ) {
293
- $atts_string .= esc_html( $key ) . ' ';
294
- } else {
295
- $atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
296
- }
297
- }
298
-
299
- return $atts_string;
300
- }
301
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Installed Plugins
26
+ *
27
+ * @since 1.1.4
28
+ *
29
+ * @access private
30
+ * @var array Installed plugins list.
31
+ */
32
+ private static $installed_plugins = null;
33
+
34
+ /**
35
+ * Checkout Fields
36
+ *
37
+ * @var checkout_fields
38
+ */
39
+ private static $checkout_fields = null;
40
+
41
+ /**
42
+ * Returns an option from the database for
43
+ * the admin settings page.
44
+ *
45
+ * @param string $key The option key.
46
+ * @param mixed $default Option default value if option is not available.
47
+ * @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
48
+ * @return string Return the option value
49
+ */
50
+ public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
51
+
52
+ // Get the site-wide option if we're in the network admin.
53
+ if ( $network_override && is_multisite() ) {
54
+ $value = get_site_option( $key, $default );
55
+ } else {
56
+ $value = get_option( $key, $default );
57
+ }
58
+
59
+ return $value;
60
+ }
61
+
62
+ /**
63
+ * Updates an option from the admin settings page.
64
+ *
65
+ * @param string $key The option key.
66
+ * @param mixed $value The value to update.
67
+ * @param bool $network Whether to allow the network admin setting to be overridden on subsites.
68
+ * @return mixed
69
+ */
70
+ static public function update_admin_settings_option( $key, $value, $network = false ) {
71
+
72
+ // Update the site-wide option since we're in the network admin.
73
+ if ( $network && is_multisite() ) {
74
+ update_site_option( $key, $value );
75
+ } else {
76
+ update_option( $key, $value );
77
+ }
78
+
79
+ }
80
+
81
+ /**
82
+ * Get single setting
83
+ *
84
+ * @since 1.1.4
85
+ *
86
+ * @param string $key Option key.
87
+ * @param string $default Option default value if not exist.
88
+ * @return mixed
89
+ */
90
+ static public function get_common_setting( $key = '', $default = '' ) {
91
+ $settings = self::get_common_settings();
92
+
93
+ if ( $settings && array_key_exists( $key, $settings ) ) {
94
+ return $settings[ $key ];
95
+ }
96
+
97
+ return $default;
98
+ }
99
+
100
+ /**
101
+ * Get required plugins for page builder
102
+ *
103
+ * @since 1.1.4
104
+ *
105
+ * @param string $page_builder_slug Page builder slug.
106
+ * @param string $default Default page builder.
107
+ * @return array selected page builder required plugins list.
108
+ */
109
+ public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
110
+ $plugins = self::get_plugins_groupby_page_builders();
111
+
112
+ if ( array_key_exists( $page_builder_slug, $plugins ) ) {
113
+ return $plugins[ $page_builder_slug ];
114
+ }
115
+
116
+ return $plugins[ $default ];
117
+ }
118
+
119
+ /**
120
+ * Get Plugins list by page builder.
121
+ *
122
+ * @since 1.1.4
123
+ *
124
+ * @return array Required Plugins list.
125
+ */
126
+ public static function get_plugins_groupby_page_builders() {
127
+ return array(
128
+ 'beaver-builder' => array(
129
+ 'title' => 'Beaver Builder',
130
+ 'plugins' => array(
131
+ array(
132
+ 'slug' => 'beaver-builder-lite-version', // For download from wp.org.
133
+ 'init' => 'beaver-builder-lite-version/fl-builder.php',
134
+ 'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
135
+ ),
136
+ array(
137
+ 'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
138
+ 'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
139
+ 'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
140
+ ),
141
+ ),
142
+ ),
143
+ 'elementor' => array(
144
+ 'title' => 'Elementor',
145
+ 'plugins' => array(
146
+ array(
147
+ 'slug' => 'elementor', // For download from wp.org.
148
+ 'init' => 'elementor/elementor.php',
149
+ 'status' => self::get_plugin_status( 'elementor/elementor.php' ),
150
+ ),
151
+ ),
152
+ ),
153
+ );
154
+ }
155
+
156
+ /**
157
+ * Get plugin status
158
+ *
159
+ * @since 1.1.4
160
+ *
161
+ * @param string $plugin_init_file Plguin init file.
162
+ * @return mixed
163
+ */
164
+ public static function get_plugin_status( $plugin_init_file ) {
165
+
166
+ if ( null == self::$installed_plugins ) {
167
+ self::$installed_plugins = get_plugins();
168
+ }
169
+
170
+ if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
171
+ return 'install';
172
+ } elseif ( ! is_plugin_active( $plugin_init_file ) ) {
173
+ return 'activate';
174
+ }
175
+
176
+ return;
177
+ }
178
+
179
+ /**
180
+ * Get zapier settings.
181
+ *
182
+ * @return array.
183
+ */
184
+ static public function get_common_settings() {
185
+
186
+ if ( null === self::$common ) {
187
+
188
+ $common_default = apply_filters(
189
+ 'cartflows_common_settings_default',
190
+ array(
191
+ 'disallow_indexing' => 'disable',
192
+ 'global_checkout' => '',
193
+ 'default_page_builder' => 'elementor',
194
+ )
195
+ );
196
+
197
+ $common = Cartflows_Helper::get_admin_settings_option( '_cartflows_common', false, true );
198
+
199
+ self::$common = wp_parse_args( $common, $common_default );
200
+ }
201
+
202
+ return self::$common;
203
+ }
204
+
205
+ /**
206
+ * Get Checkout field.
207
+ *
208
+ * @param string $key Field key.
209
+ * @param int $post_id Post id.
210
+ * @return array.
211
+ */
212
+ static public function get_checkout_fields( $key, $post_id ) {
213
+
214
+ $saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
215
+
216
+ if ( ! $saved_fields ) {
217
+ $saved_fields = array();
218
+ }
219
+
220
+ $fields = array_filter( $saved_fields );
221
+
222
+ if ( empty( $fields ) ) {
223
+ if ( 'billing' === $key || 'shipping' === $key ) {
224
+
225
+ $fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
226
+
227
+ update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
228
+ }
229
+ }
230
+
231
+ return $fields;
232
+ }
233
+
234
+ /**
235
+ * Add Checkout field.
236
+ *
237
+ * @param string $type Field type.
238
+ * @param string $field_key Field key.
239
+ * @param array $field_data Field data.
240
+ * @param int $post_id Post id.
241
+ * @return boolean.
242
+ */
243
+ static public function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
244
+
245
+ $fields = self::get_checkout_fields( $type, $post_id );
246
+
247
+ $fields[ $field_key ] = $field_data;
248
+
249
+ update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
250
+
251
+ return true;
252
+ }
253
+
254
+ /**
255
+ * Get checkout fields settings.
256
+ *
257
+ * @param string $type Field type.
258
+ * @param string $field_key Field key.
259
+ * @param int $post_id Post id.
260
+ * @return array.
261
+ */
262
+ static public function delete_checkout_field( $type, $field_key, $post_id ) {
263
+
264
+ $fields = self::get_checkout_fields( $type, $post_id );
265
+
266
+ if ( isset( $fields[ $field_key ] ) ) {
267
+ unset( $fields[ $field_key ] );
268
+ }
269
+
270
+ update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
271
+
272
+ return true;
273
+ }
274
+
275
+ /**
276
+ * Get checkout fields settings.
277
+ *
278
+ * @return array.
279
+ */
280
+ static public function get_checkout_fields_settings() {
281
+
282
+ if ( null === self::$checkout_fields ) {
283
+ $checkout_fields_default = array(
284
+ 'enable_customization' => 'disable',
285
+ 'enable_billing_fields' => 'disable',
286
+ );
287
+
288
+ $billing_fields = self::get_checkout_fields( 'billing' );
289
+
290
+ if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
291
+
292
+ foreach ( $billing_fields as $key => $value ) {
293
+
294
+ $checkout_fields_default[ $key ] = 'enable';
295
+ }
296
+ }
297
+
298
+ $checkout_fields = Cartflows_Helper::get_admin_settings_option( '_wcf_checkout_fields', false, true );
299
+
300
+ self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
301
+ }
302
+
303
+ return self::$checkout_fields;
304
+ }
305
+
306
+ /**
307
+ * Get meta options
308
+ *
309
+ * @since 1.0.0
310
+ * @param int $post_id Product ID.
311
+ * @param string $key Meta Key.
312
+ * @param string $default Default value.
313
+ * @return string Meta Value.
314
+ */
315
+ static public function get_meta_option( $post_id, $key, $default = '' ) {
316
+
317
+ $value = get_post_meta( $post_id, $key, true );
318
+
319
+ if ( ! $value ) {
320
+ $value = $default;
321
+ }
322
+
323
+ return $value;
324
+ }
325
+
326
+ /**
327
+ * Save meta option
328
+ *
329
+ * @since 1.0.0
330
+ * @param int $post_id Product ID.
331
+ * @param array $args Arguments array.
332
+ */
333
+ static public function save_meta_option( $post_id, $args = array() ) {
334
+
335
+ if ( is_array( $args ) && ! empty( $args ) ) {
336
+
337
+ foreach ( $args as $key => $value ) {
338
+
339
+ update_post_meta( $post_id, $key, $value );
340
+ }
341
+ }
342
+ }
343
+
344
+ /**
345
+ * Check if Elementor page builder is installed
346
+ *
347
+ * @since 1.0.0
348
+ *
349
+ * @access public
350
+ */
351
+ static public function _is_elementor_installed() {
352
+ $path = 'elementor/elementor.php';
353
+ $plugins = get_plugins();
354
+
355
+ return isset( $plugins[ $path ] );
356
+ }
357
+
358
+ /**
359
+ * Check if Step has product assigned.
360
+ *
361
+ * @since 1.0.0
362
+ * @param int $step_id step ID.
363
+ *
364
+ * @access public
365
+ */
366
+ static public function has_product_assigned( $step_id ) {
367
+
368
+ $step_type = get_post_meta( $step_id, 'wcf-step-type', true );
369
+
370
+ if ( 'checkout' == $step_type ) {
371
+ $product = get_post_meta( $step_id, 'wcf-checkout-products', true );
372
+ } else {
373
+ $product = get_post_meta( $step_id, 'wcf-offer-product', true );
374
+ }
375
+
376
+ if ( ! empty( $product ) ) {
377
+ return true;
378
+ }
379
+ return false;
380
+
381
+ }
382
+
383
+ /**
384
+ * Get attributes for cartflows wrap.
385
+ *
386
+ * @since 1.1.4
387
+ *
388
+ * @access public
389
+ */
390
+ static public function get_cartflows_container_atts() {
391
+
392
+ $attributes = apply_filters( 'cartflows_container_atts', array() );
393
+ $atts_string = '';
394
+
395
+ foreach ( $attributes as $key => $value ) {
396
+
397
+ if ( ! $value ) {
398
+ continue;
399
+ }
400
+
401
+ if ( true === $value ) {
402
+ $atts_string .= esc_html( $key ) . ' ';
403
+ } else {
404
+ $atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
405
+ }
406
+ }
407
+
408
+ return $atts_string;
409
+ }
410
+ }
classes/class-cartflows-importer.php CHANGED
@@ -1,1429 +1,1419 @@
1
- <?php
2
- /**
3
- * CartFlows Admin
4
- *
5
- * @package CartFlows
6
- * @since 1.0.0
7
- */
8
-
9
- if ( ! class_exists( 'CartFlows_Importer' ) ) :
10
-
11
- /**
12
- * CartFlows Import
13
- *
14
- * @since 1.0.0
15
- */
16
- class CartFlows_Importer {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.0.0
22
- * @access private
23
- * @var object Class object.
24
- */
25
- private static $instance;
26
-
27
- /**
28
- * Installed Plugins
29
- *
30
- * @since 1.0.0
31
- * @access private
32
- * @var object Class object.
33
- */
34
- private static $installed_plugins = null;
35
-
36
- /**
37
- * Initiator
38
- *
39
- * @since 1.0.0
40
- * @return object initialized object of class.
41
- */
42
- public static function get_instance() {
43
- if ( ! isset( self::$instance ) ) {
44
- self::$instance = new self;
45
- }
46
-
47
- return self::$instance;
48
- }
49
-
50
- /**
51
- * Constructor
52
- *
53
- * @since 1.0.0
54
- */
55
- public function __construct() {
56
- add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
57
- add_action( 'wp_ajax_cartflows_load_steps', array( $this, 'load_templates' ) );
58
- add_action( 'wp_ajax_cartflows_step_import', array( $this, 'import_step' ) );
59
- add_action( 'wp_ajax_cartflows_create_flow', array( $this, 'create_flow' ) );
60
- add_action( 'wp_ajax_cartflows_default_flow', array( $this, 'create_default_flow' ) );
61
- add_action( 'wp_ajax_cartflows_step_create_blank', array( $this, 'step_create_blank' ) );
62
- add_action( 'wp_ajax_cartflows_import_flow_step', array( $this, 'import_flow' ) );
63
- add_action( 'admin_footer', array( $this, 'js_templates' ) );
64
- add_action( 'cartflows_import_complete', array( $this, 'clear_cache' ) );
65
-
66
- add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
67
-
68
- add_action( 'wp_ajax_cartflows_activate_plugin', array( $this, 'activate_plugin' ) );
69
-
70
- add_action( 'admin_menu', array( $this, 'add_to_menus' ) );
71
- add_action( 'admin_init', array( $this, 'export' ) );
72
- add_action( 'admin_init', array( $this, 'import' ) );
73
- add_filter( 'post_row_actions', array( $this, 'export_link' ), 10, 2 );
74
- add_action( 'admin_action_cartflows_export_flow', array( $this, 'export_flow' ) );
75
- }
76
-
77
- /**
78
- * Add the export link to action list for flows row actions
79
- *
80
- * @since x.x.x
81
- *
82
- * @param array $actions Actions array.
83
- * @param object $post Post object.
84
- *
85
- * @return array
86
- */
87
- function export_link( $actions, $post ) {
88
- if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
89
- $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>';
90
- }
91
- return $actions;
92
- }
93
-
94
- /**
95
- * Add menus
96
- *
97
- * @since x.x.x
98
- */
99
- function add_to_menus() {
100
- add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Export', 'cartflows' ), __( 'Flow Export', 'cartflows' ), 'export', 'flow_exporter', array( $this, 'exporter_markup' ) );
101
- add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Import', 'cartflows' ), __( 'Flow Import', 'cartflows' ), 'import', 'flow_importer', array( $this, 'importer_markup' ) );
102
- }
103
-
104
- /**
105
- * Export flow with steps and its meta
106
- *
107
- * @since x.x.x
108
- */
109
- function export_flow() {
110
-
111
- if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_export_flow' == $_REQUEST['action'] ) ) ) {
112
- wp_die( __( 'No post to export has been supplied!', 'cartflows' ) );
113
- }
114
-
115
- if ( ! isset( $_GET['flow_export_nonce'] ) || ! wp_verify_nonce( $_GET['flow_export_nonce'], basename( __FILE__ ) ) ) {
116
- return;
117
- }
118
-
119
- // Get the original post id.
120
- $flow_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
121
-
122
- $flows = array();
123
- $flows[] = $this->get_flow_export_data( $flow_id );
124
- $flows = apply_filters( 'cartflows_export_data', $flows );
125
-
126
- nocache_headers();
127
- header( 'Content-Type: application/json; charset=utf-8' );
128
- header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
129
- header( 'Expires: 0' );
130
-
131
- echo json_encode( $flows );
132
- exit;
133
- }
134
-
135
- /**
136
- * Export flow markup
137
- *
138
- * @since x.x.x
139
- */
140
- function exporter_markup() {
141
- include_once CARTFLOWS_DIR . 'includes/exporter.php';
142
- }
143
-
144
- /**
145
- * Import flow markup
146
- *
147
- * @since x.x.x
148
- */
149
- function importer_markup() {
150
- include_once CARTFLOWS_DIR . 'includes/importer.php';
151
- }
152
-
153
- /**
154
- * Export flow
155
- *
156
- * @since x.x.x
157
- */
158
- function export() {
159
- if ( empty( $_POST['cartflows-action'] ) || 'export' != $_POST['cartflows-action'] ) {
160
- return;
161
- }
162
-
163
- if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
164
- return;
165
- }
166
-
167
- if ( ! current_user_can( 'manage_options' ) ) {
168
- return;
169
- }
170
-
171
- $flows = $this->get_all_flow_export_data();
172
- $flows = apply_filters( 'cartflows_export_data', $flows );
173
-
174
- nocache_headers();
175
- header( 'Content-Type: application/json; charset=utf-8' );
176
- header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
177
- header( 'Expires: 0' );
178
-
179
- echo json_encode( $flows );
180
- exit;
181
- }
182
-
183
- /**
184
- * Get flow export data
185
- *
186
- * @since x.x.x
187
- *
188
- * @param integer $flow_id Flow ID.
189
- * @return array
190
- */
191
- function get_flow_export_data( $flow_id ) {
192
-
193
- $valid_step_meta_keys = array(
194
- '_wp_page_template',
195
- '_thumbnail_id',
196
- 'classic-editor-remember',
197
- );
198
-
199
- $new_steps = array();
200
- $steps = get_post_meta( $flow_id, 'wcf-steps', true );
201
- if ( $steps ) {
202
- foreach ( $steps as $key => $step ) {
203
-
204
- // Add step post meta.
205
- $new_all_meta = array();
206
- $all_meta = get_post_meta( $step['id'] );
207
- if ( is_array( $all_meta ) ) {
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
- }
215
- }
216
-
217
- // Add single step.
218
- $new_steps[] = array(
219
- 'title' => get_the_title( $step['id'] ),
220
- 'type' => $step['type'],
221
- 'meta' => $new_all_meta,
222
- );
223
- }
224
- }
225
-
226
- // Add single flow.
227
- return array(
228
- 'title' => get_the_title( $flow_id ),
229
- 'steps' => $new_steps,
230
- );
231
- }
232
-
233
- /**
234
- * Get all flow export data
235
- *
236
- * @since x.x.x
237
- */
238
- function get_all_flow_export_data() {
239
-
240
- $query_args = array(
241
- 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
242
-
243
- // Query performance optimization.
244
- 'fields' => 'ids',
245
- 'no_found_rows' => true,
246
- 'posts_per_page' => -1,
247
- );
248
-
249
- $query = new WP_Query( $query_args );
250
- $flows = array();
251
- if ( $query->posts ) {
252
- foreach ( $query->posts as $key => $post_id ) {
253
- $flows[] = $this->get_flow_export_data( $post_id );
254
- }
255
- }
256
-
257
- return $flows;
258
- }
259
-
260
- /**
261
- * Import our exported file
262
- *
263
- * @since x.x.x
264
- */
265
- function import() {
266
- if ( empty( $_POST['cartflows-action'] ) || 'import' != $_POST['cartflows-action'] ) {
267
- return;
268
- }
269
-
270
- if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
271
- return;
272
- }
273
-
274
- if ( ! current_user_can( 'manage_options' ) ) {
275
- return;
276
- }
277
-
278
- $filename = $_FILES['file']['name'];
279
- $file_info = explode( '.', $filename );
280
- $extension = end( $file_info );
281
-
282
- if ( 'json' != $extension ) {
283
- wp_die( __( 'Please upload a valid .json file', 'cartflows' ) );
284
- }
285
-
286
- $file = $_FILES['file']['tmp_name'];
287
-
288
- if ( empty( $file ) ) {
289
- wp_die( __( 'Please upload a file to import', 'cartflows' ) );
290
- }
291
-
292
- // Retrieve the settings from the file and convert the JSON object to an array.
293
- $flows = json_decode( file_get_contents( $file ), true );
294
-
295
- if ( $flows ) {
296
-
297
- foreach ( $flows as $key => $flow ) {
298
-
299
- $flow_title = $flow['title'];
300
- if ( post_exists( $flow['title'] ) ) {
301
- $flow_title = $flow['title'] . ' Copy';
302
- }
303
-
304
- // Create post object.
305
- $new_flow_args = array(
306
- 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
307
- 'post_title' => $flow_title,
308
- 'post_status' => 'draft',
309
- );
310
-
311
- // Insert the post into the database.
312
- $flow_id = wp_insert_post( $new_flow_args );
313
-
314
- if ( $flow['steps'] ) {
315
- foreach ( $flow['steps'] as $key => $step ) {
316
- $new_step_id = wp_insert_post(
317
- array(
318
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
319
- 'post_title' => $step['title'],
320
- 'post_status' => 'draft',
321
- 'meta_input' => $step['meta'],
322
- )
323
- );
324
-
325
- // Insert post meta.
326
- update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
327
-
328
- $step_taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
329
- $current_term = term_exists( $step['type'], $step_taxonomy );
330
-
331
- // // Set type object.
332
- $data = get_term( $current_term['term_id'], $step_taxonomy );
333
- $step_slug = $data->slug;
334
- wp_set_object_terms( $new_step_id, $data->slug, $step_taxonomy );
335
-
336
- // Set type.
337
- update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
338
-
339
- // Set flow.
340
- wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
341
-
342
- CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step['title'], $step_slug );
343
- }
344
- }
345
- }
346
- }
347
-
348
- add_action( 'admin_notices', array( $this, 'imported_successfully' ) );
349
- }
350
-
351
- /**
352
- * Imported notice
353
- *
354
- * @since x.x.x
355
- */
356
- function imported_successfully() {
357
- ?>
358
- <div class="notice notice-success">
359
- <p><?php _e( 'Successfully imported flows.', 'cartflows' ); ?></p>
360
- </div>
361
- <?php
362
- }
363
-
364
- /**
365
- * Clear Cache.
366
- *
367
- * @since 1.0.0
368
- */
369
- public function clear_cache() {
370
- // Clear 'Elementor' file cache.
371
- if ( class_exists( '\Elementor\Plugin' ) ) {
372
- Elementor\Plugin::$instance->files_manager->clear_cache();
373
- }
374
- }
375
-
376
- /**
377
- * JS Templates
378
- *
379
- * @since 1.0.0
380
- *
381
- * @return void
382
- */
383
- function js_templates() {
384
-
385
- // Loading Templates.
386
- ?>
387
- <script type="text/template" id="tmpl-cartflows-step-loading">
388
- <div class="template-message-block cartflows-step-loading">
389
- <h2>
390
- <span class="spinner"></span>
391
- <?php _e( 'Loading Steps', 'cartflows' ); ?>
392
- </h2>
393
- <p class="description"><?php _e( 'Getting steps from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
394
- </div>
395
- </script>
396
-
397
- <?php
398
- // Search Templates.
399
- ?>
400
- <script type="text/template" id="tmpl-cartflows-searching-templates">
401
- <div class="template-message-block cartflows-searching-templates">
402
- <h2>
403
- <span class="spinner"></span>
404
- <?php _e( 'Searching Template..', 'cartflows' ); ?>
405
- </h2>
406
- <p class="description"><?php _e( 'Getting templates from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
407
- </div>
408
- </script>
409
-
410
- <?php
411
- // CartFlows Importing Template.
412
- ?>
413
- <script type="text/template" id="tmpl-cartflows-step-importing">
414
- <div class="template-message-block cartflows-step-importing">
415
- <h2><span class="spinner"></span> <?php _e( 'Importing..', 'cartflows' ); ?></h2>
416
- </div>
417
- </script>
418
-
419
- <?php
420
- // CartFlows Imported.
421
- ?>
422
- <script type="text/template" id="tmpl-cartflows-step-imported">
423
- <div class="template-message-block cartflows-step-imported">
424
- <h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
425
- <p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span></p></div>
426
- </script>
427
-
428
- <?php
429
- // No templates.
430
- ?>
431
- <script type="text/template" id="tmpl-cartflows-no-steps">
432
- <div class="cartflows-no-steps">
433
- <div class="template-message-block">
434
- <h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
435
- <p class="description"></p>
436
- </div>
437
- </div>
438
- </script>
439
-
440
- <?php
441
- // No templates.
442
- ?>
443
- <script type="text/template" id="tmpl-cartflows-no-flows">
444
- <div class="cartflows-no-flows">
445
- <div class="template-message-block">
446
- <h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
447
- <p class="description"></p>
448
- </div>
449
- </div>
450
- </script>
451
-
452
- <?php
453
- // Error handling.
454
- ?>
455
- <script type="text/template" id="tmpl-templator-error">
456
- <div class="notice notice-error"><p>{{ data }}</p></div>
457
- </script>
458
-
459
- <?php
460
- // Redirect to Elementor.
461
- ?>
462
- <script type="text/template" id="tmpl-templator-redirect-to-elementor">
463
- <div class="template-message-block templator-redirect-to-elementor">
464
- <h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
465
- <p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span><br/><br/><?php _e( 'Redirecting to the Elementor edit window.', 'cartflows' ); ?> </p></div>
466
- </script>
467
-
468
- <?php
469
- /**
470
- * Responsive Buttons
471
- */
472
- ?>
473
- <script type="text/template" id="tmpl-cartflows-responsive-view">
474
- <span class="responsive-view">
475
- <span class="actions">
476
- <a class="desktop" href="#"><span data-view="desktop " class="active dashicons dashicons-desktop"></span></a>
477
- <a class="tablet" href="#"><span data-view="tablet" class="dashicons dashicons-tablet"></span></a>
478
- <a class="mobile" href="#"><span data-view="mobile" class="dashicons dashicons-smartphone"></span></a>
479
- </span>
480
- </span>
481
- </script>
482
-
483
- <?php
484
- // Templates data.
485
- ?>
486
- <script type="text/template" id="tmpl-cartflows-flows-list">
487
-
488
- <# if ( data.items.length ) { #>
489
- <# for ( key in data.items ) { #>
490
- <#
491
- var flow_steps = [];
492
- if( data.items[ key ].flow_steps ) {
493
- flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
494
- return value['id'];
495
- });
496
- }
497
- #>
498
- <# console.log( 'here ' + key ); #>
499
- <div class="inner">
500
- <div class="template">
501
- <span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
502
- <div class="template-screenshot">
503
- <# if( data.items[ key ].featured_image_url ) { #>
504
- <img src="{{ data.items[ key ].featured_image_url }}" />
505
- <# } else { #>
506
- <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
507
- <# } #>
508
- </div>
509
- <a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>flow={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
510
- <# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
511
- <span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
512
- <# } #>
513
- </span>
514
- <div class="template-id-container">
515
- <h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
516
- <div class="template-actions">
517
-
518
- <#
519
- if( data.items[ key ].page_builder.slug ) {
520
- required_plugin_group = data.items[ key ].page_builder.slug;
521
- } else {
522
- required_plugin_group = '';
523
- }
524
-
525
- if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
526
- import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
527
- } else {
528
- import_btn_title = 'Import';
529
- } #>
530
-
531
- <# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
532
- <a data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
533
- <# } else if( CartFlowsImportVars._is_pro_active ) { #>
534
- <a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
535
- <# } else { #>
536
- <a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
537
- <# } #>
538
- </div>
539
- </div>
540
- </div>
541
- </div>
542
- <# } #>
543
- <# } #>
544
- </script>
545
-
546
- <?php
547
- // Empty Step.
548
- ?>
549
- <script type="text/template" id="tmpl-cartflows-create-blank-step">
550
- <div class="inner">
551
- <div class="template">
552
- <span class="thumbnail site-preview cartflows-flow-preview">
553
- <div class="template-screenshot">
554
- <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
555
- </div>
556
- <div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
557
- </span>
558
- <div class="template-id-container">
559
- <h3 class="template-name"> Blank </h3>
560
- <div class="template-actions">
561
- <a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create', 'cartflows' ); ?></a>
562
- </div>
563
- </div>
564
- </div>
565
- </div>
566
- </script>
567
-
568
- <?php
569
- // Templates data.
570
- ?>
571
- <script type="text/template" id="tmpl-cartflows-steps-list">
572
- <# if ( data.items.length ) { #>
573
- <# for ( key in data.items ) { #>
574
- <#
575
- var flow_steps = [];
576
- if( data.items[ key ].flow_steps ) {
577
- flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
578
- return value['id'];
579
- });
580
- }
581
- #>
582
- <div class="inner">
583
- <div class="template">
584
- <span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
585
- <div class="template-screenshot">
586
- <# if( data.items[ key ].featured_image_url ) { #>
587
- <img src="{{ data.items[ key ].featured_image_url }}" />
588
- <# } else { #>
589
- <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
590
- <# } #>
591
- </div>
592
- <div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
593
- <a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>step={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
594
- <# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
595
- <span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
596
- <# } #>
597
- </span>
598
- <div class="template-id-container">
599
- <h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
600
- <div class="template-actions">
601
-
602
- <#
603
-
604
- var required_plugin_group = data.items[ key ].page_builder.slug || '';
605
- var step_slug = data.items[ key ].step_type.slug || '';
606
- var step_title = data.items[ key ].step_type.name || '';
607
-
608
- if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
609
- import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
610
- } else {
611
- import_btn_title = 'Import';
612
- } #>
613
-
614
- <# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
615
- <a data-slug="{{step_slug}}" data-title="{{step_title}}" data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
616
- <# } else if( CartFlowsImportVars._is_pro_active ) { #>
617
- <a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
618
- <# } else { #>
619
- <a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
620
- <# } #>
621
- </div>
622
- </div>
623
- </div>
624
- </div>
625
- <# } #>
626
- <# } #>
627
- </script>
628
-
629
- <?php
630
- /**
631
- * TMPL - Filters
632
- */
633
- ?>
634
- <script type="text/template" id="tmpl-cartflows-term-filters">
635
-
636
- <# if ( data ) { #>
637
-
638
- <# if ( CartFlowsImportVars.flow_page_builder === data.args.remote_slug || CartFlowsImportVars.step_page_builder === data.args.remote_slug ) { #>
639
- <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
640
-
641
- <# if ( data.args.show_all ) { #>
642
- <li>
643
- <a href="#" data-group="all"> All </a>
644
- </li>
645
- <# } #>
646
-
647
- <# for ( key in data.items ) { #>
648
- <li>
649
- <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</a>
650
- </li>
651
- <# } #>
652
-
653
- </ul>
654
-
655
- <# } else { #>
656
- <select class="{{ data.args.wrapper_class }} {{ data.args.class }}">
657
-
658
- <# if ( data.args.show_all ) { #>
659
- <option value="all"> <?php _e( 'All', 'cartflows' ); ?> </option>
660
- <# } #>
661
-
662
- <# if ( CartFlowsImportVars.step_type === data.args.remote_slug ) { #>
663
- <option value=""> <?php _e( 'Select Step Type', 'cartflows' ); ?> </option>
664
- <# } #>
665
-
666
- <# for ( key in data.items ) { #>
667
- <option value='{{ data.items[ key ].id }}' data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</option>
668
- <# } #>
669
-
670
- </select>
671
- <# } #>
672
-
673
- <# } #>
674
- </script>
675
-
676
- <?php
677
- // Step Type.
678
- ?>
679
- <script type="text/template" id="tmpl-cartflows-step-types">
680
- <ul class="wcf-tab nav-tabs">
681
- <# if( data.items_count ) { #>
682
- <# for( key in data.items ) { #>
683
- <# console.log( data.items[ key ].id ) #>
684
- <li data-slug="{{data.items[ key ].slug}}" data-title="{{ data.items[ key ].name }}">
685
- <a href="#{{{ data.items[ key ].slug }}}">{{{ data.items[ key ].name }}}</a>
686
- </li>
687
- <# } #>
688
- <# } #>
689
- </ul>
690
- </script>
691
-
692
- <?php
693
- // Add to library button.
694
- ?>
695
- <script type="text/template" id="tmpl-templator-add-to-library">
696
- <a class="templator-add-to-library page-title-action cartflows-load-steps-library"><i class="dashicons dashicons-cloud"></i><?php esc_attr_e( 'Import from Cloud', 'cartflows' ); ?></a>
697
- </script>
698
- <?php
699
- }
700
-
701
- /**
702
- * Get plugin button string.
703
- *
704
- * @param string $plugin_init_file Plguin init file.
705
- * @param string $plugin_title Plguin title.
706
- * @return string
707
- */
708
- function get_plugin_button_string( $plugin_init_file, $plugin_title ) {
709
-
710
- if ( null == self::$installed_plugins ) {
711
- self::$installed_plugins = get_plugins();
712
- }
713
-
714
- if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
715
- /* translators: %s is plugin name. */
716
- return sprintf( __( 'Import', 'cartflows' ), $plugin_title );
717
- } elseif ( ! is_plugin_active( $plugin_init_file ) ) {
718
- /* translators: %s is plugin name. */
719
- return sprintf( __( 'Import', 'cartflows' ), $plugin_title );
720
- }
721
-
722
- return __( 'Import', 'cartflows' );
723
- }
724
-
725
- /**
726
- * Get plugin status
727
- *
728
- * @param string $plugin_init_file Plguin init file.
729
- * @return mixed
730
- */
731
- function get_plugin_status( $plugin_init_file ) {
732
-
733
- if ( null == self::$installed_plugins ) {
734
- self::$installed_plugins = get_plugins();
735
- }
736
-
737
- if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
738
- return 'install';
739
- } elseif ( ! is_plugin_active( $plugin_init_file ) ) {
740
- return 'activate';
741
- }
742
-
743
- return;
744
- }
745
-
746
- /**
747
- * Enqueue scripts
748
- *
749
- * @since 1.0.0
750
- *
751
- * @hook admin_enqueue_scripts
752
- * @param string $hook Current page hook.
753
- */
754
- function scripts( $hook = '' ) {
755
-
756
- if ( ! self::is_supported_post( get_current_screen()->post_type ) ) {
757
- return;
758
- }
759
-
760
- wp_enqueue_script( 'cartflows-rest-api', CARTFLOWS_URL . 'assets/js/rest-api.js', array( 'jquery' ), CARTFLOWS_VER, true );
761
- wp_enqueue_style( 'cartflows-import', CARTFLOWS_URL . 'assets/css/import.css', null, CARTFLOWS_VER, 'all' );
762
- wp_style_add_data( 'cartflows-import', 'rtl', 'replace' );
763
- wp_enqueue_script( 'cartflows-import', CARTFLOWS_URL . 'assets/js/import.js', array( 'jquery', 'wp-util', 'cartflows-rest-api', 'updates' ), CARTFLOWS_VER, true );
764
-
765
- $localize_vars = array(
766
- '_is_pro_active' => _is_cartflows_pro(),
767
-
768
- // Flow and its rest fields.
769
- 'flow' => CARTFLOWS_FLOW_POST_TYPE,
770
- 'flow_fields' => array(
771
- 'id',
772
- 'title',
773
- 'flow_type',
774
- 'page_builder',
775
- 'flow_steps',
776
- 'licence_status',
777
- 'featured_image_url',
778
- 'featured_media', // @required for field `featured_image_url`.
779
- ),
780
-
781
- // Flow type and rest fields.
782
- 'flow_type' => CARTFLOWS_TAXONOMY_FLOW_CATEGORY,
783
- 'flow_type_fields' => array(
784
- 'id',
785
- 'name',
786
- 'slug',
787
- ),
788
-
789
- // Flow page builder and rest fields.
790
- 'flow_page_builder' => CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER,
791
- 'flow_page_builder_fields' => array(
792
- 'id',
793
- 'name',
794
- 'slug',
795
- ),
796
-
797
- // Step page builder and rest fields.
798
- 'step_page_builder' => CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER,
799
- 'step_page_builder_fields' => array(
800
- 'id',
801
- 'name',
802
- 'slug',
803
- ),
804
-
805
- // Step and its rest fields.
806
- 'step' => CARTFLOWS_STEP_POST_TYPE,
807
- 'step_fields' => array(
808
- 'title',
809
- 'featured_image_url',
810
- 'featured_media', // @required for field `featured_image_url`.
811
- 'id',
812
- 'flow_type',
813
- 'step_type',
814
- 'page_builder',
815
- 'licence_status',
816
- ),
817
-
818
- // Step type and its rest fields.
819
- 'step_type' => CARTFLOWS_TAXONOMY_STEP_TYPE,
820
- 'step_type_fields' => array(
821
- 'id',
822
- 'name',
823
- 'slug',
824
- ),
825
-
826
- 'domain_url' => CARTFLOWS_DOMAIN_URL,
827
- 'server_url' => CARTFLOWS_TEMPLATES_URL,
828
- 'server_rest_url' => CARTFLOWS_TEMPLATES_URL . 'wp-json/wp/v2/',
829
- 'site_url' => site_url(),
830
- 'import_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_importer' ),
831
- 'export_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_exporter' ),
832
- 'admin_url' => admin_url(),
833
- 'licence_args' => CartFlows_API::get_instance()->get_licence_args(),
834
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
835
- 'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
836
-
837
- 'required_plugins' => array(
838
- 'elementor' => array(
839
- 'button_title' => $this->get_plugin_button_string( 'elementor/elementor.php', 'Elementor' ),
840
- 'status' => $this->get_plugin_status( 'elementor/elementor.php' ),
841
- 'plugins' => array(
842
- array(
843
- 'slug' => 'elementor', // For download from wp.org.
844
- 'status' => $this->get_plugin_status( 'elementor/elementor.php' ),
845
- ),
846
- ),
847
- ),
848
- ),
849
- );
850
-
851
- // Add thickbox.
852
- add_thickbox();
853
-
854
- wp_localize_script( 'cartflows-import', 'CartFlowsImportVars', $localize_vars );
855
- wp_localize_script( 'cartflows-rest-api', 'CartFlowsImportVars', $localize_vars );
856
- }
857
-
858
- /**
859
- * Load Template
860
- *
861
- * @since 1.0.0
862
- *
863
- * @hook cartflows_load_steps
864
- * @return void
865
- */
866
- function load_templates() {
867
-
868
- check_ajax_referer( 'cf-load-steps', 'security' );
869
-
870
- $args = ( isset( $_POST['args'] ) ) ? array_map( 'sanitize_text_field', $_POST['args'] ) : array();
871
- $templates = CartFlows_API::get_instance()->get_templates( $args );
872
-
873
- if ( $templates['templates_count'] ) {
874
- wp_send_json_success( $templates );
875
- } else {
876
- wp_send_json_error( $templates );
877
- }
878
- wp_die();
879
- }
880
-
881
- /**
882
- * Import.
883
- *
884
- * @since 1.0.0
885
- *
886
- * @hook wp_ajax_cartflows_import_flow_step
887
- * @return void
888
- */
889
- function import_flow() {
890
-
891
- check_ajax_referer( 'cf-import-flow-step', 'security' );
892
-
893
- $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
894
- $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
895
-
896
- wcf()->logger->import_log( '------------------------------------' );
897
- wcf()->logger->import_log( 'STARTED! Importing FLOW' );
898
- wcf()->logger->import_log( '------------------------------------' );
899
- wcf()->logger->import_log( '(✓) Creating new step from remote step [' . $template_id . '] for FLOW ' . get_the_title( $flow_id ) . ' [' . $flow_id . ']' );
900
-
901
- $response = CartFlows_API::get_instance()->get_template( $template_id );
902
-
903
- if ( false === $response['success'] ) {
904
- wcf()->logger->import_log( '(✕) Failed to fetch remote data.' );
905
- wp_send_json_error( $response );
906
- }
907
-
908
- wcf()->logger->import_log( '(✓) Successfully getting remote step response ' . json_encode( $response ) );
909
-
910
- $new_step_id = wp_insert_post(
911
- array(
912
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
913
- 'post_title' => $response['title'],
914
- 'post_content' => '',
915
- 'post_status' => 'publish',
916
- )
917
- );
918
-
919
- if ( is_wp_error( $new_step_id ) ) {
920
- wcf()->logger->import_log( '(✕) Failed to create new step for flow ' . $flow_id );
921
- wp_send_json_error( $new_step_id );
922
- }
923
-
924
- wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id );
925
- // insert post meta.
926
- update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
927
- wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' );
928
-
929
- /**
930
- * Import & Set type.
931
- */
932
- $term = isset( $response['data']['step_type'] ) ? $response['data']['step_type'] : '';
933
- $term_slug = '';
934
- if ( $term ) {
935
-
936
- $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
937
- $term_exist = term_exists( $term->name, $taxonomy );
938
-
939
- if ( empty( $term_exist ) ) {
940
- $terms = array(
941
- array(
942
- 'name' => $term->name,
943
- ),
944
- );
945
-
946
- Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
947
- wcf()->logger->import_log( '(✓) Created new term ' . $term->name );
948
- }
949
-
950
- $current_term = term_exists( $term->name, $taxonomy );
951
-
952
- // Set type object.
953
- $data = get_term( $current_term['term_id'], $taxonomy );
954
- $term_slug = $data->slug;
955
- $term_name = $data->name;
956
- wp_set_object_terms( $new_step_id, $term_slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
957
- wcf()->logger->import_log( '(✓) Assigned existing term ' . $term_name . ' to the template ' . $new_step_id );
958
-
959
- // Set type.
960
- update_post_meta( $new_step_id, 'wcf-step-type', $term_slug );
961
- wcf()->logger->import_log( '(✓) Updated term ' . $term_name . ' to the post meta wcf-step-type.' );
962
- }
963
-
964
- // Set flow.
965
- wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
966
- wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
967
-
968
- /**
969
- * Update steps for the current flow.
970
- */
971
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
972
-
973
- if ( ! is_array( $flow_steps ) ) {
974
- $flow_steps = array();
975
- }
976
-
977
- $flow_steps[] = array(
978
- 'id' => $new_step_id,
979
- 'title' => $response['title'],
980
- 'type' => $term_slug,
981
- );
982
- update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
983
- wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
984
-
985
- // Import Post Meta.
986
- self::import_post_meta( $new_step_id, $response );
987
-
988
- wcf()->logger->import_log( '(✓) Importing step "' . get_the_title( $new_step_id ) . '" [' . $new_step_id . '] for FLOW "' . get_the_title( $flow_id ) . '" [' . $flow_id . ']' );
989
- wcf()->logger->import_log( '------------------------------------' );
990
- wcf()->logger->import_log( 'COMPLETE! Importing FLOW' );
991
- wcf()->logger->import_log( '------------------------------------' );
992
-
993
- do_action( 'cartflows_import_complete' );
994
- wcf()->logger->import_log( '(✓) BATCH STARTED for step ' . $new_step_id . ' for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' );
995
-
996
- // Batch Process.
997
- do_action( 'cartflows_after_template_import', $new_step_id, $response );
998
-
999
- /**
1000
- * End
1001
- */
1002
- wp_send_json_success( $new_step_id );
1003
- }
1004
-
1005
- /**
1006
- * Import Step.
1007
- *
1008
- * @since 1.0.0
1009
- * @hook wp_ajax_cartflows_step_import
1010
- *
1011
- * @return void
1012
- */
1013
- function create_default_flow() {
1014
-
1015
- check_ajax_referer( 'cf-default-flow', 'security' );
1016
-
1017
- // Create post object.
1018
- $new_flow_post = array(
1019
- 'post_content' => '',
1020
- 'post_status' => 'publish',
1021
- 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
1022
- );
1023
-
1024
- // Insert the post into the database.
1025
- $flow_id = wp_insert_post( $new_flow_post );
1026
-
1027
- if ( is_wp_error( $flow_id ) ) {
1028
- wp_send_json_error( $flow_id->get_error_message() );
1029
- }
1030
-
1031
- $flow_steps = array();
1032
-
1033
- $steps_data = array(
1034
- 'landing' => __( 'Landing Page', 'cartflows' ),
1035
- 'checkout' => __( 'Checkout Page', 'cartflows' ),
1036
- 'thankyou' => __( 'Thank You Page', 'cartflows' ),
1037
- );
1038
-
1039
- foreach ( $steps_data as $slug => $title ) {
1040
-
1041
- $post_content = '';
1042
-
1043
- switch ( $slug ) {
1044
- case 'checkout':
1045
- $post_content = '';
1046
- break;
1047
- case 'thankyou':
1048
- $post_content = '';
1049
- break;
1050
- default:
1051
- $post_content = '';
1052
- break;
1053
- }
1054
-
1055
- $step_id = wp_insert_post(
1056
- array(
1057
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
1058
- 'post_title' => $title,
1059
- 'post_content' => $post_content,
1060
- 'post_status' => 'publish',
1061
- )
1062
- );
1063
-
1064
- if ( is_wp_error( $step_id ) ) {
1065
- wp_send_json_error( $step_id->get_error_message() );
1066
- }
1067
-
1068
- if ( $step_id ) {
1069
-
1070
- $flow_steps[] = array(
1071
- 'id' => $step_id,
1072
- 'title' => $title,
1073
- 'type' => $slug,
1074
- );
1075
-
1076
- // insert post meta.
1077
- update_post_meta( $step_id, 'wcf-flow-id', $flow_id );
1078
- update_post_meta( $step_id, 'wcf-step-type', $slug );
1079
-
1080
- wp_set_object_terms( $step_id, $slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
1081
- wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
1082
- }
1083
- }
1084
-
1085
- update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
1086
-
1087
- wp_send_json_success( $flow_id );
1088
- }
1089
-
1090
- /**
1091
- * Create Flow
1092
- *
1093
- * @return void
1094
- */
1095
- function create_flow() {
1096
-
1097
- check_ajax_referer( 'cf-create-flow', 'security' );
1098
-
1099
- // Create post object.
1100
- $new_flow_post = array(
1101
- 'post_content' => '',
1102
- 'post_status' => 'publish',
1103
- 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
1104
- );
1105
-
1106
- // Insert the post into the database.
1107
- $flow_id = wp_insert_post( $new_flow_post );
1108
-
1109
- if ( is_wp_error( $flow_id ) ) {
1110
- wp_send_json_error( $flow_id->get_error_message() );
1111
- }
1112
-
1113
- wp_send_json_success( $flow_id );
1114
- }
1115
-
1116
- /**
1117
- * Create Step
1118
- *
1119
- * @return void
1120
- */
1121
- function import_step() {
1122
-
1123
- check_ajax_referer( 'cf-step-import', 'security' );
1124
-
1125
- $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
1126
- $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
1127
- $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
1128
- $step_type = isset( $_POST['step_type'] ) ? sanitize_title( $_POST['step_type'] ) : '';
1129
- $step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( $_POST['step_custom_title'] ) : $step_title;
1130
-
1131
- $cartflow_meta = Cartflows_Flow_Meta::get_instance();
1132
-
1133
- $post_id = $cartflow_meta->create_step( $flow_id, $step_type, $step_custom_title );
1134
-
1135
- wcf()->logger->import_log( '------------------------------------' );
1136
- wcf()->logger->import_log( 'STARTED! Importing STEP' );
1137
- wcf()->logger->import_log( '------------------------------------' );
1138
-
1139
- if ( empty( $template_id ) || empty( $post_id ) ) {
1140
- /* translators: %s: template ID */
1141
- $data = sprintf( __( 'Invalid template id %1$s or post id %2$s.', 'cartflows' ), $template_id, $post_id );
1142
- wcf()->logger->import_log( $data );
1143
- wp_send_json_error( $data );
1144
- }
1145
-
1146
- wcf()->logger->import_log( 'Remote Step ' . $template_id . ' for local flow "' . get_the_title( $post_id ) . '" [' . $post_id . ']' );
1147
-
1148
- $response = CartFlows_API::get_instance()->get_template( $template_id );
1149
-
1150
- wcf()->logger->import_log( json_encode( $response ) );
1151
-
1152
- // Import Post Meta.
1153
- self::import_post_meta( $post_id, $response );
1154
-
1155
- do_action( 'cartflows_import_complete' );
1156
-
1157
- // Batch Process.
1158
- do_action( 'cartflows_after_template_import', $post_id, $response );
1159
-
1160
- wcf()->logger->import_log( '------------------------------------' );
1161
- wcf()->logger->import_log( 'COMPLETE! Importing Step' );
1162
- wcf()->logger->import_log( '------------------------------------' );
1163
-
1164
- wp_send_json_success( $post_id );
1165
- }
1166
-
1167
- /**
1168
- * Import Step.
1169
- *
1170
- * @since 1.0.0
1171
- * @hook wp_ajax_cartflows_step_create_blank
1172
- *
1173
- * @return void
1174
- */
1175
- function step_create_blank() {
1176
-
1177
- check_ajax_referer( 'cf-step-create-blank', 'security' );
1178
-
1179
- $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
1180
- $step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( $_POST['step_type'] ) : '';
1181
- $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
1182
-
1183
- if ( empty( $flow_id ) || empty( $step_type ) ) {
1184
- /* translators: %s: flow ID */
1185
- $data = sprintf( __( 'Invalid flow id %1$s OR step type %2$s.', 'cartflows' ), $flow_id, $step_type );
1186
- wcf()->logger->import_log( $data );
1187
- wp_send_json_error( $data );
1188
- }
1189
-
1190
- wcf()->logger->import_log( '------------------------------------' );
1191
- wcf()->logger->import_log( 'STARTED! Creating Blank STEP for Flow ' . $flow_id );
1192
-
1193
- $step_type_title = str_replace( '-', ' ', $step_type );
1194
- $step_type_slug = strtolower( str_replace( '-', ' ', $step_type ) );
1195
-
1196
- $new_step_id = wp_insert_post(
1197
- array(
1198
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
1199
- 'post_title' => $step_title,
1200
- 'post_content' => '',
1201
- 'post_status' => 'publish',
1202
- )
1203
- );
1204
-
1205
- // insert post meta.
1206
- update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
1207
-
1208
- $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
1209
- $term_exist = term_exists( $step_type_title, $taxonomy );
1210
-
1211
- if ( empty( $term_exist ) ) {
1212
- $terms = array(
1213
- array(
1214
- 'name' => $step_type_title,
1215
- ),
1216
- );
1217
-
1218
- Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
1219
- wcf()->logger->import_log( '(✓) Created new term ' . $step_type_title );
1220
- }
1221
-
1222
- $current_term = term_exists( $step_type_title, $taxonomy );
1223
-
1224
- // Set type object.
1225
- $data = get_term( $current_term['term_id'], $taxonomy );
1226
- $step_slug = $data->slug;
1227
- wp_set_object_terms( $new_step_id, $data->slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
1228
- wcf()->logger->import_log( '(✓) Assigned existing term ' . $step_type_title . ' to the template ' . $new_step_id );
1229
-
1230
- // Set type.
1231
- update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
1232
- wcf()->logger->import_log( '(✓) Updated term ' . $data->name . ' to the post meta wcf-step-type.' );
1233
-
1234
- // Set flow.
1235
- wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
1236
- wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
1237
-
1238
- CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step_type_title, $step_slug );
1239
-
1240
- wcf()->logger->import_log( 'COMPLETE! Creating Blank STEP for Flow ' . $flow_id );
1241
- wcf()->logger->import_log( '------------------------------------' );
1242
-
1243
- wp_send_json_success( $new_step_id );
1244
- }
1245
-
1246
- /**
1247
- * Import Post Meta
1248
- *
1249
- * @since 1.0.0
1250
- *
1251
- * @param integer $post_id Post ID.
1252
- * @param array $response Post meta.
1253
- * @return void
1254
- */
1255
- public static function import_post_meta( $post_id, $response ) {
1256
-
1257
- $metadata = (array) $response['post_meta'];
1258
-
1259
- foreach ( $metadata as $meta_key => $meta_value ) {
1260
- $meta_value = isset( $meta_value[0] ) ? $meta_value[0] : '';
1261
-
1262
- if ( $meta_value ) {
1263
-
1264
- if ( is_serialized( $meta_value, true ) ) {
1265
- $raw_data = maybe_unserialize( stripslashes( $meta_value ) );
1266
- } elseif ( is_array( $meta_value ) ) {
1267
- $raw_data = json_decode( stripslashes( $meta_value ), true );
1268
- } else {
1269
- $raw_data = $meta_value;
1270
- }
1271
-
1272
- if ( '_elementor_data' === $meta_key ) {
1273
- if ( is_array( $raw_data ) ) {
1274
- $raw_data = wp_slash( json_encode( $raw_data ) );
1275
- } else {
1276
- $raw_data = wp_slash( $raw_data );
1277
- }
1278
- wcf()->logger->import_log( $raw_data );
1279
- }
1280
-
1281
- if ( is_array( $raw_data ) ) {
1282
- wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . json_encode( $raw_data ) );
1283
- } else {
1284
-
1285
- if ( ! is_object( $raw_data ) ) {
1286
- wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data );
1287
- }
1288
- }
1289
-
1290
- update_post_meta( $post_id, $meta_key, $raw_data );
1291
- }
1292
- }
1293
- }
1294
-
1295
- /**
1296
- * Import Template for Elementor
1297
- *
1298
- * @since 1.0.0
1299
- *
1300
- * @param integer $post_id Post ID.
1301
- * @param array $response Post meta.
1302
- * @param array $page_build_data Page build data.
1303
- * @return void
1304
- */
1305
- public static function import_template_elementor( $post_id, $response, $page_build_data ) {
1306
- if ( ! is_plugin_active( 'elementor/elementor.php' ) ) {
1307
- $data = __( 'Elementor is not activated. Please activate plugin Elementor Page Builder to import the step.', 'cartflows' );
1308
- wcf()->logger->import_log( $data );
1309
- wp_send_json_error( $data );
1310
- }
1311
-
1312
- require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
1313
-
1314
- wcf()->logger->import_log( '# Started "importing page builder data" for step ' . $post_id );
1315
-
1316
- $obj = new \Elementor\TemplateLibrary\CartFlows_Importer_Elementor();
1317
- $obj->import_single_template( $post_id );
1318
-
1319
- wcf()->logger->import_log( '# Complete "importing page builder data" for step ' . $post_id );
1320
- }
1321
-
1322
- /**
1323
- * Supported post types
1324
- *
1325
- * @since 1.0.0
1326
- *
1327
- * @return array Supported post types.
1328
- */
1329
- public static function supported_post_types() {
1330
- return apply_filters(
1331
- 'cartflows_supported_post_types',
1332
- array(
1333
- CARTFLOWS_FLOW_POST_TYPE,
1334
- )
1335
- );
1336
- }
1337
-
1338
- /**
1339
- * Check supported post type
1340
- *
1341
- * @since 1.0.0
1342
- *
1343
- * @param string $post_type Post type.
1344
- * @return boolean Supported post type status.
1345
- */
1346
- public static function is_supported_post( $post_type = '' ) {
1347
- if ( in_array( $post_type, self::supported_post_types() ) ) {
1348
- return true;
1349
- }
1350
-
1351
- return false;
1352
- }
1353
-
1354
- /**
1355
- * Set steps to the flow
1356
- *
1357
- * @param integer $flow_id Flow ID.
1358
- * @param integer $new_step_id New step ID.
1359
- * @param string $step_title Flow Type.
1360
- * @param string $step_slug Flow Type.
1361
- */
1362
- function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) {
1363
- // Update steps for the current flow.
1364
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
1365
-
1366
- if ( ! is_array( $flow_steps ) ) {
1367
- $flow_steps = array();
1368
- }
1369
-
1370
- $flow_steps[] = array(
1371
- 'id' => $new_step_id,
1372
- 'title' => $step_title,
1373
- 'type' => $step_slug,
1374
- );
1375
- update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
1376
- wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
1377
- }
1378
-
1379
- /**
1380
- * Localize variables in admin
1381
- *
1382
- * @param array $vars variables.
1383
- */
1384
- function localize_vars( $vars ) {
1385
-
1386
- $ajax_actions = array(
1387
- 'cf_step_import',
1388
- 'cf_load_steps',
1389
- 'cf_create_flow',
1390
- 'cf_default_flow',
1391
- 'cf_step_create_blank',
1392
- 'cf_import_flow_step',
1393
- );
1394
-
1395
- foreach ( $ajax_actions as $action ) {
1396
-
1397
- $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
1398
- }
1399
-
1400
- return $vars;
1401
- }
1402
-
1403
- /**
1404
- * Ajax action to activate plugin
1405
- */
1406
- public function activate_plugin() {
1407
-
1408
- $plugin_slug = isset( $_POST['plugin_slug'] ) ? sanitize_text_field( $_POST['plugin_slug'] ) : '';
1409
-
1410
- if ( ! is_plugin_active( $plugin_slug ) ) {
1411
-
1412
- $activate = activate_plugin( $plugin_slug, '', false, true );
1413
-
1414
- if ( is_wp_error( $activate ) ) {
1415
- wp_send_json_error();
1416
- }
1417
- }
1418
-
1419
- wp_send_json_success();
1420
- }
1421
-
1422
- }
1423
-
1424
- /**
1425
- * Initialize class object with 'get_instance()' method
1426
- */
1427
- CartFlows_Importer::get_instance();
1428
-
1429
- endif;
1
+ <?php
2
+ /**
3
+ * CartFlows Admin
4
+ *
5
+ * @package CartFlows
6
+ * @since 1.0.0
7
+ */
8
+
9
+ if ( ! class_exists( 'CartFlows_Importer' ) ) :
10
+
11
+ /**
12
+ * CartFlows Import
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ class CartFlows_Importer {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.0.0
22
+ * @access private
23
+ * @var object Class object.
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
+
38
+ return self::$instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor
43
+ *
44
+ * @since 1.0.0
45
+ */
46
+ public function __construct() {
47
+ add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
48
+ add_action( 'wp_ajax_cartflows_load_steps', array( $this, 'load_templates' ) );
49
+ add_action( 'wp_ajax_cartflows_step_import', array( $this, 'import_step' ) );
50
+ add_action( 'wp_ajax_cartflows_create_flow', array( $this, 'create_flow' ) );
51
+ add_action( 'wp_ajax_cartflows_default_flow', array( $this, 'create_default_flow' ) );
52
+ add_action( 'wp_ajax_cartflows_step_create_blank', array( $this, 'step_create_blank' ) );
53
+ add_action( 'wp_ajax_cartflows_import_flow_step', array( $this, 'import_flow' ) );
54
+ add_action( 'admin_footer', array( $this, 'js_templates' ) );
55
+ add_action( 'cartflows_import_complete', array( $this, 'clear_cache' ) );
56
+
57
+ add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
58
+
59
+ add_action( 'wp_ajax_cartflows_activate_plugin', array( $this, 'activate_plugin' ) );
60
+
61
+ add_action( 'admin_menu', array( $this, 'add_to_menus' ) );
62
+ add_action( 'admin_init', array( $this, 'export' ) );
63
+ add_action( 'admin_init', array( $this, 'import' ) );
64
+ add_filter( 'post_row_actions', array( $this, 'export_link' ), 10, 2 );
65
+ add_action( 'admin_action_cartflows_export_flow', array( $this, 'export_flow' ) );
66
+ }
67
+
68
+ /**
69
+ * Add the export link to action list for flows row actions
70
+ *
71
+ * @since 1.1.4
72
+ *
73
+ * @param array $actions Actions array.
74
+ * @param object $post Post object.
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
+ }
82
+ return $actions;
83
+ }
84
+
85
+ /**
86
+ * Add menus
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
+ }
94
+
95
+ /**
96
+ * Export flow with steps and its meta
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
+
110
+ // Get the original post id.
111
+ $flow_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
112
+
113
+ $flows = array();
114
+ $flows[] = $this->get_flow_export_data( $flow_id );
115
+ $flows = apply_filters( 'cartflows_export_data', $flows );
116
+
117
+ nocache_headers();
118
+ header( 'Content-Type: application/json; charset=utf-8' );
119
+ header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
120
+ header( 'Expires: 0' );
121
+
122
+ echo json_encode( $flows );
123
+ exit;
124
+ }
125
+
126
+ /**
127
+ * Export flow markup
128
+ *
129
+ * @since 1.1.4
130
+ */
131
+ function exporter_markup() {
132
+ include_once CARTFLOWS_DIR . 'includes/exporter.php';
133
+ }
134
+
135
+ /**
136
+ * Import flow markup
137
+ *
138
+ * @since 1.1.4
139
+ */
140
+ function importer_markup() {
141
+ include_once CARTFLOWS_DIR . 'includes/importer.php';
142
+ }
143
+
144
+ /**
145
+ * Export flow
146
+ *
147
+ * @since 1.1.4
148
+ */
149
+ function export() {
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
+
158
+ if ( ! current_user_can( 'manage_options' ) ) {
159
+ return;
160
+ }
161
+
162
+ $flows = $this->get_all_flow_export_data();
163
+ $flows = apply_filters( 'cartflows_export_data', $flows );
164
+
165
+ nocache_headers();
166
+ header( 'Content-Type: application/json; charset=utf-8' );
167
+ header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
168
+ header( 'Expires: 0' );
169
+
170
+ echo json_encode( $flows );
171
+ exit;
172
+ }
173
+
174
+ /**
175
+ * Get flow export data
176
+ *
177
+ * @since 1.1.4
178
+ *
179
+ * @param integer $flow_id Flow ID.
180
+ * @return array
181
+ */
182
+ function get_flow_export_data( $flow_id ) {
183
+
184
+ $valid_step_meta_keys = array(
185
+ '_wp_page_template',
186
+ '_thumbnail_id',
187
+ 'classic-editor-remember',
188
+ );
189
+
190
+ $new_steps = array();
191
+ $steps = get_post_meta( $flow_id, 'wcf-steps', true );
192
+ if ( $steps ) {
193
+ foreach ( $steps as $key => $step ) {
194
+
195
+ // Add step post meta.
196
+ $new_all_meta = array();
197
+ $all_meta = get_post_meta( $step['id'] );
198
+ if ( is_array( $all_meta ) ) {
199
+ foreach ( $all_meta as $meta_key => $value ) {
200
+ if ( substr( $meta_key, 0, strlen( 'wcf' ) ) === 'wcf' ) {
201
+ $new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
202
+ } elseif ( in_array( $meta_key, $valid_step_meta_keys ) ) {
203
+ $new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
204
+ }
205
+ }
206
+ }
207
+
208
+ // Add single step.
209
+ $new_steps[] = array(
210
+ 'title' => get_the_title( $step['id'] ),
211
+ 'type' => $step['type'],
212
+ 'meta' => $new_all_meta,
213
+ );
214
+ }
215
+ }
216
+
217
+ // Add single flow.
218
+ return array(
219
+ 'title' => get_the_title( $flow_id ),
220
+ 'steps' => $new_steps,
221
+ );
222
+ }
223
+
224
+ /**
225
+ * Get all flow export data
226
+ *
227
+ * @since 1.1.4
228
+ */
229
+ function get_all_flow_export_data() {
230
+
231
+ $query_args = array(
232
+ 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
233
+
234
+ // Query performance optimization.
235
+ 'fields' => 'ids',
236
+ 'no_found_rows' => true,
237
+ 'posts_per_page' => -1,
238
+ );
239
+
240
+ $query = new WP_Query( $query_args );
241
+ $flows = array();
242
+ if ( $query->posts ) {
243
+ foreach ( $query->posts as $key => $post_id ) {
244
+ $flows[] = $this->get_flow_export_data( $post_id );
245
+ }
246
+ }
247
+
248
+ return $flows;
249
+ }
250
+
251
+ /**
252
+ * Import our exported file
253
+ *
254
+ * @since 1.1.4
255
+ */
256
+ function import() {
257
+ if ( empty( $_POST['cartflows-action'] ) || 'import' != $_POST['cartflows-action'] ) {
258
+ return;
259
+ }
260
+
261
+ if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
262
+ return;
263
+ }
264
+
265
+ if ( ! current_user_can( 'manage_options' ) ) {
266
+ return;
267
+ }
268
+
269
+ $filename = $_FILES['file']['name'];
270
+ $file_info = explode( '.', $filename );
271
+ $extension = end( $file_info );
272
+
273
+ if ( 'json' != $extension ) {
274
+ wp_die( __( 'Please upload a valid .json file', 'cartflows' ) );
275
+ }
276
+
277
+ $file = $_FILES['file']['tmp_name'];
278
+
279
+ if ( empty( $file ) ) {
280
+ wp_die( __( 'Please upload a file to import', 'cartflows' ) );
281
+ }
282
+
283
+ // Retrieve the settings from the file and convert the JSON object to an array.
284
+ $flows = json_decode( file_get_contents( $file ), true );
285
+
286
+ if ( $flows ) {
287
+
288
+ foreach ( $flows as $key => $flow ) {
289
+
290
+ $flow_title = $flow['title'];
291
+ if ( post_exists( $flow['title'] ) ) {
292
+ $flow_title = $flow['title'] . ' Copy';
293
+ }
294
+
295
+ // Create post object.
296
+ $new_flow_args = array(
297
+ 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
298
+ 'post_title' => $flow_title,
299
+ 'post_status' => 'draft',
300
+ );
301
+
302
+ // Insert the post into the database.
303
+ $flow_id = wp_insert_post( $new_flow_args );
304
+
305
+ if ( $flow['steps'] ) {
306
+ foreach ( $flow['steps'] as $key => $step ) {
307
+ $new_step_id = wp_insert_post(
308
+ array(
309
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
310
+ 'post_title' => $step['title'],
311
+ 'post_status' => 'draft',
312
+ 'meta_input' => $step['meta'],
313
+ )
314
+ );
315
+
316
+ // Insert post meta.
317
+ update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
318
+
319
+ $step_taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
320
+ $current_term = term_exists( $step['type'], $step_taxonomy );
321
+
322
+ // // Set type object.
323
+ $data = get_term( $current_term['term_id'], $step_taxonomy );
324
+ $step_slug = $data->slug;
325
+ wp_set_object_terms( $new_step_id, $data->slug, $step_taxonomy );
326
+
327
+ // Set type.
328
+ update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
329
+
330
+ // Set flow.
331
+ wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
332
+
333
+ CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step['title'], $step_slug );
334
+ }
335
+ }
336
+ }
337
+ }
338
+
339
+ add_action( 'admin_notices', array( $this, 'imported_successfully' ) );
340
+ }
341
+
342
+ /**
343
+ * Imported notice
344
+ *
345
+ * @since 1.1.4
346
+ */
347
+ function imported_successfully() {
348
+ ?>
349
+ <div class="notice notice-success">
350
+ <p><?php _e( 'Successfully imported flows.', 'cartflows' ); ?></p>
351
+ </div>
352
+ <?php
353
+ }
354
+
355
+ /**
356
+ * Clear Cache.
357
+ *
358
+ * @since 1.0.0
359
+ */
360
+ public function clear_cache() {
361
+ // Clear 'Elementor' file cache.
362
+ if ( class_exists( '\Elementor\Plugin' ) ) {
363
+ Elementor\Plugin::$instance->files_manager->clear_cache();
364
+ }
365
+ }
366
+
367
+ /**
368
+ * JS Templates
369
+ *
370
+ * @since 1.0.0
371
+ *
372
+ * @return void
373
+ */
374
+ function js_templates() {
375
+
376
+ // Loading Templates.
377
+ ?>
378
+ <script type="text/template" id="tmpl-cartflows-step-loading">
379
+ <div class="template-message-block cartflows-step-loading">
380
+ <h2>
381
+ <span class="spinner"></span>
382
+ <?php _e( 'Loading Steps', 'cartflows' ); ?>
383
+ </h2>
384
+ <p class="description"><?php _e( 'Getting steps from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
385
+ </div>
386
+ </script>
387
+
388
+ <?php
389
+ // Search Templates.
390
+ ?>
391
+ <script type="text/template" id="tmpl-cartflows-searching-templates">
392
+ <div class="template-message-block cartflows-searching-templates">
393
+ <h2>
394
+ <span class="spinner"></span>
395
+ <?php _e( 'Searching Template..', 'cartflows' ); ?>
396
+ </h2>
397
+ <p class="description"><?php _e( 'Getting templates from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
398
+ </div>
399
+ </script>
400
+
401
+ <?php
402
+ // CartFlows Importing Template.
403
+ ?>
404
+ <script type="text/template" id="tmpl-cartflows-step-importing">
405
+ <div class="template-message-block cartflows-step-importing">
406
+ <h2><span class="spinner"></span> <?php _e( 'Importing..', 'cartflows' ); ?></h2>
407
+ </div>
408
+ </script>
409
+
410
+ <?php
411
+ // CartFlows Imported.
412
+ ?>
413
+ <script type="text/template" id="tmpl-cartflows-step-imported">
414
+ <div class="template-message-block cartflows-step-imported">
415
+ <h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
416
+ <p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span></p></div>
417
+ </script>
418
+
419
+ <?php
420
+ // No templates.
421
+ ?>
422
+ <script type="text/template" id="tmpl-cartflows-no-steps">
423
+ <div class="cartflows-no-steps">
424
+ <div class="template-message-block">
425
+ <h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
426
+ <p class="description"></p>
427
+ </div>
428
+ </div>
429
+ </script>
430
+
431
+ <?php
432
+ // No templates.
433
+ ?>
434
+ <script type="text/template" id="tmpl-cartflows-no-flows">
435
+ <div class="cartflows-no-flows">
436
+ <div class="template-message-block">
437
+ <h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
438
+ <p class="description"></p>
439
+ </div>
440
+ </div>
441
+ </script>
442
+
443
+ <?php
444
+ // Error handling.
445
+ ?>
446
+ <script type="text/template" id="tmpl-templator-error">
447
+ <div class="notice notice-error"><p>{{ data }}</p></div>
448
+ </script>
449
+
450
+ <?php
451
+ // Redirect to Elementor.
452
+ ?>
453
+ <script type="text/template" id="tmpl-templator-redirect-to-elementor">
454
+ <div class="template-message-block templator-redirect-to-elementor">
455
+ <h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
456
+ <p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span><br/><br/><?php _e( 'Redirecting to the Elementor edit window.', 'cartflows' ); ?> </p></div>
457
+ </script>
458
+
459
+ <?php
460
+ /**
461
+ * Responsive Buttons
462
+ */
463
+ ?>
464
+ <script type="text/template" id="tmpl-cartflows-responsive-view">
465
+ <span class="responsive-view">
466
+ <span class="actions">
467
+ <a class="desktop" href="#"><span data-view="desktop " class="active dashicons dashicons-desktop"></span></a>
468
+ <a class="tablet" href="#"><span data-view="tablet" class="dashicons dashicons-tablet"></span></a>
469
+ <a class="mobile" href="#"><span data-view="mobile" class="dashicons dashicons-smartphone"></span></a>
470
+ </span>
471
+ </span>
472
+ </script>
473
+
474
+ <?php
475
+ // Templates data.
476
+ ?>
477
+ <script type="text/template" id="tmpl-cartflows-flows-list">
478
+
479
+ <# console.log( data.items.length ) #>
480
+ <# console.log( data.items ) #>
481
+ <# if ( data.items.length ) { #>
482
+ <# for ( key in data.items ) { #>
483
+ <#
484
+ var flow_steps = [];
485
+ if( data.items[ key ].flow_steps ) {
486
+ flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
487
+ return value['id'];
488
+ });
489
+ }
490
+ #>
491
+ <div class="inner">
492
+ <div class="template">
493
+ <span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
494
+ <div class="template-screenshot">
495
+ <# if( data.items[ key ].featured_image_url ) { #>
496
+ <img src="{{ data.items[ key ].featured_image_url }}" />
497
+ <# } else { #>
498
+ <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
499
+ <# } #>
500
+ </div>
501
+ <a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>flow={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
502
+ <# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
503
+ <span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
504
+ <# } #>
505
+ </span>
506
+ <div class="template-id-container">
507
+ <h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
508
+ <div class="template-actions">
509
+
510
+ <#
511
+ if( data.items[ key ].page_builder.slug ) {
512
+ required_plugin_group = data.items[ key ].page_builder.slug;
513
+ } else {
514
+ required_plugin_group = '';
515
+ }
516
+
517
+ if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
518
+ import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
519
+ } else {
520
+ import_btn_title = 'Import';
521
+ } #>
522
+
523
+ <# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
524
+ <a data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
525
+ <# } else if( CartFlowsImportVars._is_pro_active ) { #>
526
+ <a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
527
+ <# } else { #>
528
+ <a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
529
+ <# } #>
530
+ </div>
531
+ </div>
532
+ </div>
533
+ </div>
534
+ <# } #>
535
+ <# } #>
536
+ </script>
537
+
538
+ <?php
539
+ // Empty Step.
540
+ ?>
541
+ <script type="text/template" id="tmpl-cartflows-create-blank-step">
542
+ <div class="inner">
543
+ <div class="template">
544
+ <span class="thumbnail site-preview cartflows-flow-preview">
545
+ <div class="template-screenshot">
546
+ <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
547
+ </div>
548
+ <div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
549
+ </span>
550
+ <div class="template-id-container">
551
+ <h3 class="template-name"> Blank </h3>
552
+ <div class="template-actions">
553
+ <a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create', 'cartflows' ); ?></a>
554
+ </div>
555
+ </div>
556
+ </div>
557
+ </div>
558
+ </script>
559
+
560
+ <?php
561
+ // Templates data.
562
+ ?>
563
+ <script type="text/template" id="tmpl-cartflows-steps-list">
564
+ <# if ( data.items.length ) { #>
565
+ <# for ( key in data.items ) { #>
566
+ <#
567
+ var flow_steps = [];
568
+ if( data.items[ key ].flow_steps ) {
569
+ flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
570
+ return value['id'];
571
+ });
572
+ }
573
+ #>
574
+ <div class="inner">
575
+ <div class="template">
576
+ <span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
577
+ <div class="template-screenshot">
578
+ <# if( data.items[ key ].featured_image_url ) { #>
579
+ <img src="{{ data.items[ key ].featured_image_url }}" />
580
+ <# } else { #>
581
+ <img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
582
+ <# } #>
583
+ </div>
584
+ <div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
585
+ <a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>step={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
586
+ <# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
587
+ <span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
588
+ <# } #>
589
+ </span>
590
+ <div class="template-id-container">
591
+ <h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
592
+ <div class="template-actions">
593
+
594
+ <#
595
+
596
+ var step_slug = data.items[ key ].step_type.slug || '';
597
+ var step_title = data.items[ key ].step_type.name || '';
598
+ var import_btn_title = 'Import';
599
+
600
+ var required_plugin_group = '';
601
+ if( data.items[ key ].page_builder ) {
602
+ required_plugin_group = data.items[ key ].page_builder.slug;
603
+
604
+ if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
605
+ import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
606
+ }
607
+ }
608
+ #>
609
+
610
+ <# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
611
+ <a data-slug="{{step_slug}}" data-title="{{step_title}}" data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
612
+ <# } else if( CartFlowsImportVars._is_pro_active ) { #>
613
+ <a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
614
+ <# } else { #>
615
+ <a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
616
+ <# } #>
617
+ </div>
618
+ </div>
619
+ </div>
620
+ </div>
621
+ <# } #>
622
+ <# } #>
623
+ </script>
624
+
625
+ <?php
626
+ /**
627
+ * TMPL - Filters
628
+ */
629
+ ?>
630
+ <script type="text/template" id="tmpl-cartflows-page-builder-notice">
631
+ <?php
632
+ $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
633
+ $page_builder = Cartflows_Helper::get_required_plugins_for_page_builder( Cartflows_Helper::get_common_setting( 'default_page_builder' ) );
634
+ $title = $page_builder['title'];
635
+ ?>
636
+ <div class="wcf-page-builder-message">
637
+ <p><a href="#" data-slug="<?php echo $default_page_builder; ?>" class="wcf-install-plugin">Please click here and activate <?php echo $title; ?></a> to see CartFlows templates. If you prefer another page builder tool, you can <a href="<?php echo esc_url( admin_url( 'admin.php?page=' . CARTFLOWS_SETTINGS . '&action=common-settings#form-field-wcf_default_page_builder' ) ); ?>" target="blank">select it here</a>.</p>
638
+ <p>If your preferred page builder is not available, feel free to <a href="#" data-slug="canvas" class="wcf-create-from-scratch-link">create your own</a> pages using page builder of your choice as CartFlows works with all major page builders.</p>
639
+ <p>We plan to add design templates made with more page builder shortly!</p>
640
+ </div>
641
+ </script>
642
+
643
+ <?php
644
+ /**
645
+ * TMPL - Filters
646
+ */
647
+ ?>
648
+ <script type="text/template" id="tmpl-cartflows-term-filters-dropdown">
649
+ <# if ( data ) { #>
650
+ <select class="{{ data.args.wrapper_class }} {{ data.args.class }}">
651
+ <# if ( data.args.show_all ) { #>
652
+ <option value="all"> <?php _e( 'All', 'cartflows' ); ?> </option>
653
+ <# } #>
654
+ <# if ( CartFlowsImportVars.step_type === data.args.remote_slug ) { #>
655
+ <option value=""> <?php _e( 'Select Step Type', 'cartflows' ); ?> </option>
656
+ <# } #>
657
+ <# for ( key in data.items ) { #>
658
+ <option value='{{ data.items[ key ].id }}' data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</option>
659
+ <# } #>
660
+ </select>
661
+ <# } #>
662
+ </script>
663
+
664
+ <script type="text/template" id="tmpl-cartflows-term-filters">
665
+
666
+ <# if ( data ) { #>
667
+
668
+ <?php /* <# if ( CartFlowsImportVars.flow_page_builder === data.args.remote_slug || CartFlowsImportVars.step_page_builder === data.args.remote_slug ) { #> */ ?>
669
+ <ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
670
+
671
+ <# if ( data.args.show_all ) { #>
672
+ <li>
673
+ <a href="#" data-group="all"> All </a>
674
+ </li>
675
+ <# } #>
676
+
677
+ <# for ( key in data.items ) { #>
678
+ <li>
679
+ <a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</a>
680
+ </li>
681
+ <# } #>
682
+
683
+ </ul>
684
+
685
+ <?php
686
+
687
+ /*
688
+ <# } else { #>
689
+ <select class="{{ data.args.wrapper_class }} {{ data.args.class }}">
690
+
691
+ <# if ( data.args.show_all ) { #>
692
+ <option value="all"> <?php _e( 'All', 'cartflows' ); ?> </option>
693
+ <# } #>
694
+
695
+ <# if ( CartFlowsImportVars.step_type === data.args.remote_slug ) { #>
696
+ <option value=""> <?php _e( 'Select Step Type', 'cartflows' ); ?> </option>
697
+ <# } #>
698
+
699
+ <# for ( key in data.items ) { #>
700
+ <option value='{{ data.items[ key ].id }}' data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</option>
701
+ <# } #>
702
+
703
+ </select>
704
+ */
705
+ ?>
706
+
707
+ <?php /* <# } #> */ ?>
708
+
709
+ <# } #>
710
+ </script>
711
+
712
+ <?php
713
+ // Step Type.
714
+ ?>
715
+ <script type="text/template" id="tmpl-cartflows-step-types">
716
+ <ul class="wcf-tab nav-tabs">
717
+ <# if( data.items_count ) { #>
718
+ <# for( key in data.items ) { #>
719
+ <# console.log( data.items[ key ].id ) #>
720
+ <li data-slug="{{data.items[ key ].slug}}" data-title="{{ data.items[ key ].name }}">
721
+ <a href="#{{{ data.items[ key ].slug }}}">{{{ data.items[ key ].name }}}</a>
722
+ </li>
723
+ <# } #>
724
+ <# } #>
725
+ </ul>
726
+ </script>
727
+
728
+ <?php
729
+ // Add to library button.
730
+ ?>
731
+ <script type="text/template" id="tmpl-templator-add-to-library">
732
+ <a class="templator-add-to-library page-title-action cartflows-load-steps-library"><i class="dashicons dashicons-cloud"></i><?php esc_attr_e( 'Import from Cloud', 'cartflows' ); ?></a>
733
+ </script>
734
+ <?php
735
+ }
736
+
737
+ /**
738
+ * Enqueue scripts
739
+ *
740
+ * @since 1.0.0
741
+ *
742
+ * @hook admin_enqueue_scripts
743
+ * @param string $hook Current page hook.
744
+ */
745
+ function scripts( $hook = '' ) {
746
+
747
+ if ( ! self::is_supported_post( get_current_screen()->post_type ) ) {
748
+ return;
749
+ }
750
+
751
+ wp_enqueue_script( 'cartflows-rest-api', CARTFLOWS_URL . 'assets/js/rest-api.js', array( 'jquery' ), CARTFLOWS_VER, true );
752
+ wp_enqueue_style( 'cartflows-import', CARTFLOWS_URL . 'assets/css/import.css', null, CARTFLOWS_VER, 'all' );
753
+ wp_style_add_data( 'cartflows-import', 'rtl', 'replace' );
754
+ wp_enqueue_script( 'cartflows-import', CARTFLOWS_URL . 'assets/js/import.js', array( 'jquery', 'wp-util', 'cartflows-rest-api', 'updates' ), CARTFLOWS_VER, true );
755
+
756
+ $localize_vars = array(
757
+ '_is_pro_active' => _is_cartflows_pro(),
758
+
759
+ // Flow and its rest fields.
760
+ 'flow' => CARTFLOWS_FLOW_POST_TYPE,
761
+ 'flow_fields' => array(
762
+ 'id',
763
+ 'title',
764
+ 'flow_type',
765
+ 'page_builder',
766
+ 'flow_steps',
767
+ 'licence_status',
768
+ 'featured_image_url',
769
+ 'featured_media', // @required for field `featured_image_url`.
770
+ ),
771
+
772
+ // Flow type and rest fields.
773
+ 'flow_type' => CARTFLOWS_TAXONOMY_FLOW_CATEGORY,
774
+ 'flow_type_fields' => array(
775
+ 'id',
776
+ 'name',
777
+ 'slug',
778
+ ),
779
+
780
+ // Flow page builder and rest fields.
781
+ 'flow_page_builder' => CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER,
782
+ 'flow_page_builder_fields' => array(
783
+ 'id',
784
+ 'name',
785
+ 'slug',
786
+ ),
787
+
788
+ // Step page builder and rest fields.
789
+ 'step_page_builder' => CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER,
790
+ 'step_page_builder_fields' => array(
791
+ 'id',
792
+ 'name',
793
+ 'slug',
794
+ ),
795
+
796
+ // Step and its rest fields.
797
+ 'step' => CARTFLOWS_STEP_POST_TYPE,
798
+ 'step_fields' => array(
799
+ 'title',
800
+ 'featured_image_url',
801
+ 'featured_media', // @required for field `featured_image_url`.
802
+ 'id',
803
+ 'flow_type',
804
+ 'step_type',
805
+ 'page_builder',
806
+ 'licence_status',
807
+ ),
808
+
809
+ // Step type and its rest fields.
810
+ 'step_type' => CARTFLOWS_TAXONOMY_STEP_TYPE,
811
+ 'step_type_fields' => array(
812
+ 'id',
813
+ 'name',
814
+ 'slug',
815
+ ),
816
+
817
+ 'domain_url' => CARTFLOWS_DOMAIN_URL,
818
+ 'server_url' => CARTFLOWS_TEMPLATES_URL,
819
+ 'server_rest_url' => CARTFLOWS_TEMPLATES_URL . 'wp-json/wp/v2/',
820
+ 'site_url' => site_url(),
821
+ 'import_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_importer' ),
822
+ 'export_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_exporter' ),
823
+ 'admin_url' => admin_url(),
824
+ 'licence_args' => CartFlows_API::get_instance()->get_licence_args(),
825
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
826
+ 'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
827
+
828
+ 'required_plugins' => Cartflows_Helper::get_plugins_groupby_page_builders(),
829
+
830
+ 'default_page_builder' => Cartflows_Helper::get_common_setting( 'default_page_builder' ),
831
+ );
832
+
833
+ // var_dump(Cartflows_Helper::get_common_setting( 'default_page_builder' ));
834
+ // wp_die( );
835
+ // Add thickbox.
836
+ add_thickbox();
837
+
838
+ wp_localize_script( 'cartflows-import', 'CartFlowsImportVars', $localize_vars );
839
+ wp_localize_script( 'cartflows-rest-api', 'CartFlowsImportVars', $localize_vars );
840
+ }
841
+
842
+ /**
843
+ * Load Template
844
+ *
845
+ * @since 1.0.0
846
+ *
847
+ * @hook cartflows_load_steps
848
+ * @return void
849
+ */
850
+ function load_templates() {
851
+
852
+ check_ajax_referer( 'cf-load-steps', 'security' );
853
+
854
+ $args = ( isset( $_POST['args'] ) ) ? array_map( 'sanitize_text_field', $_POST['args'] ) : array();
855
+ $templates = CartFlows_API::get_instance()->get_templates( $args );
856
+
857
+ if ( $templates['templates_count'] ) {
858
+ wp_send_json_success( $templates );
859
+ } else {
860
+ wp_send_json_error( $templates );
861
+ }
862
+ wp_die();
863
+ }
864
+
865
+ /**
866
+ * Import.
867
+ *
868
+ * @since 1.0.0
869
+ *
870
+ * @hook wp_ajax_cartflows_import_flow_step
871
+ * @return void
872
+ */
873
+ function import_flow() {
874
+
875
+ check_ajax_referer( 'cf-import-flow-step', 'security' );
876
+
877
+ $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
878
+ $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
879
+
880
+ wcf()->logger->import_log( '------------------------------------' );
881
+ wcf()->logger->import_log( 'STARTED! Importing FLOW' );
882
+ wcf()->logger->import_log( '------------------------------------' );
883
+ wcf()->logger->import_log( '(✓) Creating new step from remote step [' . $template_id . '] for FLOW ' . get_the_title( $flow_id ) . ' [' . $flow_id . ']' );
884
+
885
+ $response = CartFlows_API::get_instance()->get_template( $template_id );
886
+
887
+ if ( false === $response['success'] ) {
888
+ wcf()->logger->import_log( '(✕) Failed to fetch remote data.' );
889
+ wp_send_json_error( $response );
890
+ }
891
+
892
+ wcf()->logger->import_log( '(✓) Successfully getting remote step response ' . json_encode( $response ) );
893
+
894
+ $new_step_id = wp_insert_post(
895
+ array(
896
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
897
+ 'post_title' => $response['title'],
898
+ 'post_content' => '',
899
+ 'post_status' => 'publish',
900
+ )
901
+ );
902
+
903
+ if ( is_wp_error( $new_step_id ) ) {
904
+ wcf()->logger->import_log( '(✕) Failed to create new step for flow ' . $flow_id );
905
+ wp_send_json_error( $new_step_id );
906
+ }
907
+
908
+ wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id );
909
+ // insert post meta.
910
+ update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
911
+ wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' );
912
+
913
+ /**
914
+ * Import & Set type.
915
+ */
916
+ $term = isset( $response['data']['step_type'] ) ? $response['data']['step_type'] : '';
917
+ $term_slug = '';
918
+ if ( $term ) {
919
+
920
+ $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
921
+ $term_exist = term_exists( $term->name, $taxonomy );
922
+
923
+ if ( empty( $term_exist ) ) {
924
+ $terms = array(
925
+ array(
926
+ 'name' => $term->name,
927
+ ),
928
+ );
929
+
930
+ Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
931
+ wcf()->logger->import_log( '(✓) Created new term ' . $term->name );
932
+ }
933
+
934
+ $current_term = term_exists( $term->name, $taxonomy );
935
+
936
+ // Set type object.
937
+ $data = get_term( $current_term['term_id'], $taxonomy );
938
+ $term_slug = $data->slug;
939
+ $term_name = $data->name;
940
+ wp_set_object_terms( $new_step_id, $term_slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
941
+ wcf()->logger->import_log( '(✓) Assigned existing term ' . $term_name . ' to the template ' . $new_step_id );
942
+
943
+ // Set type.
944
+ update_post_meta( $new_step_id, 'wcf-step-type', $term_slug );
945
+ wcf()->logger->import_log( '(✓) Updated term ' . $term_name . ' to the post meta wcf-step-type.' );
946
+ }
947
+
948
+ // Set flow.
949
+ wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
950
+ wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
951
+
952
+ /**
953
+ * Update steps for the current flow.
954
+ */
955
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
956
+
957
+ if ( ! is_array( $flow_steps ) ) {
958
+ $flow_steps = array();
959
+ }
960
+
961
+ $flow_steps[] = array(
962
+ 'id' => $new_step_id,
963
+ 'title' => $response['title'],
964
+ 'type' => $term_slug,
965
+ );
966
+ update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
967
+ wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
968
+
969
+ // Import Post Meta.
970
+ self::import_post_meta( $new_step_id, $response );
971
+
972
+ wcf()->logger->import_log( '(✓) Importing step "' . get_the_title( $new_step_id ) . '" [' . $new_step_id . '] for FLOW "' . get_the_title( $flow_id ) . '" [' . $flow_id . ']' );
973
+ wcf()->logger->import_log( '------------------------------------' );
974
+ wcf()->logger->import_log( 'COMPLETE! Importing FLOW' );
975
+ wcf()->logger->import_log( '------------------------------------' );
976
+
977
+ do_action( 'cartflows_import_complete' );
978
+ wcf()->logger->import_log( '(✓) BATCH STARTED for step ' . $new_step_id . ' for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' );
979
+
980
+ // Batch Process.
981
+ do_action( 'cartflows_after_template_import', $new_step_id, $response );
982
+
983
+ /**
984
+ * End
985
+ */
986
+ wp_send_json_success( $new_step_id );
987
+ }
988
+
989
+ /**
990
+ * Import Step.
991
+ *
992
+ * @since 1.0.0
993
+ * @hook wp_ajax_cartflows_step_import
994
+ *
995
+ * @return void
996
+ */
997
+ function create_default_flow() {
998
+
999
+ check_ajax_referer( 'cf-default-flow', 'security' );
1000
+
1001
+ // Create post object.
1002
+ $new_flow_post = array(
1003
+ 'post_content' => '',
1004
+ 'post_status' => 'publish',
1005
+ 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
1006
+ );
1007
+
1008
+ // Insert the post into the database.
1009
+ $flow_id = wp_insert_post( $new_flow_post );
1010
+
1011
+ if ( is_wp_error( $flow_id ) ) {
1012
+ wp_send_json_error( $flow_id->get_error_message() );
1013
+ }
1014
+
1015
+ $flow_steps = array();
1016
+
1017
+ $steps_data = array(
1018
+ 'landing' => __( 'Landing Page', 'cartflows' ),
1019
+ 'checkout' => __( 'Checkout Page', 'cartflows' ),
1020
+ 'thankyou' => __( 'Thank You Page', 'cartflows' ),
1021
+ );
1022
+
1023
+ foreach ( $steps_data as $slug => $title ) {
1024
+
1025
+ $post_content = '';
1026
+
1027
+ switch ( $slug ) {
1028
+ case 'checkout':
1029
+ $post_content = '';
1030
+ break;
1031
+ case 'thankyou':
1032
+ $post_content = '';
1033
+ break;
1034
+ default:
1035
+ $post_content = '';
1036
+ break;
1037
+ }
1038
+
1039
+ $step_id = wp_insert_post(
1040
+ array(
1041
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
1042
+ 'post_title' => $title,
1043
+ 'post_content' => $post_content,
1044
+ 'post_status' => 'publish',
1045
+ )
1046
+ );
1047
+
1048
+ if ( is_wp_error( $step_id ) ) {
1049
+ wp_send_json_error( $step_id->get_error_message() );
1050
+ }
1051
+
1052
+ if ( $step_id ) {
1053
+
1054
+ $flow_steps[] = array(
1055
+ 'id' => $step_id,
1056
+ 'title' => $title,
1057
+ 'type' => $slug,
1058
+ );
1059
+
1060
+ // insert post meta.
1061
+ update_post_meta( $step_id, 'wcf-flow-id', $flow_id );
1062
+ update_post_meta( $step_id, 'wcf-step-type', $slug );
1063
+
1064
+ wp_set_object_terms( $step_id, $slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
1065
+ wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
1066
+ }
1067
+ }
1068
+
1069
+ update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
1070
+
1071
+ wp_send_json_success( $flow_id );
1072
+ }
1073
+
1074
+ /**
1075
+ * Create Flow
1076
+ *
1077
+ * @return void
1078
+ */
1079
+ function create_flow() {
1080
+
1081
+ check_ajax_referer( 'cf-create-flow', 'security' );
1082
+
1083
+ // Create post object.
1084
+ $new_flow_post = array(
1085
+ 'post_content' => '',
1086
+ 'post_status' => 'publish',
1087
+ 'post_type' => CARTFLOWS_FLOW_POST_TYPE,
1088
+ );
1089
+
1090
+ // Insert the post into the database.
1091
+ $flow_id = wp_insert_post( $new_flow_post );
1092
+
1093
+ if ( is_wp_error( $flow_id ) ) {
1094
+ wp_send_json_error( $flow_id->get_error_message() );
1095
+ }
1096
+
1097
+ wp_send_json_success( $flow_id );
1098
+ }
1099
+
1100
+ /**
1101
+ * Create Step
1102
+ *
1103
+ * @return void
1104
+ */
1105
+ function import_step() {
1106
+
1107
+ check_ajax_referer( 'cf-step-import', 'security' );
1108
+
1109
+ $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
1110
+ $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
1111
+ $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
1112
+ $step_type = isset( $_POST['step_type'] ) ? sanitize_title( $_POST['step_type'] ) : '';
1113
+ $step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( $_POST['step_custom_title'] ) : $step_title;
1114
+
1115
+ $cartflow_meta = Cartflows_Flow_Meta::get_instance();
1116
+
1117
+ $post_id = $cartflow_meta->create_step( $flow_id, $step_type, $step_custom_title );
1118
+
1119
+ wcf()->logger->import_log( '------------------------------------' );
1120
+ wcf()->logger->import_log( 'STARTED! Importing STEP' );
1121
+ wcf()->logger->import_log( '------------------------------------' );
1122
+
1123
+ if ( empty( $template_id ) || empty( $post_id ) ) {
1124
+ /* translators: %s: template ID */
1125
+ $data = sprintf( __( 'Invalid template id %1$s or post id %2$s.', 'cartflows' ), $template_id, $post_id );
1126
+ wcf()->logger->import_log( $data );
1127
+ wp_send_json_error( $data );
1128
+ }
1129
+
1130
+ wcf()->logger->import_log( 'Remote Step ' . $template_id . ' for local flow "' . get_the_title( $post_id ) . '" [' . $post_id . ']' );
1131
+
1132
+ $response = CartFlows_API::get_instance()->get_template( $template_id );
1133
+
1134
+ // Import Post Meta.
1135
+ self::import_post_meta( $post_id, $response );
1136
+
1137
+ do_action( 'cartflows_import_complete' );
1138
+
1139
+ // Batch Process.
1140
+ do_action( 'cartflows_after_template_import', $post_id, $response );
1141
+
1142
+ wcf()->logger->import_log( '------------------------------------' );
1143
+ wcf()->logger->import_log( 'COMPLETE! Importing Step' );
1144
+ wcf()->logger->import_log( '------------------------------------' );
1145
+
1146
+ wp_send_json_success( $post_id );
1147
+ }
1148
+
1149
+ /**
1150
+ * Import Step.
1151
+ *
1152
+ * @since 1.0.0
1153
+ * @hook wp_ajax_cartflows_step_create_blank
1154
+ *
1155
+ * @return void
1156
+ */
1157
+ function step_create_blank() {
1158
+
1159
+ check_ajax_referer( 'cf-step-create-blank', 'security' );
1160
+
1161
+ $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
1162
+ $step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( $_POST['step_type'] ) : '';
1163
+ $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
1164
+
1165
+ if ( empty( $flow_id ) || empty( $step_type ) ) {
1166
+ /* translators: %s: flow ID */
1167
+ $data = sprintf( __( 'Invalid flow id %1$s OR step type %2$s.', 'cartflows' ), $flow_id, $step_type );
1168
+ wcf()->logger->import_log( $data );
1169
+ wp_send_json_error( $data );
1170
+ }
1171
+
1172
+ wcf()->logger->import_log( '------------------------------------' );
1173
+ wcf()->logger->import_log( 'STARTED! Creating Blank STEP for Flow ' . $flow_id );
1174
+
1175
+ $step_type_title = str_replace( '-', ' ', $step_type );
1176
+ $step_type_slug = strtolower( str_replace( '-', ' ', $step_type ) );
1177
+
1178
+ $new_step_id = wp_insert_post(
1179
+ array(
1180
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
1181
+ 'post_title' => $step_title,
1182
+ 'post_content' => '',
1183
+ 'post_status' => 'publish',
1184
+ )
1185
+ );
1186
+
1187
+ // insert post meta.
1188
+ update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
1189
+
1190
+ $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
1191
+ $term_exist = term_exists( $step_type_title, $taxonomy );
1192
+
1193
+ if ( empty( $term_exist ) ) {
1194
+ $terms = array(
1195
+ array(
1196
+ 'name' => $step_type_title,
1197
+ ),
1198
+ );
1199
+
1200
+ Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
1201
+ wcf()->logger->import_log( '(✓) Created new term ' . $step_type_title );
1202
+ }
1203
+
1204
+ $current_term = term_exists( $step_type_title, $taxonomy );
1205
+
1206
+ // Set type object.
1207
+ $data = get_term( $current_term['term_id'], $taxonomy );
1208
+ $step_slug = $data->slug;
1209
+ wp_set_object_terms( $new_step_id, $data->slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
1210
+ wcf()->logger->import_log( '(✓) Assigned existing term ' . $step_type_title . ' to the template ' . $new_step_id );
1211
+
1212
+ // Set type.
1213
+ update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
1214
+ wcf()->logger->import_log( '(✓) Updated term ' . $data->name . ' to the post meta wcf-step-type.' );
1215
+
1216
+ // Set flow.
1217
+ wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
1218
+ wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
1219
+
1220
+ CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step_type_title, $step_slug );
1221
+
1222
+ wcf()->logger->import_log( 'COMPLETE! Creating Blank STEP for Flow ' . $flow_id );
1223
+ wcf()->logger->import_log( '------------------------------------' );
1224
+
1225
+ wp_send_json_success( $new_step_id );
1226
+ }
1227
+
1228
+ /**
1229
+ * Import Post Meta
1230
+ *
1231
+ * @since 1.0.0
1232
+ *
1233
+ * @param integer $post_id Post ID.
1234
+ * @param array $response Post meta.
1235
+ * @return void
1236
+ */
1237
+ public static function import_post_meta( $post_id, $response ) {
1238
+
1239
+ $metadata = (array) $response['post_meta'];
1240
+
1241
+ foreach ( $metadata as $meta_key => $meta_value ) {
1242
+ $meta_value = isset( $meta_value[0] ) ? $meta_value[0] : '';
1243
+
1244
+ if ( $meta_value ) {
1245
+
1246
+ if ( is_serialized( $meta_value, true ) ) {
1247
+ $raw_data = maybe_unserialize( stripslashes( $meta_value ) );
1248
+ } elseif ( is_array( $meta_value ) ) {
1249
+ $raw_data = json_decode( stripslashes( $meta_value ), true );
1250
+ } else {
1251
+ $raw_data = $meta_value;
1252
+ }
1253
+
1254
+ if ( '_elementor_data' === $meta_key ) {
1255
+ if ( is_array( $raw_data ) ) {
1256
+ $raw_data = wp_slash( json_encode( $raw_data ) );
1257
+ } else {
1258
+ $raw_data = wp_slash( $raw_data );
1259
+ }
1260
+ }
1261
+ if ( '_elementor_data' !== $meta_key && '_elementor_draft' !== $meta_key && '_fl_builder_data' !== $meta_key && '_fl_builder_draft' !== $meta_key ) {
1262
+ if ( is_array( $raw_data ) ) {
1263
+ wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . json_encode( $raw_data ) );
1264
+ } else {
1265
+ if ( ! is_object( $raw_data ) ) {
1266
+ wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data );
1267
+ }
1268
+ }
1269
+ }
1270
+
1271
+ update_post_meta( $post_id, $meta_key, $raw_data );
1272
+ }
1273
+ }
1274
+ }
1275
+
1276
+ /**
1277
+ * Import Template for Elementor
1278
+ *
1279
+ * @since 1.0.0
1280
+ *
1281
+ * @param integer $post_id Post ID.
1282
+ * @param array $response Post meta.
1283
+ * @param array $page_build_data Page build data.
1284
+ * @return void
1285
+ */
1286
+ public static function import_template_elementor( $post_id, $response, $page_build_data ) {
1287
+ if ( ! is_plugin_active( 'elementor/elementor.php' ) ) {
1288
+ $data = __( 'Elementor is not activated. Please activate plugin Elementor Page Builder to import the step.', 'cartflows' );
1289
+ wcf()->logger->import_log( $data );
1290
+ wp_send_json_error( $data );
1291
+ }
1292
+
1293
+ require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
1294
+
1295
+ wcf()->logger->import_log( '# Started "importing page builder data" for step ' . $post_id );
1296
+
1297
+ $obj = new \Elementor\TemplateLibrary\CartFlows_Importer_Elementor();
1298
+ $obj->import_single_template( $post_id );
1299
+
1300
+ wcf()->logger->import_log( '# Complete "importing page builder data" for step ' . $post_id );
1301
+ }
1302
+
1303
+ /**
1304
+ * Supported post types
1305
+ *
1306
+ * @since 1.0.0
1307
+ *
1308
+ * @return array Supported post types.
1309
+ */
1310
+ public static function supported_post_types() {
1311
+ return apply_filters(
1312
+ 'cartflows_supported_post_types',
1313
+ array(
1314
+ CARTFLOWS_FLOW_POST_TYPE,
1315
+ )
1316
+ );
1317
+ }
1318
+
1319
+ /**
1320
+ * Check supported post type
1321
+ *
1322
+ * @since 1.0.0
1323
+ *
1324
+ * @param string $post_type Post type.
1325
+ * @return boolean Supported post type status.
1326
+ */
1327
+ public static function is_supported_post( $post_type = '' ) {
1328
+ if ( in_array( $post_type, self::supported_post_types() ) ) {
1329
+ return true;
1330
+ }
1331
+
1332
+ return false;
1333
+ }
1334
+
1335
+ /**
1336
+ * Set steps to the flow
1337
+ *
1338
+ * @param integer $flow_id Flow ID.
1339
+ * @param integer $new_step_id New step ID.
1340
+ * @param string $step_title Flow Type.
1341
+ * @param string $step_slug Flow Type.
1342
+ */
1343
+ function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) {
1344
+ // Update steps for the current flow.
1345
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
1346
+
1347
+ if ( ! is_array( $flow_steps ) ) {
1348
+ $flow_steps = array();
1349
+ }
1350
+
1351
+ $flow_steps[] = array(
1352
+ 'id' => $new_step_id,
1353
+ 'title' => $step_title,
1354
+ 'type' => $step_slug,
1355
+ );
1356
+ update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
1357
+ wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
1358
+ }
1359
+
1360
+ /**
1361
+ * Localize variables in admin
1362
+ *
1363
+ * @param array $vars variables.
1364
+ */
1365
+ function localize_vars( $vars ) {
1366
+
1367
+ $ajax_actions = array(
1368
+ 'cf_step_import',
1369
+ 'cf_load_steps',
1370
+ 'cf_create_flow',
1371
+ 'cf_default_flow',
1372
+ 'cf_step_create_blank',
1373
+ 'cf_import_flow_step',
1374
+ );
1375
+
1376
+ foreach ( $ajax_actions as $action ) {
1377
+
1378
+ $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
1379
+ }
1380
+
1381
+ return $vars;
1382
+ }
1383
+
1384
+ /**
1385
+ * Ajax action to activate plugin
1386
+ */
1387
+ public function activate_plugin() {
1388
+
1389
+ $plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( $_POST['plugin_init'] ) : '';
1390
+
1391
+ $activate = activate_plugin( $plugin_init, '', false, true );
1392
+
1393
+ if ( is_wp_error( $activate ) ) {
1394
+ wp_send_json_error(
1395
+ array(
1396
+ 'success' => false,
1397
+ 'message' => $activate->get_error_message(),
1398
+ 'init' => $plugin_init,
1399
+ )
1400
+ );
1401
+ }
1402
+
1403
+ wp_send_json_success(
1404
+ array(
1405
+ 'success' => true,
1406
+ 'message' => __( 'Plugin Successfully Activated', 'cartflows' ),
1407
+ 'init' => $plugin_init,
1408
+ )
1409
+ );
1410
+ }
1411
+
1412
+ }
1413
+
1414
+ /**
1415
+ * Initialize class object with 'get_instance()' method
1416
+ */
1417
+ CartFlows_Importer::get_instance();
1418
+
1419
+ endif;
 
 
 
 
 
 
 
 
 
 
classes/class-cartflows-loader.php CHANGED
@@ -115,7 +115,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
115
  define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
116
  define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
117
  define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
118
- define( 'CARTFLOWS_VER', '1.1.3' );
119
  define( 'CARTFLOWS_SLUG', 'cartflows' );
120
  define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
121
 
115
  define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
116
  define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
117
  define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
118
+ define( 'CARTFLOWS_VER', '1.1.4' );
119
  define( 'CARTFLOWS_SLUG', 'cartflows' );
120
  define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
121
 
includes/admin/cartflows-general.php CHANGED
@@ -1,127 +1,142 @@
1
- <?php
2
- /**
3
- * General settings
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- $settings = Cartflows_Helper::get_common_settings();
9
-
10
- ?>
11
-
12
- <form method="post" class="wrap wcf-clear" action="" >
13
- <div class="wrap wcf-addon-wrap wcf-clear wcf-container">
14
- <input type="hidden" name="action" value="wcf_save_common_settings">
15
- <h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
16
-
17
- <div id="poststuff">
18
- <div id="post-body" class="columns-2">
19
- <div id="post-body-content">
20
- <div class="postbox introduction">
21
- <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
22
- <span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
23
- </h2>
24
- <div class="inside">
25
- <div class="iframe-wrap">
26
- <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>
27
- </div>
28
- <p>
29
- <?php
30
- esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
31
- ?>
32
- </p>
33
- </div>
34
- </div>
35
-
36
- <div class="general-settings-form postbox">
37
- <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
38
- <span><?php _e( 'General Settings', 'cartflows' ); ?></span>
39
- </h2>
40
- <div class="inside">
41
- <div class="form-wrap">
42
- <?php
43
-
44
- do_action( 'cartflows_before_settings_fields', $settings );
45
-
46
- echo Cartflows_Admin_Fields::checkobox_field(
47
- array(
48
- 'id' => 'wcf_disallow_indexing',
49
- 'name' => '_cartflows_common[disallow_indexing]',
50
- 'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
51
- 'value' => $settings['disallow_indexing'],
52
- )
53
- );
54
- echo Cartflows_Admin_Fields::flow_checkout_selection_field(
55
- array(
56
- 'id' => 'wcf_global_checkout',
57
- 'name' => '_cartflows_common[global_checkout]',
58
- 'title' => __( 'Global Checkout', 'cartflows' ),
59
- 'value' => $settings['global_checkout'],
60
- )
61
- );
62
-
63
- do_action( 'cartflows_after_settings_fields', $settings );
64
-
65
- ?>
66
- </div>
67
- <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
68
- <?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
69
- </div>
70
- </div>
71
- </div>
72
- <div class="postbox-container" id="postbox-container-1">
73
- <div id="side-sortables">
74
-
75
- <div class="postbox">
76
- <h2 class="hndle">
77
- <span class="dashicons dashicons-book"></span>
78
- <span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
79
- </h2>
80
- <div class="inside">
81
- <p>
82
- <?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
83
- </p>
84
- <p>
85
- <a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
86
- </p>
87
- </div>
88
- </div>
89
-
90
- <div class="postbox">
91
- <h2 class="hndle">
92
- <span class="dashicons dashicons-groups"></span>
93
- <span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
94
- </h2>
95
- <div class="inside">
96
- <p>
97
- <?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
98
- </p>
99
- <p>
100
- <a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
101
- </p>
102
- </div>
103
- </div>
104
-
105
- <div class="postbox">
106
- <h2 class="hndle">
107
- <span class="dashicons dashicons-sos"></span>
108
- <span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
109
- </h2>
110
- <div class="inside">
111
- <p>
112
- <?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
113
- </p>
114
- <p>
115
- <a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
116
- </p>
117
- </div>
118
- </div>
119
-
120
- </div>
121
- </div>
122
- </div>
123
- <!-- /post-body -->
124
- <br class="clear">
125
- </div>
126
- </div>
127
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * General settings
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ $settings = Cartflows_Helper::get_common_settings();
9
+
10
+ ?>
11
+
12
+ <form method="post" class="wrap wcf-clear" action="" >
13
+ <div class="wrap wcf-addon-wrap wcf-clear wcf-container">
14
+ <input type="hidden" name="action" value="wcf_save_common_settings">
15
+ <h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
16
+
17
+ <div id="poststuff">
18
+ <div id="post-body" class="columns-2">
19
+ <div id="post-body-content">
20
+ <div class="postbox introduction">
21
+ <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
22
+ <span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
23
+ </h2>
24
+ <div class="inside">
25
+ <div class="iframe-wrap">
26
+ <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>
27
+ </div>
28
+ <p>
29
+ <?php
30
+ esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
31
+ ?>
32
+ </p>
33
+ </div>
34
+ </div>
35
+
36
+ <div class="general-settings-form postbox">
37
+ <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
38
+ <span><?php _e( 'General Settings', 'cartflows' ); ?></span>
39
+ </h2>
40
+ <div class="inside">
41
+ <div class="form-wrap">
42
+ <?php
43
+
44
+ do_action( 'cartflows_before_settings_fields', $settings );
45
+
46
+ echo Cartflows_Admin_Fields::checkobox_field(
47
+ array(
48
+ 'id' => 'wcf_disallow_indexing',
49
+ 'name' => '_cartflows_common[disallow_indexing]',
50
+ 'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
51
+ 'value' => $settings['disallow_indexing'],
52
+ )
53
+ );
54
+ echo Cartflows_Admin_Fields::flow_checkout_selection_field(
55
+ array(
56
+ 'id' => 'wcf_global_checkout',
57
+ 'name' => '_cartflows_common[global_checkout]',
58
+ 'title' => __( 'Global Checkout', 'cartflows' ),
59
+ 'value' => $settings['global_checkout'],
60
+ )
61
+ );
62
+
63
+ echo Cartflows_Admin_Fields::select_field(
64
+ array(
65
+ 'id' => 'wcf_default_page_builder',
66
+ 'name' => '_cartflows_common[default_page_builder]',
67
+ 'title' => __( 'Show Templates designed with', 'cartflows' ),
68
+ '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' ),
69
+ 'value' => $settings['default_page_builder'],
70
+ 'options' => array(
71
+ 'elementor' => __( 'Elementor', 'cartflows' ),
72
+ 'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
73
+ 'other' => __( 'Other', 'cartflows' ),
74
+ ),
75
+ )
76
+ );
77
+
78
+ do_action( 'cartflows_after_settings_fields', $settings );
79
+
80
+ ?>
81
+ </div>
82
+ <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
83
+ <?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ <div class="postbox-container" id="postbox-container-1">
88
+ <div id="side-sortables">
89
+
90
+ <div class="postbox">
91
+ <h2 class="hndle">
92
+ <span class="dashicons dashicons-book"></span>
93
+ <span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
94
+ </h2>
95
+ <div class="inside">
96
+ <p>
97
+ <?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
98
+ </p>
99
+ <p>
100
+ <a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
101
+ </p>
102
+ </div>
103
+ </div>
104
+
105
+ <div class="postbox">
106
+ <h2 class="hndle">
107
+ <span class="dashicons dashicons-groups"></span>
108
+ <span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
109
+ </h2>
110
+ <div class="inside">
111
+ <p>
112
+ <?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
113
+ </p>
114
+ <p>
115
+ <a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
116
+ </p>
117
+ </div>
118
+ </div>
119
+
120
+ <div class="postbox">
121
+ <h2 class="hndle">
122
+ <span class="dashicons dashicons-sos"></span>
123
+ <span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
124
+ </h2>
125
+ <div class="inside">
126
+ <p>
127
+ <?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
128
+ </p>
129
+ <p>
130
+ <a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
131
+ </p>
132
+ </div>
133
+ </div>
134
+
135
+ </div>
136
+ </div>
137
+ </div>
138
+ <!-- /post-body -->
139
+ <br class="clear">
140
+ </div>
141
+ </div>
142
+ </form>
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.1.3\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
7
- "POT-Creation-Date: 2019-01-15 10:41:49+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -36,15 +36,15 @@ msgstr ""
36
  msgid "Every %d Minutes"
37
  msgstr ""
38
 
39
- #: classes/class-cartflows-admin-fields.php:121
40
  msgid "Select"
41
  msgstr ""
42
 
43
- #: classes/class-cartflows-admin-fields.php:124
44
  msgid "No Checkout Steps"
45
  msgstr ""
46
 
47
- #: classes/class-cartflows-admin-fields.php:150
48
  #. translators: %s: link
49
  msgid ""
50
  "Be sure not to add any product in above selected Global Checkout step. "
@@ -56,34 +56,39 @@ msgstr ""
56
  msgid "Settings"
57
  msgstr ""
58
 
59
- #: classes/class-cartflows-admin.php:301
60
  msgid "Flows Library"
61
  msgstr ""
62
 
63
- #: classes/class-cartflows-admin.php:307
64
- #: modules/flow/view/meta-flow-steps.php:142
65
  msgid "Ready Templates"
66
  msgstr ""
67
 
68
- #: classes/class-cartflows-admin.php:310
69
- #: modules/flow/view/meta-flow-steps.php:145
70
  msgid "Create Your Own"
71
  msgstr ""
72
 
73
- #: classes/class-cartflows-admin.php:320
74
- #: modules/flow/view/meta-flow-steps.php:156
75
  msgid "Search Sites"
76
  msgstr ""
77
 
78
- #: classes/class-cartflows-admin.php:321
79
- #: modules/flow/view/meta-flow-steps.php:157
80
  msgid "Search Flow..."
81
  msgstr ""
82
 
83
- #: classes/class-cartflows-admin.php:336
84
  msgid "Design Your Flow"
85
  msgstr ""
86
 
 
 
 
 
 
87
  #: classes/class-cartflows-api.php:363
88
  msgid "Request successfully processed!"
89
  msgstr ""
@@ -102,146 +107,143 @@ msgid ""
102
  "be deactivated from the flow settings in the admin dashboard."
103
  msgstr ""
104
 
105
- #: classes/class-cartflows-importer.php:89
106
  msgid "Export this flow"
107
  msgstr ""
108
 
109
- #: classes/class-cartflows-importer.php:89 includes/exporter.php:18
110
  msgid "Export"
111
  msgstr ""
112
 
113
- #: classes/class-cartflows-importer.php:100
114
  msgid "Flow Export"
115
  msgstr ""
116
 
117
- #: classes/class-cartflows-importer.php:101
118
  msgid "Flow Import"
119
  msgstr ""
120
 
121
- #: classes/class-cartflows-importer.php:112
122
  msgid "No post to export has been supplied!"
123
  msgstr ""
124
 
125
- #: classes/class-cartflows-importer.php:283
126
  msgid "Please upload a valid .json file"
127
  msgstr ""
128
 
129
- #: classes/class-cartflows-importer.php:289
130
  msgid "Please upload a file to import"
131
  msgstr ""
132
 
133
- #: classes/class-cartflows-importer.php:359
134
  msgid "Successfully imported flows."
135
  msgstr ""
136
 
137
- #: classes/class-cartflows-importer.php:391
138
  msgid "Loading Steps"
139
  msgstr ""
140
 
141
- #: classes/class-cartflows-importer.php:393
142
  msgid "Getting steps from the cloud. Please wait for the moment."
143
  msgstr ""
144
 
145
- #: classes/class-cartflows-importer.php:404
146
  msgid "Searching Template.."
147
  msgstr ""
148
 
149
- #: classes/class-cartflows-importer.php:406
150
  msgid "Getting templates from the cloud. Please wait for the moment."
151
  msgstr ""
152
 
153
- #: classes/class-cartflows-importer.php:415
154
  msgid "Importing.."
155
  msgstr ""
156
 
157
- #: classes/class-cartflows-importer.php:424
158
- #: classes/class-cartflows-importer.php:464
159
  msgid "Imported"
160
  msgstr ""
161
 
162
- #: classes/class-cartflows-importer.php:425
163
- #: classes/class-cartflows-importer.php:465
164
  msgid "Thanks for patience"
165
  msgstr ""
166
 
167
- #: classes/class-cartflows-importer.php:434
168
- #: classes/class-cartflows-importer.php:446
169
  msgid "Coming Soon!"
170
  msgstr ""
171
 
172
- #: classes/class-cartflows-importer.php:465
173
  msgid "Redirecting to the Elementor edit window."
174
  msgstr ""
175
 
176
- #: classes/class-cartflows-importer.php:511
177
- #: classes/class-cartflows-importer.php:595
178
  msgid "Pro"
179
  msgstr ""
180
 
181
- #: classes/class-cartflows-importer.php:534
182
- #: classes/class-cartflows-importer.php:617
183
  msgid "Activate License"
184
  msgstr ""
185
 
186
- #: classes/class-cartflows-importer.php:536
187
- #: classes/class-cartflows-importer.php:619
188
  msgid "Get Pro"
189
  msgstr ""
190
 
191
- #: classes/class-cartflows-importer.php:561
192
  msgid "Create"
193
  msgstr ""
194
 
195
- #: classes/class-cartflows-importer.php:659
196
  msgid "All"
197
  msgstr ""
198
 
199
- #: classes/class-cartflows-importer.php:663
200
  msgid "Select Step Type"
201
  msgstr ""
202
 
203
- #: classes/class-cartflows-importer.php:696
204
  msgid "Import from Cloud"
205
  msgstr ""
206
 
207
- #: classes/class-cartflows-importer.php:716
208
- #: classes/class-cartflows-importer.php:719
209
- #: classes/class-cartflows-importer.php:722 includes/importer.php:21
210
- #. translators: %s is plugin name.
211
- msgid "Import"
212
- msgstr ""
213
-
214
- #: classes/class-cartflows-importer.php:1034
215
  #: modules/flow/classes/class-cartflows-flow-meta.php:224
216
  msgid "Landing Page"
217
  msgstr ""
218
 
219
- #: classes/class-cartflows-importer.php:1035
220
  #: modules/flow/classes/class-cartflows-flow-meta.php:225
221
  msgid "Checkout Page"
222
  msgstr ""
223
 
224
- #: classes/class-cartflows-importer.php:1036
225
  #: modules/flow/classes/class-cartflows-flow-meta.php:226
226
  msgid "Thank You Page"
227
  msgstr ""
228
 
229
- #: classes/class-cartflows-importer.php:1141
230
  #. translators: %s: template ID
231
  msgid "Invalid template id %1$s or post id %2$s."
232
  msgstr ""
233
 
234
- #: classes/class-cartflows-importer.php:1185
235
  #. translators: %s: flow ID
236
  msgid "Invalid flow id %1$s OR step type %2$s."
237
  msgstr ""
238
 
239
- #: classes/class-cartflows-importer.php:1307
240
  msgid ""
241
  "Elementor is not activated. Please activate plugin Elementor Page Builder "
242
  "to import the step."
243
  msgstr ""
244
 
 
 
 
 
245
  #: classes/class-cartflows-loader.php:332
246
  #. translators: %s: html tags
247
  msgid ""
@@ -368,6 +370,7 @@ msgid "Add locations for where this Schema should appear."
368
  msgstr ""
369
 
370
  #: classes/class-cartflows-wizard.php:273
 
371
  msgid "Elementor"
372
  msgstr ""
373
 
@@ -429,49 +432,69 @@ msgid "Disallow search engines from indexing flows"
429
  msgstr ""
430
 
431
  #: includes/admin/cartflows-general.php:58
432
- #: modules/flow/view/meta-flow-steps.php:85
433
  msgid "Global Checkout"
434
  msgstr ""
435
 
436
  #: includes/admin/cartflows-general.php:67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
  msgid "Save Changes"
438
  msgstr ""
439
 
440
- #: includes/admin/cartflows-general.php:78
441
  msgid "Knowledge Base"
442
  msgstr ""
443
 
444
- #: includes/admin/cartflows-general.php:82
445
  msgid "Not sure how something works? Take a peek at the knowledge base and learn."
446
  msgstr ""
447
 
448
- #: includes/admin/cartflows-general.php:85
449
  msgid "Visit Knowledge Base »"
450
  msgstr ""
451
 
452
- #: includes/admin/cartflows-general.php:93
453
  msgid "Community"
454
  msgstr ""
455
 
456
- #: includes/admin/cartflows-general.php:97
457
  msgid ""
458
  "Join the community of super helpful CartFlows users. Say hello, ask "
459
  "questions, give feedback and help each other!"
460
  msgstr ""
461
 
462
- #: includes/admin/cartflows-general.php:100
463
  msgid "Join Our Facebook Group »"
464
  msgstr ""
465
 
466
- #: includes/admin/cartflows-general.php:108
467
  msgid "Five Star Support"
468
  msgstr ""
469
 
470
- #: includes/admin/cartflows-general.php:112
471
  msgid "Got a question? Get in touch with CartFlows developers. We're happy to help!"
472
  msgstr ""
473
 
474
- #: includes/admin/cartflows-general.php:115
475
  msgid "Submit a Ticket »"
476
  msgstr ""
477
 
@@ -493,6 +516,10 @@ msgstr ""
493
  msgid "This tool allows you to import the flows from the JSON file."
494
  msgstr ""
495
 
 
 
 
 
496
  #: modules/checkout/classes/class-cartflows-checkout-markup.php:145
497
  #: modules/thankyou/classes/class-cartflows-thankyou-markup.php:62
498
  msgid ""
@@ -512,11 +539,11 @@ msgstr ""
512
  msgid "This product can't be purcahsed"
513
  msgstr ""
514
 
515
- #: modules/checkout/classes/class-cartflows-checkout-markup.php:904
516
  msgid "Coupon Code"
517
  msgstr ""
518
 
519
- #: modules/checkout/classes/class-cartflows-checkout-markup.php:913
520
  msgid "Apply"
521
  msgstr ""
522
 
@@ -904,12 +931,12 @@ msgid "All Steps"
904
  msgstr ""
905
 
906
  #: modules/flow/classes/class-cartflows-step-post-type.php:142
907
- #: modules/flow/view/meta-flow-steps.php:97
908
  msgid "Edit Step"
909
  msgstr ""
910
 
911
  #: modules/flow/classes/class-cartflows-step-post-type.php:143
912
- #: modules/flow/view/meta-flow-steps.php:93
913
  msgid "View Step"
914
  msgstr ""
915
 
@@ -930,60 +957,60 @@ msgid "Step Flow"
930
  msgstr ""
931
 
932
  #: modules/flow/classes/class-cartflows-step-post-type.php:196
933
- #: modules/flow/view/meta-flow-steps.php:9
934
  msgid "Landing"
935
  msgstr ""
936
 
937
  #: modules/flow/classes/class-cartflows-step-post-type.php:202
938
- #: modules/flow/view/meta-flow-steps.php:10
939
  msgid "Checkout"
940
  msgstr ""
941
 
942
  #: modules/flow/classes/class-cartflows-step-post-type.php:208
943
- #: modules/flow/view/meta-flow-steps.php:11
944
  msgid "Thank You"
945
  msgstr ""
946
 
947
  #: modules/flow/classes/class-cartflows-step-post-type.php:214
948
- #: modules/flow/view/meta-flow-steps.php:12
949
  msgid "Upsell"
950
  msgstr ""
951
 
952
  #: modules/flow/classes/class-cartflows-step-post-type.php:220
953
- #: modules/flow/view/meta-flow-steps.php:13
954
  msgid "Downsell"
955
  msgstr ""
956
 
957
- #: modules/flow/view/meta-flow-steps.php:77
958
  msgid "No Product Assigned"
959
  msgstr ""
960
 
961
- #: modules/flow/view/meta-flow-steps.php:81
962
  msgid "Global Checkout - Remove selected checkout product"
963
  msgstr ""
964
 
965
- #: modules/flow/view/meta-flow-steps.php:101
966
  msgid "Clone Step"
967
  msgstr ""
968
 
969
- #: modules/flow/view/meta-flow-steps.php:105
970
  msgid "Delete Step"
971
  msgstr ""
972
 
973
- #: modules/flow/view/meta-flow-steps.php:120
974
  msgid "Add New Step"
975
  msgstr ""
976
 
977
- #: modules/flow/view/meta-flow-steps.php:136
978
  msgid "Steps Library"
979
  msgstr ""
980
 
981
- #: modules/flow/view/meta-flow-steps.php:160
982
- msgid "You need a Cartflows Pro version to import Upsell / Downsell"
983
  msgstr ""
984
 
985
- #: modules/flow/view/meta-flow-steps.php:175
986
- msgid "Create Step"
987
  msgstr ""
988
 
989
  #: modules/landing/classes/class-cartflows-landing-meta.php:66
2
  # This file is distributed under the same license as the CartFlows package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: CartFlows 1.1.4\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
7
+ "POT-Creation-Date: 2019-01-22 10:38:03+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
36
  msgid "Every %d Minutes"
37
  msgstr ""
38
 
39
+ #: classes/class-cartflows-admin-fields.php:162
40
  msgid "Select"
41
  msgstr ""
42
 
43
+ #: classes/class-cartflows-admin-fields.php:165
44
  msgid "No Checkout Steps"
45
  msgstr ""
46
 
47
+ #: classes/class-cartflows-admin-fields.php:191
48
  #. translators: %s: link
49
  msgid ""
50
  "Be sure not to add any product in above selected Global Checkout step. "
56
  msgid "Settings"
57
  msgstr ""
58
 
59
+ #: classes/class-cartflows-admin.php:306
60
  msgid "Flows Library"
61
  msgstr ""
62
 
63
+ #: classes/class-cartflows-admin.php:313
64
+ #: modules/flow/view/meta-flow-steps.php:145
65
  msgid "Ready Templates"
66
  msgstr ""
67
 
68
+ #: classes/class-cartflows-admin.php:316
69
+ #: modules/flow/view/meta-flow-steps.php:148
70
  msgid "Create Your Own"
71
  msgstr ""
72
 
73
+ #: classes/class-cartflows-admin.php:327
74
+ #: modules/flow/view/meta-flow-steps.php:160
75
  msgid "Search Sites"
76
  msgstr ""
77
 
78
+ #: classes/class-cartflows-admin.php:328
79
+ #: modules/flow/view/meta-flow-steps.php:161
80
  msgid "Search Flow..."
81
  msgstr ""
82
 
83
+ #: classes/class-cartflows-admin.php:345
84
  msgid "Design Your Flow"
85
  msgstr ""
86
 
87
+ #: classes/class-cartflows-admin.php:346
88
+ #: modules/flow/view/meta-flow-steps.php:192
89
+ msgid "Learn How"
90
+ msgstr ""
91
+
92
  #: classes/class-cartflows-api.php:363
93
  msgid "Request successfully processed!"
94
  msgstr ""
107
  "be deactivated from the flow settings in the admin dashboard."
108
  msgstr ""
109
 
110
+ #: classes/class-cartflows-importer.php:80
111
  msgid "Export this flow"
112
  msgstr ""
113
 
114
+ #: classes/class-cartflows-importer.php:80 includes/exporter.php:18
115
  msgid "Export"
116
  msgstr ""
117
 
118
+ #: classes/class-cartflows-importer.php:91
119
  msgid "Flow Export"
120
  msgstr ""
121
 
122
+ #: classes/class-cartflows-importer.php:92
123
  msgid "Flow Import"
124
  msgstr ""
125
 
126
+ #: classes/class-cartflows-importer.php:103
127
  msgid "No post to export has been supplied!"
128
  msgstr ""
129
 
130
+ #: classes/class-cartflows-importer.php:274
131
  msgid "Please upload a valid .json file"
132
  msgstr ""
133
 
134
+ #: classes/class-cartflows-importer.php:280
135
  msgid "Please upload a file to import"
136
  msgstr ""
137
 
138
+ #: classes/class-cartflows-importer.php:350
139
  msgid "Successfully imported flows."
140
  msgstr ""
141
 
142
+ #: classes/class-cartflows-importer.php:382
143
  msgid "Loading Steps"
144
  msgstr ""
145
 
146
+ #: classes/class-cartflows-importer.php:384
147
  msgid "Getting steps from the cloud. Please wait for the moment."
148
  msgstr ""
149
 
150
+ #: classes/class-cartflows-importer.php:395
151
  msgid "Searching Template.."
152
  msgstr ""
153
 
154
+ #: classes/class-cartflows-importer.php:397
155
  msgid "Getting templates from the cloud. Please wait for the moment."
156
  msgstr ""
157
 
158
+ #: classes/class-cartflows-importer.php:406
159
  msgid "Importing.."
160
  msgstr ""
161
 
162
+ #: classes/class-cartflows-importer.php:415
163
+ #: classes/class-cartflows-importer.php:455
164
  msgid "Imported"
165
  msgstr ""
166
 
167
+ #: classes/class-cartflows-importer.php:416
168
+ #: classes/class-cartflows-importer.php:456
169
  msgid "Thanks for patience"
170
  msgstr ""
171
 
172
+ #: classes/class-cartflows-importer.php:425
173
+ #: classes/class-cartflows-importer.php:437
174
  msgid "Coming Soon!"
175
  msgstr ""
176
 
177
+ #: classes/class-cartflows-importer.php:456
178
  msgid "Redirecting to the Elementor edit window."
179
  msgstr ""
180
 
181
+ #: classes/class-cartflows-importer.php:503
182
+ #: classes/class-cartflows-importer.php:587
183
  msgid "Pro"
184
  msgstr ""
185
 
186
+ #: classes/class-cartflows-importer.php:526
187
+ #: classes/class-cartflows-importer.php:613
188
  msgid "Activate License"
189
  msgstr ""
190
 
191
+ #: classes/class-cartflows-importer.php:528
192
+ #: classes/class-cartflows-importer.php:615
193
  msgid "Get Pro"
194
  msgstr ""
195
 
196
+ #: classes/class-cartflows-importer.php:553
197
  msgid "Create"
198
  msgstr ""
199
 
200
+ #: classes/class-cartflows-importer.php:652
201
  msgid "All"
202
  msgstr ""
203
 
204
+ #: classes/class-cartflows-importer.php:655
205
  msgid "Select Step Type"
206
  msgstr ""
207
 
208
+ #: classes/class-cartflows-importer.php:732
209
  msgid "Import from Cloud"
210
  msgstr ""
211
 
212
+ #: classes/class-cartflows-importer.php:1018
 
 
 
 
 
 
 
213
  #: modules/flow/classes/class-cartflows-flow-meta.php:224
214
  msgid "Landing Page"
215
  msgstr ""
216
 
217
+ #: classes/class-cartflows-importer.php:1019
218
  #: modules/flow/classes/class-cartflows-flow-meta.php:225
219
  msgid "Checkout Page"
220
  msgstr ""
221
 
222
+ #: classes/class-cartflows-importer.php:1020
223
  #: modules/flow/classes/class-cartflows-flow-meta.php:226
224
  msgid "Thank You Page"
225
  msgstr ""
226
 
227
+ #: classes/class-cartflows-importer.php:1125
228
  #. translators: %s: template ID
229
  msgid "Invalid template id %1$s or post id %2$s."
230
  msgstr ""
231
 
232
+ #: classes/class-cartflows-importer.php:1167
233
  #. translators: %s: flow ID
234
  msgid "Invalid flow id %1$s OR step type %2$s."
235
  msgstr ""
236
 
237
+ #: classes/class-cartflows-importer.php:1288
238
  msgid ""
239
  "Elementor is not activated. Please activate plugin Elementor Page Builder "
240
  "to import the step."
241
  msgstr ""
242
 
243
+ #: classes/class-cartflows-importer.php:1406
244
+ msgid "Plugin Successfully Activated"
245
+ msgstr ""
246
+
247
  #: classes/class-cartflows-loader.php:332
248
  #. translators: %s: html tags
249
  msgid ""
370
  msgstr ""
371
 
372
  #: classes/class-cartflows-wizard.php:273
373
+ #: includes/admin/cartflows-general.php:71
374
  msgid "Elementor"
375
  msgstr ""
376
 
432
  msgstr ""
433
 
434
  #: includes/admin/cartflows-general.php:58
435
+ #: modules/flow/view/meta-flow-steps.php:87
436
  msgid "Global Checkout"
437
  msgstr ""
438
 
439
  #: includes/admin/cartflows-general.php:67
440
+ msgid "Show Templates designed with"
441
+ msgstr ""
442
+
443
+ #: includes/admin/cartflows-general.php:68
444
+ msgid ""
445
+ "CartFlows offers flow templates that can be imported in one click. These "
446
+ "templates are available in few different page builders. Please choose your "
447
+ "preferred page builder from the list so you will only see templates that "
448
+ "are made using that page builder.."
449
+ msgstr ""
450
+
451
+ #: includes/admin/cartflows-general.php:72
452
+ msgid "Beaver Builder"
453
+ msgstr ""
454
+
455
+ #: includes/admin/cartflows-general.php:73
456
+ msgid "Other"
457
+ msgstr ""
458
+
459
+ #: includes/admin/cartflows-general.php:82
460
  msgid "Save Changes"
461
  msgstr ""
462
 
463
+ #: includes/admin/cartflows-general.php:93
464
  msgid "Knowledge Base"
465
  msgstr ""
466
 
467
+ #: includes/admin/cartflows-general.php:97
468
  msgid "Not sure how something works? Take a peek at the knowledge base and learn."
469
  msgstr ""
470
 
471
+ #: includes/admin/cartflows-general.php:100
472
  msgid "Visit Knowledge Base »"
473
  msgstr ""
474
 
475
+ #: includes/admin/cartflows-general.php:108
476
  msgid "Community"
477
  msgstr ""
478
 
479
+ #: includes/admin/cartflows-general.php:112
480
  msgid ""
481
  "Join the community of super helpful CartFlows users. Say hello, ask "
482
  "questions, give feedback and help each other!"
483
  msgstr ""
484
 
485
+ #: includes/admin/cartflows-general.php:115
486
  msgid "Join Our Facebook Group »"
487
  msgstr ""
488
 
489
+ #: includes/admin/cartflows-general.php:123
490
  msgid "Five Star Support"
491
  msgstr ""
492
 
493
+ #: includes/admin/cartflows-general.php:127
494
  msgid "Got a question? Get in touch with CartFlows developers. We're happy to help!"
495
  msgstr ""
496
 
497
+ #: includes/admin/cartflows-general.php:130
498
  msgid "Submit a Ticket »"
499
  msgstr ""
500
 
516
  msgid "This tool allows you to import the flows from the JSON file."
517
  msgstr ""
518
 
519
+ #: includes/importer.php:21
520
+ msgid "Import"
521
+ msgstr ""
522
+
523
  #: modules/checkout/classes/class-cartflows-checkout-markup.php:145
524
  #: modules/thankyou/classes/class-cartflows-thankyou-markup.php:62
525
  msgid ""
539
  msgid "This product can't be purcahsed"
540
  msgstr ""
541
 
542
+ #: modules/checkout/classes/class-cartflows-checkout-markup.php:919
543
  msgid "Coupon Code"
544
  msgstr ""
545
 
546
+ #: modules/checkout/classes/class-cartflows-checkout-markup.php:928
547
  msgid "Apply"
548
  msgstr ""
549
 
931
  msgstr ""
932
 
933
  #: modules/flow/classes/class-cartflows-step-post-type.php:142
934
+ #: modules/flow/view/meta-flow-steps.php:99
935
  msgid "Edit Step"
936
  msgstr ""
937
 
938
  #: modules/flow/classes/class-cartflows-step-post-type.php:143
939
+ #: modules/flow/view/meta-flow-steps.php:95
940
  msgid "View Step"
941
  msgstr ""
942
 
957
  msgstr ""
958
 
959
  #: modules/flow/classes/class-cartflows-step-post-type.php:196
960
+ #: modules/flow/view/meta-flow-steps.php:11
961
  msgid "Landing"
962
  msgstr ""
963
 
964
  #: modules/flow/classes/class-cartflows-step-post-type.php:202
965
+ #: modules/flow/view/meta-flow-steps.php:12
966
  msgid "Checkout"
967
  msgstr ""
968
 
969
  #: modules/flow/classes/class-cartflows-step-post-type.php:208
970
+ #: modules/flow/view/meta-flow-steps.php:13
971
  msgid "Thank You"
972
  msgstr ""
973
 
974
  #: modules/flow/classes/class-cartflows-step-post-type.php:214
975
+ #: modules/flow/view/meta-flow-steps.php:14
976
  msgid "Upsell"
977
  msgstr ""
978
 
979
  #: modules/flow/classes/class-cartflows-step-post-type.php:220
980
+ #: modules/flow/view/meta-flow-steps.php:15
981
  msgid "Downsell"
982
  msgstr ""
983
 
984
+ #: modules/flow/view/meta-flow-steps.php:79
985
  msgid "No Product Assigned"
986
  msgstr ""
987
 
988
+ #: modules/flow/view/meta-flow-steps.php:83
989
  msgid "Global Checkout - Remove selected checkout product"
990
  msgstr ""
991
 
992
+ #: modules/flow/view/meta-flow-steps.php:103
993
  msgid "Clone Step"
994
  msgstr ""
995
 
996
+ #: modules/flow/view/meta-flow-steps.php:107
997
  msgid "Delete Step"
998
  msgstr ""
999
 
1000
+ #: modules/flow/view/meta-flow-steps.php:122
1001
  msgid "Add New Step"
1002
  msgstr ""
1003
 
1004
+ #: modules/flow/view/meta-flow-steps.php:138
1005
  msgid "Steps Library"
1006
  msgstr ""
1007
 
1008
+ #: modules/flow/view/meta-flow-steps.php:188
1009
+ msgid "Create Step"
1010
  msgstr ""
1011
 
1012
+ #: modules/flow/view/meta-flow-steps.php:190
1013
+ msgid "You need a Cartflows Pro version to import Upsell / Downsell"
1014
  msgstr ""
1015
 
1016
  #: modules/landing/classes/class-cartflows-landing-meta.php:66
modules/checkout/classes/class-cartflows-checkout-markup.php CHANGED
@@ -1,1005 +1,1021 @@
1
- <?php
2
- /**
3
- * Checkout markup.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Checkout Markup
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Checkout_Markup {
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
- /* Set is checkout flag */
38
- add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 );
39
-
40
- add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_checkout_fields' ), 10, 2 );
41
-
42
- /* Show notice if cart is empty */
43
- add_action( 'cartflows_checkout_cart_empty', 'woocommerce_output_all_notices' );
44
-
45
- /* Checkout Shortcode */
46
- add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) );
47
-
48
- /* Preconfigured cart data */
49
- add_action( 'wp', array( $this, 'preconfigured_cart_data' ), 1 );
50
-
51
- /* Embed Checkout */
52
- add_action( 'wp', array( $this, 'shortcode_load_data' ), 999 );
53
-
54
- /* Ajax Endpoint */
55
- add_filter( 'woocommerce_ajax_get_endpoint', array( $this, 'get_ajax_endpoint' ) );
56
-
57
- add_filter( 'cartflows_add_before_main_section', array( $this, 'enable_logo_in_header' ) );
58
-
59
- add_filter( 'cartflows_primary_container_bottom', array( $this, 'show_cartflows_copyright_message' ) );
60
-
61
- add_filter( 'woocommerce_login_redirect', array( $this, 'after_login_redirect' ), 10, 2 );
62
-
63
- add_action( 'wp_ajax_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
64
- add_action( 'wp_ajax_nopriv_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
65
-
66
- add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
67
-
68
- /* Global Checkout */
69
- add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
70
- }
71
-
72
-
73
- /**
74
- * Redirect from default to the global checkout page
75
- *
76
- * @since 1.0.0
77
- */
78
- function global_checkout_template_redirect() {
79
-
80
- if ( ! is_checkout() ) {
81
- return;
82
- }
83
-
84
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
85
- return;
86
- }
87
-
88
- // redirect only from any non HC checkout pages.
89
- $order_pay_endpoint = get_option( 'woocommerce_checkout_order_pay_endpoint', 'order-pay' );
90
- $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
91
-
92
- $common = Cartflows_Helper::get_common_settings();
93
-
94
- $global_checkout = $common['global_checkout'];
95
-
96
- if (
97
- // ignore on order-pay.
98
- false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
99
- // ignore on TY page.
100
- false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
101
- ) {
102
-
103
- if ( '' !== $global_checkout ) {
104
-
105
- $link = get_permalink( $global_checkout );
106
-
107
- if ( ! empty( $link ) ) {
108
-
109
- wp_redirect( $link );
110
- die();
111
- }
112
- }
113
- }
114
- }
115
-
116
- /**
117
- * Check for checkout flag
118
- *
119
- * @param bool $is_checkout is checkout.
120
- *
121
- * @return bool
122
- */
123
- function woo_checkout_flag( $is_checkout ) {
124
-
125
- if ( ! is_admin() ) {
126
-
127
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
128
-
129
- $is_checkout = true;
130
- }
131
- }
132
-
133
- return $is_checkout;
134
- }
135
-
136
- /**
137
- * Render checkout shortcode markup.
138
- *
139
- * @param array $atts attributes.
140
- * @return string
141
- */
142
- function checkout_shortcode_markup( $atts ) {
143
-
144
- if ( ! function_exists( 'wc_print_notices' ) ) {
145
- return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
146
- }
147
-
148
- $atts = shortcode_atts(
149
- array(
150
- 'id' => 0,
151
- ),
152
- $atts
153
- );
154
-
155
- $checkout_id = intval( $atts['id'] );
156
-
157
- if ( empty( $checkout_id ) ) {
158
-
159
- if ( ! _is_wcf_checkout_type() ) {
160
-
161
- return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
162
- }
163
-
164
- global $post;
165
-
166
- $checkout_id = intval( $post->ID );
167
- }
168
-
169
- $output = '';
170
-
171
- ob_start();
172
-
173
- do_action( 'cartflows_checkout_form_before', $checkout_id );
174
-
175
- $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
176
-
177
- $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
178
-
179
- $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
180
-
181
- if ( file_exists( $template_layout ) ) {
182
- include $template_layout;
183
- } else {
184
- include $template_default;
185
- }
186
-
187
- $output .= ob_get_clean();
188
-
189
- return $output;
190
- }
191
-
192
- /**
193
- * Configure Cart Data.
194
- *
195
- * @since 1.0.0
196
- *
197
- * @return void
198
- */
199
- function preconfigured_cart_data() {
200
-
201
- if ( is_admin() ) {
202
- return;
203
- }
204
-
205
- global $post;
206
-
207
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
208
-
209
- if ( wp_doing_ajax() ) {
210
-
211
- return;
212
- } else {
213
-
214
- if ( _is_wcf_checkout_type() ) {
215
- $checkout_id = $post->ID;
216
- } else {
217
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
218
- }
219
-
220
- do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
221
-
222
- $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
223
-
224
- if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
225
- $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
226
- } else {
227
- $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
228
- }
229
-
230
- if ( ! is_array( $products ) ) {
231
-
232
- if ( 'dummy' === $products ) {
233
-
234
- $args = array(
235
- 'posts_per_page' => 1,
236
- 'orderby' => 'rand',
237
- 'post_type' => 'product',
238
- 'meta_query' => array(
239
- // Exclude out of stock products.
240
- array(
241
- 'key' => '_stock_status',
242
- 'value' => 'outofstock',
243
- 'compare' => 'NOT IN',
244
- ),
245
- ),
246
- 'tax_query' => array(
247
- array(
248
- 'taxonomy' => 'product_type',
249
- 'field' => 'slug',
250
- 'terms' => 'simple',
251
- ),
252
- ),
253
- );
254
-
255
- $random_product = get_posts( $args );
256
-
257
- if ( isset( $random_product[0]->ID ) ) {
258
- $products = array(
259
- array(
260
- 'product' => $random_product[0]->ID,
261
- ),
262
- );
263
- } else {
264
- return;
265
- }
266
- } else {
267
- return;
268
- }
269
- }
270
-
271
- if ( is_array( $products ) && count( $products ) < 1 ) {
272
-
273
- return;
274
- }
275
- /* Empty the current cart */
276
- WC()->cart->empty_cart();
277
-
278
- /* Set customer session if not set */
279
- if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
280
- WC()->session->set_customer_session_cookie( true );
281
- }
282
-
283
- $cart_product_count = 0;
284
-
285
- foreach ( $products as $index => $data ) {
286
-
287
- if ( ! isset( $data['product'] ) ) {
288
- return;
289
- }
290
-
291
- if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
292
- return;
293
- }
294
-
295
- $product_id = $data['product'];
296
- $_product = wc_get_product( $product_id );
297
-
298
- if ( ! empty( $_product ) ) {
299
-
300
- $quantity = 1;
301
-
302
- if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
303
-
304
- if ( $_product->is_type( 'variable' ) ) {
305
-
306
- $default_attributes = $_product->get_default_attributes();
307
-
308
- if ( ! empty( $default_attributes ) ) {
309
-
310
- foreach ( $_product->get_children() as $variation_id ) {
311
-
312
- $single_variation = new WC_Product_Variation( $variation_id );
313
-
314
- if ( $default_attributes == $single_variation->get_attributes() ) {
315
- WC()->cart->add_to_cart( $variation_id, $quantity );
316
- $cart_product_count++;
317
- }
318
- }
319
- } else {
320
-
321
- $product_childrens = $_product->get_children();
322
-
323
- if ( isset( $product_childrens[0] ) ) {
324
- WC()->cart->add_to_cart( $product_childrens[0], $quantity );
325
- $cart_product_count++;
326
- } else {
327
- echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
328
- }
329
- }
330
- } else {
331
- WC()->cart->add_to_cart( $product_id, $quantity );
332
- $cart_product_count++;
333
- }
334
- } else {
335
-
336
- echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
337
- // WC()->cart->add_to_cart( $product_id, $quantity );.
338
- }
339
- }
340
- }
341
-
342
- do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
343
- do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
344
- }
345
- }
346
- }
347
-
348
- /**
349
- * Load shortcode data.
350
- *
351
- * @return void
352
- */
353
- function shortcode_load_data() {
354
-
355
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
356
-
357
- add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
358
-
359
- add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
360
-
361
- add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
362
-
363
- // Outputting the hidden field in checkout page.
364
- add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
365
- add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
366
-
367
- remove_all_actions( 'woocommerce_checkout_billing' );
368
- remove_all_actions( 'woocommerce_checkout_shipping' );
369
-
370
- // Hook in actions once.
371
- add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
372
- add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
373
-
374
- remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
375
-
376
- add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
377
-
378
- add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
379
-
380
- global $post;
381
-
382
- if ( _is_wcf_checkout_type() ) {
383
- $checkout_id = $post->ID;
384
- } else {
385
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
386
- }
387
-
388
- do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
389
- }
390
- }
391
-
392
- /**
393
- * Render checkout ID hidden field.
394
- *
395
- * @param array $checkout checkout session data.
396
- * @return void
397
- */
398
- function checkout_shortcode_post_id( $checkout ) {
399
-
400
- global $post;
401
-
402
- if ( _is_wcf_checkout_type() ) {
403
- $checkout_id = $post->ID;
404
- } else {
405
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
406
- }
407
-
408
- $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
409
-
410
- echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
411
- echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
412
- }
413
-
414
- /**
415
- * Load shortcode scripts.
416
- *
417
- * @return void
418
- */
419
- function shortcode_scripts() {
420
-
421
- wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
422
- wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
423
-
424
- if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
425
- wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
426
- wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
427
- }
428
-
429
- wp_enqueue_script(
430
- 'wcf-checkout-template',
431
- CARTFLOWS_URL . 'assets/js/checkout-template.js',
432
- array( 'jquery' ),
433
- CARTFLOWS_VER,
434
- true
435
- );
436
-
437
- do_action( 'cartflows_checkout_scripts' );
438
-
439
- $style = $this->generate_style();
440
-
441
- wp_add_inline_style( 'wcf-checkout-template', $style );
442
-
443
- }
444
-
445
-
446
- /**
447
- * Generate styles.
448
- *
449
- * @return string
450
- */
451
- function generate_style() {
452
-
453
- global $post;
454
-
455
- if ( _is_wcf_checkout_type() ) {
456
- $checkout_id = $post->ID;
457
- } else {
458
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
459
- }
460
-
461
- CartFlows_Font_Families::render_fonts( $checkout_id );
462
-
463
- $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
464
-
465
- $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
466
-
467
- $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
468
-
469
- /*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
470
-
471
- $field_tb_padding = '';
472
- $field_lr_padding = '';
473
-
474
- $field_heading_color = '';
475
- $field_color = '';
476
- $field_bg_color = '';
477
- $field_border_color = '';
478
- $field_label_color = '';
479
- $submit_tb_padding = '';
480
- $submit_lr_padding = '';
481
- $hl_bg_color = '';
482
- $field_input_size = '';
483
- $box_border_color = '';
484
- $section_bg_color = '';
485
- $submit_button_height = '';
486
- $submit_color = '';
487
- $submit_bg_color = $primary_color;
488
- $submit_border_color = $primary_color;
489
-
490
- $submit_hover_color = '';
491
- $submit_bg_hover_color = $primary_color;
492
- $submit_border_hover_color = $primary_color;
493
-
494
- $section_heading_color = '';
495
-
496
- $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
497
-
498
- $button_font_family = '';
499
- $button_font_weight = '';
500
- $input_font_family = '';
501
- $input_font_weight = '';
502
- $heading_font_family = '';
503
- $heading_font_weight = '';
504
- $base_font_family = $base_font_family;
505
- /*$base_font_weight = $base_font_weight;*/
506
-
507
- if ( 'yes' == $is_advance_option ) {
508
-
509
- /**
510
- * Get Font Family and Font Weight weight values
511
- */
512
- $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
513
-
514
- $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
515
- $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
516
- $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
517
- $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
518
- $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
519
- $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
520
- $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
521
- $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
522
- $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
523
- $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
524
-
525
- $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
526
-
527
- $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
528
-
529
- $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
530
-
531
- $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
532
-
533
- $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
534
-
535
- $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
536
-
537
- $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
538
-
539
- $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
540
-
541
- $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
542
-
543
- $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
544
-
545
- $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
546
-
547
- $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
548
-
549
- $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
550
-
551
- $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
552
-
553
- $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
554
-
555
- $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
556
-
557
- /**
558
- * Get font values
559
- */
560
-
561
- if ( 'custom' == $submit_button_height ) {
562
- $submit_button_height = '38px';
563
- }
564
-
565
- if ( 'custom' == $field_input_size ) {
566
- $field_input_size = '38px';
567
- }
568
- }
569
-
570
- $output = "
571
- .wcf-embed-checkout-form .wcf-checkout-header-image img{
572
- width: {$header_logo_width}px;
573
- }
574
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:after,
575
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:not(:checked):after,
576
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label:after,
577
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label:after {
578
- background: {$primary_color};
579
- }
580
-
581
- .wcf-embed-checkout-form .woocommerce-checkout label{
582
- color: {$field_label_color};
583
- }
584
- .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
585
- background-color: {$hl_bg_color};
586
- font-family: {$input_font_family};
587
- font-weight: {$input_font_weight};
588
- }
589
-
590
- .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
591
- .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
592
- .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
593
- {
594
- border-color: {$hl_bg_color};
595
- border-right-color: transparent;
596
- border-left-color: transparent;
597
- border-top-color: transparent;
598
- position: absolute;
599
- }
600
-
601
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
602
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
603
- font-family: {$input_font_family};
604
- font-weight: {$input_font_weight};
605
- }
606
-
607
- .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
608
- .wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
609
- .wcf-embed-checkout-form .woocommerce form .form-row textarea,
610
- .wcf-embed-checkout-form .select2-container--default .select2-selection--single {
611
- color: {$field_color};
612
- background: {$field_bg_color};
613
- border-color: {$field_border_color};
614
- padding-top: {$field_tb_padding}px;
615
- padding-bottom: {$field_tb_padding}px;
616
- padding-left: {$field_lr_padding}px;
617
- padding-right: {$field_lr_padding}px;
618
- min-height: {$field_input_size};
619
- font-family: {$input_font_family};
620
- font-weight: {$input_font_weight};
621
- }
622
-
623
- .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
624
- .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
625
- .wcf-embed-checkout-form .woocommerce-checkout .shop_table,
626
- .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
627
- .wcf-embed-checkout-form .woocommerce-checkout #payment,
628
- .wcf-embed-checkout-form .woocommerce form.checkout_coupon
629
- {
630
- background-color: {$section_bg_color};
631
- border-color: {$box_border_color};
632
- font-family: {$input_font_family};
633
- font-weight: {$input_font_weight};
634
- }
635
-
636
- .woocommerce table.shop_table th{
637
- color: {$field_label_color};
638
- }
639
- .wcf-embed-checkout-form .woocommerce .woocommerce-info,
640
- .wcf-embed-checkout-form .woocommerce-message{
641
- border-top-color: {$primary_color};
642
- background-color: {$hl_bg_color};
643
- }
644
- .wcf-embed-checkout-form .woocommerce a{
645
- color: {$primary_color};
646
- }
647
- .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
648
- color: {$field_color};
649
- }
650
- .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
651
- color: {$field_color};
652
- }
653
- .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
654
- color: {$field_color};
655
- }
656
- .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
657
- color: {$field_color};
658
- }
659
- .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
660
- color: {$field_color};
661
- }
662
- .wcf-embed-checkout-form .woocommerce form p.form-row label {
663
- color: {$field_label_color};
664
- font-family: {$input_font_family};
665
- font-weight: {$input_font_weight};
666
- }
667
- .wcf-embed-checkout-form .woocommerce #order_review button {
668
- color: {$submit_color};
669
- background: {$submit_bg_color};
670
- padding-top: {$submit_tb_padding}px;
671
- padding-bottom: {$submit_tb_padding}px;
672
- padding-left: {$submit_lr_padding}px;
673
- padding-right: {$submit_lr_padding}px;
674
- border-color: {$submit_border_color};
675
- min-height: {$submit_button_height};
676
- font-family: {$button_font_family};
677
- font-weight: {$button_font_weight};
678
- }
679
- .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
680
- .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
681
- background: {$submit_bg_color};
682
- border: 1px {$submit_border_color} solid;
683
- color: {$submit_color};
684
- min-height: {$submit_button_height};
685
- font-family: {$button_font_family};
686
- font-weight: {$button_font_weight};
687
- }
688
- .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
689
- .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
690
- .wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
691
- .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
692
- color: {$submit_hover_color};
693
- background-color: {$submit_bg_hover_color};
694
- border-color: {$submit_border_hover_color};
695
- }
696
- .wcf-embed-checkout-form .woocommerce h3,
697
- .wcf-embed-checkout-form .woocommerce h3 span,
698
- .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
699
- color: {$section_heading_color};
700
- font-family: {$heading_font_family};
701
- font-weight: {$heading_font_weight};
702
- }
703
- .wcf-embed-checkout-form .woocommerce-info::before,
704
- .wcf-embed-checkout-form .woocommerce-message::before{
705
- color: {$primary_color};
706
- }
707
- .wcf-embed-checkout-form{
708
- font-family: {$base_font_family};
709
- }";
710
-
711
- return $output;
712
- }
713
-
714
- /**
715
- * Get ajax end points.
716
- *
717
- * @param string $endpoint_url end point URL.
718
- * @return string
719
- */
720
- function get_ajax_endpoint( $endpoint_url ) {
721
-
722
- global $post;
723
-
724
- if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
725
-
726
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
727
-
728
- if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
729
-
730
- $query_args = array(
731
- 'wc-ajax' => '%%endpoint%%',
732
- );
733
-
734
- $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
735
- $uri = $uri[0];
736
-
737
- $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
738
- }
739
- }
740
- }
741
-
742
- return $endpoint_url;
743
- }
744
-
745
-
746
- /**
747
- * Save checkout fields.
748
- *
749
- * @param int $order_id order id.
750
- * @param array $posted posted data.
751
- * @return void
752
- */
753
- function save_checkout_fields( $order_id, $posted ) {
754
-
755
- if ( isset( $_POST['_wcf_checkout_id'] ) ) {
756
-
757
- $checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
758
-
759
- update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
760
-
761
- /*
762
- Custom Field To Do
763
- $custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
764
-
765
- if ( 'yes' === $custom_fields ) {
766
-
767
- $billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
768
-
769
- foreach ( $billing_fields as $field => $data ) {
770
-
771
- if ( isset( $data['custom'] ) && $data['custom'] ) {
772
-
773
- if ( isset( $_POST[ $field ] ) ) {
774
- update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
775
- }
776
- }
777
- }
778
-
779
- $shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
780
-
781
- foreach ( $shipping_fields as $field => $data ) {
782
-
783
- if ( isset( $data['custom'] ) && $data['custom'] ) {
784
-
785
- if ( isset( $_POST[ $field ] ) ) {
786
- update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
787
- }
788
- }
789
- }
790
- }
791
- */
792
- if ( isset( $_POST['_wcf_flow_id'] ) ) {
793
-
794
- $checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
795
-
796
- update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
797
- }
798
- }
799
-
800
- }
801
-
802
- /**
803
- * Enable Logo In Header Of Checkout Page
804
- *
805
- * @return void
806
- */
807
- function enable_logo_in_header() {
808
- global $post;
809
-
810
- if ( _is_wcf_checkout_type() ) {
811
- $checkout_id = $post->ID;
812
- } else {
813
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
814
- }
815
-
816
- $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
817
- $add_image_markup = '';
818
-
819
- if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
820
- $add_image_markup = '<div class="wcf-checkout-header-image">';
821
- $add_image_markup .= '<img src="' . $header_logo_image . '" />';
822
- $add_image_markup .= '</div>';
823
- }
824
-
825
- echo $add_image_markup;
826
- }
827
-
828
- /**
829
- * Add text to the bootom of the checkout page.
830
- *
831
- * @return void
832
- */
833
- function show_cartflows_copyright_message() {
834
- $output_string = '';
835
-
836
- $output_string .= '<div class="wcf-footer-primary">';
837
- $output_string .= '<div class="wcf-footer-content">';
838
- $output_string .= '<p class="wcf-footer-message">';
839
- $output_string .= 'Checkout powered by CartFlows';
840
- $output_string .= '</p>';
841
- $output_string .= '</div>';
842
- $output_string .= '</div>';
843
-
844
- echo $output_string;
845
- }
846
-
847
- /**
848
- * Redirect users to our checkout if hidden param
849
- *
850
- * @param string $redirect redirect url.
851
- * @param object $user user.
852
- * @return string
853
- */
854
- function after_login_redirect( $redirect, $user ) {
855
-
856
- if ( isset( $_POST['_wcf_checkout_id'] ) ) {
857
-
858
- $checkout_id = intval( $_POST['_wcf_checkout_id'] );
859
-
860
- $redirect = get_permalink( $checkout_id );
861
- }
862
-
863
- return $redirect;
864
- }
865
-
866
- /**
867
- * Display coupon code field after review order fields.
868
- */
869
- function display_custom_coupon_field() {
870
-
871
- $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
872
-
873
- if ( ! $coupon_enabled ) {
874
- return;
875
- }
876
-
877
- ob_start();
878
-
879
- ?>
880
- <div class="wcf-custom-coupon-field">
881
- <div class="wcf-coupon-col-1">
882
- <span>
883
- <input type="text" name="coupon_code" class="input-text cf-coupon-code-input" placeholder="<?php echo $this->coupon_field_placeholder(); ?>" id="coupon_code" value="">
884
- </span>
885
- </div>
886
- <div class="wcf-coupon-col-2">
887
- <span>
888
- <button type="button" class="button cf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php echo $this->coupon_button_text(); ?></button>
889
- </span>
890
- </div>
891
- </div>
892
-
893
- <?php
894
-
895
- echo ob_get_clean();
896
- }
897
-
898
- /**
899
- * Apply filter to change the placeholder text of coupon field.
900
- *
901
- * @return string
902
- */
903
- function coupon_field_placeholder() {
904
- return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
905
- }
906
-
907
- /**
908
- * Apply filter to change the button text of coupon field.
909
- *
910
- * @return string
911
- */
912
- function coupon_button_text() {
913
- return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
914
- }
915
-
916
- /**
917
- * Apply coupon on submit of custom coupon form.
918
- */
919
- function apply_coupon() {
920
-
921
- check_ajax_referer( 'cf-apply-coupon', 'security' );
922
-
923
- $result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
924
-
925
- echo json_encode( $result );
926
- die();
927
- }
928
-
929
- /**
930
- * Added ajax nonce to localize variable.
931
- *
932
- * @param array $vars localize variables.
933
- */
934
- function add_localize_vars( $vars ) {
935
-
936
- $vars['cf_validate_coupon_nonce'] = wp_create_nonce( 'cf-apply-coupon' );
937
-
938
- return $vars;
939
- }
940
-
941
- /**
942
- * Add custom class to the fields to change the UI to three column.
943
- *
944
- * @param array $fields fields.
945
- */
946
- function add_three_column_layout_fields( $fields ) {
947
-
948
- if ( empty( $fields['billing']['billing_address_2'] ) ) {
949
-
950
- if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
951
- $fields['billing']['billing_address_1']['class'][] = 'form-row-full';
952
- }
953
- }
954
-
955
- if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
956
-
957
- if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
958
- $fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
959
- }
960
- }
961
-
962
- if ( isset( $fields['billing']['billing_city'] ) &&
963
- isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
964
-
965
- $fields['billing']['billing_city']['class'] = array( 'wcf-form-col-3' );
966
- $fields['billing']['billing_state']['class'] = array( 'wcf-form-col-3' );
967
- $fields['billing']['billing_postcode']['class'] = array( 'wcf-form-col-3' );
968
- }
969
-
970
- if ( isset( $fields['shipping']['shipping_city'] ) &&
971
- isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
972
-
973
- $fields['shipping']['shipping_city']['class'] = array( 'wcf-form-col-3' );
974
- $fields['shipping']['shipping_state']['class'] = array( 'wcf-form-col-3' );
975
- $fields['shipping']['shipping_postcode']['class'] = array( 'wcf-form-col-3' );
976
- }
977
-
978
- return $fields;
979
- }
980
-
981
- /**
982
- * Add opening dev
983
- *
984
- * @since 1.0.0
985
- */
986
- function order_wrap_div_start() {
987
-
988
- echo "<div class='wcf-order-wrap'> ";
989
- }
990
-
991
- /**
992
- * Add closing dev
993
- *
994
- * @since 1.0.0
995
- */
996
- function order_wrap_div_end() {
997
-
998
- echo '</div> ';
999
- }
1000
- }
1001
-
1002
- /**
1003
- * Kicking this off by calling 'get_instance()' method
1004
- */
1005
- Cartflows_Checkout_Markup::get_instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checkout markup.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Checkout Markup
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Checkout_Markup {
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
+ /* Set is checkout flag */
38
+ add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 );
39
+
40
+ add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_checkout_fields' ), 10, 2 );
41
+
42
+ /* Show notice if cart is empty */
43
+ add_action( 'cartflows_checkout_cart_empty', 'woocommerce_output_all_notices' );
44
+
45
+ /* Checkout Shortcode */
46
+ add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) );
47
+
48
+ /* Preconfigured cart data */
49
+ add_action( 'wp', array( $this, 'preconfigured_cart_data' ), 1 );
50
+
51
+ /* Embed Checkout */
52
+ add_action( 'wp', array( $this, 'shortcode_load_data' ), 999 );
53
+
54
+ /* Ajax Endpoint */
55
+ add_filter( 'woocommerce_ajax_get_endpoint', array( $this, 'get_ajax_endpoint' ) );
56
+
57
+ add_filter( 'cartflows_add_before_main_section', array( $this, 'enable_logo_in_header' ) );
58
+
59
+ add_filter( 'cartflows_primary_container_bottom', array( $this, 'show_cartflows_copyright_message' ) );
60
+
61
+ add_filter( 'woocommerce_login_redirect', array( $this, 'after_login_redirect' ), 10, 2 );
62
+
63
+ add_action( 'wp_ajax_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
64
+ add_action( 'wp_ajax_nopriv_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
65
+
66
+ add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
67
+
68
+ /* Global Checkout */
69
+ add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
70
+ }
71
+
72
+
73
+ /**
74
+ * Redirect from default to the global checkout page
75
+ *
76
+ * @since 1.0.0
77
+ */
78
+ function global_checkout_template_redirect() {
79
+
80
+ if ( ! is_checkout() ) {
81
+ return;
82
+ }
83
+
84
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
85
+ return;
86
+ }
87
+
88
+ // redirect only from any non HC checkout pages.
89
+ $order_pay_endpoint = get_option( 'woocommerce_checkout_order_pay_endpoint', 'order-pay' );
90
+ $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
91
+
92
+ $common = Cartflows_Helper::get_common_settings();
93
+
94
+ $global_checkout = $common['global_checkout'];
95
+
96
+ if (
97
+ // ignore on order-pay.
98
+ false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
99
+ // ignore on TY page.
100
+ false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
101
+ ) {
102
+
103
+ if ( '' !== $global_checkout ) {
104
+
105
+ $link = get_permalink( $global_checkout );
106
+
107
+ if ( ! empty( $link ) ) {
108
+
109
+ wp_redirect( $link );
110
+ die();
111
+ }
112
+ }
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Check for checkout flag
118
+ *
119
+ * @param bool $is_checkout is checkout.
120
+ *
121
+ * @return bool
122
+ */
123
+ function woo_checkout_flag( $is_checkout ) {
124
+
125
+ if ( ! is_admin() ) {
126
+
127
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
128
+
129
+ $is_checkout = true;
130
+ }
131
+ }
132
+
133
+ return $is_checkout;
134
+ }
135
+
136
+ /**
137
+ * Render checkout shortcode markup.
138
+ *
139
+ * @param array $atts attributes.
140
+ * @return string
141
+ */
142
+ function checkout_shortcode_markup( $atts ) {
143
+
144
+ if ( ! function_exists( 'wc_print_notices' ) ) {
145
+ return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
146
+ }
147
+
148
+ $atts = shortcode_atts(
149
+ array(
150
+ 'id' => 0,
151
+ ),
152
+ $atts
153
+ );
154
+
155
+ $checkout_id = intval( $atts['id'] );
156
+
157
+ if ( empty( $checkout_id ) ) {
158
+
159
+ if ( ! _is_wcf_checkout_type() ) {
160
+
161
+ return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
162
+ }
163
+
164
+ global $post;
165
+
166
+ $checkout_id = intval( $post->ID );
167
+ }
168
+
169
+ $output = '';
170
+
171
+ ob_start();
172
+
173
+ do_action( 'cartflows_checkout_form_before', $checkout_id );
174
+
175
+ $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
176
+
177
+ $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
178
+
179
+ $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
180
+
181
+ if ( file_exists( $template_layout ) ) {
182
+ include $template_layout;
183
+ } else {
184
+ include $template_default;
185
+ }
186
+
187
+ $output .= ob_get_clean();
188
+
189
+ return $output;
190
+ }
191
+
192
+ /**
193
+ * Configure Cart Data.
194
+ *
195
+ * @since 1.0.0
196
+ *
197
+ * @return void
198
+ */
199
+ function preconfigured_cart_data() {
200
+
201
+ if ( is_admin() ) {
202
+ return;
203
+ }
204
+
205
+ global $post;
206
+
207
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
208
+
209
+ if ( wp_doing_ajax() ) {
210
+
211
+ return;
212
+ } else {
213
+
214
+ if ( _is_wcf_checkout_type() ) {
215
+ $checkout_id = $post->ID;
216
+ } else {
217
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
218
+ }
219
+
220
+ do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
221
+
222
+ $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
223
+
224
+ if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
225
+ $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
226
+ } else {
227
+ $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
228
+ }
229
+
230
+ if ( ! is_array( $products ) ) {
231
+
232
+ if ( 'dummy' === $products ) {
233
+
234
+ $args = array(
235
+ 'posts_per_page' => 1,
236
+ 'orderby' => 'rand',
237
+ 'post_type' => 'product',
238
+ 'meta_query' => array(
239
+ // Exclude out of stock products.
240
+ array(
241
+ 'key' => '_stock_status',
242
+ 'value' => 'outofstock',
243
+ 'compare' => 'NOT IN',
244
+ ),
245
+ ),
246
+ 'tax_query' => array(
247
+ array(
248
+ 'taxonomy' => 'product_type',
249
+ 'field' => 'slug',
250
+ 'terms' => 'simple',
251
+ ),
252
+ ),
253
+ );
254
+
255
+ $random_product = get_posts( $args );
256
+
257
+ if ( isset( $random_product[0]->ID ) ) {
258
+ $products = array(
259
+ array(
260
+ 'product' => $random_product[0]->ID,
261
+ ),
262
+ );
263
+ } else {
264
+ return;
265
+ }
266
+ } else {
267
+ return;
268
+ }
269
+ }
270
+
271
+ if ( is_array( $products ) && count( $products ) < 1 ) {
272
+
273
+ return;
274
+ }
275
+ /* Empty the current cart */
276
+ WC()->cart->empty_cart();
277
+
278
+ /* Set customer session if not set */
279
+ if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
280
+ WC()->session->set_customer_session_cookie( true );
281
+ }
282
+
283
+ $cart_product_count = 0;
284
+
285
+ foreach ( $products as $index => $data ) {
286
+
287
+ if ( ! isset( $data['product'] ) ) {
288
+ return;
289
+ }
290
+
291
+ if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
292
+ return;
293
+ }
294
+
295
+ $product_id = $data['product'];
296
+ $_product = wc_get_product( $product_id );
297
+
298
+ if ( ! empty( $_product ) ) {
299
+
300
+ $quantity = 1;
301
+
302
+ if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
303
+
304
+ if ( $_product->is_type( 'variable' ) ) {
305
+
306
+ $default_attributes = $_product->get_default_attributes();
307
+
308
+ if ( ! empty( $default_attributes ) ) {
309
+
310
+ foreach ( $_product->get_children() as $variation_id ) {
311
+
312
+ $single_variation = new WC_Product_Variation( $variation_id );
313
+
314
+ if ( $default_attributes == $single_variation->get_attributes() ) {
315
+ WC()->cart->add_to_cart( $variation_id, $quantity );
316
+ $cart_product_count++;
317
+ }
318
+ }
319
+ } else {
320
+
321
+ $product_childrens = $_product->get_children();
322
+
323
+ if ( isset( $product_childrens[0] ) ) {
324
+ WC()->cart->add_to_cart( $product_childrens[0], $quantity );
325
+ $cart_product_count++;
326
+ } else {
327
+ echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
328
+ }
329
+ }
330
+ } else {
331
+ WC()->cart->add_to_cart( $product_id, $quantity );
332
+ $cart_product_count++;
333
+ }
334
+ } else {
335
+
336
+ echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
337
+ // WC()->cart->add_to_cart( $product_id, $quantity );.
338
+ }
339
+ }
340
+ }
341
+
342
+ do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
343
+ do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
344
+ }
345
+ }
346
+ }
347
+
348
+ /**
349
+ * Load shortcode data.
350
+ *
351
+ * @return void
352
+ */
353
+ function shortcode_load_data() {
354
+
355
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
356
+
357
+ add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
358
+
359
+ /* Show notices if cart has errors */
360
+ add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
361
+
362
+ add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
363
+
364
+ add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
365
+
366
+ // Outputting the hidden field in checkout page.
367
+ add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
368
+ add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
369
+
370
+ remove_all_actions( 'woocommerce_checkout_billing' );
371
+ remove_all_actions( 'woocommerce_checkout_shipping' );
372
+
373
+ // Hook in actions once.
374
+ add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
375
+ add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
376
+
377
+ remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
378
+
379
+ add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
380
+
381
+ add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
382
+
383
+ global $post;
384
+
385
+ if ( _is_wcf_checkout_type() ) {
386
+ $checkout_id = $post->ID;
387
+ } else {
388
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
389
+ }
390
+
391
+ do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
392
+ }
393
+ }
394
+
395
+ /**
396
+ * Render checkout ID hidden field.
397
+ *
398
+ * @param array $checkout checkout session data.
399
+ * @return void
400
+ */
401
+ function checkout_shortcode_post_id( $checkout ) {
402
+
403
+ global $post;
404
+
405
+ if ( _is_wcf_checkout_type() ) {
406
+ $checkout_id = $post->ID;
407
+ } else {
408
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
409
+ }
410
+
411
+ $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
412
+
413
+ echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
414
+ echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
415
+ }
416
+
417
+ /**
418
+ * Load shortcode scripts.
419
+ *
420
+ * @return void
421
+ */
422
+ function shortcode_scripts() {
423
+
424
+ wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
425
+ wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
426
+
427
+ if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
428
+ wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
429
+ wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
430
+ }
431
+
432
+ wp_enqueue_script(
433
+ 'wcf-checkout-template',
434
+ CARTFLOWS_URL . 'assets/js/checkout-template.js',
435
+ array( 'jquery' ),
436
+ CARTFLOWS_VER,
437
+ true
438
+ );
439
+
440
+ do_action( 'cartflows_checkout_scripts' );
441
+
442
+ $style = $this->generate_style();
443
+
444
+ wp_add_inline_style( 'wcf-checkout-template', $style );
445
+
446
+ }
447
+
448
+
449
+ /**
450
+ * Generate styles.
451
+ *
452
+ * @return string
453
+ */
454
+ function generate_style() {
455
+
456
+ global $post;
457
+
458
+ if ( _is_wcf_checkout_type() ) {
459
+ $checkout_id = $post->ID;
460
+ } else {
461
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
462
+ }
463
+
464
+ CartFlows_Font_Families::render_fonts( $checkout_id );
465
+
466
+ $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
467
+
468
+ $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
469
+
470
+ $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
471
+
472
+ /*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
473
+ $r = '';
474
+ $g = '';
475
+ $b = '';
476
+
477
+ $field_tb_padding = '';
478
+ $field_lr_padding = '';
479
+
480
+ $field_heading_color = '';
481
+ $field_color = '';
482
+ $field_bg_color = '';
483
+ $field_border_color = '';
484
+ $field_label_color = '';
485
+ $submit_tb_padding = '';
486
+ $submit_lr_padding = '';
487
+ $hl_bg_color = '';
488
+ $field_input_size = '';
489
+ $box_border_color = '';
490
+ $section_bg_color = '';
491
+ $submit_button_height = '';
492
+ $submit_color = '';
493
+ $submit_bg_color = $primary_color;
494
+ $submit_border_color = $primary_color;
495
+
496
+ $submit_hover_color = '';
497
+ $submit_bg_hover_color = $primary_color;
498
+ $submit_border_hover_color = $primary_color;
499
+
500
+ $section_heading_color = '';
501
+
502
+ $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
503
+
504
+ $button_font_family = '';
505
+ $button_font_weight = '';
506
+ $input_font_family = '';
507
+ $input_font_weight = '';
508
+ $heading_font_family = '';
509
+ $heading_font_weight = '';
510
+ $base_font_family = $base_font_family;
511
+ /*$base_font_weight = $base_font_weight;*/
512
+
513
+ if ( 'yes' == $is_advance_option ) {
514
+
515
+ /**
516
+ * Get Font Family and Font Weight weight values
517
+ */
518
+ $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
519
+
520
+ $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
521
+ $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
522
+ $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
523
+ $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
524
+ $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
525
+ $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
526
+ $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
527
+ $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
528
+ $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
529
+ $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
530
+
531
+ $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
532
+
533
+ $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
534
+
535
+ $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
536
+
537
+ $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
538
+
539
+ $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
540
+
541
+ $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
542
+
543
+ $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
544
+
545
+ $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
546
+
547
+ $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
548
+
549
+ $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
550
+
551
+ $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
552
+
553
+ $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
554
+
555
+ $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
556
+
557
+ $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
558
+
559
+ $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
560
+
561
+ $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
562
+
563
+ /**
564
+ * Get font values
565
+ */
566
+
567
+ if ( 'custom' == $submit_button_height ) {
568
+ $submit_button_height = '38px';
569
+ }
570
+
571
+ if ( 'custom' == $field_input_size ) {
572
+ $field_input_size = '38px';
573
+ }
574
+ }
575
+ if ( isset( $primary_color ) ) {
576
+
577
+ list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
578
+ }
579
+ $output = "
580
+ .wcf-embed-checkout-form .wcf-checkout-header-image img{
581
+ width: {$header_logo_width}px;
582
+ }
583
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
584
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
585
+ color: {$primary_color};
586
+ }
587
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
588
+ background-color: {$primary_color};
589
+ }
590
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
591
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
592
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
593
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
594
+ border-color: {$primary_color};
595
+ box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
596
+ }
597
+ .wcf-embed-checkout-form .woocommerce-checkout label{
598
+ color: {$field_label_color};
599
+ }
600
+ .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
601
+ background-color: {$hl_bg_color};
602
+ font-family: {$input_font_family};
603
+ font-weight: {$input_font_weight};
604
+ }
605
+
606
+ .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
607
+ .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
608
+ .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
609
+ {
610
+ border-color: {$hl_bg_color};
611
+ border-right-color: transparent;
612
+ border-left-color: transparent;
613
+ border-top-color: transparent;
614
+ position: absolute;
615
+ }
616
+
617
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
618
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
619
+ font-family: {$input_font_family};
620
+ font-weight: {$input_font_weight};
621
+ }
622
+
623
+ .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
624
+ .wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
625
+ .wcf-embed-checkout-form .woocommerce form .form-row textarea,
626
+ .wcf-embed-checkout-form .select2-container--default .select2-selection--single {
627
+ color: {$field_color};
628
+ background: {$field_bg_color};
629
+ border-color: {$field_border_color};
630
+ padding-top: {$field_tb_padding}px;
631
+ padding-bottom: {$field_tb_padding}px;
632
+ padding-left: {$field_lr_padding}px;
633
+ padding-right: {$field_lr_padding}px;
634
+ min-height: {$field_input_size};
635
+ font-family: {$input_font_family};
636
+ font-weight: {$input_font_weight};
637
+ }
638
+
639
+ .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
640
+ .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
641
+ .wcf-embed-checkout-form .woocommerce-checkout .shop_table,
642
+ .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
643
+ .wcf-embed-checkout-form .woocommerce-checkout #payment,
644
+ .wcf-embed-checkout-form .woocommerce form.checkout_coupon
645
+ {
646
+ background-color: {$section_bg_color};
647
+ border-color: {$box_border_color};
648
+ font-family: {$input_font_family};
649
+ font-weight: {$input_font_weight};
650
+ }
651
+
652
+ .woocommerce table.shop_table th{
653
+ color: {$field_label_color};
654
+ }
655
+ .wcf-embed-checkout-form .woocommerce .woocommerce-info,
656
+ .wcf-embed-checkout-form .woocommerce-message{
657
+ border-top-color: {$primary_color};
658
+ background-color: {$hl_bg_color};
659
+ }
660
+ .wcf-embed-checkout-form .woocommerce a{
661
+ color: {$primary_color};
662
+ }
663
+ .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
664
+ color: {$field_color};
665
+ }
666
+ .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
667
+ color: {$field_color};
668
+ }
669
+ .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
670
+ color: {$field_color};
671
+ }
672
+ .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
673
+ color: {$field_color};
674
+ }
675
+ .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
676
+ color: {$field_color};
677
+ }
678
+ .wcf-embed-checkout-form .woocommerce form p.form-row label {
679
+ color: {$field_label_color};
680
+ font-family: {$input_font_family};
681
+ font-weight: {$input_font_weight};
682
+ }
683
+ .wcf-embed-checkout-form .woocommerce #order_review button {
684
+ color: {$submit_color};
685
+ background: {$submit_bg_color};
686
+ padding-top: {$submit_tb_padding}px;
687
+ padding-bottom: {$submit_tb_padding}px;
688
+ padding-left: {$submit_lr_padding}px;
689
+ padding-right: {$submit_lr_padding}px;
690
+ border-color: {$submit_border_color};
691
+ min-height: {$submit_button_height};
692
+ font-family: {$button_font_family};
693
+ font-weight: {$button_font_weight};
694
+ }
695
+ .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
696
+ .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
697
+ background: {$submit_bg_color};
698
+ border: 1px {$submit_border_color} solid;
699
+ color: {$submit_color};
700
+ min-height: {$submit_button_height};
701
+ font-family: {$button_font_family};
702
+ font-weight: {$button_font_weight};
703
+ }
704
+ .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
705
+ .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
706
+ .wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
707
+ .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
708
+ color: {$submit_hover_color};
709
+ background-color: {$submit_bg_hover_color};
710
+ border-color: {$submit_border_hover_color};
711
+ }
712
+ .wcf-embed-checkout-form .woocommerce h3,
713
+ .wcf-embed-checkout-form .woocommerce h3 span,
714
+ .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
715
+ color: {$section_heading_color};
716
+ font-family: {$heading_font_family};
717
+ font-weight: {$heading_font_weight};
718
+ }
719
+ .wcf-embed-checkout-form .woocommerce-info::before,
720
+ .wcf-embed-checkout-form .woocommerce-message::before{
721
+ color: {$primary_color};
722
+ }
723
+ .wcf-embed-checkout-form{
724
+ font-family: {$base_font_family};
725
+ }";
726
+
727
+ return $output;
728
+ }
729
+
730
+ /**
731
+ * Get ajax end points.
732
+ *
733
+ * @param string $endpoint_url end point URL.
734
+ * @return string
735
+ */
736
+ function get_ajax_endpoint( $endpoint_url ) {
737
+
738
+ global $post;
739
+
740
+ if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
741
+
742
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
743
+
744
+ if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
745
+
746
+ $query_args = array(
747
+ 'wc-ajax' => '%%endpoint%%',
748
+ );
749
+
750
+ $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
751
+ $uri = $uri[0];
752
+
753
+ $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
754
+ }
755
+ }
756
+ }
757
+
758
+ return $endpoint_url;
759
+ }
760
+
761
+
762
+ /**
763
+ * Save checkout fields.
764
+ *
765
+ * @param int $order_id order id.
766
+ * @param array $posted posted data.
767
+ * @return void
768
+ */
769
+ function save_checkout_fields( $order_id, $posted ) {
770
+
771
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) {
772
+
773
+ $checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
774
+
775
+ update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
776
+
777
+ /*
778
+ Custom Field To Do
779
+ $custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
780
+
781
+ if ( 'yes' === $custom_fields ) {
782
+
783
+ $billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
784
+
785
+ foreach ( $billing_fields as $field => $data ) {
786
+
787
+ if ( isset( $data['custom'] ) && $data['custom'] ) {
788
+
789
+ if ( isset( $_POST[ $field ] ) ) {
790
+ update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
791
+ }
792
+ }
793
+ }
794
+
795
+ $shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
796
+
797
+ foreach ( $shipping_fields as $field => $data ) {
798
+
799
+ if ( isset( $data['custom'] ) && $data['custom'] ) {
800
+
801
+ if ( isset( $_POST[ $field ] ) ) {
802
+ update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
803
+ }
804
+ }
805
+ }
806
+ }
807
+ */
808
+ if ( isset( $_POST['_wcf_flow_id'] ) ) {
809
+
810
+ $checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
811
+
812
+ update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
813
+ }
814
+ }
815
+
816
+ }
817
+
818
+ /**
819
+ * Enable Logo In Header Of Checkout Page
820
+ *
821
+ * @return void
822
+ */
823
+ function enable_logo_in_header() {
824
+ global $post;
825
+
826
+ if ( _is_wcf_checkout_type() ) {
827
+ $checkout_id = $post->ID;
828
+ } else {
829
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
830
+ }
831
+
832
+ $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
833
+ $add_image_markup = '';
834
+
835
+ if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
836
+ $add_image_markup = '<div class="wcf-checkout-header-image">';
837
+ $add_image_markup .= '<img src="' . $header_logo_image . '" />';
838
+ $add_image_markup .= '</div>';
839
+ }
840
+
841
+ echo $add_image_markup;
842
+ }
843
+
844
+ /**
845
+ * Add text to the bootom of the checkout page.
846
+ *
847
+ * @return void
848
+ */
849
+ function show_cartflows_copyright_message() {
850
+ $output_string = '';
851
+
852
+ $output_string .= '<div class="wcf-footer-primary">';
853
+ $output_string .= '<div class="wcf-footer-content">';
854
+ $output_string .= '<p class="wcf-footer-message">';
855
+ $output_string .= 'Checkout powered by CartFlows';
856
+ $output_string .= '</p>';
857
+ $output_string .= '</div>';
858
+ $output_string .= '</div>';
859
+
860
+ echo $output_string;
861
+ }
862
+
863
+ /**
864
+ * Redirect users to our checkout if hidden param
865
+ *
866
+ * @param string $redirect redirect url.
867
+ * @param object $user user.
868
+ * @return string
869
+ */
870
+ function after_login_redirect( $redirect, $user ) {
871
+
872
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) {
873
+
874
+ $checkout_id = intval( $_POST['_wcf_checkout_id'] );
875
+
876
+ $redirect = get_permalink( $checkout_id );
877
+ }
878
+
879
+ return $redirect;
880
+ }
881
+
882
+ /**
883
+ * Display coupon code field after review order fields.
884
+ */
885
+ function display_custom_coupon_field() {
886
+
887
+ $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
888
+
889
+ if ( ! $coupon_enabled ) {
890
+ return;
891
+ }
892
+
893
+ ob_start();
894
+
895
+ ?>
896
+ <div class="wcf-custom-coupon-field">
897
+ <div class="wcf-coupon-col-1">
898
+ <span>
899
+ <input type="text" name="coupon_code" class="input-text cf-coupon-code-input" placeholder="<?php echo $this->coupon_field_placeholder(); ?>" id="coupon_code" value="">
900
+ </span>
901
+ </div>
902
+ <div class="wcf-coupon-col-2">
903
+ <span>
904
+ <button type="button" class="button cf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php echo $this->coupon_button_text(); ?></button>
905
+ </span>
906
+ </div>
907
+ </div>
908
+
909
+ <?php
910
+
911
+ echo ob_get_clean();
912
+ }
913
+
914
+ /**
915
+ * Apply filter to change the placeholder text of coupon field.
916
+ *
917
+ * @return string
918
+ */
919
+ function coupon_field_placeholder() {
920
+ return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
921
+ }
922
+
923
+ /**
924
+ * Apply filter to change the button text of coupon field.
925
+ *
926
+ * @return string
927
+ */
928
+ function coupon_button_text() {
929
+ return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
930
+ }
931
+
932
+ /**
933
+ * Apply coupon on submit of custom coupon form.
934
+ */
935
+ function apply_coupon() {
936
+
937
+ check_ajax_referer( 'cf-apply-coupon', 'security' );
938
+
939
+ $result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
940
+
941
+ echo json_encode( $result );
942
+ die();
943
+ }
944
+
945
+ /**
946
+ * Added ajax nonce to localize variable.
947
+ *
948
+ * @param array $vars localize variables.
949
+ */
950
+ function add_localize_vars( $vars ) {
951
+
952
+ $vars['cf_validate_coupon_nonce'] = wp_create_nonce( 'cf-apply-coupon' );
953
+
954
+ return $vars;
955
+ }
956
+
957
+ /**
958
+ * Add custom class to the fields to change the UI to three column.
959
+ *
960
+ * @param array $fields fields.
961
+ */
962
+ function add_three_column_layout_fields( $fields ) {
963
+
964
+ if ( empty( $fields['billing']['billing_address_2'] ) ) {
965
+
966
+ if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
967
+ $fields['billing']['billing_address_1']['class'][] = 'form-row-full';
968
+ }
969
+ }
970
+
971
+ if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
972
+
973
+ if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
974
+ $fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
975
+ }
976
+ }
977
+
978
+ if ( isset( $fields['billing']['billing_city'] ) &&
979
+ isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
980
+
981
+ $fields['billing']['billing_city']['class'] = array( 'wcf-form-col-3' );
982
+ $fields['billing']['billing_state']['class'] = array( 'wcf-form-col-3' );
983
+ $fields['billing']['billing_postcode']['class'] = array( 'wcf-form-col-3' );
984
+ }
985
+
986
+ if ( isset( $fields['shipping']['shipping_city'] ) &&
987
+ isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
988
+
989
+ $fields['shipping']['shipping_city']['class'] = array( 'wcf-form-col-3' );
990
+ $fields['shipping']['shipping_state']['class'] = array( 'wcf-form-col-3' );
991
+ $fields['shipping']['shipping_postcode']['class'] = array( 'wcf-form-col-3' );
992
+ }
993
+
994
+ return $fields;
995
+ }
996
+
997
+ /**
998
+ * Add opening dev
999
+ *
1000
+ * @since 1.0.0
1001
+ */
1002
+ function order_wrap_div_start() {
1003
+
1004
+ echo "<div class='wcf-order-wrap'> ";
1005
+ }
1006
+
1007
+ /**
1008
+ * Add closing dev
1009
+ *
1010
+ * @since 1.0.0
1011
+ */
1012
+ function order_wrap_div_end() {
1013
+
1014
+ echo '</div> ';
1015
+ }
1016
+ }
1017
+
1018
+ /**
1019
+ * Kicking this off by calling 'get_instance()' method
1020
+ */
1021
+ Cartflows_Checkout_Markup::get_instance();
modules/flow/templates/template-canvas.php CHANGED
@@ -39,10 +39,7 @@
39
 
40
  <?php do_action( 'cartflows_wp_footer' ); ?>
41
 
42
- <div class="cartflows-def-footer-wrap">
43
  <?php wp_footer(); ?>
44
- </div>
45
-
46
  </body>
47
 
48
  </html>
39
 
40
  <?php do_action( 'cartflows_wp_footer' ); ?>
41
 
 
42
  <?php wp_footer(); ?>
 
 
43
  </body>
44
 
45
  </html>
modules/flow/templates/template-default.php CHANGED
@@ -43,10 +43,7 @@
43
 
44
  <?php do_action( 'cartflows_wp_footer' ); ?>
45
 
46
- <div class="cartflows-def-footer-wrap">
47
  <?php wp_footer(); ?>
48
- </div>
49
-
50
  </body>
51
 
52
  </html>
43
 
44
  <?php do_action( 'cartflows_wp_footer' ); ?>
45
 
 
46
  <?php wp_footer(); ?>
 
 
47
  </body>
48
 
49
  </html>
modules/flow/view/meta-flow-steps.php CHANGED
@@ -1,183 +1,200 @@
1
- <?php
2
- /**
3
- * View Flow steps
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- $get_steps = array(
9
- 'landing' => __( 'Landing', 'cartflows' ),
10
- 'checkout' => __( 'Checkout', 'cartflows' ),
11
- 'thankyou' => __( 'Thank You', 'cartflows' ),
12
- 'upsell' => __( 'Upsell', 'cartflows' ),
13
- 'downsell' => __( 'Downsell', 'cartflows' ),
14
-
15
- );
16
-
17
- ?>
18
- <div class="wcf-flow-steps-meta-box">
19
- <div class="wcf-flow-settings">
20
- <?php do_action( 'cartflows_above_flow_steps' ); ?>
21
- <div class="wcf-flow-steps-wrap">
22
- <div class="wcf-flow-steps-container">
23
- <?php if ( is_array( $options['steps'] ) ) { ?>
24
- <?php foreach ( $options['steps'] as $index => $data ) { ?>
25
- <?php
26
- $term_slug = '';
27
- $term_name = '';
28
- $step_wrap_class = '';
29
- $has_product_assigned = true;
30
- $is_global_checkout = '';
31
- $common = '';
32
-
33
- if ( isset( $data['type'] ) ) {
34
- $term_slug = $data['type'];
35
- $term_name = $get_steps[ $data['type'] ];
36
- }
37
-
38
- if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) {
39
- $step_wrap_class .= ' invalid-step';
40
- }
41
-
42
- if ( isset( $_GET['highlight-step-id'] ) && $_GET['highlight-step-id'] == $data['id'] ) {
43
- $step_wrap_class .= ' wcf-new-step-highlight';
44
- }
45
-
46
- if ( 'checkout' === $term_slug ) {
47
-
48
- $common = Cartflows_Helper::get_common_settings();
49
-
50
- $is_global_checkout = (int) $common['global_checkout'];
51
-
52
- if ( $data['id'] === $is_global_checkout ) {
53
- $step_wrap_class .= ' wcf-global-checkout';
54
- }
55
- }
56
-
57
- if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) {
58
-
59
- $has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] );
60
-
61
- if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
62
- $step_wrap_class .= ' wcf-no-product-step';
63
- }
64
- }
65
-
66
- ?>
67
- <div class="wcf-step-wrap <?php echo $step_wrap_class; ?>" data-id="<?php echo $data['id']; ?>" data-term-slug="<?php echo esc_attr( $term_slug ); ?>">
68
- <div class="wcf-step">
69
- <div class="wcf-step-left-content">
70
- <span class="dashicons dashicons-menu"></span>
71
- <span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span>
72
- <span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span>
73
-
74
- <?php
75
- if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
76
- ?>
77
- <span class="wcf-no-product-badge"><?php _e( 'No Product Assigned', 'cartflows' ); ?></span>
78
- <?php
79
- } elseif ( ( $has_product_assigned ) && ( $data['id'] === $is_global_checkout ) ) {
80
- ?>
81
- <span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout - Remove selected checkout product', 'cartflows' ); ?></span>
82
- <?php
83
- } elseif ( ( ! $has_product_assigned ) && $data['id'] === $is_global_checkout ) {
84
- ?>
85
- <span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout', 'cartflows' ); ?></span>
86
- <?php
87
- }
88
- ?>
89
-
90
- <input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>">
91
- </div>
92
- <div class="wcf-steps-action-buttons">
93
- <a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'View Step', 'cartflows' ); ?>" >
94
- <span class="dashicons dashicons-visibility"></span>
95
- <span class="wcf-step-act-btn-text">View</span>
96
- </a>
97
- <a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Edit Step', 'cartflows' ); ?>" >
98
- <span class="dashicons dashicons-edit"></span>
99
- <span class="wcf-step-act-btn-text">Edit</span>
100
- </a>
101
- <a href="<?php echo wp_nonce_url( 'admin.php?action=cartflows_clone_step&post=' . $data['id'], 'step_clone', 'step_clone_nonce' ); ?>" class="wcf-step-clone wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
102
- <span class="dashicons dashicons-admin-page"></span>
103
- <span class="wcf-step-act-btn-text">Clone</span>
104
- </a>
105
- <a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
106
- <span class="dashicons dashicons-trash"></span>
107
- <span class="wcf-step-act-btn-text">Delete</span>
108
- </a>
109
- </div>
110
- </div>
111
- </div><!-- .wcf-step-wrap -->
112
- <?php } ?>
113
- <?php } ?>
114
- </div><!-- .wcf-flow-steps-container -->
115
- </div> <!-- .wcf-flow-steps-wrap -->
116
- <div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap -->
117
- <?php do_action( 'cartflows_bellow_flow_steps' ); ?>
118
- <div class='wcf-add-new-step-btn-wrap'>
119
- <button class='wcf-trigger-popup button button-primary'>
120
- <?php echo __( 'Add New Step', 'cartflows' ); ?>
121
- </button>
122
- </div>
123
- </div><!-- .wcf-flow-buttons-wrap -->
124
- </div><!-- .wcf-flow-settings -->
125
-
126
- <div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay">
127
- <div class="wcf-templates-popup-content">
128
- <div class="spinner"></div>
129
- <div class="wcf-templates-wrap wcf-templates-wrap-flows">
130
-
131
- <div id="wcf-remote-step-actions" class="wcf-template-header">
132
- <div class="wcf-template-logo-wrap">
133
- <span class="wcf-cartflows-logo-img">
134
- <span class="cartflows-icon"></span>
135
- </span>
136
- <span class="wcf-cartflows-title"><?php _e( 'Steps Library', 'cartflows' ); ?></span>
137
- </div>
138
- <div class="wcf-tab-wrapper">
139
- <div id="wcf-get-started-steps">
140
- <ul class="filter-links ">
141
- <li>
142
- <a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
143
- </li>
144
- <li>
145
- <a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
146
- </li>
147
- </ul>
148
- </div>
149
- </div>
150
- <div class="wcf-popup-close-wrap">
151
- <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
152
- </div>
153
- </div>
154
-
155
- <!--<div class="wcf-search-form">
156
- <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
157
- <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
158
- </div>-->
159
- <?php if ( ! _is_cartflows_pro() ) { ?>
160
- <div class="wcf-template-notice"><p><?php echo __( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div>
161
- <?php } ?>
162
- <div id="wcf-remote-content">
163
- <div id="wcf-ready-templates">
164
- <div id="wcf-remote-filters">
165
- <div id="wcf-page-builders"></div>
166
- <div id="wcf-categories"></div>
167
- </div>
168
- <div class="wcf-page-builder-notice"></div>
169
- <div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"></div>
170
- <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
171
- </div>
172
- <div id="wcf-start-from-scratch" style="display: none;">
173
- <div class="inner">
174
- <div id="wcf-scratch-steps-categories"></div>
175
- <a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create Step', 'cartflows' ); ?></a>
176
- </div>
177
- </div>
178
- </div>
179
- </div>
180
- </div>
181
- </div><!-- .wcf-templates-popup-overlay -->
182
- </div>
183
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * View Flow steps
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
9
+
10
+ $get_steps = array(
11
+ 'landing' => __( 'Landing', 'cartflows' ),
12
+ 'checkout' => __( 'Checkout', 'cartflows' ),
13
+ 'thankyou' => __( 'Thank You', 'cartflows' ),
14
+ 'upsell' => __( 'Upsell', 'cartflows' ),
15
+ 'downsell' => __( 'Downsell', 'cartflows' ),
16
+
17
+ );
18
+
19
+ ?>
20
+ <div class="wcf-flow-steps-meta-box">
21
+ <div class="wcf-flow-settings">
22
+ <?php do_action( 'cartflows_above_flow_steps' ); ?>
23
+ <div class="wcf-flow-steps-wrap">
24
+ <div class="wcf-flow-steps-container">
25
+ <?php if ( is_array( $options['steps'] ) ) { ?>
26
+ <?php foreach ( $options['steps'] as $index => $data ) { ?>
27
+ <?php
28
+ $term_slug = '';
29
+ $term_name = '';
30
+ $step_wrap_class = '';
31
+ $has_product_assigned = true;
32
+ $is_global_checkout = '';
33
+ $common = '';
34
+
35
+ if ( isset( $data['type'] ) ) {
36
+ $term_slug = $data['type'];
37
+ $term_name = $get_steps[ $data['type'] ];
38
+ }
39
+
40
+ if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) {
41
+ $step_wrap_class .= ' invalid-step';
42
+ }
43
+
44
+ if ( isset( $_GET['highlight-step-id'] ) && $_GET['highlight-step-id'] == $data['id'] ) {
45
+ $step_wrap_class .= ' wcf-new-step-highlight';
46
+ }
47
+
48
+ if ( 'checkout' === $term_slug ) {
49
+
50
+ $common = Cartflows_Helper::get_common_settings();
51
+
52
+ $is_global_checkout = (int) $common['global_checkout'];
53
+
54
+ if ( $data['id'] === $is_global_checkout ) {
55
+ $step_wrap_class .= ' wcf-global-checkout';
56
+ }
57
+ }
58
+
59
+ if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) {
60
+
61
+ $has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] );
62
+
63
+ if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
64
+ $step_wrap_class .= ' wcf-no-product-step';
65
+ }
66
+ }
67
+
68
+ ?>
69
+ <div class="wcf-step-wrap <?php echo $step_wrap_class; ?>" data-id="<?php echo $data['id']; ?>" data-term-slug="<?php echo esc_attr( $term_slug ); ?>">
70
+ <div class="wcf-step">
71
+ <div class="wcf-step-left-content">
72
+ <span class="dashicons dashicons-menu"></span>
73
+ <span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span>
74
+ <span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span>
75
+
76
+ <?php
77
+ if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
78
+ ?>
79
+ <span class="wcf-no-product-badge"><?php _e( 'No Product Assigned', 'cartflows' ); ?></span>
80
+ <?php
81
+ } elseif ( ( $has_product_assigned ) && ( $data['id'] === $is_global_checkout ) ) {
82
+ ?>
83
+ <span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout - Remove selected checkout product', 'cartflows' ); ?></span>
84
+ <?php
85
+ } elseif ( ( ! $has_product_assigned ) && $data['id'] === $is_global_checkout ) {
86
+ ?>
87
+ <span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout', 'cartflows' ); ?></span>
88
+ <?php
89
+ }
90
+ ?>
91
+
92
+ <input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>">
93
+ </div>
94
+ <div class="wcf-steps-action-buttons">
95
+ <a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'View Step', 'cartflows' ); ?>" >
96
+ <span class="dashicons dashicons-visibility"></span>
97
+ <span class="wcf-step-act-btn-text">View</span>
98
+ </a>
99
+ <a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Edit Step', 'cartflows' ); ?>" >
100
+ <span class="dashicons dashicons-edit"></span>
101
+ <span class="wcf-step-act-btn-text">Edit</span>
102
+ </a>
103
+ <a href="<?php echo wp_nonce_url( 'admin.php?action=cartflows_clone_step&post=' . $data['id'], 'step_clone', 'step_clone_nonce' ); ?>" class="wcf-step-clone wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
104
+ <span class="dashicons dashicons-admin-page"></span>
105
+ <span class="wcf-step-act-btn-text">Clone</span>
106
+ </a>
107
+ <a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
108
+ <span class="dashicons dashicons-trash"></span>
109
+ <span class="wcf-step-act-btn-text">Delete</span>
110
+ </a>
111
+ </div>
112
+ </div>
113
+ </div><!-- .wcf-step-wrap -->
114
+ <?php } ?>
115
+ <?php } ?>
116
+ </div><!-- .wcf-flow-steps-container -->
117
+ </div> <!-- .wcf-flow-steps-wrap -->
118
+ <div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap -->
119
+ <?php do_action( 'cartflows_bellow_flow_steps' ); ?>
120
+ <div class='wcf-add-new-step-btn-wrap'>
121
+ <button class='wcf-trigger-popup button button-primary'>
122
+ <?php echo __( 'Add New Step', 'cartflows' ); ?>
123
+ </button>
124
+ </div>
125
+ </div><!-- .wcf-flow-buttons-wrap -->
126
+ </div><!-- .wcf-flow-settings -->
127
+
128
+ <div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay">
129
+ <div class="wcf-templates-popup-content">
130
+ <div class="spinner"></div>
131
+ <div class="wcf-templates-wrap wcf-templates-wrap-flows">
132
+
133
+ <div id="wcf-remote-step-actions" class="wcf-template-header">
134
+ <div class="wcf-template-logo-wrap">
135
+ <span class="wcf-cartflows-logo-img">
136
+ <span class="cartflows-icon"></span>
137
+ </span>
138
+ <span class="wcf-cartflows-title"><?php _e( 'Steps Library', 'cartflows' ); ?></span>
139
+ </div>
140
+ <div class="wcf-tab-wrapper">
141
+ <?php if ( 'other' !== $default_page_builder ) { ?>
142
+ <div id="wcf-get-started-steps">
143
+ <ul class="filter-links ">
144
+ <li>
145
+ <a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
146
+ </li>
147
+ <li>
148
+ <a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
149
+ </li>
150
+ </ul>
151
+ </div>
152
+ <?php } ?>
153
+ </div>
154
+ <div class="wcf-popup-close-wrap">
155
+ <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
156
+ </div>
157
+ </div>
158
+
159
+ <!--<div class="wcf-search-form">
160
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
161
+ <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
162
+ </div>-->
163
+
164
+ <div id="wcf-remote-content">
165
+ <?php if ( 'other' !== $default_page_builder ) { ?>
166
+ <div id="wcf-ready-templates">
167
+ <div id="wcf-remote-filters">
168
+ <div id="wcf-page-builders"></div>
169
+ <div id="wcf-categories"></div>
170
+ </div>
171
+ <div class="wcf-page-builder-notice"></div>
172
+ <div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
173
+ <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
174
+ </div>
175
+ <?php } ?>
176
+ <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
177
+ <div class="inner">
178
+ <div id="wcf-scratch-steps-categories">
179
+ <select class="step-type-filter-links filter-links">
180
+ <option value="" class="current"> Select Step Type </option>
181
+ <option value="52" data-group="52" class="Landing" data-slug="landing" data-title="Landing">Landing</option>
182
+ <option value="53" data-group="53" class="Checkout" data-slug="checkout" data-title="Checkout">Checkout</option>
183
+ <option value="55" data-group="55" class="Upsell" data-slug="upsell" data-title="Upsell">Upsell</option>
184
+ <option value="56" data-group="56" class="Downsell" data-slug="downsell" data-title="Downsell">Downsell</option>
185
+ <option value="54" data-group="54" class="Thank You" data-slug="thankyou" data-title="Thank You">Thank You</option>
186
+ </select>
187
+ </div>
188
+ <a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create Step', 'cartflows' ); ?></a>
189
+ <?php if ( ! _is_cartflows_pro() ) { ?>
190
+ <div class="wcf-template-notice"><p><?php echo __( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div>
191
+ <?php } ?>
192
+ <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>
193
+ </div>
194
+ </div>
195
+ </div>
196
+ </div>
197
+ </div>
198
+ </div><!-- .wcf-templates-popup-overlay -->
199
+ </div>
200
+ <?php
modules/thankyou/classes/class-cartflows-thankyou-markup.php CHANGED
@@ -1,272 +1,273 @@
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
- * 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
- /* Downsell Shortcode */
38
- add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );
39
-
40
- add_action( 'wp_enqueue_scripts', array( $this, 'thank_you_scripts' ), 21 );
41
-
42
- add_action( 'woocommerce_is_order_received_page', array( $this, 'set_order_received_page' ) );
43
-
44
- }
45
-
46
- /**
47
- * Order shortcode markup
48
- *
49
- * @param array $atts attributes.
50
- * @since 1.0.0
51
- */
52
- function cartflows_order_details_shortcode_markup( $atts ) {
53
-
54
- $output = '';
55
-
56
- if ( _is_wcf_thankyou_type() ) {
57
-
58
- /* Remove order item link */
59
- add_filter( 'woocommerce_order_item_permalink', '__return_false' );
60
-
61
- if ( ! function_exists( 'wc_print_notices' ) ) {
62
- return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
63
- }
64
-
65
- $order = false;
66
-
67
- if ( ! isset( $_GET['wcf-order'] ) && wcf()->flow->is_flow_testmode() ) {
68
-
69
- $args = array(
70
- 'limit' => 1,
71
- 'order' => 'DESC',
72
- 'status' => array( 'completed', 'processing' ),
73
- );
74
-
75
- $latest_order = wc_get_orders( $args );
76
-
77
- $order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;
78
-
79
- if ( $order_id > 0 ) {
80
-
81
- $order = wc_get_order( $order_id );
82
-
83
- if ( ! $order ) {
84
- $order = false;
85
- }
86
- }
87
- } else {
88
- if ( ! isset( $_GET['wcf-order'] ) ) {
89
- return '<p class="woocommerce-notice">Order not found. You cannot access this page directly.</p>';
90
- }
91
-
92
- // Get the order.
93
- $order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] ) );
94
- $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) ) ); // WPCS: input var ok, CSRF ok.
95
-
96
- if ( $order_id > 0 ) {
97
-
98
- $order = wc_get_order( $order_id );
99
-
100
- if ( ! $order || $order->get_order_key() !== $order_key ) {
101
- $order = false;
102
- }
103
- }
104
- }
105
-
106
- // Empty awaiting payment session.
107
- unset( WC()->session->order_awaiting_payment );
108
-
109
- if ( null !== WC()->session ) {
110
-
111
- if ( ! isset( WC()->cart ) || '' === WC()->cart ) {
112
- WC()->cart = new WC_Cart();
113
- }
114
-
115
- if ( ! WC()->cart->is_empty() ) {
116
- // wc_empty_cart();
117
- // Empty current cart.
118
- WC()->cart->empty_cart( true );
119
-
120
- wc_clear_notices();
121
- }
122
-
123
- wc_print_notices();
124
- }
125
-
126
- ob_start();
127
- echo "<div class='wcf-thankyou-wrap'>";
128
- wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
129
- echo '</div>';
130
- $output = ob_get_clean();
131
- }
132
-
133
- return $output;
134
- }
135
-
136
- /**
137
- * Load Thank You scripts.
138
- *
139
- * @return void
140
- */
141
- function thank_you_scripts() {
142
-
143
- if ( _is_wcf_thankyou_type() ) {
144
-
145
- do_action( 'cartflows_thank_you_scripts' );
146
-
147
- $style = $this->generate_thank_you_style();
148
-
149
- wp_add_inline_style( 'wcf-frontend-global', $style );
150
- }
151
- }
152
-
153
- /**
154
- * Set thank you as a order received page.
155
- *
156
- * @param boolean $is_order_page order page.
157
- * @return boolean
158
- */
159
- function set_order_received_page( $is_order_page ) {
160
-
161
- if ( _is_wcf_thankyou_type() ) {
162
-
163
- $is_order_page = true;
164
- }
165
-
166
- return $is_order_page;
167
- }
168
-
169
- /**
170
- * Generate Thank You Styles.
171
- *
172
- * @return string
173
- */
174
- function generate_thank_you_style() {
175
-
176
- global $post;
177
-
178
- if ( _is_wcf_thankyou_type() ) {
179
- $thank_you_id = $post->ID;
180
- } else {
181
- $thank_you_id = _get_wcf_thankyou_id( $post->post_content );
182
- }
183
-
184
- CartFlows_Font_Families::render_fonts( $thank_you_id );
185
-
186
- $text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text-color' );
187
- $text_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-family' );
188
- $heading_text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-color' );
189
- $heading_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-family' );
190
- $heading_font_weight = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-wt' );
191
- $container_width = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-container-width' );
192
- $section_bg_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-section-bg-color' );
193
-
194
- $show_order_review = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-overview-section' );
195
-
196
- $show_order_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-details-section' );
197
-
198
- $show_billing_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-billing-section' );
199
-
200
- $show_shipping_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-shipping-section' );
201
-
202
- $output = "
203
- .wcf-thankyou-wrap{
204
- color: {$text_color};
205
- font-family: {$text_font_family};
206
- max-width:{$container_width}px;
207
- }
208
-
209
- .woocommerce-order h2.woocommerce-column__title,
210
- .woocommerce-order h2.woocommerce-order-details__title,
211
- .woocommerce-order .woocommerce-thankyou-order-received,
212
- .woocommerce-order-details h2 {
213
- color: {$heading_text_color};
214
- font-family: {$heading_font_family};
215
- font-weight: {$heading_font_weight};
216
- }
217
-
218
- .woocommerce-order ul.order_details,
219
- .woocommerce-order .woocommerce-order-details,
220
- .woocommerce-order .woocommerce-customer-details{
221
- background-color: {$section_bg_color}
222
- }
223
- ";
224
-
225
- if ( 'no' == $show_order_review ) {
226
- $output .= '
227
- .woocommerce-order ul.order_details{
228
- display: none;
229
- }
230
- ';
231
- }
232
-
233
- if ( 'no' == $show_order_details ) {
234
- $output .= '
235
- .woocommerce-order .woocommerce-order-details{
236
- display: none;
237
- }
238
- ';
239
- }
240
-
241
- if ( 'no' == $show_billing_details ) {
242
- $output .= '
243
- .woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
244
- display: none;
245
- }
246
- ';
247
- }
248
-
249
- if ( 'no' == $show_shipping_details ) {
250
- $output .= '
251
- .woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
252
- display: none;
253
- }
254
- ';
255
- }
256
-
257
- if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
258
- $output .= '
259
- .woocommerce-order .woocommerce-customer-details{
260
- display: none;
261
- }
262
- ';
263
- }
264
-
265
- return $output;
266
- }
267
- }
268
-
269
- /**
270
- * Kicking this off by calling 'get_instance()' method
271
- */
272
- 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
+ * 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
+ /* Downsell Shortcode */
38
+ add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );
39
+
40
+ add_action( 'wp_enqueue_scripts', array( $this, 'thank_you_scripts' ), 21 );
41
+
42
+ add_action( 'woocommerce_is_order_received_page', array( $this, 'set_order_received_page' ) );
43
+
44
+ }
45
+
46
+ /**
47
+ * Order shortcode markup
48
+ *
49
+ * @param array $atts attributes.
50
+ * @since 1.0.0
51
+ */
52
+ function cartflows_order_details_shortcode_markup( $atts ) {
53
+
54
+ $output = '';
55
+
56
+ if ( _is_wcf_thankyou_type() ) {
57
+
58
+ /* Remove order item link */
59
+ add_filter( 'woocommerce_order_item_permalink', '__return_false' );
60
+
61
+ if ( ! function_exists( 'wc_print_notices' ) ) {
62
+ return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
63
+ }
64
+
65
+ $order = false;
66
+
67
+ if ( ! isset( $_GET['wcf-order'] ) && wcf()->flow->is_flow_testmode() ) {
68
+
69
+ $args = array(
70
+ 'limit' => 1,
71
+ 'order' => 'DESC',
72
+ 'post_type' => 'shop_order',
73
+ 'status' => array( 'completed', 'processing' ),
74
+ );
75
+
76
+ $latest_order = wc_get_orders( $args );
77
+
78
+ $order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;
79
+
80
+ if ( $order_id > 0 ) {
81
+
82
+ $order = wc_get_order( $order_id );
83
+
84
+ if ( ! $order ) {
85
+ $order = false;
86
+ }
87
+ }
88
+ } else {
89
+ if ( ! isset( $_GET['wcf-order'] ) ) {
90
+ return '<p class="woocommerce-notice">Order not found. You cannot access this page directly.</p>';
91
+ }
92
+
93
+ // Get the order.
94
+ $order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] ) );
95
+ $order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) ) ); // WPCS: input var ok, CSRF ok.
96
+
97
+ if ( $order_id > 0 ) {
98
+
99
+ $order = wc_get_order( $order_id );
100
+
101
+ if ( ! $order || $order->get_order_key() !== $order_key ) {
102
+ $order = false;
103
+ }
104
+ }
105
+ }
106
+
107
+ // Empty awaiting payment session.
108
+ unset( WC()->session->order_awaiting_payment );
109
+
110
+ if ( null !== WC()->session ) {
111
+
112
+ if ( ! isset( WC()->cart ) || '' === WC()->cart ) {
113
+ WC()->cart = new WC_Cart();
114
+ }
115
+
116
+ if ( ! WC()->cart->is_empty() ) {
117
+ // wc_empty_cart();
118
+ // Empty current cart.
119
+ WC()->cart->empty_cart( true );
120
+
121
+ wc_clear_notices();
122
+ }
123
+
124
+ wc_print_notices();
125
+ }
126
+
127
+ ob_start();
128
+ echo "<div class='wcf-thankyou-wrap'>";
129
+ wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
130
+ echo '</div>';
131
+ $output = ob_get_clean();
132
+ }
133
+
134
+ return $output;
135
+ }
136
+
137
+ /**
138
+ * Load Thank You scripts.
139
+ *
140
+ * @return void
141
+ */
142
+ function thank_you_scripts() {
143
+
144
+ if ( _is_wcf_thankyou_type() ) {
145
+
146
+ do_action( 'cartflows_thank_you_scripts' );
147
+
148
+ $style = $this->generate_thank_you_style();
149
+
150
+ wp_add_inline_style( 'wcf-frontend-global', $style );
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Set thank you as a order received page.
156
+ *
157
+ * @param boolean $is_order_page order page.
158
+ * @return boolean
159
+ */
160
+ function set_order_received_page( $is_order_page ) {
161
+
162
+ if ( _is_wcf_thankyou_type() ) {
163
+
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
+ color: {$heading_text_color};
215
+ font-family: {$heading_font_family};
216
+ font-weight: {$heading_font_weight};
217
+ }
218
+
219
+ .woocommerce-order ul.order_details,
220
+ .woocommerce-order .woocommerce-order-details,
221
+ .woocommerce-order .woocommerce-customer-details{
222
+ background-color: {$section_bg_color}
223
+ }
224
+ ";
225
+
226
+ if ( 'no' == $show_order_review ) {
227
+ $output .= '
228
+ .woocommerce-order ul.order_details{
229
+ display: none;
230
+ }
231
+ ';
232
+ }
233
+
234
+ if ( 'no' == $show_order_details ) {
235
+ $output .= '
236
+ .woocommerce-order .woocommerce-order-details{
237
+ display: none;
238
+ }
239
+ ';
240
+ }
241
+
242
+ if ( 'no' == $show_billing_details ) {
243
+ $output .= '
244
+ .woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
245
+ display: none;
246
+ }
247
+ ';
248
+ }
249
+
250
+ if ( 'no' == $show_shipping_details ) {
251
+ $output .= '
252
+ .woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
253
+ display: none;
254
+ }
255
+ ';
256
+ }
257
+
258
+ if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
259
+ $output .= '
260
+ .woocommerce-order .woocommerce-customer-details{
261
+ display: none;
262
+ }
263
+ ';
264
+ }
265
+
266
+ return $output;
267
+ }
268
+ }
269
+
270
+ /**
271
+ * Kicking this off by calling 'get_instance()' method
272
+ */
273
+ Cartflows_Thankyou_Markup::get_instance();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, cart
5
  Requires at least: 4.4
6
  Requires PHP: 5.6
7
  Tested up to: 5.0.2
8
- Stable tag: 1.1.3
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -93,6 +93,12 @@ Say goodby to using the same ridgid checkout page that everyone else is using. C
93
  2. Activate the plugin through the 'Plugins' menu in WordPress
94
 
95
  == Changelog ==
 
 
 
 
 
 
96
  Version 1.1.3 - Tuesday, 15th January 2019
97
  * New: Import / Export the flows
98
  * Improvement: Pixel Caffeine plugin pixel compatibility added.
5
  Requires at least: 4.4
6
  Requires PHP: 5.6
7
  Tested up to: 5.0.2
8
+ Stable tag: 1.1.4
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
93
  2. Activate the plugin through the 'Plugins' menu in WordPress
94
 
95
  == Changelog ==
96
+ Version 1.1.4 - Tuesday, 22nd January 2019
97
+ * New: Beaver Builder templates.
98
+ * Improvement: Better error handling on the checkout page.
99
+ * Fix: Product variants were not getting aligned properly in the order summary.
100
+ * Fix: Divi builder conflict.
101
+
102
  Version 1.1.3 - Tuesday, 15th January 2019
103
  * New: Import / Export the flows
104
  * Improvement: Pixel Caffeine plugin pixel compatibility added.