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

Version Description

Download this release

Release Info

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

Code changes from version 1.5.6 to 1.5.7

admin/assets/css/global-admin-rtl.css CHANGED
@@ -76,10 +76,21 @@
76
  .post-type-cartflows_flow .wcf-notice-back-edit-flow .button-primary{
77
  height: 30px;
78
  }
 
79
  .wcf-notice-back-edit-flow .dashicons-arrow-left-alt{
80
  vertical-align: text-bottom;
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
83
  /*
84
  * ************************
85
  * Add Flow Popup Window
@@ -315,13 +326,6 @@
315
  * Shortcode Box on the Head Section of Checkout Meta Box
316
  * ******************************************************
317
  */
318
- #field-wcf-shortcode{
319
- display: none;
320
- margin-right: 5px;
321
- vertical-align: top;
322
- line-height: 0;
323
- }
324
-
325
  /*
326
  * ************************
327
  * Css For
76
  .post-type-cartflows_flow .wcf-notice-back-edit-flow .button-primary{
77
  height: 30px;
78
  }
79
+
80
  .wcf-notice-back-edit-flow .dashicons-arrow-left-alt{
81
  vertical-align: text-bottom;
82
  }
83
 
84
+ .wcf-notice-back-edit-flow .button.button-large{
85
+ margin: 2px;
86
+ height: 33px;
87
+ font-size: 13px;
88
+ }
89
+
90
+ .wcf-notice-back-edit-flow.gutenberg-button .dashicons-arrow-left-alt{
91
+ vertical-align: middle;
92
+ }
93
+
94
  /*
95
  * ************************
96
  * Add Flow Popup Window
326
  * Shortcode Box on the Head Section of Checkout Meta Box
327
  * ******************************************************
328
  */
 
 
 
 
 
 
 
329
  /*
330
  * ************************
331
  * Css For
admin/assets/css/global-admin.css CHANGED
@@ -76,10 +76,21 @@
76
  .post-type-cartflows_flow .wcf-notice-back-edit-flow .button-primary{
77
  height: 30px;
78
  }
 
79
  .wcf-notice-back-edit-flow .dashicons-arrow-left-alt{
80
  vertical-align: text-bottom;
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
83
  /*
84
  * ************************
85
  * Add Flow Popup Window
@@ -315,13 +326,6 @@
315
  * Shortcode Box on the Head Section of Checkout Meta Box
316
  * ******************************************************
317
  */
318
- #field-wcf-shortcode{
319
- display: none;
320
- margin-left: 5px;
321
- vertical-align: top;
322
- line-height: 0;
323
- }
324
-
325
  /*
326
  * ************************
327
  * Css For
76
  .post-type-cartflows_flow .wcf-notice-back-edit-flow .button-primary{
77
  height: 30px;
78
  }
79
+
80
  .wcf-notice-back-edit-flow .dashicons-arrow-left-alt{
81
  vertical-align: text-bottom;
82
  }
83
 
84
+ .wcf-notice-back-edit-flow .button.button-large{
85
+ margin: 2px;
86
+ height: 33px;
87
+ font-size: 13px;
88
+ }
89
+
90
+ .wcf-notice-back-edit-flow.gutenberg-button .dashicons-arrow-left-alt{
91
+ vertical-align: middle;
92
+ }
93
+
94
  /*
95
  * ************************
96
  * Add Flow Popup Window
326
  * Shortcode Box on the Head Section of Checkout Meta Box
327
  * ******************************************************
328
  */
 
 
 
 
 
 
 
329
  /*
330
  * ************************
331
  * Css For
admin/assets/js/global-admin.js CHANGED
@@ -52,7 +52,7 @@
52
  var hide_show_fields = function() {
53
  // body...
54
  }
55
- }
56
 
57
  /* Show Hide Custom Options for input types */
58
  var wcf_checkout_show_field_custom_options = function() {
@@ -84,7 +84,7 @@
84
  $('.field-wcf-field-lr-padding').hide();
85
  }
86
  });
87
- }
88
 
89
  /* Show Hide Custom Options for Buttons */
90
  var wcf_checkout_show_button_custom_options = function() {
@@ -122,7 +122,7 @@
122
  wrapper.find('.field-wcf-submit-lr-padding').hide();
123
  }
124
  });
125
- }
126
 
127
  /* Show Hide Custom Options for Buttons */
128
  var wcf_optin_submit_button_custom_options = function() {
@@ -418,15 +418,66 @@
418
  });
419
  };
420
 
421
- $( document ).ready(function() {
 
422
 
423
- //wcf_toggle_fields_general_logic();
 
 
 
 
 
 
424
 
425
- //alert("Before Stattement");
426
- $( '#field-wcf-shortcode' ).appendTo( '#wcf-checkout-settings .hndle span' );
427
- $( '#field-wcf-shortcode' ).css( "display", "inline" );
428
- //alert("After Stattement");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  /* Checkout */
431
  wcf_checkout_show_field_custom_options();
432
 
@@ -449,7 +500,8 @@
449
 
450
  /* Create woo product from iframe */
451
  wcf_create_woo_product_from_iframe();
452
-
453
- });
454
 
455
- } )( jQuery );
 
 
 
52
  var hide_show_fields = function() {
53
  // body...
54
  }
55
+ };
56
 
57
  /* Show Hide Custom Options for input types */
58
  var wcf_checkout_show_field_custom_options = function() {
84
  $('.field-wcf-field-lr-padding').hide();
85
  }
86
  });
87
+ };
88
 
89
  /* Show Hide Custom Options for Buttons */
90
  var wcf_checkout_show_button_custom_options = function() {
122
  wrapper.find('.field-wcf-submit-lr-padding').hide();
123
  }
124
  });
125
+ };
126
 
127
  /* Show Hide Custom Options for Buttons */
128
  var wcf_optin_submit_button_custom_options = function() {
418
  });
419
  };
420
 
421
+ /* Gutenberg compatibility and events */
422
+ var wcf_gutenberg_compatibility_and_events = function() {
423
 
424
+ if( $('body .block-editor #editor').length < 1 ) {
425
+ return;
426
+ }
427
+
428
+ var wcf_trigger_update_button_click = function(){
429
+
430
+ $( '.wcf-column-right-footer #wcf-save' ).on( 'click', function( event ) {
431
 
432
+ event.preventDefault();
433
+
434
+ var wcf_update_button = $(this),
435
+ wp_update_button = $('.edit-post-header__settings button.editor-post-publish-button');
436
+
437
+ if ( wcf_update_button.hasClass('is-busy') ) {
438
+ return;
439
+ }
440
+
441
+ wcf_update_button.addClass('is-busy').val('Updating...');
442
+ wp_update_button.trigger('click', 'update');
443
+
444
+ var reloader = setInterval(function() {
445
+
446
+ success = wp.data.select('core/editor').didPostSaveRequestSucceed();
447
+
448
+ if ( success && ! wp_update_button.hasClass('is-busy') ) {
449
+
450
+ clearInterval(reloader);
451
+
452
+ wcf_update_button.removeClass('is-busy').val('Update');
453
+ }
454
+ }, 300);
455
+ });
456
+ };
457
 
458
+ var wcf_back_flow_button = function(){
459
+
460
+ if ( 'cartflows_step' === typenow ) {
461
+
462
+ var flow_back_button = $('#wcf-gutenberg-back-flow-button').html();
463
+
464
+ if( flow_back_button.length > 0 ){
465
+
466
+ $('body #editor').find('.edit-post-header-toolbar').append(flow_back_button);
467
+ }
468
+ }
469
+ };
470
+
471
+ /* Trigger update button click */
472
+ wcf_trigger_update_button_click();
473
+
474
+ setTimeout(function () {
475
+ wcf_back_flow_button();
476
+ }, 300);
477
+ };
478
+
479
+ $( document ).ready(function() {
480
+
481
  /* Checkout */
482
  wcf_checkout_show_field_custom_options();
483
 
500
 
501
  /* Create woo product from iframe */
502
  wcf_create_woo_product_from_iframe();
 
 
503
 
504
+ /* Gutenberg compatibility and events */
505
+ wcf_gutenberg_compatibility_and_events();
506
+ });
507
+ })( jQuery );
admin/meta-assets/css/admin-edit-rtl.css CHANGED
@@ -52,10 +52,6 @@ td.wcf-field-section-heading {
52
  font-weight: 700;
53
  text-decoration: underline;
54
  }
55
- .field-wcf-shortcode input {
56
- width: 50%;
57
- display: inline-block;
58
- }
59
 
60
  .wcf-field-row-heading {
61
  width: 30%;
52
  font-weight: 700;
53
  text-decoration: underline;
54
  }
 
 
 
 
55
 
56
  .wcf-field-row-heading {
57
  width: 30%;
admin/meta-assets/css/admin-edit.css CHANGED
@@ -52,10 +52,6 @@ td.wcf-field-section-heading {
52
  font-weight: 700;
53
  text-decoration: underline;
54
  }
55
- .field-wcf-shortcode input {
56
- width: 50%;
57
- display: inline-block;
58
- }
59
 
60
  .wcf-field-row-heading {
61
  width: 30%;
52
  font-weight: 700;
53
  text-decoration: underline;
54
  }
 
 
 
 
55
 
56
  .wcf-field-row-heading {
57
  width: 30%;
cartflows.php CHANGED
@@ -1,24 +1,24 @@
1
- <?php
2
- /**
3
- * Plugin Name: CartFlows
4
- * Plugin URI: https://cartflows.com/
5
- * Description: Create beautiful checkout pages & sales flows for WooCommerce.
6
- * Version: 1.5.6
7
- * Author: CartFlows Inc
8
- * Author URI: https://cartflows.com/
9
- * Text Domain: cartflows
10
- * WC requires at least: 3.0
11
- * WC tested up to: 4.0.1
12
- *
13
- * @package CartFlows
14
- */
15
-
16
- /**
17
- * Set constants.
18
- */
19
- define( 'CARTFLOWS_FILE', __FILE__ );
20
-
21
- /**
22
- * Loader
23
- */
24
- require_once 'classes/class-cartflows-loader.php';
1
+ <?php
2
+ /**
3
+ * Plugin Name: CartFlows
4
+ * Plugin URI: https://cartflows.com/
5
+ * Description: Create beautiful checkout pages & sales flows for WooCommerce.
6
+ * Version: 1.5.7
7
+ * Author: CartFlows Inc
8
+ * Author URI: https://cartflows.com/
9
+ * Text Domain: cartflows
10
+ * WC requires at least: 3.0
11
+ * WC tested up to: 4.0.1
12
+ *
13
+ * @package CartFlows
14
+ */
15
+
16
+ /**
17
+ * Set constants.
18
+ */
19
+ define( 'CARTFLOWS_FILE', __FILE__ );
20
+
21
+ /**
22
+ * Loader
23
+ */
24
+ require_once 'classes/class-cartflows-loader.php';
changelog.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  Version 1.5.6 - Thursday, 23rd April 2020
2
  - Fix: Checkout two-step type CSS conflict with the latest version of The-7 theme.
3
  - Fix: Optin step CSS conflict with the Astra theme.
1
+ Version 1.5.7 - Monday, 4th May 2020
2
+ - New: Gutenberg support added for steps.
3
+ - Fix: Astra's mini cart icon display issue on the CartFlows steps.
4
+
5
  Version 1.5.6 - Thursday, 23rd April 2020
6
  - Fix: Checkout two-step type CSS conflict with the latest version of The-7 theme.
7
  - Fix: Optin step CSS conflict with the Astra theme.
classes/class-cartflows-frontend.php CHANGED
@@ -152,7 +152,7 @@ class Cartflows_Frontend {
152
 
153
  $page_template = apply_filters( 'cartflows_page_template', $page_template );
154
 
155
- if ( 'default' === $page_template ) {
156
  return;
157
  }
158
 
@@ -448,7 +448,7 @@ class Cartflows_Frontend {
448
 
449
  wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
450
 
451
- if ( 'default' !== $page_template ) {
452
 
453
  wp_enqueue_style( 'wcf-normalize-frontend-global', wcf()->utils->get_css_url( 'cartflows-normalize' ), array(), CARTFLOWS_VER );
454
  }
152
 
153
  $page_template = apply_filters( 'cartflows_page_template', $page_template );
154
 
155
+ if ( ! _wcf_supported_template( $page_template ) ) {
156
  return;
157
  }
158
 
448
 
449
  wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
450
 
451
+ if ( _wcf_supported_template( $page_template ) ) {
452
 
453
  wp_enqueue_style( 'wcf-normalize-frontend-global', wcf()->utils->get_css_url( 'cartflows-normalize' ), array(), CARTFLOWS_VER );
454
  }
classes/class-cartflows-functions.php CHANGED
@@ -521,3 +521,21 @@ function _wcf_check_is_optin_by_id( $post_id ) {
521
 
522
  return false;
523
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
 
522
  return false;
523
  }
524
+
525
+ /**
526
+ * Supported Page Template
527
+ *
528
+ * @param string $page_template current page template.
529
+ *
530
+ * @return int/bool
531
+ * @since 1.5.7
532
+ */
533
+ function _wcf_supported_template( $page_template ) {
534
+
535
+ if ( in_array( $page_template, array( 'cartflows-default', 'cartflows-canvas' ), true ) ) {
536
+
537
+ return true;
538
+ }
539
+
540
+ return false;
541
+ }
classes/class-cartflows-loader.php CHANGED
@@ -1,560 +1,560 @@
1
- <?php
2
- /**
3
- * CartFlows Loader.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- if ( ! class_exists( 'Cartflows_Loader' ) ) {
9
-
10
- /**
11
- * Class Cartflows_Loader.
12
- */
13
- final class Cartflows_Loader {
14
-
15
- /**
16
- * Member Variable
17
- *
18
- * @var instance
19
- */
20
- private static $instance = null;
21
-
22
- /**
23
- * Member Variable
24
- *
25
- * @var utils
26
- */
27
- public $utils = null;
28
-
29
- /**
30
- * Member Variable
31
- *
32
- * @var logger
33
- */
34
- public $logger = null;
35
-
36
- /**
37
- * Member Variable
38
- *
39
- * @var options
40
- */
41
- public $options = null;
42
-
43
- /**
44
- * Member Variable
45
- *
46
- * @var meta
47
- */
48
- public $meta = null;
49
-
50
- /**
51
- * Member Variable
52
- *
53
- * @var Tracking_Data
54
- */
55
- public $alldata;
56
-
57
- /**
58
- * Member Variable
59
- *
60
- * @var flow
61
- */
62
- public $flow = null;
63
-
64
- /**
65
- * Member Variable
66
- *
67
- * @var assets_vars
68
- */
69
- public $assets_vars = null;
70
-
71
- /**
72
- * Member Variable
73
- *
74
- * @var assets_vars
75
- */
76
-
77
- public $is_woo_active = true;
78
-
79
- /**
80
- * Initiator
81
- */
82
- public static function get_instance() {
83
-
84
- if ( is_null( self::$instance ) ) {
85
-
86
- self::$instance = new self();
87
-
88
- /**
89
- * CartFlows loaded.
90
- *
91
- * Fires when Cartflows was fully loaded and instantiated.
92
- *
93
- * @since 1.0.0
94
- */
95
- do_action( 'cartflows_loaded' );
96
- }
97
-
98
- return self::$instance;
99
- }
100
-
101
- /**
102
- * Constructor
103
- */
104
- public function __construct() {
105
-
106
- $this->define_constants();
107
-
108
- // Activation hook.
109
- register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) );
110
-
111
- // deActivation hook.
112
- register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) );
113
-
114
- add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 );
115
- add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) );
116
- }
117
-
118
- /**
119
- * Defines all constants
120
- *
121
- * @since 1.0.0
122
- */
123
- public function define_constants() {
124
-
125
- define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
126
- define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
127
- define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
128
- define( 'CARTFLOWS_VER', '1.5.6' );
129
- define( 'CARTFLOWS_SLUG', 'cartflows' );
130
- define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
131
-
132
- define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' );
133
- define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' );
134
-
135
- if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) {
136
- define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' );
137
- }
138
- define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' );
139
- define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' );
140
- define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' );
141
- define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' );
142
-
143
- if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) {
144
- define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' );
145
- }
146
- if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER' ) ) {
147
- define( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER', 'cartflows_flow_page_builder' );
148
- }
149
- if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) {
150
- define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' );
151
- }
152
-
153
- if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) {
154
-
155
- $upload_dir = wp_upload_dir( null, false );
156
-
157
- define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' );
158
- }
159
- }
160
-
161
- /**
162
- * Loads plugin files.
163
- *
164
- * @since 1.0.0
165
- *
166
- * @return void
167
- */
168
- public function load_plugin() {
169
-
170
- $this->load_helper_files_components();
171
- $this->load_core_files();
172
- $this->load_core_components();
173
-
174
- add_action( 'wp_loaded', array( $this, 'initialize' ) );
175
- add_action( 'cartflows_pro_init', array( $this, 'after_cartflows_pro_init' ) );
176
-
177
- if ( ! $this->is_woo_active ) {
178
- add_action( 'admin_notices', array( $this, 'fails_to_load' ) );
179
- }
180
-
181
- /**
182
- * CartFlows Init.
183
- *
184
- * Fires when Cartflows is instantiated.
185
- *
186
- * @since 1.0.0
187
- */
188
- do_action( 'cartflows_init' );
189
- }
190
-
191
- /**
192
- * After CartFlows Pro init.
193
- *
194
- * @since 1.1.19
195
- *
196
- * @return void
197
- */
198
- public function after_cartflows_pro_init() {
199
-
200
- if ( ! is_admin() ) {
201
- return;
202
- }
203
-
204
- if ( version_compare( CARTFLOWS_PRO_VER, '1.4.0', '<' ) ) {
205
- add_action( 'admin_notices', array( $this, 'required_cartflows_pro_notice' ) );
206
- }
207
- }
208
-
209
- /**
210
- * Required CartFlows Pro Notice.
211
- *
212
- * @since 1.1.19
213
- *
214
- * @return void
215
- */
216
- public function required_cartflows_pro_notice() {
217
-
218
- $required_pro_version = '1.4.0';
219
-
220
- $class = 'notice notice-warning';
221
- /* translators: %s: html tags */
222
- $message = sprintf( __( 'You are using an older version of %1$sCartFlows Pro%2$s. Please update %1$sCartFlows Pro%2$s plugin to version %1$s%3$s%2$s or higher.', 'cartflows' ), '<strong>', '</strong>', $required_pro_version );
223
-
224
- printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
225
- }
226
-
227
- /**
228
- * Load Helper Files and Components.
229
- *
230
- * @since 1.0.0
231
- *
232
- * @return void
233
- */
234
- public function load_helper_files_components() {
235
-
236
- $this->is_woo_active = function_exists( 'WC' );
237
-
238
- /* Public Utils */
239
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php';
240
-
241
- /* Public Global Namespace Function */
242
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
243
-
244
- /* Admin Helper */
245
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
246
-
247
- /* Meta Default Values */
248
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php';
249
-
250
- require_once CARTFLOWS_DIR . 'classes/class-cartflows-tracking.php';
251
-
252
- $this->utils = Cartflows_Utils::get_instance();
253
- $this->options = Cartflows_Default_Meta::get_instance();
254
- $this->alldata = Cartflows_Tracking::get_instance();
255
- }
256
-
257
- /**
258
- * Init hooked function.
259
- *
260
- * @since 1.0.0
261
- *
262
- * @return void
263
- */
264
- public function initialize() {
265
- $this->assets_vars = $this->utils->get_assets_path();
266
- }
267
-
268
- /**
269
- * Load Core Files.
270
- *
271
- * @since 1.0.0
272
- *
273
- * @return void
274
- */
275
- public function load_core_files() {
276
-
277
- /* Update compatibility. */
278
- require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
279
-
280
- /* Page builder compatibilty class */
281
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php';
282
-
283
- /* Theme support */
284
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-theme-support.php';
285
-
286
- /* Admin Meta Fields*/
287
- include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php';
288
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php';
289
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php';
290
-
291
- /* Cloning */
292
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php';
293
-
294
- /* Admin Settings */
295
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php';
296
-
297
- /* Logger */
298
- include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler-interface.php';
299
- include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler.php';
300
- include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler-file.php';
301
- include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-levels.php';
302
- include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-logger-interface.php';
303
- include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-wc-logger.php';
304
-
305
- /* Core Modules */
306
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php';
307
-
308
- /* Frontend Global */
309
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php';
310
- require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php';
311
-
312
- /* Modules */
313
- include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php';
314
- include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php';
315
-
316
- if ( $this->is_woo_active ) {
317
- include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php';
318
- include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php';
319
- include_once CARTFLOWS_DIR . 'modules/optin/class-cartflows-optin.php';
320
- }
321
-
322
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php';
323
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php';
324
-
325
- include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php';
326
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php';
327
-
328
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-wizard.php';
329
-
330
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-metabox.php';
331
-
332
- include_once CARTFLOWS_DIR . 'classes/deprecated/deprecated-hooks.php';
333
-
334
- }
335
-
336
- /**
337
- * Load Core Components.
338
- *
339
- * @since 1.0.0
340
- *
341
- * @return void
342
- */
343
- public function load_core_components() {
344
-
345
- $this->meta = Cartflows_Meta_Fields::get_instance();
346
- $this->logger = Cartflows_Logger::get_instance();
347
- $this->flow = Cartflows_Flow_Frontend::get_instance();
348
- }
349
-
350
- /**
351
- * Create files/directories.
352
- */
353
- public function create_files() {
354
-
355
- // Install files and folders for uploading files and prevent hotlinking.
356
- $upload_dir = wp_upload_dir();
357
-
358
- $files = array(
359
- array(
360
- 'base' => CARTFLOWS_LOG_DIR,
361
- 'file' => '.htaccess',
362
- 'content' => 'deny from all',
363
- ),
364
- array(
365
- 'base' => CARTFLOWS_LOG_DIR,
366
- 'file' => 'index.html',
367
- 'content' => '',
368
- ),
369
- );
370
-
371
- foreach ( $files as $file ) {
372
- if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
373
- $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore
374
- if ( $file_handle ) {
375
- fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
376
- fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
377
- }
378
- }
379
- }
380
- }
381
- /**
382
- * Load CartFlows Pro Text Domain.
383
- * This will load the translation textdomain depending on the file priorities.
384
- * 1. Global Languages /wp-content/languages/cartflows/ folder
385
- * 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder
386
- *
387
- * @since 1.0.3
388
- * @return void
389
- */
390
- public function load_cf_textdomain() {
391
-
392
- // Default languages directory for CartFlows Pro.
393
- $lang_dir = CARTFLOWS_DIR . 'languages/';
394
-
395
- /**
396
- * Filters the languages directory path to use for CartFlows Pro.
397
- *
398
- * @param string $lang_dir The languages directory path.
399
- */
400
- $lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir );
401
-
402
- // Traditional WordPress plugin locale filter.
403
- global $wp_version;
404
-
405
- $get_locale = get_locale();
406
-
407
- if ( $wp_version >= 4.7 ) {
408
- $get_locale = get_user_locale();
409
- }
410
-
411
- /**
412
- * Language Locale for CartFlows Pro
413
- *
414
- * @var $get_locale The locale to use.
415
- * Uses get_user_locale()` in WordPress 4.7 or greater,
416
- * otherwise uses `get_locale()`.
417
- */
418
- $locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' );
419
- $mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale );
420
-
421
- // Setup paths to current locale file.
422
- $mofile_local = $lang_dir . $mofile;
423
- $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
424
-
425
- if ( file_exists( $mofile_global ) ) {
426
- // Look in global /wp-content/languages/cartflows/ folder.
427
- load_textdomain( 'cartflows', $mofile_global );
428
- } elseif ( file_exists( $mofile_local ) ) {
429
- // Look in local /wp-content/plugins/cartflows/languages/ folder.
430
- load_textdomain( 'cartflows', $mofile_local );
431
- } else {
432
- // Load the default language files.
433
- load_plugin_textdomain( 'cartflows', false, $lang_dir );
434
- }
435
- }
436
-
437
- /**
438
- * Fires admin notice when Elementor is not installed and activated.
439
- *
440
- * @since 1.0.0
441
- *
442
- * @return void
443
- */
444
- public function fails_to_load() {
445
-
446
- $screen = get_current_screen();
447
-
448
- if ( ! wcf()->utils->is_step_post_type() ) {
449
- return;
450
- }
451
-
452
- if ( ! wcf()->utils->check_is_woo_required_page() ) {
453
- return;
454
- }
455
-
456
- $skip_notice = false;
457
-
458
- wp_localize_script( 'wcf-global-admin', 'cartflows_woo', array( 'show_update_post' => $skip_notice ) );
459
-
460
- $class = 'notice notice-warning';
461
- /* translators: %s: html tags */
462
- $message = sprintf( __( 'This %1$sCartFlows%2$s page requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '<strong>', '</strong>' );
463
-
464
- $plugin = 'woocommerce/woocommerce.php';
465
-
466
- if ( _is_woo_installed() ) {
467
- if ( ! current_user_can( 'activate_plugins' ) ) {
468
- return;
469
- }
470
-
471
- $action_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
472
- $button_label = __( 'Activate WooCommerce', 'cartflows' );
473
-
474
- } else {
475
- if ( ! current_user_can( 'install_plugins' ) ) {
476
- return;
477
- }
478
-
479
- $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
480
- $button_label = __( 'Install WooCommerce', 'cartflows' );
481
- }
482
-
483
- $button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
484
-
485
- printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
486
- }
487
-
488
- /**
489
- * Activation Reset
490
- */
491
- public function activation_reset() {
492
-
493
- if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) {
494
-
495
- $upload_dir = wp_upload_dir( null, false );
496
-
497
- define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' );
498
- }
499
-
500
- $this->create_files();
501
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
502
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
503
- include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php';
504
- include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php';
505
-
506
- Cartflows_Flow_Post_Type::get_instance()->flow_post_type();
507
- Cartflows_Step_Post_Type::get_instance()->step_post_type();
508
- flush_rewrite_rules();
509
- }
510
-
511
- /**
512
- * Deactivation Reset
513
- */
514
- public function deactivation_reset() {
515
- }
516
-
517
- /**
518
- * Logger Class Instance
519
- */
520
- public function logger() {
521
- return Cartflows_Logger::get_instance();
522
- }
523
-
524
-
525
- }
526
-
527
- /**
528
- * Prepare if class 'Cartflows_Loader' exist.
529
- * Kicking this off by calling 'get_instance()' method
530
- */
531
- Cartflows_Loader::get_instance();
532
- }
533
-
534
- /**
535
- * Get global class.
536
- *
537
- * @return object
538
- */
539
- function wcf() {
540
- return Cartflows_Loader::get_instance();
541
- }
542
-
543
-
544
- if ( ! function_exists( '_is_woo_installed' ) ) {
545
-
546
- /**
547
- * Is woocommerce plugin installed.
548
- *
549
- * @since 1.0.0
550
- *
551
- * @access public
552
- */
553
- function _is_woo_installed() {
554
-
555
- $path = 'woocommerce/woocommerce.php';
556
- $plugins = get_plugins();
557
-
558
- return isset( $plugins[ $path ] );
559
- }
560
- }
1
+ <?php
2
+ /**
3
+ * CartFlows Loader.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ if ( ! class_exists( 'Cartflows_Loader' ) ) {
9
+
10
+ /**
11
+ * Class Cartflows_Loader.
12
+ */
13
+ final class Cartflows_Loader {
14
+
15
+ /**
16
+ * Member Variable
17
+ *
18
+ * @var instance
19
+ */
20
+ private static $instance = null;
21
+
22
+ /**
23
+ * Member Variable
24
+ *
25
+ * @var utils
26
+ */
27
+ public $utils = null;
28
+
29
+ /**
30
+ * Member Variable
31
+ *
32
+ * @var logger
33
+ */
34
+ public $logger = null;
35
+
36
+ /**
37
+ * Member Variable
38
+ *
39
+ * @var options
40
+ */
41
+ public $options = null;
42
+
43
+ /**
44
+ * Member Variable
45
+ *
46
+ * @var meta
47
+ */
48
+ public $meta = null;
49
+
50
+ /**
51
+ * Member Variable
52
+ *
53
+ * @var Tracking_Data
54
+ */
55
+ public $alldata;
56
+
57
+ /**
58
+ * Member Variable
59
+ *
60
+ * @var flow
61
+ */
62
+ public $flow = null;
63
+
64
+ /**
65
+ * Member Variable
66
+ *
67
+ * @var assets_vars
68
+ */
69
+ public $assets_vars = null;
70
+
71
+ /**
72
+ * Member Variable
73
+ *
74
+ * @var assets_vars
75
+ */
76
+
77
+ public $is_woo_active = true;
78
+
79
+ /**
80
+ * Initiator
81
+ */
82
+ public static function get_instance() {
83
+
84
+ if ( is_null( self::$instance ) ) {
85
+
86
+ self::$instance = new self();
87
+
88
+ /**
89
+ * CartFlows loaded.
90
+ *
91
+ * Fires when Cartflows was fully loaded and instantiated.
92
+ *
93
+ * @since 1.0.0
94
+ */
95
+ do_action( 'cartflows_loaded' );
96
+ }
97
+
98
+ return self::$instance;
99
+ }
100
+
101
+ /**
102
+ * Constructor
103
+ */
104
+ public function __construct() {
105
+
106
+ $this->define_constants();
107
+
108
+ // Activation hook.
109
+ register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) );
110
+
111
+ // deActivation hook.
112
+ register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) );
113
+
114
+ add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 );
115
+ add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) );
116
+ }
117
+
118
+ /**
119
+ * Defines all constants
120
+ *
121
+ * @since 1.0.0
122
+ */
123
+ public function define_constants() {
124
+
125
+ define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
126
+ define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
127
+ define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
128
+ define( 'CARTFLOWS_VER', '1.5.7' );
129
+ define( 'CARTFLOWS_SLUG', 'cartflows' );
130
+ define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
131
+
132
+ define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' );
133
+ define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' );
134
+
135
+ if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) {
136
+ define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' );
137
+ }
138
+ define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' );
139
+ define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' );
140
+ define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' );
141
+ define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' );
142
+
143
+ if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) {
144
+ define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' );
145
+ }
146
+ if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER' ) ) {
147
+ define( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER', 'cartflows_flow_page_builder' );
148
+ }
149
+ if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) {
150
+ define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' );
151
+ }
152
+
153
+ if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) {
154
+
155
+ $upload_dir = wp_upload_dir( null, false );
156
+
157
+ define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' );
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Loads plugin files.
163
+ *
164
+ * @since 1.0.0
165
+ *
166
+ * @return void
167
+ */
168
+ public function load_plugin() {
169
+
170
+ $this->load_helper_files_components();
171
+ $this->load_core_files();
172
+ $this->load_core_components();
173
+
174
+ add_action( 'wp_loaded', array( $this, 'initialize' ) );
175
+ add_action( 'cartflows_pro_init', array( $this, 'after_cartflows_pro_init' ) );
176
+
177
+ if ( ! $this->is_woo_active ) {
178
+ add_action( 'admin_notices', array( $this, 'fails_to_load' ) );
179
+ }
180
+
181
+ /**
182
+ * CartFlows Init.
183
+ *
184
+ * Fires when Cartflows is instantiated.
185
+ *
186
+ * @since 1.0.0
187
+ */
188
+ do_action( 'cartflows_init' );
189
+ }
190
+
191
+ /**
192
+ * After CartFlows Pro init.
193
+ *
194
+ * @since 1.1.19
195
+ *
196
+ * @return void
197
+ */
198
+ public function after_cartflows_pro_init() {
199
+
200
+ if ( ! is_admin() ) {
201
+ return;
202
+ }
203
+
204
+ if ( version_compare( CARTFLOWS_PRO_VER, '1.4.0', '<' ) ) {
205
+ add_action( 'admin_notices', array( $this, 'required_cartflows_pro_notice' ) );
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Required CartFlows Pro Notice.
211
+ *
212
+ * @since 1.1.19
213
+ *
214
+ * @return void
215
+ */
216
+ public function required_cartflows_pro_notice() {
217
+
218
+ $required_pro_version = '1.4.0';
219
+
220
+ $class = 'notice notice-warning';
221
+ /* translators: %s: html tags */
222
+ $message = sprintf( __( 'You are using an older version of %1$sCartFlows Pro%2$s. Please update %1$sCartFlows Pro%2$s plugin to version %1$s%3$s%2$s or higher.', 'cartflows' ), '<strong>', '</strong>', $required_pro_version );
223
+
224
+ printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
225
+ }
226
+
227
+ /**
228
+ * Load Helper Files and Components.
229
+ *
230
+ * @since 1.0.0
231
+ *
232
+ * @return void
233
+ */
234
+ public function load_helper_files_components() {
235
+
236
+ $this->is_woo_active = function_exists( 'WC' );
237
+
238
+ /* Public Utils */
239
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php';
240
+
241
+ /* Public Global Namespace Function */
242
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
243
+
244
+ /* Admin Helper */
245
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
246
+
247
+ /* Meta Default Values */
248
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php';
249
+
250
+ require_once CARTFLOWS_DIR . 'classes/class-cartflows-tracking.php';
251
+
252
+ $this->utils = Cartflows_Utils::get_instance();
253
+ $this->options = Cartflows_Default_Meta::get_instance();
254
+ $this->alldata = Cartflows_Tracking::get_instance();
255
+ }
256
+
257
+ /**
258
+ * Init hooked function.
259
+ *
260
+ * @since 1.0.0
261
+ *
262
+ * @return void
263
+ */
264
+ public function initialize() {
265
+ $this->assets_vars = $this->utils->get_assets_path();
266
+ }
267
+
268
+ /**
269
+ * Load Core Files.
270
+ *
271
+ * @since 1.0.0
272
+ *
273
+ * @return void
274
+ */
275
+ public function load_core_files() {
276
+
277
+ /* Update compatibility. */
278
+ require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
279
+
280
+ /* Page builder compatibilty class */
281
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php';
282
+
283
+ /* Theme support */
284
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-theme-support.php';
285
+
286
+ /* Admin Meta Fields*/
287
+ include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php';
288
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php';
289
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php';
290
+
291
+ /* Cloning */
292
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php';
293
+
294
+ /* Admin Settings */
295
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php';
296
+
297
+ /* Logger */
298
+ include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler-interface.php';
299
+ include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler.php';
300
+ include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler-file.php';
301
+ include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-levels.php';
302
+ include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-logger-interface.php';
303
+ include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-wc-logger.php';
304
+
305
+ /* Core Modules */
306
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php';
307
+
308
+ /* Frontend Global */
309
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php';
310
+ require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php';
311
+
312
+ /* Modules */
313
+ include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php';
314
+ include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php';
315
+
316
+ if ( $this->is_woo_active ) {
317
+ include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php';
318
+ include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php';
319
+ include_once CARTFLOWS_DIR . 'modules/optin/class-cartflows-optin.php';
320
+ }
321
+
322
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php';
323
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php';
324
+
325
+ include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php';
326
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php';
327
+
328
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-wizard.php';
329
+
330
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-metabox.php';
331
+
332
+ include_once CARTFLOWS_DIR . 'classes/deprecated/deprecated-hooks.php';
333
+
334
+ }
335
+
336
+ /**
337
+ * Load Core Components.
338
+ *
339
+ * @since 1.0.0
340
+ *
341
+ * @return void
342
+ */
343
+ public function load_core_components() {
344
+
345
+ $this->meta = Cartflows_Meta_Fields::get_instance();
346
+ $this->logger = Cartflows_Logger::get_instance();
347
+ $this->flow = Cartflows_Flow_Frontend::get_instance();
348
+ }
349
+
350
+ /**
351
+ * Create files/directories.
352
+ */
353
+ public function create_files() {
354
+
355
+ // Install files and folders for uploading files and prevent hotlinking.
356
+ $upload_dir = wp_upload_dir();
357
+
358
+ $files = array(
359
+ array(
360
+ 'base' => CARTFLOWS_LOG_DIR,
361
+ 'file' => '.htaccess',
362
+ 'content' => 'deny from all',
363
+ ),
364
+ array(
365
+ 'base' => CARTFLOWS_LOG_DIR,
366
+ 'file' => 'index.html',
367
+ 'content' => '',
368
+ ),
369
+ );
370
+
371
+ foreach ( $files as $file ) {
372
+ if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) {
373
+ $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore
374
+ if ( $file_handle ) {
375
+ fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite
376
+ fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
377
+ }
378
+ }
379
+ }
380
+ }
381
+ /**
382
+ * Load CartFlows Pro Text Domain.
383
+ * This will load the translation textdomain depending on the file priorities.
384
+ * 1. Global Languages /wp-content/languages/cartflows/ folder
385
+ * 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder
386
+ *
387
+ * @since 1.0.3
388
+ * @return void
389
+ */
390
+ public function load_cf_textdomain() {
391
+
392
+ // Default languages directory for CartFlows Pro.
393
+ $lang_dir = CARTFLOWS_DIR . 'languages/';
394
+
395
+ /**
396
+ * Filters the languages directory path to use for CartFlows Pro.
397
+ *
398
+ * @param string $lang_dir The languages directory path.
399
+ */
400
+ $lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir );
401
+
402
+ // Traditional WordPress plugin locale filter.
403
+ global $wp_version;
404
+
405
+ $get_locale = get_locale();
406
+
407
+ if ( $wp_version >= 4.7 ) {
408
+ $get_locale = get_user_locale();
409
+ }
410
+
411
+ /**
412
+ * Language Locale for CartFlows Pro
413
+ *
414
+ * @var $get_locale The locale to use.
415
+ * Uses get_user_locale()` in WordPress 4.7 or greater,
416
+ * otherwise uses `get_locale()`.
417
+ */
418
+ $locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' );
419
+ $mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale );
420
+
421
+ // Setup paths to current locale file.
422
+ $mofile_local = $lang_dir . $mofile;
423
+ $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
424
+
425
+ if ( file_exists( $mofile_global ) ) {
426
+ // Look in global /wp-content/languages/cartflows/ folder.
427
+ load_textdomain( 'cartflows', $mofile_global );
428
+ } elseif ( file_exists( $mofile_local ) ) {
429
+ // Look in local /wp-content/plugins/cartflows/languages/ folder.
430
+ load_textdomain( 'cartflows', $mofile_local );
431
+ } else {
432
+ // Load the default language files.
433
+ load_plugin_textdomain( 'cartflows', false, $lang_dir );
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Fires admin notice when Elementor is not installed and activated.
439
+ *
440
+ * @since 1.0.0
441
+ *
442
+ * @return void
443
+ */
444
+ public function fails_to_load() {
445
+
446
+ $screen = get_current_screen();
447
+
448
+ if ( ! wcf()->utils->is_step_post_type() ) {
449
+ return;
450
+ }
451
+
452
+ if ( ! wcf()->utils->check_is_woo_required_page() ) {
453
+ return;
454
+ }
455
+
456
+ $skip_notice = false;
457
+
458
+ wp_localize_script( 'wcf-global-admin', 'cartflows_woo', array( 'show_update_post' => $skip_notice ) );
459
+
460
+ $class = 'notice notice-warning';
461
+ /* translators: %s: html tags */
462
+ $message = sprintf( __( 'This %1$sCartFlows%2$s page requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '<strong>', '</strong>' );
463
+
464
+ $plugin = 'woocommerce/woocommerce.php';
465
+
466
+ if ( _is_woo_installed() ) {
467
+ if ( ! current_user_can( 'activate_plugins' ) ) {
468
+ return;
469
+ }
470
+
471
+ $action_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
472
+ $button_label = __( 'Activate WooCommerce', 'cartflows' );
473
+
474
+ } else {
475
+ if ( ! current_user_can( 'install_plugins' ) ) {
476
+ return;
477
+ }
478
+
479
+ $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
480
+ $button_label = __( 'Install WooCommerce', 'cartflows' );
481
+ }
482
+
483
+ $button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
484
+
485
+ printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
486
+ }
487
+
488
+ /**
489
+ * Activation Reset
490
+ */
491
+ public function activation_reset() {
492
+
493
+ if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) {
494
+
495
+ $upload_dir = wp_upload_dir( null, false );
496
+
497
+ define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' );
498
+ }
499
+
500
+ $this->create_files();
501
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
502
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
503
+ include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php';
504
+ include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php';
505
+
506
+ Cartflows_Flow_Post_Type::get_instance()->flow_post_type();
507
+ Cartflows_Step_Post_Type::get_instance()->step_post_type();
508
+ flush_rewrite_rules();
509
+ }
510
+
511
+ /**
512
+ * Deactivation Reset
513
+ */
514
+ public function deactivation_reset() {
515
+ }
516
+
517
+ /**
518
+ * Logger Class Instance
519
+ */
520
+ public function logger() {
521
+ return Cartflows_Logger::get_instance();
522
+ }
523
+
524
+
525
+ }
526
+
527
+ /**
528
+ * Prepare if class 'Cartflows_Loader' exist.
529
+ * Kicking this off by calling 'get_instance()' method
530
+ */
531
+ Cartflows_Loader::get_instance();
532
+ }
533
+
534
+ /**
535
+ * Get global class.
536
+ *
537
+ * @return object
538
+ */
539
+ function wcf() {
540
+ return Cartflows_Loader::get_instance();
541
+ }
542
+
543
+
544
+ if ( ! function_exists( '_is_woo_installed' ) ) {
545
+
546
+ /**
547
+ * Is woocommerce plugin installed.
548
+ *
549
+ * @since 1.0.0
550
+ *
551
+ * @access public
552
+ */
553
+ function _is_woo_installed() {
554
+
555
+ $path = 'woocommerce/woocommerce.php';
556
+ $plugins = get_plugins();
557
+
558
+ return isset( $plugins[ $path ] );
559
+ }
560
+ }
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', '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;
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 components-button is-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-theme-support.php CHANGED
@@ -21,7 +21,7 @@ function load_cartflows_theme_support() {
21
  /**
22
  * Astra
23
  */
24
- include_once CARTFLOWS_DIR . 'theme-support/astra/astra.php';
25
  }
26
 
27
  }
21
  /**
22
  * Astra
23
  */
24
+ include_once CARTFLOWS_DIR . 'theme-support/astra/class-cartflows-astra-compatibility.php';
25
  }
26
 
27
  }
classes/class-cartflows-utils.php CHANGED
@@ -338,6 +338,12 @@ class Cartflows_Utils {
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 );
338
  */
339
  public function do_not_cache() {
340
 
341
+ global $post;
342
+
343
+ if ( ! apply_filters( 'cartflows_do_not_cache_step', true, $post->ID ) ) {
344
+ return;
345
+ }
346
+
347
  wcf_maybe_define_constant( 'DONOTCACHEPAGE', true );
348
  wcf_maybe_define_constant( 'DONOTCACHEOBJECT', true );
349
  wcf_maybe_define_constant( 'DONOTCACHEDB', true );
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.5.6\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
7
- "POT-Creation-Date: 2020-04-23 10:43:59+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -212,7 +212,7 @@ msgstr ""
212
 
213
  #: classes/class-cartflows-importer.php:673
214
  #: classes/class-cartflows-importer.php:780
215
- #: modules/flow/classes/class-cartflows-flow-meta.php:461
216
  msgid "Get Pro"
217
  msgstr ""
218
 
@@ -261,19 +261,19 @@ msgid "Sales Landing"
261
  msgstr ""
262
 
263
  #: classes/class-cartflows-importer.php:1234
264
- #: modules/flow/classes/class-cartflows-step-post-type.php:251
265
  #: modules/flow/view/meta-flow-steps.php:12
266
  msgid "Checkout (Woo)"
267
  msgstr ""
268
 
269
  #: classes/class-cartflows-importer.php:1238
270
- #: modules/flow/classes/class-cartflows-step-post-type.php:258
271
  #: modules/flow/view/meta-flow-steps.php:13
272
  msgid "Thank You (Woo)"
273
  msgstr ""
274
 
275
  #: classes/class-cartflows-importer.php:1246
276
- #: modules/flow/classes/class-cartflows-step-post-type.php:237
277
  #: modules/flow/view/meta-flow-steps.php:11
278
  msgid "Landing"
279
  msgstr ""
@@ -413,7 +413,8 @@ msgid "Update"
413
  msgstr ""
414
 
415
  #: classes/class-cartflows-meta.php:42
416
- #: modules/flow/classes/class-cartflows-flow-meta.php:82
 
417
  msgid "Back to edit Flow"
418
  msgstr ""
419
 
@@ -1298,50 +1299,50 @@ msgstr ""
1298
  msgid "All Rights Reserved"
1299
  msgstr ""
1300
 
1301
- #: modules/flow/classes/class-cartflows-flow-meta.php:250
1302
  #. translators: %s flow id
1303
  msgid "Step not deleted for flow - %s"
1304
  msgstr ""
1305
 
1306
- #: modules/flow/classes/class-cartflows-flow-meta.php:281
1307
  #. translators: %s flow id
1308
  msgid "Step deleted for flow - %s"
1309
  msgstr ""
1310
 
1311
- #: modules/flow/classes/class-cartflows-flow-meta.php:309
1312
  #. translators: %s flow id
1313
  msgid "Steps not sorted for flow - %s"
1314
  msgstr ""
1315
 
1316
- #: modules/flow/classes/class-cartflows-flow-meta.php:332
1317
  #. translators: %s flow id
1318
  msgid "Steps sorted for flow - %s"
1319
  msgstr ""
1320
 
1321
- #: modules/flow/classes/class-cartflows-flow-meta.php:443
1322
  msgid "Analytics"
1323
  msgstr ""
1324
 
1325
- #: modules/flow/classes/class-cartflows-flow-meta.php:460
1326
  #. translators: %s: link
1327
  msgid "Upgrade to %1$sCartFlows Pro%2$s for Analytics feature"
1328
  msgstr ""
1329
 
1330
- #: modules/flow/classes/class-cartflows-flow-meta.php:478
1331
  msgid "Flow Settings"
1332
  msgstr ""
1333
 
1334
- #: modules/flow/classes/class-cartflows-flow-meta.php:563
1335
  msgid "Enable Test Mode"
1336
  msgstr ""
1337
 
1338
- #: modules/flow/classes/class-cartflows-flow-meta.php:570
1339
  msgid ""
1340
  "If you are using WooCommerce plugin then test mode will add random products "
1341
  "in your flow, so you can preview it easily while testing."
1342
  msgstr ""
1343
 
1344
- #: modules/flow/classes/class-cartflows-flow-meta.php:689
1345
  #: modules/flow/view/meta-flow-steps.php:133
1346
  msgid "Add New Step"
1347
  msgstr ""
@@ -1399,57 +1400,57 @@ msgstr ""
1399
 
1400
  #: modules/flow/classes/class-cartflows-flow-post-type.php:354
1401
  #: modules/flow/classes/class-cartflows-flow-post-type.php:360
1402
- #: modules/flow/classes/class-cartflows-step-post-type.php:397
1403
- #: modules/flow/classes/class-cartflows-step-post-type.php:403
1404
  #. translators: %s: singular custom post type name
1405
  msgid "%s updated."
1406
  msgstr ""
1407
 
1408
  #: modules/flow/classes/class-cartflows-flow-post-type.php:356
1409
- #: modules/flow/classes/class-cartflows-step-post-type.php:399
1410
  #. translators: %s: singular custom post type name
1411
  msgid "Custom %s updated."
1412
  msgstr ""
1413
 
1414
  #: modules/flow/classes/class-cartflows-flow-post-type.php:358
1415
- #: modules/flow/classes/class-cartflows-step-post-type.php:401
1416
  #. translators: %s: singular custom post type name
1417
  msgid "Custom %s deleted."
1418
  msgstr ""
1419
 
1420
  #: modules/flow/classes/class-cartflows-flow-post-type.php:362
1421
- #: modules/flow/classes/class-cartflows-step-post-type.php:405
1422
  #. translators: %1$s: singular custom post type name ,%2$s: date and time of
1423
  #. the revision
1424
  msgid "%1$s restored to revision from %2$s"
1425
  msgstr ""
1426
 
1427
  #: modules/flow/classes/class-cartflows-flow-post-type.php:364
1428
- #: modules/flow/classes/class-cartflows-step-post-type.php:407
1429
  #. translators: %s: singular custom post type name
1430
  msgid "%s published."
1431
  msgstr ""
1432
 
1433
  #: modules/flow/classes/class-cartflows-flow-post-type.php:366
1434
- #: modules/flow/classes/class-cartflows-step-post-type.php:409
1435
  #. translators: %s: singular custom post type name
1436
  msgid "%s saved."
1437
  msgstr ""
1438
 
1439
  #: modules/flow/classes/class-cartflows-flow-post-type.php:368
1440
- #: modules/flow/classes/class-cartflows-step-post-type.php:411
1441
  #. translators: %s: singular custom post type name
1442
  msgid "%s submitted."
1443
  msgstr ""
1444
 
1445
  #: modules/flow/classes/class-cartflows-flow-post-type.php:370
1446
- #: modules/flow/classes/class-cartflows-step-post-type.php:413
1447
  #. translators: %s: singular custom post type name
1448
  msgid "%s scheduled for."
1449
  msgstr ""
1450
 
1451
  #: modules/flow/classes/class-cartflows-flow-post-type.php:372
1452
- #: modules/flow/classes/class-cartflows-step-post-type.php:415
1453
  #. translators: %s: singular custom post type name
1454
  msgid "%s draft updated."
1455
  msgstr ""
@@ -1485,25 +1486,25 @@ msgstr ""
1485
  msgid "New Step Name"
1486
  msgstr ""
1487
 
1488
- #: modules/flow/classes/class-cartflows-step-post-type.php:209
1489
  msgid "Step Type"
1490
  msgstr ""
1491
 
1492
- #: modules/flow/classes/class-cartflows-step-post-type.php:219
1493
  msgid "Step Flow"
1494
  msgstr ""
1495
 
1496
- #: modules/flow/classes/class-cartflows-step-post-type.php:244
1497
  #: modules/flow/view/meta-flow-steps.php:16
1498
  msgid "Optin (Woo)"
1499
  msgstr ""
1500
 
1501
- #: modules/flow/classes/class-cartflows-step-post-type.php:265
1502
  #: modules/flow/view/meta-flow-steps.php:14
1503
  msgid "Upsell (Woo)"
1504
  msgstr ""
1505
 
1506
- #: modules/flow/classes/class-cartflows-step-post-type.php:272
1507
  #: modules/flow/view/meta-flow-steps.php:15
1508
  msgid "Downsell (Woo)"
1509
  msgstr ""
@@ -1877,11 +1878,13 @@ msgid "Update totals"
1877
  msgstr ""
1878
 
1879
  #: woocommerce/template/checkout/review-order.php:26
 
1880
  msgid "Product"
1881
  msgstr ""
1882
 
1883
  #: woocommerce/template/checkout/review-order.php:27
1884
  #: woocommerce/template/checkout/review-order.php:107
 
1885
  msgid "Total"
1886
  msgstr ""
1887
 
@@ -1944,6 +1947,14 @@ msgstr ""
1944
  msgid "Lost your password?"
1945
  msgstr ""
1946
 
 
 
 
 
 
 
 
 
1947
  #. Plugin Name of the plugin/theme
1948
  msgid "CartFlows"
1949
  msgstr ""
@@ -1980,12 +1991,12 @@ msgctxt "flow step singular name"
1980
  msgid "Step"
1981
  msgstr ""
1982
 
1983
- #: modules/flow/classes/class-cartflows-step-post-type.php:313
1984
  msgctxt "cartflows"
1985
  msgid "CartFlows — Boxed"
1986
  msgstr ""
1987
 
1988
- #: modules/flow/classes/class-cartflows-step-post-type.php:314
1989
  msgctxt "cartflows"
1990
  msgid "Template for Page Builders"
1991
  msgstr ""
2
  # This file is distributed under the same license as the CartFlows package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: CartFlows 1.5.7\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
7
+ "POT-Creation-Date: 2020-05-04 05:04:33+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
212
 
213
  #: classes/class-cartflows-importer.php:673
214
  #: classes/class-cartflows-importer.php:780
215
+ #: modules/flow/classes/class-cartflows-flow-meta.php:474
216
  msgid "Get Pro"
217
  msgstr ""
218
 
261
  msgstr ""
262
 
263
  #: classes/class-cartflows-importer.php:1234
264
+ #: modules/flow/classes/class-cartflows-step-post-type.php:252
265
  #: modules/flow/view/meta-flow-steps.php:12
266
  msgid "Checkout (Woo)"
267
  msgstr ""
268
 
269
  #: classes/class-cartflows-importer.php:1238
270
+ #: modules/flow/classes/class-cartflows-step-post-type.php:259
271
  #: modules/flow/view/meta-flow-steps.php:13
272
  msgid "Thank You (Woo)"
273
  msgstr ""
274
 
275
  #: classes/class-cartflows-importer.php:1246
276
+ #: modules/flow/classes/class-cartflows-step-post-type.php:238
277
  #: modules/flow/view/meta-flow-steps.php:11
278
  msgid "Landing"
279
  msgstr ""
413
  msgstr ""
414
 
415
  #: classes/class-cartflows-meta.php:42
416
+ #: modules/flow/classes/class-cartflows-flow-meta.php:95
417
+ #: modules/flow/classes/class-cartflows-flow-meta.php:733
418
  msgid "Back to edit Flow"
419
  msgstr ""
420
 
1299
  msgid "All Rights Reserved"
1300
  msgstr ""
1301
 
1302
+ #: modules/flow/classes/class-cartflows-flow-meta.php:263
1303
  #. translators: %s flow id
1304
  msgid "Step not deleted for flow - %s"
1305
  msgstr ""
1306
 
1307
+ #: modules/flow/classes/class-cartflows-flow-meta.php:294
1308
  #. translators: %s flow id
1309
  msgid "Step deleted for flow - %s"
1310
  msgstr ""
1311
 
1312
+ #: modules/flow/classes/class-cartflows-flow-meta.php:322
1313
  #. translators: %s flow id
1314
  msgid "Steps not sorted for flow - %s"
1315
  msgstr ""
1316
 
1317
+ #: modules/flow/classes/class-cartflows-flow-meta.php:345
1318
  #. translators: %s flow id
1319
  msgid "Steps sorted for flow - %s"
1320
  msgstr ""
1321
 
1322
+ #: modules/flow/classes/class-cartflows-flow-meta.php:456
1323
  msgid "Analytics"
1324
  msgstr ""
1325
 
1326
+ #: modules/flow/classes/class-cartflows-flow-meta.php:473
1327
  #. translators: %s: link
1328
  msgid "Upgrade to %1$sCartFlows Pro%2$s for Analytics feature"
1329
  msgstr ""
1330
 
1331
+ #: modules/flow/classes/class-cartflows-flow-meta.php:491
1332
  msgid "Flow Settings"
1333
  msgstr ""
1334
 
1335
+ #: modules/flow/classes/class-cartflows-flow-meta.php:576
1336
  msgid "Enable Test Mode"
1337
  msgstr ""
1338
 
1339
+ #: modules/flow/classes/class-cartflows-flow-meta.php:583
1340
  msgid ""
1341
  "If you are using WooCommerce plugin then test mode will add random products "
1342
  "in your flow, so you can preview it easily while testing."
1343
  msgstr ""
1344
 
1345
+ #: modules/flow/classes/class-cartflows-flow-meta.php:702
1346
  #: modules/flow/view/meta-flow-steps.php:133
1347
  msgid "Add New Step"
1348
  msgstr ""
1400
 
1401
  #: modules/flow/classes/class-cartflows-flow-post-type.php:354
1402
  #: modules/flow/classes/class-cartflows-flow-post-type.php:360
1403
+ #: modules/flow/classes/class-cartflows-step-post-type.php:398
1404
+ #: modules/flow/classes/class-cartflows-step-post-type.php:404
1405
  #. translators: %s: singular custom post type name
1406
  msgid "%s updated."
1407
  msgstr ""
1408
 
1409
  #: modules/flow/classes/class-cartflows-flow-post-type.php:356
1410
+ #: modules/flow/classes/class-cartflows-step-post-type.php:400
1411
  #. translators: %s: singular custom post type name
1412
  msgid "Custom %s updated."
1413
  msgstr ""
1414
 
1415
  #: modules/flow/classes/class-cartflows-flow-post-type.php:358
1416
+ #: modules/flow/classes/class-cartflows-step-post-type.php:402
1417
  #. translators: %s: singular custom post type name
1418
  msgid "Custom %s deleted."
1419
  msgstr ""
1420
 
1421
  #: modules/flow/classes/class-cartflows-flow-post-type.php:362
1422
+ #: modules/flow/classes/class-cartflows-step-post-type.php:406
1423
  #. translators: %1$s: singular custom post type name ,%2$s: date and time of
1424
  #. the revision
1425
  msgid "%1$s restored to revision from %2$s"
1426
  msgstr ""
1427
 
1428
  #: modules/flow/classes/class-cartflows-flow-post-type.php:364
1429
+ #: modules/flow/classes/class-cartflows-step-post-type.php:408
1430
  #. translators: %s: singular custom post type name
1431
  msgid "%s published."
1432
  msgstr ""
1433
 
1434
  #: modules/flow/classes/class-cartflows-flow-post-type.php:366
1435
+ #: modules/flow/classes/class-cartflows-step-post-type.php:410
1436
  #. translators: %s: singular custom post type name
1437
  msgid "%s saved."
1438
  msgstr ""
1439
 
1440
  #: modules/flow/classes/class-cartflows-flow-post-type.php:368
1441
+ #: modules/flow/classes/class-cartflows-step-post-type.php:412
1442
  #. translators: %s: singular custom post type name
1443
  msgid "%s submitted."
1444
  msgstr ""
1445
 
1446
  #: modules/flow/classes/class-cartflows-flow-post-type.php:370
1447
+ #: modules/flow/classes/class-cartflows-step-post-type.php:414
1448
  #. translators: %s: singular custom post type name
1449
  msgid "%s scheduled for."
1450
  msgstr ""
1451
 
1452
  #: modules/flow/classes/class-cartflows-flow-post-type.php:372
1453
+ #: modules/flow/classes/class-cartflows-step-post-type.php:416
1454
  #. translators: %s: singular custom post type name
1455
  msgid "%s draft updated."
1456
  msgstr ""
1486
  msgid "New Step Name"
1487
  msgstr ""
1488
 
1489
+ #: modules/flow/classes/class-cartflows-step-post-type.php:210
1490
  msgid "Step Type"
1491
  msgstr ""
1492
 
1493
+ #: modules/flow/classes/class-cartflows-step-post-type.php:220
1494
  msgid "Step Flow"
1495
  msgstr ""
1496
 
1497
+ #: modules/flow/classes/class-cartflows-step-post-type.php:245
1498
  #: modules/flow/view/meta-flow-steps.php:16
1499
  msgid "Optin (Woo)"
1500
  msgstr ""
1501
 
1502
+ #: modules/flow/classes/class-cartflows-step-post-type.php:266
1503
  #: modules/flow/view/meta-flow-steps.php:14
1504
  msgid "Upsell (Woo)"
1505
  msgstr ""
1506
 
1507
+ #: modules/flow/classes/class-cartflows-step-post-type.php:273
1508
  #: modules/flow/view/meta-flow-steps.php:15
1509
  msgid "Downsell (Woo)"
1510
  msgstr ""
1878
  msgstr ""
1879
 
1880
  #: woocommerce/template/checkout/review-order.php:26
1881
+ #: woocommerce/template/order/order-details.php:51
1882
  msgid "Product"
1883
  msgstr ""
1884
 
1885
  #: woocommerce/template/checkout/review-order.php:27
1886
  #: woocommerce/template/checkout/review-order.php:107
1887
+ #: woocommerce/template/order/order-details.php:52
1888
  msgid "Total"
1889
  msgstr ""
1890
 
1947
  msgid "Lost your password?"
1948
  msgstr ""
1949
 
1950
+ #: woocommerce/template/order/order-details.php:45
1951
+ msgid "Order details"
1952
+ msgstr ""
1953
+
1954
+ #: woocommerce/template/order/order-details.php:93
1955
+ msgid "Note:"
1956
+ msgstr ""
1957
+
1958
  #. Plugin Name of the plugin/theme
1959
  msgid "CartFlows"
1960
  msgstr ""
1991
  msgid "Step"
1992
  msgstr ""
1993
 
1994
+ #: modules/flow/classes/class-cartflows-step-post-type.php:314
1995
  msgctxt "cartflows"
1996
  msgid "CartFlows — Boxed"
1997
  msgstr ""
1998
 
1999
+ #: modules/flow/classes/class-cartflows-step-post-type.php:315
2000
  msgctxt "cartflows"
2001
  msgid "Template for Page Builders"
2002
  msgstr ""
modules/flow/classes/class-cartflows-flow-meta.php CHANGED
@@ -1,700 +1,760 @@
1
- <?php
2
- /**
3
- * Flow meta
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Meta Boxes setup
10
- */
11
- class Cartflows_Flow_Meta {
12
-
13
-
14
- /**
15
- * Instance
16
- *
17
- * @var $instance
18
- */
19
- private static $instance;
20
-
21
- /**
22
- * Meta Option
23
- *
24
- * @var $meta_option
25
- */
26
- private static $meta_option;
27
-
28
- /**
29
- * Initiator
30
- */
31
- public static function get_instance() {
32
- if ( ! isset( self::$instance ) ) {
33
- self::$instance = new self();
34
- }
35
-
36
- return self::$instance;
37
- }
38
-
39
- /**
40
- * Constructor
41
- */
42
- public function __construct() {
43
-
44
- add_action( 'admin_head', array( $this, 'menu_highlight' ) );
45
-
46
- add_action( 'admin_init', array( $this, 'admin_init_actions' ) );
47
-
48
- /* Init Metabox */
49
- add_action( 'load-post.php', array( $this, 'init_metabox' ) );
50
- add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
51
-
52
- /* Add Scripts */
53
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 20 );
54
-
55
- add_action( 'wp_ajax_cartflows_delete_flow_step', array( $this, 'cartflows_delete_flow_step' ) );
56
- add_action( 'wp_ajax_cartflows_reorder_flow_steps', array( $this, 'cartflows_reorder_flow_steps' ) );
57
-
58
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
59
-
60
- add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
61
- }
62
-
63
- /**
64
- * Display admin notices.
65
- *
66
- * @since 1.0.0
67
- *
68
- * @return void
69
- */
70
- public function admin_notices() {
71
-
72
- if ( CARTFLOWS_STEP_POST_TYPE !== get_post_type() ) {
73
- return;
74
- }
75
-
76
- $flow_id = get_post_meta( get_the_id(), 'wcf-flow-id', true );
77
- if ( $flow_id ) { ?>
78
- <div class="wcf-notice-back-edit-flow">
79
- <p>
80
- <a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button button-primary button-hero" style="text-decoration: none;">
81
- <i class="dashicons dashicons-arrow-left-alt"></i>
82
- <?php esc_html_e( 'Back to edit Flow', 'cartflows' ); ?>
83
- </a>
84
- </p>
85
- </div>
86
- <?php
87
- }
88
- }
89
-
90
- /**
91
- * Initialize admin actions.
92
- *
93
- * @since 1.0.0
94
- *
95
- * @return void
96
- */
97
- public function admin_init_actions() {
98
- add_action( 'before_delete_post', array( $this, 'step_post_sync' ) );
99
- add_action( 'wp_trash_post', array( $this, 'step_post_trash_sync' ) );
100
- add_action( 'untrashed_post', array( $this, 'step_post_untrash_sync' ) );
101
- }
102
-
103
- /**
104
- * Delete term data and steps data after deleting flow.
105
- *
106
- * @since 1.0.0
107
- * @param int $pid post id.
108
- *
109
- * @return void
110
- */
111
- public function step_post_sync( $pid ) {
112
-
113
- global $post_type;
114
-
115
- if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
116
-
117
- $steps = get_post_meta( $pid, 'wcf-steps', true );
118
-
119
- if ( $steps && is_array( $steps ) ) {
120
- foreach ( $steps as $i => $step ) {
121
- wp_delete_post( $step['id'], true );
122
- }
123
- }
124
-
125
- $term_data = term_exists( 'flow-' . $pid, CARTFLOWS_TAXONOMY_STEP_FLOW );
126
-
127
- if ( is_array( $term_data ) ) {
128
- wp_delete_term( $term_data['term_id'], CARTFLOWS_TAXONOMY_STEP_FLOW );
129
- }
130
- }
131
- }
132
-
133
- /**
134
- * Trash steps data after trashing flow.
135
- *
136
- * @since 1.0.0
137
- * @param int $pid post id.
138
- *
139
- * @return void
140
- */
141
- public function step_post_trash_sync( $pid ) {
142
-
143
- global $post_type;
144
-
145
- if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
146
-
147
- $steps = get_post_meta( $pid, 'wcf-steps', true );
148
-
149
- if ( $steps && is_array( $steps ) ) {
150
- foreach ( $steps as $i => $step ) {
151
- wp_trash_post( $step['id'] );
152
- }
153
- }
154
- }
155
- }
156
-
157
- /**
158
- * Untrash steps data after restoring flow.
159
- *
160
- * @since 1.0.0
161
- * @param int $pid post id.
162
- *
163
- * @return void
164
- */
165
- public function step_post_untrash_sync( $pid ) {
166
-
167
- global $post_type;
168
-
169
- if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
170
-
171
- $steps = get_post_meta( $pid, 'wcf-steps', true );
172
-
173
- if ( $steps && is_array( $steps ) ) {
174
- foreach ( $steps as $i => $step ) {
175
- wp_untrash_post( $step['id'] );
176
- }
177
- }
178
- }
179
- }
180
-
181
- /**
182
- * Create step for given flow.
183
- *
184
- * @param int $flow_id flow ID.
185
- * @param int $step_type step type.
186
- * @param int $step_title step title.
187
- * @since 1.0.0
188
- *
189
- * @return int
190
- */
191
- public function create_step( $flow_id, $step_type, $step_title ) {
192
-
193
- $new_step_id = wp_insert_post(
194
- array(
195
- 'post_type' => CARTFLOWS_STEP_POST_TYPE,
196
- 'post_title' => $step_title,
197
- 'post_status' => 'publish',
198
- )
199
- );
200
-
201
- if ( $new_step_id ) {
202
-
203
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
204
-
205
- if ( ! is_array( $flow_steps ) ) {
206
- $flow_steps = array();
207
- }
208
-
209
- $flow_steps[] = array(
210
- 'id' => $new_step_id,
211
- 'title' => $step_title,
212
- 'type' => $step_type,
213
- );
214
-
215
- // insert post meta.
216
- update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
217
- update_post_meta( $new_step_id, 'wcf-step-type', $step_type );
218
-
219
- wp_set_object_terms( $new_step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE );
220
- wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
221
- }
222
-
223
- update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
224
-
225
- return $new_step_id;
226
- }
227
-
228
- /**
229
- * Delete step for flow
230
- *
231
- * @since 1.0.0
232
- *
233
- * @return void
234
- */
235
- public function cartflows_delete_flow_step() {
236
-
237
- if ( ! current_user_can( 'manage_options' ) ) {
238
- return;
239
- }
240
-
241
- check_ajax_referer( 'wcf-delete-flow-step', 'security' );
242
-
243
- if ( isset( $_POST['post_id'] ) && isset( $_POST['step_id'] ) ) {
244
- $flow_id = intval( $_POST['post_id'] );
245
- $step_id = intval( $_POST['step_id'] );
246
- }
247
- $result = array(
248
- 'status' => false,
249
- /* translators: %s flow id */
250
- 'text' => sprintf( __( 'Step not deleted for flow - %s', 'cartflows' ), $flow_id ),
251
- );
252
-
253
- if ( ! $flow_id || ! $step_id ) {
254
- wp_send_json( $result );
255
- }
256
-
257
- wp_delete_post( $step_id, true );
258
-
259
- $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
260
-
261
- if ( ! is_array( $flow_steps ) ) {
262
- wp_send_json( $result );
263
- }
264
-
265
- foreach ( $flow_steps as $index => $data ) {
266
-
267
- if ( intval( $data['id'] ) === $step_id ) {
268
- unset( $flow_steps[ $index ] );
269
- break;
270
- }
271
- }
272
-
273
- /* Set index order properly */
274
- $flow_steps = array_merge( $flow_steps );
275
-
276
- update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
277
-
278
- $result = array(
279
- 'status' => true,
280
- /* translators: %s flow id */
281
- 'text' => sprintf( __( 'Step deleted for flow - %s', 'cartflows' ), $flow_id ),
282
- );
283
-
284
- wp_send_json( $result );
285
- }
286
-
287
- /**
288
- * Reorder step flow
289
- *
290
- * @since 1.0.0
291
- *
292
- * @return void
293
- */
294
- public function cartflows_reorder_flow_steps() {
295
-
296
- if ( ! current_user_can( 'manage_options' ) ) {
297
- return;
298
- }
299
-
300
- check_ajax_referer( 'wcf-reorder-flow-steps', 'security' );
301
-
302
- if ( isset( $_POST['post_id'] ) && isset( $_POST['step_ids'] ) ) {
303
- $flow_id = intval( $_POST['post_id'] );
304
- $step_ids = array_map( 'intval', $_POST['step_ids'] );
305
- }
306
- $result = array(
307
- 'status' => false,
308
- /* translators: %s flow id */
309
- 'text' => sprintf( __( 'Steps not sorted for flow - %s', 'cartflows' ), $flow_id ),
310
- );
311
-
312
- if ( ! $flow_id || ! is_array( $step_ids ) ) {
313
- wp_send_json( $result );
314
- }
315
-
316
- $new_flow_steps = array();
317
-
318
- foreach ( $step_ids as $index => $step_id ) {
319
-
320
- $new_flow_steps[] = array(
321
- 'id' => intval( $step_id ),
322
- 'title' => get_the_title( $step_id ),
323
- 'type' => get_post_meta( $step_id, 'wcf-step-type', true ),
324
- );
325
- }
326
-
327
- update_post_meta( $flow_id, 'wcf-steps', $new_flow_steps );
328
-
329
- $result = array(
330
- 'status' => true,
331
- /* translators: %s flow id */
332
- 'text' => sprintf( __( 'Steps sorted for flow - %s', 'cartflows' ), $flow_id ),
333
- );
334
-
335
- wp_send_json( $result );
336
- }
337
-
338
-
339
- /**
340
- * Load admin scripts
341
- *
342
- * @since 1.0.0
343
- *
344
- * @return void
345
- */
346
- public function admin_scripts() {
347
-
348
- global $pagenow;
349
- global $post;
350
-
351
- $screen = get_current_screen();
352
-
353
- if ( ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) && CARTFLOWS_FLOW_POST_TYPE == $screen->post_type ) {
354
-
355
- wp_enqueue_script(
356
- 'wcf-flow-meta',
357
- CARTFLOWS_URL . 'admin/assets/js/flow-admin-edit.js',
358
- array( 'jquery', 'jquery-ui-sortable' ),
359
- CARTFLOWS_VER,
360
- true
361
- );
362
-
363
- wp_enqueue_style( 'wcf-flow-meta', CARTFLOWS_URL . 'admin/assets/css/flow-admin-edit.css', '', CARTFLOWS_VER );
364
- wp_style_add_data( 'wcf-flow-meta', 'rtl', 'replace' );
365
-
366
- $localize = array(
367
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
368
- );
369
-
370
- wp_localize_script( 'jquery', 'cartflows', apply_filters( 'wcf_js_localize', $localize ) );
371
- }
372
- }
373
-
374
- /**
375
- * Initialize meta box
376
- *
377
- * @since 1.0.0
378
- *
379
- * @return void
380
- */
381
- public function init_metabox() {
382
-
383
- /**
384
- * Fires after the title field.
385
- *
386
- * @param WP_Post $post Post object.
387
- */
388
- add_action( 'add_meta_boxes', array( $this, 'settings_meta_box' ) );
389
- add_action( 'edit_form_after_title', array( $this, 'setup_meta_box' ) );
390
- add_action( 'save_post', array( $this, 'save_meta_box' ) );
391
- }
392
-
393
- /**
394
- * Is first time import?
395
- *
396
- * @param integer $post_id post ID.
397
- * @return bool
398
- */
399
- public function is_flow_imported( $post_id = 0 ) {
400
-
401
- if ( 0 === $post_id ) {
402
- $post_id = get_the_ID();
403
- }
404
-
405
- $steps = get_post_meta( $post_id, 'wcf-steps', true );
406
- $choice = get_post_meta( $post_id, 'wcf-flow-choise', true );
407
-
408
- if ( empty( $steps ) && 'import' === $choice ) {
409
- return true;
410
- }
411
-
412
- return false;
413
- }
414
-
415
- /**
416
- * Setup meta box.
417
- *
418
- * @return void
419
- */
420
- public function setup_meta_box() {
421
- if ( ! Cartflows_Admin::is_flow_edit_admin() ) {
422
- return;
423
- }
424
-
425
- /**
426
- * Adding Add new step button to the top*/
427
- echo $this->add_add_new_step_button();
428
-
429
- $this->markup_meta_box();
430
-
431
- $this->add_upgrade_to_pro_metabox();
432
- }
433
-
434
-
435
- /**
436
- * Add metabox when cartflows pro is not enabled.
437
- */
438
- public function add_upgrade_to_pro_metabox() {
439
-
440
- if ( ! _is_cartflows_pro() ) {
441
- add_meta_box(
442
- 'wcf-upgrade-pro',
443
- __( 'Analytics', 'cartflows' ),
444
- array( $this, 'upgrade_to_pro' ),
445
- CARTFLOWS_FLOW_POST_TYPE,
446
- 'side',
447
- 'high'
448
- );
449
- }
450
-
451
- }
452
-
453
- /**
454
- * Show Upgrade To Pro markup.
455
- */
456
- public function upgrade_to_pro() {
457
-
458
- echo '<div>';
459
- /* translators: %s: link */
460
- echo '<p><i>' . sprintf( esc_html__( 'Upgrade to %1$sCartFlows Pro%2$s for Analytics feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i></p>';
461
- echo '<p><a target="_blank" href="https://cartflows.com/" class="button button-primary">' . esc_html__( 'Get Pro', 'cartflows' ) . '</a></p>';
462
- echo '</div>';
463
-
464
- }
465
-
466
- /**
467
- * Settings meta box.
468
- *
469
- * @return void
470
- */
471
- public function settings_meta_box() {
472
-
473
- if ( CARTFLOWS_FLOW_POST_TYPE === get_post_type() ) {
474
-
475
- /* No need of sandbox will delete it later */
476
- add_meta_box(
477
- 'wcf-sandbox-settings', // Id.
478
- __( 'Flow Settings', 'cartflows' ), // Title.
479
- array( $this, 'sandbox_meta_box' ), // Callback.
480
- CARTFLOWS_FLOW_POST_TYPE, // Post_type.
481
- 'side', // Context.
482
- 'high' // Priority.
483
- );
484
-
485
- do_action( 'cartflows_add_flow_metabox' );
486
- }
487
- }
488
-
489
- /**
490
- * Metabox Markup
491
- *
492
- * @return void
493
- */
494
- public function markup_meta_box() {
495
- global $post;
496
-
497
- wp_nonce_field( 'save-nonce-flow-meta', 'nonce-flow-meta' );
498
-
499
- // Get defaults.
500
- $meta = self::get_current_post_meta( $post->ID );
501
-
502
- /**
503
- * Get options
504
- */
505
- $updated_data = array(
506
- 'steps' => $meta['wcf-steps']['default'],
507
- );
508
-
509
- do_action( 'wcf_flow_settings_markup_before', $meta );
510
- $this->page_header_tab( $updated_data );
511
- do_action( 'wcf_flow_settings_markup_after', $meta );
512
- }
513
-
514
- /**
515
- * Metabox Markup
516
- *
517
- * @param object $post Post object.
518
- * @return void
519
- */
520
- public function sandbox_meta_box( $post ) {
521
-
522
- // Get defaults.
523
- $meta = self::get_current_post_meta( $post->ID );
524
-
525
- /**
526
- * Get options
527
- */
528
- foreach ( $meta as $key => $value ) {
529
- $updated_data[ $key ] = $meta[ $key ]['default'];
530
- }
531
-
532
- do_action( 'wcf_flow_sandbox_markup_before', $meta );
533
- $this->sandbox_markup( $updated_data );
534
- do_action( 'wcf_flow_sandbox_markup_after', $meta );
535
- }
536
-
537
- /**
538
- * Page Header Tabs
539
- *
540
- * @param array $options Post meta.
541
- * @return void
542
- */
543
- public function page_header_tab( $options ) {
544
-
545
- include_once CARTFLOWS_FLOW_DIR . 'view/meta-flow-steps.php';
546
- }
547
-
548
- /**
549
- * Sandbox Markup
550
- *
551
- * @param array $options Post meta.
552
- * @return void
553
- */
554
- public function sandbox_markup( $options ) {
555
- ?>
556
- <div class="wcf-flow-sandbox-table wcf-general-metabox-wrap widefat">
557
- <div class="wcf-flow-sandbox-table-container">
558
- <?php
559
- echo wcf()->meta->get_checkbox_field(
560
- array(
561
- 'name' => 'wcf-testing',
562
- 'value' => $options['wcf-testing'],
563
- 'after' => esc_html__( 'Enable Test Mode', 'cartflows' ),
564
- )
565
- );
566
-
567
- echo wcf()->meta->get_description_field(
568
- array(
569
- 'name' => 'wcf-testing-note',
570
- 'content' => esc_html__( 'If you are using WooCommerce plugin then test mode will add random products in your flow, so you can preview it easily while testing.', 'cartflows' ),
571
- )
572
- );
573
-
574
- ?>
575
- </div>
576
- </div>
577
- <?php
578
- }
579
-
580
- /**
581
- * Keep the menu open when editing the flows.
582
- * Highlights the wanted admin (sub-) menu items for the CPT.
583
- *
584
- * @since 1.0.0
585
- */
586
- public function menu_highlight() {
587
- global $parent_file, $submenu_file, $post_type;
588
- if ( CARTFLOWS_FLOW_POST_TYPE == $post_type ) :
589
- $parent_file = CARTFLOWS_SLUG;//phpcs:ignore
590
- $submenu_file = 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE;//phpcs:ignore
591
- endif;
592
- }
593
-
594
- /**
595
- * Get metabox options
596
- *
597
- * @param int $post_id post id.
598
- * @return array
599
- */
600
- public static function get_meta_option( $post_id ) {
601
-
602
- if ( null === self::$meta_option ) {
603
- /**
604
- * Set metabox options
605
- */
606
- self::$meta_option = wcf()->options->get_flow_fields( $post_id );
607
- }
608
-
609
- return self::$meta_option;
610
- }
611
-
612
- /**
613
- * Get metabox options
614
- *
615
- * @param int $post_id post ID.
616
- * @return array
617
- */
618
- public static function get_current_post_meta( $post_id ) {
619
-
620
- $stored = get_post_meta( $post_id );
621
-
622
- $default_meta = self::get_meta_option( $post_id );
623
-
624
- // Set stored and override defaults.
625
- foreach ( $stored as $key => $value ) {
626
- if ( array_key_exists( $key, $default_meta ) ) {
627
- self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
628
- } else {
629
- self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
630
- }
631
- }
632
-
633
- return self::get_meta_option( $post_id );
634
- }
635
-
636
- /**
637
- * Metabox Save
638
- *
639
- * @param number $post_id Post ID.
640
- * @return void
641
- */
642
- public function save_meta_box( $post_id ) {
643
-
644
- // Checks save status.
645
- $is_autosave = wp_is_post_autosave( $post_id );
646
- $is_revision = wp_is_post_revision( $post_id );
647
-
648
- $is_valid_nonce = ( isset( $_POST['nonce-flow-meta'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce-flow-meta'] ) ), 'save-nonce-flow-meta' ) ) ? true : false;
649
-
650
- // Exits script depending on save status.
651
- if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
652
- return;
653
- }
654
-
655
- wcf()->options->save_flow_fields( $post_id );
656
- }
657
-
658
- /**
659
- * Localize variables in admin
660
- *
661
- * @param array $vars variables.
662
- */
663
- public function localize_vars( $vars ) {
664
-
665
- $ajax_actions = array(
666
- 'wcf_setup_default_steps',
667
- 'wcf_add_flow_step',
668
- 'wcf_delete_flow_step',
669
- 'wcf_reorder_flow_steps',
670
- );
671
-
672
- foreach ( $ajax_actions as $action ) {
673
-
674
- $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
675
- }
676
-
677
- return $vars;
678
- }
679
-
680
- /**
681
- * Add New Step Button
682
- *
683
- * @return string
684
- */
685
- public function add_add_new_step_button() {
686
- $add_new_btn_markup = '<style>.wrap{ position:relative;}</style>';
687
- $add_new_btn_markup .= "<div class='wcf-button-wrap'>";
688
- $add_new_btn_markup .= "<button class='wcf-trigger-popup page-title-action'>";
689
- $add_new_btn_markup .= esc_html__( 'Add New Step', 'cartflows' );
690
- $add_new_btn_markup .= '</button>';
691
- $add_new_btn_markup .= '</div>';
692
-
693
- return $add_new_btn_markup;
694
- }
695
- }
696
-
697
- /**
698
- * Kicking this off by calling 'get_instance()' method
699
- */
700
- Cartflows_Flow_Meta::get_instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Flow meta
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Meta Boxes setup
10
+ */
11
+ class Cartflows_Flow_Meta {
12
+
13
+
14
+ /**
15
+ * Instance
16
+ *
17
+ * @var $instance
18
+ */
19
+ private static $instance;
20
+
21
+ /**
22
+ * Meta Option
23
+ *
24
+ * @var $meta_option
25
+ */
26
+ private static $meta_option;
27
+
28
+ /**
29
+ * For Gutenberg
30
+ *
31
+ * @var $is_gutenberg_editor_active
32
+ */
33
+ private $is_gutenberg_editor_active = false;
34
+
35
+ /**
36
+ * Initiator
37
+ */
38
+ public static function get_instance() {
39
+ if ( ! isset( self::$instance ) ) {
40
+ self::$instance = new self();
41
+ }
42
+
43
+ return self::$instance;
44
+ }
45
+
46
+ /**
47
+ * Constructor
48
+ */
49
+ public function __construct() {
50
+
51
+ add_action( 'admin_head', array( $this, 'menu_highlight' ) );
52
+
53
+ add_action( 'admin_init', array( $this, 'admin_init_actions' ) );
54
+
55
+ /* Init Metabox */
56
+ add_action( 'load-post.php', array( $this, 'init_metabox' ) );
57
+ add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
58
+
59
+ /* Add Scripts */
60
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 20 );
61
+
62
+ add_action( 'wp_ajax_cartflows_delete_flow_step', array( $this, 'cartflows_delete_flow_step' ) );
63
+ add_action( 'wp_ajax_cartflows_reorder_flow_steps', array( $this, 'cartflows_reorder_flow_steps' ) );
64
+
65
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
66
+
67
+ add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
68
+
69
+ /* To check the status of gutenberg */
70
+ add_action( 'enqueue_block_editor_assets', array( $this, 'set_block_editor_status' ) );
71
+
72
+ /* Add back to edit flow button for gutenberg */
73
+ add_action( 'admin_footer', array( $this, 'gutenberg_module_templates' ) );
74
+ }
75
+
76
+ /**
77
+ * Display admin notices.
78
+ *
79
+ * @since 1.0.0
80
+ *
81
+ * @return void
82
+ */
83
+ public function admin_notices() {
84
+
85
+ if ( CARTFLOWS_STEP_POST_TYPE !== get_post_type() ) {
86
+ return;
87
+ }
88
+
89
+ $flow_id = get_post_meta( get_the_id(), 'wcf-flow-id', true );
90
+ if ( $flow_id ) { ?>
91
+ <div class="wcf-notice-back-edit-flow">
92
+ <p>
93
+ <a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button button-primary button-hero wcf-header-back-button" style="text-decoration: none;">
94
+ <i class="dashicons dashicons-arrow-left-alt"></i>
95
+ <?php esc_html_e( 'Back to edit Flow', 'cartflows' ); ?>
96
+ </a>
97
+ </p>
98
+ </div>
99
+ <?php
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Initialize admin actions.
105
+ *
106
+ * @since 1.0.0
107
+ *
108
+ * @return void
109
+ */
110
+ public function admin_init_actions() {
111
+ add_action( 'before_delete_post', array( $this, 'step_post_sync' ) );
112
+ add_action( 'wp_trash_post', array( $this, 'step_post_trash_sync' ) );
113
+ add_action( 'untrashed_post', array( $this, 'step_post_untrash_sync' ) );
114
+ }
115
+
116
+ /**
117
+ * Delete term data and steps data after deleting flow.
118
+ *
119
+ * @since 1.0.0
120
+ * @param int $pid post id.
121
+ *
122
+ * @return void
123
+ */
124
+ public function step_post_sync( $pid ) {
125
+
126
+ global $post_type;
127
+
128
+ if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
129
+
130
+ $steps = get_post_meta( $pid, 'wcf-steps', true );
131
+
132
+ if ( $steps && is_array( $steps ) ) {
133
+ foreach ( $steps as $i => $step ) {
134
+ wp_delete_post( $step['id'], true );
135
+ }
136
+ }
137
+
138
+ $term_data = term_exists( 'flow-' . $pid, CARTFLOWS_TAXONOMY_STEP_FLOW );
139
+
140
+ if ( is_array( $term_data ) ) {
141
+ wp_delete_term( $term_data['term_id'], CARTFLOWS_TAXONOMY_STEP_FLOW );
142
+ }
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Trash steps data after trashing flow.
148
+ *
149
+ * @since 1.0.0
150
+ * @param int $pid post id.
151
+ *
152
+ * @return void
153
+ */
154
+ public function step_post_trash_sync( $pid ) {
155
+
156
+ global $post_type;
157
+
158
+ if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
159
+
160
+ $steps = get_post_meta( $pid, 'wcf-steps', true );
161
+
162
+ if ( $steps && is_array( $steps ) ) {
163
+ foreach ( $steps as $i => $step ) {
164
+ wp_trash_post( $step['id'] );
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Untrash steps data after restoring flow.
172
+ *
173
+ * @since 1.0.0
174
+ * @param int $pid post id.
175
+ *
176
+ * @return void
177
+ */
178
+ public function step_post_untrash_sync( $pid ) {
179
+
180
+ global $post_type;
181
+
182
+ if ( CARTFLOWS_FLOW_POST_TYPE === $post_type ) {
183
+
184
+ $steps = get_post_meta( $pid, 'wcf-steps', true );
185
+
186
+ if ( $steps && is_array( $steps ) ) {
187
+ foreach ( $steps as $i => $step ) {
188
+ wp_untrash_post( $step['id'] );
189
+ }
190
+ }
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Create step for given flow.
196
+ *
197
+ * @param int $flow_id flow ID.
198
+ * @param int $step_type step type.
199
+ * @param int $step_title step title.
200
+ * @since 1.0.0
201
+ *
202
+ * @return int
203
+ */
204
+ public function create_step( $flow_id, $step_type, $step_title ) {
205
+
206
+ $new_step_id = wp_insert_post(
207
+ array(
208
+ 'post_type' => CARTFLOWS_STEP_POST_TYPE,
209
+ 'post_title' => $step_title,
210
+ 'post_status' => 'publish',
211
+ )
212
+ );
213
+
214
+ if ( $new_step_id ) {
215
+
216
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
217
+
218
+ if ( ! is_array( $flow_steps ) ) {
219
+ $flow_steps = array();
220
+ }
221
+
222
+ $flow_steps[] = array(
223
+ 'id' => $new_step_id,
224
+ 'title' => $step_title,
225
+ 'type' => $step_type,
226
+ );
227
+
228
+ // insert post meta.
229
+ update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
230
+ update_post_meta( $new_step_id, 'wcf-step-type', $step_type );
231
+
232
+ wp_set_object_terms( $new_step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE );
233
+ wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
234
+ }
235
+
236
+ update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
237
+
238
+ return $new_step_id;
239
+ }
240
+
241
+ /**
242
+ * Delete step for flow
243
+ *
244
+ * @since 1.0.0
245
+ *
246
+ * @return void
247
+ */
248
+ public function cartflows_delete_flow_step() {
249
+
250
+ if ( ! current_user_can( 'manage_options' ) ) {
251
+ return;
252
+ }
253
+
254
+ check_ajax_referer( 'wcf-delete-flow-step', 'security' );
255
+
256
+ if ( isset( $_POST['post_id'] ) && isset( $_POST['step_id'] ) ) {
257
+ $flow_id = intval( $_POST['post_id'] );
258
+ $step_id = intval( $_POST['step_id'] );
259
+ }
260
+ $result = array(
261
+ 'status' => false,
262
+ /* translators: %s flow id */
263
+ 'text' => sprintf( __( 'Step not deleted for flow - %s', 'cartflows' ), $flow_id ),
264
+ );
265
+
266
+ if ( ! $flow_id || ! $step_id ) {
267
+ wp_send_json( $result );
268
+ }
269
+
270
+ wp_delete_post( $step_id, true );
271
+
272
+ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
273
+
274
+ if ( ! is_array( $flow_steps ) ) {
275
+ wp_send_json( $result );
276
+ }
277
+
278
+ foreach ( $flow_steps as $index => $data ) {
279
+
280
+ if ( intval( $data['id'] ) === $step_id ) {
281
+ unset( $flow_steps[ $index ] );
282
+ break;
283
+ }
284
+ }
285
+
286
+ /* Set index order properly */
287
+ $flow_steps = array_merge( $flow_steps );
288
+
289
+ update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
290
+
291
+ $result = array(
292
+ 'status' => true,
293
+ /* translators: %s flow id */
294
+ 'text' => sprintf( __( 'Step deleted for flow - %s', 'cartflows' ), $flow_id ),
295
+ );
296
+
297
+ wp_send_json( $result );
298
+ }
299
+
300
+ /**
301
+ * Reorder step flow
302
+ *
303
+ * @since 1.0.0
304
+ *
305
+ * @return void
306
+ */
307
+ public function cartflows_reorder_flow_steps() {
308
+
309
+ if ( ! current_user_can( 'manage_options' ) ) {
310
+ return;
311
+ }
312
+
313
+ check_ajax_referer( 'wcf-reorder-flow-steps', 'security' );
314
+
315
+ if ( isset( $_POST['post_id'] ) && isset( $_POST['step_ids'] ) ) {
316
+ $flow_id = intval( $_POST['post_id'] );
317
+ $step_ids = array_map( 'intval', $_POST['step_ids'] );
318
+ }
319
+ $result = array(
320
+ 'status' => false,
321
+ /* translators: %s flow id */
322
+ 'text' => sprintf( __( 'Steps not sorted for flow - %s', 'cartflows' ), $flow_id ),
323
+ );
324
+
325
+ if ( ! $flow_id || ! is_array( $step_ids ) ) {
326
+ wp_send_json( $result );
327
+ }
328
+
329
+ $new_flow_steps = array();
330
+
331
+ foreach ( $step_ids as $index => $step_id ) {
332
+
333
+ $new_flow_steps[] = array(
334
+ 'id' => intval( $step_id ),
335
+ 'title' => get_the_title( $step_id ),
336
+ 'type' => get_post_meta( $step_id, 'wcf-step-type', true ),
337
+ );
338
+ }
339
+
340
+ update_post_meta( $flow_id, 'wcf-steps', $new_flow_steps );
341
+
342
+ $result = array(
343
+ 'status' => true,
344
+ /* translators: %s flow id */
345
+ 'text' => sprintf( __( 'Steps sorted for flow - %s', 'cartflows' ), $flow_id ),
346
+ );
347
+
348
+ wp_send_json( $result );
349
+ }
350
+
351
+
352
+ /**
353
+ * Load admin scripts
354
+ *
355
+ * @since 1.0.0
356
+ *
357
+ * @return void
358
+ */
359
+ public function admin_scripts() {
360
+
361
+ global $pagenow;
362
+ global $post;
363
+
364
+ $screen = get_current_screen();
365
+
366
+ if ( ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) && CARTFLOWS_FLOW_POST_TYPE == $screen->post_type ) {
367
+
368
+ wp_enqueue_script(
369
+ 'wcf-flow-meta',
370
+ CARTFLOWS_URL . 'admin/assets/js/flow-admin-edit.js',
371
+ array( 'jquery', 'jquery-ui-sortable' ),
372
+ CARTFLOWS_VER,
373
+ true
374
+ );
375
+
376
+ wp_enqueue_style( 'wcf-flow-meta', CARTFLOWS_URL . 'admin/assets/css/flow-admin-edit.css', '', CARTFLOWS_VER );
377
+ wp_style_add_data( 'wcf-flow-meta', 'rtl', 'replace' );
378
+
379
+ $localize = array(
380
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
381
+ );
382
+
383
+ wp_localize_script( 'jquery', 'cartflows', apply_filters( 'wcf_js_localize', $localize ) );
384
+ }
385
+ }
386
+
387
+ /**
388
+ * Initialize meta box
389
+ *
390
+ * @since 1.0.0
391
+ *
392
+ * @return void
393
+ */
394
+ public function init_metabox() {
395
+
396
+ /**
397
+ * Fires after the title field.
398
+ *
399
+ * @param WP_Post $post Post object.
400
+ */
401
+ add_action( 'add_meta_boxes', array( $this, 'settings_meta_box' ) );
402
+ add_action( 'edit_form_after_title', array( $this, 'setup_meta_box' ) );
403
+ add_action( 'save_post', array( $this, 'save_meta_box' ) );
404
+ }
405
+
406
+ /**
407
+ * Is first time import?
408
+ *
409
+ * @param integer $post_id post ID.
410
+ * @return bool
411
+ */
412
+ public function is_flow_imported( $post_id = 0 ) {
413
+
414
+ if ( 0 === $post_id ) {
415
+ $post_id = get_the_ID();
416
+ }
417
+
418
+ $steps = get_post_meta( $post_id, 'wcf-steps', true );
419
+ $choice = get_post_meta( $post_id, 'wcf-flow-choise', true );
420
+
421
+ if ( empty( $steps ) && 'import' === $choice ) {
422
+ return true;
423
+ }
424
+
425
+ return false;
426
+ }
427
+
428
+ /**
429
+ * Setup meta box.
430
+ *
431
+ * @return void
432
+ */
433
+ public function setup_meta_box() {
434
+ if ( ! Cartflows_Admin::is_flow_edit_admin() ) {
435
+ return;
436
+ }
437
+
438
+ /**
439
+ * Adding Add new step button to the top*/
440
+ echo $this->add_add_new_step_button();
441
+
442
+ $this->markup_meta_box();
443
+
444
+ $this->add_upgrade_to_pro_metabox();
445
+ }
446
+
447
+
448
+ /**
449
+ * Add metabox when cartflows pro is not enabled.
450
+ */
451
+ public function add_upgrade_to_pro_metabox() {
452
+
453
+ if ( ! _is_cartflows_pro() ) {
454
+ add_meta_box(
455
+ 'wcf-upgrade-pro',
456
+ __( 'Analytics', 'cartflows' ),
457
+ array( $this, 'upgrade_to_pro' ),
458
+ CARTFLOWS_FLOW_POST_TYPE,
459
+ 'side',
460
+ 'high'
461
+ );
462
+ }
463
+
464
+ }
465
+
466
+ /**
467
+ * Show Upgrade To Pro markup.
468
+ */
469
+ public function upgrade_to_pro() {
470
+
471
+ echo '<div>';
472
+ /* translators: %s: link */
473
+ echo '<p><i>' . sprintf( esc_html__( 'Upgrade to %1$sCartFlows Pro%2$s for Analytics feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i></p>';
474
+ echo '<p><a target="_blank" href="https://cartflows.com/" class="button button-primary">' . esc_html__( 'Get Pro', 'cartflows' ) . '</a></p>';
475
+ echo '</div>';
476
+
477
+ }
478
+
479
+ /**
480
+ * Settings meta box.
481
+ *
482
+ * @return void
483
+ */
484
+ public function settings_meta_box() {
485
+
486
+ if ( CARTFLOWS_FLOW_POST_TYPE === get_post_type() ) {
487
+
488
+ /* No need of sandbox will delete it later */
489
+ add_meta_box(
490
+ 'wcf-sandbox-settings', // Id.
491
+ __( 'Flow Settings', 'cartflows' ), // Title.
492
+ array( $this, 'sandbox_meta_box' ), // Callback.
493
+ CARTFLOWS_FLOW_POST_TYPE, // Post_type.
494
+ 'side', // Context.
495
+ 'high' // Priority.
496
+ );
497
+
498
+ do_action( 'cartflows_add_flow_metabox' );
499
+ }
500
+ }
501
+
502
+ /**
503
+ * Metabox Markup
504
+ *
505
+ * @return void
506
+ */
507
+ public function markup_meta_box() {
508
+ global $post;
509
+
510
+ wp_nonce_field( 'save-nonce-flow-meta', 'nonce-flow-meta' );
511
+
512
+ // Get defaults.
513
+ $meta = self::get_current_post_meta( $post->ID );
514
+
515
+ /**
516
+ * Get options
517
+ */
518
+ $updated_data = array(
519
+ 'steps' => $meta['wcf-steps']['default'],
520
+ );
521
+
522
+ do_action( 'wcf_flow_settings_markup_before', $meta );
523
+ $this->page_header_tab( $updated_data );
524
+ do_action( 'wcf_flow_settings_markup_after', $meta );
525
+ }
526
+
527
+ /**
528
+ * Metabox Markup
529
+ *
530
+ * @param object $post Post object.
531
+ * @return void
532
+ */
533
+ public function sandbox_meta_box( $post ) {
534
+
535
+ // Get defaults.
536
+ $meta = self::get_current_post_meta( $post->ID );
537
+
538
+ /**
539
+ * Get options
540
+ */
541
+ foreach ( $meta as $key => $value ) {
542
+ $updated_data[ $key ] = $meta[ $key ]['default'];
543
+ }
544
+
545
+ do_action( 'wcf_flow_sandbox_markup_before', $meta );
546
+ $this->sandbox_markup( $updated_data );
547
+ do_action( 'wcf_flow_sandbox_markup_after', $meta );
548
+ }
549
+
550
+ /**
551
+ * Page Header Tabs
552
+ *
553
+ * @param array $options Post meta.
554
+ * @return void
555
+ */
556
+ public function page_header_tab( $options ) {
557
+
558
+ include_once CARTFLOWS_FLOW_DIR . 'view/meta-flow-steps.php';
559
+ }
560
+
561
+ /**
562
+ * Sandbox Markup
563
+ *
564
+ * @param array $options Post meta.
565
+ * @return void
566
+ */
567
+ public function sandbox_markup( $options ) {
568
+ ?>
569
+ <div class="wcf-flow-sandbox-table wcf-general-metabox-wrap widefat">
570
+ <div class="wcf-flow-sandbox-table-container">
571
+ <?php
572
+ echo wcf()->meta->get_checkbox_field(
573
+ array(
574
+ 'name' => 'wcf-testing',
575
+ 'value' => $options['wcf-testing'],
576
+ 'after' => esc_html__( 'Enable Test Mode', 'cartflows' ),
577
+ )
578
+ );
579
+
580
+ echo wcf()->meta->get_description_field(
581
+ array(
582
+ 'name' => 'wcf-testing-note',
583
+ 'content' => esc_html__( 'If you are using WooCommerce plugin then test mode will add random products in your flow, so you can preview it easily while testing.', 'cartflows' ),
584
+ )
585
+ );
586
+
587
+ ?>
588
+ </div>
589
+ </div>
590
+ <?php
591
+ }
592
+
593
+ /**
594
+ * Keep the menu open when editing the flows.
595
+ * Highlights the wanted admin (sub-) menu items for the CPT.
596
+ *
597
+ * @since 1.0.0
598
+ */
599
+ public function menu_highlight() {
600
+ global $parent_file, $submenu_file, $post_type;
601
+ if ( CARTFLOWS_FLOW_POST_TYPE == $post_type ) :
602
+ $parent_file = CARTFLOWS_SLUG;//phpcs:ignore
603
+ $submenu_file = 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE;//phpcs:ignore
604
+ endif;
605
+ }
606
+
607
+ /**
608
+ * Get metabox options
609
+ *
610
+ * @param int $post_id post id.
611
+ * @return array
612
+ */
613
+ public static function get_meta_option( $post_id ) {
614
+
615
+ if ( null === self::$meta_option ) {
616
+ /**
617
+ * Set metabox options
618
+ */
619
+ self::$meta_option = wcf()->options->get_flow_fields( $post_id );
620
+ }
621
+
622
+ return self::$meta_option;
623
+ }
624
+
625
+ /**
626
+ * Get metabox options
627
+ *
628
+ * @param int $post_id post ID.
629
+ * @return array
630
+ */
631
+ public static function get_current_post_meta( $post_id ) {
632
+
633
+ $stored = get_post_meta( $post_id );
634
+
635
+ $default_meta = self::get_meta_option( $post_id );
636
+
637
+ // Set stored and override defaults.
638
+ foreach ( $stored as $key => $value ) {
639
+ if ( array_key_exists( $key, $default_meta ) ) {
640
+ self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
641
+ } else {
642
+ self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
643
+ }
644
+ }
645
+
646
+ return self::get_meta_option( $post_id );
647
+ }
648
+
649
+ /**
650
+ * Metabox Save
651
+ *
652
+ * @param number $post_id Post ID.
653
+ * @return void
654
+ */
655
+ public function save_meta_box( $post_id ) {
656
+
657
+ // Checks save status.
658
+ $is_autosave = wp_is_post_autosave( $post_id );
659
+ $is_revision = wp_is_post_revision( $post_id );
660
+
661
+ $is_valid_nonce = ( isset( $_POST['nonce-flow-meta'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce-flow-meta'] ) ), 'save-nonce-flow-meta' ) ) ? true : false;
662
+
663
+ // Exits script depending on save status.
664
+ if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
665
+ return;
666
+ }
667
+
668
+ wcf()->options->save_flow_fields( $post_id );
669
+ }
670
+
671
+ /**
672
+ * Localize variables in admin
673
+ *
674
+ * @param array $vars variables.
675
+ */
676
+ public function localize_vars( $vars ) {
677
+
678
+ $ajax_actions = array(
679
+ 'wcf_setup_default_steps',
680
+ 'wcf_add_flow_step',
681
+ 'wcf_delete_flow_step',
682
+ 'wcf_reorder_flow_steps',
683
+ );
684
+
685
+ foreach ( $ajax_actions as $action ) {
686
+
687
+ $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
688
+ }
689
+
690
+ return $vars;
691
+ }
692
+
693
+ /**
694
+ * Add New Step Button
695
+ *
696
+ * @return string
697
+ */
698
+ public function add_add_new_step_button() {
699
+ $add_new_btn_markup = '<style>.wrap{ position:relative;}</style>';
700
+ $add_new_btn_markup .= "<div class='wcf-button-wrap'>";
701
+ $add_new_btn_markup .= "<button class='wcf-trigger-popup page-title-action'>";
702
+ $add_new_btn_markup .= esc_html__( 'Add New Step', 'cartflows' );
703
+ $add_new_btn_markup .= '</button>';
704
+ $add_new_btn_markup .= '</div>';
705
+
706
+ return $add_new_btn_markup;
707
+ }
708
+
709
+ /**
710
+ * Back to flow button gutenberg template
711
+ *
712
+ * @return void
713
+ */
714
+ public function gutenberg_module_templates() {
715
+
716
+ // Exit if block editor is not enabled.
717
+ if ( ! $this->is_gutenberg_editor_active ) {
718
+ return;
719
+ }
720
+
721
+ if ( CARTFLOWS_STEP_POST_TYPE !== get_post_type() ) {
722
+ return;
723
+ }
724
+
725
+ $flow_id = get_post_meta( get_the_id(), 'wcf-flow-id', true );
726
+
727
+ if ( $flow_id ) {
728
+ ?>
729
+ <script id="wcf-gutenberg-back-flow-button" type="text/html">
730
+ <div class="wcf-notice-back-edit-flow gutenberg-button" >
731
+ <a href="<?php echo esc_url( get_edit_post_link( $flow_id ) ); ?>" class="button button-primary button-large wcf-header-back-button" style="text-decoration: none;">
732
+ <i class="dashicons dashicons-arrow-left-alt"></i>
733
+ <?php esc_html_e( 'Back to edit Flow', 'cartflows' ); ?>
734
+ </a>
735
+ </div>
736
+ </script>
737
+ <?php
738
+ }
739
+ }
740
+
741
+ /**
742
+ * Set status true for gutenberg.
743
+ *
744
+ * @return void
745
+ */
746
+ public function set_block_editor_status() {
747
+
748
+ if ( ! current_user_can( 'manage_options' ) ) {
749
+ return;
750
+ }
751
+
752
+ // Set gutenberg status here.
753
+ $this->is_gutenberg_editor_active = true;
754
+ }
755
+ }
756
+
757
+ /**
758
+ * Kicking this off by calling 'get_instance()' method
759
+ */
760
+ Cartflows_Flow_Meta::get_instance();
modules/flow/classes/class-cartflows-step-post-type.php CHANGED
@@ -1,475 +1,498 @@
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
+ add_action( 'admin_init', array( $this, 'disallowed_admin_all_steps_view' ) );
55
+ }
56
+
57
+ /**
58
+ * Trys to load page.php for a header, footer or part theme layout.
59
+ *
60
+ * @since 1.0.0
61
+ * @param string $template The current template to be loaded.
62
+ * @return string
63
+ */
64
+ public function load_page_template( $template ) {
65
+
66
+ global $post;
67
+
68
+ if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
69
+
70
+ /**
71
+ * Remove Next/Prev Navigation
72
+ * add_filter('next_post_link', '__return_empty_string');
73
+ * add_filter('previous_post_link', '__return_empty_string');
74
+ *
75
+ * $page = locate_template( array( 'page.php' ) );
76
+ *
77
+ * if ( ! empty( $page ) ) {
78
+ * return $page;
79
+ * }
80
+ */
81
+
82
+ /* Remove Next / Previous Rel Link */
83
+ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
84
+ add_filter( 'next_post_rel_link', '__return_empty_string' );
85
+ add_filter( 'previous_post_rel_link', '__return_empty_string' );
86
+
87
+ $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
88
+
89
+ $page_template = apply_filters( 'cartflows_page_template', $page_template );
90
+
91
+ $file = '';
92
+
93
+ switch ( $page_template ) {
94
+
95
+ case 'cartflows-default':
96
+ $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
97
+ $this->body_classes[] = $page_template;
98
+ break;
99
+ case 'cartflows-canvas':
100
+ $file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
101
+ $this->body_classes[] = $page_template;
102
+ break;
103
+ default:
104
+ /**
105
+ * Remove Next/Prev Navigation
106
+ */
107
+ add_filter( 'next_post_link', '__return_empty_string' );
108
+ add_filter( 'previous_post_link', '__return_empty_string' );
109
+
110
+ $page = locate_template( array( 'page.php' ) );
111
+
112
+ if ( ! empty( $page ) ) {
113
+ $file = $page;
114
+ }
115
+
116
+ break;
117
+
118
+ /**
119
+ * Default:
120
+ * $file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
121
+ * $this->body_classes[] = 'cartflows-default';
122
+ * break;
123
+ */
124
+ }
125
+
126
+ // Just to be safe, we check if the file exist first.
127
+ if ( file_exists( $file ) ) {
128
+
129
+ /* Add Body Class */
130
+ add_filter( 'body_class', array( $this, 'body_class' ) );
131
+
132
+ return $file;
133
+ } else {
134
+ echo $file;
135
+ }
136
+ }
137
+
138
+ return $template;
139
+ }
140
+
141
+ /**
142
+ * Body classes.
143
+ *
144
+ * @since 1.0.0
145
+ * @param array $classes Body classes.
146
+ * @return array
147
+ */
148
+ public function body_class( $classes = array() ) {
149
+
150
+ $classes = array_merge( $classes, $this->body_classes );
151
+
152
+ return $classes;
153
+ }
154
+
155
+ /**
156
+ * Create custom post type
157
+ */
158
+ public function step_post_type() {
159
+
160
+ $labels = array(
161
+ 'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
162
+ 'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
163
+ 'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
164
+ 'all_items' => esc_html__( 'All Steps', 'cartflows' ),
165
+ 'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
166
+ 'view_item' => esc_html__( 'View Step', 'cartflows' ),
167
+ 'add_new' => esc_html__( 'Add New', 'cartflows' ),
168
+ 'update_item' => esc_html__( 'Update Step', 'cartflows' ),
169
+ 'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
170
+ 'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
171
+ );
172
+
173
+ $permalink_settings = Cartflows_Helper::get_permalink_settings();
174
+
175
+ $args = array(
176
+ 'labels' => $labels,
177
+ 'public' => true,
178
+ 'query_var' => true,
179
+ 'can_export' => true,
180
+ 'exclude_from_search' => true,
181
+ 'show_ui' => true,
182
+ 'show_in_menu' => false,
183
+ 'show_in_admin_bar' => true,
184
+ 'show_in_rest' => true,
185
+ 'supports' => array( 'title', 'editor', 'elementor', 'revisions' ),
186
+ 'capability_type' => 'post',
187
+ 'capabilities' => array(
188
+ 'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
189
+ ),
190
+ 'map_meta_cap' => true,
191
+ );
192
+
193
+ if ( isset( $permalink_settings['permalink_structure'] ) && ! empty( $permalink_settings['permalink_structure'] ) ) {
194
+ $args['rewrite'] = array(
195
+ 'slug' => $permalink_settings['permalink_structure'],
196
+ 'with_front' => false,
197
+ );
198
+
199
+ } elseif ( isset( $permalink_settings['permalink'] ) && ! empty( $permalink_settings['permalink'] ) ) {
200
+
201
+ $args['rewrite'] = array(
202
+ 'slug' => $permalink_settings['permalink'],
203
+ 'with_front' => false,
204
+ );
205
+ }
206
+
207
+ register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
208
+
209
+ // Step Type.
210
+ $args = array(
211
+ 'label' => __( 'Step Type', 'cartflows' ),
212
+ 'public' => false,
213
+ 'rewrite' => false,
214
+ 'hierarchical' => false,
215
+ );
216
+
217
+ register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
218
+
219
+ // Step Flow.
220
+ $args = array(
221
+ 'label' => __( 'Step Flow', 'cartflows' ),
222
+ 'public' => false,
223
+ 'rewrite' => false,
224
+ 'hierarchical' => false,
225
+ );
226
+
227
+ register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
228
+
229
+ if ( is_admin() ) {
230
+ /**
231
+ * Register 'Elementor' & 'Beaver Builder' site types.
232
+ *
233
+ * @see self::add_terms();
234
+ */
235
+ $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
236
+
237
+ $terms = array(
238
+ array(
239
+ 'name' => __( 'Landing', 'cartflows' ),
240
+ 'slug' => 'landing',
241
+ 'args' => array(
242
+ 'slug' => 'landing',
243
+ ),
244
+ ),
245
+ array(
246
+ 'name' => __( 'Optin (Woo)', 'cartflows' ),
247
+ 'slug' => 'optin',
248
+ 'args' => array(
249
+ 'slug' => 'optin',
250
+ ),
251
+ ),
252
+ array(
253
+ 'name' => __( 'Checkout (Woo)', 'cartflows' ),
254
+ 'slug' => 'checkout',
255
+ 'args' => array(
256
+ 'slug' => 'checkout',
257
+ ),
258
+ ),
259
+ array(
260
+ 'name' => __( 'Thank You (Woo)', 'cartflows' ),
261
+ 'slug' => 'thankyou',
262
+ 'args' => array(
263
+ 'slug' => 'thankyou',
264
+ ),
265
+ ),
266
+ array(
267
+ 'name' => __( 'Upsell (Woo)', 'cartflows' ),
268
+ 'slug' => 'upsell',
269
+ 'args' => array(
270
+ 'slug' => 'upsell',
271
+ ),
272
+ ),
273
+ array(
274
+ 'name' => __( 'Downsell (Woo)', 'cartflows' ),
275
+ 'slug' => 'downsell',
276
+ 'args' => array(
277
+ 'slug' => 'downsell',
278
+ ),
279
+ ),
280
+ );
281
+
282
+ $this->add_terms( $taxonomy, $terms );
283
+
284
+ }
285
+ }
286
+
287
+ /**
288
+ * Add WordPress templates.
289
+ *
290
+ * Adds Cartflows templates to steps
291
+ *
292
+ * @since 1.0.0
293
+ * @access public
294
+ */
295
+ public function add_wp_templates_support() {
296
+ add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
297
+ }
298
+
299
+ /**
300
+ * Add page templates.
301
+ *
302
+ * @since 1.0.0
303
+ * @access public
304
+ *
305
+ * @param array $page_templates Array of page templates.
306
+ *
307
+ * @param object $wp_theme wp theme.
308
+ * @param object $post post.
309
+ *
310
+ * @return array Page templates.
311
+ */
312
+ public function add_page_templates( $page_templates, $wp_theme, $post ) {
313
+
314
+ $page_templates = array(
315
+ 'cartflows-default' => _x( 'CartFlows — Boxed', 'cartflows' ),
316
+ 'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
317
+ );
318
+
319
+ return $page_templates;
320
+ }
321
+
322
+
323
+
324
+ /**
325
+ * Query fixe throwing error on 404 page due our post type changes.
326
+ * We are setting post_type as empty array to fix the issue.
327
+ * Ther error was throwing due to redirect_canonical function
328
+ * This fix is apply for 404 page only
329
+ */
330
+ public function query_fix() {
331
+
332
+ global $wp_query;
333
+
334
+ if ( $wp_query->is_404() ) {
335
+ $wp_query->set( 'post_type', array() );
336
+ }
337
+ }
338
+
339
+ /**
340
+ * Prevent slug duplicated
341
+ *
342
+ * @param string $slug post slug.
343
+ * @param int $post_ID post id.
344
+ * @param string $post_status post status.
345
+ * @param string $post_type post type.
346
+ * @param int $post_parent post parent id.
347
+ * @param string $original_slug original slug.
348
+ * @return string
349
+ */
350
+ public function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
351
+
352
+ $check_post_types = array(
353
+ 'post',
354
+ 'page',
355
+ CARTFLOWS_STEP_POST_TYPE,
356
+ );
357
+
358
+ if ( ! in_array( $post_type, $check_post_types, true ) ) {
359
+ return $slug;
360
+ }
361
+
362
+ if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
363
+ // Saving a post, check for duplicates in POST or PAGE post types.
364
+ $post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
365
+ $page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
366
+
367
+ if ( $post_match || $page_match ) {
368
+ $slug .= '-2';
369
+ }
370
+ } else {
371
+
372
+ // Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
373
+ $custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
374
+
375
+ if ( $custom_post_type_match ) {
376
+ $slug .= '-2';
377
+ }
378
+ }
379
+
380
+ return $slug;
381
+ }
382
+
383
+ /**
384
+ * Add Update messages for any custom post type
385
+ *
386
+ * @param array $messages Array of default messages.
387
+ */
388
+ public function post_update_messages( $messages ) {
389
+
390
+ $custom_post_type = get_post_type( get_the_ID() );
391
+
392
+ if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
393
+
394
+ $obj = get_post_type_object( $custom_post_type );
395
+ $singular_name = $obj->labels->singular_name;
396
+ $messages[ $custom_post_type ] = array(
397
+ 0 => '', // Unused. Messages start at index 1.
398
+ /* translators: %s: singular custom post type name */
399
+ 1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
400
+ /* translators: %s: singular custom post type name */
401
+ 2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
402
+ /* translators: %s: singular custom post type name */
403
+ 3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
404
+ /* translators: %s: singular custom post type name */
405
+ 4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
406
+ /* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
407
+ 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
408
+ /* translators: %s: singular custom post type name */
409
+ 6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
410
+ /* translators: %s: singular custom post type name */
411
+ 7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
412
+ /* translators: %s: singular custom post type name */
413
+ 8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
414
+ /* translators: %s: singular custom post type name */
415
+ 9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
416
+ /* translators: %s: singular custom post type name */
417
+ 10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
418
+ );
419
+ }
420
+
421
+ return $messages;
422
+ }
423
+
424
+ /**
425
+ * Add Terms for Taxonomy.
426
+ *
427
+ * => Example.
428
+ *
429
+ * $taxonomy = '{taxonomy}';
430
+ * $terms = array(
431
+ * array(
432
+ * 'name' => 'Landing',
433
+ * 'slug' => 'landing',
434
+ * ),
435
+ * array(
436
+ * 'name' => 'Checkout',
437
+ * 'slug' => 'checkout',
438
+ * ),
439
+ * );
440
+ *
441
+ * self::add_terms( $taxonomy, $terms );
442
+ *
443
+ * @since 1.0.0
444
+ * @param string $taxonomy Taxonomy Name.
445
+ * @param array $terms Terms list.
446
+ * @return void
447
+ */
448
+ public function add_terms( $taxonomy = '', $terms = array() ) {
449
+
450
+ foreach ( $terms as $key => $term ) {
451
+
452
+ $term_exist = term_exists( $term['slug'], $taxonomy );
453
+
454
+ if ( empty( $term_exist ) ) {
455
+
456
+ /**
457
+ * Add additional args if passed from request.
458
+ *
459
+ * @see https://codex.wordpress.org/Function_Reference/wp_insert_term
460
+ */
461
+ if ( array_key_exists( 'args', $term ) ) {
462
+ wp_insert_term( $term['name'], $taxonomy, $term['args'] );
463
+ } else {
464
+
465
+ $term['args'] = array( $term['slug'] );
466
+
467
+ wp_insert_term( $term['name'], $taxonomy, $term['args'] );
468
+ }
469
+ }
470
+ }
471
+ }
472
+
473
+ /**
474
+ * Redirect admin pages.
475
+ *
476
+ * @return void
477
+ */
478
+ public function disallowed_admin_all_steps_view() {
479
+
480
+ global $pagenow;
481
+
482
+ // Check current admin page. If step post type view redirect it to flow.
483
+ if ( 'edit.php' === $pagenow && isset( $_GET['post_type'] ) && CARTFLOWS_STEP_POST_TYPE === $_GET['post_type'] ) { //phpcs:ignore
484
+
485
+ if ( isset( $_GET['debug'] ) && $_GET['debug'] ) { //phpcs:ignore
486
+ return;
487
+ }
488
+
489
+ wp_safe_redirect( admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE ) );
490
+ exit;
491
+ }
492
+ }
493
+ }
494
+
495
+ /**
496
+ * Kicking this off by calling 'get_instance()' method
497
+ */
498
+ Cartflows_Step_Post_Type::get_instance();
modules/thankyou/classes/class-cartflows-thankyou-markup.php CHANGED
@@ -159,6 +159,8 @@ class Cartflows_Thankyou_Markup {
159
  wc_print_notices();
160
  }
161
 
 
 
162
  ob_start();
163
  echo "<div class='wcf-thankyou-wrap' id='wcf-thankyou-wrap'>";
164
  wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
159
  wc_print_notices();
160
  }
161
 
162
+ do_action( 'cartflows_thankyou_details_before', $order );
163
+
164
  ob_start();
165
  echo "<div class='wcf-thankyou-wrap' id='wcf-thankyou-wrap'>";
166
  wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
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.4
7
- Stable tag: 1.5.6
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,10 @@ Glad you asked! CartFlows Pro is an optional add-on to CartFlows that adds addit
125
 
126
  == Changelog ==
127
 
 
 
 
 
128
  = Version 1.5.6 - Thursday, 23rd April 2020 =
129
  * Fix: Checkout two-step type CSS conflict with the latest version of The-7 theme.
130
  * Fix: Optin step CSS conflict with the Astra theme.
4
  Tags: woocommerce, funnel builder, sales funnels, elementor, beaver builder
5
  Requires at least: 4.4
6
  Tested up to: 5.4
7
+ Stable tag: 1.5.7
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.5.7 - Monday, 4th May 2020 =
129
+ * New: Gutenberg support added for steps.
130
+ * Fix: Astra's mini cart icon display issue on the CartFlows steps.
131
+
132
  = Version 1.5.6 - Thursday, 23rd April 2020 =
133
  * Fix: Checkout two-step type CSS conflict with the latest version of The-7 theme.
134
  * Fix: Optin step CSS conflict with the Astra theme.
theme-support/astra/astra.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /**
3
- * Action call to remove the astra two step action hooks.
4
- *
5
- * @since X.X.X
6
- *
7
- * @package CartFlows
8
- */
9
-
10
- add_action( 'cartflows_checkout_before_shortcode', 'cartflows_theme_compatibility_astra' );
11
- add_action( 'cartflows_optin_before_shortcode', 'cartflows_theme_compatibility_astra' );
12
-
13
- if ( ! function_exists( 'cartflows_theme_compatibility_astra' ) ) {
14
-
15
- /**
16
- * Function to remove the astra hooks.
17
- *
18
- * @since X.X.X
19
- *
20
- * @return void
21
- */
22
- function cartflows_theme_compatibility_astra() {
23
- remove_action( 'woocommerce_checkout_before_customer_details', 'astra_two_step_checkout_form_wrapper_div', 1 );
24
- remove_action( 'woocommerce_checkout_before_customer_details', 'astra_two_step_checkout_form_ul_wrapper', 2 );
25
- remove_action( 'woocommerce_checkout_order_review', 'astra_woocommerce_div_wrapper_close', 30 );
26
- remove_action( 'woocommerce_checkout_order_review', 'astra_woocommerce_ul_close', 30 );
27
- remove_action( 'woocommerce_checkout_before_customer_details', 'astra_two_step_checkout_address_li_wrapper', 5 );
28
- remove_action( 'woocommerce_checkout_after_customer_details', 'astra_woocommerce_li_close' );
29
- remove_action( 'woocommerce_checkout_before_order_review', 'astra_two_step_checkout_order_review_wrap', 1 );
30
- remove_action( 'woocommerce_checkout_after_order_review', 'astra_woocommerce_li_close', 40 );
31
-
32
- add_filter( 'astra_theme_woocommerce_dynamic_css', '__return_empty_string' );
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
theme-support/astra/class-cartflows-astra-compatibility.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Astra theme compatibility
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ if ( ! class_exists( 'Cartflows_Astra_Compatibility' ) ) :
9
+
10
+ /**
11
+ * Class for Astra theme compatibility
12
+ */
13
+ class Cartflows_Astra_Compatibility {
14
+
15
+ /**
16
+ * Member Variable
17
+ *
18
+ * @var instance
19
+ */
20
+ private static $instance;
21
+
22
+ /**
23
+ * Initiator
24
+ *
25
+ * @since 1.5.7
26
+ */
27
+ public static function get_instance() {
28
+ if ( ! isset( self::$instance ) ) {
29
+ self::$instance = new self();
30
+ }
31
+ return self::$instance;
32
+ }
33
+
34
+ /**
35
+ * Constructor
36
+ *
37
+ * @since 1.5.7
38
+ */
39
+ public function __construct() {
40
+
41
+ add_action( 'cartflows_checkout_before_shortcode', array( $this, 'cartflows_theme_compatibility_astra' ) );
42
+ add_action( 'cartflows_optin_before_shortcode', array( $this, 'cartflows_theme_compatibility_astra' ) );
43
+
44
+ add_action( 'wp', array( $this, 'cartflows_load_wp_actions_for_astra' ), 56 );
45
+ }
46
+
47
+
48
+ /**
49
+ * Function to remove the astra hooks.
50
+ *
51
+ * @since 1.5.7
52
+ *
53
+ * @return void
54
+ */
55
+ public function cartflows_theme_compatibility_astra() {
56
+ remove_action( 'woocommerce_checkout_before_customer_details', 'astra_two_step_checkout_form_wrapper_div', 1 );
57
+ remove_action( 'woocommerce_checkout_before_customer_details', 'astra_two_step_checkout_form_ul_wrapper', 2 );
58
+ remove_action( 'woocommerce_checkout_order_review', 'astra_woocommerce_div_wrapper_close', 30 );
59
+ remove_action( 'woocommerce_checkout_order_review', 'astra_woocommerce_ul_close', 30 );
60
+ remove_action( 'woocommerce_checkout_before_customer_details', 'astra_two_step_checkout_address_li_wrapper', 5 );
61
+ remove_action( 'woocommerce_checkout_after_customer_details', 'astra_woocommerce_li_close' );
62
+ remove_action( 'woocommerce_checkout_before_order_review', 'astra_two_step_checkout_order_review_wrap', 1 );
63
+ remove_action( 'woocommerce_checkout_after_order_review', 'astra_woocommerce_li_close', 40 );
64
+
65
+ add_filter( 'astra_theme_woocommerce_dynamic_css', '__return_empty_string' );
66
+ }
67
+
68
+
69
+ /**
70
+ * Function to add/remove the actions/hooks on wp action.
71
+ *
72
+ * @since 1.5.7
73
+ *
74
+ * @return void
75
+ */
76
+ public function cartflows_load_wp_actions_for_astra() {
77
+
78
+ // Return if not the CartFlows page.
79
+ if ( ! wcf()->utils->is_step_post_type() ) {
80
+ return;
81
+ }
82
+
83
+ $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
84
+
85
+ if ( _wcf_supported_template( $page_template ) ) {
86
+ return;
87
+ }
88
+
89
+ add_action( 'wp_enqueue_scripts', array( $this, 'astra_compatibility_external_css' ), 101 );
90
+ // Re-add the WooCommerce's styles& script swhich are form Astra.
91
+ $astra_woo = Astra_Woocommerce::get_instance();
92
+ add_filter( 'woocommerce_enqueue_styles', array( $astra_woo, 'woo_filter_style' ), 9999 );
93
+
94
+ }
95
+
96
+ /**
97
+ * Load the CSS
98
+ *
99
+ * @since 1.5.7
100
+ *
101
+ * @return void
102
+ */
103
+ public function astra_compatibility_external_css() {
104
+
105
+ wp_enqueue_style( 'wcf-checkout-astra-compatibility', CARTFLOWS_URL . 'theme-support/astra/css/astra-compatibility.css', '', CARTFLOWS_VER );
106
+ }
107
+ }
108
+ /**
109
+ * Kicking this off by calling 'get_instance()' method
110
+ */
111
+ Cartflows_Astra_Compatibility::get_instance();
112
+
113
+ endif;
theme-support/astra/css/astra-compatibility.css ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Astra's normalize css
3
+ */
4
+
5
+ /* Two Column CSS */
6
+
7
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout #customer_details h3,
8
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout #customer_details h3{
9
+ font-size: 20px;
10
+ padding: 0;
11
+ margin: 0 0 25px 0;
12
+ border-bottom: none;
13
+ }
14
+
15
+ .cartflows_step-template-default.woocommerce #customer_details, .woocommerce .woocommerce table.shop_table {
16
+ margin-bottom: 0;
17
+ border-radius: 0;
18
+ }
19
+
20
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout form .form-row:last-child, .woocommerce.woocommerce-checkout form .form-row:last-child {
21
+ margin-bottom: 1.1em;
22
+ }
23
+
24
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout form #order_review_heading,
25
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout form #order_review_heading {
26
+ font-size: 20px;
27
+ margin: 20px 0 0;
28
+ padding: 3px 3px 20px;
29
+ width: 100%;
30
+ border-width: 0;
31
+ border-style: none;
32
+ border-color: unset;
33
+ }
34
+
35
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout form #order_review,
36
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout form #order_review {
37
+ padding: 3px;
38
+ border-width: 0;
39
+ border-style: none;
40
+ border-color: unset;
41
+ }
42
+
43
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout table.shop_table th,
44
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout table.shop_table th {
45
+ padding: 0.6em 0;
46
+ }
47
+
48
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout table.shop_table td,
49
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout table.shop_table td {
50
+ padding: 0.6em 0;
51
+ border-color: unset;
52
+ opacity: 1;
53
+ }
54
+
55
+ .cartflows_step-template-default.woocommerce table.shop_table .woocommerce-Price-amount,
56
+ .cartflows_step-template-default.woocommerce-page table.shop_table .woocommerce-Price-amount {
57
+ font-weight: inherit;
58
+ }
59
+
60
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout form #order_review td,
61
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout form #order_review th,
62
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout form #order_review td,
63
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout form #order_review th {
64
+ border-top: none;
65
+ border-right: 0;
66
+ padding-left: 0;
67
+ border-color: #cccccc;
68
+ }
69
+
70
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout form #order_review tfoot tr.order-total:not(.recurring-total) th,
71
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout form #order_review tfoot tr.order-total:not(.recurring-total) td{
72
+ font-weight: 600;
73
+ border-top: 1px dashed #cccccc;
74
+ }
75
+
76
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout #payment ul.payment_methods,
77
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout #payment ul.payment_methods {
78
+ margin-bottom: 0;
79
+ }
80
+
81
+ .cartflows_step-template-default.woocommerce-page.woocommerce-checkout #payment div.form-row,
82
+ .cartflows_step-template-default.woocommerce.woocommerce-checkout #payment div.form-row {
83
+ padding: 0px;
84
+ margin: 0px;
85
+ }
86
+
87
+ /* Two Column CSS */
88
+
89
+ /* One Column CSS */
90
+ .cartflows_step-template-default.woocommerce .wcf-embed-checkout-form-one-column #customer_details,
91
+ .cartflows_step-template-default.woocommerce .wcf-embed-checkout-form-one-column .woocommerce table.shop_table {
92
+ margin-bottom: 0;
93
+ border-radius: 0;
94
+ }
95
+ /* One Column CSS */
woocommerce/template/order/order-details.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Order details
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woocommerce/order/order-details.php.
6
+ *
7
+ * HOWEVER, on occasion WooCommerce will need to update template files and you
8
+ * (the theme developer) will need to copy the new files to your theme to
9
+ * maintain compatibility. We try to do this as little as possible, but it does
10
+ * happen. When this occurs the version of the template file will be bumped and
11
+ * the readme will list any important changes.
12
+ *
13
+ * @see https://docs.woocommerce.com/document/template-structure/
14
+ * @package WooCommerce/Templates
15
+ * @version 3.7.0
16
+ */
17
+
18
+ defined( 'ABSPATH' ) || exit;
19
+
20
+ $order = wc_get_order( $order_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
21
+
22
+ if ( ! $order ) {
23
+ return;
24
+ }
25
+
26
+ $order_items = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) );
27
+ $show_purchase_note = $order->has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) );
28
+ $show_customer_details = is_user_logged_in() && $order->get_user_id() === get_current_user_id();
29
+ $downloads = $order->get_downloadable_items();
30
+ $show_downloads = $order->has_downloadable_item() && $order->is_download_permitted();
31
+
32
+ if ( $show_downloads ) {
33
+ wc_get_template(
34
+ 'order/order-downloads.php',
35
+ array(
36
+ 'downloads' => $downloads,
37
+ 'show_title' => true,
38
+ )
39
+ );
40
+ }
41
+ ?>
42
+ <section class="woocommerce-order-details">
43
+ <?php do_action( 'woocommerce_order_details_before_order_table', $order ); ?>
44
+
45
+ <h2 class="woocommerce-order-details__title"><?php esc_html_e( 'Order details', 'woocommerce' ); ?></h2>
46
+
47
+ <table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
48
+
49
+ <thead>
50
+ <tr>
51
+ <th class="woocommerce-table__product-name product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
52
+ <th class="woocommerce-table__product-table product-total"><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
53
+ </tr>
54
+ </thead>
55
+
56
+ <tbody>
57
+ <?php
58
+ do_action( 'woocommerce_order_details_before_order_table_items', $order );
59
+
60
+ foreach ( $order_items as $item_id => $item ) {
61
+ $product = $item->get_product();
62
+
63
+ wc_get_template(
64
+ 'order/order-details-item.php',
65
+ array(
66
+ 'order' => $order,
67
+ 'item_id' => $item_id,
68
+ 'item' => $item,
69
+ 'show_purchase_note' => $show_purchase_note,
70
+ 'purchase_note' => $product ? $product->get_purchase_note() : '',
71
+ 'product' => $product,
72
+ )
73
+ );
74
+ }
75
+
76
+ do_action( 'woocommerce_order_details_after_order_table_items', $order );
77
+ ?>
78
+ </tbody>
79
+
80
+ <tfoot>
81
+ <?php
82
+ foreach ( $order->get_order_item_totals() as $key => $total ) {
83
+ ?>
84
+ <tr>
85
+ <th scope="row"><?php echo esc_html( $total['label'] ); ?></th>
86
+ <td><?php echo ( 'payment_method' === $key ) ? esc_html( $total['value'] ) : wp_kses_post( $total['value'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></td>
87
+ </tr>
88
+ <?php
89
+ }
90
+ ?>
91
+ <?php if ( $order->get_customer_note() ) : ?>
92
+ <tr>
93
+ <th><?php esc_html_e( 'Note:', 'woocommerce' ); ?></th>
94
+ <td><?php echo wp_kses_post( nl2br( wptexturize( $order->get_customer_note() ) ) ); ?></td>
95
+ </tr>
96
+ <?php endif; ?>
97
+ </tfoot>
98
+ </table>
99
+
100
+ <?php do_action( 'woocommerce_order_details_after_order_table', $order ); ?>
101
+ </section>
102
+
103
+ <?php do_action( 'woocommerce_after_order_details', $order ); ?>
104
+
105
+ <?php
106
+ if ( $show_customer_details ) {
107
+ wc_get_template( 'order/order-details-customer.php', array( 'order' => $order ) );
108
+ }