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

Version Description

Download this release

Release Info

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

Code changes from version 1.4.0 to 1.4.2

admin/assets/css/global-admin-rtl.css CHANGED
@@ -833,6 +833,121 @@ input[type="text"].error:focus{
833
  }
834
 
835
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
  * Display upgrade popup custom button
837
  */
838
  .wcf-custom-add-new-button.button{
@@ -947,4 +1062,16 @@ input[type="text"].error:focus{
947
  }
948
  }
949
 
 
 
 
 
 
 
950
 
 
 
 
 
 
 
833
  }
834
 
835
  /**
836
+ * ************************
837
+ * Create Woo Product Start
838
+ * ************************
839
+ */
840
+
841
+ .wcf-create-woo-iframe-opened{
842
+ overflow: hidden;
843
+ }
844
+
845
+ .wcf-create-woo-product-overlay{
846
+ position: fixed;
847
+ height: 100%;
848
+ width: 100%;
849
+ top: 0;
850
+ right: 0;
851
+ background: rgba(0, 0, 0, 0.7);
852
+ -webkit-transition: opacity 500ms;
853
+ transition: opacity 500ms;
854
+ visibility: hidden;
855
+ opacity: 0;
856
+ z-index: 9999;
857
+ -webkit-user-select: none;
858
+ -moz-user-select: none;
859
+ -ms-user-select: none;
860
+ user-select: none;
861
+ -webkit-transition: none;
862
+ transition: none;
863
+ }
864
+
865
+ .wcf-create-woo-product-overlay.open {
866
+ visibility: visible;
867
+ opacity: 1;
868
+ z-index: 999999;
869
+ }
870
+
871
+ .wcf-create-woo-product-wrap{
872
+ max-width: 100%;
873
+ background-color: transparent;
874
+ position: relative;
875
+ -webkit-border-radius: 3px;
876
+ border-radius: 3px;
877
+ top: 50%;
878
+ margin: 0 auto;
879
+ -ms-transform: translate(50%, -35%);
880
+ width: 90%;
881
+ min-height: 85%;
882
+ max-height: 85%;
883
+ height: 85%;
884
+ transform: translateY(-50%);
885
+ z-index: 99999;
886
+ }
887
+
888
+ .wcf-create-woo-product-wrap:not(.product-loaded):before {
889
+ content: "";
890
+ position: absolute;
891
+ background: none !important;
892
+ top: 50%;
893
+ margin: 0 auto;
894
+ text-align: center;
895
+ color: #fff;
896
+ right: 50%;
897
+ width: 48px;
898
+ height: 48px;
899
+ display: block;
900
+ border: 3px solid white;
901
+ -webkit-border-radius: 50%;
902
+ border-radius: 50%;
903
+ border-left-color: transparent;
904
+ border-right-color: transparent;
905
+ -webkit-animation: wcf-admin-loader 575ms infinite linear;
906
+ animation: wcf-admin-loader 575ms infinite linear;
907
+ }
908
+
909
+ .wcf-woo-product-iframe {
910
+ max-width: 100%;
911
+ width: 100%;
912
+ min-height: 100%;
913
+ height: 100%;
914
+ background: #ffffff;
915
+ }
916
+
917
+ .wcf-close-create-woo-product{
918
+ background: #fff;
919
+ border: 1px #fff solid;
920
+ border-radius: 50%;
921
+ color: #000;
922
+ height: 25px;
923
+ position: fixed;
924
+ width: 25px;
925
+ top: -10px;
926
+ right: auto;
927
+ z-index: 100000;
928
+ cursor: pointer;
929
+ left: -10px;
930
+ font-size: 20px;
931
+ line-height: 1.3;
932
+ text-align: center;
933
+ }
934
+
935
+ .wcf-close-create-woo-product:before{
936
+ content: "\f158";
937
+ font-family: dashicons;
938
+ }
939
+
940
+ #wcf-create-woo-product iframe.wcf-create-woo-product-iframe #wpadminbar,
941
+ #wcf-create-woo-product iframe.wcf-create-woo-product-iframe #adminmenumain{
942
+ display: none;
943
+ }
944
+ /**
945
+ * ************************
946
+ * Create Woo Product End
947
+ * ************************
948
+ */
949
+
950
+ /*
951
  * Display upgrade popup custom button
952
  */
953
  .wcf-custom-add-new-button.button{
1062
  }
1063
  }
1064
 
1065
+ @keyframes wcf-admin-loader {
1066
+ 100% {
1067
+ -webkit-transform: rotate(360deg);
1068
+ transform: rotate(360deg);
1069
+ }
1070
+ }
1071
 
1072
+ @-webkit-keyframes wcf-admin-loader {
1073
+ 100% {
1074
+ -webkit-transform: rotate(360deg);
1075
+ transform: rotate(360deg);
1076
+ }
1077
+ }
admin/assets/css/global-admin.css CHANGED
@@ -833,6 +833,121 @@ input[type="text"].error:focus{
833
  }
834
 
835
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
  * Display upgrade popup custom button
837
  */
838
  .wcf-custom-add-new-button.button{
@@ -947,4 +1062,16 @@ input[type="text"].error:focus{
947
  }
948
  }
949
 
 
 
 
 
 
 
950
 
 
 
 
 
 
 
833
  }
834
 
835
  /**
836
+ * ************************
837
+ * Create Woo Product Start
838
+ * ************************
839
+ */
840
+
841
+ .wcf-create-woo-iframe-opened{
842
+ overflow: hidden;
843
+ }
844
+
845
+ .wcf-create-woo-product-overlay{
846
+ position: fixed;
847
+ height: 100%;
848
+ width: 100%;
849
+ top: 0;
850
+ left: 0;
851
+ background: rgba(0, 0, 0, 0.7);
852
+ -webkit-transition: opacity 500ms;
853
+ transition: opacity 500ms;
854
+ visibility: hidden;
855
+ opacity: 0;
856
+ z-index: 9999;
857
+ -webkit-user-select: none;
858
+ -moz-user-select: none;
859
+ -ms-user-select: none;
860
+ user-select: none;
861
+ -webkit-transition: none;
862
+ transition: none;
863
+ }
864
+
865
+ .wcf-create-woo-product-overlay.open {
866
+ visibility: visible;
867
+ opacity: 1;
868
+ z-index: 999999;
869
+ }
870
+
871
+ .wcf-create-woo-product-wrap{
872
+ max-width: 100%;
873
+ background-color: transparent;
874
+ position: relative;
875
+ -webkit-border-radius: 3px;
876
+ border-radius: 3px;
877
+ top: 50%;
878
+ margin: 0 auto;
879
+ -ms-transform: translate(-50%, -35%);
880
+ width: 90%;
881
+ min-height: 85%;
882
+ max-height: 85%;
883
+ height: 85%;
884
+ transform: translateY(-50%);
885
+ z-index: 99999;
886
+ }
887
+
888
+ .wcf-create-woo-product-wrap:not(.product-loaded):before {
889
+ content: "";
890
+ position: absolute;
891
+ background: none !important;
892
+ top: 50%;
893
+ margin: 0 auto;
894
+ text-align: center;
895
+ color: #fff;
896
+ left: 50%;
897
+ width: 48px;
898
+ height: 48px;
899
+ display: block;
900
+ border: 3px solid white;
901
+ -webkit-border-radius: 50%;
902
+ border-radius: 50%;
903
+ border-right-color: transparent;
904
+ border-left-color: transparent;
905
+ -webkit-animation: wcf-admin-loader 575ms infinite linear;
906
+ animation: wcf-admin-loader 575ms infinite linear;
907
+ }
908
+
909
+ .wcf-woo-product-iframe {
910
+ max-width: 100%;
911
+ width: 100%;
912
+ min-height: 100%;
913
+ height: 100%;
914
+ background: #ffffff;
915
+ }
916
+
917
+ .wcf-close-create-woo-product{
918
+ background: #fff;
919
+ border: 1px #fff solid;
920
+ border-radius: 50%;
921
+ color: #000;
922
+ height: 25px;
923
+ position: fixed;
924
+ width: 25px;
925
+ top: -10px;
926
+ left: auto;
927
+ z-index: 100000;
928
+ cursor: pointer;
929
+ right: -10px;
930
+ font-size: 20px;
931
+ line-height: 1.3;
932
+ text-align: center;
933
+ }
934
+
935
+ .wcf-close-create-woo-product:before{
936
+ content: "\f158";
937
+ font-family: dashicons;
938
+ }
939
+
940
+ #wcf-create-woo-product iframe.wcf-create-woo-product-iframe #wpadminbar,
941
+ #wcf-create-woo-product iframe.wcf-create-woo-product-iframe #adminmenumain{
942
+ display: none;
943
+ }
944
+ /**
945
+ * ************************
946
+ * Create Woo Product End
947
+ * ************************
948
+ */
949
+
950
+ /*
951
  * Display upgrade popup custom button
952
  */
953
  .wcf-custom-add-new-button.button{
1062
  }
1063
  }
1064
 
1065
+ @keyframes wcf-admin-loader {
1066
+ 100% {
1067
+ -webkit-transform: rotate(-360deg);
1068
+ transform: rotate(-360deg);
1069
+ }
1070
+ }
1071
 
1072
+ @-webkit-keyframes wcf-admin-loader {
1073
+ 100% {
1074
+ -webkit-transform: rotate(-360deg);
1075
+ transform: rotate(-360deg);
1076
+ }
1077
+ }
admin/assets/js/global-admin.js CHANGED
@@ -165,7 +165,7 @@
165
  wrapper.find('.field-wcf-submit-button-position').hide();
166
  }
167
  });
168
- }
169
 
170
  var wcf_checkout_prevent_toggle_for_shortcode = function() {
171
  // Prevent inputs in meta box headings opening/closing contents.
@@ -180,9 +180,9 @@
180
 
181
  $( '#wcf-checkout-settings' ).toggleClass( 'closed' );
182
  });
183
- }
184
 
185
- function add_tool_tip_msg(){
186
  var tooltip = false;
187
 
188
  $('.wcf-field-heading-help').click(function(){
@@ -191,12 +191,11 @@
191
 
192
  closest_tooltip.toggleClass('display_tool_tip');
193
  });
194
-
195
- }
196
 
197
 
198
  // Check for the highlight area and add the class.
199
- function highlight_the_metabox(){
200
 
201
  if( ( 'undefined' !== typeof cartflows_admin ) && ( cartflows_admin.wcf_edit_test_mode ) ){
202
 
@@ -204,22 +203,22 @@
204
 
205
  // Remove the class automatically after 6 seconds.
206
  setTimeout(function(){
207
- deactivateHighlight()
208
  }, 6000);
209
 
210
  // Click outside the higlight element and remove the class
211
  $(document).on('click', function (e) {
212
- deactivateHighlight();
213
  });
214
  }
215
- }
216
 
217
  // Function to remove the highlighted class
218
- function deactivateHighlight() {
219
  $('#wcf-sandbox-settings').removeClass('wcf-highlight');
220
- }
221
 
222
- function wcf_toggle_post_update() {
223
 
224
  if ( 'undefined' === typeof cartflows_woo ) {
225
  return;
@@ -228,9 +227,146 @@
228
  if( ! cartflows_woo.show_update_post ) {
229
  $("#submitdiv").hide();
230
  }
231
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
 
233
- function show_upgrade_to_pro_popup(){
 
 
 
234
 
235
  $('.wcf-custom-add-new-button').click(function(){
236
  $('#cartflows-upgrade-notice-popup').show();
@@ -244,10 +380,10 @@
244
  $('#cartflows-upgrade-notice-popup').hide();
245
  $('#cartflows-upgrade-notice-overlay').hide();
246
  });
247
- }
248
 
249
  /* Optin - hide/show login */
250
- function wcf_optin_hide_show_init(){
251
 
252
  var wrapper = $('.wcf-optin-table');
253
 
@@ -280,7 +416,7 @@
280
  });
281
  }
282
  });
283
- }
284
 
285
  $( document ).ready(function() {
286
 
@@ -303,13 +439,16 @@
303
  wcf_optin_hide_show_init();
304
 
305
  /* Other */
306
- add_tool_tip_msg();
307
 
308
- highlight_the_metabox();
309
 
310
  wcf_toggle_post_update();
311
-
312
- show_upgrade_to_pro_popup();
 
 
 
313
 
314
  });
315
 
165
  wrapper.find('.field-wcf-submit-button-position').hide();
166
  }
167
  });
168
+ };
169
 
170
  var wcf_checkout_prevent_toggle_for_shortcode = function() {
171
  // Prevent inputs in meta box headings opening/closing contents.
180
 
181
  $( '#wcf-checkout-settings' ).toggleClass( 'closed' );
182
  });
183
+ };
184
 
185
+ var wcf_add_tool_tip_msg = function(){
186
  var tooltip = false;
187
 
188
  $('.wcf-field-heading-help').click(function(){
191
 
192
  closest_tooltip.toggleClass('display_tool_tip');
193
  });
194
+ };
 
195
 
196
 
197
  // Check for the highlight area and add the class.
198
+ var wcf_highlight_the_metabox = function(){
199
 
200
  if( ( 'undefined' !== typeof cartflows_admin ) && ( cartflows_admin.wcf_edit_test_mode ) ){
201
 
203
 
204
  // Remove the class automatically after 6 seconds.
205
  setTimeout(function(){
206
+ wcfDeactivateHighlight()
207
  }, 6000);
208
 
209
  // Click outside the higlight element and remove the class
210
  $(document).on('click', function (e) {
211
+ wcfDeactivateHighlight();
212
  });
213
  }
214
+ };
215
 
216
  // Function to remove the highlighted class
217
+ var wcfDeactivateHighlight = function() {
218
  $('#wcf-sandbox-settings').removeClass('wcf-highlight');
219
+ };
220
 
221
+ var wcf_toggle_post_update = function() {
222
 
223
  if ( 'undefined' === typeof cartflows_woo ) {
224
  return;
227
  if( ! cartflows_woo.show_update_post ) {
228
  $("#submitdiv").hide();
229
  }
230
+ };
231
+
232
+ var wcf_create_woo_product_from_iframe = function() {
233
+
234
+ // Function to create an HTML elements
235
+ function _create_html_element( args, appent_to ){
236
+
237
+ window.htmlElement = document.createElement( args['element'] );
238
+ window.htmlElement.id = args['id'];
239
+ window.htmlElement.className = args['class'];
240
+
241
+ if( 'body' === appent_to ){
242
+
243
+ document.getElementsByTagName('body')[0].appendChild(window.htmlElement);
244
+ }else{
245
+ document.getElementById( appent_to ).appendChild(window.htmlElement);
246
+ }
247
+ }
248
+
249
+ // Function to create Iframe
250
+ function _create_iframe_element( args, appent_to ){
251
+
252
+ window.iFrameElement = document.createElement( args['element'] );
253
+ window.iFrameElement.id = args['id'];
254
+ window.iFrameElement.className = args['class'];
255
+ window.iFrameElement.frameborder = args['border'];
256
+ window.iFrameElement.allowtransparency = args['transparency'];
257
+ window.iFrameElement.src = args['src'];
258
+
259
+ window.iFrameElement.setAttribute('style', 'opacity: 0; visibility:hidden;');
260
+
261
+ var created = document.getElementById( appent_to ).appendChild(window.iFrameElement);
262
+
263
+ $('#' + args['id'] ).on( 'load', function() {
264
+
265
+ $('#wcf-create-woo-product-iframe').contents().find("body").addClass("wcf-in-iframe");
266
+
267
+ /* Create Close Button */
268
+ var args = {
269
+ 'element' : 'a',
270
+ 'id' : 'wcf-close-create-woo-product',
271
+ 'class' : 'wcf-close-create-woo-product close-icon',
272
+ };
273
+ _create_html_element( args, 'wcf-create-woo-product-wrap' );
274
+
275
+ // Display Iframe
276
+ window.iFrameElement.setAttribute('style', 'opacity: 1; visibility:visible;');
277
+ $( '.wcf-create-woo-product-wrap' ).addClass( 'product-loaded' );
278
+
279
+ } );
280
+ }
281
+
282
+ // Function to destroy the Iframe & close the popup.
283
+ function _destroy_create_woo_product_iframe(){
284
+ window.iFrameElement.setAttribute('style', 'opacity: 0; visibility:hidden;');
285
+ $('body').removeClass('wcf-create-woo-iframe-opened');
286
+ $('#wcf-create-woo-product-overlay').removeClass('open');
287
+ $('.wcf-create-woo-product').removeClass('updating-message');
288
+ $( '.wcf-create-woo-product-wrap' ).removeClass( 'product-loaded' );
289
+ $("#wcf-create-woo-product-overlay").remove();
290
+
291
+ }
292
+
293
+ function wcf_open_create_woo_product_popup(){
294
+ $( '.wcf-create-woo-product' ).on( 'click', function( event ) {
295
+
296
+ event.preventDefault();
297
+
298
+ var create_btn = $('.wcf-create-woo-product');
299
+
300
+ /* Display Loading */
301
+ create_btn.addClass('updating-message');
302
+
303
+ // Create wrapper div.
304
+ var args = {
305
+ 'element': 'div',
306
+ 'id': 'wcf-create-woo-product-overlay',
307
+ 'class': 'wcf-create-woo-product-overlay'
308
+ };
309
+
310
+ // Create wrapper div.
311
+ var args = {
312
+ 'element': 'div',
313
+ 'id': 'wcf-create-woo-product-overlay',
314
+ 'class': 'wcf-create-woo-product-overlay'
315
+ };
316
+
317
+ _create_html_element( args, 'body' );
318
+
319
+
320
+ /* Create frame wrap */
321
+ var args = {
322
+ 'element': 'div',
323
+ 'id': 'wcf-create-woo-product-wrap',
324
+ 'class': 'wcf-create-woo-product-wrap'
325
+ };
326
+
327
+ _create_html_element( args, 'wcf-create-woo-product-overlay' );
328
+
329
+ $( '#wcf-create-woo-product-overlay' ).addClass( 'open' );
330
+
331
+ /* Create Iframe */
332
+ var args = {
333
+ 'element' : 'iframe',
334
+ 'id' : 'wcf-create-woo-product-iframe',
335
+ 'class' : 'wcf-woo-product-iframe',
336
+ 'border' : 0,
337
+ 'transparency' : 'true',
338
+ 'src' : cartflows_admin.create_product_src,
339
+ };
340
+
341
+ _create_iframe_element( args, 'wcf-create-woo-product-wrap' );
342
+
343
+ $('body').addClass('wcf-create-woo-iframe-opened');
344
+ });
345
+ }
346
+
347
+ // Close iframe events function.
348
+ function wcf_close_create_woo_product_popup() {
349
+ $( document.body ).on( 'click', '#wcf-close-create-woo-product', function(){
350
+ if( $(this).hasClass('close-icon') && $('#wcf-create-woo-product-overlay').hasClass('open') ){
351
+
352
+ _destroy_create_woo_product_iframe();
353
+ }
354
+ } );
355
+
356
+ $( document.body ).on( 'click', '#wcf-create-woo-product-overlay', function(){
357
+ if( $('#wcf-create-woo-product-overlay').hasClass('open') ){
358
+
359
+ _destroy_create_woo_product_iframe();
360
+ }
361
+ } );
362
+ }
363
+
364
+ wcf_open_create_woo_product_popup();
365
 
366
+ wcf_close_create_woo_product_popup();
367
+ };
368
+
369
+ var wcf_show_upgrade_to_pro_popup = function(){
370
 
371
  $('.wcf-custom-add-new-button').click(function(){
372
  $('#cartflows-upgrade-notice-popup').show();
380
  $('#cartflows-upgrade-notice-popup').hide();
381
  $('#cartflows-upgrade-notice-overlay').hide();
382
  });
383
+ };
384
 
385
  /* Optin - hide/show login */
386
+ var wcf_optin_hide_show_init = function(){
387
 
388
  var wrapper = $('.wcf-optin-table');
389
 
416
  });
417
  }
418
  });
419
+ };
420
 
421
  $( document ).ready(function() {
422
 
439
  wcf_optin_hide_show_init();
440
 
441
  /* Other */
442
+ wcf_add_tool_tip_msg();
443
 
444
+ wcf_highlight_the_metabox();
445
 
446
  wcf_toggle_post_update();
447
+
448
+ wcf_show_upgrade_to_pro_popup();
449
+
450
+ /* Create woo product from iframe */
451
+ wcf_create_woo_product_from_iframe();
452
 
453
  });
454
 
admin/meta-assets/css/admin-edit-rtl.css CHANGED
@@ -91,6 +91,14 @@ body li.select2-results__option.select2-results__message {
91
  }
92
 
93
  /* Repeater Product Field */
 
 
 
 
 
 
 
 
94
  .wcf-repeatable-row {
95
  background: #f9f9f9;
96
  border: 1px solid #e5e5e5;
@@ -115,12 +123,12 @@ body li.select2-results__option.select2-results__message {
115
  .wcf-repeatable-row-setting-field {
116
  display: inline-block;
117
  }
118
- .wcf-repeatable-row-setting-label {
119
  width: 25%;
120
  }
121
  .wcf-repeatable-row-setting-field {
122
  width: 75%;
123
- }
124
 
125
  .wcf-repeatable-fields {
126
  margin-bottom: 10px;
@@ -133,6 +141,10 @@ body li.select2-results__option.select2-results__message {
133
  padding: 4px 0 0 4px !important;
134
  }
135
 
 
 
 
 
136
  .wcf-repeatable-remove {
137
  cursor: pointer;
138
  }
@@ -189,4 +201,5 @@ body li.select2-results__option.select2-results__message {
189
 
190
  .wcf-field-row .wcf-cpf-actions a {
191
  cursor: pointer;
192
- }
 
91
  }
92
 
93
  /* Repeater Product Field */
94
+ .wcf-product-repeater-field-row .wcf-field-row-content {
95
+ width: 100% !important;
96
+ }
97
+
98
+ .wcf-product-repeater-field-row .wcf-field-row-content {
99
+ width: 100%;
100
+ }
101
+
102
  .wcf-repeatable-row {
103
  background: #f9f9f9;
104
  border: 1px solid #e5e5e5;
123
  .wcf-repeatable-row-setting-field {
124
  display: inline-block;
125
  }
126
+ /*.wcf-repeatable-row-setting-label {
127
  width: 25%;
128
  }
129
  .wcf-repeatable-row-setting-field {
130
  width: 75%;
131
+ }*/
132
 
133
  .wcf-repeatable-fields {
134
  margin-bottom: 10px;
141
  padding: 4px 0 0 4px !important;
142
  }
143
 
144
+ .wcf-add-repeatable-wrap button.button-primary {
145
+ margin: 0 0 0 8px;
146
+ }
147
+
148
  .wcf-repeatable-remove {
149
  cursor: pointer;
150
  }
201
 
202
  .wcf-field-row .wcf-cpf-actions a {
203
  cursor: pointer;
204
+ }
205
+
admin/meta-assets/css/admin-edit.css CHANGED
@@ -91,6 +91,14 @@ body li.select2-results__option.select2-results__message {
91
  }
92
 
93
  /* Repeater Product Field */
 
 
 
 
 
 
 
 
94
  .wcf-repeatable-row {
95
  background: #f9f9f9;
96
  border: 1px solid #e5e5e5;
@@ -115,12 +123,12 @@ body li.select2-results__option.select2-results__message {
115
  .wcf-repeatable-row-setting-field {
116
  display: inline-block;
117
  }
118
- .wcf-repeatable-row-setting-label {
119
  width: 25%;
120
  }
121
  .wcf-repeatable-row-setting-field {
122
  width: 75%;
123
- }
124
 
125
  .wcf-repeatable-fields {
126
  margin-bottom: 10px;
@@ -133,6 +141,10 @@ body li.select2-results__option.select2-results__message {
133
  padding: 4px 4px 0 0 !important;
134
  }
135
 
 
 
 
 
136
  .wcf-repeatable-remove {
137
  cursor: pointer;
138
  }
@@ -189,4 +201,5 @@ body li.select2-results__option.select2-results__message {
189
 
190
  .wcf-field-row .wcf-cpf-actions a {
191
  cursor: pointer;
192
- }
 
91
  }
92
 
93
  /* Repeater Product Field */
94
+ .wcf-product-repeater-field-row .wcf-field-row-content {
95
+ width: 100% !important;
96
+ }
97
+
98
+ .wcf-product-repeater-field-row .wcf-field-row-content {
99
+ width: 100%;
100
+ }
101
+
102
  .wcf-repeatable-row {
103
  background: #f9f9f9;
104
  border: 1px solid #e5e5e5;
123
  .wcf-repeatable-row-setting-field {
124
  display: inline-block;
125
  }
126
+ /*.wcf-repeatable-row-setting-label {
127
  width: 25%;
128
  }
129
  .wcf-repeatable-row-setting-field {
130
  width: 75%;
131
+ }*/
132
 
133
  .wcf-repeatable-fields {
134
  margin-bottom: 10px;
141
  padding: 4px 4px 0 0 !important;
142
  }
143
 
144
+ .wcf-add-repeatable-wrap button.button-primary {
145
+ margin: 0 8px 0 0;
146
+ }
147
+
148
  .wcf-repeatable-remove {
149
  cursor: pointer;
150
  }
201
 
202
  .wcf-field-row .wcf-cpf-actions a {
203
  cursor: pointer;
204
+ }
205
+
admin/meta-assets/js/admin-edit.js CHANGED
@@ -630,13 +630,13 @@
630
 
631
  window.inputWrapper.find( '#wcf-image-preview' ).append('<img src="' + attachment.url + '" width="150" class="saved-image" style="margin-bottom:12px;" />');
632
 
633
- window.inputWrapper.find( '#wcf-image-value' ).val( attachment.url );
634
 
635
  // window.inputWrapper.find( '.wcf-image-id' ).val( attachment.id );
636
 
637
  // window.inputWrapper.find( '.wcf-image-value' ).val( attachment.url );
638
 
639
- $('.wcf-remove-image').show();
640
  });
641
 
642
  // Finally, open the modal
630
 
631
  window.inputWrapper.find( '#wcf-image-preview' ).append('<img src="' + attachment.url + '" width="150" class="saved-image" style="margin-bottom:12px;" />');
632
 
633
+ window.inputWrapper.find( '.wcf-image' ).val( attachment.url );
634
 
635
  // window.inputWrapper.find( '.wcf-image-id' ).val( attachment.id );
636
 
637
  // window.inputWrapper.find( '.wcf-image-value' ).val( attachment.url );
638
 
639
+ window.inputWrapper.find('.wcf-remove-image').show();
640
  });
641
 
642
  // Finally, open the modal
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.4.0
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.4.2
7
  * Author: CartFlows Inc
8
  * Author URI: https://cartflows.com/
9
  * Text Domain: cartflows
changelog.txt CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  Version 1.4.0 - Tuesday, 11th February 2020
2
  - New: Introduced a new optin step type for lead generation.
3
  - Improvement: Added compatibility for a future release of CartFlows Pro.
1
+ Version 1.4.2 - Wednesday, 19th February 2020
2
+ - New: Added option to change default order confirmations text on thank you page.
3
+ - New: Added ability to set optin step type as a home page.
4
+ - New: Create WooCommerce's product directly from the checkout step.
5
+ - Improvement: Optin step type is included in LearnDash LMS template settings.
6
+
7
+ Version 1.4.1 - Thursday, 13th February 2020
8
+ - Fix: Optin step was redirecting to the global checkout.
9
+
10
  Version 1.4.0 - Tuesday, 11th February 2020
11
  - New: Introduced a new optin step type for lead generation.
12
  - Improvement: Added compatibility for a future release of CartFlows Pro.
classes/class-cartflows-admin.php CHANGED
@@ -1,620 +1,620 @@
1
- <?php
2
- /**
3
- * CartFlows Admin.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Class Cartflows_Admin.
10
- */
11
- class Cartflows_Admin {
12
-
13
- /**
14
- * Calls on initialization
15
- *
16
- * @since 1.0.0
17
- */
18
- public static function init() {
19
-
20
- self::initialise_plugin();
21
- self::init_hooks();
22
- }
23
-
24
- /**
25
- * Init Hooks.
26
- *
27
- * @since 1.0.0
28
- * @return void
29
- */
30
- public static function init_hooks() {
31
-
32
- if ( ! is_admin() ) {
33
- return;
34
- }
35
-
36
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
37
-
38
- /*
39
- Add CARTFLOWS menu option to admin.
40
- add_action( 'network_admin_menu', __CLASS__ . '::menu' );
41
- */
42
- add_action( 'admin_menu', __CLASS__ . '::menu' );
43
- add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
44
-
45
- add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
46
-
47
- add_action( 'admin_init', __CLASS__ . '::settings_admin_scripts' );
48
-
49
- /* Global Addmin Script */
50
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
51
-
52
- add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
53
-
54
- /* Add lite version class to body */
55
- add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
56
-
57
- add_filter( 'plugin_action_links_' . CARTFLOWS_BASE, __CLASS__ . '::add_action_links' );
58
-
59
- add_action( 'admin_init', __CLASS__ . '::cartflows_after_save_permalinks' );
60
-
61
- }
62
-
63
- /**
64
- * After save of permalinks.
65
- */
66
- public static function cartflows_after_save_permalinks() {
67
-
68
- $has_saved_permalinks = get_option( 'cartflows_permalink_saved' );
69
- if ( $has_saved_permalinks ) {
70
- flush_rewrite_rules();
71
- delete_option( 'cartflows_permalink_saved' );
72
- }
73
- }
74
-
75
-
76
- /**
77
- * Initialize after Cartflows pro get loaded.
78
- */
79
- public static function settings_admin_scripts() {
80
- // Enqueue admin scripts.
81
- if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS === $_REQUEST['page'] ) { //phpcs:ignore
82
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
83
-
84
- self::save_settings();
85
- }
86
- }
87
- /**
88
- * Show action on plugin page.
89
- *
90
- * @param array $links links.
91
- * @return array
92
- */
93
- public static function add_action_links( $links ) {
94
- $mylinks = array(
95
- '<a href="' . admin_url( 'admin.php?page=' . CARTFLOWS_SETTINGS ) . '">Settings</a>',
96
- '<a target="_blank" href="' . esc_url( 'https://cartflows.com/docs' ) . '">Docs</a>',
97
- );
98
-
99
- if ( ! _is_cartflows_pro() ) {
100
- array_push( $mylinks, '<a style="color: #39b54a; font-weight: bold;" target="_blank" href="' . esc_url( 'https://cartflows.com/pricing/' ) . '"> Go Pro </a>' );
101
- }
102
-
103
- return array_merge( $links, $mylinks );
104
- }
105
-
106
- /**
107
- * Initialises the Plugin Name.
108
- *
109
- * @since 1.0.0
110
- * @return void
111
- */
112
- public static function initialise_plugin() {
113
-
114
- $name = 'Cartflows';
115
- $short_name = 'Cflows';
116
-
117
- define( 'CARTFLOWS_PLUGIN_NAME', $name );
118
- define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
119
- }
120
-
121
- /**
122
- * Renders the admin settings menu.
123
- *
124
- * @since 1.0.0
125
- * @return void
126
- */
127
- public static function menu() {
128
-
129
- if ( ! current_user_can( 'manage_options' ) ) {
130
- return;
131
- }
132
-
133
- add_menu_page(
134
- 'CartFlows',
135
- 'CartFlows',
136
- 'manage_options',
137
- CARTFLOWS_SLUG,
138
- __CLASS__ . '::render',
139
- 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),//phpcs:ignore
140
- 39.7
141
- );
142
-
143
- }
144
-
145
- /**
146
- * Add submenu to admin menu.
147
- *
148
- * @since 1.0.0
149
- */
150
- public static function submenu() {
151
-
152
- $parent_slug = CARTFLOWS_SLUG;
153
- $page_title = __( 'Settings', 'cartflows' );
154
- $menu_title = __( 'Settings', 'cartflows' );
155
- $capability = 'manage_options';
156
- $menu_slug = 'cartflows_settings';
157
- $callback = __CLASS__ . '::render';
158
-
159
- add_submenu_page(
160
- $parent_slug,
161
- $page_title,
162
- $menu_title,
163
- $capability,
164
- $menu_slug,
165
- $callback
166
- );
167
- }
168
-
169
- /**
170
- * Renders the admin settings.
171
- *
172
- * @since 1.0.0
173
- * @return void
174
- */
175
- public static function render() {
176
- $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; //phpcs:ignore
177
- $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
178
- $action = str_replace( '_', '-', $action );
179
-
180
- // Enable header icon filter below.
181
- $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
182
-
183
- include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
184
- }
185
-
186
- /**
187
- * Renders the admin settings content.
188
- *
189
- * @since 1.0.0
190
- * @return void
191
- */
192
- public static function render_content() {
193
-
194
- $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; //phpcs:ignore
195
- $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
196
- $action = str_replace( '_', '-', $action );
197
- $action = 'general';
198
-
199
- $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
200
-
201
- include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
202
- }
203
-
204
- /**
205
- * Save Global Setting options.
206
- *
207
- * @since 1.0.0
208
- */
209
- public static function save_common_settings() {
210
-
211
- if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-common-settings-nonce'] ) ), 'cartflows-common-settings' ) ) {
212
-
213
- $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
214
- $new_settings = array();
215
-
216
- if ( isset( $_POST['_cartflows_common'] ) ) {
217
- // Loop through the input and sanitize each of the values.
218
- $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_common'] ) ); //phpcs:ignore
219
- }
220
-
221
- Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, false );
222
-
223
- $query = array(
224
- 'message' => 'saved',
225
- );
226
-
227
- $redirect_to = add_query_arg( $query, $url );
228
-
229
- wp_safe_redirect( $redirect_to );
230
- exit;
231
- } // End if statement.
232
- }
233
-
234
- /**
235
- * Save Debug Setting options.
236
- *
237
- * @since 1.1.14
238
- */
239
- public static function save_debug_settings() {
240
-
241
- if ( isset( $_POST['cartflows-debug-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-debug-settings-nonce'] ) ), 'cartflows-debug-settings' ) ) {
242
-
243
- $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
244
- $new_settings = array();
245
-
246
- if ( isset( $_POST['_cartflows_debug_data'] ) ) {
247
- $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_debug_data'] ) ); //phpcs:ignore
248
- }
249
-
250
- Cartflows_Helper::update_admin_settings_option( '_cartflows_debug_data', $new_settings, false );
251
-
252
- $query = array(
253
- 'message' => 'saved',
254
- );
255
-
256
- $redirect_to = add_query_arg( $query, $url );
257
-
258
- wp_safe_redirect( $redirect_to );
259
- exit;
260
-
261
- }
262
- }
263
-
264
-
265
- /**
266
- * Save permalink Setting options.
267
- *
268
- * @since 1.1.14
269
- */
270
- public static function save_permalink_settings() {
271
-
272
- if ( isset( $_POST['cartflows-permalink-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-permalink-settings-nonce'] ) ), 'cartflows-permalink-settings' ) ) {
273
-
274
- $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
275
- $new_settings = array();
276
-
277
- if ( isset( $_POST['reset'] ) ) {
278
- $_POST['_cartflows_permalink'] = array(
279
- 'permalink' => CARTFLOWS_STEP_POST_TYPE,
280
- 'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE,
281
- 'permalink_structure' => '',
282
- );
283
-
284
- }
285
-
286
- if ( isset( $_POST['_cartflows_permalink'] ) ) {
287
- $cartflows_permalink_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_permalink'] ) ); //phpcs:ignore
288
-
289
- if ( empty( $cartflows_permalink_settings['permalink'] ) ) {
290
- $new_settings['permalink'] = CARTFLOWS_STEP_POST_TYPE;
291
- } else {
292
- $new_settings['permalink'] = $cartflows_permalink_settings['permalink'];
293
- }
294
-
295
- if ( empty( $cartflows_permalink_settings['permalink_flow_base'] ) ) {
296
- $new_settings['permalink_flow_base'] = CARTFLOWS_FLOW_POST_TYPE;
297
- } else {
298
- $new_settings['permalink_flow_base'] = $cartflows_permalink_settings['permalink_flow_base'];
299
- }
300
-
301
- $new_settings['permalink_structure'] = $cartflows_permalink_settings['permalink_structure'];
302
-
303
- }
304
-
305
- Cartflows_Helper::update_admin_settings_option( '_cartflows_permalink', $new_settings, false );
306
-
307
- $query = array(
308
- 'message' => 'saved',
309
- );
310
-
311
- $redirect_to = add_query_arg( $query, $url );
312
-
313
- update_option( 'cartflows_permalink_saved', true );
314
-
315
- wp_safe_redirect( $redirect_to );
316
- exit;
317
-
318
- }
319
- }
320
-
321
- /**
322
- * Loop through the input and sanitize each of the values.
323
- *
324
- * @param array $input_settings input settings.
325
- * @return array
326
- */
327
- public static function sanitize_form_inputs( $input_settings = array() ) {
328
- $new_settings = array();
329
- foreach ( $input_settings as $key => $val ) {
330
-
331
- if ( is_array( $val ) ) {
332
- foreach ( $val as $k => $v ) {
333
- $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
334
- }
335
- } else {
336
- $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
337
- }
338
- }
339
- return $new_settings;
340
- }
341
-
342
- /**
343
- * Check is cartflows admin.
344
- *
345
- * @since 1.0.0
346
- * @return boolean
347
- */
348
- public static function is_global_admin() {
349
-
350
- $current_screen = get_current_screen();
351
-
352
- if (
353
- is_object( $current_screen ) &&
354
- isset( $current_screen->post_type ) &&
355
- ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
356
- CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
357
- )
358
- ) {
359
- return true;
360
- }
361
- return false;
362
- }
363
-
364
- /**
365
- * Check is flow admin.
366
- *
367
- * @since 1.0.0
368
- * @return boolean
369
- */
370
- public static function is_flow_edit_admin() {
371
-
372
- $current_screen = get_current_screen();
373
-
374
- if (
375
- is_object( $current_screen ) &&
376
- isset( $current_screen->post_type ) &&
377
- ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
378
- isset( $current_screen->base ) &&
379
- ( 'post' === $current_screen->base )
380
- ) {
381
- return true;
382
- }
383
- return false;
384
- }
385
-
386
- /**
387
- * Global Admin Scripts.
388
- *
389
- * @since 1.0.0
390
- */
391
- public static function global_admin_scripts() {
392
-
393
- $installed_plugins = get_plugins();
394
- $is_wc_installed = isset( $installed_plugins['woocommerce/woocommerce.php'] ) ? true : false;
395
- $edit_test_mode = filter_input( INPUT_GET, 'edit_test_mode', FILTER_SANITIZE_STRING );
396
- $edit_test_mode = 'yes' === $edit_test_mode ? true : false;
397
-
398
- $localize = array(
399
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
400
- 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
401
- 'wc_status' => array(
402
- 'installed' => $is_wc_installed,
403
- 'active' => wcf()->is_woo_active,
404
- ),
405
- 'wc_activating_message' => __( 'Installing and activating..', 'cartflows' ),
406
- 'wc_install_error' => __( 'There was an error with the installation of plugin.', 'cartflows' ),
407
- 'wcf_edit_test_mode' => $edit_test_mode,
408
- );
409
-
410
- wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
411
-
412
- if ( self::is_global_admin() ) {
413
-
414
- // Styles.
415
- wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
416
- wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
417
-
418
- wp_enqueue_script(
419
- 'wcf-global-admin',
420
- CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
421
- array( 'jquery' ),
422
- CARTFLOWS_VER,
423
- true
424
- );
425
-
426
- do_action( 'cartflows_global_admin_scripts' );
427
- }
428
- }
429
-
430
- /**
431
- * Global Admin Data.
432
- *
433
- * @since 1.0.0
434
- */
435
- public static function global_admin_data() {
436
-
437
- $current_screen = get_current_screen();
438
-
439
- if ( ! $current_screen ) {
440
- return;
441
- }
442
-
443
- if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
444
- return;
445
- }
446
-
447
- $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
448
- ?>
449
-
450
- <div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
451
- <div class="wcf-templates-popup-content">
452
- <div class="spinner"></div>
453
- <div class="wcf-templates-wrap wcf-templates-wrap-flows">
454
-
455
- <div id="wcf-remote-flow-actions" class="wcf-template-header">
456
- <div class="wcf-template-logo-wrap">
457
- <span class="wcf-cartflows-logo-img">
458
- <span class="cartflows-logo-icon"></span>
459
- </span>
460
- <span class="wcf-cartflows-title"><?php esc_html_e( 'Flows Library', 'cartflows' ); ?></span>
461
- </div>
462
- <div class="wcf-tab-wrapper">
463
- <?php if ( 'other' !== $default_page_builder ) { ?>
464
- <div id="wcf-get-started-steps">
465
- <ul class="filter-links ">
466
- <li>
467
- <a href="#" class="current" data-slug="ready-templates" data-title="<?php esc_html_e( 'Ready Templates', 'cartflows' ); ?>"><?php esc_html_e( 'Ready Templates', 'cartflows' ); ?></a>
468
- </li>
469
- <li>
470
- <a href="#" data-slug="canvas" data-title="<?php esc_html_e( 'Create Your Own', 'cartflows' ); ?>"><?php esc_html_e( 'Create Your Own', 'cartflows' ); ?></a>
471
- </li>
472
- </ul>
473
- </div>
474
- <?php } ?>
475
- </div>
476
- <div class="wcf-popup-close-wrap">
477
- <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
478
- </div>
479
- </div>
480
- <!-- <div class="wcf-search-form">
481
- <label class="screen-reader-text" for="wp-filter-search-input"><?php esc_html_e( 'Search Sites', 'cartflows' ); ?> </label>
482
- <input placeholder="<?php esc_html_e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
483
- </div> -->
484
-
485
- <div id="wcf-remote-content">
486
- <?php if ( 'other' !== $default_page_builder ) { ?>
487
- <div id="wcf-ready-templates">
488
- <div id="wcf-remote-filters">
489
- <div id="wcf-page-builders"></div>
490
- <div id="wcf-categories"></div>
491
- </div>
492
- <div class="wcf-page-builder-notice"></div>
493
- <div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
494
- <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
495
- </div>
496
- <?php } ?>
497
- <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
498
- <div class="inner">
499
- <a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php esc_html_e( 'Design Your Flow', 'cartflows' ); ?></a>
500
- <p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php esc_html_e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
501
- </div>
502
- </div>
503
- </div>
504
- </div>
505
- </div>
506
- </div>
507
-
508
- <?php
509
- }
510
-
511
- /**
512
- * Enqueues the needed CSS/JS for the builder's admin settings page.
513
- *
514
- * @since 1.0.0
515
- */
516
- public static function styles_scripts() {
517
-
518
- // Styles.
519
- wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
520
- wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
521
-
522
- // Script.
523
- wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER, false );
524
-
525
- $localize = array(
526
- 'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
527
- );
528
-
529
- wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
530
-
531
- do_action( 'cartflows_admin_settings_after_enqueue_scripts' );
532
- }
533
-
534
- /**
535
- * Save All admin settings here
536
- */
537
- public static function save_settings() {
538
-
539
- // Only admins can save settings.
540
- if ( ! current_user_can( 'manage_options' ) ) {
541
- return;
542
- }
543
-
544
- self::save_common_settings();
545
- self::save_debug_settings();
546
- self::save_permalink_settings();
547
- self::save_facebook_settings();
548
-
549
- // Let extensions hook into saving.
550
- do_action( 'cartflows_admin_settings_save' );
551
- }
552
-
553
- /**
554
- * Get and return page URL
555
- *
556
- * @param string $menu_slug Menu name.
557
- * @since 1.0.0
558
- * @return string page url
559
- */
560
- public static function get_page_url( $menu_slug ) {
561
-
562
- $parent_page = self::$default_menu_position;
563
-
564
- if ( strpos( $parent_page, '?' ) !== false ) {
565
- $query_var = '&page=' . self::$plugin_slug;
566
- } else {
567
- $query_var = '?page=' . self::$plugin_slug;
568
- }
569
-
570
- $parent_page_url = admin_url( $parent_page . $query_var );
571
-
572
- $url = $parent_page_url . '&action=' . $menu_slug;
573
-
574
- return esc_url( $url );
575
- }
576
-
577
- /**
578
- * Admin body classes.
579
- *
580
- * Body classes to be added to <body> tag in admin page
581
- *
582
- * @param String $classes body classes returned from the filter.
583
- * @return String body classes to be added to <body> tag in admin page
584
- */
585
- public static function add_admin_body_class( $classes ) {
586
-
587
- $classes .= ' cartflows-' . CARTFLOWS_VER;
588
-
589
- return $classes;
590
- }
591
-
592
- /**
593
- * Save Global Setting options.
594
- *
595
- * @since 1.0.0
596
- */
597
- public static function save_facebook_settings() {
598
-
599
- if ( isset( $_POST['cartflows-facebook-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-facebook-settings-nonce'] ) ), 'cartflows-facebook-settings' ) ) {
600
-
601
- $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
602
- $new_settings = array();
603
-
604
- if ( isset( $_POST['_cartflows_facebook'] ) ) {
605
- $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_facebook'] ) ); //phpcs:ignore
606
- }
607
-
608
- Cartflows_Helper::update_admin_settings_option( '_cartflows_facebook', $new_settings, false );
609
- $query = array(
610
- 'message' => 'saved',
611
- );
612
- $redirect_to = add_query_arg( $query, $url );
613
- wp_safe_redirect( $redirect_to );
614
- exit;
615
- }
616
- }
617
-
618
- }
619
-
620
- Cartflows_Admin::init();
1
+ <?php
2
+ /**
3
+ * CartFlows Admin.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Class Cartflows_Admin.
10
+ */
11
+ class Cartflows_Admin {
12
+
13
+ /**
14
+ * Calls on initialization
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ public static function init() {
19
+
20
+ self::initialise_plugin();
21
+ self::init_hooks();
22
+ }
23
+
24
+ /**
25
+ * Init Hooks.
26
+ *
27
+ * @since 1.0.0
28
+ * @return void
29
+ */
30
+ public static function init_hooks() {
31
+
32
+ if ( ! is_admin() ) {
33
+ return;
34
+ }
35
+
36
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
37
+
38
+ /*
39
+ Add CARTFLOWS menu option to admin.
40
+ add_action( 'network_admin_menu', __CLASS__ . '::menu' );
41
+ */
42
+ add_action( 'admin_menu', __CLASS__ . '::menu' );
43
+ add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
44
+
45
+ add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
46
+
47
+ add_action( 'admin_init', __CLASS__ . '::settings_admin_scripts' );
48
+
49
+ /* Global Addmin Script */
50
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
51
+
52
+ add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
53
+
54
+ /* Add lite version class to body */
55
+ add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
56
+
57
+ add_filter( 'plugin_action_links_' . CARTFLOWS_BASE, __CLASS__ . '::add_action_links' );
58
+
59
+ add_action( 'admin_init', __CLASS__ . '::cartflows_after_save_permalinks' );
60
+
61
+ }
62
+
63
+ /**
64
+ * After save of permalinks.
65
+ */
66
+ public static function cartflows_after_save_permalinks() {
67
+
68
+ $has_saved_permalinks = get_option( 'cartflows_permalink_saved' );
69
+ if ( $has_saved_permalinks ) {
70
+ flush_rewrite_rules();
71
+ delete_option( 'cartflows_permalink_saved' );
72
+ }
73
+ }
74
+
75
+
76
+ /**
77
+ * Initialize after Cartflows pro get loaded.
78
+ */
79
+ public static function settings_admin_scripts() {
80
+ // Enqueue admin scripts.
81
+ if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS === $_REQUEST['page'] ) { //phpcs:ignore
82
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
83
+
84
+ self::save_settings();
85
+ }
86
+ }
87
+ /**
88
+ * Show action on plugin page.
89
+ *
90
+ * @param array $links links.
91
+ * @return array
92
+ */
93
+ public static function add_action_links( $links ) {
94
+ $mylinks = array(
95
+ '<a href="' . admin_url( 'admin.php?page=' . CARTFLOWS_SETTINGS ) . '">Settings</a>',
96
+ '<a target="_blank" href="' . esc_url( 'https://cartflows.com/docs' ) . '">Docs</a>',
97
+ );
98
+
99
+ if ( ! _is_cartflows_pro() ) {
100
+ array_push( $mylinks, '<a style="color: #39b54a; font-weight: bold;" target="_blank" href="' . esc_url( 'https://cartflows.com/pricing/' ) . '"> Go Pro </a>' );
101
+ }
102
+
103
+ return array_merge( $links, $mylinks );
104
+ }
105
+
106
+ /**
107
+ * Initialises the Plugin Name.
108
+ *
109
+ * @since 1.0.0
110
+ * @return void
111
+ */
112
+ public static function initialise_plugin() {
113
+
114
+ $name = 'Cartflows';
115
+ $short_name = 'Cflows';
116
+
117
+ define( 'CARTFLOWS_PLUGIN_NAME', $name );
118
+ define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
119
+ }
120
+
121
+ /**
122
+ * Renders the admin settings menu.
123
+ *
124
+ * @since 1.0.0
125
+ * @return void
126
+ */
127
+ public static function menu() {
128
+
129
+ if ( ! current_user_can( 'manage_options' ) ) {
130
+ return;
131
+ }
132
+
133
+ add_menu_page(
134
+ 'CartFlows',
135
+ 'CartFlows',
136
+ 'manage_options',
137
+ CARTFLOWS_SLUG,
138
+ __CLASS__ . '::render',
139
+ 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),//phpcs:ignore
140
+ 39.7
141
+ );
142
+
143
+ }
144
+
145
+ /**
146
+ * Add submenu to admin menu.
147
+ *
148
+ * @since 1.0.0
149
+ */
150
+ public static function submenu() {
151
+
152
+ $parent_slug = CARTFLOWS_SLUG;
153
+ $page_title = __( 'Settings', 'cartflows' );
154
+ $menu_title = __( 'Settings', 'cartflows' );
155
+ $capability = 'manage_options';
156
+ $menu_slug = 'cartflows_settings';
157
+ $callback = __CLASS__ . '::render';
158
+
159
+ add_submenu_page(
160
+ $parent_slug,
161
+ $page_title,
162
+ $menu_title,
163
+ $capability,
164
+ $menu_slug,
165
+ $callback
166
+ );
167
+ }
168
+
169
+ /**
170
+ * Renders the admin settings.
171
+ *
172
+ * @since 1.0.0
173
+ * @return void
174
+ */
175
+ public static function render() {
176
+ $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; //phpcs:ignore
177
+ $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
178
+ $action = str_replace( '_', '-', $action );
179
+
180
+ // Enable header icon filter below.
181
+ $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
182
+
183
+ include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
184
+ }
185
+
186
+ /**
187
+ * Renders the admin settings content.
188
+ *
189
+ * @since 1.0.0
190
+ * @return void
191
+ */
192
+ public static function render_content() {
193
+
194
+ $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; //phpcs:ignore
195
+ $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
196
+ $action = str_replace( '_', '-', $action );
197
+ $action = 'general';
198
+
199
+ $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
200
+
201
+ include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
202
+ }
203
+
204
+ /**
205
+ * Save Global Setting options.
206
+ *
207
+ * @since 1.0.0
208
+ */
209
+ public static function save_common_settings() {
210
+
211
+ if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-common-settings-nonce'] ) ), 'cartflows-common-settings' ) ) {
212
+
213
+ $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
214
+ $new_settings = array();
215
+
216
+ if ( isset( $_POST['_cartflows_common'] ) ) {
217
+ // Loop through the input and sanitize each of the values.
218
+ $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_common'] ) ); //phpcs:ignore
219
+ }
220
+
221
+ Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, false );
222
+
223
+ $query = array(
224
+ 'message' => 'saved',
225
+ );
226
+
227
+ $redirect_to = add_query_arg( $query, $url );
228
+
229
+ wp_safe_redirect( $redirect_to );
230
+ exit;
231
+ } // End if statement.
232
+ }
233
+
234
+ /**
235
+ * Save Debug Setting options.
236
+ *
237
+ * @since 1.1.14
238
+ */
239
+ public static function save_debug_settings() {
240
+
241
+ if ( isset( $_POST['cartflows-debug-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-debug-settings-nonce'] ) ), 'cartflows-debug-settings' ) ) {
242
+
243
+ $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
244
+ $new_settings = array();
245
+
246
+ if ( isset( $_POST['_cartflows_debug_data'] ) ) {
247
+ $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_debug_data'] ) ); //phpcs:ignore
248
+ }
249
+
250
+ Cartflows_Helper::update_admin_settings_option( '_cartflows_debug_data', $new_settings, false );
251
+
252
+ $query = array(
253
+ 'message' => 'saved',
254
+ );
255
+
256
+ $redirect_to = add_query_arg( $query, $url );
257
+
258
+ wp_safe_redirect( $redirect_to );
259
+ exit;
260
+
261
+ }
262
+ }
263
+
264
+
265
+ /**
266
+ * Save permalink Setting options.
267
+ *
268
+ * @since 1.1.14
269
+ */
270
+ public static function save_permalink_settings() {
271
+
272
+ if ( isset( $_POST['cartflows-permalink-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-permalink-settings-nonce'] ) ), 'cartflows-permalink-settings' ) ) {
273
+
274
+ $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
275
+ $new_settings = array();
276
+
277
+ if ( isset( $_POST['reset'] ) ) {
278
+ $_POST['_cartflows_permalink'] = array(
279
+ 'permalink' => CARTFLOWS_STEP_POST_TYPE,
280
+ 'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE,
281
+ 'permalink_structure' => '',
282
+ );
283
+
284
+ }
285
+
286
+ if ( isset( $_POST['_cartflows_permalink'] ) ) {
287
+ $cartflows_permalink_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_permalink'] ) ); //phpcs:ignore
288
+
289
+ if ( empty( $cartflows_permalink_settings['permalink'] ) ) {
290
+ $new_settings['permalink'] = CARTFLOWS_STEP_POST_TYPE;
291
+ } else {
292
+ $new_settings['permalink'] = $cartflows_permalink_settings['permalink'];
293
+ }
294
+
295
+ if ( empty( $cartflows_permalink_settings['permalink_flow_base'] ) ) {
296
+ $new_settings['permalink_flow_base'] = CARTFLOWS_FLOW_POST_TYPE;
297
+ } else {
298
+ $new_settings['permalink_flow_base'] = $cartflows_permalink_settings['permalink_flow_base'];
299
+ }
300
+
301
+ $new_settings['permalink_structure'] = $cartflows_permalink_settings['permalink_structure'];
302
+
303
+ }
304
+
305
+ Cartflows_Helper::update_admin_settings_option( '_cartflows_permalink', $new_settings, false );
306
+
307
+ $query = array(
308
+ 'message' => 'saved',
309
+ );
310
+
311
+ $redirect_to = add_query_arg( $query, $url );
312
+
313
+ update_option( 'cartflows_permalink_saved', true );
314
+
315
+ wp_safe_redirect( $redirect_to );
316
+ exit;
317
+
318
+ }
319
+ }
320
+
321
+ /**
322
+ * Loop through the input and sanitize each of the values.
323
+ *
324
+ * @param array $input_settings input settings.
325
+ * @return array
326
+ */
327
+ public static function sanitize_form_inputs( $input_settings = array() ) {
328
+ $new_settings = array();
329
+ foreach ( $input_settings as $key => $val ) {
330
+
331
+ if ( is_array( $val ) ) {
332
+ foreach ( $val as $k => $v ) {
333
+ $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
334
+ }
335
+ } else {
336
+ $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
337
+ }
338
+ }
339
+ return $new_settings;
340
+ }
341
+
342
+ /**
343
+ * Check is cartflows admin.
344
+ *
345
+ * @since 1.0.0
346
+ * @return boolean
347
+ */
348
+ public static function is_global_admin() {
349
+
350
+ $current_screen = get_current_screen();
351
+
352
+ if (
353
+ is_object( $current_screen ) &&
354
+ isset( $current_screen->post_type ) &&
355
+ ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
356
+ CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
357
+ )
358
+ ) {
359
+ return true;
360
+ }
361
+ return false;
362
+ }
363
+
364
+ /**
365
+ * Check is flow admin.
366
+ *
367
+ * @since 1.0.0
368
+ * @return boolean
369
+ */
370
+ public static function is_flow_edit_admin() {
371
+
372
+ $current_screen = get_current_screen();
373
+
374
+ if (
375
+ is_object( $current_screen ) &&
376
+ isset( $current_screen->post_type ) &&
377
+ ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
378
+ isset( $current_screen->base ) &&
379
+ ( 'post' === $current_screen->base )
380
+ ) {
381
+ return true;
382
+ }
383
+ return false;
384
+ }
385
+
386
+ /**
387
+ * Global Admin Scripts.
388
+ *
389
+ * @since 1.0.0
390
+ */
391
+ public static function global_admin_scripts() {
392
+
393
+ $installed_plugins = get_plugins();
394
+ $is_wc_installed = isset( $installed_plugins['woocommerce/woocommerce.php'] ) ? true : false;
395
+ $edit_test_mode = filter_input( INPUT_GET, 'edit_test_mode', FILTER_SANITIZE_STRING );
396
+ $edit_test_mode = 'yes' === $edit_test_mode ? true : false;
397
+
398
+ $localize = array(
399
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
400
+ 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
401
+ 'wc_status' => array(
402
+ 'installed' => $is_wc_installed,
403
+ 'active' => wcf()->is_woo_active,
404
+ ),
405
+ 'wc_activating_message' => __( 'Installing and activating..', 'cartflows' ),
406
+ 'wc_install_error' => __( 'There was an error with the installation of plugin.', 'cartflows' ),
407
+ 'wcf_edit_test_mode' => $edit_test_mode,
408
+ );
409
+
410
+ wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
411
+
412
+ if ( self::is_global_admin() ) {
413
+
414
+ // Styles.
415
+ wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
416
+ wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
417
+
418
+ wp_enqueue_script(
419
+ 'wcf-global-admin',
420
+ CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
421
+ array( 'jquery' ),
422
+ CARTFLOWS_VER,
423
+ true
424
+ );
425
+
426
+ do_action( 'cartflows_global_admin_scripts' );
427
+ }
428
+ }
429
+
430
+ /**
431
+ * Global Admin Data.
432
+ *
433
+ * @since 1.0.0
434
+ */
435
+ public static function global_admin_data() {
436
+
437
+ $current_screen = get_current_screen();
438
+
439
+ if ( ! $current_screen ) {
440
+ return;
441
+ }
442
+
443
+ if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
444
+ return;
445
+ }
446
+
447
+ $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
448
+ ?>
449
+
450
+ <div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
451
+ <div class="wcf-templates-popup-content">
452
+ <div class="spinner"></div>
453
+ <div class="wcf-templates-wrap wcf-templates-wrap-flows">
454
+
455
+ <div id="wcf-remote-flow-actions" class="wcf-template-header">
456
+ <div class="wcf-template-logo-wrap">
457
+ <span class="wcf-cartflows-logo-img">
458
+ <span class="cartflows-logo-icon"></span>
459
+ </span>
460
+ <span class="wcf-cartflows-title"><?php esc_html_e( 'Flows Library', 'cartflows' ); ?></span>
461
+ </div>
462
+ <div class="wcf-tab-wrapper">
463
+ <?php if ( 'other' !== $default_page_builder ) { ?>
464
+ <div id="wcf-get-started-steps">
465
+ <ul class="filter-links ">
466
+ <li>
467
+ <a href="#" class="current" data-slug="ready-templates" data-title="<?php esc_html_e( 'Ready Templates', 'cartflows' ); ?>"><?php esc_html_e( 'Ready Templates', 'cartflows' ); ?></a>
468
+ </li>
469
+ <li>
470
+ <a href="#" data-slug="canvas" data-title="<?php esc_html_e( 'Create Your Own', 'cartflows' ); ?>"><?php esc_html_e( 'Create Your Own', 'cartflows' ); ?></a>
471
+ </li>
472
+ </ul>
473
+ </div>
474
+ <?php } ?>
475
+ </div>
476
+ <div class="wcf-popup-close-wrap">
477
+ <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
478
+ </div>
479
+ </div>
480
+ <!-- <div class="wcf-search-form">
481
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php esc_html_e( 'Search Sites', 'cartflows' ); ?> </label>
482
+ <input placeholder="<?php esc_html_e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
483
+ </div> -->
484
+
485
+ <div id="wcf-remote-content">
486
+ <?php if ( 'other' !== $default_page_builder ) { ?>
487
+ <div id="wcf-ready-templates">
488
+ <div id="wcf-remote-filters">
489
+ <div id="wcf-page-builders"></div>
490
+ <div id="wcf-categories"></div>
491
+ </div>
492
+ <div class="wcf-page-builder-notice"></div>
493
+ <div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
494
+ <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
495
+ </div>
496
+ <?php } ?>
497
+ <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
498
+ <div class="inner">
499
+ <a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php esc_html_e( 'Design Your Flow', 'cartflows' ); ?></a>
500
+ <p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php esc_html_e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
501
+ </div>
502
+ </div>
503
+ </div>
504
+ </div>
505
+ </div>
506
+ </div>
507
+
508
+ <?php
509
+ }
510
+
511
+ /**
512
+ * Enqueues the needed CSS/JS for the builder's admin settings page.
513
+ *
514
+ * @since 1.0.0
515
+ */
516
+ public static function styles_scripts() {
517
+
518
+ // Styles.
519
+ wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
520
+ wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
521
+
522
+ // Script.
523
+ wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER, false );
524
+
525
+ $localize = array(
526
+ 'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
527
+ );
528
+
529
+ wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
530
+
531
+ do_action( 'cartflows_admin_settings_after_enqueue_scripts' );
532
+ }
533
+
534
+ /**
535
+ * Save All admin settings here
536
+ */
537
+ public static function save_settings() {
538
+
539
+ // Only admins can save settings.
540
+ if ( ! current_user_can( 'manage_options' ) ) {
541
+ return;
542
+ }
543
+
544
+ self::save_common_settings();
545
+ self::save_debug_settings();
546
+ self::save_permalink_settings();
547
+ self::save_facebook_settings();
548
+
549
+ // Let extensions hook into saving.
550
+ do_action( 'cartflows_admin_settings_save' );
551
+ }
552
+
553
+ /**
554
+ * Get and return page URL
555
+ *
556
+ * @param string $menu_slug Menu name.
557
+ * @since 1.0.0
558
+ * @return string page url
559
+ */
560
+ public static function get_page_url( $menu_slug ) {
561
+
562
+ $parent_page = self::$default_menu_position;
563
+
564
+ if ( strpos( $parent_page, '?' ) !== false ) {
565
+ $query_var = '&page=' . self::$plugin_slug;
566
+ } else {
567
+ $query_var = '?page=' . self::$plugin_slug;
568
+ }
569
+
570
+ $parent_page_url = admin_url( $parent_page . $query_var );
571
+
572
+ $url = $parent_page_url . '&action=' . $menu_slug;
573
+
574
+ return esc_url( $url );
575
+ }
576
+
577
+ /**
578
+ * Admin body classes.
579
+ *
580
+ * Body classes to be added to <body> tag in admin page
581
+ *
582
+ * @param String $classes body classes returned from the filter.
583
+ * @return String body classes to be added to <body> tag in admin page
584
+ */
585
+ public static function add_admin_body_class( $classes ) {
586
+
587
+ $classes .= ' cartflows-' . CARTFLOWS_VER;
588
+
589
+ return $classes;
590
+ }
591
+
592
+ /**
593
+ * Save Global Setting options.
594
+ *
595
+ * @since 1.0.0
596
+ */
597
+ public static function save_facebook_settings() {
598
+
599
+ if ( isset( $_POST['cartflows-facebook-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-facebook-settings-nonce'] ) ), 'cartflows-facebook-settings' ) ) {
600
+
601
+ $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
602
+ $new_settings = array();
603
+
604
+ if ( isset( $_POST['_cartflows_facebook'] ) ) {
605
+ $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_facebook'] ) ); //phpcs:ignore
606
+ }
607
+
608
+ Cartflows_Helper::update_admin_settings_option( '_cartflows_facebook', $new_settings, false );
609
+ $query = array(
610
+ 'message' => 'saved',
611
+ );
612
+ $redirect_to = add_query_arg( $query, $url );
613
+ wp_safe_redirect( $redirect_to );
614
+ exit;
615
+ }
616
+ }
617
+
618
+ }
619
+
620
+ Cartflows_Admin::init();
classes/class-cartflows-default-meta.php CHANGED
@@ -124,7 +124,7 @@ class Cartflows_Default_Meta {
124
  ),
125
  'wcf-checkout-place-order-button-text' => array(
126
  'default' => '',
127
- 'sanitize' => 'FILTER_DEFAULT',
128
  ),
129
  'wcf-base-font-weight' => array(
130
  'default' => '',
@@ -555,6 +555,10 @@ class Cartflows_Default_Meta {
555
  'default' => '',
556
  'sanitize' => 'FILTER_SANITIZE_URL',
557
  ),
 
 
 
 
558
  'wcf-custom-script' => array(
559
  'default' => '',
560
  'sanitize' => 'FILTER_DEFAULT',
124
  ),
125
  'wcf-checkout-place-order-button-text' => array(
126
  'default' => '',
127
+ 'sanitize' => 'FILTER_SANITIZE_STRING',
128
  ),
129
  'wcf-base-font-weight' => array(
130
  'default' => '',
555
  'default' => '',
556
  'sanitize' => 'FILTER_SANITIZE_URL',
557
  ),
558
+ 'wcf-tq-text' => array(
559
+ 'default' => '',
560
+ 'sanitize' => 'FILTER_DEFAULT',
561
+ ),
562
  'wcf-custom-script' => array(
563
  'default' => '',
564
  'sanitize' => 'FILTER_DEFAULT',
classes/class-cartflows-flow-frontend.php CHANGED
@@ -1,247 +1,247 @@
1
- <?php
2
- /**
3
- * Frontend & Markup
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Flow Markup
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Flow_Frontend {
14
-
15
-
16
- /**
17
- * Member Variable
18
- *
19
- * @var object instance
20
- */
21
- private static $instance;
22
-
23
- /**
24
- * Initiator
25
- */
26
- public static function get_instance() {
27
- if ( ! isset( self::$instance ) ) {
28
- self::$instance = new self();
29
- }
30
- return self::$instance;
31
- }
32
-
33
- /**
34
- * Constructor
35
- */
36
- public function __construct() {
37
-
38
- /* Analytics */
39
- add_action( 'cartflows_wp_footer', array( $this, 'footer_markup' ) );
40
- }
41
-
42
- /**
43
- * Footer markup
44
- */
45
- public function footer_markup() {
46
-
47
- if ( wcf()->utils->is_step_post_type() ) {
48
- // @codingStandardsIgnoreStart
49
- $flow_id = wcf()->utils->get_flow_id();
50
- ?>
51
- <?php if( $this->is_flow_testmode( $flow_id ) ) { ?>
52
- <div class="wcf-preview-mode">
53
- <span><?php _e( 'Test mode is active — which displays random products for previewing. It can be deactivated from the flow settings in the admin dashboard.', 'cartflows' ); ?></span>
54
- <?php if ( current_user_can( 'manage_options' ) ) { ?>
55
- <?php
56
- $flow_edit_link = add_query_arg( 'edit_test_mode', 'yes', get_edit_post_link( $flow_id ) );
57
- ?>
58
- <a href="<?php echo $flow_edit_link; ?>"><?php _e( 'Click here to disable it', 'cartflows'); ?></a>
59
- <?php } ?>
60
- </div>
61
- <?php } ?>
62
- <?php
63
- // @codingStandardsIgnoreEnd
64
- }
65
- }
66
-
67
- /**
68
- * Check if flow test mode is enable.
69
- *
70
- * @since 1.0.0
71
- * @param int $flow_id flow ID.
72
- *
73
- * @return boolean
74
- */
75
- public function is_flow_testmode( $flow_id = '' ) {
76
-
77
- if ( ! $flow_id ) {
78
- $flow_id = wcf()->utils->get_flow_id();
79
- }
80
-
81
- $test_mode = wcf()->options->get_flow_meta_value( $flow_id, 'wcf-testing' );
82
-
83
- if ( 'no' === $test_mode ) {
84
- return false;
85
- }
86
-
87
- return true;
88
- }
89
-
90
- /**
91
- * Get steps data.
92
- *
93
- * @since 1.0.0
94
- * @param int $flow_id flow ID.
95
- *
96
- * @return array
97
- */
98
- public function get_steps( $flow_id ) {
99
-
100
- $steps = get_post_meta( $flow_id, 'wcf-steps', true );
101
-
102
- if ( ! is_array( $steps ) ) {
103
-
104
- $steps = array();
105
- }
106
-
107
- return $steps;
108
- }
109
-
110
- /**
111
- * Check thank you page exists.
112
- *
113
- * @since 1.0.0
114
- * @param array $order order data.
115
- *
116
- * @return bool
117
- */
118
- public function is_thankyou_page_exists( $order ) {
119
-
120
- $thankyou_step_exist = false;
121
-
122
- $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
123
-
124
- if ( $flow_id ) {
125
-
126
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
127
- $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
128
-
129
- if ( is_array( $flow_steps ) ) {
130
-
131
- $current_step_found = false;
132
-
133
- foreach ( $flow_steps as $index => $data ) {
134
-
135
- if ( $current_step_found ) {
136
-
137
- if ( 'thankyou' === $data['type'] ) {
138
-
139
- $thankyou_step_exist = true;
140
- break;
141
- }
142
- } else {
143
-
144
- if ( intval( $data['id'] ) === $step_id ) {
145
-
146
- $current_step_found = true;
147
- }
148
- }
149
- }
150
- }
151
- }
152
-
153
- return $thankyou_step_exist;
154
- }
155
-
156
- /**
157
- * Check thank you page exists.
158
- *
159
- * @since 1.0.0
160
- * @param array $order order data.
161
- *
162
- * @return bool
163
- */
164
- public function get_thankyou_page_id( $order ) {
165
-
166
- $thankyou_step_id = false;
167
-
168
- $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
169
-
170
- if ( $flow_id ) {
171
-
172
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
173
- $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
174
-
175
- if ( is_array( $flow_steps ) ) {
176
-
177
- $current_step_found = false;
178
-
179
- foreach ( $flow_steps as $index => $data ) {
180
-
181
- if ( $current_step_found ) {
182
-
183
- if ( 'thankyou' === $data['type'] ) {
184
-
185
- $thankyou_step_id = intval( $data['id'] );
186
- break;
187
- }
188
- } else {
189
-
190
- if ( intval( $data['id'] ) === $step_id ) {
191
-
192
- $current_step_found = true;
193
- }
194
- }
195
- }
196
- }
197
- }
198
-
199
- return $thankyou_step_id;
200
- }
201
-
202
- /**
203
- * Check thank you page exists.
204
- *
205
- * @since 1.0.0
206
- * @param array $order order data.
207
- *
208
- * @return bool
209
- */
210
- public function get_next_step_id( $order ) {
211
-
212
- $next_step_id = false;
213
-
214
- $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
215
-
216
- if ( $flow_id ) {
217
-
218
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
219
- $step_id = wcf()->utils->get_optin_id_from_order( $order->get_id() );
220
-
221
- if ( is_array( $flow_steps ) ) {
222
-
223
- foreach ( $flow_steps as $index => $data ) {
224
-
225
- if ( intval( $data['id'] ) === $step_id ) {
226
-
227
- $next_step_index = $index + 1;
228
-
229
- if ( isset( $flow_steps[ $next_step_index ] ) ) {
230
-
231
- $next_step_id = intval( $flow_steps[ $next_step_index ]['id'] );
232
- }
233
-
234
- break;
235
- }
236
- }
237
- }
238
- }
239
-
240
- return $next_step_id;
241
- }
242
- }
243
-
244
- /**
245
- * Kicking this off by calling 'get_instance()' method
246
- */
247
- Cartflows_Flow_Frontend::get_instance();
1
+ <?php
2
+ /**
3
+ * Frontend & Markup
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Flow Markup
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Flow_Frontend {
14
+
15
+
16
+ /**
17
+ * Member Variable
18
+ *
19
+ * @var object instance
20
+ */
21
+ private static $instance;
22
+
23
+ /**
24
+ * Initiator
25
+ */
26
+ public static function get_instance() {
27
+ if ( ! isset( self::$instance ) ) {
28
+ self::$instance = new self();
29
+ }
30
+ return self::$instance;
31
+ }
32
+
33
+ /**
34
+ * Constructor
35
+ */
36
+ public function __construct() {
37
+
38
+ /* Analytics */
39
+ add_action( 'cartflows_wp_footer', array( $this, 'footer_markup' ) );
40
+ }
41
+
42
+ /**
43
+ * Footer markup
44
+ */
45
+ public function footer_markup() {
46
+
47
+ if ( wcf()->utils->is_step_post_type() ) {
48
+ // @codingStandardsIgnoreStart
49
+ $flow_id = wcf()->utils->get_flow_id();
50
+ ?>
51
+ <?php if( $this->is_flow_testmode( $flow_id ) ) { ?>
52
+ <div class="wcf-preview-mode">
53
+ <span><?php _e( 'Test mode is active — which displays random products for previewing. It can be deactivated from the flow settings in the admin dashboard.', 'cartflows' ); ?></span>
54
+ <?php if ( current_user_can( 'manage_options' ) ) { ?>
55
+ <?php
56
+ $flow_edit_link = add_query_arg( 'edit_test_mode', 'yes', get_edit_post_link( $flow_id ) );
57
+ ?>
58
+ <a href="<?php echo $flow_edit_link; ?>"><?php _e( 'Click here to disable it', 'cartflows'); ?></a>
59
+ <?php } ?>
60
+ </div>
61
+ <?php } ?>
62
+ <?php
63
+ // @codingStandardsIgnoreEnd
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Check if flow test mode is enable.
69
+ *
70
+ * @since 1.0.0
71
+ * @param int $flow_id flow ID.
72
+ *
73
+ * @return boolean
74
+ */
75
+ public function is_flow_testmode( $flow_id = '' ) {
76
+
77
+ if ( ! $flow_id ) {
78
+ $flow_id = wcf()->utils->get_flow_id();
79
+ }
80
+
81
+ $test_mode = wcf()->options->get_flow_meta_value( $flow_id, 'wcf-testing' );
82
+
83
+ if ( 'no' === $test_mode ) {
84
+ return false;
85
+ }
86
+
87
+ return true;
88
+ }
89
+
90
+ /**
91
+ * Get steps data.
92
+ *
93
+ * @since 1.0.0
94
+ * @param int $flow_id flow ID.
95
+ *
96
+ * @return array
97
+ */
98
+ public function get_steps( $flow_id ) {
99
+
100
+ $steps = get_post_meta( $flow_id, 'wcf-steps', true );
101
+
102
+ if ( ! is_array( $steps ) ) {
103
+
104
+ $steps = array();
105
+ }
106
+
107
+ return $steps;
108
+ }
109
+
110
+ /**
111
+ * Check thank you page exists.
112
+ *
113
+ * @since 1.0.0
114
+ * @param array $order order data.
115
+ *
116
+ * @return bool
117
+ */
118
+ public function is_thankyou_page_exists( $order ) {
119
+
120
+ $thankyou_step_exist = false;
121
+
122
+ $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
123
+
124
+ if ( $flow_id ) {
125
+
126
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
127
+ $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
128
+
129
+ if ( is_array( $flow_steps ) ) {
130
+
131
+ $current_step_found = false;
132
+
133
+ foreach ( $flow_steps as $index => $data ) {
134
+
135
+ if ( $current_step_found ) {
136
+
137
+ if ( 'thankyou' === $data['type'] ) {
138
+
139
+ $thankyou_step_exist = true;
140
+ break;
141
+ }
142
+ } else {
143
+
144
+ if ( intval( $data['id'] ) === $step_id ) {
145
+
146
+ $current_step_found = true;
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+
153
+ return $thankyou_step_exist;
154
+ }
155
+
156
+ /**
157
+ * Check thank you page exists.
158
+ *
159
+ * @since 1.0.0
160
+ * @param array $order order data.
161
+ *
162
+ * @return bool
163
+ */
164
+ public function get_thankyou_page_id( $order ) {
165
+
166
+ $thankyou_step_id = false;
167
+
168
+ $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
169
+
170
+ if ( $flow_id ) {
171
+
172
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
173
+ $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
174
+
175
+ if ( is_array( $flow_steps ) ) {
176
+
177
+ $current_step_found = false;
178
+
179
+ foreach ( $flow_steps as $index => $data ) {
180
+
181
+ if ( $current_step_found ) {
182
+
183
+ if ( 'thankyou' === $data['type'] ) {
184
+
185
+ $thankyou_step_id = intval( $data['id'] );
186
+ break;
187
+ }
188
+ } else {
189
+
190
+ if ( intval( $data['id'] ) === $step_id ) {
191
+
192
+ $current_step_found = true;
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+
199
+ return $thankyou_step_id;
200
+ }
201
+
202
+ /**
203
+ * Check thank you page exists.
204
+ *
205
+ * @since 1.0.0
206
+ * @param array $order order data.
207
+ *
208
+ * @return bool
209
+ */
210
+ public function get_next_step_id( $order ) {
211
+
212
+ $next_step_id = false;
213
+
214
+ $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() );
215
+
216
+ if ( $flow_id ) {
217
+
218
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
219
+ $step_id = wcf()->utils->get_optin_id_from_order( $order->get_id() );
220
+
221
+ if ( is_array( $flow_steps ) ) {
222
+
223
+ foreach ( $flow_steps as $index => $data ) {
224
+
225
+ if ( intval( $data['id'] ) === $step_id ) {
226
+
227
+ $next_step_index = $index + 1;
228
+
229
+ if ( isset( $flow_steps[ $next_step_index ] ) ) {
230
+
231
+ $next_step_id = intval( $flow_steps[ $next_step_index ]['id'] );
232
+ }
233
+
234
+ break;
235
+ }
236
+ }
237
+ }
238
+ }
239
+
240
+ return $next_step_id;
241
+ }
242
+ }
243
+
244
+ /**
245
+ * Kicking this off by calling 'get_instance()' method
246
+ */
247
+ Cartflows_Flow_Frontend::get_instance();
classes/class-cartflows-functions.php CHANGED
@@ -172,7 +172,7 @@ function _is_wcf_checkout_type() {
172
  */
173
  function _is_wcf_doing_checkout_ajax() {
174
 
175
- if ( wp_doing_ajax() ) {
176
 
177
  if ( isset( $_GET['wc-ajax'] ) && //phpcs:ignore
178
  'checkout' === $_GET['wc-ajax'] && //phpcs:ignore
@@ -193,7 +193,7 @@ function _is_wcf_doing_checkout_ajax() {
193
  */
194
  function _is_wcf_doing_optin_ajax() {
195
 
196
- if ( wp_doing_ajax() ) {
197
 
198
  if ( isset( $_GET['wc-ajax'] ) && //phpcs:ignore
199
  'checkout' === $_GET['wc-ajax'] && //phpcs:ignore
172
  */
173
  function _is_wcf_doing_checkout_ajax() {
174
 
175
+ if ( wp_doing_ajax() || isset( $_GET['wc-ajax'] ) ) { //phpcs:ignore
176
 
177
  if ( isset( $_GET['wc-ajax'] ) && //phpcs:ignore
178
  'checkout' === $_GET['wc-ajax'] && //phpcs:ignore
193
  */
194
  function _is_wcf_doing_optin_ajax() {
195
 
196
+ if ( wp_doing_ajax() || isset( $_GET['wc-ajax'] ) ) { //phpcs:ignore
197
 
198
  if ( isset( $_GET['wc-ajax'] ) && //phpcs:ignore
199
  'checkout' === $_GET['wc-ajax'] && //phpcs:ignore
classes/class-cartflows-helper.php CHANGED
@@ -1,694 +1,694 @@
1
- <?php
2
- /**
3
- * CARTFLOWS Helper.
4
- *
5
- * @package CARTFLOWS
6
- */
7
-
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit; // Exit if accessed directly.
10
- }
11
-
12
- /**
13
- * Class Cartflows_Helper.
14
- */
15
- class Cartflows_Helper {
16
-
17
- /**
18
- * Common global data
19
- *
20
- * @var zapier
21
- */
22
- private static $common = null;
23
-
24
- /**
25
- * Common Debug data
26
- *
27
- * @var zapier
28
- */
29
- private static $debug_data = null;
30
-
31
-
32
- /**
33
- * Permalink settings
34
- *
35
- * @var permalink_setting
36
- */
37
- private static $permalink_setting = null;
38
-
39
- /**
40
- * Installed Plugins
41
- *
42
- * @since 1.1.4
43
- *
44
- * @access private
45
- * @var array Installed plugins list.
46
- */
47
- private static $installed_plugins = null;
48
-
49
- /**
50
- * Checkout Fields
51
- *
52
- * @var checkout_fields
53
- */
54
- private static $checkout_fields = null;
55
-
56
- /**
57
- * Facebook pixel global data
58
- *
59
- * @var faceboook
60
- */
61
- private static $facebook = null;
62
-
63
-
64
- /**
65
- * Returns an option from the database for
66
- * the admin settings page.
67
- *
68
- * @param string $key The option key.
69
- * @param mixed $default Option default value if option is not available.
70
- * @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
71
- * @return string Return the option value
72
- */
73
- public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
74
-
75
- // Get the site-wide option if we're in the network admin.
76
- if ( $network_override && is_multisite() ) {
77
- $value = get_site_option( $key, $default );
78
- } else {
79
- $value = get_option( $key, $default );
80
- }
81
-
82
- return $value;
83
- }
84
-
85
- /**
86
- * Updates an option from the admin settings page.
87
- *
88
- * @param string $key The option key.
89
- * @param mixed $value The value to update.
90
- * @param bool $network Whether to allow the network admin setting to be overridden on subsites.
91
- * @return mixed
92
- */
93
- public static function update_admin_settings_option( $key, $value, $network = false ) {
94
-
95
- // Update the site-wide option since we're in the network admin.
96
- if ( $network && is_multisite() ) {
97
- update_site_option( $key, $value );
98
- } else {
99
- update_option( $key, $value );
100
- }
101
-
102
- }
103
-
104
- /**
105
- * Get single setting
106
- *
107
- * @since 1.1.4
108
- *
109
- * @param string $key Option key.
110
- * @param string $default Option default value if not exist.
111
- * @return mixed
112
- */
113
- public static function get_common_setting( $key = '', $default = '' ) {
114
- $settings = self::get_common_settings();
115
-
116
- if ( $settings && array_key_exists( $key, $settings ) ) {
117
- return $settings[ $key ];
118
- }
119
-
120
- return $default;
121
- }
122
-
123
- /**
124
- * Get single debug options
125
- *
126
- * @since 1.1.4
127
- *
128
- * @param string $key Option key.
129
- * @param string $default Option default value if not exist.
130
- * @return mixed
131
- */
132
- public static function get_debug_setting( $key = '', $default = '' ) {
133
- $debug_data = self::get_debug_settings();
134
-
135
- if ( $debug_data && array_key_exists( $key, $debug_data ) ) {
136
- return $debug_data[ $key ];
137
- }
138
-
139
- return $default;
140
- }
141
-
142
- /**
143
- * Get required plugins for page builder
144
- *
145
- * @since 1.1.4
146
- *
147
- * @param string $page_builder_slug Page builder slug.
148
- * @param string $default Default page builder.
149
- * @return array selected page builder required plugins list.
150
- */
151
- public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
152
- $plugins = self::get_plugins_groupby_page_builders();
153
-
154
- if ( array_key_exists( $page_builder_slug, $plugins ) ) {
155
- return $plugins[ $page_builder_slug ];
156
- }
157
-
158
- return $plugins[ $default ];
159
- }
160
-
161
- /**
162
- * Get Plugins list by page builder.
163
- *
164
- * @since 1.1.4
165
- *
166
- * @return array Required Plugins list.
167
- */
168
- public static function get_plugins_groupby_page_builders() {
169
-
170
- $divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
171
- $theme_status = 'not-installed';
172
- if ( $divi_status ) {
173
- if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
174
- $theme_status = 'installed';
175
- if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
176
- $theme_status = 'deactivate';
177
- $divi_status = 'activate';
178
- } else {
179
- $divi_status = '';
180
- }
181
- }
182
- }
183
-
184
- $plugins = array(
185
- 'elementor' => array(
186
- 'title' => 'Elementor',
187
- 'plugins' => array(
188
- array(
189
- 'slug' => 'elementor', // For download from wp.org.
190
- 'init' => 'elementor/elementor.php',
191
- 'status' => self::get_plugin_status( 'elementor/elementor.php' ),
192
- ),
193
- ),
194
- ),
195
- 'divi' => array(
196
- 'title' => 'Divi',
197
- 'theme-status' => $theme_status,
198
- 'plugin-status' => $divi_status,
199
- 'plugins' => array(
200
- array(
201
- 'slug' => 'divi-builder', // For download from wp.org.
202
- 'init' => 'divi-builder/divi-builder.php',
203
- 'status' => $divi_status,
204
- ),
205
- ),
206
- ),
207
- );
208
-
209
- $plugins['beaver-builder'] = array(
210
- 'title' => 'Beaver Builder',
211
- 'plugins' => array(),
212
- );
213
-
214
- // Check Pro Exist.
215
- if ( file_exists( WP_PLUGIN_DIR . '/bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
216
- $plugins['beaver-builder']['plugins'][] = array(
217
- 'slug' => 'bb-plugin',
218
- 'init' => 'bb-plugin/fl-builder.php',
219
- 'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
220
- );
221
- } else {
222
- $plugins['beaver-builder']['plugins'][] = array(
223
- 'slug' => 'beaver-builder-lite-version', // For download from wp.org.
224
- 'init' => 'beaver-builder-lite-version/fl-builder.php',
225
- 'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
226
- );
227
- }
228
-
229
- if ( file_exists( WP_PLUGIN_DIR . '/bb-ultimate-addon/bb-ultimate-addon.php' ) && ! is_plugin_active( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) {
230
- $plugins['beaver-builder']['plugins'][] = array(
231
- 'slug' => 'bb-ultimate-addon',
232
- 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
233
- 'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
234
- );
235
- } else {
236
- $plugins['beaver-builder']['plugins'][] = array(
237
- 'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
238
- 'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
239
- 'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
240
- );
241
- }
242
-
243
- return $plugins;
244
- }
245
-
246
- /**
247
- * Get plugin status
248
- *
249
- * @since 1.1.4
250
- *
251
- * @param string $plugin_init_file Plguin init file.
252
- * @return mixed
253
- */
254
- public static function get_plugin_status( $plugin_init_file ) {
255
-
256
- if ( null == self::$installed_plugins ) {
257
- self::$installed_plugins = get_plugins();
258
- }
259
-
260
- if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
261
- return 'install';
262
- } elseif ( ! is_plugin_active( $plugin_init_file ) ) {
263
- return 'activate';
264
- } else {
265
- return;
266
- }
267
- }
268
-
269
- /**
270
- * Get zapier settings.
271
- *
272
- * @return array.
273
- */
274
- public static function get_common_settings() {
275
-
276
- if ( null === self::$common ) {
277
-
278
- $common_default = apply_filters(
279
- 'cartflows_common_settings_default',
280
- array(
281
- 'disallow_indexing' => 'disable',
282
- 'global_checkout' => '',
283
- 'default_page_builder' => 'elementor',
284
- )
285
- );
286
-
287
- $common = self::get_admin_settings_option( '_cartflows_common', false, false );
288
-
289
- $common = wp_parse_args( $common, $common_default );
290
-
291
- if ( ! did_action( 'wp' ) ) {
292
- return $common;
293
- } else {
294
- self::$common = $common;
295
- }
296
- }
297
-
298
- return self::$common;
299
- }
300
-
301
- /**
302
- * Get debug settings data.
303
- *
304
- * @return array.
305
- */
306
- public static function get_debug_settings() {
307
-
308
- if ( null === self::$debug_data ) {
309
-
310
- $debug_data_default = apply_filters(
311
- 'cartflows_debug_settings_default',
312
- array(
313
- 'allow_minified_files' => 'disable',
314
- )
315
- );
316
-
317
- $debug_data = self::get_admin_settings_option( '_cartflows_debug_data', false, false );
318
-
319
- $debug_data = wp_parse_args( $debug_data, $debug_data_default );
320
-
321
- if ( ! did_action( 'wp' ) ) {
322
- return $debug_data;
323
- } else {
324
- self::$debug_data = $debug_data;
325
- }
326
- }
327
-
328
- return self::$debug_data;
329
- }
330
-
331
-
332
- /**
333
- * Get debug settings data.
334
- *
335
- * @return array.
336
- */
337
- public static function get_permalink_settings() {
338
-
339
- if ( null === self::$permalink_setting ) {
340
-
341
- $permalink_default = apply_filters(
342
- 'cartflows_permalink_settings_default',
343
- array(
344
- 'permalink' => CARTFLOWS_STEP_POST_TYPE,
345
- 'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE,
346
- 'permalink_structure' => '',
347
-
348
- )
349
- );
350
-
351
- $permalink_data = self::get_admin_settings_option( '_cartflows_permalink', false, false );
352
-
353
- $permalink_data = wp_parse_args( $permalink_data, $permalink_default );
354
-
355
- if ( ! did_action( 'wp' ) ) {
356
- return $permalink_data;
357
- } else {
358
- self::$permalink_setting = $permalink_data;
359
- }
360
- }
361
-
362
- return self::$permalink_setting;
363
- }
364
-
365
- /**
366
- * Get Checkout field.
367
- *
368
- * @param string $key Field key.
369
- * @param int $post_id Post id.
370
- * @return array.
371
- */
372
- public static function get_checkout_fields( $key, $post_id ) {
373
-
374
- $saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
375
-
376
- if ( ! $saved_fields ) {
377
- $saved_fields = array();
378
- }
379
-
380
- $fields = array_filter( $saved_fields );
381
-
382
- if ( empty( $fields ) ) {
383
- if ( 'billing' === $key || 'shipping' === $key ) {
384
-
385
- $fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
386
-
387
- update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
388
- }
389
- }
390
-
391
- return $fields;
392
- }
393
-
394
- /**
395
- * Add Checkout field.
396
- *
397
- * @param string $type Field type.
398
- * @param string $field_key Field key.
399
- * @param array $field_data Field data.
400
- * @param int $post_id Post id.
401
- * @return boolean.
402
- */
403
- public static function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
404
-
405
- $fields = self::get_checkout_fields( $type, $post_id );
406
-
407
- $fields[ $field_key ] = $field_data;
408
-
409
- update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
410
-
411
- return true;
412
- }
413
-
414
- /**
415
- * Get checkout fields settings.
416
- *
417
- * @param string $type Field type.
418
- * @param string $field_key Field key.
419
- * @param int $post_id Post id.
420
- * @return array.
421
- */
422
- public static function delete_checkout_field( $type, $field_key, $post_id ) {
423
-
424
- $fields = self::get_checkout_fields( $type, $post_id );
425
-
426
- if ( isset( $fields[ $field_key ] ) ) {
427
- unset( $fields[ $field_key ] );
428
- }
429
-
430
- update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
431
-
432
- return true;
433
- }
434
-
435
- /**
436
- * Get checkout fields settings.
437
- *
438
- * @return array.
439
- */
440
- public static function get_checkout_fields_settings() {
441
-
442
- if ( null === self::$checkout_fields ) {
443
- $checkout_fields_default = array(
444
- 'enable_customization' => 'disable',
445
- 'enable_billing_fields' => 'disable',
446
- );
447
-
448
- $billing_fields = self::get_checkout_fields( 'billing' );
449
-
450
- if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
451
-
452
- foreach ( $billing_fields as $key => $value ) {
453
-
454
- $checkout_fields_default[ $key ] = 'enable';
455
- }
456
- }
457
-
458
- $checkout_fields = self::get_admin_settings_option( '_wcf_checkout_fields', false, false );
459
-
460
- self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
461
- }
462
-
463
- return self::$checkout_fields;
464
- }
465
-
466
- /**
467
- * Get meta options
468
- *
469
- * @since 1.0.0
470
- * @param int $post_id Product ID.
471
- * @param string $key Meta Key.
472
- * @param string $default Default value.
473
- * @return string Meta Value.
474
- */
475
- public static function get_meta_option( $post_id, $key, $default = '' ) {
476
-
477
- $value = get_post_meta( $post_id, $key, true );
478
-
479
- if ( ! $value ) {
480
- $value = $default;
481
- }
482
-
483
- return $value;
484
- }
485
-
486
- /**
487
- * Save meta option
488
- *
489
- * @since 1.0.0
490
- * @param int $post_id Product ID.
491
- * @param array $args Arguments array.
492
- */
493
- public static function save_meta_option( $post_id, $args = array() ) {
494
-
495
- if ( is_array( $args ) && ! empty( $args ) ) {
496
-
497
- foreach ( $args as $key => $value ) {
498
-
499
- update_post_meta( $post_id, $key, $value );
500
- }
501
- }
502
- }
503
-
504
- /**
505
- * Check if Elementor page builder is installed
506
- *
507
- * @since 1.0.0
508
- *
509
- * @access public
510
- */
511
- public static function is_elementor_installed() {
512
- $path = 'elementor/elementor.php';
513
- $plugins = get_plugins();
514
-
515
- return isset( $plugins[ $path ] );
516
- }
517
-
518
- /**
519
- * Check if Step has product assigned.
520
- *
521
- * @since 1.0.0
522
- * @param int $step_id step ID.
523
- *
524
- * @access public
525
- */
526
- public static function has_product_assigned( $step_id ) {
527
-
528
- $step_type = get_post_meta( $step_id, 'wcf-step-type', true );
529
-
530
- if ( 'checkout' == $step_type ) {
531
- $product = get_post_meta( $step_id, 'wcf-checkout-products', true );
532
- } else {
533
- $product = get_post_meta( $step_id, 'wcf-offer-product', true );
534
- }
535
-
536
- if ( ! empty( $product ) ) {
537
- return true;
538
- }
539
- return false;
540
-
541
- }
542
-
543
- /**
544
- * Get attributes for cartflows wrap.
545
- *
546
- * @since 1.1.4
547
- *
548
- * @access public
549
- */
550
- public static function get_cartflows_container_atts() {
551
-
552
- $attributes = apply_filters( 'cartflows_container_atts', array() );
553
- $atts_string = '';
554
-
555
- foreach ( $attributes as $key => $value ) {
556
-
557
- if ( ! $value ) {
558
- continue;
559
- }
560
-
561
- if ( true === $value ) {
562
- $atts_string .= esc_html( $key ) . ' ';
563
- } else {
564
- $atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
565
- }
566
- }
567
-
568
- return $atts_string;
569
- }
570
-
571
- /**
572
- * Get facebook pixel settings.
573
- *
574
- * @return facebook array.
575
- */
576
- public static function get_facebook_settings() {
577
-
578
- if ( null === self::$facebook ) {
579
-
580
- $facebook_default = array(
581
- 'facebook_pixel_id' => '',
582
- 'facebook_pixel_add_to_cart' => 'enable',
583
- 'facebook_pixel_initiate_checkout' => 'enable',
584
- 'facebook_pixel_add_payment_info' => 'enable',
585
- 'facebook_pixel_purchase_complete' => 'enable',
586
- 'facebook_pixel_tracking' => 'disable',
587
- );
588
-
589
- $facebook = self::get_admin_settings_option( '_cartflows_facebook', false, false );
590
-
591
- $facebook = wp_parse_args( $facebook, $facebook_default );
592
-
593
- self::$facebook = apply_filters( 'cartflows_facebook_settings_default', $facebook );
594
-
595
- }
596
-
597
- return self::$facebook;
598
- }
599
-
600
-
601
- /**
602
- * Prepare response data for facebook.
603
- *
604
- * @param int $order_id order_id.
605
- * @param array $offer_data offer data.
606
- */
607
- public static function send_fb_response_if_enabled( $order_id, $offer_data = array() ) {
608
-
609
- $fb_settings = self::get_facebook_settings();
610
- if ( 'enable' === $fb_settings['facebook_pixel_tracking'] ) {
611
- setcookie( 'wcf_order_details', wp_json_encode( self::prepare_purchase_data_fb_response( $order_id, $offer_data ) ), strtotime( '+1 year' ), '/' );
612
- }
613
-
614
- }
615
-
616
- /**
617
- * Prepare purchase response for facebook purcase event.
618
- *
619
- * @param integer $order_id order id.
620
- * @param array $offer_data offer data.
621
- * @return mixed
622
- */
623
- public static function prepare_purchase_data_fb_response( $order_id, $offer_data = array() ) {
624
-
625
- $thankyou['order_id'] = $order_id;
626
- $thankyou['content_type'] = 'product';
627
- $thankyou['currency'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_currency' );
628
- $thankyou['userAgent'] = wcf()->options->get_checkout_meta_value( $order_id, '_customer_user_agent' );
629
- $thankyou['plugin'] = 'CartFlows';
630
- $order = wc_get_order( $order_id );
631
- if ( empty( $offer_data ) ) {
632
- // Iterating through each WC_Order_Item_Product objects.
633
- foreach ( $order->get_items() as $item_key => $item ) {
634
- $product = $item->get_product(); // Get the WC_Product object.
635
- $thankyou['content_ids'][] = (string) $product->get_id();
636
- }
637
- $thankyou['value'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_total' );
638
- } else {
639
- $thankyou['content_ids'][] = (string) $offer_data['id'];
640
- $thankyou['value'] = $offer_data['total'];
641
- }
642
-
643
- return $thankyou;
644
- }
645
-
646
- /**
647
- * Prepare cart data for fb response.
648
- *
649
- * @return array
650
- */
651
- public static function prepare_cart_data_fb_response() {
652
- $params = array();
653
- $cart_total = WC()->cart->get_cart_contents_total();
654
- $cart_items_count = WC()->cart->get_cart_contents_count();
655
- $items = WC()->cart->get_cart();
656
- $product_names = '';
657
- $category_names = '';
658
- $cart_contents = array();
659
- foreach ( $items as $item => $value ) {
660
-
661
- $_product = wc_get_product( $value['product_id'] );
662
- $params['content_ids'][] = (string) $_product->get_id();
663
- $product_names = $product_names . ', ' . $_product->get_title();
664
- $category_names = $category_names . ', ' . wp_strip_all_tags( wc_get_product_category_list( $_product->get_id() ) );
665
- array_push(
666
- $cart_contents,
667
- array(
668
- 'id' => $_product->get_id(),
669
- 'name' => $_product->get_title(),
670
- 'quantity' => $value['quantity'],
671
- 'item_price' => $_product->get_price(),
672
- )
673
- );
674
- }
675
-
676
- $user = wp_get_current_user();
677
- $roles = implode( ', ', $user->roles );
678
- $params['content_name'] = substr( $product_names, 2 );
679
- $params['categoey_name'] = substr( $category_names, 2 );
680
- $params['user_roles'] = $roles;
681
- $params['plugin'] = 'CartFlows';
682
- $params['contents'] = wp_json_encode( $cart_contents );
683
- $params['content_type'] = 'product';
684
- $params['value'] = $cart_total;
685
- $params['num_items'] = $cart_items_count;
686
- $params['currency'] = get_woocommerce_currency();
687
- $params['language'] = get_bloginfo( 'language' );
688
- $params['userAgent'] = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); //phpcs:ignore
689
- $params['product_catalog_id'] = '';
690
- $params['domain'] = get_site_url();
691
- return $params;
692
- }
693
-
694
- }
1
+ <?php
2
+ /**
3
+ * CARTFLOWS Helper.
4
+ *
5
+ * @package CARTFLOWS
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly.
10
+ }
11
+
12
+ /**
13
+ * Class Cartflows_Helper.
14
+ */
15
+ class Cartflows_Helper {
16
+
17
+ /**
18
+ * Common global data
19
+ *
20
+ * @var zapier
21
+ */
22
+ private static $common = null;
23
+
24
+ /**
25
+ * Common Debug data
26
+ *
27
+ * @var zapier
28
+ */
29
+ private static $debug_data = null;
30
+
31
+
32
+ /**
33
+ * Permalink settings
34
+ *
35
+ * @var permalink_setting
36
+ */
37
+ private static $permalink_setting = null;
38
+
39
+ /**
40
+ * Installed Plugins
41
+ *
42
+ * @since 1.1.4
43
+ *
44
+ * @access private
45
+ * @var array Installed plugins list.
46
+ */
47
+ private static $installed_plugins = null;
48
+
49
+ /**
50
+ * Checkout Fields
51
+ *
52
+ * @var checkout_fields
53
+ */
54
+ private static $checkout_fields = null;
55
+
56
+ /**
57
+ * Facebook pixel global data
58
+ *
59
+ * @var faceboook
60
+ */
61
+ private static $facebook = null;
62
+
63
+
64
+ /**
65
+ * Returns an option from the database for
66
+ * the admin settings page.
67
+ *
68
+ * @param string $key The option key.
69
+ * @param mixed $default Option default value if option is not available.
70
+ * @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
71
+ * @return string Return the option value
72
+ */
73
+ public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
74
+
75
+ // Get the site-wide option if we're in the network admin.
76
+ if ( $network_override && is_multisite() ) {
77
+ $value = get_site_option( $key, $default );
78
+ } else {
79
+ $value = get_option( $key, $default );
80
+ }
81
+
82
+ return $value;
83
+ }
84
+
85
+ /**
86
+ * Updates an option from the admin settings page.
87
+ *
88
+ * @param string $key The option key.
89
+ * @param mixed $value The value to update.
90
+ * @param bool $network Whether to allow the network admin setting to be overridden on subsites.
91
+ * @return mixed
92
+ */
93
+ public static function update_admin_settings_option( $key, $value, $network = false ) {
94
+
95
+ // Update the site-wide option since we're in the network admin.
96
+ if ( $network && is_multisite() ) {
97
+ update_site_option( $key, $value );
98
+ } else {
99
+ update_option( $key, $value );
100
+ }
101
+
102
+ }
103
+
104
+ /**
105
+ * Get single setting
106
+ *
107
+ * @since 1.1.4
108
+ *
109
+ * @param string $key Option key.
110
+ * @param string $default Option default value if not exist.
111
+ * @return mixed
112
+ */
113
+ public static function get_common_setting( $key = '', $default = '' ) {
114
+ $settings = self::get_common_settings();
115
+
116
+ if ( $settings && array_key_exists( $key, $settings ) ) {
117
+ return $settings[ $key ];
118
+ }
119
+
120
+ return $default;
121
+ }
122
+
123
+ /**
124
+ * Get single debug options
125
+ *
126
+ * @since 1.1.4
127
+ *
128
+ * @param string $key Option key.
129
+ * @param string $default Option default value if not exist.
130
+ * @return mixed
131
+ */
132
+ public static function get_debug_setting( $key = '', $default = '' ) {
133
+ $debug_data = self::get_debug_settings();
134
+
135
+ if ( $debug_data && array_key_exists( $key, $debug_data ) ) {
136
+ return $debug_data[ $key ];
137
+ }
138
+
139
+ return $default;
140
+ }
141
+
142
+ /**
143
+ * Get required plugins for page builder
144
+ *
145
+ * @since 1.1.4
146
+ *
147
+ * @param string $page_builder_slug Page builder slug.
148
+ * @param string $default Default page builder.
149
+ * @return array selected page builder required plugins list.
150
+ */
151
+ public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
152
+ $plugins = self::get_plugins_groupby_page_builders();
153
+
154
+ if ( array_key_exists( $page_builder_slug, $plugins ) ) {
155
+ return $plugins[ $page_builder_slug ];
156
+ }
157
+
158
+ return $plugins[ $default ];
159
+ }
160
+
161
+ /**
162
+ * Get Plugins list by page builder.
163
+ *
164
+ * @since 1.1.4
165
+ *
166
+ * @return array Required Plugins list.
167
+ */
168
+ public static function get_plugins_groupby_page_builders() {
169
+
170
+ $divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
171
+ $theme_status = 'not-installed';
172
+ if ( $divi_status ) {
173
+ if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
174
+ $theme_status = 'installed';
175
+ if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
176
+ $theme_status = 'deactivate';
177
+ $divi_status = 'activate';
178
+ } else {
179
+ $divi_status = '';
180
+ }
181
+ }
182
+ }
183
+
184
+ $plugins = array(
185
+ 'elementor' => array(
186
+ 'title' => 'Elementor',
187
+ 'plugins' => array(
188
+ array(
189
+ 'slug' => 'elementor', // For download from wp.org.
190
+ 'init' => 'elementor/elementor.php',
191
+ 'status' => self::get_plugin_status( 'elementor/elementor.php' ),
192
+ ),
193
+ ),
194
+ ),
195
+ 'divi' => array(
196
+ 'title' => 'Divi',
197
+ 'theme-status' => $theme_status,
198
+ 'plugin-status' => $divi_status,
199
+ 'plugins' => array(
200
+ array(
201
+ 'slug' => 'divi-builder', // For download from wp.org.
202
+ 'init' => 'divi-builder/divi-builder.php',
203
+ 'status' => $divi_status,
204
+ ),
205
+ ),
206
+ ),
207
+ );
208
+
209
+ $plugins['beaver-builder'] = array(
210
+ 'title' => 'Beaver Builder',
211
+ 'plugins' => array(),
212
+ );
213
+
214
+ // Check Pro Exist.
215
+ if ( file_exists( WP_PLUGIN_DIR . '/bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
216
+ $plugins['beaver-builder']['plugins'][] = array(
217
+ 'slug' => 'bb-plugin',
218
+ 'init' => 'bb-plugin/fl-builder.php',
219
+ 'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
220
+ );
221
+ } else {
222
+ $plugins['beaver-builder']['plugins'][] = array(
223
+ 'slug' => 'beaver-builder-lite-version', // For download from wp.org.
224
+ 'init' => 'beaver-builder-lite-version/fl-builder.php',
225
+ 'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
226
+ );
227
+ }
228
+
229
+ if ( file_exists( WP_PLUGIN_DIR . '/bb-ultimate-addon/bb-ultimate-addon.php' ) && ! is_plugin_active( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) {
230
+ $plugins['beaver-builder']['plugins'][] = array(
231
+ 'slug' => 'bb-ultimate-addon',
232
+ 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
233
+ 'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
234
+ );
235
+ } else {
236
+ $plugins['beaver-builder']['plugins'][] = array(
237
+ 'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
238
+ 'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
239
+ 'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
240
+ );
241
+ }
242
+
243
+ return $plugins;
244
+ }
245
+
246
+ /**
247
+ * Get plugin status
248
+ *
249
+ * @since 1.1.4
250
+ *
251
+ * @param string $plugin_init_file Plguin init file.
252
+ * @return mixed
253
+ */
254
+ public static function get_plugin_status( $plugin_init_file ) {
255
+
256
+ if ( null == self::$installed_plugins ) {
257
+ self::$installed_plugins = get_plugins();
258
+ }
259
+
260
+ if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
261
+ return 'install';
262
+ } elseif ( ! is_plugin_active( $plugin_init_file ) ) {
263
+ return 'activate';
264
+ } else {
265
+ return;
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Get zapier settings.
271
+ *
272
+ * @return array.
273
+ */
274
+ public static function get_common_settings() {
275
+
276
+ if ( null === self::$common ) {
277
+
278
+ $common_default = apply_filters(
279
+ 'cartflows_common_settings_default',
280
+ array(
281
+ 'disallow_indexing' => 'disable',
282
+ 'global_checkout' => '',
283
+ 'default_page_builder' => 'elementor',
284
+ )
285
+ );
286
+
287
+ $common = self::get_admin_settings_option( '_cartflows_common', false, false );
288
+
289
+ $common = wp_parse_args( $common, $common_default );
290
+
291
+ if ( ! did_action( 'wp' ) ) {
292
+ return $common;
293
+ } else {
294
+ self::$common = $common;
295
+ }
296
+ }
297
+
298
+ return self::$common;
299
+ }
300
+
301
+ /**
302
+ * Get debug settings data.
303
+ *
304
+ * @return array.
305
+ */
306
+ public static function get_debug_settings() {
307
+
308
+ if ( null === self::$debug_data ) {
309
+
310
+ $debug_data_default = apply_filters(
311
+ 'cartflows_debug_settings_default',
312
+ array(
313
+ 'allow_minified_files' => 'disable',
314
+ )
315
+ );
316
+
317
+ $debug_data = self::get_admin_settings_option( '_cartflows_debug_data', false, false );
318
+
319
+ $debug_data = wp_parse_args( $debug_data, $debug_data_default );
320
+
321
+ if ( ! did_action( 'wp' ) ) {
322
+ return $debug_data;
323
+ } else {
324
+ self::$debug_data = $debug_data;
325
+ }
326
+ }
327
+
328
+ return self::$debug_data;
329
+ }
330
+
331
+
332
+ /**
333
+ * Get debug settings data.
334
+ *
335
+ * @return array.
336
+ */
337
+ public static function get_permalink_settings() {
338
+
339
+ if ( null === self::$permalink_setting ) {
340
+
341
+ $permalink_default = apply_filters(
342
+ 'cartflows_permalink_settings_default',
343
+ array(
344
+ 'permalink' => CARTFLOWS_STEP_POST_TYPE,
345
+ 'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE,
346
+ 'permalink_structure' => '',
347
+
348
+ )
349
+ );
350
+
351
+ $permalink_data = self::get_admin_settings_option( '_cartflows_permalink', false, false );
352
+
353
+ $permalink_data = wp_parse_args( $permalink_data, $permalink_default );
354
+
355
+ if ( ! did_action( 'wp' ) ) {
356
+ return $permalink_data;
357
+ } else {
358
+ self::$permalink_setting = $permalink_data;
359
+ }
360
+ }
361
+
362
+ return self::$permalink_setting;
363
+ }
364
+
365
+ /**
366
+ * Get Checkout field.
367
+ *
368
+ * @param string $key Field key.
369
+ * @param int $post_id Post id.
370
+ * @return array.
371
+ */
372
+ public static function get_checkout_fields( $key, $post_id ) {
373
+
374
+ $saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
375
+
376
+ if ( ! $saved_fields ) {
377
+ $saved_fields = array();
378
+ }
379
+
380
+ $fields = array_filter( $saved_fields );
381
+
382
+ if ( empty( $fields ) ) {
383
+ if ( 'billing' === $key || 'shipping' === $key ) {
384
+
385
+ $fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
386
+
387
+ update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
388
+ }
389
+ }
390
+
391
+ return $fields;
392
+ }
393
+
394
+ /**
395
+ * Add Checkout field.
396
+ *
397
+ * @param string $type Field type.
398
+ * @param string $field_key Field key.
399
+ * @param array $field_data Field data.
400
+ * @param int $post_id Post id.
401
+ * @return boolean.
402
+ */
403
+ public static function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
404
+
405
+ $fields = self::get_checkout_fields( $type, $post_id );
406
+
407
+ $fields[ $field_key ] = $field_data;
408
+
409
+ update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
410
+
411
+ return true;
412
+ }
413
+
414
+ /**
415
+ * Get checkout fields settings.
416
+ *
417
+ * @param string $type Field type.
418
+ * @param string $field_key Field key.
419
+ * @param int $post_id Post id.
420
+ * @return array.
421
+ */
422
+ public static function delete_checkout_field( $type, $field_key, $post_id ) {
423
+
424
+ $fields = self::get_checkout_fields( $type, $post_id );
425
+
426
+ if ( isset( $fields[ $field_key ] ) ) {
427
+ unset( $fields[ $field_key ] );
428
+ }
429
+
430
+ update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
431
+
432
+ return true;
433
+ }
434
+
435
+ /**
436
+ * Get checkout fields settings.
437
+ *
438
+ * @return array.
439
+ */
440
+ public static function get_checkout_fields_settings() {
441
+
442
+ if ( null === self::$checkout_fields ) {
443
+ $checkout_fields_default = array(
444
+ 'enable_customization' => 'disable',
445
+ 'enable_billing_fields' => 'disable',
446
+ );
447
+
448
+ $billing_fields = self::get_checkout_fields( 'billing' );
449
+
450
+ if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
451
+
452
+ foreach ( $billing_fields as $key => $value ) {
453
+
454
+ $checkout_fields_default[ $key ] = 'enable';
455
+ }
456
+ }
457
+
458
+ $checkout_fields = self::get_admin_settings_option( '_wcf_checkout_fields', false, false );
459
+
460
+ self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
461
+ }
462
+
463
+ return self::$checkout_fields;
464
+ }
465
+
466
+ /**
467
+ * Get meta options
468
+ *
469
+ * @since 1.0.0
470
+ * @param int $post_id Product ID.
471
+ * @param string $key Meta Key.
472
+ * @param string $default Default value.
473
+ * @return string Meta Value.
474
+ */
475
+ public static function get_meta_option( $post_id, $key, $default = '' ) {
476
+
477
+ $value = get_post_meta( $post_id, $key, true );
478
+
479
+ if ( ! $value ) {
480
+ $value = $default;
481
+ }
482
+
483
+ return $value;
484
+ }
485
+
486
+ /**
487
+ * Save meta option
488
+ *
489
+ * @since 1.0.0
490
+ * @param int $post_id Product ID.
491
+ * @param array $args Arguments array.
492
+ */
493
+ public static function save_meta_option( $post_id, $args = array() ) {
494
+
495
+ if ( is_array( $args ) && ! empty( $args ) ) {
496
+
497
+ foreach ( $args as $key => $value ) {
498
+
499
+ update_post_meta( $post_id, $key, $value );
500
+ }
501
+ }
502
+ }
503
+
504
+ /**
505
+ * Check if Elementor page builder is installed
506
+ *
507
+ * @since 1.0.0
508
+ *
509
+ * @access public
510
+ */
511
+ public static function is_elementor_installed() {
512
+ $path = 'elementor/elementor.php';
513
+ $plugins = get_plugins();
514
+
515
+ return isset( $plugins[ $path ] );
516
+ }
517
+
518
+ /**
519
+ * Check if Step has product assigned.
520
+ *
521
+ * @since 1.0.0
522
+ * @param int $step_id step ID.
523
+ *
524
+ * @access public
525
+ */
526
+ public static function has_product_assigned( $step_id ) {
527
+
528
+ $step_type = get_post_meta( $step_id, 'wcf-step-type', true );
529
+
530
+ if ( 'checkout' == $step_type ) {
531
+ $product = get_post_meta( $step_id, 'wcf-checkout-products', true );
532
+ } else {
533
+ $product = get_post_meta( $step_id, 'wcf-offer-product', true );
534
+ }
535
+
536
+ if ( ! empty( $product ) ) {
537
+ return true;
538
+ }
539
+ return false;
540
+
541
+ }
542
+
543
+ /**
544
+ * Get attributes for cartflows wrap.
545
+ *
546
+ * @since 1.1.4
547
+ *
548
+ * @access public
549
+ */
550
+ public static function get_cartflows_container_atts() {
551
+
552
+ $attributes = apply_filters( 'cartflows_container_atts', array() );
553
+ $atts_string = '';
554
+
555
+ foreach ( $attributes as $key => $value ) {
556
+
557
+ if ( ! $value ) {
558
+ continue;
559
+ }
560
+
561
+ if ( true === $value ) {
562
+ $atts_string .= esc_html( $key ) . ' ';
563
+ } else {
564
+ $atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
565
+ }
566
+ }
567
+
568
+ return $atts_string;
569
+ }
570
+
571
+ /**
572
+ * Get facebook pixel settings.
573
+ *
574
+ * @return facebook array.
575
+ */
576
+ public static function get_facebook_settings() {
577
+
578
+ if ( null === self::$facebook ) {
579
+
580
+ $facebook_default = array(
581
+ 'facebook_pixel_id' => '',
582
+ 'facebook_pixel_add_to_cart' => 'enable',
583
+ 'facebook_pixel_initiate_checkout' => 'enable',
584
+ 'facebook_pixel_add_payment_info' => 'enable',
585
+ 'facebook_pixel_purchase_complete' => 'enable',
586
+ 'facebook_pixel_tracking' => 'disable',
587
+ );
588
+
589
+ $facebook = self::get_admin_settings_option( '_cartflows_facebook', false, false );
590
+
591
+ $facebook = wp_parse_args( $facebook, $facebook_default );
592
+
593
+ self::$facebook = apply_filters( 'cartflows_facebook_settings_default', $facebook );
594
+
595
+ }
596
+
597
+ return self::$facebook;
598
+ }
599
+
600
+
601
+ /**
602
+ * Prepare response data for facebook.
603
+ *
604
+ * @param int $order_id order_id.
605
+ * @param array $offer_data offer data.
606
+ */
607
+ public static function send_fb_response_if_enabled( $order_id, $offer_data = array() ) {
608
+
609
+ $fb_settings = self::get_facebook_settings();
610
+ if ( 'enable' === $fb_settings['facebook_pixel_tracking'] ) {
611
+ setcookie( 'wcf_order_details', wp_json_encode( self::prepare_purchase_data_fb_response( $order_id, $offer_data ) ), strtotime( '+1 year' ), '/' );
612
+ }
613
+
614
+ }
615
+
616
+ /**
617
+ * Prepare purchase response for facebook purcase event.
618
+ *
619
+ * @param integer $order_id order id.
620
+ * @param array $offer_data offer data.
621
+ * @return mixed
622
+ */
623
+ public static function prepare_purchase_data_fb_response( $order_id, $offer_data = array() ) {
624
+
625
+ $thankyou['order_id'] = $order_id;
626
+ $thankyou['content_type'] = 'product';
627
+ $thankyou['currency'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_currency' );
628
+ $thankyou['userAgent'] = wcf()->options->get_checkout_meta_value( $order_id, '_customer_user_agent' );
629
+ $thankyou['plugin'] = 'CartFlows';
630
+ $order = wc_get_order( $order_id );
631
+ if ( empty( $offer_data ) ) {
632
+ // Iterating through each WC_Order_Item_Product objects.
633
+ foreach ( $order->get_items() as $item_key => $item ) {
634
+ $product = $item->get_product(); // Get the WC_Product object.
635
+ $thankyou['content_ids'][] = (string) $product->get_id();
636
+ }
637
+ $thankyou['value'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_total' );
638
+ } else {
639
+ $thankyou['content_ids'][] = (string) $offer_data['id'];
640
+ $thankyou['value'] = $offer_data['total'];
641
+ }
642
+
643
+ return $thankyou;
644
+ }
645
+
646
+ /**
647
+ * Prepare cart data for fb response.
648
+ *
649
+ * @return array
650
+ */
651
+ public static function prepare_cart_data_fb_response() {
652
+ $params = array();
653
+ $cart_total = WC()->cart->get_cart_contents_total();
654
+ $cart_items_count = WC()->cart->get_cart_contents_count();
655
+ $items = WC()->cart->get_cart();
656
+ $product_names = '';
657
+ $category_names = '';
658
+ $cart_contents = array();
659
+ foreach ( $items as $item => $value ) {
660
+
661
+ $_product = wc_get_product( $value['product_id'] );
662
+ $params['content_ids'][] = (string) $_product->get_id();
663
+ $product_names = $product_names . ', ' . $_product->get_title();
664
+ $category_names = $category_names . ', ' . wp_strip_all_tags( wc_get_product_category_list( $_product->get_id() ) );
665
+ array_push(
666
+ $cart_contents,
667
+ array(
668
+ 'id' => $_product->get_id(),
669
+ 'name' => $_product->get_title(),
670
+ 'quantity' => $value['quantity'],
671
+ 'item_price' => $_product->get_price(),
672
+ )
673
+ );
674
+ }
675
+
676
+ $user = wp_get_current_user();
677
+ $roles = implode( ', ', $user->roles );
678
+ $params['content_name'] = substr( $product_names, 2 );
679
+ $params['categoey_name'] = substr( $category_names, 2 );
680
+ $params['user_roles'] = $roles;
681
+ $params['plugin'] = 'CartFlows';
682
+ $params['contents'] = wp_json_encode( $cart_contents );
683
+ $params['content_type'] = 'product';
684
+ $params['value'] = $cart_total;
685
+ $params['num_items'] = $cart_items_count;
686
+ $params['currency'] = get_woocommerce_currency();
687
+ $params['language'] = get_bloginfo( 'language' );
688
+ $params['userAgent'] = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); //phpcs:ignore
689
+ $params['product_catalog_id'] = '';
690
+ $params['domain'] = get_site_url();
691
+ return $params;
692
+ }
693
+
694
+ }
classes/class-cartflows-learndash-compatibility.php CHANGED
@@ -1,140 +1,140 @@
1
- <?php
2
- /**
3
- * LearnDash compatibility
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Class for LearnDash compatibility
10
- */
11
- class Cartflows_Learndash_Compatibility {
12
-
13
- /**
14
- * Member Variable
15
- *
16
- * @var instance
17
- */
18
- private static $instance;
19
-
20
- /**
21
- * Initiator
22
- */
23
- public static function get_instance() {
24
- if ( ! isset( self::$instance ) ) {
25
- self::$instance = new self();
26
- }
27
- return self::$instance;
28
- }
29
-
30
- /**
31
- * Constructor
32
- */
33
- public function __construct() {
34
- add_filter( 'learndash_post_args', array( $this, 'cartflows_course_setting_fields' ) );
35
- add_action( 'template_redirect', array( $this, 'cartflows_override_course_template' ) );
36
-
37
- }
38
-
39
- /**
40
- * Override course cartflows template.
41
- *
42
- * @return bool
43
- */
44
- public function cartflows_override_course_template() {
45
-
46
- // Don't run any code in admin area.
47
- if ( is_admin() ) {
48
- return false;
49
- }
50
-
51
- // Don't override the template if the post type is not `course`.
52
- if ( ! is_singular( 'sfwd-courses' ) ) {
53
- return false;
54
- }
55
-
56
- $course_id = learndash_get_course_id();
57
- $user_id = get_current_user_id();
58
- if ( is_user_logged_in() && sfwd_lms_has_access( $course_id, $user_id ) ) {
59
- return false;
60
- }
61
-
62
- if ( defined( LEARNDASH_VERSION ) && version_compare( LEARNDASH_VERSION, '2.6.4', '>' ) ) {
63
-
64
- $template = learndash_get_course_meta_setting( get_the_id(), 'wcf_course_template' );
65
- } else {
66
-
67
- $template = get_course_meta_setting( get_the_id(), 'wcf_course_template' );
68
- }
69
-
70
- if ( 'none' !== $template && $template ) {
71
- $link = get_permalink( $template );
72
- wp_safe_redirect( $link );
73
- }
74
- }
75
-
76
- /**
77
- * Add settings inside learndash settings.
78
- *
79
- * @param array $fields fields.
80
- * @return mixed
81
- */
82
- public function cartflows_course_setting_fields( $fields ) {
83
- global $post;
84
-
85
- $all_posts = array(
86
- 'none' => __( 'None', 'cartflows' ),
87
- );
88
-
89
- $landing_steps = get_posts(
90
- array(
91
- 'posts_per_page' => -1,
92
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
93
- 'post_status' => 'publish',
94
- 'orderby' => 'ID',
95
- 'order' => 'DESC',
96
- 'meta_query' => array( //phpcs:ignore
97
- array(
98
- 'key' => 'wcf-step-type',
99
- 'value' => array( 'landing', 'checkout' ),
100
- 'compare' => 'IN',
101
- ),
102
- ),
103
- )
104
- );
105
-
106
- foreach ( $landing_steps as $landing_step ) {
107
- $all_posts[ $landing_step->ID ] = get_the_title( $landing_step->ID ) . ' ( #' . $landing_step->ID . ')';
108
- }
109
-
110
- $selected = get_post_meta( get_the_ID(), 'wcf_course_template', true );
111
- $description = sprintf(
112
- /* translators: 1: anchor start, 2: anchor close */
113
- __( 'Non-enrolled students will redirect to the selected CartFlows template. If you have not created any Flow already, add new Flow from %1$shere%2$s.', 'cartflows' ),
114
- '<a href="' . esc_url( admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&add-new-flow' ) ) . '">',
115
- '</a>'
116
- );
117
-
118
- $fields['sfwd-courses']['fields']['wcf_course_template'] = array(
119
- 'name' => __( 'Select CartFlows Template for this Course', 'cartflows' ),
120
- 'type' => 'select',
121
- 'initial_options' => $all_posts,
122
- 'default' => 'none',
123
- 'help_text' => $description,
124
- 'show_in_rest' => true,
125
- 'rest_args' => array(
126
- 'schema' => array(
127
- 'type' => 'string',
128
- ),
129
- ),
130
- );
131
-
132
- return $fields;
133
- }
134
-
135
- }
136
-
137
- /**
138
- * Kicking this off by calling 'get_instance()' method
139
- */
140
- Cartflows_Learndash_Compatibility::get_instance();
1
+ <?php
2
+ /**
3
+ * LearnDash compatibility
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Class for LearnDash compatibility
10
+ */
11
+ class Cartflows_Learndash_Compatibility {
12
+
13
+ /**
14
+ * Member Variable
15
+ *
16
+ * @var instance
17
+ */
18
+ private static $instance;
19
+
20
+ /**
21
+ * Initiator
22
+ */
23
+ public static function get_instance() {
24
+ if ( ! isset( self::$instance ) ) {
25
+ self::$instance = new self();
26
+ }
27
+ return self::$instance;
28
+ }
29
+
30
+ /**
31
+ * Constructor
32
+ */
33
+ public function __construct() {
34
+ add_filter( 'learndash_post_args', array( $this, 'cartflows_course_setting_fields' ) );
35
+ add_action( 'template_redirect', array( $this, 'cartflows_override_course_template' ) );
36
+
37
+ }
38
+
39
+ /**
40
+ * Override course cartflows template.
41
+ *
42
+ * @return bool
43
+ */
44
+ public function cartflows_override_course_template() {
45
+
46
+ // Don't run any code in admin area.
47
+ if ( is_admin() ) {
48
+ return false;
49
+ }
50
+
51
+ // Don't override the template if the post type is not `course`.
52
+ if ( ! is_singular( 'sfwd-courses' ) ) {
53
+ return false;
54
+ }
55
+
56
+ $course_id = learndash_get_course_id();
57
+ $user_id = get_current_user_id();
58
+ if ( is_user_logged_in() && sfwd_lms_has_access( $course_id, $user_id ) ) {
59
+ return false;
60
+ }
61
+
62
+ if ( defined( LEARNDASH_VERSION ) && version_compare( LEARNDASH_VERSION, '2.6.4', '>' ) ) {
63
+
64
+ $template = learndash_get_course_meta_setting( get_the_id(), 'wcf_course_template' );
65
+ } else {
66
+
67
+ $template = get_course_meta_setting( get_the_id(), 'wcf_course_template' );
68
+ }
69
+
70
+ if ( 'none' !== $template && $template ) {
71
+ $link = get_permalink( $template );
72
+ wp_safe_redirect( $link );
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Add settings inside learndash settings.
78
+ *
79
+ * @param array $fields fields.
80
+ * @return mixed
81
+ */
82
+ public function cartflows_course_setting_fields( $fields ) {
83
+ global $post;
84
+
85
+ $all_posts = array(
86
+ 'none' => __( 'None', 'cartflows' ),
87
+ );
88
+
89
+ $landing_steps = get_posts(
90
+ array(
91
+ 'posts_per_page' => -1,
92
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
93
+ 'post_status' => 'publish',
94
+ 'orderby' => 'ID',
95
+ 'order' => 'DESC',
96
+ 'meta_query' => array( //phpcs:ignore
97
+ array(
98
+ 'key' => 'wcf-step-type',
99
+ 'value' => array( 'landing', 'checkout', 'optin' ),
100
+ 'compare' => 'IN',
101
+ ),
102
+ ),
103
+ )
104
+ );
105
+
106
+ foreach ( $landing_steps as $landing_step ) {
107
+ $all_posts[ $landing_step->ID ] = get_the_title( $landing_step->ID ) . ' ( #' . $landing_step->ID . ')';
108
+ }
109
+
110
+ $selected = get_post_meta( get_the_ID(), 'wcf_course_template', true );
111
+ $description = sprintf(
112
+ /* translators: 1: anchor start, 2: anchor close */
113
+ __( 'Non-enrolled students will redirect to the selected CartFlows template. If you have not created any Flow already, add new Flow from %1$shere%2$s.', 'cartflows' ),
114
+ '<a href="' . esc_url( admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&add-new-flow' ) ) . '">',
115
+ '</a>'
116
+ );
117
+
118
+ $fields['sfwd-courses']['fields']['wcf_course_template'] = array(
119
+ 'name' => __( 'Select CartFlows Template for this Course', 'cartflows' ),
120
+ 'type' => 'select',
121
+ 'initial_options' => $all_posts,
122
+ 'default' => 'none',
123
+ 'help_text' => $description,
124
+ 'show_in_rest' => true,
125
+ 'rest_args' => array(
126
+ 'schema' => array(
127
+ 'type' => 'string',
128
+ ),
129
+ ),
130
+ );
131
+
132
+ return $fields;
133
+ }
134
+
135
+ }
136
+
137
+ /**
138
+ * Kicking this off by calling 'get_instance()' method
139
+ */
140
+ Cartflows_Learndash_Compatibility::get_instance();
classes/class-cartflows-loader.php CHANGED
@@ -118,7 +118,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
118
  define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
119
  define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
120
  define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
121
- define( 'CARTFLOWS_VER', '1.4.0' );
122
  define( 'CARTFLOWS_SLUG', 'cartflows' );
123
  define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
124
 
118
  define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
119
  define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
120
  define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
121
+ define( 'CARTFLOWS_VER', '1.4.2' );
122
  define( 'CARTFLOWS_SLUG', 'cartflows' );
123
  define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
124
 
classes/class-cartflows-meta-fields.php CHANGED
@@ -42,8 +42,8 @@ class Cartflows_Meta_Fields {
42
  add_action( 'wp_ajax_wcf_json_search_pages', array( $this, 'json_search_pages' ) );
43
 
44
  add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
45
- }
46
 
 
47
  public function admin_meta_scripts() {
48
 
49
  global $pagenow;
@@ -273,7 +273,7 @@ class Cartflows_Meta_Fields {
273
  }
274
  }
275
 
276
- $field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
277
 
278
  return $this->get_field( $field_data, $field_content );
279
  }
@@ -686,13 +686,15 @@ class Cartflows_Meta_Fields {
686
  }
687
  }
688
 
 
 
689
  $field_html = '';
690
 
691
  $field_html .= '<script type="text/html" id="tmpl-wcf-product-repeater">';
692
  $field_html .= $this->generate_product_repeater_html( '{{id}}' );
693
  $field_html .= '</script>';
694
 
695
- $field_html .= '<div class="wcf-field-row">';
696
  $field_html .= '<div class="wcf-field-row-content">';
697
  $field_html .= '<div class="wcf-repeatables-wrap">';
698
 
@@ -718,11 +720,13 @@ class Cartflows_Meta_Fields {
718
  }
719
  }
720
 
721
- $field_html .= '<div class="wcf-add-repeatable-row">';
722
- $field_html .= '<div class="submit wcf-add-repeatable-wrap">';
723
- $field_html .= '<button class="button-primary wcf-add-repeatable" data-name="wcf-checkout-products">Add New Product</button>';
 
724
  $field_html .= '</div>';
725
  $field_html .= '</div>';
 
726
  $field_html .= '</div>';
727
  $field_html .= '</div>';
728
  $field_html .= '</div>';
@@ -782,7 +786,7 @@ class Cartflows_Meta_Fields {
782
  }
783
  $field_content .= '</div>';
784
  // $field_content .= '<input type="hidden" id="wcf-image-id" class="wcf-image-id" name="wcf-image-id[image-id]" value="">';
785
- $field_content .= '<input type="hidden" id="wcf-image-value" class="wcf-image" name="' . $field_data['name'] . '" value="'.$value.'">';
786
 
787
  $field_content .= '<button type="button" ' . $attr . ' class="wcf-select-image button-secondary">Select Image</button>';
788
 
@@ -810,6 +814,15 @@ class Cartflows_Meta_Fields {
810
  $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
811
  }
812
 
 
 
 
 
 
 
 
 
 
813
  return $vars;
814
  }
815
  }
42
  add_action( 'wp_ajax_wcf_json_search_pages', array( $this, 'json_search_pages' ) );
43
 
44
  add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
 
45
 
46
+ }
47
  public function admin_meta_scripts() {
48
 
49
  global $pagenow;
273
  }
274
  }
275
 
276
+ $field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . esc_attr( $value ) . '" ' . $attr . '>';
277
 
278
  return $this->get_field( $field_data, $field_content );
279
  }
686
  }
687
  }
688
 
689
+ $name_class = 'field-' . $field_data['name'];
690
+
691
  $field_html = '';
692
 
693
  $field_html .= '<script type="text/html" id="tmpl-wcf-product-repeater">';
694
  $field_html .= $this->generate_product_repeater_html( '{{id}}' );
695
  $field_html .= '</script>';
696
 
697
+ $field_html .= '<div class="wcf-field-row wcf-product-repeater-field-row ' . $name_class . '">';
698
  $field_html .= '<div class="wcf-field-row-content">';
699
  $field_html .= '<div class="wcf-repeatables-wrap">';
700
 
720
  }
721
  }
722
 
723
+ $field_html .= '<div class="wcf-add-repeatable-row">';
724
+ $field_html .= '<div class="submit wcf-add-repeatable-wrap">';
725
+ $field_html .= '<button class="button-primary wcf-add-repeatable" data-name="wcf-checkout-products">' . __( 'Add New Product', 'cartflows' ) . '</button>';
726
+ $field_html .= '<a href="#!" class="button button-primary wcf-create-woo-product" data-name="wcf-create-woo-product">'. __( 'Create Product', 'cartflows' ) . '</a>';
727
  $field_html .= '</div>';
728
  $field_html .= '</div>';
729
+
730
  $field_html .= '</div>';
731
  $field_html .= '</div>';
732
  $field_html .= '</div>';
786
  }
787
  $field_content .= '</div>';
788
  // $field_content .= '<input type="hidden" id="wcf-image-id" class="wcf-image-id" name="wcf-image-id[image-id]" value="">';
789
+ $field_content .= '<input type="hidden" id="'. $field_data['name'] .'" class="wcf-image" name="' . $field_data['name'] . '" value="'.$value.'">';
790
 
791
  $field_content .= '<button type="button" ' . $attr . ' class="wcf-select-image button-secondary">Select Image</button>';
792
 
814
  $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
815
  }
816
 
817
+ /* Add product from iframe */
818
+ $product_src = esc_url_raw( add_query_arg( array(
819
+ 'post_type' => 'product',
820
+ 'wcf-woo-iframe' => 'true',
821
+ ), admin_url( 'post-new.php' ) ) );
822
+
823
+ $vars['create_product_src'] = $product_src;
824
+ /* Add product from iframe End */
825
+
826
  return $vars;
827
  }
828
  }
classes/class-cartflows-meta.php CHANGED
@@ -1,75 +1,75 @@
1
- <?php
2
- /**
3
- * CartFlows Meta
4
- *
5
- * @package CartFlows
6
- * @since 1.0.0
7
- */
8
-
9
- if ( ! class_exists( 'Cartflows_Meta' ) ) :
10
-
11
- /**
12
- * CartFlows_Meta
13
- *
14
- * @since 1.0.0
15
- */
16
- class Cartflows_Meta {
17
- /**
18
- * Constructor
19
- *
20
- * @since 1.0.0
21
- */
22
- public function __construct() {
23
- }
24
-
25
- /**
26
- * Flow & Step Actions
27
- *
28
- * @param array $options options.
29
- * @param int $post_id post ID.
30
- */
31
- public function right_column_footer( $options, $post_id ) {
32
- ?>
33
- <div class="wcf-column-right-footer">
34
- <?php submit_button( __( 'Update', 'cartflows' ), 'primary', 'save', false ); ?>
35
-
36
- <?php
37
- $flow_id = get_post_meta( $post_id, 'wcf-flow-id', true );
38
- if ( $flow_id ) {
39
- ?>
40
- <a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button pull-right wcf-back-to-flow-edit">
41
- <i class="dashicons dashicons-arrow-left-alt"></i>
42
- <?php esc_html_e( 'Back to edit Flow', 'cartflows' ); ?>
43
- </a>
44
- <?php } ?>
45
-
46
- </div>
47
- <?php
48
- }
49
-
50
- /**
51
- * Script Header (Used for add script into header)
52
- *
53
- * @param array $options options.
54
- * @param int $post_id post ID.
55
- */
56
- public function tab_custom_script( $options, $post_id ) {
57
- ?>
58
- <div class="wcf-<?php echo wcf()->utils->get_step_type( $post_id ); ?>-custom-script-header wcf-tab-content widefat">
59
- <?php
60
- /* Script added onto the header */
61
- echo wcf()->meta->get_area_field(
62
- array(
63
- 'label' => __( 'Custom Script', 'cartflows' ),
64
- 'name' => 'wcf-custom-script',
65
- 'value' => htmlspecialchars( $options['wcf-custom-script'], ENT_COMPAT, 'utf-8' ),
66
- 'help' => esc_html__( 'Custom script lets you add your own custom script on front end of this flow page.', 'cartflows' ),
67
- )
68
- );
69
- ?>
70
- </div>
71
- <?php
72
- }
73
- }
74
-
75
- endif;
1
+ <?php
2
+ /**
3
+ * CartFlows Meta
4
+ *
5
+ * @package CartFlows
6
+ * @since 1.0.0
7
+ */
8
+
9
+ if ( ! class_exists( 'Cartflows_Meta' ) ) :
10
+
11
+ /**
12
+ * CartFlows_Meta
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ class Cartflows_Meta {
17
+ /**
18
+ * Constructor
19
+ *
20
+ * @since 1.0.0
21
+ */
22
+ public function __construct() {
23
+ }
24
+
25
+ /**
26
+ * Flow & Step Actions
27
+ *
28
+ * @param array $options options.
29
+ * @param int $post_id post ID.
30
+ */
31
+ public function right_column_footer( $options, $post_id ) {
32
+ ?>
33
+ <div class="wcf-column-right-footer">
34
+ <?php submit_button( __( 'Update', 'cartflows' ), 'primary', 'wcf-save', false ); ?>
35
+
36
+ <?php
37
+ $flow_id = get_post_meta( $post_id, 'wcf-flow-id', true );
38
+ if ( $flow_id ) {
39
+ ?>
40
+ <a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button pull-right wcf-back-to-flow-edit">
41
+ <i class="dashicons dashicons-arrow-left-alt"></i>
42
+ <?php esc_html_e( 'Back to edit Flow', 'cartflows' ); ?>
43
+ </a>
44
+ <?php } ?>
45
+
46
+ </div>
47
+ <?php
48
+ }
49
+
50
+ /**
51
+ * Script Header (Used for add script into header)
52
+ *
53
+ * @param array $options options.
54
+ * @param int $post_id post ID.
55
+ */
56
+ public function tab_custom_script( $options, $post_id ) {
57
+ ?>
58
+ <div class="wcf-<?php echo wcf()->utils->get_step_type( $post_id ); ?>-custom-script-header wcf-tab-content widefat">
59
+ <?php
60
+ /* Script added onto the header */
61
+ echo wcf()->meta->get_area_field(
62
+ array(
63
+ 'label' => __( 'Custom Script', 'cartflows' ),
64
+ 'name' => 'wcf-custom-script',
65
+ 'value' => htmlspecialchars( $options['wcf-custom-script'], ENT_COMPAT, 'utf-8' ),
66
+ 'help' => esc_html__( 'Custom script lets you add your own custom script on front end of this flow page.', 'cartflows' ),
67
+ )
68
+ );
69
+ ?>
70
+ </div>
71
+ <?php
72
+ }
73
+ }
74
+
75
+ endif;
classes/class-cartflows-utils.php CHANGED
@@ -1,455 +1,455 @@
1
- <?php
2
- /**
3
- * Utils.
4
- *
5
- * @package CARTFLOWS
6
- */
7
-
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit; // Exit if accessed directly.
10
- }
11
-
12
- /**
13
- * Class Cartflows_Utils.
14
- */
15
- class Cartflows_Utils {
16
-
17
- /**
18
- * Member Variable
19
- *
20
- * @var instance
21
- */
22
- private static $instance;
23
-
24
- /**
25
- * Initiator
26
- */
27
- public static function get_instance() {
28
- if ( ! isset( self::$instance ) ) {
29
- self::$instance = new self();
30
- }
31
- return self::$instance;
32
- }
33
-
34
- /**
35
- * Constructor
36
- */
37
- public function __construct() {
38
- }
39
-
40
- /**
41
- * Get current post type
42
- *
43
- * @param string $post_type post type.
44
- * @return string
45
- */
46
- public function current_post_type( $post_type = '' ) {
47
-
48
- if ( '' === $post_type ) {
49
- $post_type = get_post_type();
50
- }
51
-
52
- return $post_type;
53
- }
54
-
55
- /**
56
- * Check if post type is of step.
57
- *
58
- * @param string $post_type post type.
59
- * @return bool
60
- */
61
- public function is_step_post_type( $post_type = '' ) {
62
-
63
- if ( $this->get_step_post_type() === $this->current_post_type( $post_type ) ) {
64
-
65
- return true;
66
- }
67
-
68
- return false;
69
- }
70
-
71
- /**
72
- * Check if post type is of flow.
73
- *
74
- * @param string $post_type post type.
75
- * @return bool
76
- */
77
- public function is_flow_post_type( $post_type = '' ) {
78
-
79
- if ( $this->get_flow_post_type() === $this->current_post_type( $post_type ) ) {
80
-
81
- return true;
82
- }
83
-
84
- return false;
85
- }
86
-
87
- /**
88
- * Get post type of step.
89
- *
90
- * @return string
91
- */
92
- public function get_step_post_type() {
93
-
94
- return CARTFLOWS_STEP_POST_TYPE;
95
- }
96
-
97
- /**
98
- * Get post type of flow.
99
- *
100
- * @return string
101
- */
102
- public function get_flow_post_type() {
103
-
104
- return CARTFLOWS_FLOW_POST_TYPE;
105
- }
106
-
107
- /**
108
- * Get flow id
109
- *
110
- * @return int
111
- */
112
- public function get_flow_id() {
113
-
114
- global $post;
115
-
116
- return get_post_meta( $post->ID, 'wcf-flow-id', true );
117
- }
118
-
119
- /**
120
- * Get flow id by step
121
- *
122
- * @param int $step_id step ID.
123
- * @return int
124
- */
125
- public function get_flow_id_from_step_id( $step_id ) {
126
-
127
- return get_post_meta( $step_id, 'wcf-flow-id', true );
128
- }
129
-
130
- /**
131
- * Get flow steps by id
132
- *
133
- * @param int $flow_id flow ID.
134
- * @return int
135
- */
136
- public function get_flow_steps( $flow_id ) {
137
-
138
- $steps = get_post_meta( $flow_id, 'wcf-steps', true );
139
-
140
- if ( is_array( $steps ) && ! empty( $steps ) ) {
141
- return $steps;
142
- }
143
-
144
- return false;
145
- }
146
-
147
- /**
148
- * Get template type of step
149
- *
150
- * @param int $step_id step ID.
151
- * @return int
152
- */
153
- public function get_step_type( $step_id ) {
154
-
155
- return get_post_meta( $step_id, 'wcf-step-type', true );
156
- }
157
-
158
- /**
159
- * Get next id for step
160
- *
161
- * @param int $flow_id flow ID.
162
- * @param int $step_id step ID.
163
- * @return bool
164
- */
165
- public function get_next_step_id( $flow_id, $step_id ) {
166
-
167
- $steps = $this->get_flow_steps( $flow_id );
168
- $step_id = intval( $step_id );
169
-
170
- if ( ! $steps ) {
171
- return false;
172
- }
173
-
174
- foreach ( $steps as $i => $step ) {
175
-
176
- if ( intval( $step['id'] ) === $step_id ) {
177
-
178
- $next_i = $i + 1;
179
-
180
- if ( isset( $steps[ $next_i ] ) ) {
181
-
182
- $navigation = $steps[ $next_i ];
183
-
184
- return intval( $navigation['id'] );
185
- }
186
-
187
- break;
188
- }
189
- }
190
-
191
- return false;
192
- }
193
-
194
- /**
195
- * Get next id for step
196
- *
197
- * @param int $order_id order ID.
198
- * @return int
199
- */
200
- public function get_flow_id_from_order( $order_id ) {
201
-
202
- $flow_id = get_post_meta( $order_id, '_wcf_flow_id', true );
203
-
204
- return intval( $flow_id );
205
- }
206
-
207
- /**
208
- * Get checkout id for order
209
- *
210
- * @param int $order_id order ID.
211
- * @return int
212
- */
213
- public function get_checkout_id_from_order( $order_id ) {
214
-
215
- $checkout_id = get_post_meta( $order_id, '_wcf_checkout_id', true );
216
-
217
- return intval( $checkout_id );
218
- }
219
-
220
- /**
221
- * We are using this function mostly in ajax on checkout page
222
- *
223
- * @return bool
224
- */
225
- public function get_checkout_id_from_post_data() {
226
-
227
- if ( isset( $_POST['_wcf_checkout_id'] ) ) { //phpcs:ignore
228
-
229
- $checkout_id = filter_var( wp_unslash( $_POST['_wcf_checkout_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore
230
-
231
- return intval( $checkout_id );
232
- }
233
-
234
- return false;
235
- }
236
-
237
- /**
238
- * We are using this function mostly in ajax on checkout page
239
- *
240
- * @return bool
241
- */
242
- public function get_flow_id_from_post_data() {
243
-
244
- if ( isset( $_POST['_wcf_flow_id'] ) ) { //phpcs:ignore
245
-
246
- $flow_id = filter_var( wp_unslash( $_POST['_wcf_flow_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore
247
-
248
- return intval( $flow_id );
249
- }
250
-
251
- return false;
252
- }
253
-
254
- /**
255
- * Get optin id for order
256
- *
257
- * @param int $order_id order ID.
258
- * @return int
259
- */
260
- public function get_optin_id_from_order( $order_id ) {
261
-
262
- $optin_id = get_post_meta( $order_id, '_wcf_optin_id', true );
263
-
264
- return intval( $optin_id );
265
- }
266
-
267
- /**
268
- * We are using this function mostly in ajax on checkout page
269
- *
270
- * @return bool
271
- */
272
- public function get_optin_id_from_post_data() {
273
-
274
- if ( isset( $_POST['_wcf_optin_id'] ) ) { //phpcs:ignore
275
-
276
- $optin_id = filter_var( wp_unslash( $_POST['_wcf_optin_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore
277
-
278
- return intval( $optin_id );
279
- }
280
-
281
- return false;
282
- }
283
-
284
- /**
285
- * Check for thank you page
286
- *
287
- * @param int $step_id step ID.
288
- * @return bool
289
- */
290
- public function check_is_thankyou_page( $step_id ) {
291
-
292
- $step_type = $this->get_step_type( $step_id );
293
-
294
- if ( 'thankyou' === $step_type ) {
295
-
296
- return true;
297
- }
298
-
299
- return false;
300
- }
301
-
302
- /**
303
- * Check for offer page
304
- *
305
- * @param int $step_id step ID.
306
- * @return bool
307
- */
308
- public function check_is_offer_page( $step_id ) {
309
-
310
- $step_type = $this->get_step_type( $step_id );
311
-
312
- if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
313
-
314
- return true;
315
- }
316
-
317
- return false;
318
- }
319
-
320
- /**
321
- * Check if loaded page requires woo.
322
- *
323
- * @return bool
324
- */
325
- public function check_is_woo_required_page() {
326
-
327
- global $post;
328
- $step_id = $post->ID;
329
- $woo_not_required_type = array( 'landing' );
330
- $step_type = $this->get_step_type( $step_id );
331
- return ( ! in_array( $step_type, $woo_not_required_type, true ) );
332
- }
333
-
334
- /**
335
- * Define constant for cache
336
- *
337
- * @return void
338
- */
339
- public function do_not_cache() {
340
-
341
- wcf_maybe_define_constant( 'DONOTCACHEPAGE', true );
342
- wcf_maybe_define_constant( 'DONOTCACHEOBJECT', true );
343
- wcf_maybe_define_constant( 'DONOTCACHEDB', true );
344
-
345
- nocache_headers();
346
- }
347
-
348
- /**
349
- * Get linking url
350
- *
351
- * @param array $args query args.
352
- * @return string
353
- */
354
- public function get_linking_url( $args = array() ) {
355
-
356
- $url = get_home_url();
357
-
358
- $url = add_query_arg( $args, $url );
359
-
360
- return $url;
361
- }
362
-
363
- /**
364
- * Get assets urls
365
- *
366
- * @return array
367
- * @since 1.1.6
368
- */
369
- public function get_assets_path() {
370
-
371
- $rtl = '';
372
-
373
- if ( is_rtl() ) {
374
- $rtl = '-rtl';
375
- }
376
-
377
- $file_prefix = '';
378
- $dir_name = '';
379
-
380
- $is_min = apply_filters( 'cartflows_load_min_assets', false );
381
-
382
- if ( $is_min ) {
383
- $file_prefix = '.min';
384
- $dir_name = 'min-';
385
- }
386
-
387
- $js_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'js/';
388
- $css_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'css/';
389
-
390
- return array(
391
- 'css' => $css_gen_path,
392
- 'js' => $js_gen_path,
393
- 'file_prefix' => $file_prefix,
394
- 'rtl' => $rtl,
395
- );
396
- }
397
-
398
- /**
399
- * Get assets css url
400
- *
401
- * @param string $file file name.
402
- * @return string
403
- * @since 1.1.6
404
- */
405
- public function get_css_url( $file ) {
406
-
407
- $assets_vars = wcf()->assets_vars;
408
-
409
- $url = $assets_vars['css'] . $file . $assets_vars['rtl'] . $assets_vars['file_prefix'] . '.css';
410
-
411
- return $url;
412
- }
413
-
414
- /**
415
- * Get assets js url
416
- *
417
- * @param string $file file name.
418
- * @return string
419
- * @since 1.1.6
420
- */
421
- public function get_js_url( $file ) {
422
-
423
- $assets_vars = wcf()->assets_vars;
424
-
425
- $url = $assets_vars['js'] . $file . $assets_vars['file_prefix'] . '.js';
426
-
427
- return $url;
428
- }
429
- }
430
-
431
- /**
432
- * Get a specific property of an array without needing to check if that property exists.
433
- *
434
- * Provide a default value if you want to return a specific value if the property is not set.
435
- *
436
- * @param array $array Array from which the property's value should be retrieved.
437
- * @param string $prop Name of the property to be retrieved.
438
- * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null.
439
- *
440
- * @return null|string|mixed The value
441
- */
442
- function wcf_get_prop( $array, $prop, $default = null ) {
443
-
444
- if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) {
445
- return $default;
446
- }
447
-
448
- if ( isset( $array[ $prop ] ) ) {
449
- $value = $array[ $prop ];
450
- } else {
451
- $value = '';
452
- }
453
-
454
- return empty( $value ) && null !== $default ? $default : $value;
455
- }
1
+ <?php
2
+ /**
3
+ * Utils.
4
+ *
5
+ * @package CARTFLOWS
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly.
10
+ }
11
+
12
+ /**
13
+ * Class Cartflows_Utils.
14
+ */
15
+ class Cartflows_Utils {
16
+
17
+ /**
18
+ * Member Variable
19
+ *
20
+ * @var instance
21
+ */
22
+ private static $instance;
23
+
24
+ /**
25
+ * Initiator
26
+ */
27
+ public static function get_instance() {
28
+ if ( ! isset( self::$instance ) ) {
29
+ self::$instance = new self();
30
+ }
31
+ return self::$instance;
32
+ }
33
+
34
+ /**
35
+ * Constructor
36
+ */
37
+ public function __construct() {
38
+ }
39
+
40
+ /**
41
+ * Get current post type
42
+ *
43
+ * @param string $post_type post type.
44
+ * @return string
45
+ */
46
+ public function current_post_type( $post_type = '' ) {
47
+
48
+ if ( '' === $post_type ) {
49
+ $post_type = get_post_type();
50
+ }
51
+
52
+ return $post_type;
53
+ }
54
+
55
+ /**
56
+ * Check if post type is of step.
57
+ *
58
+ * @param string $post_type post type.
59
+ * @return bool
60
+ */
61
+ public function is_step_post_type( $post_type = '' ) {
62
+
63
+ if ( $this->get_step_post_type() === $this->current_post_type( $post_type ) ) {
64
+
65
+ return true;
66
+ }
67
+
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * Check if post type is of flow.
73
+ *
74
+ * @param string $post_type post type.
75
+ * @return bool
76
+ */
77
+ public function is_flow_post_type( $post_type = '' ) {
78
+
79
+ if ( $this->get_flow_post_type() === $this->current_post_type( $post_type ) ) {
80
+
81
+ return true;
82
+ }
83
+
84
+ return false;
85
+ }
86
+
87
+ /**
88
+ * Get post type of step.
89
+ *
90
+ * @return string
91
+ */
92
+ public function get_step_post_type() {
93
+
94
+ return CARTFLOWS_STEP_POST_TYPE;
95
+ }
96
+
97
+ /**
98
+ * Get post type of flow.
99
+ *
100
+ * @return string
101
+ */
102
+ public function get_flow_post_type() {
103
+
104
+ return CARTFLOWS_FLOW_POST_TYPE;
105
+ }
106
+
107
+ /**
108
+ * Get flow id
109
+ *
110
+ * @return int
111
+ */
112
+ public function get_flow_id() {
113
+
114
+ global $post;
115
+
116
+ return get_post_meta( $post->ID, 'wcf-flow-id', true );
117
+ }
118
+
119
+ /**
120
+ * Get flow id by step
121
+ *
122
+ * @param int $step_id step ID.
123
+ * @return int
124
+ */
125
+ public function get_flow_id_from_step_id( $step_id ) {
126
+
127
+ return get_post_meta( $step_id, 'wcf-flow-id', true );
128
+ }
129
+
130
+ /**
131
+ * Get flow steps by id
132
+ *
133
+ * @param int $flow_id flow ID.
134
+ * @return int
135
+ */
136
+ public function get_flow_steps( $flow_id ) {
137
+
138
+ $steps = get_post_meta( $flow_id, 'wcf-steps', true );
139
+
140
+ if ( is_array( $steps ) && ! empty( $steps ) ) {
141
+ return $steps;
142
+ }
143
+
144
+ return false;
145
+ }
146
+
147
+ /**
148
+ * Get template type of step
149
+ *
150
+ * @param int $step_id step ID.
151
+ * @return int
152
+ */
153
+ public function get_step_type( $step_id ) {
154
+
155
+ return get_post_meta( $step_id, 'wcf-step-type', true );
156
+ }
157
+
158
+ /**
159
+ * Get next id for step
160
+ *
161
+ * @param int $flow_id flow ID.
162
+ * @param int $step_id step ID.
163
+ * @return bool
164
+ */
165
+ public function get_next_step_id( $flow_id, $step_id ) {
166
+
167
+ $steps = $this->get_flow_steps( $flow_id );
168
+ $step_id = intval( $step_id );
169
+
170
+ if ( ! $steps ) {
171
+ return false;
172
+ }
173
+
174
+ foreach ( $steps as $i => $step ) {
175
+
176
+ if ( intval( $step['id'] ) === $step_id ) {
177
+
178
+ $next_i = $i + 1;
179
+
180
+ if ( isset( $steps[ $next_i ] ) ) {
181
+
182
+ $navigation = $steps[ $next_i ];
183
+
184
+ return intval( $navigation['id'] );
185
+ }
186
+
187
+ break;
188
+ }
189
+ }
190
+
191
+ return false;
192
+ }
193
+
194
+ /**
195
+ * Get next id for step
196
+ *
197
+ * @param int $order_id order ID.
198
+ * @return int
199
+ */
200
+ public function get_flow_id_from_order( $order_id ) {
201
+
202
+ $flow_id = get_post_meta( $order_id, '_wcf_flow_id', true );
203
+
204
+ return intval( $flow_id );
205
+ }
206
+
207
+ /**
208
+ * Get checkout id for order
209
+ *
210
+ * @param int $order_id order ID.
211
+ * @return int
212
+ */
213
+ public function get_checkout_id_from_order( $order_id ) {
214
+
215
+ $checkout_id = get_post_meta( $order_id, '_wcf_checkout_id', true );
216
+
217
+ return intval( $checkout_id );
218
+ }
219
+
220
+ /**
221
+ * We are using this function mostly in ajax on checkout page
222
+ *
223
+ * @return bool
224
+ */
225
+ public function get_checkout_id_from_post_data() {
226
+
227
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) { //phpcs:ignore
228
+
229
+ $checkout_id = filter_var( wp_unslash( $_POST['_wcf_checkout_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore
230
+
231
+ return intval( $checkout_id );
232
+ }
233
+
234
+ return false;
235
+ }
236
+
237
+ /**
238
+ * We are using this function mostly in ajax on checkout page
239
+ *
240
+ * @return bool
241
+ */
242
+ public function get_flow_id_from_post_data() {
243
+
244
+ if ( isset( $_POST['_wcf_flow_id'] ) ) { //phpcs:ignore
245
+
246
+ $flow_id = filter_var( wp_unslash( $_POST['_wcf_flow_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore
247
+
248
+ return intval( $flow_id );
249
+ }
250
+
251
+ return false;
252
+ }
253
+
254
+ /**
255
+ * Get optin id for order
256
+ *
257
+ * @param int $order_id order ID.
258
+ * @return int
259
+ */
260
+ public function get_optin_id_from_order( $order_id ) {
261
+
262
+ $optin_id = get_post_meta( $order_id, '_wcf_optin_id', true );
263
+
264
+ return intval( $optin_id );
265
+ }
266
+
267
+ /**
268
+ * We are using this function mostly in ajax on checkout page
269
+ *
270
+ * @return bool
271
+ */
272
+ public function get_optin_id_from_post_data() {
273
+
274
+ if ( isset( $_POST['_wcf_optin_id'] ) ) { //phpcs:ignore
275
+
276
+ $optin_id = filter_var( wp_unslash( $_POST['_wcf_optin_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore
277
+
278
+ return intval( $optin_id );
279
+ }
280
+
281
+ return false;
282
+ }
283
+
284
+ /**
285
+ * Check for thank you page
286
+ *
287
+ * @param int $step_id step ID.
288
+ * @return bool
289
+ */
290
+ public function check_is_thankyou_page( $step_id ) {
291
+
292
+ $step_type = $this->get_step_type( $step_id );
293
+
294
+ if ( 'thankyou' === $step_type ) {
295
+
296
+ return true;
297
+ }
298
+
299
+ return false;
300
+ }
301
+
302
+ /**
303
+ * Check for offer page
304
+ *
305
+ * @param int $step_id step ID.
306
+ * @return bool
307
+ */
308
+ public function check_is_offer_page( $step_id ) {
309
+
310
+ $step_type = $this->get_step_type( $step_id );
311
+
312
+ if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
313
+
314
+ return true;
315
+ }
316
+
317
+ return false;
318
+ }
319
+
320
+ /**
321
+ * Check if loaded page requires woo.
322
+ *
323
+ * @return bool
324
+ */
325
+ public function check_is_woo_required_page() {
326
+
327
+ global $post;
328
+ $step_id = $post->ID;
329
+ $woo_not_required_type = array( 'landing' );
330
+ $step_type = $this->get_step_type( $step_id );
331
+ return ( ! in_array( $step_type, $woo_not_required_type, true ) );
332
+ }
333
+
334
+ /**
335
+ * Define constant for cache
336
+ *
337
+ * @return void
338
+ */
339
+ public function do_not_cache() {
340
+
341
+ wcf_maybe_define_constant( 'DONOTCACHEPAGE', true );
342
+ wcf_maybe_define_constant( 'DONOTCACHEOBJECT', true );
343
+ wcf_maybe_define_constant( 'DONOTCACHEDB', true );
344
+
345
+ nocache_headers();
346
+ }
347
+
348
+ /**
349
+ * Get linking url
350
+ *
351
+ * @param array $args query args.
352
+ * @return string
353
+ */
354
+ public function get_linking_url( $args = array() ) {
355
+
356
+ $url = get_home_url();
357
+
358
+ $url = add_query_arg( $args, $url );
359
+
360
+ return $url;
361
+ }
362
+
363
+ /**
364
+ * Get assets urls
365
+ *
366
+ * @return array
367
+ * @since 1.1.6
368
+ */
369
+ public function get_assets_path() {
370
+
371
+ $rtl = '';
372
+
373
+ if ( is_rtl() ) {
374
+ $rtl = '-rtl';
375
+ }
376
+
377
+ $file_prefix = '';
378
+ $dir_name = '';
379
+
380
+ $is_min = apply_filters( 'cartflows_load_min_assets', false );
381
+
382
+ if ( $is_min ) {
383
+ $file_prefix = '.min';
384
+ $dir_name = 'min-';
385
+ }
386
+
387
+ $js_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'js/';
388
+ $css_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'css/';
389
+
390
+ return array(
391
+ 'css' => $css_gen_path,
392
+ 'js' => $js_gen_path,
393
+ 'file_prefix' => $file_prefix,
394
+ 'rtl' => $rtl,
395
+ );
396
+ }
397
+
398
+ /**
399
+ * Get assets css url
400
+ *
401
+ * @param string $file file name.
402
+ * @return string
403
+ * @since 1.1.6
404
+ */
405
+ public function get_css_url( $file ) {
406
+
407
+ $assets_vars = wcf()->assets_vars;
408
+
409
+ $url = $assets_vars['css'] . $file . $assets_vars['rtl'] . $assets_vars['file_prefix'] . '.css';
410
+
411
+ return $url;
412
+ }
413
+
414
+ /**
415
+ * Get assets js url
416
+ *
417
+ * @param string $file file name.
418
+ * @return string
419
+ * @since 1.1.6
420
+ */
421
+ public function get_js_url( $file ) {
422
+
423
+ $assets_vars = wcf()->assets_vars;
424
+
425
+ $url = $assets_vars['js'] . $file . $assets_vars['file_prefix'] . '.js';
426
+
427
+ return $url;
428
+ }
429
+ }
430
+
431
+ /**
432
+ * Get a specific property of an array without needing to check if that property exists.
433
+ *
434
+ * Provide a default value if you want to return a specific value if the property is not set.
435
+ *
436
+ * @param array $array Array from which the property's value should be retrieved.
437
+ * @param string $prop Name of the property to be retrieved.
438
+ * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null.
439
+ *
440
+ * @return null|string|mixed The value
441
+ */
442
+ function wcf_get_prop( $array, $prop, $default = null ) {
443
+
444
+ if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) {
445
+ return $default;
446
+ }
447
+
448
+ if ( isset( $array[ $prop ] ) ) {
449
+ $value = $array[ $prop ];
450
+ } else {
451
+ $value = '';
452
+ }
453
+
454
+ return empty( $value ) && null !== $default ? $default : $value;
455
+ }
includes/admin/cartflows-general.php CHANGED
@@ -1,370 +1,370 @@
1
- <?php
2
- /**
3
- * General settings
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- $settings = Cartflows_Helper::get_common_settings();
9
-
10
- $debug_data = Cartflows_Helper::get_debug_settings();
11
-
12
- $permalink_settings = Cartflows_Helper::get_permalink_settings();
13
-
14
- $facebook_settings = Cartflows_Helper::get_facebook_settings();
15
-
16
- $debug_on = ( isset( $_GET['debug'] ) ) ? sanitize_text_field( wp_unslash( $_GET['debug'] ) ) : 'false'; //phpcs:ignore
17
-
18
- $error_log = filter_input( INPUT_GET, 'cartflows-error-log', FILTER_VALIDATE_BOOLEAN );
19
- ?>
20
-
21
-
22
- <?php if ( $error_log ) : ?>
23
- <div class="wrap wcf-addon-wrap wcf-clear wcf-container">
24
- <?php Cartflows_Logger::status_logs_file(); ?>
25
- </div>
26
- <?php else : ?>
27
- <div class="wrap wcf-addon-wrap wcf-clear wcf-container">
28
- <input type="hidden" name="action" value="wcf_save_common_settings">
29
- <h1 class="screen-reader-text"><?php esc_html_e( 'General Settings', 'cartflows' ); ?></h1>
30
-
31
- <div id="poststuff">
32
- <div id="post-body" class="columns-2">
33
- <div id="post-body-content">
34
- <div class="postbox introduction">
35
- <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
36
- <span><?php esc_html_e( 'Getting Started', 'cartflows' ); ?></span>
37
- </h2>
38
- <div class="inside">
39
- <div class="iframe-wrap">
40
- <iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
41
- </div>
42
- <p>
43
- <?php
44
- esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
45
- ?>
46
- </p>
47
- </div>
48
- </div>
49
-
50
- <div class="general-settings-form postbox">
51
- <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
52
- <span><?php esc_html_e( 'General Settings', 'cartflows' ); ?></span>
53
- </h2>
54
- <div class="inside">
55
- <form method="post" class="wrap wcf-clear" action="" >
56
- <div class="form-wrap">
57
- <?php
58
-
59
- do_action( 'cartflows_before_settings_fields', $settings );
60
-
61
- echo Cartflows_Admin_Fields::checkobox_field(
62
- array(
63
- 'id' => 'wcf_disallow_indexing',
64
- 'name' => '_cartflows_common[disallow_indexing]',
65
- 'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
66
- 'value' => $settings['disallow_indexing'],
67
- )
68
- );
69
-
70
- if ( wcf()->is_woo_active ) {
71
- echo Cartflows_Admin_Fields::flow_checkout_selection_field(
72
- array(
73
- 'id' => 'wcf_global_checkout',
74
- 'name' => '_cartflows_common[global_checkout]',
75
- 'title' => __( 'Global Checkout', 'cartflows' ),
76
- 'value' => $settings['global_checkout'],
77
- )
78
- );
79
- }
80
- echo Cartflows_Admin_Fields::select_field(
81
- array(
82
- 'id' => 'wcf_default_page_builder',
83
- 'name' => '_cartflows_common[default_page_builder]',
84
- 'title' => __( 'Show Templates designed with', 'cartflows' ),
85
- 'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
86
- 'value' => $settings['default_page_builder'],
87
- 'options' => array(
88
- 'elementor' => __( 'Elementor', 'cartflows' ),
89
- 'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
90
- 'divi' => __( 'Divi', 'cartflows' ),
91
- 'other' => __( 'Other', 'cartflows' ),
92
- ),
93
- )
94
- );
95
-
96
- do_action( 'cartflows_after_settings_fields', $settings );
97
-
98
- ?>
99
- </div>
100
- <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
101
- <?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
102
- </form>
103
- </div>
104
- </div>
105
-
106
- <div class="general-settingss-form postbox">
107
- <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
108
- <span><?php esc_html_e( 'Permalink Settings', 'cartflows' ); ?></span>
109
- </h2>
110
- <div class="inside">
111
- <form method="post" class="wrap wcf-clear" action="" >
112
- <div class="form-wrap wcf_permalink_settings">
113
- <?php
114
-
115
- echo Cartflows_Admin_Fields::radio_field(
116
- array(
117
- 'id' => 'permalink_structure',
118
- 'name' => '_cartflows_permalink[permalink_structure]',
119
- 'value' => $permalink_settings['permalink_structure'],
120
- 'options' => array(
121
- '' =>
122
- array(
123
- 'label' => __( 'Default', 'cartflows' ),
124
- 'description' => 'Default WordPress Permalink',
125
- ),
126
-
127
- '/' . CARTFLOWS_FLOW_POST_TYPE . '/%flowname%/' . CARTFLOWS_STEP_POST_TYPE =>
128
- array(
129
- 'label' => __( 'Flow and Step Slug', 'cartflows' ),
130
- 'description' => '/<code>' . CARTFLOWS_FLOW_POST_TYPE . '</code>/%flowname%/<code>' . CARTFLOWS_STEP_POST_TYPE . '</code>/%stepname%/',
131
- ),
132
-
133
- '/' . CARTFLOWS_FLOW_POST_TYPE . '/%flowname%' =>
134
- array(
135
- 'label' => __( 'Flow Slug', 'cartflows' ),
136
- 'description' => '/<code>' . CARTFLOWS_FLOW_POST_TYPE . '</code>/%flowname%/%stepname%/',
137
- ),
138
-
139
- '/%flowname%/' . CARTFLOWS_STEP_POST_TYPE =>
140
- array(
141
- 'label' => __( 'Step Slug', 'cartflows' ),
142
- 'description' => '/%flowname%/<code>' . CARTFLOWS_STEP_POST_TYPE . '</code>/%stepname%/',
143
- ),
144
- ),
145
- )
146
- );
147
- ?>
148
- <hr/>
149
- <?php
150
-
151
- echo Cartflows_Admin_Fields::title_field(
152
- array(
153
- 'title' => __( 'Post Type Permalink Base', 'cartflows' ),
154
- )
155
- );
156
-
157
- echo Cartflows_Admin_Fields::text_field(
158
- array(
159
- 'id' => 'wcf_permalink_step_base',
160
- 'name' => '_cartflows_permalink[permalink]',
161
- 'title' => __( 'Step Base', 'cartflows' ),
162
- 'value' => $permalink_settings['permalink'],
163
- 'placeholder' => CARTFLOWS_STEP_POST_TYPE,
164
- )
165
- );
166
-
167
- echo Cartflows_Admin_Fields::text_field(
168
- array(
169
- 'id' => 'wcf_permalink_flow_base',
170
- 'name' => '_cartflows_permalink[permalink_flow_base]',
171
- 'title' => __( 'Flow Base', 'cartflows' ),
172
- 'value' => $permalink_settings['permalink_flow_base'],
173
- 'placeholder' => CARTFLOWS_FLOW_POST_TYPE,
174
- )
175
- );
176
-
177
- ?>
178
-
179
-
180
- </div>
181
- <p>
182
- <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
183
- <?php submit_button( __( 'Set Default', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'reset', false ); ?>
184
- <?php wp_nonce_field( 'cartflows-permalink-settings', 'cartflows-permalink-settings-nonce' ); ?>
185
- </p>
186
-
187
-
188
- </form>
189
- </div>
190
- </div>
191
-
192
-
193
- <div class="general-settingss-form postbox">
194
- <h2 class="wcf-facebook-hndle wcf-normal-cusror ui-sortable-handle hndle">
195
-
196
- <span><?php esc_html_e( 'Facebook Pixel Settings', 'cartflows' ); ?></span>
197
- </h2>
198
-
199
- <form method="post" class="wrap wcf-clear" action="">
200
- <div class="form-wrap">
201
- <input type="hidden" name="action" value="wcf_save_facebook_pixel_settings">
202
- <div id="post-body">
203
-
204
- <div class="inside">
205
- <div class="form-wrap">
206
- <?php
207
- echo Cartflows_Admin_Fields::checkobox_field(
208
- array(
209
- 'id' => 'wcf_facebook_pixel_tracking',
210
- 'name' => '_cartflows_facebook[facebook_pixel_tracking]',
211
- 'title' => __( 'Enable Facebook Pixel Tracking', 'cartflows' ),
212
- 'value' => $facebook_settings['facebook_pixel_tracking'],
213
- )
214
- );
215
-
216
- echo "<div class='wcf-fb-pixel-wrapper'>";
217
-
218
- echo Cartflows_Admin_Fields::text_field(
219
- array(
220
- 'id' => 'wcf_facebook_pixel_id',
221
- 'name' => '_cartflows_facebook[facebook_pixel_id]',
222
- 'title' => __( 'Enter Facebook pixel ID', 'cartflows' ),
223
- 'value' => $facebook_settings['facebook_pixel_id'],
224
- )
225
- );
226
-
227
-
228
- echo Cartflows_Admin_Fields::title_field(
229
- array(
230
- 'title' => __( 'Enable Events:', 'cartflows' ),
231
- )
232
- );
233
-
234
-
235
- echo Cartflows_Admin_Fields::checkobox_field(
236
- array(
237
- 'id' => 'wcf_facebook_pixel_initiate_checkout',
238
- 'name' => '_cartflows_facebook[facebook_pixel_initiate_checkout]',
239
- 'title' => __( 'Initiate Checkout', 'cartflows' ),
240
- 'value' => $facebook_settings['facebook_pixel_initiate_checkout'],
241
- )
242
- );
243
-
244
- echo Cartflows_Admin_Fields::checkobox_field(
245
- array(
246
- 'id' => 'wcf_facebook_pixel_add_payment_info',
247
- 'name' => '_cartflows_facebook[facebook_pixel_add_payment_info]',
248
- 'title' => __( 'Add Payment Info', 'cartflows' ),
249
- 'value' => $facebook_settings['facebook_pixel_add_payment_info'],
250
- )
251
- );
252
-
253
- echo Cartflows_Admin_Fields::checkobox_field(
254
- array(
255
- 'id' => 'wcf_facebook_pixel_purchase_complete',
256
- 'name' => '_cartflows_facebook[facebook_pixel_purchase_complete]',
257
- 'title' => __( 'Purchase Complete', 'cartflows' ),
258
- 'value' => $facebook_settings['facebook_pixel_purchase_complete'],
259
- )
260
- );
261
-
262
- echo '</div>';
263
-
264
- ?>
265
- </div>
266
-
267
- <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-facebook-setting-save-btn button-primary button', 'submit', false ); ?>
268
- <?php wp_nonce_field( 'cartflows-facebook-settings', 'cartflows-facebook-settings-nonce' ); ?>
269
- </div>
270
-
271
- </div>
272
- </div>
273
- </form>
274
-
275
-
276
- </div>
277
- </div>
278
- <div class="postbox-container" id="postbox-container-1">
279
- <div id="side-sortables">
280
-
281
- <div class="postbox">
282
- <h2 class="hndle">
283
- <span class="dashicons dashicons-book"></span>
284
- <span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
285
- </h2>
286
- <div class="inside">
287
- <p>
288
- <?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
289
- </p>
290
- <p>
291
- <a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
292
- </p>
293
- </div>
294
- </div>
295
-
296
- <div class="postbox">
297
- <h2 class="hndle">
298
- <span class="dashicons dashicons-groups"></span>
299
- <span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
300
- </h2>
301
- <div class="inside">
302
- <p>
303
- <?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
304
- </p>
305
- <p>
306
- <a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
307
- </p>
308
- </div>
309
- </div>
310
-
311
- <div class="postbox">
312
- <h2 class="hndle">
313
- <span class="dashicons dashicons-sos"></span>
314
- <span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
315
- </h2>
316
- <div class="inside">
317
- <p>
318
- <?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
319
- </p>
320
- <p>
321
- <a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Submit a Ticket »', 'cartflows' ); ?></a>
322
- </p>
323
- </div>
324
- </div>
325
- <?php
326
- if ( 'true' == $debug_on ) {
327
- ?>
328
- <div class="postbox">
329
- <h2 class="hndle">
330
- <span class="dashicons dashicons-editor-code"></span>
331
- <span><?php esc_html_e( 'Load Minified CSS', 'cartflows' ); ?></span>
332
- </h2>
333
- <div class="inside">
334
- <form method="post" class="wrap wcf-clear" action="">
335
- <p>
336
- <?php esc_html_e( 'Load the Minified CSS from here. Just Enable it by checking the below given checkbox.', 'cartflows' ); ?>
337
- </p>
338
- <?php
339
- echo Cartflows_Admin_Fields::checkobox_field(
340
- array(
341
- 'id' => 'allow_minified_files',
342
- 'name' => '_cartflows_debug_data[allow_minified_files]',
343
- 'title' => __( 'Load minified CSS & JS Files', 'cartflows' ),
344
- 'value' => $debug_data['allow_minified_files'],
345
- )
346
- );
347
- ?>
348
- <?php submit_button( __( 'Save', 'cartflows' ), 'button-primary button', 'submit', false ); ?>
349
- <?php wp_nonce_field( 'cartflows-debug-settings', 'cartflows-debug-settings-nonce' ); ?>
350
- </form>
351
- </div>
352
- </div>
353
- <?php
354
- }
355
- ?>
356
- </div>
357
- </div>
358
- </div>
359
- <!-- /post-body -->
360
- <br class="clear">
361
- </div>
362
- </div>
363
- <?php endif; ?>
364
-
365
- <?php
366
- /**
367
- * Loads Zapier settings admin view.
368
- */
369
- do_action( 'cartflows_after_general_settings' );
370
- ?>
1
+ <?php
2
+ /**
3
+ * General settings
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ $settings = Cartflows_Helper::get_common_settings();
9
+
10
+ $debug_data = Cartflows_Helper::get_debug_settings();
11
+
12
+ $permalink_settings = Cartflows_Helper::get_permalink_settings();
13
+
14
+ $facebook_settings = Cartflows_Helper::get_facebook_settings();
15
+
16
+ $debug_on = ( isset( $_GET['debug'] ) ) ? sanitize_text_field( wp_unslash( $_GET['debug'] ) ) : 'false'; //phpcs:ignore
17
+
18
+ $error_log = filter_input( INPUT_GET, 'cartflows-error-log', FILTER_VALIDATE_BOOLEAN );
19
+ ?>
20
+
21
+
22
+ <?php if ( $error_log ) : ?>
23
+ <div class="wrap wcf-addon-wrap wcf-clear wcf-container">
24
+ <?php Cartflows_Logger::status_logs_file(); ?>
25
+ </div>
26
+ <?php else : ?>
27
+ <div class="wrap wcf-addon-wrap wcf-clear wcf-container">
28
+ <input type="hidden" name="action" value="wcf_save_common_settings">
29
+ <h1 class="screen-reader-text"><?php esc_html_e( 'General Settings', 'cartflows' ); ?></h1>
30
+
31
+ <div id="poststuff">
32
+ <div id="post-body" class="columns-2">
33
+ <div id="post-body-content">
34
+ <div class="postbox introduction">
35
+ <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
36
+ <span><?php esc_html_e( 'Getting Started', 'cartflows' ); ?></span>
37
+ </h2>
38
+ <div class="inside">
39
+ <div class="iframe-wrap">
40
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
41
+ </div>
42
+ <p>
43
+ <?php
44
+ esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
45
+ ?>
46
+ </p>
47
+ </div>
48
+ </div>
49
+
50
+ <div class="general-settings-form postbox">
51
+ <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
52
+ <span><?php esc_html_e( 'General Settings', 'cartflows' ); ?></span>
53
+ </h2>
54
+ <div class="inside">
55
+ <form method="post" class="wrap wcf-clear" action="" >
56
+ <div class="form-wrap">
57
+ <?php
58
+
59
+ do_action( 'cartflows_before_settings_fields', $settings );
60
+
61
+ echo Cartflows_Admin_Fields::checkobox_field(
62
+ array(
63
+ 'id' => 'wcf_disallow_indexing',
64
+ 'name' => '_cartflows_common[disallow_indexing]',
65
+ 'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
66
+ 'value' => $settings['disallow_indexing'],
67
+ )
68
+ );
69
+
70
+ if ( wcf()->is_woo_active ) {
71
+ echo Cartflows_Admin_Fields::flow_checkout_selection_field(
72
+ array(
73
+ 'id' => 'wcf_global_checkout',
74
+ 'name' => '_cartflows_common[global_checkout]',
75
+ 'title' => __( 'Global Checkout', 'cartflows' ),
76
+ 'value' => $settings['global_checkout'],
77
+ )
78
+ );
79
+ }
80
+ echo Cartflows_Admin_Fields::select_field(
81
+ array(
82
+ 'id' => 'wcf_default_page_builder',
83
+ 'name' => '_cartflows_common[default_page_builder]',
84
+ 'title' => __( 'Show Templates designed with', 'cartflows' ),
85
+ 'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
86
+ 'value' => $settings['default_page_builder'],
87
+ 'options' => array(
88
+ 'elementor' => __( 'Elementor', 'cartflows' ),
89
+ 'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
90
+ 'divi' => __( 'Divi', 'cartflows' ),
91
+ 'other' => __( 'Other', 'cartflows' ),
92
+ ),
93
+ )
94
+ );
95
+
96
+ do_action( 'cartflows_after_settings_fields', $settings );
97
+
98
+ ?>
99
+ </div>
100
+ <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
101
+ <?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
102
+ </form>
103
+ </div>
104
+ </div>
105
+
106
+ <div class="general-settingss-form postbox">
107
+ <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
108
+ <span><?php esc_html_e( 'Permalink Settings', 'cartflows' ); ?></span>
109
+ </h2>
110
+ <div class="inside">
111
+ <form method="post" class="wrap wcf-clear" action="" >
112
+ <div class="form-wrap wcf_permalink_settings">
113
+ <?php
114
+
115
+ echo Cartflows_Admin_Fields::radio_field(
116
+ array(
117
+ 'id' => 'permalink_structure',
118
+ 'name' => '_cartflows_permalink[permalink_structure]',
119
+ 'value' => $permalink_settings['permalink_structure'],
120
+ 'options' => array(
121
+ '' =>
122
+ array(
123
+ 'label' => __( 'Default', 'cartflows' ),
124
+ 'description' => 'Default WordPress Permalink',
125
+ ),
126
+
127
+ '/' . CARTFLOWS_FLOW_POST_TYPE . '/%flowname%/' . CARTFLOWS_STEP_POST_TYPE =>
128
+ array(
129
+ 'label' => __( 'Flow and Step Slug', 'cartflows' ),
130
+ 'description' => '/<code>' . CARTFLOWS_FLOW_POST_TYPE . '</code>/%flowname%/<code>' . CARTFLOWS_STEP_POST_TYPE . '</code>/%stepname%/',
131
+ ),
132
+
133
+ '/' . CARTFLOWS_FLOW_POST_TYPE . '/%flowname%' =>
134
+ array(
135
+ 'label' => __( 'Flow Slug', 'cartflows' ),
136
+ 'description' => '/<code>' . CARTFLOWS_FLOW_POST_TYPE . '</code>/%flowname%/%stepname%/',
137
+ ),
138
+
139
+ '/%flowname%/' . CARTFLOWS_STEP_POST_TYPE =>
140
+ array(
141
+ 'label' => __( 'Step Slug', 'cartflows' ),
142
+ 'description' => '/%flowname%/<code>' . CARTFLOWS_STEP_POST_TYPE . '</code>/%stepname%/',
143
+ ),
144
+ ),
145
+ )
146
+ );
147
+ ?>
148
+ <hr/>
149
+ <?php
150
+
151
+ echo Cartflows_Admin_Fields::title_field(
152
+ array(
153
+ 'title' => __( 'Post Type Permalink Base', 'cartflows' ),
154
+ )
155
+ );
156
+
157
+ echo Cartflows_Admin_Fields::text_field(
158
+ array(
159
+ 'id' => 'wcf_permalink_step_base',
160
+ 'name' => '_cartflows_permalink[permalink]',
161
+ 'title' => __( 'Step Base', 'cartflows' ),
162
+ 'value' => $permalink_settings['permalink'],
163
+ 'placeholder' => CARTFLOWS_STEP_POST_TYPE,
164
+ )
165
+ );
166
+
167
+ echo Cartflows_Admin_Fields::text_field(
168
+ array(
169
+ 'id' => 'wcf_permalink_flow_base',
170
+ 'name' => '_cartflows_permalink[permalink_flow_base]',
171
+ 'title' => __( 'Flow Base', 'cartflows' ),
172
+ 'value' => $permalink_settings['permalink_flow_base'],
173
+ 'placeholder' => CARTFLOWS_FLOW_POST_TYPE,
174
+ )
175
+ );
176
+
177
+ ?>
178
+
179
+
180
+ </div>
181
+ <p>
182
+ <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
183
+ <?php submit_button( __( 'Set Default', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'reset', false ); ?>
184
+ <?php wp_nonce_field( 'cartflows-permalink-settings', 'cartflows-permalink-settings-nonce' ); ?>
185
+ </p>
186
+
187
+
188
+ </form>
189
+ </div>
190
+ </div>
191
+
192
+
193
+ <div class="general-settingss-form postbox">
194
+ <h2 class="wcf-facebook-hndle wcf-normal-cusror ui-sortable-handle hndle">
195
+
196
+ <span><?php esc_html_e( 'Facebook Pixel Settings', 'cartflows' ); ?></span>
197
+ </h2>
198
+
199
+ <form method="post" class="wrap wcf-clear" action="">
200
+ <div class="form-wrap">
201
+ <input type="hidden" name="action" value="wcf_save_facebook_pixel_settings">
202
+ <div id="post-body">
203
+
204
+ <div class="inside">
205
+ <div class="form-wrap">
206
+ <?php
207
+ echo Cartflows_Admin_Fields::checkobox_field(
208
+ array(
209
+ 'id' => 'wcf_facebook_pixel_tracking',
210
+ 'name' => '_cartflows_facebook[facebook_pixel_tracking]',
211
+ 'title' => __( 'Enable Facebook Pixel Tracking', 'cartflows' ),
212
+ 'value' => $facebook_settings['facebook_pixel_tracking'],
213
+ )
214
+ );
215
+
216
+ echo "<div class='wcf-fb-pixel-wrapper'>";
217
+
218
+ echo Cartflows_Admin_Fields::text_field(
219
+ array(
220
+ 'id' => 'wcf_facebook_pixel_id',
221
+ 'name' => '_cartflows_facebook[facebook_pixel_id]',
222
+ 'title' => __( 'Enter Facebook pixel ID', 'cartflows' ),
223
+ 'value' => $facebook_settings['facebook_pixel_id'],
224
+ )
225
+ );
226
+
227
+
228
+ echo Cartflows_Admin_Fields::title_field(
229
+ array(
230
+ 'title' => __( 'Enable Events:', 'cartflows' ),
231
+ )
232
+ );
233
+
234
+
235
+ echo Cartflows_Admin_Fields::checkobox_field(
236
+ array(
237
+ 'id' => 'wcf_facebook_pixel_initiate_checkout',
238
+ 'name' => '_cartflows_facebook[facebook_pixel_initiate_checkout]',
239
+ 'title' => __( 'Initiate Checkout', 'cartflows' ),
240
+ 'value' => $facebook_settings['facebook_pixel_initiate_checkout'],
241
+ )
242
+ );
243
+
244
+ echo Cartflows_Admin_Fields::checkobox_field(
245
+ array(
246
+ 'id' => 'wcf_facebook_pixel_add_payment_info',
247
+ 'name' => '_cartflows_facebook[facebook_pixel_add_payment_info]',
248
+ 'title' => __( 'Add Payment Info', 'cartflows' ),
249
+ 'value' => $facebook_settings['facebook_pixel_add_payment_info'],
250
+ )
251
+ );
252
+
253
+ echo Cartflows_Admin_Fields::checkobox_field(
254
+ array(
255
+ 'id' => 'wcf_facebook_pixel_purchase_complete',
256
+ 'name' => '_cartflows_facebook[facebook_pixel_purchase_complete]',
257
+ 'title' => __( 'Purchase Complete', 'cartflows' ),
258
+ 'value' => $facebook_settings['facebook_pixel_purchase_complete'],
259
+ )
260
+ );
261
+
262
+ echo '</div>';
263
+
264
+ ?>
265
+ </div>
266
+
267
+ <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-facebook-setting-save-btn button-primary button', 'submit', false ); ?>
268
+ <?php wp_nonce_field( 'cartflows-facebook-settings', 'cartflows-facebook-settings-nonce' ); ?>
269
+ </div>
270
+
271
+ </div>
272
+ </div>
273
+ </form>
274
+
275
+
276
+ </div>
277
+ </div>
278
+ <div class="postbox-container" id="postbox-container-1">
279
+ <div id="side-sortables">
280
+
281
+ <div class="postbox">
282
+ <h2 class="hndle">
283
+ <span class="dashicons dashicons-book"></span>
284
+ <span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
285
+ </h2>
286
+ <div class="inside">
287
+ <p>
288
+ <?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
289
+ </p>
290
+ <p>
291
+ <a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
292
+ </p>
293
+ </div>
294
+ </div>
295
+
296
+ <div class="postbox">
297
+ <h2 class="hndle">
298
+ <span class="dashicons dashicons-groups"></span>
299
+ <span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
300
+ </h2>
301
+ <div class="inside">
302
+ <p>
303
+ <?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
304
+ </p>
305
+ <p>
306
+ <a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
307
+ </p>
308
+ </div>
309
+ </div>
310
+
311
+ <div class="postbox">
312
+ <h2 class="hndle">
313
+ <span class="dashicons dashicons-sos"></span>
314
+ <span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
315
+ </h2>
316
+ <div class="inside">
317
+ <p>
318
+ <?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
319
+ </p>
320
+ <p>
321
+ <a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Submit a Ticket »', 'cartflows' ); ?></a>
322
+ </p>
323
+ </div>
324
+ </div>
325
+ <?php
326
+ if ( 'true' == $debug_on ) {
327
+ ?>
328
+ <div class="postbox">
329
+ <h2 class="hndle">
330
+ <span class="dashicons dashicons-editor-code"></span>
331
+ <span><?php esc_html_e( 'Load Minified CSS', 'cartflows' ); ?></span>
332
+ </h2>
333
+ <div class="inside">
334
+ <form method="post" class="wrap wcf-clear" action="">
335
+ <p>
336
+ <?php esc_html_e( 'Load the Minified CSS from here. Just Enable it by checking the below given checkbox.', 'cartflows' ); ?>
337
+ </p>
338
+ <?php
339
+ echo Cartflows_Admin_Fields::checkobox_field(
340
+ array(
341
+ 'id' => 'allow_minified_files',
342
+ 'name' => '_cartflows_debug_data[allow_minified_files]',
343
+ 'title' => __( 'Load minified CSS & JS Files', 'cartflows' ),
344
+ 'value' => $debug_data['allow_minified_files'],
345
+ )
346
+ );
347
+ ?>
348
+ <?php submit_button( __( 'Save', 'cartflows' ), 'button-primary button', 'submit', false ); ?>
349
+ <?php wp_nonce_field( 'cartflows-debug-settings', 'cartflows-debug-settings-nonce' ); ?>
350
+ </form>
351
+ </div>
352
+ </div>
353
+ <?php
354
+ }
355
+ ?>
356
+ </div>
357
+ </div>
358
+ </div>
359
+ <!-- /post-body -->
360
+ <br class="clear">
361
+ </div>
362
+ </div>
363
+ <?php endif; ?>
364
+
365
+ <?php
366
+ /**
367
+ * Loads Zapier settings admin view.
368
+ */
369
+ do_action( 'cartflows_after_general_settings' );
370
+ ?>
languages/cartflows.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the CartFlows package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: CartFlows 1.4.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
7
- "POT-Creation-Date: 2020-02-11 07:35:02+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -114,7 +114,7 @@ msgstr ""
114
  msgid "Clone"
115
  msgstr ""
116
 
117
- #: classes/class-cartflows-default-meta.php:710
118
  #: modules/optin/classes/class-cartflows-optin-meta.php:487
119
  msgid "Submit"
120
  msgstr ""
@@ -388,7 +388,7 @@ msgid "Ultra-Bold 900"
388
  msgstr ""
389
 
390
  #: classes/class-cartflows-meta-fields.php:551
391
- #: classes/class-cartflows-meta-fields.php:746
392
  msgid "Search for a product&hellip;"
393
  msgstr ""
394
 
@@ -396,7 +396,15 @@ msgstr ""
396
  msgid "Search for a coupon&hellip;"
397
  msgstr ""
398
 
399
- #: classes/class-cartflows-meta-fields.php:754
 
 
 
 
 
 
 
 
400
  msgid "Remove"
401
  msgstr ""
402
 
@@ -850,7 +858,7 @@ msgstr ""
850
 
851
  #: modules/checkout/classes/class-cartflows-checkout-markup.php:254
852
  #: modules/optin/classes/class-cartflows-optin-markup.php:146
853
- #: modules/thankyou/classes/class-cartflows-thankyou-markup.php:88
854
  msgid ""
855
  "WooCommerce functions do not exist. If you are in an IFrame, please reload "
856
  "it."
@@ -858,7 +866,7 @@ msgstr ""
858
 
859
  #: modules/checkout/classes/class-cartflows-checkout-markup.php:255
860
  #: modules/optin/classes/class-cartflows-optin-markup.php:147
861
- #: modules/thankyou/classes/class-cartflows-thankyou-markup.php:89
862
  msgid "Click Here to Reload"
863
  msgstr ""
864
 
@@ -1674,14 +1682,28 @@ msgid "Enable Shipping Details "
1674
  msgstr ""
1675
 
1676
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1677
  msgid "Redirect After Purchase"
1678
  msgstr ""
1679
 
1680
- #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:338
1681
  msgid "Redirect Link"
1682
  msgstr ""
1683
 
1684
- #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:342
1685
  msgid "https://"
1686
  msgstr ""
1687
 
@@ -1855,11 +1877,6 @@ msgstr ""
1855
  msgid "My account"
1856
  msgstr ""
1857
 
1858
- #: woocommerce/template/checkout/thankyou.php:41
1859
- #: woocommerce/template/checkout/thankyou.php:83
1860
- msgid "Thank you. Your order has been received."
1861
- msgstr ""
1862
-
1863
  #: woocommerce/template/checkout/thankyou.php:46
1864
  msgid "Order number:"
1865
  msgstr ""
2
  # This file is distributed under the same license as the CartFlows package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: CartFlows 1.4.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
7
+ "POT-Creation-Date: 2020-02-19 09:23:27+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
114
  msgid "Clone"
115
  msgstr ""
116
 
117
+ #: classes/class-cartflows-default-meta.php:714
118
  #: modules/optin/classes/class-cartflows-optin-meta.php:487
119
  msgid "Submit"
120
  msgstr ""
388
  msgstr ""
389
 
390
  #: classes/class-cartflows-meta-fields.php:551
391
+ #: classes/class-cartflows-meta-fields.php:750
392
  msgid "Search for a product&hellip;"
393
  msgstr ""
394
 
396
  msgid "Search for a coupon&hellip;"
397
  msgstr ""
398
 
399
+ #: classes/class-cartflows-meta-fields.php:725
400
+ msgid "Add New Product"
401
+ msgstr ""
402
+
403
+ #: classes/class-cartflows-meta-fields.php:726
404
+ msgid "Create Product"
405
+ msgstr ""
406
+
407
+ #: classes/class-cartflows-meta-fields.php:758
408
  msgid "Remove"
409
  msgstr ""
410
 
858
 
859
  #: modules/checkout/classes/class-cartflows-checkout-markup.php:254
860
  #: modules/optin/classes/class-cartflows-optin-markup.php:146
861
+ #: modules/thankyou/classes/class-cartflows-thankyou-markup.php:90
862
  msgid ""
863
  "WooCommerce functions do not exist. If you are in an IFrame, please reload "
864
  "it."
866
 
867
  #: modules/checkout/classes/class-cartflows-checkout-markup.php:255
868
  #: modules/optin/classes/class-cartflows-optin-markup.php:147
869
+ #: modules/thankyou/classes/class-cartflows-thankyou-markup.php:91
870
  msgid "Click Here to Reload"
871
  msgstr ""
872
 
1682
  msgstr ""
1683
 
1684
  #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:329
1685
+ msgid "Thank You Page Text"
1686
+ msgstr ""
1687
+
1688
+ #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:333
1689
+ #: woocommerce/template/checkout/thankyou.php:41
1690
+ #: woocommerce/template/checkout/thankyou.php:83
1691
+ msgid "Thank you. Your order has been received."
1692
+ msgstr ""
1693
+
1694
+ #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:335
1695
+ msgid "It will change the default text on thank you page."
1696
+ msgstr ""
1697
+
1698
+ #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:343
1699
  msgid "Redirect After Purchase"
1700
  msgstr ""
1701
 
1702
+ #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:352
1703
  msgid "Redirect Link"
1704
  msgstr ""
1705
 
1706
+ #: modules/thankyou/classes/class-cartflows-thankyou-meta.php:356
1707
  msgid "https://"
1708
  msgstr ""
1709
 
1877
  msgid "My account"
1878
  msgstr ""
1879
 
 
 
 
 
 
1880
  #: woocommerce/template/checkout/thankyou.php:46
1881
  msgid "Order number:"
1882
  msgstr ""
modules/checkout/classes/class-cartflows-checkout-markup.php CHANGED
@@ -1,1300 +1,1300 @@
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', array( $this, 'display_woo_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' ), 10, 2 );
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_wcf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
64
- add_action( 'wp_ajax_nopriv_wcf_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
- add_action( 'wp_ajax_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
72
- add_action( 'wp_ajax_nopriv_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
73
-
74
- add_action( 'wp_ajax_wcf_woo_remove_cart_product', array( $this, 'wcf_woo_remove_cart_product' ) );
75
- add_action( 'wp_ajax_nopriv_wcf_woo_remove_cart_product', array( $this, 'wcf_woo_remove_cart_product' ) );
76
-
77
- add_filter( 'woocommerce_paypal_args', array( $this, 'modify_paypal_args' ), 10, 2 );
78
-
79
- add_filter( 'woocommerce_cart_item_name', array( $this, 'wcf_add_remove_label' ), 10, 3 );
80
- }
81
-
82
- /**
83
- * Modify WooCommerce paypal arguments.
84
- *
85
- * @param array $args argumenets for payment.
86
- * @param WC_Order $order order data.
87
- * @return array
88
- */
89
- public function modify_paypal_args( $args, $order ) {
90
-
91
- $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
92
-
93
- if ( ! $checkout_id ) {
94
- return $args;
95
- }
96
-
97
- // Set cancel return URL.
98
- $args['cancel_return'] = esc_url_raw( $order->get_cancel_order_url_raw( get_permalink( $checkout_id ) ) );
99
-
100
- return $args;
101
- }
102
-
103
- /**
104
- * Modify WooCommerce paypal arguments.
105
- *
106
- * @param string $product_name product name.
107
- * @param object $cart_item cart item.
108
- * @param string $cart_item_key cart item key.
109
- * @return string
110
- */
111
- public function wcf_add_remove_label( $product_name, $cart_item, $cart_item_key ) {
112
-
113
- $checkout_id = get_the_ID();
114
- if ( ! $checkout_id ) {
115
- $checkout_id = ( isset( $_POST['option']['checkout_id'] ) ) ? wp_unslash( $_POST['option']['checkout_id'] ) : '';//phpcs:ignore
116
- }
117
-
118
- if ( ! empty( $checkout_id ) ) {
119
- $is_remove_product_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-remove-product-field' );
120
- if ( 'checkout' === get_post_meta( $checkout_id, 'wcf-step-type', true ) && ( 'yes' === $is_remove_product_option ) ) {
121
- $remove_label = apply_filters(
122
- 'woocommerce_cart_item_remove_link',
123
- sprintf(
124
- '<a href="#" rel="nofollow" class="remove cartflows-icon-close" data-id="%s" data-item-key="%s" ></a>',
125
- esc_attr( $cart_item['product_id'] ),
126
- $cart_item_key
127
- ),
128
- $cart_item_key
129
- );
130
-
131
- $product_name = $remove_label . $product_name;
132
- }
133
- }
134
-
135
- return $product_name;
136
-
137
- }
138
-
139
- /**
140
- * Change order button text .
141
- *
142
- * @param string $woo_button_text place order.
143
- * @return string
144
- */
145
- public function place_order_button_text( $woo_button_text ) {
146
-
147
- $checkout_id = get_the_ID();
148
- if ( ! $checkout_id ) {
149
- $checkout_id = ( isset( $_POST['option']['checkout_id'] ) ) ? intval( $_POST['option']['checkout_id'] ) : 0; //phpcs:ignore
150
- }
151
-
152
- $wcf_order_button_text = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-place-order-button-text' );
153
-
154
- if ( ! empty( $wcf_order_button_text ) ) {
155
- $woo_button_text = $wcf_order_button_text;
156
- }
157
-
158
- return $woo_button_text;
159
- }
160
-
161
- /**
162
- * Display all WooCommerce notices.
163
- *
164
- * @since 1.1.5
165
- */
166
- public function display_woo_notices() {
167
-
168
- if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
169
- woocommerce_output_all_notices();
170
- }
171
- }
172
-
173
-
174
- /**
175
- * Redirect from default to the global checkout page
176
- *
177
- * @since 1.0.0
178
- */
179
- public function global_checkout_template_redirect() {
180
-
181
- if ( ! is_checkout() ) {
182
- return;
183
- }
184
-
185
- if ( _is_wcf_checkout_type() || _is_wcf_thankyou_type() ) {
186
- return;
187
- }
188
-
189
- // Return if the key OR Order paramater is found in the URL for certain Payment gateways.
190
- if ( isset( $_GET['key'] ) || isset( $_GET['order'] ) ) { //phpcs:ignore
191
- return;
192
- }
193
-
194
- // redirect only for cartflows checkout pages.
195
- $order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
196
- $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
197
-
198
- $common = Cartflows_Helper::get_common_settings();
199
-
200
- $global_checkout = $common['global_checkout'];
201
-
202
- if (
203
- isset( $_SERVER['REQUEST_URI'] ) &&
204
- // ignore on order-pay.
205
- false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/' . $order_pay_endpoint . '/' ) &&
206
- // ignore on TY page.
207
- false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/' . $order_received_endpoint . '/' ) &&
208
- // ignore if order-pay in query param.
209
- false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), $order_pay_endpoint . '=' )
210
- ) {
211
-
212
- if ( '' !== $global_checkout ) {
213
-
214
- $link = apply_filters( 'cartflows_global_checkout_url', get_permalink( $global_checkout ) );
215
-
216
- if ( ! empty( $link ) ) {
217
-
218
- wp_safe_redirect( $link );
219
- die();
220
- }
221
- }
222
- }
223
- }
224
-
225
- /**
226
- * Check for checkout flag
227
- *
228
- * @param bool $is_checkout is checkout.
229
- *
230
- * @return bool
231
- */
232
- public function woo_checkout_flag( $is_checkout ) {
233
-
234
- if ( ! is_admin() ) {
235
-
236
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
237
-
238
- $is_checkout = true;
239
- }
240
- }
241
-
242
- return $is_checkout;
243
- }
244
-
245
- /**
246
- * Render checkout shortcode markup.
247
- *
248
- * @param array $atts attributes.
249
- * @return string
250
- */
251
- public function checkout_shortcode_markup( $atts ) {
252
-
253
- if ( ! function_exists( 'wc_print_notices' ) ) {
254
- $notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>';
255
- $notice_out .= '<button onClick="location.reload()">' . __( 'Click Here to Reload', 'cartflows' ) . '</button>';
256
-
257
- return $notice_out;
258
- }
259
-
260
- $atts = shortcode_atts(
261
- array(
262
- 'id' => 0,
263
- ),
264
- $atts
265
- );
266
-
267
- $checkout_id = intval( $atts['id'] );
268
-
269
- if ( empty( $checkout_id ) ) {
270
-
271
- if ( ! _is_wcf_checkout_type() ) {
272
-
273
- return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
274
- }
275
-
276
- global $post;
277
-
278
- $checkout_id = intval( $post->ID );
279
- }
280
-
281
- $output = '';
282
-
283
- ob_start();
284
-
285
- do_action( 'cartflows_checkout_form_before', $checkout_id );
286
-
287
- $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
288
-
289
- $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
290
-
291
- $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
292
-
293
- if ( file_exists( $template_layout ) ) {
294
- include $template_layout;
295
- } else {
296
- include $template_default;
297
- }
298
-
299
- $output .= ob_get_clean();
300
-
301
- return $output;
302
- }
303
-
304
- /**
305
- * Configure Cart Data.
306
- *
307
- * @since 1.0.0
308
- *
309
- * @return void
310
- */
311
- public function preconfigured_cart_data() {
312
-
313
- if ( is_admin() ) {
314
- return;
315
- }
316
-
317
- global $post;
318
-
319
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
320
-
321
- if ( wp_doing_ajax() ) {
322
- return;
323
- } else {
324
-
325
- if ( _is_wcf_checkout_type() ) {
326
- $checkout_id = $post->ID;
327
- } else {
328
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
329
- }
330
-
331
- $global_checkout = intval( Cartflows_Helper::get_common_setting( 'global_checkout' ) );
332
-
333
- if ( ! empty( $global_checkout ) && $checkout_id === $global_checkout ) {
334
-
335
- if ( WC()->cart->is_empty() ) {
336
- wc_add_notice( __( 'Your cart is currently empty.', 'cartflows' ), 'error' );
337
- }
338
-
339
- return;
340
- }
341
-
342
- if ( apply_filters( 'cartflows_skip_configure_cart', false, $checkout_id ) ) {
343
- return;
344
- }
345
-
346
- do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
347
-
348
- $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
349
-
350
- if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
351
- $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
352
- } else {
353
- $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
354
- }
355
-
356
- if ( ! is_array( $products ) ) {
357
-
358
- if ( 'dummy' === $products ) {
359
-
360
- $args = array(
361
- 'posts_per_page' => 1,
362
- 'orderby' => 'rand',
363
- 'post_type' => 'product',
364
- 'meta_query' => array( //phpcs:ignore
365
- // Exclude out of stock products.
366
- array(
367
- 'key' => '_stock_status',
368
- 'value' => 'outofstock',
369
- 'compare' => 'NOT IN',
370
- ),
371
- ),
372
- 'tax_query' => array( //phpcs:ignore
373
- array(
374
- 'taxonomy' => 'product_type',
375
- 'field' => 'slug',
376
- 'terms' => 'simple',
377
- ),
378
- ),
379
- );
380
-
381
- $random_product = get_posts( $args );
382
-
383
- if ( isset( $random_product[0]->ID ) ) {
384
- $products = array(
385
- array(
386
- 'product' => $random_product[0]->ID,
387
- ),
388
- );
389
- } else {
390
- return;
391
- }
392
- } else {
393
- return;
394
- }
395
- }
396
-
397
- /* Empty the current cart */
398
- WC()->cart->empty_cart();
399
-
400
- if ( is_array( $products ) && count( $products ) < 1 ) {
401
- wc_add_notice( __( 'No product is selected. Please select products from the checkout meta settings to continue.', 'cartflows' ), 'error' );
402
- return;
403
- }
404
-
405
- /* Set customer session if not set */
406
- if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
407
- WC()->session->set_customer_session_cookie( true );
408
- }
409
-
410
- $cart_product_count = 0;
411
-
412
- foreach ( $products as $index => $data ) {
413
-
414
- if ( ! isset( $data['product'] ) ) {
415
- return;
416
- }
417
-
418
- if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
419
- break;
420
- }
421
-
422
- $product_id = $data['product'];
423
- $_product = wc_get_product( $product_id );
424
-
425
- if ( ! empty( $_product ) ) {
426
-
427
- $quantity = 1;
428
-
429
- if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
430
-
431
- if ( $_product->is_type( 'variable' ) ) {
432
-
433
- $default_attributes = $_product->get_default_attributes();
434
-
435
- if ( ! empty( $default_attributes ) ) {
436
-
437
- foreach ( $_product->get_children() as $variation_id ) {
438
-
439
- $single_variation = new WC_Product_Variation( $variation_id );
440
-
441
- if ( $default_attributes == $single_variation->get_attributes() ) {
442
- WC()->cart->add_to_cart( $variation_id, $quantity );
443
- $cart_product_count++;
444
- }
445
- }
446
- } else {
447
-
448
- $product_childrens = $_product->get_children();
449
-
450
- if ( isset( $product_childrens[0] ) ) {
451
- WC()->cart->add_to_cart( $product_childrens[0], $quantity );
452
- $cart_product_count++;
453
- } else {
454
- echo '<p>' . esc_html__( 'Variations Not set', 'cartflows' ) . '</p>';
455
- }
456
- }
457
- } else {
458
- WC()->cart->add_to_cart( $product_id, $quantity );
459
- $cart_product_count++;
460
- }
461
- } else {
462
- $wrong_product_notice = __( 'This product can\'t be purchased', 'cartflows' );
463
- wc_add_notice( $wrong_product_notice );
464
- /**
465
- WC()->cart->add_to_cart( $product_id, $quantity );.
466
- */
467
- }
468
- }
469
- }
470
-
471
- /* Since 1.2.2 */
472
- wcf_do_action_deprecated( 'cartflows_checkout_aftet_configure_cart', array( $checkout_id ), '1.2.2', 'cartflows_checkout_after_configure_cart' );
473
- do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
474
- }
475
- }
476
- }
477
-
478
- /**
479
- * Load shortcode data.
480
- *
481
- * @return void
482
- */
483
- public function shortcode_load_data() {
484
-
485
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
486
-
487
- add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
488
-
489
- add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 );
490
-
491
- /* Show notices if cart has errors */
492
- add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
493
-
494
- add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
495
-
496
- add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
497
-
498
- // Outputting the hidden field in checkout page.
499
- add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
500
- add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
501
-
502
- remove_all_actions( 'woocommerce_checkout_billing' );
503
- remove_all_actions( 'woocommerce_checkout_shipping' );
504
-
505
- // Hook in actions once.
506
- add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
507
- add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
508
-
509
- remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
510
-
511
- add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
512
-
513
- add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
514
-
515
- add_filter( 'woocommerce_cart_totals_coupon_html', array( $this, 'remove_coupon_text' ) );
516
-
517
- add_filter( 'woocommerce_order_button_text', array( $this, 'place_order_button_text' ), 10, 1 );
518
-
519
- global $post;
520
-
521
- if ( _is_wcf_checkout_type() ) {
522
- $checkout_id = $post->ID;
523
- } else {
524
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
525
- }
526
-
527
- do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
528
- }
529
- }
530
-
531
- /**
532
- * Render checkout ID hidden field.
533
- *
534
- * @param array $checkout checkout session data.
535
- * @return void
536
- */
537
- public function checkout_shortcode_post_id( $checkout ) {
538
-
539
- global $post;
540
-
541
- if ( _is_wcf_checkout_type() ) {
542
- $checkout_id = $post->ID;
543
- } else {
544
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
545
- }
546
-
547
- $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
548
-
549
- echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
550
- echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
551
- }
552
-
553
- /**
554
- * Load shortcode scripts.
555
- *
556
- * @return void
557
- */
558
- public function shortcode_scripts() {
559
-
560
- wp_enqueue_style( 'wcf-checkout-template', wcf()->utils->get_css_url( 'checkout-template' ), '', CARTFLOWS_VER );
561
-
562
- wp_enqueue_script(
563
- 'wcf-checkout-template',
564
- wcf()->utils->get_js_url( 'checkout-template' ),
565
- array( 'jquery' ),
566
- CARTFLOWS_VER,
567
- true
568
- );
569
-
570
- do_action( 'cartflows_checkout_scripts' );
571
-
572
- $style = $this->generate_style();
573
-
574
- wp_add_inline_style( 'wcf-checkout-template', $style );
575
-
576
- }
577
-
578
- /**
579
- * Load compatibility scripts.
580
- *
581
- * @return void
582
- */
583
- public function compatibility_scripts() {
584
-
585
- global $post;
586
-
587
- if ( _is_wcf_checkout_type() ) {
588
- $checkout_id = $post->ID;
589
- } else {
590
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
591
- }
592
-
593
- // Add DIVI Compatibility css if DIVI theme is enabled.
594
- if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ||
595
- Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id )
596
- ) {
597
- wp_enqueue_style( 'wcf-checkout-template-divi', wcf()->utils->get_css_url( 'checkout-template-divi' ), '', CARTFLOWS_VER );
598
- }
599
-
600
- // Add Flatsome Compatibility css if Flatsome theme is enabled.
601
- if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
602
- wp_enqueue_style( 'wcf-checkout-template-flatsome', wcf()->utils->get_css_url( 'checkout-template-flatsome' ), '', CARTFLOWS_VER );
603
- }
604
-
605
- // Add The7 Compatibility css if The7 theme is enabled.
606
- if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) {
607
- wp_enqueue_style( 'wcf-checkout-template-the-seven', wcf()->utils->get_css_url( 'checkout-template-the-seven' ), '', CARTFLOWS_VER );
608
- }
609
- }
610
-
611
- /**
612
- * Generate styles.
613
- *
614
- * @return string
615
- */
616
- public function generate_style() {
617
-
618
- global $post;
619
-
620
- if ( _is_wcf_checkout_type() ) {
621
- $checkout_id = $post->ID;
622
- } else {
623
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
624
- }
625
-
626
- CartFlows_Font_Families::render_fonts( $checkout_id );
627
-
628
- $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
629
-
630
- $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
631
-
632
- $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
633
-
634
- /**
635
- $base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
636
- $r = '';
637
- $g = '';
638
- $b = '';
639
-
640
- $field_tb_padding = '';
641
- $field_lr_padding = '';
642
-
643
- $field_heading_color = '';
644
- $field_color = '';
645
- $field_bg_color = '';
646
- $field_border_color = '';
647
- $field_label_color = '';
648
- $submit_tb_padding = '';
649
- $submit_lr_padding = '';
650
- $hl_bg_color = '';
651
- $field_input_size = '';
652
- $box_border_color = '';
653
- $section_bg_color = '';
654
- $submit_button_height = '';
655
- $submit_color = '';
656
- $submit_bg_color = $primary_color;
657
- $submit_border_color = $primary_color;
658
-
659
- $submit_hover_color = '';
660
- $submit_bg_hover_color = $primary_color;
661
- $submit_border_hover_color = $primary_color;
662
-
663
- $section_heading_color = '';
664
-
665
- $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
666
-
667
- $button_font_family = '';
668
- $button_font_weight = '';
669
- $input_font_family = '';
670
- $input_font_weight = '';
671
- $heading_font_family = '';
672
- $heading_font_weight = '';
673
- $base_font_family = $base_font_family;
674
- /**
675
- $base_font_weight = $base_font_weight;*/
676
-
677
- if ( 'yes' == $is_advance_option ) {
678
-
679
- /**
680
- * Get Font Family and Font Weight weight values
681
- */
682
- $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
683
-
684
- $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
685
- $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
686
- $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
687
- $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
688
- $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
689
- $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
690
- $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
691
- $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
692
- $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
693
- $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
694
-
695
- $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
696
-
697
- $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
698
-
699
- $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
700
-
701
- $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
702
-
703
- $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
704
-
705
- $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
706
-
707
- $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
708
-
709
- $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
710
-
711
- $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
712
-
713
- $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
714
-
715
- $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
716
-
717
- $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
718
-
719
- $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
720
-
721
- $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
722
-
723
- $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
724
-
725
- $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
726
-
727
- /**
728
- * Get font values
729
- */
730
-
731
- if ( 'custom' == $submit_button_height ) {
732
- $submit_button_height = '38px';
733
- }
734
-
735
- if ( 'custom' == $field_input_size ) {
736
- $field_input_size = '38px';
737
- }
738
- }
739
- if ( isset( $primary_color ) ) {
740
-
741
- list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
742
- }
743
- $output = "
744
- .wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{
745
- color:$primary_color !important;
746
- border:1px solid $primary_color !important;
747
- }
748
- .wcf-embed-checkout-form .wcf-checkout-header-image img{
749
- width: {$header_logo_width}px;
750
- }
751
- .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
752
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
753
- color: {$primary_color};
754
- }
755
- .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
756
- background-color: {$primary_color};
757
- }
758
- .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
759
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
760
- .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
761
- .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
762
- border-color: {$primary_color};
763
- box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
764
- }
765
- .wcf-embed-checkout-form .woocommerce-checkout label{
766
- color: {$field_label_color};
767
- }
768
- .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
769
- background-color: {$hl_bg_color};
770
- font-family: {$input_font_family};
771
- font-weight: {$input_font_weight};
772
- }
773
-
774
- .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
775
- .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
776
- .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
777
- {
778
- border-bottom-color: {$hl_bg_color};
779
- border-right-color: transparent;
780
- border-left-color: transparent;
781
- border-top-color: transparent;
782
- position: absolute;
783
- }
784
-
785
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
786
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
787
- font-family: {$input_font_family};
788
- font-weight: {$input_font_weight};
789
- }
790
-
791
- .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
792
- .wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
793
- .wcf-embed-checkout-form .woocommerce form .form-row textarea,
794
- .wcf-embed-checkout-form .select2-container--default .select2-selection--single {
795
- color: {$field_color};
796
- background: {$field_bg_color};
797
- border-color: {$field_border_color};
798
- padding-top: {$field_tb_padding}px;
799
- padding-bottom: {$field_tb_padding}px;
800
- padding-left: {$field_lr_padding}px;
801
- padding-right: {$field_lr_padding}px;
802
- min-height: {$field_input_size};
803
- font-family: {$input_font_family};
804
- font-weight: {$input_font_weight};
805
- }
806
-
807
- .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
808
- .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
809
- .wcf-embed-checkout-form .woocommerce-checkout .shop_table,
810
- .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
811
- .wcf-embed-checkout-form .woocommerce-checkout #payment,
812
- .wcf-embed-checkout-form .woocommerce form.checkout_coupon
813
- {
814
- background-color: {$section_bg_color};
815
- border-color: {$box_border_color};
816
- font-family: {$input_font_family};
817
- font-weight: {$input_font_weight};
818
- }
819
-
820
- .woocommerce table.shop_table th{
821
- color: {$field_label_color};
822
- }
823
- /*.wcf-embed-checkout-form .woocommerce .woocommerce-info,
824
- .wcf-embed-checkout-form .woocommerce-message{
825
- border-top-color: {$primary_color};
826
- background-color: {$hl_bg_color};
827
- }*/
828
- .wcf-embed-checkout-form .woocommerce a{
829
- color: {$primary_color};
830
- }
831
- .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
832
- color: {$field_color};
833
- }
834
- .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
835
- color: {$field_color};
836
- }
837
- .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
838
- color: {$field_color};
839
- }
840
- .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
841
- color: {$field_color};
842
- }
843
- .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
844
- color: {$field_color};
845
- }
846
- .wcf-embed-checkout-form .woocommerce form p.form-row label {
847
- color: {$field_label_color};
848
- font-family: {$input_font_family};
849
- font-weight: {$input_font_weight};
850
- }
851
- .wcf-embed-checkout-form .woocommerce #order_review button,
852
- .wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,
853
- .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small {
854
- color: {$submit_color};
855
- background: {$submit_bg_color};
856
- padding-top: {$submit_tb_padding}px;
857
- padding-bottom: {$submit_tb_padding}px;
858
- padding-left: {$submit_lr_padding}px;
859
- padding-right: {$submit_lr_padding}px;
860
- border-color: {$submit_border_color};
861
- min-height: {$submit_button_height};
862
- font-family: {$button_font_family};
863
- font-weight: {$button_font_weight};
864
- }
865
- .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
866
- .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
867
- background: {$submit_bg_color};
868
- border: 1px {$submit_border_color} solid;
869
- color: {$submit_color};
870
- min-height: {$submit_button_height};
871
- font-family: {$button_font_family};
872
- font-weight: {$button_font_weight};
873
- }
874
- .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
875
- .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
876
- .wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
877
- .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
878
- color: {$submit_hover_color};
879
- background-color: {$submit_bg_hover_color};
880
- border-color: {$submit_border_hover_color};
881
- }
882
- .wcf-embed-checkout-form .woocommerce h3,
883
- .wcf-embed-checkout-form .woocommerce h3 span,
884
- .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
885
- color: {$section_heading_color};
886
- font-family: {$heading_font_family};
887
- font-weight: {$heading_font_weight};
888
- }
889
- .wcf-embed-checkout-form .woocommerce-info::before,
890
- .wcf-embed-checkout-form .woocommerce-message::before{
891
- color: {$primary_color};
892
- }
893
- .wcf-embed-checkout-form{
894
- font-family: {$base_font_family};
895
- }
896
- img.emoji, img.wp-smiley {}";
897
-
898
- return $output;
899
- }
900
-
901
- /**
902
- * Get ajax end points.
903
- *
904
- * @param string $endpoint_url end point URL.
905
- * @param string $request end point request.
906
- * @return string
907
- */
908
- public function get_ajax_endpoint( $endpoint_url, $request ) {
909
-
910
- global $post;
911
-
912
- if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
913
-
914
- if ( _is_wcf_checkout_type() ) {
915
-
916
- if ( mb_strpos( $endpoint_url, 'checkout', 0, 'utf-8' ) === false ) {
917
-
918
- if ( '' === $request ) {
919
- $query_args = array(
920
- 'wc-ajax' => '%%endpoint%%',
921
- );
922
- } else {
923
- $query_args = array(
924
- 'wc-ajax' => $request,
925
- );
926
- }
927
-
928
- $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 ); //phpcs:ignore
929
- $uri = $uri[0];
930
-
931
- $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
932
- }
933
- }
934
- }
935
-
936
- return $endpoint_url;
937
- }
938
-
939
-
940
- /**
941
- * Save checkout fields.
942
- *
943
- * @param int $order_id order id.
944
- * @param array $posted posted data.
945
- * @return void
946
- */
947
- public function save_checkout_fields( $order_id, $posted ) {
948
-
949
- if ( isset( $_POST['_wcf_checkout_id'] ) ) { //phpcs:ignore
950
-
951
- $checkout_id = wc_clean( intval( $_POST['_wcf_checkout_id'] ) ); //phpcs:ignore
952
-
953
- update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
954
-
955
- if ( isset( $_POST['_wcf_flow_id'] ) ) { //phpcs:ignore
956
-
957
- $flow_id = wc_clean( intval( $_POST['_wcf_flow_id'] ) ); //phpcs:ignore
958
-
959
- update_post_meta( $order_id, '_wcf_flow_id', $flow_id );
960
- }
961
- }
962
-
963
- }
964
-
965
- /**
966
- * Enable Logo In Header Of Checkout Page
967
- *
968
- * @return void
969
- */
970
- public function enable_logo_in_header() {
971
- global $post;
972
-
973
- if ( _is_wcf_checkout_type() ) {
974
- $checkout_id = $post->ID;
975
- } else {
976
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
977
- }
978
-
979
- $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
980
- $add_image_markup = '';
981
-
982
- if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
983
- $add_image_markup = '<div class="wcf-checkout-header-image">';
984
- $add_image_markup .= '<img src="' . $header_logo_image . '" />';
985
- $add_image_markup .= '</div>';
986
- }
987
-
988
- echo $add_image_markup;
989
- }
990
-
991
- /**
992
- * Add text to the bootom of the checkout page.
993
- *
994
- * @return void
995
- */
996
- public function show_cartflows_copyright_message() {
997
- $output_string = '';
998
-
999
- $output_string .= '<div class="wcf-footer-primary">';
1000
- $output_string .= '<div class="wcf-footer-content">';
1001
- $output_string .= '<p class="wcf-footer-message">';
1002
- $output_string .= 'Checkout powered by CartFlows';
1003
- $output_string .= '</p>';
1004
- $output_string .= '</div>';
1005
- $output_string .= '</div>';
1006
-
1007
- echo $output_string;
1008
- }
1009
-
1010
- /**
1011
- * Redirect users to our checkout if hidden param
1012
- *
1013
- * @param string $redirect redirect url.
1014
- * @param object $user user.
1015
- * @return string
1016
- */
1017
- public function after_login_redirect( $redirect, $user ) {
1018
-
1019
- if ( isset( $_POST['_wcf_checkout_id'] ) ) { //phpcs:ignore
1020
-
1021
- $checkout_id = intval( $_POST['_wcf_checkout_id'] ); //phpcs:ignore
1022
-
1023
- $redirect = get_permalink( $checkout_id );
1024
- }
1025
-
1026
- return $redirect;
1027
- }
1028
-
1029
- /**
1030
- * Display coupon code field after review order fields.
1031
- */
1032
- public function display_custom_coupon_field() {
1033
-
1034
- $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
1035
- $show_coupon = apply_filters( 'cartflows_show_coupon_field', true );
1036
-
1037
- if ( ! ( $coupon_enabled && $show_coupon ) ) {
1038
- return;
1039
-
1040
- }
1041
-
1042
- $coupon_field = array(
1043
- 'field_text' => __( 'Coupon Code', 'cartflows' ),
1044
- 'button_text' => __( 'Apply', 'cartflows' ),
1045
- 'class' => '',
1046
- );
1047
-
1048
- $coupon_field = apply_filters( 'cartflows_coupon_field_options', $coupon_field );
1049
-
1050
- ob_start();
1051
- ?>
1052
- <div class="wcf-custom-coupon-field <?php echo $coupon_field['class']; ?>" id="wcf_custom_coupon_field">
1053
- <div class="wcf-coupon-col-1">
1054
- <span>
1055
- <input type="text" name="coupon_code" class="input-text wcf-coupon-code-input" placeholder="<?php echo $coupon_field['field_text']; ?>" id="coupon_code" value="">
1056
- </span>
1057
- </div>
1058
- <div class="wcf-coupon-col-2">
1059
- <span>
1060
- <button type="button" class="button wcf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php echo $coupon_field['button_text']; ?></button>
1061
- </span>
1062
- </div>
1063
- </div>
1064
- <?php
1065
- echo ob_get_clean();
1066
- }
1067
-
1068
- /**
1069
- * Apply filter to change class of remove coupon field.
1070
- *
1071
- * @param string $coupon coupon.
1072
- * @return string
1073
- */
1074
- public function remove_coupon_text( $coupon ) {
1075
-
1076
- $coupon = str_replace( 'woocommerce-remove-coupon', 'wcf-remove-coupon', $coupon );
1077
- return $coupon;
1078
-
1079
- }
1080
- /**
1081
- * Apply filter to change the placeholder text of coupon field.
1082
- *
1083
- * @return string
1084
- */
1085
- public function coupon_field_placeholder() {
1086
- return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
1087
- }
1088
-
1089
- /**
1090
- * Apply filter to change the button text of coupon field.
1091
- *
1092
- * @return string
1093
- */
1094
- public function coupon_button_text() {
1095
- return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
1096
- }
1097
-
1098
- /**
1099
- * Apply coupon on submit of custom coupon form.
1100
- */
1101
- public function apply_coupon() {
1102
-
1103
- $response = '';
1104
-
1105
- check_ajax_referer( 'wcf-apply-coupon', 'security' );
1106
- if ( ! empty( $_POST['coupon_code'] ) ) {
1107
- $result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
1108
- } else {
1109
- wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' );
1110
- }
1111
-
1112
- $response = array(
1113
- 'status' => $result,
1114
- 'msg' => wc_print_notices( true ),
1115
- );
1116
-
1117
- echo wp_json_encode( $response );
1118
-
1119
- die();
1120
- }
1121
-
1122
-
1123
- /**
1124
- * Added ajax nonce to localize variable.
1125
- *
1126
- * @param array $vars localize variables.
1127
- */
1128
- public function add_localize_vars( $vars ) {
1129
-
1130
- $vars['wcf_validate_coupon_nonce'] = wp_create_nonce( 'wcf-apply-coupon' );
1131
-
1132
- $vars['wcf_validate_remove_coupon_nonce'] = wp_create_nonce( 'wcf-remove-coupon' );
1133
-
1134
- $vars['wcf_validate_remove_cart_product_nonce'] = wp_create_nonce( 'wcf-remove-cart-product' );
1135
-
1136
- $vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
1137
-
1138
- return $vars;
1139
- }
1140
-
1141
- /**
1142
- * Add custom class to the fields to change the UI to three column.
1143
- *
1144
- * @param array $fields fields.
1145
- */
1146
- public function add_three_column_layout_fields( $fields ) {
1147
-
1148
- if ( empty( $fields['billing']['billing_address_2'] ) ) {
1149
-
1150
- if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
1151
- $fields['billing']['billing_address_1']['class'][] = 'form-row-full';
1152
- }
1153
- }
1154
-
1155
- if ( ! empty( $fields['billing']['billing_company'] ) ) {
1156
-
1157
- if ( isset( $fields['billing']['billing_company'] ) && is_array( $fields['billing']['billing_company'] ) ) {
1158
- $fields['billing']['billing_company']['class'][] = 'form-row-full';
1159
- }
1160
- }
1161
-
1162
- if ( ! empty( $fields['shipping']['shipping_company'] ) ) {
1163
-
1164
- if ( isset( $fields['shipping']['shipping_company'] ) && is_array( $fields['shipping']['shipping_company'] ) ) {
1165
- $fields['shipping']['shipping_company']['class'][] = 'form-row-full';
1166
- }
1167
- }
1168
-
1169
- if ( ! empty( $fields['billing']['billing_country'] ) ) {
1170
-
1171
- if ( isset( $fields['billing']['billing_country'] ) && is_array( $fields['billing']['billing_country'] ) ) {
1172
- $fields['billing']['billing_country']['class'][] = 'form-row-full';
1173
- }
1174
- }
1175
-
1176
- if ( ! empty( $fields['shipping']['shipping_country'] ) ) {
1177
-
1178
- if ( isset( $fields['shipping']['shipping_country'] ) && is_array( $fields['shipping']['shipping_country'] ) ) {
1179
- $fields['shipping']['shipping_country']['class'][] = 'form-row-full';
1180
- }
1181
- }
1182
-
1183
- if ( ! empty( $fields['billing']['billing_phone'] ) ) {
1184
-
1185
- if ( isset( $fields['billing']['billing_phone'] ) && is_array( $fields['billing']['billing_phone'] ) ) {
1186
- $fields['billing']['billing_phone']['class'][] = 'form-row-full';
1187
- }
1188
- }
1189
-
1190
- if ( ! empty( $fields['billing']['billing_email'] ) ) {
1191
-
1192
- if ( isset( $fields['billing']['billing_email'] ) && is_array( $fields['billing']['billing_email'] ) ) {
1193
- $fields['billing']['billing_email']['class'][] = 'form-row-full';
1194
- }
1195
- }
1196
-
1197
- if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
1198
-
1199
- if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
1200
- $fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
1201
- }
1202
- }
1203
-
1204
- if ( isset( $fields['billing']['billing_city'] ) &&
1205
- isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
1206
-
1207
- $fields['billing']['billing_city']['class'][] = 'wcf-column-33';
1208
- $fields['billing']['billing_state']['class'][] = 'wcf-column-33';
1209
- $fields['billing']['billing_postcode']['class'][] = 'wcf-column-33';
1210
- }
1211
-
1212
- if ( isset( $fields['shipping']['shipping_city'] ) &&
1213
- isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
1214
-
1215
- $fields['shipping']['shipping_city']['class'][] = 'wcf-column-33';
1216
- $fields['shipping']['shipping_state']['class'][] = 'wcf-column-33';
1217
- $fields['shipping']['shipping_postcode']['class'][] = 'wcf-column-33';
1218
- }
1219
-
1220
- return $fields;
1221
- }
1222
-
1223
- /**
1224
- * Add opening dev
1225
- *
1226
- * @since 1.0.0
1227
- */
1228
- public function order_wrap_div_start() {
1229
-
1230
- echo "<div class='wcf-order-wrap'> ";
1231
- }
1232
-
1233
- /**
1234
- * Add closing dev
1235
- *
1236
- * @since 1.0.0
1237
- */
1238
- public function order_wrap_div_end() {
1239
-
1240
- echo '</div> ';
1241
- }
1242
- /**
1243
- * Remove coupon.
1244
- */
1245
- public function remove_coupon() {
1246
-
1247
- check_ajax_referer( 'wcf-remove-coupon', 'security' );
1248
- $coupon = isset( $_POST['coupon_code'] ) ? wc_clean( wp_unslash( $_POST['coupon_code'] ) ) : false; //phpcs:ignore
1249
-
1250
- if ( empty( $coupon ) ) {
1251
- echo "<div class='woocommerce-error'>" . esc_html__( 'Sorry there was a problem removing this coupon.', 'cartflows' );
1252
- } else {
1253
- WC()->cart->remove_coupon( $coupon );
1254
- echo "<div class='woocommerce-error'>" . esc_html__( 'Coupon has been removed.', 'cartflows' ) . '</div>';
1255
- }
1256
- wc_print_notices();
1257
- wp_die();
1258
- }
1259
-
1260
- /**
1261
- * Remove cart item.
1262
- */
1263
- public function wcf_woo_remove_cart_product() {
1264
-
1265
- check_ajax_referer( 'wcf-remove-cart-product', 'security' );
1266
- $product_key = isset( $_POST['p_key'] ) ? wc_clean( wp_unslash( $_POST['p_key'] ) ) : false; //phpcs:ignore
1267
- $product_id = isset( $_POST['p_id'] ) ? wc_clean( wp_unslash( $_POST['p_id'] ) ) : ''; //phpcs:ignore
1268
- $product_title = get_the_title( $product_id );
1269
-
1270
- $needs_shipping = false;
1271
-
1272
- if ( empty( $product_key ) ) {
1273
- $msg = "<div class='woocommerce-message'>" . __( 'Sorry there was a problem removing ', 'cartflows' ) . $product_title;
1274
- } else {
1275
- WC()->cart->remove_cart_item( $product_key );
1276
- $msg = "<div class='woocommerce-message'>" . $product_title . __( ' has been removed.', 'cartflows' ) . '</div>';
1277
- }
1278
-
1279
- foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
1280
- if ( $values['data']->needs_shipping() ) {
1281
- $needs_shipping = true;
1282
- break;
1283
- }
1284
- }
1285
-
1286
- $response = array(
1287
- 'need_shipping' => $needs_shipping,
1288
- 'msg' => $msg,
1289
- );
1290
-
1291
- echo wp_json_encode( $response );
1292
- wp_die();
1293
- }
1294
-
1295
- }
1296
-
1297
- /**
1298
- * Kicking this off by calling 'get_instance()' method
1299
- */
1300
- 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', array( $this, 'display_woo_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' ), 10, 2 );
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_wcf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
64
+ add_action( 'wp_ajax_nopriv_wcf_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
+ add_action( 'wp_ajax_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
72
+ add_action( 'wp_ajax_nopriv_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
73
+
74
+ add_action( 'wp_ajax_wcf_woo_remove_cart_product', array( $this, 'wcf_woo_remove_cart_product' ) );
75
+ add_action( 'wp_ajax_nopriv_wcf_woo_remove_cart_product', array( $this, 'wcf_woo_remove_cart_product' ) );
76
+
77
+ add_filter( 'woocommerce_paypal_args', array( $this, 'modify_paypal_args' ), 10, 2 );
78
+
79
+ add_filter( 'woocommerce_cart_item_name', array( $this, 'wcf_add_remove_label' ), 10, 3 );
80
+ }
81
+
82
+ /**
83
+ * Modify WooCommerce paypal arguments.
84
+ *
85
+ * @param array $args argumenets for payment.
86
+ * @param WC_Order $order order data.
87
+ * @return array
88
+ */
89
+ public function modify_paypal_args( $args, $order ) {
90
+
91
+ $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
92
+
93
+ if ( ! $checkout_id ) {
94
+ return $args;
95
+ }
96
+
97
+ // Set cancel return URL.
98
+ $args['cancel_return'] = esc_url_raw( $order->get_cancel_order_url_raw( get_permalink( $checkout_id ) ) );
99
+
100
+ return $args;
101
+ }
102
+
103
+ /**
104
+ * Modify WooCommerce paypal arguments.
105
+ *
106
+ * @param string $product_name product name.
107
+ * @param object $cart_item cart item.
108
+ * @param string $cart_item_key cart item key.
109
+ * @return string
110
+ */
111
+ public function wcf_add_remove_label( $product_name, $cart_item, $cart_item_key ) {
112
+
113
+ $checkout_id = get_the_ID();
114
+ if ( ! $checkout_id ) {
115
+ $checkout_id = ( isset( $_POST['option']['checkout_id'] ) ) ? wp_unslash( $_POST['option']['checkout_id'] ) : '';//phpcs:ignore
116
+ }
117
+
118
+ if ( ! empty( $checkout_id ) ) {
119
+ $is_remove_product_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-remove-product-field' );
120
+ if ( 'checkout' === get_post_meta( $checkout_id, 'wcf-step-type', true ) && ( 'yes' === $is_remove_product_option ) ) {
121
+ $remove_label = apply_filters(
122
+ 'woocommerce_cart_item_remove_link',
123
+ sprintf(
124
+ '<a href="#" rel="nofollow" class="remove cartflows-icon-close" data-id="%s" data-item-key="%s" ></a>',
125
+ esc_attr( $cart_item['product_id'] ),
126
+ $cart_item_key
127
+ ),
128
+ $cart_item_key
129
+ );
130
+
131
+ $product_name = $remove_label . $product_name;
132
+ }
133
+ }
134
+
135
+ return $product_name;
136
+
137
+ }
138
+
139
+ /**
140
+ * Change order button text .
141
+ *
142
+ * @param string $woo_button_text place order.
143
+ * @return string
144
+ */
145
+ public function place_order_button_text( $woo_button_text ) {
146
+
147
+ $checkout_id = get_the_ID();
148
+ if ( ! $checkout_id ) {
149
+ $checkout_id = ( isset( $_POST['option']['checkout_id'] ) ) ? intval( $_POST['option']['checkout_id'] ) : 0; //phpcs:ignore
150
+ }
151
+
152
+ $wcf_order_button_text = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-place-order-button-text' );
153
+
154
+ if ( ! empty( $wcf_order_button_text ) ) {
155
+ $woo_button_text = $wcf_order_button_text;
156
+ }
157
+
158
+ return $woo_button_text;
159
+ }
160
+
161
+ /**
162
+ * Display all WooCommerce notices.
163
+ *
164
+ * @since 1.1.5
165
+ */
166
+ public function display_woo_notices() {
167
+
168
+ if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
169
+ woocommerce_output_all_notices();
170
+ }
171
+ }
172
+
173
+
174
+ /**
175
+ * Redirect from default to the global checkout page
176
+ *
177
+ * @since 1.0.0
178
+ */
179
+ public function global_checkout_template_redirect() {
180
+
181
+ if ( ! is_checkout() ) {
182
+ return;
183
+ }
184
+
185
+ if ( wcf()->utils->is_step_post_type() ) {
186
+ return;
187
+ }
188
+
189
+ // Return if the key OR Order paramater is found in the URL for certain Payment gateways.
190
+ if ( isset( $_GET['key'] ) || isset( $_GET['order'] ) ) { //phpcs:ignore
191
+ return;
192
+ }
193
+
194
+ // redirect only for cartflows checkout pages.
195
+ $order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
196
+ $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
197
+
198
+ $common = Cartflows_Helper::get_common_settings();
199
+
200
+ $global_checkout = $common['global_checkout'];
201
+
202
+ if (
203
+ isset( $_SERVER['REQUEST_URI'] ) &&
204
+ // ignore on order-pay.
205
+ false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/' . $order_pay_endpoint . '/' ) &&
206
+ // ignore on TY page.
207
+ false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/' . $order_received_endpoint . '/' ) &&
208
+ // ignore if order-pay in query param.
209
+ false === wcf_mb_strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), $order_pay_endpoint . '=' )
210
+ ) {
211
+
212
+ if ( '' !== $global_checkout ) {
213
+
214
+ $link = apply_filters( 'cartflows_global_checkout_url', get_permalink( $global_checkout ) );
215
+
216
+ if ( ! empty( $link ) ) {
217
+
218
+ wp_safe_redirect( $link );
219
+ die();
220
+ }
221
+ }
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Check for checkout flag
227
+ *
228
+ * @param bool $is_checkout is checkout.
229
+ *
230
+ * @return bool
231
+ */
232
+ public function woo_checkout_flag( $is_checkout ) {
233
+
234
+ if ( ! is_admin() ) {
235
+
236
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
237
+
238
+ $is_checkout = true;
239
+ }
240
+ }
241
+
242
+ return $is_checkout;
243
+ }
244
+
245
+ /**
246
+ * Render checkout shortcode markup.
247
+ *
248
+ * @param array $atts attributes.
249
+ * @return string
250
+ */
251
+ public function checkout_shortcode_markup( $atts ) {
252
+
253
+ if ( ! function_exists( 'wc_print_notices' ) ) {
254
+ $notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>';
255
+ $notice_out .= '<button onClick="location.reload()">' . __( 'Click Here to Reload', 'cartflows' ) . '</button>';
256
+
257
+ return $notice_out;
258
+ }
259
+
260
+ $atts = shortcode_atts(
261
+ array(
262
+ 'id' => 0,
263
+ ),
264
+ $atts
265
+ );
266
+
267
+ $checkout_id = intval( $atts['id'] );
268
+
269
+ if ( empty( $checkout_id ) ) {
270
+
271
+ if ( ! _is_wcf_checkout_type() ) {
272
+
273
+ return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
274
+ }
275
+
276
+ global $post;
277
+
278
+ $checkout_id = intval( $post->ID );
279
+ }
280
+
281
+ $output = '';
282
+
283
+ ob_start();
284
+
285
+ do_action( 'cartflows_checkout_form_before', $checkout_id );
286
+
287
+ $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
288
+
289
+ $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
290
+
291
+ $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
292
+
293
+ if ( file_exists( $template_layout ) ) {
294
+ include $template_layout;
295
+ } else {
296
+ include $template_default;
297
+ }
298
+
299
+ $output .= ob_get_clean();
300
+
301
+ return $output;
302
+ }
303
+
304
+ /**
305
+ * Configure Cart Data.
306
+ *
307
+ * @since 1.0.0
308
+ *
309
+ * @return void
310
+ */
311
+ public function preconfigured_cart_data() {
312
+
313
+ if ( is_admin() ) {
314
+ return;
315
+ }
316
+
317
+ global $post;
318
+
319
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
320
+
321
+ if ( wp_doing_ajax() ) {
322
+ return;
323
+ } else {
324
+
325
+ if ( _is_wcf_checkout_type() ) {
326
+ $checkout_id = $post->ID;
327
+ } else {
328
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
329
+ }
330
+
331
+ $global_checkout = intval( Cartflows_Helper::get_common_setting( 'global_checkout' ) );
332
+
333
+ if ( ! empty( $global_checkout ) && $checkout_id === $global_checkout ) {
334
+
335
+ if ( WC()->cart->is_empty() ) {
336
+ wc_add_notice( __( 'Your cart is currently empty.', 'cartflows' ), 'error' );
337
+ }
338
+
339
+ return;
340
+ }
341
+
342
+ if ( apply_filters( 'cartflows_skip_configure_cart', false, $checkout_id ) ) {
343
+ return;
344
+ }
345
+
346
+ do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
347
+
348
+ $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
349
+
350
+ if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
351
+ $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
352
+ } else {
353
+ $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
354
+ }
355
+
356
+ if ( ! is_array( $products ) ) {
357
+
358
+ if ( 'dummy' === $products ) {
359
+
360
+ $args = array(
361
+ 'posts_per_page' => 1,
362
+ 'orderby' => 'rand',
363
+ 'post_type' => 'product',
364
+ 'meta_query' => array( //phpcs:ignore
365
+ // Exclude out of stock products.
366
+ array(
367
+ 'key' => '_stock_status',
368
+ 'value' => 'outofstock',
369
+ 'compare' => 'NOT IN',
370
+ ),
371
+ ),
372
+ 'tax_query' => array( //phpcs:ignore
373
+ array(
374
+ 'taxonomy' => 'product_type',
375
+ 'field' => 'slug',
376
+ 'terms' => 'simple',
377
+ ),
378
+ ),
379
+ );
380
+
381
+ $random_product = get_posts( $args );
382
+
383
+ if ( isset( $random_product[0]->ID ) ) {
384
+ $products = array(
385
+ array(
386
+ 'product' => $random_product[0]->ID,
387
+ ),
388
+ );
389
+ } else {
390
+ return;
391
+ }
392
+ } else {
393
+ return;
394
+ }
395
+ }
396
+
397
+ /* Empty the current cart */
398
+ WC()->cart->empty_cart();
399
+
400
+ if ( is_array( $products ) && count( $products ) < 1 ) {
401
+ wc_add_notice( __( 'No product is selected. Please select products from the checkout meta settings to continue.', 'cartflows' ), 'error' );
402
+ return;
403
+ }
404
+
405
+ /* Set customer session if not set */
406
+ if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
407
+ WC()->session->set_customer_session_cookie( true );
408
+ }
409
+
410
+ $cart_product_count = 0;
411
+
412
+ foreach ( $products as $index => $data ) {
413
+
414
+ if ( ! isset( $data['product'] ) ) {
415
+ return;
416
+ }
417
+
418
+ if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
419
+ break;
420
+ }
421
+
422
+ $product_id = $data['product'];
423
+ $_product = wc_get_product( $product_id );
424
+
425
+ if ( ! empty( $_product ) ) {
426
+
427
+ $quantity = 1;
428
+
429
+ if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
430
+
431
+ if ( $_product->is_type( 'variable' ) ) {
432
+
433
+ $default_attributes = $_product->get_default_attributes();
434
+
435
+ if ( ! empty( $default_attributes ) ) {
436
+
437
+ foreach ( $_product->get_children() as $variation_id ) {
438
+
439
+ $single_variation = new WC_Product_Variation( $variation_id );
440
+
441
+ if ( $default_attributes == $single_variation->get_attributes() ) {
442
+ WC()->cart->add_to_cart( $variation_id, $quantity );
443
+ $cart_product_count++;
444
+ }
445
+ }
446
+ } else {
447
+
448
+ $product_childrens = $_product->get_children();
449
+
450
+ if ( isset( $product_childrens[0] ) ) {
451
+ WC()->cart->add_to_cart( $product_childrens[0], $quantity );
452
+ $cart_product_count++;
453
+ } else {
454
+ echo '<p>' . esc_html__( 'Variations Not set', 'cartflows' ) . '</p>';
455
+ }
456
+ }
457
+ } else {
458
+ WC()->cart->add_to_cart( $product_id, $quantity );
459
+ $cart_product_count++;
460
+ }
461
+ } else {
462
+ $wrong_product_notice = __( 'This product can\'t be purchased', 'cartflows' );
463
+ wc_add_notice( $wrong_product_notice );
464
+ /**
465
+ WC()->cart->add_to_cart( $product_id, $quantity );.
466
+ */
467
+ }
468
+ }
469
+ }
470
+
471
+ /* Since 1.2.2 */
472
+ wcf_do_action_deprecated( 'cartflows_checkout_aftet_configure_cart', array( $checkout_id ), '1.2.2', 'cartflows_checkout_after_configure_cart' );
473
+ do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
474
+ }
475
+ }
476
+ }
477
+
478
+ /**
479
+ * Load shortcode data.
480
+ *
481
+ * @return void
482
+ */
483
+ public function shortcode_load_data() {
484
+
485
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
486
+
487
+ add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
488
+
489
+ add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 );
490
+
491
+ /* Show notices if cart has errors */
492
+ add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
493
+
494
+ add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
495
+
496
+ add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
497
+
498
+ // Outputting the hidden field in checkout page.
499
+ add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
500
+ add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
501
+
502
+ remove_all_actions( 'woocommerce_checkout_billing' );
503
+ remove_all_actions( 'woocommerce_checkout_shipping' );
504
+
505
+ // Hook in actions once.
506
+ add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
507
+ add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
508
+
509
+ remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
510
+
511
+ add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
512
+
513
+ add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
514
+
515
+ add_filter( 'woocommerce_cart_totals_coupon_html', array( $this, 'remove_coupon_text' ) );
516
+
517
+ add_filter( 'woocommerce_order_button_text', array( $this, 'place_order_button_text' ), 10, 1 );
518
+
519
+ global $post;
520
+
521
+ if ( _is_wcf_checkout_type() ) {
522
+ $checkout_id = $post->ID;
523
+ } else {
524
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
525
+ }
526
+
527
+ do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
528
+ }
529
+ }
530
+
531
+ /**
532
+ * Render checkout ID hidden field.
533
+ *
534
+ * @param array $checkout checkout session data.
535
+ * @return void
536
+ */
537
+ public function checkout_shortcode_post_id( $checkout ) {
538
+
539
+ global $post;
540
+
541
+ if ( _is_wcf_checkout_type() ) {
542
+ $checkout_id = $post->ID;
543
+ } else {
544
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
545
+ }
546
+
547
+ $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
548
+
549
+ echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
550
+ echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
551
+ }
552
+
553
+ /**
554
+ * Load shortcode scripts.
555
+ *
556
+ * @return void
557
+ */
558
+ public function shortcode_scripts() {
559
+
560
+ wp_enqueue_style( 'wcf-checkout-template', wcf()->utils->get_css_url( 'checkout-template' ), '', CARTFLOWS_VER );
561
+
562
+ wp_enqueue_script(
563
+ 'wcf-checkout-template',
564
+ wcf()->utils->get_js_url( 'checkout-template' ),
565
+ array( 'jquery' ),
566
+ CARTFLOWS_VER,
567
+ true
568
+ );
569
+
570
+ do_action( 'cartflows_checkout_scripts' );
571
+
572
+ $style = $this->generate_style();
573
+
574
+ wp_add_inline_style( 'wcf-checkout-template', $style );
575
+
576
+ }
577
+
578
+ /**
579
+ * Load compatibility scripts.
580
+ *
581
+ * @return void
582
+ */
583
+ public function compatibility_scripts() {
584
+
585
+ global $post;
586
+
587
+ if ( _is_wcf_checkout_type() ) {
588
+ $checkout_id = $post->ID;
589
+ } else {
590
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
591
+ }
592
+
593
+ // Add DIVI Compatibility css if DIVI theme is enabled.
594
+ if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ||
595
+ Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id )
596
+ ) {
597
+ wp_enqueue_style( 'wcf-checkout-template-divi', wcf()->utils->get_css_url( 'checkout-template-divi' ), '', CARTFLOWS_VER );
598
+ }
599
+
600
+ // Add Flatsome Compatibility css if Flatsome theme is enabled.
601
+ if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
602
+ wp_enqueue_style( 'wcf-checkout-template-flatsome', wcf()->utils->get_css_url( 'checkout-template-flatsome' ), '', CARTFLOWS_VER );
603
+ }
604
+
605
+ // Add The7 Compatibility css if The7 theme is enabled.
606
+ if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) {
607
+ wp_enqueue_style( 'wcf-checkout-template-the-seven', wcf()->utils->get_css_url( 'checkout-template-the-seven' ), '', CARTFLOWS_VER );
608
+ }
609
+ }
610
+
611
+ /**
612
+ * Generate styles.
613
+ *
614
+ * @return string
615
+ */
616
+ public function generate_style() {
617
+
618
+ global $post;
619
+
620
+ if ( _is_wcf_checkout_type() ) {
621
+ $checkout_id = $post->ID;
622
+ } else {
623
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
624
+ }
625
+
626
+ CartFlows_Font_Families::render_fonts( $checkout_id );
627
+
628
+ $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
629
+
630
+ $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
631
+
632
+ $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
633
+
634
+ /**
635
+ $base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
636
+ $r = '';
637
+ $g = '';
638
+ $b = '';
639
+
640
+ $field_tb_padding = '';
641
+ $field_lr_padding = '';
642
+
643
+ $field_heading_color = '';
644
+ $field_color = '';
645
+ $field_bg_color = '';
646
+ $field_border_color = '';
647
+ $field_label_color = '';
648
+ $submit_tb_padding = '';
649
+ $submit_lr_padding = '';
650
+ $hl_bg_color = '';
651
+ $field_input_size = '';
652
+ $box_border_color = '';
653
+ $section_bg_color = '';
654
+ $submit_button_height = '';
655
+ $submit_color = '';
656
+ $submit_bg_color = $primary_color;
657
+ $submit_border_color = $primary_color;
658
+
659
+ $submit_hover_color = '';
660
+ $submit_bg_hover_color = $primary_color;
661
+ $submit_border_hover_color = $primary_color;
662
+
663
+ $section_heading_color = '';
664
+
665
+ $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
666
+
667
+ $button_font_family = '';
668
+ $button_font_weight = '';
669
+ $input_font_family = '';
670
+ $input_font_weight = '';
671
+ $heading_font_family = '';
672
+ $heading_font_weight = '';
673
+ $base_font_family = $base_font_family;
674
+ /**
675
+ $base_font_weight = $base_font_weight;*/
676
+
677
+ if ( 'yes' == $is_advance_option ) {
678
+
679
+ /**
680
+ * Get Font Family and Font Weight weight values
681
+ */
682
+ $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
683
+
684
+ $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
685
+ $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
686
+ $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
687
+ $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
688
+ $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
689
+ $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
690
+ $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
691
+ $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
692
+ $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
693
+ $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
694
+
695
+ $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
696
+
697
+ $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
698
+
699
+ $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
700
+
701
+ $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
702
+
703
+ $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
704
+
705
+ $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
706
+
707
+ $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
708
+
709
+ $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
710
+
711
+ $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
712
+
713
+ $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
714
+
715
+ $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
716
+
717
+ $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
718
+
719
+ $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
720
+
721
+ $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
722
+
723
+ $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
724
+
725
+ $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
726
+
727
+ /**
728
+ * Get font values
729
+ */
730
+
731
+ if ( 'custom' == $submit_button_height ) {
732
+ $submit_button_height = '38px';
733
+ }
734
+
735
+ if ( 'custom' == $field_input_size ) {
736
+ $field_input_size = '38px';
737
+ }
738
+ }
739
+ if ( isset( $primary_color ) ) {
740
+
741
+ list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
742
+ }
743
+ $output = "
744
+ .wcf-embed-checkout-form .woocommerce .woocommerce-checkout .product-name .remove:hover{
745
+ color:$primary_color !important;
746
+ border:1px solid $primary_color !important;
747
+ }
748
+ .wcf-embed-checkout-form .wcf-checkout-header-image img{
749
+ width: {$header_logo_width}px;
750
+ }
751
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
752
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
753
+ color: {$primary_color};
754
+ }
755
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
756
+ background-color: {$primary_color};
757
+ }
758
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
759
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
760
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
761
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
762
+ border-color: {$primary_color};
763
+ box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
764
+ }
765
+ .wcf-embed-checkout-form .woocommerce-checkout label{
766
+ color: {$field_label_color};
767
+ }
768
+ .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
769
+ background-color: {$hl_bg_color};
770
+ font-family: {$input_font_family};
771
+ font-weight: {$input_font_weight};
772
+ }
773
+
774
+ .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
775
+ .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
776
+ .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
777
+ {
778
+ border-bottom-color: {$hl_bg_color};
779
+ border-right-color: transparent;
780
+ border-left-color: transparent;
781
+ border-top-color: transparent;
782
+ position: absolute;
783
+ }
784
+
785
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
786
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
787
+ font-family: {$input_font_family};
788
+ font-weight: {$input_font_weight};
789
+ }
790
+
791
+ .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
792
+ .wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
793
+ .wcf-embed-checkout-form .woocommerce form .form-row textarea,
794
+ .wcf-embed-checkout-form .select2-container--default .select2-selection--single {
795
+ color: {$field_color};
796
+ background: {$field_bg_color};
797
+ border-color: {$field_border_color};
798
+ padding-top: {$field_tb_padding}px;
799
+ padding-bottom: {$field_tb_padding}px;
800
+ padding-left: {$field_lr_padding}px;
801
+ padding-right: {$field_lr_padding}px;
802
+ min-height: {$field_input_size};
803
+ font-family: {$input_font_family};
804
+ font-weight: {$input_font_weight};
805
+ }
806
+
807
+ .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
808
+ .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
809
+ .wcf-embed-checkout-form .woocommerce-checkout .shop_table,
810
+ .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
811
+ .wcf-embed-checkout-form .woocommerce-checkout #payment,
812
+ .wcf-embed-checkout-form .woocommerce form.checkout_coupon
813
+ {
814
+ background-color: {$section_bg_color};
815
+ border-color: {$box_border_color};
816
+ font-family: {$input_font_family};
817
+ font-weight: {$input_font_weight};
818
+ }
819
+
820
+ .woocommerce table.shop_table th{
821
+ color: {$field_label_color};
822
+ }
823
+ /*.wcf-embed-checkout-form .woocommerce .woocommerce-info,
824
+ .wcf-embed-checkout-form .woocommerce-message{
825
+ border-top-color: {$primary_color};
826
+ background-color: {$hl_bg_color};
827
+ }*/
828
+ .wcf-embed-checkout-form .woocommerce a{
829
+ color: {$primary_color};
830
+ }
831
+ .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
832
+ color: {$field_color};
833
+ }
834
+ .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
835
+ color: {$field_color};
836
+ }
837
+ .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
838
+ color: {$field_color};
839
+ }
840
+ .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
841
+ color: {$field_color};
842
+ }
843
+ .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
844
+ color: {$field_color};
845
+ }
846
+ .wcf-embed-checkout-form .woocommerce form p.form-row label {
847
+ color: {$field_label_color};
848
+ font-family: {$input_font_family};
849
+ font-weight: {$input_font_weight};
850
+ }
851
+ .wcf-embed-checkout-form .woocommerce #order_review button,
852
+ .wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,
853
+ .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small {
854
+ color: {$submit_color};
855
+ background: {$submit_bg_color};
856
+ padding-top: {$submit_tb_padding}px;
857
+ padding-bottom: {$submit_tb_padding}px;
858
+ padding-left: {$submit_lr_padding}px;
859
+ padding-right: {$submit_lr_padding}px;
860
+ border-color: {$submit_border_color};
861
+ min-height: {$submit_button_height};
862
+ font-family: {$button_font_family};
863
+ font-weight: {$button_font_weight};
864
+ }
865
+ .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
866
+ .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
867
+ background: {$submit_bg_color};
868
+ border: 1px {$submit_border_color} solid;
869
+ color: {$submit_color};
870
+ min-height: {$submit_button_height};
871
+ font-family: {$button_font_family};
872
+ font-weight: {$button_font_weight};
873
+ }
874
+ .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
875
+ .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
876
+ .wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
877
+ .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
878
+ color: {$submit_hover_color};
879
+ background-color: {$submit_bg_hover_color};
880
+ border-color: {$submit_border_hover_color};
881
+ }
882
+ .wcf-embed-checkout-form .woocommerce h3,
883
+ .wcf-embed-checkout-form .woocommerce h3 span,
884
+ .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
885
+ color: {$section_heading_color};
886
+ font-family: {$heading_font_family};
887
+ font-weight: {$heading_font_weight};
888
+ }
889
+ .wcf-embed-checkout-form .woocommerce-info::before,
890
+ .wcf-embed-checkout-form .woocommerce-message::before{
891
+ color: {$primary_color};
892
+ }
893
+ .wcf-embed-checkout-form{
894
+ font-family: {$base_font_family};
895
+ }
896
+ img.emoji, img.wp-smiley {}";
897
+
898
+ return $output;
899
+ }
900
+
901
+ /**
902
+ * Get ajax end points.
903
+ *
904
+ * @param string $endpoint_url end point URL.
905
+ * @param string $request end point request.
906
+ * @return string
907
+ */
908
+ public function get_ajax_endpoint( $endpoint_url, $request ) {
909
+
910
+ global $post;
911
+
912
+ if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
913
+
914
+ if ( _is_wcf_checkout_type() ) {
915
+
916
+ if ( mb_strpos( $endpoint_url, 'checkout', 0, 'utf-8' ) === false ) {
917
+
918
+ if ( '' === $request ) {
919
+ $query_args = array(
920
+ 'wc-ajax' => '%%endpoint%%',
921
+ );
922
+ } else {
923
+ $query_args = array(
924
+ 'wc-ajax' => $request,
925
+ );
926
+ }
927
+
928
+ $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 ); //phpcs:ignore
929
+ $uri = $uri[0];
930
+
931
+ $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
932
+ }
933
+ }
934
+ }
935
+
936
+ return $endpoint_url;
937
+ }
938
+
939
+
940
+ /**
941
+ * Save checkout fields.
942
+ *
943
+ * @param int $order_id order id.
944
+ * @param array $posted posted data.
945
+ * @return void
946
+ */
947
+ public function save_checkout_fields( $order_id, $posted ) {
948
+
949
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) { //phpcs:ignore
950
+
951
+ $checkout_id = wc_clean( intval( $_POST['_wcf_checkout_id'] ) ); //phpcs:ignore
952
+
953
+ update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
954
+
955
+ if ( isset( $_POST['_wcf_flow_id'] ) ) { //phpcs:ignore
956
+
957
+ $flow_id = wc_clean( intval( $_POST['_wcf_flow_id'] ) ); //phpcs:ignore
958
+
959
+ update_post_meta( $order_id, '_wcf_flow_id', $flow_id );
960
+ }
961
+ }
962
+
963
+ }
964
+
965
+ /**
966
+ * Enable Logo In Header Of Checkout Page
967
+ *
968
+ * @return void
969
+ */
970
+ public function enable_logo_in_header() {
971
+ global $post;
972
+
973
+ if ( _is_wcf_checkout_type() ) {
974
+ $checkout_id = $post->ID;
975
+ } else {
976
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
977
+ }
978
+
979
+ $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
980
+ $add_image_markup = '';
981
+
982
+ if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
983
+ $add_image_markup = '<div class="wcf-checkout-header-image">';
984
+ $add_image_markup .= '<img src="' . $header_logo_image . '" />';
985
+ $add_image_markup .= '</div>';
986
+ }
987
+
988
+ echo $add_image_markup;
989
+ }
990
+
991
+ /**
992
+ * Add text to the bootom of the checkout page.
993
+ *
994
+ * @return void
995
+ */
996
+ public function show_cartflows_copyright_message() {
997
+ $output_string = '';
998
+
999
+ $output_string .= '<div class="wcf-footer-primary">';
1000
+ $output_string .= '<div class="wcf-footer-content">';
1001
+ $output_string .= '<p class="wcf-footer-message">';
1002
+ $output_string .= 'Checkout powered by CartFlows';
1003
+ $output_string .= '</p>';
1004
+ $output_string .= '</div>';
1005
+ $output_string .= '</div>';
1006
+
1007
+ echo $output_string;
1008
+ }
1009
+
1010
+ /**
1011
+ * Redirect users to our checkout if hidden param
1012
+ *
1013
+ * @param string $redirect redirect url.
1014
+ * @param object $user user.
1015
+ * @return string
1016
+ */
1017
+ public function after_login_redirect( $redirect, $user ) {
1018
+
1019
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) { //phpcs:ignore
1020
+
1021
+ $checkout_id = intval( $_POST['_wcf_checkout_id'] ); //phpcs:ignore
1022
+
1023
+ $redirect = get_permalink( $checkout_id );
1024
+ }
1025
+
1026
+ return $redirect;
1027
+ }
1028
+
1029
+ /**
1030
+ * Display coupon code field after review order fields.
1031
+ */
1032
+ public function display_custom_coupon_field() {
1033
+
1034
+ $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
1035
+ $show_coupon = apply_filters( 'cartflows_show_coupon_field', true );
1036
+
1037
+ if ( ! ( $coupon_enabled && $show_coupon ) ) {
1038
+ return;
1039
+
1040
+ }
1041
+
1042
+ $coupon_field = array(
1043
+ 'field_text' => __( 'Coupon Code', 'cartflows' ),
1044
+ 'button_text' => __( 'Apply', 'cartflows' ),
1045
+ 'class' => '',
1046
+ );
1047
+
1048
+ $coupon_field = apply_filters( 'cartflows_coupon_field_options', $coupon_field );
1049
+
1050
+ ob_start();
1051
+ ?>
1052
+ <div class="wcf-custom-coupon-field <?php echo $coupon_field['class']; ?>" id="wcf_custom_coupon_field">
1053
+ <div class="wcf-coupon-col-1">
1054
+ <span>
1055
+ <input type="text" name="coupon_code" class="input-text wcf-coupon-code-input" placeholder="<?php echo $coupon_field['field_text']; ?>" id="coupon_code" value="">
1056
+ </span>
1057
+ </div>
1058
+ <div class="wcf-coupon-col-2">
1059
+ <span>
1060
+ <button type="button" class="button wcf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php echo $coupon_field['button_text']; ?></button>
1061
+ </span>
1062
+ </div>
1063
+ </div>
1064
+ <?php
1065
+ echo ob_get_clean();
1066
+ }
1067
+
1068
+ /**
1069
+ * Apply filter to change class of remove coupon field.
1070
+ *
1071
+ * @param string $coupon coupon.
1072
+ * @return string
1073
+ */
1074
+ public function remove_coupon_text( $coupon ) {
1075
+
1076
+ $coupon = str_replace( 'woocommerce-remove-coupon', 'wcf-remove-coupon', $coupon );
1077
+ return $coupon;
1078
+
1079
+ }
1080
+ /**
1081
+ * Apply filter to change the placeholder text of coupon field.
1082
+ *
1083
+ * @return string
1084
+ */
1085
+ public function coupon_field_placeholder() {
1086
+ return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
1087
+ }
1088
+
1089
+ /**
1090
+ * Apply filter to change the button text of coupon field.
1091
+ *
1092
+ * @return string
1093
+ */
1094
+ public function coupon_button_text() {
1095
+ return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
1096
+ }
1097
+
1098
+ /**
1099
+ * Apply coupon on submit of custom coupon form.
1100
+ */
1101
+ public function apply_coupon() {
1102
+
1103
+ $response = '';
1104
+
1105
+ check_ajax_referer( 'wcf-apply-coupon', 'security' );
1106
+ if ( ! empty( $_POST['coupon_code'] ) ) {
1107
+ $result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
1108
+ } else {
1109
+ wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' );
1110
+ }
1111
+
1112
+ $response = array(
1113
+ 'status' => $result,
1114
+ 'msg' => wc_print_notices( true ),
1115
+ );
1116
+
1117
+ echo wp_json_encode( $response );
1118
+
1119
+ die();
1120
+ }
1121
+
1122
+
1123
+ /**
1124
+ * Added ajax nonce to localize variable.
1125
+ *
1126
+ * @param array $vars localize variables.
1127
+ */
1128
+ public function add_localize_vars( $vars ) {
1129
+
1130
+ $vars['wcf_validate_coupon_nonce'] = wp_create_nonce( 'wcf-apply-coupon' );
1131
+
1132
+ $vars['wcf_validate_remove_coupon_nonce'] = wp_create_nonce( 'wcf-remove-coupon' );
1133
+
1134
+ $vars['wcf_validate_remove_cart_product_nonce'] = wp_create_nonce( 'wcf-remove-cart-product' );
1135
+
1136
+ $vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
1137
+
1138
+ return $vars;
1139
+ }
1140
+
1141
+ /**
1142
+ * Add custom class to the fields to change the UI to three column.
1143
+ *
1144
+ * @param array $fields fields.
1145
+ */
1146
+ public function add_three_column_layout_fields( $fields ) {
1147
+
1148
+ if ( empty( $fields['billing']['billing_address_2'] ) ) {
1149
+
1150
+ if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
1151
+ $fields['billing']['billing_address_1']['class'][] = 'form-row-full';
1152
+ }
1153
+ }
1154
+
1155
+ if ( ! empty( $fields['billing']['billing_company'] ) ) {
1156
+
1157
+ if ( isset( $fields['billing']['billing_company'] ) && is_array( $fields['billing']['billing_company'] ) ) {
1158
+ $fields['billing']['billing_company']['class'][] = 'form-row-full';
1159
+ }
1160
+ }
1161
+
1162
+ if ( ! empty( $fields['shipping']['shipping_company'] ) ) {
1163
+
1164
+ if ( isset( $fields['shipping']['shipping_company'] ) && is_array( $fields['shipping']['shipping_company'] ) ) {
1165
+ $fields['shipping']['shipping_company']['class'][] = 'form-row-full';
1166
+ }
1167
+ }
1168
+
1169
+ if ( ! empty( $fields['billing']['billing_country'] ) ) {
1170
+
1171
+ if ( isset( $fields['billing']['billing_country'] ) && is_array( $fields['billing']['billing_country'] ) ) {
1172
+ $fields['billing']['billing_country']['class'][] = 'form-row-full';
1173
+ }
1174
+ }
1175
+
1176
+ if ( ! empty( $fields['shipping']['shipping_country'] ) ) {
1177
+
1178
+ if ( isset( $fields['shipping']['shipping_country'] ) && is_array( $fields['shipping']['shipping_country'] ) ) {
1179
+ $fields['shipping']['shipping_country']['class'][] = 'form-row-full';
1180
+ }
1181
+ }
1182
+
1183
+ if ( ! empty( $fields['billing']['billing_phone'] ) ) {
1184
+
1185
+ if ( isset( $fields['billing']['billing_phone'] ) && is_array( $fields['billing']['billing_phone'] ) ) {
1186
+ $fields['billing']['billing_phone']['class'][] = 'form-row-full';
1187
+ }
1188
+ }
1189
+
1190
+ if ( ! empty( $fields['billing']['billing_email'] ) ) {
1191
+
1192
+ if ( isset( $fields['billing']['billing_email'] ) && is_array( $fields['billing']['billing_email'] ) ) {
1193
+ $fields['billing']['billing_email']['class'][] = 'form-row-full';
1194
+ }
1195
+ }
1196
+
1197
+ if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
1198
+
1199
+ if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
1200
+ $fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
1201
+ }
1202
+ }
1203
+
1204
+ if ( isset( $fields['billing']['billing_city'] ) &&
1205
+ isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
1206
+
1207
+ $fields['billing']['billing_city']['class'][] = 'wcf-column-33';
1208
+ $fields['billing']['billing_state']['class'][] = 'wcf-column-33';
1209
+ $fields['billing']['billing_postcode']['class'][] = 'wcf-column-33';
1210
+ }
1211
+
1212
+ if ( isset( $fields['shipping']['shipping_city'] ) &&
1213
+ isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
1214
+
1215
+ $fields['shipping']['shipping_city']['class'][] = 'wcf-column-33';
1216
+ $fields['shipping']['shipping_state']['class'][] = 'wcf-column-33';
1217
+ $fields['shipping']['shipping_postcode']['class'][] = 'wcf-column-33';
1218
+ }
1219
+
1220
+ return $fields;
1221
+ }
1222
+
1223
+ /**
1224
+ * Add opening dev
1225
+ *
1226
+ * @since 1.0.0
1227
+ */
1228
+ public function order_wrap_div_start() {
1229
+
1230
+ echo "<div class='wcf-order-wrap'> ";
1231
+ }
1232
+
1233
+ /**
1234
+ * Add closing dev
1235
+ *
1236
+ * @since 1.0.0
1237
+ */
1238
+ public function order_wrap_div_end() {
1239
+
1240
+ echo '</div> ';
1241
+ }
1242
+ /**
1243
+ * Remove coupon.
1244
+ */
1245
+ public function remove_coupon() {
1246
+
1247
+ check_ajax_referer( 'wcf-remove-coupon', 'security' );
1248
+ $coupon = isset( $_POST['coupon_code'] ) ? wc_clean( wp_unslash( $_POST['coupon_code'] ) ) : false; //phpcs:ignore
1249
+
1250
+ if ( empty( $coupon ) ) {
1251
+ echo "<div class='woocommerce-error'>" . esc_html__( 'Sorry there was a problem removing this coupon.', 'cartflows' );
1252
+ } else {
1253
+ WC()->cart->remove_coupon( $coupon );
1254
+ echo "<div class='woocommerce-error'>" . esc_html__( 'Coupon has been removed.', 'cartflows' ) . '</div>';
1255
+ }
1256
+ wc_print_notices();
1257
+ wp_die();
1258
+ }
1259
+
1260
+ /**
1261
+ * Remove cart item.
1262
+ */
1263
+ public function wcf_woo_remove_cart_product() {
1264
+
1265
+ check_ajax_referer( 'wcf-remove-cart-product', 'security' );
1266
+ $product_key = isset( $_POST['p_key'] ) ? wc_clean( wp_unslash( $_POST['p_key'] ) ) : false; //phpcs:ignore
1267
+ $product_id = isset( $_POST['p_id'] ) ? wc_clean( wp_unslash( $_POST['p_id'] ) ) : ''; //phpcs:ignore
1268
+ $product_title = get_the_title( $product_id );
1269
+
1270
+ $needs_shipping = false;
1271
+
1272
+ if ( empty( $product_key ) ) {
1273
+ $msg = "<div class='woocommerce-message'>" . __( 'Sorry there was a problem removing ', 'cartflows' ) . $product_title;
1274
+ } else {
1275
+ WC()->cart->remove_cart_item( $product_key );
1276
+ $msg = "<div class='woocommerce-message'>" . $product_title . __( ' has been removed.', 'cartflows' ) . '</div>';
1277
+ }
1278
+
1279
+ foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
1280
+ if ( $values['data']->needs_shipping() ) {
1281
+ $needs_shipping = true;
1282
+ break;
1283
+ }
1284
+ }
1285
+
1286
+ $response = array(
1287
+ 'need_shipping' => $needs_shipping,
1288
+ 'msg' => $msg,
1289
+ );
1290
+
1291
+ echo wp_json_encode( $response );
1292
+ wp_die();
1293
+ }
1294
+
1295
+ }
1296
+
1297
+ /**
1298
+ * Kicking this off by calling 'get_instance()' method
1299
+ */
1300
+ Cartflows_Checkout_Markup::get_instance();
modules/flow/classes/class-cartflows-step-post-type.php CHANGED
@@ -1,475 +1,475 @@
1
- <?php
2
- /**
3
- * Step post type.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Initialization
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Step_Post_Type {
14
-
15
-
16
- /**
17
- * Member Variable
18
- *
19
- * @var instance
20
- */
21
- private static $instance;
22
-
23
- /**
24
- * Member Variable
25
- *
26
- * @var body_classes
27
- */
28
- private $body_classes = array();
29
-
30
- /**
31
- * Initiator
32
- */
33
- public static function get_instance() {
34
- if ( ! isset( self::$instance ) ) {
35
- self::$instance = new self();
36
- }
37
- return self::$instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- */
43
- public function __construct() {
44
-
45
- add_action( 'init', array( $this, 'step_post_type' ) );
46
- add_action( 'init', array( $this, 'add_wp_templates_support' ) );
47
- add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
48
-
49
- add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
50
-
51
- add_filter( 'template_include', array( $this, 'load_page_template' ), 90 );
52
- add_filter( 'template_redirect', array( $this, 'query_fix' ), 3 );
53
- }
54
-
55
-
56
- /**
57
- * Trys to load page.php for a header, footer or part theme layout.
58
- *
59
- * @since 1.0.0
60
- * @param string $template The current template to be loaded.
61
- * @return string
62
- */
63
- public function load_page_template( $template ) {
64
-
65
- global $post;
66
-
67
- if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
68
-
69
- /**
70
- * Remove Next/Prev Navigation
71
- * add_filter('next_post_link', '__return_empty_string');
72
- * add_filter('previous_post_link', '__return_empty_string');
73
- *
74
- * $page = locate_template( array( 'page.php' ) );
75
- *
76
- * if ( ! empty( $page ) ) {
77
- * return $page;
78
- * }
79
- */
80
-
81
- /* Remove Next / Previous Rel Link */
82
- remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
83
- add_filter( 'next_post_rel_link', '__return_empty_string' );
84
- add_filter( 'previous_post_rel_link', '__return_empty_string' );
85
-
86
- $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
87
-
88
- $page_template = apply_filters( 'cartflows_page_template', $page_template );
89
-
90
- $file = '';
91
-
92
- switch ( $page_template ) {
93
-
94
- case 'cartflows-default':
95
- $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
96
- $this->body_classes[] = $page_template;
97
- break;
98
- case 'cartflows-canvas':
99
- $file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
100
- $this->body_classes[] = $page_template;
101
- break;
102
- default:
103
- /**
104
- * Remove Next/Prev Navigation
105
- */
106
- add_filter( 'next_post_link', '__return_empty_string' );
107
- add_filter( 'previous_post_link', '__return_empty_string' );
108
-
109
- $page = locate_template( array( 'page.php' ) );
110
-
111
- if ( ! empty( $page ) ) {
112
- $file = $page;
113
- }
114
-
115
- break;
116
-
117
- /**
118
- * Default:
119
- * $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
120
- * $this->body_classes[] = 'cartflows-default';
121
- * break;
122
- */
123
- }
124
-
125
- // Just to be safe, we check if the file exist first.
126
- if ( file_exists( $file ) ) {
127
-
128
- /* Add Body Class */
129
- add_filter( 'body_class', array( $this, 'body_class' ) );
130
-
131
- return $file;
132
- } else {
133
- echo $file;
134
- }
135
- }
136
-
137
- return $template;
138
- }
139
-
140
- /**
141
- * Body classes.
142
- *
143
- * @since 1.0.0
144
- * @param array $classes Body classes.
145
- * @return array
146
- */
147
- public function body_class( $classes = array() ) {
148
-
149
- $classes = array_merge( $classes, $this->body_classes );
150
-
151
- return $classes;
152
- }
153
-
154
- /**
155
- * Create custom post type
156
- */
157
- public function step_post_type() {
158
-
159
- $labels = array(
160
- 'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
161
- 'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
162
- 'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
163
- 'all_items' => esc_html__( 'All Steps', 'cartflows' ),
164
- 'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
165
- 'view_item' => esc_html__( 'View Step', 'cartflows' ),
166
- 'add_new' => esc_html__( 'Add New', 'cartflows' ),
167
- 'update_item' => esc_html__( 'Update Step', 'cartflows' ),
168
- 'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
169
- 'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
170
- );
171
-
172
- $permalink_settings = Cartflows_Helper::get_permalink_settings();
173
-
174
- $args = array(
175
- 'labels' => $labels,
176
- 'public' => true,
177
- 'query_var' => true,
178
- 'can_export' => true,
179
- 'exclude_from_search' => true,
180
- 'show_ui' => true,
181
- 'show_in_menu' => false,
182
- 'show_in_admin_bar' => true,
183
- 'supports' => array( 'title', 'editor', 'elementor', 'revisions' ),
184
- 'capability_type' => 'post',
185
- 'capabilities' => array(
186
- 'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
187
- ),
188
- 'map_meta_cap' => true,
189
- );
190
-
191
- if ( isset( $permalink_settings['permalink_structure'] ) && ! empty( $permalink_settings['permalink_structure'] ) ) {
192
- $args['rewrite'] = array(
193
- 'slug' => $permalink_settings['permalink_structure'],
194
- 'with_front' => false,
195
- );
196
-
197
- } elseif ( isset( $permalink_settings['permalink'] ) && ! empty( $permalink_settings['permalink'] ) ) {
198
-
199
- $args['rewrite'] = array(
200
- 'slug' => $permalink_settings['permalink'],
201
- 'with_front' => false,
202
- );
203
- }
204
-
205
- register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
206
-
207
- // Step Type.
208
- $args = array(
209
- 'label' => __( 'Step Type', 'cartflows' ),
210
- 'public' => false,
211
- 'rewrite' => false,
212
- 'hierarchical' => false,
213
- );
214
-
215
- register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
216
-
217
- // Step Flow.
218
- $args = array(
219
- 'label' => __( 'Step Flow', 'cartflows' ),
220
- 'public' => false,
221
- 'rewrite' => false,
222
- 'hierarchical' => false,
223
- );
224
-
225
- register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
226
-
227
- if ( is_admin() ) {
228
- /**
229
- * Register 'Elementor' & 'Beaver Builder' site types.
230
- *
231
- * @see self::add_terms();
232
- */
233
- $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
234
-
235
- $terms = array(
236
- array(
237
- 'name' => __( 'Landing', 'cartflows' ),
238
- 'slug' => 'landing',
239
- 'args' => array(
240
- 'slug' => 'landing',
241
- ),
242
- ),
243
- array(
244
- 'name' => __( 'Optin (Woo)', 'cartflows' ),
245
- 'slug' => 'optin',
246
- 'args' => array(
247
- 'slug' => 'optin',
248
- ),
249
- ),
250
- array(
251
- 'name' => __( 'Checkout (Woo)', 'cartflows' ),
252
- 'slug' => 'checkout',
253
- 'args' => array(
254
- 'slug' => 'checkout',
255
- ),
256
- ),
257
- array(
258
- 'name' => __( 'Thank You (Woo)', 'cartflows' ),
259
- 'slug' => 'thankyou',
260
- 'args' => array(
261
- 'slug' => 'thankyou',
262
- ),
263
- ),
264
- array(
265
- 'name' => __( 'Upsell (Woo)', 'cartflows' ),
266
- 'slug' => 'upsell',
267
- 'args' => array(
268
- 'slug' => 'upsell',
269
- ),
270
- ),
271
- array(
272
- 'name' => __( 'Downsell (Woo)', 'cartflows' ),
273
- 'slug' => 'downsell',
274
- 'args' => array(
275
- 'slug' => 'downsell',
276
- ),
277
- ),
278
- );
279
-
280
- $this->add_terms( $taxonomy, $terms );
281
-
282
- }
283
- }
284
-
285
- /**
286
- * Add WordPress templates.
287
- *
288
- * Adds Cartflows templates to steps
289
- *
290
- * @since 1.0.0
291
- * @access public
292
- */
293
- public function add_wp_templates_support() {
294
- add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
295
- }
296
-
297
- /**
298
- * Add page templates.
299
- *
300
- * @since 1.0.0
301
- * @access public
302
- *
303
- * @param array $page_templates Array of page templates.
304
- *
305
- * @param object $wp_theme wp theme.
306
- * @param object $post post.
307
- *
308
- * @return array Page templates.
309
- */
310
- public function add_page_templates( $page_templates, $wp_theme, $post ) {
311
-
312
- $page_templates = array(
313
- 'cartflows-default' => _x( 'CartFlows — Boxed', 'cartflows' ),
314
- 'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
315
- );
316
-
317
- return $page_templates;
318
- }
319
-
320
-
321
-
322
- /**
323
- * Query fixe throwing error on 404 page due our post type changes.
324
- * We are setting post_type as empty array to fix the issue.
325
- * Ther error was throwing due to redirect_canonical function
326
- * This fix is apply for 404 page only
327
- */
328
- public function query_fix() {
329
-
330
- global $wp_query;
331
-
332
- if ( $wp_query->is_404() ) {
333
- $wp_query->set( 'post_type', array() );
334
- }
335
- }
336
-
337
- /**
338
- * Prevent slug duplicated
339
- *
340
- * @param string $slug post slug.
341
- * @param int $post_ID post id.
342
- * @param string $post_status post status.
343
- * @param string $post_type post type.
344
- * @param int $post_parent post parent id.
345
- * @param string $original_slug original slug.
346
- * @return string
347
- */
348
- public function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
349
-
350
- $check_post_types = array(
351
- 'post',
352
- 'page',
353
- CARTFLOWS_STEP_POST_TYPE,
354
- );
355
-
356
- if ( ! in_array( $post_type, $check_post_types, true ) ) {
357
- return $slug;
358
- }
359
-
360
- if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
361
- // Saving a post, check for duplicates in POST or PAGE post types.
362
- $post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
363
- $page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
364
-
365
- if ( $post_match || $page_match ) {
366
- $slug .= '-2';
367
- }
368
- } else {
369
-
370
- // Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
371
- $custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
372
-
373
- if ( $custom_post_type_match ) {
374
- $slug .= '-2';
375
- }
376
- }
377
-
378
- return $slug;
379
- }
380
-
381
- /**
382
- * Add Update messages for any custom post type
383
- *
384
- * @param array $messages Array of default messages.
385
- */
386
- public function post_update_messages( $messages ) {
387
-
388
- $custom_post_type = get_post_type( get_the_ID() );
389
-
390
- if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
391
-
392
- $obj = get_post_type_object( $custom_post_type );
393
- $singular_name = $obj->labels->singular_name;
394
- $messages[ $custom_post_type ] = array(
395
- 0 => '', // Unused. Messages start at index 1.
396
- /* translators: %s: singular custom post type name */
397
- 1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
398
- /* translators: %s: singular custom post type name */
399
- 2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
400
- /* translators: %s: singular custom post type name */
401
- 3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
402
- /* translators: %s: singular custom post type name */
403
- 4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
404
- /* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
405
- 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, //phpcs:ignore
406
- /* translators: %s: singular custom post type name */
407
- 6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
408
- /* translators: %s: singular custom post type name */
409
- 7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
410
- /* translators: %s: singular custom post type name */
411
- 8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
412
- /* translators: %s: singular custom post type name */
413
- 9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
414
- /* translators: %s: singular custom post type name */
415
- 10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
416
- );
417
- }
418
-
419
- return $messages;
420
- }
421
-
422
- /**
423
- * Add Terms for Taxonomy.
424
- *
425
- * => Example.
426
- *
427
- * $taxonomy = '{taxonomy}';
428
- * $terms = array(
429
- * array(
430
- * 'name' => 'Landing',
431
- * 'slug' => 'landing',
432
- * ),
433
- * array(
434
- * 'name' => 'Checkout',
435
- * 'slug' => 'checkout',
436
- * ),
437
- * );
438
- *
439
- * self::add_terms( $taxonomy, $terms );
440
- *
441
- * @since 1.0.0
442
- * @param string $taxonomy Taxonomy Name.
443
- * @param array $terms Terms list.
444
- * @return void
445
- */
446
- public function add_terms( $taxonomy = '', $terms = array() ) {
447
-
448
- foreach ( $terms as $key => $term ) {
449
-
450
- $term_exist = term_exists( $term['slug'], $taxonomy );
451
-
452
- if ( empty( $term_exist ) ) {
453
-
454
- /**
455
- * Add additional args if passed from request.
456
- *
457
- * @see https://codex.wordpress.org/Function_Reference/wp_insert_term
458
- */
459
- if ( array_key_exists( 'args', $term ) ) {
460
- wp_insert_term( $term['name'], $taxonomy, $term['args'] );
461
- } else {
462
-
463
- $term['args'] = array( $term['slug'] );
464
-
465
- wp_insert_term( $term['name'], $taxonomy, $term['args'] );
466
- }
467
- }
468
- }
469
- }
470
- }
471
-
472
- /**
473
- * Kicking this off by calling 'get_instance()' method
474
- */
475
- Cartflows_Step_Post_Type::get_instance();
1
+ <?php
2
+ /**
3
+ * Step post type.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Initialization
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Step_Post_Type {
14
+
15
+
16
+ /**
17
+ * Member Variable
18
+ *
19
+ * @var instance
20
+ */
21
+ private static $instance;
22
+
23
+ /**
24
+ * Member Variable
25
+ *
26
+ * @var body_classes
27
+ */
28
+ private $body_classes = array();
29
+
30
+ /**
31
+ * Initiator
32
+ */
33
+ public static function get_instance() {
34
+ if ( ! isset( self::$instance ) ) {
35
+ self::$instance = new self();
36
+ }
37
+ return self::$instance;
38
+ }
39
+
40
+ /**
41
+ * Constructor
42
+ */
43
+ public function __construct() {
44
+
45
+ add_action( 'init', array( $this, 'step_post_type' ) );
46
+ add_action( 'init', array( $this, 'add_wp_templates_support' ) );
47
+ add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
48
+
49
+ add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
50
+
51
+ add_filter( 'template_include', array( $this, 'load_page_template' ), 90 );
52
+ add_filter( 'template_redirect', array( $this, 'query_fix' ), 3 );
53
+ }
54
+
55
+
56
+ /**
57
+ * Trys to load page.php for a header, footer or part theme layout.
58
+ *
59
+ * @since 1.0.0
60
+ * @param string $template The current template to be loaded.
61
+ * @return string
62
+ */
63
+ public function load_page_template( $template ) {
64
+
65
+ global $post;
66
+
67
+ if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
68
+
69
+ /**
70
+ * Remove Next/Prev Navigation
71
+ * add_filter('next_post_link', '__return_empty_string');
72
+ * add_filter('previous_post_link', '__return_empty_string');
73
+ *
74
+ * $page = locate_template( array( 'page.php' ) );
75
+ *
76
+ * if ( ! empty( $page ) ) {
77
+ * return $page;
78
+ * }
79
+ */
80
+
81
+ /* Remove Next / Previous Rel Link */
82
+ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
83
+ add_filter( 'next_post_rel_link', '__return_empty_string' );
84
+ add_filter( 'previous_post_rel_link', '__return_empty_string' );
85
+
86
+ $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
87
+
88
+ $page_template = apply_filters( 'cartflows_page_template', $page_template );
89
+
90
+ $file = '';
91
+
92
+ switch ( $page_template ) {
93
+
94
+ case 'cartflows-default':
95
+ $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
96
+ $this->body_classes[] = $page_template;
97
+ break;
98
+ case 'cartflows-canvas':
99
+ $file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
100
+ $this->body_classes[] = $page_template;
101
+ break;
102
+ default:
103
+ /**
104
+ * Remove Next/Prev Navigation
105
+ */
106
+ add_filter( 'next_post_link', '__return_empty_string' );
107
+ add_filter( 'previous_post_link', '__return_empty_string' );
108
+
109
+ $page = locate_template( array( 'page.php' ) );
110
+
111
+ if ( ! empty( $page ) ) {
112
+ $file = $page;
113
+ }
114
+
115
+ break;
116
+
117
+ /**
118
+ * Default:
119
+ * $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
120
+ * $this->body_classes[] = 'cartflows-default';
121
+ * break;
122
+ */
123
+ }
124
+
125
+ // Just to be safe, we check if the file exist first.
126
+ if ( file_exists( $file ) ) {
127
+
128
+ /* Add Body Class */
129
+ add_filter( 'body_class', array( $this, 'body_class' ) );
130
+
131
+ return $file;
132
+ } else {
133
+ echo $file;
134
+ }
135
+ }
136
+
137
+ return $template;
138
+ }
139
+
140
+ /**
141
+ * Body classes.
142
+ *
143
+ * @since 1.0.0
144
+ * @param array $classes Body classes.
145
+ * @return array
146
+ */
147
+ public function body_class( $classes = array() ) {
148
+
149
+ $classes = array_merge( $classes, $this->body_classes );
150
+
151
+ return $classes;
152
+ }
153
+
154
+ /**
155
+ * Create custom post type
156
+ */
157
+ public function step_post_type() {
158
+
159
+ $labels = array(
160
+ 'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
161
+ 'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
162
+ 'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
163
+ 'all_items' => esc_html__( 'All Steps', 'cartflows' ),
164
+ 'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
165
+ 'view_item' => esc_html__( 'View Step', 'cartflows' ),
166
+ 'add_new' => esc_html__( 'Add New', 'cartflows' ),
167
+ 'update_item' => esc_html__( 'Update Step', 'cartflows' ),
168
+ 'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
169
+ 'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
170
+ );
171
+
172
+ $permalink_settings = Cartflows_Helper::get_permalink_settings();
173
+
174
+ $args = array(
175
+ 'labels' => $labels,
176
+ 'public' => true,
177
+ 'query_var' => true,
178
+ 'can_export' => true,
179
+ 'exclude_from_search' => true,
180
+ 'show_ui' => true,
181
+ 'show_in_menu' => false,
182
+ 'show_in_admin_bar' => true,
183
+ 'supports' => array( 'title', 'editor', 'elementor', 'revisions' ),
184
+ 'capability_type' => 'post',
185
+ 'capabilities' => array(
186
+ 'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
187
+ ),
188
+ 'map_meta_cap' => true,
189
+ );
190
+
191
+ if ( isset( $permalink_settings['permalink_structure'] ) && ! empty( $permalink_settings['permalink_structure'] ) ) {
192
+ $args['rewrite'] = array(
193
+ 'slug' => $permalink_settings['permalink_structure'],
194
+ 'with_front' => false,
195
+ );
196
+
197
+ } elseif ( isset( $permalink_settings['permalink'] ) && ! empty( $permalink_settings['permalink'] ) ) {
198
+
199
+ $args['rewrite'] = array(
200
+ 'slug' => $permalink_settings['permalink'],
201
+ 'with_front' => false,
202
+ );
203
+ }
204
+
205
+ register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
206
+
207
+ // Step Type.
208
+ $args = array(
209
+ 'label' => __( 'Step Type', 'cartflows' ),
210
+ 'public' => false,
211
+ 'rewrite' => false,
212
+ 'hierarchical' => false,
213
+ );
214
+
215
+ register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
216
+
217
+ // Step Flow.
218
+ $args = array(
219
+ 'label' => __( 'Step Flow', 'cartflows' ),
220
+ 'public' => false,
221
+ 'rewrite' => false,
222
+ 'hierarchical' => false,
223
+ );
224
+
225
+ register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
226
+
227
+ if ( is_admin() ) {
228
+ /**
229
+ * Register 'Elementor' & 'Beaver Builder' site types.
230
+ *
231
+ * @see self::add_terms();
232
+ */
233
+ $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
234
+
235
+ $terms = array(
236
+ array(
237
+ 'name' => __( 'Landing', 'cartflows' ),
238
+ 'slug' => 'landing',
239
+ 'args' => array(
240
+ 'slug' => 'landing',
241
+ ),
242
+ ),
243
+ array(
244
+ 'name' => __( 'Optin (Woo)', 'cartflows' ),
245
+ 'slug' => 'optin',
246
+ 'args' => array(
247
+ 'slug' => 'optin',
248
+ ),
249
+ ),
250
+ array(
251
+ 'name' => __( 'Checkout (Woo)', 'cartflows' ),
252
+ 'slug' => 'checkout',
253
+ 'args' => array(
254
+ 'slug' => 'checkout',
255
+ ),
256
+ ),
257
+ array(
258
+ 'name' => __( 'Thank You (Woo)', 'cartflows' ),
259
+ 'slug' => 'thankyou',
260
+ 'args' => array(
261
+ 'slug' => 'thankyou',
262
+ ),
263
+ ),
264
+ array(
265
+ 'name' => __( 'Upsell (Woo)', 'cartflows' ),
266
+ 'slug' => 'upsell',
267
+ 'args' => array(
268
+ 'slug' => 'upsell',
269
+ ),
270
+ ),
271
+ array(
272
+ 'name' => __( 'Downsell (Woo)', 'cartflows' ),
273
+ 'slug' => 'downsell',
274
+ 'args' => array(
275
+ 'slug' => 'downsell',
276
+ ),
277
+ ),
278
+ );
279
+
280
+ $this->add_terms( $taxonomy, $terms );
281
+
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Add WordPress templates.
287
+ *
288
+ * Adds Cartflows templates to steps
289
+ *
290
+ * @since 1.0.0
291
+ * @access public
292
+ */
293
+ public function add_wp_templates_support() {
294
+ add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
295
+ }
296
+
297
+ /**
298
+ * Add page templates.
299
+ *
300
+ * @since 1.0.0
301
+ * @access public
302
+ *
303
+ * @param array $page_templates Array of page templates.
304
+ *
305
+ * @param object $wp_theme wp theme.
306
+ * @param object $post post.
307
+ *
308
+ * @return array Page templates.
309
+ */
310
+ public function add_page_templates( $page_templates, $wp_theme, $post ) {
311
+
312
+ $page_templates = array(
313
+ 'cartflows-default' => _x( 'CartFlows — Boxed', 'cartflows' ),
314
+ 'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
315
+ );
316
+
317
+ return $page_templates;
318
+ }
319
+
320
+
321
+
322
+ /**
323
+ * Query fixe throwing error on 404 page due our post type changes.
324
+ * We are setting post_type as empty array to fix the issue.
325
+ * Ther error was throwing due to redirect_canonical function
326
+ * This fix is apply for 404 page only
327
+ */
328
+ public function query_fix() {
329
+
330
+ global $wp_query;
331
+
332
+ if ( $wp_query->is_404() ) {
333
+ $wp_query->set( 'post_type', array() );
334
+ }
335
+ }
336
+
337
+ /**
338
+ * Prevent slug duplicated
339
+ *
340
+ * @param string $slug post slug.
341
+ * @param int $post_ID post id.
342
+ * @param string $post_status post status.
343
+ * @param string $post_type post type.
344
+ * @param int $post_parent post parent id.
345
+ * @param string $original_slug original slug.
346
+ * @return string
347
+ */
348
+ public function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
349
+
350
+ $check_post_types = array(
351
+ 'post',
352
+ 'page',
353
+ CARTFLOWS_STEP_POST_TYPE,
354
+ );
355
+
356
+ if ( ! in_array( $post_type, $check_post_types, true ) ) {
357
+ return $slug;
358
+ }
359
+
360
+ if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
361
+ // Saving a post, check for duplicates in POST or PAGE post types.
362
+ $post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
363
+ $page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
364
+
365
+ if ( $post_match || $page_match ) {
366
+ $slug .= '-2';
367
+ }
368
+ } else {
369
+
370
+ // Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
371
+ $custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
372
+
373
+ if ( $custom_post_type_match ) {
374
+ $slug .= '-2';
375
+ }
376
+ }
377
+
378
+ return $slug;
379
+ }
380
+
381
+ /**
382
+ * Add Update messages for any custom post type
383
+ *
384
+ * @param array $messages Array of default messages.
385
+ */
386
+ public function post_update_messages( $messages ) {
387
+
388
+ $custom_post_type = get_post_type( get_the_ID() );
389
+
390
+ if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
391
+
392
+ $obj = get_post_type_object( $custom_post_type );
393
+ $singular_name = $obj->labels->singular_name;
394
+ $messages[ $custom_post_type ] = array(
395
+ 0 => '', // Unused. Messages start at index 1.
396
+ /* translators: %s: singular custom post type name */
397
+ 1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
398
+ /* translators: %s: singular custom post type name */
399
+ 2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
400
+ /* translators: %s: singular custom post type name */
401
+ 3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
402
+ /* translators: %s: singular custom post type name */
403
+ 4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
404
+ /* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
405
+ 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, //phpcs:ignore
406
+ /* translators: %s: singular custom post type name */
407
+ 6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
408
+ /* translators: %s: singular custom post type name */
409
+ 7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
410
+ /* translators: %s: singular custom post type name */
411
+ 8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
412
+ /* translators: %s: singular custom post type name */
413
+ 9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
414
+ /* translators: %s: singular custom post type name */
415
+ 10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
416
+ );
417
+ }
418
+
419
+ return $messages;
420
+ }
421
+
422
+ /**
423
+ * Add Terms for Taxonomy.
424
+ *
425
+ * => Example.
426
+ *
427
+ * $taxonomy = '{taxonomy}';
428
+ * $terms = array(
429
+ * array(
430
+ * 'name' => 'Landing',
431
+ * 'slug' => 'landing',
432
+ * ),
433
+ * array(
434
+ * 'name' => 'Checkout',
435
+ * 'slug' => 'checkout',
436
+ * ),
437
+ * );
438
+ *
439
+ * self::add_terms( $taxonomy, $terms );
440
+ *
441
+ * @since 1.0.0
442
+ * @param string $taxonomy Taxonomy Name.
443
+ * @param array $terms Terms list.
444
+ * @return void
445
+ */
446
+ public function add_terms( $taxonomy = '', $terms = array() ) {
447
+
448
+ foreach ( $terms as $key => $term ) {
449
+
450
+ $term_exist = term_exists( $term['slug'], $taxonomy );
451
+
452
+ if ( empty( $term_exist ) ) {
453
+
454
+ /**
455
+ * Add additional args if passed from request.
456
+ *
457
+ * @see https://codex.wordpress.org/Function_Reference/wp_insert_term
458
+ */
459
+ if ( array_key_exists( 'args', $term ) ) {
460
+ wp_insert_term( $term['name'], $taxonomy, $term['args'] );
461
+ } else {
462
+
463
+ $term['args'] = array( $term['slug'] );
464
+
465
+ wp_insert_term( $term['name'], $taxonomy, $term['args'] );
466
+ }
467
+ }
468
+ }
469
+ }
470
+ }
471
+
472
+ /**
473
+ * Kicking this off by calling 'get_instance()' method
474
+ */
475
+ Cartflows_Step_Post_Type::get_instance();
modules/flow/view/meta-flow-steps.php CHANGED
@@ -1,210 +1,210 @@
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
- $steps = array(
11
- 'landing' => __( 'Landing', 'cartflows' ),
12
- 'checkout' => __( 'Checkout (Woo)', 'cartflows' ),
13
- 'thankyou' => __( 'Thank You (Woo)', 'cartflows' ),
14
- 'upsell' => __( 'Upsell (Woo)', 'cartflows' ),
15
- 'downsell' => __( 'Downsell (Woo)', 'cartflows' ),
16
- 'optin' => __( 'Optin (Woo)', 'cartflows' ),
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
- $data_step_id = intval( $data['id'] );
35
-
36
- if ( isset( $data['type'] ) ) {
37
- $term_slug = $data['type'];
38
- $term_name = $steps[ $data['type'] ];
39
- }
40
-
41
- if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) {
42
- $step_wrap_class .= ' invalid-step';
43
- }
44
-
45
- if ( isset( $_GET['highlight-step-id'] ) ) { //phpcs:ignore
46
-
47
- $highlight_step_id = intval( $_GET['highlight-step-id'] ); //phpcs:ignore
48
-
49
- if ( $highlight_step_id === $data_step_id ) {
50
- $step_wrap_class .= ' wcf-new-step-highlight';
51
- }
52
- }
53
-
54
- if ( 'checkout' === $term_slug ) {
55
-
56
- $common = Cartflows_Helper::get_common_settings();
57
-
58
- $is_global_checkout = (int) $common['global_checkout'];
59
-
60
- if ( $data['id'] === $is_global_checkout ) {
61
- $step_wrap_class .= ' wcf-global-checkout';
62
- }
63
- }
64
-
65
- if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) {
66
-
67
- $has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] );
68
-
69
- if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
70
- $step_wrap_class .= ' wcf-no-product-step';
71
- }
72
- }
73
-
74
- ?>
75
- <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 ); ?>">
76
- <div class="wcf-step">
77
- <div class="wcf-step-left-content">
78
- <span class="dashicons dashicons-menu"></span>
79
- <span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span>
80
- <span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span>
81
-
82
- <?php
83
- if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
84
- ?>
85
- <span class="wcf-no-product-badge"><?php esc_html_e( 'No Product Assigned', 'cartflows' ); ?></span>
86
- <?php
87
- } elseif ( ( $has_product_assigned ) && ( $data['id'] === $is_global_checkout ) ) {
88
- ?>
89
- <span class="wcf-global-checkout-badge"><?php esc_html_e( 'Global Checkout - Remove selected checkout product', 'cartflows' ); ?></span>
90
- <?php
91
- } elseif ( ( ! $has_product_assigned ) && $data['id'] === $is_global_checkout ) {
92
- ?>
93
- <span class="wcf-global-checkout-badge"><?php esc_html_e( 'Global Checkout', 'cartflows' ); ?></span>
94
- <?php
95
- }
96
- ?>
97
-
98
- <input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>">
99
- <?php do_action( 'cartflows_step_left_content', $data['id'], $term_slug ); ?>
100
- </div>
101
- <div class="wcf-steps-action-buttons">
102
- <a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'View Step', 'cartflows' ); ?>" >
103
- <span class="dashicons dashicons-visibility"></span>
104
- <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'View', 'cartflows' ); ?></span>
105
- </a>
106
- <a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'Edit Step', 'cartflows' ); ?>" >
107
- <span class="dashicons dashicons-edit"></span>
108
- <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Edit', 'cartflows' ); ?></span>
109
- </a>
110
- <?php
111
- if ( _is_cartflows_pro() ) {
112
- ?>
113
- <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 esc_html__( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
114
- <span class="dashicons dashicons-admin-page"></span>
115
- <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Clone', 'cartflows' ); ?></span>
116
- </a>
117
- <?php } ?>
118
- <a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
119
- <span class="dashicons dashicons-trash"></span>
120
- <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Delete', 'cartflows' ); ?></span>
121
- </a>
122
- </div>
123
- </div>
124
- </div><!-- .wcf-step-wrap -->
125
- <?php } ?>
126
- <?php } ?>
127
- </div><!-- .wcf-flow-steps-container -->
128
- </div> <!-- .wcf-flow-steps-wrap -->
129
- <div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap -->
130
- <?php do_action( 'cartflows_bellow_flow_steps' ); ?>
131
- <div class='wcf-add-new-step-btn-wrap'>
132
- <button class='wcf-trigger-popup button button-primary'>
133
- <?php echo esc_html__( 'Add New Step', 'cartflows' ); ?>
134
- </button>
135
- </div>
136
- </div><!-- .wcf-flow-buttons-wrap -->
137
- </div><!-- .wcf-flow-settings -->
138
-
139
- <div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay">
140
- <div class="wcf-templates-popup-content">
141
- <div class="spinner"></div>
142
- <div class="wcf-templates-wrap wcf-templates-wrap-flows">
143
-
144
- <div id="wcf-remote-step-actions" class="wcf-template-header">
145
- <div class="wcf-template-logo-wrap">
146
- <span class="wcf-cartflows-logo-img">
147
- <span class="cartflows-logo-icon"></span>
148
- </span>
149
- <span class="wcf-cartflows-title"><?php esc_html_e( 'Steps Library', 'cartflows' ); ?></span>
150
- </div>
151
- <div class="wcf-tab-wrapper">
152
- <?php if ( 'other' !== $default_page_builder ) { ?>
153
- <div id="wcf-get-started-steps">
154
- <ul class="filter-links ">
155
- <li>
156
- <a href="#" class="current" data-slug="ready-templates" data-title="<?php esc_html_e( 'Ready Templates', 'cartflows' ); ?>"><?php esc_html_e( 'Ready Templates', 'cartflows' ); ?></a>
157
- </li>
158
- <li>
159
- <a href="#" data-slug="canvas" data-title="<?php esc_html_e( 'Create Your Own', 'cartflows' ); ?>"><?php esc_html_e( 'Create Your Own', 'cartflows' ); ?></a>
160
- </li>
161
- </ul>
162
- </div>
163
- <?php } ?>
164
- </div>
165
- <div class="wcf-popup-close-wrap">
166
- <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
167
- </div>
168
- </div>
169
-
170
- <!--<div class="wcf-search-form">
171
- <label class="screen-reader-text" for="wp-filter-search-input"><?php esc_html_e( 'Search Sites', 'cartflows' ); ?> </label>
172
- <input placeholder="<?php esc_html_e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
173
- </div>-->
174
-
175
- <div id="wcf-remote-content">
176
- <?php if ( 'other' !== $default_page_builder ) { ?>
177
- <div id="wcf-ready-templates">
178
- <div id="wcf-remote-filters">
179
- <div id="wcf-page-builders"></div>
180
- <div id="wcf-categories"></div>
181
- </div>
182
- <div class="wcf-page-builder-notice"></div>
183
- <div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
184
- <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
185
- </div>
186
- <?php } ?>
187
- <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
188
- <div class="inner">
189
- <div id="wcf-scratch-steps-categories">
190
- <select class="step-type-filter-links filter-links">
191
- <option value="" class="current"> Select Step Type </option>
192
-
193
- <?php foreach ( $steps as $key => $value ) { ?>
194
- <option class="<?php echo $key; ?>" data-slug="<?php echo $key; ?>" data-title="<?php echo $key; ?>"><?php echo $value; ?></option>
195
- <?php } ?>
196
- </select>
197
- </div>
198
- <a href="#" class="button button-primary cartflows-step-import-blank"><?php esc_html_e( 'Create Step', 'cartflows' ); ?></a>
199
- <?php if ( ! _is_cartflows_pro() ) { ?>
200
- <div class="wcf-template-notice"><p><?php echo esc_html__( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div>
201
- <?php } ?>
202
- <p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php esc_html_e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
203
- </div>
204
- </div>
205
- </div>
206
- </div>
207
- </div>
208
- </div><!-- .wcf-templates-popup-overlay -->
209
- </div>
210
- <?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
+ $steps = array(
11
+ 'landing' => __( 'Landing', 'cartflows' ),
12
+ 'checkout' => __( 'Checkout (Woo)', 'cartflows' ),
13
+ 'thankyou' => __( 'Thank You (Woo)', 'cartflows' ),
14
+ 'upsell' => __( 'Upsell (Woo)', 'cartflows' ),
15
+ 'downsell' => __( 'Downsell (Woo)', 'cartflows' ),
16
+ 'optin' => __( 'Optin (Woo)', 'cartflows' ),
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
+ $data_step_id = intval( $data['id'] );
35
+
36
+ if ( isset( $data['type'] ) ) {
37
+ $term_slug = $data['type'];
38
+ $term_name = $steps[ $data['type'] ];
39
+ }
40
+
41
+ if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) {
42
+ $step_wrap_class .= ' invalid-step';
43
+ }
44
+
45
+ if ( isset( $_GET['highlight-step-id'] ) ) { //phpcs:ignore
46
+
47
+ $highlight_step_id = intval( $_GET['highlight-step-id'] ); //phpcs:ignore
48
+
49
+ if ( $highlight_step_id === $data_step_id ) {
50
+ $step_wrap_class .= ' wcf-new-step-highlight';
51
+ }
52
+ }
53
+
54
+ if ( 'checkout' === $term_slug ) {
55
+
56
+ $common = Cartflows_Helper::get_common_settings();
57
+
58
+ $is_global_checkout = (int) $common['global_checkout'];
59
+
60
+ if ( $data['id'] === $is_global_checkout ) {
61
+ $step_wrap_class .= ' wcf-global-checkout';
62
+ }
63
+ }
64
+
65
+ if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) {
66
+
67
+ $has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] );
68
+
69
+ if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
70
+ $step_wrap_class .= ' wcf-no-product-step';
71
+ }
72
+ }
73
+
74
+ ?>
75
+ <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 ); ?>">
76
+ <div class="wcf-step">
77
+ <div class="wcf-step-left-content">
78
+ <span class="dashicons dashicons-menu"></span>
79
+ <span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span>
80
+ <span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span>
81
+
82
+ <?php
83
+ if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
84
+ ?>
85
+ <span class="wcf-no-product-badge"><?php esc_html_e( 'No Product Assigned', 'cartflows' ); ?></span>
86
+ <?php
87
+ } elseif ( ( $has_product_assigned ) && ( $data['id'] === $is_global_checkout ) ) {
88
+ ?>
89
+ <span class="wcf-global-checkout-badge"><?php esc_html_e( 'Global Checkout - Remove selected checkout product', 'cartflows' ); ?></span>
90
+ <?php
91
+ } elseif ( ( ! $has_product_assigned ) && $data['id'] === $is_global_checkout ) {
92
+ ?>
93
+ <span class="wcf-global-checkout-badge"><?php esc_html_e( 'Global Checkout', 'cartflows' ); ?></span>
94
+ <?php
95
+ }
96
+ ?>
97
+
98
+ <input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>">
99
+ <?php do_action( 'cartflows_step_left_content', $data['id'], $term_slug ); ?>
100
+ </div>
101
+ <div class="wcf-steps-action-buttons">
102
+ <a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'View Step', 'cartflows' ); ?>" >
103
+ <span class="dashicons dashicons-visibility"></span>
104
+ <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'View', 'cartflows' ); ?></span>
105
+ </a>
106
+ <a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'Edit Step', 'cartflows' ); ?>" >
107
+ <span class="dashicons dashicons-edit"></span>
108
+ <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Edit', 'cartflows' ); ?></span>
109
+ </a>
110
+ <?php
111
+ if ( _is_cartflows_pro() ) {
112
+ ?>
113
+ <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 esc_html__( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
114
+ <span class="dashicons dashicons-admin-page"></span>
115
+ <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Clone', 'cartflows' ); ?></span>
116
+ </a>
117
+ <?php } ?>
118
+ <a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo esc_html__( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
119
+ <span class="dashicons dashicons-trash"></span>
120
+ <span class="wcf-step-act-btn-text"><?php echo esc_html__( 'Delete', 'cartflows' ); ?></span>
121
+ </a>
122
+ </div>
123
+ </div>
124
+ </div><!-- .wcf-step-wrap -->
125
+ <?php } ?>
126
+ <?php } ?>
127
+ </div><!-- .wcf-flow-steps-container -->
128
+ </div> <!-- .wcf-flow-steps-wrap -->
129
+ <div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap -->
130
+ <?php do_action( 'cartflows_bellow_flow_steps' ); ?>
131
+ <div class='wcf-add-new-step-btn-wrap'>
132
+ <button class='wcf-trigger-popup button button-primary'>
133
+ <?php echo esc_html__( 'Add New Step', 'cartflows' ); ?>
134
+ </button>
135
+ </div>
136
+ </div><!-- .wcf-flow-buttons-wrap -->
137
+ </div><!-- .wcf-flow-settings -->
138
+
139
+ <div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay">
140
+ <div class="wcf-templates-popup-content">
141
+ <div class="spinner"></div>
142
+ <div class="wcf-templates-wrap wcf-templates-wrap-flows">
143
+
144
+ <div id="wcf-remote-step-actions" class="wcf-template-header">
145
+ <div class="wcf-template-logo-wrap">
146
+ <span class="wcf-cartflows-logo-img">
147
+ <span class="cartflows-logo-icon"></span>
148
+ </span>
149
+ <span class="wcf-cartflows-title"><?php esc_html_e( 'Steps Library', 'cartflows' ); ?></span>
150
+ </div>
151
+ <div class="wcf-tab-wrapper">
152
+ <?php if ( 'other' !== $default_page_builder ) { ?>
153
+ <div id="wcf-get-started-steps">
154
+ <ul class="filter-links ">
155
+ <li>
156
+ <a href="#" class="current" data-slug="ready-templates" data-title="<?php esc_html_e( 'Ready Templates', 'cartflows' ); ?>"><?php esc_html_e( 'Ready Templates', 'cartflows' ); ?></a>
157
+ </li>
158
+ <li>
159
+ <a href="#" data-slug="canvas" data-title="<?php esc_html_e( 'Create Your Own', 'cartflows' ); ?>"><?php esc_html_e( 'Create Your Own', 'cartflows' ); ?></a>
160
+ </li>
161
+ </ul>
162
+ </div>
163
+ <?php } ?>
164
+ </div>
165
+ <div class="wcf-popup-close-wrap">
166
+ <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
167
+ </div>
168
+ </div>
169
+
170
+ <!--<div class="wcf-search-form">
171
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php esc_html_e( 'Search Sites', 'cartflows' ); ?> </label>
172
+ <input placeholder="<?php esc_html_e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
173
+ </div>-->
174
+
175
+ <div id="wcf-remote-content">
176
+ <?php if ( 'other' !== $default_page_builder ) { ?>
177
+ <div id="wcf-ready-templates">
178
+ <div id="wcf-remote-filters">
179
+ <div id="wcf-page-builders"></div>
180
+ <div id="wcf-categories"></div>
181
+ </div>
182
+ <div class="wcf-page-builder-notice"></div>
183
+ <div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
184
+ <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
185
+ </div>
186
+ <?php } ?>
187
+ <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
188
+ <div class="inner">
189
+ <div id="wcf-scratch-steps-categories">
190
+ <select class="step-type-filter-links filter-links">
191
+ <option value="" class="current"> Select Step Type </option>
192
+
193
+ <?php foreach ( $steps as $key => $value ) { ?>
194
+ <option class="<?php echo $key; ?>" data-slug="<?php echo $key; ?>" data-title="<?php echo $key; ?>"><?php echo $value; ?></option>
195
+ <?php } ?>
196
+ </select>
197
+ </div>
198
+ <a href="#" class="button button-primary cartflows-step-import-blank"><?php esc_html_e( 'Create Step', 'cartflows' ); ?></a>
199
+ <?php if ( ! _is_cartflows_pro() ) { ?>
200
+ <div class="wcf-template-notice"><p><?php echo esc_html__( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div>
201
+ <?php } ?>
202
+ <p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php esc_html_e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
203
+ </div>
204
+ </div>
205
+ </div>
206
+ </div>
207
+ </div>
208
+ </div><!-- .wcf-templates-popup-overlay -->
209
+ </div>
210
+ <?php
modules/landing/classes/class-cartflows-landing-markup.php CHANGED
@@ -1,139 +1,143 @@
1
- <?php
2
- /**
3
- * Markup
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Checkout Markup
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Landing_Markup {
14
-
15
-
16
- /**
17
- * Member Variable
18
- *
19
- * @var object instance
20
- */
21
- private static $instance;
22
-
23
- /**
24
- * Initiator
25
- */
26
- public static function get_instance() {
27
- if ( ! isset( self::$instance ) ) {
28
- self::$instance = new self();
29
- }
30
- return self::$instance;
31
- }
32
-
33
- /**
34
- * Constructor
35
- */
36
- public function __construct() {
37
-
38
- add_action( 'pre_get_posts', array( $this, 'wcf_pre_get_posts' ) );
39
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
40
-
41
- if ( is_admin() ) {
42
- add_filter( 'wp_dropdown_pages', array( $this, 'wp_dropdown_pages' ) );
43
- }
44
- }
45
-
46
- /**
47
- * Add landing pages in WordPress reading section.
48
- *
49
- * @param array $output output.
50
- */
51
- public function wp_dropdown_pages( $output ) {
52
-
53
- global $pagenow;
54
-
55
- if ( ( 'options-reading.php' === $pagenow || 'customize.php' === $pagenow ) && preg_match( '#page_on_front#', $output ) ) {
56
-
57
- $args = array(
58
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
59
- 'numberposts' => 100,
60
- 'meta_query' => array( //phpcs:ignore
61
- 'relation' => 'OR',
62
- array(
63
- 'key' => 'wcf-step-type',
64
- 'value' => 'landing',
65
- ),
66
- array(
67
- 'key' => 'wcf-step-type',
68
- 'value' => 'checkout',
69
- ),
70
- ),
71
- );
72
-
73
- $landing_pages = get_posts( $args );
74
-
75
- if ( is_array( $landing_pages ) && ! empty( $landing_pages ) ) {
76
-
77
- $cartflows_custom_option = '';
78
-
79
- $front_page_id = get_option( 'page_on_front' );
80
-
81
- foreach ( $landing_pages as $key => $landing_page ) {
82
-
83
- $selected = selected( $front_page_id, $landing_page->ID, false );
84
-
85
- $cartflows_custom_option .= "<option value=\"{$landing_page->ID}\"{$selected}>{$landing_page->post_title} ( #{$landing_page->ID} - CartFlows )</option>";
86
- }
87
-
88
- $cartflows_custom_option .= '</select>';
89
-
90
- $output = str_replace( '</select>', $cartflows_custom_option, $output );
91
- }
92
- }
93
-
94
- return $output;
95
- }
96
-
97
- /**
98
- * Set post query.
99
- *
100
- * @param string $query post query.
101
- */
102
- public function wcf_pre_get_posts( $query ) {
103
-
104
- if ( $query->is_main_query() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
105
-
106
- $post_type = $query->get( 'post_type' );
107
-
108
- $page_id = $query->get( 'page_id' );
109
-
110
- if ( empty( $post_type ) && ! empty( $page_id ) ) {
111
- $query->set( 'post_type', get_post_type( $page_id ) );
112
- }
113
- }
114
- }
115
-
116
- /**
117
- * Redirect to homepage if landing page set as home page.
118
- */
119
- public function template_redirect() {
120
-
121
- $compatibiliy = Cartflows_Compatibility::get_instance();
122
-
123
- // Do not redirect for page builder preview.
124
- if ( $compatibiliy->is_page_builder_preview() ) {
125
- return;
126
- }
127
-
128
- global $post;
129
-
130
- if ( is_singular() && ! is_front_page() && get_option( 'page_on_front' ) == $post->ID ) {
131
- wp_safe_redirect( site_url(), 301 );
132
- }
133
- }
134
- }
135
-
136
- /**
137
- * Kicking this off by calling 'get_instance()' method
138
- */
139
- Cartflows_Landing_Markup::get_instance();
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Markup
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Checkout Markup
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Landing_Markup {
14
+
15
+
16
+ /**
17
+ * Member Variable
18
+ *
19
+ * @var object instance
20
+ */
21
+ private static $instance;
22
+
23
+ /**
24
+ * Initiator
25
+ */
26
+ public static function get_instance() {
27
+ if ( ! isset( self::$instance ) ) {
28
+ self::$instance = new self();
29
+ }
30
+ return self::$instance;
31
+ }
32
+
33
+ /**
34
+ * Constructor
35
+ */
36
+ public function __construct() {
37
+
38
+ add_action( 'pre_get_posts', array( $this, 'wcf_pre_get_posts' ) );
39
+ add_action( 'template_redirect', array( $this, 'template_redirect' ) );
40
+
41
+ if ( is_admin() ) {
42
+ add_filter( 'wp_dropdown_pages', array( $this, 'wp_dropdown_pages' ) );
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Add landing pages in WordPress reading section.
48
+ *
49
+ * @param array $output output.
50
+ */
51
+ public function wp_dropdown_pages( $output ) {
52
+
53
+ global $pagenow;
54
+
55
+ if ( ( 'options-reading.php' === $pagenow || 'customize.php' === $pagenow ) && preg_match( '#page_on_front#', $output ) ) {
56
+
57
+ $args = array(
58
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
59
+ 'numberposts' => 100,
60
+ 'meta_query' => array( //phpcs:ignore
61
+ 'relation' => 'OR',
62
+ array(
63
+ 'key' => 'wcf-step-type',
64
+ 'value' => 'landing',
65
+ ),
66
+ array(
67
+ 'key' => 'wcf-step-type',
68
+ 'value' => 'checkout',
69
+ ),
70
+ array(
71
+ 'key' => 'wcf-step-type',
72
+ 'value' => 'optin',
73
+ ),
74
+ ),
75
+ );
76
+
77
+ $landing_pages = get_posts( $args );
78
+
79
+ if ( is_array( $landing_pages ) && ! empty( $landing_pages ) ) {
80
+
81
+ $cartflows_custom_option = '';
82
+
83
+ $front_page_id = get_option( 'page_on_front' );
84
+
85
+ foreach ( $landing_pages as $key => $landing_page ) {
86
+
87
+ $selected = selected( $front_page_id, $landing_page->ID, false );
88
+
89
+ $cartflows_custom_option .= "<option value=\"{$landing_page->ID}\"{$selected}>{$landing_page->post_title} ( #{$landing_page->ID} - CartFlows )</option>";
90
+ }
91
+
92
+ $cartflows_custom_option .= '</select>';
93
+
94
+ $output = str_replace( '</select>', $cartflows_custom_option, $output );
95
+ }
96
+ }
97
+
98
+ return $output;
99
+ }
100
+
101
+ /**
102
+ * Set post query.
103
+ *
104
+ * @param string $query post query.
105
+ */
106
+ public function wcf_pre_get_posts( $query ) {
107
+
108
+ if ( $query->is_main_query() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
109
+
110
+ $post_type = $query->get( 'post_type' );
111
+
112
+ $page_id = $query->get( 'page_id' );
113
+
114
+ if ( empty( $post_type ) && ! empty( $page_id ) ) {
115
+ $query->set( 'post_type', get_post_type( $page_id ) );
116
+ }
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Redirect to homepage if landing page set as home page.
122
+ */
123
+ public function template_redirect() {
124
+
125
+ $compatibiliy = Cartflows_Compatibility::get_instance();
126
+
127
+ // Do not redirect for page builder preview.
128
+ if ( $compatibiliy->is_page_builder_preview() ) {
129
+ return;
130
+ }
131
+
132
+ global $post;
133
+
134
+ if ( is_singular() && ! is_front_page() && get_option( 'page_on_front' ) == $post->ID ) {
135
+ wp_safe_redirect( site_url(), 301 );
136
+ }
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Kicking this off by calling 'get_instance()' method
142
+ */
143
+ Cartflows_Landing_Markup::get_instance();
modules/optin/class-cartflows-optin.php CHANGED
@@ -1,47 +1,47 @@
1
- <?php
2
- /**
3
- * Checkout
4
- *
5
- * @package Woo Funnel Cart
6
- */
7
-
8
- define( 'CARTFLOWS_OPTIN_DIR', CARTFLOWS_DIR . 'modules/optin/' );
9
- define( 'CARTFLOWS_OPTIN_URL', CARTFLOWS_URL . 'modules/optin/' );
10
-
11
- /**
12
- * Initial Setup
13
- *
14
- * @since 1.0.0
15
- */
16
- class Cartflows_Optin {
17
-
18
-
19
- /**
20
- * Member Variable
21
- *
22
- * @var object instance
23
- */
24
- private static $instance;
25
-
26
- /**
27
- * Initiator
28
- */
29
- public static function get_instance() {
30
- if ( ! isset( self::$instance ) ) {
31
- self::$instance = new self();
32
- }
33
- return self::$instance;
34
- }
35
-
36
- /**
37
- * Constructor function that initializes required actions and hooks
38
- */
39
- public function __construct() {
40
- require_once CARTFLOWS_OPTIN_DIR . 'classes/class-cartflows-optin-markup.php';
41
- require_once CARTFLOWS_OPTIN_DIR . 'classes/class-cartflows-optin-meta.php';
42
- }
43
- }
44
- /**
45
- * Kicking this off by calling 'get_instance()' method
46
- */
47
- Cartflows_Optin::get_instance();
1
+ <?php
2
+ /**
3
+ * Checkout
4
+ *
5
+ * @package Woo Funnel Cart
6
+ */
7
+
8
+ define( 'CARTFLOWS_OPTIN_DIR', CARTFLOWS_DIR . 'modules/optin/' );
9
+ define( 'CARTFLOWS_OPTIN_URL', CARTFLOWS_URL . 'modules/optin/' );
10
+
11
+ /**
12
+ * Initial Setup
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ class Cartflows_Optin {
17
+
18
+
19
+ /**
20
+ * Member Variable
21
+ *
22
+ * @var object instance
23
+ */
24
+ private static $instance;
25
+
26
+ /**
27
+ * Initiator
28
+ */
29
+ public static function get_instance() {
30
+ if ( ! isset( self::$instance ) ) {
31
+ self::$instance = new self();
32
+ }
33
+ return self::$instance;
34
+ }
35
+
36
+ /**
37
+ * Constructor function that initializes required actions and hooks
38
+ */
39
+ public function __construct() {
40
+ require_once CARTFLOWS_OPTIN_DIR . 'classes/class-cartflows-optin-markup.php';
41
+ require_once CARTFLOWS_OPTIN_DIR . 'classes/class-cartflows-optin-meta.php';
42
+ }
43
+ }
44
+ /**
45
+ * Kicking this off by calling 'get_instance()' method
46
+ */
47
+ Cartflows_Optin::get_instance();
modules/optin/templates/optin-template-simple.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
- /**
3
- * Checkout template
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- $optin_layout = 'one-column';
9
- $fields_skins = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-input-fields-skins' );
10
- ?>
11
- <div id="wcf-optin-form" class="wcf-optin-form wcf-optin-form-one-column wcf-field-<?php echo $fields_skins; ?>">
12
-
13
- <!-- CHECKOUT SHORTCODE -->
14
- <?php do_action( 'cartflows_optin_before_main_section', $optin_layout ); ?>
15
-
16
- <?php
17
-
18
- $checkout_html = do_shortcode( '[woocommerce_checkout]' );
19
-
20
- if (
21
- empty( $checkout_html ) ||
22
- trim( $checkout_html ) == '<div class="woocommerce"></div>'
23
- ) {
24
-
25
- echo esc_html__( 'Your cart is currently empty.', 'cartflows' );
26
- } else {
27
- echo $checkout_html;
28
- }
29
- ?>
30
-
31
- <?php do_action( 'cartflows_optin_after_main_section', $optin_layout ); ?>
32
- <!-- END CHECKOUT SHORTCODE -->
33
- </div>
1
+ <?php
2
+ /**
3
+ * Checkout template
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ $optin_layout = 'one-column';
9
+ $fields_skins = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-input-fields-skins' );
10
+ ?>
11
+ <div id="wcf-optin-form" class="wcf-optin-form wcf-optin-form-one-column wcf-field-<?php echo $fields_skins; ?>">
12
+
13
+ <!-- CHECKOUT SHORTCODE -->
14
+ <?php do_action( 'cartflows_optin_before_main_section', $optin_layout ); ?>
15
+
16
+ <?php
17
+
18
+ $checkout_html = do_shortcode( '[woocommerce_checkout]' );
19
+
20
+ if (
21
+ empty( $checkout_html ) ||
22
+ trim( $checkout_html ) == '<div class="woocommerce"></div>'
23
+ ) {
24
+
25
+ echo esc_html__( 'Your cart is currently empty.', 'cartflows' );
26
+ } else {
27
+ echo $checkout_html;
28
+ }
29
+ ?>
30
+
31
+ <?php do_action( 'cartflows_optin_after_main_section', $optin_layout ); ?>
32
+ <!-- END CHECKOUT SHORTCODE -->
33
+ </div>
modules/thankyou/classes/class-cartflows-thankyou-markup.php CHANGED
@@ -51,7 +51,6 @@ class Cartflows_Thankyou_Markup {
51
  add_action( 'cartflows_thank_you_scripts', array( $this, 'add_divi_compatibility_css' ) );
52
  }
53
 
54
-
55
  /**
56
  * Redirect to custom url instead of thank you page.
57
  */
@@ -83,6 +82,9 @@ class Cartflows_Thankyou_Markup {
83
  /* Remove order item link */
84
  add_filter( 'woocommerce_order_item_permalink', '__return_false' );
85
 
 
 
 
86
  if ( ! function_exists( 'wc_print_notices' ) ) {
87
 
88
  $notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>';
@@ -342,6 +344,26 @@ class Cartflows_Thankyou_Markup {
342
 
343
  return $is_checkout;
344
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  }
346
 
347
  /**
51
  add_action( 'cartflows_thank_you_scripts', array( $this, 'add_divi_compatibility_css' ) );
52
  }
53
 
 
54
  /**
55
  * Redirect to custom url instead of thank you page.
56
  */
82
  /* Remove order item link */
83
  add_filter( 'woocommerce_order_item_permalink', '__return_false' );
84
 
85
+ /* Change order text */
86
+ add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'custom_tq_text' ), 10, 2 );
87
+
88
  if ( ! function_exists( 'wc_print_notices' ) ) {
89
 
90
  $notice_out = '<p class="woocommerce-notice">' . __( 'WooCommerce functions do not exist. If you are in an IFrame, please reload it.', 'cartflows' ) . '</p>';
344
 
345
  return $is_checkout;
346
  }
347
+
348
+ /**
349
+ * Add custom text on thank you page.
350
+ *
351
+ * @param string $woo_text Default text.
352
+ * @param int $order order.
353
+ */
354
+ public function custom_tq_text( $woo_text, $order ) {
355
+
356
+ global $post;
357
+
358
+ $thank_you_id = $post->ID;
359
+ $new_text = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text' );
360
+
361
+ if ( ! empty( $new_text ) ) {
362
+ $woo_text = do_shortcode( $new_text );
363
+ }
364
+
365
+ return $woo_text;
366
+ }
367
  }
368
 
369
  /**
modules/thankyou/classes/class-cartflows-thankyou-meta.php CHANGED
@@ -323,27 +323,42 @@ class Cartflows_Thankyou_Meta extends Cartflows_Meta {
323
  ?>
324
  </div>
325
  <div class="wcf-thankyou-redirect wcf-tab-content widefat" >
326
- <?php
327
- echo wcf()->meta->get_checkbox_field(
328
- array(
329
- 'label' => __( 'Redirect After Purchase', 'cartflows' ),
330
- 'name' => 'wcf-show-tq-redirect-section',
331
- 'value' => $options['wcf-show-tq-redirect-section'],
332
- 'after' => 'Enable',
333
- )
334
- );
 
 
 
335
 
336
- echo wcf()->meta->get_text_field(
337
- array(
338
- 'label' => __( 'Redirect Link', 'cartflows' ),
339
- 'name' => 'wcf-tq-redirect-link',
340
- 'value' => $options['wcf-tq-redirect-link'],
341
- 'attr' => array(
342
- 'placeholder' => __( 'https://', 'cartflows' ),
343
- ),
344
- )
345
- );
346
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
347
  </div>
348
 
349
  <?php $this->tab_custom_script( $options, $post_id ); ?>
323
  ?>
324
  </div>
325
  <div class="wcf-thankyou-redirect wcf-tab-content widefat" >
326
+ <?php
327
+ echo wcf()->meta->get_text_field(
328
+ array(
329
+ 'label' => __( 'Thank You Page Text', 'cartflows' ),
330
+ 'name' => 'wcf-tq-text',
331
+ 'value' => $options['wcf-tq-text'],
332
+ 'attr' => array(
333
+ 'placeholder' => __( 'Thank you. Your order has been received.', 'cartflows' ),
334
+ ),
335
+ 'help' => __( 'It will change the default text on thank you page.', 'cartflows' ),
336
+ )
337
+ );
338
 
339
+ echo wcf()->meta->get_hr_line_field( array() );
340
+
341
+ echo wcf()->meta->get_checkbox_field(
342
+ array(
343
+ 'label' => __( 'Redirect After Purchase', 'cartflows' ),
344
+ 'name' => 'wcf-show-tq-redirect-section',
345
+ 'value' => $options['wcf-show-tq-redirect-section'],
346
+ 'after' => 'Enable',
347
+ )
348
+ );
349
+
350
+ echo wcf()->meta->get_text_field(
351
+ array(
352
+ 'label' => __( 'Redirect Link', 'cartflows' ),
353
+ 'name' => 'wcf-tq-redirect-link',
354
+ 'value' => $options['wcf-tq-redirect-link'],
355
+ 'attr' => array(
356
+ 'placeholder' => __( 'https://', 'cartflows' ),
357
+ ),
358
+ )
359
+ );
360
+
361
+ ?>
362
  </div>
363
 
364
  <?php $this->tab_custom_script( $options, $post_id ); ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/BrainstormForce
4
  Tags: woocommerce, funnel builder, sales funnels, elementor, beaver builder
5
  Requires at least: 4.4
6
  Tested up to: 5.3.2
7
- Stable tag: 1.4.0
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -125,6 +125,15 @@ Glad you asked! CartFlows Pro is an optional add-on to CartFlows that adds addit
125
 
126
  == Changelog ==
127
 
 
 
 
 
 
 
 
 
 
128
  = Version 1.4.0 - Tuesday, 11th February 2020 =
129
  * New: Introduced a new optin step type for lead generation.
130
  * Improvement: Added compatibility for a future release of CartFlows Pro.
4
  Tags: woocommerce, funnel builder, sales funnels, elementor, beaver builder
5
  Requires at least: 4.4
6
  Tested up to: 5.3.2
7
+ Stable tag: 1.4.2
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
125
 
126
  == Changelog ==
127
 
128
+ = Version 1.4.2 - Wednesday, 19th February 2020 =
129
+ * New: Added option to change default order confirmations text on thank you page.
130
+ * New: Added ability to set optin step type as a home page.
131
+ * New: Create WooCommerce's product directly from the checkout step.
132
+ * Improvement: Optin step type is included in LearnDash LMS template settings.
133
+
134
+ = Version 1.4.1 - Thursday, 13th February 2020 =
135
+ * Fix: Optin step was redirecting to the global checkout.
136
+
137
  = Version 1.4.0 - Tuesday, 11th February 2020 =
138
  * New: Introduced a new optin step type for lead generation.
139
  * Improvement: Added compatibility for a future release of CartFlows Pro.