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

Version Description

Download this release

Release Info

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

Code changes from version 1.1.14 to 1.1.15

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.1.14
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: 3.5.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.1.15
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: 3.5.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,6 @@
 
 
 
1
  Version 1.1.14 - Wednesday, 24th April 2019
2
  - Improvement: Minify CSS and Js files filter added.
3
  - Improvement: Inline coupon message. Now coupon message will show above coupon field.
1
+ Version 1.1.15 - Wednesday, 24th April 2019
2
+ - Fix: - WooCommerce dependency issue.
3
+
4
  Version 1.1.14 - Wednesday, 24th April 2019
5
  - Improvement: Minify CSS and Js files filter added.
6
  - Improvement: Inline coupon message. Now coupon message will show above coupon field.
classes/batch-process/class-cartflows-importer-divi.php CHANGED
@@ -1,116 +1,116 @@
1
- <?php
2
- /**
3
- * Divi Importer
4
- *
5
- * @package CartFlows
6
- * @since 1.1.1
7
- */
8
-
9
- if ( ! class_exists( 'CartFlows_Importer_Divi' ) ) :
10
-
11
- /**
12
- * CartFlows Import Divi
13
- *
14
- * @since 1.1.1
15
- */
16
- class CartFlows_Importer_Divi {
17
-
18
- /**
19
- * Instance
20
- *
21
- * @since 1.1.1
22
- * @access private
23
- * @var object Class object.
24
- */
25
- private static $instance;
26
-
27
- /**
28
- * Initiator
29
- *
30
- * @since 1.1.1
31
- * @return object initialized object of class.
32
- */
33
- public static function get_instance() {
34
-
35
- if ( ! isset( self::$instance ) ) {
36
- self::$instance = new self;
37
- }
38
- return self::$instance;
39
- }
40
-
41
- /**
42
- * Constructor
43
- *
44
- * @since 1.1.1
45
- */
46
- public function __construct() {}
47
-
48
- /**
49
- * Allowed tags for the batch update process
50
- *
51
- * @since x.x.x
52
- *
53
- * @param array $allowedposttags Array of default allowable HTML tags.
54
- * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
55
- * 'strip', 'data', 'entities', or the name of a field filter such as
56
- * 'pre_user_description'.
57
- * @return array Array of allowed HTML tags and their allowed attributes.
58
- */
59
- function allowed_tags_and_attributes( $allowedposttags, $context ) {
60
-
61
- // Keep only for 'post' contenxt.
62
- if ( 'post' === $context ) {
63
-
64
- // <style> tag and attributes.
65
- $allowedposttags['style'] = array();
66
- }
67
-
68
- return $allowedposttags;
69
- }
70
-
71
- /**
72
- * Update post meta.
73
- *
74
- * @param integer $post_id Post ID.
75
- * @return void
76
- */
77
- public function import_single_post( $post_id = 0 ) {
78
-
79
- // Allow the SVG tags in batch update process.
80
- add_filter( 'wp_kses_allowed_html', array( $this, 'allowed_tags_and_attributes' ), 10, 2 );
81
-
82
- // Download and replace images.
83
- $content = get_post_meta( $post_id, 'divi_content', true );
84
-
85
- if ( empty( $content ) ) {
86
- wcf()->logger->import_log( '(✕) Not have "Divi" Data. Post content is empty!' );
87
- } else {
88
-
89
- wcf()->logger->import_log( '(✓) Processing Request..' );
90
-
91
- // Update hotlink images.
92
- $content = CartFlows_Importer::get_instance()->get_content( $content );
93
-
94
- // Update post content.
95
- wp_update_post(
96
- array(
97
- 'ID' => $post_id,
98
- 'post_content' => $content,
99
- )
100
- );
101
-
102
- // Delete temporary meta key.
103
- delete_post_meta( $post_id, 'divi_content' );
104
-
105
- wcf()->logger->import_log( '(✓) Process Complete' );
106
- }
107
- }
108
-
109
- }
110
-
111
- /**
112
- * Initialize class object with 'get_instance()' method
113
- */
114
- CartFlows_Importer_Divi::get_instance();
115
-
116
- endif;
1
+ <?php
2
+ /**
3
+ * Divi Importer
4
+ *
5
+ * @package CartFlows
6
+ * @since 1.1.1
7
+ */
8
+
9
+ if ( ! class_exists( 'CartFlows_Importer_Divi' ) ) :
10
+
11
+ /**
12
+ * CartFlows Import Divi
13
+ *
14
+ * @since 1.1.1
15
+ */
16
+ class CartFlows_Importer_Divi {
17
+
18
+ /**
19
+ * Instance
20
+ *
21
+ * @since 1.1.1
22
+ * @access private
23
+ * @var object Class object.
24
+ */
25
+ private static $instance;
26
+
27
+ /**
28
+ * Initiator
29
+ *
30
+ * @since 1.1.1
31
+ * @return object initialized object of class.
32
+ */
33
+ public static function get_instance() {
34
+
35
+ if ( ! isset( self::$instance ) ) {
36
+ self::$instance = new self;
37
+ }
38
+ return self::$instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor
43
+ *
44
+ * @since 1.1.1
45
+ */
46
+ public function __construct() {}
47
+
48
+ /**
49
+ * Allowed tags for the batch update process
50
+ *
51
+ * @since x.x.x
52
+ *
53
+ * @param array $allowedposttags Array of default allowable HTML tags.
54
+ * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
55
+ * 'strip', 'data', 'entities', or the name of a field filter such as
56
+ * 'pre_user_description'.
57
+ * @return array Array of allowed HTML tags and their allowed attributes.
58
+ */
59
+ function allowed_tags_and_attributes( $allowedposttags, $context ) {
60
+
61
+ // Keep only for 'post' contenxt.
62
+ if ( 'post' === $context ) {
63
+
64
+ // <style> tag and attributes.
65
+ $allowedposttags['style'] = array();
66
+ }
67
+
68
+ return $allowedposttags;
69
+ }
70
+
71
+ /**
72
+ * Update post meta.
73
+ *
74
+ * @param integer $post_id Post ID.
75
+ * @return void
76
+ */
77
+ public function import_single_post( $post_id = 0 ) {
78
+
79
+ // Allow the SVG tags in batch update process.
80
+ add_filter( 'wp_kses_allowed_html', array( $this, 'allowed_tags_and_attributes' ), 10, 2 );
81
+
82
+ // Download and replace images.
83
+ $content = get_post_meta( $post_id, 'divi_content', true );
84
+
85
+ if ( empty( $content ) ) {
86
+ wcf()->logger->import_log( '(✕) Not have "Divi" Data. Post content is empty!' );
87
+ } else {
88
+
89
+ wcf()->logger->import_log( '(✓) Processing Request..' );
90
+
91
+ // Update hotlink images.
92
+ $content = CartFlows_Importer::get_instance()->get_content( $content );
93
+
94
+ // Update post content.
95
+ wp_update_post(
96
+ array(
97
+ 'ID' => $post_id,
98
+ 'post_content' => $content,
99
+ )
100
+ );
101
+
102
+ // Delete temporary meta key.
103
+ delete_post_meta( $post_id, 'divi_content' );
104
+
105
+ wcf()->logger->import_log( '(✓) Process Complete' );
106
+ }
107
+ }
108
+
109
+ }
110
+
111
+ /**
112
+ * Initialize class object with 'get_instance()' method
113
+ */
114
+ CartFlows_Importer_Divi::get_instance();
115
+
116
+ endif;
classes/class-cartflows-admin.php CHANGED
@@ -1,490 +1,490 @@
1
- <?php
2
- /**
3
- * CartFlows Admin.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Class Cartflows_Admin.
10
- */
11
- class Cartflows_Admin {
12
-
13
- /**
14
- * Calls on initialization
15
- *
16
- * @since 1.0.0
17
- */
18
- public static function init() {
19
-
20
- self::initialise_plugin();
21
- self::init_hooks();
22
- }
23
-
24
- /**
25
- * Init Hooks.
26
- *
27
- * @since 1.0.0
28
- * @return void
29
- */
30
- static public function init_hooks() {
31
-
32
- if ( ! is_admin() ) {
33
- return;
34
- }
35
-
36
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
37
-
38
- // Add CARTFLOWS menu option to admin.
39
- add_action( 'network_admin_menu', __CLASS__ . '::menu' );
40
- add_action( 'admin_menu', __CLASS__ . '::menu' );
41
- add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
42
-
43
- add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
44
-
45
- add_action( 'init', __CLASS__ . '::settings_admin_scripts' );
46
-
47
- /* Global Addmin Script */
48
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
49
-
50
- add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
51
-
52
- /* Add lite version class to body */
53
- add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
54
- }
55
-
56
-
57
- /**
58
- * Initialize after Cartflows pro get loaded.
59
- */
60
- static public function settings_admin_scripts() {
61
- // Enqueue admin scripts.
62
- if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
63
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
64
-
65
- self::save_settings();
66
- }
67
- }
68
- /**
69
- * Initialises the Plugin Name.
70
- *
71
- * @since 1.0.0
72
- * @return void
73
- */
74
- static public function initialise_plugin() {
75
-
76
- $name = 'Cartflows';
77
- $short_name = 'Cflows';
78
-
79
- define( 'CARTFLOWS_PLUGIN_NAME', $name );
80
- define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
81
- }
82
-
83
- /**
84
- * Renders the admin settings menu.
85
- *
86
- * @since 1.0.0
87
- * @return void
88
- */
89
- static public function menu() {
90
-
91
- if ( ! current_user_can( 'manage_options' ) ) {
92
- return;
93
- }
94
-
95
- add_menu_page(
96
- 'CartFlows',
97
- 'CartFlows',
98
- 'manage_options',
99
- CARTFLOWS_SLUG,
100
- __CLASS__ . '::render',
101
- 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
102
- 39.7
103
- );
104
-
105
- }
106
-
107
- /**
108
- * Add submenu to admin menu.
109
- *
110
- * @since 1.0.0
111
- */
112
- static function submenu() {
113
-
114
- $parent_slug = CARTFLOWS_SLUG;
115
- $page_title = __( 'Settings', 'cartflows' );
116
- $menu_title = __( 'Settings', 'cartflows' );
117
- $capability = 'manage_options';
118
- $menu_slug = 'cartflows_settings';
119
- $callback = __CLASS__ . '::render';
120
-
121
- add_submenu_page(
122
- $parent_slug,
123
- $page_title,
124
- $menu_title,
125
- $capability,
126
- $menu_slug,
127
- $callback
128
- );
129
- }
130
-
131
- /**
132
- * Renders the admin settings.
133
- *
134
- * @since 1.0.0
135
- * @return void
136
- */
137
- static public function render() {
138
- $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
139
- $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
140
- $action = str_replace( '_', '-', $action );
141
-
142
- // Enable header icon filter below.
143
- $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
144
-
145
- include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
146
- }
147
-
148
- /**
149
- * Renders the admin settings content.
150
- *
151
- * @since 1.0.0
152
- * @return void
153
- */
154
- static public function render_content() {
155
-
156
- $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
157
- $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
158
- $action = str_replace( '_', '-', $action );
159
- $action = 'general';
160
-
161
- $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
162
-
163
- include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
164
- }
165
-
166
- /**
167
- * Save Global Setting options.
168
- *
169
- * @since 1.0.0
170
- */
171
- static public function save_common_settings() {
172
-
173
- if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
174
-
175
- $url = $_SERVER['REQUEST_URI'];
176
- $input_settings = array();
177
- $new_settings = array();
178
-
179
- if ( isset( $_POST['_cartflows_common'] ) ) {
180
-
181
- $input_settings = $_POST['_cartflows_common'];
182
-
183
- // Loop through the input and sanitize each of the values.
184
- foreach ( $input_settings as $key => $val ) {
185
-
186
- if ( is_array( $val ) ) {
187
- foreach ( $val as $k => $v ) {
188
- $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
189
- }
190
- } else {
191
- $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
192
- }
193
- }
194
- }
195
-
196
- Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
197
-
198
- $query = array(
199
- 'message' => 'saved',
200
- );
201
-
202
- $redirect_to = add_query_arg( $query, $url );
203
-
204
- wp_redirect( $redirect_to );
205
- exit;
206
- } // End if statement.
207
- }
208
-
209
- /**
210
- * Save Debug Setting options.
211
- *
212
- * @since 1.1.14
213
- */
214
- static public function save_debug_settings() {
215
-
216
- if ( isset( $_POST['cartflows-debug-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-debug-settings-nonce'], 'cartflows-debug-settings' ) ) {
217
-
218
- $url = $_SERVER['REQUEST_URI'];
219
- $input_settings = array();
220
- $new_settings = array();
221
-
222
- if ( isset( $_POST['_cartflows_debug_data'] ) ) {
223
-
224
- $input_settings = $_POST['_cartflows_debug_data'];
225
-
226
- // Loop through the input and sanitize each of the values.
227
- foreach ( $input_settings as $key => $val ) {
228
-
229
- if ( is_array( $val ) ) {
230
- foreach ( $val as $k => $v ) {
231
- $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
232
- }
233
- } else {
234
- $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
235
- }
236
- }
237
- }
238
-
239
- Cartflows_Helper::update_admin_settings_option( '_cartflows_debug_data', $new_settings, true );
240
-
241
- $query = array(
242
- 'message' => 'saved',
243
- );
244
-
245
- $redirect_to = add_query_arg( $query, $url );
246
-
247
- wp_redirect( $redirect_to );
248
- exit;
249
-
250
- }
251
- }
252
-
253
- /**
254
- * Check is cartflows admin.
255
- *
256
- * @since 1.0.0
257
- * @return boolean
258
- */
259
- static public function is_global_admin() {
260
-
261
- $current_screen = get_current_screen();
262
-
263
- if (
264
- is_object( $current_screen ) &&
265
- isset( $current_screen->post_type ) &&
266
- ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
267
- CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
268
- )
269
- ) {
270
- return true;
271
- }
272
- return false;
273
- }
274
-
275
- /**
276
- * Check is flow admin.
277
- *
278
- * @since 1.0.0
279
- * @return boolean
280
- */
281
- static public function is_flow_edit_admin() {
282
-
283
- $current_screen = get_current_screen();
284
-
285
- if (
286
- is_object( $current_screen ) &&
287
- isset( $current_screen->post_type ) &&
288
- ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
289
- isset( $current_screen->base ) &&
290
- ( 'post' === $current_screen->base )
291
- ) {
292
- return true;
293
- }
294
- return false;
295
- }
296
-
297
- /**
298
- * Global Admin Scripts.
299
- *
300
- * @since 1.0.0
301
- */
302
- static public function global_admin_scripts() {
303
-
304
- $localize = array(
305
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
306
- 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
307
- );
308
-
309
- wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
310
-
311
- if ( self::is_global_admin() ) {
312
-
313
- // Styles.
314
- wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
315
- wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
316
-
317
- wp_enqueue_script(
318
- 'wcf-global-admin',
319
- CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
320
- array( 'jquery' ),
321
- CARTFLOWS_VER,
322
- true
323
- );
324
-
325
- do_action( 'cartflows_global_admin_scripts' );
326
- }
327
- }
328
-
329
- /**
330
- * Global Admin Data.
331
- *
332
- * @since 1.0.0
333
- */
334
- static public function global_admin_data() {
335
-
336
- $current_screen = get_current_screen();
337
-
338
- if ( ! $current_screen ) {
339
- return;
340
- }
341
-
342
- if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
343
- return;
344
- }
345
-
346
- $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
347
- ?>
348
-
349
- <div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
350
- <div class="wcf-templates-popup-content">
351
- <div class="spinner"></div>
352
- <div class="wcf-templates-wrap wcf-templates-wrap-flows">
353
-
354
- <div id="wcf-remote-flow-actions" class="wcf-template-header">
355
- <div class="wcf-template-logo-wrap">
356
- <span class="wcf-cartflows-logo-img">
357
- <span class="cartflows-logo-icon"></span>
358
- </span>
359
- <span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
360
- </div>
361
- <div class="wcf-tab-wrapper">
362
- <?php if ( 'other' !== $default_page_builder ) { ?>
363
- <div id="wcf-get-started-steps">
364
- <ul class="filter-links ">
365
- <li>
366
- <a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
367
- </li>
368
- <li>
369
- <a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
370
- </li>
371
- </ul>
372
- </div>
373
- <?php } ?>
374
- </div>
375
- <div class="wcf-popup-close-wrap">
376
- <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
377
- </div>
378
- </div>
379
- <!-- <div class="wcf-search-form">
380
- <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
381
- <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
382
- </div> -->
383
-
384
- <div id="wcf-remote-content">
385
- <?php if ( 'other' !== $default_page_builder ) { ?>
386
- <div id="wcf-ready-templates">
387
- <div id="wcf-remote-filters">
388
- <div id="wcf-page-builders"></div>
389
- <div id="wcf-categories"></div>
390
- </div>
391
- <div class="wcf-page-builder-notice"></div>
392
- <div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
393
- <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
394
- </div>
395
- <?php } ?>
396
- <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
397
- <div class="inner">
398
- <a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
399
- <p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
400
- </div>
401
- </div>
402
- </div>
403
- </div>
404
- </div>
405
- </div>
406
-
407
- <?php
408
- }
409
-
410
- /**
411
- * Enqueues the needed CSS/JS for the builder's admin settings page.
412
- *
413
- * @since 1.0.0
414
- */
415
- static public function styles_scripts() {
416
-
417
- // Styles.
418
- wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
419
- wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
420
-
421
- // Script.
422
- wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
423
-
424
- $localize = array(
425
- 'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
426
- );
427
-
428
- wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
429
-
430
- do_action( 'cartflows_admin_settings_after_enqueue_scripts' );
431
- }
432
-
433
- /**
434
- * Save All admin settings here
435
- */
436
- static public function save_settings() {
437
-
438
- // Only admins can save settings.
439
- if ( ! current_user_can( 'manage_options' ) ) {
440
- return;
441
- }
442
-
443
- self::save_common_settings();
444
- self::save_debug_settings();
445
-
446
- // Let extensions hook into saving.
447
- do_action( 'cartflows_admin_settings_save' );
448
- }
449
-
450
- /**
451
- * Get and return page URL
452
- *
453
- * @param string $menu_slug Menu name.
454
- * @since 1.0.0
455
- * @return string page url
456
- */
457
- static public function get_page_url( $menu_slug ) {
458
-
459
- $parent_page = self::$default_menu_position;
460
-
461
- if ( strpos( $parent_page, '?' ) !== false ) {
462
- $query_var = '&page=' . self::$plugin_slug;
463
- } else {
464
- $query_var = '?page=' . self::$plugin_slug;
465
- }
466
-
467
- $parent_page_url = admin_url( $parent_page . $query_var );
468
-
469
- $url = $parent_page_url . '&action=' . $menu_slug;
470
-
471
- return esc_url( $url );
472
- }
473
-
474
- /**
475
- * Admin body classes.
476
- *
477
- * Body classes to be added to <body> tag in admin page
478
- *
479
- * @param String $classes body classes returned from the filter.
480
- * @return String body classes to be added to <body> tag in admin page
481
- */
482
- static public function add_admin_body_class( $classes ) {
483
-
484
- $classes .= ' cartflows-' . CARTFLOWS_VER;
485
-
486
- return $classes;
487
- }
488
- }
489
-
490
- Cartflows_Admin::init();
1
+ <?php
2
+ /**
3
+ * CartFlows Admin.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Class Cartflows_Admin.
10
+ */
11
+ class Cartflows_Admin {
12
+
13
+ /**
14
+ * Calls on initialization
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ public static function init() {
19
+
20
+ self::initialise_plugin();
21
+ self::init_hooks();
22
+ }
23
+
24
+ /**
25
+ * Init Hooks.
26
+ *
27
+ * @since 1.0.0
28
+ * @return void
29
+ */
30
+ static public function init_hooks() {
31
+
32
+ if ( ! is_admin() ) {
33
+ return;
34
+ }
35
+
36
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
37
+
38
+ // Add CARTFLOWS menu option to admin.
39
+ add_action( 'network_admin_menu', __CLASS__ . '::menu' );
40
+ add_action( 'admin_menu', __CLASS__ . '::menu' );
41
+ add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
42
+
43
+ add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
44
+
45
+ add_action( 'init', __CLASS__ . '::settings_admin_scripts' );
46
+
47
+ /* Global Addmin Script */
48
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
49
+
50
+ add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
51
+
52
+ /* Add lite version class to body */
53
+ add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
54
+ }
55
+
56
+
57
+ /**
58
+ * Initialize after Cartflows pro get loaded.
59
+ */
60
+ static public function settings_admin_scripts() {
61
+ // Enqueue admin scripts.
62
+ if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
63
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
64
+
65
+ self::save_settings();
66
+ }
67
+ }
68
+ /**
69
+ * Initialises the Plugin Name.
70
+ *
71
+ * @since 1.0.0
72
+ * @return void
73
+ */
74
+ static public function initialise_plugin() {
75
+
76
+ $name = 'Cartflows';
77
+ $short_name = 'Cflows';
78
+
79
+ define( 'CARTFLOWS_PLUGIN_NAME', $name );
80
+ define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
81
+ }
82
+
83
+ /**
84
+ * Renders the admin settings menu.
85
+ *
86
+ * @since 1.0.0
87
+ * @return void
88
+ */
89
+ static public function menu() {
90
+
91
+ if ( ! current_user_can( 'manage_options' ) ) {
92
+ return;
93
+ }
94
+
95
+ add_menu_page(
96
+ 'CartFlows',
97
+ 'CartFlows',
98
+ 'manage_options',
99
+ CARTFLOWS_SLUG,
100
+ __CLASS__ . '::render',
101
+ 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
102
+ 39.7
103
+ );
104
+
105
+ }
106
+
107
+ /**
108
+ * Add submenu to admin menu.
109
+ *
110
+ * @since 1.0.0
111
+ */
112
+ static function submenu() {
113
+
114
+ $parent_slug = CARTFLOWS_SLUG;
115
+ $page_title = __( 'Settings', 'cartflows' );
116
+ $menu_title = __( 'Settings', 'cartflows' );
117
+ $capability = 'manage_options';
118
+ $menu_slug = 'cartflows_settings';
119
+ $callback = __CLASS__ . '::render';
120
+
121
+ add_submenu_page(
122
+ $parent_slug,
123
+ $page_title,
124
+ $menu_title,
125
+ $capability,
126
+ $menu_slug,
127
+ $callback
128
+ );
129
+ }
130
+
131
+ /**
132
+ * Renders the admin settings.
133
+ *
134
+ * @since 1.0.0
135
+ * @return void
136
+ */
137
+ static public function render() {
138
+ $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
139
+ $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
140
+ $action = str_replace( '_', '-', $action );
141
+
142
+ // Enable header icon filter below.
143
+ $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
144
+
145
+ include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
146
+ }
147
+
148
+ /**
149
+ * Renders the admin settings content.
150
+ *
151
+ * @since 1.0.0
152
+ * @return void
153
+ */
154
+ static public function render_content() {
155
+
156
+ $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
157
+ $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
158
+ $action = str_replace( '_', '-', $action );
159
+ $action = 'general';
160
+
161
+ $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
162
+
163
+ include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
164
+ }
165
+
166
+ /**
167
+ * Save Global Setting options.
168
+ *
169
+ * @since 1.0.0
170
+ */
171
+ static public function save_common_settings() {
172
+
173
+ if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
174
+
175
+ $url = $_SERVER['REQUEST_URI'];
176
+ $input_settings = array();
177
+ $new_settings = array();
178
+
179
+ if ( isset( $_POST['_cartflows_common'] ) ) {
180
+
181
+ $input_settings = $_POST['_cartflows_common'];
182
+
183
+ // Loop through the input and sanitize each of the values.
184
+ foreach ( $input_settings as $key => $val ) {
185
+
186
+ if ( is_array( $val ) ) {
187
+ foreach ( $val as $k => $v ) {
188
+ $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
189
+ }
190
+ } else {
191
+ $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
192
+ }
193
+ }
194
+ }
195
+
196
+ Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
197
+
198
+ $query = array(
199
+ 'message' => 'saved',
200
+ );
201
+
202
+ $redirect_to = add_query_arg( $query, $url );
203
+
204
+ wp_redirect( $redirect_to );
205
+ exit;
206
+ } // End if statement.
207
+ }
208
+
209
+ /**
210
+ * Save Debug Setting options.
211
+ *
212
+ * @since 1.1.14
213
+ */
214
+ static public function save_debug_settings() {
215
+
216
+ if ( isset( $_POST['cartflows-debug-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-debug-settings-nonce'], 'cartflows-debug-settings' ) ) {
217
+
218
+ $url = $_SERVER['REQUEST_URI'];
219
+ $input_settings = array();
220
+ $new_settings = array();
221
+
222
+ if ( isset( $_POST['_cartflows_debug_data'] ) ) {
223
+
224
+ $input_settings = $_POST['_cartflows_debug_data'];
225
+
226
+ // Loop through the input and sanitize each of the values.
227
+ foreach ( $input_settings as $key => $val ) {
228
+
229
+ if ( is_array( $val ) ) {
230
+ foreach ( $val as $k => $v ) {
231
+ $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
232
+ }
233
+ } else {
234
+ $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
235
+ }
236
+ }
237
+ }
238
+
239
+ Cartflows_Helper::update_admin_settings_option( '_cartflows_debug_data', $new_settings, true );
240
+
241
+ $query = array(
242
+ 'message' => 'saved',
243
+ );
244
+
245
+ $redirect_to = add_query_arg( $query, $url );
246
+
247
+ wp_redirect( $redirect_to );
248
+ exit;
249
+
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Check is cartflows admin.
255
+ *
256
+ * @since 1.0.0
257
+ * @return boolean
258
+ */
259
+ static public function is_global_admin() {
260
+
261
+ $current_screen = get_current_screen();
262
+
263
+ if (
264
+ is_object( $current_screen ) &&
265
+ isset( $current_screen->post_type ) &&
266
+ ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
267
+ CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
268
+ )
269
+ ) {
270
+ return true;
271
+ }
272
+ return false;
273
+ }
274
+
275
+ /**
276
+ * Check is flow admin.
277
+ *
278
+ * @since 1.0.0
279
+ * @return boolean
280
+ */
281
+ static public function is_flow_edit_admin() {
282
+
283
+ $current_screen = get_current_screen();
284
+
285
+ if (
286
+ is_object( $current_screen ) &&
287
+ isset( $current_screen->post_type ) &&
288
+ ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
289
+ isset( $current_screen->base ) &&
290
+ ( 'post' === $current_screen->base )
291
+ ) {
292
+ return true;
293
+ }
294
+ return false;
295
+ }
296
+
297
+ /**
298
+ * Global Admin Scripts.
299
+ *
300
+ * @since 1.0.0
301
+ */
302
+ static public function global_admin_scripts() {
303
+
304
+ $localize = array(
305
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
306
+ 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
307
+ );
308
+
309
+ wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
310
+
311
+ if ( self::is_global_admin() ) {
312
+
313
+ // Styles.
314
+ wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
315
+ wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
316
+
317
+ wp_enqueue_script(
318
+ 'wcf-global-admin',
319
+ CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
320
+ array( 'jquery' ),
321
+ CARTFLOWS_VER,
322
+ true
323
+ );
324
+
325
+ do_action( 'cartflows_global_admin_scripts' );
326
+ }
327
+ }
328
+
329
+ /**
330
+ * Global Admin Data.
331
+ *
332
+ * @since 1.0.0
333
+ */
334
+ static public function global_admin_data() {
335
+
336
+ $current_screen = get_current_screen();
337
+
338
+ if ( ! $current_screen ) {
339
+ return;
340
+ }
341
+
342
+ if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
343
+ return;
344
+ }
345
+
346
+ $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
347
+ ?>
348
+
349
+ <div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
350
+ <div class="wcf-templates-popup-content">
351
+ <div class="spinner"></div>
352
+ <div class="wcf-templates-wrap wcf-templates-wrap-flows">
353
+
354
+ <div id="wcf-remote-flow-actions" class="wcf-template-header">
355
+ <div class="wcf-template-logo-wrap">
356
+ <span class="wcf-cartflows-logo-img">
357
+ <span class="cartflows-logo-icon"></span>
358
+ </span>
359
+ <span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
360
+ </div>
361
+ <div class="wcf-tab-wrapper">
362
+ <?php if ( 'other' !== $default_page_builder ) { ?>
363
+ <div id="wcf-get-started-steps">
364
+ <ul class="filter-links ">
365
+ <li>
366
+ <a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
367
+ </li>
368
+ <li>
369
+ <a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
370
+ </li>
371
+ </ul>
372
+ </div>
373
+ <?php } ?>
374
+ </div>
375
+ <div class="wcf-popup-close-wrap">
376
+ <span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
377
+ </div>
378
+ </div>
379
+ <!-- <div class="wcf-search-form">
380
+ <label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
381
+ <input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
382
+ </div> -->
383
+
384
+ <div id="wcf-remote-content">
385
+ <?php if ( 'other' !== $default_page_builder ) { ?>
386
+ <div id="wcf-ready-templates">
387
+ <div id="wcf-remote-filters">
388
+ <div id="wcf-page-builders"></div>
389
+ <div id="wcf-categories"></div>
390
+ </div>
391
+ <div class="wcf-page-builder-notice"></div>
392
+ <div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
393
+ <div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
394
+ </div>
395
+ <?php } ?>
396
+ <div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
397
+ <div class="inner">
398
+ <a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
399
+ <p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
400
+ </div>
401
+ </div>
402
+ </div>
403
+ </div>
404
+ </div>
405
+ </div>
406
+
407
+ <?php
408
+ }
409
+
410
+ /**
411
+ * Enqueues the needed CSS/JS for the builder's admin settings page.
412
+ *
413
+ * @since 1.0.0
414
+ */
415
+ static public function styles_scripts() {
416
+
417
+ // Styles.
418
+ wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
419
+ wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
420
+
421
+ // Script.
422
+ wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
423
+
424
+ $localize = array(
425
+ 'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
426
+ );
427
+
428
+ wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
429
+
430
+ do_action( 'cartflows_admin_settings_after_enqueue_scripts' );
431
+ }
432
+
433
+ /**
434
+ * Save All admin settings here
435
+ */
436
+ static public function save_settings() {
437
+
438
+ // Only admins can save settings.
439
+ if ( ! current_user_can( 'manage_options' ) ) {
440
+ return;
441
+ }
442
+
443
+ self::save_common_settings();
444
+ self::save_debug_settings();
445
+
446
+ // Let extensions hook into saving.
447
+ do_action( 'cartflows_admin_settings_save' );
448
+ }
449
+
450
+ /**
451
+ * Get and return page URL
452
+ *
453
+ * @param string $menu_slug Menu name.
454
+ * @since 1.0.0
455
+ * @return string page url
456
+ */
457
+ static public function get_page_url( $menu_slug ) {
458
+
459
+ $parent_page = self::$default_menu_position;
460
+
461
+ if ( strpos( $parent_page, '?' ) !== false ) {
462
+ $query_var = '&page=' . self::$plugin_slug;
463
+ } else {
464
+ $query_var = '?page=' . self::$plugin_slug;
465
+ }
466
+
467
+ $parent_page_url = admin_url( $parent_page . $query_var );
468
+
469
+ $url = $parent_page_url . '&action=' . $menu_slug;
470
+
471
+ return esc_url( $url );
472
+ }
473
+
474
+ /**
475
+ * Admin body classes.
476
+ *
477
+ * Body classes to be added to <body> tag in admin page
478
+ *
479
+ * @param String $classes body classes returned from the filter.
480
+ * @return String body classes to be added to <body> tag in admin page
481
+ */
482
+ static public function add_admin_body_class( $classes ) {
483
+
484
+ $classes .= ' cartflows-' . CARTFLOWS_VER;
485
+
486
+ return $classes;
487
+ }
488
+ }
489
+
490
+ Cartflows_Admin::init();
classes/class-cartflows-default-meta.php CHANGED
@@ -1,926 +1,926 @@
1
- <?php
2
- /**
3
- * Cartflow default options.
4
- *
5
- * @package Cartflows
6
- */
7
-
8
- /**
9
- * Initialization
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Default_Meta {
14
-
15
-
16
- /**
17
- * Member Variable
18
- *
19
- * @var instance
20
- */
21
- private static $instance;
22
-
23
- /**
24
- * Member Variable
25
- *
26
- * @var checkout_fields
27
- */
28
- private static $checkout_fields = null;
29
-
30
- /**
31
- * Member Variable
32
- *
33
- * @var checkout_fields
34
- */
35
- private static $thankyou_fields = null;
36
-
37
- /**
38
- * Member Variable
39
- *
40
- * @var flow_fields
41
- */
42
- private static $flow_fields = null;
43
-
44
- /**
45
- * Member Variable
46
- *
47
- * @var landing_fields
48
- */
49
- private static $landing_fields = null;
50
-
51
- /**
52
- * Initiator
53
- */
54
- public static function get_instance() {
55
- if ( ! isset( self::$instance ) ) {
56
- self::$instance = new self;
57
- }
58
- return self::$instance;
59
- }
60
-
61
- /**
62
- * Constructor
63
- */
64
- public function __construct() {
65
-
66
- }
67
-
68
- /**
69
- * Checkout Default fields.
70
- *
71
- * @param int $post_id post id.
72
- * @return array
73
- */
74
- function get_checkout_fields( $post_id ) {
75
-
76
- if ( null === self::$checkout_fields ) {
77
-
78
- self::$checkout_fields = array(
79
- 'wcf-field-google-font-url' => array(
80
- 'default' => '',
81
- 'sanitize' => 'FILTER_DEFAULT',
82
- ),
83
- 'wcf-checkout-products' => array(
84
- 'default' => array(),
85
- 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS',
86
- ),
87
- 'wcf-checkout-layout' => array(
88
- 'default' => 'two-column',
89
- 'sanitize' => 'FILTER_DEFAULT',
90
- ),
91
- 'wcf-input-font-family' => array(
92
- 'default' => '',
93
- 'sanitize' => 'FILTER_DEFAULT',
94
- ),
95
- 'wcf-input-font-weight' => array(
96
- 'default' => '',
97
- 'sanitize' => 'FILTER_DEFAULT',
98
- ),
99
- 'wcf-heading-font-family' => array(
100
- 'default' => '',
101
- 'sanitize' => 'FILTER_DEFAULT',
102
- ),
103
- 'wcf-heading-font-weight' => array(
104
- 'default' => '',
105
- 'sanitize' => 'FILTER_DEFAULT',
106
- ),
107
- 'wcf-base-font-family' => array(
108
- 'default' => '',
109
- 'sanitize' => 'FILTER_DEFAULT',
110
- ),
111
- 'wcf-advance-options-fields' => array(
112
- 'default' => '',
113
- 'sanitize' => 'FILTER_DEFAULT',
114
- ),
115
- 'wcf-base-font-weight' => array(
116
- 'default' => '',
117
- 'sanitize' => 'FILTER_DEFAULT',
118
- ),
119
- 'wcf-button-font-family' => array(
120
- 'default' => '',
121
- 'sanitize' => 'FILTER_DEFAULT',
122
- ),
123
- 'wcf-button-font-weight' => array(
124
- 'default' => '',
125
- 'sanitize' => 'FILTER_DEFAULT',
126
- ),
127
- 'wcf-primary-color' => array(
128
- 'default' => '',
129
- 'sanitize' => 'FILTER_DEFAULT',
130
- ),
131
- 'wcf-heading-color' => array(
132
- 'default' => '',
133
- 'sanitize' => 'FILTER_DEFAULT',
134
- ),
135
- 'wcf-section-bg-color' => array(
136
- 'default' => '',
137
- 'sanitize' => 'FILTER_DEFAULT',
138
- ),
139
- 'wcf-hl-bg-color' => array(
140
- 'default' => '',
141
- 'sanitize' => 'FILTER_DEFAULT',
142
- ),
143
- 'wcf-field-tb-padding' => array(
144
- 'default' => '',
145
- 'sanitize' => 'FILTER_DEFAULT',
146
- ),
147
- 'wcf-field-lr-padding' => array(
148
- 'default' => '',
149
- 'sanitize' => 'FILTER_DEFAULT',
150
- ),
151
- 'wcf-fields-skins' => array(
152
- 'default' => '',
153
- 'sanitize' => 'FILTER_DEFAULT',
154
- ),
155
- 'wcf-input-field-size' => array(
156
- 'default' => '33px',
157
- 'sanitize' => 'FILTER_DEFAULT',
158
- ),
159
- 'wcf-field-color' => array(
160
- 'default' => '',
161
- 'sanitize' => 'FILTER_DEFAULT',
162
- ),
163
- 'wcf-field-bg-color' => array(
164
- 'default' => '',
165
- 'sanitize' => 'FILTER_DEFAULT',
166
- ),
167
- 'wcf-field-border-color' => array(
168
- 'default' => '',
169
- 'sanitize' => 'FILTER_DEFAULT',
170
- ),
171
- 'wcf-box-border-color' => array(
172
- 'default' => '',
173
- 'sanitize' => 'FILTER_DEFAULT',
174
- ),
175
- 'wcf-field-label-color' => array(
176
- 'default' => '',
177
- 'sanitize' => 'FILTER_DEFAULT',
178
- ),
179
- 'wcf-submit-tb-padding' => array(
180
- 'default' => '',
181
- 'sanitize' => 'FILTER_DEFAULT',
182
- ),
183
- 'wcf-submit-lr-padding' => array(
184
- 'default' => '',
185
- 'sanitize' => 'FILTER_DEFAULT',
186
- ),
187
- 'wcf-input-button-size' => array(
188
- 'default' => '33px',
189
- 'sanitize' => 'FILTER_DEFAULT',
190
- ),
191
- 'wcf-submit-color' => array(
192
- 'default' => '',
193
- 'sanitize' => 'FILTER_DEFAULT',
194
- ),
195
- 'wcf-submit-hover-color' => array(
196
- 'default' => '',
197
- 'sanitize' => 'FILTER_DEFAULT',
198
- ),
199
- 'wcf-submit-bg-color' => array(
200
- 'default' => '',
201
- 'sanitize' => 'FILTER_DEFAULT',
202
- ),
203
- 'wcf-submit-bg-hover-color' => array(
204
- 'default' => '',
205
- 'sanitize' => 'FILTER_DEFAULT',
206
- ),
207
- 'wcf-submit-border-color' => array(
208
- 'default' => '',
209
- 'sanitize' => 'FILTER_DEFAULT',
210
- ),
211
- 'wcf-submit-border-hover-color' => array(
212
- 'default' => '',
213
- 'sanitize' => 'FILTER_DEFAULT',
214
- ),
215
- 'wcf-active-tab' => array(
216
- 'default' => '',
217
- 'sanitize' => 'FILTER_DEFAULT',
218
- ),
219
- 'wcf-header-logo-image' => array(
220
- 'default' => '',
221
- 'sanitize' => 'FILTER_DEFAULT',
222
- ),
223
- 'wcf-header-logo-width' => array(
224
- 'default' => '',
225
- 'sanitize' => 'FILTER_DEFAULT',
226
- ),
227
- 'wcf-custom-script' => array(
228
- 'default' => '',
229
- 'sanitize' => 'FILTER_DEFAULT',
230
- ),
231
- );
232
-
233
- self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id );
234
- }
235
-
236
- return self::$checkout_fields;
237
- }
238
-
239
- /**
240
- * Save Checkout Meta fields.
241
- *
242
- * @param int $post_id post id.
243
- * @return void
244
- */
245
- function save_checkout_fields( $post_id ) {
246
-
247
- $post_meta = $this->get_checkout_fields( $post_id );
248
-
249
- $this->save_meta_fields( $post_id, $post_meta );
250
- }
251
-
252
- /**
253
- * Save Landing Meta fields.
254
- *
255
- * @param int $post_id post id.
256
- * @return void
257
- */
258
- function save_landing_fields( $post_id ) {
259
-
260
- $post_meta = $this->get_landing_fields( $post_id );
261
-
262
- $this->save_meta_fields( $post_id, $post_meta );
263
- }
264
-
265
- /**
266
- * Save ThankYou Meta fields.
267
- *
268
- * @param int $post_id post id.
269
- * @return void
270
- */
271
- function save_thankyou_fields( $post_id ) {
272
-
273
- $post_meta = $this->get_thankyou_fields( $post_id );
274
-
275
- $this->save_meta_fields( $post_id, $post_meta );
276
- }
277
-
278
- /**
279
- * Flow Default fields.
280
- *
281
- * @param int $post_id post id.
282
- * @return array
283
- */
284
- function get_flow_fields( $post_id ) {
285
-
286
- if ( null === self::$flow_fields ) {
287
-
288
- self::$flow_fields = array(
289
- 'wcf-steps' => array(
290
- 'default' => array(),
291
- 'sanitize' => 'FILTER_DEFAULT',
292
- ),
293
-
294
- 'wcf-testing' => array(
295
- 'default' => 'yes',
296
- 'sanitize' => 'FILTER_DEFAULT',
297
- ),
298
- );
299
- }
300
-
301
- return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields );
302
- }
303
-
304
- /**
305
- * Save Flow Meta fields.
306
- *
307
- * @param int $post_id post id.
308
- * @return void
309
- */
310
- function save_flow_fields( $post_id ) {
311
-
312
- $post_meta = $this->get_flow_fields( $post_id );
313
-
314
- if ( isset( $post_meta['wcf-steps'] ) ) {
315
- unset( $post_meta['wcf-steps'] );
316
- }
317
-
318
- $this->save_meta_fields( $post_id, $post_meta );
319
- }
320
-
321
- /**
322
- * Save Meta fields - Common Function.
323
- *
324
- * @param int $post_id post id.
325
- * @param array $post_meta options to store.
326
- * @return void
327
- */
328
- function save_meta_fields( $post_id, $post_meta ) {
329
-
330
- if ( ! ( $post_id && is_array( $post_meta ) ) ) {
331
-
332
- return;
333
- }
334
-
335
- foreach ( $post_meta as $key => $data ) {
336
-
337
- $meta_value = false;
338
-
339
- // Sanitize values.
340
- $sanitize_filter = ( isset( $data['sanitize'] ) ) ? $data['sanitize'] : 'FILTER_DEFAULT';
341
-
342
- switch ( $sanitize_filter ) {
343
-
344
- case 'FILTER_SANITIZE_STRING':
345
- $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING );
346
- break;
347
-
348
- case 'FILTER_SANITIZE_URL':
349
- $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_URL );
350
- break;
351
-
352
- case 'FILTER_SANITIZE_NUMBER_INT':
353
- $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT );
354
- break;
355
-
356
- case 'FILTER_CARTFLOWS_ARRAY':
357
- if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
358
- $meta_value = array_map( 'sanitize_text_field', $_POST[ $key ] );
359
- }
360
- break;
361
-
362
- case 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS':
363
- if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
364
-
365
- $i = 0;
366
- $q = 0;
367
-
368
- foreach ( $_POST[ $key ] as $p_index => $p_data ) {
369
-
370
- foreach ( $p_data as $i_key => $i_value ) {
371
-
372
- if ( is_array( $i_value ) ) {
373
-
374
- foreach ( $i_value as $q_key => $q_value ) {
375
-
376
- $meta_value[ $i ][ $i_key ][ $q ] = array_map( 'sanitize_text_field', $q_value );
377
-
378
- $q++;
379
- }
380
- } else {
381
- $meta_value[ $i ][ $i_key ] = sanitize_text_field( $i_value );
382
- }
383
- }
384
-
385
- $i++;
386
- }
387
- }
388
- break;
389
- case 'FILTER_CARTFLOWS_CHECKOUT_FIELDS':
390
- $count = 10;
391
- $ordered_fields = array();
392
- $billing_fields = array();
393
-
394
- if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
395
- $post_data = $_POST[ $key ];
396
-
397
- if ( 'wcf_field_order_billing' == $key ) {
398
-
399
- $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
400
-
401
- foreach ( $post_data as $index => $value ) {
402
-
403
- if ( isset( $billing_fields[ $value ] ) ) {
404
- $ordered_fields[ $value ] = $billing_fields[ $value ];
405
- $ordered_fields[ $value ]['priority'] = $count;
406
- $count += 10;
407
- }
408
- }
409
-
410
- $meta_value = $ordered_fields;
411
- }
412
-
413
- if ( 'wcf_field_order_shipping' == $key ) {
414
-
415
- $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
416
- foreach ( $post_data as $index => $value ) {
417
-
418
- if ( isset( $shipping_fields[ $value ] ) ) {
419
- $ordered_fields[ $value ] = $shipping_fields[ $value ];
420
- $ordered_fields[ $value ]['priority'] = $count;
421
- $count += 10;
422
- }
423
- }
424
- $meta_value = $ordered_fields;
425
- }
426
-
427
- if ( 'wcf_label_text_field_billing' == $key ) {
428
-
429
- $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
430
-
431
- if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
432
- echo 'con 1';
433
- $billing_fields = $get_ordered_billing_fields;
434
- } else {
435
- echo 'con 2';
436
- $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
437
- }
438
-
439
- foreach ( $post_data as $index => $value ) {
440
-
441
- if ( isset( $billing_fields[ $index ] ) ) {
442
- $ordered_fields[ $index ] = $billing_fields[ $index ];
443
- $ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) );
444
- }
445
- }
446
- $key = 'wcf_field_order_billing';
447
- $meta_value = $ordered_fields;
448
- }
449
-
450
- if ( 'wcf_label_text_field_shipping' == $key ) {
451
-
452
- $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
453
-
454
- if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
455
- $shipping_fields = $get_ordered_shipping_fields;
456
- } else {
457
- $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
458
- }
459
-
460
- foreach ( $post_data as $index => $value ) {
461
-
462
- if ( isset( $shipping_fields[ $index ] ) ) {
463
- $ordered_fields[ $index ] = $shipping_fields[ $index ];
464
- $ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) );
465
- }
466
- }
467
- $key = 'wcf_field_order_shipping';
468
- $meta_value = $ordered_fields;
469
- }
470
-
471
- if ( 'wcf_label_placeholder_field_billing' == $key ) {
472
- $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
473
-
474
- if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
475
- $billing_fields = $get_ordered_billing_fields;
476
- } else {
477
- $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
478
- }
479
- foreach ( $post_data as $index => $value ) {
480
-
481
- if ( isset( $billing_fields[ $index ] ) ) {
482
- $ordered_fields[ $index ] = $billing_fields[ $index ];
483
- $ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) );
484
- }
485
- }
486
-
487
- $key = 'wcf_field_order_billing';
488
- $meta_value = $ordered_fields;
489
- }
490
-
491
- if ( 'wcf_label_placeholder_field_shipping' == $key ) {
492
- $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
493
-
494
- if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
495
- $shipping_fields = $get_ordered_shipping_fields;
496
- } else {
497
- $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
498
- }
499
-
500
- foreach ( $post_data as $index => $value ) {
501
-
502
- if ( isset( $shipping_fields[ $index ] ) ) {
503
- $ordered_fields[ $index ] = $shipping_fields[ $index ];
504
- $ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) );
505
- }
506
- }
507
-
508
- $key = 'wcf_field_order_shipping';
509
- $meta_value = $ordered_fields;
510
-
511
- }
512
-
513
- if ( 'wcf_label_default_field_billing' == $key ) {
514
-
515
- $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
516
-
517
- if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
518
- $billing_fields = $get_ordered_billing_fields;
519
- } else {
520
- $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
521
- }
522
-
523
- foreach ( $post_data as $index => $value ) {
524
-
525
- if ( isset( $billing_fields[ $index ] ) ) {
526
- $ordered_fields[ $index ] = $billing_fields[ $index ];
527
- $ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) );
528
- }
529
- }
530
-
531
- $key = 'wcf_field_order_billing';
532
- $meta_value = $ordered_fields;
533
- }
534
-
535
- if ( 'wcf_label_default_field_shipping' == $key ) {
536
-
537
- $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
538
-
539
- if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
540
- $shipping_fields = $get_ordered_shipping_fields;
541
- } else {
542
- $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
543
- }
544
-
545
- foreach ( $post_data as $index => $value ) {
546
-
547
- if ( isset( $shipping_fields[ $index ] ) ) {
548
- $ordered_fields[ $index ] = $shipping_fields[ $index ];
549
- $ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) );
550
- }
551
- }
552
-
553
- $key = 'wcf_field_order_shipping';
554
- $meta_value = $ordered_fields;
555
- }
556
-
557
- if ( 'wcf_is_required_field_billing' == $key ) {
558
-
559
- $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
560
-
561
- if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
562
- $billing_fields = $get_ordered_billing_fields;
563
- } else {
564
- $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
565
- }
566
-
567
- foreach ( $post_data as $index => $value ) {
568
-
569
- if ( isset( $billing_fields[ $index ] ) ) {
570
- $ordered_fields[ $index ] = $billing_fields[ $index ];
571
- if ( 'yes' == $value ) {
572
-
573
- $ordered_fields[ $index ]['required'] = true;
574
- } else {
575
- $ordered_fields[ $index ]['required'] = false;
576
- }
577
- }
578
- }
579
-
580
- $key = 'wcf_field_order_billing';
581
- $meta_value = $ordered_fields;
582
- }
583
-
584
- if ( 'wcf_is_required_field_shipping' == $key ) {
585
-
586
- $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
587
-
588
- if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
589
- $shipping_fields = $get_ordered_shipping_fields;
590
- } else {
591
- $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
592
- }
593
-
594
- foreach ( $post_data as $index => $value ) {
595
-
596
- if ( isset( $shipping_fields[ $index ] ) ) {
597
- $ordered_fields[ $index ] = $shipping_fields[ $index ];
598
-
599
- if ( 'yes' == $value ) {
600
-
601
- $ordered_fields[ $index ]['required'] = true;
602
- } else {
603
- $ordered_fields[ $index ]['required'] = false;
604
- }
605
- }
606
- }
607
-
608
- $key = 'wcf_field_order_shipping';
609
- $meta_value = $ordered_fields;
610
- }
611
-
612
- if ( 'wcf_select_option_field_billing' == $key ) {
613
-
614
- $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
615
-
616
- if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
617
- $billing_fields = $get_ordered_billing_fields;
618
- } else {
619
- $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
620
- }
621
-
622
- foreach ( $post_data as $index => $value ) {
623
-
624
- $options = explode( ',', $value );
625
-
626
- if ( isset( $billing_fields[ $index ] ) ) {
627
- $ordered_fields[ $index ] = $billing_fields[ $index ];
628
-
629
- $ordered_fields[ $index ]['options'] = array();
630
-
631
- foreach ( $options as $key => $option ) {
632
-
633
- $ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) );
634
- }
635
- }
636
- }
637
-
638
- $key = 'wcf_field_order_billing';
639
- $meta_value = $ordered_fields;
640
- }
641
-
642
- if ( 'wcf_select_option_field_shipping' == $key ) {
643
-
644
- $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
645
-
646
- if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
647
- $shipping_fields = $get_ordered_shipping_fields;
648
- } else {
649
- $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
650
- }
651
-
652
- foreach ( $post_data as $index => $value ) {
653
-
654
- $options = explode( ',', $value );
655
-
656
- if ( isset( $shipping_fields[ $index ] ) ) {
657
-
658
- $ordered_fields[ $index ] = $shipping_fields[ $index ];
659
-
660
- $ordered_fields[ $index ]['options'] = array();
661
-
662
- foreach ( $options as $key => $option ) {
663
-
664
- $ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) );
665
- }
666
- }
667
- }
668
-
669
- $key = 'wcf_field_order_shipping';
670
- $meta_value = $ordered_fields;
671
- }
672
- }
673
- break;
674
-
675
- default:
676
- $meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT );
677
- break;
678
- }
679
-
680
- if ( false !== $meta_value ) {
681
- update_post_meta( $post_id, $key, $meta_value );
682
- } else {
683
- delete_post_meta( $post_id, $key );
684
- }
685
- }
686
- }
687
-
688
- /**
689
- * Get checkout meta.
690
- *
691
- * @param int $post_id post id.
692
- * @param string $key options key.
693
- * @param mix $default options default value.
694
- * @return string
695
- */
696
- function get_flow_meta_value( $post_id, $key, $default = false ) {
697
-
698
- $value = $this->get_save_meta( $post_id, $key );
699
-
700
- if ( ! $value ) {
701
-
702
- if ( $default ) {
703
-
704
- $value = $default;
705
- } else {
706
-
707
- $fields = $this->get_flow_fields( $post_id );
708
-
709
- if ( isset( $fields[ $key ]['default'] ) ) {
710
-
711
- $value = $fields[ $key ]['default'];
712
- }
713
- }
714
- }
715
-
716
- return $value;
717
- }
718
-
719
- /**
720
- * Get checkout meta.
721
- *
722
- * @param int $post_id post id.
723
- * @param string $key options key.
724
- * @param mix $default options default value.
725
- * @return string
726
- */
727
- function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) {
728
-
729
- $value = $this->get_save_meta( $post_id, $key );
730
-
731
- if ( ! $value ) {
732
-
733
- if ( false !== $default ) {
734
-
735
- $value = $default;
736
- } else {
737
-
738
- $fields = $this->get_checkout_fields( $post_id );
739
-
740
- if ( isset( $fields[ $key ]['default'] ) ) {
741
-
742
- $value = $fields[ $key ]['default'];
743
- }
744
- }
745
- }
746
-
747
- return $value;
748
- }
749
-
750
- /**
751
- * Get post meta.
752
- *
753
- * @param int $post_id post id.
754
- * @param string $key options key.
755
- * @return string
756
- */
757
- function get_save_meta( $post_id, $key ) {
758
-
759
- $value = get_post_meta( $post_id, $key, true );
760
-
761
- return $value;
762
- }
763
-
764
- /**
765
- * Thank You Default fields.
766
- *
767
- * @param int $post_id post id.
768
- * @return array
769
- */
770
- function get_thankyou_fields( $post_id ) {
771
-
772
- if ( null === self::$thankyou_fields ) {
773
-
774
- self::$thankyou_fields = array(
775
- 'wcf-field-google-font-url' => array(
776
- 'default' => '',
777
- 'sanitize' => 'FILTER_DEFAULT',
778
- ),
779
- 'wcf-active-tab' => array(
780
- 'default' => '',
781
- 'sanitize' => 'FILTER_DEFAULT',
782
- ),
783
- 'wcf-tq-text-color' => array(
784
- 'default' => '',
785
- 'sanitize' => 'FILTER_DEFAULT',
786
- ),
787
- 'wcf-tq-font-family' => array(
788
- 'default' => '',
789
- 'sanitize' => 'FILTER_DEFAULT',
790
- ),
791
- 'wcf-tq-heading-color' => array(
792
- 'default' => '',
793
- 'sanitize' => 'FILTER_DEFAULT',
794
- ),
795
- 'wcf-tq-heading-font-family' => array(
796
- 'default' => '',
797
- 'sanitize' => 'FILTER_DEFAULT',
798
- ),
799
- 'wcf-tq-heading-font-wt' => array(
800
- 'default' => '',
801
- 'sanitize' => 'FILTER_DEFAULT',
802
- ),
803
- 'wcf-tq-container-width' => array(
804
- 'default' => '',
805
- 'sanitize' => 'FILTER_DEFAULT',
806
- ),
807
- 'wcf-tq-section-bg-color' => array(
808
- 'default' => '',
809
- 'sanitize' => 'FILTER_DEFAULT',
810
- ),
811
- 'wcf-tq-advance-options-fields' => array(
812
- 'default' => '',
813
- 'sanitize' => 'FILTER_DEFAULT',
814
- ),
815
- 'wcf-show-overview-section' => array(
816
- 'default' => 'yes',
817
- 'sanitize' => 'FILTER_DEFAULT',
818
- ),
819
- 'wcf-show-details-section' => array(
820
- 'default' => 'yes',
821
- 'sanitize' => 'FILTER_DEFAULT',
822
- ),
823
- 'wcf-show-billing-section' => array(
824
- 'default' => 'yes',
825
- 'sanitize' => 'FILTER_DEFAULT',
826
- ),
827
- 'wcf-show-shipping-section' => array(
828
- 'default' => 'yes',
829
- 'sanitize' => 'FILTER_DEFAULT',
830
- ),
831
- 'wcf-custom-script' => array(
832
- 'default' => '',
833
- 'sanitize' => 'FILTER_DEFAULT',
834
- ),
835
- );
836
-
837
- }
838
-
839
- return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id );
840
- }
841
-
842
- /**
843
- * Get Thank you section meta.
844
- *
845
- * @param int $post_id post id.
846
- * @param string $key options key.
847
- * @param mix $default options default value.
848
- * @return string
849
- */
850
- function get_thankyou_meta_value( $post_id, $key, $default = false ) {
851
-
852
- $value = $this->get_save_meta( $post_id, $key );
853
-
854
- if ( ! $value ) {
855
-
856
- if ( $default ) {
857
-
858
- $value = $default;
859
- } else {
860
-
861
- $fields = $this->get_thankyou_fields( $post_id );
862
-
863
- if ( isset( $fields[ $key ]['default'] ) ) {
864
-
865
- $value = $fields[ $key ]['default'];
866
- }
867
- }
868
- }
869
-
870
- return $value;
871
- }
872
-
873
- /**
874
- * Get Landing section meta.
875
- *
876
- * @param int $post_id post id.
877
- * @param string $key options key.
878
- * @param mix $default options default value.
879
- * @return string
880
- */
881
- function get_landing_meta_value( $post_id, $key, $default = false ) {
882
-
883
- $value = $this->get_save_meta( $post_id, $key );
884
- if ( ! $value ) {
885
-
886
- if ( $default ) {
887
-
888
- $value = $default;
889
- } else {
890
-
891
- $fields = $this->get_landing_fields( $post_id );
892
-
893
- if ( isset( $fields[ $key ]['default'] ) ) {
894
- $value = $fields[ $key ]['default'];
895
- }
896
- }
897
- }
898
-
899
- return $value;
900
- }
901
-
902
- /**
903
- * Thank You Default fields.
904
- *
905
- * @param int $post_id post id.
906
- * @return array
907
- */
908
- function get_landing_fields( $post_id ) {
909
-
910
- if ( null === self::$landing_fields ) {
911
-
912
- self::$landing_fields = array(
913
- 'wcf-custom-script' => array(
914
- 'default' => '',
915
- 'sanitize' => 'FILTER_DEFAULT',
916
- ),
917
- );
918
- }
919
- return apply_filters( 'cartflows_landing_meta_options', self::$landing_fields, $post_id );
920
- }
921
- }
922
-
923
- /**
924
- * Kicking this off by calling 'get_instance()' method
925
- */
926
- Cartflows_Default_Meta::get_instance();
1
+ <?php
2
+ /**
3
+ * Cartflow default options.
4
+ *
5
+ * @package Cartflows
6
+ */
7
+
8
+ /**
9
+ * Initialization
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Default_Meta {
14
+
15
+
16
+ /**
17
+ * Member Variable
18
+ *
19
+ * @var instance
20
+ */
21
+ private static $instance;
22
+
23
+ /**
24
+ * Member Variable
25
+ *
26
+ * @var checkout_fields
27
+ */
28
+ private static $checkout_fields = null;
29
+
30
+ /**
31
+ * Member Variable
32
+ *
33
+ * @var checkout_fields
34
+ */
35
+ private static $thankyou_fields = null;
36
+
37
+ /**
38
+ * Member Variable
39
+ *
40
+ * @var flow_fields
41
+ */
42
+ private static $flow_fields = null;
43
+
44
+ /**
45
+ * Member Variable
46
+ *
47
+ * @var landing_fields
48
+ */
49
+ private static $landing_fields = null;
50
+
51
+ /**
52
+ * Initiator
53
+ */
54
+ public static function get_instance() {
55
+ if ( ! isset( self::$instance ) ) {
56
+ self::$instance = new self;
57
+ }
58
+ return self::$instance;
59
+ }
60
+
61
+ /**
62
+ * Constructor
63
+ */
64
+ public function __construct() {
65
+
66
+ }
67
+
68
+ /**
69
+ * Checkout Default fields.
70
+ *
71
+ * @param int $post_id post id.
72
+ * @return array
73
+ */
74
+ function get_checkout_fields( $post_id ) {
75
+
76
+ if ( null === self::$checkout_fields ) {
77
+
78
+ self::$checkout_fields = array(
79
+ 'wcf-field-google-font-url' => array(
80
+ 'default' => '',
81
+ 'sanitize' => 'FILTER_DEFAULT',
82
+ ),
83
+ 'wcf-checkout-products' => array(
84
+ 'default' => array(),
85
+ 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS',
86
+ ),
87
+ 'wcf-checkout-layout' => array(
88
+ 'default' => 'two-column',
89
+ 'sanitize' => 'FILTER_DEFAULT',
90
+ ),
91
+ 'wcf-input-font-family' => array(
92
+ 'default' => '',
93
+ 'sanitize' => 'FILTER_DEFAULT',
94
+ ),
95
+ 'wcf-input-font-weight' => array(
96
+ 'default' => '',
97
+ 'sanitize' => 'FILTER_DEFAULT',
98
+ ),
99
+ 'wcf-heading-font-family' => array(
100
+ 'default' => '',
101
+ 'sanitize' => 'FILTER_DEFAULT',
102
+ ),
103
+ 'wcf-heading-font-weight' => array(
104
+ 'default' => '',
105
+ 'sanitize' => 'FILTER_DEFAULT',
106
+ ),
107
+ 'wcf-base-font-family' => array(
108
+ 'default' => '',
109
+ 'sanitize' => 'FILTER_DEFAULT',
110
+ ),
111
+ 'wcf-advance-options-fields' => array(
112
+ 'default' => '',
113
+ 'sanitize' => 'FILTER_DEFAULT',
114
+ ),
115
+ 'wcf-base-font-weight' => array(
116
+ 'default' => '',
117
+ 'sanitize' => 'FILTER_DEFAULT',
118
+ ),
119
+ 'wcf-button-font-family' => array(
120
+ 'default' => '',
121
+ 'sanitize' => 'FILTER_DEFAULT',
122
+ ),
123
+ 'wcf-button-font-weight' => array(
124
+ 'default' => '',
125
+ 'sanitize' => 'FILTER_DEFAULT',
126
+ ),
127
+ 'wcf-primary-color' => array(
128
+ 'default' => '',
129
+ 'sanitize' => 'FILTER_DEFAULT',
130
+ ),
131
+ 'wcf-heading-color' => array(
132
+ 'default' => '',
133
+ 'sanitize' => 'FILTER_DEFAULT',
134
+ ),
135
+ 'wcf-section-bg-color' => array(
136
+ 'default' => '',
137
+ 'sanitize' => 'FILTER_DEFAULT',
138
+ ),
139
+ 'wcf-hl-bg-color' => array(
140
+ 'default' => '',
141
+ 'sanitize' => 'FILTER_DEFAULT',
142
+ ),
143
+ 'wcf-field-tb-padding' => array(
144
+ 'default' => '',
145
+ 'sanitize' => 'FILTER_DEFAULT',
146
+ ),
147
+ 'wcf-field-lr-padding' => array(
148
+ 'default' => '',
149
+ 'sanitize' => 'FILTER_DEFAULT',
150
+ ),
151
+ 'wcf-fields-skins' => array(
152
+ 'default' => '',
153
+ 'sanitize' => 'FILTER_DEFAULT',
154
+ ),
155
+ 'wcf-input-field-size' => array(
156
+ 'default' => '33px',
157
+ 'sanitize' => 'FILTER_DEFAULT',
158
+ ),
159
+ 'wcf-field-color' => array(
160
+ 'default' => '',
161
+ 'sanitize' => 'FILTER_DEFAULT',
162
+ ),
163
+ 'wcf-field-bg-color' => array(
164
+ 'default' => '',
165
+ 'sanitize' => 'FILTER_DEFAULT',
166
+ ),
167
+ 'wcf-field-border-color' => array(
168
+ 'default' => '',
169
+ 'sanitize' => 'FILTER_DEFAULT',
170
+ ),
171
+ 'wcf-box-border-color' => array(
172
+ 'default' => '',
173
+ 'sanitize' => 'FILTER_DEFAULT',
174
+ ),
175
+ 'wcf-field-label-color' => array(
176
+ 'default' => '',
177
+ 'sanitize' => 'FILTER_DEFAULT',
178
+ ),
179
+ 'wcf-submit-tb-padding' => array(
180
+ 'default' => '',
181
+ 'sanitize' => 'FILTER_DEFAULT',
182
+ ),
183
+ 'wcf-submit-lr-padding' => array(
184
+ 'default' => '',
185
+ 'sanitize' => 'FILTER_DEFAULT',
186
+ ),
187
+ 'wcf-input-button-size' => array(
188
+ 'default' => '33px',
189
+ 'sanitize' => 'FILTER_DEFAULT',
190
+ ),
191
+ 'wcf-submit-color' => array(
192
+ 'default' => '',
193
+ 'sanitize' => 'FILTER_DEFAULT',
194
+ ),
195
+ 'wcf-submit-hover-color' => array(
196
+ 'default' => '',
197
+ 'sanitize' => 'FILTER_DEFAULT',
198
+ ),
199
+ 'wcf-submit-bg-color' => array(
200
+ 'default' => '',
201
+ 'sanitize' => 'FILTER_DEFAULT',
202
+ ),
203
+ 'wcf-submit-bg-hover-color' => array(
204
+ 'default' => '',
205
+ 'sanitize' => 'FILTER_DEFAULT',
206
+ ),
207
+ 'wcf-submit-border-color' => array(
208
+ 'default' => '',
209
+ 'sanitize' => 'FILTER_DEFAULT',
210
+ ),
211
+ 'wcf-submit-border-hover-color' => array(
212
+ 'default' => '',
213
+ 'sanitize' => 'FILTER_DEFAULT',
214
+ ),
215
+ 'wcf-active-tab' => array(
216
+ 'default' => '',
217
+ 'sanitize' => 'FILTER_DEFAULT',
218
+ ),
219
+ 'wcf-header-logo-image' => array(
220
+ 'default' => '',
221
+ 'sanitize' => 'FILTER_DEFAULT',
222
+ ),
223
+ 'wcf-header-logo-width' => array(
224
+ 'default' => '',
225
+ 'sanitize' => 'FILTER_DEFAULT',
226
+ ),
227
+ 'wcf-custom-script' => array(
228
+ 'default' => '',
229
+ 'sanitize' => 'FILTER_DEFAULT',
230
+ ),
231
+ );
232
+
233
+ self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id );
234
+ }
235
+
236
+ return self::$checkout_fields;
237
+ }
238
+
239
+ /**
240
+ * Save Checkout Meta fields.
241
+ *
242
+ * @param int $post_id post id.
243
+ * @return void
244
+ */
245
+ function save_checkout_fields( $post_id ) {
246
+
247
+ $post_meta = $this->get_checkout_fields( $post_id );
248
+
249
+ $this->save_meta_fields( $post_id, $post_meta );
250
+ }
251
+
252
+ /**
253
+ * Save Landing Meta fields.
254
+ *
255
+ * @param int $post_id post id.
256
+ * @return void
257
+ */
258
+ function save_landing_fields( $post_id ) {
259
+
260
+ $post_meta = $this->get_landing_fields( $post_id );
261
+
262
+ $this->save_meta_fields( $post_id, $post_meta );
263
+ }
264
+
265
+ /**
266
+ * Save ThankYou Meta fields.
267
+ *
268
+ * @param int $post_id post id.
269
+ * @return void
270
+ */
271
+ function save_thankyou_fields( $post_id ) {
272
+
273
+ $post_meta = $this->get_thankyou_fields( $post_id );
274
+
275
+ $this->save_meta_fields( $post_id, $post_meta );
276
+ }
277
+
278
+ /**
279
+ * Flow Default fields.
280
+ *
281
+ * @param int $post_id post id.
282
+ * @return array
283
+ */
284
+ function get_flow_fields( $post_id ) {
285
+
286
+ if ( null === self::$flow_fields ) {
287
+
288
+ self::$flow_fields = array(
289
+ 'wcf-steps' => array(
290
+ 'default' => array(),
291
+ 'sanitize' => 'FILTER_DEFAULT',
292
+ ),
293
+
294
+ 'wcf-testing' => array(
295
+ 'default' => 'yes',
296
+ 'sanitize' => 'FILTER_DEFAULT',
297
+ ),
298
+ );
299
+ }
300
+
301
+ return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields );
302
+ }
303
+
304
+ /**
305
+ * Save Flow Meta fields.
306
+ *
307
+ * @param int $post_id post id.
308
+ * @return void
309
+ */
310
+ function save_flow_fields( $post_id ) {
311
+
312
+ $post_meta = $this->get_flow_fields( $post_id );
313
+
314
+ if ( isset( $post_meta['wcf-steps'] ) ) {
315
+ unset( $post_meta['wcf-steps'] );
316
+ }
317
+
318
+ $this->save_meta_fields( $post_id, $post_meta );
319
+ }
320
+
321
+ /**
322
+ * Save Meta fields - Common Function.
323
+ *
324
+ * @param int $post_id post id.
325
+ * @param array $post_meta options to store.
326
+ * @return void
327
+ */
328
+ function save_meta_fields( $post_id, $post_meta ) {
329
+
330
+ if ( ! ( $post_id && is_array( $post_meta ) ) ) {
331
+
332
+ return;
333
+ }
334
+
335
+ foreach ( $post_meta as $key => $data ) {
336
+
337
+ $meta_value = false;
338
+
339
+ // Sanitize values.
340
+ $sanitize_filter = ( isset( $data['sanitize'] ) ) ? $data['sanitize'] : 'FILTER_DEFAULT';
341
+
342
+ switch ( $sanitize_filter ) {
343
+
344
+ case 'FILTER_SANITIZE_STRING':
345
+ $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING );
346
+ break;
347
+
348
+ case 'FILTER_SANITIZE_URL':
349
+ $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_URL );
350
+ break;
351
+
352
+ case 'FILTER_SANITIZE_NUMBER_INT':
353
+ $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT );
354
+ break;
355
+
356
+ case 'FILTER_CARTFLOWS_ARRAY':
357
+ if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
358
+ $meta_value = array_map( 'sanitize_text_field', $_POST[ $key ] );
359
+ }
360
+ break;
361
+
362
+ case 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS':
363
+ if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
364
+
365
+ $i = 0;
366
+ $q = 0;
367
+
368
+ foreach ( $_POST[ $key ] as $p_index => $p_data ) {
369
+
370
+ foreach ( $p_data as $i_key => $i_value ) {
371
+
372
+ if ( is_array( $i_value ) ) {
373
+
374
+ foreach ( $i_value as $q_key => $q_value ) {
375
+
376
+ $meta_value[ $i ][ $i_key ][ $q ] = array_map( 'sanitize_text_field', $q_value );
377
+
378
+ $q++;
379
+ }
380
+ } else {
381
+ $meta_value[ $i ][ $i_key ] = sanitize_text_field( $i_value );
382
+ }
383
+ }
384
+
385
+ $i++;
386
+ }
387
+ }
388
+ break;
389
+ case 'FILTER_CARTFLOWS_CHECKOUT_FIELDS':
390
+ $count = 10;
391
+ $ordered_fields = array();
392
+ $billing_fields = array();
393
+
394
+ if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
395
+ $post_data = $_POST[ $key ];
396
+
397
+ if ( 'wcf_field_order_billing' == $key ) {
398
+
399
+ $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
400
+
401
+ foreach ( $post_data as $index => $value ) {
402
+
403
+ if ( isset( $billing_fields[ $value ] ) ) {
404
+ $ordered_fields[ $value ] = $billing_fields[ $value ];
405
+ $ordered_fields[ $value ]['priority'] = $count;
406
+ $count += 10;
407
+ }
408
+ }
409
+
410
+ $meta_value = $ordered_fields;
411
+ }
412
+
413
+ if ( 'wcf_field_order_shipping' == $key ) {
414
+
415
+ $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
416
+ foreach ( $post_data as $index => $value ) {
417
+
418
+ if ( isset( $shipping_fields[ $value ] ) ) {
419
+ $ordered_fields[ $value ] = $shipping_fields[ $value ];
420
+ $ordered_fields[ $value ]['priority'] = $count;
421
+ $count += 10;
422
+ }
423
+ }
424
+ $meta_value = $ordered_fields;
425
+ }
426
+
427
+ if ( 'wcf_label_text_field_billing' == $key ) {
428
+
429
+ $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
430
+
431
+ if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
432
+ echo 'con 1';
433
+ $billing_fields = $get_ordered_billing_fields;
434
+ } else {
435
+ echo 'con 2';
436
+ $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
437
+ }
438
+
439
+ foreach ( $post_data as $index => $value ) {
440
+
441
+ if ( isset( $billing_fields[ $index ] ) ) {
442
+ $ordered_fields[ $index ] = $billing_fields[ $index ];
443
+ $ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) );
444
+ }
445
+ }
446
+ $key = 'wcf_field_order_billing';
447
+ $meta_value = $ordered_fields;
448
+ }
449
+
450
+ if ( 'wcf_label_text_field_shipping' == $key ) {
451
+
452
+ $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
453
+
454
+ if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
455
+ $shipping_fields = $get_ordered_shipping_fields;
456
+ } else {
457
+ $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
458
+ }
459
+
460
+ foreach ( $post_data as $index => $value ) {
461
+
462
+ if ( isset( $shipping_fields[ $index ] ) ) {
463
+ $ordered_fields[ $index ] = $shipping_fields[ $index ];
464
+ $ordered_fields[ $index ]['label'] = wp_kses_post( trim( stripslashes( $value ) ) );
465
+ }
466
+ }
467
+ $key = 'wcf_field_order_shipping';
468
+ $meta_value = $ordered_fields;
469
+ }
470
+
471
+ if ( 'wcf_label_placeholder_field_billing' == $key ) {
472
+ $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
473
+
474
+ if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
475
+ $billing_fields = $get_ordered_billing_fields;
476
+ } else {
477
+ $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
478
+ }
479
+ foreach ( $post_data as $index => $value ) {
480
+
481
+ if ( isset( $billing_fields[ $index ] ) ) {
482
+ $ordered_fields[ $index ] = $billing_fields[ $index ];
483
+ $ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) );
484
+ }
485
+ }
486
+
487
+ $key = 'wcf_field_order_billing';
488
+ $meta_value = $ordered_fields;
489
+ }
490
+
491
+ if ( 'wcf_label_placeholder_field_shipping' == $key ) {
492
+ $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
493
+
494
+ if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
495
+ $shipping_fields = $get_ordered_shipping_fields;
496
+ } else {
497
+ $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
498
+ }
499
+
500
+ foreach ( $post_data as $index => $value ) {
501
+
502
+ if ( isset( $shipping_fields[ $index ] ) ) {
503
+ $ordered_fields[ $index ] = $shipping_fields[ $index ];
504
+ $ordered_fields[ $index ]['placeholder'] = wc_clean( stripslashes( $value ) );
505
+ }
506
+ }
507
+
508
+ $key = 'wcf_field_order_shipping';
509
+ $meta_value = $ordered_fields;
510
+
511
+ }
512
+
513
+ if ( 'wcf_label_default_field_billing' == $key ) {
514
+
515
+ $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
516
+
517
+ if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
518
+ $billing_fields = $get_ordered_billing_fields;
519
+ } else {
520
+ $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
521
+ }
522
+
523
+ foreach ( $post_data as $index => $value ) {
524
+
525
+ if ( isset( $billing_fields[ $index ] ) ) {
526
+ $ordered_fields[ $index ] = $billing_fields[ $index ];
527
+ $ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) );
528
+ }
529
+ }
530
+
531
+ $key = 'wcf_field_order_billing';
532
+ $meta_value = $ordered_fields;
533
+ }
534
+
535
+ if ( 'wcf_label_default_field_shipping' == $key ) {
536
+
537
+ $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
538
+
539
+ if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
540
+ $shipping_fields = $get_ordered_shipping_fields;
541
+ } else {
542
+ $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
543
+ }
544
+
545
+ foreach ( $post_data as $index => $value ) {
546
+
547
+ if ( isset( $shipping_fields[ $index ] ) ) {
548
+ $ordered_fields[ $index ] = $shipping_fields[ $index ];
549
+ $ordered_fields[ $index ]['default'] = wp_kses_post( trim( stripslashes( $value ) ) );
550
+ }
551
+ }
552
+
553
+ $key = 'wcf_field_order_shipping';
554
+ $meta_value = $ordered_fields;
555
+ }
556
+
557
+ if ( 'wcf_is_required_field_billing' == $key ) {
558
+
559
+ $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
560
+
561
+ if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
562
+ $billing_fields = $get_ordered_billing_fields;
563
+ } else {
564
+ $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
565
+ }
566
+
567
+ foreach ( $post_data as $index => $value ) {
568
+
569
+ if ( isset( $billing_fields[ $index ] ) ) {
570
+ $ordered_fields[ $index ] = $billing_fields[ $index ];
571
+ if ( 'yes' == $value ) {
572
+
573
+ $ordered_fields[ $index ]['required'] = true;
574
+ } else {
575
+ $ordered_fields[ $index ]['required'] = false;
576
+ }
577
+ }
578
+ }
579
+
580
+ $key = 'wcf_field_order_billing';
581
+ $meta_value = $ordered_fields;
582
+ }
583
+
584
+ if ( 'wcf_is_required_field_shipping' == $key ) {
585
+
586
+ $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
587
+
588
+ if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
589
+ $shipping_fields = $get_ordered_shipping_fields;
590
+ } else {
591
+ $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
592
+ }
593
+
594
+ foreach ( $post_data as $index => $value ) {
595
+
596
+ if ( isset( $shipping_fields[ $index ] ) ) {
597
+ $ordered_fields[ $index ] = $shipping_fields[ $index ];
598
+
599
+ if ( 'yes' == $value ) {
600
+
601
+ $ordered_fields[ $index ]['required'] = true;
602
+ } else {
603
+ $ordered_fields[ $index ]['required'] = false;
604
+ }
605
+ }
606
+ }
607
+
608
+ $key = 'wcf_field_order_shipping';
609
+ $meta_value = $ordered_fields;
610
+ }
611
+
612
+ if ( 'wcf_select_option_field_billing' == $key ) {
613
+
614
+ $get_ordered_billing_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_billing' );
615
+
616
+ if ( isset( $get_ordered_billing_fields ) && ! empty( $get_ordered_billing_fields ) ) {
617
+ $billing_fields = $get_ordered_billing_fields;
618
+ } else {
619
+ $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post_id );
620
+ }
621
+
622
+ foreach ( $post_data as $index => $value ) {
623
+
624
+ $options = explode( ',', $value );
625
+
626
+ if ( isset( $billing_fields[ $index ] ) ) {
627
+ $ordered_fields[ $index ] = $billing_fields[ $index ];
628
+
629
+ $ordered_fields[ $index ]['options'] = array();
630
+
631
+ foreach ( $options as $key => $option ) {
632
+
633
+ $ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) );
634
+ }
635
+ }
636
+ }
637
+
638
+ $key = 'wcf_field_order_billing';
639
+ $meta_value = $ordered_fields;
640
+ }
641
+
642
+ if ( 'wcf_select_option_field_shipping' == $key ) {
643
+
644
+ $get_ordered_shipping_fields = wcf()->options->get_checkout_meta_value( $post_id, 'wcf_field_order_shipping' );
645
+
646
+ if ( isset( $get_ordered_shipping_fields ) && ! empty( $get_ordered_shipping_fields ) ) {
647
+ $shipping_fields = $get_ordered_shipping_fields;
648
+ } else {
649
+ $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post_id );
650
+ }
651
+
652
+ foreach ( $post_data as $index => $value ) {
653
+
654
+ $options = explode( ',', $value );
655
+
656
+ if ( isset( $shipping_fields[ $index ] ) ) {
657
+
658
+ $ordered_fields[ $index ] = $shipping_fields[ $index ];
659
+
660
+ $ordered_fields[ $index ]['options'] = array();
661
+
662
+ foreach ( $options as $key => $option ) {
663
+
664
+ $ordered_fields[ $index ]['options'][ $option ] = trim( stripslashes( $option ) );
665
+ }
666
+ }
667
+ }
668
+
669
+ $key = 'wcf_field_order_shipping';
670
+ $meta_value = $ordered_fields;
671
+ }
672
+ }
673
+ break;
674
+
675
+ default:
676
+ $meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT );
677
+ break;
678
+ }
679
+
680
+ if ( false !== $meta_value ) {
681
+ update_post_meta( $post_id, $key, $meta_value );
682
+ } else {
683
+ delete_post_meta( $post_id, $key );
684
+ }
685
+ }
686
+ }
687
+
688
+ /**
689
+ * Get checkout meta.
690
+ *
691
+ * @param int $post_id post id.
692
+ * @param string $key options key.
693
+ * @param mix $default options default value.
694
+ * @return string
695
+ */
696
+ function get_flow_meta_value( $post_id, $key, $default = false ) {
697
+
698
+ $value = $this->get_save_meta( $post_id, $key );
699
+
700
+ if ( ! $value ) {
701
+
702
+ if ( $default ) {
703
+
704
+ $value = $default;
705
+ } else {
706
+
707
+ $fields = $this->get_flow_fields( $post_id );
708
+
709
+ if ( isset( $fields[ $key ]['default'] ) ) {
710
+
711
+ $value = $fields[ $key ]['default'];
712
+ }
713
+ }
714
+ }
715
+
716
+ return $value;
717
+ }
718
+
719
+ /**
720
+ * Get checkout meta.
721
+ *
722
+ * @param int $post_id post id.
723
+ * @param string $key options key.
724
+ * @param mix $default options default value.
725
+ * @return string
726
+ */
727
+ function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) {
728
+
729
+ $value = $this->get_save_meta( $post_id, $key );
730
+
731
+ if ( ! $value ) {
732
+
733
+ if ( false !== $default ) {
734
+
735
+ $value = $default;
736
+ } else {
737
+
738
+ $fields = $this->get_checkout_fields( $post_id );
739
+
740
+ if ( isset( $fields[ $key ]['default'] ) ) {
741
+
742
+ $value = $fields[ $key ]['default'];
743
+ }
744
+ }
745
+ }
746
+
747
+ return $value;
748
+ }
749
+
750
+ /**
751
+ * Get post meta.
752
+ *
753
+ * @param int $post_id post id.
754
+ * @param string $key options key.
755
+ * @return string
756
+ */
757
+ function get_save_meta( $post_id, $key ) {
758
+
759
+ $value = get_post_meta( $post_id, $key, true );
760
+
761
+ return $value;
762
+ }
763
+
764
+ /**
765
+ * Thank You Default fields.
766
+ *
767
+ * @param int $post_id post id.
768
+ * @return array
769
+ */
770
+ function get_thankyou_fields( $post_id ) {
771
+
772
+ if ( null === self::$thankyou_fields ) {
773
+
774
+ self::$thankyou_fields = array(
775
+ 'wcf-field-google-font-url' => array(
776
+ 'default' => '',
777
+ 'sanitize' => 'FILTER_DEFAULT',
778
+ ),
779
+ 'wcf-active-tab' => array(
780
+ 'default' => '',
781
+ 'sanitize' => 'FILTER_DEFAULT',
782
+ ),
783
+ 'wcf-tq-text-color' => array(
784
+ 'default' => '',
785
+ 'sanitize' => 'FILTER_DEFAULT',
786
+ ),
787
+ 'wcf-tq-font-family' => array(
788
+ 'default' => '',
789
+ 'sanitize' => 'FILTER_DEFAULT',
790
+ ),
791
+ 'wcf-tq-heading-color' => array(
792
+ 'default' => '',
793
+ 'sanitize' => 'FILTER_DEFAULT',
794
+ ),
795
+ 'wcf-tq-heading-font-family' => array(
796
+ 'default' => '',
797
+ 'sanitize' => 'FILTER_DEFAULT',
798
+ ),
799
+ 'wcf-tq-heading-font-wt' => array(
800
+ 'default' => '',
801
+ 'sanitize' => 'FILTER_DEFAULT',
802
+ ),
803
+ 'wcf-tq-container-width' => array(
804
+ 'default' => '',
805
+ 'sanitize' => 'FILTER_DEFAULT',
806
+ ),
807
+ 'wcf-tq-section-bg-color' => array(
808
+ 'default' => '',
809
+ 'sanitize' => 'FILTER_DEFAULT',
810
+ ),
811
+ 'wcf-tq-advance-options-fields' => array(
812
+ 'default' => '',
813
+ 'sanitize' => 'FILTER_DEFAULT',
814
+ ),
815
+ 'wcf-show-overview-section' => array(
816
+ 'default' => 'yes',
817
+ 'sanitize' => 'FILTER_DEFAULT',
818
+ ),
819
+ 'wcf-show-details-section' => array(
820
+ 'default' => 'yes',
821
+ 'sanitize' => 'FILTER_DEFAULT',
822
+ ),
823
+ 'wcf-show-billing-section' => array(
824
+ 'default' => 'yes',
825
+ 'sanitize' => 'FILTER_DEFAULT',
826
+ ),
827
+ 'wcf-show-shipping-section' => array(
828
+ 'default' => 'yes',
829
+ 'sanitize' => 'FILTER_DEFAULT',
830
+ ),
831
+ 'wcf-custom-script' => array(
832
+ 'default' => '',
833
+ 'sanitize' => 'FILTER_DEFAULT',
834
+ ),
835
+ );
836
+
837
+ }
838
+
839
+ return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id );
840
+ }
841
+
842
+ /**
843
+ * Get Thank you section meta.
844
+ *
845
+ * @param int $post_id post id.
846
+ * @param string $key options key.
847
+ * @param mix $default options default value.
848
+ * @return string
849
+ */
850
+ function get_thankyou_meta_value( $post_id, $key, $default = false ) {
851
+
852
+ $value = $this->get_save_meta( $post_id, $key );
853
+
854
+ if ( ! $value ) {
855
+
856
+ if ( $default ) {
857
+
858
+ $value = $default;
859
+ } else {
860
+
861
+ $fields = $this->get_thankyou_fields( $post_id );
862
+
863
+ if ( isset( $fields[ $key ]['default'] ) ) {
864
+
865
+ $value = $fields[ $key ]['default'];
866
+ }
867
+ }
868
+ }
869
+
870
+ return $value;
871
+ }
872
+
873
+ /**
874
+ * Get Landing section meta.
875
+ *
876
+ * @param int $post_id post id.
877
+ * @param string $key options key.
878
+ * @param mix $default options default value.
879
+ * @return string
880
+ */
881
+ function get_landing_meta_value( $post_id, $key, $default = false ) {
882
+
883
+ $value = $this->get_save_meta( $post_id, $key );
884
+ if ( ! $value ) {
885
+
886
+ if ( $default ) {
887
+
888
+ $value = $default;
889
+ } else {
890
+
891
+ $fields = $this->get_landing_fields( $post_id );
892
+
893
+ if ( isset( $fields[ $key ]['default'] ) ) {
894
+ $value = $fields[ $key ]['default'];
895
+ }
896
+ }
897
+ }
898
+
899
+ return $value;
900
+ }
901
+
902
+ /**
903
+ * Thank You Default fields.
904
+ *
905
+ * @param int $post_id post id.
906
+ * @return array
907
+ */
908
+ function get_landing_fields( $post_id ) {
909
+
910
+ if ( null === self::$landing_fields ) {
911
+
912
+ self::$landing_fields = array(
913
+ 'wcf-custom-script' => array(
914
+ 'default' => '',
915
+ 'sanitize' => 'FILTER_DEFAULT',
916
+ ),
917
+ );
918
+ }
919
+ return apply_filters( 'cartflows_landing_meta_options', self::$landing_fields, $post_id );
920
+ }
921
+ }
922
+
923
+ /**
924
+ * Kicking this off by calling 'get_instance()' method
925
+ */
926
+ Cartflows_Default_Meta::get_instance();
classes/class-cartflows-frontend.php CHANGED
@@ -1,466 +1,466 @@
1
- <?php
2
- /**
3
- * CartFlows Frontend.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Class Cartflows_Frontend.
10
- */
11
- class Cartflows_Frontend {
12
-
13
- /**
14
- * Member Variable
15
- *
16
- * @var instance
17
- */
18
- private static $instance;
19
-
20
- /**
21
- * Initiator
22
- */
23
- public static function get_instance() {
24
- if ( ! isset( self::$instance ) ) {
25
- self::$instance = new self;
26
- }
27
- return self::$instance;
28
- }
29
-
30
- /**
31
- * Constructor
32
- */
33
- public function __construct() {
34
-
35
- /* Set / Destroy Flow Sessions. Set data */
36
- add_action( 'wp', array( $this, 'init_actions' ), 1 );
37
-
38
- add_action( 'init', array( $this, 'debug_data_setting_actions' ) );
39
- /* Enqueue global required scripts */
40
- add_action( 'wp', array( $this, 'wp_actions' ), 55 );
41
-
42
- /* Modify the checkout order received url to go thank you page in our flow */
43
- add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 );
44
-
45
- }
46
-
47
- /**
48
- * Redirect to thank page if upsell not exists
49
- *
50
- * @param string $order_recieve_url url.
51
- * @param object $order order object.
52
- * @since 1.0.0
53
- */
54
- function redirect_to_thankyou_page( $order_recieve_url, $order ) {
55
-
56
- /* Only for thank you page */
57
- wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ );
58
- wcf()->logger->log( 'Only for thank you page' );
59
-
60
- if ( wcf()->flow->is_thankyou_page_exists( $order ) ) {
61
-
62
- if ( _is_wcf_doing_checkout_ajax() ) {
63
-
64
- $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
65
-
66
- if ( ! $checkout_id ) {
67
- $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
68
- }
69
- } else {
70
- $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
71
- }
72
-
73
- wcf()->logger->log( 'Checkout ID : ' . $checkout_id );
74
-
75
- if ( $checkout_id ) {
76
-
77
- $thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order );
78
-
79
- if ( $thankyou_step_id ) {
80
-
81
- $order_recieve_url = get_permalink( $thankyou_step_id );
82
-
83
- $order_recieve_url = add_query_arg(
84
- array(
85
- 'wcf-key' => $order->get_order_key(),
86
- 'wcf-order' => $order->get_id(),
87
- ),
88
- $order_recieve_url
89
- );
90
- }
91
- }
92
- }
93
-
94
- wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ );
95
-
96
- return $order_recieve_url;
97
- }
98
-
99
- /**
100
- * Cancel and redirect to checkout
101
- *
102
- * @param string $return_url url.
103
- * @since 1.0.0
104
- */
105
- function redirect_to_checkout_on_cancel( $return_url ) {
106
-
107
- if ( _is_wcf_doing_checkout_ajax() ) {
108
-
109
- $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
110
-
111
- if ( ! $checkout_id ) {
112
- $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
113
- }
114
- } else {
115
- $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
116
- }
117
-
118
- if ( $checkout_id ) {
119
-
120
- $return_url = add_query_arg(
121
- array(
122
- 'cancel_order' => 'true',
123
- '_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
124
- ),
125
- get_permalink( $checkout_id )
126
- );
127
- }
128
-
129
- return $return_url;
130
- }
131
-
132
-
133
- /**
134
- * Remove theme styles.
135
- *
136
- * @since 1.0.0
137
- */
138
- function remove_theme_styles() {
139
-
140
- if ( Cartflows_Compatibility::get_instance()->is_compatibility_theme_enabled() ) {
141
- return;
142
- }
143
-
144
- // get all styles data.
145
- global $wp_styles;
146
- global $wp_scripts;
147
-
148
- $get_stylesheet = 'themes/' . get_stylesheet() . '/';
149
- $get_template = 'themes/' . get_template() . '/';
150
-
151
- $remove_styles = apply_filters( 'cartflows_remove_theme_styles', true );
152
-
153
- if ( $remove_styles ) {
154
-
155
- // loop over all of the registered scripts..
156
- foreach ( $wp_styles->registered as $handle => $data ) {
157
-
158
- if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
159
-
160
- // remove it.
161
- wp_deregister_style( $handle );
162
- wp_dequeue_style( $handle );
163
- }
164
- }
165
- }
166
-
167
- $remove_scripts = apply_filters( 'cartflows_remove_theme_scripts', true );
168
-
169
- if ( $remove_scripts ) {
170
-
171
- // loop over all of the registered scripts.
172
- foreach ( $wp_scripts->registered as $handle => $data ) {
173
-
174
- if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
175
-
176
- // remove it.
177
- wp_deregister_script( $handle );
178
- wp_dequeue_script( $handle );
179
- }
180
- }
181
- }
182
-
183
- }
184
-
185
- /**
186
- * Update main order data in transient.
187
- *
188
- * @param array $woo_styles new styles array.
189
- * @since 1.0.0
190
- * @return array.
191
- */
192
- function woo_default_css( $woo_styles ) {
193
-
194
- $woo_styles = array(
195
- 'woocommerce-layout' => array(
196
- 'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ),
197
- 'deps' => '',
198
- 'version' => WC_VERSION,
199
- 'media' => 'all',
200
- 'has_rtl' => true,
201
- ),
202
- 'woocommerce-smallscreen' => array(
203
- 'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ),
204
- 'deps' => 'woocommerce-layout',
205
- 'version' => WC_VERSION,
206
- 'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
207
- 'has_rtl' => true,
208
- ),
209
- 'woocommerce-general' => array(
210
- 'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ),
211
- 'deps' => '',
212
- 'version' => WC_VERSION,
213
- 'media' => 'all',
214
- 'has_rtl' => true,
215
- ),
216
- );
217
-
218
- return $woo_styles;
219
- }
220
-
221
- /**
222
- * Init Actions.
223
- *
224
- * @since 1.0.0
225
- */
226
- function init_actions() {
227
-
228
- $this->set_flow_session();
229
- }
230
-
231
- /**
232
- * Set flow session.
233
- *
234
- * @since 1.0.0
235
- */
236
- function set_flow_session() {
237
-
238
- if ( wcf()->utils->is_step_post_type() ) {
239
-
240
- add_action( 'wp_head', array( $this, 'noindex_flow' ) );
241
-
242
- wcf()->utils->do_not_cache();
243
-
244
- /* Set key to support pixel */
245
- if ( isset( $_GET['wcf-key'] ) ) {
246
- $_GET['key'] = $_GET['wcf-key'];
247
- $_REQUEST['key'] = $_GET['wcf-key'];
248
- }
249
-
250
- if ( isset( $_GET['wcf-order'] ) ) {
251
- $_GET['order'] = $_GET['wcf-order'];
252
- $_REQUEST['order'] = $_GET['wcf-order'];
253
- $_GET['order-received'] = $_GET['wcf-order'];
254
- $_REQUEST['order-received'] = $_GET['wcf-order'];
255
- }
256
- }
257
- }
258
-
259
- /**
260
- * Add noindex, nofollow.
261
- *
262
- * @since 1.0.0
263
- */
264
- function noindex_flow() {
265
-
266
- $common = Cartflows_Helper::get_common_settings();
267
-
268
- if ( 'enable' === $common['disallow_indexing'] ) {
269
- echo '<meta name="robots" content="noindex,nofollow">';
270
- }
271
- }
272
-
273
- /**
274
- * WP Actions.
275
- *
276
- * @since 1.0.0
277
- */
278
- function wp_actions() {
279
-
280
- if ( wcf()->utils->is_step_post_type() ) {
281
-
282
- /* CSS Compatibility for All theme */
283
- add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 );
284
-
285
- add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 );
286
- add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 );
287
-
288
- /* Load woo templates from plugin */
289
- add_filter( 'woocommerce_locate_template', array( $this, 'override_woo_template' ), 20, 3 );
290
-
291
- /* Add version class to body in frontend. */
292
- add_filter( 'body_class', array( $this, 'add_cartflows_lite_version_to_body' ) );
293
-
294
- /* Custom Script Option */
295
- add_action( 'wp_head', array( $this, 'custom_script_option' ) );
296
-
297
- /* Remove the action applied by the Flatsome theme */
298
- if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
299
- $this->remove_flatsome_action();
300
- }
301
- }
302
- }
303
-
304
- /**
305
- * Debug Data Setting Actions.
306
- *
307
- * @since 1.1.14
308
- */
309
- function debug_data_setting_actions() {
310
-
311
- add_filter( 'cartflows_load_min_assets', array( $this, 'allow_load_minify' ) );
312
- }
313
-
314
- /**
315
- * Get/Set the allow minify option.
316
- *
317
- * @since 1.1.14
318
- */
319
- function allow_load_minify() {
320
- $debug_data = Cartflows_Helper::get_debug_settings();
321
- $allow_minified = $debug_data['allow_minified_files'];
322
- $allow_minify = false;
323
-
324
- if ( 'enable' === $allow_minified ) {
325
- $allow_minify = true;
326
- }
327
-
328
- return $allow_minify;
329
- }
330
-
331
- /**
332
- * Global flow scripts.
333
- *
334
- * @since 1.0.0
335
- */
336
- function global_flow_scripts() {
337
-
338
- global $post;
339
-
340
- $flow = get_post_meta( $post->ID, 'wcf-flow-id', true );
341
- $current_step = $post->ID;
342
- $next_step_link = '';
343
- $compatibility = Cartflows_Compatibility::get_instance();
344
-
345
- if ( _is_wcf_landing_type() ) {
346
-
347
- $next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step );
348
- $next_step_link = get_permalink( $next_step_id );
349
- }
350
-
351
- $localize = array(
352
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
353
- 'is_pb_preview' => $compatibility->is_page_builder_preview(),
354
- 'current_theme' => $compatibility->get_current_theme(),
355
- 'current_flow' => $flow,
356
- 'current_step' => $current_step,
357
- 'next_step' => $next_step_link,
358
- );
359
-
360
- wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
361
-
362
- wp_enqueue_style( 'wcf-frontend-global', wcf()->utils->get_css_url( 'frontend' ), array(), CARTFLOWS_VER );
363
-
364
- wp_enqueue_script(
365
- 'wcf-frontend-global',
366
- wcf()->utils->get_js_url( 'frontend' ),
367
- array( 'jquery' ),
368
- CARTFLOWS_VER,
369
- true
370
- );
371
- }
372
-
373
- /**
374
- * Custom Script in head.
375
- *
376
- * @since 1.0.0
377
- */
378
- function custom_script_option() {
379
-
380
- /* Add custom script to header in frontend. */
381
- $script = $this->get_custom_script();
382
- if ( '' !== $script ) {
383
- if ( false === strpos( $script, '<script' ) ) {
384
- $script = '<script>' . $script . '</script>';
385
- }
386
- echo '<!-- Custom CartFlows Script -->';
387
- echo $script;
388
- echo '<!-- End Custom CartFlows Script -->';
389
- }
390
- }
391
-
392
- /**
393
- * Override woo templates.
394
- *
395
- * @param string $template new Template full path.
396
- * @param string $template_name Template name.
397
- * @param string $template_path Template Path.
398
- * @since 1.1.5
399
- * @return string.
400
- */
401
- function override_woo_template( $template, $template_name, $template_path ) {
402
-
403
- global $woocommerce;
404
-
405
- $_template = $template;
406
-
407
- $plugin_path = CARTFLOWS_DIR . 'woocommerce/template/';
408
-
409
- if ( file_exists( $plugin_path . $template_name ) ) {
410
- $template = $plugin_path . $template_name;
411
- }
412
-
413
- if ( ! $template ) {
414
- $template = $_template;
415
- }
416
-
417
- return $template;
418
- }
419
-
420
- /**
421
- * Remove the action applied by the Flatsome theme.
422
- *
423
- * @since 1.1.5
424
- * @return void.
425
- */
426
- function remove_flatsome_action() {
427
-
428
- // Remove action where flatsome dequeued the woocommerce's default styles.
429
- remove_action( 'wp_enqueue_scripts', 'flatsome_woocommerce_scripts_styles', 98 );
430
- }
431
-
432
- /**
433
- * Add version class to body in frontend.
434
- *
435
- * @since 1.1.5
436
- * @param array $classes classes.
437
- * @return array $classes classes.
438
- */
439
- function add_cartflows_lite_version_to_body( $classes ) {
440
-
441
- $classes[] = 'cartflows-' . CARTFLOWS_VER;
442
-
443
- return $classes;
444
-
445
- }
446
-
447
- /**
448
- * Get custom script data.
449
- *
450
- * @since 1.0.0
451
- */
452
- function get_custom_script() {
453
-
454
- global $post;
455
-
456
- $script = get_post_meta( $post->ID, 'wcf-custom-script', true );
457
-
458
- return $script;
459
- }
460
- }
461
-
462
- /**
463
- * Prepare if class 'Cartflows_Frontend' exist.
464
- * Kicking this off by calling 'get_instance()' method
465
- */
466
- Cartflows_Frontend::get_instance();
1
+ <?php
2
+ /**
3
+ * CartFlows Frontend.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Class Cartflows_Frontend.
10
+ */
11
+ class Cartflows_Frontend {
12
+
13
+ /**
14
+ * Member Variable
15
+ *
16
+ * @var instance
17
+ */
18
+ private static $instance;
19
+
20
+ /**
21
+ * Initiator
22
+ */
23
+ public static function get_instance() {
24
+ if ( ! isset( self::$instance ) ) {
25
+ self::$instance = new self;
26
+ }
27
+ return self::$instance;
28
+ }
29
+
30
+ /**
31
+ * Constructor
32
+ */
33
+ public function __construct() {
34
+
35
+ /* Set / Destroy Flow Sessions. Set data */
36
+ add_action( 'wp', array( $this, 'init_actions' ), 1 );
37
+
38
+ add_action( 'init', array( $this, 'debug_data_setting_actions' ) );
39
+ /* Enqueue global required scripts */
40
+ add_action( 'wp', array( $this, 'wp_actions' ), 55 );
41
+
42
+ /* Modify the checkout order received url to go thank you page in our flow */
43
+ add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 );
44
+
45
+ }
46
+
47
+ /**
48
+ * Redirect to thank page if upsell not exists
49
+ *
50
+ * @param string $order_recieve_url url.
51
+ * @param object $order order object.
52
+ * @since 1.0.0
53
+ */
54
+ function redirect_to_thankyou_page( $order_recieve_url, $order ) {
55
+
56
+ /* Only for thank you page */
57
+ wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ );
58
+ wcf()->logger->log( 'Only for thank you page' );
59
+
60
+ if ( wcf()->flow->is_thankyou_page_exists( $order ) ) {
61
+
62
+ if ( _is_wcf_doing_checkout_ajax() ) {
63
+
64
+ $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
65
+
66
+ if ( ! $checkout_id ) {
67
+ $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
68
+ }
69
+ } else {
70
+ $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
71
+ }
72
+
73
+ wcf()->logger->log( 'Checkout ID : ' . $checkout_id );
74
+
75
+ if ( $checkout_id ) {
76
+
77
+ $thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order );
78
+
79
+ if ( $thankyou_step_id ) {
80
+
81
+ $order_recieve_url = get_permalink( $thankyou_step_id );
82
+
83
+ $order_recieve_url = add_query_arg(
84
+ array(
85
+ 'wcf-key' => $order->get_order_key(),
86
+ 'wcf-order' => $order->get_id(),
87
+ ),
88
+ $order_recieve_url
89
+ );
90
+ }
91
+ }
92
+ }
93
+
94
+ wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ );
95
+
96
+ return $order_recieve_url;
97
+ }
98
+
99
+ /**
100
+ * Cancel and redirect to checkout
101
+ *
102
+ * @param string $return_url url.
103
+ * @since 1.0.0
104
+ */
105
+ function redirect_to_checkout_on_cancel( $return_url ) {
106
+
107
+ if ( _is_wcf_doing_checkout_ajax() ) {
108
+
109
+ $checkout_id = wcf()->utils->get_checkout_id_from_post_data();
110
+
111
+ if ( ! $checkout_id ) {
112
+ $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
113
+ }
114
+ } else {
115
+ $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
116
+ }
117
+
118
+ if ( $checkout_id ) {
119
+
120
+ $return_url = add_query_arg(
121
+ array(
122
+ 'cancel_order' => 'true',
123
+ '_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
124
+ ),
125
+ get_permalink( $checkout_id )
126
+ );
127
+ }
128
+
129
+ return $return_url;
130
+ }
131
+
132
+
133
+ /**
134
+ * Remove theme styles.
135
+ *
136
+ * @since 1.0.0
137
+ */
138
+ function remove_theme_styles() {
139
+
140
+ if ( Cartflows_Compatibility::get_instance()->is_compatibility_theme_enabled() ) {
141
+ return;
142
+ }
143
+
144
+ // get all styles data.
145
+ global $wp_styles;
146
+ global $wp_scripts;
147
+
148
+ $get_stylesheet = 'themes/' . get_stylesheet() . '/';
149
+ $get_template = 'themes/' . get_template() . '/';
150
+
151
+ $remove_styles = apply_filters( 'cartflows_remove_theme_styles', true );
152
+
153
+ if ( $remove_styles ) {
154
+
155
+ // loop over all of the registered scripts..
156
+ foreach ( $wp_styles->registered as $handle => $data ) {
157
+
158
+ if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
159
+
160
+ // remove it.
161
+ wp_deregister_style( $handle );
162
+ wp_dequeue_style( $handle );
163
+ }
164
+ }
165
+ }
166
+
167
+ $remove_scripts = apply_filters( 'cartflows_remove_theme_scripts', true );
168
+
169
+ if ( $remove_scripts ) {
170
+
171
+ // loop over all of the registered scripts.
172
+ foreach ( $wp_scripts->registered as $handle => $data ) {
173
+
174
+ if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
175
+
176
+ // remove it.
177
+ wp_deregister_script( $handle );
178
+ wp_dequeue_script( $handle );
179
+ }
180
+ }
181
+ }
182
+
183
+ }
184
+
185
+ /**
186
+ * Update main order data in transient.
187
+ *
188
+ * @param array $woo_styles new styles array.
189
+ * @since 1.0.0
190
+ * @return array.
191
+ */
192
+ function woo_default_css( $woo_styles ) {
193
+
194
+ $woo_styles = array(
195
+ 'woocommerce-layout' => array(
196
+ 'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ),
197
+ 'deps' => '',
198
+ 'version' => WC_VERSION,
199
+ 'media' => 'all',
200
+ 'has_rtl' => true,
201
+ ),
202
+ 'woocommerce-smallscreen' => array(
203
+ 'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ),
204
+ 'deps' => 'woocommerce-layout',
205
+ 'version' => WC_VERSION,
206
+ 'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
207
+ 'has_rtl' => true,
208
+ ),
209
+ 'woocommerce-general' => array(
210
+ 'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ),
211
+ 'deps' => '',
212
+ 'version' => WC_VERSION,
213
+ 'media' => 'all',
214
+ 'has_rtl' => true,
215
+ ),
216
+ );
217
+
218
+ return $woo_styles;
219
+ }
220
+
221
+ /**
222
+ * Init Actions.
223
+ *
224
+ * @since 1.0.0
225
+ */
226
+ function init_actions() {
227
+
228
+ $this->set_flow_session();
229
+ }
230
+
231
+ /**
232
+ * Set flow session.
233
+ *
234
+ * @since 1.0.0
235
+ */
236
+ function set_flow_session() {
237
+
238
+ if ( wcf()->utils->is_step_post_type() ) {
239
+
240
+ add_action( 'wp_head', array( $this, 'noindex_flow' ) );
241
+
242
+ wcf()->utils->do_not_cache();
243
+
244
+ /* Set key to support pixel */
245
+ if ( isset( $_GET['wcf-key'] ) ) {
246
+ $_GET['key'] = $_GET['wcf-key'];
247
+ $_REQUEST['key'] = $_GET['wcf-key'];
248
+ }
249
+
250
+ if ( isset( $_GET['wcf-order'] ) ) {
251
+ $_GET['order'] = $_GET['wcf-order'];
252
+ $_REQUEST['order'] = $_GET['wcf-order'];
253
+ $_GET['order-received'] = $_GET['wcf-order'];
254
+ $_REQUEST['order-received'] = $_GET['wcf-order'];
255
+ }
256
+ }
257
+ }
258
+
259
+ /**
260
+ * Add noindex, nofollow.
261
+ *
262
+ * @since 1.0.0
263
+ */
264
+ function noindex_flow() {
265
+
266
+ $common = Cartflows_Helper::get_common_settings();
267
+
268
+ if ( 'enable' === $common['disallow_indexing'] ) {
269
+ echo '<meta name="robots" content="noindex,nofollow">';
270
+ }
271
+ }
272
+
273
+ /**
274
+ * WP Actions.
275
+ *
276
+ * @since 1.0.0
277
+ */
278
+ function wp_actions() {
279
+
280
+ if ( wcf()->utils->is_step_post_type() ) {
281
+
282
+ /* CSS Compatibility for All theme */
283
+ add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 );
284
+
285
+ add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 );
286
+ add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 );
287
+
288
+ /* Load woo templates from plugin */
289
+ add_filter( 'woocommerce_locate_template', array( $this, 'override_woo_template' ), 20, 3 );
290
+
291
+ /* Add version class to body in frontend. */
292
+ add_filter( 'body_class', array( $this, 'add_cartflows_lite_version_to_body' ) );
293
+
294
+ /* Custom Script Option */
295
+ add_action( 'wp_head', array( $this, 'custom_script_option' ) );
296
+
297
+ /* Remove the action applied by the Flatsome theme */
298
+ if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
299
+ $this->remove_flatsome_action();
300
+ }
301
+ }
302
+ }
303
+
304
+ /**
305
+ * Debug Data Setting Actions.
306
+ *
307
+ * @since 1.1.14
308
+ */
309
+ function debug_data_setting_actions() {
310
+
311
+ add_filter( 'cartflows_load_min_assets', array( $this, 'allow_load_minify' ) );
312
+ }
313
+
314
+ /**
315
+ * Get/Set the allow minify option.
316
+ *
317
+ * @since 1.1.14
318
+ */
319
+ function allow_load_minify() {
320
+ $debug_data = Cartflows_Helper::get_debug_settings();
321
+ $allow_minified = $debug_data['allow_minified_files'];
322
+ $allow_minify = false;
323
+
324
+ if ( 'enable' === $allow_minified ) {
325
+ $allow_minify = true;
326
+ }
327
+
328
+ return $allow_minify;
329
+ }
330
+
331
+ /**
332
+ * Global flow scripts.
333
+ *
334
+ * @since 1.0.0
335
+ */
336
+ function global_flow_scripts() {
337
+
338
+ global $post;
339
+
340
+ $flow = get_post_meta( $post->ID, 'wcf-flow-id', true );
341
+ $current_step = $post->ID;
342
+ $next_step_link = '';
343
+ $compatibility = Cartflows_Compatibility::get_instance();
344
+
345
+ if ( _is_wcf_landing_type() ) {
346
+
347
+ $next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step );
348
+ $next_step_link = get_permalink( $next_step_id );
349
+ }
350
+
351
+ $localize = array(
352
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
353
+ 'is_pb_preview' => $compatibility->is_page_builder_preview(),
354
+ 'current_theme' => $compatibility->get_current_theme(),
355
+ 'current_flow' => $flow,
356
+ 'current_step' => $current_step,
357
+ 'next_step' => $next_step_link,
358
+ );
359
+
360
+ wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
361
+
362
+ wp_enqueue_style( 'wcf-frontend-global', wcf()->utils->get_css_url( 'frontend' ), array(), CARTFLOWS_VER );
363
+
364
+ wp_enqueue_script(
365
+ 'wcf-frontend-global',
366
+ wcf()->utils->get_js_url( 'frontend' ),
367
+ array( 'jquery' ),
368
+ CARTFLOWS_VER,
369
+ true
370
+ );
371
+ }
372
+
373
+ /**
374
+ * Custom Script in head.
375
+ *
376
+ * @since 1.0.0
377
+ */
378
+ function custom_script_option() {
379
+
380
+ /* Add custom script to header in frontend. */
381
+ $script = $this->get_custom_script();
382
+ if ( '' !== $script ) {
383
+ if ( false === strpos( $script, '<script' ) ) {
384
+ $script = '<script>' . $script . '</script>';
385
+ }
386
+ echo '<!-- Custom CartFlows Script -->';
387
+ echo $script;
388
+ echo '<!-- End Custom CartFlows Script -->';
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Override woo templates.
394
+ *
395
+ * @param string $template new Template full path.
396
+ * @param string $template_name Template name.
397
+ * @param string $template_path Template Path.
398
+ * @since 1.1.5
399
+ * @return string.
400
+ */
401
+ function override_woo_template( $template, $template_name, $template_path ) {
402
+
403
+ global $woocommerce;
404
+
405
+ $_template = $template;
406
+
407
+ $plugin_path = CARTFLOWS_DIR . 'woocommerce/template/';
408
+
409
+ if ( file_exists( $plugin_path . $template_name ) ) {
410
+ $template = $plugin_path . $template_name;
411
+ }
412
+
413
+ if ( ! $template ) {
414
+ $template = $_template;
415
+ }
416
+
417
+ return $template;
418
+ }
419
+
420
+ /**
421
+ * Remove the action applied by the Flatsome theme.
422
+ *
423
+ * @since 1.1.5
424
+ * @return void.
425
+ */
426
+ function remove_flatsome_action() {
427
+
428
+ // Remove action where flatsome dequeued the woocommerce's default styles.
429
+ remove_action( 'wp_enqueue_scripts', 'flatsome_woocommerce_scripts_styles', 98 );
430
+ }
431
+
432
+ /**
433
+ * Add version class to body in frontend.
434
+ *
435
+ * @since 1.1.5
436
+ * @param array $classes classes.
437
+ * @return array $classes classes.
438
+ */
439
+ function add_cartflows_lite_version_to_body( $classes ) {
440
+
441
+ $classes[] = 'cartflows-' . CARTFLOWS_VER;
442
+
443
+ return $classes;
444
+
445
+ }
446
+
447
+ /**
448
+ * Get custom script data.
449
+ *
450
+ * @since 1.0.0
451
+ */
452
+ function get_custom_script() {
453
+
454
+ global $post;
455
+
456
+ $script = get_post_meta( $post->ID, 'wcf-custom-script', true );
457
+
458
+ return $script;
459
+ }
460
+ }
461
+
462
+ /**
463
+ * Prepare if class 'Cartflows_Frontend' exist.
464
+ * Kicking this off by calling 'get_instance()' method
465
+ */
466
+ Cartflows_Frontend::get_instance();
classes/class-cartflows-helper.php CHANGED
@@ -1,520 +1,520 @@
1
- <?php
2
- /**
3
- * CARTFLOWS Helper.
4
- *
5
- * @package CARTFLOWS
6
- */
7
-
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit; // Exit if accessed directly.
10
- }
11
-
12
- /**
13
- * Class Cartflows_Helper.
14
- */
15
- class Cartflows_Helper {
16
-
17
- /**
18
- * Common global data
19
- *
20
- * @var zapier
21
- */
22
- private static $common = null;
23
-
24
- /**
25
- * Common Debug data
26
- *
27
- * @var zapier
28
- */
29
- private static $debug_data = null;
30
-
31
- /**
32
- * Installed Plugins
33
- *
34
- * @since 1.1.4
35
- *
36
- * @access private
37
- * @var array Installed plugins list.
38
- */
39
- private static $installed_plugins = null;
40
-
41
- /**
42
- * Checkout Fields
43
- *
44
- * @var checkout_fields
45
- */
46
- private static $checkout_fields = null;
47
-
48
- /**
49
- * Returns an option from the database for
50
- * the admin settings page.
51
- *
52
- * @param string $key The option key.
53
- * @param mixed $default Option default value if option is not available.
54
- * @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
55
- * @return string Return the option value
56
- */
57
- public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
58
-
59
- // Get the site-wide option if we're in the network admin.
60
- if ( $network_override && is_multisite() ) {
61
- $value = get_site_option( $key, $default );
62
- } else {
63
- $value = get_option( $key, $default );
64
- }
65
-
66
- return $value;
67
- }
68
-
69
- /**
70
- * Updates an option from the admin settings page.
71
- *
72
- * @param string $key The option key.
73
- * @param mixed $value The value to update.
74
- * @param bool $network Whether to allow the network admin setting to be overridden on subsites.
75
- * @return mixed
76
- */
77
- static public function update_admin_settings_option( $key, $value, $network = false ) {
78
-
79
- // Update the site-wide option since we're in the network admin.
80
- if ( $network && is_multisite() ) {
81
- update_site_option( $key, $value );
82
- } else {
83
- update_option( $key, $value );
84
- }
85
-
86
- }
87
-
88
- /**
89
- * Get single setting
90
- *
91
- * @since 1.1.4
92
- *
93
- * @param string $key Option key.
94
- * @param string $default Option default value if not exist.
95
- * @return mixed
96
- */
97
- static public function get_common_setting( $key = '', $default = '' ) {
98
- $settings = self::get_common_settings();
99
-
100
- if ( $settings && array_key_exists( $key, $settings ) ) {
101
- return $settings[ $key ];
102
- }
103
-
104
- return $default;
105
- }
106
-
107
- /**
108
- * Get single debug options
109
- *
110
- * @since 1.1.4
111
- *
112
- * @param string $key Option key.
113
- * @param string $default Option default value if not exist.
114
- * @return mixed
115
- */
116
- static public function get_debug_setting( $key = '', $default = '' ) {
117
- $debug_data = self::get_debug_settings();
118
-
119
- if ( $debug_data && array_key_exists( $key, $debug_data ) ) {
120
- return $debug_data[ $key ];
121
- }
122
-
123
- return $default;
124
- }
125
-
126
- /**
127
- * Get required plugins for page builder
128
- *
129
- * @since 1.1.4
130
- *
131
- * @param string $page_builder_slug Page builder slug.
132
- * @param string $default Default page builder.
133
- * @return array selected page builder required plugins list.
134
- */
135
- public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
136
- $plugins = self::get_plugins_groupby_page_builders();
137
-
138
- if ( array_key_exists( $page_builder_slug, $plugins ) ) {
139
- return $plugins[ $page_builder_slug ];
140
- }
141
-
142
- return $plugins[ $default ];
143
- }
144
-
145
- /**
146
- * Get Plugins list by page builder.
147
- *
148
- * @since 1.1.4
149
- *
150
- * @return array Required Plugins list.
151
- */
152
- public static function get_plugins_groupby_page_builders() {
153
-
154
- $divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
155
- $theme_status = 'not-installed';
156
- if ( $divi_status ) {
157
- if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
158
- $theme_status = 'installed';
159
- if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
160
- $theme_status = 'deactivate';
161
- $divi_status = 'activate';
162
- } else {
163
- $divi_status = '';
164
- }
165
- }
166
- }
167
-
168
- $plugins = array(
169
- 'elementor' => array(
170
- 'title' => 'Elementor',
171
- 'plugins' => array(
172
- array(
173
- 'slug' => 'elementor', // For download from wp.org.
174
- 'init' => 'elementor/elementor.php',
175
- 'status' => self::get_plugin_status( 'elementor/elementor.php' ),
176
- ),
177
- ),
178
- ),
179
- 'divi' => array(
180
- 'title' => 'Divi',
181
- 'theme-status' => $theme_status,
182
- 'plugin-status' => $divi_status,
183
- 'plugins' => array(
184
- array(
185
- 'slug' => 'divi-builder', // For download from wp.org.
186
- 'init' => 'divi-builder/divi-builder.php',
187
- 'status' => $divi_status,
188
- ),
189
- ),
190
- ),
191
- );
192
-
193
- $plugins['beaver-builder'] = array(
194
- 'title' => 'Beaver Builder',
195
- 'plugins' => array(),
196
- );
197
-
198
- // Check Pro Exist.
199
- if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
200
- $plugins['beaver-builder']['plugins'][] = array(
201
- 'slug' => 'bb-plugin',
202
- 'init' => 'bb-plugin/fl-builder.php',
203
- 'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
204
- );
205
- } else {
206
- $plugins['beaver-builder']['plugins'][] = array(
207
- 'slug' => 'beaver-builder-lite-version', // For download from wp.org.
208
- 'init' => 'beaver-builder-lite-version/fl-builder.php',
209
- 'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
210
- );
211
- }
212
-
213
- if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-ultimate-addon/bb-ultimate-addon.php' ) && ! is_plugin_active( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) {
214
- $plugins['beaver-builder']['plugins'][] = array(
215
- 'slug' => 'bb-ultimate-addon',
216
- 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
217
- 'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
218
- );
219
- } else {
220
- $plugins['beaver-builder']['plugins'][] = array(
221
- 'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
222
- 'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
223
- 'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
224
- );
225
- }
226
-
227
- return $plugins;
228
- }
229
-
230
- /**
231
- * Get plugin status
232
- *
233
- * @since 1.1.4
234
- *
235
- * @param string $plugin_init_file Plguin init file.
236
- * @return mixed
237
- */
238
- public static function get_plugin_status( $plugin_init_file ) {
239
-
240
- if ( null == self::$installed_plugins ) {
241
- self::$installed_plugins = get_plugins();
242
- }
243
-
244
- if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
245
- return 'install';
246
- } elseif ( ! is_plugin_active( $plugin_init_file ) ) {
247
- return 'activate';
248
- }
249
-
250
- return;
251
- }
252
-
253
- /**
254
- * Get zapier settings.
255
- *
256
- * @return array.
257
- */
258
- static public function get_common_settings() {
259
-
260
- if ( null === self::$common ) {
261
-
262
- $common_default = apply_filters(
263
- 'cartflows_common_settings_default',
264
- array(
265
- 'disallow_indexing' => 'disable',
266
- 'global_checkout' => '',
267
- 'default_page_builder' => 'elementor',
268
- )
269
- );
270
-
271
- $common = Cartflows_Helper::get_admin_settings_option( '_cartflows_common', false, true );
272
-
273
- $common = wp_parse_args( $common, $common_default );
274
-
275
- if ( ! did_action( 'wp' ) ) {
276
- return $common;
277
- } else {
278
- self::$common = $common;
279
- }
280
- }
281
-
282
- return self::$common;
283
- }
284
-
285
- /**
286
- * Get debug settings data.
287
- *
288
- * @return array.
289
- */
290
- static public function get_debug_settings() {
291
-
292
- if ( null === self::$debug_data ) {
293
-
294
- $debug_data_default = apply_filters(
295
- 'cartflows_debug_settings_default',
296
- array(
297
- 'allow_minified_files' => 'disable',
298
- )
299
- );
300
-
301
- $debug_data = Cartflows_Helper::get_admin_settings_option( '_cartflows_debug_data', false, true );
302
-
303
- $debug_data = wp_parse_args( $debug_data, $debug_data_default );
304
-
305
- if ( ! did_action( 'wp' ) ) {
306
- return $debug_data;
307
- } else {
308
- self::$debug_data = $debug_data;
309
- }
310
- }
311
-
312
- return self::$debug_data;
313
- }
314
-
315
- /**
316
- * Get Checkout field.
317
- *
318
- * @param string $key Field key.
319
- * @param int $post_id Post id.
320
- * @return array.
321
- */
322
- static public function get_checkout_fields( $key, $post_id ) {
323
-
324
- $saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
325
-
326
- if ( ! $saved_fields ) {
327
- $saved_fields = array();
328
- }
329
-
330
- $fields = array_filter( $saved_fields );
331
-
332
- if ( empty( $fields ) ) {
333
- if ( 'billing' === $key || 'shipping' === $key ) {
334
-
335
- $fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
336
-
337
- update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
338
- }
339
- }
340
-
341
- return $fields;
342
- }
343
-
344
- /**
345
- * Add Checkout field.
346
- *
347
- * @param string $type Field type.
348
- * @param string $field_key Field key.
349
- * @param array $field_data Field data.
350
- * @param int $post_id Post id.
351
- * @return boolean.
352
- */
353
- static public function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
354
-
355
- $fields = self::get_checkout_fields( $type, $post_id );
356
-
357
- $fields[ $field_key ] = $field_data;
358
-
359
- update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
360
-
361
- return true;
362
- }
363
-
364
- /**
365
- * Get checkout fields settings.
366
- *
367
- * @param string $type Field type.
368
- * @param string $field_key Field key.
369
- * @param int $post_id Post id.
370
- * @return array.
371
- */
372
- static public function delete_checkout_field( $type, $field_key, $post_id ) {
373
-
374
- $fields = self::get_checkout_fields( $type, $post_id );
375
-
376
- if ( isset( $fields[ $field_key ] ) ) {
377
- unset( $fields[ $field_key ] );
378
- }
379
-
380
- update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
381
-
382
- return true;
383
- }
384
-
385
- /**
386
- * Get checkout fields settings.
387
- *
388
- * @return array.
389
- */
390
- static public function get_checkout_fields_settings() {
391
-
392
- if ( null === self::$checkout_fields ) {
393
- $checkout_fields_default = array(
394
- 'enable_customization' => 'disable',
395
- 'enable_billing_fields' => 'disable',
396
- );
397
-
398
- $billing_fields = self::get_checkout_fields( 'billing' );
399
-
400
- if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
401
-
402
- foreach ( $billing_fields as $key => $value ) {
403
-
404
- $checkout_fields_default[ $key ] = 'enable';
405
- }
406
- }
407
-
408
- $checkout_fields = Cartflows_Helper::get_admin_settings_option( '_wcf_checkout_fields', false, true );
409
-
410
- self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
411
- }
412
-
413
- return self::$checkout_fields;
414
- }
415
-
416
- /**
417
- * Get meta options
418
- *
419
- * @since 1.0.0
420
- * @param int $post_id Product ID.
421
- * @param string $key Meta Key.
422
- * @param string $default Default value.
423
- * @return string Meta Value.
424
- */
425
- static public function get_meta_option( $post_id, $key, $default = '' ) {
426
-
427
- $value = get_post_meta( $post_id, $key, true );
428
-
429
- if ( ! $value ) {
430
- $value = $default;
431
- }
432
-
433
- return $value;
434
- }
435
-
436
- /**
437
- * Save meta option
438
- *
439
- * @since 1.0.0
440
- * @param int $post_id Product ID.
441
- * @param array $args Arguments array.
442
- */
443
- static public function save_meta_option( $post_id, $args = array() ) {
444
-
445
- if ( is_array( $args ) && ! empty( $args ) ) {
446
-
447
- foreach ( $args as $key => $value ) {
448
-
449
- update_post_meta( $post_id, $key, $value );
450
- }
451
- }
452
- }
453
-
454
- /**
455
- * Check if Elementor page builder is installed
456
- *
457
- * @since 1.0.0
458
- *
459
- * @access public
460
- */
461
- static public function _is_elementor_installed() {
462
- $path = 'elementor/elementor.php';
463
- $plugins = get_plugins();
464
-
465
- return isset( $plugins[ $path ] );
466
- }
467
-
468
- /**
469
- * Check if Step has product assigned.
470
- *
471
- * @since 1.0.0
472
- * @param int $step_id step ID.
473
- *
474
- * @access public
475
- */
476
- static public function has_product_assigned( $step_id ) {
477
-
478
- $step_type = get_post_meta( $step_id, 'wcf-step-type', true );
479
-
480
- if ( 'checkout' == $step_type ) {
481
- $product = get_post_meta( $step_id, 'wcf-checkout-products', true );
482
- } else {
483
- $product = get_post_meta( $step_id, 'wcf-offer-product', true );
484
- }
485
-
486
- if ( ! empty( $product ) ) {
487
- return true;
488
- }
489
- return false;
490
-
491
- }
492
-
493
- /**
494
- * Get attributes for cartflows wrap.
495
- *
496
- * @since 1.1.4
497
- *
498
- * @access public
499
- */
500
- static public function get_cartflows_container_atts() {
501
-
502
- $attributes = apply_filters( 'cartflows_container_atts', array() );
503
- $atts_string = '';
504
-
505
- foreach ( $attributes as $key => $value ) {
506
-
507
- if ( ! $value ) {
508
- continue;
509
- }
510
-
511
- if ( true === $value ) {
512
- $atts_string .= esc_html( $key ) . ' ';
513
- } else {
514
- $atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
515
- }
516
- }
517
-
518
- return $atts_string;
519
- }
520
- }
1
+ <?php
2
+ /**
3
+ * CARTFLOWS Helper.
4
+ *
5
+ * @package CARTFLOWS
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly.
10
+ }
11
+
12
+ /**
13
+ * Class Cartflows_Helper.
14
+ */
15
+ class Cartflows_Helper {
16
+
17
+ /**
18
+ * Common global data
19
+ *
20
+ * @var zapier
21
+ */
22
+ private static $common = null;
23
+
24
+ /**
25
+ * Common Debug data
26
+ *
27
+ * @var zapier
28
+ */
29
+ private static $debug_data = null;
30
+
31
+ /**
32
+ * Installed Plugins
33
+ *
34
+ * @since 1.1.4
35
+ *
36
+ * @access private
37
+ * @var array Installed plugins list.
38
+ */
39
+ private static $installed_plugins = null;
40
+
41
+ /**
42
+ * Checkout Fields
43
+ *
44
+ * @var checkout_fields
45
+ */
46
+ private static $checkout_fields = null;
47
+
48
+ /**
49
+ * Returns an option from the database for
50
+ * the admin settings page.
51
+ *
52
+ * @param string $key The option key.
53
+ * @param mixed $default Option default value if option is not available.
54
+ * @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
55
+ * @return string Return the option value
56
+ */
57
+ public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
58
+
59
+ // Get the site-wide option if we're in the network admin.
60
+ if ( $network_override && is_multisite() ) {
61
+ $value = get_site_option( $key, $default );
62
+ } else {
63
+ $value = get_option( $key, $default );
64
+ }
65
+
66
+ return $value;
67
+ }
68
+
69
+ /**
70
+ * Updates an option from the admin settings page.
71
+ *
72
+ * @param string $key The option key.
73
+ * @param mixed $value The value to update.
74
+ * @param bool $network Whether to allow the network admin setting to be overridden on subsites.
75
+ * @return mixed
76
+ */
77
+ static public function update_admin_settings_option( $key, $value, $network = false ) {
78
+
79
+ // Update the site-wide option since we're in the network admin.
80
+ if ( $network && is_multisite() ) {
81
+ update_site_option( $key, $value );
82
+ } else {
83
+ update_option( $key, $value );
84
+ }
85
+
86
+ }
87
+
88
+ /**
89
+ * Get single setting
90
+ *
91
+ * @since 1.1.4
92
+ *
93
+ * @param string $key Option key.
94
+ * @param string $default Option default value if not exist.
95
+ * @return mixed
96
+ */
97
+ static public function get_common_setting( $key = '', $default = '' ) {
98
+ $settings = self::get_common_settings();
99
+
100
+ if ( $settings && array_key_exists( $key, $settings ) ) {
101
+ return $settings[ $key ];
102
+ }
103
+
104
+ return $default;
105
+ }
106
+
107
+ /**
108
+ * Get single debug options
109
+ *
110
+ * @since 1.1.4
111
+ *
112
+ * @param string $key Option key.
113
+ * @param string $default Option default value if not exist.
114
+ * @return mixed
115
+ */
116
+ static public function get_debug_setting( $key = '', $default = '' ) {
117
+ $debug_data = self::get_debug_settings();
118
+
119
+ if ( $debug_data && array_key_exists( $key, $debug_data ) ) {
120
+ return $debug_data[ $key ];
121
+ }
122
+
123
+ return $default;
124
+ }
125
+
126
+ /**
127
+ * Get required plugins for page builder
128
+ *
129
+ * @since 1.1.4
130
+ *
131
+ * @param string $page_builder_slug Page builder slug.
132
+ * @param string $default Default page builder.
133
+ * @return array selected page builder required plugins list.
134
+ */
135
+ public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
136
+ $plugins = self::get_plugins_groupby_page_builders();
137
+
138
+ if ( array_key_exists( $page_builder_slug, $plugins ) ) {
139
+ return $plugins[ $page_builder_slug ];
140
+ }
141
+
142
+ return $plugins[ $default ];
143
+ }
144
+
145
+ /**
146
+ * Get Plugins list by page builder.
147
+ *
148
+ * @since 1.1.4
149
+ *
150
+ * @return array Required Plugins list.
151
+ */
152
+ public static function get_plugins_groupby_page_builders() {
153
+
154
+ $divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
155
+ $theme_status = 'not-installed';
156
+ if ( $divi_status ) {
157
+ if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
158
+ $theme_status = 'installed';
159
+ if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
160
+ $theme_status = 'deactivate';
161
+ $divi_status = 'activate';
162
+ } else {
163
+ $divi_status = '';
164
+ }
165
+ }
166
+ }
167
+
168
+ $plugins = array(
169
+ 'elementor' => array(
170
+ 'title' => 'Elementor',
171
+ 'plugins' => array(
172
+ array(
173
+ 'slug' => 'elementor', // For download from wp.org.
174
+ 'init' => 'elementor/elementor.php',
175
+ 'status' => self::get_plugin_status( 'elementor/elementor.php' ),
176
+ ),
177
+ ),
178
+ ),
179
+ 'divi' => array(
180
+ 'title' => 'Divi',
181
+ 'theme-status' => $theme_status,
182
+ 'plugin-status' => $divi_status,
183
+ 'plugins' => array(
184
+ array(
185
+ 'slug' => 'divi-builder', // For download from wp.org.
186
+ 'init' => 'divi-builder/divi-builder.php',
187
+ 'status' => $divi_status,
188
+ ),
189
+ ),
190
+ ),
191
+ );
192
+
193
+ $plugins['beaver-builder'] = array(
194
+ 'title' => 'Beaver Builder',
195
+ 'plugins' => array(),
196
+ );
197
+
198
+ // Check Pro Exist.
199
+ if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
200
+ $plugins['beaver-builder']['plugins'][] = array(
201
+ 'slug' => 'bb-plugin',
202
+ 'init' => 'bb-plugin/fl-builder.php',
203
+ 'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
204
+ );
205
+ } else {
206
+ $plugins['beaver-builder']['plugins'][] = array(
207
+ 'slug' => 'beaver-builder-lite-version', // For download from wp.org.
208
+ 'init' => 'beaver-builder-lite-version/fl-builder.php',
209
+ 'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
210
+ );
211
+ }
212
+
213
+ if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-ultimate-addon/bb-ultimate-addon.php' ) && ! is_plugin_active( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) {
214
+ $plugins['beaver-builder']['plugins'][] = array(
215
+ 'slug' => 'bb-ultimate-addon',
216
+ 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
217
+ 'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
218
+ );
219
+ } else {
220
+ $plugins['beaver-builder']['plugins'][] = array(
221
+ 'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
222
+ 'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
223
+ 'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
224
+ );
225
+ }
226
+
227
+ return $plugins;
228
+ }
229
+
230
+ /**
231
+ * Get plugin status
232
+ *
233
+ * @since 1.1.4
234
+ *
235
+ * @param string $plugin_init_file Plguin init file.
236
+ * @return mixed
237
+ */
238
+ public static function get_plugin_status( $plugin_init_file ) {
239
+
240
+ if ( null == self::$installed_plugins ) {
241
+ self::$installed_plugins = get_plugins();
242
+ }
243
+
244
+ if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
245
+ return 'install';
246
+ } elseif ( ! is_plugin_active( $plugin_init_file ) ) {
247
+ return 'activate';
248
+ }
249
+
250
+ return;
251
+ }
252
+
253
+ /**
254
+ * Get zapier settings.
255
+ *
256
+ * @return array.
257
+ */
258
+ static public function get_common_settings() {
259
+
260
+ if ( null === self::$common ) {
261
+
262
+ $common_default = apply_filters(
263
+ 'cartflows_common_settings_default',
264
+ array(
265
+ 'disallow_indexing' => 'disable',
266
+ 'global_checkout' => '',
267
+ 'default_page_builder' => 'elementor',
268
+ )
269
+ );
270
+
271
+ $common = Cartflows_Helper::get_admin_settings_option( '_cartflows_common', false, true );
272
+
273
+ $common = wp_parse_args( $common, $common_default );
274
+
275
+ if ( ! did_action( 'wp' ) ) {
276
+ return $common;
277
+ } else {
278
+ self::$common = $common;
279
+ }
280
+ }
281
+
282
+ return self::$common;
283
+ }
284
+
285
+ /**
286
+ * Get debug settings data.
287
+ *
288
+ * @return array.
289
+ */
290
+ static public function get_debug_settings() {
291
+
292
+ if ( null === self::$debug_data ) {
293
+
294
+ $debug_data_default = apply_filters(
295
+ 'cartflows_debug_settings_default',
296
+ array(
297
+ 'allow_minified_files' => 'disable',
298
+ )
299
+ );
300
+
301
+ $debug_data = Cartflows_Helper::get_admin_settings_option( '_cartflows_debug_data', false, true );
302
+
303
+ $debug_data = wp_parse_args( $debug_data, $debug_data_default );
304
+
305
+ if ( ! did_action( 'wp' ) ) {
306
+ return $debug_data;
307
+ } else {
308
+ self::$debug_data = $debug_data;
309
+ }
310
+ }
311
+
312
+ return self::$debug_data;
313
+ }
314
+
315
+ /**
316
+ * Get Checkout field.
317
+ *
318
+ * @param string $key Field key.
319
+ * @param int $post_id Post id.
320
+ * @return array.
321
+ */
322
+ static public function get_checkout_fields( $key, $post_id ) {
323
+
324
+ $saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
325
+
326
+ if ( ! $saved_fields ) {
327
+ $saved_fields = array();
328
+ }
329
+
330
+ $fields = array_filter( $saved_fields );
331
+
332
+ if ( empty( $fields ) ) {
333
+ if ( 'billing' === $key || 'shipping' === $key ) {
334
+
335
+ $fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
336
+
337
+ update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
338
+ }
339
+ }
340
+
341
+ return $fields;
342
+ }
343
+
344
+ /**
345
+ * Add Checkout field.
346
+ *
347
+ * @param string $type Field type.
348
+ * @param string $field_key Field key.
349
+ * @param array $field_data Field data.
350
+ * @param int $post_id Post id.
351
+ * @return boolean.
352
+ */
353
+ static public function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
354
+
355
+ $fields = self::get_checkout_fields( $type, $post_id );
356
+
357
+ $fields[ $field_key ] = $field_data;
358
+
359
+ update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
360
+
361
+ return true;
362
+ }
363
+
364
+ /**
365
+ * Get checkout fields settings.
366
+ *
367
+ * @param string $type Field type.
368
+ * @param string $field_key Field key.
369
+ * @param int $post_id Post id.
370
+ * @return array.
371
+ */
372
+ static public function delete_checkout_field( $type, $field_key, $post_id ) {
373
+
374
+ $fields = self::get_checkout_fields( $type, $post_id );
375
+
376
+ if ( isset( $fields[ $field_key ] ) ) {
377
+ unset( $fields[ $field_key ] );
378
+ }
379
+
380
+ update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
381
+
382
+ return true;
383
+ }
384
+
385
+ /**
386
+ * Get checkout fields settings.
387
+ *
388
+ * @return array.
389
+ */
390
+ static public function get_checkout_fields_settings() {
391
+
392
+ if ( null === self::$checkout_fields ) {
393
+ $checkout_fields_default = array(
394
+ 'enable_customization' => 'disable',
395
+ 'enable_billing_fields' => 'disable',
396
+ );
397
+
398
+ $billing_fields = self::get_checkout_fields( 'billing' );
399
+
400
+ if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
401
+
402
+ foreach ( $billing_fields as $key => $value ) {
403
+
404
+ $checkout_fields_default[ $key ] = 'enable';
405
+ }
406
+ }
407
+
408
+ $checkout_fields = Cartflows_Helper::get_admin_settings_option( '_wcf_checkout_fields', false, true );
409
+
410
+ self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
411
+ }
412
+
413
+ return self::$checkout_fields;
414
+ }
415
+
416
+ /**
417
+ * Get meta options
418
+ *
419
+ * @since 1.0.0
420
+ * @param int $post_id Product ID.
421
+ * @param string $key Meta Key.
422
+ * @param string $default Default value.
423
+ * @return string Meta Value.
424
+ */
425
+ static public function get_meta_option( $post_id, $key, $default = '' ) {
426
+
427
+ $value = get_post_meta( $post_id, $key, true );
428
+
429
+ if ( ! $value ) {
430
+ $value = $default;
431
+ }
432
+
433
+ return $value;
434
+ }
435
+
436
+ /**
437
+ * Save meta option
438
+ *
439
+ * @since 1.0.0
440
+ * @param int $post_id Product ID.
441
+ * @param array $args Arguments array.
442
+ */
443
+ static public function save_meta_option( $post_id, $args = array() ) {
444
+
445
+ if ( is_array( $args ) && ! empty( $args ) ) {
446
+
447
+ foreach ( $args as $key => $value ) {
448
+
449
+ update_post_meta( $post_id, $key, $value );
450
+ }
451
+ }
452
+ }
453
+
454
+ /**
455
+ * Check if Elementor page builder is installed
456
+ *
457
+ * @since 1.0.0
458
+ *
459
+ * @access public
460
+ */
461
+ static public function _is_elementor_installed() {
462
+ $path = 'elementor/elementor.php';
463
+ $plugins = get_plugins();
464
+
465
+ return isset( $plugins[ $path ] );
466
+ }
467
+
468
+ /**
469
+ * Check if Step has product assigned.
470
+ *
471
+ * @since 1.0.0
472
+ * @param int $step_id step ID.
473
+ *
474
+ * @access public
475
+ */
476
+ static public function has_product_assigned( $step_id ) {
477
+
478
+ $step_type = get_post_meta( $step_id, 'wcf-step-type', true );
479
+
480
+ if ( 'checkout' == $step_type ) {
481
+ $product = get_post_meta( $step_id, 'wcf-checkout-products', true );
482
+ } else {
483
+ $product = get_post_meta( $step_id, 'wcf-offer-product', true );
484
+ }
485
+
486
+ if ( ! empty( $product ) ) {
487
+ return true;
488
+ }
489
+ return false;
490
+
491
+ }
492
+
493
+ /**
494
+ * Get attributes for cartflows wrap.
495
+ *
496
+ * @since 1.1.4
497
+ *
498
+ * @access public
499
+ */
500
+ static public function get_cartflows_container_atts() {
501
+
502
+ $attributes = apply_filters( 'cartflows_container_atts', array() );
503
+ $atts_string = '';
504
+
505
+ foreach ( $attributes as $key => $value ) {
506
+
507
+ if ( ! $value ) {
508
+ continue;
509
+ }
510
+
511
+ if ( true === $value ) {
512
+ $atts_string .= esc_html( $key ) . ' ';
513
+ } else {
514
+ $atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
515
+ }
516
+ }
517
+
518
+ return $atts_string;
519
+ }
520
+ }
classes/class-cartflows-loader.php CHANGED
@@ -1,436 +1,437 @@
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 session
40
- */
41
- public $session = null;
42
-
43
-
44
- /**
45
- * Member Variable
46
- *
47
- * @var options
48
- */
49
- public $options = null;
50
-
51
- /**
52
- * Member Variable
53
- *
54
- * @var meta
55
- */
56
- public $meta = null;
57
-
58
- /**
59
- * Member Variable
60
- *
61
- * @var flow
62
- */
63
- public $flow = null;
64
-
65
- /**
66
- * Member Variable
67
- *
68
- * @var assets_vars
69
- */
70
- public $assets_vars = null;
71
-
72
- /**
73
- * Initiator
74
- */
75
- public static function get_instance() {
76
-
77
- if ( is_null( self::$instance ) ) {
78
-
79
- self::$instance = new self;
80
-
81
- /**
82
- * CartFlows loaded.
83
- *
84
- * Fires when Cartflows was fully loaded and instantiated.
85
- *
86
- * @since 1.0.0
87
- */
88
- do_action( 'cartflows_loaded' );
89
- }
90
-
91
- return self::$instance;
92
- }
93
-
94
- /**
95
- * Constructor
96
- */
97
- public function __construct() {
98
-
99
- $this->define_constants();
100
-
101
- // Activation hook.
102
- register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) );
103
-
104
- // deActivation hook.
105
- register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) );
106
-
107
- add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 );
108
- add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) );
109
- add_action( 'wp_loaded', array( $this, 'initialize' ) );
110
-
111
- // Update compatibility.
112
- require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
113
- }
114
-
115
- /**
116
- * Defines all constants
117
- *
118
- * @since 1.0.0
119
- */
120
- public function define_constants() {
121
-
122
- define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
123
- define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
124
- define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
125
- define( 'CARTFLOWS_VER', '1.1.14' );
126
- define( 'CARTFLOWS_SLUG', 'cartflows' );
127
- define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
128
-
129
- define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' );
130
- define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' );
131
-
132
- if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) {
133
- define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' );
134
- }
135
- define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' );
136
- define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' );
137
- define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' );
138
- define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' );
139
-
140
- if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) {
141
- define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' );
142
- }
143
- if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER' ) ) {
144
- define( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER', 'cartflows_flow_page_builder' );
145
- }
146
- if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) {
147
- define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' );
148
- }
149
- }
150
-
151
- /**
152
- * Loads plugin files.
153
- *
154
- * @since 1.0.0
155
- *
156
- * @return void
157
- */
158
- function load_plugin() {
159
-
160
- if ( ! function_exists( 'WC' ) ) {
161
- add_action( 'admin_notices', array( $this, 'fails_to_load' ) );
162
- return;
163
- }
164
-
165
- $this->load_helper_files_components();
166
- $this->load_core_files();
167
- $this->load_core_components();
168
-
169
- /**
170
- * CartFlows Init.
171
- *
172
- * Fires when Cartflows is instantiated.
173
- *
174
- * @since 1.0.0
175
- */
176
- do_action( 'cartflows_init' );
177
- }
178
-
179
- /**
180
- * Load Helper Files and Components.
181
- *
182
- * @since 1.0.0
183
- *
184
- * @return void
185
- */
186
- function load_helper_files_components() {
187
-
188
- /* Public Utils */
189
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php';
190
-
191
- /* Public Session */
192
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-session.php';
193
-
194
- /* Public Global namespace functions */
195
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
196
-
197
- /* Admin Helper */
198
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
199
-
200
- /* Meta Default Values */
201
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php';
202
-
203
- $this->utils = Cartflows_Utils::get_instance();
204
- $this->session = Cartflows_Session::get_instance();
205
- $this->options = Cartflows_Default_Meta::get_instance();
206
- }
207
-
208
- /**
209
- * Init hooked function.
210
- *
211
- * @since 1.0.0
212
- *
213
- * @return void
214
- */
215
- function initialize() {
216
- $this->assets_vars = $this->utils->get_assets_path();
217
- }
218
-
219
- /**
220
- * Load Core Files.
221
- *
222
- * @since 1.0.0
223
- *
224
- * @return void
225
- */
226
- function load_core_files() {
227
-
228
- /* Page builder compatibilty class */
229
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php';
230
-
231
- /* Admin Meta Fields*/
232
- include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php';
233
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php';
234
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php';
235
-
236
- /* Cloning */
237
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php';
238
-
239
- /* Admin Settings */
240
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php';
241
-
242
- /* Core Modules */
243
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php';
244
-
245
- /* Frontend Global */
246
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php';
247
- require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php';
248
-
249
- /* Modules */
250
- include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php';
251
- include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php';
252
- include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php';
253
- include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php';
254
-
255
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php';
256
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php';
257
-
258
- include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php';
259
- include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php';
260
- }
261
-
262
- /**
263
- * Load Core Components.
264
- *
265
- * @since 1.0.0
266
- *
267
- * @return void
268
- */
269
- function load_core_components() {
270
-
271
- $this->meta = Cartflows_Meta_Fields::get_instance();
272
- $this->logger = Cartflows_Logger::get_instance();
273
- $this->flow = Cartflows_Flow_Frontend::get_instance();
274
- }
275
-
276
- /**
277
- * Load CartFlows Pro Text Domain.
278
- * This will load the translation textdomain depending on the file priorities.
279
- * 1. Global Languages /wp-content/languages/cartflows/ folder
280
- * 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder
281
- *
282
- * @since 1.0.3
283
- * @return void
284
- */
285
- public function load_cf_textdomain() {
286
-
287
- // Default languages directory for CartFlows Pro.
288
- $lang_dir = CARTFLOWS_DIR . 'languages/';
289
-
290
- /**
291
- * Filters the languages directory path to use for CartFlows Pro.
292
- *
293
- * @param string $lang_dir The languages directory path.
294
- */
295
- $lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir );
296
-
297
- // Traditional WordPress plugin locale filter.
298
- global $wp_version;
299
-
300
- $get_locale = get_locale();
301
-
302
- if ( $wp_version >= 4.7 ) {
303
- $get_locale = get_user_locale();
304
- }
305
-
306
- /**
307
- * Language Locale for CartFlows Pro
308
- *
309
- * @var $get_locale The locale to use.
310
- * Uses get_user_locale()` in WordPress 4.7 or greater,
311
- * otherwise uses `get_locale()`.
312
- */
313
- $locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' );
314
- $mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale );
315
-
316
- // Setup paths to current locale file.
317
- $mofile_local = $lang_dir . $mofile;
318
- $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
319
-
320
- if ( file_exists( $mofile_global ) ) {
321
- // Look in global /wp-content/languages/cartflows/ folder.
322
- load_textdomain( 'cartflows', $mofile_global );
323
- } elseif ( file_exists( $mofile_local ) ) {
324
- // Look in local /wp-content/plugins/cartflows/languages/ folder.
325
- load_textdomain( 'cartflows', $mofile_local );
326
- } else {
327
- // Load the default language files.
328
- load_plugin_textdomain( 'cartflows', false, $lang_dir );
329
- }
330
- }
331
-
332
- /**
333
- * Fires admin notice when Elementor is not installed and activated.
334
- *
335
- * @since 1.0.0
336
- *
337
- * @return void
338
- */
339
- public function fails_to_load() {
340
-
341
- $screen = get_current_screen();
342
-
343
- if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
344
- return;
345
- }
346
-
347
- $class = 'notice notice-error';
348
- /* translators: %s: html tags */
349
- $message = sprintf( __( 'The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '<strong>', '</strong>' );
350
-
351
- $plugin = 'woocommerce/woocommerce.php';
352
-
353
- if ( _is_woo_installed() ) {
354
- if ( ! current_user_can( 'activate_plugins' ) ) {
355
- return;
356
- }
357
-
358
- $action_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
359
- $button_label = __( 'Activate WooCommerce', 'cartflows' );
360
-
361
- } else {
362
- if ( ! current_user_can( 'install_plugins' ) ) {
363
- return;
364
- }
365
-
366
- $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
367
- $button_label = __( 'Install WooCommerce', 'cartflows' );
368
- }
369
-
370
- $button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
371
-
372
- printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
373
- }
374
-
375
- /**
376
- * Activation Reset
377
- */
378
- function activation_reset() {
379
-
380
- include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php';
381
- include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php';
382
-
383
- Cartflows_Flow_Post_Type::get_instance()->flow_post_type();
384
- Cartflows_Step_Post_Type::get_instance()->step_post_type();
385
- flush_rewrite_rules();
386
- }
387
-
388
- /**
389
- * Deactivation Reset
390
- */
391
- function deactivation_reset() {
392
- }
393
-
394
- /**
395
- * Logger Class Instance
396
- */
397
- function logger() {
398
- return Cartflows_Logger::get_instance();
399
- }
400
-
401
-
402
- }
403
-
404
- /**
405
- * Prepare if class 'Cartflows_Loader' exist.
406
- * Kicking this off by calling 'get_instance()' method
407
- */
408
- Cartflows_Loader::get_instance();
409
- }
410
-
411
- /**
412
- * Get global class.
413
- *
414
- * @return object
415
- */
416
- function wcf() {
417
- return Cartflows_Loader::get_instance();
418
- }
419
-
420
- if ( ! function_exists( '_is_woo_installed' ) ) {
421
-
422
- /**
423
- * Is woocommerce plugin installed.
424
- *
425
- * @since 1.0.0
426
- *
427
- * @access public
428
- */
429
- function _is_woo_installed() {
430
-
431
- $path = 'woocommerce/woocommerce.php';
432
- $plugins = get_plugins();
433
-
434
- return isset( $plugins[ $path ] );
435
- }
436
- }
 
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 session
40
+ */
41
+ public $session = null;
42
+
43
+
44
+ /**
45
+ * Member Variable
46
+ *
47
+ * @var options
48
+ */
49
+ public $options = null;
50
+
51
+ /**
52
+ * Member Variable
53
+ *
54
+ * @var meta
55
+ */
56
+ public $meta = null;
57
+
58
+ /**
59
+ * Member Variable
60
+ *
61
+ * @var flow
62
+ */
63
+ public $flow = null;
64
+
65
+ /**
66
+ * Member Variable
67
+ *
68
+ * @var assets_vars
69
+ */
70
+ public $assets_vars = null;
71
+
72
+ /**
73
+ * Initiator
74
+ */
75
+ public static function get_instance() {
76
+
77
+ if ( is_null( self::$instance ) ) {
78
+
79
+ self::$instance = new self;
80
+
81
+ /**
82
+ * CartFlows loaded.
83
+ *
84
+ * Fires when Cartflows was fully loaded and instantiated.
85
+ *
86
+ * @since 1.0.0
87
+ */
88
+ do_action( 'cartflows_loaded' );
89
+ }
90
+
91
+ return self::$instance;
92
+ }
93
+
94
+ /**
95
+ * Constructor
96
+ */
97
+ public function __construct() {
98
+
99
+ $this->define_constants();
100
+
101
+ // Activation hook.
102
+ register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) );
103
+
104
+ // deActivation hook.
105
+ register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) );
106
+
107
+ add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 );
108
+ add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) );
109
+
110
+ // Update compatibility.
111
+ require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
112
+ }
113
+
114
+ /**
115
+ * Defines all constants
116
+ *
117
+ * @since 1.0.0
118
+ */
119
+ public function define_constants() {
120
+
121
+ define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
122
+ define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
123
+ define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
124
+ define( 'CARTFLOWS_VER', '1.1.15' );
125
+ define( 'CARTFLOWS_SLUG', 'cartflows' );
126
+ define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
127
+
128
+ define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' );
129
+ define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' );
130
+
131
+ if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) {
132
+ define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' );
133
+ }
134
+ define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' );
135
+ define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' );
136
+ define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' );
137
+ define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' );
138
+
139
+ if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) {
140
+ define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' );
141
+ }
142
+ if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER' ) ) {
143
+ define( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER', 'cartflows_flow_page_builder' );
144
+ }
145
+ if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) {
146
+ define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' );
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Loads plugin files.
152
+ *
153
+ * @since 1.0.0
154
+ *
155
+ * @return void
156
+ */
157
+ function load_plugin() {
158
+
159
+ if ( ! function_exists( 'WC' ) ) {
160
+ add_action( 'admin_notices', array( $this, 'fails_to_load' ) );
161
+ return;
162
+ }
163
+
164
+ $this->load_helper_files_components();
165
+ $this->load_core_files();
166
+ $this->load_core_components();
167
+
168
+ add_action( 'wp_loaded', array( $this, 'initialize' ) );
169
+
170
+ /**
171
+ * CartFlows Init.
172
+ *
173
+ * Fires when Cartflows is instantiated.
174
+ *
175
+ * @since 1.0.0
176
+ */
177
+ do_action( 'cartflows_init' );
178
+ }
179
+
180
+ /**
181
+ * Load Helper Files and Components.
182
+ *
183
+ * @since 1.0.0
184
+ *
185
+ * @return void
186
+ */
187
+ function load_helper_files_components() {
188
+
189
+ /* Public Utils */
190
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php';
191
+
192
+ /* Public Session */
193
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-session.php';
194
+
195
+ /* Public Global namespace functions */
196
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
197
+
198
+ /* Admin Helper */
199
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
200
+
201
+ /* Meta Default Values */
202
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php';
203
+
204
+ $this->utils = Cartflows_Utils::get_instance();
205
+ $this->session = Cartflows_Session::get_instance();
206
+ $this->options = Cartflows_Default_Meta::get_instance();
207
+ }
208
+
209
+ /**
210
+ * Init hooked function.
211
+ *
212
+ * @since 1.0.0
213
+ *
214
+ * @return void
215
+ */
216
+ function initialize() {
217
+ $this->assets_vars = $this->utils->get_assets_path();
218
+ }
219
+
220
+ /**
221
+ * Load Core Files.
222
+ *
223
+ * @since 1.0.0
224
+ *
225
+ * @return void
226
+ */
227
+ function load_core_files() {
228
+
229
+ /* Page builder compatibilty class */
230
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php';
231
+
232
+ /* Admin Meta Fields*/
233
+ include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php';
234
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php';
235
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php';
236
+
237
+ /* Cloning */
238
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php';
239
+
240
+ /* Admin Settings */
241
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php';
242
+
243
+ /* Core Modules */
244
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php';
245
+
246
+ /* Frontend Global */
247
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php';
248
+ require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php';
249
+
250
+ /* Modules */
251
+ include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php';
252
+ include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php';
253
+ include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php';
254
+ include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php';
255
+
256
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php';
257
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php';
258
+
259
+ include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php';
260
+ include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php';
261
+ }
262
+
263
+ /**
264
+ * Load Core Components.
265
+ *
266
+ * @since 1.0.0
267
+ *
268
+ * @return void
269
+ */
270
+ function load_core_components() {
271
+
272
+ $this->meta = Cartflows_Meta_Fields::get_instance();
273
+ $this->logger = Cartflows_Logger::get_instance();
274
+ $this->flow = Cartflows_Flow_Frontend::get_instance();
275
+ }
276
+
277
+ /**
278
+ * Load CartFlows Pro Text Domain.
279
+ * This will load the translation textdomain depending on the file priorities.
280
+ * 1. Global Languages /wp-content/languages/cartflows/ folder
281
+ * 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder
282
+ *
283
+ * @since 1.0.3
284
+ * @return void
285
+ */
286
+ public function load_cf_textdomain() {
287
+
288
+ // Default languages directory for CartFlows Pro.
289
+ $lang_dir = CARTFLOWS_DIR . 'languages/';
290
+
291
+ /**
292
+ * Filters the languages directory path to use for CartFlows Pro.
293
+ *
294
+ * @param string $lang_dir The languages directory path.
295
+ */
296
+ $lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir );
297
+
298
+ // Traditional WordPress plugin locale filter.
299
+ global $wp_version;
300
+
301
+ $get_locale = get_locale();
302
+
303
+ if ( $wp_version >= 4.7 ) {
304
+ $get_locale = get_user_locale();
305
+ }
306
+
307
+ /**
308
+ * Language Locale for CartFlows Pro
309
+ *
310
+ * @var $get_locale The locale to use.
311
+ * Uses get_user_locale()` in WordPress 4.7 or greater,
312
+ * otherwise uses `get_locale()`.
313
+ */
314
+ $locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' );
315
+ $mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale );
316
+
317
+ // Setup paths to current locale file.
318
+ $mofile_local = $lang_dir . $mofile;
319
+ $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
320
+
321
+ if ( file_exists( $mofile_global ) ) {
322
+ // Look in global /wp-content/languages/cartflows/ folder.
323
+ load_textdomain( 'cartflows', $mofile_global );
324
+ } elseif ( file_exists( $mofile_local ) ) {
325
+ // Look in local /wp-content/plugins/cartflows/languages/ folder.
326
+ load_textdomain( 'cartflows', $mofile_local );
327
+ } else {
328
+ // Load the default language files.
329
+ load_plugin_textdomain( 'cartflows', false, $lang_dir );
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Fires admin notice when Elementor is not installed and activated.
335
+ *
336
+ * @since 1.0.0
337
+ *
338
+ * @return void
339
+ */
340
+ public function fails_to_load() {
341
+
342
+ $screen = get_current_screen();
343
+
344
+ if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
345
+ return;
346
+ }
347
+
348
+ $class = 'notice notice-error';
349
+ /* translators: %s: html tags */
350
+ $message = sprintf( __( 'The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '<strong>', '</strong>' );
351
+
352
+ $plugin = 'woocommerce/woocommerce.php';
353
+
354
+ if ( _is_woo_installed() ) {
355
+ if ( ! current_user_can( 'activate_plugins' ) ) {
356
+ return;
357
+ }
358
+
359
+ $action_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
360
+ $button_label = __( 'Activate WooCommerce', 'cartflows' );
361
+
362
+ } else {
363
+ if ( ! current_user_can( 'install_plugins' ) ) {
364
+ return;
365
+ }
366
+
367
+ $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
368
+ $button_label = __( 'Install WooCommerce', 'cartflows' );
369
+ }
370
+
371
+ $button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
372
+
373
+ printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
374
+ }
375
+
376
+ /**
377
+ * Activation Reset
378
+ */
379
+ function activation_reset() {
380
+
381
+ include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php';
382
+ include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php';
383
+
384
+ Cartflows_Flow_Post_Type::get_instance()->flow_post_type();
385
+ Cartflows_Step_Post_Type::get_instance()->step_post_type();
386
+ flush_rewrite_rules();
387
+ }
388
+
389
+ /**
390
+ * Deactivation Reset
391
+ */
392
+ function deactivation_reset() {
393
+ }
394
+
395
+ /**
396
+ * Logger Class Instance
397
+ */
398
+ function logger() {
399
+ return Cartflows_Logger::get_instance();
400
+ }
401
+
402
+
403
+ }
404
+
405
+ /**
406
+ * Prepare if class 'Cartflows_Loader' exist.
407
+ * Kicking this off by calling 'get_instance()' method
408
+ */
409
+ Cartflows_Loader::get_instance();
410
+ }
411
+
412
+ /**
413
+ * Get global class.
414
+ *
415
+ * @return object
416
+ */
417
+ function wcf() {
418
+ return Cartflows_Loader::get_instance();
419
+ }
420
+
421
+ if ( ! function_exists( '_is_woo_installed' ) ) {
422
+
423
+ /**
424
+ * Is woocommerce plugin installed.
425
+ *
426
+ * @since 1.0.0
427
+ *
428
+ * @access public
429
+ */
430
+ function _is_woo_installed() {
431
+
432
+ $path = 'woocommerce/woocommerce.php';
433
+ $plugins = get_plugins();
434
+
435
+ return isset( $plugins[ $path ] );
436
+ }
437
+ }
classes/class-cartflows-utils.php CHANGED
@@ -1,411 +1,411 @@
1
- <?php
2
- /**
3
- * Utils.
4
- *
5
- * @package CARTFLOWS
6
- */
7
-
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit; // Exit if accessed directly.
10
- }
11
-
12
- /**
13
- * Class Cartflows_Utils.
14
- */
15
- class Cartflows_Utils {
16
-
17
- /**
18
- * Member Variable
19
- *
20
- * @var instance
21
- */
22
- private static $instance;
23
-
24
- /**
25
- * Initiator
26
- */
27
- public static function get_instance() {
28
- if ( ! isset( self::$instance ) ) {
29
- self::$instance = new self;
30
- }
31
- return self::$instance;
32
- }
33
-
34
- /**
35
- * Constructor
36
- */
37
- function __construct() {
38
- }
39
-
40
- /**
41
- * Get current post type
42
- *
43
- * @param string $post_type post type.
44
- * @return string
45
- */
46
- function current_post_type( $post_type = '' ) {
47
-
48
- if ( '' === $post_type ) {
49
- $post_type = get_post_type();
50
- }
51
-
52
- return $post_type;
53
- }
54
-
55
- /**
56
- * Check if post type is of step.
57
- *
58
- * @param string $post_type post type.
59
- * @return bool
60
- */
61
- function is_step_post_type( $post_type = '' ) {
62
-
63
- if ( $this->get_step_post_type() === $this->current_post_type( $post_type ) ) {
64
-
65
- return true;
66
- }
67
-
68
- return false;
69
- }
70
-
71
- /**
72
- * Check if post type is of flow.
73
- *
74
- * @param string $post_type post type.
75
- * @return bool
76
- */
77
- function is_flow_post_type( $post_type = '' ) {
78
-
79
- if ( $this->get_flow_post_type() === $this->current_post_type( $post_type ) ) {
80
-
81
- return true;
82
- }
83
-
84
- return false;
85
- }
86
-
87
- /**
88
- * Get post type of step.
89
- *
90
- * @return string
91
- */
92
- function get_step_post_type() {
93
-
94
- return CARTFLOWS_STEP_POST_TYPE;
95
- }
96
-
97
- /**
98
- * Get post type of flow.
99
- *
100
- * @return string
101
- */
102
- function get_flow_post_type() {
103
-
104
- return CARTFLOWS_FLOW_POST_TYPE;
105
- }
106
-
107
- /**
108
- * Get flow id
109
- *
110
- * @return int
111
- */
112
- function get_flow_id() {
113
-
114
- global $post;
115
-
116
- return get_post_meta( $post->ID, 'wcf-flow-id', true );
117
- }
118
-
119
- /**
120
- * Get flow id by step
121
- *
122
- * @param int $step_id step ID.
123
- * @return int
124
- */
125
- function get_flow_id_from_step_id( $step_id ) {
126
-
127
- return get_post_meta( $step_id, 'wcf-flow-id', true );
128
- }
129
-
130
- /**
131
- * Get flow steps by id
132
- *
133
- * @param int $flow_id flow ID.
134
- * @return int
135
- */
136
- function get_flow_steps( $flow_id ) {
137
-
138
- $steps = get_post_meta( $flow_id, 'wcf-steps', true );
139
-
140
- if ( is_array( $steps ) && ! empty( $steps ) ) {
141
- return $steps;
142
- }
143
-
144
- return false;
145
- }
146
-
147
- /**
148
- * Get template type of step
149
- *
150
- * @param int $step_id step ID.
151
- * @return int
152
- */
153
- function get_step_type( $step_id ) {
154
-
155
- return get_post_meta( $step_id, 'wcf-step-type', true );
156
- }
157
-
158
- /**
159
- * Get next id for step
160
- *
161
- * @param int $flow_id flow ID.
162
- * @param int $step_id step ID.
163
- * @return bool
164
- */
165
- function get_next_step_id( $flow_id, $step_id ) {
166
-
167
- $steps = $this->get_flow_steps( $flow_id );
168
- $step_id = intval( $step_id );
169
-
170
- if ( ! $steps ) {
171
- return false;
172
- }
173
-
174
- foreach ( $steps as $i => $step ) {
175
-
176
- if ( intval( $step['id'] ) === $step_id ) {
177
-
178
- $next_i = $i + 1;
179
-
180
- if ( isset( $steps[ $next_i ] ) ) {
181
-
182
- $navigation = $steps[ $next_i ];
183
-
184
- return intval( $navigation['id'] );
185
- }
186
-
187
- break;
188
- }
189
- }
190
-
191
- return false;
192
- }
193
-
194
- /**
195
- * Get next id for step
196
- *
197
- * @param int $order_id order ID.
198
- * @return int
199
- */
200
- function get_flow_id_from_order( $order_id ) {
201
-
202
- $flow_id = get_post_meta( $order_id, '_wcf_flow_id', true );
203
-
204
- return intval( $flow_id );
205
- }
206
-
207
- /**
208
- * Get checkout id for order
209
- *
210
- * @param int $order_id order ID.
211
- * @return int
212
- */
213
- function get_checkout_id_from_order( $order_id ) {
214
-
215
- $checkout_id = get_post_meta( $order_id, '_wcf_checkout_id', true );
216
-
217
- return intval( $checkout_id );
218
- }
219
-
220
- /**
221
- * We are using this function mostly in ajax on checkout page
222
- *
223
- * @return bool
224
- */
225
- function get_checkout_id_from_post_data() {
226
-
227
- if ( isset( $_POST['_wcf_checkout_id'] ) ) {
228
-
229
- $checkout_id = filter_var( $_POST['_wcf_checkout_id'], FILTER_SANITIZE_NUMBER_INT );
230
-
231
- return intval( $checkout_id );
232
- }
233
-
234
- return false;
235
- }
236
-
237
- /**
238
- * We are using this function mostly in ajax on checkout page
239
- *
240
- * @return bool
241
- */
242
- function get_flow_id_from_post_data() {
243
-
244
- if ( isset( $_POST['_wcf_flow_id'] ) ) {
245
-
246
- $flow_id = filter_var( $_POST['_wcf_flow_id'], FILTER_SANITIZE_NUMBER_INT );
247
-
248
- return intval( $flow_id );
249
- }
250
-
251
- return false;
252
- }
253
-
254
- /**
255
- * Check for thank you page
256
- *
257
- * @param int $step_id step ID.
258
- * @return bool
259
- */
260
- function check_is_thankyou_page( $step_id ) {
261
-
262
- $step_type = $this->get_step_type( $step_id );
263
-
264
- if ( 'thankyou' === $step_type ) {
265
-
266
- return true;
267
- }
268
-
269
- return false;
270
- }
271
-
272
- /**
273
- * Check for offer page
274
- *
275
- * @param int $step_id step ID.
276
- * @return bool
277
- */
278
- function check_is_offer_page( $step_id ) {
279
-
280
- $step_type = $this->get_step_type( $step_id );
281
-
282
- if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
283
-
284
- return true;
285
- }
286
-
287
- return false;
288
- }
289
-
290
- /**
291
- * Define constant for cache
292
- *
293
- * @return void
294
- */
295
- function do_not_cache() {
296
-
297
- wc_maybe_define_constant( 'DONOTCACHEPAGE', true );
298
- wc_maybe_define_constant( 'DONOTCACHEOBJECT', true );
299
- wc_maybe_define_constant( 'DONOTCACHEDB', true );
300
-
301
- nocache_headers();
302
- }
303
-
304
- /**
305
- * Get linking url
306
- *
307
- * @param array $args query args.
308
- * @return string
309
- */
310
- function get_linking_url( $args = array() ) {
311
-
312
- $url = get_home_url();
313
-
314
- $url = add_query_arg( $args, $url );
315
-
316
- return $url;
317
- }
318
-
319
- /**
320
- * Get assets urls
321
- *
322
- * @return array
323
- * @since 1.1.6
324
- */
325
- function get_assets_path() {
326
-
327
- $rtl = '';
328
-
329
- if ( is_rtl() ) {
330
- $rtl = '-rtl';
331
- }
332
-
333
- $file_prefix = '';
334
- $dir_name = '';
335
-
336
- $is_min = apply_filters( 'cartflows_load_min_assets', false );
337
-
338
- if ( $is_min ) {
339
- $file_prefix = '.min';
340
- $dir_name = 'min-';
341
- }
342
-
343
- $js_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'js/';
344
- $css_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'css/';
345
-
346
- return array(
347
- 'css' => $css_gen_path,
348
- 'js' => $js_gen_path,
349
- 'file_prefix' => $file_prefix,
350
- 'rtl' => $rtl,
351
- );
352
- }
353
-
354
- /**
355
- * Get assets css url
356
- *
357
- * @param string $file file name.
358
- * @return string
359
- * @since 1.1.6
360
- */
361
- function get_css_url( $file ) {
362
-
363
- $assets_vars = wcf()->assets_vars;
364
-
365
- $url = $assets_vars['css'] . $file . $assets_vars['rtl'] . $assets_vars['file_prefix'] . '.css';
366
-
367
- return $url;
368
- }
369
-
370
- /**
371
- * Get assets js url
372
- *
373
- * @param string $file file name.
374
- * @return string
375
- * @since 1.1.6
376
- */
377
- function get_js_url( $file ) {
378
-
379
- $assets_vars = wcf()->assets_vars;
380
-
381
- $url = $assets_vars['js'] . $file . $assets_vars['file_prefix'] . '.js';
382
-
383
- return $url;
384
- }
385
- }
386
-
387
- /**
388
- * Get a specific property of an array without needing to check if that property exists.
389
- *
390
- * Provide a default value if you want to return a specific value if the property is not set.
391
- *
392
- * @param array $array Array from which the property's value should be retrieved.
393
- * @param string $prop Name of the property to be retrieved.
394
- * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null.
395
- *
396
- * @return null|string|mixed The value
397
- */
398
- function wcf_get_prop( $array, $prop, $default = null ) {
399
-
400
- if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) {
401
- return $default;
402
- }
403
-
404
- if ( isset( $array[ $prop ] ) ) {
405
- $value = $array[ $prop ];
406
- } else {
407
- $value = '';
408
- }
409
-
410
- return empty( $value ) && null !== $default ? $default : $value;
411
- }
1
+ <?php
2
+ /**
3
+ * Utils.
4
+ *
5
+ * @package CARTFLOWS
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit; // Exit if accessed directly.
10
+ }
11
+
12
+ /**
13
+ * Class Cartflows_Utils.
14
+ */
15
+ class Cartflows_Utils {
16
+
17
+ /**
18
+ * Member Variable
19
+ *
20
+ * @var instance
21
+ */
22
+ private static $instance;
23
+
24
+ /**
25
+ * Initiator
26
+ */
27
+ public static function get_instance() {
28
+ if ( ! isset( self::$instance ) ) {
29
+ self::$instance = new self;
30
+ }
31
+ return self::$instance;
32
+ }
33
+
34
+ /**
35
+ * Constructor
36
+ */
37
+ function __construct() {
38
+ }
39
+
40
+ /**
41
+ * Get current post type
42
+ *
43
+ * @param string $post_type post type.
44
+ * @return string
45
+ */
46
+ function current_post_type( $post_type = '' ) {
47
+
48
+ if ( '' === $post_type ) {
49
+ $post_type = get_post_type();
50
+ }
51
+
52
+ return $post_type;
53
+ }
54
+
55
+ /**
56
+ * Check if post type is of step.
57
+ *
58
+ * @param string $post_type post type.
59
+ * @return bool
60
+ */
61
+ function is_step_post_type( $post_type = '' ) {
62
+
63
+ if ( $this->get_step_post_type() === $this->current_post_type( $post_type ) ) {
64
+
65
+ return true;
66
+ }
67
+
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * Check if post type is of flow.
73
+ *
74
+ * @param string $post_type post type.
75
+ * @return bool
76
+ */
77
+ function is_flow_post_type( $post_type = '' ) {
78
+
79
+ if ( $this->get_flow_post_type() === $this->current_post_type( $post_type ) ) {
80
+
81
+ return true;
82
+ }
83
+
84
+ return false;
85
+ }
86
+
87
+ /**
88
+ * Get post type of step.
89
+ *
90
+ * @return string
91
+ */
92
+ function get_step_post_type() {
93
+
94
+ return CARTFLOWS_STEP_POST_TYPE;
95
+ }
96
+
97
+ /**
98
+ * Get post type of flow.
99
+ *
100
+ * @return string
101
+ */
102
+ function get_flow_post_type() {
103
+
104
+ return CARTFLOWS_FLOW_POST_TYPE;
105
+ }
106
+
107
+ /**
108
+ * Get flow id
109
+ *
110
+ * @return int
111
+ */
112
+ function get_flow_id() {
113
+
114
+ global $post;
115
+
116
+ return get_post_meta( $post->ID, 'wcf-flow-id', true );
117
+ }
118
+
119
+ /**
120
+ * Get flow id by step
121
+ *
122
+ * @param int $step_id step ID.
123
+ * @return int
124
+ */
125
+ function get_flow_id_from_step_id( $step_id ) {
126
+
127
+ return get_post_meta( $step_id, 'wcf-flow-id', true );
128
+ }
129
+
130
+ /**
131
+ * Get flow steps by id
132
+ *
133
+ * @param int $flow_id flow ID.
134
+ * @return int
135
+ */
136
+ function get_flow_steps( $flow_id ) {
137
+
138
+ $steps = get_post_meta( $flow_id, 'wcf-steps', true );
139
+
140
+ if ( is_array( $steps ) && ! empty( $steps ) ) {
141
+ return $steps;
142
+ }
143
+
144
+ return false;
145
+ }
146
+
147
+ /**
148
+ * Get template type of step
149
+ *
150
+ * @param int $step_id step ID.
151
+ * @return int
152
+ */
153
+ function get_step_type( $step_id ) {
154
+
155
+ return get_post_meta( $step_id, 'wcf-step-type', true );
156
+ }
157
+
158
+ /**
159
+ * Get next id for step
160
+ *
161
+ * @param int $flow_id flow ID.
162
+ * @param int $step_id step ID.
163
+ * @return bool
164
+ */
165
+ function get_next_step_id( $flow_id, $step_id ) {
166
+
167
+ $steps = $this->get_flow_steps( $flow_id );
168
+ $step_id = intval( $step_id );
169
+
170
+ if ( ! $steps ) {
171
+ return false;
172
+ }
173
+
174
+ foreach ( $steps as $i => $step ) {
175
+
176
+ if ( intval( $step['id'] ) === $step_id ) {
177
+
178
+ $next_i = $i + 1;
179
+
180
+ if ( isset( $steps[ $next_i ] ) ) {
181
+
182
+ $navigation = $steps[ $next_i ];
183
+
184
+ return intval( $navigation['id'] );
185
+ }
186
+
187
+ break;
188
+ }
189
+ }
190
+
191
+ return false;
192
+ }
193
+
194
+ /**
195
+ * Get next id for step
196
+ *
197
+ * @param int $order_id order ID.
198
+ * @return int
199
+ */
200
+ function get_flow_id_from_order( $order_id ) {
201
+
202
+ $flow_id = get_post_meta( $order_id, '_wcf_flow_id', true );
203
+
204
+ return intval( $flow_id );
205
+ }
206
+
207
+ /**
208
+ * Get checkout id for order
209
+ *
210
+ * @param int $order_id order ID.
211
+ * @return int
212
+ */
213
+ function get_checkout_id_from_order( $order_id ) {
214
+
215
+ $checkout_id = get_post_meta( $order_id, '_wcf_checkout_id', true );
216
+
217
+ return intval( $checkout_id );
218
+ }
219
+
220
+ /**
221
+ * We are using this function mostly in ajax on checkout page
222
+ *
223
+ * @return bool
224
+ */
225
+ function get_checkout_id_from_post_data() {
226
+
227
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) {
228
+
229
+ $checkout_id = filter_var( $_POST['_wcf_checkout_id'], FILTER_SANITIZE_NUMBER_INT );
230
+
231
+ return intval( $checkout_id );
232
+ }
233
+
234
+ return false;
235
+ }
236
+
237
+ /**
238
+ * We are using this function mostly in ajax on checkout page
239
+ *
240
+ * @return bool
241
+ */
242
+ function get_flow_id_from_post_data() {
243
+
244
+ if ( isset( $_POST['_wcf_flow_id'] ) ) {
245
+
246
+ $flow_id = filter_var( $_POST['_wcf_flow_id'], FILTER_SANITIZE_NUMBER_INT );
247
+
248
+ return intval( $flow_id );
249
+ }
250
+
251
+ return false;
252
+ }
253
+
254
+ /**
255
+ * Check for thank you page
256
+ *
257
+ * @param int $step_id step ID.
258
+ * @return bool
259
+ */
260
+ function check_is_thankyou_page( $step_id ) {
261
+
262
+ $step_type = $this->get_step_type( $step_id );
263
+
264
+ if ( 'thankyou' === $step_type ) {
265
+
266
+ return true;
267
+ }
268
+
269
+ return false;
270
+ }
271
+
272
+ /**
273
+ * Check for offer page
274
+ *
275
+ * @param int $step_id step ID.
276
+ * @return bool
277
+ */
278
+ function check_is_offer_page( $step_id ) {
279
+
280
+ $step_type = $this->get_step_type( $step_id );
281
+
282
+ if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
283
+
284
+ return true;
285
+ }
286
+
287
+ return false;
288
+ }
289
+
290
+ /**
291
+ * Define constant for cache
292
+ *
293
+ * @return void
294
+ */
295
+ function do_not_cache() {
296
+
297
+ wc_maybe_define_constant( 'DONOTCACHEPAGE', true );
298
+ wc_maybe_define_constant( 'DONOTCACHEOBJECT', true );
299
+ wc_maybe_define_constant( 'DONOTCACHEDB', true );
300
+
301
+ nocache_headers();
302
+ }
303
+
304
+ /**
305
+ * Get linking url
306
+ *
307
+ * @param array $args query args.
308
+ * @return string
309
+ */
310
+ function get_linking_url( $args = array() ) {
311
+
312
+ $url = get_home_url();
313
+
314
+ $url = add_query_arg( $args, $url );
315
+
316
+ return $url;
317
+ }
318
+
319
+ /**
320
+ * Get assets urls
321
+ *
322
+ * @return array
323
+ * @since 1.1.6
324
+ */
325
+ function get_assets_path() {
326
+
327
+ $rtl = '';
328
+
329
+ if ( is_rtl() ) {
330
+ $rtl = '-rtl';
331
+ }
332
+
333
+ $file_prefix = '';
334
+ $dir_name = '';
335
+
336
+ $is_min = apply_filters( 'cartflows_load_min_assets', false );
337
+
338
+ if ( $is_min ) {
339
+ $file_prefix = '.min';
340
+ $dir_name = 'min-';
341
+ }
342
+
343
+ $js_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'js/';
344
+ $css_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'css/';
345
+
346
+ return array(
347
+ 'css' => $css_gen_path,
348
+ 'js' => $js_gen_path,
349
+ 'file_prefix' => $file_prefix,
350
+ 'rtl' => $rtl,
351
+ );
352
+ }
353
+
354
+ /**
355
+ * Get assets css url
356
+ *
357
+ * @param string $file file name.
358
+ * @return string
359
+ * @since 1.1.6
360
+ */
361
+ function get_css_url( $file ) {
362
+
363
+ $assets_vars = wcf()->assets_vars;
364
+
365
+ $url = $assets_vars['css'] . $file . $assets_vars['rtl'] . $assets_vars['file_prefix'] . '.css';
366
+
367
+ return $url;
368
+ }
369
+
370
+ /**
371
+ * Get assets js url
372
+ *
373
+ * @param string $file file name.
374
+ * @return string
375
+ * @since 1.1.6
376
+ */
377
+ function get_js_url( $file ) {
378
+
379
+ $assets_vars = wcf()->assets_vars;
380
+
381
+ $url = $assets_vars['js'] . $file . $assets_vars['file_prefix'] . '.js';
382
+
383
+ return $url;
384
+ }
385
+ }
386
+
387
+ /**
388
+ * Get a specific property of an array without needing to check if that property exists.
389
+ *
390
+ * Provide a default value if you want to return a specific value if the property is not set.
391
+ *
392
+ * @param array $array Array from which the property's value should be retrieved.
393
+ * @param string $prop Name of the property to be retrieved.
394
+ * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null.
395
+ *
396
+ * @return null|string|mixed The value
397
+ */
398
+ function wcf_get_prop( $array, $prop, $default = null ) {
399
+
400
+ if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) {
401
+ return $default;
402
+ }
403
+
404
+ if ( isset( $array[ $prop ] ) ) {
405
+ $value = $array[ $prop ];
406
+ } else {
407
+ $value = '';
408
+ }
409
+
410
+ return empty( $value ) && null !== $default ? $default : $value;
411
+ }
includes/admin/cartflows-general.php CHANGED
@@ -1,185 +1,185 @@
1
- <?php
2
- /**
3
- * General settings
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- $settings = Cartflows_Helper::get_common_settings();
9
-
10
- $debug_data = Cartflows_Helper::get_debug_settings();
11
-
12
- $debug_on = ( isset( $_GET['debug'] ) ) ? sanitize_text_field( $_GET['debug'] ) : 'false';
13
- ?>
14
-
15
-
16
- <div class="wrap wcf-addon-wrap wcf-clear wcf-container">
17
- <input type="hidden" name="action" value="wcf_save_common_settings">
18
- <h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
19
-
20
- <div id="poststuff">
21
- <div id="post-body" class="columns-2">
22
- <div id="post-body-content">
23
- <div class="postbox introduction">
24
- <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
25
- <span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
26
- </h2>
27
- <div class="inside">
28
- <div class="iframe-wrap">
29
- <iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
30
- </div>
31
- <p>
32
- <?php
33
- esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
34
- ?>
35
- </p>
36
- </div>
37
- </div>
38
-
39
- <div class="general-settings-form postbox">
40
- <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
41
- <span><?php _e( 'General Settings', 'cartflows' ); ?></span>
42
- </h2>
43
- <div class="inside">
44
- <form method="post" class="wrap wcf-clear" action="" >
45
- <div class="form-wrap">
46
- <?php
47
-
48
- do_action( 'cartflows_before_settings_fields', $settings );
49
-
50
- echo Cartflows_Admin_Fields::checkobox_field(
51
- array(
52
- 'id' => 'wcf_disallow_indexing',
53
- 'name' => '_cartflows_common[disallow_indexing]',
54
- 'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
55
- 'value' => $settings['disallow_indexing'],
56
- )
57
- );
58
-
59
- echo Cartflows_Admin_Fields::flow_checkout_selection_field(
60
- array(
61
- 'id' => 'wcf_global_checkout',
62
- 'name' => '_cartflows_common[global_checkout]',
63
- 'title' => __( 'Global Checkout', 'cartflows' ),
64
- 'value' => $settings['global_checkout'],
65
- )
66
- );
67
-
68
- echo Cartflows_Admin_Fields::select_field(
69
- array(
70
- 'id' => 'wcf_default_page_builder',
71
- 'name' => '_cartflows_common[default_page_builder]',
72
- 'title' => __( 'Show Templates designed with', 'cartflows' ),
73
- 'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
74
- 'value' => $settings['default_page_builder'],
75
- 'options' => array(
76
- 'elementor' => __( 'Elementor', 'cartflows' ),
77
- 'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
78
- 'divi' => __( 'Divi', 'cartflows' ),
79
- 'other' => __( 'Other', 'cartflows' ),
80
- ),
81
- )
82
- );
83
-
84
- do_action( 'cartflows_after_settings_fields', $settings );
85
-
86
- ?>
87
- </div>
88
- <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
89
- <?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
90
- </form>
91
- </div>
92
- </div>
93
- </div>
94
- <div class="postbox-container" id="postbox-container-1">
95
- <div id="side-sortables">
96
-
97
- <div class="postbox">
98
- <h2 class="hndle">
99
- <span class="dashicons dashicons-book"></span>
100
- <span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
101
- </h2>
102
- <div class="inside">
103
- <p>
104
- <?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
105
- </p>
106
- <p>
107
- <a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
108
- </p>
109
- </div>
110
- </div>
111
-
112
- <div class="postbox">
113
- <h2 class="hndle">
114
- <span class="dashicons dashicons-groups"></span>
115
- <span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
116
- </h2>
117
- <div class="inside">
118
- <p>
119
- <?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
120
- </p>
121
- <p>
122
- <a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
123
- </p>
124
- </div>
125
- </div>
126
-
127
- <div class="postbox">
128
- <h2 class="hndle">
129
- <span class="dashicons dashicons-sos"></span>
130
- <span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
131
- </h2>
132
- <div class="inside">
133
- <p>
134
- <?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
135
- </p>
136
- <p>
137
- <a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
138
- </p>
139
- </div>
140
- </div>
141
- <?php
142
- if ( 'true' == $debug_on ) {
143
- ?>
144
- <div class="postbox">
145
- <h2 class="hndle">
146
- <span class="dashicons dashicons-editor-code"></span>
147
- <span><?php esc_html_e( 'Load Minified CSS', 'cartflows' ); ?></span>
148
- </h2>
149
- <div class="inside">
150
- <form method="post" class="wrap wcf-clear" action="">
151
- <p>
152
- <?php esc_html_e( 'Load the Minified CSS from here. Just Enable it by checking the below given checkbox.', 'cartflows' ); ?>
153
- </p>
154
- <?php
155
- echo Cartflows_Admin_Fields::checkobox_field(
156
- array(
157
- 'id' => 'allow_minified_files',
158
- 'name' => '_cartflows_debug_data[allow_minified_files]',
159
- 'title' => __( 'Load minified CSS & JS Files', 'cartflows' ),
160
- 'value' => $debug_data['allow_minified_files'],
161
- )
162
- );
163
- ?>
164
- <?php submit_button( __( 'Save', 'cartflows' ), 'button-primary button', 'submit', false ); ?>
165
- <?php wp_nonce_field( 'cartflows-debug-settings', 'cartflows-debug-settings-nonce' ); ?>
166
- </form>
167
- </div>
168
- </div>
169
- <?php
170
- }
171
- ?>
172
- </div>
173
- </div>
174
- </div>
175
- <!-- /post-body -->
176
- <br class="clear">
177
- </div>
178
- </div>
179
-
180
- <?php
181
- /**
182
- * Loads Zapier settings admin view.
183
- */
184
- do_action( 'cartflows_after_general_settings' );
185
- ?>
1
+ <?php
2
+ /**
3
+ * General settings
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ $settings = Cartflows_Helper::get_common_settings();
9
+
10
+ $debug_data = Cartflows_Helper::get_debug_settings();
11
+
12
+ $debug_on = ( isset( $_GET['debug'] ) ) ? sanitize_text_field( $_GET['debug'] ) : 'false';
13
+ ?>
14
+
15
+
16
+ <div class="wrap wcf-addon-wrap wcf-clear wcf-container">
17
+ <input type="hidden" name="action" value="wcf_save_common_settings">
18
+ <h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
19
+
20
+ <div id="poststuff">
21
+ <div id="post-body" class="columns-2">
22
+ <div id="post-body-content">
23
+ <div class="postbox introduction">
24
+ <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
25
+ <span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
26
+ </h2>
27
+ <div class="inside">
28
+ <div class="iframe-wrap">
29
+ <iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
30
+ </div>
31
+ <p>
32
+ <?php
33
+ esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
34
+ ?>
35
+ </p>
36
+ </div>
37
+ </div>
38
+
39
+ <div class="general-settings-form postbox">
40
+ <h2 class="hndle wcf-normal-cusror ui-sortable-handle">
41
+ <span><?php _e( 'General Settings', 'cartflows' ); ?></span>
42
+ </h2>
43
+ <div class="inside">
44
+ <form method="post" class="wrap wcf-clear" action="" >
45
+ <div class="form-wrap">
46
+ <?php
47
+
48
+ do_action( 'cartflows_before_settings_fields', $settings );
49
+
50
+ echo Cartflows_Admin_Fields::checkobox_field(
51
+ array(
52
+ 'id' => 'wcf_disallow_indexing',
53
+ 'name' => '_cartflows_common[disallow_indexing]',
54
+ 'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
55
+ 'value' => $settings['disallow_indexing'],
56
+ )
57
+ );
58
+
59
+ echo Cartflows_Admin_Fields::flow_checkout_selection_field(
60
+ array(
61
+ 'id' => 'wcf_global_checkout',
62
+ 'name' => '_cartflows_common[global_checkout]',
63
+ 'title' => __( 'Global Checkout', 'cartflows' ),
64
+ 'value' => $settings['global_checkout'],
65
+ )
66
+ );
67
+
68
+ echo Cartflows_Admin_Fields::select_field(
69
+ array(
70
+ 'id' => 'wcf_default_page_builder',
71
+ 'name' => '_cartflows_common[default_page_builder]',
72
+ 'title' => __( 'Show Templates designed with', 'cartflows' ),
73
+ 'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
74
+ 'value' => $settings['default_page_builder'],
75
+ 'options' => array(
76
+ 'elementor' => __( 'Elementor', 'cartflows' ),
77
+ 'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
78
+ 'divi' => __( 'Divi', 'cartflows' ),
79
+ 'other' => __( 'Other', 'cartflows' ),
80
+ ),
81
+ )
82
+ );
83
+
84
+ do_action( 'cartflows_after_settings_fields', $settings );
85
+
86
+ ?>
87
+ </div>
88
+ <?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
89
+ <?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
90
+ </form>
91
+ </div>
92
+ </div>
93
+ </div>
94
+ <div class="postbox-container" id="postbox-container-1">
95
+ <div id="side-sortables">
96
+
97
+ <div class="postbox">
98
+ <h2 class="hndle">
99
+ <span class="dashicons dashicons-book"></span>
100
+ <span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
101
+ </h2>
102
+ <div class="inside">
103
+ <p>
104
+ <?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
105
+ </p>
106
+ <p>
107
+ <a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
108
+ </p>
109
+ </div>
110
+ </div>
111
+
112
+ <div class="postbox">
113
+ <h2 class="hndle">
114
+ <span class="dashicons dashicons-groups"></span>
115
+ <span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
116
+ </h2>
117
+ <div class="inside">
118
+ <p>
119
+ <?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
120
+ </p>
121
+ <p>
122
+ <a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
123
+ </p>
124
+ </div>
125
+ </div>
126
+
127
+ <div class="postbox">
128
+ <h2 class="hndle">
129
+ <span class="dashicons dashicons-sos"></span>
130
+ <span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
131
+ </h2>
132
+ <div class="inside">
133
+ <p>
134
+ <?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
135
+ </p>
136
+ <p>
137
+ <a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
138
+ </p>
139
+ </div>
140
+ </div>
141
+ <?php
142
+ if ( 'true' == $debug_on ) {
143
+ ?>
144
+ <div class="postbox">
145
+ <h2 class="hndle">
146
+ <span class="dashicons dashicons-editor-code"></span>
147
+ <span><?php esc_html_e( 'Load Minified CSS', 'cartflows' ); ?></span>
148
+ </h2>
149
+ <div class="inside">
150
+ <form method="post" class="wrap wcf-clear" action="">
151
+ <p>
152
+ <?php esc_html_e( 'Load the Minified CSS from here. Just Enable it by checking the below given checkbox.', 'cartflows' ); ?>
153
+ </p>
154
+ <?php
155
+ echo Cartflows_Admin_Fields::checkobox_field(
156
+ array(
157
+ 'id' => 'allow_minified_files',
158
+ 'name' => '_cartflows_debug_data[allow_minified_files]',
159
+ 'title' => __( 'Load minified CSS & JS Files', 'cartflows' ),
160
+ 'value' => $debug_data['allow_minified_files'],
161
+ )
162
+ );
163
+ ?>
164
+ <?php submit_button( __( 'Save', 'cartflows' ), 'button-primary button', 'submit', false ); ?>
165
+ <?php wp_nonce_field( 'cartflows-debug-settings', 'cartflows-debug-settings-nonce' ); ?>
166
+ </form>
167
+ </div>
168
+ </div>
169
+ <?php
170
+ }
171
+ ?>
172
+ </div>
173
+ </div>
174
+ </div>
175
+ <!-- /post-body -->
176
+ <br class="clear">
177
+ </div>
178
+ </div>
179
+
180
+ <?php
181
+ /**
182
+ * Loads Zapier settings admin view.
183
+ */
184
+ do_action( 'cartflows_after_general_settings' );
185
+ ?>
modules/checkout/classes/class-cartflows-checkout-markup.php CHANGED
@@ -1,1157 +1,1157 @@
1
- <?php
2
- /**
3
- * Checkout markup.
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Checkout Markup
10
- *
11
- * @since 1.0.0
12
- */
13
- class Cartflows_Checkout_Markup {
14
-
15
- /**
16
- * Member Variable
17
- *
18
- * @var object instance
19
- */
20
- private static $instance;
21
-
22
- /**
23
- * Initiator
24
- */
25
- public static function get_instance() {
26
- if ( ! isset( self::$instance ) ) {
27
- self::$instance = new self;
28
- }
29
- return self::$instance;
30
- }
31
-
32
- /**
33
- * Constructor
34
- */
35
- public function __construct() {
36
-
37
- /* Set is checkout flag */
38
- add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 );
39
-
40
- add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_checkout_fields' ), 10, 2 );
41
-
42
- /* Show notice if cart is empty */
43
- add_action( 'cartflows_checkout_cart_empty', array( $this, 'display_woo_notices' ) );
44
-
45
- /* Checkout Shortcode */
46
- add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) );
47
-
48
- /* Preconfigured cart data */
49
- add_action( 'wp', array( $this, 'preconfigured_cart_data' ), 1 );
50
-
51
- /* Embed Checkout */
52
- add_action( 'wp', array( $this, 'shortcode_load_data' ), 999 );
53
-
54
- /* Ajax Endpoint */
55
- add_filter( 'woocommerce_ajax_get_endpoint', array( $this, 'get_ajax_endpoint' ) );
56
-
57
- add_filter( 'cartflows_add_before_main_section', array( $this, 'enable_logo_in_header' ) );
58
-
59
- add_filter( 'cartflows_primary_container_bottom', array( $this, 'show_cartflows_copyright_message' ) );
60
-
61
- add_filter( 'woocommerce_login_redirect', array( $this, 'after_login_redirect' ), 10, 2 );
62
-
63
- add_action( 'wp_ajax_wcf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
64
- add_action( 'wp_ajax_nopriv_wcf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
65
-
66
- add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
67
-
68
- /* Global Checkout */
69
- add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
70
-
71
- add_action( 'wp_ajax_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
72
- add_action( 'wp_ajax_nopriv_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
73
-
74
- }
75
-
76
- /**
77
- * Display all WooCommerce notices.
78
- *
79
- * @since 1.1.5
80
- */
81
- function display_woo_notices() {
82
-
83
- if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
84
- woocommerce_output_all_notices();
85
- }
86
- }
87
-
88
-
89
- /**
90
- * Redirect from default to the global checkout page
91
- *
92
- * @since 1.0.0
93
- */
94
- function global_checkout_template_redirect() {
95
-
96
- if ( ! is_checkout() ) {
97
- return;
98
- }
99
-
100
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
101
- return;
102
- }
103
-
104
- // redirect only from any non HC checkout pages.
105
- $order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
106
- $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
107
-
108
- $common = Cartflows_Helper::get_common_settings();
109
-
110
- $global_checkout = $common['global_checkout'];
111
-
112
- if (
113
- // ignore on order-pay.
114
- false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
115
- // ignore on TY page.
116
- false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
117
- ) {
118
-
119
- if ( '' !== $global_checkout ) {
120
-
121
- $link = get_permalink( $global_checkout );
122
-
123
- if ( ! empty( $link ) ) {
124
-
125
- wp_redirect( $link );
126
- die();
127
- }
128
- }
129
- }
130
- }
131
-
132
- /**
133
- * Check for checkout flag
134
- *
135
- * @param bool $is_checkout is checkout.
136
- *
137
- * @return bool
138
- */
139
- function woo_checkout_flag( $is_checkout ) {
140
-
141
- if ( ! is_admin() ) {
142
-
143
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
144
-
145
- $is_checkout = true;
146
- }
147
- }
148
-
149
- return $is_checkout;
150
- }
151
-
152
- /**
153
- * Render checkout shortcode markup.
154
- *
155
- * @param array $atts attributes.
156
- * @return string
157
- */
158
- function checkout_shortcode_markup( $atts ) {
159
-
160
- if ( ! function_exists( 'wc_print_notices' ) ) {
161
- return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
162
- }
163
-
164
- $atts = shortcode_atts(
165
- array(
166
- 'id' => 0,
167
- ),
168
- $atts
169
- );
170
-
171
- $checkout_id = intval( $atts['id'] );
172
-
173
- if ( empty( $checkout_id ) ) {
174
-
175
- if ( ! _is_wcf_checkout_type() ) {
176
-
177
- return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
178
- }
179
-
180
- global $post;
181
-
182
- $checkout_id = intval( $post->ID );
183
- }
184
-
185
- $output = '';
186
-
187
- ob_start();
188
-
189
- do_action( 'cartflows_checkout_form_before', $checkout_id );
190
-
191
- $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
192
-
193
- $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
194
-
195
- $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
196
-
197
- if ( file_exists( $template_layout ) ) {
198
- include $template_layout;
199
- } else {
200
- include $template_default;
201
- }
202
-
203
- $output .= ob_get_clean();
204
-
205
- return $output;
206
- }
207
-
208
- /**
209
- * Configure Cart Data.
210
- *
211
- * @since 1.0.0
212
- *
213
- * @return void
214
- */
215
- function preconfigured_cart_data() {
216
-
217
- if ( is_admin() ) {
218
- return;
219
- }
220
-
221
- global $post;
222
-
223
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
224
-
225
- if ( wp_doing_ajax() ) {
226
-
227
- return;
228
- } else {
229
-
230
- if ( _is_wcf_checkout_type() ) {
231
- $checkout_id = $post->ID;
232
- } else {
233
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
234
- }
235
-
236
- do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
237
-
238
- $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
239
-
240
- if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
241
- $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
242
- } else {
243
- $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
244
- }
245
-
246
- if ( ! is_array( $products ) ) {
247
-
248
- if ( 'dummy' === $products ) {
249
-
250
- $args = array(
251
- 'posts_per_page' => 1,
252
- 'orderby' => 'rand',
253
- 'post_type' => 'product',
254
- 'meta_query' => array(
255
- // Exclude out of stock products.
256
- array(
257
- 'key' => '_stock_status',
258
- 'value' => 'outofstock',
259
- 'compare' => 'NOT IN',
260
- ),
261
- ),
262
- 'tax_query' => array(
263
- array(
264
- 'taxonomy' => 'product_type',
265
- 'field' => 'slug',
266
- 'terms' => 'simple',
267
- ),
268
- ),
269
- );
270
-
271
- $random_product = get_posts( $args );
272
-
273
- if ( isset( $random_product[0]->ID ) ) {
274
- $products = array(
275
- array(
276
- 'product' => $random_product[0]->ID,
277
- ),
278
- );
279
- } else {
280
- return;
281
- }
282
- } else {
283
- return;
284
- }
285
- }
286
-
287
- if ( is_array( $products ) && count( $products ) < 1 ) {
288
-
289
- return;
290
- }
291
- /* Empty the current cart */
292
- WC()->cart->empty_cart();
293
-
294
- /* Set customer session if not set */
295
- if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
296
- WC()->session->set_customer_session_cookie( true );
297
- }
298
-
299
- $cart_product_count = 0;
300
-
301
- foreach ( $products as $index => $data ) {
302
-
303
- if ( ! isset( $data['product'] ) ) {
304
- return;
305
- }
306
-
307
- if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
308
- break;
309
- }
310
-
311
- $product_id = $data['product'];
312
- $_product = wc_get_product( $product_id );
313
-
314
- if ( ! empty( $_product ) ) {
315
-
316
- $quantity = 1;
317
-
318
- if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
319
-
320
- if ( $_product->is_type( 'variable' ) ) {
321
-
322
- $default_attributes = $_product->get_default_attributes();
323
-
324
- if ( ! empty( $default_attributes ) ) {
325
-
326
- foreach ( $_product->get_children() as $variation_id ) {
327
-
328
- $single_variation = new WC_Product_Variation( $variation_id );
329
-
330
- if ( $default_attributes == $single_variation->get_attributes() ) {
331
- WC()->cart->add_to_cart( $variation_id, $quantity );
332
- $cart_product_count++;
333
- }
334
- }
335
- } else {
336
-
337
- $product_childrens = $_product->get_children();
338
-
339
- if ( isset( $product_childrens[0] ) ) {
340
- WC()->cart->add_to_cart( $product_childrens[0], $quantity );
341
- $cart_product_count++;
342
- } else {
343
- echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
344
- }
345
- }
346
- } else {
347
- WC()->cart->add_to_cart( $product_id, $quantity );
348
- $cart_product_count++;
349
- }
350
- } else {
351
-
352
- echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
353
- // WC()->cart->add_to_cart( $product_id, $quantity );.
354
- }
355
- }
356
- }
357
-
358
- do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
359
- do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
360
- }
361
- }
362
- }
363
-
364
- /**
365
- * Load shortcode data.
366
- *
367
- * @return void
368
- */
369
- function shortcode_load_data() {
370
-
371
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
372
-
373
- add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
374
-
375
- add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 );
376
-
377
- /* Show notices if cart has errors */
378
- add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
379
-
380
- add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
381
-
382
- add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
383
-
384
- // Outputting the hidden field in checkout page.
385
- add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
386
- add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
387
-
388
- remove_all_actions( 'woocommerce_checkout_billing' );
389
- remove_all_actions( 'woocommerce_checkout_shipping' );
390
-
391
- // Hook in actions once.
392
- add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
393
- add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
394
-
395
- remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
396
-
397
- add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
398
-
399
- add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
400
-
401
- add_filter( 'woocommerce_cart_totals_coupon_html', array( $this, 'remove_coupon_text' ) );
402
- global $post;
403
-
404
- if ( _is_wcf_checkout_type() ) {
405
- $checkout_id = $post->ID;
406
- } else {
407
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
408
- }
409
-
410
- do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
411
- }
412
- }
413
-
414
- /**
415
- * Render checkout ID hidden field.
416
- *
417
- * @param array $checkout checkout session data.
418
- * @return void
419
- */
420
- function checkout_shortcode_post_id( $checkout ) {
421
-
422
- global $post;
423
-
424
- if ( _is_wcf_checkout_type() ) {
425
- $checkout_id = $post->ID;
426
- } else {
427
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
428
- }
429
-
430
- $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
431
-
432
- echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
433
- echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
434
- }
435
-
436
- /**
437
- * Load shortcode scripts.
438
- *
439
- * @return void
440
- */
441
- function shortcode_scripts() {
442
-
443
- wp_enqueue_style( 'wcf-checkout-template', wcf()->utils->get_css_url( 'checkout-template' ), '', CARTFLOWS_VER );
444
-
445
- wp_enqueue_script(
446
- 'wcf-checkout-template',
447
- wcf()->utils->get_js_url( 'checkout-template' ),
448
- array( 'jquery' ),
449
- CARTFLOWS_VER,
450
- true
451
- );
452
-
453
- do_action( 'cartflows_checkout_scripts' );
454
-
455
- $style = $this->generate_style();
456
-
457
- wp_add_inline_style( 'wcf-checkout-template', $style );
458
-
459
- }
460
-
461
- /**
462
- * Load compatibility scripts.
463
- *
464
- * @return void
465
- */
466
- function compatibility_scripts() {
467
-
468
- global $post;
469
-
470
- if ( _is_wcf_checkout_type() ) {
471
- $checkout_id = $post->ID;
472
- } else {
473
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
474
- }
475
-
476
- // Add DIVI Compatibility css if DIVI theme is enabled.
477
- if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ||
478
- Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id )
479
- ) {
480
- wp_enqueue_style( 'wcf-checkout-template-divi', wcf()->utils->get_css_url( 'checkout-template-divi' ), '', CARTFLOWS_VER );
481
- }
482
-
483
- // Add Flatsome Compatibility css if Flatsome theme is enabled.
484
- if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
485
- wp_enqueue_style( 'wcf-checkout-template-flatsome', wcf()->utils->get_css_url( 'checkout-template-flatsome' ), '', CARTFLOWS_VER );
486
- }
487
-
488
- // Add The7 Compatibility css if The7 theme is enabled.
489
- if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) {
490
- wp_enqueue_style( 'wcf-checkout-template-the-seven', wcf()->utils->get_css_url( 'checkout-template-the-seven' ), '', CARTFLOWS_VER );
491
- }
492
- }
493
-
494
- /**
495
- * Generate styles.
496
- *
497
- * @return string
498
- */
499
- function generate_style() {
500
-
501
- global $post;
502
-
503
- if ( _is_wcf_checkout_type() ) {
504
- $checkout_id = $post->ID;
505
- } else {
506
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
507
- }
508
-
509
- CartFlows_Font_Families::render_fonts( $checkout_id );
510
-
511
- $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
512
-
513
- $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
514
-
515
- $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
516
-
517
- /*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
518
- $r = '';
519
- $g = '';
520
- $b = '';
521
-
522
- $field_tb_padding = '';
523
- $field_lr_padding = '';
524
-
525
- $field_heading_color = '';
526
- $field_color = '';
527
- $field_bg_color = '';
528
- $field_border_color = '';
529
- $field_label_color = '';
530
- $submit_tb_padding = '';
531
- $submit_lr_padding = '';
532
- $hl_bg_color = '';
533
- $field_input_size = '';
534
- $box_border_color = '';
535
- $section_bg_color = '';
536
- $submit_button_height = '';
537
- $submit_color = '';
538
- $submit_bg_color = $primary_color;
539
- $submit_border_color = $primary_color;
540
-
541
- $submit_hover_color = '';
542
- $submit_bg_hover_color = $primary_color;
543
- $submit_border_hover_color = $primary_color;
544
-
545
- $section_heading_color = '';
546
-
547
- $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
548
-
549
- $button_font_family = '';
550
- $button_font_weight = '';
551
- $input_font_family = '';
552
- $input_font_weight = '';
553
- $heading_font_family = '';
554
- $heading_font_weight = '';
555
- $base_font_family = $base_font_family;
556
- /*$base_font_weight = $base_font_weight;*/
557
-
558
- if ( 'yes' == $is_advance_option ) {
559
-
560
- /**
561
- * Get Font Family and Font Weight weight values
562
- */
563
- $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
564
-
565
- $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
566
- $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
567
- $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
568
- $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
569
- $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
570
- $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
571
- $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
572
- $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
573
- $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
574
- $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
575
-
576
- $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
577
-
578
- $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
579
-
580
- $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
581
-
582
- $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
583
-
584
- $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
585
-
586
- $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
587
-
588
- $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
589
-
590
- $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
591
-
592
- $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
593
-
594
- $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
595
-
596
- $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
597
-
598
- $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
599
-
600
- $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
601
-
602
- $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
603
-
604
- $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
605
-
606
- $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
607
-
608
- /**
609
- * Get font values
610
- */
611
-
612
- if ( 'custom' == $submit_button_height ) {
613
- $submit_button_height = '38px';
614
- }
615
-
616
- if ( 'custom' == $field_input_size ) {
617
- $field_input_size = '38px';
618
- }
619
- }
620
- if ( isset( $primary_color ) ) {
621
-
622
- list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
623
- }
624
- $output = "
625
- .wcf-embed-checkout-form .wcf-checkout-header-image img{
626
- width: {$header_logo_width}px;
627
- }
628
- .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
629
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
630
- color: {$primary_color};
631
- }
632
- .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
633
- background-color: {$primary_color};
634
- }
635
- .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
636
- .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
637
- .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
638
- .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
639
- border-color: {$primary_color};
640
- box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
641
- }
642
- .wcf-embed-checkout-form .woocommerce-checkout label{
643
- color: {$field_label_color};
644
- }
645
- .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
646
- background-color: {$hl_bg_color};
647
- font-family: {$input_font_family};
648
- font-weight: {$input_font_weight};
649
- }
650
-
651
- .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
652
- .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
653
- .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
654
- {
655
- border-bottom-color: {$hl_bg_color};
656
- border-right-color: transparent;
657
- border-left-color: transparent;
658
- border-top-color: transparent;
659
- position: absolute;
660
- }
661
-
662
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
663
- .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
664
- font-family: {$input_font_family};
665
- font-weight: {$input_font_weight};
666
- }
667
-
668
- .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
669
- .wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
670
- .wcf-embed-checkout-form .woocommerce form .form-row textarea,
671
- .wcf-embed-checkout-form .select2-container--default .select2-selection--single {
672
- color: {$field_color};
673
- background: {$field_bg_color};
674
- border-color: {$field_border_color};
675
- padding-top: {$field_tb_padding}px;
676
- padding-bottom: {$field_tb_padding}px;
677
- padding-left: {$field_lr_padding}px;
678
- padding-right: {$field_lr_padding}px;
679
- min-height: {$field_input_size};
680
- font-family: {$input_font_family};
681
- font-weight: {$input_font_weight};
682
- }
683
-
684
- .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
685
- .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
686
- .wcf-embed-checkout-form .woocommerce-checkout .shop_table,
687
- .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
688
- .wcf-embed-checkout-form .woocommerce-checkout #payment,
689
- .wcf-embed-checkout-form .woocommerce form.checkout_coupon
690
- {
691
- background-color: {$section_bg_color};
692
- border-color: {$box_border_color};
693
- font-family: {$input_font_family};
694
- font-weight: {$input_font_weight};
695
- }
696
-
697
- .woocommerce table.shop_table th{
698
- color: {$field_label_color};
699
- }
700
- /*.wcf-embed-checkout-form .woocommerce .woocommerce-info,
701
- .wcf-embed-checkout-form .woocommerce-message{
702
- border-top-color: {$primary_color};
703
- background-color: {$hl_bg_color};
704
- }*/
705
- .wcf-embed-checkout-form .woocommerce a{
706
- color: {$primary_color};
707
- }
708
- .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
709
- color: {$field_color};
710
- }
711
- .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
712
- color: {$field_color};
713
- }
714
- .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
715
- color: {$field_color};
716
- }
717
- .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
718
- color: {$field_color};
719
- }
720
- .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
721
- color: {$field_color};
722
- }
723
- .wcf-embed-checkout-form .woocommerce form p.form-row label {
724
- color: {$field_label_color};
725
- font-family: {$input_font_family};
726
- font-weight: {$input_font_weight};
727
- }
728
- .wcf-embed-checkout-form .woocommerce #order_review button,
729
- .wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,
730
- .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small {
731
- color: {$submit_color};
732
- background: {$submit_bg_color};
733
- padding-top: {$submit_tb_padding}px;
734
- padding-bottom: {$submit_tb_padding}px;
735
- padding-left: {$submit_lr_padding}px;
736
- padding-right: {$submit_lr_padding}px;
737
- border-color: {$submit_border_color};
738
- min-height: {$submit_button_height};
739
- font-family: {$button_font_family};
740
- font-weight: {$button_font_weight};
741
- }
742
- .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
743
- .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
744
- background: {$submit_bg_color};
745
- border: 1px {$submit_border_color} solid;
746
- color: {$submit_color};
747
- min-height: {$submit_button_height};
748
- font-family: {$button_font_family};
749
- font-weight: {$button_font_weight};
750
- }
751
- .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
752
- .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
753
- .wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
754
- .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
755
- color: {$submit_hover_color};
756
- background-color: {$submit_bg_hover_color};
757
- border-color: {$submit_border_hover_color};
758
- }
759
- .wcf-embed-checkout-form .woocommerce h3,
760
- .wcf-embed-checkout-form .woocommerce h3 span,
761
- .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
762
- color: {$section_heading_color};
763
- font-family: {$heading_font_family};
764
- font-weight: {$heading_font_weight};
765
- }
766
- .wcf-embed-checkout-form .woocommerce-info::before,
767
- .wcf-embed-checkout-form .woocommerce-message::before{
768
- color: {$primary_color};
769
- }
770
- .wcf-embed-checkout-form{
771
- font-family: {$base_font_family};
772
- }
773
- img.emoji, img.wp-smiley {}";
774
-
775
- return $output;
776
- }
777
-
778
- /**
779
- * Get ajax end points.
780
- *
781
- * @param string $endpoint_url end point URL.
782
- * @return string
783
- */
784
- function get_ajax_endpoint( $endpoint_url ) {
785
-
786
- global $post;
787
-
788
- if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
789
-
790
- if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
791
-
792
- if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
793
-
794
- $query_args = array(
795
- 'wc-ajax' => '%%endpoint%%',
796
- );
797
-
798
- $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
799
- $uri = $uri[0];
800
-
801
- $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
802
- }
803
- }
804
- }
805
-
806
- return $endpoint_url;
807
- }
808
-
809
-
810
- /**
811
- * Save checkout fields.
812
- *
813
- * @param int $order_id order id.
814
- * @param array $posted posted data.
815
- * @return void
816
- */
817
- function save_checkout_fields( $order_id, $posted ) {
818
-
819
- if ( isset( $_POST['_wcf_checkout_id'] ) ) {
820
-
821
- $checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
822
-
823
- update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
824
-
825
- /*
826
- Custom Field To Do
827
- $custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
828
-
829
- if ( 'yes' === $custom_fields ) {
830
-
831
- $billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
832
-
833
- foreach ( $billing_fields as $field => $data ) {
834
-
835
- if ( isset( $data['custom'] ) && $data['custom'] ) {
836
-
837
- if ( isset( $_POST[ $field ] ) ) {
838
- update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
839
- }
840
- }
841
- }
842
-
843
- $shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
844
-
845
- foreach ( $shipping_fields as $field => $data ) {
846
-
847
- if ( isset( $data['custom'] ) && $data['custom'] ) {
848
-
849
- if ( isset( $_POST[ $field ] ) ) {
850
- update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
851
- }
852
- }
853
- }
854
- }
855
- */
856
- if ( isset( $_POST['_wcf_flow_id'] ) ) {
857
-
858
- $checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
859
-
860
- update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
861
- }
862
- }
863
-
864
- }
865
-
866
- /**
867
- * Enable Logo In Header Of Checkout Page
868
- *
869
- * @return void
870
- */
871
- function enable_logo_in_header() {
872
- global $post;
873
-
874
- if ( _is_wcf_checkout_type() ) {
875
- $checkout_id = $post->ID;
876
- } else {
877
- $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
878
- }
879
-
880
- $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
881
- $add_image_markup = '';
882
-
883
- if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
884
- $add_image_markup = '<div class="wcf-checkout-header-image">';
885
- $add_image_markup .= '<img src="' . $header_logo_image . '" />';
886
- $add_image_markup .= '</div>';
887
- }
888
-
889
- echo $add_image_markup;
890
- }
891
-
892
- /**
893
- * Add text to the bootom of the checkout page.
894
- *
895
- * @return void
896
- */
897
- function show_cartflows_copyright_message() {
898
- $output_string = '';
899
-
900
- $output_string .= '<div class="wcf-footer-primary">';
901
- $output_string .= '<div class="wcf-footer-content">';
902
- $output_string .= '<p class="wcf-footer-message">';
903
- $output_string .= 'Checkout powered by CartFlows';
904
- $output_string .= '</p>';
905
- $output_string .= '</div>';
906
- $output_string .= '</div>';
907
-
908
- echo $output_string;
909
- }
910
-
911
- /**
912
- * Redirect users to our checkout if hidden param
913
- *
914
- * @param string $redirect redirect url.
915
- * @param object $user user.
916
- * @return string
917
- */
918
- function after_login_redirect( $redirect, $user ) {
919
-
920
- if ( isset( $_POST['_wcf_checkout_id'] ) ) {
921
-
922
- $checkout_id = intval( $_POST['_wcf_checkout_id'] );
923
-
924
- $redirect = get_permalink( $checkout_id );
925
- }
926
-
927
- return $redirect;
928
- }
929
-
930
- /**
931
- * Display coupon code field after review order fields.
932
- */
933
- function display_custom_coupon_field() {
934
-
935
- $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
936
- $show_coupon = apply_filters( 'cartflows_show_coupon_field', true );
937
-
938
- if ( ! ( $coupon_enabled && $show_coupon ) ) {
939
- return;
940
-
941
- }
942
-
943
- ob_start();
944
- ?>
945
- <div class="wcf-custom-coupon-field">
946
- <div class="wcf-coupon-col-1">
947
- <span>
948
- <input type="text" name="coupon_code" class="input-text wcf-coupon-code-input" placeholder="<?php _e( 'Coupon Code', 'cartflows' ); ?>" id="coupon_code" value="">
949
- </span>
950
- </div>
951
- <div class="wcf-coupon-col-2">
952
- <span>
953
- <button type="button" class="button wcf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php _e( 'Apply', 'cartflows' ); ?></button>
954
- </span>
955
- </div>
956
- </div>
957
- <?php
958
- echo ob_get_clean();
959
- }
960
-
961
- /**
962
- * Apply filter to change class of remove coupon field.
963
- *
964
- * @param string $coupon coupon.
965
- * @return string
966
- */
967
- function remove_coupon_text( $coupon ) {
968
-
969
- $coupon = str_replace( 'woocommerce-remove-coupon', 'wcf-remove-coupon', $coupon );
970
- return $coupon;
971
-
972
- }
973
- /**
974
- * Apply filter to change the placeholder text of coupon field.
975
- *
976
- * @return string
977
- */
978
- function coupon_field_placeholder() {
979
- return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
980
- }
981
-
982
- /**
983
- * Apply filter to change the button text of coupon field.
984
- *
985
- * @return string
986
- */
987
- function coupon_button_text() {
988
- return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
989
- }
990
-
991
- /**
992
- * Apply coupon on submit of custom coupon form.
993
- */
994
- function apply_coupon() {
995
-
996
- $response = '';
997
-
998
- check_ajax_referer( 'wcf-apply-coupon', 'security' );
999
- if ( ! empty( $_POST['coupon_code'] ) ) {
1000
- $result = WC()->cart->add_discount( sanitize_text_field( $_POST['coupon_code'] ) );
1001
- } else {
1002
- wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' );
1003
- }
1004
-
1005
- $response = array(
1006
- 'status' => $result,
1007
- 'msg' => wc_print_notices( true ),
1008
- );
1009
-
1010
- echo json_encode( $response );
1011
-
1012
- die();
1013
- }
1014
-
1015
-
1016
- /**
1017
- * Added ajax nonce to localize variable.
1018
- *
1019
- * @param array $vars localize variables.
1020
- */
1021
- function add_localize_vars( $vars ) {
1022
-
1023
- $vars['wcf_validate_coupon_nonce'] = wp_create_nonce( 'wcf-apply-coupon' );
1024
-
1025
- $vars['wcf_validate_remove_coupon_nonce'] = wp_create_nonce( 'wcf-remove-coupon' );
1026
-
1027
- $vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
1028
-
1029
- return $vars;
1030
- }
1031
-
1032
- /**
1033
- * Add custom class to the fields to change the UI to three column.
1034
- *
1035
- * @param array $fields fields.
1036
- */
1037
- function add_three_column_layout_fields( $fields ) {
1038
-
1039
- if ( empty( $fields['billing']['billing_address_2'] ) ) {
1040
-
1041
- if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
1042
- $fields['billing']['billing_address_1']['class'][] = 'form-row-full';
1043
- }
1044
- }
1045
-
1046
- if ( ! empty( $fields['billing']['billing_company'] ) ) {
1047
-
1048
- if ( isset( $fields['billing']['billing_company'] ) && is_array( $fields['billing']['billing_company'] ) ) {
1049
- $fields['billing']['billing_company']['class'][] = 'form-row-full';
1050
- }
1051
- }
1052
-
1053
- if ( ! empty( $fields['shipping']['shipping_company'] ) ) {
1054
-
1055
- if ( isset( $fields['shipping']['shipping_company'] ) && is_array( $fields['shipping']['shipping_company'] ) ) {
1056
- $fields['shipping']['shipping_company']['class'][] = 'form-row-full';
1057
- }
1058
- }
1059
-
1060
- if ( ! empty( $fields['billing']['billing_country'] ) ) {
1061
-
1062
- if ( isset( $fields['billing']['billing_country'] ) && is_array( $fields['billing']['billing_country'] ) ) {
1063
- $fields['billing']['billing_country']['class'][] = 'form-row-full';
1064
- }
1065
- }
1066
-
1067
- if ( ! empty( $fields['shipping']['shipping_country'] ) ) {
1068
-
1069
- if ( isset( $fields['shipping']['shipping_country'] ) && is_array( $fields['shipping']['shipping_country'] ) ) {
1070
- $fields['shipping']['shipping_country']['class'][] = 'form-row-full';
1071
- }
1072
- }
1073
-
1074
- if ( ! empty( $fields['billing']['billing_phone'] ) ) {
1075
-
1076
- if ( isset( $fields['billing']['billing_phone'] ) && is_array( $fields['billing']['billing_phone'] ) ) {
1077
- $fields['billing']['billing_phone']['class'][] = 'form-row-full';
1078
- }
1079
- }
1080
-
1081
- if ( ! empty( $fields['billing']['billing_email'] ) ) {
1082
-
1083
- if ( isset( $fields['billing']['billing_email'] ) && is_array( $fields['billing']['billing_email'] ) ) {
1084
- $fields['billing']['billing_email']['class'][] = 'form-row-full';
1085
- }
1086
- }
1087
-
1088
- if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
1089
-
1090
- if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
1091
- $fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
1092
- }
1093
- }
1094
-
1095
- if ( isset( $fields['billing']['billing_city'] ) &&
1096
- isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
1097
-
1098
- $fields['billing']['billing_city']['class'][] = 'wcf-column-33';
1099
- $fields['billing']['billing_state']['class'][] = 'wcf-column-33';
1100
- $fields['billing']['billing_postcode']['class'][] = 'wcf-column-33';
1101
- }
1102
-
1103
- if ( isset( $fields['shipping']['shipping_city'] ) &&
1104
- isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
1105
-
1106
- $fields['shipping']['shipping_city']['class'][] = 'wcf-column-33';
1107
- $fields['shipping']['shipping_state']['class'][] = 'wcf-column-33';
1108
- $fields['shipping']['shipping_postcode']['class'][] = 'wcf-column-33';
1109
- }
1110
-
1111
- return $fields;
1112
- }
1113
-
1114
- /**
1115
- * Add opening dev
1116
- *
1117
- * @since 1.0.0
1118
- */
1119
- function order_wrap_div_start() {
1120
-
1121
- echo "<div class='wcf-order-wrap'> ";
1122
- }
1123
-
1124
- /**
1125
- * Add closing dev
1126
- *
1127
- * @since 1.0.0
1128
- */
1129
- function order_wrap_div_end() {
1130
-
1131
- echo '</div> ';
1132
- }
1133
-
1134
- /**
1135
- * Remove coupon.
1136
- */
1137
- function remove_coupon() {
1138
-
1139
- check_ajax_referer( 'wcf-remove-coupon', 'security' );
1140
- $coupon = isset( $_POST['coupon_code'] ) ? wc_clean( $_POST['coupon_code'] ) : false;
1141
-
1142
- if ( empty( $coupon ) ) {
1143
- echo "<div class='woocommerce-error'>Sorry there was a problem removing this coupon.";
1144
- } else {
1145
- WC()->cart->remove_coupon( $coupon );
1146
- echo "<div class='woocommerce-error'>Coupon has been removed.</div>";
1147
- }
1148
- wc_print_notices();
1149
- wp_die();
1150
- }
1151
-
1152
- }
1153
-
1154
- /**
1155
- * Kicking this off by calling 'get_instance()' method
1156
- */
1157
- Cartflows_Checkout_Markup::get_instance();
1
+ <?php
2
+ /**
3
+ * Checkout markup.
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Checkout Markup
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ class Cartflows_Checkout_Markup {
14
+
15
+ /**
16
+ * Member Variable
17
+ *
18
+ * @var object instance
19
+ */
20
+ private static $instance;
21
+
22
+ /**
23
+ * Initiator
24
+ */
25
+ public static function get_instance() {
26
+ if ( ! isset( self::$instance ) ) {
27
+ self::$instance = new self;
28
+ }
29
+ return self::$instance;
30
+ }
31
+
32
+ /**
33
+ * Constructor
34
+ */
35
+ public function __construct() {
36
+
37
+ /* Set is checkout flag */
38
+ add_filter( 'woocommerce_is_checkout', array( $this, 'woo_checkout_flag' ), 9999 );
39
+
40
+ add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'save_checkout_fields' ), 10, 2 );
41
+
42
+ /* Show notice if cart is empty */
43
+ add_action( 'cartflows_checkout_cart_empty', array( $this, 'display_woo_notices' ) );
44
+
45
+ /* Checkout Shortcode */
46
+ add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) );
47
+
48
+ /* Preconfigured cart data */
49
+ add_action( 'wp', array( $this, 'preconfigured_cart_data' ), 1 );
50
+
51
+ /* Embed Checkout */
52
+ add_action( 'wp', array( $this, 'shortcode_load_data' ), 999 );
53
+
54
+ /* Ajax Endpoint */
55
+ add_filter( 'woocommerce_ajax_get_endpoint', array( $this, 'get_ajax_endpoint' ) );
56
+
57
+ add_filter( 'cartflows_add_before_main_section', array( $this, 'enable_logo_in_header' ) );
58
+
59
+ add_filter( 'cartflows_primary_container_bottom', array( $this, 'show_cartflows_copyright_message' ) );
60
+
61
+ add_filter( 'woocommerce_login_redirect', array( $this, 'after_login_redirect' ), 10, 2 );
62
+
63
+ add_action( 'wp_ajax_wcf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
64
+ add_action( 'wp_ajax_nopriv_wcf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
65
+
66
+ add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
67
+
68
+ /* Global Checkout */
69
+ add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
70
+
71
+ add_action( 'wp_ajax_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
72
+ add_action( 'wp_ajax_nopriv_wcf_woo_remove_coupon', array( $this, 'remove_coupon' ) );
73
+
74
+ }
75
+
76
+ /**
77
+ * Display all WooCommerce notices.
78
+ *
79
+ * @since 1.1.5
80
+ */
81
+ function display_woo_notices() {
82
+
83
+ if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
84
+ woocommerce_output_all_notices();
85
+ }
86
+ }
87
+
88
+
89
+ /**
90
+ * Redirect from default to the global checkout page
91
+ *
92
+ * @since 1.0.0
93
+ */
94
+ function global_checkout_template_redirect() {
95
+
96
+ if ( ! is_checkout() ) {
97
+ return;
98
+ }
99
+
100
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
101
+ return;
102
+ }
103
+
104
+ // redirect only from any non HC checkout pages.
105
+ $order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
106
+ $order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
107
+
108
+ $common = Cartflows_Helper::get_common_settings();
109
+
110
+ $global_checkout = $common['global_checkout'];
111
+
112
+ if (
113
+ // ignore on order-pay.
114
+ false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
115
+ // ignore on TY page.
116
+ false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
117
+ ) {
118
+
119
+ if ( '' !== $global_checkout ) {
120
+
121
+ $link = get_permalink( $global_checkout );
122
+
123
+ if ( ! empty( $link ) ) {
124
+
125
+ wp_redirect( $link );
126
+ die();
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Check for checkout flag
134
+ *
135
+ * @param bool $is_checkout is checkout.
136
+ *
137
+ * @return bool
138
+ */
139
+ function woo_checkout_flag( $is_checkout ) {
140
+
141
+ if ( ! is_admin() ) {
142
+
143
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
144
+
145
+ $is_checkout = true;
146
+ }
147
+ }
148
+
149
+ return $is_checkout;
150
+ }
151
+
152
+ /**
153
+ * Render checkout shortcode markup.
154
+ *
155
+ * @param array $atts attributes.
156
+ * @return string
157
+ */
158
+ function checkout_shortcode_markup( $atts ) {
159
+
160
+ if ( ! function_exists( 'wc_print_notices' ) ) {
161
+ return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
162
+ }
163
+
164
+ $atts = shortcode_atts(
165
+ array(
166
+ 'id' => 0,
167
+ ),
168
+ $atts
169
+ );
170
+
171
+ $checkout_id = intval( $atts['id'] );
172
+
173
+ if ( empty( $checkout_id ) ) {
174
+
175
+ if ( ! _is_wcf_checkout_type() ) {
176
+
177
+ return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
178
+ }
179
+
180
+ global $post;
181
+
182
+ $checkout_id = intval( $post->ID );
183
+ }
184
+
185
+ $output = '';
186
+
187
+ ob_start();
188
+
189
+ do_action( 'cartflows_checkout_form_before', $checkout_id );
190
+
191
+ $checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
192
+
193
+ $template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
194
+
195
+ $template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
196
+
197
+ if ( file_exists( $template_layout ) ) {
198
+ include $template_layout;
199
+ } else {
200
+ include $template_default;
201
+ }
202
+
203
+ $output .= ob_get_clean();
204
+
205
+ return $output;
206
+ }
207
+
208
+ /**
209
+ * Configure Cart Data.
210
+ *
211
+ * @since 1.0.0
212
+ *
213
+ * @return void
214
+ */
215
+ function preconfigured_cart_data() {
216
+
217
+ if ( is_admin() ) {
218
+ return;
219
+ }
220
+
221
+ global $post;
222
+
223
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
224
+
225
+ if ( wp_doing_ajax() ) {
226
+
227
+ return;
228
+ } else {
229
+
230
+ if ( _is_wcf_checkout_type() ) {
231
+ $checkout_id = $post->ID;
232
+ } else {
233
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
234
+ }
235
+
236
+ do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
237
+
238
+ $flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
239
+
240
+ if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
241
+ $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
242
+ } else {
243
+ $products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
244
+ }
245
+
246
+ if ( ! is_array( $products ) ) {
247
+
248
+ if ( 'dummy' === $products ) {
249
+
250
+ $args = array(
251
+ 'posts_per_page' => 1,
252
+ 'orderby' => 'rand',
253
+ 'post_type' => 'product',
254
+ 'meta_query' => array(
255
+ // Exclude out of stock products.
256
+ array(
257
+ 'key' => '_stock_status',
258
+ 'value' => 'outofstock',
259
+ 'compare' => 'NOT IN',
260
+ ),
261
+ ),
262
+ 'tax_query' => array(
263
+ array(
264
+ 'taxonomy' => 'product_type',
265
+ 'field' => 'slug',
266
+ 'terms' => 'simple',
267
+ ),
268
+ ),
269
+ );
270
+
271
+ $random_product = get_posts( $args );
272
+
273
+ if ( isset( $random_product[0]->ID ) ) {
274
+ $products = array(
275
+ array(
276
+ 'product' => $random_product[0]->ID,
277
+ ),
278
+ );
279
+ } else {
280
+ return;
281
+ }
282
+ } else {
283
+ return;
284
+ }
285
+ }
286
+
287
+ if ( is_array( $products ) && count( $products ) < 1 ) {
288
+
289
+ return;
290
+ }
291
+ /* Empty the current cart */
292
+ WC()->cart->empty_cart();
293
+
294
+ /* Set customer session if not set */
295
+ if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
296
+ WC()->session->set_customer_session_cookie( true );
297
+ }
298
+
299
+ $cart_product_count = 0;
300
+
301
+ foreach ( $products as $index => $data ) {
302
+
303
+ if ( ! isset( $data['product'] ) ) {
304
+ return;
305
+ }
306
+
307
+ if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
308
+ break;
309
+ }
310
+
311
+ $product_id = $data['product'];
312
+ $_product = wc_get_product( $product_id );
313
+
314
+ if ( ! empty( $_product ) ) {
315
+
316
+ $quantity = 1;
317
+
318
+ if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
319
+
320
+ if ( $_product->is_type( 'variable' ) ) {
321
+
322
+ $default_attributes = $_product->get_default_attributes();
323
+
324
+ if ( ! empty( $default_attributes ) ) {
325
+
326
+ foreach ( $_product->get_children() as $variation_id ) {
327
+
328
+ $single_variation = new WC_Product_Variation( $variation_id );
329
+
330
+ if ( $default_attributes == $single_variation->get_attributes() ) {
331
+ WC()->cart->add_to_cart( $variation_id, $quantity );
332
+ $cart_product_count++;
333
+ }
334
+ }
335
+ } else {
336
+
337
+ $product_childrens = $_product->get_children();
338
+
339
+ if ( isset( $product_childrens[0] ) ) {
340
+ WC()->cart->add_to_cart( $product_childrens[0], $quantity );
341
+ $cart_product_count++;
342
+ } else {
343
+ echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
344
+ }
345
+ }
346
+ } else {
347
+ WC()->cart->add_to_cart( $product_id, $quantity );
348
+ $cart_product_count++;
349
+ }
350
+ } else {
351
+
352
+ echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
353
+ // WC()->cart->add_to_cart( $product_id, $quantity );.
354
+ }
355
+ }
356
+ }
357
+
358
+ do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
359
+ do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
360
+ }
361
+ }
362
+ }
363
+
364
+ /**
365
+ * Load shortcode data.
366
+ *
367
+ * @return void
368
+ */
369
+ function shortcode_load_data() {
370
+
371
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
372
+
373
+ add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
374
+
375
+ add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 );
376
+
377
+ /* Show notices if cart has errors */
378
+ add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
379
+
380
+ add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
381
+
382
+ add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
383
+
384
+ // Outputting the hidden field in checkout page.
385
+ add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
386
+ add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
387
+
388
+ remove_all_actions( 'woocommerce_checkout_billing' );
389
+ remove_all_actions( 'woocommerce_checkout_shipping' );
390
+
391
+ // Hook in actions once.
392
+ add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
393
+ add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
394
+
395
+ remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
396
+
397
+ add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
398
+
399
+ add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
400
+
401
+ add_filter( 'woocommerce_cart_totals_coupon_html', array( $this, 'remove_coupon_text' ) );
402
+ global $post;
403
+
404
+ if ( _is_wcf_checkout_type() ) {
405
+ $checkout_id = $post->ID;
406
+ } else {
407
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
408
+ }
409
+
410
+ do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
411
+ }
412
+ }
413
+
414
+ /**
415
+ * Render checkout ID hidden field.
416
+ *
417
+ * @param array $checkout checkout session data.
418
+ * @return void
419
+ */
420
+ function checkout_shortcode_post_id( $checkout ) {
421
+
422
+ global $post;
423
+
424
+ if ( _is_wcf_checkout_type() ) {
425
+ $checkout_id = $post->ID;
426
+ } else {
427
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
428
+ }
429
+
430
+ $flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
431
+
432
+ echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
433
+ echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
434
+ }
435
+
436
+ /**
437
+ * Load shortcode scripts.
438
+ *
439
+ * @return void
440
+ */
441
+ function shortcode_scripts() {
442
+
443
+ wp_enqueue_style( 'wcf-checkout-template', wcf()->utils->get_css_url( 'checkout-template' ), '', CARTFLOWS_VER );
444
+
445
+ wp_enqueue_script(
446
+ 'wcf-checkout-template',
447
+ wcf()->utils->get_js_url( 'checkout-template' ),
448
+ array( 'jquery' ),
449
+ CARTFLOWS_VER,
450
+ true
451
+ );
452
+
453
+ do_action( 'cartflows_checkout_scripts' );
454
+
455
+ $style = $this->generate_style();
456
+
457
+ wp_add_inline_style( 'wcf-checkout-template', $style );
458
+
459
+ }
460
+
461
+ /**
462
+ * Load compatibility scripts.
463
+ *
464
+ * @return void
465
+ */
466
+ function compatibility_scripts() {
467
+
468
+ global $post;
469
+
470
+ if ( _is_wcf_checkout_type() ) {
471
+ $checkout_id = $post->ID;
472
+ } else {
473
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
474
+ }
475
+
476
+ // Add DIVI Compatibility css if DIVI theme is enabled.
477
+ if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ||
478
+ Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id )
479
+ ) {
480
+ wp_enqueue_style( 'wcf-checkout-template-divi', wcf()->utils->get_css_url( 'checkout-template-divi' ), '', CARTFLOWS_VER );
481
+ }
482
+
483
+ // Add Flatsome Compatibility css if Flatsome theme is enabled.
484
+ if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
485
+ wp_enqueue_style( 'wcf-checkout-template-flatsome', wcf()->utils->get_css_url( 'checkout-template-flatsome' ), '', CARTFLOWS_VER );
486
+ }
487
+
488
+ // Add The7 Compatibility css if The7 theme is enabled.
489
+ if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) {
490
+ wp_enqueue_style( 'wcf-checkout-template-the-seven', wcf()->utils->get_css_url( 'checkout-template-the-seven' ), '', CARTFLOWS_VER );
491
+ }
492
+ }
493
+
494
+ /**
495
+ * Generate styles.
496
+ *
497
+ * @return string
498
+ */
499
+ function generate_style() {
500
+
501
+ global $post;
502
+
503
+ if ( _is_wcf_checkout_type() ) {
504
+ $checkout_id = $post->ID;
505
+ } else {
506
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
507
+ }
508
+
509
+ CartFlows_Font_Families::render_fonts( $checkout_id );
510
+
511
+ $primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
512
+
513
+ $base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
514
+
515
+ $header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
516
+
517
+ /*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
518
+ $r = '';
519
+ $g = '';
520
+ $b = '';
521
+
522
+ $field_tb_padding = '';
523
+ $field_lr_padding = '';
524
+
525
+ $field_heading_color = '';
526
+ $field_color = '';
527
+ $field_bg_color = '';
528
+ $field_border_color = '';
529
+ $field_label_color = '';
530
+ $submit_tb_padding = '';
531
+ $submit_lr_padding = '';
532
+ $hl_bg_color = '';
533
+ $field_input_size = '';
534
+ $box_border_color = '';
535
+ $section_bg_color = '';
536
+ $submit_button_height = '';
537
+ $submit_color = '';
538
+ $submit_bg_color = $primary_color;
539
+ $submit_border_color = $primary_color;
540
+
541
+ $submit_hover_color = '';
542
+ $submit_bg_hover_color = $primary_color;
543
+ $submit_border_hover_color = $primary_color;
544
+
545
+ $section_heading_color = '';
546
+
547
+ $is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
548
+
549
+ $button_font_family = '';
550
+ $button_font_weight = '';
551
+ $input_font_family = '';
552
+ $input_font_weight = '';
553
+ $heading_font_family = '';
554
+ $heading_font_weight = '';
555
+ $base_font_family = $base_font_family;
556
+ /*$base_font_weight = $base_font_weight;*/
557
+
558
+ if ( 'yes' == $is_advance_option ) {
559
+
560
+ /**
561
+ * Get Font Family and Font Weight weight values
562
+ */
563
+ $section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
564
+
565
+ $heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
566
+ $heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
567
+ $section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
568
+ $button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
569
+ $button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
570
+ $input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
571
+ $input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
572
+ $field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
573
+ $field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
574
+ $field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
575
+
576
+ $field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
577
+
578
+ $field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
579
+
580
+ $field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
581
+
582
+ $field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
583
+
584
+ $field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
585
+
586
+ $submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
587
+
588
+ $submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
589
+
590
+ $submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
591
+
592
+ $submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
593
+
594
+ $submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
595
+
596
+ $submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
597
+
598
+ $submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
599
+
600
+ $submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
601
+
602
+ $hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
603
+
604
+ $box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
605
+
606
+ $submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
607
+
608
+ /**
609
+ * Get font values
610
+ */
611
+
612
+ if ( 'custom' == $submit_button_height ) {
613
+ $submit_button_height = '38px';
614
+ }
615
+
616
+ if ( 'custom' == $field_input_size ) {
617
+ $field_input_size = '38px';
618
+ }
619
+ }
620
+ if ( isset( $primary_color ) ) {
621
+
622
+ list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
623
+ }
624
+ $output = "
625
+ .wcf-embed-checkout-form .wcf-checkout-header-image img{
626
+ width: {$header_logo_width}px;
627
+ }
628
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
629
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
630
+ color: {$primary_color};
631
+ }
632
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
633
+ background-color: {$primary_color};
634
+ }
635
+ .wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
636
+ .wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
637
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
638
+ .wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
639
+ border-color: {$primary_color};
640
+ box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
641
+ }
642
+ .wcf-embed-checkout-form .woocommerce-checkout label{
643
+ color: {$field_label_color};
644
+ }
645
+ .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
646
+ background-color: {$hl_bg_color};
647
+ font-family: {$input_font_family};
648
+ font-weight: {$input_font_weight};
649
+ }
650
+
651
+ .wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
652
+ .wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
653
+ .wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
654
+ {
655
+ border-bottom-color: {$hl_bg_color};
656
+ border-right-color: transparent;
657
+ border-left-color: transparent;
658
+ border-top-color: transparent;
659
+ position: absolute;
660
+ }
661
+
662
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
663
+ .wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
664
+ font-family: {$input_font_family};
665
+ font-weight: {$input_font_weight};
666
+ }
667
+
668
+ .wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
669
+ .wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
670
+ .wcf-embed-checkout-form .woocommerce form .form-row textarea,
671
+ .wcf-embed-checkout-form .select2-container--default .select2-selection--single {
672
+ color: {$field_color};
673
+ background: {$field_bg_color};
674
+ border-color: {$field_border_color};
675
+ padding-top: {$field_tb_padding}px;
676
+ padding-bottom: {$field_tb_padding}px;
677
+ padding-left: {$field_lr_padding}px;
678
+ padding-right: {$field_lr_padding}px;
679
+ min-height: {$field_input_size};
680
+ font-family: {$input_font_family};
681
+ font-weight: {$input_font_weight};
682
+ }
683
+
684
+ .wcf-embed-checkout-form .woocommerce .col2-set .col-1,
685
+ .wcf-embed-checkout-form .woocommerce .col2-set .col-2,
686
+ .wcf-embed-checkout-form .woocommerce-checkout .shop_table,
687
+ .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
688
+ .wcf-embed-checkout-form .woocommerce-checkout #payment,
689
+ .wcf-embed-checkout-form .woocommerce form.checkout_coupon
690
+ {
691
+ background-color: {$section_bg_color};
692
+ border-color: {$box_border_color};
693
+ font-family: {$input_font_family};
694
+ font-weight: {$input_font_weight};
695
+ }
696
+
697
+ .woocommerce table.shop_table th{
698
+ color: {$field_label_color};
699
+ }
700
+ /*.wcf-embed-checkout-form .woocommerce .woocommerce-info,
701
+ .wcf-embed-checkout-form .woocommerce-message{
702
+ border-top-color: {$primary_color};
703
+ background-color: {$hl_bg_color};
704
+ }*/
705
+ .wcf-embed-checkout-form .woocommerce a{
706
+ color: {$primary_color};
707
+ }
708
+ .wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
709
+ color: {$field_color};
710
+ }
711
+ .wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
712
+ color: {$field_color};
713
+ }
714
+ .wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
715
+ color: {$field_color};
716
+ }
717
+ .wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
718
+ color: {$field_color};
719
+ }
720
+ .wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
721
+ color: {$field_color};
722
+ }
723
+ .wcf-embed-checkout-form .woocommerce form p.form-row label {
724
+ color: {$field_label_color};
725
+ font-family: {$input_font_family};
726
+ font-weight: {$input_font_weight};
727
+ }
728
+ .wcf-embed-checkout-form .woocommerce #order_review button,
729
+ .wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,
730
+ .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small {
731
+ color: {$submit_color};
732
+ background: {$submit_bg_color};
733
+ padding-top: {$submit_tb_padding}px;
734
+ padding-bottom: {$submit_tb_padding}px;
735
+ padding-left: {$submit_lr_padding}px;
736
+ padding-right: {$submit_lr_padding}px;
737
+ border-color: {$submit_border_color};
738
+ min-height: {$submit_button_height};
739
+ font-family: {$button_font_family};
740
+ font-weight: {$button_font_weight};
741
+ }
742
+ .wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
743
+ .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
744
+ background: {$submit_bg_color};
745
+ border: 1px {$submit_border_color} solid;
746
+ color: {$submit_color};
747
+ min-height: {$submit_button_height};
748
+ font-family: {$button_font_family};
749
+ font-weight: {$button_font_weight};
750
+ }
751
+ .wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
752
+ .wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
753
+ .wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
754
+ .wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
755
+ color: {$submit_hover_color};
756
+ background-color: {$submit_bg_hover_color};
757
+ border-color: {$submit_border_hover_color};
758
+ }
759
+ .wcf-embed-checkout-form .woocommerce h3,
760
+ .wcf-embed-checkout-form .woocommerce h3 span,
761
+ .wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
762
+ color: {$section_heading_color};
763
+ font-family: {$heading_font_family};
764
+ font-weight: {$heading_font_weight};
765
+ }
766
+ .wcf-embed-checkout-form .woocommerce-info::before,
767
+ .wcf-embed-checkout-form .woocommerce-message::before{
768
+ color: {$primary_color};
769
+ }
770
+ .wcf-embed-checkout-form{
771
+ font-family: {$base_font_family};
772
+ }
773
+ img.emoji, img.wp-smiley {}";
774
+
775
+ return $output;
776
+ }
777
+
778
+ /**
779
+ * Get ajax end points.
780
+ *
781
+ * @param string $endpoint_url end point URL.
782
+ * @return string
783
+ */
784
+ function get_ajax_endpoint( $endpoint_url ) {
785
+
786
+ global $post;
787
+
788
+ if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
789
+
790
+ if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
791
+
792
+ if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
793
+
794
+ $query_args = array(
795
+ 'wc-ajax' => '%%endpoint%%',
796
+ );
797
+
798
+ $uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
799
+ $uri = $uri[0];
800
+
801
+ $endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
802
+ }
803
+ }
804
+ }
805
+
806
+ return $endpoint_url;
807
+ }
808
+
809
+
810
+ /**
811
+ * Save checkout fields.
812
+ *
813
+ * @param int $order_id order id.
814
+ * @param array $posted posted data.
815
+ * @return void
816
+ */
817
+ function save_checkout_fields( $order_id, $posted ) {
818
+
819
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) {
820
+
821
+ $checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
822
+
823
+ update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
824
+
825
+ /*
826
+ Custom Field To Do
827
+ $custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
828
+
829
+ if ( 'yes' === $custom_fields ) {
830
+
831
+ $billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
832
+
833
+ foreach ( $billing_fields as $field => $data ) {
834
+
835
+ if ( isset( $data['custom'] ) && $data['custom'] ) {
836
+
837
+ if ( isset( $_POST[ $field ] ) ) {
838
+ update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
839
+ }
840
+ }
841
+ }
842
+
843
+ $shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
844
+
845
+ foreach ( $shipping_fields as $field => $data ) {
846
+
847
+ if ( isset( $data['custom'] ) && $data['custom'] ) {
848
+
849
+ if ( isset( $_POST[ $field ] ) ) {
850
+ update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
851
+ }
852
+ }
853
+ }
854
+ }
855
+ */
856
+ if ( isset( $_POST['_wcf_flow_id'] ) ) {
857
+
858
+ $checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
859
+
860
+ update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
861
+ }
862
+ }
863
+
864
+ }
865
+
866
+ /**
867
+ * Enable Logo In Header Of Checkout Page
868
+ *
869
+ * @return void
870
+ */
871
+ function enable_logo_in_header() {
872
+ global $post;
873
+
874
+ if ( _is_wcf_checkout_type() ) {
875
+ $checkout_id = $post->ID;
876
+ } else {
877
+ $checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
878
+ }
879
+
880
+ $header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
881
+ $add_image_markup = '';
882
+
883
+ if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
884
+ $add_image_markup = '<div class="wcf-checkout-header-image">';
885
+ $add_image_markup .= '<img src="' . $header_logo_image . '" />';
886
+ $add_image_markup .= '</div>';
887
+ }
888
+
889
+ echo $add_image_markup;
890
+ }
891
+
892
+ /**
893
+ * Add text to the bootom of the checkout page.
894
+ *
895
+ * @return void
896
+ */
897
+ function show_cartflows_copyright_message() {
898
+ $output_string = '';
899
+
900
+ $output_string .= '<div class="wcf-footer-primary">';
901
+ $output_string .= '<div class="wcf-footer-content">';
902
+ $output_string .= '<p class="wcf-footer-message">';
903
+ $output_string .= 'Checkout powered by CartFlows';
904
+ $output_string .= '</p>';
905
+ $output_string .= '</div>';
906
+ $output_string .= '</div>';
907
+
908
+ echo $output_string;
909
+ }
910
+
911
+ /**
912
+ * Redirect users to our checkout if hidden param
913
+ *
914
+ * @param string $redirect redirect url.
915
+ * @param object $user user.
916
+ * @return string
917
+ */
918
+ function after_login_redirect( $redirect, $user ) {
919
+
920
+ if ( isset( $_POST['_wcf_checkout_id'] ) ) {
921
+
922
+ $checkout_id = intval( $_POST['_wcf_checkout_id'] );
923
+
924
+ $redirect = get_permalink( $checkout_id );
925
+ }
926
+
927
+ return $redirect;
928
+ }
929
+
930
+ /**
931
+ * Display coupon code field after review order fields.
932
+ */
933
+ function display_custom_coupon_field() {
934
+
935
+ $coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
936
+ $show_coupon = apply_filters( 'cartflows_show_coupon_field', true );
937
+
938
+ if ( ! ( $coupon_enabled && $show_coupon ) ) {
939
+ return;
940
+
941
+ }
942
+
943
+ ob_start();
944
+ ?>
945
+ <div class="wcf-custom-coupon-field">
946
+ <div class="wcf-coupon-col-1">
947
+ <span>
948
+ <input type="text" name="coupon_code" class="input-text wcf-coupon-code-input" placeholder="<?php _e( 'Coupon Code', 'cartflows' ); ?>" id="coupon_code" value="">
949
+ </span>
950
+ </div>
951
+ <div class="wcf-coupon-col-2">
952
+ <span>
953
+ <button type="button" class="button wcf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php _e( 'Apply', 'cartflows' ); ?></button>
954
+ </span>
955
+ </div>
956
+ </div>
957
+ <?php
958
+ echo ob_get_clean();
959
+ }
960
+
961
+ /**
962
+ * Apply filter to change class of remove coupon field.
963
+ *
964
+ * @param string $coupon coupon.
965
+ * @return string
966
+ */
967
+ function remove_coupon_text( $coupon ) {
968
+
969
+ $coupon = str_replace( 'woocommerce-remove-coupon', 'wcf-remove-coupon', $coupon );
970
+ return $coupon;
971
+
972
+ }
973
+ /**
974
+ * Apply filter to change the placeholder text of coupon field.
975
+ *
976
+ * @return string
977
+ */
978
+ function coupon_field_placeholder() {
979
+ return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
980
+ }
981
+
982
+ /**
983
+ * Apply filter to change the button text of coupon field.
984
+ *
985
+ * @return string
986
+ */
987
+ function coupon_button_text() {
988
+ return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
989
+ }
990
+
991
+ /**
992
+ * Apply coupon on submit of custom coupon form.
993
+ */
994
+ function apply_coupon() {
995
+
996
+ $response = '';
997
+
998
+ check_ajax_referer( 'wcf-apply-coupon', 'security' );
999
+ if ( ! empty( $_POST['coupon_code'] ) ) {
1000
+ $result = WC()->cart->add_discount( sanitize_text_field( $_POST['coupon_code'] ) );
1001
+ } else {
1002
+ wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' );
1003
+ }
1004
+
1005
+ $response = array(
1006
+ 'status' => $result,
1007
+ 'msg' => wc_print_notices( true ),
1008
+ );
1009
+
1010
+ echo json_encode( $response );
1011
+
1012
+ die();
1013
+ }
1014
+
1015
+
1016
+ /**
1017
+ * Added ajax nonce to localize variable.
1018
+ *
1019
+ * @param array $vars localize variables.
1020
+ */
1021
+ function add_localize_vars( $vars ) {
1022
+
1023
+ $vars['wcf_validate_coupon_nonce'] = wp_create_nonce( 'wcf-apply-coupon' );
1024
+
1025
+ $vars['wcf_validate_remove_coupon_nonce'] = wp_create_nonce( 'wcf-remove-coupon' );
1026
+
1027
+ $vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
1028
+
1029
+ return $vars;
1030
+ }
1031
+
1032
+ /**
1033
+ * Add custom class to the fields to change the UI to three column.
1034
+ *
1035
+ * @param array $fields fields.
1036
+ */
1037
+ function add_three_column_layout_fields( $fields ) {
1038
+
1039
+ if ( empty( $fields['billing']['billing_address_2'] ) ) {
1040
+
1041
+ if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
1042
+ $fields['billing']['billing_address_1']['class'][] = 'form-row-full';
1043
+ }
1044
+ }
1045
+
1046
+ if ( ! empty( $fields['billing']['billing_company'] ) ) {
1047
+
1048
+ if ( isset( $fields['billing']['billing_company'] ) && is_array( $fields['billing']['billing_company'] ) ) {
1049
+ $fields['billing']['billing_company']['class'][] = 'form-row-full';
1050
+ }
1051
+ }
1052
+
1053
+ if ( ! empty( $fields['shipping']['shipping_company'] ) ) {
1054
+
1055
+ if ( isset( $fields['shipping']['shipping_company'] ) && is_array( $fields['shipping']['shipping_company'] ) ) {
1056
+ $fields['shipping']['shipping_company']['class'][] = 'form-row-full';
1057
+ }
1058
+ }
1059
+
1060
+ if ( ! empty( $fields['billing']['billing_country'] ) ) {
1061
+
1062
+ if ( isset( $fields['billing']['billing_country'] ) && is_array( $fields['billing']['billing_country'] ) ) {
1063
+ $fields['billing']['billing_country']['class'][] = 'form-row-full';
1064
+ }
1065
+ }
1066
+
1067
+ if ( ! empty( $fields['shipping']['shipping_country'] ) ) {
1068
+
1069
+ if ( isset( $fields['shipping']['shipping_country'] ) && is_array( $fields['shipping']['shipping_country'] ) ) {
1070
+ $fields['shipping']['shipping_country']['class'][] = 'form-row-full';
1071
+ }
1072
+ }
1073
+
1074
+ if ( ! empty( $fields['billing']['billing_phone'] ) ) {
1075
+
1076
+ if ( isset( $fields['billing']['billing_phone'] ) && is_array( $fields['billing']['billing_phone'] ) ) {
1077
+ $fields['billing']['billing_phone']['class'][] = 'form-row-full';
1078
+ }
1079
+ }
1080
+
1081
+ if ( ! empty( $fields['billing']['billing_email'] ) ) {
1082
+
1083
+ if ( isset( $fields['billing']['billing_email'] ) && is_array( $fields['billing']['billing_email'] ) ) {
1084
+ $fields['billing']['billing_email']['class'][] = 'form-row-full';
1085
+ }
1086
+ }
1087
+
1088
+ if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
1089
+
1090
+ if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
1091
+ $fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
1092
+ }
1093
+ }
1094
+
1095
+ if ( isset( $fields['billing']['billing_city'] ) &&
1096
+ isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
1097
+
1098
+ $fields['billing']['billing_city']['class'][] = 'wcf-column-33';
1099
+ $fields['billing']['billing_state']['class'][] = 'wcf-column-33';
1100
+ $fields['billing']['billing_postcode']['class'][] = 'wcf-column-33';
1101
+ }
1102
+
1103
+ if ( isset( $fields['shipping']['shipping_city'] ) &&
1104
+ isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
1105
+
1106
+ $fields['shipping']['shipping_city']['class'][] = 'wcf-column-33';
1107
+ $fields['shipping']['shipping_state']['class'][] = 'wcf-column-33';
1108
+ $fields['shipping']['shipping_postcode']['class'][] = 'wcf-column-33';
1109
+ }
1110
+
1111
+ return $fields;
1112
+ }
1113
+
1114
+ /**
1115
+ * Add opening dev
1116
+ *
1117
+ * @since 1.0.0
1118
+ */
1119
+ function order_wrap_div_start() {
1120
+
1121
+ echo "<div class='wcf-order-wrap'> ";
1122
+ }
1123
+
1124
+ /**
1125
+ * Add closing dev
1126
+ *
1127
+ * @since 1.0.0
1128
+ */
1129
+ function order_wrap_div_end() {
1130
+
1131
+ echo '</div> ';
1132
+ }
1133
+
1134
+ /**
1135
+ * Remove coupon.
1136
+ */
1137
+ function remove_coupon() {
1138
+
1139
+ check_ajax_referer( 'wcf-remove-coupon', 'security' );
1140
+ $coupon = isset( $_POST['coupon_code'] ) ? wc_clean( $_POST['coupon_code'] ) : false;
1141
+
1142
+ if ( empty( $coupon ) ) {
1143
+ echo "<div class='woocommerce-error'>Sorry there was a problem removing this coupon.";
1144
+ } else {
1145
+ WC()->cart->remove_coupon( $coupon );
1146
+ echo "<div class='woocommerce-error'>Coupon has been removed.</div>";
1147
+ }
1148
+ wc_print_notices();
1149
+ wp_die();
1150
+ }
1151
+
1152
+ }
1153
+
1154
+ /**
1155
+ * Kicking this off by calling 'get_instance()' method
1156
+ */
1157
+ Cartflows_Checkout_Markup::get_instance();
modules/checkout/classes/class-cartflows-checkout-meta.php CHANGED
@@ -1,772 +1,772 @@
1
- <?php
2
- /**
3
- * Checkout post meta
4
- *
5
- * @package CartFlows
6
- */
7
-
8
- /**
9
- * Meta Boxes setup
10
- */
11
- class Cartflows_Checkout_Meta extends Cartflows_Meta {
12
-
13
- /**
14
- * Instance
15
- *
16
- * @var $instance
17
- */
18
- private static $instance;
19
-
20
- /**
21
- * Meta Option
22
- *
23
- * @var $meta_option
24
- */
25
- private static $meta_option = null;
26
-
27
- /**
28
- * Initiator
29
- */
30
- public static function get_instance() {
31
- if ( ! isset( self::$instance ) ) {
32
- self::$instance = new self;
33
- }
34
-
35
- return self::$instance;
36
- }
37
-
38
- /**
39
- * Constructor
40
- */
41
- public function __construct() {
42
-
43
- /* Init Metabox */
44
- add_action( 'load-post.php', array( $this, 'init_metabox' ) );
45
- add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
46
- }
47
-
48
- /**
49
- * Init Metabox
50
- */
51
- public function init_metabox() {
52
-
53
- add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) );
54
- add_action( 'save_post', array( $this, 'save_meta_box' ) );
55
- }
56
-
57
- /**
58
- * Setup Metabox
59
- */
60
- function setup_meta_box() {
61
-
62
- // Get all posts.
63
- $post_types = get_post_types();
64
-
65
- if ( _is_wcf_checkout_type() ) {
66
- add_meta_box(
67
- 'wcf-checkout-settings', // Id.
68
- __( 'Checkout Layout', 'cartflows' ), // Title.
69
- array( $this, 'markup_meta_box' ), // Callback.
70
- wcf()->utils->get_step_post_type(), // Post_type.
71
- 'normal', // Context.
72
- 'high' // Priority.
73
- );
74
- }
75
- }
76
-
77
- /**
78
- * Metabox Markup
79
- *
80
- * @param object $post Post object.
81
- * @return void
82
- */
83
- function markup_meta_box( $post ) {
84
-
85
- wp_nonce_field( 'save-nonce-checkout-step-meta', 'nonce-checkout-step-meta' );
86
-
87
- $stored = get_post_meta( $post->ID );
88
-
89
- $checkout_meta = self::get_meta_option( $post->ID );
90
-
91
- // Set stored and override defaults.
92
- foreach ( $stored as $key => $value ) {
93
- if ( array_key_exists( $key, $checkout_meta ) ) {
94
- self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
95
- } else {
96
- self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
97
- }
98
- }
99
-
100
- // Get defaults.
101
- $meta = self::get_meta_option( $post->ID );
102
- $checkout_data = array();
103
-
104
- foreach ( $meta as $key => $value ) {
105
-
106
- $checkout_data[ $key ] = $meta[ $key ]['default'];
107
- }
108
-
109
- /*
110
- $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post->ID );
111
-
112
- foreach ( $billing_fields as $key => $value ) {
113
-
114
- $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
115
- }
116
-
117
- $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post->ID );
118
-
119
- foreach ( $shipping_fields as $key => $value ) {
120
-
121
- $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
122
- }
123
-
124
- $additional_fields = Cartflows_Helper::get_checkout_fields( 'additional', $post->ID );
125
-
126
- foreach ( $additional_fields as $key => $value ) {
127
-
128
- $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
129
- }
130
- */
131
-
132
- do_action( 'wcf_checkout_settings_markup_before' );
133
- $this->tabs_markup( $checkout_data, $post->ID );
134
- do_action( 'wcf_checkout_settings_markup_after' );
135
- }
136
-
137
- /**
138
- * Page Header Tabs
139
- *
140
- * @param array $options options.
141
- * @param int $post_id post ID.
142
- */
143
- function tabs_markup( $options, $post_id ) {
144
-
145
- $active_tab = get_post_meta( $post_id, 'wcf-active-tab', true );
146
-
147
- if ( empty( $active_tab ) ) {
148
- $active_tab = 'wcf-checkout-shortcodes';
149
- }
150
-
151
- $tabs = apply_filters(
152
- 'cartflows_checkout_tabs',
153
- array(
154
- array(
155
- 'title' => __( 'Shortcodes', 'cartflows' ),
156
- 'id' => 'wcf-checkout-shortcodes',
157
- 'class' => 'wcf-checkout-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
158
- 'icon' => 'dashicons-editor-code',
159
- ),
160
- array(
161
- 'title' => __( 'Select Product', 'cartflows' ),
162
- 'id' => 'wcf-checkout-general',
163
- 'class' => 'wcf-checkout-general' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
164
- 'icon' => 'dashicons-info',
165
- ),
166
- array(
167
- 'title' => __( 'Order Bump', 'cartflows' ),
168
- 'id' => 'wcf-product-order-bump',
169
- 'class' => 'wcf-product-order-bump' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
170
- 'icon' => 'dashicons-cart',
171
- ),
172
- array(
173
- 'title' => __( 'Checkout Design', 'cartflows' ),
174
- 'id' => 'wcf-checkout-style',
175
- 'class' => 'wcf-checkout-style' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
176
- 'icon' => 'dashicons-admin-customizer',
177
- ),
178
- array(
179
- 'title' => __( 'Checkout Fields', 'cartflows' ),
180
- 'id' => 'wcf-checkout-custom-fields',
181
- 'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
182
- 'icon' => 'dashicons-welcome-widgets-menus',
183
- ),
184
- array(
185
- 'title' => __( 'Logo (Optional)', 'cartflows' ),
186
- 'id' => 'wcf-checkout-header',
187
- 'class' => 'wcf-checkout-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
188
- 'icon' => 'dashicons-format-image',
189
- ),
190
- array(
191
- 'title' => __( 'Custom Script', 'cartflows' ),
192
- 'id' => 'wcf-checkout-custom-script-header',
193
- 'class' => 'wcf-checkout-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
194
- 'icon' => 'dashicons-format-aside',
195
- ),
196
- ),
197
- $active_tab
198
- );
199
-
200
- ?>
201
- <div class="wcf-checkout-table wcf-metabox-wrap widefat">
202
- <div class="wcf-table-container">
203
- <div class="wcf-column-left">
204
- <div class="wcf-tab-wrapper">
205
-
206
- <?php foreach ( $tabs as $key => $tab ) { ?>
207
- <div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
208
- <span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
209
- <span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
210
- </div>
211
- <?php } ?>
212
-
213
- <input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" />
214
- </div>
215
- </div>
216
- <div class="wcf-column-right">
217
- <?php $this->tab_shortcodes( $options, $post_id ); ?>
218
- <?php $this->tab_general( $options, $post_id ); ?>
219
- <?php $this->tab_style( $options, $post_id ); ?>
220
- <?php $this->tab_product_bump( $options, $post_id ); ?>
221
- <?php $this->tab_custom_fields( $options, $post_id ); ?>
222
- <?php $this->tab_header_content( $options, $post_id ); ?>
223
- <?php $this->tab_custom_script( $options, $post_id ); ?>
224
- <?php do_action( 'cartflows_checkout_tabs_content', $options, $post_id ); ?>
225
- <?php $this->right_column_footer( $options, $post_id ); ?>
226
- </div>
227
- </div>
228
- </div>
229
-
230
- <?php
231
- }
232
-
233
- /**
234
- * Shortcodes tab
235
- *
236
- * @param array $options options.
237
- * @param int $post_id post ID.
238
- */
239
- function tab_shortcodes( $options, $post_id ) {
240
- ?>
241
- <div class="wcf-checkout-shortcodes wcf-tab-content widefat">
242
-
243
- <?php
244
-
245
- echo wcf()->meta->get_shortcode_field(
246
- array(
247
- 'label' => 'Checkout Page',
248
- 'name' => 'wcf-checkout-shortcode',
249
- 'content' => '[cartflows_checkout]',
250
- 'help' => __( 'Add this shortcode to your checkout page', 'cartflows' ),
251
- )
252
- );
253
- ?>
254
- </div>
255
- <?php
256
- }
257
-
258
-
259
- /**
260
- * General tab
261
- *
262
- * @param array $options options.
263
- * @param int $post_id post ID.
264
- */
265
- function tab_general( $options, $post_id ) {
266
- ?>
267
- <div class="wcf-checkout-general wcf-tab-content widefat">
268
-
269
- <?php
270
-
271
- echo wcf()->meta->get_product_selection_repeater(
272
- array(
273
- 'name' => 'wcf-checkout-products',
274
- 'value' => $options['wcf-checkout-products'],
275
- 'allow_clear' => true,
276
- )
277
- );
278
-
279
- do_action( 'cartflows_checkout_general_tab_content', $options, $post_id );
280
-
281
- ?>
282
- </div>
283
- <?php
284
- }
285
-
286
- /**
287
- * Product bump tab
288
- *
289
- * @param array $options options.
290
- * @param int $post_id post ID.
291
- */
292
- function tab_product_bump( $options, $post_id ) {
293
- ?>
294
- <div class="wcf-product-order-bump wcf-tab-content widefat">
295
- <?php
296
- if ( ! _is_cartflows_pro() ) {
297
-
298
- echo wcf()->meta->get_description_field(
299
- array(
300
- 'name' => 'wcf-upgrade-to-pro',
301
- /* translators: %s: link */
302
- 'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
303
- )
304
- );
305
- }
306
- ?>
307
-
308
- <?php do_action( 'cartflows_order_bump_tab_content', $options, $post_id ); ?>
309
- </div>
310
- <?php
311
- }
312
- /**
313
- * Tab custom fields
314
- *
315
- * @param array $options options.
316
- * @param int $post_id post ID.
317
- */
318
- function tab_custom_fields( $options, $post_id ) {
319
- ?>
320
- <div class="wcf-checkout-custom-fields wcf-tab-content widefat">
321
- <?php
322
- /* Custom Checkout Fields Section */
323
-
324
- if ( ! _is_cartflows_pro() ) {
325
-
326
- echo wcf()->meta->get_description_field(
327
- array(
328
- 'name' => 'wcf-upgrade-to-pro',
329
- /* translators: %s: link */
330
- 'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
331
- )
332
- );
333
- }
334
- ?>
335
- <?php do_action( 'cartflows_custom_fields_tab_content', $options, $post_id ); ?>
336
- </div>
337
- <?php
338
- }
339
-
340
- /**
341
- * Tab style
342
- *
343
- * @param array $options options.
344
- * @param int $post_id post ID.
345
- */
346
- function tab_style( $options, $post_id ) {
347
- ?>
348
-
349
- <div class="wcf-checkout-style wcf-tab-content widefat">
350
- <div class="wcf-cs-fields">
351
- <div class="wcf-cs-checkbox-field">
352
- <?php
353
-
354
- $layout_pro_option = array();
355
-
356
- if ( ! _is_cartflows_pro() ) {
357
- $layout_pro_option = array(
358
- 'one-column' => __( 'One Column (Available in CartFlows Pro) ', 'cartflows' ),
359
- 'two-step' => __( 'Two Step (Available in CartFlows Pro) ', 'cartflows' ),
360
- );
361
- }
362
-
363
- echo wcf()->meta->get_select_field(
364
- array(
365
- 'label' => __( 'Checkout Skin', 'cartflows' ),
366
- 'name' => 'wcf-checkout-layout',
367
- 'value' => $options['wcf-checkout-layout'],
368
- 'options' => array(
369
- 'one-column' => __( 'One Column', 'cartflows' ),
370
- 'two-column' => __( 'Two Column', 'cartflows' ),
371
- 'two-step' => __( 'Two Step', 'cartflows' ),
372
- ),
373
- 'pro-options' => $layout_pro_option,
374
-
375
- )
376
- );
377
-
378
- echo wcf()->meta->get_color_picker_field(
379
- array(
380
- 'label' => __( 'Primary Color', 'cartflows' ),
381
- 'name' => 'wcf-primary-color',
382
- 'value' => $options['wcf-primary-color'],
383
- )
384
- );
385
-
386
- echo wcf()->meta->get_font_family_field(
387
- array(
388
- 'for' => 'wcf-base',
389
- 'label' => __( 'Font Family', 'cartflows' ),
390
- 'name' => 'wcf-base-font-family',
391
- 'value' => $options['wcf-base-font-family'],
392
- )
393
- );
394
-
395
- echo wcf()->meta->get_checkbox_field(
396
- array(
397
- 'label' => __( 'Advance Options', 'cartflows' ),
398
- 'name' => 'wcf-advance-options-fields',
399
- 'value' => $options['wcf-advance-options-fields'],
400
- 'after' => 'Enable',
401
- )
402
- );
403
- ?>
404
- </div>
405
- <div class="wcf-cs-fields-options">
406
- <?php
407
- echo wcf()->meta->get_section(
408
- array(
409
- 'label' => __( 'Heading', 'cartflows' ),
410
- )
411
- );
412
-
413
- echo wcf()->meta->get_color_picker_field(
414
- array(
415
- 'label' => __( 'Heading Color', 'cartflows' ),
416
- 'name' => 'wcf-heading-color',
417
- 'value' => $options['wcf-heading-color'],
418
- )
419
- );
420
-
421
- echo wcf()->meta->get_font_family_field(
422
- array(
423
- 'for' => 'wcf-heading',
424
- 'label' => __( 'Font Family', 'cartflows' ),
425
- 'name' => 'wcf-heading-font-family',
426
- 'value' => $options['wcf-heading-font-family'],
427
- )
428
- );
429
-
430
- echo wcf()->meta->get_font_weight_field(
431
- array(
432
- 'for' => 'wcf-heading',
433
- 'label' => __( 'Font Weight', 'cartflows' ),
434
- 'name' => 'wcf-heading-font-weight',
435
- 'value' => $options['wcf-heading-font-weight'],
436
- )
437
- );
438
-
439
- echo wcf()->meta->get_section(
440
- array(
441
- 'label' => __( 'Input Fields', 'cartflows' ),
442
- )
443
- );
444
-
445
- $fields_skin_pro_option = array();
446
-
447
- if ( ! _is_cartflows_pro() ) {
448
- $fields_skin_pro_option = array(
449
- 'skin-one' => __( 'Floating Labels (Available in CartFlows Pro)', 'cartflows' ),
450
- );
451
- }
452
-
453
- echo wcf()->meta->get_select_field(
454
- array(
455
- 'label' => __( 'Style', 'cartflows' ),
456
- 'name' => 'wcf-fields-skins',
457
- 'value' => $options['wcf-fields-skins'],
458
- 'options' => array(
459
- 'default' => __( 'Default', 'cartflows' ),
460
- 'style-one' => __( 'Floating Labels', 'cartflows' ),
461
- ),
462
- 'pro-options' => $fields_skin_pro_option,
463
-
464
- )
465
- );
466
-
467
- echo wcf()->meta->get_font_family_field(
468
- array(
469
- 'for' => 'wcf-input',
470
- 'label' => __( 'Font Family', 'cartflows' ),
471
- 'name' => 'wcf-input-font-family',
472
- 'value' => $options['wcf-input-font-family'],
473
- )
474
- );
475
-
476
- echo wcf()->meta->get_font_weight_field(
477
- array(
478
- 'for' => 'wcf-input',
479
- 'label' => __( 'Font Weight', 'cartflows' ),
480
- 'name' => 'wcf-input-font-weight',
481
- 'value' => $options['wcf-input-font-weight'],
482
- )
483
- );
484
-
485
- echo wcf()->meta->get_select_field(
486
- array(
487
- 'label' => __( 'Size', 'cartflows' ),
488
- 'name' => 'wcf-input-field-size',
489
- 'value' => $options['wcf-input-field-size'],
490
- 'options' => array(
491
- '33px' => __( 'Extra Small', 'cartflows' ),
492
- '38px' => __( 'Small', 'cartflows' ),
493
- '44px' => __( 'Medium', 'cartflows' ),
494
- '58px' => __( 'Large', 'cartflows' ),
495
- '68px' => __( 'Extra Large', 'cartflows' ),
496
- 'custom' => __( 'Custom', 'cartflows' ),
497
- ),
498
- )
499
- );
500
-
501
- echo wcf()->meta->get_number_field(
502
- array(
503
- 'label' => __( 'Top Bottom Spacing', 'cartflows' ),
504
- 'name' => 'wcf-field-tb-padding',
505
- 'value' => $options['wcf-field-tb-padding'],
506
- )
507
- );
508
-
509
- echo wcf()->meta->get_number_field(
510
- array(
511
- 'label' => __( 'Left Right Spacing', 'cartflows' ),
512
- 'name' => 'wcf-field-lr-padding',
513
- 'value' => $options['wcf-field-lr-padding'],
514
- )
515
- );
516
-
517
- echo wcf()->meta->get_color_picker_field(
518
- array(
519
- 'label' => __( 'Text / Placeholder Color', 'cartflows' ),
520
- 'name' => 'wcf-field-color',
521
- 'value' => $options['wcf-field-color'],
522
- )
523
- );
524
-
525
- echo wcf()->meta->get_color_picker_field(
526
- array(
527
- 'label' => __( 'Background Color', 'cartflows' ),
528
- 'name' => 'wcf-field-bg-color',
529
- 'value' => $options['wcf-field-bg-color'],
530
- )
531
- );
532
-
533
- echo wcf()->meta->get_color_picker_field(
534
- array(
535
- 'label' => __( 'Border Color', 'cartflows' ),
536
- 'name' => 'wcf-field-border-color',
537
- 'value' => $options['wcf-field-border-color'],
538
- )
539
- );
540
- echo wcf()->meta->get_color_picker_field(
541
- array(
542
- 'label' => __( 'Label Color', 'cartflows' ),
543
- 'name' => 'wcf-field-label-color',
544
- 'value' => $options['wcf-field-label-color'],
545
- )
546
- );
547
-
548
- ?>
549
- </div>
550
- <div class="wcf-cs-button-options">
551
- <?php
552
-
553
- echo wcf()->meta->get_section(
554
- array(
555
- 'label' => __( 'Buttons', 'cartflows' ),
556
- )
557
- );
558
-
559
- echo wcf()->meta->get_font_family_field(
560
- array(
561
- 'for' => 'wcf-button',
562
- 'label' => __( 'Font Family', 'cartflows' ),
563
- 'name' => 'wcf-button-font-family',
564
- 'value' => $options['wcf-button-font-family'],
565
- )
566
- );
567
-
568
- echo wcf()->meta->get_font_weight_field(
569
- array(
570
- 'for' => 'wcf-button',
571
- 'label' => __( 'Font Weight', 'cartflows' ),
572
- 'name' => 'wcf-button-font-weight',
573
- 'value' => $options['wcf-button-font-weight'],
574
- )
575
- );
576
-
577
- echo wcf()->meta->get_select_field(
578
- array(
579
- 'label' => __( 'Size', 'cartflows' ),
580
- 'name' => 'wcf-input-button-size',
581
- 'value' => $options['wcf-input-button-size'],
582
- 'options' => array(
583
- '33px' => __( 'Extra Small', 'cartflows' ),
584
- '38px' => __( 'Small', 'cartflows' ),
585
- '44px' => __( 'Medium', 'cartflows' ),
586
- '58px' => __( 'Large', 'cartflows' ),
587
- '68px' => __( 'Extra Large', 'cartflows' ),
588
- 'custom' => __( 'Custom', 'cartflows' ),
589
- ),
590
- )
591
- );
592
-
593
- echo wcf()->meta->get_number_field(
594
- array(
595
- 'label' => __( 'Top Bottom Spacing', 'cartflows' ),
596
- 'name' => 'wcf-submit-tb-padding',
597
- 'value' => $options['wcf-submit-tb-padding'],
598
- )
599
- );
600
-
601
- echo wcf()->meta->get_number_field(
602
- array(
603
- 'label' => __( 'Left Right Spacing', 'cartflows' ),
604
- 'name' => 'wcf-submit-lr-padding',
605
- 'value' => $options['wcf-submit-lr-padding'],
606
- )
607
- );
608
-
609
- echo wcf()->meta->get_color_picker_field(
610
- array(
611
- 'label' => __( 'Text Color', 'cartflows' ),
612
- 'name' => 'wcf-submit-color',
613
- 'value' => $options['wcf-submit-color'],
614
- )
615
- );
616
-
617
- echo wcf()->meta->get_color_picker_field(
618
- array(
619
- 'label' => __( 'Text Hover Color', 'cartflows' ),
620
- 'name' => 'wcf-submit-hover-color',
621
- 'value' => $options['wcf-submit-hover-color'],
622
- )
623
- );
624
-
625
- echo wcf()->meta->get_color_picker_field(
626
- array(
627
- 'label' => __( 'Background Color', 'cartflows' ),
628
- 'name' => 'wcf-submit-bg-color',
629
- 'value' => $options['wcf-submit-bg-color'],
630
- )
631
- );
632
-
633
- echo wcf()->meta->get_color_picker_field(
634
- array(
635
- 'label' => __( 'Background Hover Color', 'cartflows' ),
636
- 'name' => 'wcf-submit-bg-hover-color',
637
- 'value' => $options['wcf-submit-bg-hover-color'],
638
- )
639
- );
640
-
641
- echo wcf()->meta->get_color_picker_field(
642
- array(
643
- 'label' => __( 'Border Color', 'cartflows' ),
644
- 'name' => 'wcf-submit-border-color',
645
- 'value' => $options['wcf-submit-border-color'],
646
- )
647
- );
648
-
649
- echo wcf()->meta->get_color_picker_field(
650
- array(
651
- 'label' => __( 'Border Hover Color', 'cartflows' ),
652
- 'name' => 'wcf-submit-border-hover-color',
653
- 'value' => $options['wcf-submit-border-hover-color'],
654
- )
655
- );
656
-
657
- ?>
658
- </div>
659
- <div class="wcf-cs-section-options">
660
- <?php
661
-
662
- echo wcf()->meta->get_section(
663
- array(
664
- 'label' => __( 'Sections', 'cartflows' ),
665
- )
666
- );
667
-
668
- echo wcf()->meta->get_color_picker_field(
669
- array(
670
- 'label' => __( 'Highlight Area Background Color', 'cartflows' ),
671
- 'name' => 'wcf-hl-bg-color',
672
- 'value' => $options['wcf-hl-bg-color'],
673
- )
674
- );
675
-
676
- echo wcf()->meta->get_hidden_field(
677
- array(
678
- 'name' => 'wcf-field-google-font-url',
679
- 'value' => $options['wcf-field-google-font-url'],
680
- )
681
- );
682
- ?>
683
- </div>
684
- <?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?>
685
- </div>
686
- </div>
687
- <?php
688
- }
689
-
690
-
691
- /**
692
- * Tab Header (Used for add logo into header)
693
- *
694
- * @param array $options options.
695
- * @param int $post_id post ID.
696
- */
697
- function tab_header_content( $options, $post_id ) {
698
- ?>
699
-
700
- <div class="wcf-checkout-header wcf-tab-content widefat">
701
- <?php
702
-
703
- $layout_pro_option = array();
704
-
705
- echo wcf()->meta->get_image_field(
706
- array(
707
- 'name' => 'wcf-header-logo-image',
708
- 'value' => $options['wcf-header-logo-image'],
709
- 'label' => __( 'Header Logo', 'cartflows' ),
710
- )
711
- );
712
-
713
- echo wcf()->meta->get_number_field(
714
- array(
715
- 'name' => 'wcf-header-logo-width',
716
- 'value' => $options['wcf-header-logo-width'],
717
- 'label' => __( 'Logo Width (In px)', 'cartflows' ),
718
- )
719
- );
720
- ?>
721
- <?php do_action( 'cartflows_checkout_header_tab_content', $options, $post_id ); ?>
722
- </div>
723
- <?php
724
- }
725
- /**
726
- * Get metabox options
727
- *
728
- * @param int $post_id post ID.
729
- */
730
- public static function get_meta_option( $post_id ) {
731
-
732
- if ( null === self::$meta_option ) {
733
-
734
- /**
735
- * Set metabox options
736
- *
737
- * @see http://php.net/manual/en/filter.filters.sanitize.php
738
- */
739
- self::$meta_option = wcf()->options->get_checkout_fields( $post_id );
740
- }
741
-
742
- return self::$meta_option;
743
- }
744
-
745
- /**
746
- * Metabox Save
747
- *
748
- * @param number $post_id Post ID.
749
- * @return void
750
- */
751
- function save_meta_box( $post_id ) {
752
-
753
- // Checks save status.
754
- $is_autosave = wp_is_post_autosave( $post_id );
755
- $is_revision = wp_is_post_revision( $post_id );
756
-
757
- $is_valid_nonce = ( isset( $_POST['nonce-checkout-step-meta'] ) && wp_verify_nonce( $_POST['nonce-checkout-step-meta'], 'save-nonce-checkout-step-meta' ) ) ? true : false;
758
-
759
- // Exits script depending on save status.
760
- if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
761
- return;
762
- }
763
-
764
- wcf()->options->save_checkout_fields( $post_id );
765
- }
766
-
767
- }
768
-
769
- /**
770
- * Kicking this off by calling 'get_instance()' method
771
- */
772
- Cartflows_Checkout_Meta::get_instance();
1
+ <?php
2
+ /**
3
+ * Checkout post meta
4
+ *
5
+ * @package CartFlows
6
+ */
7
+
8
+ /**
9
+ * Meta Boxes setup
10
+ */
11
+ class Cartflows_Checkout_Meta extends Cartflows_Meta {
12
+
13
+ /**
14
+ * Instance
15
+ *
16
+ * @var $instance
17
+ */
18
+ private static $instance;
19
+
20
+ /**
21
+ * Meta Option
22
+ *
23
+ * @var $meta_option
24
+ */
25
+ private static $meta_option = null;
26
+
27
+ /**
28
+ * Initiator
29
+ */
30
+ public static function get_instance() {
31
+ if ( ! isset( self::$instance ) ) {
32
+ self::$instance = new self;
33
+ }
34
+
35
+ return self::$instance;
36
+ }
37
+
38
+ /**
39
+ * Constructor
40
+ */
41
+ public function __construct() {
42
+
43
+ /* Init Metabox */
44
+ add_action( 'load-post.php', array( $this, 'init_metabox' ) );
45
+ add_action( 'load-post-new.php', array( $this, 'init_metabox' ) );
46
+ }
47
+
48
+ /**
49
+ * Init Metabox
50
+ */
51
+ public function init_metabox() {
52
+
53
+ add_action( 'add_meta_boxes', array( $this, 'setup_meta_box' ) );
54
+ add_action( 'save_post', array( $this, 'save_meta_box' ) );
55
+ }
56
+
57
+ /**
58
+ * Setup Metabox
59
+ */
60
+ function setup_meta_box() {
61
+
62
+ // Get all posts.
63
+ $post_types = get_post_types();
64
+
65
+ if ( _is_wcf_checkout_type() ) {
66
+ add_meta_box(
67
+ 'wcf-checkout-settings', // Id.
68
+ __( 'Checkout Layout', 'cartflows' ), // Title.
69
+ array( $this, 'markup_meta_box' ), // Callback.
70
+ wcf()->utils->get_step_post_type(), // Post_type.
71
+ 'normal', // Context.
72
+ 'high' // Priority.
73
+ );
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Metabox Markup
79
+ *
80
+ * @param object $post Post object.
81
+ * @return void
82
+ */
83
+ function markup_meta_box( $post ) {
84
+
85
+ wp_nonce_field( 'save-nonce-checkout-step-meta', 'nonce-checkout-step-meta' );
86
+
87
+ $stored = get_post_meta( $post->ID );
88
+
89
+ $checkout_meta = self::get_meta_option( $post->ID );
90
+
91
+ // Set stored and override defaults.
92
+ foreach ( $stored as $key => $value ) {
93
+ if ( array_key_exists( $key, $checkout_meta ) ) {
94
+ self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? maybe_unserialize( $stored[ $key ][0] ) : '';
95
+ } else {
96
+ self::$meta_option[ $key ]['default'] = ( isset( $stored[ $key ][0] ) ) ? $stored[ $key ][0] : '';
97
+ }
98
+ }
99
+
100
+ // Get defaults.
101
+ $meta = self::get_meta_option( $post->ID );
102
+ $checkout_data = array();
103
+
104
+ foreach ( $meta as $key => $value ) {
105
+
106
+ $checkout_data[ $key ] = $meta[ $key ]['default'];
107
+ }
108
+
109
+ /*
110
+ $billing_fields = Cartflows_Helper::get_checkout_fields( 'billing', $post->ID );
111
+
112
+ foreach ( $billing_fields as $key => $value ) {
113
+
114
+ $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
115
+ }
116
+
117
+ $shipping_fields = Cartflows_Helper::get_checkout_fields( 'shipping', $post->ID );
118
+
119
+ foreach ( $shipping_fields as $key => $value ) {
120
+
121
+ $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
122
+ }
123
+
124
+ $additional_fields = Cartflows_Helper::get_checkout_fields( 'additional', $post->ID );
125
+
126
+ foreach ( $additional_fields as $key => $value ) {
127
+
128
+ $checkout_data[ 'wcf-' . $key ] = $meta[ 'wcf-' . $key ]['default'];
129
+ }
130
+ */
131
+
132
+ do_action( 'wcf_checkout_settings_markup_before' );
133
+ $this->tabs_markup( $checkout_data, $post->ID );
134
+ do_action( 'wcf_checkout_settings_markup_after' );
135
+ }
136
+
137
+ /**
138
+ * Page Header Tabs
139
+ *
140
+ * @param array $options options.
141
+ * @param int $post_id post ID.
142
+ */
143
+ function tabs_markup( $options, $post_id ) {
144
+
145
+ $active_tab = get_post_meta( $post_id, 'wcf-active-tab', true );
146
+
147
+ if ( empty( $active_tab ) ) {
148
+ $active_tab = 'wcf-checkout-shortcodes';
149
+ }
150
+
151
+ $tabs = apply_filters(
152
+ 'cartflows_checkout_tabs',
153
+ array(
154
+ array(
155
+ 'title' => __( 'Shortcodes', 'cartflows' ),
156
+ 'id' => 'wcf-checkout-shortcodes',
157
+ 'class' => 'wcf-checkout-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
158
+ 'icon' => 'dashicons-editor-code',
159
+ ),
160
+ array(
161
+ 'title' => __( 'Select Product', 'cartflows' ),
162
+ 'id' => 'wcf-checkout-general',
163
+ 'class' => 'wcf-checkout-general' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
164
+ 'icon' => 'dashicons-info',
165
+ ),
166
+ array(
167
+ 'title' => __( 'Order Bump', 'cartflows' ),
168
+ 'id' => 'wcf-product-order-bump',
169
+ 'class' => 'wcf-product-order-bump' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
170
+ 'icon' => 'dashicons-cart',
171
+ ),
172
+ array(
173
+ 'title' => __( 'Checkout Design', 'cartflows' ),
174
+ 'id' => 'wcf-checkout-style',
175
+ 'class' => 'wcf-checkout-style' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
176
+ 'icon' => 'dashicons-admin-customizer',
177
+ ),
178
+ array(
179
+ 'title' => __( 'Checkout Fields', 'cartflows' ),
180
+ 'id' => 'wcf-checkout-custom-fields',
181
+ 'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
182
+ 'icon' => 'dashicons-welcome-widgets-menus',
183
+ ),
184
+ array(
185
+ 'title' => __( 'Logo (Optional)', 'cartflows' ),
186
+ 'id' => 'wcf-checkout-header',
187
+ 'class' => 'wcf-checkout-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
188
+ 'icon' => 'dashicons-format-image',
189
+ ),
190
+ array(
191
+ 'title' => __( 'Custom Script', 'cartflows' ),
192
+ 'id' => 'wcf-checkout-custom-script-header',
193
+ 'class' => 'wcf-checkout-custom-script-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
194
+ 'icon' => 'dashicons-format-aside',
195
+ ),
196
+ ),
197
+ $active_tab
198
+ );
199
+
200
+ ?>
201
+ <div class="wcf-checkout-table wcf-metabox-wrap widefat">
202
+ <div class="wcf-table-container">
203
+ <div class="wcf-column-left">
204
+ <div class="wcf-tab-wrapper">
205
+
206
+ <?php foreach ( $tabs as $key => $tab ) { ?>
207
+ <div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
208
+ <span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
209
+ <span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
210
+ </div>
211
+ <?php } ?>
212
+
213
+ <input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" />
214
+ </div>
215
+ </div>
216
+ <div class="wcf-column-right">
217
+ <?php $this->tab_shortcodes( $options, $post_id ); ?>
218
+ <?php $this->tab_general( $options, $post_id ); ?>
219
+ <?php $this->tab_style( $options, $post_id ); ?>
220
+ <?php $this->tab_product_bump( $options, $post_id ); ?>
221
+ <?php $this->tab_custom_fields( $options, $post_id ); ?>
222
+ <?php $this->tab_header_content( $options, $post_id ); ?>
223
+ <?php $this->tab_custom_script( $options, $post_id ); ?>
224
+ <?php do_action( 'cartflows_checkout_tabs_content', $options, $post_id ); ?>
225
+ <?php $this->right_column_footer( $options, $post_id ); ?>
226
+ </div>
227
+ </div>
228
+ </div>
229
+
230
+ <?php
231
+ }
232
+
233
+ /**
234
+ * Shortcodes tab
235
+ *
236
+ * @param array $options options.
237
+ * @param int $post_id post ID.
238
+ */
239
+ function tab_shortcodes( $options, $post_id ) {
240
+ ?>
241
+ <div class="wcf-checkout-shortcodes wcf-tab-content widefat">
242
+
243
+ <?php
244
+
245
+ echo wcf()->meta->get_shortcode_field(
246
+ array(
247
+ 'label' => 'Checkout Page',
248
+ 'name' => 'wcf-checkout-shortcode',
249
+ 'content' => '[cartflows_checkout]',
250
+ 'help' => __( 'Add this shortcode to your checkout page', 'cartflows' ),
251
+ )
252
+ );
253
+ ?>
254
+ </div>
255
+ <?php
256
+ }
257
+
258
+
259
+ /**
260
+ * General tab
261
+ *
262
+ * @param array $options options.
263
+ * @param int $post_id post ID.
264
+ */
265
+ function tab_general( $options, $post_id ) {
266
+ ?>
267
+ <div class="wcf-checkout-general wcf-tab-content widefat">
268
+
269
+ <?php
270
+
271
+ echo wcf()->meta->get_product_selection_repeater(
272
+ array(
273
+ 'name' => 'wcf-checkout-products',
274
+ 'value' => $options['wcf-checkout-products'],
275
+ 'allow_clear' => true,
276
+ )
277
+ );
278
+
279
+ do_action( 'cartflows_checkout_general_tab_content', $options, $post_id );
280
+
281
+ ?>
282
+ </div>
283
+ <?php
284
+ }
285
+
286
+ /**
287
+ * Product bump tab
288
+ *
289
+ * @param array $options options.
290
+ * @param int $post_id post ID.
291
+ */
292
+ function tab_product_bump( $options, $post_id ) {
293
+ ?>
294
+ <div class="wcf-product-order-bump wcf-tab-content widefat">
295
+ <?php
296
+ if ( ! _is_cartflows_pro() ) {
297
+
298
+ echo wcf()->meta->get_description_field(
299
+ array(
300
+ 'name' => 'wcf-upgrade-to-pro',
301
+ /* translators: %s: link */
302
+ 'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
303
+ )
304
+ );
305
+ }
306
+ ?>
307
+
308
+ <?php do_action( 'cartflows_order_bump_tab_content', $options, $post_id ); ?>
309
+ </div>
310
+ <?php
311
+ }
312
+ /**
313
+ * Tab custom fields
314
+ *
315
+ * @param array $options options.
316
+ * @param int $post_id post ID.
317
+ */
318
+ function tab_custom_fields( $options, $post_id ) {
319
+ ?>
320
+ <div class="wcf-checkout-custom-fields wcf-tab-content widefat">
321
+ <?php
322
+ /* Custom Checkout Fields Section */
323
+
324
+ if ( ! _is_cartflows_pro() ) {
325
+
326
+ echo wcf()->meta->get_description_field(
327
+ array(
328
+ 'name' => 'wcf-upgrade-to-pro',
329
+ /* translators: %s: link */
330
+ 'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
331
+ )
332
+ );
333
+ }
334
+ ?>
335
+ <?php do_action( 'cartflows_custom_fields_tab_content', $options, $post_id ); ?>
336
+ </div>
337
+ <?php
338
+ }
339
+
340
+ /**
341
+ * Tab style
342
+ *
343
+ * @param array $options options.
344
+ * @param int $post_id post ID.
345
+ */
346
+ function tab_style( $options, $post_id ) {
347
+ ?>
348
+
349
+ <div class="wcf-checkout-style wcf-tab-content widefat">
350
+ <div class="wcf-cs-fields">
351
+ <div class="wcf-cs-checkbox-field">
352
+ <?php
353
+
354
+ $layout_pro_option = array();
355
+
356
+ if ( ! _is_cartflows_pro() ) {
357
+ $layout_pro_option = array(
358
+ 'one-column' => __( 'One Column (Available in CartFlows Pro) ', 'cartflows' ),
359
+ 'two-step' => __( 'Two Step (Available in CartFlows Pro) ', 'cartflows' ),
360
+ );
361
+ }
362
+
363
+ echo wcf()->meta->get_select_field(
364
+ array(
365
+ 'label' => __( 'Checkout Skin', 'cartflows' ),
366
+ 'name' => 'wcf-checkout-layout',
367
+ 'value' => $options['wcf-checkout-layout'],
368
+ 'options' => array(
369
+ 'one-column' => __( 'One Column', 'cartflows' ),
370
+ 'two-column' => __( 'Two Column', 'cartflows' ),
371
+ 'two-step' => __( 'Two Step', 'cartflows' ),
372
+ ),
373
+ 'pro-options' => $layout_pro_option,
374
+
375
+ )
376
+ );
377
+
378
+ echo wcf()->meta->get_color_picker_field(
379
+ array(
380
+ 'label' => __( 'Primary Color', 'cartflows' ),
381
+ 'name' => 'wcf-primary-color',
382
+ 'value' => $options['wcf-primary-color'],
383
+ )
384
+ );
385
+
386
+ echo wcf()->meta->get_font_family_field(
387
+ array(
388
+ 'for' => 'wcf-base',
389
+ 'label' => __( 'Font Family', 'cartflows' ),
390
+ 'name' => 'wcf-base-font-family',
391
+ 'value' => $options['wcf-base-font-family'],
392
+ )
393
+ );
394
+
395
+ echo wcf()->meta->get_checkbox_field(
396
+ array(
397
+ 'label' => __( 'Advance Options', 'cartflows' ),
398
+ 'name' => 'wcf-advance-options-fields',
399
+ 'value' => $options['wcf-advance-options-fields'],
400
+ 'after' => 'Enable',
401
+ )
402
+ );
403
+ ?>
404
+ </div>
405
+ <div class="wcf-cs-fields-options">
406
+ <?php
407
+ echo wcf()->meta->get_section(
408
+ array(
409
+ 'label' => __( 'Heading', 'cartflows' ),
410
+ )
411
+ );
412
+
413
+ echo wcf()->meta->get_color_picker_field(
414
+ array(
415
+ 'label' => __( 'Heading Color', 'cartflows' ),
416
+ 'name' => 'wcf-heading-color',
417
+ 'value' => $options['wcf-heading-color'],
418
+ )
419
+ );
420
+
421
+ echo wcf()->meta->get_font_family_field(
422
+ array(
423
+ 'for' => 'wcf-heading',
424
+ 'label' => __( 'Font Family', 'cartflows' ),
425
+ 'name' => 'wcf-heading-font-family',
426
+ 'value' => $options['wcf-heading-font-family'],
427
+ )
428
+ );
429
+
430
+ echo wcf()->meta->get_font_weight_field(
431
+ array(
432
+ 'for' => 'wcf-heading',
433
+ 'label' => __( 'Font Weight', 'cartflows' ),
434
+ 'name' => 'wcf-heading-font-weight',
435
+ 'value' => $options['wcf-heading-font-weight'],
436
+ )
437
+ );
438
+
439
+ echo wcf()->meta->get_section(
440
+ array(
441
+ 'label' => __( 'Input Fields', 'cartflows' ),
442
+ )
443
+ );
444
+
445
+ $fields_skin_pro_option = array();
446
+
447
+ if ( ! _is_cartflows_pro() ) {
448
+ $fields_skin_pro_option = array(
449
+ 'skin-one' => __( 'Floating Labels (Available in CartFlows Pro)', 'cartflows' ),
450
+ );
451
+ }
452
+
453
+ echo wcf()->meta->get_select_field(
454
+ array(
455
+ 'label' => __( 'Style', 'cartflows' ),
456
+ 'name' => 'wcf-fields-skins',
457
+ 'value' => $options['wcf-fields-skins'],
458
+ 'options' => array(
459
+ 'default' => __( 'Default', 'cartflows' ),
460
+ 'style-one' => __( 'Floating Labels', 'cartflows' ),
461
+ ),
462
+ 'pro-options' => $fields_skin_pro_option,
463
+
464
+ )
465
+ );
466
+
467
+ echo wcf()->meta->get_font_family_field(
468
+ array(
469
+ 'for' => 'wcf-input',
470
+ 'label' => __( 'Font Family', 'cartflows' ),
471
+ 'name' => 'wcf-input-font-family',
472
+ 'value' => $options['wcf-input-font-family'],
473
+ )
474
+ );
475
+
476
+ echo wcf()->meta->get_font_weight_field(
477
+ array(
478
+ 'for' => 'wcf-input',
479
+ 'label' => __( 'Font Weight', 'cartflows' ),
480
+ 'name' => 'wcf-input-font-weight',
481
+ 'value' => $options['wcf-input-font-weight'],
482
+ )
483
+ );
484
+
485
+ echo wcf()->meta->get_select_field(
486
+ array(
487
+ 'label' => __( 'Size', 'cartflows' ),
488
+ 'name' => 'wcf-input-field-size',
489
+ 'value' => $options['wcf-input-field-size'],
490
+ 'options' => array(
491
+ '33px' => __( 'Extra Small', 'cartflows' ),
492
+ '38px' => __( 'Small', 'cartflows' ),
493
+ '44px' => __( 'Medium', 'cartflows' ),
494
+ '58px' => __( 'Large', 'cartflows' ),
495
+ '68px' => __( 'Extra Large', 'cartflows' ),
496
+ 'custom' => __( 'Custom', 'cartflows' ),
497
+ ),
498
+ )
499
+ );
500
+
501
+ echo wcf()->meta->get_number_field(
502
+ array(
503
+ 'label' => __( 'Top Bottom Spacing', 'cartflows' ),
504
+ 'name' => 'wcf-field-tb-padding',
505
+ 'value' => $options['wcf-field-tb-padding'],
506
+ )
507
+ );
508
+
509
+ echo wcf()->meta->get_number_field(
510
+ array(
511
+ 'label' => __( 'Left Right Spacing', 'cartflows' ),
512
+ 'name' => 'wcf-field-lr-padding',
513
+ 'value' => $options['wcf-field-lr-padding'],
514
+ )
515
+ );
516
+
517
+ echo wcf()->meta->get_color_picker_field(
518
+ array(
519
+ 'label' => __( 'Text / Placeholder Color', 'cartflows' ),
520
+ 'name' => 'wcf-field-color',
521
+ 'value' => $options['wcf-field-color'],
522
+ )
523
+ );
524
+
525
+ echo wcf()->meta->get_color_picker_field(
526
+ array(
527
+ 'label' => __( 'Background Color', 'cartflows' ),
528
+ 'name' => 'wcf-field-bg-color',
529
+ 'value' => $options['wcf-field-bg-color'],
530
+ )
531
+ );
532
+
533
+ echo wcf()->meta->get_color_picker_field(
534
+ array(
535
+ 'label' => __( 'Border Color', 'cartflows' ),
536
+ 'name' => 'wcf-field-border-color',
537
+ 'value' => $options['wcf-field-border-color'],
538
+ )
539
+ );
540
+ echo wcf()->meta->get_color_picker_field(
541
+ array(
542
+ 'label' => __( 'Label Color', 'cartflows' ),
543
+ 'name' => 'wcf-field-label-color',
544
+ 'value' => $options['wcf-field-label-color'],
545
+ )
546
+ );
547
+
548
+ ?>
549
+ </div>
550
+ <div class="wcf-cs-button-options">
551
+ <?php
552
+
553
+ echo wcf()->meta->get_section(
554
+ array(
555
+ 'label' => __( 'Buttons', 'cartflows' ),
556
+ )
557
+ );
558
+
559
+ echo wcf()->meta->get_font_family_field(
560
+ array(
561
+ 'for' => 'wcf-button',
562
+ 'label' => __( 'Font Family', 'cartflows' ),
563
+ 'name' => 'wcf-button-font-family',
564
+ 'value' => $options['wcf-button-font-family'],
565
+ )
566
+ );
567
+
568
+ echo wcf()->meta->get_font_weight_field(
569
+ array(
570
+ 'for' => 'wcf-button',
571
+ 'label' => __( 'Font Weight', 'cartflows' ),
572
+ 'name' => 'wcf-button-font-weight',
573
+ 'value' => $options['wcf-button-font-weight'],
574
+ )
575
+ );
576
+
577
+ echo wcf()->meta->get_select_field(
578
+ array(
579
+ 'label' => __( 'Size', 'cartflows' ),
580
+ 'name' => 'wcf-input-button-size',
581
+ 'value' => $options['wcf-input-button-size'],
582
+ 'options' => array(
583
+ '33px' => __( 'Extra Small', 'cartflows' ),
584
+ '38px' => __( 'Small', 'cartflows' ),
585
+ '44px' => __( 'Medium', 'cartflows' ),
586
+ '58px' => __( 'Large', 'cartflows' ),
587
+ '68px' => __( 'Extra Large', 'cartflows' ),
588
+ 'custom' => __( 'Custom', 'cartflows' ),
589
+ ),
590
+ )
591
+ );
592
+
593
+ echo wcf()->meta->get_number_field(
594
+ array(
595
+ 'label' => __( 'Top Bottom Spacing', 'cartflows' ),
596
+ 'name' => 'wcf-submit-tb-padding',
597
+ 'value' => $options['wcf-submit-tb-padding'],
598
+ )
599
+ );
600
+
601
+ echo wcf()->meta->get_number_field(
602
+ array(
603
+ 'label' => __( 'Left Right Spacing', 'cartflows' ),
604
+ 'name' => 'wcf-submit-lr-padding',
605
+ 'value' => $options['wcf-submit-lr-padding'],
606
+ )
607
+ );
608
+
609
+ echo wcf()->meta->get_color_picker_field(
610
+ array(
611
+ 'label' => __( 'Text Color', 'cartflows' ),
612
+ 'name' => 'wcf-submit-color',
613
+ 'value' => $options['wcf-submit-color'],
614
+ )
615
+ );
616
+
617
+ echo wcf()->meta->get_color_picker_field(
618
+ array(
619
+ 'label' => __( 'Text Hover Color', 'cartflows' ),
620
+ 'name' => 'wcf-submit-hover-color',
621
+ 'value' => $options['wcf-submit-hover-color'],
622
+ )
623
+ );
624
+
625
+ echo wcf()->meta->get_color_picker_field(
626
+ array(
627
+ 'label' => __( 'Background Color', 'cartflows' ),
628
+ 'name' => 'wcf-submit-bg-color',
629
+ 'value' => $options['wcf-submit-bg-color'],
630
+ )
631
+ );
632
+
633
+ echo wcf()->meta->get_color_picker_field(
634
+ array(
635
+ 'label' => __( 'Background Hover Color', 'cartflows' ),
636
+ 'name' => 'wcf-submit-bg-hover-color',
637
+ 'value' => $options['wcf-submit-bg-hover-color'],
638
+ )
639
+ );
640
+
641
+ echo wcf()->meta->get_color_picker_field(
642
+ array(
643
+ 'label' => __( 'Border Color', 'cartflows' ),
644
+ 'name' => 'wcf-submit-border-color',
645
+ 'value' => $options['wcf-submit-border-color'],
646
+ )
647
+ );
648
+
649
+ echo wcf()->meta->get_color_picker_field(
650
+ array(
651
+ 'label' => __( 'Border Hover Color', 'cartflows' ),
652
+ 'name' => 'wcf-submit-border-hover-color',
653
+ 'value' => $options['wcf-submit-border-hover-color'],
654
+ )
655
+ );
656
+
657
+ ?>
658
+ </div>
659
+ <div class="wcf-cs-section-options">
660
+ <?php
661
+
662
+ echo wcf()->meta->get_section(
663
+ array(
664
+ 'label' => __( 'Sections', 'cartflows' ),
665
+ )
666
+ );
667
+
668
+ echo wcf()->meta->get_color_picker_field(
669
+ array(
670
+ 'label' => __( 'Highlight Area Background Color', 'cartflows' ),
671
+ 'name' => 'wcf-hl-bg-color',
672
+ 'value' => $options['wcf-hl-bg-color'],
673
+ )
674
+ );
675
+
676
+ echo wcf()->meta->get_hidden_field(
677
+ array(
678
+ 'name' => 'wcf-field-google-font-url',
679
+ 'value' => $options['wcf-field-google-font-url'],
680
+ )
681
+ );
682
+ ?>
683
+ </div>
684
+ <?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?>
685
+ </div>
686
+ </div>
687
+ <?php
688
+ }
689
+
690
+
691
+ /**
692
+ * Tab Header (Used for add logo into header)
693
+ *
694
+ * @param array $options options.
695
+ * @param int $post_id post ID.
696
+ */
697
+ function tab_header_content( $options, $post_id ) {
698
+ ?>
699
+
700
+ <div class="wcf-checkout-header wcf-tab-content widefat">
701
+ <?php
702
+
703
+ $layout_pro_option = array();
704
+
705
+ echo wcf()->meta->get_image_field(
706
+ array(
707
+ 'name' => 'wcf-header-logo-image',
708
+ 'value' => $options['wcf-header-logo-image'],
709
+ 'label' => __( 'Header Logo', 'cartflows' ),
710
+ )
711
+ );
712
+
713
+ echo wcf()->meta->get_number_field(
714
+ array(
715
+ 'name' => 'wcf-header-logo-width',
716
+ 'value' => $options['wcf-header-logo-width'],
717
+ 'label' => __( 'Logo Width (In px)', 'cartflows' ),
718
+ )
719
+ );
720
+ ?>
721
+ <?php do_action( 'cartflows_checkout_header_tab_content', $options, $post_id ); ?>
722
+ </div>
723
+ <?php
724
+ }
725
+ /**
726
+ * Get metabox options
727
+ *
728
+ * @param int $post_id post ID.
729
+ */
730
+ public static function get_meta_option( $post_id ) {
731
+
732
+ if ( null === self::$meta_option ) {
733
+
734
+ /**
735
+ * Set metabox options
736
+ *
737
+ * @see http://php.net/manual/en/filter.filters.sanitize.php
738
+ */
739
+ self::$meta_option = wcf()->options->get_checkout_fields( $post_id );
740
+ }
741
+
742
+ return self::$meta_option;
743
+ }
744
+
745
+ /**
746
+ * Metabox Save
747
+ *
748
+ * @param number $post_id Post ID.
749
+ * @return void
750
+ */
751
+ function save_meta_box( $post_id ) {
752
+
753
+ // Checks save status.
754
+ $is_autosave = wp_is_post_autosave( $post_id );
755
+ $is_revision = wp_is_post_revision( $post_id );
756
+
757
+ $is_valid_nonce = ( isset( $_POST['nonce-checkout-step-meta'] ) && wp_verify_nonce( $_POST['nonce-checkout-step-meta'], 'save-nonce-checkout-step-meta' ) ) ? true : false;
758
+
759
+ // Exits script depending on save status.
760
+ if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
761
+ return;
762
+ }
763
+
764
+ wcf()->options->save_checkout_fields( $post_id );
765
+ }
766
+
767
+ }
768
+
769
+ /**
770
+ * Kicking this off by calling 'get_instance()' method
771
+ */
772
+ Cartflows_Checkout_Meta::get_instance();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, cart
5
  Requires at least: 4.4
6
  Requires PHP: 5.6
7
  Tested up to: 5.1
8
- Stable tag: 1.1.14
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -93,6 +93,9 @@ Say goodby to using the same ridgid checkout page that everyone else is using. C
93
 
94
  == Changelog ==
95
 
 
 
 
96
  = Version 1.1.14 - Wednesday, 24th April 2019 =
97
  * Improvement: Minify CSS and Js files filter added.
98
  * Improvement: Inline coupon message. Now coupon message will show above coupon field.
5
  Requires at least: 4.4
6
  Requires PHP: 5.6
7
  Tested up to: 5.1
8
+ Stable tag: 1.1.15
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
93
 
94
  == Changelog ==
95
 
96
+ = Version 1.1.15 - Wednesday, 24th April 2019 =
97
+ * Fix: - WooCommerce dependency issue.
98
+
99
  = Version 1.1.14 - Wednesday, 24th April 2019 =
100
  * Improvement: Minify CSS and Js files filter added.
101
  * Improvement: Inline coupon message. Now coupon message will show above coupon field.
woocommerce/template/global/form-login.php CHANGED
@@ -1,67 +1,67 @@
1
- <?php
2
- /**
3
- * Login form
4
- *
5
- * This template can be overridden by copying it to yourtheme/woocommerce/global/form-login.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.6.0
16
- */
17
-
18
- if ( ! defined( 'ABSPATH' ) ) {
19
- exit; // Exit if accessed directly.
20
- }
21
-
22
- if ( is_user_logged_in() ) {
23
- return;
24
- }
25
-
26
- ?>
27
- <form class="woocommerce-form woocommerce-form-login login" method="post" <?php echo ( $hidden ) ? 'style="display:none;"' : ''; ?>>
28
-
29
- <?php do_action( 'woocommerce_login_form_start' ); ?>
30
-
31
- <?php echo ( $message ) ? wpautop( wptexturize( $message ) ) : ''; // @codingStandardsIgnoreLine ?>
32
-
33
- <p class="form-row form-row-first">
34
- <label for="username"><?php esc_html_e( 'Username or email', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
35
- <input type="text" class="input-text" name="username" id="username" autocomplete="username" />
36
- </p>
37
- <p class="form-row form-row-last">
38
- <label for="password"><?php esc_html_e( 'Password', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
39
- <input class="input-text" type="password" name="password" id="password" autocomplete="current-password" />
40
- </p>
41
- <div class="clear"></div>
42
-
43
- <?php do_action( 'woocommerce_login_form' ); ?>
44
-
45
- <p class="form-row">
46
- <?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?>
47
- <input type="hidden" name="redirect" value="<?php echo esc_url( $redirect ); ?>" />
48
- <button type="submit" class="woocommerce-button button woocommerce-form-login__submit" name="login" value="<?php esc_attr_e( 'Login', 'woocommerce' ); ?>"><?php esc_html_e( 'Login', 'woocommerce' ); ?></button>
49
- <span class="form-row login-form-actions">
50
- <span class="remember_me">
51
- <label class="woocommerce-form__label woocommerce-form__label-for-checkbox woocommerce-form-login__rememberme">
52
- <input class="woocommerce-form__input woocommerce-form__input-checkbox" name="rememberme" type="checkbox" id="rememberme" value="forever" />
53
- <span><?php esc_html_e( 'Remember me', 'woocommerce' ); ?></span>
54
- </label>
55
- </span>
56
- <span class="lost_password">
57
- <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'woocommerce' ); ?></a>
58
- </span>
59
- </span>
60
- </p>
61
-
62
-
63
- <div class="clear"></div>
64
-
65
- <?php do_action( 'woocommerce_login_form_end' ); ?>
66
-
67
- </form>
1
+ <?php
2
+ /**
3
+ * Login form
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woocommerce/global/form-login.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.6.0
16
+ */
17
+
18
+ if ( ! defined( 'ABSPATH' ) ) {
19
+ exit; // Exit if accessed directly.
20
+ }
21
+
22
+ if ( is_user_logged_in() ) {
23
+ return;
24
+ }
25
+
26
+ ?>
27
+ <form class="woocommerce-form woocommerce-form-login login" method="post" <?php echo ( $hidden ) ? 'style="display:none;"' : ''; ?>>
28
+
29
+ <?php do_action( 'woocommerce_login_form_start' ); ?>
30
+
31
+ <?php echo ( $message ) ? wpautop( wptexturize( $message ) ) : ''; // @codingStandardsIgnoreLine ?>
32
+
33
+ <p class="form-row form-row-first">
34
+ <label for="username"><?php esc_html_e( 'Username or email', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
35
+ <input type="text" class="input-text" name="username" id="username" autocomplete="username" />
36
+ </p>
37
+ <p class="form-row form-row-last">
38
+ <label for="password"><?php esc_html_e( 'Password', 'woocommerce' ); ?>&nbsp;<span class="required">*</span></label>
39
+ <input class="input-text" type="password" name="password" id="password" autocomplete="current-password" />
40
+ </p>
41
+ <div class="clear"></div>
42
+
43
+ <?php do_action( 'woocommerce_login_form' ); ?>
44
+
45
+ <p class="form-row">
46
+ <?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?>
47
+ <input type="hidden" name="redirect" value="<?php echo esc_url( $redirect ); ?>" />
48
+ <button type="submit" class="woocommerce-button button woocommerce-form-login__submit" name="login" value="<?php esc_attr_e( 'Login', 'woocommerce' ); ?>"><?php esc_html_e( 'Login', 'woocommerce' ); ?></button>
49
+ <span class="form-row login-form-actions">
50
+ <span class="remember_me">
51
+ <label class="woocommerce-form__label woocommerce-form__label-for-checkbox woocommerce-form-login__rememberme">
52
+ <input class="woocommerce-form__input woocommerce-form__input-checkbox" name="rememberme" type="checkbox" id="rememberme" value="forever" />
53
+ <span><?php esc_html_e( 'Remember me', 'woocommerce' ); ?></span>
54
+ </label>
55
+ </span>
56
+ <span class="lost_password">
57
+ <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_html_e( 'Lost your password?', 'woocommerce' ); ?></a>
58
+ </span>
59
+ </span>
60
+ </p>
61
+
62
+
63
+ <div class="clear"></div>
64
+
65
+ <?php do_action( 'woocommerce_login_form_end' ); ?>
66
+
67
+ </form>