Version Description
Download this release
Release Info
Developer | sandesh055 |
Plugin | Funnel Builder by CartFlows – Create High Converting Sales Funnels For WordPress |
Version | 1.1.7.1 |
Comparing to | |
See all releases |
Code changes from version 1.1.6 to 1.1.7.1
- assets/js/import.js +1 -1
- cartflows.php +1 -1
- changelog.txt +4 -0
- classes/batch-process/class-cartflows-batch-process.php +268 -244
- classes/batch-process/class-cartflows-importer-divi-batch-reset-data.php +59 -0
- classes/batch-process/class-cartflows-importer-divi-batch.php +63 -0
- classes/batch-process/class-cartflows-importer-divi.php +233 -0
- classes/batch-process/helpers/class-cartflows-importer-image.php +17 -17
- classes/class-cartflows-admin.php +437 -437
- classes/class-cartflows-api.php +386 -376
- classes/class-cartflows-compatibility.php +14 -0
- classes/class-cartflows-default-meta.php +0 -1
- classes/class-cartflows-frontend.php +402 -402
- classes/class-cartflows-functions.php +388 -388
- classes/class-cartflows-helper.php +458 -432
- classes/class-cartflows-importer-core.php +272 -269
- classes/class-cartflows-importer.php +1564 -1432
- classes/class-cartflows-loader.php +1 -1
- classes/class-cartflows-meta-fields.php +1482 -1482
- classes/class-cartflows-thrive-compatibility.php +77 -77
- includes/admin/cartflows-general.php +143 -142
- languages/cartflows.pot +1357 -1346
- modules/checkout/classes/class-cartflows-checkout-markup.php +1109 -1109
- modules/checkout/classes/class-cartflows-checkout-meta.php +759 -759
- modules/flow/classes/class-cartflows-step-post-type.php +465 -465
- readme.txt +8 -1
- woocommerce/template/cart/cart-shipping.php +79 -79
- woocommerce/template/checkout/form-billing.php +80 -80
- woocommerce/template/checkout/form-checkout.php +64 -64
- woocommerce/template/checkout/form-coupon.php +42 -42
- woocommerce/template/checkout/form-login.php +36 -36
- woocommerce/template/checkout/review-order.php +113 -113
- woocommerce/template/checkout/thankyou.php +87 -87
- woocommerce/template/notices/error.php +35 -35
- woocommerce/template/notices/notice.php +34 -34
- woocommerce/template/notices/success.php +34 -34
assets/js/import.js
CHANGED
@@ -625,7 +625,7 @@ var CartFlowsAjaxQueue = (function() {
|
|
625 |
CartFlowsImport._cache_remote_flows();
|
626 |
} else {
|
627 |
var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
|
628 |
-
|
629 |
var anyInactive = true;
|
630 |
|
631 |
$.each( page_builder_plugins, function( index, plugin ) {
|
625 |
CartFlowsImport._cache_remote_flows();
|
626 |
} else {
|
627 |
var page_builder_plugins = CartFlowsImportVars.required_plugins[ CartFlowsImportVars.default_page_builder ]['plugins'];
|
628 |
+
|
629 |
var anyInactive = true;
|
630 |
|
631 |
$.each( page_builder_plugins, function( index, plugin ) {
|
cartflows.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: CartFlows
|
4 |
* Plugin URI: https://cartflows.com/
|
5 |
* Description: Create beautiful checkout pages & sales flows for WooCommerce.
|
6 |
-
* Version: 1.1.
|
7 |
* Author: CartFlows Inc
|
8 |
* Author URI: https://cartflows.com/
|
9 |
* Text Domain: cartflows
|
3 |
* Plugin Name: CartFlows
|
4 |
* Plugin URI: https://cartflows.com/
|
5 |
* Description: Create beautiful checkout pages & sales flows for WooCommerce.
|
6 |
+
* Version: 1.1.7.1
|
7 |
* Author: CartFlows Inc
|
8 |
* Author URI: https://cartflows.com/
|
9 |
* Text Domain: cartflows
|
changelog.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
Version 1.1.6 - Thursday, 07th February 2019
|
2 |
- Improvement: Added compatibility for a future release of CartFlows Pro's checkout field editor.
|
3 |
- Fix: Permalink conflict with listing theme.
|
1 |
+
Version 1.1.7 - Monday, 25th February 2019
|
2 |
+
- New: DIVI templates.
|
3 |
+
- Fix: Shipping fields label issue.
|
4 |
+
|
5 |
Version 1.1.6 - Thursday, 07th February 2019
|
6 |
- Improvement: Added compatibility for a future release of CartFlows Pro's checkout field editor.
|
7 |
- Fix: Permalink conflict with listing theme.
|
classes/batch-process/class-cartflows-batch-process.php
CHANGED
@@ -1,244 +1,268 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Batch Processing
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows_Batch_Process
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class CartFlows_Batch_Process {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @since 1.0.0
|
22 |
-
* @var object Class object.
|
23 |
-
* @access private
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Elementor Batch Instance
|
29 |
-
*
|
30 |
-
* @since 1.1.1 Updated instance name with elementor specific.
|
31 |
-
*
|
32 |
-
* @since 1.0.0
|
33 |
-
* @var object Class object.
|
34 |
-
* @access public
|
35 |
-
*/
|
36 |
-
public static $batch_instance_elementor;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Beaver Builder Batch Instance
|
40 |
-
*
|
41 |
-
* @since 1.1.1
|
42 |
-
* @var object Class object.
|
43 |
-
* @access public
|
44 |
-
*/
|
45 |
-
public static $batch_instance_bb;
|
46 |
-
|
47 |
-
/**
|
48 |
-
*
|
49 |
-
*
|
50 |
-
* @since 1.
|
51 |
-
* @
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
//
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
*
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
)
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
wcf()->logger->import_log( '(✓)
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Batch Processing
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows_Batch_Process
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class CartFlows_Batch_Process {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @var object Class object.
|
23 |
+
* @access private
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Elementor Batch Instance
|
29 |
+
*
|
30 |
+
* @since 1.1.1 Updated instance name with elementor specific.
|
31 |
+
*
|
32 |
+
* @since 1.0.0
|
33 |
+
* @var object Class object.
|
34 |
+
* @access public
|
35 |
+
*/
|
36 |
+
public static $batch_instance_elementor;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Beaver Builder Batch Instance
|
40 |
+
*
|
41 |
+
* @since 1.1.1
|
42 |
+
* @var object Class object.
|
43 |
+
* @access public
|
44 |
+
*/
|
45 |
+
public static $batch_instance_bb;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Divi Batch Instance
|
49 |
+
*
|
50 |
+
* @since 1.1.1
|
51 |
+
* @var object Class object.
|
52 |
+
* @access public
|
53 |
+
*/
|
54 |
+
public static $batch_instance_divi;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Initiator
|
58 |
+
*
|
59 |
+
* @since 1.0.0
|
60 |
+
* @return object initialized object of class.
|
61 |
+
*/
|
62 |
+
public static function get_instance() {
|
63 |
+
if ( ! isset( self::$instance ) ) {
|
64 |
+
self::$instance = new self;
|
65 |
+
}
|
66 |
+
return self::$instance;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Constructor
|
71 |
+
*
|
72 |
+
* @since 1.0.0
|
73 |
+
*/
|
74 |
+
public function __construct() {
|
75 |
+
|
76 |
+
// Not BB or Elementor then avoid importer.
|
77 |
+
// if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
|
78 |
+
// return;
|
79 |
+
// }
|
80 |
+
// Core Helpers - Image.
|
81 |
+
require_once ABSPATH . 'wp-admin/includes/image.php';
|
82 |
+
|
83 |
+
// Core Helpers - Batch Processing.
|
84 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-cartflows-importer-image.php';
|
85 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
|
86 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';
|
87 |
+
|
88 |
+
// Elementor.
|
89 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
90 |
+
// Add "elementor" in import [queue].
|
91 |
+
// @todo Remove required `allow_url_fopen` support.
|
92 |
+
if ( ini_get( 'allow_url_fopen' ) ) {
|
93 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
|
94 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor-batch.php';
|
95 |
+
self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
// Beaver Builder.
|
100 |
+
if ( class_exists( 'FLBuilder' ) ) {
|
101 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder.php';
|
102 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder-batch.php';
|
103 |
+
self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
|
104 |
+
}
|
105 |
+
|
106 |
+
// Divi.
|
107 |
+
if ( class_exists( 'ET_Builder_Plugin' ) || Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
|
108 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi.php';
|
109 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi-batch.php';
|
110 |
+
self::$batch_instance_divi = new Cartflows_Importer_Divi_Batch();
|
111 |
+
}
|
112 |
+
|
113 |
+
// Start image importing after site import complete.
|
114 |
+
add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
|
115 |
+
add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
|
116 |
+
add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
|
117 |
+
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Added .svg files as supported format in the uploader.
|
122 |
+
*
|
123 |
+
* @since 1.1.4
|
124 |
+
*
|
125 |
+
* @param array $mimes Already supported mime types.
|
126 |
+
*/
|
127 |
+
public function custom_upload_mimes( $mimes ) {
|
128 |
+
|
129 |
+
// Allow SVG files.
|
130 |
+
$mimes['svg'] = 'image/svg+xml';
|
131 |
+
$mimes['svgz'] = 'image/svg+xml';
|
132 |
+
|
133 |
+
// Allow XML files.
|
134 |
+
$mimes['xml'] = 'text/xml';
|
135 |
+
|
136 |
+
return $mimes;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Add SVG image support
|
141 |
+
*
|
142 |
+
* @since 1.1.4
|
143 |
+
*
|
144 |
+
* @param array $response Attachment response.
|
145 |
+
* @param object $attachment Attachment object.
|
146 |
+
* @param array $meta Attachment meta data.
|
147 |
+
*/
|
148 |
+
function add_svg_image_support( $response, $attachment, $meta ) {
|
149 |
+
if ( ! function_exists( 'simplexml_load_file' ) ) {
|
150 |
+
return $response;
|
151 |
+
}
|
152 |
+
|
153 |
+
if ( ! empty( $response['sizes'] ) ) {
|
154 |
+
return $response;
|
155 |
+
}
|
156 |
+
|
157 |
+
if ( 'image/svg+xml' !== $response['mime'] ) {
|
158 |
+
return $response;
|
159 |
+
}
|
160 |
+
|
161 |
+
$svg_path = get_attached_file( $attachment->ID );
|
162 |
+
|
163 |
+
$dimensions = self::get_svg_dimensions( $svg_path );
|
164 |
+
|
165 |
+
$response['sizes'] = array(
|
166 |
+
'full' => array(
|
167 |
+
'url' => $response['url'],
|
168 |
+
'width' => $dimensions->width,
|
169 |
+
'height' => $dimensions->height,
|
170 |
+
'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
|
171 |
+
),
|
172 |
+
);
|
173 |
+
|
174 |
+
return $response;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Get SVG Dimensions
|
179 |
+
*
|
180 |
+
* @since 1.1.4.
|
181 |
+
*
|
182 |
+
* @param string $svg SVG file path.
|
183 |
+
* @return array Return SVG file height & width for valid SVG file.
|
184 |
+
*/
|
185 |
+
public static function get_svg_dimensions( $svg ) {
|
186 |
+
|
187 |
+
$svg = simplexml_load_file( $svg );
|
188 |
+
|
189 |
+
if ( false === $svg ) {
|
190 |
+
$width = '0';
|
191 |
+
$height = '0';
|
192 |
+
} else {
|
193 |
+
$attributes = $svg->attributes();
|
194 |
+
$width = (string) $attributes->width;
|
195 |
+
$height = (string) $attributes->height;
|
196 |
+
}
|
197 |
+
|
198 |
+
return (object) array(
|
199 |
+
'width' => $width,
|
200 |
+
'height' => $height,
|
201 |
+
);
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Batch Process Complete.
|
206 |
+
*
|
207 |
+
* @return void
|
208 |
+
*/
|
209 |
+
public function complete_batch_import() {
|
210 |
+
wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Start Image Import
|
215 |
+
*
|
216 |
+
* @param integer $post_id Post Id.
|
217 |
+
*
|
218 |
+
* @return void
|
219 |
+
*/
|
220 |
+
public function start_batch_process( $post_id = '' ) {
|
221 |
+
|
222 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
223 |
+
|
224 |
+
wcf()->logger->import_log( '(✓) BATCH Started!' );
|
225 |
+
wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
|
226 |
+
|
227 |
+
// Add "elementor" in import [queue].
|
228 |
+
if ( 'beaver-builder' === $default_page_builder && self::$batch_instance_bb ) {
|
229 |
+
|
230 |
+
// Add to queue.
|
231 |
+
self::$batch_instance_bb->push_to_queue( $post_id );
|
232 |
+
|
233 |
+
// Dispatch Queue.
|
234 |
+
self::$batch_instance_bb->save()->dispatch();
|
235 |
+
|
236 |
+
wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
|
237 |
+
|
238 |
+
} elseif ( 'elementor' === $default_page_builder && self::$batch_instance_elementor ) {
|
239 |
+
|
240 |
+
// Add to queue.
|
241 |
+
self::$batch_instance_elementor->push_to_queue( $post_id );
|
242 |
+
|
243 |
+
// Dispatch Queue.
|
244 |
+
self::$batch_instance_elementor->save()->dispatch();
|
245 |
+
|
246 |
+
wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
|
247 |
+
} elseif ( 'divi' === $default_page_builder && self::$batch_instance_divi ) {
|
248 |
+
|
249 |
+
// Add to queue.
|
250 |
+
self::$batch_instance_divi->push_to_queue( $post_id );
|
251 |
+
|
252 |
+
// Dispatch Queue.
|
253 |
+
self::$batch_instance_divi->save()->dispatch();
|
254 |
+
|
255 |
+
wcf()->logger->import_log( '(✓) Dispatch "Divi" Request..' );
|
256 |
+
} else {
|
257 |
+
wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Kicking this off by calling 'get_instance()' method
|
265 |
+
*/
|
266 |
+
CartFlows_Batch_Process::get_instance();
|
267 |
+
|
268 |
+
endif;
|
classes/batch-process/class-cartflows-importer-divi-batch-reset-data.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Divi Batch Process
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.1.1
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'Cartflows_Importer_Divi_Batch_Reset_Data' ) && class_exists( 'WP_Background_Process' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Image Background Process
|
13 |
+
*
|
14 |
+
* @since 1.1.1
|
15 |
+
*/
|
16 |
+
class Cartflows_Importer_Divi_Batch_Reset_Data extends WP_Background_Process {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Image Process
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $action = 'cartflows_divi_image_process_reset_data';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Task
|
27 |
+
*
|
28 |
+
* Override this method to perform any actions required on each
|
29 |
+
* queue item. Return the modified item for further processing
|
30 |
+
* in the next pass through. Or, return false to remove the
|
31 |
+
* item from the queue.
|
32 |
+
*
|
33 |
+
* @since 1.1.1
|
34 |
+
*
|
35 |
+
* @param integer $post_id Post Id.
|
36 |
+
* @return mixed
|
37 |
+
*/
|
38 |
+
protected function task( $post_id ) {
|
39 |
+
|
40 |
+
CartFlows_Importer_Divi::get_instance()->reset_data( $post_id );
|
41 |
+
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Complete
|
47 |
+
*
|
48 |
+
* Override if applicable, but ensure that the below actions are
|
49 |
+
* performed, or, call parent::complete().
|
50 |
+
*
|
51 |
+
* @since 1.1.1
|
52 |
+
*/
|
53 |
+
protected function complete() {
|
54 |
+
parent::complete();
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
endif;
|
classes/batch-process/class-cartflows-importer-divi-batch.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Divi Batch Process
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.1.1
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'Cartflows_Importer_Divi_Batch' ) && class_exists( 'WP_Background_Process' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Image Background Process
|
13 |
+
*
|
14 |
+
* @since 1.1.1
|
15 |
+
*/
|
16 |
+
class Cartflows_Importer_Divi_Batch extends WP_Background_Process {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Image Process
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $action = 'cartflows_divi_image_process';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Task
|
27 |
+
*
|
28 |
+
* Override this method to perform any actions required on each
|
29 |
+
* queue item. Return the modified item for further processing
|
30 |
+
* in the next pass through. Or, return false to remove the
|
31 |
+
* item from the queue.
|
32 |
+
*
|
33 |
+
* @since 1.1.1
|
34 |
+
*
|
35 |
+
* @param integer $post_id Post Id.
|
36 |
+
* @return mixed
|
37 |
+
*/
|
38 |
+
protected function task( $post_id ) {
|
39 |
+
|
40 |
+
CartFlows_Importer_Divi::get_instance()->import_single_post( $post_id );
|
41 |
+
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Complete
|
47 |
+
*
|
48 |
+
* Override if applicable, but ensure that the below actions are
|
49 |
+
* performed, or, call parent::complete().
|
50 |
+
*
|
51 |
+
* @since 1.1.1
|
52 |
+
*/
|
53 |
+
protected function complete() {
|
54 |
+
|
55 |
+
parent::complete();
|
56 |
+
|
57 |
+
do_action( 'cartflows_import_complete' );
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
endif;
|
classes/batch-process/class-cartflows-importer-divi.php
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Instance
|
29 |
+
*
|
30 |
+
* @since 1.1.1
|
31 |
+
* @access private
|
32 |
+
* @var object Class object.
|
33 |
+
*/
|
34 |
+
private $batch_instance_divi_reset_data;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Initiator
|
38 |
+
*
|
39 |
+
* @since 1.1.1
|
40 |
+
* @return object initialized object of class.
|
41 |
+
*/
|
42 |
+
public static function get_instance() {
|
43 |
+
|
44 |
+
if ( ! isset( self::$instance ) ) {
|
45 |
+
self::$instance = new self;
|
46 |
+
}
|
47 |
+
return self::$instance;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Constructor
|
52 |
+
*
|
53 |
+
* @since 1.1.1
|
54 |
+
*/
|
55 |
+
public function __construct() {
|
56 |
+
|
57 |
+
add_action( 'admin_head', array( $this, 'all_re_process_data' ) );
|
58 |
+
|
59 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi-batch-reset-data.php';
|
60 |
+
|
61 |
+
$this->batch_instance_divi_reset_data = new Cartflows_Importer_Divi_Batch_Reset_Data();
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Rest Data.
|
66 |
+
*
|
67 |
+
* @param integer $post_id Post ID.
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
function reset_data( $post_id ) {
|
71 |
+
|
72 |
+
// wcf()->logger->import_log( ' Reprocessing step - ' . $post_id );.
|
73 |
+
// $content = get_post_meta( $post_id, 'divi_content', true );.
|
74 |
+
// wcf()->logger->import_log( 'Unprocessed' );.
|
75 |
+
// wcf()->logger->import_log( $content );.
|
76 |
+
$content = get_post_meta( $post_id, 'divi_content_processed', true );
|
77 |
+
|
78 |
+
if ( ! empty( $content ) ) {
|
79 |
+
// wcf()->logger->import_log( 'Processed' );.
|
80 |
+
// wcf()->logger->import_log( $content );.
|
81 |
+
$content = CartFlows_Importer::get_instance()->get_content( $content );
|
82 |
+
// wcf()->logger->import_log( 'After' );.
|
83 |
+
// wcf()->logger->import_log( $content );.
|
84 |
+
// Update post content.
|
85 |
+
wp_update_post(
|
86 |
+
array(
|
87 |
+
'ID' => $post_id,
|
88 |
+
'post_content' => $content,
|
89 |
+
)
|
90 |
+
);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Re process data for flow and step.
|
96 |
+
*/
|
97 |
+
function all_re_process_data() {
|
98 |
+
$this->re_process_data();
|
99 |
+
$this->re_process_data_step();
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Re process data.
|
104 |
+
*/
|
105 |
+
function re_process_data() {
|
106 |
+
|
107 |
+
wcf()->logger->import_log( ' Without batch started.. ' );
|
108 |
+
|
109 |
+
if ( CARTFLOWS_FLOW_POST_TYPE !== get_post_type() ) {
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
$post_id = get_the_ID();
|
114 |
+
|
115 |
+
// wcf()->logger->import_log( ' Reprocessing Divi Data.. ' . $post_id );.
|
116 |
+
$processed = get_post_meta( $post_id, 'wcf_divi_data_processed', true );
|
117 |
+
|
118 |
+
if ( ! $processed ) {
|
119 |
+
|
120 |
+
$steps = get_post_meta( $post_id, 'wcf-steps', true );
|
121 |
+
foreach ( $steps as $key => $step ) {
|
122 |
+
|
123 |
+
$this->reset_data( $step['id'] );
|
124 |
+
|
125 |
+
wcf()->logger->import_log( ' Processing without batch.. ' . $step['id'] );
|
126 |
+
// Add to queue.
|
127 |
+
// $this->batch_instance_divi_reset_data->push_to_queue( $step['id'] );.
|
128 |
+
}
|
129 |
+
|
130 |
+
update_post_meta( $post_id, 'wcf_divi_data_processed', true );
|
131 |
+
} else {
|
132 |
+
wcf()->logger->import_log( ' Already processed.. ' );
|
133 |
+
}
|
134 |
+
|
135 |
+
wcf()->logger->import_log( ' Without batch end.. ' );
|
136 |
+
|
137 |
+
// // Dispatch Queue.
|
138 |
+
// $this->batch_instance_divi_reset_data->save()->dispatch();
|
139 |
+
// wcf()->logger->import_log( '(✓) "Divi Reset Data" Request..' );
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Re process data for step.
|
144 |
+
*/
|
145 |
+
function re_process_data_step() {
|
146 |
+
|
147 |
+
wcf()->logger->import_log( ' Without batch started.. ' );
|
148 |
+
|
149 |
+
if ( CARTFLOWS_FLOW_POST_TYPE !== get_post_type() ) {
|
150 |
+
return;
|
151 |
+
}
|
152 |
+
|
153 |
+
if ( ! isset( $_GET['highlight-step-id'] ) ) {
|
154 |
+
return;
|
155 |
+
}
|
156 |
+
|
157 |
+
$post_id = intval( $_GET['highlight-step-id'] );
|
158 |
+
|
159 |
+
// wcf()->logger->import_log( ' Reprocessing Divi Data.. ' . $post_id );.
|
160 |
+
$processed = get_post_meta( $post_id, 'wcf_divi_data_processed', true );
|
161 |
+
|
162 |
+
if ( ! $processed ) {
|
163 |
+
|
164 |
+
$this->reset_data( $post_id );
|
165 |
+
|
166 |
+
wcf()->logger->import_log( ' Processing without batch.. ' . $post_id );
|
167 |
+
|
168 |
+
update_post_meta( $post_id, 'wcf_divi_data_processed', true );
|
169 |
+
} else {
|
170 |
+
wcf()->logger->import_log( ' Already processed.. ' );
|
171 |
+
}
|
172 |
+
|
173 |
+
wcf()->logger->import_log( ' Without batch end.. ' );
|
174 |
+
|
175 |
+
// // Dispatch Queue.
|
176 |
+
// $this->batch_instance_divi_reset_data->save()->dispatch();
|
177 |
+
// wcf()->logger->import_log( '(✓) "Divi Reset Data" Request..' );
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Update post meta.
|
182 |
+
*
|
183 |
+
* @param integer $post_id Post ID.
|
184 |
+
* @return void
|
185 |
+
*/
|
186 |
+
public function import_single_post( $post_id = 0 ) {
|
187 |
+
|
188 |
+
// Download and replace images.
|
189 |
+
$content = get_post_meta( $post_id, 'divi_content', true );
|
190 |
+
|
191 |
+
if ( empty( $content ) ) {
|
192 |
+
wcf()->logger->import_log( '(✕) Not have "Divi" Data. Post content is empty!' );
|
193 |
+
} else {
|
194 |
+
|
195 |
+
wcf()->logger->import_log( '(✓) Processing Request..' );
|
196 |
+
|
197 |
+
wcf()->logger->import_log( '------------------------ BEFORE ------------------------' );
|
198 |
+
wcf()->logger->import_log( $content );
|
199 |
+
// $content = wp_slash( base64_decode( $content ) );
|
200 |
+
// wcf()->logger->import_log( '------------------------ AFTER ------------------------' );
|
201 |
+
// wcf()->logger->import_log( $content );
|
202 |
+
// wcf()->logger->import_log( 'Step link - http://localhost/m.sharkz.in/?p=' . $post_id );
|
203 |
+
// Update hotlink images.
|
204 |
+
$content = CartFlows_Importer::get_instance()->get_content( $content );
|
205 |
+
|
206 |
+
// Backup.
|
207 |
+
update_post_meta( $post_id, 'divi_content_processed', $content );
|
208 |
+
|
209 |
+
// $content = get_post_meta( $post_id, 'divi_content_processed', true );
|
210 |
+
// Update post content.
|
211 |
+
wp_update_post(
|
212 |
+
array(
|
213 |
+
'ID' => $post_id,
|
214 |
+
'post_content' => $content,
|
215 |
+
)
|
216 |
+
);
|
217 |
+
|
218 |
+
do_action( 'wcf_divi_single_post_process_complete', $post_id );
|
219 |
+
|
220 |
+
// Delete temporary meta key.
|
221 |
+
// delete_post_meta( $post_id, 'divi_content' );.
|
222 |
+
wcf()->logger->import_log( '(✓) Process Complete' );
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Initialize class object with 'get_instance()' method
|
230 |
+
*/
|
231 |
+
CartFlows_Importer_Divi::get_instance();
|
232 |
+
|
233 |
+
endif;
|
classes/batch-process/helpers/class-cartflows-importer-image.php
CHANGED
@@ -107,6 +107,8 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
|
|
107 |
*/
|
108 |
private function get_saved_image( $attachment ) {
|
109 |
|
|
|
|
|
110 |
if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) {
|
111 |
|
112 |
wcf()->logger->import_log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
@@ -116,7 +118,6 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
|
|
116 |
|
117 |
global $wpdb;
|
118 |
|
119 |
-
|
120 |
// Already imported? Then return!
|
121 |
if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
|
122 |
|
@@ -128,10 +129,11 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
|
|
128 |
// 1. Is already imported in Batch Import Process?
|
129 |
$post_id = $wpdb->get_var(
|
130 |
$wpdb->prepare(
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
135 |
$this->get_hash_image( $attachment['url'] )
|
136 |
)
|
137 |
);
|
@@ -141,17 +143,15 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
|
|
141 |
|
142 |
// Get file name without extension.
|
143 |
// To check it exist in attachment.
|
144 |
-
$filename =
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
)
|
154 |
-
);
|
155 |
|
156 |
wcf()->logger->import_log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
|
157 |
}
|
@@ -184,7 +184,7 @@ if ( ! class_exists( 'CartFlows_Import_Image' ) ) :
|
|
184 |
return $saved_image;
|
185 |
}
|
186 |
|
187 |
-
$file_content = wp_remote_retrieve_body( wp_safe_remote_get( $attachment['url'] ) );
|
188 |
|
189 |
// Empty file content?
|
190 |
if ( empty( $file_content ) ) {
|
107 |
*/
|
108 |
private function get_saved_image( $attachment ) {
|
109 |
|
110 |
+
wcf()->logger->import_log( 'importer-image.php File' );
|
111 |
+
|
112 |
if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) {
|
113 |
|
114 |
wcf()->logger->import_log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
118 |
|
119 |
global $wpdb;
|
120 |
|
|
|
121 |
// Already imported? Then return!
|
122 |
if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
|
123 |
|
129 |
// 1. Is already imported in Batch Import Process?
|
130 |
$post_id = $wpdb->get_var(
|
131 |
$wpdb->prepare(
|
132 |
+
"
|
133 |
+
SELECT post_id FROM {$wpdb->postmeta}
|
134 |
+
WHERE meta_key = '_cartflows_image_hash'
|
135 |
+
AND meta_value = %s
|
136 |
+
",
|
137 |
$this->get_hash_image( $attachment['url'] )
|
138 |
)
|
139 |
);
|
143 |
|
144 |
// Get file name without extension.
|
145 |
// To check it exist in attachment.
|
146 |
+
$filename = basename( $attachment['url'] );
|
147 |
+
|
148 |
+
wcf()->logger->import_log( 'File Basename - ' . $filename );
|
149 |
+
|
150 |
+
$post_id = $wpdb->get_var( $wpdb->prepare( "
|
151 |
+
SELECT post_id FROM {$wpdb->postmeta}
|
152 |
+
WHERE meta_key = '_wp_attached_file'
|
153 |
+
AND meta_value LIKE %s
|
154 |
+
", '%/' . $filename . '%' ) );
|
|
|
|
|
155 |
|
156 |
wcf()->logger->import_log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
|
157 |
}
|
184 |
return $saved_image;
|
185 |
}
|
186 |
|
187 |
+
$file_content = wp_remote_retrieve_body( wp_safe_remote_get( $attachment['url'], array( 'timeout' => '60', 'sslverify' => false) ) );
|
188 |
|
189 |
// Empty file content?
|
190 |
if ( empty( $file_content ) ) {
|
classes/class-cartflows-admin.php
CHANGED
@@ -1,437 +1,437 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Admin.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Cartflows_Admin.
|
10 |
-
*/
|
11 |
-
class Cartflows_Admin {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Calls on initialization
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
*/
|
18 |
-
public static function init() {
|
19 |
-
|
20 |
-
self::initialise_plugin();
|
21 |
-
self::init_hooks();
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Init Hooks.
|
26 |
-
*
|
27 |
-
* @since 1.0.0
|
28 |
-
* @return void
|
29 |
-
*/
|
30 |
-
static public function init_hooks() {
|
31 |
-
|
32 |
-
if ( ! is_admin() ) {
|
33 |
-
return;
|
34 |
-
}
|
35 |
-
|
36 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
|
37 |
-
|
38 |
-
// Add CARTFLOWS menu option to admin.
|
39 |
-
add_action( 'network_admin_menu', __CLASS__ . '::menu' );
|
40 |
-
add_action( 'admin_menu', __CLASS__ . '::menu' );
|
41 |
-
add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
|
42 |
-
|
43 |
-
add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
|
44 |
-
|
45 |
-
// Enqueue admin scripts.
|
46 |
-
if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
|
47 |
-
|
48 |
-
add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
|
49 |
-
|
50 |
-
self::save_settings();
|
51 |
-
}
|
52 |
-
|
53 |
-
/* Global Addmin Script */
|
54 |
-
add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
|
55 |
-
|
56 |
-
add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
|
57 |
-
|
58 |
-
/* Add lite version class to body */
|
59 |
-
add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Initialises the Plugin Name.
|
64 |
-
*
|
65 |
-
* @since 1.0.0
|
66 |
-
* @return void
|
67 |
-
*/
|
68 |
-
static public function initialise_plugin() {
|
69 |
-
|
70 |
-
$name = 'Cartflows';
|
71 |
-
$short_name = 'Cflows';
|
72 |
-
|
73 |
-
define( 'CARTFLOWS_PLUGIN_NAME', $name );
|
74 |
-
define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Renders the admin settings menu.
|
79 |
-
*
|
80 |
-
* @since 1.0.0
|
81 |
-
* @return void
|
82 |
-
*/
|
83 |
-
static public function menu() {
|
84 |
-
|
85 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
86 |
-
return;
|
87 |
-
}
|
88 |
-
|
89 |
-
add_menu_page(
|
90 |
-
'CartFlows',
|
91 |
-
'CartFlows',
|
92 |
-
'manage_options',
|
93 |
-
CARTFLOWS_SLUG,
|
94 |
-
__CLASS__ . '::render',
|
95 |
-
'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
|
96 |
-
39.7
|
97 |
-
);
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Add submenu to admin menu.
|
103 |
-
*
|
104 |
-
* @since 1.0.0
|
105 |
-
*/
|
106 |
-
static function submenu() {
|
107 |
-
|
108 |
-
$parent_slug = CARTFLOWS_SLUG;
|
109 |
-
$page_title = __( 'Settings', 'cartflows' );
|
110 |
-
$menu_title = __( 'Settings', 'cartflows' );
|
111 |
-
$capability = 'manage_options';
|
112 |
-
$menu_slug = 'cartflows_settings';
|
113 |
-
$callback = __CLASS__ . '::render';
|
114 |
-
|
115 |
-
add_submenu_page(
|
116 |
-
$parent_slug,
|
117 |
-
$page_title,
|
118 |
-
$menu_title,
|
119 |
-
$capability,
|
120 |
-
$menu_slug,
|
121 |
-
$callback
|
122 |
-
);
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Renders the admin settings.
|
127 |
-
*
|
128 |
-
* @since 1.0.0
|
129 |
-
* @return void
|
130 |
-
*/
|
131 |
-
static public function render() {
|
132 |
-
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
133 |
-
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
134 |
-
$action = str_replace( '_', '-', $action );
|
135 |
-
|
136 |
-
// Enable header icon filter below.
|
137 |
-
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
138 |
-
|
139 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Renders the admin settings content.
|
144 |
-
*
|
145 |
-
* @since 1.0.0
|
146 |
-
* @return void
|
147 |
-
*/
|
148 |
-
static public function render_content() {
|
149 |
-
|
150 |
-
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
151 |
-
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
152 |
-
$action = str_replace( '_', '-', $action );
|
153 |
-
$action = 'general';
|
154 |
-
|
155 |
-
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
156 |
-
|
157 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Save Global Setting options.
|
162 |
-
*
|
163 |
-
* @since 1.0.0
|
164 |
-
*/
|
165 |
-
static public function save_common_settings() {
|
166 |
-
|
167 |
-
if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
|
168 |
-
|
169 |
-
$url = $_SERVER['REQUEST_URI'];
|
170 |
-
$input_settings = array();
|
171 |
-
$new_settings = array();
|
172 |
-
|
173 |
-
if ( isset( $_POST['_cartflows_common'] ) ) {
|
174 |
-
|
175 |
-
$input_settings = $_POST['_cartflows_common'];
|
176 |
-
|
177 |
-
// Loop through the input and sanitize each of the values.
|
178 |
-
foreach ( $input_settings as $key => $val ) {
|
179 |
-
|
180 |
-
if ( is_array( $val ) ) {
|
181 |
-
foreach ( $val as $k => $v ) {
|
182 |
-
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
|
183 |
-
}
|
184 |
-
} else {
|
185 |
-
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
186 |
-
}
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
|
191 |
-
|
192 |
-
$query = array(
|
193 |
-
'message' => 'saved',
|
194 |
-
);
|
195 |
-
|
196 |
-
$redirect_to = add_query_arg( $query, $url );
|
197 |
-
|
198 |
-
wp_redirect( $redirect_to );
|
199 |
-
exit;
|
200 |
-
} // End if statement.
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Check is cartflows admin.
|
205 |
-
*
|
206 |
-
* @since 1.0.0
|
207 |
-
* @return boolean
|
208 |
-
*/
|
209 |
-
static public function is_global_admin() {
|
210 |
-
|
211 |
-
$current_screen = get_current_screen();
|
212 |
-
|
213 |
-
if (
|
214 |
-
is_object( $current_screen ) &&
|
215 |
-
isset( $current_screen->post_type ) &&
|
216 |
-
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
|
217 |
-
CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
|
218 |
-
)
|
219 |
-
) {
|
220 |
-
return true;
|
221 |
-
}
|
222 |
-
return false;
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Check is flow admin.
|
227 |
-
*
|
228 |
-
* @since 1.0.0
|
229 |
-
* @return boolean
|
230 |
-
*/
|
231 |
-
static public function is_flow_edit_admin() {
|
232 |
-
|
233 |
-
$current_screen = get_current_screen();
|
234 |
-
|
235 |
-
if (
|
236 |
-
is_object( $current_screen ) &&
|
237 |
-
isset( $current_screen->post_type ) &&
|
238 |
-
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
|
239 |
-
isset( $current_screen->base ) &&
|
240 |
-
( 'post' === $current_screen->base )
|
241 |
-
) {
|
242 |
-
return true;
|
243 |
-
}
|
244 |
-
return false;
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Global Admin Scripts.
|
249 |
-
*
|
250 |
-
* @since 1.0.0
|
251 |
-
*/
|
252 |
-
static public function global_admin_scripts() {
|
253 |
-
|
254 |
-
$localize = array(
|
255 |
-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
256 |
-
'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
|
257 |
-
);
|
258 |
-
|
259 |
-
wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
|
260 |
-
|
261 |
-
if ( self::is_global_admin() ) {
|
262 |
-
|
263 |
-
// Styles.
|
264 |
-
wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
|
265 |
-
wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
|
266 |
-
|
267 |
-
wp_enqueue_script(
|
268 |
-
'wcf-global-admin',
|
269 |
-
CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
|
270 |
-
array( 'jquery' ),
|
271 |
-
CARTFLOWS_VER,
|
272 |
-
true
|
273 |
-
);
|
274 |
-
|
275 |
-
do_action( 'cartflows_global_admin_scripts' );
|
276 |
-
}
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Global Admin Data.
|
281 |
-
*
|
282 |
-
* @since 1.0.0
|
283 |
-
*/
|
284 |
-
static public function global_admin_data() {
|
285 |
-
|
286 |
-
$current_screen = get_current_screen();
|
287 |
-
|
288 |
-
if ( ! $current_screen ) {
|
289 |
-
return;
|
290 |
-
}
|
291 |
-
|
292 |
-
if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
|
293 |
-
return;
|
294 |
-
}
|
295 |
-
|
296 |
-
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
297 |
-
?>
|
298 |
-
|
299 |
-
<div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
|
300 |
-
<div class="wcf-templates-popup-content">
|
301 |
-
<div class="spinner"></div>
|
302 |
-
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
303 |
-
|
304 |
-
<div id="wcf-remote-flow-actions" class="wcf-template-header">
|
305 |
-
<div class="wcf-template-logo-wrap">
|
306 |
-
<span class="wcf-cartflows-logo-img">
|
307 |
-
<span class="cartflows-icon"></span>
|
308 |
-
</span>
|
309 |
-
<span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
|
310 |
-
</div>
|
311 |
-
<div class="wcf-tab-wrapper">
|
312 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
313 |
-
<div id="wcf-get-started-steps">
|
314 |
-
<ul class="filter-links ">
|
315 |
-
<li>
|
316 |
-
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
317 |
-
</li>
|
318 |
-
<li>
|
319 |
-
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
320 |
-
</li>
|
321 |
-
</ul>
|
322 |
-
</div>
|
323 |
-
<?php } ?>
|
324 |
-
</div>
|
325 |
-
<div class="wcf-popup-close-wrap">
|
326 |
-
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
327 |
-
</div>
|
328 |
-
</div>
|
329 |
-
<!-- <div class="wcf-search-form">
|
330 |
-
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
331 |
-
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
332 |
-
</div> -->
|
333 |
-
|
334 |
-
<div id="wcf-remote-content">
|
335 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
336 |
-
<div id="wcf-ready-templates">
|
337 |
-
<div id="wcf-remote-filters">
|
338 |
-
<div id="wcf-page-builders"></div>
|
339 |
-
<div id="wcf-categories"></div>
|
340 |
-
</div>
|
341 |
-
<div class="wcf-page-builder-notice"></div>
|
342 |
-
<div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
343 |
-
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
344 |
-
</div>
|
345 |
-
<?php } ?>
|
346 |
-
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
347 |
-
<div class="inner">
|
348 |
-
<a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
|
349 |
-
<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>
|
350 |
-
</div>
|
351 |
-
</div>
|
352 |
-
</div>
|
353 |
-
</div>
|
354 |
-
</div>
|
355 |
-
</div>
|
356 |
-
|
357 |
-
<?php
|
358 |
-
}
|
359 |
-
|
360 |
-
/**
|
361 |
-
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
362 |
-
*
|
363 |
-
* @since 1.0.0
|
364 |
-
*/
|
365 |
-
static public function styles_scripts() {
|
366 |
-
|
367 |
-
// Styles.
|
368 |
-
wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
|
369 |
-
wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
|
370 |
-
|
371 |
-
// Script.
|
372 |
-
wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
|
373 |
-
|
374 |
-
$localize = array(
|
375 |
-
'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
|
376 |
-
);
|
377 |
-
|
378 |
-
wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
|
379 |
-
}
|
380 |
-
|
381 |
-
/**
|
382 |
-
* Save All admin settings here
|
383 |
-
*/
|
384 |
-
static public function save_settings() {
|
385 |
-
|
386 |
-
// Only admins can save settings.
|
387 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
388 |
-
return;
|
389 |
-
}
|
390 |
-
|
391 |
-
self::save_common_settings();
|
392 |
-
|
393 |
-
// Let extensions hook into saving.
|
394 |
-
do_action( 'cartflows_admin_settings_save' );
|
395 |
-
}
|
396 |
-
|
397 |
-
/**
|
398 |
-
* Get and return page URL
|
399 |
-
*
|
400 |
-
* @param string $menu_slug Menu name.
|
401 |
-
* @since 1.0.0
|
402 |
-
* @return string page url
|
403 |
-
*/
|
404 |
-
static public function get_page_url( $menu_slug ) {
|
405 |
-
|
406 |
-
$parent_page = self::$default_menu_position;
|
407 |
-
|
408 |
-
if ( strpos( $parent_page, '?' ) !== false ) {
|
409 |
-
$query_var = '&page=' . self::$plugin_slug;
|
410 |
-
} else {
|
411 |
-
$query_var = '?page=' . self::$plugin_slug;
|
412 |
-
}
|
413 |
-
|
414 |
-
$parent_page_url = admin_url( $parent_page . $query_var );
|
415 |
-
|
416 |
-
$url = $parent_page_url . '&action=' . $menu_slug;
|
417 |
-
|
418 |
-
return esc_url( $url );
|
419 |
-
}
|
420 |
-
|
421 |
-
/**
|
422 |
-
* Admin body classes.
|
423 |
-
*
|
424 |
-
* Body classes to be added to <body> tag in admin page
|
425 |
-
*
|
426 |
-
* @param String $classes body classes returned from the filter.
|
427 |
-
* @return String body classes to be added to <body> tag in admin page
|
428 |
-
*/
|
429 |
-
static public function add_admin_body_class( $classes ) {
|
430 |
-
|
431 |
-
$classes .= ' cartflows-' . CARTFLOWS_VER;
|
432 |
-
|
433 |
-
return $classes;
|
434 |
-
}
|
435 |
-
}
|
436 |
-
|
437 |
-
Cartflows_Admin::init();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Admin.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Cartflows_Admin.
|
10 |
+
*/
|
11 |
+
class Cartflows_Admin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Calls on initialization
|
15 |
+
*
|
16 |
+
* @since 1.0.0
|
17 |
+
*/
|
18 |
+
public static function init() {
|
19 |
+
|
20 |
+
self::initialise_plugin();
|
21 |
+
self::init_hooks();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Init Hooks.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
static public function init_hooks() {
|
31 |
+
|
32 |
+
if ( ! is_admin() ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
|
37 |
+
|
38 |
+
// Add CARTFLOWS menu option to admin.
|
39 |
+
add_action( 'network_admin_menu', __CLASS__ . '::menu' );
|
40 |
+
add_action( 'admin_menu', __CLASS__ . '::menu' );
|
41 |
+
add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
|
42 |
+
|
43 |
+
add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
|
44 |
+
|
45 |
+
// Enqueue admin scripts.
|
46 |
+
if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
|
47 |
+
|
48 |
+
add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
|
49 |
+
|
50 |
+
self::save_settings();
|
51 |
+
}
|
52 |
+
|
53 |
+
/* Global Addmin Script */
|
54 |
+
add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
|
55 |
+
|
56 |
+
add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
|
57 |
+
|
58 |
+
/* Add lite version class to body */
|
59 |
+
add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Initialises the Plugin Name.
|
64 |
+
*
|
65 |
+
* @since 1.0.0
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
static public function initialise_plugin() {
|
69 |
+
|
70 |
+
$name = 'Cartflows';
|
71 |
+
$short_name = 'Cflows';
|
72 |
+
|
73 |
+
define( 'CARTFLOWS_PLUGIN_NAME', $name );
|
74 |
+
define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Renders the admin settings menu.
|
79 |
+
*
|
80 |
+
* @since 1.0.0
|
81 |
+
* @return void
|
82 |
+
*/
|
83 |
+
static public function menu() {
|
84 |
+
|
85 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
add_menu_page(
|
90 |
+
'CartFlows',
|
91 |
+
'CartFlows',
|
92 |
+
'manage_options',
|
93 |
+
CARTFLOWS_SLUG,
|
94 |
+
__CLASS__ . '::render',
|
95 |
+
'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
|
96 |
+
39.7
|
97 |
+
);
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Add submenu to admin menu.
|
103 |
+
*
|
104 |
+
* @since 1.0.0
|
105 |
+
*/
|
106 |
+
static function submenu() {
|
107 |
+
|
108 |
+
$parent_slug = CARTFLOWS_SLUG;
|
109 |
+
$page_title = __( 'Settings', 'cartflows' );
|
110 |
+
$menu_title = __( 'Settings', 'cartflows' );
|
111 |
+
$capability = 'manage_options';
|
112 |
+
$menu_slug = 'cartflows_settings';
|
113 |
+
$callback = __CLASS__ . '::render';
|
114 |
+
|
115 |
+
add_submenu_page(
|
116 |
+
$parent_slug,
|
117 |
+
$page_title,
|
118 |
+
$menu_title,
|
119 |
+
$capability,
|
120 |
+
$menu_slug,
|
121 |
+
$callback
|
122 |
+
);
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Renders the admin settings.
|
127 |
+
*
|
128 |
+
* @since 1.0.0
|
129 |
+
* @return void
|
130 |
+
*/
|
131 |
+
static public function render() {
|
132 |
+
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
133 |
+
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
134 |
+
$action = str_replace( '_', '-', $action );
|
135 |
+
|
136 |
+
// Enable header icon filter below.
|
137 |
+
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
138 |
+
|
139 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Renders the admin settings content.
|
144 |
+
*
|
145 |
+
* @since 1.0.0
|
146 |
+
* @return void
|
147 |
+
*/
|
148 |
+
static public function render_content() {
|
149 |
+
|
150 |
+
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
151 |
+
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
152 |
+
$action = str_replace( '_', '-', $action );
|
153 |
+
$action = 'general';
|
154 |
+
|
155 |
+
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
156 |
+
|
157 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Save Global Setting options.
|
162 |
+
*
|
163 |
+
* @since 1.0.0
|
164 |
+
*/
|
165 |
+
static public function save_common_settings() {
|
166 |
+
|
167 |
+
if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
|
168 |
+
|
169 |
+
$url = $_SERVER['REQUEST_URI'];
|
170 |
+
$input_settings = array();
|
171 |
+
$new_settings = array();
|
172 |
+
|
173 |
+
if ( isset( $_POST['_cartflows_common'] ) ) {
|
174 |
+
|
175 |
+
$input_settings = $_POST['_cartflows_common'];
|
176 |
+
|
177 |
+
// Loop through the input and sanitize each of the values.
|
178 |
+
foreach ( $input_settings as $key => $val ) {
|
179 |
+
|
180 |
+
if ( is_array( $val ) ) {
|
181 |
+
foreach ( $val as $k => $v ) {
|
182 |
+
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
|
183 |
+
}
|
184 |
+
} else {
|
185 |
+
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
|
191 |
+
|
192 |
+
$query = array(
|
193 |
+
'message' => 'saved',
|
194 |
+
);
|
195 |
+
|
196 |
+
$redirect_to = add_query_arg( $query, $url );
|
197 |
+
|
198 |
+
wp_redirect( $redirect_to );
|
199 |
+
exit;
|
200 |
+
} // End if statement.
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Check is cartflows admin.
|
205 |
+
*
|
206 |
+
* @since 1.0.0
|
207 |
+
* @return boolean
|
208 |
+
*/
|
209 |
+
static public function is_global_admin() {
|
210 |
+
|
211 |
+
$current_screen = get_current_screen();
|
212 |
+
|
213 |
+
if (
|
214 |
+
is_object( $current_screen ) &&
|
215 |
+
isset( $current_screen->post_type ) &&
|
216 |
+
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
|
217 |
+
CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
|
218 |
+
)
|
219 |
+
) {
|
220 |
+
return true;
|
221 |
+
}
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Check is flow admin.
|
227 |
+
*
|
228 |
+
* @since 1.0.0
|
229 |
+
* @return boolean
|
230 |
+
*/
|
231 |
+
static public function is_flow_edit_admin() {
|
232 |
+
|
233 |
+
$current_screen = get_current_screen();
|
234 |
+
|
235 |
+
if (
|
236 |
+
is_object( $current_screen ) &&
|
237 |
+
isset( $current_screen->post_type ) &&
|
238 |
+
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
|
239 |
+
isset( $current_screen->base ) &&
|
240 |
+
( 'post' === $current_screen->base )
|
241 |
+
) {
|
242 |
+
return true;
|
243 |
+
}
|
244 |
+
return false;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Global Admin Scripts.
|
249 |
+
*
|
250 |
+
* @since 1.0.0
|
251 |
+
*/
|
252 |
+
static public function global_admin_scripts() {
|
253 |
+
|
254 |
+
$localize = array(
|
255 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
256 |
+
'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
|
257 |
+
);
|
258 |
+
|
259 |
+
wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
|
260 |
+
|
261 |
+
if ( self::is_global_admin() ) {
|
262 |
+
|
263 |
+
// Styles.
|
264 |
+
wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
|
265 |
+
wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
|
266 |
+
|
267 |
+
wp_enqueue_script(
|
268 |
+
'wcf-global-admin',
|
269 |
+
CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
|
270 |
+
array( 'jquery' ),
|
271 |
+
CARTFLOWS_VER,
|
272 |
+
true
|
273 |
+
);
|
274 |
+
|
275 |
+
do_action( 'cartflows_global_admin_scripts' );
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Global Admin Data.
|
281 |
+
*
|
282 |
+
* @since 1.0.0
|
283 |
+
*/
|
284 |
+
static public function global_admin_data() {
|
285 |
+
|
286 |
+
$current_screen = get_current_screen();
|
287 |
+
|
288 |
+
if ( ! $current_screen ) {
|
289 |
+
return;
|
290 |
+
}
|
291 |
+
|
292 |
+
if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
|
296 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
297 |
+
?>
|
298 |
+
|
299 |
+
<div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
|
300 |
+
<div class="wcf-templates-popup-content">
|
301 |
+
<div class="spinner"></div>
|
302 |
+
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
303 |
+
|
304 |
+
<div id="wcf-remote-flow-actions" class="wcf-template-header">
|
305 |
+
<div class="wcf-template-logo-wrap">
|
306 |
+
<span class="wcf-cartflows-logo-img">
|
307 |
+
<span class="cartflows-icon"></span>
|
308 |
+
</span>
|
309 |
+
<span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
|
310 |
+
</div>
|
311 |
+
<div class="wcf-tab-wrapper">
|
312 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
313 |
+
<div id="wcf-get-started-steps">
|
314 |
+
<ul class="filter-links ">
|
315 |
+
<li>
|
316 |
+
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
317 |
+
</li>
|
318 |
+
<li>
|
319 |
+
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
320 |
+
</li>
|
321 |
+
</ul>
|
322 |
+
</div>
|
323 |
+
<?php } ?>
|
324 |
+
</div>
|
325 |
+
<div class="wcf-popup-close-wrap">
|
326 |
+
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
327 |
+
</div>
|
328 |
+
</div>
|
329 |
+
<!-- <div class="wcf-search-form">
|
330 |
+
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
331 |
+
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
332 |
+
</div> -->
|
333 |
+
|
334 |
+
<div id="wcf-remote-content">
|
335 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
336 |
+
<div id="wcf-ready-templates">
|
337 |
+
<div id="wcf-remote-filters">
|
338 |
+
<div id="wcf-page-builders"></div>
|
339 |
+
<div id="wcf-categories"></div>
|
340 |
+
</div>
|
341 |
+
<div class="wcf-page-builder-notice"></div>
|
342 |
+
<div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
343 |
+
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
344 |
+
</div>
|
345 |
+
<?php } ?>
|
346 |
+
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
347 |
+
<div class="inner">
|
348 |
+
<a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
|
349 |
+
<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>
|
350 |
+
</div>
|
351 |
+
</div>
|
352 |
+
</div>
|
353 |
+
</div>
|
354 |
+
</div>
|
355 |
+
</div>
|
356 |
+
|
357 |
+
<?php
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
362 |
+
*
|
363 |
+
* @since 1.0.0
|
364 |
+
*/
|
365 |
+
static public function styles_scripts() {
|
366 |
+
|
367 |
+
// Styles.
|
368 |
+
wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
|
369 |
+
wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
|
370 |
+
|
371 |
+
// Script.
|
372 |
+
wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
|
373 |
+
|
374 |
+
$localize = array(
|
375 |
+
'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
|
376 |
+
);
|
377 |
+
|
378 |
+
wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Save All admin settings here
|
383 |
+
*/
|
384 |
+
static public function save_settings() {
|
385 |
+
|
386 |
+
// Only admins can save settings.
|
387 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
388 |
+
return;
|
389 |
+
}
|
390 |
+
|
391 |
+
self::save_common_settings();
|
392 |
+
|
393 |
+
// Let extensions hook into saving.
|
394 |
+
do_action( 'cartflows_admin_settings_save' );
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Get and return page URL
|
399 |
+
*
|
400 |
+
* @param string $menu_slug Menu name.
|
401 |
+
* @since 1.0.0
|
402 |
+
* @return string page url
|
403 |
+
*/
|
404 |
+
static public function get_page_url( $menu_slug ) {
|
405 |
+
|
406 |
+
$parent_page = self::$default_menu_position;
|
407 |
+
|
408 |
+
if ( strpos( $parent_page, '?' ) !== false ) {
|
409 |
+
$query_var = '&page=' . self::$plugin_slug;
|
410 |
+
} else {
|
411 |
+
$query_var = '?page=' . self::$plugin_slug;
|
412 |
+
}
|
413 |
+
|
414 |
+
$parent_page_url = admin_url( $parent_page . $query_var );
|
415 |
+
|
416 |
+
$url = $parent_page_url . '&action=' . $menu_slug;
|
417 |
+
|
418 |
+
return esc_url( $url );
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Admin body classes.
|
423 |
+
*
|
424 |
+
* Body classes to be added to <body> tag in admin page
|
425 |
+
*
|
426 |
+
* @param String $classes body classes returned from the filter.
|
427 |
+
* @return String body classes to be added to <body> tag in admin page
|
428 |
+
*/
|
429 |
+
static public function add_admin_body_class( $classes ) {
|
430 |
+
|
431 |
+
$classes .= ' cartflows-' . CARTFLOWS_VER;
|
432 |
+
|
433 |
+
return $classes;
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
Cartflows_Admin::init();
|
classes/class-cartflows-api.php
CHANGED
@@ -1,376 +1,386 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows API
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'CartFlows_API' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows API
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class CartFlows_API {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @access private
|
22 |
-
* @var object Class object.
|
23 |
-
* @since 1.0.0
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Initiator
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
* @return object initialized object of class.
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
if ( ! isset( self::$instance ) ) {
|
35 |
-
self::$instance = new self;
|
36 |
-
}
|
37 |
-
return self::$instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor
|
42 |
-
*
|
43 |
-
* @since 1.0.0
|
44 |
-
*/
|
45 |
-
public function __construct() {
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Get site URL.
|
50 |
-
*
|
51 |
-
* @since 1.0.0
|
52 |
-
*
|
53 |
-
* @return string Site URL.
|
54 |
-
*/
|
55 |
-
public static function get_site_url() {
|
56 |
-
return apply_filters( 'cartflows_templates_url', CARTFLOWS_TEMPLATES_URL );
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Get Client Site Templates Rest API URL.
|
61 |
-
*
|
62 |
-
* @since 1.0.0
|
63 |
-
*
|
64 |
-
* @return string API site URL.
|
65 |
-
*/
|
66 |
-
public static function get_step_endpoint_url() {
|
67 |
-
return self::get_site_url() . 'wp-json/wp/v2/' . CARTFLOWS_STEP_POST_TYPE . '/';
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Get Client Site Category Rest API URL.
|
72 |
-
*
|
73 |
-
* @since 1.0.0
|
74 |
-
*
|
75 |
-
* @return string API site URL.
|
76 |
-
*/
|
77 |
-
public static function get_category_endpoint_url() {
|
78 |
-
return self::get_site_url() . 'wp-json/wp/v2/' . CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER . '/';
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Get API request URL.
|
83 |
-
*
|
84 |
-
* @since 1.0.0
|
85 |
-
*
|
86 |
-
* @param string $api_base base of api request.
|
87 |
-
* @return string API site URL.
|
88 |
-
*/
|
89 |
-
public static function get_request_api_url( $api_base = '' ) {
|
90 |
-
return self::get_site_url() . 'wp-json/' . CARTFLOWS_STEP_POST_TYPE . '/v1/' . $api_base;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* License Args.
|
95 |
-
*
|
96 |
-
* @return array License arguments.
|
97 |
-
*/
|
98 |
-
public static function get_licence_args() {
|
99 |
-
return apply_filters( 'cartflows_licence_args', array() );
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Get single demo.
|
104 |
-
*
|
105 |
-
* @since 1.0.0
|
106 |
-
*
|
107 |
-
* @param string $site_id Template ID of the site.
|
108 |
-
* @return array Template data.
|
109 |
-
*/
|
110 |
-
public static function get_template( $site_id ) {
|
111 |
-
// @codingStandardsIgnoreStart
|
112 |
-
$request_params = array(
|
113 |
-
'licence_args' => self::get_licence_args(),
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
'
|
192 |
-
'
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
*
|
284 |
-
*
|
285 |
-
* @
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
*
|
299 |
-
*
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
* API
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
//
|
336 |
-
if (
|
337 |
-
return array(
|
338 |
-
'success' => false,
|
339 |
-
'message' => $request
|
340 |
-
'data' => $request,
|
341 |
-
'count' => 0,
|
342 |
-
);
|
343 |
-
}
|
344 |
-
|
345 |
-
//
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
'
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
//
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows API
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_API' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows API
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class CartFlows_API {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @access private
|
22 |
+
* @var object Class object.
|
23 |
+
* @since 1.0.0
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initiator
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @return object initialized object of class.
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self;
|
36 |
+
}
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor
|
42 |
+
*
|
43 |
+
* @since 1.0.0
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get site URL.
|
50 |
+
*
|
51 |
+
* @since 1.0.0
|
52 |
+
*
|
53 |
+
* @return string Site URL.
|
54 |
+
*/
|
55 |
+
public static function get_site_url() {
|
56 |
+
return apply_filters( 'cartflows_templates_url', CARTFLOWS_TEMPLATES_URL );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Get Client Site Templates Rest API URL.
|
61 |
+
*
|
62 |
+
* @since 1.0.0
|
63 |
+
*
|
64 |
+
* @return string API site URL.
|
65 |
+
*/
|
66 |
+
public static function get_step_endpoint_url() {
|
67 |
+
return self::get_site_url() . 'wp-json/wp/v2/' . CARTFLOWS_STEP_POST_TYPE . '/';
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get Client Site Category Rest API URL.
|
72 |
+
*
|
73 |
+
* @since 1.0.0
|
74 |
+
*
|
75 |
+
* @return string API site URL.
|
76 |
+
*/
|
77 |
+
public static function get_category_endpoint_url() {
|
78 |
+
return self::get_site_url() . 'wp-json/wp/v2/' . CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER . '/';
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Get API request URL.
|
83 |
+
*
|
84 |
+
* @since 1.0.0
|
85 |
+
*
|
86 |
+
* @param string $api_base base of api request.
|
87 |
+
* @return string API site URL.
|
88 |
+
*/
|
89 |
+
public static function get_request_api_url( $api_base = '' ) {
|
90 |
+
return self::get_site_url() . 'wp-json/' . CARTFLOWS_STEP_POST_TYPE . '/v1/' . $api_base;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* License Args.
|
95 |
+
*
|
96 |
+
* @return array License arguments.
|
97 |
+
*/
|
98 |
+
public static function get_licence_args() {
|
99 |
+
return apply_filters( 'cartflows_licence_args', array() );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get single demo.
|
104 |
+
*
|
105 |
+
* @since 1.0.0
|
106 |
+
*
|
107 |
+
* @param string $site_id Template ID of the site.
|
108 |
+
* @return array Template data.
|
109 |
+
*/
|
110 |
+
public static function get_template( $site_id ) {
|
111 |
+
// @codingStandardsIgnoreStart
|
112 |
+
$request_params = array(
|
113 |
+
'licence_args' => self::get_licence_args(),
|
114 |
+
'_fields' => 'id,slug,status,type,link,title,featured_media,template,cartflows_step_page_builder,cartflows_step_type,cartflows_step_flow,featured_image_url,licence_status,flow_type,step_type,page_builder,divi_content,post_meta',
|
115 |
+
);
|
116 |
+
// @codingStandardsIgnoreEnd
|
117 |
+
|
118 |
+
$url = add_query_arg( $request_params, self::get_step_endpoint_url() . $site_id );
|
119 |
+
|
120 |
+
$api_args = array(
|
121 |
+
'timeout' => 15,
|
122 |
+
);
|
123 |
+
|
124 |
+
$response = self::remote_get( $url, $api_args );
|
125 |
+
// vl( $url );.
|
126 |
+
// vl( 'Here' );.
|
127 |
+
// vl( $api_args );.
|
128 |
+
// vl( $response['data']['divi_content'] );.
|
129 |
+
// vl( 'Here too..' );.
|
130 |
+
// wp_die();.
|
131 |
+
if ( $response['success'] ) {
|
132 |
+
$template = $response['data'];
|
133 |
+
return array(
|
134 |
+
'title' => ( isset( $template['title']->rendered ) ) ? $template['title']->rendered : '',
|
135 |
+
'post_meta' => ( isset( $template['post_meta'] ) ) ? $template['post_meta'] : '',
|
136 |
+
'data' => $template,
|
137 |
+
'divi_content' => isset( $response['data']['divi_content'] ) ? $response['data']['divi_content'] : '',
|
138 |
+
'message' => $response['message'], // __( 'Your API Key is not valid. Please add valid API Key.', 'cartflows' ),
|
139 |
+
'success' => $response['success'],
|
140 |
+
);
|
141 |
+
}
|
142 |
+
|
143 |
+
return array(
|
144 |
+
'title' => '',
|
145 |
+
'post_meta' => array(),
|
146 |
+
'message' => $response['message'],
|
147 |
+
'data' => $response['data'],
|
148 |
+
'divi_content' => '',
|
149 |
+
'success' => $response['success'],
|
150 |
+
);
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Get Cloud Templates
|
155 |
+
*
|
156 |
+
* @since 1.0.0
|
157 |
+
*
|
158 |
+
* @param array $args For selecting the demos (Search terms, pagination etc).
|
159 |
+
* @return array CartFlows list.
|
160 |
+
*/
|
161 |
+
public static function get_templates( $args = array() ) {
|
162 |
+
|
163 |
+
$request_params = wp_parse_args(
|
164 |
+
$args,
|
165 |
+
array(
|
166 |
+
'page' => '1',
|
167 |
+
'per_page' => '15',
|
168 |
+
)
|
169 |
+
);
|
170 |
+
|
171 |
+
$url = add_query_arg( $request_params, self::get_step_endpoint_url() );
|
172 |
+
|
173 |
+
$api_args = array(
|
174 |
+
'timeout' => 15,
|
175 |
+
);
|
176 |
+
|
177 |
+
$response = self::remote_get( $url, $api_args );
|
178 |
+
|
179 |
+
if ( $response['success'] ) {
|
180 |
+
$templates_data = $response['data'];
|
181 |
+
$templates = array();
|
182 |
+
foreach ( $templates_data as $key => $template ) {
|
183 |
+
|
184 |
+
if ( ! isset( $template->id ) ) {
|
185 |
+
continue;
|
186 |
+
}
|
187 |
+
|
188 |
+
$templates[ $key ]['id'] = isset( $template->id ) ? esc_attr( $template->id ) : '';
|
189 |
+
$templates[ $key ]['slug'] = isset( $template->slug ) ? esc_attr( $template->slug ) : '';
|
190 |
+
$templates[ $key ]['link'] = isset( $template->link ) ? esc_url( $template->link ) : '';
|
191 |
+
$templates[ $key ]['date'] = isset( $template->date ) ? esc_attr( $template->date ) : '';
|
192 |
+
$templates[ $key ]['title'] = isset( $template->title->rendered ) ? esc_attr( $template->title->rendered ) : '';
|
193 |
+
$templates[ $key ]['featured_image_url'] = isset( $template->featured_image_url ) ? esc_url( $template->featured_image_url ) : '';
|
194 |
+
$templates[ $key ]['content'] = isset( $template->content->rendered ) ? $template->content->rendered : '';
|
195 |
+
$templates[ $key ]['divi_content'] = isset( $template->divi_content ) ? $template->divi_content : '';
|
196 |
+
$templates[ $key ]['post_meta'] = isset( $template->post_meta ) ? $template->post_meta : '';
|
197 |
+
}
|
198 |
+
|
199 |
+
return array(
|
200 |
+
'templates' => $templates,
|
201 |
+
'templates_count' => $response['count'],
|
202 |
+
'data' => $response,
|
203 |
+
);
|
204 |
+
}
|
205 |
+
|
206 |
+
return array(
|
207 |
+
'templates' => array(),
|
208 |
+
'templates_count' => 0,
|
209 |
+
'data' => $response,
|
210 |
+
);
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Get categories.
|
216 |
+
*
|
217 |
+
* @since 1.0.0
|
218 |
+
* @param array $args Arguments.
|
219 |
+
* @return array Category data.
|
220 |
+
*/
|
221 |
+
public static function get_categories( $args = array() ) {
|
222 |
+
|
223 |
+
$request_params = apply_filters(
|
224 |
+
'cartflows_categories_api_params',
|
225 |
+
wp_parse_args(
|
226 |
+
$args,
|
227 |
+
array(
|
228 |
+
'page' => '1',
|
229 |
+
'per_page' => '15',
|
230 |
+
)
|
231 |
+
)
|
232 |
+
);
|
233 |
+
|
234 |
+
$url = add_query_arg( $request_params, self::get_category_endpoint_url() );
|
235 |
+
|
236 |
+
$api_args = apply_filters(
|
237 |
+
'cartflows_api_args',
|
238 |
+
array(
|
239 |
+
'timeout' => 15,
|
240 |
+
)
|
241 |
+
);
|
242 |
+
|
243 |
+
$response = self::remote_get( $url, $api_args );
|
244 |
+
|
245 |
+
if ( $response['success'] ) {
|
246 |
+
$categories_data = $response['data'];
|
247 |
+
$categories = array();
|
248 |
+
|
249 |
+
foreach ( $categories_data as $key => $category ) {
|
250 |
+
if ( isset( $category->count ) && ! empty( $category->count ) ) {
|
251 |
+
$categories[] = array(
|
252 |
+
'id' => isset( $category->id ) ? absint( $category->id ) : 0,
|
253 |
+
'count' => isset( $category->count ) ? absint( $category->count ) : 0,
|
254 |
+
'description' => isset( $category->description ) ? $category->description : '',
|
255 |
+
'link' => isset( $category->link ) ? esc_url( $category->link ) : '',
|
256 |
+
'name' => isset( $category->name ) ? $category->name : '',
|
257 |
+
'slug' => isset( $category->slug ) ? sanitize_text_field( $category->slug ) : '',
|
258 |
+
'taxonomy' => isset( $category->taxonomy ) ? $category->taxonomy : '',
|
259 |
+
'parent' => isset( $category->parent ) ? $category->parent : '',
|
260 |
+
);
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
return array(
|
265 |
+
'categories' => $categories,
|
266 |
+
'categories_count' => $response['count'],
|
267 |
+
'data' => $response,
|
268 |
+
);
|
269 |
+
}
|
270 |
+
|
271 |
+
return array(
|
272 |
+
'categories' => array(),
|
273 |
+
'categories_count' => 0,
|
274 |
+
'data' => $response,
|
275 |
+
);
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Remote GET API Request
|
280 |
+
*
|
281 |
+
* @since 1.0.0
|
282 |
+
*
|
283 |
+
* @param string $url Target server API URL.
|
284 |
+
* @param array $args Array of arguments for the API request.
|
285 |
+
* @return mixed Return the API request result.
|
286 |
+
*/
|
287 |
+
public static function remote_get( $url = '', $args = array() ) {
|
288 |
+
$request = wp_remote_get( $url, $args );
|
289 |
+
return self::request( $request );
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Remote POST API Request
|
294 |
+
*
|
295 |
+
* @since 1.0.0
|
296 |
+
*
|
297 |
+
* @param string $url Target server API URL.
|
298 |
+
* @param array $args Array of arguments for the API request.
|
299 |
+
* @return mixed Return the API request result.
|
300 |
+
*/
|
301 |
+
public static function remote_post( $url = '', $args = array() ) {
|
302 |
+
$request = wp_remote_post( $url, $args );
|
303 |
+
|
304 |
+
return self::request( $request );
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Site API Request
|
309 |
+
*
|
310 |
+
* @since 1.0.0
|
311 |
+
*
|
312 |
+
* @param boolean $api_base Target server API URL.
|
313 |
+
* @param array $args Array of arguments for the API request.
|
314 |
+
* @return mixed Return the API request result.
|
315 |
+
*/
|
316 |
+
public static function site_request( $api_base = '', $args = array() ) {
|
317 |
+
|
318 |
+
$api_url = self::get_request_api_url( $api_base );
|
319 |
+
|
320 |
+
return self::remote_post( $api_url, $args );
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* API Request
|
325 |
+
*
|
326 |
+
* Handle the API request and return the result.
|
327 |
+
*
|
328 |
+
* @since 1.0.0
|
329 |
+
*
|
330 |
+
* @param array $request Array of arguments for the API request.
|
331 |
+
* @return mixed Return the API request result.
|
332 |
+
*/
|
333 |
+
public static function request( $request ) {
|
334 |
+
|
335 |
+
// Is WP Error?
|
336 |
+
if ( is_wp_error( $request ) ) {
|
337 |
+
return array(
|
338 |
+
'success' => false,
|
339 |
+
'message' => $request->get_error_message(),
|
340 |
+
'data' => $request,
|
341 |
+
'count' => 0,
|
342 |
+
);
|
343 |
+
}
|
344 |
+
|
345 |
+
// Invalid response code.
|
346 |
+
if ( wp_remote_retrieve_response_code( $request ) != 200 ) {
|
347 |
+
return array(
|
348 |
+
'success' => false,
|
349 |
+
'message' => $request['response'],
|
350 |
+
'data' => $request,
|
351 |
+
'count' => 0,
|
352 |
+
);
|
353 |
+
}
|
354 |
+
|
355 |
+
// Get body data.
|
356 |
+
$body = wp_remote_retrieve_body( $request );
|
357 |
+
|
358 |
+
// Is WP Error?
|
359 |
+
if ( is_wp_error( $body ) ) {
|
360 |
+
return array(
|
361 |
+
'success' => false,
|
362 |
+
'message' => $body->get_error_message(),
|
363 |
+
'data' => $request,
|
364 |
+
'count' => 0,
|
365 |
+
);
|
366 |
+
}
|
367 |
+
|
368 |
+
// Decode body content.
|
369 |
+
$body_decoded = json_decode( $body );
|
370 |
+
|
371 |
+
return array(
|
372 |
+
'success' => true,
|
373 |
+
'message' => __( 'Request successfully processed!', 'cartflows' ),
|
374 |
+
'data' => (array) $body_decoded,
|
375 |
+
'count' => wp_remote_retrieve_header( $request, 'x-wp-total' ),
|
376 |
+
);
|
377 |
+
}
|
378 |
+
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Initialize class object with 'get_instance()' method
|
383 |
+
*/
|
384 |
+
CartFlows_API::get_instance();
|
385 |
+
|
386 |
+
endif;
|
classes/class-cartflows-compatibility.php
CHANGED
@@ -187,6 +187,20 @@ if ( ! class_exists( 'Cartflows_Compatibility' ) ) {
|
|
187 |
return false;
|
188 |
}
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
/**
|
191 |
* Check if Flatsome enabled for post id.
|
192 |
*
|
187 |
return false;
|
188 |
}
|
189 |
|
190 |
+
/**
|
191 |
+
* Check if Divi theme is install status.
|
192 |
+
*
|
193 |
+
* @return boolean
|
194 |
+
*/
|
195 |
+
function is_divi_theme_installed() {
|
196 |
+
foreach ( (array) wp_get_themes() as $theme_dir => $theme ) {
|
197 |
+
if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme ) {
|
198 |
+
return true;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
return false;
|
202 |
+
}
|
203 |
+
|
204 |
/**
|
205 |
* Check if Flatsome enabled for post id.
|
206 |
*
|
classes/class-cartflows-default-meta.php
CHANGED
@@ -356,7 +356,6 @@ class Cartflows_Default_Meta {
|
|
356 |
$billing_fields = array();
|
357 |
|
358 |
if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
|
359 |
-
$key_count = count( $key );
|
360 |
$post_data = $_POST[ $key ];
|
361 |
|
362 |
if ( 'wcf_field_order_billing' == $key ) {
|
356 |
$billing_fields = array();
|
357 |
|
358 |
if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) {
|
|
|
359 |
$post_data = $_POST[ $key ];
|
360 |
|
361 |
if ( 'wcf_field_order_billing' == $key ) {
|
classes/class-cartflows-frontend.php
CHANGED
@@ -1,402 +1,402 @@
|
|
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 |
-
/* Enqueue global required scripts */
|
39 |
-
add_action( 'wp', array( $this, 'wp_actions' ), 55 );
|
40 |
-
|
41 |
-
/* Modify the checkout order received url to go thank you page in our flow */
|
42 |
-
add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 );
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Redirect to thank page if upsell not exists
|
47 |
-
*
|
48 |
-
* @param string $order_recieve_url url.
|
49 |
-
* @param object $order order object.
|
50 |
-
* @since 1.0.0
|
51 |
-
*/
|
52 |
-
function redirect_to_thankyou_page( $order_recieve_url, $order ) {
|
53 |
-
|
54 |
-
/* Only for thank you page */
|
55 |
-
wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ );
|
56 |
-
wcf()->logger->log( 'Only for thank you page' );
|
57 |
-
|
58 |
-
if ( wcf()->flow->is_thankyou_page_exists( $order ) ) {
|
59 |
-
|
60 |
-
if ( _is_wcf_doing_checkout_ajax() ) {
|
61 |
-
|
62 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_post_data();
|
63 |
-
|
64 |
-
if ( ! $checkout_id ) {
|
65 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
66 |
-
}
|
67 |
-
} else {
|
68 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
69 |
-
}
|
70 |
-
|
71 |
-
wcf()->logger->log( 'Checkout ID : ' . $checkout_id );
|
72 |
-
|
73 |
-
if ( $checkout_id ) {
|
74 |
-
|
75 |
-
$thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order );
|
76 |
-
|
77 |
-
if ( $thankyou_step_id ) {
|
78 |
-
|
79 |
-
$order_recieve_url = get_permalink( $thankyou_step_id );
|
80 |
-
|
81 |
-
$order_recieve_url = add_query_arg(
|
82 |
-
array(
|
83 |
-
'wcf-order' => $order->get_id(),
|
84 |
-
'wcf-key' => $order->get_order_key(),
|
85 |
-
),
|
86 |
-
$order_recieve_url
|
87 |
-
);
|
88 |
-
}
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ );
|
93 |
-
|
94 |
-
return $order_recieve_url;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Cancel and redirect to checkout
|
99 |
-
*
|
100 |
-
* @param string $return_url url.
|
101 |
-
* @since 1.0.0
|
102 |
-
*/
|
103 |
-
function redirect_to_checkout_on_cancel( $return_url ) {
|
104 |
-
|
105 |
-
if ( _is_wcf_doing_checkout_ajax() ) {
|
106 |
-
|
107 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_post_data();
|
108 |
-
|
109 |
-
if ( ! $checkout_id ) {
|
110 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
111 |
-
}
|
112 |
-
} else {
|
113 |
-
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
114 |
-
}
|
115 |
-
|
116 |
-
if ( $checkout_id ) {
|
117 |
-
|
118 |
-
$return_url = add_query_arg(
|
119 |
-
array(
|
120 |
-
'cancel_order' => 'true',
|
121 |
-
'_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
|
122 |
-
),
|
123 |
-
get_permalink( $checkout_id )
|
124 |
-
);
|
125 |
-
}
|
126 |
-
|
127 |
-
return $return_url;
|
128 |
-
}
|
129 |
-
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Remove theme styles.
|
133 |
-
*
|
134 |
-
* @since 1.0.0
|
135 |
-
*/
|
136 |
-
function remove_theme_styles() {
|
137 |
-
|
138 |
-
if ( Cartflows_Compatibility::get_instance()->is_compatibility_theme_enabled() ) {
|
139 |
-
return;
|
140 |
-
}
|
141 |
-
|
142 |
-
// get all styles data.
|
143 |
-
global $wp_styles;
|
144 |
-
global $wp_scripts;
|
145 |
-
|
146 |
-
$get_stylesheet = 'themes/' . get_stylesheet() . '/';
|
147 |
-
$get_template = 'themes/' . get_template() . '/';
|
148 |
-
|
149 |
-
$remove_styles = apply_filters( 'cartflows_remove_theme_styles', true );
|
150 |
-
|
151 |
-
if ( $remove_styles ) {
|
152 |
-
|
153 |
-
// loop over all of the registered scripts..
|
154 |
-
foreach ( $wp_styles->registered as $handle => $data ) {
|
155 |
-
|
156 |
-
if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
|
157 |
-
|
158 |
-
// remove it.
|
159 |
-
wp_deregister_style( $handle );
|
160 |
-
wp_dequeue_style( $handle );
|
161 |
-
}
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
$remove_scripts = apply_filters( 'cartflows_remove_theme_scripts', true );
|
166 |
-
|
167 |
-
if ( $remove_scripts ) {
|
168 |
-
|
169 |
-
// loop over all of the registered scripts.
|
170 |
-
foreach ( $wp_scripts->registered as $handle => $data ) {
|
171 |
-
|
172 |
-
if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
|
173 |
-
|
174 |
-
// remove it.
|
175 |
-
wp_deregister_script( $handle );
|
176 |
-
wp_dequeue_script( $handle );
|
177 |
-
}
|
178 |
-
}
|
179 |
-
}
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Update main order data in transient.
|
185 |
-
*
|
186 |
-
* @param array $woo_styles new styles array.
|
187 |
-
* @since 1.0.0
|
188 |
-
* @return array.
|
189 |
-
*/
|
190 |
-
function woo_default_css( $woo_styles ) {
|
191 |
-
|
192 |
-
$woo_styles = array(
|
193 |
-
'woocommerce-layout' => array(
|
194 |
-
'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ),
|
195 |
-
'deps' => '',
|
196 |
-
'version' => WC_VERSION,
|
197 |
-
'media' => 'all',
|
198 |
-
'has_rtl' => true,
|
199 |
-
),
|
200 |
-
'woocommerce-smallscreen' => array(
|
201 |
-
'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ),
|
202 |
-
'deps' => 'woocommerce-layout',
|
203 |
-
'version' => WC_VERSION,
|
204 |
-
'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
|
205 |
-
'has_rtl' => true,
|
206 |
-
),
|
207 |
-
'woocommerce-general' => array(
|
208 |
-
'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ),
|
209 |
-
'deps' => '',
|
210 |
-
'version' => WC_VERSION,
|
211 |
-
'media' => 'all',
|
212 |
-
'has_rtl' => true,
|
213 |
-
),
|
214 |
-
);
|
215 |
-
|
216 |
-
return $woo_styles;
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Init Actions.
|
221 |
-
*
|
222 |
-
* @since 1.0.0
|
223 |
-
*/
|
224 |
-
function init_actions() {
|
225 |
-
|
226 |
-
$this->set_flow_session();
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Set flow session.
|
231 |
-
*
|
232 |
-
* @since 1.0.0
|
233 |
-
*/
|
234 |
-
function set_flow_session() {
|
235 |
-
|
236 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
237 |
-
|
238 |
-
add_action( 'wp_head', array( $this, 'noindex_flow' ) );
|
239 |
-
|
240 |
-
wcf()->utils->do_not_cache();
|
241 |
-
|
242 |
-
/* Set key to support pixel */
|
243 |
-
if ( isset( $_GET['wcf-key'] ) ) {
|
244 |
-
$_GET['key'] = $_GET['wcf-key'];
|
245 |
-
$_REQUEST['key'] = $_GET['wcf-key'];
|
246 |
-
}
|
247 |
-
|
248 |
-
if ( isset( $_GET['wcf-order'] ) ) {
|
249 |
-
$_GET['order'] = $_GET['wcf-order'];
|
250 |
-
$_REQUEST['order'] = $_GET['wcf-order'];
|
251 |
-
$_GET['order-received'] = $_GET['wcf-order'];
|
252 |
-
$_REQUEST['order-received'] = $_GET['wcf-order'];
|
253 |
-
}
|
254 |
-
}
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* Add noindex, nofollow.
|
259 |
-
*
|
260 |
-
* @since 1.0.0
|
261 |
-
*/
|
262 |
-
function noindex_flow() {
|
263 |
-
|
264 |
-
$common = Cartflows_Helper::get_common_settings();
|
265 |
-
|
266 |
-
if ( 'enable' === $common['disallow_indexing'] ) {
|
267 |
-
echo '<meta name="robots" content="noindex,nofollow">';
|
268 |
-
}
|
269 |
-
}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* WP Actions.
|
273 |
-
*
|
274 |
-
* @since 1.0.0
|
275 |
-
*/
|
276 |
-
function wp_actions() {
|
277 |
-
|
278 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
279 |
-
|
280 |
-
/* CSS Compatibility for All theme */
|
281 |
-
add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 );
|
282 |
-
|
283 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 );
|
284 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 );
|
285 |
-
|
286 |
-
/* Load woo templates from plugin */
|
287 |
-
add_filter( 'woocommerce_locate_template', array( $this, 'override_woo_template' ), 20, 3 );
|
288 |
-
|
289 |
-
/* Add version class to body in frontend. */
|
290 |
-
add_filter( 'body_class', array( $this, 'add_cartflows_lite_version_to_body' ) );
|
291 |
-
|
292 |
-
/* Remove the action applied by the Flatsome theme */
|
293 |
-
if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
|
294 |
-
$this->remove_flatsome_action();
|
295 |
-
}
|
296 |
-
}
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* Global flow scripts.
|
301 |
-
*
|
302 |
-
* @since 1.0.0
|
303 |
-
*/
|
304 |
-
function global_flow_scripts() {
|
305 |
-
|
306 |
-
global $post;
|
307 |
-
|
308 |
-
$flow = get_post_meta( $post->ID, 'wcf-flow-id', true );
|
309 |
-
$current_step = $post->ID;
|
310 |
-
$next_step_link = '';
|
311 |
-
$compatibility = Cartflows_Compatibility::get_instance();
|
312 |
-
|
313 |
-
if ( _is_wcf_landing_type() ) {
|
314 |
-
|
315 |
-
$next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step );
|
316 |
-
$next_step_link = get_permalink( $next_step_id );
|
317 |
-
}
|
318 |
-
|
319 |
-
$localize = array(
|
320 |
-
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
321 |
-
'is_pb_preview' => $compatibility->is_page_builder_preview(),
|
322 |
-
'current_theme' => $compatibility->get_current_theme(),
|
323 |
-
'current_flow' => $flow,
|
324 |
-
'current_step' => $current_step,
|
325 |
-
'next_step' => $next_step_link,
|
326 |
-
);
|
327 |
-
|
328 |
-
wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
|
329 |
-
|
330 |
-
wp_enqueue_style( 'wcf-frontend-global', CARTFLOWS_URL . 'assets/css/frontend.css', array(), CARTFLOWS_VER );
|
331 |
-
wp_style_add_data( 'wcf-frontend-global', 'rtl', 'replace' );
|
332 |
-
|
333 |
-
wp_enqueue_script(
|
334 |
-
'wcf-frontend-global',
|
335 |
-
CARTFLOWS_URL . 'assets/js/frontend.js',
|
336 |
-
array( 'jquery' ),
|
337 |
-
CARTFLOWS_VER,
|
338 |
-
true
|
339 |
-
);
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Override woo templates.
|
344 |
-
*
|
345 |
-
* @param string $template new Template full path.
|
346 |
-
* @param string $template_name Template name.
|
347 |
-
* @param string $template_path Template Path.
|
348 |
-
* @since 1.1.5
|
349 |
-
* @return string.
|
350 |
-
*/
|
351 |
-
function override_woo_template( $template, $template_name, $template_path ) {
|
352 |
-
|
353 |
-
global $woocommerce;
|
354 |
-
|
355 |
-
$_template = $template;
|
356 |
-
|
357 |
-
$plugin_path = CARTFLOWS_DIR . 'woocommerce/template/';
|
358 |
-
|
359 |
-
if ( file_exists( $plugin_path . $template_name ) ) {
|
360 |
-
$template = $plugin_path . $template_name;
|
361 |
-
}
|
362 |
-
|
363 |
-
if ( ! $template ) {
|
364 |
-
$template = $_template;
|
365 |
-
}
|
366 |
-
|
367 |
-
return $template;
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Remove the action applied by the Flatsome theme.
|
372 |
-
*
|
373 |
-
* @since 1.1.5
|
374 |
-
* @return void.
|
375 |
-
*/
|
376 |
-
function remove_flatsome_action() {
|
377 |
-
|
378 |
-
// Remove action where flatsome dequeued the woocommerce's default styles.
|
379 |
-
remove_action( 'wp_enqueue_scripts', 'flatsome_woocommerce_scripts_styles', 98 );
|
380 |
-
}
|
381 |
-
|
382 |
-
/**
|
383 |
-
* Add version class to body in frontend.
|
384 |
-
*
|
385 |
-
* @since 1.1.5
|
386 |
-
* @param array $classes classes.
|
387 |
-
* @return array $classes classes.
|
388 |
-
*/
|
389 |
-
function add_cartflows_lite_version_to_body( $classes ) {
|
390 |
-
|
391 |
-
$classes[] = 'cartflows-' . CARTFLOWS_VER;
|
392 |
-
|
393 |
-
return $classes;
|
394 |
-
|
395 |
-
}
|
396 |
-
}
|
397 |
-
|
398 |
-
/**
|
399 |
-
* Prepare if class 'Cartflows_Frontend' exist.
|
400 |
-
* Kicking this off by calling 'get_instance()' method
|
401 |
-
*/
|
402 |
-
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 |
+
/* Enqueue global required scripts */
|
39 |
+
add_action( 'wp', array( $this, 'wp_actions' ), 55 );
|
40 |
+
|
41 |
+
/* Modify the checkout order received url to go thank you page in our flow */
|
42 |
+
add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Redirect to thank page if upsell not exists
|
47 |
+
*
|
48 |
+
* @param string $order_recieve_url url.
|
49 |
+
* @param object $order order object.
|
50 |
+
* @since 1.0.0
|
51 |
+
*/
|
52 |
+
function redirect_to_thankyou_page( $order_recieve_url, $order ) {
|
53 |
+
|
54 |
+
/* Only for thank you page */
|
55 |
+
wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ );
|
56 |
+
wcf()->logger->log( 'Only for thank you page' );
|
57 |
+
|
58 |
+
if ( wcf()->flow->is_thankyou_page_exists( $order ) ) {
|
59 |
+
|
60 |
+
if ( _is_wcf_doing_checkout_ajax() ) {
|
61 |
+
|
62 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_post_data();
|
63 |
+
|
64 |
+
if ( ! $checkout_id ) {
|
65 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
66 |
+
}
|
67 |
+
} else {
|
68 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
69 |
+
}
|
70 |
+
|
71 |
+
wcf()->logger->log( 'Checkout ID : ' . $checkout_id );
|
72 |
+
|
73 |
+
if ( $checkout_id ) {
|
74 |
+
|
75 |
+
$thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order );
|
76 |
+
|
77 |
+
if ( $thankyou_step_id ) {
|
78 |
+
|
79 |
+
$order_recieve_url = get_permalink( $thankyou_step_id );
|
80 |
+
|
81 |
+
$order_recieve_url = add_query_arg(
|
82 |
+
array(
|
83 |
+
'wcf-order' => $order->get_id(),
|
84 |
+
'wcf-key' => $order->get_order_key(),
|
85 |
+
),
|
86 |
+
$order_recieve_url
|
87 |
+
);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ );
|
93 |
+
|
94 |
+
return $order_recieve_url;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Cancel and redirect to checkout
|
99 |
+
*
|
100 |
+
* @param string $return_url url.
|
101 |
+
* @since 1.0.0
|
102 |
+
*/
|
103 |
+
function redirect_to_checkout_on_cancel( $return_url ) {
|
104 |
+
|
105 |
+
if ( _is_wcf_doing_checkout_ajax() ) {
|
106 |
+
|
107 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_post_data();
|
108 |
+
|
109 |
+
if ( ! $checkout_id ) {
|
110 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
111 |
+
}
|
112 |
+
} else {
|
113 |
+
$checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() );
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( $checkout_id ) {
|
117 |
+
|
118 |
+
$return_url = add_query_arg(
|
119 |
+
array(
|
120 |
+
'cancel_order' => 'true',
|
121 |
+
'_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ),
|
122 |
+
),
|
123 |
+
get_permalink( $checkout_id )
|
124 |
+
);
|
125 |
+
}
|
126 |
+
|
127 |
+
return $return_url;
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Remove theme styles.
|
133 |
+
*
|
134 |
+
* @since 1.0.0
|
135 |
+
*/
|
136 |
+
function remove_theme_styles() {
|
137 |
+
|
138 |
+
if ( Cartflows_Compatibility::get_instance()->is_compatibility_theme_enabled() ) {
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
// get all styles data.
|
143 |
+
global $wp_styles;
|
144 |
+
global $wp_scripts;
|
145 |
+
|
146 |
+
$get_stylesheet = 'themes/' . get_stylesheet() . '/';
|
147 |
+
$get_template = 'themes/' . get_template() . '/';
|
148 |
+
|
149 |
+
$remove_styles = apply_filters( 'cartflows_remove_theme_styles', true );
|
150 |
+
|
151 |
+
if ( $remove_styles ) {
|
152 |
+
|
153 |
+
// loop over all of the registered scripts..
|
154 |
+
foreach ( $wp_styles->registered as $handle => $data ) {
|
155 |
+
|
156 |
+
if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
|
157 |
+
|
158 |
+
// remove it.
|
159 |
+
wp_deregister_style( $handle );
|
160 |
+
wp_dequeue_style( $handle );
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
$remove_scripts = apply_filters( 'cartflows_remove_theme_scripts', true );
|
166 |
+
|
167 |
+
if ( $remove_scripts ) {
|
168 |
+
|
169 |
+
// loop over all of the registered scripts.
|
170 |
+
foreach ( $wp_scripts->registered as $handle => $data ) {
|
171 |
+
|
172 |
+
if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) {
|
173 |
+
|
174 |
+
// remove it.
|
175 |
+
wp_deregister_script( $handle );
|
176 |
+
wp_dequeue_script( $handle );
|
177 |
+
}
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Update main order data in transient.
|
185 |
+
*
|
186 |
+
* @param array $woo_styles new styles array.
|
187 |
+
* @since 1.0.0
|
188 |
+
* @return array.
|
189 |
+
*/
|
190 |
+
function woo_default_css( $woo_styles ) {
|
191 |
+
|
192 |
+
$woo_styles = array(
|
193 |
+
'woocommerce-layout' => array(
|
194 |
+
'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ),
|
195 |
+
'deps' => '',
|
196 |
+
'version' => WC_VERSION,
|
197 |
+
'media' => 'all',
|
198 |
+
'has_rtl' => true,
|
199 |
+
),
|
200 |
+
'woocommerce-smallscreen' => array(
|
201 |
+
'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ),
|
202 |
+
'deps' => 'woocommerce-layout',
|
203 |
+
'version' => WC_VERSION,
|
204 |
+
'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')',
|
205 |
+
'has_rtl' => true,
|
206 |
+
),
|
207 |
+
'woocommerce-general' => array(
|
208 |
+
'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ),
|
209 |
+
'deps' => '',
|
210 |
+
'version' => WC_VERSION,
|
211 |
+
'media' => 'all',
|
212 |
+
'has_rtl' => true,
|
213 |
+
),
|
214 |
+
);
|
215 |
+
|
216 |
+
return $woo_styles;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Init Actions.
|
221 |
+
*
|
222 |
+
* @since 1.0.0
|
223 |
+
*/
|
224 |
+
function init_actions() {
|
225 |
+
|
226 |
+
$this->set_flow_session();
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Set flow session.
|
231 |
+
*
|
232 |
+
* @since 1.0.0
|
233 |
+
*/
|
234 |
+
function set_flow_session() {
|
235 |
+
|
236 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
237 |
+
|
238 |
+
add_action( 'wp_head', array( $this, 'noindex_flow' ) );
|
239 |
+
|
240 |
+
wcf()->utils->do_not_cache();
|
241 |
+
|
242 |
+
/* Set key to support pixel */
|
243 |
+
if ( isset( $_GET['wcf-key'] ) ) {
|
244 |
+
$_GET['key'] = $_GET['wcf-key'];
|
245 |
+
$_REQUEST['key'] = $_GET['wcf-key'];
|
246 |
+
}
|
247 |
+
|
248 |
+
if ( isset( $_GET['wcf-order'] ) ) {
|
249 |
+
$_GET['order'] = $_GET['wcf-order'];
|
250 |
+
$_REQUEST['order'] = $_GET['wcf-order'];
|
251 |
+
$_GET['order-received'] = $_GET['wcf-order'];
|
252 |
+
$_REQUEST['order-received'] = $_GET['wcf-order'];
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Add noindex, nofollow.
|
259 |
+
*
|
260 |
+
* @since 1.0.0
|
261 |
+
*/
|
262 |
+
function noindex_flow() {
|
263 |
+
|
264 |
+
$common = Cartflows_Helper::get_common_settings();
|
265 |
+
|
266 |
+
if ( 'enable' === $common['disallow_indexing'] ) {
|
267 |
+
echo '<meta name="robots" content="noindex,nofollow">';
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* WP Actions.
|
273 |
+
*
|
274 |
+
* @since 1.0.0
|
275 |
+
*/
|
276 |
+
function wp_actions() {
|
277 |
+
|
278 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
279 |
+
|
280 |
+
/* CSS Compatibility for All theme */
|
281 |
+
add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 );
|
282 |
+
|
283 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 );
|
284 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 );
|
285 |
+
|
286 |
+
/* Load woo templates from plugin */
|
287 |
+
add_filter( 'woocommerce_locate_template', array( $this, 'override_woo_template' ), 20, 3 );
|
288 |
+
|
289 |
+
/* Add version class to body in frontend. */
|
290 |
+
add_filter( 'body_class', array( $this, 'add_cartflows_lite_version_to_body' ) );
|
291 |
+
|
292 |
+
/* Remove the action applied by the Flatsome theme */
|
293 |
+
if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
|
294 |
+
$this->remove_flatsome_action();
|
295 |
+
}
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Global flow scripts.
|
301 |
+
*
|
302 |
+
* @since 1.0.0
|
303 |
+
*/
|
304 |
+
function global_flow_scripts() {
|
305 |
+
|
306 |
+
global $post;
|
307 |
+
|
308 |
+
$flow = get_post_meta( $post->ID, 'wcf-flow-id', true );
|
309 |
+
$current_step = $post->ID;
|
310 |
+
$next_step_link = '';
|
311 |
+
$compatibility = Cartflows_Compatibility::get_instance();
|
312 |
+
|
313 |
+
if ( _is_wcf_landing_type() ) {
|
314 |
+
|
315 |
+
$next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step );
|
316 |
+
$next_step_link = get_permalink( $next_step_id );
|
317 |
+
}
|
318 |
+
|
319 |
+
$localize = array(
|
320 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
321 |
+
'is_pb_preview' => $compatibility->is_page_builder_preview(),
|
322 |
+
'current_theme' => $compatibility->get_current_theme(),
|
323 |
+
'current_flow' => $flow,
|
324 |
+
'current_step' => $current_step,
|
325 |
+
'next_step' => $next_step_link,
|
326 |
+
);
|
327 |
+
|
328 |
+
wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) );
|
329 |
+
|
330 |
+
wp_enqueue_style( 'wcf-frontend-global', CARTFLOWS_URL . 'assets/css/frontend.css', array(), CARTFLOWS_VER );
|
331 |
+
wp_style_add_data( 'wcf-frontend-global', 'rtl', 'replace' );
|
332 |
+
|
333 |
+
wp_enqueue_script(
|
334 |
+
'wcf-frontend-global',
|
335 |
+
CARTFLOWS_URL . 'assets/js/frontend.js',
|
336 |
+
array( 'jquery' ),
|
337 |
+
CARTFLOWS_VER,
|
338 |
+
true
|
339 |
+
);
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Override woo templates.
|
344 |
+
*
|
345 |
+
* @param string $template new Template full path.
|
346 |
+
* @param string $template_name Template name.
|
347 |
+
* @param string $template_path Template Path.
|
348 |
+
* @since 1.1.5
|
349 |
+
* @return string.
|
350 |
+
*/
|
351 |
+
function override_woo_template( $template, $template_name, $template_path ) {
|
352 |
+
|
353 |
+
global $woocommerce;
|
354 |
+
|
355 |
+
$_template = $template;
|
356 |
+
|
357 |
+
$plugin_path = CARTFLOWS_DIR . 'woocommerce/template/';
|
358 |
+
|
359 |
+
if ( file_exists( $plugin_path . $template_name ) ) {
|
360 |
+
$template = $plugin_path . $template_name;
|
361 |
+
}
|
362 |
+
|
363 |
+
if ( ! $template ) {
|
364 |
+
$template = $_template;
|
365 |
+
}
|
366 |
+
|
367 |
+
return $template;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Remove the action applied by the Flatsome theme.
|
372 |
+
*
|
373 |
+
* @since 1.1.5
|
374 |
+
* @return void.
|
375 |
+
*/
|
376 |
+
function remove_flatsome_action() {
|
377 |
+
|
378 |
+
// Remove action where flatsome dequeued the woocommerce's default styles.
|
379 |
+
remove_action( 'wp_enqueue_scripts', 'flatsome_woocommerce_scripts_styles', 98 );
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Add version class to body in frontend.
|
384 |
+
*
|
385 |
+
* @since 1.1.5
|
386 |
+
* @param array $classes classes.
|
387 |
+
* @return array $classes classes.
|
388 |
+
*/
|
389 |
+
function add_cartflows_lite_version_to_body( $classes ) {
|
390 |
+
|
391 |
+
$classes[] = 'cartflows-' . CARTFLOWS_VER;
|
392 |
+
|
393 |
+
return $classes;
|
394 |
+
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Prepare if class 'Cartflows_Frontend' exist.
|
400 |
+
* Kicking this off by calling 'get_instance()' method
|
401 |
+
*/
|
402 |
+
Cartflows_Frontend::get_instance();
|
classes/class-cartflows-functions.php
CHANGED
@@ -1,388 +1,388 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Functions.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit; // Exit if accessed directly.
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Check if cartflows pro activated.
|
14 |
-
*
|
15 |
-
* @since 1.0.0
|
16 |
-
*/
|
17 |
-
function _is_cartflows_pro() {
|
18 |
-
|
19 |
-
if ( defined( 'CARTFLOWS_PRO_FILE' ) ) {
|
20 |
-
return true;
|
21 |
-
}
|
22 |
-
|
23 |
-
return false;
|
24 |
-
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Returns step id.
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
*/
|
32 |
-
function _get_wcf_post_id() {
|
33 |
-
|
34 |
-
global $post;
|
35 |
-
|
36 |
-
if ( isset( $post->ID ) ) {
|
37 |
-
return $post->ID;
|
38 |
-
}
|
39 |
-
|
40 |
-
return 0;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Returns step id.
|
45 |
-
*
|
46 |
-
* @since 1.0.0
|
47 |
-
*/
|
48 |
-
function _get_wcf_step_id() {
|
49 |
-
|
50 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
51 |
-
|
52 |
-
global $post;
|
53 |
-
|
54 |
-
return $post->ID;
|
55 |
-
}
|
56 |
-
|
57 |
-
return false;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Check if it is a landing page?
|
62 |
-
*
|
63 |
-
* @since 1.0.0
|
64 |
-
*/
|
65 |
-
function _is_wcf_landing_type() {
|
66 |
-
|
67 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
68 |
-
|
69 |
-
global $post;
|
70 |
-
|
71 |
-
if ( 'landing' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
72 |
-
|
73 |
-
return true;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
return false;
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Returns landing id.
|
82 |
-
*
|
83 |
-
* @since 1.0.0
|
84 |
-
*/
|
85 |
-
function _get_wcf_landing_id() {
|
86 |
-
|
87 |
-
if ( _is_wcf_landing_type() ) {
|
88 |
-
|
89 |
-
global $post;
|
90 |
-
|
91 |
-
return $post->ID;
|
92 |
-
}
|
93 |
-
|
94 |
-
return false;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Is custom checkout?
|
99 |
-
*
|
100 |
-
* @param int $checkout_id checkout ID.
|
101 |
-
* @since 1.0.0
|
102 |
-
*/
|
103 |
-
function _is_wcf_meta_custom_checkout( $checkout_id ) {
|
104 |
-
|
105 |
-
$is_custom = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-custom-checkout-fields' );
|
106 |
-
|
107 |
-
if ( 'yes' === $is_custom ) {
|
108 |
-
|
109 |
-
return true;
|
110 |
-
}
|
111 |
-
|
112 |
-
return false;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Check if page is cartflow checkout.
|
117 |
-
*
|
118 |
-
* @since 1.0.0
|
119 |
-
* @return bool
|
120 |
-
*/
|
121 |
-
function _is_wcf_checkout_type() {
|
122 |
-
|
123 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
124 |
-
|
125 |
-
global $post;
|
126 |
-
|
127 |
-
if ( 'checkout' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
128 |
-
|
129 |
-
return true;
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
return false;
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Check if AJAX call is in progress.
|
138 |
-
*
|
139 |
-
* @since 1.0.0
|
140 |
-
* @return bool
|
141 |
-
*/
|
142 |
-
function _is_wcf_doing_checkout_ajax() {
|
143 |
-
|
144 |
-
if ( wp_doing_ajax() ) {
|
145 |
-
|
146 |
-
if ( isset( $_GET['wc-ajax'] ) &&
|
147 |
-
'checkout' === $_GET['wc-ajax'] &&
|
148 |
-
isset( $_POST['_wcf_checkout_id'] )
|
149 |
-
) {
|
150 |
-
return true;
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
return false;
|
155 |
-
}
|
156 |
-
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Returns checkout ID.
|
160 |
-
*
|
161 |
-
* @since 1.0.0
|
162 |
-
* @return int/bool
|
163 |
-
*/
|
164 |
-
function _get_wcf_checkout_id() {
|
165 |
-
|
166 |
-
if ( _is_wcf_checkout_type() ) {
|
167 |
-
|
168 |
-
global $post;
|
169 |
-
|
170 |
-
return $post->ID;
|
171 |
-
}
|
172 |
-
|
173 |
-
return false;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Check if it is checkout shortcode.
|
178 |
-
*
|
179 |
-
* @since 1.0.0
|
180 |
-
* @return bool
|
181 |
-
*/
|
182 |
-
function _is_wcf_checkout_shortcode() {
|
183 |
-
|
184 |
-
global $post;
|
185 |
-
|
186 |
-
if ( ! empty( $post ) && has_shortcode( $post->post_content, 'cartflows_checkout' ) ) {
|
187 |
-
|
188 |
-
return true;
|
189 |
-
}
|
190 |
-
|
191 |
-
return false;
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Check if it is checkout shortcode.
|
196 |
-
*
|
197 |
-
* @since 1.0.0
|
198 |
-
* @param string $content shortcode content.
|
199 |
-
* @return bool
|
200 |
-
*/
|
201 |
-
function _get_wcf_checkout_id_from_shortcode( $content = '' ) {
|
202 |
-
|
203 |
-
$checkout_id = 0;
|
204 |
-
|
205 |
-
if ( ! empty( $content ) ) {
|
206 |
-
|
207 |
-
$regex_pattern = get_shortcode_regex( array( 'cartflows_checkout' ) );
|
208 |
-
|
209 |
-
preg_match( '/' . $regex_pattern . '/s', $content, $regex_matches );
|
210 |
-
|
211 |
-
if ( ! empty( $regex_matches ) ) {
|
212 |
-
|
213 |
-
if ( 'cartflows_checkout' == $regex_matches[2] ) {
|
214 |
-
|
215 |
-
$attribure_str = str_replace( ' ', '&', trim( $regex_matches[3] ) );
|
216 |
-
$attribure_str = str_replace( '"', '', $attribure_str );
|
217 |
-
|
218 |
-
$attributes = wp_parse_args( $attribure_str );
|
219 |
-
|
220 |
-
if ( isset( $attributes['id'] ) ) {
|
221 |
-
$checkout_id = $attributes['id'];
|
222 |
-
}
|
223 |
-
}
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
227 |
-
return $checkout_id;
|
228 |
-
}
|
229 |
-
|
230 |
-
/**
|
231 |
-
* Check if post type is upsell.
|
232 |
-
*
|
233 |
-
* @since 1.0.0
|
234 |
-
* @return bool
|
235 |
-
*/
|
236 |
-
function _is_wcf_upsell_type() {
|
237 |
-
|
238 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
239 |
-
|
240 |
-
global $post;
|
241 |
-
|
242 |
-
if ( 'upsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
243 |
-
|
244 |
-
return true;
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
-
return false;
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* Returns upsell ID.
|
253 |
-
*
|
254 |
-
* @since 1.0.0
|
255 |
-
* @return int/bool
|
256 |
-
*/
|
257 |
-
function _get_wcf_upsell_id() {
|
258 |
-
|
259 |
-
if ( _is_wcf_upsell_type() ) {
|
260 |
-
|
261 |
-
global $post;
|
262 |
-
|
263 |
-
return $post->ID;
|
264 |
-
}
|
265 |
-
|
266 |
-
return false;
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Check if post is of type downsell.
|
271 |
-
*
|
272 |
-
* @since 1.0.0
|
273 |
-
* @return int/bool
|
274 |
-
*/
|
275 |
-
function _is_wcf_downsell_type() {
|
276 |
-
|
277 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
278 |
-
|
279 |
-
global $post;
|
280 |
-
|
281 |
-
if ( 'downsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
282 |
-
|
283 |
-
return true;
|
284 |
-
}
|
285 |
-
}
|
286 |
-
|
287 |
-
return false;
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Get downsell page ID.
|
292 |
-
*
|
293 |
-
* @since 1.0.0
|
294 |
-
* @return int/bool
|
295 |
-
*/
|
296 |
-
function _get_wcf_downsell_id() {
|
297 |
-
|
298 |
-
if ( _is_wcf_downsell_type() ) {
|
299 |
-
|
300 |
-
global $post;
|
301 |
-
|
302 |
-
return $post->ID;
|
303 |
-
}
|
304 |
-
|
305 |
-
return false;
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* Check if page is of thank you type.
|
310 |
-
*
|
311 |
-
* @since 1.0.0
|
312 |
-
* @return int/bool
|
313 |
-
*/
|
314 |
-
function _is_wcf_thankyou_type() {
|
315 |
-
|
316 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
317 |
-
|
318 |
-
global $post;
|
319 |
-
|
320 |
-
if ( 'thankyou' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
321 |
-
|
322 |
-
return true;
|
323 |
-
}
|
324 |
-
}
|
325 |
-
|
326 |
-
return false;
|
327 |
-
}
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Get thank you page ID.
|
331 |
-
*
|
332 |
-
* @since 1.0.0
|
333 |
-
* @return int/bool
|
334 |
-
*/
|
335 |
-
function _get_wcf_thankyou_id() {
|
336 |
-
|
337 |
-
if ( _is_wcf_thankyou_type() ) {
|
338 |
-
|
339 |
-
global $post;
|
340 |
-
|
341 |
-
return $post->ID;
|
342 |
-
}
|
343 |
-
|
344 |
-
return false;
|
345 |
-
}
|
346 |
-
|
347 |
-
|
348 |
-
/**
|
349 |
-
* Check if post type is upsell.
|
350 |
-
*
|
351 |
-
* @since 1.0.0
|
352 |
-
* @return bool
|
353 |
-
*/
|
354 |
-
function _is_wcf_base_offer_type() {
|
355 |
-
|
356 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
357 |
-
|
358 |
-
global $post;
|
359 |
-
|
360 |
-
$step_type = get_post_meta( $post->ID, 'wcf-step-type', true );
|
361 |
-
|
362 |
-
if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
|
363 |
-
|
364 |
-
return true;
|
365 |
-
}
|
366 |
-
}
|
367 |
-
|
368 |
-
return false;
|
369 |
-
}
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Returns upsell ID.
|
373 |
-
*
|
374 |
-
* @since 1.0.0
|
375 |
-
* @return int/bool
|
376 |
-
*/
|
377 |
-
function _get_wcf_base_offer_id() {
|
378 |
-
|
379 |
-
if ( _is_wcf_base_offer_type() ) {
|
380 |
-
|
381 |
-
global $post;
|
382 |
-
|
383 |
-
return $post->ID;
|
384 |
-
}
|
385 |
-
|
386 |
-
return false;
|
387 |
-
}
|
388 |
-
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Functions.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Check if cartflows pro activated.
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
function _is_cartflows_pro() {
|
18 |
+
|
19 |
+
if ( defined( 'CARTFLOWS_PRO_FILE' ) ) {
|
20 |
+
return true;
|
21 |
+
}
|
22 |
+
|
23 |
+
return false;
|
24 |
+
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Returns step id.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
*/
|
32 |
+
function _get_wcf_post_id() {
|
33 |
+
|
34 |
+
global $post;
|
35 |
+
|
36 |
+
if ( isset( $post->ID ) ) {
|
37 |
+
return $post->ID;
|
38 |
+
}
|
39 |
+
|
40 |
+
return 0;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Returns step id.
|
45 |
+
*
|
46 |
+
* @since 1.0.0
|
47 |
+
*/
|
48 |
+
function _get_wcf_step_id() {
|
49 |
+
|
50 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
51 |
+
|
52 |
+
global $post;
|
53 |
+
|
54 |
+
return $post->ID;
|
55 |
+
}
|
56 |
+
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Check if it is a landing page?
|
62 |
+
*
|
63 |
+
* @since 1.0.0
|
64 |
+
*/
|
65 |
+
function _is_wcf_landing_type() {
|
66 |
+
|
67 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
68 |
+
|
69 |
+
global $post;
|
70 |
+
|
71 |
+
if ( 'landing' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
72 |
+
|
73 |
+
return true;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Returns landing id.
|
82 |
+
*
|
83 |
+
* @since 1.0.0
|
84 |
+
*/
|
85 |
+
function _get_wcf_landing_id() {
|
86 |
+
|
87 |
+
if ( _is_wcf_landing_type() ) {
|
88 |
+
|
89 |
+
global $post;
|
90 |
+
|
91 |
+
return $post->ID;
|
92 |
+
}
|
93 |
+
|
94 |
+
return false;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Is custom checkout?
|
99 |
+
*
|
100 |
+
* @param int $checkout_id checkout ID.
|
101 |
+
* @since 1.0.0
|
102 |
+
*/
|
103 |
+
function _is_wcf_meta_custom_checkout( $checkout_id ) {
|
104 |
+
|
105 |
+
$is_custom = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-custom-checkout-fields' );
|
106 |
+
|
107 |
+
if ( 'yes' === $is_custom ) {
|
108 |
+
|
109 |
+
return true;
|
110 |
+
}
|
111 |
+
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Check if page is cartflow checkout.
|
117 |
+
*
|
118 |
+
* @since 1.0.0
|
119 |
+
* @return bool
|
120 |
+
*/
|
121 |
+
function _is_wcf_checkout_type() {
|
122 |
+
|
123 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
124 |
+
|
125 |
+
global $post;
|
126 |
+
|
127 |
+
if ( 'checkout' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
128 |
+
|
129 |
+
return true;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
return false;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Check if AJAX call is in progress.
|
138 |
+
*
|
139 |
+
* @since 1.0.0
|
140 |
+
* @return bool
|
141 |
+
*/
|
142 |
+
function _is_wcf_doing_checkout_ajax() {
|
143 |
+
|
144 |
+
if ( wp_doing_ajax() ) {
|
145 |
+
|
146 |
+
if ( isset( $_GET['wc-ajax'] ) &&
|
147 |
+
'checkout' === $_GET['wc-ajax'] &&
|
148 |
+
isset( $_POST['_wcf_checkout_id'] )
|
149 |
+
) {
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
return false;
|
155 |
+
}
|
156 |
+
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Returns checkout ID.
|
160 |
+
*
|
161 |
+
* @since 1.0.0
|
162 |
+
* @return int/bool
|
163 |
+
*/
|
164 |
+
function _get_wcf_checkout_id() {
|
165 |
+
|
166 |
+
if ( _is_wcf_checkout_type() ) {
|
167 |
+
|
168 |
+
global $post;
|
169 |
+
|
170 |
+
return $post->ID;
|
171 |
+
}
|
172 |
+
|
173 |
+
return false;
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Check if it is checkout shortcode.
|
178 |
+
*
|
179 |
+
* @since 1.0.0
|
180 |
+
* @return bool
|
181 |
+
*/
|
182 |
+
function _is_wcf_checkout_shortcode() {
|
183 |
+
|
184 |
+
global $post;
|
185 |
+
|
186 |
+
if ( ! empty( $post ) && has_shortcode( $post->post_content, 'cartflows_checkout' ) ) {
|
187 |
+
|
188 |
+
return true;
|
189 |
+
}
|
190 |
+
|
191 |
+
return false;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Check if it is checkout shortcode.
|
196 |
+
*
|
197 |
+
* @since 1.0.0
|
198 |
+
* @param string $content shortcode content.
|
199 |
+
* @return bool
|
200 |
+
*/
|
201 |
+
function _get_wcf_checkout_id_from_shortcode( $content = '' ) {
|
202 |
+
|
203 |
+
$checkout_id = 0;
|
204 |
+
|
205 |
+
if ( ! empty( $content ) ) {
|
206 |
+
|
207 |
+
$regex_pattern = get_shortcode_regex( array( 'cartflows_checkout' ) );
|
208 |
+
|
209 |
+
preg_match( '/' . $regex_pattern . '/s', $content, $regex_matches );
|
210 |
+
|
211 |
+
if ( ! empty( $regex_matches ) ) {
|
212 |
+
|
213 |
+
if ( 'cartflows_checkout' == $regex_matches[2] ) {
|
214 |
+
|
215 |
+
$attribure_str = str_replace( ' ', '&', trim( $regex_matches[3] ) );
|
216 |
+
$attribure_str = str_replace( '"', '', $attribure_str );
|
217 |
+
|
218 |
+
$attributes = wp_parse_args( $attribure_str );
|
219 |
+
|
220 |
+
if ( isset( $attributes['id'] ) ) {
|
221 |
+
$checkout_id = $attributes['id'];
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
return $checkout_id;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Check if post type is upsell.
|
232 |
+
*
|
233 |
+
* @since 1.0.0
|
234 |
+
* @return bool
|
235 |
+
*/
|
236 |
+
function _is_wcf_upsell_type() {
|
237 |
+
|
238 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
239 |
+
|
240 |
+
global $post;
|
241 |
+
|
242 |
+
if ( 'upsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
243 |
+
|
244 |
+
return true;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
return false;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Returns upsell ID.
|
253 |
+
*
|
254 |
+
* @since 1.0.0
|
255 |
+
* @return int/bool
|
256 |
+
*/
|
257 |
+
function _get_wcf_upsell_id() {
|
258 |
+
|
259 |
+
if ( _is_wcf_upsell_type() ) {
|
260 |
+
|
261 |
+
global $post;
|
262 |
+
|
263 |
+
return $post->ID;
|
264 |
+
}
|
265 |
+
|
266 |
+
return false;
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Check if post is of type downsell.
|
271 |
+
*
|
272 |
+
* @since 1.0.0
|
273 |
+
* @return int/bool
|
274 |
+
*/
|
275 |
+
function _is_wcf_downsell_type() {
|
276 |
+
|
277 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
278 |
+
|
279 |
+
global $post;
|
280 |
+
|
281 |
+
if ( 'downsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
282 |
+
|
283 |
+
return true;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
return false;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Get downsell page ID.
|
292 |
+
*
|
293 |
+
* @since 1.0.0
|
294 |
+
* @return int/bool
|
295 |
+
*/
|
296 |
+
function _get_wcf_downsell_id() {
|
297 |
+
|
298 |
+
if ( _is_wcf_downsell_type() ) {
|
299 |
+
|
300 |
+
global $post;
|
301 |
+
|
302 |
+
return $post->ID;
|
303 |
+
}
|
304 |
+
|
305 |
+
return false;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Check if page is of thank you type.
|
310 |
+
*
|
311 |
+
* @since 1.0.0
|
312 |
+
* @return int/bool
|
313 |
+
*/
|
314 |
+
function _is_wcf_thankyou_type() {
|
315 |
+
|
316 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
317 |
+
|
318 |
+
global $post;
|
319 |
+
|
320 |
+
if ( 'thankyou' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) {
|
321 |
+
|
322 |
+
return true;
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
return false;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Get thank you page ID.
|
331 |
+
*
|
332 |
+
* @since 1.0.0
|
333 |
+
* @return int/bool
|
334 |
+
*/
|
335 |
+
function _get_wcf_thankyou_id() {
|
336 |
+
|
337 |
+
if ( _is_wcf_thankyou_type() ) {
|
338 |
+
|
339 |
+
global $post;
|
340 |
+
|
341 |
+
return $post->ID;
|
342 |
+
}
|
343 |
+
|
344 |
+
return false;
|
345 |
+
}
|
346 |
+
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Check if post type is upsell.
|
350 |
+
*
|
351 |
+
* @since 1.0.0
|
352 |
+
* @return bool
|
353 |
+
*/
|
354 |
+
function _is_wcf_base_offer_type() {
|
355 |
+
|
356 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
357 |
+
|
358 |
+
global $post;
|
359 |
+
|
360 |
+
$step_type = get_post_meta( $post->ID, 'wcf-step-type', true );
|
361 |
+
|
362 |
+
if ( 'upsell' === $step_type || 'downsell' === $step_type ) {
|
363 |
+
|
364 |
+
return true;
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
return false;
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Returns upsell ID.
|
373 |
+
*
|
374 |
+
* @since 1.0.0
|
375 |
+
* @return int/bool
|
376 |
+
*/
|
377 |
+
function _get_wcf_base_offer_id() {
|
378 |
+
|
379 |
+
if ( _is_wcf_base_offer_type() ) {
|
380 |
+
|
381 |
+
global $post;
|
382 |
+
|
383 |
+
return $post->ID;
|
384 |
+
}
|
385 |
+
|
386 |
+
return false;
|
387 |
+
}
|
388 |
+
|
classes/class-cartflows-helper.php
CHANGED
@@ -1,432 +1,458 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CARTFLOWS Helper.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit; // Exit if accessed directly.
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Cartflows_Helper.
|
14 |
-
*/
|
15 |
-
class Cartflows_Helper {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Common global data
|
19 |
-
*
|
20 |
-
* @var zapier
|
21 |
-
*/
|
22 |
-
private static $common = null;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Installed Plugins
|
26 |
-
*
|
27 |
-
* @since 1.1.4
|
28 |
-
*
|
29 |
-
* @access private
|
30 |
-
* @var array Installed plugins list.
|
31 |
-
*/
|
32 |
-
private static $installed_plugins = null;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Checkout Fields
|
36 |
-
*
|
37 |
-
* @var checkout_fields
|
38 |
-
*/
|
39 |
-
private static $checkout_fields = null;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Returns an option from the database for
|
43 |
-
* the admin settings page.
|
44 |
-
*
|
45 |
-
* @param string $key The option key.
|
46 |
-
* @param mixed $default Option default value if option is not available.
|
47 |
-
* @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
|
48 |
-
* @return string Return the option value
|
49 |
-
*/
|
50 |
-
public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
|
51 |
-
|
52 |
-
// Get the site-wide option if we're in the network admin.
|
53 |
-
if ( $network_override && is_multisite() ) {
|
54 |
-
$value = get_site_option( $key, $default );
|
55 |
-
} else {
|
56 |
-
$value = get_option( $key, $default );
|
57 |
-
}
|
58 |
-
|
59 |
-
return $value;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Updates an option from the admin settings page.
|
64 |
-
*
|
65 |
-
* @param string $key The option key.
|
66 |
-
* @param mixed $value The value to update.
|
67 |
-
* @param bool $network Whether to allow the network admin setting to be overridden on subsites.
|
68 |
-
* @return mixed
|
69 |
-
*/
|
70 |
-
static public function update_admin_settings_option( $key, $value, $network = false ) {
|
71 |
-
|
72 |
-
// Update the site-wide option since we're in the network admin.
|
73 |
-
if ( $network && is_multisite() ) {
|
74 |
-
update_site_option( $key, $value );
|
75 |
-
} else {
|
76 |
-
update_option( $key, $value );
|
77 |
-
}
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Get single setting
|
83 |
-
*
|
84 |
-
* @since 1.1.4
|
85 |
-
*
|
86 |
-
* @param string $key Option key.
|
87 |
-
* @param string $default Option default value if not exist.
|
88 |
-
* @return mixed
|
89 |
-
*/
|
90 |
-
static public function get_common_setting( $key = '', $default = '' ) {
|
91 |
-
$settings = self::get_common_settings();
|
92 |
-
|
93 |
-
if ( $settings && array_key_exists( $key, $settings ) ) {
|
94 |
-
return $settings[ $key ];
|
95 |
-
}
|
96 |
-
|
97 |
-
return $default;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Get required plugins for page builder
|
102 |
-
*
|
103 |
-
* @since 1.1.4
|
104 |
-
*
|
105 |
-
* @param string $page_builder_slug Page builder slug.
|
106 |
-
* @param string $default Default page builder.
|
107 |
-
* @return array selected page builder required plugins list.
|
108 |
-
*/
|
109 |
-
public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
|
110 |
-
$plugins = self::get_plugins_groupby_page_builders();
|
111 |
-
|
112 |
-
if ( array_key_exists( $page_builder_slug, $plugins ) ) {
|
113 |
-
return $plugins[ $page_builder_slug ];
|
114 |
-
}
|
115 |
-
|
116 |
-
return $plugins[ $default ];
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Get Plugins list by page builder.
|
121 |
-
*
|
122 |
-
* @since 1.1.4
|
123 |
-
*
|
124 |
-
* @return array Required Plugins list.
|
125 |
-
*/
|
126 |
-
public static function get_plugins_groupby_page_builders() {
|
127 |
-
|
128 |
-
$
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
'
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
)
|
153 |
-
|
154 |
-
|
155 |
-
'
|
156 |
-
'
|
157 |
-
'
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
return
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Get
|
229 |
-
*
|
230 |
-
* @
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
*
|
258 |
-
*
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
*
|
408 |
-
*
|
409 |
-
*
|
410 |
-
* @
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CARTFLOWS Helper.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Cartflows_Helper.
|
14 |
+
*/
|
15 |
+
class Cartflows_Helper {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Common global data
|
19 |
+
*
|
20 |
+
* @var zapier
|
21 |
+
*/
|
22 |
+
private static $common = null;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Installed Plugins
|
26 |
+
*
|
27 |
+
* @since 1.1.4
|
28 |
+
*
|
29 |
+
* @access private
|
30 |
+
* @var array Installed plugins list.
|
31 |
+
*/
|
32 |
+
private static $installed_plugins = null;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Checkout Fields
|
36 |
+
*
|
37 |
+
* @var checkout_fields
|
38 |
+
*/
|
39 |
+
private static $checkout_fields = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns an option from the database for
|
43 |
+
* the admin settings page.
|
44 |
+
*
|
45 |
+
* @param string $key The option key.
|
46 |
+
* @param mixed $default Option default value if option is not available.
|
47 |
+
* @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
|
48 |
+
* @return string Return the option value
|
49 |
+
*/
|
50 |
+
public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
|
51 |
+
|
52 |
+
// Get the site-wide option if we're in the network admin.
|
53 |
+
if ( $network_override && is_multisite() ) {
|
54 |
+
$value = get_site_option( $key, $default );
|
55 |
+
} else {
|
56 |
+
$value = get_option( $key, $default );
|
57 |
+
}
|
58 |
+
|
59 |
+
return $value;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Updates an option from the admin settings page.
|
64 |
+
*
|
65 |
+
* @param string $key The option key.
|
66 |
+
* @param mixed $value The value to update.
|
67 |
+
* @param bool $network Whether to allow the network admin setting to be overridden on subsites.
|
68 |
+
* @return mixed
|
69 |
+
*/
|
70 |
+
static public function update_admin_settings_option( $key, $value, $network = false ) {
|
71 |
+
|
72 |
+
// Update the site-wide option since we're in the network admin.
|
73 |
+
if ( $network && is_multisite() ) {
|
74 |
+
update_site_option( $key, $value );
|
75 |
+
} else {
|
76 |
+
update_option( $key, $value );
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Get single setting
|
83 |
+
*
|
84 |
+
* @since 1.1.4
|
85 |
+
*
|
86 |
+
* @param string $key Option key.
|
87 |
+
* @param string $default Option default value if not exist.
|
88 |
+
* @return mixed
|
89 |
+
*/
|
90 |
+
static public function get_common_setting( $key = '', $default = '' ) {
|
91 |
+
$settings = self::get_common_settings();
|
92 |
+
|
93 |
+
if ( $settings && array_key_exists( $key, $settings ) ) {
|
94 |
+
return $settings[ $key ];
|
95 |
+
}
|
96 |
+
|
97 |
+
return $default;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get required plugins for page builder
|
102 |
+
*
|
103 |
+
* @since 1.1.4
|
104 |
+
*
|
105 |
+
* @param string $page_builder_slug Page builder slug.
|
106 |
+
* @param string $default Default page builder.
|
107 |
+
* @return array selected page builder required plugins list.
|
108 |
+
*/
|
109 |
+
public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
|
110 |
+
$plugins = self::get_plugins_groupby_page_builders();
|
111 |
+
|
112 |
+
if ( array_key_exists( $page_builder_slug, $plugins ) ) {
|
113 |
+
return $plugins[ $page_builder_slug ];
|
114 |
+
}
|
115 |
+
|
116 |
+
return $plugins[ $default ];
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get Plugins list by page builder.
|
121 |
+
*
|
122 |
+
* @since 1.1.4
|
123 |
+
*
|
124 |
+
* @return array Required Plugins list.
|
125 |
+
*/
|
126 |
+
public static function get_plugins_groupby_page_builders() {
|
127 |
+
|
128 |
+
$divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
|
129 |
+
$theme_status = 'not-installed';
|
130 |
+
if ( $divi_status ) {
|
131 |
+
if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
|
132 |
+
$theme_status = 'installed';
|
133 |
+
if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
|
134 |
+
$theme_status = 'deactivate';
|
135 |
+
$divi_status = 'activate';
|
136 |
+
} else {
|
137 |
+
$divi_status = '';
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
$plugins = array(
|
143 |
+
'elementor' => array(
|
144 |
+
'title' => 'Elementor',
|
145 |
+
'plugins' => array(
|
146 |
+
array(
|
147 |
+
'slug' => 'elementor', // For download from wp.org.
|
148 |
+
'init' => 'elementor/elementor.php',
|
149 |
+
'status' => self::get_plugin_status( 'elementor/elementor.php' ),
|
150 |
+
),
|
151 |
+
),
|
152 |
+
),
|
153 |
+
'divi' => array(
|
154 |
+
'title' => 'Divi',
|
155 |
+
'theme-status' => $theme_status,
|
156 |
+
'plugin-status' => $divi_status,
|
157 |
+
'plugins' => array(
|
158 |
+
array(
|
159 |
+
'slug' => 'divi-builder', // For download from wp.org.
|
160 |
+
'init' => 'divi-builder/divi-builder.php',
|
161 |
+
'status' => $divi_status,
|
162 |
+
),
|
163 |
+
),
|
164 |
+
),
|
165 |
+
);
|
166 |
+
|
167 |
+
$plugins['beaver-builder'] = array(
|
168 |
+
'title' => 'Beaver Builder',
|
169 |
+
'plugins' => array(),
|
170 |
+
);
|
171 |
+
|
172 |
+
// Check Pro Exist.
|
173 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
|
174 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
175 |
+
'slug' => 'bb-plugin',
|
176 |
+
'init' => 'bb-plugin/fl-builder.php',
|
177 |
+
'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
|
178 |
+
);
|
179 |
+
} else {
|
180 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
181 |
+
'slug' => 'beaver-builder-lite-version', // For download from wp.org.
|
182 |
+
'init' => 'beaver-builder-lite-version/fl-builder.php',
|
183 |
+
'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
|
184 |
+
);
|
185 |
+
}
|
186 |
+
|
187 |
+
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' ) ) {
|
188 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
189 |
+
'slug' => 'bb-ultimate-addon',
|
190 |
+
'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
191 |
+
'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
|
192 |
+
);
|
193 |
+
} else {
|
194 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
195 |
+
'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
|
196 |
+
'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
|
197 |
+
'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
|
198 |
+
);
|
199 |
+
}
|
200 |
+
|
201 |
+
return $plugins;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Get plugin status
|
206 |
+
*
|
207 |
+
* @since 1.1.4
|
208 |
+
*
|
209 |
+
* @param string $plugin_init_file Plguin init file.
|
210 |
+
* @return mixed
|
211 |
+
*/
|
212 |
+
public static function get_plugin_status( $plugin_init_file ) {
|
213 |
+
|
214 |
+
if ( null == self::$installed_plugins ) {
|
215 |
+
self::$installed_plugins = get_plugins();
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
|
219 |
+
return 'install';
|
220 |
+
} elseif ( ! is_plugin_active( $plugin_init_file ) ) {
|
221 |
+
return 'activate';
|
222 |
+
}
|
223 |
+
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Get zapier settings.
|
229 |
+
*
|
230 |
+
* @return array.
|
231 |
+
*/
|
232 |
+
static public function get_common_settings() {
|
233 |
+
|
234 |
+
if ( null === self::$common ) {
|
235 |
+
|
236 |
+
$common_default = apply_filters(
|
237 |
+
'cartflows_common_settings_default',
|
238 |
+
array(
|
239 |
+
'disallow_indexing' => 'disable',
|
240 |
+
'global_checkout' => '',
|
241 |
+
'default_page_builder' => 'elementor',
|
242 |
+
)
|
243 |
+
);
|
244 |
+
|
245 |
+
$common = Cartflows_Helper::get_admin_settings_option( '_cartflows_common', false, true );
|
246 |
+
|
247 |
+
self::$common = wp_parse_args( $common, $common_default );
|
248 |
+
}
|
249 |
+
|
250 |
+
return self::$common;
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Get Checkout field.
|
255 |
+
*
|
256 |
+
* @param string $key Field key.
|
257 |
+
* @param int $post_id Post id.
|
258 |
+
* @return array.
|
259 |
+
*/
|
260 |
+
static public function get_checkout_fields( $key, $post_id ) {
|
261 |
+
|
262 |
+
$saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
|
263 |
+
|
264 |
+
if ( ! $saved_fields ) {
|
265 |
+
$saved_fields = array();
|
266 |
+
}
|
267 |
+
|
268 |
+
$fields = array_filter( $saved_fields );
|
269 |
+
|
270 |
+
if ( empty( $fields ) ) {
|
271 |
+
if ( 'billing' === $key || 'shipping' === $key ) {
|
272 |
+
|
273 |
+
$fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
|
274 |
+
|
275 |
+
update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
return $fields;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Add Checkout field.
|
284 |
+
*
|
285 |
+
* @param string $type Field type.
|
286 |
+
* @param string $field_key Field key.
|
287 |
+
* @param array $field_data Field data.
|
288 |
+
* @param int $post_id Post id.
|
289 |
+
* @return boolean.
|
290 |
+
*/
|
291 |
+
static public function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
|
292 |
+
|
293 |
+
$fields = self::get_checkout_fields( $type, $post_id );
|
294 |
+
|
295 |
+
$fields[ $field_key ] = $field_data;
|
296 |
+
|
297 |
+
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
298 |
+
|
299 |
+
return true;
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Get checkout fields settings.
|
304 |
+
*
|
305 |
+
* @param string $type Field type.
|
306 |
+
* @param string $field_key Field key.
|
307 |
+
* @param int $post_id Post id.
|
308 |
+
* @return array.
|
309 |
+
*/
|
310 |
+
static public function delete_checkout_field( $type, $field_key, $post_id ) {
|
311 |
+
|
312 |
+
$fields = self::get_checkout_fields( $type, $post_id );
|
313 |
+
|
314 |
+
if ( isset( $fields[ $field_key ] ) ) {
|
315 |
+
unset( $fields[ $field_key ] );
|
316 |
+
}
|
317 |
+
|
318 |
+
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
319 |
+
|
320 |
+
return true;
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Get checkout fields settings.
|
325 |
+
*
|
326 |
+
* @return array.
|
327 |
+
*/
|
328 |
+
static public function get_checkout_fields_settings() {
|
329 |
+
|
330 |
+
if ( null === self::$checkout_fields ) {
|
331 |
+
$checkout_fields_default = array(
|
332 |
+
'enable_customization' => 'disable',
|
333 |
+
'enable_billing_fields' => 'disable',
|
334 |
+
);
|
335 |
+
|
336 |
+
$billing_fields = self::get_checkout_fields( 'billing' );
|
337 |
+
|
338 |
+
if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
|
339 |
+
|
340 |
+
foreach ( $billing_fields as $key => $value ) {
|
341 |
+
|
342 |
+
$checkout_fields_default[ $key ] = 'enable';
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
$checkout_fields = Cartflows_Helper::get_admin_settings_option( '_wcf_checkout_fields', false, true );
|
347 |
+
|
348 |
+
self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
|
349 |
+
}
|
350 |
+
|
351 |
+
return self::$checkout_fields;
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Get meta options
|
356 |
+
*
|
357 |
+
* @since 1.0.0
|
358 |
+
* @param int $post_id Product ID.
|
359 |
+
* @param string $key Meta Key.
|
360 |
+
* @param string $default Default value.
|
361 |
+
* @return string Meta Value.
|
362 |
+
*/
|
363 |
+
static public function get_meta_option( $post_id, $key, $default = '' ) {
|
364 |
+
|
365 |
+
$value = get_post_meta( $post_id, $key, true );
|
366 |
+
|
367 |
+
if ( ! $value ) {
|
368 |
+
$value = $default;
|
369 |
+
}
|
370 |
+
|
371 |
+
return $value;
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Save meta option
|
376 |
+
*
|
377 |
+
* @since 1.0.0
|
378 |
+
* @param int $post_id Product ID.
|
379 |
+
* @param array $args Arguments array.
|
380 |
+
*/
|
381 |
+
static public function save_meta_option( $post_id, $args = array() ) {
|
382 |
+
|
383 |
+
if ( is_array( $args ) && ! empty( $args ) ) {
|
384 |
+
|
385 |
+
foreach ( $args as $key => $value ) {
|
386 |
+
|
387 |
+
update_post_meta( $post_id, $key, $value );
|
388 |
+
}
|
389 |
+
}
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Check if Elementor page builder is installed
|
394 |
+
*
|
395 |
+
* @since 1.0.0
|
396 |
+
*
|
397 |
+
* @access public
|
398 |
+
*/
|
399 |
+
static public function _is_elementor_installed() {
|
400 |
+
$path = 'elementor/elementor.php';
|
401 |
+
$plugins = get_plugins();
|
402 |
+
|
403 |
+
return isset( $plugins[ $path ] );
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Check if Step has product assigned.
|
408 |
+
*
|
409 |
+
* @since 1.0.0
|
410 |
+
* @param int $step_id step ID.
|
411 |
+
*
|
412 |
+
* @access public
|
413 |
+
*/
|
414 |
+
static public function has_product_assigned( $step_id ) {
|
415 |
+
|
416 |
+
$step_type = get_post_meta( $step_id, 'wcf-step-type', true );
|
417 |
+
|
418 |
+
if ( 'checkout' == $step_type ) {
|
419 |
+
$product = get_post_meta( $step_id, 'wcf-checkout-products', true );
|
420 |
+
} else {
|
421 |
+
$product = get_post_meta( $step_id, 'wcf-offer-product', true );
|
422 |
+
}
|
423 |
+
|
424 |
+
if ( ! empty( $product ) ) {
|
425 |
+
return true;
|
426 |
+
}
|
427 |
+
return false;
|
428 |
+
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Get attributes for cartflows wrap.
|
433 |
+
*
|
434 |
+
* @since 1.1.4
|
435 |
+
*
|
436 |
+
* @access public
|
437 |
+
*/
|
438 |
+
static public function get_cartflows_container_atts() {
|
439 |
+
|
440 |
+
$attributes = apply_filters( 'cartflows_container_atts', array() );
|
441 |
+
$atts_string = '';
|
442 |
+
|
443 |
+
foreach ( $attributes as $key => $value ) {
|
444 |
+
|
445 |
+
if ( ! $value ) {
|
446 |
+
continue;
|
447 |
+
}
|
448 |
+
|
449 |
+
if ( true === $value ) {
|
450 |
+
$atts_string .= esc_html( $key ) . ' ';
|
451 |
+
} else {
|
452 |
+
$atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
return $atts_string;
|
457 |
+
}
|
458 |
+
}
|
classes/class-cartflows-importer-core.php
CHANGED
@@ -1,269 +1,272 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Image Importer
|
4 |
-
*
|
5 |
-
* => How to use?
|
6 |
-
*
|
7 |
-
* $image = array(
|
8 |
-
* 'url' => '<image-url>',
|
9 |
-
* 'id' => '<image-id>',
|
10 |
-
* );
|
11 |
-
*
|
12 |
-
* $downloaded_image = CartFlows_Importer_Core::get_instance()->import( $image );
|
13 |
-
*
|
14 |
-
* @package CartFlows
|
15 |
-
* @since 1.0.0
|
16 |
-
*/
|
17 |
-
|
18 |
-
if ( ! class_exists( 'CartFlows_Importer_Core' ) ) :
|
19 |
-
|
20 |
-
/**
|
21 |
-
* CartFlows Importer
|
22 |
-
*
|
23 |
-
* @since 1.0.0
|
24 |
-
*/
|
25 |
-
class CartFlows_Importer_Core {
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Instance
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
* @var object Class object.
|
32 |
-
* @access private
|
33 |
-
*/
|
34 |
-
private static $instance;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Images IDs
|
38 |
-
*
|
39 |
-
* @var array The Array of already image IDs.
|
40 |
-
* @since 1.0.0
|
41 |
-
*/
|
42 |
-
private $already_imported_ids = array();
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Initiator
|
46 |
-
*
|
47 |
-
* @since 1.0.0
|
48 |
-
* @return object initialized object of class.
|
49 |
-
*/
|
50 |
-
public static function get_instance() {
|
51 |
-
if ( ! isset( self::$instance ) ) {
|
52 |
-
self::$instance = new self;
|
53 |
-
}
|
54 |
-
return self::$instance;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Constructor
|
59 |
-
*
|
60 |
-
* @since 1.0.0
|
61 |
-
*/
|
62 |
-
public function __construct() {
|
63 |
-
|
64 |
-
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
65 |
-
require_once ABSPATH . 'wp-admin/includes/file.php';
|
66 |
-
}
|
67 |
-
|
68 |
-
WP_Filesystem();
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Process Image Download
|
73 |
-
*
|
74 |
-
* @since 1.0.0
|
75 |
-
* @param array $attachments Attachment array.
|
76 |
-
* @return array Attachment array.
|
77 |
-
*/
|
78 |
-
public function process( $attachments ) {
|
79 |
-
|
80 |
-
$downloaded_images = array();
|
81 |
-
|
82 |
-
foreach ( $attachments as $key => $attachment ) {
|
83 |
-
$downloaded_images[] = $this->import( $attachment );
|
84 |
-
}
|
85 |
-
|
86 |
-
return $downloaded_images;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Get Hash Image.
|
91 |
-
*
|
92 |
-
* @since 1.0.0
|
93 |
-
* @param string $attachment_url Attachment URL.
|
94 |
-
* @return string Hash string.
|
95 |
-
*/
|
96 |
-
private function get_hash_image( $attachment_url ) {
|
97 |
-
return sha1( $attachment_url );
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Get Saved Image.
|
102 |
-
*
|
103 |
-
* @since 1.0.0
|
104 |
-
* @param string $attachment Attachment Data.
|
105 |
-
* @return string Hash string.
|
106 |
-
*/
|
107 |
-
private function get_saved_image( $attachment ) {
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
*
|
177 |
-
*
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
}
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
*
|
247 |
-
*
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Image Importer
|
4 |
+
*
|
5 |
+
* => How to use?
|
6 |
+
*
|
7 |
+
* $image = array(
|
8 |
+
* 'url' => '<image-url>',
|
9 |
+
* 'id' => '<image-id>',
|
10 |
+
* );
|
11 |
+
*
|
12 |
+
* $downloaded_image = CartFlows_Importer_Core::get_instance()->import( $image );
|
13 |
+
*
|
14 |
+
* @package CartFlows
|
15 |
+
* @since 1.0.0
|
16 |
+
*/
|
17 |
+
|
18 |
+
if ( ! class_exists( 'CartFlows_Importer_Core' ) ) :
|
19 |
+
|
20 |
+
/**
|
21 |
+
* CartFlows Importer
|
22 |
+
*
|
23 |
+
* @since 1.0.0
|
24 |
+
*/
|
25 |
+
class CartFlows_Importer_Core {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Instance
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @var object Class object.
|
32 |
+
* @access private
|
33 |
+
*/
|
34 |
+
private static $instance;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Images IDs
|
38 |
+
*
|
39 |
+
* @var array The Array of already image IDs.
|
40 |
+
* @since 1.0.0
|
41 |
+
*/
|
42 |
+
private $already_imported_ids = array();
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initiator
|
46 |
+
*
|
47 |
+
* @since 1.0.0
|
48 |
+
* @return object initialized object of class.
|
49 |
+
*/
|
50 |
+
public static function get_instance() {
|
51 |
+
if ( ! isset( self::$instance ) ) {
|
52 |
+
self::$instance = new self;
|
53 |
+
}
|
54 |
+
return self::$instance;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Constructor
|
59 |
+
*
|
60 |
+
* @since 1.0.0
|
61 |
+
*/
|
62 |
+
public function __construct() {
|
63 |
+
|
64 |
+
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
65 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
66 |
+
}
|
67 |
+
|
68 |
+
WP_Filesystem();
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Process Image Download
|
73 |
+
*
|
74 |
+
* @since 1.0.0
|
75 |
+
* @param array $attachments Attachment array.
|
76 |
+
* @return array Attachment array.
|
77 |
+
*/
|
78 |
+
public function process( $attachments ) {
|
79 |
+
|
80 |
+
$downloaded_images = array();
|
81 |
+
|
82 |
+
foreach ( $attachments as $key => $attachment ) {
|
83 |
+
$downloaded_images[] = $this->import( $attachment );
|
84 |
+
}
|
85 |
+
|
86 |
+
return $downloaded_images;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get Hash Image.
|
91 |
+
*
|
92 |
+
* @since 1.0.0
|
93 |
+
* @param string $attachment_url Attachment URL.
|
94 |
+
* @return string Hash string.
|
95 |
+
*/
|
96 |
+
private function get_hash_image( $attachment_url ) {
|
97 |
+
return sha1( $attachment_url );
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get Saved Image.
|
102 |
+
*
|
103 |
+
* @since 1.0.0
|
104 |
+
* @param string $attachment Attachment Data.
|
105 |
+
* @return string Hash string.
|
106 |
+
*/
|
107 |
+
private function get_saved_image( $attachment ) {
|
108 |
+
|
109 |
+
wcf()->logger->import_log( 'importer-core.php File' );
|
110 |
+
|
111 |
+
if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) {
|
112 |
+
|
113 |
+
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
114 |
+
|
115 |
+
return $attachment;
|
116 |
+
}
|
117 |
+
|
118 |
+
global $wpdb;
|
119 |
+
|
120 |
+
// Already imported? Then return!
|
121 |
+
if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) {
|
122 |
+
|
123 |
+
self::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
|
124 |
+
|
125 |
+
return $this->already_imported_ids[ $attachment['id'] ];
|
126 |
+
}
|
127 |
+
|
128 |
+
// 1. Is already imported in Batch Import Process?
|
129 |
+
$post_id = $wpdb->get_var(
|
130 |
+
$wpdb->prepare(
|
131 |
+
'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
|
132 |
+
WHERE `meta_key` = \'_cartflows_image_hash\'
|
133 |
+
AND `meta_value` = %s
|
134 |
+
;',
|
135 |
+
$this->get_hash_image( $attachment['url'] )
|
136 |
+
)
|
137 |
+
);
|
138 |
+
|
139 |
+
// 2. Is image already imported though XML?
|
140 |
+
if ( empty( $post_id ) ) {
|
141 |
+
|
142 |
+
// Get file name without extension.
|
143 |
+
// To check it exist in attachment.
|
144 |
+
$filename = preg_replace( '/\\.[^.\\s]{3,4}$/', '', basename( $attachment['url'] ) );
|
145 |
+
|
146 |
+
$post_id = $wpdb->get_var(
|
147 |
+
$wpdb->prepare(
|
148 |
+
'SELECT `post_id` FROM `' . $wpdb->postmeta . '`
|
149 |
+
WHERE `meta_key` = \'_wp_attached_file\'
|
150 |
+
AND `meta_value` LIKE %s
|
151 |
+
;',
|
152 |
+
'%' . $filename . '%'
|
153 |
+
)
|
154 |
+
);
|
155 |
+
|
156 |
+
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( $post_id ) {
|
160 |
+
|
161 |
+
$new_imgage_url = wp_get_attachment_url( $post_id );
|
162 |
+
$new_attachment = array(
|
163 |
+
'id' => $post_id,
|
164 |
+
'url' => $new_imgage_url,
|
165 |
+
);
|
166 |
+
$this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
|
167 |
+
|
168 |
+
self::log( 'Download (✓) Replace (✓) - ' . $new_imgage_url );
|
169 |
+
return $new_attachment;
|
170 |
+
}
|
171 |
+
|
172 |
+
return false;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Import Image
|
177 |
+
*
|
178 |
+
* @since 1.0.0
|
179 |
+
* @param array $attachment Attachment array.
|
180 |
+
* @return array Attachment array.
|
181 |
+
*/
|
182 |
+
public function import( $attachment ) {
|
183 |
+
|
184 |
+
$saved_image = $this->get_saved_image( $attachment );
|
185 |
+
if ( $saved_image ) {
|
186 |
+
return $saved_image;
|
187 |
+
}
|
188 |
+
|
189 |
+
$args = array(
|
190 |
+
'timeout' => 300,
|
191 |
+
);
|
192 |
+
|
193 |
+
$file_content = wp_remote_retrieve_body( wp_safe_remote_get( $attachment['url'], $args ) );
|
194 |
+
|
195 |
+
// Empty file content?
|
196 |
+
if ( empty( $file_content ) ) {
|
197 |
+
|
198 |
+
self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] );
|
199 |
+
self::log( 'Error: Failed wp_remote_retrieve_body().' );
|
200 |
+
|
201 |
+
return $attachment;
|
202 |
+
}
|
203 |
+
|
204 |
+
// Extract the file name and extension from the URL.
|
205 |
+
$filename = basename( $attachment['url'] );
|
206 |
+
|
207 |
+
$upload = wp_upload_bits(
|
208 |
+
$filename,
|
209 |
+
null,
|
210 |
+
$file_content
|
211 |
+
);
|
212 |
+
|
213 |
+
$post = array(
|
214 |
+
'post_title' => $filename,
|
215 |
+
'guid' => $upload['url'],
|
216 |
+
);
|
217 |
+
|
218 |
+
$info = wp_check_filetype( $upload['file'] );
|
219 |
+
if ( $info ) {
|
220 |
+
$post['post_mime_type'] = $info['type'];
|
221 |
+
} else {
|
222 |
+
// For now just return the origin attachment.
|
223 |
+
return $attachment;
|
224 |
+
}
|
225 |
+
|
226 |
+
$post_id = wp_insert_attachment( $post, $upload['file'] );
|
227 |
+
wp_update_attachment_metadata(
|
228 |
+
$post_id,
|
229 |
+
wp_generate_attachment_metadata( $post_id, $upload['file'] )
|
230 |
+
);
|
231 |
+
update_post_meta( $post_id, '_cartflows_image_hash', $this->get_hash_image( $attachment['url'] ) );
|
232 |
+
|
233 |
+
$new_attachment = array(
|
234 |
+
'id' => $post_id,
|
235 |
+
'url' => $upload['url'],
|
236 |
+
);
|
237 |
+
|
238 |
+
self::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] );
|
239 |
+
|
240 |
+
$this->already_imported_ids[ $attachment['id'] ] = $new_attachment;
|
241 |
+
|
242 |
+
return $new_attachment;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Debugging Log.
|
247 |
+
*
|
248 |
+
* @since 1.0.0
|
249 |
+
* @param mixed $log Log data.
|
250 |
+
* @return void
|
251 |
+
*/
|
252 |
+
public static function log( $log ) {
|
253 |
+
|
254 |
+
if ( ! WP_DEBUG_LOG ) {
|
255 |
+
return;
|
256 |
+
}
|
257 |
+
|
258 |
+
if ( is_array( $log ) || is_object( $log ) ) {
|
259 |
+
wcf()->logger->import_log( print_r( $log, true ) );
|
260 |
+
} else {
|
261 |
+
wcf()->logger->import_log( $log );
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Initialize class object with 'get_instance()' method
|
269 |
+
*/
|
270 |
+
CartFlows_Importer_Core::get_instance();
|
271 |
+
|
272 |
+
endif;
|
classes/class-cartflows-importer.php
CHANGED
@@ -1,1432 +1,1564 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Admin
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows Import
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class CartFlows_Importer {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @since 1.0.0
|
22 |
-
* @access private
|
23 |
-
* @var object Class object.
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Initiator
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
* @return object initialized object of class.
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
if ( ! isset( self::$instance ) ) {
|
35 |
-
self::$instance = new self;
|
36 |
-
}
|
37 |
-
|
38 |
-
return self::$instance;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Constructor
|
43 |
-
*
|
44 |
-
* @since 1.0.0
|
45 |
-
*/
|
46 |
-
public function __construct() {
|
47 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
|
48 |
-
add_action( 'wp_ajax_cartflows_load_steps', array( $this, 'load_templates' ) );
|
49 |
-
add_action( 'wp_ajax_cartflows_step_import', array( $this, 'import_step' ) );
|
50 |
-
add_action( 'wp_ajax_cartflows_create_flow', array( $this, 'create_flow' ) );
|
51 |
-
add_action( 'wp_ajax_cartflows_default_flow', array( $this, 'create_default_flow' ) );
|
52 |
-
add_action( 'wp_ajax_cartflows_step_create_blank', array( $this, 'step_create_blank' ) );
|
53 |
-
add_action( 'wp_ajax_cartflows_import_flow_step', array( $this, 'import_flow' ) );
|
54 |
-
add_action( 'admin_footer', array( $this, 'js_templates' ) );
|
55 |
-
add_action( 'cartflows_import_complete', array( $this, 'clear_cache' ) );
|
56 |
-
|
57 |
-
add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
|
58 |
-
|
59 |
-
add_action( 'wp_ajax_cartflows_activate_plugin', array( $this, 'activate_plugin' ) );
|
60 |
-
|
61 |
-
add_action( 'admin_menu', array( $this, 'add_to_menus' ) );
|
62 |
-
add_action( 'admin_init', array( $this, 'export' ) );
|
63 |
-
add_action( 'admin_init', array( $this, 'import' ) );
|
64 |
-
add_filter( 'post_row_actions', array( $this, 'export_link' ), 10, 2 );
|
65 |
-
add_action( 'admin_action_cartflows_export_flow', array( $this, 'export_flow' ) );
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Add the export link to action list for flows row actions
|
70 |
-
*
|
71 |
-
* @since 1.1.4
|
72 |
-
*
|
73 |
-
* @param array $actions Actions array.
|
74 |
-
* @param object $post Post object.
|
75 |
-
*
|
76 |
-
* @return array
|
77 |
-
*/
|
78 |
-
function export_link( $actions, $post ) {
|
79 |
-
if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
80 |
-
$actions['export'] = '<a href="' . wp_nonce_url( 'admin.php?action=cartflows_export_flow&post=' . $post->ID, basename( __FILE__ ), 'flow_export_nonce' ) . '" title="' . __( 'Export this flow', 'cartflows' ) . '" rel="permalink">' . __( 'Export', 'cartflows' ) . '</a>';
|
81 |
-
}
|
82 |
-
return $actions;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Add menus
|
87 |
-
*
|
88 |
-
* @since 1.1.4
|
89 |
-
*/
|
90 |
-
function add_to_menus() {
|
91 |
-
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Export', 'cartflows' ), __( 'Flow Export', 'cartflows' ), 'export', 'flow_exporter', array( $this, 'exporter_markup' ) );
|
92 |
-
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Import', 'cartflows' ), __( 'Flow Import', 'cartflows' ), 'import', 'flow_importer', array( $this, 'importer_markup' ) );
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Export flow with steps and its meta
|
97 |
-
*
|
98 |
-
* @since 1.1.4
|
99 |
-
*/
|
100 |
-
function export_flow() {
|
101 |
-
|
102 |
-
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_export_flow' == $_REQUEST['action'] ) ) ) {
|
103 |
-
wp_die( __( 'No post to export has been supplied!', 'cartflows' ) );
|
104 |
-
}
|
105 |
-
|
106 |
-
if ( ! isset( $_GET['flow_export_nonce'] ) || ! wp_verify_nonce( $_GET['flow_export_nonce'], basename( __FILE__ ) ) ) {
|
107 |
-
return;
|
108 |
-
}
|
109 |
-
|
110 |
-
// Get the original post id.
|
111 |
-
$flow_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
|
112 |
-
|
113 |
-
$flows = array();
|
114 |
-
$flows[] = $this->get_flow_export_data( $flow_id );
|
115 |
-
$flows = apply_filters( 'cartflows_export_data', $flows );
|
116 |
-
|
117 |
-
nocache_headers();
|
118 |
-
header( 'Content-Type: application/json; charset=utf-8' );
|
119 |
-
header( 'Content-Disposition: attachment; filename=cartflows-flow-
|
120 |
-
header( 'Expires: 0' );
|
121 |
-
|
122 |
-
echo json_encode( $flows );
|
123 |
-
exit;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Export flow markup
|
128 |
-
*
|
129 |
-
* @since 1.1.4
|
130 |
-
*/
|
131 |
-
function exporter_markup() {
|
132 |
-
include_once CARTFLOWS_DIR . 'includes/exporter.php';
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Import flow markup
|
137 |
-
*
|
138 |
-
* @since 1.1.4
|
139 |
-
*/
|
140 |
-
function importer_markup() {
|
141 |
-
include_once CARTFLOWS_DIR . 'includes/importer.php';
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Export flow
|
146 |
-
*
|
147 |
-
* @since 1.1.4
|
148 |
-
*/
|
149 |
-
function export() {
|
150 |
-
if ( empty( $_POST['cartflows-action'] ) || 'export' != $_POST['cartflows-action'] ) {
|
151 |
-
return;
|
152 |
-
}
|
153 |
-
|
154 |
-
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
155 |
-
return;
|
156 |
-
}
|
157 |
-
|
158 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
159 |
-
return;
|
160 |
-
}
|
161 |
-
|
162 |
-
$flows = $this->get_all_flow_export_data();
|
163 |
-
$flows = apply_filters( 'cartflows_export_data', $flows );
|
164 |
-
|
165 |
-
nocache_headers();
|
166 |
-
header( 'Content-Type: application/json; charset=utf-8' );
|
167 |
-
header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
|
168 |
-
header( 'Expires: 0' );
|
169 |
-
|
170 |
-
echo json_encode( $flows );
|
171 |
-
exit;
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Get flow export data
|
176 |
-
*
|
177 |
-
* @since 1.1.4
|
178 |
-
*
|
179 |
-
* @param integer $flow_id Flow ID.
|
180 |
-
* @return array
|
181 |
-
*/
|
182 |
-
function get_flow_export_data( $flow_id ) {
|
183 |
-
|
184 |
-
$
|
185 |
-
|
186 |
-
|
187 |
-
'
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
<#
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
?>
|
643 |
-
<script type="text/template" id="tmpl-cartflows-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
<a href="
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
'
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
$
|
1016 |
-
|
1017 |
-
|
1018 |
-
'
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
)
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
$
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
'
|
1100 |
-
'
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
$
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
$
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
*
|
1296 |
-
*
|
1297 |
-
* @
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
$
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
//
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
);
|
1369 |
-
|
1370 |
-
|
1371 |
-
}
|
1372 |
-
|
1373 |
-
/**
|
1374 |
-
*
|
1375 |
-
*
|
1376 |
-
* @
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Admin
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows Import
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class CartFlows_Importer {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @access private
|
23 |
+
* @var object Class object.
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initiator
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @return object initialized object of class.
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self;
|
36 |
+
}
|
37 |
+
|
38 |
+
return self::$instance;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor
|
43 |
+
*
|
44 |
+
* @since 1.0.0
|
45 |
+
*/
|
46 |
+
public function __construct() {
|
47 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
|
48 |
+
add_action( 'wp_ajax_cartflows_load_steps', array( $this, 'load_templates' ) );
|
49 |
+
add_action( 'wp_ajax_cartflows_step_import', array( $this, 'import_step' ) );
|
50 |
+
add_action( 'wp_ajax_cartflows_create_flow', array( $this, 'create_flow' ) );
|
51 |
+
add_action( 'wp_ajax_cartflows_default_flow', array( $this, 'create_default_flow' ) );
|
52 |
+
add_action( 'wp_ajax_cartflows_step_create_blank', array( $this, 'step_create_blank' ) );
|
53 |
+
add_action( 'wp_ajax_cartflows_import_flow_step', array( $this, 'import_flow' ) );
|
54 |
+
add_action( 'admin_footer', array( $this, 'js_templates' ) );
|
55 |
+
add_action( 'cartflows_import_complete', array( $this, 'clear_cache' ) );
|
56 |
+
|
57 |
+
add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
|
58 |
+
|
59 |
+
add_action( 'wp_ajax_cartflows_activate_plugin', array( $this, 'activate_plugin' ) );
|
60 |
+
|
61 |
+
add_action( 'admin_menu', array( $this, 'add_to_menus' ) );
|
62 |
+
add_action( 'admin_init', array( $this, 'export' ) );
|
63 |
+
add_action( 'admin_init', array( $this, 'import' ) );
|
64 |
+
add_filter( 'post_row_actions', array( $this, 'export_link' ), 10, 2 );
|
65 |
+
add_action( 'admin_action_cartflows_export_flow', array( $this, 'export_flow' ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Add the export link to action list for flows row actions
|
70 |
+
*
|
71 |
+
* @since 1.1.4
|
72 |
+
*
|
73 |
+
* @param array $actions Actions array.
|
74 |
+
* @param object $post Post object.
|
75 |
+
*
|
76 |
+
* @return array
|
77 |
+
*/
|
78 |
+
function export_link( $actions, $post ) {
|
79 |
+
if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
80 |
+
$actions['export'] = '<a href="' . wp_nonce_url( 'admin.php?action=cartflows_export_flow&post=' . $post->ID, basename( __FILE__ ), 'flow_export_nonce' ) . '" title="' . __( 'Export this flow', 'cartflows' ) . '" rel="permalink">' . __( 'Export', 'cartflows' ) . '</a>';
|
81 |
+
}
|
82 |
+
return $actions;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add menus
|
87 |
+
*
|
88 |
+
* @since 1.1.4
|
89 |
+
*/
|
90 |
+
function add_to_menus() {
|
91 |
+
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Export', 'cartflows' ), __( 'Flow Export', 'cartflows' ), 'export', 'flow_exporter', array( $this, 'exporter_markup' ) );
|
92 |
+
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Import', 'cartflows' ), __( 'Flow Import', 'cartflows' ), 'import', 'flow_importer', array( $this, 'importer_markup' ) );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Export flow with steps and its meta
|
97 |
+
*
|
98 |
+
* @since 1.1.4
|
99 |
+
*/
|
100 |
+
function export_flow() {
|
101 |
+
|
102 |
+
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_export_flow' == $_REQUEST['action'] ) ) ) {
|
103 |
+
wp_die( __( 'No post to export has been supplied!', 'cartflows' ) );
|
104 |
+
}
|
105 |
+
|
106 |
+
if ( ! isset( $_GET['flow_export_nonce'] ) || ! wp_verify_nonce( $_GET['flow_export_nonce'], basename( __FILE__ ) ) ) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
+
// Get the original post id.
|
111 |
+
$flow_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
|
112 |
+
|
113 |
+
$flows = array();
|
114 |
+
$flows[] = $this->get_flow_export_data( $flow_id );
|
115 |
+
$flows = apply_filters( 'cartflows_export_data', $flows );
|
116 |
+
|
117 |
+
nocache_headers();
|
118 |
+
header( 'Content-Type: application/json; charset=utf-8' );
|
119 |
+
header( 'Content-Disposition: attachment; filename=cartflows-flow-' . $flow_id . '-' . date( 'm-d-Y' ) . '.json' );
|
120 |
+
header( 'Expires: 0' );
|
121 |
+
|
122 |
+
echo json_encode( $flows );
|
123 |
+
exit;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Export flow markup
|
128 |
+
*
|
129 |
+
* @since 1.1.4
|
130 |
+
*/
|
131 |
+
function exporter_markup() {
|
132 |
+
include_once CARTFLOWS_DIR . 'includes/exporter.php';
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Import flow markup
|
137 |
+
*
|
138 |
+
* @since 1.1.4
|
139 |
+
*/
|
140 |
+
function importer_markup() {
|
141 |
+
include_once CARTFLOWS_DIR . 'includes/importer.php';
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Export flow
|
146 |
+
*
|
147 |
+
* @since 1.1.4
|
148 |
+
*/
|
149 |
+
function export() {
|
150 |
+
if ( empty( $_POST['cartflows-action'] ) || 'export' != $_POST['cartflows-action'] ) {
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
|
162 |
+
$flows = $this->get_all_flow_export_data();
|
163 |
+
$flows = apply_filters( 'cartflows_export_data', $flows );
|
164 |
+
|
165 |
+
nocache_headers();
|
166 |
+
header( 'Content-Type: application/json; charset=utf-8' );
|
167 |
+
header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
|
168 |
+
header( 'Expires: 0' );
|
169 |
+
|
170 |
+
echo json_encode( $flows );
|
171 |
+
exit;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Get flow export data
|
176 |
+
*
|
177 |
+
* @since 1.1.4
|
178 |
+
*
|
179 |
+
* @param integer $flow_id Flow ID.
|
180 |
+
* @return array
|
181 |
+
*/
|
182 |
+
function get_flow_export_data( $flow_id ) {
|
183 |
+
|
184 |
+
$export_all = apply_filters( 'cartflows_export_all', false );
|
185 |
+
|
186 |
+
$valid_step_meta_keys = array(
|
187 |
+
'_wp_page_template',
|
188 |
+
'_thumbnail_id',
|
189 |
+
'classic-editor-remember',
|
190 |
+
);
|
191 |
+
|
192 |
+
$new_steps = array();
|
193 |
+
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
194 |
+
if ( $steps ) {
|
195 |
+
foreach ( $steps as $key => $step ) {
|
196 |
+
|
197 |
+
// Add step post meta.
|
198 |
+
$new_all_meta = array();
|
199 |
+
$all_meta = get_post_meta( $step['id'] );
|
200 |
+
if ( is_array( $all_meta ) ) {
|
201 |
+
|
202 |
+
if ( $export_all ) {
|
203 |
+
foreach ( $all_meta as $meta_key => $value ) {
|
204 |
+
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
205 |
+
}
|
206 |
+
} else {
|
207 |
+
|
208 |
+
foreach ( $all_meta as $meta_key => $value ) {
|
209 |
+
if ( substr( $meta_key, 0, strlen( 'wcf' ) ) === 'wcf' ) {
|
210 |
+
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
211 |
+
} elseif ( in_array( $meta_key, $valid_step_meta_keys ) ) {
|
212 |
+
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
// Add single step.
|
219 |
+
$step_data_arr = array(
|
220 |
+
'title' => get_the_title( $step['id'] ),
|
221 |
+
'type' => $step['type'],
|
222 |
+
'meta' => $new_all_meta,
|
223 |
+
'post_content' => '',
|
224 |
+
);
|
225 |
+
|
226 |
+
if ( $export_all ) {
|
227 |
+
|
228 |
+
$step_post_obj = get_post( $step['id'] );
|
229 |
+
|
230 |
+
$step_data_arr['post_content'] = $step_post_obj->post_content;
|
231 |
+
}
|
232 |
+
|
233 |
+
$new_steps[] = $step_data_arr;
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
// Add single flow.
|
238 |
+
return array(
|
239 |
+
'title' => get_the_title( $flow_id ),
|
240 |
+
'steps' => $new_steps,
|
241 |
+
);
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Get all flow export data
|
246 |
+
*
|
247 |
+
* @since 1.1.4
|
248 |
+
*/
|
249 |
+
function get_all_flow_export_data() {
|
250 |
+
|
251 |
+
$query_args = array(
|
252 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
253 |
+
|
254 |
+
// Query performance optimization.
|
255 |
+
'fields' => 'ids',
|
256 |
+
'no_found_rows' => true,
|
257 |
+
'posts_per_page' => -1,
|
258 |
+
);
|
259 |
+
|
260 |
+
$query = new WP_Query( $query_args );
|
261 |
+
$flows = array();
|
262 |
+
if ( $query->posts ) {
|
263 |
+
foreach ( $query->posts as $key => $post_id ) {
|
264 |
+
$flows[] = $this->get_flow_export_data( $post_id );
|
265 |
+
}
|
266 |
+
}
|
267 |
+
|
268 |
+
return $flows;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Import our exported file
|
273 |
+
*
|
274 |
+
* @since 1.1.4
|
275 |
+
*/
|
276 |
+
function import() {
|
277 |
+
if ( empty( $_POST['cartflows-action'] ) || 'import' != $_POST['cartflows-action'] ) {
|
278 |
+
return;
|
279 |
+
}
|
280 |
+
|
281 |
+
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
282 |
+
return;
|
283 |
+
}
|
284 |
+
|
285 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
286 |
+
return;
|
287 |
+
}
|
288 |
+
|
289 |
+
$filename = $_FILES['file']['name'];
|
290 |
+
$file_info = explode( '.', $filename );
|
291 |
+
$extension = end( $file_info );
|
292 |
+
|
293 |
+
if ( 'json' != $extension ) {
|
294 |
+
wp_die( __( 'Please upload a valid .json file', 'cartflows' ) );
|
295 |
+
}
|
296 |
+
|
297 |
+
$file = $_FILES['file']['tmp_name'];
|
298 |
+
|
299 |
+
if ( empty( $file ) ) {
|
300 |
+
wp_die( __( 'Please upload a file to import', 'cartflows' ) );
|
301 |
+
}
|
302 |
+
|
303 |
+
// Retrieve the settings from the file and convert the JSON object to an array.
|
304 |
+
$flows = json_decode( file_get_contents( $file ), true );
|
305 |
+
|
306 |
+
if ( $flows ) {
|
307 |
+
|
308 |
+
foreach ( $flows as $key => $flow ) {
|
309 |
+
|
310 |
+
$flow_title = $flow['title'];
|
311 |
+
if ( post_exists( $flow['title'] ) ) {
|
312 |
+
$flow_title = $flow['title'] . ' Copy';
|
313 |
+
}
|
314 |
+
|
315 |
+
// Create post object.
|
316 |
+
$new_flow_args = array(
|
317 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
318 |
+
'post_title' => $flow_title,
|
319 |
+
'post_status' => 'draft',
|
320 |
+
);
|
321 |
+
|
322 |
+
// Insert the post into the database.
|
323 |
+
$flow_id = wp_insert_post( $new_flow_args );
|
324 |
+
|
325 |
+
if ( $flow['steps'] ) {
|
326 |
+
foreach ( $flow['steps'] as $key => $step ) {
|
327 |
+
|
328 |
+
$new_step_id = wp_insert_post(
|
329 |
+
array(
|
330 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
331 |
+
'post_title' => $step['title'],
|
332 |
+
'post_status' => 'publish',
|
333 |
+
'meta_input' => $step['meta'],
|
334 |
+
'post_content' => isset( $step['post_content'] ) ? $step['post_content'] : '',
|
335 |
+
)
|
336 |
+
);
|
337 |
+
|
338 |
+
// Insert post meta.
|
339 |
+
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
340 |
+
|
341 |
+
$step_taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
342 |
+
$current_term = term_exists( $step['type'], $step_taxonomy );
|
343 |
+
|
344 |
+
// // Set type object.
|
345 |
+
$data = get_term( $current_term['term_id'], $step_taxonomy );
|
346 |
+
$step_slug = $data->slug;
|
347 |
+
wp_set_object_terms( $new_step_id, $data->slug, $step_taxonomy );
|
348 |
+
|
349 |
+
// Set type.
|
350 |
+
update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
|
351 |
+
|
352 |
+
// Set flow.
|
353 |
+
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
354 |
+
|
355 |
+
CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step['title'], $step_slug );
|
356 |
+
|
357 |
+
if ( isset( $step['post_content'] ) && ! empty( $step['post_content'] ) ) {
|
358 |
+
|
359 |
+
// Download and replace images.
|
360 |
+
$content = $this->get_content( $step['post_content'] );
|
361 |
+
|
362 |
+
// Update post content.
|
363 |
+
wp_update_post(
|
364 |
+
array(
|
365 |
+
'ID' => $new_step_id,
|
366 |
+
'post_content' => $content,
|
367 |
+
)
|
368 |
+
);
|
369 |
+
}
|
370 |
+
}
|
371 |
+
}
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
add_action( 'admin_notices', array( $this, 'imported_successfully' ) );
|
376 |
+
}
|
377 |
+
|
378 |
+
/**
|
379 |
+
* Download and Replace hotlink images
|
380 |
+
*
|
381 |
+
* @since x.x.x
|
382 |
+
*
|
383 |
+
* @param string $content Mixed post content.
|
384 |
+
* @return array Hotlink image array.
|
385 |
+
*/
|
386 |
+
function get_content( $content = '' ) {
|
387 |
+
|
388 |
+
$all_links = wp_extract_urls( $content );
|
389 |
+
$image_links = array();
|
390 |
+
$image_map = array();
|
391 |
+
|
392 |
+
// Not have any link.
|
393 |
+
if ( empty( $all_links ) ) {
|
394 |
+
return $content;
|
395 |
+
}
|
396 |
+
|
397 |
+
foreach ( $all_links as $key => $link ) {
|
398 |
+
if ( preg_match( '/\.(jpg|jpeg|png|gif)/i', $link ) ) {
|
399 |
+
$image_links[] = $link;
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
// Not have any image link.
|
404 |
+
if ( empty( $image_links ) ) {
|
405 |
+
return $content;
|
406 |
+
}
|
407 |
+
|
408 |
+
foreach ( $image_links as $key => $image_url ) {
|
409 |
+
|
410 |
+
// Download remote image.
|
411 |
+
$image = array(
|
412 |
+
'url' => $image_url,
|
413 |
+
'id' => rand( 000, 999 ),
|
414 |
+
);
|
415 |
+
$downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
|
416 |
+
|
417 |
+
// Old and New image mapping links.
|
418 |
+
$image_map[ $image_url ] = $downloaded_image['url'];
|
419 |
+
}
|
420 |
+
|
421 |
+
// Replace old image links with new image links.
|
422 |
+
// vl( $content );.
|
423 |
+
// $content = esc_html( $content );.
|
424 |
+
foreach ( $image_map as $old_url => $new_url ) {
|
425 |
+
$content = str_replace( $old_url, $new_url, $content );
|
426 |
+
}
|
427 |
+
// vl( $content );.
|
428 |
+
// exit();.
|
429 |
+
wcf()->logger->import_log( '------------------------------------------------' );
|
430 |
+
wcf()->logger->import_log( '(✓) DATA Before' );
|
431 |
+
wcf()->logger->import_log( '------------------------------------------------' );
|
432 |
+
wcf()->logger->import_log( $content );
|
433 |
+
|
434 |
+
// $content = html_entity_decode( $content );
|
435 |
+
wcf()->logger->import_log( '------------------------------------------------' );
|
436 |
+
wcf()->logger->import_log( '(✓) DATA After' );
|
437 |
+
wcf()->logger->import_log( '------------------------------------------------' );
|
438 |
+
wcf()->logger->import_log( $content );
|
439 |
+
|
440 |
+
return $content;
|
441 |
+
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Imported notice
|
446 |
+
*
|
447 |
+
* @since 1.1.4
|
448 |
+
*/
|
449 |
+
function imported_successfully() {
|
450 |
+
?>
|
451 |
+
<div class="notice notice-success">
|
452 |
+
<p><?php _e( 'Successfully imported flows.', 'cartflows' ); ?></p>
|
453 |
+
</div>
|
454 |
+
<?php
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Clear Cache.
|
459 |
+
*
|
460 |
+
* @since 1.0.0
|
461 |
+
*/
|
462 |
+
public function clear_cache() {
|
463 |
+
// Clear 'Elementor' file cache.
|
464 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
465 |
+
Elementor\Plugin::$instance->files_manager->clear_cache();
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
/**
|
470 |
+
* JS Templates
|
471 |
+
*
|
472 |
+
* @since 1.0.0
|
473 |
+
*
|
474 |
+
* @return void
|
475 |
+
*/
|
476 |
+
function js_templates() {
|
477 |
+
|
478 |
+
// Loading Templates.
|
479 |
+
?>
|
480 |
+
<script type="text/template" id="tmpl-cartflows-step-loading">
|
481 |
+
<div class="template-message-block cartflows-step-loading">
|
482 |
+
<h2>
|
483 |
+
<span class="spinner"></span>
|
484 |
+
<?php _e( 'Loading Steps', 'cartflows' ); ?>
|
485 |
+
</h2>
|
486 |
+
<p class="description"><?php _e( 'Getting steps from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
|
487 |
+
</div>
|
488 |
+
</script>
|
489 |
+
|
490 |
+
<?php
|
491 |
+
// Search Templates.
|
492 |
+
?>
|
493 |
+
<script type="text/template" id="tmpl-cartflows-searching-templates">
|
494 |
+
<div class="template-message-block cartflows-searching-templates">
|
495 |
+
<h2>
|
496 |
+
<span class="spinner"></span>
|
497 |
+
<?php _e( 'Searching Template..', 'cartflows' ); ?>
|
498 |
+
</h2>
|
499 |
+
<p class="description"><?php _e( 'Getting templates from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
|
500 |
+
</div>
|
501 |
+
</script>
|
502 |
+
|
503 |
+
<?php
|
504 |
+
// CartFlows Importing Template.
|
505 |
+
?>
|
506 |
+
<script type="text/template" id="tmpl-cartflows-step-importing">
|
507 |
+
<div class="template-message-block cartflows-step-importing">
|
508 |
+
<h2><span class="spinner"></span> <?php _e( 'Importing..', 'cartflows' ); ?></h2>
|
509 |
+
</div>
|
510 |
+
</script>
|
511 |
+
|
512 |
+
<?php
|
513 |
+
// CartFlows Imported.
|
514 |
+
?>
|
515 |
+
<script type="text/template" id="tmpl-cartflows-step-imported">
|
516 |
+
<div class="template-message-block cartflows-step-imported">
|
517 |
+
<h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
|
518 |
+
<p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span></p></div>
|
519 |
+
</script>
|
520 |
+
|
521 |
+
<?php
|
522 |
+
// No templates.
|
523 |
+
?>
|
524 |
+
<script type="text/template" id="tmpl-cartflows-no-steps">
|
525 |
+
<div class="cartflows-no-steps">
|
526 |
+
<div class="template-message-block">
|
527 |
+
<h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
|
528 |
+
<p class="description"></p>
|
529 |
+
</div>
|
530 |
+
</div>
|
531 |
+
</script>
|
532 |
+
|
533 |
+
<?php
|
534 |
+
// No templates.
|
535 |
+
?>
|
536 |
+
<script type="text/template" id="tmpl-cartflows-no-flows">
|
537 |
+
<div class="cartflows-no-flows">
|
538 |
+
<div class="template-message-block">
|
539 |
+
<h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
|
540 |
+
<p class="description"></p>
|
541 |
+
</div>
|
542 |
+
</div>
|
543 |
+
</script>
|
544 |
+
|
545 |
+
<?php
|
546 |
+
// Error handling.
|
547 |
+
?>
|
548 |
+
<script type="text/template" id="tmpl-templator-error">
|
549 |
+
<div class="notice notice-error"><p>{{ data }}</p></div>
|
550 |
+
</script>
|
551 |
+
|
552 |
+
<?php
|
553 |
+
// Redirect to Elementor.
|
554 |
+
?>
|
555 |
+
<script type="text/template" id="tmpl-templator-redirect-to-elementor">
|
556 |
+
<div class="template-message-block templator-redirect-to-elementor">
|
557 |
+
<h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
|
558 |
+
<p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span><br/><br/><?php _e( 'Redirecting to the Elementor edit window.', 'cartflows' ); ?> </p></div>
|
559 |
+
</script>
|
560 |
+
|
561 |
+
<?php
|
562 |
+
/**
|
563 |
+
* Responsive Buttons
|
564 |
+
*/
|
565 |
+
?>
|
566 |
+
<script type="text/template" id="tmpl-cartflows-responsive-view">
|
567 |
+
<span class="responsive-view">
|
568 |
+
<span class="actions">
|
569 |
+
<a class="desktop" href="#"><span data-view="desktop " class="active dashicons dashicons-desktop"></span></a>
|
570 |
+
<a class="tablet" href="#"><span data-view="tablet" class="dashicons dashicons-tablet"></span></a>
|
571 |
+
<a class="mobile" href="#"><span data-view="mobile" class="dashicons dashicons-smartphone"></span></a>
|
572 |
+
</span>
|
573 |
+
</span>
|
574 |
+
</script>
|
575 |
+
|
576 |
+
<?php
|
577 |
+
// Templates data.
|
578 |
+
?>
|
579 |
+
<script type="text/template" id="tmpl-cartflows-flows-list">
|
580 |
+
|
581 |
+
<# console.log( data.items.length ) #>
|
582 |
+
<# console.log( data.items ) #>
|
583 |
+
<# if ( data.items.length ) { #>
|
584 |
+
<# for ( key in data.items ) { #>
|
585 |
+
<#
|
586 |
+
var flow_steps = [];
|
587 |
+
if( data.items[ key ].flow_steps ) {
|
588 |
+
flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
|
589 |
+
return value['id'];
|
590 |
+
});
|
591 |
+
}
|
592 |
+
#>
|
593 |
+
<div class="inner">
|
594 |
+
<div class="template">
|
595 |
+
<span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
|
596 |
+
<div class="template-screenshot">
|
597 |
+
<# if( data.items[ key ].featured_image_url ) { #>
|
598 |
+
<img src="{{ data.items[ key ].featured_image_url }}" />
|
599 |
+
<# } else { #>
|
600 |
+
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
|
601 |
+
<# } #>
|
602 |
+
</div>
|
603 |
+
<a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>flow={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
|
604 |
+
<# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
|
605 |
+
<span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
|
606 |
+
<# } #>
|
607 |
+
</span>
|
608 |
+
<div class="template-id-container">
|
609 |
+
<h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
|
610 |
+
<div class="template-actions">
|
611 |
+
|
612 |
+
<#
|
613 |
+
if( data.items[ key ].page_builder.slug ) {
|
614 |
+
required_plugin_group = data.items[ key ].page_builder.slug;
|
615 |
+
} else {
|
616 |
+
required_plugin_group = '';
|
617 |
+
}
|
618 |
+
|
619 |
+
if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
|
620 |
+
import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
|
621 |
+
} else {
|
622 |
+
import_btn_title = 'Import';
|
623 |
+
} #>
|
624 |
+
|
625 |
+
<# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
|
626 |
+
<a data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
|
627 |
+
<# } else if( CartFlowsImportVars._is_pro_active ) { #>
|
628 |
+
<a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
|
629 |
+
<# } else { #>
|
630 |
+
<a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
|
631 |
+
<# } #>
|
632 |
+
</div>
|
633 |
+
</div>
|
634 |
+
</div>
|
635 |
+
</div>
|
636 |
+
<# } #>
|
637 |
+
<# } #>
|
638 |
+
</script>
|
639 |
+
|
640 |
+
<?php
|
641 |
+
// Empty Step.
|
642 |
+
?>
|
643 |
+
<script type="text/template" id="tmpl-cartflows-create-blank-step">
|
644 |
+
<div class="inner">
|
645 |
+
<div class="template">
|
646 |
+
<span class="thumbnail site-preview cartflows-flow-preview">
|
647 |
+
<div class="template-screenshot">
|
648 |
+
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
|
649 |
+
</div>
|
650 |
+
<div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
|
651 |
+
</span>
|
652 |
+
<div class="template-id-container">
|
653 |
+
<h3 class="template-name"> Blank </h3>
|
654 |
+
<div class="template-actions">
|
655 |
+
<a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create', 'cartflows' ); ?></a>
|
656 |
+
</div>
|
657 |
+
</div>
|
658 |
+
</div>
|
659 |
+
</div>
|
660 |
+
</script>
|
661 |
+
|
662 |
+
<?php
|
663 |
+
// Templates data.
|
664 |
+
?>
|
665 |
+
<script type="text/template" id="tmpl-cartflows-steps-list">
|
666 |
+
<# if ( data.items.length ) { #>
|
667 |
+
<# for ( key in data.items ) { #>
|
668 |
+
<#
|
669 |
+
var flow_steps = [];
|
670 |
+
if( data.items[ key ].flow_steps ) {
|
671 |
+
flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
|
672 |
+
return value['id'];
|
673 |
+
});
|
674 |
+
}
|
675 |
+
#>
|
676 |
+
<div class="inner">
|
677 |
+
<div class="template">
|
678 |
+
<span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
|
679 |
+
<div class="template-screenshot">
|
680 |
+
<# if( data.items[ key ].featured_image_url ) { #>
|
681 |
+
<img src="{{ data.items[ key ].featured_image_url }}" />
|
682 |
+
<# } else { #>
|
683 |
+
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
|
684 |
+
<# } #>
|
685 |
+
</div>
|
686 |
+
<div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
|
687 |
+
<a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>step={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
|
688 |
+
<# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
|
689 |
+
<span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
|
690 |
+
<# } #>
|
691 |
+
</span>
|
692 |
+
<div class="template-id-container">
|
693 |
+
<h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
|
694 |
+
<div class="template-actions">
|
695 |
+
|
696 |
+
<#
|
697 |
+
|
698 |
+
var step_slug = data.items[ key ].step_type.slug || '';
|
699 |
+
var step_title = data.items[ key ].step_type.name || '';
|
700 |
+
var import_btn_title = 'Import';
|
701 |
+
|
702 |
+
var required_plugin_group = '';
|
703 |
+
if( data.items[ key ].page_builder ) {
|
704 |
+
required_plugin_group = data.items[ key ].page_builder.slug;
|
705 |
+
|
706 |
+
if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
|
707 |
+
import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
|
708 |
+
}
|
709 |
+
}
|
710 |
+
#>
|
711 |
+
|
712 |
+
<# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
|
713 |
+
<a data-slug="{{step_slug}}" data-title="{{step_title}}" data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
|
714 |
+
<# } else if( CartFlowsImportVars._is_pro_active ) { #>
|
715 |
+
<a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
|
716 |
+
<# } else { #>
|
717 |
+
<a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
|
718 |
+
<# } #>
|
719 |
+
</div>
|
720 |
+
</div>
|
721 |
+
</div>
|
722 |
+
</div>
|
723 |
+
<# } #>
|
724 |
+
<# } #>
|
725 |
+
</script>
|
726 |
+
|
727 |
+
<?php
|
728 |
+
/**
|
729 |
+
* TMPL - Website Unreachable
|
730 |
+
*/
|
731 |
+
?>
|
732 |
+
<script type="text/template" id="tmpl-cartflows-website-unreachable">
|
733 |
+
<div class="postbox cartflows-website-unreachable">
|
734 |
+
<h2><?php _e( 'Under Maintenance..', 'cartflows' ); ?></h2>
|
735 |
+
<p><?php _e( 'If you are seeing this message, most likely our servers are under routine maintenance and we will be back shortly.', 'cartflows' ); ?></p>
|
736 |
+
<p><?php _e( 'In rare case, it is possible your website is having trouble connecting with ours. If you need help, please feel free to get in touch with us from our website..', 'cartflows' ); ?></p>
|
737 |
+
</div>
|
738 |
+
</script>
|
739 |
+
|
740 |
+
<?php
|
741 |
+
/**
|
742 |
+
* TMPL - Filters
|
743 |
+
*/
|
744 |
+
?>
|
745 |
+
<script type="text/template" id="tmpl-cartflows-page-builder-notice">
|
746 |
+
<?php
|
747 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
748 |
+
$page_builder = Cartflows_Helper::get_required_plugins_for_page_builder( Cartflows_Helper::get_common_setting( 'default_page_builder' ) );
|
749 |
+
$title = $page_builder['title'];
|
750 |
+
|
751 |
+
$plugin_string = '<a href="#" data-slug="' . esc_html( $default_page_builder ) . '" class="wcf-install-plugin">Please click here and activate ' . esc_html( $title ) . '</a>';
|
752 |
+
$theme_status = '';
|
753 |
+
if ( 'divi' === $default_page_builder ) {
|
754 |
+
|
755 |
+
$theme_status = $page_builder['theme-status'];
|
756 |
+
$plugin_status = $page_builder['plugin-status'];
|
757 |
+
|
758 |
+
if ( 'deactivate' === $theme_status || 'install' === $plugin_status ) {
|
759 |
+
$plugin_string = 'Please activate ' . esc_html( $title );
|
760 |
+
} elseif ( ( 'deactivate' === $theme_status || 'not-installed' === $theme_status ) && 'install' === $plugin_status ) {
|
761 |
+
$plugin_string = 'Please install and activate ' . esc_html( $title );
|
762 |
+
}
|
763 |
+
}
|
764 |
+
?>
|
765 |
+
<div class="wcf-page-builder-message">
|
766 |
+
<p><?php /* translators: %s: Plugin string */ printf( __( '%1$s to see CartFlows templates. If you prefer another page builder tool, you can <a href="%2$s" target="blank">select it here</a>.', 'cartflows' ), $plugin_string, admin_url( 'admin.php?page=' . CARTFLOWS_SETTINGS . '&action=common-settings#form-field-wcf_default_page_builder' ) ); ?></p>
|
767 |
+
<p>If your preferred page builder is not available, feel free to <a href="#" data-slug="canvas" class="wcf-create-from-scratch-link">create your own</a> pages using page builder of your choice as CartFlows works with all major page builders.</p>
|
768 |
+
<p>We plan to add design templates made with more page builder shortly!</p>
|
769 |
+
</div>
|
770 |
+
</script>
|
771 |
+
|
772 |
+
<?php
|
773 |
+
/**
|
774 |
+
* TMPL - Filters
|
775 |
+
*/
|
776 |
+
?>
|
777 |
+
<script type="text/template" id="tmpl-cartflows-term-filters-dropdown">
|
778 |
+
<# if ( data ) { #>
|
779 |
+
<select class="{{ data.args.wrapper_class }} {{ data.args.class }}">
|
780 |
+
<# if ( data.args.show_all ) { #>
|
781 |
+
<option value="all"> <?php _e( 'All', 'cartflows' ); ?> </option>
|
782 |
+
<# } #>
|
783 |
+
<# if ( CartFlowsImportVars.step_type === data.args.remote_slug ) { #>
|
784 |
+
<option value=""> <?php _e( 'Select Step Type', 'cartflows' ); ?> </option>
|
785 |
+
<# } #>
|
786 |
+
<# for ( key in data.items ) { #>
|
787 |
+
<option value='{{ data.items[ key ].id }}' data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</option>
|
788 |
+
<# } #>
|
789 |
+
</select>
|
790 |
+
<# } #>
|
791 |
+
</script>
|
792 |
+
|
793 |
+
<script type="text/template" id="tmpl-cartflows-term-filters">
|
794 |
+
|
795 |
+
<# if ( data ) { #>
|
796 |
+
|
797 |
+
<?php /* <# if ( CartFlowsImportVars.flow_page_builder === data.args.remote_slug || CartFlowsImportVars.step_page_builder === data.args.remote_slug ) { #> */ ?>
|
798 |
+
<ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
|
799 |
+
|
800 |
+
<# if ( data.args.show_all ) { #>
|
801 |
+
<li>
|
802 |
+
<a href="#" data-group="all"> All </a>
|
803 |
+
</li>
|
804 |
+
<# } #>
|
805 |
+
|
806 |
+
<# for ( key in data.items ) { #>
|
807 |
+
<li>
|
808 |
+
<a href="#" data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</a>
|
809 |
+
</li>
|
810 |
+
<# } #>
|
811 |
+
|
812 |
+
</ul>
|
813 |
+
|
814 |
+
<?php
|
815 |
+
|
816 |
+
/*
|
817 |
+
<# } else { #>
|
818 |
+
<select class="{{ data.args.wrapper_class }} {{ data.args.class }}">
|
819 |
+
|
820 |
+
<# if ( data.args.show_all ) { #>
|
821 |
+
<option value="all"> <?php _e( 'All', 'cartflows' ); ?> </option>
|
822 |
+
<# } #>
|
823 |
+
|
824 |
+
<# if ( CartFlowsImportVars.step_type === data.args.remote_slug ) { #>
|
825 |
+
<option value=""> <?php _e( 'Select Step Type', 'cartflows' ); ?> </option>
|
826 |
+
<# } #>
|
827 |
+
|
828 |
+
<# for ( key in data.items ) { #>
|
829 |
+
<option value='{{ data.items[ key ].id }}' data-group='{{ data.items[ key ].id }}' class="{{ data.items[ key ].name }}" data-slug="{{ data.items[ key ].slug }}" data-title="{{ data.items[ key ].name }}">{{ data.items[ key ].name }}</option>
|
830 |
+
<# } #>
|
831 |
+
|
832 |
+
</select>
|
833 |
+
*/
|
834 |
+
?>
|
835 |
+
|
836 |
+
<?php /* <# } #> */ ?>
|
837 |
+
|
838 |
+
<# } #>
|
839 |
+
</script>
|
840 |
+
|
841 |
+
<?php
|
842 |
+
// Step Type.
|
843 |
+
?>
|
844 |
+
<script type="text/template" id="tmpl-cartflows-step-types">
|
845 |
+
<ul class="wcf-tab nav-tabs">
|
846 |
+
<# if( data.items_count ) { #>
|
847 |
+
<# for( key in data.items ) { #>
|
848 |
+
<# console.log( data.items[ key ].id ) #>
|
849 |
+
<li data-slug="{{data.items[ key ].slug}}" data-title="{{ data.items[ key ].name }}">
|
850 |
+
<a href="#{{{ data.items[ key ].slug }}}">{{{ data.items[ key ].name }}}</a>
|
851 |
+
</li>
|
852 |
+
<# } #>
|
853 |
+
<# } #>
|
854 |
+
</ul>
|
855 |
+
</script>
|
856 |
+
|
857 |
+
<?php
|
858 |
+
// Add to library button.
|
859 |
+
?>
|
860 |
+
<script type="text/template" id="tmpl-templator-add-to-library">
|
861 |
+
<a class="templator-add-to-library page-title-action cartflows-load-steps-library"><i class="dashicons dashicons-cloud"></i><?php esc_attr_e( 'Import from Cloud', 'cartflows' ); ?></a>
|
862 |
+
</script>
|
863 |
+
<?php
|
864 |
+
}
|
865 |
+
|
866 |
+
/**
|
867 |
+
* Enqueue scripts
|
868 |
+
*
|
869 |
+
* @since 1.0.0
|
870 |
+
*
|
871 |
+
* @hook admin_enqueue_scripts
|
872 |
+
* @param string $hook Current page hook.
|
873 |
+
*/
|
874 |
+
function scripts( $hook = '' ) {
|
875 |
+
|
876 |
+
if ( ! self::is_supported_post( get_current_screen()->post_type ) ) {
|
877 |
+
return;
|
878 |
+
}
|
879 |
+
|
880 |
+
wp_enqueue_script( 'cartflows-rest-api', CARTFLOWS_URL . 'assets/js/rest-api.js', array( 'jquery' ), CARTFLOWS_VER, true );
|
881 |
+
wp_enqueue_style( 'cartflows-import', CARTFLOWS_URL . 'assets/css/import.css', null, CARTFLOWS_VER, 'all' );
|
882 |
+
wp_style_add_data( 'cartflows-import', 'rtl', 'replace' );
|
883 |
+
wp_enqueue_script( 'cartflows-import', CARTFLOWS_URL . 'assets/js/import.js', array( 'jquery', 'wp-util', 'cartflows-rest-api', 'updates' ), CARTFLOWS_VER, true );
|
884 |
+
|
885 |
+
$localize_vars = array(
|
886 |
+
'_is_pro_active' => _is_cartflows_pro(),
|
887 |
+
|
888 |
+
// Flow and its rest fields.
|
889 |
+
'flow' => CARTFLOWS_FLOW_POST_TYPE,
|
890 |
+
'flow_fields' => array(
|
891 |
+
'id',
|
892 |
+
'title',
|
893 |
+
'flow_type',
|
894 |
+
'page_builder',
|
895 |
+
'flow_steps',
|
896 |
+
'licence_status',
|
897 |
+
'featured_image_url',
|
898 |
+
'featured_media', // @required for field `featured_image_url`.
|
899 |
+
),
|
900 |
+
|
901 |
+
// Flow type and rest fields.
|
902 |
+
'flow_type' => CARTFLOWS_TAXONOMY_FLOW_CATEGORY,
|
903 |
+
'flow_type_fields' => array(
|
904 |
+
'id',
|
905 |
+
'name',
|
906 |
+
'slug',
|
907 |
+
),
|
908 |
+
|
909 |
+
// Flow page builder and rest fields.
|
910 |
+
'flow_page_builder' => CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER,
|
911 |
+
'flow_page_builder_fields' => array(
|
912 |
+
'id',
|
913 |
+
'name',
|
914 |
+
'slug',
|
915 |
+
),
|
916 |
+
|
917 |
+
// Step page builder and rest fields.
|
918 |
+
'step_page_builder' => CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER,
|
919 |
+
'step_page_builder_fields' => array(
|
920 |
+
'id',
|
921 |
+
'name',
|
922 |
+
'slug',
|
923 |
+
),
|
924 |
+
|
925 |
+
// Step and its rest fields.
|
926 |
+
'step' => CARTFLOWS_STEP_POST_TYPE,
|
927 |
+
'step_fields' => array(
|
928 |
+
'title',
|
929 |
+
'featured_image_url',
|
930 |
+
'featured_media', // @required for field `featured_image_url`.
|
931 |
+
'id',
|
932 |
+
'flow_type',
|
933 |
+
'step_type',
|
934 |
+
'page_builder',
|
935 |
+
'licence_status',
|
936 |
+
),
|
937 |
+
|
938 |
+
// Step type and its rest fields.
|
939 |
+
'step_type' => CARTFLOWS_TAXONOMY_STEP_TYPE,
|
940 |
+
'step_type_fields' => array(
|
941 |
+
'id',
|
942 |
+
'name',
|
943 |
+
'slug',
|
944 |
+
),
|
945 |
+
|
946 |
+
'domain_url' => CARTFLOWS_DOMAIN_URL,
|
947 |
+
'server_url' => CARTFLOWS_TEMPLATES_URL,
|
948 |
+
'server_rest_url' => CARTFLOWS_TEMPLATES_URL . 'wp-json/wp/v2/',
|
949 |
+
'site_url' => site_url(),
|
950 |
+
'import_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_importer' ),
|
951 |
+
'export_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_exporter' ),
|
952 |
+
'admin_url' => admin_url(),
|
953 |
+
'licence_args' => CartFlows_API::get_instance()->get_licence_args(),
|
954 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
955 |
+
'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
|
956 |
+
|
957 |
+
'required_plugins' => Cartflows_Helper::get_plugins_groupby_page_builders(),
|
958 |
+
|
959 |
+
'default_page_builder' => Cartflows_Helper::get_common_setting( 'default_page_builder' ),
|
960 |
+
);
|
961 |
+
|
962 |
+
// var_dump(Cartflows_Helper::get_common_setting( 'default_page_builder' ));
|
963 |
+
// wp_die( );
|
964 |
+
// Add thickbox.
|
965 |
+
add_thickbox();
|
966 |
+
|
967 |
+
wp_localize_script( 'cartflows-import', 'CartFlowsImportVars', $localize_vars );
|
968 |
+
wp_localize_script( 'cartflows-rest-api', 'CartFlowsImportVars', $localize_vars );
|
969 |
+
}
|
970 |
+
|
971 |
+
/**
|
972 |
+
* Load Template
|
973 |
+
*
|
974 |
+
* @since 1.0.0
|
975 |
+
*
|
976 |
+
* @hook cartflows_load_steps
|
977 |
+
* @return void
|
978 |
+
*/
|
979 |
+
function load_templates() {
|
980 |
+
|
981 |
+
check_ajax_referer( 'cf-load-steps', 'security' );
|
982 |
+
|
983 |
+
$args = ( isset( $_POST['args'] ) ) ? array_map( 'sanitize_text_field', $_POST['args'] ) : array();
|
984 |
+
$templates = CartFlows_API::get_instance()->get_templates( $args );
|
985 |
+
|
986 |
+
if ( $templates['templates_count'] ) {
|
987 |
+
wp_send_json_success( $templates );
|
988 |
+
} else {
|
989 |
+
wp_send_json_error( $templates );
|
990 |
+
}
|
991 |
+
wp_die();
|
992 |
+
}
|
993 |
+
|
994 |
+
/**
|
995 |
+
* Import.
|
996 |
+
*
|
997 |
+
* @since 1.0.0
|
998 |
+
*
|
999 |
+
* @hook wp_ajax_cartflows_import_flow_step
|
1000 |
+
* @return void
|
1001 |
+
*/
|
1002 |
+
function import_flow() {
|
1003 |
+
|
1004 |
+
check_ajax_referer( 'cf-import-flow-step', 'security' );
|
1005 |
+
|
1006 |
+
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1007 |
+
$template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
|
1008 |
+
|
1009 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1010 |
+
wcf()->logger->import_log( 'STARTED! Importing FLOW' );
|
1011 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1012 |
+
wcf()->logger->import_log( '(✓) Creating new step from remote step [' . $template_id . '] for FLOW ' . get_the_title( $flow_id ) . ' [' . $flow_id . ']' );
|
1013 |
+
|
1014 |
+
$response = CartFlows_API::get_instance()->get_template( $template_id );
|
1015 |
+
// vl( $response );.
|
1016 |
+
// wp_die();.
|
1017 |
+
if ( false === $response['success'] ) {
|
1018 |
+
wcf()->logger->import_log( '(✕) Failed to fetch remote data.' );
|
1019 |
+
wp_send_json_error( $response );
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
wcf()->logger->import_log( '(✓) Successfully getting remote step response ' . json_encode( $response ) );
|
1023 |
+
|
1024 |
+
$content = isset( $response['data']['content']->rendered ) ? $response['data']['content']->rendered : '';
|
1025 |
+
$new_step_id = wp_insert_post(
|
1026 |
+
array(
|
1027 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
1028 |
+
'post_title' => $response['title'],
|
1029 |
+
'post_content' => $content,
|
1030 |
+
'post_status' => 'publish',
|
1031 |
+
)
|
1032 |
+
);
|
1033 |
+
|
1034 |
+
if ( is_wp_error( $new_step_id ) ) {
|
1035 |
+
wcf()->logger->import_log( '(✕) Failed to create new step for flow ' . $flow_id );
|
1036 |
+
wp_send_json_error( $new_step_id );
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
if ( 'divi' === Cartflows_Helper::get_common_setting( 'default_page_builder' ) ) {
|
1040 |
+
if ( isset( $response['data']['divi_content'] ) && ! empty( $response['data']['divi_content'] ) ) {
|
1041 |
+
update_post_meta( $new_step_id, 'divi_content', $response['data']['divi_content'] );
|
1042 |
+
}
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id );
|
1046 |
+
// insert post meta.
|
1047 |
+
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
1048 |
+
wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' );
|
1049 |
+
|
1050 |
+
/**
|
1051 |
+
* Import & Set type.
|
1052 |
+
*/
|
1053 |
+
$term = isset( $response['data']['step_type'] ) ? $response['data']['step_type'] : '';
|
1054 |
+
$term_slug = '';
|
1055 |
+
if ( $term ) {
|
1056 |
+
|
1057 |
+
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
1058 |
+
$term_exist = term_exists( $term->name, $taxonomy );
|
1059 |
+
|
1060 |
+
if ( empty( $term_exist ) ) {
|
1061 |
+
$terms = array(
|
1062 |
+
array(
|
1063 |
+
'name' => $term->name,
|
1064 |
+
),
|
1065 |
+
);
|
1066 |
+
|
1067 |
+
Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
|
1068 |
+
wcf()->logger->import_log( '(✓) Created new term ' . $term->name );
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
$current_term = term_exists( $term->name, $taxonomy );
|
1072 |
+
|
1073 |
+
// Set type object.
|
1074 |
+
$data = get_term( $current_term['term_id'], $taxonomy );
|
1075 |
+
$term_slug = $data->slug;
|
1076 |
+
$term_name = $data->name;
|
1077 |
+
wp_set_object_terms( $new_step_id, $term_slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
1078 |
+
wcf()->logger->import_log( '(✓) Assigned existing term ' . $term_name . ' to the template ' . $new_step_id );
|
1079 |
+
|
1080 |
+
// Set type.
|
1081 |
+
update_post_meta( $new_step_id, 'wcf-step-type', $term_slug );
|
1082 |
+
wcf()->logger->import_log( '(✓) Updated term ' . $term_name . ' to the post meta wcf-step-type.' );
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
// Set flow.
|
1086 |
+
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
1087 |
+
wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
|
1088 |
+
|
1089 |
+
/**
|
1090 |
+
* Update steps for the current flow.
|
1091 |
+
*/
|
1092 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
1093 |
+
|
1094 |
+
if ( ! is_array( $flow_steps ) ) {
|
1095 |
+
$flow_steps = array();
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
$flow_steps[] = array(
|
1099 |
+
'id' => $new_step_id,
|
1100 |
+
'title' => $response['title'],
|
1101 |
+
'type' => $term_slug,
|
1102 |
+
);
|
1103 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1104 |
+
wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
|
1105 |
+
|
1106 |
+
// Import Post Meta.
|
1107 |
+
self::import_post_meta( $new_step_id, $response );
|
1108 |
+
|
1109 |
+
wcf()->logger->import_log( '(✓) Importing step "' . get_the_title( $new_step_id ) . '" [' . $new_step_id . '] for FLOW "' . get_the_title( $flow_id ) . '" [' . $flow_id . ']' );
|
1110 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1111 |
+
wcf()->logger->import_log( 'COMPLETE! Importing FLOW' );
|
1112 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1113 |
+
|
1114 |
+
do_action( 'cartflows_import_complete' );
|
1115 |
+
wcf()->logger->import_log( '(✓) BATCH STARTED for step ' . $new_step_id . ' for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' );
|
1116 |
+
|
1117 |
+
// Batch Process.
|
1118 |
+
do_action( 'cartflows_after_template_import', $new_step_id, $response );
|
1119 |
+
|
1120 |
+
/**
|
1121 |
+
* End
|
1122 |
+
*/
|
1123 |
+
wp_send_json_success( $new_step_id );
|
1124 |
+
}
|
1125 |
+
|
1126 |
+
/**
|
1127 |
+
* Import Step.
|
1128 |
+
*
|
1129 |
+
* @since 1.0.0
|
1130 |
+
* @hook wp_ajax_cartflows_step_import
|
1131 |
+
*
|
1132 |
+
* @return void
|
1133 |
+
*/
|
1134 |
+
function create_default_flow() {
|
1135 |
+
|
1136 |
+
check_ajax_referer( 'cf-default-flow', 'security' );
|
1137 |
+
|
1138 |
+
// Create post object.
|
1139 |
+
$new_flow_post = array(
|
1140 |
+
'post_content' => '',
|
1141 |
+
'post_status' => 'publish',
|
1142 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
1143 |
+
);
|
1144 |
+
|
1145 |
+
// Insert the post into the database.
|
1146 |
+
$flow_id = wp_insert_post( $new_flow_post );
|
1147 |
+
|
1148 |
+
if ( is_wp_error( $flow_id ) ) {
|
1149 |
+
wp_send_json_error( $flow_id->get_error_message() );
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
$flow_steps = array();
|
1153 |
+
|
1154 |
+
$steps_data = array(
|
1155 |
+
'landing' => __( 'Landing Page', 'cartflows' ),
|
1156 |
+
'checkout' => __( 'Checkout Page', 'cartflows' ),
|
1157 |
+
'thankyou' => __( 'Thank You Page', 'cartflows' ),
|
1158 |
+
);
|
1159 |
+
|
1160 |
+
foreach ( $steps_data as $slug => $title ) {
|
1161 |
+
|
1162 |
+
$post_content = '';
|
1163 |
+
|
1164 |
+
switch ( $slug ) {
|
1165 |
+
case 'checkout':
|
1166 |
+
$post_content = '';
|
1167 |
+
break;
|
1168 |
+
case 'thankyou':
|
1169 |
+
$post_content = '';
|
1170 |
+
break;
|
1171 |
+
default:
|
1172 |
+
$post_content = '';
|
1173 |
+
break;
|
1174 |
+
}
|
1175 |
+
|
1176 |
+
$step_id = wp_insert_post(
|
1177 |
+
array(
|
1178 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
1179 |
+
'post_title' => $title,
|
1180 |
+
'post_content' => $post_content,
|
1181 |
+
'post_status' => 'publish',
|
1182 |
+
)
|
1183 |
+
);
|
1184 |
+
|
1185 |
+
if ( is_wp_error( $step_id ) ) {
|
1186 |
+
wp_send_json_error( $step_id->get_error_message() );
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
if ( $step_id ) {
|
1190 |
+
|
1191 |
+
$flow_steps[] = array(
|
1192 |
+
'id' => $step_id,
|
1193 |
+
'title' => $title,
|
1194 |
+
'type' => $slug,
|
1195 |
+
);
|
1196 |
+
|
1197 |
+
// insert post meta.
|
1198 |
+
update_post_meta( $step_id, 'wcf-flow-id', $flow_id );
|
1199 |
+
update_post_meta( $step_id, 'wcf-step-type', $slug );
|
1200 |
+
|
1201 |
+
wp_set_object_terms( $step_id, $slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
1202 |
+
wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
1203 |
+
}
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1207 |
+
|
1208 |
+
wp_send_json_success( $flow_id );
|
1209 |
+
}
|
1210 |
+
|
1211 |
+
/**
|
1212 |
+
* Create Flow
|
1213 |
+
*
|
1214 |
+
* @return void
|
1215 |
+
*/
|
1216 |
+
function create_flow() {
|
1217 |
+
|
1218 |
+
check_ajax_referer( 'cf-create-flow', 'security' );
|
1219 |
+
|
1220 |
+
// Create post object.
|
1221 |
+
$new_flow_post = array(
|
1222 |
+
'post_content' => '',
|
1223 |
+
'post_status' => 'publish',
|
1224 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
1225 |
+
);
|
1226 |
+
|
1227 |
+
// Insert the post into the database.
|
1228 |
+
$flow_id = wp_insert_post( $new_flow_post );
|
1229 |
+
|
1230 |
+
if ( is_wp_error( $flow_id ) ) {
|
1231 |
+
wp_send_json_error( $flow_id->get_error_message() );
|
1232 |
+
}
|
1233 |
+
|
1234 |
+
wp_send_json_success( $flow_id );
|
1235 |
+
}
|
1236 |
+
|
1237 |
+
/**
|
1238 |
+
* Create Step
|
1239 |
+
*
|
1240 |
+
* @return void
|
1241 |
+
*/
|
1242 |
+
function import_step() {
|
1243 |
+
|
1244 |
+
check_ajax_referer( 'cf-step-import', 'security' );
|
1245 |
+
|
1246 |
+
$template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
|
1247 |
+
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1248 |
+
$step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
|
1249 |
+
$step_type = isset( $_POST['step_type'] ) ? sanitize_title( $_POST['step_type'] ) : '';
|
1250 |
+
$step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( $_POST['step_custom_title'] ) : $step_title;
|
1251 |
+
|
1252 |
+
$cartflow_meta = Cartflows_Flow_Meta::get_instance();
|
1253 |
+
|
1254 |
+
$post_id = $cartflow_meta->create_step( $flow_id, $step_type, $step_custom_title );
|
1255 |
+
|
1256 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1257 |
+
wcf()->logger->import_log( 'STARTED! Importing STEP' );
|
1258 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1259 |
+
|
1260 |
+
if ( empty( $template_id ) || empty( $post_id ) ) {
|
1261 |
+
/* translators: %s: template ID */
|
1262 |
+
$data = sprintf( __( 'Invalid template id %1$s or post id %2$s.', 'cartflows' ), $template_id, $post_id );
|
1263 |
+
wcf()->logger->import_log( $data );
|
1264 |
+
wp_send_json_error( $data );
|
1265 |
+
}
|
1266 |
+
|
1267 |
+
wcf()->logger->import_log( 'Remote Step ' . $template_id . ' for local flow "' . get_the_title( $post_id ) . '" [' . $post_id . ']' );
|
1268 |
+
|
1269 |
+
$response = CartFlows_API::get_instance()->get_template( $template_id );
|
1270 |
+
|
1271 |
+
// vl( $response );.
|
1272 |
+
// wp_die();.
|
1273 |
+
if ( 'divi' === Cartflows_Helper::get_common_setting( 'default_page_builder' ) ) {
|
1274 |
+
if ( isset( $response['data']['divi_content'] ) && ! empty( $response['data']['divi_content'] ) ) {
|
1275 |
+
update_post_meta( $post_id, 'divi_content', $response['data']['divi_content'] );
|
1276 |
+
}
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
// Import Post Meta.
|
1280 |
+
self::import_post_meta( $post_id, $response );
|
1281 |
+
|
1282 |
+
do_action( 'cartflows_import_complete' );
|
1283 |
+
|
1284 |
+
// Batch Process.
|
1285 |
+
do_action( 'cartflows_after_template_import', $post_id, $response );
|
1286 |
+
|
1287 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1288 |
+
wcf()->logger->import_log( 'COMPLETE! Importing Step' );
|
1289 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1290 |
+
|
1291 |
+
wp_send_json_success( $post_id );
|
1292 |
+
}
|
1293 |
+
|
1294 |
+
/**
|
1295 |
+
* Import Step.
|
1296 |
+
*
|
1297 |
+
* @since 1.0.0
|
1298 |
+
* @hook wp_ajax_cartflows_step_create_blank
|
1299 |
+
*
|
1300 |
+
* @return void
|
1301 |
+
*/
|
1302 |
+
function step_create_blank() {
|
1303 |
+
|
1304 |
+
check_ajax_referer( 'cf-step-create-blank', 'security' );
|
1305 |
+
|
1306 |
+
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1307 |
+
$step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( $_POST['step_type'] ) : '';
|
1308 |
+
$step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
|
1309 |
+
|
1310 |
+
if ( empty( $flow_id ) || empty( $step_type ) ) {
|
1311 |
+
/* translators: %s: flow ID */
|
1312 |
+
$data = sprintf( __( 'Invalid flow id %1$s OR step type %2$s.', 'cartflows' ), $flow_id, $step_type );
|
1313 |
+
wcf()->logger->import_log( $data );
|
1314 |
+
wp_send_json_error( $data );
|
1315 |
+
}
|
1316 |
+
|
1317 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1318 |
+
wcf()->logger->import_log( 'STARTED! Creating Blank STEP for Flow ' . $flow_id );
|
1319 |
+
|
1320 |
+
$step_type_title = str_replace( '-', ' ', $step_type );
|
1321 |
+
$step_type_slug = strtolower( str_replace( '-', ' ', $step_type ) );
|
1322 |
+
|
1323 |
+
$new_step_id = wp_insert_post(
|
1324 |
+
array(
|
1325 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
1326 |
+
'post_title' => $step_title,
|
1327 |
+
'post_content' => '',
|
1328 |
+
'post_status' => 'publish',
|
1329 |
+
)
|
1330 |
+
);
|
1331 |
+
|
1332 |
+
// insert post meta.
|
1333 |
+
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
1334 |
+
|
1335 |
+
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
1336 |
+
$term_exist = term_exists( $step_type_title, $taxonomy );
|
1337 |
+
|
1338 |
+
if ( empty( $term_exist ) ) {
|
1339 |
+
$terms = array(
|
1340 |
+
array(
|
1341 |
+
'name' => $step_type_title,
|
1342 |
+
),
|
1343 |
+
);
|
1344 |
+
|
1345 |
+
Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
|
1346 |
+
wcf()->logger->import_log( '(✓) Created new term ' . $step_type_title );
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
$current_term = term_exists( $step_type_title, $taxonomy );
|
1350 |
+
|
1351 |
+
// Set type object.
|
1352 |
+
$data = get_term( $current_term['term_id'], $taxonomy );
|
1353 |
+
$step_slug = $data->slug;
|
1354 |
+
wp_set_object_terms( $new_step_id, $data->slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
1355 |
+
wcf()->logger->import_log( '(✓) Assigned existing term ' . $step_type_title . ' to the template ' . $new_step_id );
|
1356 |
+
|
1357 |
+
// Set type.
|
1358 |
+
update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
|
1359 |
+
wcf()->logger->import_log( '(✓) Updated term ' . $data->name . ' to the post meta wcf-step-type.' );
|
1360 |
+
|
1361 |
+
// Set flow.
|
1362 |
+
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
1363 |
+
wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
|
1364 |
+
|
1365 |
+
CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step_type_title, $step_slug );
|
1366 |
+
|
1367 |
+
wcf()->logger->import_log( 'COMPLETE! Creating Blank STEP for Flow ' . $flow_id );
|
1368 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1369 |
+
|
1370 |
+
wp_send_json_success( $new_step_id );
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
/**
|
1374 |
+
* Import Post Meta
|
1375 |
+
*
|
1376 |
+
* @since 1.0.0
|
1377 |
+
*
|
1378 |
+
* @param integer $post_id Post ID.
|
1379 |
+
* @param array $response Post meta.
|
1380 |
+
* @return void
|
1381 |
+
*/
|
1382 |
+
public static function import_post_meta( $post_id, $response ) {
|
1383 |
+
|
1384 |
+
$metadata = (array) $response['post_meta'];
|
1385 |
+
|
1386 |
+
foreach ( $metadata as $meta_key => $meta_value ) {
|
1387 |
+
$meta_value = isset( $meta_value[0] ) ? $meta_value[0] : '';
|
1388 |
+
|
1389 |
+
if ( $meta_value ) {
|
1390 |
+
|
1391 |
+
if ( is_serialized( $meta_value, true ) ) {
|
1392 |
+
$raw_data = maybe_unserialize( stripslashes( $meta_value ) );
|
1393 |
+
} elseif ( is_array( $meta_value ) ) {
|
1394 |
+
$raw_data = json_decode( stripslashes( $meta_value ), true );
|
1395 |
+
} else {
|
1396 |
+
$raw_data = $meta_value;
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
if ( '_elementor_data' === $meta_key ) {
|
1400 |
+
if ( is_array( $raw_data ) ) {
|
1401 |
+
$raw_data = wp_slash( json_encode( $raw_data ) );
|
1402 |
+
} else {
|
1403 |
+
$raw_data = wp_slash( $raw_data );
|
1404 |
+
}
|
1405 |
+
}
|
1406 |
+
if ( '_elementor_data' !== $meta_key && '_elementor_draft' !== $meta_key && '_fl_builder_data' !== $meta_key && '_fl_builder_draft' !== $meta_key ) {
|
1407 |
+
if ( is_array( $raw_data ) ) {
|
1408 |
+
wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . json_encode( $raw_data ) );
|
1409 |
+
} else {
|
1410 |
+
if ( ! is_object( $raw_data ) ) {
|
1411 |
+
wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data );
|
1412 |
+
}
|
1413 |
+
}
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
update_post_meta( $post_id, $meta_key, $raw_data );
|
1417 |
+
}
|
1418 |
+
}
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
/**
|
1422 |
+
* Import Template for Elementor
|
1423 |
+
*
|
1424 |
+
* @since 1.0.0
|
1425 |
+
*
|
1426 |
+
* @param integer $post_id Post ID.
|
1427 |
+
* @param array $response Post meta.
|
1428 |
+
* @param array $page_build_data Page build data.
|
1429 |
+
* @return void
|
1430 |
+
*/
|
1431 |
+
public static function import_template_elementor( $post_id, $response, $page_build_data ) {
|
1432 |
+
if ( ! is_plugin_active( 'elementor/elementor.php' ) ) {
|
1433 |
+
$data = __( 'Elementor is not activated. Please activate plugin Elementor Page Builder to import the step.', 'cartflows' );
|
1434 |
+
wcf()->logger->import_log( $data );
|
1435 |
+
wp_send_json_error( $data );
|
1436 |
+
}
|
1437 |
+
|
1438 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
|
1439 |
+
|
1440 |
+
wcf()->logger->import_log( '# Started "importing page builder data" for step ' . $post_id );
|
1441 |
+
|
1442 |
+
$obj = new \Elementor\TemplateLibrary\CartFlows_Importer_Elementor();
|
1443 |
+
$obj->import_single_template( $post_id );
|
1444 |
+
|
1445 |
+
wcf()->logger->import_log( '# Complete "importing page builder data" for step ' . $post_id );
|
1446 |
+
}
|
1447 |
+
|
1448 |
+
/**
|
1449 |
+
* Supported post types
|
1450 |
+
*
|
1451 |
+
* @since 1.0.0
|
1452 |
+
*
|
1453 |
+
* @return array Supported post types.
|
1454 |
+
*/
|
1455 |
+
public static function supported_post_types() {
|
1456 |
+
return apply_filters(
|
1457 |
+
'cartflows_supported_post_types',
|
1458 |
+
array(
|
1459 |
+
CARTFLOWS_FLOW_POST_TYPE,
|
1460 |
+
)
|
1461 |
+
);
|
1462 |
+
}
|
1463 |
+
|
1464 |
+
/**
|
1465 |
+
* Check supported post type
|
1466 |
+
*
|
1467 |
+
* @since 1.0.0
|
1468 |
+
*
|
1469 |
+
* @param string $post_type Post type.
|
1470 |
+
* @return boolean Supported post type status.
|
1471 |
+
*/
|
1472 |
+
public static function is_supported_post( $post_type = '' ) {
|
1473 |
+
if ( in_array( $post_type, self::supported_post_types() ) ) {
|
1474 |
+
return true;
|
1475 |
+
}
|
1476 |
+
|
1477 |
+
return false;
|
1478 |
+
}
|
1479 |
+
|
1480 |
+
/**
|
1481 |
+
* Set steps to the flow
|
1482 |
+
*
|
1483 |
+
* @param integer $flow_id Flow ID.
|
1484 |
+
* @param integer $new_step_id New step ID.
|
1485 |
+
* @param string $step_title Flow Type.
|
1486 |
+
* @param string $step_slug Flow Type.
|
1487 |
+
*/
|
1488 |
+
function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) {
|
1489 |
+
// Update steps for the current flow.
|
1490 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
1491 |
+
|
1492 |
+
if ( ! is_array( $flow_steps ) ) {
|
1493 |
+
$flow_steps = array();
|
1494 |
+
}
|
1495 |
+
|
1496 |
+
$flow_steps[] = array(
|
1497 |
+
'id' => $new_step_id,
|
1498 |
+
'title' => $step_title,
|
1499 |
+
'type' => $step_slug,
|
1500 |
+
);
|
1501 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1502 |
+
wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
|
1503 |
+
}
|
1504 |
+
|
1505 |
+
/**
|
1506 |
+
* Localize variables in admin
|
1507 |
+
*
|
1508 |
+
* @param array $vars variables.
|
1509 |
+
*/
|
1510 |
+
function localize_vars( $vars ) {
|
1511 |
+
|
1512 |
+
$ajax_actions = array(
|
1513 |
+
'cf_step_import',
|
1514 |
+
'cf_load_steps',
|
1515 |
+
'cf_create_flow',
|
1516 |
+
'cf_default_flow',
|
1517 |
+
'cf_step_create_blank',
|
1518 |
+
'cf_import_flow_step',
|
1519 |
+
);
|
1520 |
+
|
1521 |
+
foreach ( $ajax_actions as $action ) {
|
1522 |
+
|
1523 |
+
$vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
|
1524 |
+
}
|
1525 |
+
|
1526 |
+
return $vars;
|
1527 |
+
}
|
1528 |
+
|
1529 |
+
/**
|
1530 |
+
* Ajax action to activate plugin
|
1531 |
+
*/
|
1532 |
+
public function activate_plugin() {
|
1533 |
+
|
1534 |
+
$plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( $_POST['plugin_init'] ) : '';
|
1535 |
+
|
1536 |
+
$activate = activate_plugin( $plugin_init, '', false, true );
|
1537 |
+
|
1538 |
+
if ( is_wp_error( $activate ) ) {
|
1539 |
+
wp_send_json_error(
|
1540 |
+
array(
|
1541 |
+
'success' => false,
|
1542 |
+
'message' => $activate->get_error_message(),
|
1543 |
+
'init' => $plugin_init,
|
1544 |
+
)
|
1545 |
+
);
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
wp_send_json_success(
|
1549 |
+
array(
|
1550 |
+
'success' => true,
|
1551 |
+
'message' => __( 'Plugin Successfully Activated', 'cartflows' ),
|
1552 |
+
'init' => $plugin_init,
|
1553 |
+
)
|
1554 |
+
);
|
1555 |
+
}
|
1556 |
+
|
1557 |
+
}
|
1558 |
+
|
1559 |
+
/**
|
1560 |
+
* Initialize class object with 'get_instance()' method
|
1561 |
+
*/
|
1562 |
+
CartFlows_Importer::get_instance();
|
1563 |
+
|
1564 |
+
endif;
|
classes/class-cartflows-loader.php
CHANGED
@@ -115,7 +115,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
115 |
define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
|
116 |
define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
|
117 |
define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
|
118 |
-
define( 'CARTFLOWS_VER', '1.1.
|
119 |
define( 'CARTFLOWS_SLUG', 'cartflows' );
|
120 |
define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
|
121 |
|
115 |
define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
|
116 |
define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
|
117 |
define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
|
118 |
+
define( 'CARTFLOWS_VER', '1.1.7.1' );
|
119 |
define( 'CARTFLOWS_SLUG', 'cartflows' );
|
120 |
define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
|
121 |
|
classes/class-cartflows-meta-fields.php
CHANGED
@@ -1,1482 +1,1482 @@
|
|
1 |
-
<?php
|
2 |
-
// @codingStandardsIgnoreStart
|
3 |
-
/**
|
4 |
-
* Meta Fields.
|
5 |
-
*
|
6 |
-
* @package CartFlows
|
7 |
-
*/
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class Cartflows_Meta_Fields.
|
11 |
-
*/
|
12 |
-
class Cartflows_Meta_Fields {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Instance
|
16 |
-
*
|
17 |
-
* @var $instance
|
18 |
-
*/
|
19 |
-
private static $instance;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Initiator
|
23 |
-
*/
|
24 |
-
public static function get_instance() {
|
25 |
-
if ( ! isset( self::$instance ) ) {
|
26 |
-
self::$instance = new self;
|
27 |
-
}
|
28 |
-
|
29 |
-
return self::$instance;
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Constructor
|
34 |
-
*/
|
35 |
-
public function __construct() {
|
36 |
-
|
37 |
-
/* Add Scripts */
|
38 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_meta_scripts' ), 20 );
|
39 |
-
|
40 |
-
add_action( 'wp_ajax_wcf_json_search_coupons', array( $this, 'json_search_coupons' ) );
|
41 |
-
|
42 |
-
add_action( 'wp_ajax_wcf_add_checkout_custom_field', array( $this, 'add_checkout_custom_field' ) );
|
43 |
-
|
44 |
-
add_action( 'wp_ajax_wcf_pro_add_checkout_custom_field', array( $this, 'add_pro_checkout_custom_field' ) );
|
45 |
-
|
46 |
-
add_action( 'wp_ajax_wcf_delete_checkout_custom_field', array( $this, 'delete_checkout_custom_field' ) );
|
47 |
-
|
48 |
-
add_action( 'wp_ajax_wcf_json_search_pages', array( $this, 'json_search_pages' ) );
|
49 |
-
|
50 |
-
add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
|
51 |
-
}
|
52 |
-
|
53 |
-
public function admin_meta_scripts() {
|
54 |
-
|
55 |
-
global $pagenow;
|
56 |
-
global $post;
|
57 |
-
|
58 |
-
$screen = get_current_screen();
|
59 |
-
|
60 |
-
if (
|
61 |
-
( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) &&
|
62 |
-
wcf()->utils->is_step_post_type( $screen->post_type )
|
63 |
-
) {
|
64 |
-
|
65 |
-
wp_enqueue_style( 'woocommerce_admin_styles' );
|
66 |
-
|
67 |
-
wp_enqueue_script( 'select2' );
|
68 |
-
wp_enqueue_script( 'wc-enhanced-select' );
|
69 |
-
|
70 |
-
wp_enqueue_script(
|
71 |
-
'wcf-admin-meta',
|
72 |
-
CARTFLOWS_URL . 'admin/meta-assets/js/admin-edit.js',
|
73 |
-
array( 'jquery', 'select2', 'wp-color-picker' ),
|
74 |
-
CARTFLOWS_VER,
|
75 |
-
true
|
76 |
-
);
|
77 |
-
|
78 |
-
wp_enqueue_style( 'wcf-admin-meta', CARTFLOWS_URL . 'admin/meta-assets/css/admin-edit.css', array( 'wp-color-picker' ), CARTFLOWS_VER );
|
79 |
-
wp_style_add_data( 'wcf-admin-meta', 'rtl', 'replace' );
|
80 |
-
|
81 |
-
$localize = array(
|
82 |
-
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
83 |
-
'google_fonts' => CartFlows_Font_Families::get_google_fonts(),
|
84 |
-
'system_fonts' => CartFlows_Font_Families::get_system_fonts(),
|
85 |
-
'font_weights' => array(
|
86 |
-
'100' => __( 'Thin 100', 'cartflows' ),
|
87 |
-
'200' => __( 'Extra-Light 200', 'cartflows' ),
|
88 |
-
'300' => __( 'Light 300', 'cartflows' ),
|
89 |
-
'400' => __( 'Normal 400', 'cartflows' ),
|
90 |
-
'500' => __( 'Medium 500', 'cartflows' ),
|
91 |
-
'600' => __( 'Semi-Bold 600', 'cartflows' ),
|
92 |
-
'700' => __( 'Bold 700', 'cartflows' ),
|
93 |
-
'800' => __( 'Extra-Bold 800', 'cartflows' ),
|
94 |
-
'900' => __( 'Ultra-Bold 900', 'cartflows' ),
|
95 |
-
)
|
96 |
-
);
|
97 |
-
|
98 |
-
wp_localize_script( 'jquery', 'wcf', apply_filters( 'wcf_js_localize', $localize ) );
|
99 |
-
|
100 |
-
do_action( 'cartflows_admin_meta_scripts' );
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Function to search coupons
|
106 |
-
*/
|
107 |
-
public function json_search_coupons() {
|
108 |
-
|
109 |
-
check_admin_referer( 'wcf-json-search-coupons', 'security' );
|
110 |
-
|
111 |
-
global $wpdb;
|
112 |
-
|
113 |
-
$term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore
|
114 |
-
|
115 |
-
if ( empty( $term ) ) {
|
116 |
-
die();
|
117 |
-
}
|
118 |
-
|
119 |
-
$posts = wp_cache_get( 'wcf_search_coupons', 'wcf_funnel_Cart' );
|
120 |
-
|
121 |
-
if ( false === $posts ) {
|
122 |
-
$posts = $wpdb->get_results( // phpcs:ignore
|
123 |
-
$wpdb->prepare(
|
124 |
-
"SELECT *
|
125 |
-
FROM {$wpdb->prefix}posts
|
126 |
-
WHERE post_type = %s
|
127 |
-
AND post_title LIKE %s
|
128 |
-
AND post_status = %s",
|
129 |
-
'shop_coupon',
|
130 |
-
$wpdb->esc_like( $term ) . '%',
|
131 |
-
'publish'
|
132 |
-
)
|
133 |
-
);
|
134 |
-
wp_cache_set( 'wcf_search_coupons', $posts, 'wcf_funnel_Cart' );
|
135 |
-
}
|
136 |
-
|
137 |
-
$coupons_found = array();
|
138 |
-
$all_discount_types = wc_get_coupon_types();
|
139 |
-
|
140 |
-
if ( $posts ) {
|
141 |
-
foreach ( $posts as $post ) {
|
142 |
-
|
143 |
-
$discount_type = get_post_meta( $post->ID, 'discount_type', true );
|
144 |
-
|
145 |
-
if ( ! empty( $all_discount_types[ $discount_type ] ) ) {
|
146 |
-
$coupons_found[ get_the_title( $post->ID ) ] = get_the_title( $post->ID ) . ' (Type: ' . $all_discount_types[ $discount_type ] . ')';
|
147 |
-
}
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
wp_send_json( $coupons_found );
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* [add_checkout_custom_field description]
|
156 |
-
*
|
157 |
-
* @hook wcf_add_checkout_custom_field
|
158 |
-
*/
|
159 |
-
public function add_checkout_custom_field() {
|
160 |
-
|
161 |
-
check_ajax_referer( 'wcf-add-checkout-custom-field', 'security' );
|
162 |
-
|
163 |
-
$post_id = intval( $_POST['post_id'] );
|
164 |
-
$add_to = sanitize_text_field( wp_unslash( $_POST['add_to'] ) );
|
165 |
-
$type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
|
166 |
-
$options = sanitize_text_field( wp_unslash( $_POST['options'] ) );
|
167 |
-
$label = sanitize_text_field( wp_unslash( $_POST['label'] ) );
|
168 |
-
$name = sanitize_text_field( wp_unslash( $_POST['name'] ) );
|
169 |
-
|
170 |
-
if ( '' !== $name ) {
|
171 |
-
|
172 |
-
$fields = Cartflows_Helper::get_checkout_fields( $add_to, $post_id );
|
173 |
-
$field_keys = array_keys($fields);
|
174 |
-
|
175 |
-
$name = $add_to . '_' . sanitize_key( $name );
|
176 |
-
if( in_array($name, $field_keys) ) {
|
177 |
-
$name = $name . '_' . rand( 0000, 9999 );
|
178 |
-
}
|
179 |
-
|
180 |
-
$field_data = array(
|
181 |
-
'type' => $type,
|
182 |
-
'label' => $label,
|
183 |
-
'placeholder' => '',
|
184 |
-
'class' => array( 'form-row-wide' ),
|
185 |
-
'label_class' => array(),
|
186 |
-
'required' => true,
|
187 |
-
'custom' => true,
|
188 |
-
);
|
189 |
-
|
190 |
-
if ( 'select' === $type ) {
|
191 |
-
|
192 |
-
$options = explode( ',', $options );
|
193 |
-
$field_data['options'] = array();
|
194 |
-
|
195 |
-
if ( is_array( $options ) && ! empty( $options ) ) {
|
196 |
-
|
197 |
-
foreach ( $options as $key => $value ) {
|
198 |
-
|
199 |
-
$field_data['options'][ $value ] = $value;
|
200 |
-
}
|
201 |
-
}
|
202 |
-
}
|
203 |
-
|
204 |
-
Cartflows_Helper::add_checkout_field( $add_to, $name, $field_data, $post_id );
|
205 |
-
|
206 |
-
$key = sanitize_key( $name );
|
207 |
-
$name = 'wcf-' . $key;
|
208 |
-
|
209 |
-
$field_args = array(
|
210 |
-
'label' => $label,
|
211 |
-
'name' => $name,
|
212 |
-
'value' => 'yes',
|
213 |
-
'after' => 'Enable',
|
214 |
-
);
|
215 |
-
|
216 |
-
$field_args['after_html'] = '<span class="wcf-cpf-actions" data-type="billing" data-key="' . $key . '"> | ';
|
217 |
-
$field_args['after_html'] .= '<a class="wcf-cpf-action-remove">' . __( 'Remove', 'cartflows' ) . '</a>';
|
218 |
-
$field_args['after_html'] .= '</span>';
|
219 |
-
|
220 |
-
$field_markup = wcf()->meta->get_checkbox_field( $field_args );
|
221 |
-
|
222 |
-
if( 'billing' === $add_to ) {
|
223 |
-
$add_to_class = 'wcf-cb-fields';
|
224 |
-
} else if( 'shipping' === $add_to ) {
|
225 |
-
$add_to_class = 'wcf-sb-fields';
|
226 |
-
}
|
227 |
-
|
228 |
-
$data = array(
|
229 |
-
'field_data' => $field_data,
|
230 |
-
'field_args' => $field_args,
|
231 |
-
'add_to_class' => $add_to_class,
|
232 |
-
'markup' => $field_markup,
|
233 |
-
);
|
234 |
-
|
235 |
-
wp_send_json( $data );
|
236 |
-
}
|
237 |
-
|
238 |
-
wp_send_json( false );
|
239 |
-
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* [add_checkout_custom_field description]
|
244 |
-
*
|
245 |
-
* @hook wcf_add_checkout_custom_field
|
246 |
-
*/
|
247 |
-
public function add_pro_checkout_custom_field() {
|
248 |
-
|
249 |
-
check_ajax_referer( 'wcf-pro-add-checkout-custom-field', 'security' );
|
250 |
-
|
251 |
-
$post_id = intval( $_POST['post_id'] );
|
252 |
-
$add_to = sanitize_text_field( wp_unslash( $_POST['add_to'] ) );
|
253 |
-
$type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
|
254 |
-
$options = sanitize_text_field( wp_unslash( $_POST['options'] ) );
|
255 |
-
$label = sanitize_text_field( wp_unslash( $_POST['label'] ) );
|
256 |
-
$name = sanitize_text_field( wp_unslash( str_replace(' ', '_', $_POST['label'] ) ) );
|
257 |
-
$placeholder = sanitize_text_field( wp_unslash( $_POST['placeholder'] ) );
|
258 |
-
$width = sanitize_text_field( wp_unslash( $_POST['width'] ) );
|
259 |
-
$default_value = sanitize_text_field( wp_unslash( $_POST['default'] ) );
|
260 |
-
$is_required = sanitize_text_field( wp_unslash( $_POST['required'] ) );
|
261 |
-
|
262 |
-
$field_markup = '';
|
263 |
-
|
264 |
-
if ( '' !== $name ) {
|
265 |
-
|
266 |
-
$fields = Cartflows_Helper::get_checkout_fields( $add_to, $post_id );
|
267 |
-
$field_keys = array_keys($fields);
|
268 |
-
|
269 |
-
$name = $add_to . '_' . sanitize_key( $name );
|
270 |
-
if( in_array($name, $field_keys) ) {
|
271 |
-
$name = $name . '_' . rand( 0000, 9999 );
|
272 |
-
}
|
273 |
-
|
274 |
-
$field_data = array(
|
275 |
-
'type' => $type,
|
276 |
-
'label' => $label,
|
277 |
-
'placeholder' => $placeholder,
|
278 |
-
'class' => array( 'form-row-wide' ),
|
279 |
-
'label_class' => array(),
|
280 |
-
'required' => $is_required,
|
281 |
-
'custom' => true,
|
282 |
-
'default' => $default_value,
|
283 |
-
'options' => $options,
|
284 |
-
);
|
285 |
-
|
286 |
-
if ( 'select' === $type ) {
|
287 |
-
|
288 |
-
$options = explode( ',', $options );
|
289 |
-
$field_data['options'] = array();
|
290 |
-
|
291 |
-
if ( is_array( $options ) && ! empty( $options ) ) {
|
292 |
-
|
293 |
-
foreach ( $options as $key => $value ) {
|
294 |
-
|
295 |
-
$field_data['options'][ $value ] = $value;
|
296 |
-
}
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
$width_args = array(
|
301 |
-
'wcf-field-width_'.$name => $width,
|
302 |
-
);
|
303 |
-
|
304 |
-
Cartflows_Helper::add_checkout_field( $add_to, $name, $field_data, $post_id );
|
305 |
-
Cartflows_Helper::save_meta_option( $post_id, $width_args );
|
306 |
-
|
307 |
-
$key = sanitize_key( $name );
|
308 |
-
$name = 'wcf-' . $key;
|
309 |
-
|
310 |
-
$field_args = array(
|
311 |
-
'type' => $type,
|
312 |
-
'label' => $label,
|
313 |
-
'name' => $name,
|
314 |
-
'value' => 'yes',
|
315 |
-
'placeholder' => $placeholder,
|
316 |
-
'width' => $width,
|
317 |
-
'after' => 'Enable',
|
318 |
-
'section' => $add_to,
|
319 |
-
'default' => $default_value,
|
320 |
-
'required' => $is_required,
|
321 |
-
'options' => $options,
|
322 |
-
);
|
323 |
-
|
324 |
-
$field_args['after_html'] = '<span class="wcf-cpf-actions" data-type="billing" data-key="' . $key . '"> ';
|
325 |
-
$field_args['after_html'] .= '<a class="wcf-cpf-action-remove wp-ui-text-notification">'. __( 'Remove', 'cartflows' ).'</a>';
|
326 |
-
$field_args['after_html'] .= '</span>';
|
327 |
-
|
328 |
-
// $field_markup = wcf()->meta->get_checkbox_field( $field_args );
|
329 |
-
|
330 |
-
$field_markup .= "<li class='wcf-field-item-edit-inactive wcf-field-item ui-sortable-handle'>";
|
331 |
-
$field_markup .= $this->get_field_html_via_ajax($field_args);
|
332 |
-
$field_markup .= "</li>";
|
333 |
-
|
334 |
-
if( 'billing' === $add_to ) {
|
335 |
-
$add_to_class = 'billing-field-sortable';
|
336 |
-
$section = 'billing';
|
337 |
-
} else if( 'shipping' === $add_to ) {
|
338 |
-
$add_to_class = 'shipping-field-sortable';
|
339 |
-
$section = 'shipping';
|
340 |
-
}
|
341 |
-
|
342 |
-
$data = array(
|
343 |
-
'field_data' => $field_data,
|
344 |
-
'field_args' => $field_args,
|
345 |
-
'add_to_class' => $add_to_class,
|
346 |
-
'markup' => $field_markup,
|
347 |
-
'section' => $section,
|
348 |
-
);
|
349 |
-
|
350 |
-
wp_send_json( $data );
|
351 |
-
}
|
352 |
-
|
353 |
-
wp_send_json( false );
|
354 |
-
|
355 |
-
}
|
356 |
-
|
357 |
-
/**
|
358 |
-
* Get field html.
|
359 |
-
*
|
360 |
-
* @param array $args field arguments.
|
361 |
-
* @return string
|
362 |
-
*/
|
363 |
-
function get_field_html_via_ajax( $field_args ) {
|
364 |
-
|
365 |
-
$value = $field_args['value'];
|
366 |
-
|
367 |
-
$is_checkbox = false;
|
368 |
-
$is_require = false;
|
369 |
-
$is_select = false;
|
370 |
-
|
371 |
-
$display = 'none';
|
372 |
-
|
373 |
-
$field_content = '';
|
374 |
-
|
375 |
-
if ( isset( $field_args['before'] ) ) {
|
376 |
-
$field_content .= '<span>' . $field_args['before'] . '</span>';
|
377 |
-
}
|
378 |
-
$field_content .= '<input type="hidden" name="' . $field_args['name'] . '" value="no">';
|
379 |
-
$field_content .= '<input type="checkbox" name="' . $field_args['name'] . '" value="yes" ' . checked( 'yes', $value, false ) . '>';
|
380 |
-
|
381 |
-
if ( isset( $field_args['after'] ) ) {
|
382 |
-
$field_content .= $field_args['after'];
|
383 |
-
}
|
384 |
-
|
385 |
-
$type = isset( $field_args['type'] ) ? $field_args['type'] : '';
|
386 |
-
$label = isset( $field_args['label'] ) ? $field_args['label'] : '';
|
387 |
-
$help = isset( $field_args['help'] ) ? $field_args['help'] : '';
|
388 |
-
$after_html = isset( $field_args['after_html'] ) ? $field_args['after_html'] : '';
|
389 |
-
$name = isset( $field_args['name'] ) ? $field_args['name'] : '';
|
390 |
-
$default = isset( $field_args['default']) ? $field_args['default'] : '';
|
391 |
-
$required = isset( $field_args['required']) ? $field_args['required'] : '';
|
392 |
-
$options = isset( $field_args['options']) ? $field_args['options'] : '';
|
393 |
-
$width = isset( $field_args['width']) ? $field_args['width'] : '';
|
394 |
-
$name_class = 'field-' . $field_args['name'];
|
395 |
-
|
396 |
-
if( isset( $options ) && !empty( $options ) ){
|
397 |
-
$options = implode(', ', $options );
|
398 |
-
}else{
|
399 |
-
$options = '';
|
400 |
-
}
|
401 |
-
|
402 |
-
if( 'yes' == $required ){
|
403 |
-
$is_require = true;
|
404 |
-
}
|
405 |
-
|
406 |
-
if( 'checkbox' == $type ){
|
407 |
-
$is_checkbox = true;
|
408 |
-
}
|
409 |
-
|
410 |
-
if( 'select' == $type ){
|
411 |
-
$is_select = true;
|
412 |
-
$display = 'block';
|
413 |
-
}
|
414 |
-
|
415 |
-
// echo "<pre>";
|
416 |
-
// var_dump($after_html);
|
417 |
-
// echo "</pre>";
|
418 |
-
|
419 |
-
// $field_markup = wcf()->meta->get_only_checkbox_field( $field_args );
|
420 |
-
ob_start();
|
421 |
-
|
422 |
-
?>
|
423 |
-
<div class="wcf-field-item-bar">
|
424 |
-
<div class="wcf-field-item-handle ui-sortable-handle">
|
425 |
-
<label class="dashicons <?php if( 'no' == $value ){ echo 'dashicons-hidden'; } else{ echo 'dashicons-visibility';} ?> " for="<?php echo $field_args['name']; ?>"></label>
|
426 |
-
<span class="item-title">
|
427 |
-
<span class="wcf-field-item-title"><?php echo $label; if( $is_require ) { ?> <i>*</i> <?php } ?></span>
|
428 |
-
<span class="is-submenu" style="display: none;">sub item</span>
|
429 |
-
</span>
|
430 |
-
<span class="item-controls">
|
431 |
-
<span class="dashicons dashicons-menu"></span>
|
432 |
-
<span class="item-order hide-if-js">
|
433 |
-
<a href="#" class="item-move-up" aria-label="Move up">↑</a>
|
434 |
-
|
|
435 |
-
<a href="#" class="item-move-down" aria-label="Move down">↓</a>
|
436 |
-
</span>
|
437 |
-
<a class="item-edit" id="edit-64" href="javascript:void(0);" aria-label="My account. Menu item 1 of 5."><span class="screen-reader-text">Edit</span></a>
|
438 |
-
</span>
|
439 |
-
</div>
|
440 |
-
</div>
|
441 |
-
<div class="wcf-field-item-settings">
|
442 |
-
<div class="wcf-field-item-settings-row-width">
|
443 |
-
<?php
|
444 |
-
echo wcf()->meta->get_select_field(
|
445 |
-
array(
|
446 |
-
'label' => __( 'Field Width', 'cartflows' ),
|
447 |
-
'name' => 'wcf-field-width_' . str_replace( 'wcf-', '', $field_args['name'] ),
|
448 |
-
'value' => $width,
|
449 |
-
'options' => array(
|
450 |
-
'33' => __( '33%', 'cartflows' ),
|
451 |
-
'50' => __( '50%', 'cartflows' ),
|
452 |
-
'100' => __( '100%', 'cartflows' ),
|
453 |
-
),
|
454 |
-
)
|
455 |
-
);
|
456 |
-
?>
|
457 |
-
</div>
|
458 |
-
|
459 |
-
<div class="wcf-field-item-settings-label">
|
460 |
-
<?php
|
461 |
-
echo wcf()->meta->get_text_field(
|
462 |
-
array(
|
463 |
-
'label' => __( 'Field Label', 'cartflows' ),
|
464 |
-
'name' => 'wcf_label_text_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
465 |
-
'value' => $label,
|
466 |
-
)
|
467 |
-
);
|
468 |
-
|
469 |
-
?>
|
470 |
-
<input type="hidden" name="wcf_field_order_<?php echo $field_args['section']; ?>[]" value="<?php echo str_replace( 'wcf-', '', $field_args['name'] ); ?>">
|
471 |
-
</div>
|
472 |
-
|
473 |
-
<div class="wcf-field-item-select-options" style="display:<?php if( isset( $display ) ){ print $display; } ?>;" >
|
474 |
-
<?php
|
475 |
-
echo wcf()->meta->get_text_field(
|
476 |
-
array(
|
477 |
-
'label' => __( 'Options', 'cartflows' ),
|
478 |
-
'name' => 'wcf_select_option_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
479 |
-
'value' => $options,
|
480 |
-
)
|
481 |
-
);
|
482 |
-
|
483 |
-
?>
|
484 |
-
<input type="hidden" name="wcf_field_order_<?php echo $field_args['section']; ?>[]" value="<?php echo str_replace( 'wcf-', '', $field_args['name'] ); ?>">
|
485 |
-
</div>
|
486 |
-
|
487 |
-
<div class="wcf-field-item-settings-default">
|
488 |
-
<?php
|
489 |
-
if( true == $is_checkbox ){
|
490 |
-
echo wcf()->meta->get_select_field(
|
491 |
-
array(
|
492 |
-
'label' => __( 'Default', 'cartflows' ),
|
493 |
-
'name' => 'wcf_label_default_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
494 |
-
'value' => $value,
|
495 |
-
'options' => array(
|
496 |
-
'1' => __( 'Checked', 'cartflows' ),
|
497 |
-
'0' => __( 'Un-Checked', 'cartflows' ),
|
498 |
-
),
|
499 |
-
)
|
500 |
-
);
|
501 |
-
}else{
|
502 |
-
|
503 |
-
echo wcf()->meta->get_text_field(
|
504 |
-
array(
|
505 |
-
'label' => __( 'Default', 'cartflows' ),
|
506 |
-
'name' => 'wcf_label_default_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
507 |
-
'value' => $default,
|
508 |
-
)
|
509 |
-
);
|
510 |
-
}
|
511 |
-
?>
|
512 |
-
</div>
|
513 |
-
|
514 |
-
<div class="wcf-field-item-settings-placeholder" <?php if( true == $is_checkbox ) {?> style="display: none;" <?php } ?> >
|
515 |
-
<?php
|
516 |
-
echo wcf()->meta->get_text_field(
|
517 |
-
array(
|
518 |
-
'label' => __( 'Placeholder', 'cartflows' ),
|
519 |
-
'name' => 'wcf_label_placeholder_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
520 |
-
'value' => $label,
|
521 |
-
)
|
522 |
-
);
|
523 |
-
?>
|
524 |
-
</div>
|
525 |
-
|
526 |
-
<div class="wcf-field-item-settings-required">
|
527 |
-
<?php
|
528 |
-
echo wcf()->meta->get_checkbox_field(
|
529 |
-
array(
|
530 |
-
'label' => __( 'Required', 'cartflows' ),
|
531 |
-
'name' => 'wcf_is_required_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
532 |
-
'value' => $required,
|
533 |
-
)
|
534 |
-
);
|
535 |
-
?>
|
536 |
-
</div>
|
537 |
-
|
538 |
-
<div class="wcf-field-item-settings-checkbox">
|
539 |
-
<?php
|
540 |
-
echo wcf()->meta->get_checkbox_field(
|
541 |
-
array(
|
542 |
-
'label' => __( 'Enable this field', 'cartflows' ),
|
543 |
-
'name' => $field_args['name'],
|
544 |
-
'value' => $value,
|
545 |
-
)
|
546 |
-
);
|
547 |
-
?>
|
548 |
-
</div>
|
549 |
-
|
550 |
-
<?php
|
551 |
-
if(isset( $field_args['after_html']) )
|
552 |
-
{
|
553 |
-
?>
|
554 |
-
<div class="wcf-field-item-settings-row-delete-cf">
|
555 |
-
<?php echo $field_args['after_html']; ?>
|
556 |
-
</div>
|
557 |
-
<?php
|
558 |
-
}
|
559 |
-
?>
|
560 |
-
<!--
|
561 |
-
<label for="<?php echo $field_args['name']; ?>">
|
562 |
-
<?php _e( 'Label', 'cartflows' ); ?><br>
|
563 |
-
<input type="text" value="<?php echo $field_args['label']; ?>">
|
564 |
-
|
565 |
-
<?php if( isset( $field_markup ) ) { echo $field_markup; }?>
|
566 |
-
|
567 |
-
<input type="hidden" name="wcf_field_order_<?php echo $field_args['section']; ?>[]" value="<?php echo str_replace('wcf-', '', $field_args['name'] ); ?>">
|
568 |
-
</label> -->
|
569 |
-
</div>
|
570 |
-
|
571 |
-
<?php
|
572 |
-
|
573 |
-
return ob_get_clean();
|
574 |
-
}
|
575 |
-
|
576 |
-
/**
|
577 |
-
* [delete_checkout_custom_field description]
|
578 |
-
*
|
579 |
-
* @hook wcf_delete_checkout_custom_field
|
580 |
-
* @return [type] [description]
|
581 |
-
*/
|
582 |
-
public function delete_checkout_custom_field() {
|
583 |
-
|
584 |
-
check_ajax_referer( 'wcf-delete-checkout-custom-field', 'security' );
|
585 |
-
|
586 |
-
$post_id = intval( $_POST['post_id'] );
|
587 |
-
$type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
|
588 |
-
$key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
|
589 |
-
|
590 |
-
if ( '' !== $key ) {
|
591 |
-
|
592 |
-
Cartflows_Helper::delete_checkout_field( $type, $key, $post_id );
|
593 |
-
|
594 |
-
wp_send_json( true );
|
595 |
-
|
596 |
-
}
|
597 |
-
|
598 |
-
wp_send_json( false );
|
599 |
-
|
600 |
-
}
|
601 |
-
|
602 |
-
/**
|
603 |
-
* Function to search coupons
|
604 |
-
*/
|
605 |
-
public function json_search_pages() {
|
606 |
-
|
607 |
-
check_ajax_referer( 'wcf-json-search-pages', 'security' );
|
608 |
-
|
609 |
-
$term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore
|
610 |
-
|
611 |
-
if ( empty( $term ) ) {
|
612 |
-
die( 'not found' );
|
613 |
-
}
|
614 |
-
|
615 |
-
$search_string = $term;
|
616 |
-
$data = array();
|
617 |
-
$result = array();
|
618 |
-
|
619 |
-
add_filter( 'posts_search', array( $this, 'search_only_titles' ), 10, 2 );
|
620 |
-
|
621 |
-
$query = new WP_Query(
|
622 |
-
array(
|
623 |
-
's' => $search_string,
|
624 |
-
'post_type' => 'page',
|
625 |
-
'posts_per_page' => - 1,
|
626 |
-
)
|
627 |
-
);
|
628 |
-
|
629 |
-
if ( $query->have_posts() ) {
|
630 |
-
while ( $query->have_posts() ) {
|
631 |
-
$query->the_post();
|
632 |
-
$title = get_the_title();
|
633 |
-
$title .= ( 0 != $query->post->post_parent ) ? ' (' . get_the_title( $query->post->post_parent ) . ')' : '';
|
634 |
-
$id = get_the_id();
|
635 |
-
$data[] = array(
|
636 |
-
'id' => $id,
|
637 |
-
'text' => $title,
|
638 |
-
);
|
639 |
-
}
|
640 |
-
}
|
641 |
-
|
642 |
-
if ( is_array( $data ) && ! empty( $data ) ) {
|
643 |
-
$result[] = array(
|
644 |
-
'text' => '',
|
645 |
-
'children' => $data,
|
646 |
-
);
|
647 |
-
}
|
648 |
-
|
649 |
-
wp_reset_postdata();
|
650 |
-
|
651 |
-
// return the result in json.
|
652 |
-
wp_send_json( $result );
|
653 |
-
}
|
654 |
-
|
655 |
-
public function search_only_titles( $search, $wp_query ) {
|
656 |
-
if ( ! empty( $search ) && ! empty( $wp_query->query_vars['search_terms'] ) ) {
|
657 |
-
global $wpdb;
|
658 |
-
|
659 |
-
$q = $wp_query->query_vars;
|
660 |
-
$n = ! empty( $q['exact'] ) ? '' : '%';
|
661 |
-
|
662 |
-
$search = array();
|
663 |
-
|
664 |
-
foreach ( (array) $q['search_terms'] as $term ) {
|
665 |
-
$search[] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like( $term ) . $n );
|
666 |
-
}
|
667 |
-
|
668 |
-
if ( ! is_user_logged_in() ) {
|
669 |
-
$search[] = "$wpdb->posts.post_password = ''";
|
670 |
-
}
|
671 |
-
|
672 |
-
$search = ' AND ' . implode( ' AND ', $search );
|
673 |
-
}
|
674 |
-
|
675 |
-
return $search;
|
676 |
-
}
|
677 |
-
|
678 |
-
function get_field( $field_data, $field_content ) {
|
679 |
-
|
680 |
-
$label = isset( $field_data['label'] ) ? $field_data['label'] : '';
|
681 |
-
$help = isset( $field_data['help'] ) ? $field_data['help'] : '';
|
682 |
-
$after_html = isset( $field_data['after_html'] ) ? $field_data['after_html'] : '';
|
683 |
-
|
684 |
-
$name_class = 'field-' . $field_data['name'];
|
685 |
-
|
686 |
-
$field_html = '<div class="wcf-field-row ' . $name_class . '">';
|
687 |
-
|
688 |
-
if( ! empty( $label ) || ! empty( $help ) ) {
|
689 |
-
$field_html .= '<div class="wcf-field-row-heading">';
|
690 |
-
if( ! empty( $label ) ) {
|
691 |
-
$field_html .= '<label>' . esc_html( $label ) . '</label>';
|
692 |
-
}
|
693 |
-
if ( ! empty( $help ) ) {
|
694 |
-
$field_html .= '<i class="wcf-field-heading-help dashicons dashicons-editor-help">';
|
695 |
-
// $field_html .= '<span class="wcf-tooltip" data-tooltip= "'. esc_attr( $help ) .'"></span>';
|
696 |
-
$field_html .= '</i>';
|
697 |
-
$field_html .= '<span class="wcf-tooltip-text">';
|
698 |
-
$field_html .= $help;
|
699 |
-
$field_html .= '</span>';
|
700 |
-
}
|
701 |
-
$field_html .= '</div>';
|
702 |
-
}
|
703 |
-
|
704 |
-
$field_html .= '<div class="wcf-field-row-content">';
|
705 |
-
$field_html .= $field_content;
|
706 |
-
|
707 |
-
if ( ! empty( $after_html ) ) {
|
708 |
-
$field_html .= $after_html;
|
709 |
-
}
|
710 |
-
|
711 |
-
$field_html .= '</div>';
|
712 |
-
$field_html .= '</div>';
|
713 |
-
|
714 |
-
return $field_html;
|
715 |
-
}
|
716 |
-
|
717 |
-
function get_text_field( $field_data ) {
|
718 |
-
|
719 |
-
$value = $field_data['value'];
|
720 |
-
|
721 |
-
$attr = '';
|
722 |
-
|
723 |
-
if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
|
724 |
-
|
725 |
-
foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
|
726 |
-
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
727 |
-
}
|
728 |
-
}
|
729 |
-
|
730 |
-
$field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
|
731 |
-
|
732 |
-
return $this->get_field( $field_data, $field_content );
|
733 |
-
}
|
734 |
-
|
735 |
-
function get_shortcode_field( $field_data ) {
|
736 |
-
|
737 |
-
$attr = '';
|
738 |
-
|
739 |
-
$attr_fields = array(
|
740 |
-
'readonly' => 'readonly',
|
741 |
-
'onfocus' => 'this.select()',
|
742 |
-
'onmouseup' => 'return false',
|
743 |
-
);
|
744 |
-
|
745 |
-
if ( $attr_fields && is_array( $attr_fields ) ) {
|
746 |
-
|
747 |
-
foreach ( $attr_fields as $attr_key => $attr_value ) {
|
748 |
-
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
749 |
-
}
|
750 |
-
}
|
751 |
-
|
752 |
-
$field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $field_data['content'] . '" ' . $attr . '>';
|
753 |
-
|
754 |
-
return $this->get_field( $field_data, $field_content );
|
755 |
-
}
|
756 |
-
|
757 |
-
function get_display_field( $field_data ) {
|
758 |
-
|
759 |
-
$field_content = $field_data['content'];
|
760 |
-
|
761 |
-
return $this->get_field( $field_data, $field_content );
|
762 |
-
}
|
763 |
-
|
764 |
-
function get_hr_line_field( $field_data ) {
|
765 |
-
|
766 |
-
$field_data = array(
|
767 |
-
'name' => 'wcf-hr-line',
|
768 |
-
'content' => '<hr>'
|
769 |
-
);
|
770 |
-
|
771 |
-
$field_content = $field_data['content'];
|
772 |
-
|
773 |
-
return $this->get_field( $field_data, $field_content );
|
774 |
-
}
|
775 |
-
|
776 |
-
function get_number_field( $field_data ) {
|
777 |
-
|
778 |
-
$value = $field_data['value'];
|
779 |
-
|
780 |
-
$attr = '';
|
781 |
-
|
782 |
-
if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
|
783 |
-
|
784 |
-
foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
|
785 |
-
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
786 |
-
}
|
787 |
-
}
|
788 |
-
|
789 |
-
$field_content = '<input type="number" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
|
790 |
-
|
791 |
-
return $this->get_field( $field_data, $field_content );
|
792 |
-
}
|
793 |
-
|
794 |
-
function get_hidden_field( $field_data ) {
|
795 |
-
|
796 |
-
$value = $field_data['value'];
|
797 |
-
|
798 |
-
$attr = '';
|
799 |
-
|
800 |
-
if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
|
801 |
-
|
802 |
-
foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
|
803 |
-
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
804 |
-
}
|
805 |
-
}
|
806 |
-
|
807 |
-
$field_content = '<input type="hidden" id="' . $field_data['name'] . '" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
|
808 |
-
|
809 |
-
return $this->get_field( $field_data, $field_content );
|
810 |
-
}
|
811 |
-
|
812 |
-
function get_area_field( $field_data ) {
|
813 |
-
|
814 |
-
$value = $field_data['value'];
|
815 |
-
|
816 |
-
$field_content = '<textarea name="' . $field_data['name'] . '" rows="10" cols="50">';
|
817 |
-
$field_content .= $value;
|
818 |
-
$field_content .= '</textarea>';
|
819 |
-
|
820 |
-
return $this->get_field( $field_data, $field_content );
|
821 |
-
}
|
822 |
-
|
823 |
-
function get_only_checkbox_field( $field_data ) {
|
824 |
-
// echo "<pre>";
|
825 |
-
// var_dump($field_data);
|
826 |
-
// echo "</pre>";
|
827 |
-
|
828 |
-
$value = $field_data['value'];
|
829 |
-
|
830 |
-
|
831 |
-
$field_content = '';
|
832 |
-
if ( isset( $field_data['before'] ) ) {
|
833 |
-
$field_content .= '<span>' . $field_data['before'] . '</span>';
|
834 |
-
}
|
835 |
-
$field_content .= '<input type="hidden" name="' . $field_data['name'] . '" value="no">';
|
836 |
-
$field_content .= '<input type="checkbox" name="' . $field_data['name'] . '" value="yes" ' . checked( 'yes', $value, false ) . '>';
|
837 |
-
|
838 |
-
if ( isset( $field_data['after'] ) ) {
|
839 |
-
$field_content .= '<span>' . $field_data['after'] . '</span>';
|
840 |
-
}
|
841 |
-
|
842 |
-
if ( isset( $field_data['after_html'] ) ) {
|
843 |
-
$field_content .= '<span>' . $field_data['after_html'] . '</span>';
|
844 |
-
}
|
845 |
-
|
846 |
-
return $field_content;
|
847 |
-
}
|
848 |
-
|
849 |
-
function get_checkbox_field( $field_data ) {
|
850 |
-
|
851 |
-
$value = $field_data['value'];
|
852 |
-
|
853 |
-
$field_content = '';
|
854 |
-
if ( isset( $field_data['before'] ) ) {
|
855 |
-
$field_content .= '<span>' . $field_data['before'] . '</span>';
|
856 |
-
}
|
857 |
-
$field_content .= '<input type="hidden" name="' . $field_data['name'] . '" value="no">';
|
858 |
-
$field_content .= '<input type="checkbox" id="'.$field_data['name'].'" name="' . $field_data['name'] . '" value="yes" ' . checked( 'yes', $value, false ) . '>';
|
859 |
-
|
860 |
-
if ( isset( $field_data['after'] ) ) {
|
861 |
-
$field_content .= '<span>' . $field_data['after'] . '</span>';
|
862 |
-
}
|
863 |
-
|
864 |
-
return $this->get_field( $field_data, $field_content );
|
865 |
-
}
|
866 |
-
|
867 |
-
function get_radio_field( $field_data ) {
|
868 |
-
|
869 |
-
$value = $field_data['value'];
|
870 |
-
$field_content = '';
|
871 |
-
|
872 |
-
if ( is_array( $field_data['options'] ) && ! empty( $field_data['options'] ) ) {
|
873 |
-
|
874 |
-
foreach ( $field_data['options'] as $data_key => $data_value ) {
|
875 |
-
|
876 |
-
$field_content .= '<div class="wcf-radio-option">';
|
877 |
-
$field_content .= '<input type="radio" name="' . $field_data['name'] . '" value="' . $data_key . '" ' . checked( $data_key, $value, false ) . '>';
|
878 |
-
$field_content .= $data_value;
|
879 |
-
$field_content .= '</div>';
|
880 |
-
}
|
881 |
-
}
|
882 |
-
|
883 |
-
return $this->get_field( $field_data, $field_content );
|
884 |
-
}
|
885 |
-
|
886 |
-
function get_font_family_field( $field_data ) {
|
887 |
-
|
888 |
-
$value = $field_data['value'];
|
889 |
-
|
890 |
-
$pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
|
891 |
-
|
892 |
-
$field_content = '<select class="wcf-field-font-family" data-for="' . $field_data['for'] . '" name="' . $field_data['name'] . '">';
|
893 |
-
|
894 |
-
$field_content .= '<option value="" ' . selected( '', $value, false ) . '>Default</option>';
|
895 |
-
|
896 |
-
$field_content .= '<optgroup label="Other System Fonts">';
|
897 |
-
foreach ( CartFlows_Font_Families::get_system_fonts() as $name => $variants ) {
|
898 |
-
$field_content .= '<option value="' . esc_attr( $name ) . '" ' . selected( $name, $value, false ) . '>' . esc_attr( $name ) . '</option>';
|
899 |
-
}
|
900 |
-
$field_content .= '</optgroup>';
|
901 |
-
$field_content .= '<optgroup label="Google">';
|
902 |
-
foreach ( CartFlows_Font_Families::get_google_fonts() as $name => $single_font ) {
|
903 |
-
$variants = wcf_get_prop( $single_font, '0' );
|
904 |
-
$category = wcf_get_prop( $single_font, '1' );
|
905 |
-
$font_value = '\'' . esc_attr( $name ) . '\', ' . esc_attr( $category );
|
906 |
-
$field_content .= '<option value="' . esc_attr( $font_value ) . '" ' . selected( $font_value, $value, false ) . '>' . esc_attr( $name ) . '</option>';
|
907 |
-
}
|
908 |
-
$field_content .= '</optgroup>';
|
909 |
-
|
910 |
-
$field_content .= '</select>';
|
911 |
-
|
912 |
-
return $this->get_field( $field_data, $field_content );
|
913 |
-
}
|
914 |
-
|
915 |
-
function get_font_weight_field( $field_data ) {
|
916 |
-
|
917 |
-
$value = $field_data['value'];
|
918 |
-
|
919 |
-
$pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
|
920 |
-
|
921 |
-
$field_content = '<select data-selected="'.esc_attr( $value ).'" class="wcf-field-font-weight" data-for="' . $field_data['for'] . '" name="' . $field_data['name'] . '">';
|
922 |
-
|
923 |
-
$field_content .= '<option value="" ' . selected( '', $value, false ) . '>Default</option>';
|
924 |
-
|
925 |
-
$field_content .= '</select>';
|
926 |
-
|
927 |
-
return $this->get_field( $field_data, $field_content );
|
928 |
-
}
|
929 |
-
|
930 |
-
function get_select_field( $field_data ) {
|
931 |
-
|
932 |
-
$value = $field_data['value'];
|
933 |
-
$pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
|
934 |
-
|
935 |
-
$field_content = '<select name="' . $field_data['name'] . '">';
|
936 |
-
|
937 |
-
|
938 |
-
if ( is_array( $field_data['options'] ) && ! empty( $field_data['options'] ) ) {
|
939 |
-
|
940 |
-
foreach ( $field_data['options'] as $data_key => $data_value ) {
|
941 |
-
|
942 |
-
$disabled = '';
|
943 |
-
|
944 |
-
if ( array_key_exists( $data_key, $pro_options ) ) {
|
945 |
-
$disabled = 'disabled ';
|
946 |
-
$data_value = $pro_options[ $data_key ];
|
947 |
-
}
|
948 |
-
|
949 |
-
$field_content .= '<option value="' . $data_key . '" ' . selected( $value, $data_key, false ) . ' ' . $disabled .'>' . $data_value . '</option>';
|
950 |
-
}
|
951 |
-
}
|
952 |
-
|
953 |
-
$field_content .= '</select>';
|
954 |
-
|
955 |
-
if ( isset( $field_data['after'] ) ) {
|
956 |
-
$field_content .= '<span>' . $field_data['after'] . '</span>';
|
957 |
-
}
|
958 |
-
|
959 |
-
return $this->get_field( $field_data, $field_content );
|
960 |
-
}
|
961 |
-
|
962 |
-
function get_color_picker_field( $field_data ) {
|
963 |
-
|
964 |
-
$value = $field_data['value'];
|
965 |
-
|
966 |
-
$field_content = '<input class="wcf-color-picker" type="text" name="' . $field_data['name'] . '" value="' . $value . '">';
|
967 |
-
|
968 |
-
return $this->get_field( $field_data, $field_content );
|
969 |
-
}
|
970 |
-
|
971 |
-
function get_product_selection_field( $field_data ) {
|
972 |
-
|
973 |
-
$value = $field_data['value'];
|
974 |
-
|
975 |
-
$multiple = '';
|
976 |
-
|
977 |
-
if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
|
978 |
-
$multiple = ' multiple="multiple"';
|
979 |
-
}
|
980 |
-
|
981 |
-
$allow_clear = '';
|
982 |
-
|
983 |
-
if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) {
|
984 |
-
$allow_clear = ' data-allow_clear="allow_clear"';
|
985 |
-
}
|
986 |
-
|
987 |
-
$field_content = '<select
|
988 |
-
name="' . $field_data['name'] . '[]"
|
989 |
-
class="wcf-product-search" ' . $multiple . $allow_clear . '
|
990 |
-
data-placeholder="' . __( 'Search for a product…', 'cartflows' ) . '"
|
991 |
-
data-action="woocommerce_json_search_products_and_variations">';
|
992 |
-
|
993 |
-
if ( is_array( $value ) && ! empty( $value ) ) {
|
994 |
-
|
995 |
-
foreach ( $value as $data_key => $product_id ) {
|
996 |
-
|
997 |
-
$product = wc_get_product( $product_id );
|
998 |
-
|
999 |
-
// posts.
|
1000 |
-
if ( ! empty( $product ) ) {
|
1001 |
-
$post_title = $product->get_name() . ' (#' . $product_id . ')';
|
1002 |
-
|
1003 |
-
$field_content .= '<option value="' . $product_id . '" selected="selected" >' . $post_title . '</option>';
|
1004 |
-
}
|
1005 |
-
}
|
1006 |
-
}
|
1007 |
-
$field_content .= '</select>';
|
1008 |
-
|
1009 |
-
return $this->get_field( $field_data, $field_content );
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
function get_coupon_selection_field( $field_data ) {
|
1013 |
-
|
1014 |
-
$value = $field_data['value'];
|
1015 |
-
|
1016 |
-
$multiple = '';
|
1017 |
-
|
1018 |
-
if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
|
1019 |
-
$multiple = ' multiple="multiple"';
|
1020 |
-
}
|
1021 |
-
|
1022 |
-
$allow_clear = '';
|
1023 |
-
|
1024 |
-
if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) {
|
1025 |
-
$allow_clear = ' data-allow_clear="allow_clear"';
|
1026 |
-
}
|
1027 |
-
|
1028 |
-
$field_content = '<select
|
1029 |
-
name="' . $field_data['name'] . '[]"
|
1030 |
-
class="wc-coupon-search wcf-coupon-search" ' . $multiple . $allow_clear . '
|
1031 |
-
data-placeholder="' . __( 'Search for a coupon…', 'cartflows' ) . '"
|
1032 |
-
data-action="wcf_json_search_coupons">';
|
1033 |
-
|
1034 |
-
if ( is_array( $value ) && ! empty( $value ) ) {
|
1035 |
-
|
1036 |
-
$all_discount_types = wc_get_coupon_types();
|
1037 |
-
|
1038 |
-
foreach ( $value as $coupon_title ) {
|
1039 |
-
|
1040 |
-
$coupon = new WC_Coupon( $coupon_title );
|
1041 |
-
|
1042 |
-
$discount_type = $coupon->get_discount_type();
|
1043 |
-
|
1044 |
-
if ( isset( $discount_type ) && $discount_type ) {
|
1045 |
-
$discount_type = ' ( Type: ' . $all_discount_types[ $discount_type ] . ' )';
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
$field_content .= '<option value="' . $coupon_title . '" selected="selected">' . $coupon_title . $discount_type . '</option>';
|
1049 |
-
}
|
1050 |
-
}
|
1051 |
-
|
1052 |
-
$field_content .= '</select>';
|
1053 |
-
|
1054 |
-
return $this->get_field( $field_data, $field_content );
|
1055 |
-
}
|
1056 |
-
|
1057 |
-
function get_page_selection_field( $field_data ) {
|
1058 |
-
|
1059 |
-
$value = $field_data['value'];
|
1060 |
-
|
1061 |
-
$multiple = '';
|
1062 |
-
|
1063 |
-
if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
|
1064 |
-
$multiple = 'multiple="multiple"';
|
1065 |
-
}
|
1066 |
-
|
1067 |
-
$field_content = '<select
|
1068 |
-
name="' . $field_data['name'] . '[]"
|
1069 |
-
class="wcf-search-pages" ' . $multiple . '"
|
1070 |
-
data-action="wcf_json_search_pages">';
|
1071 |
-
|
1072 |
-
if ( is_array( $value ) && ! empty( $value ) ) {
|
1073 |
-
|
1074 |
-
foreach ( $value as $data_key => $data_value ) {
|
1075 |
-
|
1076 |
-
$field_content .= '<option value="' . $data_value . '">' . get_the_title( $data_value ) . '</option>';
|
1077 |
-
}
|
1078 |
-
}
|
1079 |
-
|
1080 |
-
$field_content .= '</select>';
|
1081 |
-
|
1082 |
-
return $this->get_field( $field_data, $field_content );
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
function get_section( $field_data ) {
|
1086 |
-
$field_html = '<div class="wcf-field-row wcf-field-section">';
|
1087 |
-
$field_html .= '<div class="wcf-field-section-heading" colspan="2">';
|
1088 |
-
$field_html .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
|
1089 |
-
|
1090 |
-
if ( isset( $field_data['help'] ) ) {
|
1091 |
-
$field_html .= '<i class="wcf-field-heading-help dashicons dashicons-editor-help" title="' . esc_attr( $field_data['help'] ) . '"></i>';
|
1092 |
-
}
|
1093 |
-
$field_html .= '</div>';
|
1094 |
-
$field_html .= '</div>';
|
1095 |
-
return $field_html;
|
1096 |
-
}
|
1097 |
-
|
1098 |
-
function get_description_field( $field_data ) {
|
1099 |
-
|
1100 |
-
$field_html = '<div class="wcf-field-row wcf-field-desc ' . $field_data['name'] . '">';
|
1101 |
-
$field_html .= '<div class="wcf-field-desc-content">';
|
1102 |
-
$field_html .= $field_data['content'];
|
1103 |
-
$field_html .= '</div>';
|
1104 |
-
$field_html .= '</div>';
|
1105 |
-
|
1106 |
-
return $field_html;
|
1107 |
-
}
|
1108 |
-
|
1109 |
-
function get_checkout_field_repeater( $field_data ) {
|
1110 |
-
|
1111 |
-
$value = array();
|
1112 |
-
|
1113 |
-
$value[0] = array(
|
1114 |
-
'add_to' => '',
|
1115 |
-
'type' => '',
|
1116 |
-
'label' => '',
|
1117 |
-
'name' => '',
|
1118 |
-
);
|
1119 |
-
|
1120 |
-
$field_content = '';
|
1121 |
-
|
1122 |
-
$field_content .= '<div class="wcf-field-row">';
|
1123 |
-
// $field_content .= '<div class="wcf-field-row-heading">';
|
1124 |
-
// $field_content .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
|
1125 |
-
// $field_content .= '</div>';
|
1126 |
-
$field_content .= '<div class="wcf-field-row-content">';
|
1127 |
-
$field_content .= '<div class="wcf-cpf-wrap">';
|
1128 |
-
|
1129 |
-
foreach ( $value as $p_key => $p_data ) {
|
1130 |
-
$field_content .= '<div class="wcf-cpf-row" data-key="' . $p_key . '">';
|
1131 |
-
$field_content .= '<div class="wcf-cpf-row-header">';
|
1132 |
-
$field_content .= '<span class="wcf-cpf-row-title">Add New Custom Field</span>';
|
1133 |
-
$field_content .= '</div>';
|
1134 |
-
|
1135 |
-
$field_content .= '<div class="wcf-cpf-row-standard-fields">';
|
1136 |
-
|
1137 |
-
/* Add To */
|
1138 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-add_to">';
|
1139 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Add to</span>';
|
1140 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1141 |
-
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][add_to]" class="wcf-cpf-add_to">';
|
1142 |
-
$field_content .= '<option value="billing">Billing</option>';
|
1143 |
-
$field_content .= '<option value="shipping">Shipping</option>';
|
1144 |
-
$field_content .= '</select>';
|
1145 |
-
$field_content .= '</span>';
|
1146 |
-
$field_content .= '</div>';
|
1147 |
-
|
1148 |
-
/* Type */
|
1149 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-type">';
|
1150 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Type</span>';
|
1151 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1152 |
-
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][type]" class="wcf-cpf-type">';
|
1153 |
-
$field_content .= '<option value="text">Text</option>';
|
1154 |
-
$field_content .= '<option value="textarea">Textarea</option>';
|
1155 |
-
$field_content .= '<option value="select">Select</option>';
|
1156 |
-
$field_content .= '<option value="checkbox">Checkbox</option>';
|
1157 |
-
$field_content .= '</select>';
|
1158 |
-
$field_content .= '</span>';
|
1159 |
-
$field_content .= '</div>';
|
1160 |
-
|
1161 |
-
/* Textarea */
|
1162 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-options">';
|
1163 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Options *</span>';
|
1164 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1165 |
-
$field_content .= '<textarea value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-options" placeholder="Enter your options separated by comma."></textarea>';
|
1166 |
-
$field_content .= '</span>';
|
1167 |
-
$field_content .= '</div>';
|
1168 |
-
|
1169 |
-
/* Label */
|
1170 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-label">';
|
1171 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Label *</span>';
|
1172 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1173 |
-
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-label">';
|
1174 |
-
$field_content .= '</span>';
|
1175 |
-
$field_content .= '</div>';
|
1176 |
-
|
1177 |
-
/* Name */
|
1178 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-name">';
|
1179 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Name *</span>';
|
1180 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1181 |
-
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][name]" class="wcf-cpf-name">';
|
1182 |
-
$field_content .= '</span>';
|
1183 |
-
$field_content .= '</div>';
|
1184 |
-
|
1185 |
-
$field_content .= '</div>';
|
1186 |
-
$field_content .= '</div>';
|
1187 |
-
}
|
1188 |
-
|
1189 |
-
/* Add New Custom Field */
|
1190 |
-
$field_content .= '<div class="wcf-cpf-add-row">';
|
1191 |
-
$field_content .= '<div class="wcf-cpf-add-wrap">';
|
1192 |
-
$field_content .= '<button class="button button-secondary wcf-cpf-add" data-name="wcf-checkout-custom-fields">Add New Field</button>';
|
1193 |
-
$field_content .= '</div>';
|
1194 |
-
$field_content .= '</div>';
|
1195 |
-
/* End Add new custom field */
|
1196 |
-
|
1197 |
-
$field_content .= '</div>';
|
1198 |
-
$field_content .= '</div>';
|
1199 |
-
$field_content .= '</div>';
|
1200 |
-
|
1201 |
-
return $field_content;
|
1202 |
-
}
|
1203 |
-
|
1204 |
-
function get_pro_checkout_field_repeater( $field_data ) {
|
1205 |
-
|
1206 |
-
$value = array();
|
1207 |
-
|
1208 |
-
$value[0] = array(
|
1209 |
-
'add_to' => '',
|
1210 |
-
'type' => '',
|
1211 |
-
'label' => '',
|
1212 |
-
'name' => '',
|
1213 |
-
);
|
1214 |
-
|
1215 |
-
$field_content = '';
|
1216 |
-
|
1217 |
-
$field_content .= '<div class="wcf-field-row">';
|
1218 |
-
// $field_content .= '<div class="wcf-field-row-heading">';
|
1219 |
-
// $field_content .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
|
1220 |
-
// $field_content .= '</div>';
|
1221 |
-
$field_content .= '<div class="wcf-field-row-content">';
|
1222 |
-
$field_content .= '<div class="wcf-cpf-wrap">';
|
1223 |
-
|
1224 |
-
foreach ( $value as $p_key => $p_data ) {
|
1225 |
-
$field_content .= '<div class="wcf-cpf-row" data-key="' . $p_key . '">';
|
1226 |
-
$field_content .= '<div class="wcf-cpf-row-header">';
|
1227 |
-
$field_content .= '<span class="wcf-cpf-row-title">Add New Custom Field</span>';
|
1228 |
-
$field_content .= '</div>';
|
1229 |
-
|
1230 |
-
$field_content .= '<div class="wcf-cpf-row-standard-fields">';
|
1231 |
-
|
1232 |
-
/* Add To */
|
1233 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-add_to">';
|
1234 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Add to</span>';
|
1235 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1236 |
-
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][add_to]" class="wcf-cpf-add_to">';
|
1237 |
-
$field_content .= '<option value="billing">Billing</option>';
|
1238 |
-
$field_content .= '<option value="shipping">Shipping</option>';
|
1239 |
-
$field_content .= '</select>';
|
1240 |
-
$field_content .= '</span>';
|
1241 |
-
$field_content .= '</div>';
|
1242 |
-
|
1243 |
-
/* Type */
|
1244 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-type">';
|
1245 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Type</span>';
|
1246 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1247 |
-
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][type]" class="wcf-cpf-type">';
|
1248 |
-
$field_content .= '<option value="text">Text</option>';
|
1249 |
-
$field_content .= '<option value="textarea">Textarea</option>';
|
1250 |
-
$field_content .= '<option value="select">Select</option>';
|
1251 |
-
$field_content .= '<option value="checkbox">Checkbox</option>';
|
1252 |
-
$field_content .= '<option value="hidden">Hidden</option>';
|
1253 |
-
$field_content .= '</select>';
|
1254 |
-
$field_content .= '</span>';
|
1255 |
-
$field_content .= '</div>';
|
1256 |
-
|
1257 |
-
/* Label */
|
1258 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-label">';
|
1259 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Label <i>*</i></span>';
|
1260 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1261 |
-
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-label">';
|
1262 |
-
$field_content .= '<span id="wcf-cpf-label-error-msg"></span>';
|
1263 |
-
$field_content .= '</span>';
|
1264 |
-
$field_content .= '</div>';
|
1265 |
-
|
1266 |
-
/* Default */
|
1267 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-default">';
|
1268 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Default</span>';
|
1269 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1270 |
-
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][default]" class="wcf-cpf-default">';
|
1271 |
-
$field_content .= '<span id="wcf-cpf-default-error-msg"></span>';
|
1272 |
-
$field_content .= '</span>';
|
1273 |
-
$field_content .= '</div>';
|
1274 |
-
|
1275 |
-
/* Placeholder */
|
1276 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-placeholder">';
|
1277 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Placeholder</span>';
|
1278 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1279 |
-
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][placeholder]" class="wcf-cpf-placeholder">';
|
1280 |
-
$field_content .= '<span id="wcf-cpf-placeholder-error-msg"></span>';
|
1281 |
-
$field_content .= '</span>';
|
1282 |
-
$field_content .= '</div>';
|
1283 |
-
|
1284 |
-
/* Options */
|
1285 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-options">';
|
1286 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Options <i>*</i></span>';
|
1287 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1288 |
-
$field_content .= '<textarea value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-options" placeholder="Enter your options separated by comma."></textarea>';
|
1289 |
-
$field_content .= '</span>';
|
1290 |
-
$field_content .= '</div>';
|
1291 |
-
|
1292 |
-
/* Width */
|
1293 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-width">';
|
1294 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Width</span>';
|
1295 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1296 |
-
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][width]" class="wcf-cpf-width">';
|
1297 |
-
$field_content .= '<option value="33">33%</option>';
|
1298 |
-
$field_content .= '<option value="50">50%</option>';
|
1299 |
-
$field_content .= '<option value="100" selected>100%</option>';
|
1300 |
-
$field_content .= '</select>';
|
1301 |
-
$field_content .= '</span>';
|
1302 |
-
$field_content .= '</div>';
|
1303 |
-
|
1304 |
-
/* Required */
|
1305 |
-
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-required">';
|
1306 |
-
$field_content .= '<span class="wcf-cpf-row-setting-label">Required</span>';
|
1307 |
-
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1308 |
-
$field_content .= '<input type="hidden" value="no" name="wcf-checkout-custom-fields[' . $p_key . '][required]" class="wcf-cpf-required">';
|
1309 |
-
$field_content .= '<input type="checkbox" value="yes" name="wcf-checkout-custom-fields[' . $p_key . '][required]" class="wcf-cpf-required">';
|
1310 |
-
$field_content .= '<span id="wcf-cpf-required-error-msg"></span>';
|
1311 |
-
$field_content .= '</span>';
|
1312 |
-
$field_content .= '</div>';
|
1313 |
-
|
1314 |
-
$field_content .= '</div>';
|
1315 |
-
$field_content .= '</div>';
|
1316 |
-
}
|
1317 |
-
|
1318 |
-
/* Add New Custom Field */
|
1319 |
-
$field_content .= '<div class="wcf-cpf-add-row">';
|
1320 |
-
$field_content .= '<div class="wcf-cpf-add-wrap">';
|
1321 |
-
$field_content .= '<button class="button button-secondary wcf-pro-cpf-add" data-name="wcf-checkout-custom-fields">Add New Field</button>';
|
1322 |
-
$field_content .= '</div>';
|
1323 |
-
$field_content .= '</div>';
|
1324 |
-
/* End Add new custom field */
|
1325 |
-
|
1326 |
-
$field_content .= '</div>';
|
1327 |
-
$field_content .= '</div>';
|
1328 |
-
$field_content .= '</div>';
|
1329 |
-
|
1330 |
-
return $field_content;
|
1331 |
-
}
|
1332 |
-
|
1333 |
-
function get_product_selection_repeater( $field_data ) {
|
1334 |
-
|
1335 |
-
$value = $field_data['value'];
|
1336 |
-
|
1337 |
-
if ( ! is_array( $value ) ) {
|
1338 |
-
|
1339 |
-
$value[0] = array(
|
1340 |
-
'product' => '',
|
1341 |
-
);
|
1342 |
-
} else {
|
1343 |
-
|
1344 |
-
if ( ! isset( $value[0] ) ) {
|
1345 |
-
|
1346 |
-
$value[0] = array(
|
1347 |
-
'product' => '',
|
1348 |
-
);
|
1349 |
-
}
|
1350 |
-
}
|
1351 |
-
|
1352 |
-
$field_html = '';
|
1353 |
-
|
1354 |
-
$field_html .= '<script type="text/html" id="tmpl-wcf-product-repeater">';
|
1355 |
-
$field_html .= $this->generate_product_repeater_html( '{{id}}' );
|
1356 |
-
$field_html .= '</script>';
|
1357 |
-
|
1358 |
-
$field_html .= '<div class="wcf-field-row">';
|
1359 |
-
$field_html .= '<div class="wcf-field-row-content">';
|
1360 |
-
$field_html .= '<div class="wcf-repeatables-wrap">';
|
1361 |
-
|
1362 |
-
if ( is_array( $value ) ) {
|
1363 |
-
|
1364 |
-
foreach ( $value as $p_key => $p_data ) {
|
1365 |
-
|
1366 |
-
$selected_options = '';
|
1367 |
-
|
1368 |
-
if ( isset( $p_data['product'] ) ) {
|
1369 |
-
|
1370 |
-
$product = wc_get_product( $p_data['product'] );
|
1371 |
-
|
1372 |
-
// posts.
|
1373 |
-
if ( ! empty( $product ) ) {
|
1374 |
-
$post_title = $product->get_name() . ' (#' . $p_data['product'] . ')';
|
1375 |
-
|
1376 |
-
$selected_options = '<option value="' . $p_data['product'] . '" selected="selected" >' . $post_title . '</option>';
|
1377 |
-
}
|
1378 |
-
}
|
1379 |
-
|
1380 |
-
$field_html .= $this->generate_product_repeater_html( $p_key, $selected_options );
|
1381 |
-
}
|
1382 |
-
}
|
1383 |
-
|
1384 |
-
$field_html .= '<div class="wcf-add-repeatable-row">';
|
1385 |
-
$field_html .= '<div class="submit wcf-add-repeatable-wrap">';
|
1386 |
-
$field_html .= '<button class="button-primary wcf-add-repeatable" data-name="wcf-checkout-products">Add New Product</button>';
|
1387 |
-
$field_html .= '</div>';
|
1388 |
-
$field_html .= '</div>';
|
1389 |
-
$field_html .= '</div>';
|
1390 |
-
$field_html .= '</div>';
|
1391 |
-
$field_html .= '</div>';
|
1392 |
-
|
1393 |
-
return $field_html;
|
1394 |
-
}
|
1395 |
-
|
1396 |
-
function generate_product_repeater_html( $id, $options = '' ) {
|
1397 |
-
|
1398 |
-
$field_html = '<div class="wcf-repeatable-row" data-key="' . $id . '">';
|
1399 |
-
|
1400 |
-
$field_html .= '<div class="wcf-repeatable-row-standard-fields">';
|
1401 |
-
|
1402 |
-
/* Product Name */
|
1403 |
-
$field_html .= '<div class="wcf-repeatable-fields wcf-sel-product">';
|
1404 |
-
$field_html .= '<span class="wcf-repeatable-row-setting-field">';
|
1405 |
-
$field_html .= '<select
|
1406 |
-
name="wcf-checkout-products[' . $id . '][product]"
|
1407 |
-
class="wcf-product-search"
|
1408 |
-
data-allow_clear="allow_clear"
|
1409 |
-
data-placeholder="' . __( 'Search for a product…', 'cartflows' ) . '"
|
1410 |
-
data-action="woocommerce_json_search_products_and_variations">';
|
1411 |
-
$field_html .= $options;
|
1412 |
-
$field_html .= '</select>';
|
1413 |
-
$field_html .= '</span>';
|
1414 |
-
$field_html .= '<span class="wcf-repeatable-row-actions">';
|
1415 |
-
$field_html .= '<a class="wcf-remove-row wcf-repeatable-remove button" data-type="product">';
|
1416 |
-
$field_html .= '<span class="dashicons dashicons-trash"></span>';
|
1417 |
-
$field_html .= '<span class="wcf-repeatable-remove-button">'. __( 'Remove', 'cartflows' ).'</span>';
|
1418 |
-
$field_html .= '</a>';
|
1419 |
-
$field_html .= '</span>';
|
1420 |
-
$field_html .= '</div>';
|
1421 |
-
$field_html .= '</div>';
|
1422 |
-
$field_html .= '</div>';
|
1423 |
-
|
1424 |
-
return $field_html;
|
1425 |
-
}
|
1426 |
-
|
1427 |
-
function get_image_field( $field_data ) {
|
1428 |
-
|
1429 |
-
$value = $field_data['value'];
|
1430 |
-
|
1431 |
-
$attr = '';
|
1432 |
-
|
1433 |
-
if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
|
1434 |
-
|
1435 |
-
foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
|
1436 |
-
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
1437 |
-
}
|
1438 |
-
}
|
1439 |
-
|
1440 |
-
$display_preview_box = ( isset( $value ) && '' != $value ) ? 'display:block;' : 'display:none';
|
1441 |
-
|
1442 |
-
$field_content = '<div id="wcf-image-preview" style="'.$display_preview_box.'">';
|
1443 |
-
if( isset( $value ) ){
|
1444 |
-
$field_content .= '<img src="'. $value .'" class="saved-image" name="'. $field_data['name'] .'" width="150">';
|
1445 |
-
}
|
1446 |
-
$field_content .= '</div>';
|
1447 |
-
// $field_content .= '<input type="hidden" id="wcf-image-id" class="wcf-image-id" name="wcf-image-id[image-id]" value="">';
|
1448 |
-
$field_content .= '<input type="hidden" id="wcf-image-value" class="wcf-image" name="' . $field_data['name'] . '" value="'.$value.'">';
|
1449 |
-
|
1450 |
-
$field_content .= '<button type="button" ' . $attr . ' class="wcf-select-image button-secondary">Select Image</button>';
|
1451 |
-
|
1452 |
-
$display_remove_button = ( isset( $value ) && '' != $value ) ? 'display:inline-block; margin-left: 5px;' : 'display:none';
|
1453 |
-
|
1454 |
-
$field_content .= '<button type="button" class="wcf-remove-image button-secondary" style="'.$display_remove_button.'">Remove Image</button>';
|
1455 |
-
|
1456 |
-
return $this->get_field( $field_data, $field_content );
|
1457 |
-
}
|
1458 |
-
|
1459 |
-
/**
|
1460 |
-
* Localize variables in admin
|
1461 |
-
*
|
1462 |
-
* @param array $vars variables.
|
1463 |
-
*/
|
1464 |
-
function localize_vars( $vars ) {
|
1465 |
-
|
1466 |
-
$ajax_actions = array(
|
1467 |
-
'wcf_add_checkout_custom_field',
|
1468 |
-
'wcf_pro_add_checkout_custom_field',
|
1469 |
-
'wcf_delete_checkout_custom_field',
|
1470 |
-
'wcf_json_search_pages',
|
1471 |
-
'wcf_json_search_coupons'
|
1472 |
-
);
|
1473 |
-
|
1474 |
-
foreach ( $ajax_actions as $action ) {
|
1475 |
-
|
1476 |
-
$vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
|
1477 |
-
}
|
1478 |
-
|
1479 |
-
return $vars;
|
1480 |
-
}
|
1481 |
-
}
|
1482 |
-
// @codingStandardsIgnoreEnd
|
1 |
+
<?php
|
2 |
+
// @codingStandardsIgnoreStart
|
3 |
+
/**
|
4 |
+
* Meta Fields.
|
5 |
+
*
|
6 |
+
* @package CartFlows
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Cartflows_Meta_Fields.
|
11 |
+
*/
|
12 |
+
class Cartflows_Meta_Fields {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Instance
|
16 |
+
*
|
17 |
+
* @var $instance
|
18 |
+
*/
|
19 |
+
private static $instance;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Initiator
|
23 |
+
*/
|
24 |
+
public static function get_instance() {
|
25 |
+
if ( ! isset( self::$instance ) ) {
|
26 |
+
self::$instance = new self;
|
27 |
+
}
|
28 |
+
|
29 |
+
return self::$instance;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Constructor
|
34 |
+
*/
|
35 |
+
public function __construct() {
|
36 |
+
|
37 |
+
/* Add Scripts */
|
38 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_meta_scripts' ), 20 );
|
39 |
+
|
40 |
+
add_action( 'wp_ajax_wcf_json_search_coupons', array( $this, 'json_search_coupons' ) );
|
41 |
+
|
42 |
+
add_action( 'wp_ajax_wcf_add_checkout_custom_field', array( $this, 'add_checkout_custom_field' ) );
|
43 |
+
|
44 |
+
add_action( 'wp_ajax_wcf_pro_add_checkout_custom_field', array( $this, 'add_pro_checkout_custom_field' ) );
|
45 |
+
|
46 |
+
add_action( 'wp_ajax_wcf_delete_checkout_custom_field', array( $this, 'delete_checkout_custom_field' ) );
|
47 |
+
|
48 |
+
add_action( 'wp_ajax_wcf_json_search_pages', array( $this, 'json_search_pages' ) );
|
49 |
+
|
50 |
+
add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
|
51 |
+
}
|
52 |
+
|
53 |
+
public function admin_meta_scripts() {
|
54 |
+
|
55 |
+
global $pagenow;
|
56 |
+
global $post;
|
57 |
+
|
58 |
+
$screen = get_current_screen();
|
59 |
+
|
60 |
+
if (
|
61 |
+
( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) &&
|
62 |
+
wcf()->utils->is_step_post_type( $screen->post_type )
|
63 |
+
) {
|
64 |
+
|
65 |
+
wp_enqueue_style( 'woocommerce_admin_styles' );
|
66 |
+
|
67 |
+
wp_enqueue_script( 'select2' );
|
68 |
+
wp_enqueue_script( 'wc-enhanced-select' );
|
69 |
+
|
70 |
+
wp_enqueue_script(
|
71 |
+
'wcf-admin-meta',
|
72 |
+
CARTFLOWS_URL . 'admin/meta-assets/js/admin-edit.js',
|
73 |
+
array( 'jquery', 'select2', 'wp-color-picker' ),
|
74 |
+
CARTFLOWS_VER,
|
75 |
+
true
|
76 |
+
);
|
77 |
+
|
78 |
+
wp_enqueue_style( 'wcf-admin-meta', CARTFLOWS_URL . 'admin/meta-assets/css/admin-edit.css', array( 'wp-color-picker' ), CARTFLOWS_VER );
|
79 |
+
wp_style_add_data( 'wcf-admin-meta', 'rtl', 'replace' );
|
80 |
+
|
81 |
+
$localize = array(
|
82 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
83 |
+
'google_fonts' => CartFlows_Font_Families::get_google_fonts(),
|
84 |
+
'system_fonts' => CartFlows_Font_Families::get_system_fonts(),
|
85 |
+
'font_weights' => array(
|
86 |
+
'100' => __( 'Thin 100', 'cartflows' ),
|
87 |
+
'200' => __( 'Extra-Light 200', 'cartflows' ),
|
88 |
+
'300' => __( 'Light 300', 'cartflows' ),
|
89 |
+
'400' => __( 'Normal 400', 'cartflows' ),
|
90 |
+
'500' => __( 'Medium 500', 'cartflows' ),
|
91 |
+
'600' => __( 'Semi-Bold 600', 'cartflows' ),
|
92 |
+
'700' => __( 'Bold 700', 'cartflows' ),
|
93 |
+
'800' => __( 'Extra-Bold 800', 'cartflows' ),
|
94 |
+
'900' => __( 'Ultra-Bold 900', 'cartflows' ),
|
95 |
+
)
|
96 |
+
);
|
97 |
+
|
98 |
+
wp_localize_script( 'jquery', 'wcf', apply_filters( 'wcf_js_localize', $localize ) );
|
99 |
+
|
100 |
+
do_action( 'cartflows_admin_meta_scripts' );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Function to search coupons
|
106 |
+
*/
|
107 |
+
public function json_search_coupons() {
|
108 |
+
|
109 |
+
check_admin_referer( 'wcf-json-search-coupons', 'security' );
|
110 |
+
|
111 |
+
global $wpdb;
|
112 |
+
|
113 |
+
$term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore
|
114 |
+
|
115 |
+
if ( empty( $term ) ) {
|
116 |
+
die();
|
117 |
+
}
|
118 |
+
|
119 |
+
$posts = wp_cache_get( 'wcf_search_coupons', 'wcf_funnel_Cart' );
|
120 |
+
|
121 |
+
if ( false === $posts ) {
|
122 |
+
$posts = $wpdb->get_results( // phpcs:ignore
|
123 |
+
$wpdb->prepare(
|
124 |
+
"SELECT *
|
125 |
+
FROM {$wpdb->prefix}posts
|
126 |
+
WHERE post_type = %s
|
127 |
+
AND post_title LIKE %s
|
128 |
+
AND post_status = %s",
|
129 |
+
'shop_coupon',
|
130 |
+
$wpdb->esc_like( $term ) . '%',
|
131 |
+
'publish'
|
132 |
+
)
|
133 |
+
);
|
134 |
+
wp_cache_set( 'wcf_search_coupons', $posts, 'wcf_funnel_Cart' );
|
135 |
+
}
|
136 |
+
|
137 |
+
$coupons_found = array();
|
138 |
+
$all_discount_types = wc_get_coupon_types();
|
139 |
+
|
140 |
+
if ( $posts ) {
|
141 |
+
foreach ( $posts as $post ) {
|
142 |
+
|
143 |
+
$discount_type = get_post_meta( $post->ID, 'discount_type', true );
|
144 |
+
|
145 |
+
if ( ! empty( $all_discount_types[ $discount_type ] ) ) {
|
146 |
+
$coupons_found[ get_the_title( $post->ID ) ] = get_the_title( $post->ID ) . ' (Type: ' . $all_discount_types[ $discount_type ] . ')';
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
wp_send_json( $coupons_found );
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* [add_checkout_custom_field description]
|
156 |
+
*
|
157 |
+
* @hook wcf_add_checkout_custom_field
|
158 |
+
*/
|
159 |
+
public function add_checkout_custom_field() {
|
160 |
+
|
161 |
+
check_ajax_referer( 'wcf-add-checkout-custom-field', 'security' );
|
162 |
+
|
163 |
+
$post_id = intval( $_POST['post_id'] );
|
164 |
+
$add_to = sanitize_text_field( wp_unslash( $_POST['add_to'] ) );
|
165 |
+
$type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
|
166 |
+
$options = sanitize_text_field( wp_unslash( $_POST['options'] ) );
|
167 |
+
$label = sanitize_text_field( wp_unslash( $_POST['label'] ) );
|
168 |
+
$name = sanitize_text_field( wp_unslash( $_POST['name'] ) );
|
169 |
+
|
170 |
+
if ( '' !== $name ) {
|
171 |
+
|
172 |
+
$fields = Cartflows_Helper::get_checkout_fields( $add_to, $post_id );
|
173 |
+
$field_keys = array_keys($fields);
|
174 |
+
|
175 |
+
$name = $add_to . '_' . sanitize_key( $name );
|
176 |
+
if( in_array($name, $field_keys) ) {
|
177 |
+
$name = $name . '_' . rand( 0000, 9999 );
|
178 |
+
}
|
179 |
+
|
180 |
+
$field_data = array(
|
181 |
+
'type' => $type,
|
182 |
+
'label' => $label,
|
183 |
+
'placeholder' => '',
|
184 |
+
'class' => array( 'form-row-wide' ),
|
185 |
+
'label_class' => array(),
|
186 |
+
'required' => true,
|
187 |
+
'custom' => true,
|
188 |
+
);
|
189 |
+
|
190 |
+
if ( 'select' === $type ) {
|
191 |
+
|
192 |
+
$options = explode( ',', $options );
|
193 |
+
$field_data['options'] = array();
|
194 |
+
|
195 |
+
if ( is_array( $options ) && ! empty( $options ) ) {
|
196 |
+
|
197 |
+
foreach ( $options as $key => $value ) {
|
198 |
+
|
199 |
+
$field_data['options'][ $value ] = $value;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
Cartflows_Helper::add_checkout_field( $add_to, $name, $field_data, $post_id );
|
205 |
+
|
206 |
+
$key = sanitize_key( $name );
|
207 |
+
$name = 'wcf-' . $key;
|
208 |
+
|
209 |
+
$field_args = array(
|
210 |
+
'label' => $label,
|
211 |
+
'name' => $name,
|
212 |
+
'value' => 'yes',
|
213 |
+
'after' => 'Enable',
|
214 |
+
);
|
215 |
+
|
216 |
+
$field_args['after_html'] = '<span class="wcf-cpf-actions" data-type="billing" data-key="' . $key . '"> | ';
|
217 |
+
$field_args['after_html'] .= '<a class="wcf-cpf-action-remove">' . __( 'Remove', 'cartflows' ) . '</a>';
|
218 |
+
$field_args['after_html'] .= '</span>';
|
219 |
+
|
220 |
+
$field_markup = wcf()->meta->get_checkbox_field( $field_args );
|
221 |
+
|
222 |
+
if( 'billing' === $add_to ) {
|
223 |
+
$add_to_class = 'wcf-cb-fields';
|
224 |
+
} else if( 'shipping' === $add_to ) {
|
225 |
+
$add_to_class = 'wcf-sb-fields';
|
226 |
+
}
|
227 |
+
|
228 |
+
$data = array(
|
229 |
+
'field_data' => $field_data,
|
230 |
+
'field_args' => $field_args,
|
231 |
+
'add_to_class' => $add_to_class,
|
232 |
+
'markup' => $field_markup,
|
233 |
+
);
|
234 |
+
|
235 |
+
wp_send_json( $data );
|
236 |
+
}
|
237 |
+
|
238 |
+
wp_send_json( false );
|
239 |
+
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* [add_checkout_custom_field description]
|
244 |
+
*
|
245 |
+
* @hook wcf_add_checkout_custom_field
|
246 |
+
*/
|
247 |
+
public function add_pro_checkout_custom_field() {
|
248 |
+
|
249 |
+
check_ajax_referer( 'wcf-pro-add-checkout-custom-field', 'security' );
|
250 |
+
|
251 |
+
$post_id = intval( $_POST['post_id'] );
|
252 |
+
$add_to = sanitize_text_field( wp_unslash( $_POST['add_to'] ) );
|
253 |
+
$type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
|
254 |
+
$options = sanitize_text_field( wp_unslash( $_POST['options'] ) );
|
255 |
+
$label = sanitize_text_field( wp_unslash( $_POST['label'] ) );
|
256 |
+
$name = sanitize_text_field( wp_unslash( str_replace(' ', '_', $_POST['label'] ) ) );
|
257 |
+
$placeholder = sanitize_text_field( wp_unslash( $_POST['placeholder'] ) );
|
258 |
+
$width = sanitize_text_field( wp_unslash( $_POST['width'] ) );
|
259 |
+
$default_value = sanitize_text_field( wp_unslash( $_POST['default'] ) );
|
260 |
+
$is_required = sanitize_text_field( wp_unslash( $_POST['required'] ) );
|
261 |
+
|
262 |
+
$field_markup = '';
|
263 |
+
|
264 |
+
if ( '' !== $name ) {
|
265 |
+
|
266 |
+
$fields = Cartflows_Helper::get_checkout_fields( $add_to, $post_id );
|
267 |
+
$field_keys = array_keys($fields);
|
268 |
+
|
269 |
+
$name = $add_to . '_' . sanitize_key( $name );
|
270 |
+
if( in_array($name, $field_keys) ) {
|
271 |
+
$name = $name . '_' . rand( 0000, 9999 );
|
272 |
+
}
|
273 |
+
|
274 |
+
$field_data = array(
|
275 |
+
'type' => $type,
|
276 |
+
'label' => $label,
|
277 |
+
'placeholder' => $placeholder,
|
278 |
+
'class' => array( 'form-row-wide' ),
|
279 |
+
'label_class' => array(),
|
280 |
+
'required' => $is_required,
|
281 |
+
'custom' => true,
|
282 |
+
'default' => $default_value,
|
283 |
+
'options' => $options,
|
284 |
+
);
|
285 |
+
|
286 |
+
if ( 'select' === $type ) {
|
287 |
+
|
288 |
+
$options = explode( ',', $options );
|
289 |
+
$field_data['options'] = array();
|
290 |
+
|
291 |
+
if ( is_array( $options ) && ! empty( $options ) ) {
|
292 |
+
|
293 |
+
foreach ( $options as $key => $value ) {
|
294 |
+
|
295 |
+
$field_data['options'][ $value ] = $value;
|
296 |
+
}
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
$width_args = array(
|
301 |
+
'wcf-field-width_'.$name => $width,
|
302 |
+
);
|
303 |
+
|
304 |
+
Cartflows_Helper::add_checkout_field( $add_to, $name, $field_data, $post_id );
|
305 |
+
Cartflows_Helper::save_meta_option( $post_id, $width_args );
|
306 |
+
|
307 |
+
$key = sanitize_key( $name );
|
308 |
+
$name = 'wcf-' . $key;
|
309 |
+
|
310 |
+
$field_args = array(
|
311 |
+
'type' => $type,
|
312 |
+
'label' => $label,
|
313 |
+
'name' => $name,
|
314 |
+
'value' => 'yes',
|
315 |
+
'placeholder' => $placeholder,
|
316 |
+
'width' => $width,
|
317 |
+
'after' => 'Enable',
|
318 |
+
'section' => $add_to,
|
319 |
+
'default' => $default_value,
|
320 |
+
'required' => $is_required,
|
321 |
+
'options' => $options,
|
322 |
+
);
|
323 |
+
|
324 |
+
$field_args['after_html'] = '<span class="wcf-cpf-actions" data-type="billing" data-key="' . $key . '"> ';
|
325 |
+
$field_args['after_html'] .= '<a class="wcf-cpf-action-remove wp-ui-text-notification">'. __( 'Remove', 'cartflows' ).'</a>';
|
326 |
+
$field_args['after_html'] .= '</span>';
|
327 |
+
|
328 |
+
// $field_markup = wcf()->meta->get_checkbox_field( $field_args );
|
329 |
+
|
330 |
+
$field_markup .= "<li class='wcf-field-item-edit-inactive wcf-field-item ui-sortable-handle'>";
|
331 |
+
$field_markup .= $this->get_field_html_via_ajax($field_args);
|
332 |
+
$field_markup .= "</li>";
|
333 |
+
|
334 |
+
if( 'billing' === $add_to ) {
|
335 |
+
$add_to_class = 'billing-field-sortable';
|
336 |
+
$section = 'billing';
|
337 |
+
} else if( 'shipping' === $add_to ) {
|
338 |
+
$add_to_class = 'shipping-field-sortable';
|
339 |
+
$section = 'shipping';
|
340 |
+
}
|
341 |
+
|
342 |
+
$data = array(
|
343 |
+
'field_data' => $field_data,
|
344 |
+
'field_args' => $field_args,
|
345 |
+
'add_to_class' => $add_to_class,
|
346 |
+
'markup' => $field_markup,
|
347 |
+
'section' => $section,
|
348 |
+
);
|
349 |
+
|
350 |
+
wp_send_json( $data );
|
351 |
+
}
|
352 |
+
|
353 |
+
wp_send_json( false );
|
354 |
+
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Get field html.
|
359 |
+
*
|
360 |
+
* @param array $args field arguments.
|
361 |
+
* @return string
|
362 |
+
*/
|
363 |
+
function get_field_html_via_ajax( $field_args ) {
|
364 |
+
|
365 |
+
$value = $field_args['value'];
|
366 |
+
|
367 |
+
$is_checkbox = false;
|
368 |
+
$is_require = false;
|
369 |
+
$is_select = false;
|
370 |
+
|
371 |
+
$display = 'none';
|
372 |
+
|
373 |
+
$field_content = '';
|
374 |
+
|
375 |
+
if ( isset( $field_args['before'] ) ) {
|
376 |
+
$field_content .= '<span>' . $field_args['before'] . '</span>';
|
377 |
+
}
|
378 |
+
$field_content .= '<input type="hidden" name="' . $field_args['name'] . '" value="no">';
|
379 |
+
$field_content .= '<input type="checkbox" name="' . $field_args['name'] . '" value="yes" ' . checked( 'yes', $value, false ) . '>';
|
380 |
+
|
381 |
+
if ( isset( $field_args['after'] ) ) {
|
382 |
+
$field_content .= $field_args['after'];
|
383 |
+
}
|
384 |
+
|
385 |
+
$type = isset( $field_args['type'] ) ? $field_args['type'] : '';
|
386 |
+
$label = isset( $field_args['label'] ) ? $field_args['label'] : '';
|
387 |
+
$help = isset( $field_args['help'] ) ? $field_args['help'] : '';
|
388 |
+
$after_html = isset( $field_args['after_html'] ) ? $field_args['after_html'] : '';
|
389 |
+
$name = isset( $field_args['name'] ) ? $field_args['name'] : '';
|
390 |
+
$default = isset( $field_args['default']) ? $field_args['default'] : '';
|
391 |
+
$required = isset( $field_args['required']) ? $field_args['required'] : '';
|
392 |
+
$options = isset( $field_args['options']) ? $field_args['options'] : '';
|
393 |
+
$width = isset( $field_args['width']) ? $field_args['width'] : '';
|
394 |
+
$name_class = 'field-' . $field_args['name'];
|
395 |
+
|
396 |
+
if( isset( $options ) && !empty( $options ) ){
|
397 |
+
$options = implode(', ', $options );
|
398 |
+
}else{
|
399 |
+
$options = '';
|
400 |
+
}
|
401 |
+
|
402 |
+
if( 'yes' == $required ){
|
403 |
+
$is_require = true;
|
404 |
+
}
|
405 |
+
|
406 |
+
if( 'checkbox' == $type ){
|
407 |
+
$is_checkbox = true;
|
408 |
+
}
|
409 |
+
|
410 |
+
if( 'select' == $type ){
|
411 |
+
$is_select = true;
|
412 |
+
$display = 'block';
|
413 |
+
}
|
414 |
+
|
415 |
+
// echo "<pre>";
|
416 |
+
// var_dump($after_html);
|
417 |
+
// echo "</pre>";
|
418 |
+
|
419 |
+
// $field_markup = wcf()->meta->get_only_checkbox_field( $field_args );
|
420 |
+
ob_start();
|
421 |
+
|
422 |
+
?>
|
423 |
+
<div class="wcf-field-item-bar">
|
424 |
+
<div class="wcf-field-item-handle ui-sortable-handle">
|
425 |
+
<label class="dashicons <?php if( 'no' == $value ){ echo 'dashicons-hidden'; } else{ echo 'dashicons-visibility';} ?> " for="<?php echo $field_args['name']; ?>"></label>
|
426 |
+
<span class="item-title">
|
427 |
+
<span class="wcf-field-item-title"><?php echo $label; if( $is_require ) { ?> <i>*</i> <?php } ?></span>
|
428 |
+
<span class="is-submenu" style="display: none;">sub item</span>
|
429 |
+
</span>
|
430 |
+
<span class="item-controls">
|
431 |
+
<span class="dashicons dashicons-menu"></span>
|
432 |
+
<span class="item-order hide-if-js">
|
433 |
+
<a href="#" class="item-move-up" aria-label="Move up">↑</a>
|
434 |
+
|
|
435 |
+
<a href="#" class="item-move-down" aria-label="Move down">↓</a>
|
436 |
+
</span>
|
437 |
+
<a class="item-edit" id="edit-64" href="javascript:void(0);" aria-label="My account. Menu item 1 of 5."><span class="screen-reader-text">Edit</span></a>
|
438 |
+
</span>
|
439 |
+
</div>
|
440 |
+
</div>
|
441 |
+
<div class="wcf-field-item-settings">
|
442 |
+
<div class="wcf-field-item-settings-row-width">
|
443 |
+
<?php
|
444 |
+
echo wcf()->meta->get_select_field(
|
445 |
+
array(
|
446 |
+
'label' => __( 'Field Width', 'cartflows' ),
|
447 |
+
'name' => 'wcf-field-width_' . str_replace( 'wcf-', '', $field_args['name'] ),
|
448 |
+
'value' => $width,
|
449 |
+
'options' => array(
|
450 |
+
'33' => __( '33%', 'cartflows' ),
|
451 |
+
'50' => __( '50%', 'cartflows' ),
|
452 |
+
'100' => __( '100%', 'cartflows' ),
|
453 |
+
),
|
454 |
+
)
|
455 |
+
);
|
456 |
+
?>
|
457 |
+
</div>
|
458 |
+
|
459 |
+
<div class="wcf-field-item-settings-label">
|
460 |
+
<?php
|
461 |
+
echo wcf()->meta->get_text_field(
|
462 |
+
array(
|
463 |
+
'label' => __( 'Field Label', 'cartflows' ),
|
464 |
+
'name' => 'wcf_label_text_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
465 |
+
'value' => $label,
|
466 |
+
)
|
467 |
+
);
|
468 |
+
|
469 |
+
?>
|
470 |
+
<input type="hidden" name="wcf_field_order_<?php echo $field_args['section']; ?>[]" value="<?php echo str_replace( 'wcf-', '', $field_args['name'] ); ?>">
|
471 |
+
</div>
|
472 |
+
|
473 |
+
<div class="wcf-field-item-select-options" style="display:<?php if( isset( $display ) ){ print $display; } ?>;" >
|
474 |
+
<?php
|
475 |
+
echo wcf()->meta->get_text_field(
|
476 |
+
array(
|
477 |
+
'label' => __( 'Options', 'cartflows' ),
|
478 |
+
'name' => 'wcf_select_option_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
479 |
+
'value' => $options,
|
480 |
+
)
|
481 |
+
);
|
482 |
+
|
483 |
+
?>
|
484 |
+
<input type="hidden" name="wcf_field_order_<?php echo $field_args['section']; ?>[]" value="<?php echo str_replace( 'wcf-', '', $field_args['name'] ); ?>">
|
485 |
+
</div>
|
486 |
+
|
487 |
+
<div class="wcf-field-item-settings-default">
|
488 |
+
<?php
|
489 |
+
if( true == $is_checkbox ){
|
490 |
+
echo wcf()->meta->get_select_field(
|
491 |
+
array(
|
492 |
+
'label' => __( 'Default', 'cartflows' ),
|
493 |
+
'name' => 'wcf_label_default_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
494 |
+
'value' => $value,
|
495 |
+
'options' => array(
|
496 |
+
'1' => __( 'Checked', 'cartflows' ),
|
497 |
+
'0' => __( 'Un-Checked', 'cartflows' ),
|
498 |
+
),
|
499 |
+
)
|
500 |
+
);
|
501 |
+
}else{
|
502 |
+
|
503 |
+
echo wcf()->meta->get_text_field(
|
504 |
+
array(
|
505 |
+
'label' => __( 'Default', 'cartflows' ),
|
506 |
+
'name' => 'wcf_label_default_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
507 |
+
'value' => $default,
|
508 |
+
)
|
509 |
+
);
|
510 |
+
}
|
511 |
+
?>
|
512 |
+
</div>
|
513 |
+
|
514 |
+
<div class="wcf-field-item-settings-placeholder" <?php if( true == $is_checkbox ) {?> style="display: none;" <?php } ?> >
|
515 |
+
<?php
|
516 |
+
echo wcf()->meta->get_text_field(
|
517 |
+
array(
|
518 |
+
'label' => __( 'Placeholder', 'cartflows' ),
|
519 |
+
'name' => 'wcf_label_placeholder_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
520 |
+
'value' => $label,
|
521 |
+
)
|
522 |
+
);
|
523 |
+
?>
|
524 |
+
</div>
|
525 |
+
|
526 |
+
<div class="wcf-field-item-settings-required">
|
527 |
+
<?php
|
528 |
+
echo wcf()->meta->get_checkbox_field(
|
529 |
+
array(
|
530 |
+
'label' => __( 'Required', 'cartflows' ),
|
531 |
+
'name' => 'wcf_is_required_field_' . $field_args['section'] . '[' . str_replace( 'wcf-', '', $field_args['name'] ) . ']',
|
532 |
+
'value' => $required,
|
533 |
+
)
|
534 |
+
);
|
535 |
+
?>
|
536 |
+
</div>
|
537 |
+
|
538 |
+
<div class="wcf-field-item-settings-checkbox">
|
539 |
+
<?php
|
540 |
+
echo wcf()->meta->get_checkbox_field(
|
541 |
+
array(
|
542 |
+
'label' => __( 'Enable this field', 'cartflows' ),
|
543 |
+
'name' => $field_args['name'],
|
544 |
+
'value' => $value,
|
545 |
+
)
|
546 |
+
);
|
547 |
+
?>
|
548 |
+
</div>
|
549 |
+
|
550 |
+
<?php
|
551 |
+
if(isset( $field_args['after_html']) )
|
552 |
+
{
|
553 |
+
?>
|
554 |
+
<div class="wcf-field-item-settings-row-delete-cf">
|
555 |
+
<?php echo $field_args['after_html']; ?>
|
556 |
+
</div>
|
557 |
+
<?php
|
558 |
+
}
|
559 |
+
?>
|
560 |
+
<!--
|
561 |
+
<label for="<?php echo $field_args['name']; ?>">
|
562 |
+
<?php _e( 'Label', 'cartflows' ); ?><br>
|
563 |
+
<input type="text" value="<?php echo $field_args['label']; ?>">
|
564 |
+
|
565 |
+
<?php if( isset( $field_markup ) ) { echo $field_markup; }?>
|
566 |
+
|
567 |
+
<input type="hidden" name="wcf_field_order_<?php echo $field_args['section']; ?>[]" value="<?php echo str_replace('wcf-', '', $field_args['name'] ); ?>">
|
568 |
+
</label> -->
|
569 |
+
</div>
|
570 |
+
|
571 |
+
<?php
|
572 |
+
|
573 |
+
return ob_get_clean();
|
574 |
+
}
|
575 |
+
|
576 |
+
/**
|
577 |
+
* [delete_checkout_custom_field description]
|
578 |
+
*
|
579 |
+
* @hook wcf_delete_checkout_custom_field
|
580 |
+
* @return [type] [description]
|
581 |
+
*/
|
582 |
+
public function delete_checkout_custom_field() {
|
583 |
+
|
584 |
+
check_ajax_referer( 'wcf-delete-checkout-custom-field', 'security' );
|
585 |
+
|
586 |
+
$post_id = intval( $_POST['post_id'] );
|
587 |
+
$type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
|
588 |
+
$key = sanitize_text_field( wp_unslash( $_POST['key'] ) );
|
589 |
+
|
590 |
+
if ( '' !== $key ) {
|
591 |
+
|
592 |
+
Cartflows_Helper::delete_checkout_field( $type, $key, $post_id );
|
593 |
+
|
594 |
+
wp_send_json( true );
|
595 |
+
|
596 |
+
}
|
597 |
+
|
598 |
+
wp_send_json( false );
|
599 |
+
|
600 |
+
}
|
601 |
+
|
602 |
+
/**
|
603 |
+
* Function to search coupons
|
604 |
+
*/
|
605 |
+
public function json_search_pages() {
|
606 |
+
|
607 |
+
check_ajax_referer( 'wcf-json-search-pages', 'security' );
|
608 |
+
|
609 |
+
$term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore
|
610 |
+
|
611 |
+
if ( empty( $term ) ) {
|
612 |
+
die( 'not found' );
|
613 |
+
}
|
614 |
+
|
615 |
+
$search_string = $term;
|
616 |
+
$data = array();
|
617 |
+
$result = array();
|
618 |
+
|
619 |
+
add_filter( 'posts_search', array( $this, 'search_only_titles' ), 10, 2 );
|
620 |
+
|
621 |
+
$query = new WP_Query(
|
622 |
+
array(
|
623 |
+
's' => $search_string,
|
624 |
+
'post_type' => 'page',
|
625 |
+
'posts_per_page' => - 1,
|
626 |
+
)
|
627 |
+
);
|
628 |
+
|
629 |
+
if ( $query->have_posts() ) {
|
630 |
+
while ( $query->have_posts() ) {
|
631 |
+
$query->the_post();
|
632 |
+
$title = get_the_title();
|
633 |
+
$title .= ( 0 != $query->post->post_parent ) ? ' (' . get_the_title( $query->post->post_parent ) . ')' : '';
|
634 |
+
$id = get_the_id();
|
635 |
+
$data[] = array(
|
636 |
+
'id' => $id,
|
637 |
+
'text' => $title,
|
638 |
+
);
|
639 |
+
}
|
640 |
+
}
|
641 |
+
|
642 |
+
if ( is_array( $data ) && ! empty( $data ) ) {
|
643 |
+
$result[] = array(
|
644 |
+
'text' => '',
|
645 |
+
'children' => $data,
|
646 |
+
);
|
647 |
+
}
|
648 |
+
|
649 |
+
wp_reset_postdata();
|
650 |
+
|
651 |
+
// return the result in json.
|
652 |
+
wp_send_json( $result );
|
653 |
+
}
|
654 |
+
|
655 |
+
public function search_only_titles( $search, $wp_query ) {
|
656 |
+
if ( ! empty( $search ) && ! empty( $wp_query->query_vars['search_terms'] ) ) {
|
657 |
+
global $wpdb;
|
658 |
+
|
659 |
+
$q = $wp_query->query_vars;
|
660 |
+
$n = ! empty( $q['exact'] ) ? '' : '%';
|
661 |
+
|
662 |
+
$search = array();
|
663 |
+
|
664 |
+
foreach ( (array) $q['search_terms'] as $term ) {
|
665 |
+
$search[] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like( $term ) . $n );
|
666 |
+
}
|
667 |
+
|
668 |
+
if ( ! is_user_logged_in() ) {
|
669 |
+
$search[] = "$wpdb->posts.post_password = ''";
|
670 |
+
}
|
671 |
+
|
672 |
+
$search = ' AND ' . implode( ' AND ', $search );
|
673 |
+
}
|
674 |
+
|
675 |
+
return $search;
|
676 |
+
}
|
677 |
+
|
678 |
+
function get_field( $field_data, $field_content ) {
|
679 |
+
|
680 |
+
$label = isset( $field_data['label'] ) ? $field_data['label'] : '';
|
681 |
+
$help = isset( $field_data['help'] ) ? $field_data['help'] : '';
|
682 |
+
$after_html = isset( $field_data['after_html'] ) ? $field_data['after_html'] : '';
|
683 |
+
|
684 |
+
$name_class = 'field-' . $field_data['name'];
|
685 |
+
|
686 |
+
$field_html = '<div class="wcf-field-row ' . $name_class . '">';
|
687 |
+
|
688 |
+
if( ! empty( $label ) || ! empty( $help ) ) {
|
689 |
+
$field_html .= '<div class="wcf-field-row-heading">';
|
690 |
+
if( ! empty( $label ) ) {
|
691 |
+
$field_html .= '<label>' . esc_html( $label ) . '</label>';
|
692 |
+
}
|
693 |
+
if ( ! empty( $help ) ) {
|
694 |
+
$field_html .= '<i class="wcf-field-heading-help dashicons dashicons-editor-help">';
|
695 |
+
// $field_html .= '<span class="wcf-tooltip" data-tooltip= "'. esc_attr( $help ) .'"></span>';
|
696 |
+
$field_html .= '</i>';
|
697 |
+
$field_html .= '<span class="wcf-tooltip-text">';
|
698 |
+
$field_html .= $help;
|
699 |
+
$field_html .= '</span>';
|
700 |
+
}
|
701 |
+
$field_html .= '</div>';
|
702 |
+
}
|
703 |
+
|
704 |
+
$field_html .= '<div class="wcf-field-row-content">';
|
705 |
+
$field_html .= $field_content;
|
706 |
+
|
707 |
+
if ( ! empty( $after_html ) ) {
|
708 |
+
$field_html .= $after_html;
|
709 |
+
}
|
710 |
+
|
711 |
+
$field_html .= '</div>';
|
712 |
+
$field_html .= '</div>';
|
713 |
+
|
714 |
+
return $field_html;
|
715 |
+
}
|
716 |
+
|
717 |
+
function get_text_field( $field_data ) {
|
718 |
+
|
719 |
+
$value = $field_data['value'];
|
720 |
+
|
721 |
+
$attr = '';
|
722 |
+
|
723 |
+
if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
|
724 |
+
|
725 |
+
foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
|
726 |
+
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
727 |
+
}
|
728 |
+
}
|
729 |
+
|
730 |
+
$field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
|
731 |
+
|
732 |
+
return $this->get_field( $field_data, $field_content );
|
733 |
+
}
|
734 |
+
|
735 |
+
function get_shortcode_field( $field_data ) {
|
736 |
+
|
737 |
+
$attr = '';
|
738 |
+
|
739 |
+
$attr_fields = array(
|
740 |
+
'readonly' => 'readonly',
|
741 |
+
'onfocus' => 'this.select()',
|
742 |
+
'onmouseup' => 'return false',
|
743 |
+
);
|
744 |
+
|
745 |
+
if ( $attr_fields && is_array( $attr_fields ) ) {
|
746 |
+
|
747 |
+
foreach ( $attr_fields as $attr_key => $attr_value ) {
|
748 |
+
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
749 |
+
}
|
750 |
+
}
|
751 |
+
|
752 |
+
$field_content = '<input type="text" name="' . $field_data['name'] . '" value="' . $field_data['content'] . '" ' . $attr . '>';
|
753 |
+
|
754 |
+
return $this->get_field( $field_data, $field_content );
|
755 |
+
}
|
756 |
+
|
757 |
+
function get_display_field( $field_data ) {
|
758 |
+
|
759 |
+
$field_content = $field_data['content'];
|
760 |
+
|
761 |
+
return $this->get_field( $field_data, $field_content );
|
762 |
+
}
|
763 |
+
|
764 |
+
function get_hr_line_field( $field_data ) {
|
765 |
+
|
766 |
+
$field_data = array(
|
767 |
+
'name' => 'wcf-hr-line',
|
768 |
+
'content' => '<hr>'
|
769 |
+
);
|
770 |
+
|
771 |
+
$field_content = $field_data['content'];
|
772 |
+
|
773 |
+
return $this->get_field( $field_data, $field_content );
|
774 |
+
}
|
775 |
+
|
776 |
+
function get_number_field( $field_data ) {
|
777 |
+
|
778 |
+
$value = $field_data['value'];
|
779 |
+
|
780 |
+
$attr = '';
|
781 |
+
|
782 |
+
if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
|
783 |
+
|
784 |
+
foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
|
785 |
+
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
786 |
+
}
|
787 |
+
}
|
788 |
+
|
789 |
+
$field_content = '<input type="number" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
|
790 |
+
|
791 |
+
return $this->get_field( $field_data, $field_content );
|
792 |
+
}
|
793 |
+
|
794 |
+
function get_hidden_field( $field_data ) {
|
795 |
+
|
796 |
+
$value = $field_data['value'];
|
797 |
+
|
798 |
+
$attr = '';
|
799 |
+
|
800 |
+
if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
|
801 |
+
|
802 |
+
foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
|
803 |
+
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
804 |
+
}
|
805 |
+
}
|
806 |
+
|
807 |
+
$field_content = '<input type="hidden" id="' . $field_data['name'] . '" name="' . $field_data['name'] . '" value="' . $value . '" ' . $attr . '>';
|
808 |
+
|
809 |
+
return $this->get_field( $field_data, $field_content );
|
810 |
+
}
|
811 |
+
|
812 |
+
function get_area_field( $field_data ) {
|
813 |
+
|
814 |
+
$value = $field_data['value'];
|
815 |
+
|
816 |
+
$field_content = '<textarea name="' . $field_data['name'] . '" rows="10" cols="50">';
|
817 |
+
$field_content .= $value;
|
818 |
+
$field_content .= '</textarea>';
|
819 |
+
|
820 |
+
return $this->get_field( $field_data, $field_content );
|
821 |
+
}
|
822 |
+
|
823 |
+
function get_only_checkbox_field( $field_data ) {
|
824 |
+
// echo "<pre>";
|
825 |
+
// var_dump($field_data);
|
826 |
+
// echo "</pre>";
|
827 |
+
|
828 |
+
$value = $field_data['value'];
|
829 |
+
|
830 |
+
|
831 |
+
$field_content = '';
|
832 |
+
if ( isset( $field_data['before'] ) ) {
|
833 |
+
$field_content .= '<span>' . $field_data['before'] . '</span>';
|
834 |
+
}
|
835 |
+
$field_content .= '<input type="hidden" name="' . $field_data['name'] . '" value="no">';
|
836 |
+
$field_content .= '<input type="checkbox" name="' . $field_data['name'] . '" value="yes" ' . checked( 'yes', $value, false ) . '>';
|
837 |
+
|
838 |
+
if ( isset( $field_data['after'] ) ) {
|
839 |
+
$field_content .= '<span>' . $field_data['after'] . '</span>';
|
840 |
+
}
|
841 |
+
|
842 |
+
if ( isset( $field_data['after_html'] ) ) {
|
843 |
+
$field_content .= '<span>' . $field_data['after_html'] . '</span>';
|
844 |
+
}
|
845 |
+
|
846 |
+
return $field_content;
|
847 |
+
}
|
848 |
+
|
849 |
+
function get_checkbox_field( $field_data ) {
|
850 |
+
|
851 |
+
$value = $field_data['value'];
|
852 |
+
|
853 |
+
$field_content = '';
|
854 |
+
if ( isset( $field_data['before'] ) ) {
|
855 |
+
$field_content .= '<span>' . $field_data['before'] . '</span>';
|
856 |
+
}
|
857 |
+
$field_content .= '<input type="hidden" name="' . $field_data['name'] . '" value="no">';
|
858 |
+
$field_content .= '<input type="checkbox" id="'.$field_data['name'].'" name="' . $field_data['name'] . '" value="yes" ' . checked( 'yes', $value, false ) . '>';
|
859 |
+
|
860 |
+
if ( isset( $field_data['after'] ) ) {
|
861 |
+
$field_content .= '<span>' . $field_data['after'] . '</span>';
|
862 |
+
}
|
863 |
+
|
864 |
+
return $this->get_field( $field_data, $field_content );
|
865 |
+
}
|
866 |
+
|
867 |
+
function get_radio_field( $field_data ) {
|
868 |
+
|
869 |
+
$value = $field_data['value'];
|
870 |
+
$field_content = '';
|
871 |
+
|
872 |
+
if ( is_array( $field_data['options'] ) && ! empty( $field_data['options'] ) ) {
|
873 |
+
|
874 |
+
foreach ( $field_data['options'] as $data_key => $data_value ) {
|
875 |
+
|
876 |
+
$field_content .= '<div class="wcf-radio-option">';
|
877 |
+
$field_content .= '<input type="radio" name="' . $field_data['name'] . '" value="' . $data_key . '" ' . checked( $data_key, $value, false ) . '>';
|
878 |
+
$field_content .= $data_value;
|
879 |
+
$field_content .= '</div>';
|
880 |
+
}
|
881 |
+
}
|
882 |
+
|
883 |
+
return $this->get_field( $field_data, $field_content );
|
884 |
+
}
|
885 |
+
|
886 |
+
function get_font_family_field( $field_data ) {
|
887 |
+
|
888 |
+
$value = $field_data['value'];
|
889 |
+
|
890 |
+
$pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
|
891 |
+
|
892 |
+
$field_content = '<select class="wcf-field-font-family" data-for="' . $field_data['for'] . '" name="' . $field_data['name'] . '">';
|
893 |
+
|
894 |
+
$field_content .= '<option value="" ' . selected( '', $value, false ) . '>Default</option>';
|
895 |
+
|
896 |
+
$field_content .= '<optgroup label="Other System Fonts">';
|
897 |
+
foreach ( CartFlows_Font_Families::get_system_fonts() as $name => $variants ) {
|
898 |
+
$field_content .= '<option value="' . esc_attr( $name ) . '" ' . selected( $name, $value, false ) . '>' . esc_attr( $name ) . '</option>';
|
899 |
+
}
|
900 |
+
$field_content .= '</optgroup>';
|
901 |
+
$field_content .= '<optgroup label="Google">';
|
902 |
+
foreach ( CartFlows_Font_Families::get_google_fonts() as $name => $single_font ) {
|
903 |
+
$variants = wcf_get_prop( $single_font, '0' );
|
904 |
+
$category = wcf_get_prop( $single_font, '1' );
|
905 |
+
$font_value = '\'' . esc_attr( $name ) . '\', ' . esc_attr( $category );
|
906 |
+
$field_content .= '<option value="' . esc_attr( $font_value ) . '" ' . selected( $font_value, $value, false ) . '>' . esc_attr( $name ) . '</option>';
|
907 |
+
}
|
908 |
+
$field_content .= '</optgroup>';
|
909 |
+
|
910 |
+
$field_content .= '</select>';
|
911 |
+
|
912 |
+
return $this->get_field( $field_data, $field_content );
|
913 |
+
}
|
914 |
+
|
915 |
+
function get_font_weight_field( $field_data ) {
|
916 |
+
|
917 |
+
$value = $field_data['value'];
|
918 |
+
|
919 |
+
$pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
|
920 |
+
|
921 |
+
$field_content = '<select data-selected="'.esc_attr( $value ).'" class="wcf-field-font-weight" data-for="' . $field_data['for'] . '" name="' . $field_data['name'] . '">';
|
922 |
+
|
923 |
+
$field_content .= '<option value="" ' . selected( '', $value, false ) . '>Default</option>';
|
924 |
+
|
925 |
+
$field_content .= '</select>';
|
926 |
+
|
927 |
+
return $this->get_field( $field_data, $field_content );
|
928 |
+
}
|
929 |
+
|
930 |
+
function get_select_field( $field_data ) {
|
931 |
+
|
932 |
+
$value = $field_data['value'];
|
933 |
+
$pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array();
|
934 |
+
|
935 |
+
$field_content = '<select name="' . $field_data['name'] . '">';
|
936 |
+
|
937 |
+
|
938 |
+
if ( is_array( $field_data['options'] ) && ! empty( $field_data['options'] ) ) {
|
939 |
+
|
940 |
+
foreach ( $field_data['options'] as $data_key => $data_value ) {
|
941 |
+
|
942 |
+
$disabled = '';
|
943 |
+
|
944 |
+
if ( array_key_exists( $data_key, $pro_options ) ) {
|
945 |
+
$disabled = 'disabled ';
|
946 |
+
$data_value = $pro_options[ $data_key ];
|
947 |
+
}
|
948 |
+
|
949 |
+
$field_content .= '<option value="' . $data_key . '" ' . selected( $value, $data_key, false ) . ' ' . $disabled .'>' . $data_value . '</option>';
|
950 |
+
}
|
951 |
+
}
|
952 |
+
|
953 |
+
$field_content .= '</select>';
|
954 |
+
|
955 |
+
if ( isset( $field_data['after'] ) ) {
|
956 |
+
$field_content .= '<span>' . $field_data['after'] . '</span>';
|
957 |
+
}
|
958 |
+
|
959 |
+
return $this->get_field( $field_data, $field_content );
|
960 |
+
}
|
961 |
+
|
962 |
+
function get_color_picker_field( $field_data ) {
|
963 |
+
|
964 |
+
$value = $field_data['value'];
|
965 |
+
|
966 |
+
$field_content = '<input class="wcf-color-picker" type="text" name="' . $field_data['name'] . '" value="' . $value . '">';
|
967 |
+
|
968 |
+
return $this->get_field( $field_data, $field_content );
|
969 |
+
}
|
970 |
+
|
971 |
+
function get_product_selection_field( $field_data ) {
|
972 |
+
|
973 |
+
$value = $field_data['value'];
|
974 |
+
|
975 |
+
$multiple = '';
|
976 |
+
|
977 |
+
if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
|
978 |
+
$multiple = ' multiple="multiple"';
|
979 |
+
}
|
980 |
+
|
981 |
+
$allow_clear = '';
|
982 |
+
|
983 |
+
if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) {
|
984 |
+
$allow_clear = ' data-allow_clear="allow_clear"';
|
985 |
+
}
|
986 |
+
|
987 |
+
$field_content = '<select
|
988 |
+
name="' . $field_data['name'] . '[]"
|
989 |
+
class="wcf-product-search" ' . $multiple . $allow_clear . '
|
990 |
+
data-placeholder="' . __( 'Search for a product…', 'cartflows' ) . '"
|
991 |
+
data-action="woocommerce_json_search_products_and_variations">';
|
992 |
+
|
993 |
+
if ( is_array( $value ) && ! empty( $value ) ) {
|
994 |
+
|
995 |
+
foreach ( $value as $data_key => $product_id ) {
|
996 |
+
|
997 |
+
$product = wc_get_product( $product_id );
|
998 |
+
|
999 |
+
// posts.
|
1000 |
+
if ( ! empty( $product ) ) {
|
1001 |
+
$post_title = $product->get_name() . ' (#' . $product_id . ')';
|
1002 |
+
|
1003 |
+
$field_content .= '<option value="' . $product_id . '" selected="selected" >' . $post_title . '</option>';
|
1004 |
+
}
|
1005 |
+
}
|
1006 |
+
}
|
1007 |
+
$field_content .= '</select>';
|
1008 |
+
|
1009 |
+
return $this->get_field( $field_data, $field_content );
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
function get_coupon_selection_field( $field_data ) {
|
1013 |
+
|
1014 |
+
$value = $field_data['value'];
|
1015 |
+
|
1016 |
+
$multiple = '';
|
1017 |
+
|
1018 |
+
if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
|
1019 |
+
$multiple = ' multiple="multiple"';
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
$allow_clear = '';
|
1023 |
+
|
1024 |
+
if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) {
|
1025 |
+
$allow_clear = ' data-allow_clear="allow_clear"';
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
$field_content = '<select
|
1029 |
+
name="' . $field_data['name'] . '[]"
|
1030 |
+
class="wc-coupon-search wcf-coupon-search" ' . $multiple . $allow_clear . '
|
1031 |
+
data-placeholder="' . __( 'Search for a coupon…', 'cartflows' ) . '"
|
1032 |
+
data-action="wcf_json_search_coupons">';
|
1033 |
+
|
1034 |
+
if ( is_array( $value ) && ! empty( $value ) ) {
|
1035 |
+
|
1036 |
+
$all_discount_types = wc_get_coupon_types();
|
1037 |
+
|
1038 |
+
foreach ( $value as $coupon_title ) {
|
1039 |
+
|
1040 |
+
$coupon = new WC_Coupon( $coupon_title );
|
1041 |
+
|
1042 |
+
$discount_type = $coupon->get_discount_type();
|
1043 |
+
|
1044 |
+
if ( isset( $discount_type ) && $discount_type ) {
|
1045 |
+
$discount_type = ' ( Type: ' . $all_discount_types[ $discount_type ] . ' )';
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
$field_content .= '<option value="' . $coupon_title . '" selected="selected">' . $coupon_title . $discount_type . '</option>';
|
1049 |
+
}
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
$field_content .= '</select>';
|
1053 |
+
|
1054 |
+
return $this->get_field( $field_data, $field_content );
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
function get_page_selection_field( $field_data ) {
|
1058 |
+
|
1059 |
+
$value = $field_data['value'];
|
1060 |
+
|
1061 |
+
$multiple = '';
|
1062 |
+
|
1063 |
+
if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) {
|
1064 |
+
$multiple = 'multiple="multiple"';
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
$field_content = '<select
|
1068 |
+
name="' . $field_data['name'] . '[]"
|
1069 |
+
class="wcf-search-pages" ' . $multiple . '"
|
1070 |
+
data-action="wcf_json_search_pages">';
|
1071 |
+
|
1072 |
+
if ( is_array( $value ) && ! empty( $value ) ) {
|
1073 |
+
|
1074 |
+
foreach ( $value as $data_key => $data_value ) {
|
1075 |
+
|
1076 |
+
$field_content .= '<option value="' . $data_value . '">' . get_the_title( $data_value ) . '</option>';
|
1077 |
+
}
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
$field_content .= '</select>';
|
1081 |
+
|
1082 |
+
return $this->get_field( $field_data, $field_content );
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
function get_section( $field_data ) {
|
1086 |
+
$field_html = '<div class="wcf-field-row wcf-field-section">';
|
1087 |
+
$field_html .= '<div class="wcf-field-section-heading" colspan="2">';
|
1088 |
+
$field_html .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
|
1089 |
+
|
1090 |
+
if ( isset( $field_data['help'] ) ) {
|
1091 |
+
$field_html .= '<i class="wcf-field-heading-help dashicons dashicons-editor-help" title="' . esc_attr( $field_data['help'] ) . '"></i>';
|
1092 |
+
}
|
1093 |
+
$field_html .= '</div>';
|
1094 |
+
$field_html .= '</div>';
|
1095 |
+
return $field_html;
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
function get_description_field( $field_data ) {
|
1099 |
+
|
1100 |
+
$field_html = '<div class="wcf-field-row wcf-field-desc ' . $field_data['name'] . '">';
|
1101 |
+
$field_html .= '<div class="wcf-field-desc-content">';
|
1102 |
+
$field_html .= $field_data['content'];
|
1103 |
+
$field_html .= '</div>';
|
1104 |
+
$field_html .= '</div>';
|
1105 |
+
|
1106 |
+
return $field_html;
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
function get_checkout_field_repeater( $field_data ) {
|
1110 |
+
|
1111 |
+
$value = array();
|
1112 |
+
|
1113 |
+
$value[0] = array(
|
1114 |
+
'add_to' => '',
|
1115 |
+
'type' => '',
|
1116 |
+
'label' => '',
|
1117 |
+
'name' => '',
|
1118 |
+
);
|
1119 |
+
|
1120 |
+
$field_content = '';
|
1121 |
+
|
1122 |
+
$field_content .= '<div class="wcf-field-row">';
|
1123 |
+
// $field_content .= '<div class="wcf-field-row-heading">';
|
1124 |
+
// $field_content .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
|
1125 |
+
// $field_content .= '</div>';
|
1126 |
+
$field_content .= '<div class="wcf-field-row-content">';
|
1127 |
+
$field_content .= '<div class="wcf-cpf-wrap">';
|
1128 |
+
|
1129 |
+
foreach ( $value as $p_key => $p_data ) {
|
1130 |
+
$field_content .= '<div class="wcf-cpf-row" data-key="' . $p_key . '">';
|
1131 |
+
$field_content .= '<div class="wcf-cpf-row-header">';
|
1132 |
+
$field_content .= '<span class="wcf-cpf-row-title">Add New Custom Field</span>';
|
1133 |
+
$field_content .= '</div>';
|
1134 |
+
|
1135 |
+
$field_content .= '<div class="wcf-cpf-row-standard-fields">';
|
1136 |
+
|
1137 |
+
/* Add To */
|
1138 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-add_to">';
|
1139 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Add to</span>';
|
1140 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1141 |
+
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][add_to]" class="wcf-cpf-add_to">';
|
1142 |
+
$field_content .= '<option value="billing">Billing</option>';
|
1143 |
+
$field_content .= '<option value="shipping">Shipping</option>';
|
1144 |
+
$field_content .= '</select>';
|
1145 |
+
$field_content .= '</span>';
|
1146 |
+
$field_content .= '</div>';
|
1147 |
+
|
1148 |
+
/* Type */
|
1149 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-type">';
|
1150 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Type</span>';
|
1151 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1152 |
+
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][type]" class="wcf-cpf-type">';
|
1153 |
+
$field_content .= '<option value="text">Text</option>';
|
1154 |
+
$field_content .= '<option value="textarea">Textarea</option>';
|
1155 |
+
$field_content .= '<option value="select">Select</option>';
|
1156 |
+
$field_content .= '<option value="checkbox">Checkbox</option>';
|
1157 |
+
$field_content .= '</select>';
|
1158 |
+
$field_content .= '</span>';
|
1159 |
+
$field_content .= '</div>';
|
1160 |
+
|
1161 |
+
/* Textarea */
|
1162 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-options">';
|
1163 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Options *</span>';
|
1164 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1165 |
+
$field_content .= '<textarea value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-options" placeholder="Enter your options separated by comma."></textarea>';
|
1166 |
+
$field_content .= '</span>';
|
1167 |
+
$field_content .= '</div>';
|
1168 |
+
|
1169 |
+
/* Label */
|
1170 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-label">';
|
1171 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Label *</span>';
|
1172 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1173 |
+
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-label">';
|
1174 |
+
$field_content .= '</span>';
|
1175 |
+
$field_content .= '</div>';
|
1176 |
+
|
1177 |
+
/* Name */
|
1178 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-name">';
|
1179 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Name *</span>';
|
1180 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1181 |
+
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][name]" class="wcf-cpf-name">';
|
1182 |
+
$field_content .= '</span>';
|
1183 |
+
$field_content .= '</div>';
|
1184 |
+
|
1185 |
+
$field_content .= '</div>';
|
1186 |
+
$field_content .= '</div>';
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
/* Add New Custom Field */
|
1190 |
+
$field_content .= '<div class="wcf-cpf-add-row">';
|
1191 |
+
$field_content .= '<div class="wcf-cpf-add-wrap">';
|
1192 |
+
$field_content .= '<button class="button button-secondary wcf-cpf-add" data-name="wcf-checkout-custom-fields">Add New Field</button>';
|
1193 |
+
$field_content .= '</div>';
|
1194 |
+
$field_content .= '</div>';
|
1195 |
+
/* End Add new custom field */
|
1196 |
+
|
1197 |
+
$field_content .= '</div>';
|
1198 |
+
$field_content .= '</div>';
|
1199 |
+
$field_content .= '</div>';
|
1200 |
+
|
1201 |
+
return $field_content;
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
function get_pro_checkout_field_repeater( $field_data ) {
|
1205 |
+
|
1206 |
+
$value = array();
|
1207 |
+
|
1208 |
+
$value[0] = array(
|
1209 |
+
'add_to' => '',
|
1210 |
+
'type' => '',
|
1211 |
+
'label' => '',
|
1212 |
+
'name' => '',
|
1213 |
+
);
|
1214 |
+
|
1215 |
+
$field_content = '';
|
1216 |
+
|
1217 |
+
$field_content .= '<div class="wcf-field-row">';
|
1218 |
+
// $field_content .= '<div class="wcf-field-row-heading">';
|
1219 |
+
// $field_content .= '<label>' . esc_html( $field_data['label'] ) . '</label>';
|
1220 |
+
// $field_content .= '</div>';
|
1221 |
+
$field_content .= '<div class="wcf-field-row-content">';
|
1222 |
+
$field_content .= '<div class="wcf-cpf-wrap">';
|
1223 |
+
|
1224 |
+
foreach ( $value as $p_key => $p_data ) {
|
1225 |
+
$field_content .= '<div class="wcf-cpf-row" data-key="' . $p_key . '">';
|
1226 |
+
$field_content .= '<div class="wcf-cpf-row-header">';
|
1227 |
+
$field_content .= '<span class="wcf-cpf-row-title">Add New Custom Field</span>';
|
1228 |
+
$field_content .= '</div>';
|
1229 |
+
|
1230 |
+
$field_content .= '<div class="wcf-cpf-row-standard-fields">';
|
1231 |
+
|
1232 |
+
/* Add To */
|
1233 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-add_to">';
|
1234 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Add to</span>';
|
1235 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1236 |
+
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][add_to]" class="wcf-cpf-add_to">';
|
1237 |
+
$field_content .= '<option value="billing">Billing</option>';
|
1238 |
+
$field_content .= '<option value="shipping">Shipping</option>';
|
1239 |
+
$field_content .= '</select>';
|
1240 |
+
$field_content .= '</span>';
|
1241 |
+
$field_content .= '</div>';
|
1242 |
+
|
1243 |
+
/* Type */
|
1244 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-type">';
|
1245 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Type</span>';
|
1246 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1247 |
+
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][type]" class="wcf-cpf-type">';
|
1248 |
+
$field_content .= '<option value="text">Text</option>';
|
1249 |
+
$field_content .= '<option value="textarea">Textarea</option>';
|
1250 |
+
$field_content .= '<option value="select">Select</option>';
|
1251 |
+
$field_content .= '<option value="checkbox">Checkbox</option>';
|
1252 |
+
$field_content .= '<option value="hidden">Hidden</option>';
|
1253 |
+
$field_content .= '</select>';
|
1254 |
+
$field_content .= '</span>';
|
1255 |
+
$field_content .= '</div>';
|
1256 |
+
|
1257 |
+
/* Label */
|
1258 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-label">';
|
1259 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Label <i>*</i></span>';
|
1260 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1261 |
+
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-label">';
|
1262 |
+
$field_content .= '<span id="wcf-cpf-label-error-msg"></span>';
|
1263 |
+
$field_content .= '</span>';
|
1264 |
+
$field_content .= '</div>';
|
1265 |
+
|
1266 |
+
/* Default */
|
1267 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-default">';
|
1268 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Default</span>';
|
1269 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1270 |
+
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][default]" class="wcf-cpf-default">';
|
1271 |
+
$field_content .= '<span id="wcf-cpf-default-error-msg"></span>';
|
1272 |
+
$field_content .= '</span>';
|
1273 |
+
$field_content .= '</div>';
|
1274 |
+
|
1275 |
+
/* Placeholder */
|
1276 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-placeholder">';
|
1277 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Placeholder</span>';
|
1278 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1279 |
+
$field_content .= '<input type="text" value="" name="wcf-checkout-custom-fields[' . $p_key . '][placeholder]" class="wcf-cpf-placeholder">';
|
1280 |
+
$field_content .= '<span id="wcf-cpf-placeholder-error-msg"></span>';
|
1281 |
+
$field_content .= '</span>';
|
1282 |
+
$field_content .= '</div>';
|
1283 |
+
|
1284 |
+
/* Options */
|
1285 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-options">';
|
1286 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Options <i>*</i></span>';
|
1287 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1288 |
+
$field_content .= '<textarea value="" name="wcf-checkout-custom-fields[' . $p_key . '][label]" class="wcf-cpf-options" placeholder="Enter your options separated by comma."></textarea>';
|
1289 |
+
$field_content .= '</span>';
|
1290 |
+
$field_content .= '</div>';
|
1291 |
+
|
1292 |
+
/* Width */
|
1293 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-width">';
|
1294 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Width</span>';
|
1295 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1296 |
+
$field_content .= '<select name="wcf-checkout-custom-fields[' . $p_key . '][width]" class="wcf-cpf-width">';
|
1297 |
+
$field_content .= '<option value="33">33%</option>';
|
1298 |
+
$field_content .= '<option value="50">50%</option>';
|
1299 |
+
$field_content .= '<option value="100" selected>100%</option>';
|
1300 |
+
$field_content .= '</select>';
|
1301 |
+
$field_content .= '</span>';
|
1302 |
+
$field_content .= '</div>';
|
1303 |
+
|
1304 |
+
/* Required */
|
1305 |
+
$field_content .= '<div class="wcf-cpf-fields wcf-cpf-required">';
|
1306 |
+
$field_content .= '<span class="wcf-cpf-row-setting-label">Required</span>';
|
1307 |
+
$field_content .= '<span class="wcf-cpf-row-setting-field">';
|
1308 |
+
$field_content .= '<input type="hidden" value="no" name="wcf-checkout-custom-fields[' . $p_key . '][required]" class="wcf-cpf-required">';
|
1309 |
+
$field_content .= '<input type="checkbox" value="yes" name="wcf-checkout-custom-fields[' . $p_key . '][required]" class="wcf-cpf-required">';
|
1310 |
+
$field_content .= '<span id="wcf-cpf-required-error-msg"></span>';
|
1311 |
+
$field_content .= '</span>';
|
1312 |
+
$field_content .= '</div>';
|
1313 |
+
|
1314 |
+
$field_content .= '</div>';
|
1315 |
+
$field_content .= '</div>';
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
/* Add New Custom Field */
|
1319 |
+
$field_content .= '<div class="wcf-cpf-add-row">';
|
1320 |
+
$field_content .= '<div class="wcf-cpf-add-wrap">';
|
1321 |
+
$field_content .= '<button class="button button-secondary wcf-pro-cpf-add" data-name="wcf-checkout-custom-fields">Add New Field</button>';
|
1322 |
+
$field_content .= '</div>';
|
1323 |
+
$field_content .= '</div>';
|
1324 |
+
/* End Add new custom field */
|
1325 |
+
|
1326 |
+
$field_content .= '</div>';
|
1327 |
+
$field_content .= '</div>';
|
1328 |
+
$field_content .= '</div>';
|
1329 |
+
|
1330 |
+
return $field_content;
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
function get_product_selection_repeater( $field_data ) {
|
1334 |
+
|
1335 |
+
$value = $field_data['value'];
|
1336 |
+
|
1337 |
+
if ( ! is_array( $value ) ) {
|
1338 |
+
|
1339 |
+
$value[0] = array(
|
1340 |
+
'product' => '',
|
1341 |
+
);
|
1342 |
+
} else {
|
1343 |
+
|
1344 |
+
if ( ! isset( $value[0] ) ) {
|
1345 |
+
|
1346 |
+
$value[0] = array(
|
1347 |
+
'product' => '',
|
1348 |
+
);
|
1349 |
+
}
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
$field_html = '';
|
1353 |
+
|
1354 |
+
$field_html .= '<script type="text/html" id="tmpl-wcf-product-repeater">';
|
1355 |
+
$field_html .= $this->generate_product_repeater_html( '{{id}}' );
|
1356 |
+
$field_html .= '</script>';
|
1357 |
+
|
1358 |
+
$field_html .= '<div class="wcf-field-row">';
|
1359 |
+
$field_html .= '<div class="wcf-field-row-content">';
|
1360 |
+
$field_html .= '<div class="wcf-repeatables-wrap">';
|
1361 |
+
|
1362 |
+
if ( is_array( $value ) ) {
|
1363 |
+
|
1364 |
+
foreach ( $value as $p_key => $p_data ) {
|
1365 |
+
|
1366 |
+
$selected_options = '';
|
1367 |
+
|
1368 |
+
if ( isset( $p_data['product'] ) ) {
|
1369 |
+
|
1370 |
+
$product = wc_get_product( $p_data['product'] );
|
1371 |
+
|
1372 |
+
// posts.
|
1373 |
+
if ( ! empty( $product ) ) {
|
1374 |
+
$post_title = $product->get_name() . ' (#' . $p_data['product'] . ')';
|
1375 |
+
|
1376 |
+
$selected_options = '<option value="' . $p_data['product'] . '" selected="selected" >' . $post_title . '</option>';
|
1377 |
+
}
|
1378 |
+
}
|
1379 |
+
|
1380 |
+
$field_html .= $this->generate_product_repeater_html( $p_key, $selected_options );
|
1381 |
+
}
|
1382 |
+
}
|
1383 |
+
|
1384 |
+
$field_html .= '<div class="wcf-add-repeatable-row">';
|
1385 |
+
$field_html .= '<div class="submit wcf-add-repeatable-wrap">';
|
1386 |
+
$field_html .= '<button class="button-primary wcf-add-repeatable" data-name="wcf-checkout-products">Add New Product</button>';
|
1387 |
+
$field_html .= '</div>';
|
1388 |
+
$field_html .= '</div>';
|
1389 |
+
$field_html .= '</div>';
|
1390 |
+
$field_html .= '</div>';
|
1391 |
+
$field_html .= '</div>';
|
1392 |
+
|
1393 |
+
return $field_html;
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
function generate_product_repeater_html( $id, $options = '' ) {
|
1397 |
+
|
1398 |
+
$field_html = '<div class="wcf-repeatable-row" data-key="' . $id . '">';
|
1399 |
+
|
1400 |
+
$field_html .= '<div class="wcf-repeatable-row-standard-fields">';
|
1401 |
+
|
1402 |
+
/* Product Name */
|
1403 |
+
$field_html .= '<div class="wcf-repeatable-fields wcf-sel-product">';
|
1404 |
+
$field_html .= '<span class="wcf-repeatable-row-setting-field">';
|
1405 |
+
$field_html .= '<select
|
1406 |
+
name="wcf-checkout-products[' . $id . '][product]"
|
1407 |
+
class="wcf-product-search"
|
1408 |
+
data-allow_clear="allow_clear"
|
1409 |
+
data-placeholder="' . __( 'Search for a product…', 'cartflows' ) . '"
|
1410 |
+
data-action="woocommerce_json_search_products_and_variations">';
|
1411 |
+
$field_html .= $options;
|
1412 |
+
$field_html .= '</select>';
|
1413 |
+
$field_html .= '</span>';
|
1414 |
+
$field_html .= '<span class="wcf-repeatable-row-actions">';
|
1415 |
+
$field_html .= '<a class="wcf-remove-row wcf-repeatable-remove button" data-type="product">';
|
1416 |
+
$field_html .= '<span class="dashicons dashicons-trash"></span>';
|
1417 |
+
$field_html .= '<span class="wcf-repeatable-remove-button">'. __( 'Remove', 'cartflows' ).'</span>';
|
1418 |
+
$field_html .= '</a>';
|
1419 |
+
$field_html .= '</span>';
|
1420 |
+
$field_html .= '</div>';
|
1421 |
+
$field_html .= '</div>';
|
1422 |
+
$field_html .= '</div>';
|
1423 |
+
|
1424 |
+
return $field_html;
|
1425 |
+
}
|
1426 |
+
|
1427 |
+
function get_image_field( $field_data ) {
|
1428 |
+
|
1429 |
+
$value = $field_data['value'];
|
1430 |
+
|
1431 |
+
$attr = '';
|
1432 |
+
|
1433 |
+
if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) {
|
1434 |
+
|
1435 |
+
foreach ( $field_data['attr'] as $attr_key => $attr_value ) {
|
1436 |
+
$attr .= ' ' . $attr_key . '="' . $attr_value . '"';
|
1437 |
+
}
|
1438 |
+
}
|
1439 |
+
|
1440 |
+
$display_preview_box = ( isset( $value ) && '' != $value ) ? 'display:block;' : 'display:none';
|
1441 |
+
|
1442 |
+
$field_content = '<div id="wcf-image-preview" style="'.$display_preview_box.'">';
|
1443 |
+
if( isset( $value ) ){
|
1444 |
+
$field_content .= '<img src="'. $value .'" class="saved-image" name="'. $field_data['name'] .'" width="150">';
|
1445 |
+
}
|
1446 |
+
$field_content .= '</div>';
|
1447 |
+
// $field_content .= '<input type="hidden" id="wcf-image-id" class="wcf-image-id" name="wcf-image-id[image-id]" value="">';
|
1448 |
+
$field_content .= '<input type="hidden" id="wcf-image-value" class="wcf-image" name="' . $field_data['name'] . '" value="'.$value.'">';
|
1449 |
+
|
1450 |
+
$field_content .= '<button type="button" ' . $attr . ' class="wcf-select-image button-secondary">Select Image</button>';
|
1451 |
+
|
1452 |
+
$display_remove_button = ( isset( $value ) && '' != $value ) ? 'display:inline-block; margin-left: 5px;' : 'display:none';
|
1453 |
+
|
1454 |
+
$field_content .= '<button type="button" class="wcf-remove-image button-secondary" style="'.$display_remove_button.'">Remove Image</button>';
|
1455 |
+
|
1456 |
+
return $this->get_field( $field_data, $field_content );
|
1457 |
+
}
|
1458 |
+
|
1459 |
+
/**
|
1460 |
+
* Localize variables in admin
|
1461 |
+
*
|
1462 |
+
* @param array $vars variables.
|
1463 |
+
*/
|
1464 |
+
function localize_vars( $vars ) {
|
1465 |
+
|
1466 |
+
$ajax_actions = array(
|
1467 |
+
'wcf_add_checkout_custom_field',
|
1468 |
+
'wcf_pro_add_checkout_custom_field',
|
1469 |
+
'wcf_delete_checkout_custom_field',
|
1470 |
+
'wcf_json_search_pages',
|
1471 |
+
'wcf_json_search_coupons'
|
1472 |
+
);
|
1473 |
+
|
1474 |
+
foreach ( $ajax_actions as $action ) {
|
1475 |
+
|
1476 |
+
$vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
|
1477 |
+
}
|
1478 |
+
|
1479 |
+
return $vars;
|
1480 |
+
}
|
1481 |
+
}
|
1482 |
+
// @codingStandardsIgnoreEnd
|
classes/class-cartflows-thrive-compatibility.php
CHANGED
@@ -1,77 +1,77 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Thrive Visual Editor Compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class for Thrive Visual Editor Compatibility
|
10 |
-
*/
|
11 |
-
class Cartflows_Thrive_Compatibility {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Member Variable
|
15 |
-
*
|
16 |
-
* @var instance
|
17 |
-
*/
|
18 |
-
private static $instance;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Initiator
|
22 |
-
*/
|
23 |
-
public static function get_instance() {
|
24 |
-
if ( ! isset( self::$instance ) ) {
|
25 |
-
self::$instance = new self;
|
26 |
-
}
|
27 |
-
return self::$instance;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Constructor
|
32 |
-
*/
|
33 |
-
public function __construct() {
|
34 |
-
|
35 |
-
// Add CartFlows post type in the thrive page editor.
|
36 |
-
add_filter( 'tve_post_type_can_use_landing_page', array( $this, 'send_post_type_to_thrive' ) );
|
37 |
-
|
38 |
-
// add_filter( 'tve_landing_page_post_types', array( $this, 'send_post_type_to_thrive' ) );.
|
39 |
-
add_filter( 'tcb_can_use_landing_pages', array( $this, 'display_change_template_option' ) );
|
40 |
-
|
41 |
-
add_filter( 'tcb_has_templates_tab', array( $this, 'display_change_template_option' ) );
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Return step post type for Thrive Architect.
|
46 |
-
*
|
47 |
-
* @since 1.0.0
|
48 |
-
* @param array $post_type_pt the current step post type.
|
49 |
-
* @return array $post_type_pt current step post type.
|
50 |
-
*/
|
51 |
-
function send_post_type_to_thrive( $post_type_pt ) {
|
52 |
-
|
53 |
-
$post_type_pt[] = CARTFLOWS_STEP_POST_TYPE;
|
54 |
-
|
55 |
-
return $post_type_pt;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Return true/false to show change template option.
|
60 |
-
*
|
61 |
-
* @since 1.0.0
|
62 |
-
* @param array $bool true/false.
|
63 |
-
* @return array $bool true/false.
|
64 |
-
*/
|
65 |
-
function display_change_template_option( $bool ) {
|
66 |
-
|
67 |
-
if ( wcf()->utils->is_step_post_type() ) {
|
68 |
-
$bool = true;
|
69 |
-
}
|
70 |
-
return $bool;
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Kicking this off by calling 'get_instance()' method
|
76 |
-
*/
|
77 |
-
Cartflows_Thrive_Compatibility::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Thrive Visual Editor Compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class for Thrive Visual Editor Compatibility
|
10 |
+
*/
|
11 |
+
class Cartflows_Thrive_Compatibility {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Member Variable
|
15 |
+
*
|
16 |
+
* @var instance
|
17 |
+
*/
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Initiator
|
22 |
+
*/
|
23 |
+
public static function get_instance() {
|
24 |
+
if ( ! isset( self::$instance ) ) {
|
25 |
+
self::$instance = new self;
|
26 |
+
}
|
27 |
+
return self::$instance;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Constructor
|
32 |
+
*/
|
33 |
+
public function __construct() {
|
34 |
+
|
35 |
+
// Add CartFlows post type in the thrive page editor.
|
36 |
+
add_filter( 'tve_post_type_can_use_landing_page', array( $this, 'send_post_type_to_thrive' ) );
|
37 |
+
|
38 |
+
// add_filter( 'tve_landing_page_post_types', array( $this, 'send_post_type_to_thrive' ) );.
|
39 |
+
add_filter( 'tcb_can_use_landing_pages', array( $this, 'display_change_template_option' ) );
|
40 |
+
|
41 |
+
add_filter( 'tcb_has_templates_tab', array( $this, 'display_change_template_option' ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Return step post type for Thrive Architect.
|
46 |
+
*
|
47 |
+
* @since 1.0.0
|
48 |
+
* @param array $post_type_pt the current step post type.
|
49 |
+
* @return array $post_type_pt current step post type.
|
50 |
+
*/
|
51 |
+
function send_post_type_to_thrive( $post_type_pt ) {
|
52 |
+
|
53 |
+
$post_type_pt[] = CARTFLOWS_STEP_POST_TYPE;
|
54 |
+
|
55 |
+
return $post_type_pt;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Return true/false to show change template option.
|
60 |
+
*
|
61 |
+
* @since 1.0.0
|
62 |
+
* @param array $bool true/false.
|
63 |
+
* @return array $bool true/false.
|
64 |
+
*/
|
65 |
+
function display_change_template_option( $bool ) {
|
66 |
+
|
67 |
+
if ( wcf()->utils->is_step_post_type() ) {
|
68 |
+
$bool = true;
|
69 |
+
}
|
70 |
+
return $bool;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Kicking this off by calling 'get_instance()' method
|
76 |
+
*/
|
77 |
+
Cartflows_Thrive_Compatibility::get_instance();
|
includes/admin/cartflows-general.php
CHANGED
@@ -1,142 +1,143 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* General settings
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
$settings = Cartflows_Helper::get_common_settings();
|
9 |
-
|
10 |
-
?>
|
11 |
-
|
12 |
-
<form method="post" class="wrap wcf-clear" action="" >
|
13 |
-
<div class="wrap wcf-addon-wrap wcf-clear wcf-container">
|
14 |
-
<input type="hidden" name="action" value="wcf_save_common_settings">
|
15 |
-
<h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
|
16 |
-
|
17 |
-
<div id="poststuff">
|
18 |
-
<div id="post-body" class="columns-2">
|
19 |
-
<div id="post-body-content">
|
20 |
-
<div class="postbox introduction">
|
21 |
-
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
22 |
-
<span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
|
23 |
-
</h2>
|
24 |
-
<div class="inside">
|
25 |
-
<div class="iframe-wrap">
|
26 |
-
<iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
27 |
-
</div>
|
28 |
-
<p>
|
29 |
-
<?php
|
30 |
-
esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
|
31 |
-
?>
|
32 |
-
</p>
|
33 |
-
</div>
|
34 |
-
</div>
|
35 |
-
|
36 |
-
<div class="general-settings-form postbox">
|
37 |
-
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
38 |
-
<span><?php _e( 'General Settings', 'cartflows' ); ?></span>
|
39 |
-
</h2>
|
40 |
-
<div class="inside">
|
41 |
-
<div class="form-wrap">
|
42 |
-
<?php
|
43 |
-
|
44 |
-
do_action( 'cartflows_before_settings_fields', $settings );
|
45 |
-
|
46 |
-
echo Cartflows_Admin_Fields::checkobox_field(
|
47 |
-
array(
|
48 |
-
'id' => 'wcf_disallow_indexing',
|
49 |
-
'name' => '_cartflows_common[disallow_indexing]',
|
50 |
-
'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
|
51 |
-
'value' => $settings['disallow_indexing'],
|
52 |
-
)
|
53 |
-
);
|
54 |
-
echo Cartflows_Admin_Fields::flow_checkout_selection_field(
|
55 |
-
array(
|
56 |
-
'id' => 'wcf_global_checkout',
|
57 |
-
'name' => '_cartflows_common[global_checkout]',
|
58 |
-
'title' => __( 'Global Checkout', 'cartflows' ),
|
59 |
-
'value' => $settings['global_checkout'],
|
60 |
-
)
|
61 |
-
);
|
62 |
-
|
63 |
-
echo Cartflows_Admin_Fields::select_field(
|
64 |
-
array(
|
65 |
-
'id' => 'wcf_default_page_builder',
|
66 |
-
'name' => '_cartflows_common[default_page_builder]',
|
67 |
-
'title' => __( 'Show Templates designed with', 'cartflows' ),
|
68 |
-
'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
|
69 |
-
'value' => $settings['default_page_builder'],
|
70 |
-
'options' => array(
|
71 |
-
'elementor' => __( 'Elementor', 'cartflows' ),
|
72 |
-
'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
|
73 |
-
'
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
<?php
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
<span
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
<span
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
<span
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
</div>
|
142 |
-
</
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* General settings
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
$settings = Cartflows_Helper::get_common_settings();
|
9 |
+
|
10 |
+
?>
|
11 |
+
|
12 |
+
<form method="post" class="wrap wcf-clear" action="" >
|
13 |
+
<div class="wrap wcf-addon-wrap wcf-clear wcf-container">
|
14 |
+
<input type="hidden" name="action" value="wcf_save_common_settings">
|
15 |
+
<h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
|
16 |
+
|
17 |
+
<div id="poststuff">
|
18 |
+
<div id="post-body" class="columns-2">
|
19 |
+
<div id="post-body-content">
|
20 |
+
<div class="postbox introduction">
|
21 |
+
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
22 |
+
<span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
|
23 |
+
</h2>
|
24 |
+
<div class="inside">
|
25 |
+
<div class="iframe-wrap">
|
26 |
+
<iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
27 |
+
</div>
|
28 |
+
<p>
|
29 |
+
<?php
|
30 |
+
esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
|
31 |
+
?>
|
32 |
+
</p>
|
33 |
+
</div>
|
34 |
+
</div>
|
35 |
+
|
36 |
+
<div class="general-settings-form postbox">
|
37 |
+
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
38 |
+
<span><?php _e( 'General Settings', 'cartflows' ); ?></span>
|
39 |
+
</h2>
|
40 |
+
<div class="inside">
|
41 |
+
<div class="form-wrap">
|
42 |
+
<?php
|
43 |
+
|
44 |
+
do_action( 'cartflows_before_settings_fields', $settings );
|
45 |
+
|
46 |
+
echo Cartflows_Admin_Fields::checkobox_field(
|
47 |
+
array(
|
48 |
+
'id' => 'wcf_disallow_indexing',
|
49 |
+
'name' => '_cartflows_common[disallow_indexing]',
|
50 |
+
'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
|
51 |
+
'value' => $settings['disallow_indexing'],
|
52 |
+
)
|
53 |
+
);
|
54 |
+
echo Cartflows_Admin_Fields::flow_checkout_selection_field(
|
55 |
+
array(
|
56 |
+
'id' => 'wcf_global_checkout',
|
57 |
+
'name' => '_cartflows_common[global_checkout]',
|
58 |
+
'title' => __( 'Global Checkout', 'cartflows' ),
|
59 |
+
'value' => $settings['global_checkout'],
|
60 |
+
)
|
61 |
+
);
|
62 |
+
|
63 |
+
echo Cartflows_Admin_Fields::select_field(
|
64 |
+
array(
|
65 |
+
'id' => 'wcf_default_page_builder',
|
66 |
+
'name' => '_cartflows_common[default_page_builder]',
|
67 |
+
'title' => __( 'Show Templates designed with', 'cartflows' ),
|
68 |
+
'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
|
69 |
+
'value' => $settings['default_page_builder'],
|
70 |
+
'options' => array(
|
71 |
+
'elementor' => __( 'Elementor', 'cartflows' ),
|
72 |
+
'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
|
73 |
+
'divi' => __( 'Divi', 'cartflows' ),
|
74 |
+
'other' => __( 'Other', 'cartflows' ),
|
75 |
+
),
|
76 |
+
)
|
77 |
+
);
|
78 |
+
|
79 |
+
do_action( 'cartflows_after_settings_fields', $settings );
|
80 |
+
|
81 |
+
?>
|
82 |
+
</div>
|
83 |
+
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
|
84 |
+
<?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
|
85 |
+
</div>
|
86 |
+
</div>
|
87 |
+
</div>
|
88 |
+
<div class="postbox-container" id="postbox-container-1">
|
89 |
+
<div id="side-sortables">
|
90 |
+
|
91 |
+
<div class="postbox">
|
92 |
+
<h2 class="hndle">
|
93 |
+
<span class="dashicons dashicons-book"></span>
|
94 |
+
<span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
|
95 |
+
</h2>
|
96 |
+
<div class="inside">
|
97 |
+
<p>
|
98 |
+
<?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
|
99 |
+
</p>
|
100 |
+
<p>
|
101 |
+
<a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
|
102 |
+
</p>
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
+
|
106 |
+
<div class="postbox">
|
107 |
+
<h2 class="hndle">
|
108 |
+
<span class="dashicons dashicons-groups"></span>
|
109 |
+
<span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
|
110 |
+
</h2>
|
111 |
+
<div class="inside">
|
112 |
+
<p>
|
113 |
+
<?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
|
114 |
+
</p>
|
115 |
+
<p>
|
116 |
+
<a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
|
117 |
+
</p>
|
118 |
+
</div>
|
119 |
+
</div>
|
120 |
+
|
121 |
+
<div class="postbox">
|
122 |
+
<h2 class="hndle">
|
123 |
+
<span class="dashicons dashicons-sos"></span>
|
124 |
+
<span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
|
125 |
+
</h2>
|
126 |
+
<div class="inside">
|
127 |
+
<p>
|
128 |
+
<?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
|
129 |
+
</p>
|
130 |
+
<p>
|
131 |
+
<a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
|
132 |
+
</p>
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
|
136 |
+
</div>
|
137 |
+
</div>
|
138 |
+
</div>
|
139 |
+
<!-- /post-body -->
|
140 |
+
<br class="clear">
|
141 |
+
</div>
|
142 |
+
</div>
|
143 |
+
</form>
|
languages/cartflows.pot
CHANGED
@@ -1,1347 +1,1358 @@
|
|
1 |
-
# Copyright (C) 2019 CartFlows Inc
|
2 |
-
# This file is distributed under the same license as the CartFlows package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: CartFlows 1.1.
|
6 |
-
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
|
7 |
-
"POT-Creation-Date: 2019-02-
|
8 |
-
"MIME-Version: 1.0\n"
|
9 |
-
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
-
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
|
12 |
-
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
-
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
-
"Language: en\n"
|
15 |
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
16 |
-
"X-Poedit-Country: United States\n"
|
17 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
18 |
-
"X-Poedit-KeywordsList: "
|
19 |
-
"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
|
20 |
-
"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
|
21 |
-
"X-Poedit-Basepath: ../\n"
|
22 |
-
"X-Poedit-SearchPath-0: .\n"
|
23 |
-
"X-Poedit-Bookmarks: \n"
|
24 |
-
"X-Textdomain-Support: yes\n"
|
25 |
-
"X-Generator: grunt-wp-i18n1.0.2\n"
|
26 |
-
|
27 |
-
#: classes/batch-process/class-cartflows-importer-elementor.php:44
|
28 |
-
msgid "Invalid content."
|
29 |
-
msgstr ""
|
30 |
-
|
31 |
-
#: classes/batch-process/class-cartflows-importer-elementor.php:52
|
32 |
-
msgid "Invalid content. Expected an array."
|
33 |
-
msgstr ""
|
34 |
-
|
35 |
-
#: classes/batch-process/helpers/class-wp-background-process.php:435
|
36 |
-
msgid "Every %d Minutes"
|
37 |
-
msgstr ""
|
38 |
-
|
39 |
-
#: classes/class-cartflows-admin-fields.php:162
|
40 |
-
msgid "Select"
|
41 |
-
msgstr ""
|
42 |
-
|
43 |
-
#: classes/class-cartflows-admin-fields.php:165
|
44 |
-
msgid "No Checkout Steps"
|
45 |
-
msgstr ""
|
46 |
-
|
47 |
-
#: classes/class-cartflows-admin-fields.php:191
|
48 |
-
#. translators: %s: link
|
49 |
-
msgid ""
|
50 |
-
"Be sure not to add any product in above selected Global Checkout step. "
|
51 |
-
"Please read information about how to set up Global Checkout %1$shere%2$s."
|
52 |
-
msgstr ""
|
53 |
-
|
54 |
-
#: classes/class-cartflows-admin.php:109 classes/class-cartflows-admin.php:110
|
55 |
-
#: includes/admin/cartflows-general-bck.php:34
|
56 |
-
msgid "Settings"
|
57 |
-
msgstr ""
|
58 |
-
|
59 |
-
#: classes/class-cartflows-admin.php:309
|
60 |
-
msgid "Flows Library"
|
61 |
-
msgstr ""
|
62 |
-
|
63 |
-
#: classes/class-cartflows-admin.php:316
|
64 |
-
#: modules/flow/view/meta-flow-steps.php:145
|
65 |
-
msgid "Ready Templates"
|
66 |
-
msgstr ""
|
67 |
-
|
68 |
-
#: classes/class-cartflows-admin.php:319
|
69 |
-
#: modules/flow/view/meta-flow-steps.php:148
|
70 |
-
msgid "Create Your Own"
|
71 |
-
msgstr ""
|
72 |
-
|
73 |
-
#: classes/class-cartflows-admin.php:330
|
74 |
-
#: modules/flow/view/meta-flow-steps.php:160
|
75 |
-
msgid "Search Sites"
|
76 |
-
msgstr ""
|
77 |
-
|
78 |
-
#: classes/class-cartflows-admin.php:331
|
79 |
-
#: modules/flow/view/meta-flow-steps.php:161
|
80 |
-
msgid "Search Flow..."
|
81 |
-
msgstr ""
|
82 |
-
|
83 |
-
#: classes/class-cartflows-admin.php:348
|
84 |
-
msgid "Design Your Flow"
|
85 |
-
msgstr ""
|
86 |
-
|
87 |
-
#: classes/class-cartflows-admin.php:349
|
88 |
-
#: modules/flow/view/meta-flow-steps.php:192
|
89 |
-
msgid "Learn How"
|
90 |
-
msgstr ""
|
91 |
-
|
92 |
-
#: classes/class-cartflows-api.php:
|
93 |
-
msgid "Request successfully processed!"
|
94 |
-
msgstr ""
|
95 |
-
|
96 |
-
#: classes/class-cartflows-cloning.php:414
|
97 |
-
msgid "Clone this flow"
|
98 |
-
msgstr ""
|
99 |
-
|
100 |
-
#: classes/class-cartflows-cloning.php:414
|
101 |
-
msgid "Clone"
|
102 |
-
msgstr ""
|
103 |
-
|
104 |
-
#: classes/class-cartflows-flow-frontend.php:52
|
105 |
-
msgid ""
|
106 |
-
"Test mode is active — which displays random products for previewing. It can "
|
107 |
-
"be deactivated from the flow settings in the admin dashboard."
|
108 |
-
msgstr ""
|
109 |
-
|
110 |
-
#: classes/class-cartflows-importer.php:80
|
111 |
-
msgid "Export this flow"
|
112 |
-
msgstr ""
|
113 |
-
|
114 |
-
#: classes/class-cartflows-importer.php:80 includes/exporter.php:18
|
115 |
-
msgid "Export"
|
116 |
-
msgstr ""
|
117 |
-
|
118 |
-
#: classes/class-cartflows-importer.php:91
|
119 |
-
msgid "Flow Export"
|
120 |
-
msgstr ""
|
121 |
-
|
122 |
-
#: classes/class-cartflows-importer.php:92
|
123 |
-
msgid "Flow Import"
|
124 |
-
msgstr ""
|
125 |
-
|
126 |
-
#: classes/class-cartflows-importer.php:103
|
127 |
-
msgid "No post to export has been supplied!"
|
128 |
-
msgstr ""
|
129 |
-
|
130 |
-
#: classes/class-cartflows-importer.php:
|
131 |
-
msgid "Please upload a valid .json file"
|
132 |
-
msgstr ""
|
133 |
-
|
134 |
-
#: classes/class-cartflows-importer.php:
|
135 |
-
msgid "Please upload a file to import"
|
136 |
-
msgstr ""
|
137 |
-
|
138 |
-
#: classes/class-cartflows-importer.php:
|
139 |
-
msgid "Successfully imported flows."
|
140 |
-
msgstr ""
|
141 |
-
|
142 |
-
#: classes/class-cartflows-importer.php:
|
143 |
-
msgid "Loading Steps"
|
144 |
-
msgstr ""
|
145 |
-
|
146 |
-
#: classes/class-cartflows-importer.php:
|
147 |
-
msgid "Getting steps from the cloud. Please wait for the moment."
|
148 |
-
msgstr ""
|
149 |
-
|
150 |
-
#: classes/class-cartflows-importer.php:
|
151 |
-
msgid "Searching Template.."
|
152 |
-
msgstr ""
|
153 |
-
|
154 |
-
#: classes/class-cartflows-importer.php:
|
155 |
-
msgid "Getting templates from the cloud. Please wait for the moment."
|
156 |
-
msgstr ""
|
157 |
-
|
158 |
-
#: classes/class-cartflows-importer.php:
|
159 |
-
msgid "Importing.."
|
160 |
-
msgstr ""
|
161 |
-
|
162 |
-
#: classes/class-cartflows-importer.php:
|
163 |
-
#: classes/class-cartflows-importer.php:
|
164 |
-
msgid "Imported"
|
165 |
-
msgstr ""
|
166 |
-
|
167 |
-
#: classes/class-cartflows-importer.php:
|
168 |
-
#: classes/class-cartflows-importer.php:
|
169 |
-
msgid "Thanks for patience"
|
170 |
-
msgstr ""
|
171 |
-
|
172 |
-
#: classes/class-cartflows-importer.php:
|
173 |
-
#: classes/class-cartflows-importer.php:
|
174 |
-
msgid "Coming Soon!"
|
175 |
-
msgstr ""
|
176 |
-
|
177 |
-
#: classes/class-cartflows-importer.php:
|
178 |
-
msgid "Redirecting to the Elementor edit window."
|
179 |
-
msgstr ""
|
180 |
-
|
181 |
-
#: classes/class-cartflows-importer.php:
|
182 |
-
#: classes/class-cartflows-importer.php:
|
183 |
-
msgid "Pro"
|
184 |
-
msgstr ""
|
185 |
-
|
186 |
-
#: classes/class-cartflows-importer.php:
|
187 |
-
#: classes/class-cartflows-importer.php:
|
188 |
-
msgid "Activate License"
|
189 |
-
msgstr ""
|
190 |
-
|
191 |
-
#: classes/class-cartflows-importer.php:
|
192 |
-
#: classes/class-cartflows-importer.php:
|
193 |
-
msgid "Get Pro"
|
194 |
-
msgstr ""
|
195 |
-
|
196 |
-
#: classes/class-cartflows-importer.php:
|
197 |
-
msgid "Create"
|
198 |
-
msgstr ""
|
199 |
-
|
200 |
-
#: classes/class-cartflows-importer.php:
|
201 |
-
msgid "Under Maintenance.."
|
202 |
-
msgstr ""
|
203 |
-
|
204 |
-
#: classes/class-cartflows-importer.php:
|
205 |
-
msgid ""
|
206 |
-
"If you are seeing this message, most likely our servers are under routine "
|
207 |
-
"maintenance and we will be back shortly."
|
208 |
-
msgstr ""
|
209 |
-
|
210 |
-
#: classes/class-cartflows-importer.php:
|
211 |
-
msgid ""
|
212 |
-
"In rare case, it is possible your website is having trouble connecting with "
|
213 |
-
"ours. If you need help, please feel free to get in touch with us from our "
|
214 |
-
"website.."
|
215 |
-
msgstr ""
|
216 |
-
|
217 |
-
#: classes/class-cartflows-importer.php:
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
"
|
269 |
-
msgstr ""
|
270 |
-
|
271 |
-
#: classes/class-cartflows-loader.php:
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
#:
|
405 |
-
msgid "
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
"
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
"
|
600 |
-
msgstr ""
|
601 |
-
|
602 |
-
#:
|
603 |
-
msgid "
|
604 |
-
msgstr ""
|
605 |
-
|
606 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
700 |
-
#: modules/
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
711 |
-
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:
|
712 |
-
msgid "
|
713 |
-
msgstr ""
|
714 |
-
|
715 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
716 |
-
msgid "
|
717 |
-
msgstr ""
|
718 |
-
|
719 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
#: modules/checkout/classes/class-cartflows-checkout-meta.php:
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
#: modules/flow/classes/class-cartflows-
|
912 |
-
msgid "
|
913 |
-
msgstr ""
|
914 |
-
|
915 |
-
#: modules/flow/classes/class-cartflows-flow-post-type.php:
|
916 |
-
msgid "
|
917 |
-
msgstr ""
|
918 |
-
|
919 |
-
#: modules/flow/classes/class-cartflows-flow-post-type.php:
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
#: modules/flow/classes/class-cartflows-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
#: modules/flow/classes/class-cartflows-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
#: modules/flow/classes/class-cartflows-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
#: modules/flow/classes/class-cartflows-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
#: modules/flow/classes/class-cartflows-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
#: modules/flow/classes/class-cartflows-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
#: modules/flow/classes/class-cartflows-
|
989 |
-
|
990 |
-
msgid "
|
991 |
-
msgstr ""
|
992 |
-
|
993 |
-
#: modules/flow/classes/class-cartflows-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
#: modules/flow/
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
#: modules/flow/
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
#: modules/flow/
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
msgid "
|
1195 |
-
msgstr ""
|
1196 |
-
|
1197 |
-
#: woocommerce/template/cart/cart-shipping.php:
|
1198 |
-
msgid "
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
#: woocommerce/template/checkout/
|
1261 |
-
msgid "
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
"
|
1273 |
-
msgstr ""
|
1274 |
-
|
1275 |
-
#: woocommerce/template/checkout/
|
1276 |
-
msgid "
|
1277 |
-
msgstr ""
|
1278 |
-
|
1279 |
-
#: woocommerce/template/checkout/thankyou.php:
|
1280 |
-
msgid "
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1347 |
msgstr ""
|
1 |
+
# Copyright (C) 2019 CartFlows Inc
|
2 |
+
# This file is distributed under the same license as the CartFlows package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: CartFlows 1.1.7\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
|
7 |
+
"POT-Creation-Date: 2019-02-25 13:32:05+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
|
12 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
+
"Language: en\n"
|
15 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
16 |
+
"X-Poedit-Country: United States\n"
|
17 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
18 |
+
"X-Poedit-KeywordsList: "
|
19 |
+
"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
|
20 |
+
"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
|
21 |
+
"X-Poedit-Basepath: ../\n"
|
22 |
+
"X-Poedit-SearchPath-0: .\n"
|
23 |
+
"X-Poedit-Bookmarks: \n"
|
24 |
+
"X-Textdomain-Support: yes\n"
|
25 |
+
"X-Generator: grunt-wp-i18n1.0.2\n"
|
26 |
+
|
27 |
+
#: classes/batch-process/class-cartflows-importer-elementor.php:44
|
28 |
+
msgid "Invalid content."
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: classes/batch-process/class-cartflows-importer-elementor.php:52
|
32 |
+
msgid "Invalid content. Expected an array."
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: classes/batch-process/helpers/class-wp-background-process.php:435
|
36 |
+
msgid "Every %d Minutes"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: classes/class-cartflows-admin-fields.php:162
|
40 |
+
msgid "Select"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: classes/class-cartflows-admin-fields.php:165
|
44 |
+
msgid "No Checkout Steps"
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#: classes/class-cartflows-admin-fields.php:191
|
48 |
+
#. translators: %s: link
|
49 |
+
msgid ""
|
50 |
+
"Be sure not to add any product in above selected Global Checkout step. "
|
51 |
+
"Please read information about how to set up Global Checkout %1$shere%2$s."
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: classes/class-cartflows-admin.php:109 classes/class-cartflows-admin.php:110
|
55 |
+
#: includes/admin/cartflows-general-bck.php:34
|
56 |
+
msgid "Settings"
|
57 |
+
msgstr ""
|
58 |
+
|
59 |
+
#: classes/class-cartflows-admin.php:309
|
60 |
+
msgid "Flows Library"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: classes/class-cartflows-admin.php:316
|
64 |
+
#: modules/flow/view/meta-flow-steps.php:145
|
65 |
+
msgid "Ready Templates"
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: classes/class-cartflows-admin.php:319
|
69 |
+
#: modules/flow/view/meta-flow-steps.php:148
|
70 |
+
msgid "Create Your Own"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: classes/class-cartflows-admin.php:330
|
74 |
+
#: modules/flow/view/meta-flow-steps.php:160
|
75 |
+
msgid "Search Sites"
|
76 |
+
msgstr ""
|
77 |
+
|
78 |
+
#: classes/class-cartflows-admin.php:331
|
79 |
+
#: modules/flow/view/meta-flow-steps.php:161
|
80 |
+
msgid "Search Flow..."
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: classes/class-cartflows-admin.php:348
|
84 |
+
msgid "Design Your Flow"
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: classes/class-cartflows-admin.php:349
|
88 |
+
#: modules/flow/view/meta-flow-steps.php:192
|
89 |
+
msgid "Learn How"
|
90 |
+
msgstr ""
|
91 |
+
|
92 |
+
#: classes/class-cartflows-api.php:373
|
93 |
+
msgid "Request successfully processed!"
|
94 |
+
msgstr ""
|
95 |
+
|
96 |
+
#: classes/class-cartflows-cloning.php:414
|
97 |
+
msgid "Clone this flow"
|
98 |
+
msgstr ""
|
99 |
+
|
100 |
+
#: classes/class-cartflows-cloning.php:414
|
101 |
+
msgid "Clone"
|
102 |
+
msgstr ""
|
103 |
+
|
104 |
+
#: classes/class-cartflows-flow-frontend.php:52
|
105 |
+
msgid ""
|
106 |
+
"Test mode is active — which displays random products for previewing. It can "
|
107 |
+
"be deactivated from the flow settings in the admin dashboard."
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#: classes/class-cartflows-importer.php:80
|
111 |
+
msgid "Export this flow"
|
112 |
+
msgstr ""
|
113 |
+
|
114 |
+
#: classes/class-cartflows-importer.php:80 includes/exporter.php:18
|
115 |
+
msgid "Export"
|
116 |
+
msgstr ""
|
117 |
+
|
118 |
+
#: classes/class-cartflows-importer.php:91
|
119 |
+
msgid "Flow Export"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: classes/class-cartflows-importer.php:92
|
123 |
+
msgid "Flow Import"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: classes/class-cartflows-importer.php:103
|
127 |
+
msgid "No post to export has been supplied!"
|
128 |
+
msgstr ""
|
129 |
+
|
130 |
+
#: classes/class-cartflows-importer.php:294
|
131 |
+
msgid "Please upload a valid .json file"
|
132 |
+
msgstr ""
|
133 |
+
|
134 |
+
#: classes/class-cartflows-importer.php:300
|
135 |
+
msgid "Please upload a file to import"
|
136 |
+
msgstr ""
|
137 |
+
|
138 |
+
#: classes/class-cartflows-importer.php:452
|
139 |
+
msgid "Successfully imported flows."
|
140 |
+
msgstr ""
|
141 |
+
|
142 |
+
#: classes/class-cartflows-importer.php:484
|
143 |
+
msgid "Loading Steps"
|
144 |
+
msgstr ""
|
145 |
+
|
146 |
+
#: classes/class-cartflows-importer.php:486
|
147 |
+
msgid "Getting steps from the cloud. Please wait for the moment."
|
148 |
+
msgstr ""
|
149 |
+
|
150 |
+
#: classes/class-cartflows-importer.php:497
|
151 |
+
msgid "Searching Template.."
|
152 |
+
msgstr ""
|
153 |
+
|
154 |
+
#: classes/class-cartflows-importer.php:499
|
155 |
+
msgid "Getting templates from the cloud. Please wait for the moment."
|
156 |
+
msgstr ""
|
157 |
+
|
158 |
+
#: classes/class-cartflows-importer.php:508
|
159 |
+
msgid "Importing.."
|
160 |
+
msgstr ""
|
161 |
+
|
162 |
+
#: classes/class-cartflows-importer.php:517
|
163 |
+
#: classes/class-cartflows-importer.php:557
|
164 |
+
msgid "Imported"
|
165 |
+
msgstr ""
|
166 |
+
|
167 |
+
#: classes/class-cartflows-importer.php:518
|
168 |
+
#: classes/class-cartflows-importer.php:558
|
169 |
+
msgid "Thanks for patience"
|
170 |
+
msgstr ""
|
171 |
+
|
172 |
+
#: classes/class-cartflows-importer.php:527
|
173 |
+
#: classes/class-cartflows-importer.php:539
|
174 |
+
msgid "Coming Soon!"
|
175 |
+
msgstr ""
|
176 |
+
|
177 |
+
#: classes/class-cartflows-importer.php:558
|
178 |
+
msgid "Redirecting to the Elementor edit window."
|
179 |
+
msgstr ""
|
180 |
+
|
181 |
+
#: classes/class-cartflows-importer.php:605
|
182 |
+
#: classes/class-cartflows-importer.php:689
|
183 |
+
msgid "Pro"
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
+
#: classes/class-cartflows-importer.php:628
|
187 |
+
#: classes/class-cartflows-importer.php:715
|
188 |
+
msgid "Activate License"
|
189 |
+
msgstr ""
|
190 |
+
|
191 |
+
#: classes/class-cartflows-importer.php:630
|
192 |
+
#: classes/class-cartflows-importer.php:717
|
193 |
+
msgid "Get Pro"
|
194 |
+
msgstr ""
|
195 |
+
|
196 |
+
#: classes/class-cartflows-importer.php:655
|
197 |
+
msgid "Create"
|
198 |
+
msgstr ""
|
199 |
+
|
200 |
+
#: classes/class-cartflows-importer.php:734
|
201 |
+
msgid "Under Maintenance.."
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: classes/class-cartflows-importer.php:735
|
205 |
+
msgid ""
|
206 |
+
"If you are seeing this message, most likely our servers are under routine "
|
207 |
+
"maintenance and we will be back shortly."
|
208 |
+
msgstr ""
|
209 |
+
|
210 |
+
#: classes/class-cartflows-importer.php:736
|
211 |
+
msgid ""
|
212 |
+
"In rare case, it is possible your website is having trouble connecting with "
|
213 |
+
"ours. If you need help, please feel free to get in touch with us from our "
|
214 |
+
"website.."
|
215 |
+
msgstr ""
|
216 |
+
|
217 |
+
#: classes/class-cartflows-importer.php:766
|
218 |
+
#. translators: %s: Plugin string
|
219 |
+
msgid ""
|
220 |
+
"%1$s to see CartFlows templates. If you prefer another page builder tool, "
|
221 |
+
"you can <a href=\"%2$s\" target=\"blank\">select it here</a>."
|
222 |
+
msgstr ""
|
223 |
+
|
224 |
+
#: classes/class-cartflows-importer.php:781
|
225 |
+
msgid "All"
|
226 |
+
msgstr ""
|
227 |
+
|
228 |
+
#: classes/class-cartflows-importer.php:784
|
229 |
+
msgid "Select Step Type"
|
230 |
+
msgstr ""
|
231 |
+
|
232 |
+
#: classes/class-cartflows-importer.php:861
|
233 |
+
msgid "Import from Cloud"
|
234 |
+
msgstr ""
|
235 |
+
|
236 |
+
#: classes/class-cartflows-importer.php:1155
|
237 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:224
|
238 |
+
msgid "Landing Page"
|
239 |
+
msgstr ""
|
240 |
+
|
241 |
+
#: classes/class-cartflows-importer.php:1156
|
242 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:225
|
243 |
+
msgid "Checkout Page"
|
244 |
+
msgstr ""
|
245 |
+
|
246 |
+
#: classes/class-cartflows-importer.php:1157
|
247 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:226
|
248 |
+
msgid "Thank You Page"
|
249 |
+
msgstr ""
|
250 |
+
|
251 |
+
#: classes/class-cartflows-importer.php:1262
|
252 |
+
#. translators: %s: template ID
|
253 |
+
msgid "Invalid template id %1$s or post id %2$s."
|
254 |
+
msgstr ""
|
255 |
+
|
256 |
+
#: classes/class-cartflows-importer.php:1312
|
257 |
+
#. translators: %s: flow ID
|
258 |
+
msgid "Invalid flow id %1$s OR step type %2$s."
|
259 |
+
msgstr ""
|
260 |
+
|
261 |
+
#: classes/class-cartflows-importer.php:1433
|
262 |
+
msgid ""
|
263 |
+
"Elementor is not activated. Please activate plugin Elementor Page Builder "
|
264 |
+
"to import the step."
|
265 |
+
msgstr ""
|
266 |
+
|
267 |
+
#: classes/class-cartflows-importer.php:1551
|
268 |
+
msgid "Plugin Successfully Activated"
|
269 |
+
msgstr ""
|
270 |
+
|
271 |
+
#: classes/class-cartflows-loader.php:332
|
272 |
+
#. translators: %s: html tags
|
273 |
+
msgid ""
|
274 |
+
"The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed "
|
275 |
+
"& activated."
|
276 |
+
msgstr ""
|
277 |
+
|
278 |
+
#: classes/class-cartflows-loader.php:342
|
279 |
+
msgid "Activate WooCommerce"
|
280 |
+
msgstr ""
|
281 |
+
|
282 |
+
#: classes/class-cartflows-loader.php:350
|
283 |
+
msgid "Install WooCommerce"
|
284 |
+
msgstr ""
|
285 |
+
|
286 |
+
#: classes/class-cartflows-meta-fields.php:86
|
287 |
+
msgid "Thin 100"
|
288 |
+
msgstr ""
|
289 |
+
|
290 |
+
#: classes/class-cartflows-meta-fields.php:87
|
291 |
+
msgid "Extra-Light 200"
|
292 |
+
msgstr ""
|
293 |
+
|
294 |
+
#: classes/class-cartflows-meta-fields.php:88
|
295 |
+
msgid "Light 300"
|
296 |
+
msgstr ""
|
297 |
+
|
298 |
+
#: classes/class-cartflows-meta-fields.php:89
|
299 |
+
msgid "Normal 400"
|
300 |
+
msgstr ""
|
301 |
+
|
302 |
+
#: classes/class-cartflows-meta-fields.php:90
|
303 |
+
msgid "Medium 500"
|
304 |
+
msgstr ""
|
305 |
+
|
306 |
+
#: classes/class-cartflows-meta-fields.php:91
|
307 |
+
msgid "Semi-Bold 600"
|
308 |
+
msgstr ""
|
309 |
+
|
310 |
+
#: classes/class-cartflows-meta-fields.php:92
|
311 |
+
msgid "Bold 700"
|
312 |
+
msgstr ""
|
313 |
+
|
314 |
+
#: classes/class-cartflows-meta-fields.php:93
|
315 |
+
msgid "Extra-Bold 800"
|
316 |
+
msgstr ""
|
317 |
+
|
318 |
+
#: classes/class-cartflows-meta-fields.php:94
|
319 |
+
msgid "Ultra-Bold 900"
|
320 |
+
msgstr ""
|
321 |
+
|
322 |
+
#: classes/class-cartflows-meta-fields.php:217
|
323 |
+
#: classes/class-cartflows-meta-fields.php:325
|
324 |
+
#: classes/class-cartflows-meta-fields.php:1417
|
325 |
+
msgid "Remove"
|
326 |
+
msgstr ""
|
327 |
+
|
328 |
+
#: classes/class-cartflows-meta-fields.php:446
|
329 |
+
msgid "Field Width"
|
330 |
+
msgstr ""
|
331 |
+
|
332 |
+
#: classes/class-cartflows-meta-fields.php:450
|
333 |
+
msgid "33%"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: classes/class-cartflows-meta-fields.php:451
|
337 |
+
msgid "50%"
|
338 |
+
msgstr ""
|
339 |
+
|
340 |
+
#: classes/class-cartflows-meta-fields.php:452
|
341 |
+
msgid "100%"
|
342 |
+
msgstr ""
|
343 |
+
|
344 |
+
#: classes/class-cartflows-meta-fields.php:463
|
345 |
+
msgid "Field Label"
|
346 |
+
msgstr ""
|
347 |
+
|
348 |
+
#: classes/class-cartflows-meta-fields.php:477
|
349 |
+
msgid "Options"
|
350 |
+
msgstr ""
|
351 |
+
|
352 |
+
#: classes/class-cartflows-meta-fields.php:492
|
353 |
+
#: classes/class-cartflows-meta-fields.php:505
|
354 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:446
|
355 |
+
msgid "Default"
|
356 |
+
msgstr ""
|
357 |
+
|
358 |
+
#: classes/class-cartflows-meta-fields.php:496
|
359 |
+
msgid "Checked"
|
360 |
+
msgstr ""
|
361 |
+
|
362 |
+
#: classes/class-cartflows-meta-fields.php:497
|
363 |
+
msgid "Un-Checked"
|
364 |
+
msgstr ""
|
365 |
+
|
366 |
+
#: classes/class-cartflows-meta-fields.php:518
|
367 |
+
msgid "Placeholder"
|
368 |
+
msgstr ""
|
369 |
+
|
370 |
+
#: classes/class-cartflows-meta-fields.php:530
|
371 |
+
msgid "Required"
|
372 |
+
msgstr ""
|
373 |
+
|
374 |
+
#: classes/class-cartflows-meta-fields.php:542
|
375 |
+
msgid "Enable this field"
|
376 |
+
msgstr ""
|
377 |
+
|
378 |
+
#: classes/class-cartflows-meta-fields.php:562
|
379 |
+
msgid "Label"
|
380 |
+
msgstr ""
|
381 |
+
|
382 |
+
#: classes/class-cartflows-meta-fields.php:990
|
383 |
+
#: classes/class-cartflows-meta-fields.php:1409
|
384 |
+
msgid "Search for a product…"
|
385 |
+
msgstr ""
|
386 |
+
|
387 |
+
#: classes/class-cartflows-meta-fields.php:1031
|
388 |
+
msgid "Search for a coupon…"
|
389 |
+
msgstr ""
|
390 |
+
|
391 |
+
#: classes/class-cartflows-meta.php:34
|
392 |
+
msgid "Update"
|
393 |
+
msgstr ""
|
394 |
+
|
395 |
+
#: classes/class-cartflows-meta.php:42
|
396 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:84
|
397 |
+
msgid "Back to edit Flow"
|
398 |
+
msgstr ""
|
399 |
+
|
400 |
+
#: classes/class-cartflows-wizard.php:45
|
401 |
+
msgid "Thanks for installing and using CartFlows!"
|
402 |
+
msgstr ""
|
403 |
+
|
404 |
+
#: classes/class-cartflows-wizard.php:46
|
405 |
+
msgid ""
|
406 |
+
"It is easy to use the CartFlows. Please use the setup wizard to quick start "
|
407 |
+
"setup."
|
408 |
+
msgstr ""
|
409 |
+
|
410 |
+
#: classes/class-cartflows-wizard.php:71
|
411 |
+
#: includes/admin/cartflows-general-bck.php:24
|
412 |
+
msgid "Welcome"
|
413 |
+
msgstr ""
|
414 |
+
|
415 |
+
#: classes/class-cartflows-wizard.php:76 classes/class-cartflows-wizard.php:259
|
416 |
+
msgid "Page Builder"
|
417 |
+
msgstr ""
|
418 |
+
|
419 |
+
#: classes/class-cartflows-wizard.php:81
|
420 |
+
msgid "Ready!"
|
421 |
+
msgstr ""
|
422 |
+
|
423 |
+
#: classes/class-cartflows-wizard.php:150
|
424 |
+
msgid "CartFlows Setup"
|
425 |
+
msgstr ""
|
426 |
+
|
427 |
+
#: classes/class-cartflows-wizard.php:176
|
428 |
+
msgid "Exit Setup Wizard"
|
429 |
+
msgstr ""
|
430 |
+
|
431 |
+
#: classes/class-cartflows-wizard.php:225
|
432 |
+
msgid "Thank you for choosing CartFlows!"
|
433 |
+
msgstr ""
|
434 |
+
|
435 |
+
#: classes/class-cartflows-wizard.php:232
|
436 |
+
msgid "Lets Go »"
|
437 |
+
msgstr ""
|
438 |
+
|
439 |
+
#: classes/class-cartflows-wizard.php:260
|
440 |
+
msgid "Select a page builder which you want to use for creating your new flows."
|
441 |
+
msgstr ""
|
442 |
+
|
443 |
+
#: classes/class-cartflows-wizard.php:265
|
444 |
+
msgid "Select Page Builder"
|
445 |
+
msgstr ""
|
446 |
+
|
447 |
+
#: classes/class-cartflows-wizard.php:266
|
448 |
+
msgid "Add locations for where this Schema should appear."
|
449 |
+
msgstr ""
|
450 |
+
|
451 |
+
#: classes/class-cartflows-wizard.php:273
|
452 |
+
#: includes/admin/cartflows-general.php:71
|
453 |
+
msgid "Elementor"
|
454 |
+
msgstr ""
|
455 |
+
|
456 |
+
#: classes/class-cartflows-wizard.php:294
|
457 |
+
msgid "The above plugin will be installed and activated for you!"
|
458 |
+
msgstr ""
|
459 |
+
|
460 |
+
#: classes/class-cartflows-wizard.php:297
|
461 |
+
msgid "« Previous"
|
462 |
+
msgstr ""
|
463 |
+
|
464 |
+
#: classes/class-cartflows-wizard.php:300
|
465 |
+
#: classes/class-cartflows-wizard.php:301
|
466 |
+
msgid "Next »"
|
467 |
+
msgstr ""
|
468 |
+
|
469 |
+
#: classes/class-cartflows-wizard.php:393
|
470 |
+
msgid "Congratulations!"
|
471 |
+
msgstr ""
|
472 |
+
|
473 |
+
#: classes/class-cartflows-wizard.php:400
|
474 |
+
msgid ""
|
475 |
+
"You've successfully completed the setup before you begin setting now you "
|
476 |
+
"can use it."
|
477 |
+
msgstr ""
|
478 |
+
|
479 |
+
#: classes/class-cartflows-wizard.php:414
|
480 |
+
msgid "Create a flow"
|
481 |
+
msgstr ""
|
482 |
+
|
483 |
+
#: includes/admin/cartflows-admin.php:19
|
484 |
+
#: includes/admin/cartflows-general.php:30
|
485 |
+
msgid "Modernizing WordPress eCommerce!"
|
486 |
+
msgstr ""
|
487 |
+
|
488 |
+
#: includes/admin/cartflows-admin.php:29
|
489 |
+
msgid "Settings saved successfully."
|
490 |
+
msgstr ""
|
491 |
+
|
492 |
+
#: includes/admin/cartflows-general-bck.php:10
|
493 |
+
msgid "Selec"
|
494 |
+
msgstr ""
|
495 |
+
|
496 |
+
#: includes/admin/cartflows-general-bck.php:22
|
497 |
+
msgid "General"
|
498 |
+
msgstr ""
|
499 |
+
|
500 |
+
#: includes/admin/cartflows-general.php:15
|
501 |
+
#: includes/admin/cartflows-general.php:38
|
502 |
+
msgid "General Settings"
|
503 |
+
msgstr ""
|
504 |
+
|
505 |
+
#: includes/admin/cartflows-general.php:22
|
506 |
+
msgid "Getting Started"
|
507 |
+
msgstr ""
|
508 |
+
|
509 |
+
#: includes/admin/cartflows-general.php:50
|
510 |
+
msgid "Disallow search engines from indexing flows"
|
511 |
+
msgstr ""
|
512 |
+
|
513 |
+
#: includes/admin/cartflows-general.php:58
|
514 |
+
#: modules/flow/view/meta-flow-steps.php:87
|
515 |
+
msgid "Global Checkout"
|
516 |
+
msgstr ""
|
517 |
+
|
518 |
+
#: includes/admin/cartflows-general.php:67
|
519 |
+
msgid "Show Templates designed with"
|
520 |
+
msgstr ""
|
521 |
+
|
522 |
+
#: includes/admin/cartflows-general.php:68
|
523 |
+
msgid ""
|
524 |
+
"CartFlows offers flow templates that can be imported in one click. These "
|
525 |
+
"templates are available in few different page builders. Please choose your "
|
526 |
+
"preferred page builder from the list so you will only see templates that "
|
527 |
+
"are made using that page builder.."
|
528 |
+
msgstr ""
|
529 |
+
|
530 |
+
#: includes/admin/cartflows-general.php:72
|
531 |
+
msgid "Beaver Builder"
|
532 |
+
msgstr ""
|
533 |
+
|
534 |
+
#: includes/admin/cartflows-general.php:73
|
535 |
+
msgid "Divi"
|
536 |
+
msgstr ""
|
537 |
+
|
538 |
+
#: includes/admin/cartflows-general.php:74
|
539 |
+
msgid "Other"
|
540 |
+
msgstr ""
|
541 |
+
|
542 |
+
#: includes/admin/cartflows-general.php:83
|
543 |
+
msgid "Save Changes"
|
544 |
+
msgstr ""
|
545 |
+
|
546 |
+
#: includes/admin/cartflows-general.php:94
|
547 |
+
msgid "Knowledge Base"
|
548 |
+
msgstr ""
|
549 |
+
|
550 |
+
#: includes/admin/cartflows-general.php:98
|
551 |
+
msgid "Not sure how something works? Take a peek at the knowledge base and learn."
|
552 |
+
msgstr ""
|
553 |
+
|
554 |
+
#: includes/admin/cartflows-general.php:101
|
555 |
+
msgid "Visit Knowledge Base »"
|
556 |
+
msgstr ""
|
557 |
+
|
558 |
+
#: includes/admin/cartflows-general.php:109
|
559 |
+
msgid "Community"
|
560 |
+
msgstr ""
|
561 |
+
|
562 |
+
#: includes/admin/cartflows-general.php:113
|
563 |
+
msgid ""
|
564 |
+
"Join the community of super helpful CartFlows users. Say hello, ask "
|
565 |
+
"questions, give feedback and help each other!"
|
566 |
+
msgstr ""
|
567 |
+
|
568 |
+
#: includes/admin/cartflows-general.php:116
|
569 |
+
msgid "Join Our Facebook Group »"
|
570 |
+
msgstr ""
|
571 |
+
|
572 |
+
#: includes/admin/cartflows-general.php:124
|
573 |
+
msgid "Five Star Support"
|
574 |
+
msgstr ""
|
575 |
+
|
576 |
+
#: includes/admin/cartflows-general.php:128
|
577 |
+
msgid "Got a question? Get in touch with CartFlows developers. We're happy to help!"
|
578 |
+
msgstr ""
|
579 |
+
|
580 |
+
#: includes/admin/cartflows-general.php:131
|
581 |
+
msgid "Submit a Ticket »"
|
582 |
+
msgstr ""
|
583 |
+
|
584 |
+
#: includes/exporter.php:12
|
585 |
+
msgid "Export Flows to a JSON file"
|
586 |
+
msgstr ""
|
587 |
+
|
588 |
+
#: includes/exporter.php:13
|
589 |
+
msgid ""
|
590 |
+
"This tool allows you to generate and download a JSON file containing a list "
|
591 |
+
"of all flows."
|
592 |
+
msgstr ""
|
593 |
+
|
594 |
+
#: includes/importer.php:12
|
595 |
+
msgid "Import Flows to a JSON file"
|
596 |
+
msgstr ""
|
597 |
+
|
598 |
+
#: includes/importer.php:13
|
599 |
+
msgid "This tool allows you to import the flows from the JSON file."
|
600 |
+
msgstr ""
|
601 |
+
|
602 |
+
#: includes/importer.php:21
|
603 |
+
msgid "Import"
|
604 |
+
msgstr ""
|
605 |
+
|
606 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:157
|
607 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-markup.php:62
|
608 |
+
msgid ""
|
609 |
+
"WooCommerce functions not exists. If you are in iframe, please reload the "
|
610 |
+
"iframe"
|
611 |
+
msgstr ""
|
612 |
+
|
613 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:173
|
614 |
+
msgid "Checkout ID not found"
|
615 |
+
msgstr ""
|
616 |
+
|
617 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:339
|
618 |
+
msgid "Variations Not set"
|
619 |
+
msgstr ""
|
620 |
+
|
621 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:348
|
622 |
+
msgid "This product can't be purcahsed"
|
623 |
+
msgstr ""
|
624 |
+
|
625 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:964
|
626 |
+
msgid "Coupon Code"
|
627 |
+
msgstr ""
|
628 |
+
|
629 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:973
|
630 |
+
msgid "Apply"
|
631 |
+
msgstr ""
|
632 |
+
|
633 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:68
|
634 |
+
msgid "Checkout Layout"
|
635 |
+
msgstr ""
|
636 |
+
|
637 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:153
|
638 |
+
#: modules/landing/classes/class-cartflows-landing-meta.php:126
|
639 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:130
|
640 |
+
msgid "Shortcodes"
|
641 |
+
msgstr ""
|
642 |
+
|
643 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:160
|
644 |
+
msgid "Select Product"
|
645 |
+
msgstr ""
|
646 |
+
|
647 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:166
|
648 |
+
msgid "Order Bump"
|
649 |
+
msgstr ""
|
650 |
+
|
651 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:172
|
652 |
+
msgid "Checkout Design"
|
653 |
+
msgstr ""
|
654 |
+
|
655 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:178
|
656 |
+
msgid "Checkout Fields"
|
657 |
+
msgstr ""
|
658 |
+
|
659 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:184
|
660 |
+
msgid "Logo ( Optional )"
|
661 |
+
msgstr ""
|
662 |
+
|
663 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:239
|
664 |
+
msgid "Add this shortcode to your checkout page"
|
665 |
+
msgstr ""
|
666 |
+
|
667 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:291
|
668 |
+
#. translators: %s: link
|
669 |
+
msgid "Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature"
|
670 |
+
msgstr ""
|
671 |
+
|
672 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:319
|
673 |
+
#. translators: %s: link
|
674 |
+
msgid "Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature"
|
675 |
+
msgstr ""
|
676 |
+
|
677 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:347
|
678 |
+
msgid "One Column (Available in CartFlows Pro) "
|
679 |
+
msgstr ""
|
680 |
+
|
681 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:353
|
682 |
+
msgid "Checkout Skin"
|
683 |
+
msgstr ""
|
684 |
+
|
685 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:357
|
686 |
+
msgid "One Column"
|
687 |
+
msgstr ""
|
688 |
+
|
689 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:358
|
690 |
+
msgid "Two Column"
|
691 |
+
msgstr ""
|
692 |
+
|
693 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:367
|
694 |
+
msgid "Primary Color"
|
695 |
+
msgstr ""
|
696 |
+
|
697 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:376
|
698 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:411
|
699 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:457
|
700 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:549
|
701 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:197
|
702 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:220
|
703 |
+
msgid "Font Family"
|
704 |
+
msgstr ""
|
705 |
+
|
706 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:384
|
707 |
+
msgid "Advance Options"
|
708 |
+
msgstr ""
|
709 |
+
|
710 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:396
|
711 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:205
|
712 |
+
msgid "Heading"
|
713 |
+
msgstr ""
|
714 |
+
|
715 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:402
|
716 |
+
msgid "Heading Color"
|
717 |
+
msgstr ""
|
718 |
+
|
719 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:420
|
720 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:466
|
721 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:558
|
722 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:229
|
723 |
+
msgid "Font Weight"
|
724 |
+
msgstr ""
|
725 |
+
|
726 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:428
|
727 |
+
msgid "Input Fields"
|
728 |
+
msgstr ""
|
729 |
+
|
730 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:436
|
731 |
+
msgid "Floating Labels (Available in CartFlows Pro)"
|
732 |
+
msgstr ""
|
733 |
+
|
734 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:442
|
735 |
+
msgid "Style"
|
736 |
+
msgstr ""
|
737 |
+
|
738 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:447
|
739 |
+
msgid "Floating Labels"
|
740 |
+
msgstr ""
|
741 |
+
|
742 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:474
|
743 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:566
|
744 |
+
msgid "Size"
|
745 |
+
msgstr ""
|
746 |
+
|
747 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:478
|
748 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:570
|
749 |
+
msgid "Extra Small"
|
750 |
+
msgstr ""
|
751 |
+
|
752 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:479
|
753 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:571
|
754 |
+
msgid "Small"
|
755 |
+
msgstr ""
|
756 |
+
|
757 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:480
|
758 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:572
|
759 |
+
msgid "Medium"
|
760 |
+
msgstr ""
|
761 |
+
|
762 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:481
|
763 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:573
|
764 |
+
msgid "Large"
|
765 |
+
msgstr ""
|
766 |
+
|
767 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:482
|
768 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:574
|
769 |
+
msgid "Extra Large"
|
770 |
+
msgstr ""
|
771 |
+
|
772 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:483
|
773 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:575
|
774 |
+
msgid "Custom"
|
775 |
+
msgstr ""
|
776 |
+
|
777 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:490
|
778 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:582
|
779 |
+
msgid "Top Bottom Spacing"
|
780 |
+
msgstr ""
|
781 |
+
|
782 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:498
|
783 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:590
|
784 |
+
msgid "Left Right Spacing"
|
785 |
+
msgstr ""
|
786 |
+
|
787 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:506
|
788 |
+
msgid "Text / Placeholder Color"
|
789 |
+
msgstr ""
|
790 |
+
|
791 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:514
|
792 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:614
|
793 |
+
msgid "Background Color"
|
794 |
+
msgstr ""
|
795 |
+
|
796 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:522
|
797 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:630
|
798 |
+
msgid "Border Color"
|
799 |
+
msgstr ""
|
800 |
+
|
801 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:529
|
802 |
+
msgid "Label Color"
|
803 |
+
msgstr ""
|
804 |
+
|
805 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:542
|
806 |
+
msgid "Buttons"
|
807 |
+
msgstr ""
|
808 |
+
|
809 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:598
|
810 |
+
msgid "Text Color"
|
811 |
+
msgstr ""
|
812 |
+
|
813 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:606
|
814 |
+
msgid "Text Hover Color"
|
815 |
+
msgstr ""
|
816 |
+
|
817 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:622
|
818 |
+
msgid "Background Hover Color"
|
819 |
+
msgstr ""
|
820 |
+
|
821 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:638
|
822 |
+
msgid "Border Hover Color"
|
823 |
+
msgstr ""
|
824 |
+
|
825 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:651
|
826 |
+
msgid "Sections"
|
827 |
+
msgstr ""
|
828 |
+
|
829 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:657
|
830 |
+
msgid "Highlight Area Background Color"
|
831 |
+
msgstr ""
|
832 |
+
|
833 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:696
|
834 |
+
msgid "Header Logo"
|
835 |
+
msgstr ""
|
836 |
+
|
837 |
+
#: modules/checkout/classes/class-cartflows-checkout-meta.php:704
|
838 |
+
msgid "Logo Width (In px)"
|
839 |
+
msgstr ""
|
840 |
+
|
841 |
+
#: modules/checkout/templates/embed/checkout-template-simple.php:25
|
842 |
+
#: modules/checkout/templates/wcf-template.php:36
|
843 |
+
msgid "Your cart is currently empty."
|
844 |
+
msgstr ""
|
845 |
+
|
846 |
+
#: modules/checkout/templates/wcf-template.php:46
|
847 |
+
msgid "Copyright ©"
|
848 |
+
msgstr ""
|
849 |
+
|
850 |
+
#: modules/checkout/templates/wcf-template.php:50
|
851 |
+
msgid "All Rights Reserved"
|
852 |
+
msgstr ""
|
853 |
+
|
854 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:199
|
855 |
+
#. translators: %s flow id
|
856 |
+
msgid "Steps not created for flow - %s"
|
857 |
+
msgstr ""
|
858 |
+
|
859 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:213
|
860 |
+
#. translators: %s flow id
|
861 |
+
msgid "Steps already exists. Flow - %s"
|
862 |
+
msgstr ""
|
863 |
+
|
864 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:262
|
865 |
+
#. translators: %s flow id
|
866 |
+
msgid "Steps created for flow - %s"
|
867 |
+
msgstr ""
|
868 |
+
|
869 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:333
|
870 |
+
#. translators: %s flow id
|
871 |
+
msgid "Step not deleted for flow - %s"
|
872 |
+
msgstr ""
|
873 |
+
|
874 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:364
|
875 |
+
#. translators: %s flow id
|
876 |
+
msgid "Step deleted for flow - %s"
|
877 |
+
msgstr ""
|
878 |
+
|
879 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:387
|
880 |
+
#. translators: %s flow id
|
881 |
+
msgid "Steps not sorted for flow - %s"
|
882 |
+
msgstr ""
|
883 |
+
|
884 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:410
|
885 |
+
#. translators: %s flow id
|
886 |
+
msgid "Steps sorted for flow - %s"
|
887 |
+
msgstr ""
|
888 |
+
|
889 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:521
|
890 |
+
msgid "Flow Settings"
|
891 |
+
msgstr ""
|
892 |
+
|
893 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:606
|
894 |
+
msgid "Enable Test Mode"
|
895 |
+
msgstr ""
|
896 |
+
|
897 |
+
#: modules/flow/classes/class-cartflows-flow-meta.php:613
|
898 |
+
msgid ""
|
899 |
+
"Test mode adds random products in your flow, so you can preview it easily "
|
900 |
+
"while testing."
|
901 |
+
msgstr ""
|
902 |
+
|
903 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:57
|
904 |
+
msgid "Search Flows"
|
905 |
+
msgstr ""
|
906 |
+
|
907 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:58
|
908 |
+
msgid "All Flows"
|
909 |
+
msgstr ""
|
910 |
+
|
911 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:59
|
912 |
+
msgid "Edit Flow"
|
913 |
+
msgstr ""
|
914 |
+
|
915 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:60
|
916 |
+
msgid "View Flow"
|
917 |
+
msgstr ""
|
918 |
+
|
919 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:61
|
920 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:63
|
921 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:144
|
922 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:146
|
923 |
+
msgid "Add New"
|
924 |
+
msgstr ""
|
925 |
+
|
926 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:62
|
927 |
+
msgid "Update Flow"
|
928 |
+
msgstr ""
|
929 |
+
|
930 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:64
|
931 |
+
msgid "New Flow Name"
|
932 |
+
msgstr ""
|
933 |
+
|
934 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:123
|
935 |
+
msgid "View"
|
936 |
+
msgstr ""
|
937 |
+
|
938 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:230
|
939 |
+
msgid "Flows"
|
940 |
+
msgstr ""
|
941 |
+
|
942 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:252
|
943 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:258
|
944 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:392
|
945 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:398
|
946 |
+
#. translators: %s: singular custom post type name
|
947 |
+
msgid "%s updated."
|
948 |
+
msgstr ""
|
949 |
+
|
950 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:254
|
951 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:394
|
952 |
+
#. translators: %s: singular custom post type name
|
953 |
+
msgid "Custom %s updated."
|
954 |
+
msgstr ""
|
955 |
+
|
956 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:256
|
957 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:396
|
958 |
+
#. translators: %s: singular custom post type name
|
959 |
+
msgid "Custom %s deleted."
|
960 |
+
msgstr ""
|
961 |
+
|
962 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:260
|
963 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:400
|
964 |
+
#. translators: %1$s: singular custom post type name ,%2$s: date and time of
|
965 |
+
#. the revision
|
966 |
+
msgid "%1$s restored to revision from %2$s"
|
967 |
+
msgstr ""
|
968 |
+
|
969 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:262
|
970 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:402
|
971 |
+
#. translators: %s: singular custom post type name
|
972 |
+
msgid "%s published."
|
973 |
+
msgstr ""
|
974 |
+
|
975 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:264
|
976 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:404
|
977 |
+
#. translators: %s: singular custom post type name
|
978 |
+
msgid "%s saved."
|
979 |
+
msgstr ""
|
980 |
+
|
981 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:266
|
982 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:406
|
983 |
+
#. translators: %s: singular custom post type name
|
984 |
+
msgid "%s submitted."
|
985 |
+
msgstr ""
|
986 |
+
|
987 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:268
|
988 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:408
|
989 |
+
#. translators: %s: singular custom post type name
|
990 |
+
msgid "%s scheduled for."
|
991 |
+
msgstr ""
|
992 |
+
|
993 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:270
|
994 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:410
|
995 |
+
#. translators: %s: singular custom post type name
|
996 |
+
msgid "%s draft updated."
|
997 |
+
msgstr ""
|
998 |
+
|
999 |
+
#: modules/flow/classes/class-cartflows-flow-shortcodes.php:148
|
1000 |
+
#: modules/widgets/class-cartflows-next-step.php:79
|
1001 |
+
msgid "Next Step"
|
1002 |
+
msgstr ""
|
1003 |
+
|
1004 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:140
|
1005 |
+
msgid "Search Steps"
|
1006 |
+
msgstr ""
|
1007 |
+
|
1008 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:141
|
1009 |
+
msgid "All Steps"
|
1010 |
+
msgstr ""
|
1011 |
+
|
1012 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:142
|
1013 |
+
#: modules/flow/view/meta-flow-steps.php:99
|
1014 |
+
msgid "Edit Step"
|
1015 |
+
msgstr ""
|
1016 |
+
|
1017 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:143
|
1018 |
+
#: modules/flow/view/meta-flow-steps.php:95
|
1019 |
+
msgid "View Step"
|
1020 |
+
msgstr ""
|
1021 |
+
|
1022 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:145
|
1023 |
+
msgid "Update Step"
|
1024 |
+
msgstr ""
|
1025 |
+
|
1026 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:147
|
1027 |
+
msgid "New Step Name"
|
1028 |
+
msgstr ""
|
1029 |
+
|
1030 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:170
|
1031 |
+
msgid "Step Type"
|
1032 |
+
msgstr ""
|
1033 |
+
|
1034 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:179
|
1035 |
+
msgid "Step Flow"
|
1036 |
+
msgstr ""
|
1037 |
+
|
1038 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:196
|
1039 |
+
#: modules/flow/view/meta-flow-steps.php:11
|
1040 |
+
msgid "Landing"
|
1041 |
+
msgstr ""
|
1042 |
+
|
1043 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:202
|
1044 |
+
#: modules/flow/view/meta-flow-steps.php:12
|
1045 |
+
msgid "Checkout"
|
1046 |
+
msgstr ""
|
1047 |
+
|
1048 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:208
|
1049 |
+
#: modules/flow/view/meta-flow-steps.php:13
|
1050 |
+
msgid "Thank You"
|
1051 |
+
msgstr ""
|
1052 |
+
|
1053 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:214
|
1054 |
+
#: modules/flow/view/meta-flow-steps.php:14
|
1055 |
+
msgid "Upsell"
|
1056 |
+
msgstr ""
|
1057 |
+
|
1058 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:220
|
1059 |
+
#: modules/flow/view/meta-flow-steps.php:15
|
1060 |
+
msgid "Downsell"
|
1061 |
+
msgstr ""
|
1062 |
+
|
1063 |
+
#: modules/flow/view/meta-flow-steps.php:79
|
1064 |
+
msgid "No Product Assigned"
|
1065 |
+
msgstr ""
|
1066 |
+
|
1067 |
+
#: modules/flow/view/meta-flow-steps.php:83
|
1068 |
+
msgid "Global Checkout - Remove selected checkout product"
|
1069 |
+
msgstr ""
|
1070 |
+
|
1071 |
+
#: modules/flow/view/meta-flow-steps.php:103
|
1072 |
+
msgid "Clone Step"
|
1073 |
+
msgstr ""
|
1074 |
+
|
1075 |
+
#: modules/flow/view/meta-flow-steps.php:107
|
1076 |
+
msgid "Delete Step"
|
1077 |
+
msgstr ""
|
1078 |
+
|
1079 |
+
#: modules/flow/view/meta-flow-steps.php:122
|
1080 |
+
msgid "Add New Step"
|
1081 |
+
msgstr ""
|
1082 |
+
|
1083 |
+
#: modules/flow/view/meta-flow-steps.php:138
|
1084 |
+
msgid "Steps Library"
|
1085 |
+
msgstr ""
|
1086 |
+
|
1087 |
+
#: modules/flow/view/meta-flow-steps.php:188
|
1088 |
+
msgid "Create Step"
|
1089 |
+
msgstr ""
|
1090 |
+
|
1091 |
+
#: modules/flow/view/meta-flow-steps.php:190
|
1092 |
+
msgid "You need a Cartflows Pro version to import Upsell / Downsell"
|
1093 |
+
msgstr ""
|
1094 |
+
|
1095 |
+
#: modules/landing/classes/class-cartflows-landing-meta.php:66
|
1096 |
+
msgid "Landing Page Settings"
|
1097 |
+
msgstr ""
|
1098 |
+
|
1099 |
+
#: modules/landing/classes/class-cartflows-landing-meta.php:159
|
1100 |
+
msgid "Next Step Link"
|
1101 |
+
msgstr ""
|
1102 |
+
|
1103 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:65
|
1104 |
+
msgid "Thank You Page Settings"
|
1105 |
+
msgstr ""
|
1106 |
+
|
1107 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:136
|
1108 |
+
msgid "Thank You Design"
|
1109 |
+
msgstr ""
|
1110 |
+
|
1111 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:142
|
1112 |
+
msgid "Thank You Fields"
|
1113 |
+
msgstr ""
|
1114 |
+
|
1115 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:170
|
1116 |
+
msgid "Order Details"
|
1117 |
+
msgstr ""
|
1118 |
+
|
1119 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:182
|
1120 |
+
msgid "Text"
|
1121 |
+
msgstr ""
|
1122 |
+
|
1123 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:188
|
1124 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:211
|
1125 |
+
msgid "Color"
|
1126 |
+
msgstr ""
|
1127 |
+
|
1128 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:237
|
1129 |
+
msgid "Advanced Options"
|
1130 |
+
msgstr ""
|
1131 |
+
|
1132 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:247
|
1133 |
+
msgid "Container Width (In px)"
|
1134 |
+
msgstr ""
|
1135 |
+
|
1136 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:255
|
1137 |
+
msgid "Section Background Color"
|
1138 |
+
msgstr ""
|
1139 |
+
|
1140 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:269
|
1141 |
+
msgid "Enable Order Overview "
|
1142 |
+
msgstr ""
|
1143 |
+
|
1144 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:277
|
1145 |
+
msgid "Enable Order Details "
|
1146 |
+
msgstr ""
|
1147 |
+
|
1148 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:285
|
1149 |
+
msgid "Enable Billing Details "
|
1150 |
+
msgstr ""
|
1151 |
+
|
1152 |
+
#: modules/thankyou/classes/class-cartflows-thankyou-meta.php:293
|
1153 |
+
msgid "Enable Shipping Details "
|
1154 |
+
msgstr ""
|
1155 |
+
|
1156 |
+
#: modules/widgets/class-cartflows-next-step.php:25
|
1157 |
+
msgid "CartFlows Next Step"
|
1158 |
+
msgstr ""
|
1159 |
+
|
1160 |
+
#: modules/widgets/class-cartflows-next-step.php:27
|
1161 |
+
msgid "Next Step Widgets"
|
1162 |
+
msgstr ""
|
1163 |
+
|
1164 |
+
#: modules/widgets/class-cartflows-next-step.php:107
|
1165 |
+
msgid "New title"
|
1166 |
+
msgstr ""
|
1167 |
+
|
1168 |
+
#: modules/widgets/class-cartflows-next-step.php:124
|
1169 |
+
msgid "Title:"
|
1170 |
+
msgstr ""
|
1171 |
+
|
1172 |
+
#: modules/widgets/class-cartflows-next-step.php:128
|
1173 |
+
msgid "Flow ID:"
|
1174 |
+
msgstr ""
|
1175 |
+
|
1176 |
+
#: modules/widgets/class-cartflows-next-step.php:132
|
1177 |
+
msgid "Step ID:"
|
1178 |
+
msgstr ""
|
1179 |
+
|
1180 |
+
#: woocommerce/template/cart/cart-shipping.php:51
|
1181 |
+
#. Translators: $s shipping destination.
|
1182 |
+
msgid "Estimate for %s."
|
1183 |
+
msgstr ""
|
1184 |
+
|
1185 |
+
#: woocommerce/template/cart/cart-shipping.php:52
|
1186 |
+
msgid "Change address"
|
1187 |
+
msgstr ""
|
1188 |
+
|
1189 |
+
#: woocommerce/template/cart/cart-shipping.php:54
|
1190 |
+
msgid "This is only an estimate. Prices will be updated during checkout."
|
1191 |
+
msgstr ""
|
1192 |
+
|
1193 |
+
#: woocommerce/template/cart/cart-shipping.php:61
|
1194 |
+
msgid "Enter your address to view shipping options."
|
1195 |
+
msgstr ""
|
1196 |
+
|
1197 |
+
#: woocommerce/template/cart/cart-shipping.php:63
|
1198 |
+
msgid ""
|
1199 |
+
"There are no shipping methods available. Please ensure that your address "
|
1200 |
+
"has been entered correctly, or contact us if you need any help."
|
1201 |
+
msgstr ""
|
1202 |
+
|
1203 |
+
#: woocommerce/template/cart/cart-shipping.php:66
|
1204 |
+
#. Translators: $s shipping destination.
|
1205 |
+
msgid "No shipping options were found for %s."
|
1206 |
+
msgstr ""
|
1207 |
+
|
1208 |
+
#: woocommerce/template/cart/cart-shipping.php:67
|
1209 |
+
msgid "Enter a different address"
|
1210 |
+
msgstr ""
|
1211 |
+
|
1212 |
+
#: woocommerce/template/checkout/form-billing.php:27
|
1213 |
+
msgid "Billing & Shipping"
|
1214 |
+
msgstr ""
|
1215 |
+
|
1216 |
+
#: woocommerce/template/checkout/form-billing.php:31
|
1217 |
+
msgid "Billing details"
|
1218 |
+
msgstr ""
|
1219 |
+
|
1220 |
+
#: woocommerce/template/checkout/form-billing.php:59
|
1221 |
+
msgid "Create an account?"
|
1222 |
+
msgstr ""
|
1223 |
+
|
1224 |
+
#: woocommerce/template/checkout/form-checkout.php:26
|
1225 |
+
msgid "You must be logged in to checkout."
|
1226 |
+
msgstr ""
|
1227 |
+
|
1228 |
+
#: woocommerce/template/checkout/form-checkout.php:52
|
1229 |
+
msgid "Your order"
|
1230 |
+
msgstr ""
|
1231 |
+
|
1232 |
+
#: woocommerce/template/checkout/form-coupon.php:26
|
1233 |
+
msgid "Have a coupon?"
|
1234 |
+
msgstr ""
|
1235 |
+
|
1236 |
+
#: woocommerce/template/checkout/form-coupon.php:26
|
1237 |
+
msgid "Click here to enter your code"
|
1238 |
+
msgstr ""
|
1239 |
+
|
1240 |
+
#: woocommerce/template/checkout/form-coupon.php:31
|
1241 |
+
msgid "If you have a coupon code, please apply it below."
|
1242 |
+
msgstr ""
|
1243 |
+
|
1244 |
+
#: woocommerce/template/checkout/form-coupon.php:34
|
1245 |
+
msgid "Coupon code"
|
1246 |
+
msgstr ""
|
1247 |
+
|
1248 |
+
#: woocommerce/template/checkout/form-coupon.php:38
|
1249 |
+
msgid "Apply coupon"
|
1250 |
+
msgstr ""
|
1251 |
+
|
1252 |
+
#: woocommerce/template/checkout/form-login.php:26
|
1253 |
+
msgid "Returning customer?"
|
1254 |
+
msgstr ""
|
1255 |
+
|
1256 |
+
#: woocommerce/template/checkout/form-login.php:26
|
1257 |
+
msgid "Click here to login"
|
1258 |
+
msgstr ""
|
1259 |
+
|
1260 |
+
#: woocommerce/template/checkout/form-login.php:32
|
1261 |
+
msgid ""
|
1262 |
+
"If you have shopped with us before, please enter your details below. If you "
|
1263 |
+
"are a new customer, please proceed to the Billing & Shipping section."
|
1264 |
+
msgstr ""
|
1265 |
+
|
1266 |
+
#: woocommerce/template/checkout/review-order.php:26
|
1267 |
+
msgid "Product"
|
1268 |
+
msgstr ""
|
1269 |
+
|
1270 |
+
#: woocommerce/template/checkout/review-order.php:27
|
1271 |
+
#: woocommerce/template/checkout/review-order.php:106
|
1272 |
+
msgid "Total"
|
1273 |
+
msgstr ""
|
1274 |
+
|
1275 |
+
#: woocommerce/template/checkout/review-order.php:59
|
1276 |
+
msgid "Subtotal"
|
1277 |
+
msgstr ""
|
1278 |
+
|
1279 |
+
#: woocommerce/template/checkout/thankyou.php:30
|
1280 |
+
msgid ""
|
1281 |
+
"Unfortunately your order cannot be processed as the originating "
|
1282 |
+
"bank/merchant has declined your transaction. Please attempt your purchase "
|
1283 |
+
"again."
|
1284 |
+
msgstr ""
|
1285 |
+
|
1286 |
+
#: woocommerce/template/checkout/thankyou.php:33
|
1287 |
+
msgid "Pay"
|
1288 |
+
msgstr ""
|
1289 |
+
|
1290 |
+
#: woocommerce/template/checkout/thankyou.php:35
|
1291 |
+
msgid "My account"
|
1292 |
+
msgstr ""
|
1293 |
+
|
1294 |
+
#: woocommerce/template/checkout/thankyou.php:41
|
1295 |
+
#: woocommerce/template/checkout/thankyou.php:83
|
1296 |
+
msgid "Thank you. Your order has been received."
|
1297 |
+
msgstr ""
|
1298 |
+
|
1299 |
+
#: woocommerce/template/checkout/thankyou.php:46
|
1300 |
+
msgid "Order number:"
|
1301 |
+
msgstr ""
|
1302 |
+
|
1303 |
+
#: woocommerce/template/checkout/thankyou.php:51
|
1304 |
+
msgid "Date:"
|
1305 |
+
msgstr ""
|
1306 |
+
|
1307 |
+
#: woocommerce/template/checkout/thankyou.php:57
|
1308 |
+
msgid "Email:"
|
1309 |
+
msgstr ""
|
1310 |
+
|
1311 |
+
#: woocommerce/template/checkout/thankyou.php:63
|
1312 |
+
msgid "Total:"
|
1313 |
+
msgstr ""
|
1314 |
+
|
1315 |
+
#: woocommerce/template/checkout/thankyou.php:69
|
1316 |
+
msgid "Payment method:"
|
1317 |
+
msgstr ""
|
1318 |
+
|
1319 |
+
#. Plugin Name of the plugin/theme
|
1320 |
+
msgid "CartFlows"
|
1321 |
+
msgstr ""
|
1322 |
+
|
1323 |
+
#. Author URI of the plugin/theme
|
1324 |
+
msgid "https://cartflows.com/"
|
1325 |
+
msgstr ""
|
1326 |
+
|
1327 |
+
#. Description of the plugin/theme
|
1328 |
+
msgid "Create beautiful checkout pages & sales flows for WooCommerce."
|
1329 |
+
msgstr ""
|
1330 |
+
|
1331 |
+
#. Author of the plugin/theme
|
1332 |
+
msgid "CartFlows Inc"
|
1333 |
+
msgstr ""
|
1334 |
+
|
1335 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:55
|
1336 |
+
msgctxt "flow general name"
|
1337 |
+
msgid "Flows"
|
1338 |
+
msgstr ""
|
1339 |
+
|
1340 |
+
#: modules/flow/classes/class-cartflows-flow-post-type.php:56
|
1341 |
+
msgctxt "flow singular name"
|
1342 |
+
msgid "Flow"
|
1343 |
+
msgstr ""
|
1344 |
+
|
1345 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:138
|
1346 |
+
msgctxt "flow step general name"
|
1347 |
+
msgid "Steps"
|
1348 |
+
msgstr ""
|
1349 |
+
|
1350 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:139
|
1351 |
+
msgctxt "flow step singular name"
|
1352 |
+
msgid "Step"
|
1353 |
+
msgstr ""
|
1354 |
+
|
1355 |
+
#: modules/flow/classes/class-cartflows-step-post-type.php:258
|
1356 |
+
msgctxt "cartflows"
|
1357 |
+
msgid "Template for Page Builders"
|
1358 |
msgstr ""
|
modules/checkout/classes/class-cartflows-checkout-markup.php
CHANGED
@@ -1,1109 +1,1109 @@
|
|
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_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
|
64 |
-
add_action( 'wp_ajax_nopriv_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
|
65 |
-
|
66 |
-
add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
|
67 |
-
|
68 |
-
/* Global Checkout */
|
69 |
-
add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Display all WooCommerce notices.
|
74 |
-
*
|
75 |
-
* @since 1.1.5
|
76 |
-
*/
|
77 |
-
function display_woo_notices() {
|
78 |
-
|
79 |
-
if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
|
80 |
-
woocommerce_output_all_notices();
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Redirect from default to the global checkout page
|
87 |
-
*
|
88 |
-
* @since 1.0.0
|
89 |
-
*/
|
90 |
-
function global_checkout_template_redirect() {
|
91 |
-
|
92 |
-
if ( ! is_checkout() ) {
|
93 |
-
return;
|
94 |
-
}
|
95 |
-
|
96 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
97 |
-
return;
|
98 |
-
}
|
99 |
-
|
100 |
-
// redirect only from any non HC checkout pages.
|
101 |
-
$order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
|
102 |
-
$order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
|
103 |
-
|
104 |
-
$common = Cartflows_Helper::get_common_settings();
|
105 |
-
|
106 |
-
$global_checkout = $common['global_checkout'];
|
107 |
-
|
108 |
-
if (
|
109 |
-
// ignore on order-pay.
|
110 |
-
false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
|
111 |
-
// ignore on TY page.
|
112 |
-
false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
|
113 |
-
) {
|
114 |
-
|
115 |
-
if ( '' !== $global_checkout ) {
|
116 |
-
|
117 |
-
$link = get_permalink( $global_checkout );
|
118 |
-
|
119 |
-
if ( ! empty( $link ) ) {
|
120 |
-
|
121 |
-
wp_redirect( $link );
|
122 |
-
die();
|
123 |
-
}
|
124 |
-
}
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Check for checkout flag
|
130 |
-
*
|
131 |
-
* @param bool $is_checkout is checkout.
|
132 |
-
*
|
133 |
-
* @return bool
|
134 |
-
*/
|
135 |
-
function woo_checkout_flag( $is_checkout ) {
|
136 |
-
|
137 |
-
if ( ! is_admin() ) {
|
138 |
-
|
139 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
140 |
-
|
141 |
-
$is_checkout = true;
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
return $is_checkout;
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Render checkout shortcode markup.
|
150 |
-
*
|
151 |
-
* @param array $atts attributes.
|
152 |
-
* @return string
|
153 |
-
*/
|
154 |
-
function checkout_shortcode_markup( $atts ) {
|
155 |
-
|
156 |
-
if ( ! function_exists( 'wc_print_notices' ) ) {
|
157 |
-
return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
|
158 |
-
}
|
159 |
-
|
160 |
-
$atts = shortcode_atts(
|
161 |
-
array(
|
162 |
-
'id' => 0,
|
163 |
-
),
|
164 |
-
$atts
|
165 |
-
);
|
166 |
-
|
167 |
-
$checkout_id = intval( $atts['id'] );
|
168 |
-
|
169 |
-
if ( empty( $checkout_id ) ) {
|
170 |
-
|
171 |
-
if ( ! _is_wcf_checkout_type() ) {
|
172 |
-
|
173 |
-
return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
|
174 |
-
}
|
175 |
-
|
176 |
-
global $post;
|
177 |
-
|
178 |
-
$checkout_id = intval( $post->ID );
|
179 |
-
}
|
180 |
-
|
181 |
-
$output = '';
|
182 |
-
|
183 |
-
ob_start();
|
184 |
-
|
185 |
-
do_action( 'cartflows_checkout_form_before', $checkout_id );
|
186 |
-
|
187 |
-
$checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
|
188 |
-
|
189 |
-
$template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
|
190 |
-
|
191 |
-
$template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
|
192 |
-
|
193 |
-
if ( file_exists( $template_layout ) ) {
|
194 |
-
include $template_layout;
|
195 |
-
} else {
|
196 |
-
include $template_default;
|
197 |
-
}
|
198 |
-
|
199 |
-
$output .= ob_get_clean();
|
200 |
-
|
201 |
-
return $output;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Configure Cart Data.
|
206 |
-
*
|
207 |
-
* @since 1.0.0
|
208 |
-
*
|
209 |
-
* @return void
|
210 |
-
*/
|
211 |
-
function preconfigured_cart_data() {
|
212 |
-
|
213 |
-
if ( is_admin() ) {
|
214 |
-
return;
|
215 |
-
}
|
216 |
-
|
217 |
-
global $post;
|
218 |
-
|
219 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
220 |
-
|
221 |
-
if ( wp_doing_ajax() ) {
|
222 |
-
|
223 |
-
return;
|
224 |
-
} else {
|
225 |
-
|
226 |
-
if ( _is_wcf_checkout_type() ) {
|
227 |
-
$checkout_id = $post->ID;
|
228 |
-
} else {
|
229 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
230 |
-
}
|
231 |
-
|
232 |
-
do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
|
233 |
-
|
234 |
-
$flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
|
235 |
-
|
236 |
-
if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
|
237 |
-
$products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
|
238 |
-
} else {
|
239 |
-
$products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
|
240 |
-
}
|
241 |
-
|
242 |
-
if ( ! is_array( $products ) ) {
|
243 |
-
|
244 |
-
if ( 'dummy' === $products ) {
|
245 |
-
|
246 |
-
$args = array(
|
247 |
-
'posts_per_page' => 1,
|
248 |
-
'orderby' => 'rand',
|
249 |
-
'post_type' => 'product',
|
250 |
-
'meta_query' => array(
|
251 |
-
// Exclude out of stock products.
|
252 |
-
array(
|
253 |
-
'key' => '_stock_status',
|
254 |
-
'value' => 'outofstock',
|
255 |
-
'compare' => 'NOT IN',
|
256 |
-
),
|
257 |
-
),
|
258 |
-
'tax_query' => array(
|
259 |
-
array(
|
260 |
-
'taxonomy' => 'product_type',
|
261 |
-
'field' => 'slug',
|
262 |
-
'terms' => 'simple',
|
263 |
-
),
|
264 |
-
),
|
265 |
-
);
|
266 |
-
|
267 |
-
$random_product = get_posts( $args );
|
268 |
-
|
269 |
-
if ( isset( $random_product[0]->ID ) ) {
|
270 |
-
$products = array(
|
271 |
-
array(
|
272 |
-
'product' => $random_product[0]->ID,
|
273 |
-
),
|
274 |
-
);
|
275 |
-
} else {
|
276 |
-
return;
|
277 |
-
}
|
278 |
-
} else {
|
279 |
-
return;
|
280 |
-
}
|
281 |
-
}
|
282 |
-
|
283 |
-
if ( is_array( $products ) && count( $products ) < 1 ) {
|
284 |
-
|
285 |
-
return;
|
286 |
-
}
|
287 |
-
/* Empty the current cart */
|
288 |
-
WC()->cart->empty_cart();
|
289 |
-
|
290 |
-
/* Set customer session if not set */
|
291 |
-
if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
|
292 |
-
WC()->session->set_customer_session_cookie( true );
|
293 |
-
}
|
294 |
-
|
295 |
-
$cart_product_count = 0;
|
296 |
-
|
297 |
-
foreach ( $products as $index => $data ) {
|
298 |
-
|
299 |
-
if ( ! isset( $data['product'] ) ) {
|
300 |
-
return;
|
301 |
-
}
|
302 |
-
|
303 |
-
if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
|
304 |
-
break;
|
305 |
-
}
|
306 |
-
|
307 |
-
$product_id = $data['product'];
|
308 |
-
$_product = wc_get_product( $product_id );
|
309 |
-
|
310 |
-
if ( ! empty( $_product ) ) {
|
311 |
-
|
312 |
-
$quantity = 1;
|
313 |
-
|
314 |
-
if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
|
315 |
-
|
316 |
-
if ( $_product->is_type( 'variable' ) ) {
|
317 |
-
|
318 |
-
$default_attributes = $_product->get_default_attributes();
|
319 |
-
|
320 |
-
if ( ! empty( $default_attributes ) ) {
|
321 |
-
|
322 |
-
foreach ( $_product->get_children() as $variation_id ) {
|
323 |
-
|
324 |
-
$single_variation = new WC_Product_Variation( $variation_id );
|
325 |
-
|
326 |
-
if ( $default_attributes == $single_variation->get_attributes() ) {
|
327 |
-
WC()->cart->add_to_cart( $variation_id, $quantity );
|
328 |
-
$cart_product_count++;
|
329 |
-
}
|
330 |
-
}
|
331 |
-
} else {
|
332 |
-
|
333 |
-
$product_childrens = $_product->get_children();
|
334 |
-
|
335 |
-
if ( isset( $product_childrens[0] ) ) {
|
336 |
-
WC()->cart->add_to_cart( $product_childrens[0], $quantity );
|
337 |
-
$cart_product_count++;
|
338 |
-
} else {
|
339 |
-
echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
|
340 |
-
}
|
341 |
-
}
|
342 |
-
} else {
|
343 |
-
WC()->cart->add_to_cart( $product_id, $quantity );
|
344 |
-
$cart_product_count++;
|
345 |
-
}
|
346 |
-
} else {
|
347 |
-
|
348 |
-
echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
|
349 |
-
// WC()->cart->add_to_cart( $product_id, $quantity );.
|
350 |
-
}
|
351 |
-
}
|
352 |
-
}
|
353 |
-
|
354 |
-
do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
|
355 |
-
do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
|
356 |
-
}
|
357 |
-
}
|
358 |
-
}
|
359 |
-
|
360 |
-
/**
|
361 |
-
* Load shortcode data.
|
362 |
-
*
|
363 |
-
* @return void
|
364 |
-
*/
|
365 |
-
function shortcode_load_data() {
|
366 |
-
|
367 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
368 |
-
|
369 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
|
370 |
-
|
371 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 );
|
372 |
-
|
373 |
-
/* Show notices if cart has errors */
|
374 |
-
add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
|
375 |
-
|
376 |
-
add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
|
377 |
-
|
378 |
-
add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
|
379 |
-
|
380 |
-
// Outputting the hidden field in checkout page.
|
381 |
-
add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
382 |
-
add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
383 |
-
|
384 |
-
remove_all_actions( 'woocommerce_checkout_billing' );
|
385 |
-
remove_all_actions( 'woocommerce_checkout_shipping' );
|
386 |
-
|
387 |
-
// Hook in actions once.
|
388 |
-
add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
|
389 |
-
add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
|
390 |
-
|
391 |
-
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
|
392 |
-
|
393 |
-
add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
|
394 |
-
|
395 |
-
add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
|
396 |
-
|
397 |
-
global $post;
|
398 |
-
|
399 |
-
if ( _is_wcf_checkout_type() ) {
|
400 |
-
$checkout_id = $post->ID;
|
401 |
-
} else {
|
402 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
403 |
-
}
|
404 |
-
|
405 |
-
do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
|
406 |
-
}
|
407 |
-
}
|
408 |
-
|
409 |
-
/**
|
410 |
-
* Render checkout ID hidden field.
|
411 |
-
*
|
412 |
-
* @param array $checkout checkout session data.
|
413 |
-
* @return void
|
414 |
-
*/
|
415 |
-
function checkout_shortcode_post_id( $checkout ) {
|
416 |
-
|
417 |
-
global $post;
|
418 |
-
|
419 |
-
if ( _is_wcf_checkout_type() ) {
|
420 |
-
$checkout_id = $post->ID;
|
421 |
-
} else {
|
422 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
423 |
-
}
|
424 |
-
|
425 |
-
$flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
|
426 |
-
|
427 |
-
echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
|
428 |
-
echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* Load shortcode scripts.
|
433 |
-
*
|
434 |
-
* @return void
|
435 |
-
*/
|
436 |
-
function shortcode_scripts() {
|
437 |
-
|
438 |
-
wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
|
439 |
-
wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
|
440 |
-
|
441 |
-
wp_enqueue_script(
|
442 |
-
'wcf-checkout-template',
|
443 |
-
CARTFLOWS_URL . 'assets/js/checkout-template.js',
|
444 |
-
array( 'jquery' ),
|
445 |
-
CARTFLOWS_VER,
|
446 |
-
true
|
447 |
-
);
|
448 |
-
|
449 |
-
do_action( 'cartflows_checkout_scripts' );
|
450 |
-
|
451 |
-
$style = $this->generate_style();
|
452 |
-
|
453 |
-
wp_add_inline_style( 'wcf-checkout-template', $style );
|
454 |
-
|
455 |
-
}
|
456 |
-
|
457 |
-
/**
|
458 |
-
* Load compatibility scripts.
|
459 |
-
*
|
460 |
-
* @return void
|
461 |
-
*/
|
462 |
-
function compatibility_scripts() {
|
463 |
-
|
464 |
-
global $post;
|
465 |
-
|
466 |
-
if ( _is_wcf_checkout_type() ) {
|
467 |
-
$checkout_id = $post->ID;
|
468 |
-
} else {
|
469 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
470 |
-
}
|
471 |
-
|
472 |
-
// Add DIVI Compatibility css if DIVI theme is enabled.
|
473 |
-
if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ||
|
474 |
-
Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id )
|
475 |
-
) {
|
476 |
-
wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
|
477 |
-
wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
|
478 |
-
}
|
479 |
-
|
480 |
-
// Add Flatsome Compatibility css if Flatsome theme is enabled.
|
481 |
-
if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
|
482 |
-
wp_enqueue_style( 'wcf-checkout-template-flatsome', CARTFLOWS_URL . 'assets/css/checkout-template-flatsome.css', '', CARTFLOWS_VER );
|
483 |
-
wp_style_add_data( 'wcf-checkout-template-flatsome', 'rtl', 'replace' );
|
484 |
-
}
|
485 |
-
|
486 |
-
// Add The7 Compatibility css if The7 theme is enabled.
|
487 |
-
if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) {
|
488 |
-
wp_enqueue_style( 'wcf-checkout-template-the-seven', CARTFLOWS_URL . 'assets/css/checkout-template-the-seven.css', '', CARTFLOWS_VER );
|
489 |
-
wp_style_add_data( 'wcf-checkout-template-the-seven', 'rtl', 'replace' );
|
490 |
-
}
|
491 |
-
}
|
492 |
-
|
493 |
-
/**
|
494 |
-
* Generate styles.
|
495 |
-
*
|
496 |
-
* @return string
|
497 |
-
*/
|
498 |
-
function generate_style() {
|
499 |
-
|
500 |
-
global $post;
|
501 |
-
|
502 |
-
if ( _is_wcf_checkout_type() ) {
|
503 |
-
$checkout_id = $post->ID;
|
504 |
-
} else {
|
505 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
506 |
-
}
|
507 |
-
|
508 |
-
CartFlows_Font_Families::render_fonts( $checkout_id );
|
509 |
-
|
510 |
-
$primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
|
511 |
-
|
512 |
-
$base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
|
513 |
-
|
514 |
-
$header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
|
515 |
-
|
516 |
-
/*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
|
517 |
-
$r = '';
|
518 |
-
$g = '';
|
519 |
-
$b = '';
|
520 |
-
|
521 |
-
$field_tb_padding = '';
|
522 |
-
$field_lr_padding = '';
|
523 |
-
|
524 |
-
$field_heading_color = '';
|
525 |
-
$field_color = '';
|
526 |
-
$field_bg_color = '';
|
527 |
-
$field_border_color = '';
|
528 |
-
$field_label_color = '';
|
529 |
-
$submit_tb_padding = '';
|
530 |
-
$submit_lr_padding = '';
|
531 |
-
$hl_bg_color = '';
|
532 |
-
$field_input_size = '';
|
533 |
-
$box_border_color = '';
|
534 |
-
$section_bg_color = '';
|
535 |
-
$submit_button_height = '';
|
536 |
-
$submit_color = '';
|
537 |
-
$submit_bg_color = $primary_color;
|
538 |
-
$submit_border_color = $primary_color;
|
539 |
-
|
540 |
-
$submit_hover_color = '';
|
541 |
-
$submit_bg_hover_color = $primary_color;
|
542 |
-
$submit_border_hover_color = $primary_color;
|
543 |
-
|
544 |
-
$section_heading_color = '';
|
545 |
-
|
546 |
-
$is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
|
547 |
-
|
548 |
-
$button_font_family = '';
|
549 |
-
$button_font_weight = '';
|
550 |
-
$input_font_family = '';
|
551 |
-
$input_font_weight = '';
|
552 |
-
$heading_font_family = '';
|
553 |
-
$heading_font_weight = '';
|
554 |
-
$base_font_family = $base_font_family;
|
555 |
-
/*$base_font_weight = $base_font_weight;*/
|
556 |
-
|
557 |
-
if ( 'yes' == $is_advance_option ) {
|
558 |
-
|
559 |
-
/**
|
560 |
-
* Get Font Family and Font Weight weight values
|
561 |
-
*/
|
562 |
-
$section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
|
563 |
-
|
564 |
-
$heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
|
565 |
-
$heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
|
566 |
-
$section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
|
567 |
-
$button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
|
568 |
-
$button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
|
569 |
-
$input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
|
570 |
-
$input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
|
571 |
-
$field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
|
572 |
-
$field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
|
573 |
-
$field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
|
574 |
-
|
575 |
-
$field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
|
576 |
-
|
577 |
-
$field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
|
578 |
-
|
579 |
-
$field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
|
580 |
-
|
581 |
-
$field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
|
582 |
-
|
583 |
-
$field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
|
584 |
-
|
585 |
-
$submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
|
586 |
-
|
587 |
-
$submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
|
588 |
-
|
589 |
-
$submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
|
590 |
-
|
591 |
-
$submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
|
592 |
-
|
593 |
-
$submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
|
594 |
-
|
595 |
-
$submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
|
596 |
-
|
597 |
-
$submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
|
598 |
-
|
599 |
-
$submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
|
600 |
-
|
601 |
-
$hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
|
602 |
-
|
603 |
-
$box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
|
604 |
-
|
605 |
-
$submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
|
606 |
-
|
607 |
-
/**
|
608 |
-
* Get font values
|
609 |
-
*/
|
610 |
-
|
611 |
-
if ( 'custom' == $submit_button_height ) {
|
612 |
-
$submit_button_height = '38px';
|
613 |
-
}
|
614 |
-
|
615 |
-
if ( 'custom' == $field_input_size ) {
|
616 |
-
$field_input_size = '38px';
|
617 |
-
}
|
618 |
-
}
|
619 |
-
if ( isset( $primary_color ) ) {
|
620 |
-
|
621 |
-
list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
|
622 |
-
}
|
623 |
-
$output = "
|
624 |
-
.wcf-embed-checkout-form .wcf-checkout-header-image img{
|
625 |
-
width: {$header_logo_width}px;
|
626 |
-
}
|
627 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
|
628 |
-
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
|
629 |
-
color: {$primary_color};
|
630 |
-
}
|
631 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
|
632 |
-
background-color: {$primary_color};
|
633 |
-
}
|
634 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
|
635 |
-
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
|
636 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
|
637 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
|
638 |
-
border-color: {$primary_color};
|
639 |
-
box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
|
640 |
-
}
|
641 |
-
.wcf-embed-checkout-form .woocommerce-checkout label{
|
642 |
-
color: {$field_label_color};
|
643 |
-
}
|
644 |
-
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
|
645 |
-
background-color: {$hl_bg_color};
|
646 |
-
font-family: {$input_font_family};
|
647 |
-
font-weight: {$input_font_weight};
|
648 |
-
}
|
649 |
-
|
650 |
-
.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
|
651 |
-
.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
|
652 |
-
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
|
653 |
-
{
|
654 |
-
border-color: {$hl_bg_color};
|
655 |
-
border-right-color: transparent;
|
656 |
-
border-left-color: transparent;
|
657 |
-
border-top-color: transparent;
|
658 |
-
position: absolute;
|
659 |
-
}
|
660 |
-
|
661 |
-
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
|
662 |
-
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
|
663 |
-
font-family: {$input_font_family};
|
664 |
-
font-weight: {$input_font_weight};
|
665 |
-
}
|
666 |
-
|
667 |
-
.wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
|
668 |
-
.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
|
669 |
-
.wcf-embed-checkout-form .woocommerce form .form-row textarea,
|
670 |
-
.wcf-embed-checkout-form .select2-container--default .select2-selection--single {
|
671 |
-
color: {$field_color};
|
672 |
-
background: {$field_bg_color};
|
673 |
-
border-color: {$field_border_color};
|
674 |
-
padding-top: {$field_tb_padding}px;
|
675 |
-
padding-bottom: {$field_tb_padding}px;
|
676 |
-
padding-left: {$field_lr_padding}px;
|
677 |
-
padding-right: {$field_lr_padding}px;
|
678 |
-
min-height: {$field_input_size};
|
679 |
-
font-family: {$input_font_family};
|
680 |
-
font-weight: {$input_font_weight};
|
681 |
-
}
|
682 |
-
|
683 |
-
.wcf-embed-checkout-form .woocommerce .col2-set .col-1,
|
684 |
-
.wcf-embed-checkout-form .woocommerce .col2-set .col-2,
|
685 |
-
.wcf-embed-checkout-form .woocommerce-checkout .shop_table,
|
686 |
-
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
|
687 |
-
.wcf-embed-checkout-form .woocommerce-checkout #payment,
|
688 |
-
.wcf-embed-checkout-form .woocommerce form.checkout_coupon
|
689 |
-
{
|
690 |
-
background-color: {$section_bg_color};
|
691 |
-
border-color: {$box_border_color};
|
692 |
-
font-family: {$input_font_family};
|
693 |
-
font-weight: {$input_font_weight};
|
694 |
-
}
|
695 |
-
|
696 |
-
.woocommerce table.shop_table th{
|
697 |
-
color: {$field_label_color};
|
698 |
-
}
|
699 |
-
/*.wcf-embed-checkout-form .woocommerce .woocommerce-info,
|
700 |
-
.wcf-embed-checkout-form .woocommerce-message{
|
701 |
-
border-top-color: {$primary_color};
|
702 |
-
background-color: {$hl_bg_color};
|
703 |
-
}*/
|
704 |
-
.wcf-embed-checkout-form .woocommerce a{
|
705 |
-
color: {$primary_color};
|
706 |
-
}
|
707 |
-
.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
|
708 |
-
color: {$field_color};
|
709 |
-
}
|
710 |
-
.wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
|
711 |
-
color: {$field_color};
|
712 |
-
}
|
713 |
-
.wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
|
714 |
-
color: {$field_color};
|
715 |
-
}
|
716 |
-
.wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
|
717 |
-
color: {$field_color};
|
718 |
-
}
|
719 |
-
.wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
|
720 |
-
color: {$field_color};
|
721 |
-
}
|
722 |
-
.wcf-embed-checkout-form .woocommerce form p.form-row label {
|
723 |
-
color: {$field_label_color};
|
724 |
-
font-family: {$input_font_family};
|
725 |
-
font-weight: {$input_font_weight};
|
726 |
-
}
|
727 |
-
.wcf-embed-checkout-form .woocommerce #order_review button {
|
728 |
-
color: {$submit_color};
|
729 |
-
background: {$submit_bg_color};
|
730 |
-
padding-top: {$submit_tb_padding}px;
|
731 |
-
padding-bottom: {$submit_tb_padding}px;
|
732 |
-
padding-left: {$submit_lr_padding}px;
|
733 |
-
padding-right: {$submit_lr_padding}px;
|
734 |
-
border-color: {$submit_border_color};
|
735 |
-
min-height: {$submit_button_height};
|
736 |
-
font-family: {$button_font_family};
|
737 |
-
font-weight: {$button_font_weight};
|
738 |
-
}
|
739 |
-
.wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
|
740 |
-
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
|
741 |
-
background: {$submit_bg_color};
|
742 |
-
border: 1px {$submit_border_color} solid;
|
743 |
-
color: {$submit_color};
|
744 |
-
min-height: {$submit_button_height};
|
745 |
-
font-family: {$button_font_family};
|
746 |
-
font-weight: {$button_font_weight};
|
747 |
-
}
|
748 |
-
.wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
|
749 |
-
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
|
750 |
-
.wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
|
751 |
-
.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
|
752 |
-
color: {$submit_hover_color};
|
753 |
-
background-color: {$submit_bg_hover_color};
|
754 |
-
border-color: {$submit_border_hover_color};
|
755 |
-
}
|
756 |
-
.wcf-embed-checkout-form .woocommerce h3,
|
757 |
-
.wcf-embed-checkout-form .woocommerce h3 span,
|
758 |
-
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
|
759 |
-
color: {$section_heading_color};
|
760 |
-
font-family: {$heading_font_family};
|
761 |
-
font-weight: {$heading_font_weight};
|
762 |
-
}
|
763 |
-
.wcf-embed-checkout-form .woocommerce-info::before,
|
764 |
-
.wcf-embed-checkout-form .woocommerce-message::before{
|
765 |
-
color: {$primary_color};
|
766 |
-
}
|
767 |
-
.wcf-embed-checkout-form{
|
768 |
-
font-family: {$base_font_family};
|
769 |
-
}";
|
770 |
-
|
771 |
-
return $output;
|
772 |
-
}
|
773 |
-
|
774 |
-
/**
|
775 |
-
* Get ajax end points.
|
776 |
-
*
|
777 |
-
* @param string $endpoint_url end point URL.
|
778 |
-
* @return string
|
779 |
-
*/
|
780 |
-
function get_ajax_endpoint( $endpoint_url ) {
|
781 |
-
|
782 |
-
global $post;
|
783 |
-
|
784 |
-
if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
|
785 |
-
|
786 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
787 |
-
|
788 |
-
if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
|
789 |
-
|
790 |
-
$query_args = array(
|
791 |
-
'wc-ajax' => '%%endpoint%%',
|
792 |
-
);
|
793 |
-
|
794 |
-
$uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
|
795 |
-
$uri = $uri[0];
|
796 |
-
|
797 |
-
$endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
|
798 |
-
}
|
799 |
-
}
|
800 |
-
}
|
801 |
-
|
802 |
-
return $endpoint_url;
|
803 |
-
}
|
804 |
-
|
805 |
-
|
806 |
-
/**
|
807 |
-
* Save checkout fields.
|
808 |
-
*
|
809 |
-
* @param int $order_id order id.
|
810 |
-
* @param array $posted posted data.
|
811 |
-
* @return void
|
812 |
-
*/
|
813 |
-
function save_checkout_fields( $order_id, $posted ) {
|
814 |
-
|
815 |
-
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
816 |
-
|
817 |
-
$checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
|
818 |
-
|
819 |
-
update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
|
820 |
-
|
821 |
-
/*
|
822 |
-
Custom Field To Do
|
823 |
-
$custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
|
824 |
-
|
825 |
-
if ( 'yes' === $custom_fields ) {
|
826 |
-
|
827 |
-
$billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
|
828 |
-
|
829 |
-
foreach ( $billing_fields as $field => $data ) {
|
830 |
-
|
831 |
-
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
832 |
-
|
833 |
-
if ( isset( $_POST[ $field ] ) ) {
|
834 |
-
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
835 |
-
}
|
836 |
-
}
|
837 |
-
}
|
838 |
-
|
839 |
-
$shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
|
840 |
-
|
841 |
-
foreach ( $shipping_fields as $field => $data ) {
|
842 |
-
|
843 |
-
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
844 |
-
|
845 |
-
if ( isset( $_POST[ $field ] ) ) {
|
846 |
-
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
847 |
-
}
|
848 |
-
}
|
849 |
-
}
|
850 |
-
}
|
851 |
-
*/
|
852 |
-
if ( isset( $_POST['_wcf_flow_id'] ) ) {
|
853 |
-
|
854 |
-
$checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
|
855 |
-
|
856 |
-
update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
|
857 |
-
}
|
858 |
-
}
|
859 |
-
|
860 |
-
}
|
861 |
-
|
862 |
-
/**
|
863 |
-
* Enable Logo In Header Of Checkout Page
|
864 |
-
*
|
865 |
-
* @return void
|
866 |
-
*/
|
867 |
-
function enable_logo_in_header() {
|
868 |
-
global $post;
|
869 |
-
|
870 |
-
if ( _is_wcf_checkout_type() ) {
|
871 |
-
$checkout_id = $post->ID;
|
872 |
-
} else {
|
873 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
874 |
-
}
|
875 |
-
|
876 |
-
$header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
|
877 |
-
$add_image_markup = '';
|
878 |
-
|
879 |
-
if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
|
880 |
-
$add_image_markup = '<div class="wcf-checkout-header-image">';
|
881 |
-
$add_image_markup .= '<img src="' . $header_logo_image . '" />';
|
882 |
-
$add_image_markup .= '</div>';
|
883 |
-
}
|
884 |
-
|
885 |
-
echo $add_image_markup;
|
886 |
-
}
|
887 |
-
|
888 |
-
/**
|
889 |
-
* Add text to the bootom of the checkout page.
|
890 |
-
*
|
891 |
-
* @return void
|
892 |
-
*/
|
893 |
-
function show_cartflows_copyright_message() {
|
894 |
-
$output_string = '';
|
895 |
-
|
896 |
-
$output_string .= '<div class="wcf-footer-primary">';
|
897 |
-
$output_string .= '<div class="wcf-footer-content">';
|
898 |
-
$output_string .= '<p class="wcf-footer-message">';
|
899 |
-
$output_string .= 'Checkout powered by CartFlows';
|
900 |
-
$output_string .= '</p>';
|
901 |
-
$output_string .= '</div>';
|
902 |
-
$output_string .= '</div>';
|
903 |
-
|
904 |
-
echo $output_string;
|
905 |
-
}
|
906 |
-
|
907 |
-
/**
|
908 |
-
* Redirect users to our checkout if hidden param
|
909 |
-
*
|
910 |
-
* @param string $redirect redirect url.
|
911 |
-
* @param object $user user.
|
912 |
-
* @return string
|
913 |
-
*/
|
914 |
-
function after_login_redirect( $redirect, $user ) {
|
915 |
-
|
916 |
-
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
917 |
-
|
918 |
-
$checkout_id = intval( $_POST['_wcf_checkout_id'] );
|
919 |
-
|
920 |
-
$redirect = get_permalink( $checkout_id );
|
921 |
-
}
|
922 |
-
|
923 |
-
return $redirect;
|
924 |
-
}
|
925 |
-
|
926 |
-
/**
|
927 |
-
* Display coupon code field after review order fields.
|
928 |
-
*/
|
929 |
-
function display_custom_coupon_field() {
|
930 |
-
|
931 |
-
$coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
|
932 |
-
|
933 |
-
if ( ! $coupon_enabled ) {
|
934 |
-
return;
|
935 |
-
}
|
936 |
-
|
937 |
-
ob_start();
|
938 |
-
|
939 |
-
?>
|
940 |
-
<div class="wcf-custom-coupon-field">
|
941 |
-
<div class="wcf-coupon-col-1">
|
942 |
-
<span>
|
943 |
-
<input type="text" name="coupon_code" class="input-text cf-coupon-code-input" placeholder="<?php echo $this->coupon_field_placeholder(); ?>" id="coupon_code" value="">
|
944 |
-
</span>
|
945 |
-
</div>
|
946 |
-
<div class="wcf-coupon-col-2">
|
947 |
-
<span>
|
948 |
-
<button type="button" class="button cf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php echo $this->coupon_button_text(); ?></button>
|
949 |
-
</span>
|
950 |
-
</div>
|
951 |
-
</div>
|
952 |
-
|
953 |
-
<?php
|
954 |
-
|
955 |
-
echo ob_get_clean();
|
956 |
-
}
|
957 |
-
|
958 |
-
/**
|
959 |
-
* Apply filter to change the placeholder text of coupon field.
|
960 |
-
*
|
961 |
-
* @return string
|
962 |
-
*/
|
963 |
-
function coupon_field_placeholder() {
|
964 |
-
return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
|
965 |
-
}
|
966 |
-
|
967 |
-
/**
|
968 |
-
* Apply filter to change the button text of coupon field.
|
969 |
-
*
|
970 |
-
* @return string
|
971 |
-
*/
|
972 |
-
function coupon_button_text() {
|
973 |
-
return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
|
974 |
-
}
|
975 |
-
|
976 |
-
/**
|
977 |
-
* Apply coupon on submit of custom coupon form.
|
978 |
-
*/
|
979 |
-
function apply_coupon() {
|
980 |
-
|
981 |
-
check_ajax_referer( 'cf-apply-coupon', 'security' );
|
982 |
-
|
983 |
-
$result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
|
984 |
-
|
985 |
-
echo json_encode( $result );
|
986 |
-
die();
|
987 |
-
}
|
988 |
-
|
989 |
-
/**
|
990 |
-
* Added ajax nonce to localize variable.
|
991 |
-
*
|
992 |
-
* @param array $vars localize variables.
|
993 |
-
*/
|
994 |
-
function add_localize_vars( $vars ) {
|
995 |
-
|
996 |
-
$vars['cf_validate_coupon_nonce'] = wp_create_nonce( 'cf-apply-coupon' );
|
997 |
-
|
998 |
-
$vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
|
999 |
-
|
1000 |
-
return $vars;
|
1001 |
-
}
|
1002 |
-
|
1003 |
-
/**
|
1004 |
-
* Add custom class to the fields to change the UI to three column.
|
1005 |
-
*
|
1006 |
-
* @param array $fields fields.
|
1007 |
-
*/
|
1008 |
-
function add_three_column_layout_fields( $fields ) {
|
1009 |
-
|
1010 |
-
if ( empty( $fields['billing']['billing_address_2'] ) ) {
|
1011 |
-
|
1012 |
-
if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
|
1013 |
-
$fields['billing']['billing_address_1']['class'][] = 'form-row-full';
|
1014 |
-
}
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
if ( ! empty( $fields['billing']['billing_company'] ) ) {
|
1018 |
-
|
1019 |
-
if ( isset( $fields['billing']['billing_company'] ) && is_array( $fields['billing']['billing_company'] ) ) {
|
1020 |
-
$fields['billing']['billing_company']['class'][] = 'form-row-full';
|
1021 |
-
}
|
1022 |
-
}
|
1023 |
-
|
1024 |
-
if ( ! empty( $fields['shipping']['shipping_company'] ) ) {
|
1025 |
-
|
1026 |
-
if ( isset( $fields['shipping']['shipping_company'] ) && is_array( $fields['shipping']['shipping_company'] ) ) {
|
1027 |
-
$fields['shipping']['shipping_company']['class'][] = 'form-row-full';
|
1028 |
-
}
|
1029 |
-
}
|
1030 |
-
|
1031 |
-
if ( ! empty( $fields['billing']['billing_country'] ) ) {
|
1032 |
-
|
1033 |
-
if ( isset( $fields['billing']['billing_country'] ) && is_array( $fields['billing']['billing_country'] ) ) {
|
1034 |
-
$fields['billing']['billing_country']['class'][] = 'form-row-full';
|
1035 |
-
}
|
1036 |
-
}
|
1037 |
-
|
1038 |
-
if ( ! empty( $fields['shipping']['shipping_country'] ) ) {
|
1039 |
-
|
1040 |
-
if ( isset( $fields['shipping']['shipping_country'] ) && is_array( $fields['shipping']['shipping_country'] ) ) {
|
1041 |
-
$fields['shipping']['shipping_country']['class'][] = 'form-row-full';
|
1042 |
-
}
|
1043 |
-
}
|
1044 |
-
|
1045 |
-
if ( ! empty( $fields['billing']['billing_phone'] ) ) {
|
1046 |
-
|
1047 |
-
if ( isset( $fields['billing']['billing_phone'] ) && is_array( $fields['billing']['billing_phone'] ) ) {
|
1048 |
-
$fields['billing']['billing_phone']['class'][] = 'form-row-full';
|
1049 |
-
}
|
1050 |
-
}
|
1051 |
-
|
1052 |
-
if ( ! empty( $fields['billing']['billing_email'] ) ) {
|
1053 |
-
|
1054 |
-
if ( isset( $fields['billing']['billing_email'] ) && is_array( $fields['billing']['billing_email'] ) ) {
|
1055 |
-
$fields['billing']['billing_email']['class'][] = 'form-row-full';
|
1056 |
-
}
|
1057 |
-
}
|
1058 |
-
|
1059 |
-
if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
|
1060 |
-
|
1061 |
-
if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
|
1062 |
-
$fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
|
1063 |
-
}
|
1064 |
-
}
|
1065 |
-
|
1066 |
-
if ( isset( $fields['billing']['billing_city'] ) &&
|
1067 |
-
isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
|
1068 |
-
|
1069 |
-
$fields['billing']['billing_city']['class'][] = 'wcf-column-33';
|
1070 |
-
$fields['billing']['billing_state']['class'][] = 'wcf-column-33';
|
1071 |
-
$fields['billing']['billing_postcode']['class'][] = 'wcf-column-33';
|
1072 |
-
}
|
1073 |
-
|
1074 |
-
if ( isset( $fields['shipping']['shipping_city'] ) &&
|
1075 |
-
isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
|
1076 |
-
|
1077 |
-
$fields['shipping']['shipping_city']['class'][] = 'wcf-column-33';
|
1078 |
-
$fields['shipping']['shipping_state']['class'][] = 'wcf-column-33';
|
1079 |
-
$fields['shipping']['shipping_postcode']['class'][] = 'wcf-column-33';
|
1080 |
-
}
|
1081 |
-
|
1082 |
-
return $fields;
|
1083 |
-
}
|
1084 |
-
|
1085 |
-
/**
|
1086 |
-
* Add opening dev
|
1087 |
-
*
|
1088 |
-
* @since 1.0.0
|
1089 |
-
*/
|
1090 |
-
function order_wrap_div_start() {
|
1091 |
-
|
1092 |
-
echo "<div class='wcf-order-wrap'> ";
|
1093 |
-
}
|
1094 |
-
|
1095 |
-
/**
|
1096 |
-
* Add closing dev
|
1097 |
-
*
|
1098 |
-
* @since 1.0.0
|
1099 |
-
*/
|
1100 |
-
function order_wrap_div_end() {
|
1101 |
-
|
1102 |
-
echo '</div> ';
|
1103 |
-
}
|
1104 |
-
}
|
1105 |
-
|
1106 |
-
/**
|
1107 |
-
* Kicking this off by calling 'get_instance()' method
|
1108 |
-
*/
|
1109 |
-
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_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
|
64 |
+
add_action( 'wp_ajax_nopriv_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
|
65 |
+
|
66 |
+
add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
|
67 |
+
|
68 |
+
/* Global Checkout */
|
69 |
+
add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Display all WooCommerce notices.
|
74 |
+
*
|
75 |
+
* @since 1.1.5
|
76 |
+
*/
|
77 |
+
function display_woo_notices() {
|
78 |
+
|
79 |
+
if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
|
80 |
+
woocommerce_output_all_notices();
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Redirect from default to the global checkout page
|
87 |
+
*
|
88 |
+
* @since 1.0.0
|
89 |
+
*/
|
90 |
+
function global_checkout_template_redirect() {
|
91 |
+
|
92 |
+
if ( ! is_checkout() ) {
|
93 |
+
return;
|
94 |
+
}
|
95 |
+
|
96 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
97 |
+
return;
|
98 |
+
}
|
99 |
+
|
100 |
+
// redirect only from any non HC checkout pages.
|
101 |
+
$order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
|
102 |
+
$order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
|
103 |
+
|
104 |
+
$common = Cartflows_Helper::get_common_settings();
|
105 |
+
|
106 |
+
$global_checkout = $common['global_checkout'];
|
107 |
+
|
108 |
+
if (
|
109 |
+
// ignore on order-pay.
|
110 |
+
false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
|
111 |
+
// ignore on TY page.
|
112 |
+
false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
|
113 |
+
) {
|
114 |
+
|
115 |
+
if ( '' !== $global_checkout ) {
|
116 |
+
|
117 |
+
$link = get_permalink( $global_checkout );
|
118 |
+
|
119 |
+
if ( ! empty( $link ) ) {
|
120 |
+
|
121 |
+
wp_redirect( $link );
|
122 |
+
die();
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Check for checkout flag
|
130 |
+
*
|
131 |
+
* @param bool $is_checkout is checkout.
|
132 |
+
*
|
133 |
+
* @return bool
|
134 |
+
*/
|
135 |
+
function woo_checkout_flag( $is_checkout ) {
|
136 |
+
|
137 |
+
if ( ! is_admin() ) {
|
138 |
+
|
139 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
140 |
+
|
141 |
+
$is_checkout = true;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
return $is_checkout;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Render checkout shortcode markup.
|
150 |
+
*
|
151 |
+
* @param array $atts attributes.
|
152 |
+
* @return string
|
153 |
+
*/
|
154 |
+
function checkout_shortcode_markup( $atts ) {
|
155 |
+
|
156 |
+
if ( ! function_exists( 'wc_print_notices' ) ) {
|
157 |
+
return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
|
158 |
+
}
|
159 |
+
|
160 |
+
$atts = shortcode_atts(
|
161 |
+
array(
|
162 |
+
'id' => 0,
|
163 |
+
),
|
164 |
+
$atts
|
165 |
+
);
|
166 |
+
|
167 |
+
$checkout_id = intval( $atts['id'] );
|
168 |
+
|
169 |
+
if ( empty( $checkout_id ) ) {
|
170 |
+
|
171 |
+
if ( ! _is_wcf_checkout_type() ) {
|
172 |
+
|
173 |
+
return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
|
174 |
+
}
|
175 |
+
|
176 |
+
global $post;
|
177 |
+
|
178 |
+
$checkout_id = intval( $post->ID );
|
179 |
+
}
|
180 |
+
|
181 |
+
$output = '';
|
182 |
+
|
183 |
+
ob_start();
|
184 |
+
|
185 |
+
do_action( 'cartflows_checkout_form_before', $checkout_id );
|
186 |
+
|
187 |
+
$checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
|
188 |
+
|
189 |
+
$template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
|
190 |
+
|
191 |
+
$template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
|
192 |
+
|
193 |
+
if ( file_exists( $template_layout ) ) {
|
194 |
+
include $template_layout;
|
195 |
+
} else {
|
196 |
+
include $template_default;
|
197 |
+
}
|
198 |
+
|
199 |
+
$output .= ob_get_clean();
|
200 |
+
|
201 |
+
return $output;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Configure Cart Data.
|
206 |
+
*
|
207 |
+
* @since 1.0.0
|
208 |
+
*
|
209 |
+
* @return void
|
210 |
+
*/
|
211 |
+
function preconfigured_cart_data() {
|
212 |
+
|
213 |
+
if ( is_admin() ) {
|
214 |
+
return;
|
215 |
+
}
|
216 |
+
|
217 |
+
global $post;
|
218 |
+
|
219 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
220 |
+
|
221 |
+
if ( wp_doing_ajax() ) {
|
222 |
+
|
223 |
+
return;
|
224 |
+
} else {
|
225 |
+
|
226 |
+
if ( _is_wcf_checkout_type() ) {
|
227 |
+
$checkout_id = $post->ID;
|
228 |
+
} else {
|
229 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
230 |
+
}
|
231 |
+
|
232 |
+
do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
|
233 |
+
|
234 |
+
$flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
|
235 |
+
|
236 |
+
if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
|
237 |
+
$products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
|
238 |
+
} else {
|
239 |
+
$products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
|
240 |
+
}
|
241 |
+
|
242 |
+
if ( ! is_array( $products ) ) {
|
243 |
+
|
244 |
+
if ( 'dummy' === $products ) {
|
245 |
+
|
246 |
+
$args = array(
|
247 |
+
'posts_per_page' => 1,
|
248 |
+
'orderby' => 'rand',
|
249 |
+
'post_type' => 'product',
|
250 |
+
'meta_query' => array(
|
251 |
+
// Exclude out of stock products.
|
252 |
+
array(
|
253 |
+
'key' => '_stock_status',
|
254 |
+
'value' => 'outofstock',
|
255 |
+
'compare' => 'NOT IN',
|
256 |
+
),
|
257 |
+
),
|
258 |
+
'tax_query' => array(
|
259 |
+
array(
|
260 |
+
'taxonomy' => 'product_type',
|
261 |
+
'field' => 'slug',
|
262 |
+
'terms' => 'simple',
|
263 |
+
),
|
264 |
+
),
|
265 |
+
);
|
266 |
+
|
267 |
+
$random_product = get_posts( $args );
|
268 |
+
|
269 |
+
if ( isset( $random_product[0]->ID ) ) {
|
270 |
+
$products = array(
|
271 |
+
array(
|
272 |
+
'product' => $random_product[0]->ID,
|
273 |
+
),
|
274 |
+
);
|
275 |
+
} else {
|
276 |
+
return;
|
277 |
+
}
|
278 |
+
} else {
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
if ( is_array( $products ) && count( $products ) < 1 ) {
|
284 |
+
|
285 |
+
return;
|
286 |
+
}
|
287 |
+
/* Empty the current cart */
|
288 |
+
WC()->cart->empty_cart();
|
289 |
+
|
290 |
+
/* Set customer session if not set */
|
291 |
+
if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
|
292 |
+
WC()->session->set_customer_session_cookie( true );
|
293 |
+
}
|
294 |
+
|
295 |
+
$cart_product_count = 0;
|
296 |
+
|
297 |
+
foreach ( $products as $index => $data ) {
|
298 |
+
|
299 |
+
if ( ! isset( $data['product'] ) ) {
|
300 |
+
return;
|
301 |
+
}
|
302 |
+
|
303 |
+
if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
|
304 |
+
break;
|
305 |
+
}
|
306 |
+
|
307 |
+
$product_id = $data['product'];
|
308 |
+
$_product = wc_get_product( $product_id );
|
309 |
+
|
310 |
+
if ( ! empty( $_product ) ) {
|
311 |
+
|
312 |
+
$quantity = 1;
|
313 |
+
|
314 |
+
if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
|
315 |
+
|
316 |
+
if ( $_product->is_type( 'variable' ) ) {
|
317 |
+
|
318 |
+
$default_attributes = $_product->get_default_attributes();
|
319 |
+
|
320 |
+
if ( ! empty( $default_attributes ) ) {
|
321 |
+
|
322 |
+
foreach ( $_product->get_children() as $variation_id ) {
|
323 |
+
|
324 |
+
$single_variation = new WC_Product_Variation( $variation_id );
|
325 |
+
|
326 |
+
if ( $default_attributes == $single_variation->get_attributes() ) {
|
327 |
+
WC()->cart->add_to_cart( $variation_id, $quantity );
|
328 |
+
$cart_product_count++;
|
329 |
+
}
|
330 |
+
}
|
331 |
+
} else {
|
332 |
+
|
333 |
+
$product_childrens = $_product->get_children();
|
334 |
+
|
335 |
+
if ( isset( $product_childrens[0] ) ) {
|
336 |
+
WC()->cart->add_to_cart( $product_childrens[0], $quantity );
|
337 |
+
$cart_product_count++;
|
338 |
+
} else {
|
339 |
+
echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
|
340 |
+
}
|
341 |
+
}
|
342 |
+
} else {
|
343 |
+
WC()->cart->add_to_cart( $product_id, $quantity );
|
344 |
+
$cart_product_count++;
|
345 |
+
}
|
346 |
+
} else {
|
347 |
+
|
348 |
+
echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
|
349 |
+
// WC()->cart->add_to_cart( $product_id, $quantity );.
|
350 |
+
}
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
|
355 |
+
do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
|
356 |
+
}
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Load shortcode data.
|
362 |
+
*
|
363 |
+
* @return void
|
364 |
+
*/
|
365 |
+
function shortcode_load_data() {
|
366 |
+
|
367 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
368 |
+
|
369 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
|
370 |
+
|
371 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 );
|
372 |
+
|
373 |
+
/* Show notices if cart has errors */
|
374 |
+
add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
|
375 |
+
|
376 |
+
add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
|
377 |
+
|
378 |
+
add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
|
379 |
+
|
380 |
+
// Outputting the hidden field in checkout page.
|
381 |
+
add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
382 |
+
add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
383 |
+
|
384 |
+
remove_all_actions( 'woocommerce_checkout_billing' );
|
385 |
+
remove_all_actions( 'woocommerce_checkout_shipping' );
|
386 |
+
|
387 |
+
// Hook in actions once.
|
388 |
+
add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
|
389 |
+
add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
|
390 |
+
|
391 |
+
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
|
392 |
+
|
393 |
+
add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
|
394 |
+
|
395 |
+
add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
|
396 |
+
|
397 |
+
global $post;
|
398 |
+
|
399 |
+
if ( _is_wcf_checkout_type() ) {
|
400 |
+
$checkout_id = $post->ID;
|
401 |
+
} else {
|
402 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
403 |
+
}
|
404 |
+
|
405 |
+
do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Render checkout ID hidden field.
|
411 |
+
*
|
412 |
+
* @param array $checkout checkout session data.
|
413 |
+
* @return void
|
414 |
+
*/
|
415 |
+
function checkout_shortcode_post_id( $checkout ) {
|
416 |
+
|
417 |
+
global $post;
|
418 |
+
|
419 |
+
if ( _is_wcf_checkout_type() ) {
|
420 |
+
$checkout_id = $post->ID;
|
421 |
+
} else {
|
422 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
423 |
+
}
|
424 |
+
|
425 |
+
$flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
|
426 |
+
|
427 |
+
echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
|
428 |
+
echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Load shortcode scripts.
|
433 |
+
*
|
434 |
+
* @return void
|
435 |
+
*/
|
436 |
+
function shortcode_scripts() {
|
437 |
+
|
438 |
+
wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
|
439 |
+
wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
|
440 |
+
|
441 |
+
wp_enqueue_script(
|
442 |
+
'wcf-checkout-template',
|
443 |
+
CARTFLOWS_URL . 'assets/js/checkout-template.js',
|
444 |
+
array( 'jquery' ),
|
445 |
+
CARTFLOWS_VER,
|
446 |
+
true
|
447 |
+
);
|
448 |
+
|
449 |
+
do_action( 'cartflows_checkout_scripts' );
|
450 |
+
|
451 |
+
$style = $this->generate_style();
|
452 |
+
|
453 |
+
wp_add_inline_style( 'wcf-checkout-template', $style );
|
454 |
+
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Load compatibility scripts.
|
459 |
+
*
|
460 |
+
* @return void
|
461 |
+
*/
|
462 |
+
function compatibility_scripts() {
|
463 |
+
|
464 |
+
global $post;
|
465 |
+
|
466 |
+
if ( _is_wcf_checkout_type() ) {
|
467 |
+
$checkout_id = $post->ID;
|
468 |
+
} else {
|
469 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
470 |
+
}
|
471 |
+
|
472 |
+
// Add DIVI Compatibility css if DIVI theme is enabled.
|
473 |
+
if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ||
|
474 |
+
Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id )
|
475 |
+
) {
|
476 |
+
wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
|
477 |
+
wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
|
478 |
+
}
|
479 |
+
|
480 |
+
// Add Flatsome Compatibility css if Flatsome theme is enabled.
|
481 |
+
if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
|
482 |
+
wp_enqueue_style( 'wcf-checkout-template-flatsome', CARTFLOWS_URL . 'assets/css/checkout-template-flatsome.css', '', CARTFLOWS_VER );
|
483 |
+
wp_style_add_data( 'wcf-checkout-template-flatsome', 'rtl', 'replace' );
|
484 |
+
}
|
485 |
+
|
486 |
+
// Add The7 Compatibility css if The7 theme is enabled.
|
487 |
+
if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) {
|
488 |
+
wp_enqueue_style( 'wcf-checkout-template-the-seven', CARTFLOWS_URL . 'assets/css/checkout-template-the-seven.css', '', CARTFLOWS_VER );
|
489 |
+
wp_style_add_data( 'wcf-checkout-template-the-seven', 'rtl', 'replace' );
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Generate styles.
|
495 |
+
*
|
496 |
+
* @return string
|
497 |
+
*/
|
498 |
+
function generate_style() {
|
499 |
+
|
500 |
+
global $post;
|
501 |
+
|
502 |
+
if ( _is_wcf_checkout_type() ) {
|
503 |
+
$checkout_id = $post->ID;
|
504 |
+
} else {
|
505 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
506 |
+
}
|
507 |
+
|
508 |
+
CartFlows_Font_Families::render_fonts( $checkout_id );
|
509 |
+
|
510 |
+
$primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
|
511 |
+
|
512 |
+
$base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
|
513 |
+
|
514 |
+
$header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
|
515 |
+
|
516 |
+
/*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
|
517 |
+
$r = '';
|
518 |
+
$g = '';
|
519 |
+
$b = '';
|
520 |
+
|
521 |
+
$field_tb_padding = '';
|
522 |
+
$field_lr_padding = '';
|
523 |
+
|
524 |
+
$field_heading_color = '';
|
525 |
+
$field_color = '';
|
526 |
+
$field_bg_color = '';
|
527 |
+
$field_border_color = '';
|
528 |
+
$field_label_color = '';
|
529 |
+
$submit_tb_padding = '';
|
530 |
+
$submit_lr_padding = '';
|
531 |
+
$hl_bg_color = '';
|
532 |
+
$field_input_size = '';
|
533 |
+
$box_border_color = '';
|
534 |
+
$section_bg_color = '';
|
535 |
+
$submit_button_height = '';
|
536 |
+
$submit_color = '';
|
537 |
+
$submit_bg_color = $primary_color;
|
538 |
+
$submit_border_color = $primary_color;
|
539 |
+
|
540 |
+
$submit_hover_color = '';
|
541 |
+
$submit_bg_hover_color = $primary_color;
|
542 |
+
$submit_border_hover_color = $primary_color;
|
543 |
+
|
544 |
+
$section_heading_color = '';
|
545 |
+
|
546 |
+
$is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
|
547 |
+
|
548 |
+
$button_font_family = '';
|
549 |
+
$button_font_weight = '';
|
550 |
+
$input_font_family = '';
|
551 |
+
$input_font_weight = '';
|
552 |
+
$heading_font_family = '';
|
553 |
+
$heading_font_weight = '';
|
554 |
+
$base_font_family = $base_font_family;
|
555 |
+
/*$base_font_weight = $base_font_weight;*/
|
556 |
+
|
557 |
+
if ( 'yes' == $is_advance_option ) {
|
558 |
+
|
559 |
+
/**
|
560 |
+
* Get Font Family and Font Weight weight values
|
561 |
+
*/
|
562 |
+
$section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
|
563 |
+
|
564 |
+
$heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
|
565 |
+
$heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
|
566 |
+
$section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
|
567 |
+
$button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
|
568 |
+
$button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
|
569 |
+
$input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
|
570 |
+
$input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
|
571 |
+
$field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
|
572 |
+
$field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
|
573 |
+
$field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
|
574 |
+
|
575 |
+
$field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
|
576 |
+
|
577 |
+
$field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
|
578 |
+
|
579 |
+
$field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
|
580 |
+
|
581 |
+
$field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
|
582 |
+
|
583 |
+
$field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
|
584 |
+
|
585 |
+
$submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
|
586 |
+
|
587 |
+
$submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
|
588 |
+
|
589 |
+
$submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
|
590 |
+
|
591 |
+
$submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
|
592 |
+
|
593 |
+
$submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
|
594 |
+
|
595 |
+
$submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
|
596 |
+
|
597 |
+
$submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
|
598 |
+
|
599 |
+
$submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
|
600 |
+
|
601 |
+
$hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
|
602 |
+
|
603 |
+
$box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
|
604 |
+
|
605 |
+
$submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
|
606 |
+
|
607 |
+
/**
|
608 |
+
* Get font values
|
609 |
+
*/
|
610 |
+
|
611 |
+
if ( 'custom' == $submit_button_height ) {
|
612 |
+
$submit_button_height = '38px';
|
613 |
+
}
|
614 |
+
|
615 |
+
if ( 'custom' == $field_input_size ) {
|
616 |
+
$field_input_size = '38px';
|
617 |
+
}
|
618 |
+
}
|
619 |
+
if ( isset( $primary_color ) ) {
|
620 |
+
|
621 |
+
list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
|
622 |
+
}
|
623 |
+
$output = "
|
624 |
+
.wcf-embed-checkout-form .wcf-checkout-header-image img{
|
625 |
+
width: {$header_logo_width}px;
|
626 |
+
}
|
627 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
|
628 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
|
629 |
+
color: {$primary_color};
|
630 |
+
}
|
631 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
|
632 |
+
background-color: {$primary_color};
|
633 |
+
}
|
634 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
|
635 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
|
636 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
|
637 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
|
638 |
+
border-color: {$primary_color};
|
639 |
+
box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
|
640 |
+
}
|
641 |
+
.wcf-embed-checkout-form .woocommerce-checkout label{
|
642 |
+
color: {$field_label_color};
|
643 |
+
}
|
644 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
|
645 |
+
background-color: {$hl_bg_color};
|
646 |
+
font-family: {$input_font_family};
|
647 |
+
font-weight: {$input_font_weight};
|
648 |
+
}
|
649 |
+
|
650 |
+
.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
|
651 |
+
.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
|
652 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
|
653 |
+
{
|
654 |
+
border-color: {$hl_bg_color};
|
655 |
+
border-right-color: transparent;
|
656 |
+
border-left-color: transparent;
|
657 |
+
border-top-color: transparent;
|
658 |
+
position: absolute;
|
659 |
+
}
|
660 |
+
|
661 |
+
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
|
662 |
+
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
|
663 |
+
font-family: {$input_font_family};
|
664 |
+
font-weight: {$input_font_weight};
|
665 |
+
}
|
666 |
+
|
667 |
+
.wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
|
668 |
+
.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
|
669 |
+
.wcf-embed-checkout-form .woocommerce form .form-row textarea,
|
670 |
+
.wcf-embed-checkout-form .select2-container--default .select2-selection--single {
|
671 |
+
color: {$field_color};
|
672 |
+
background: {$field_bg_color};
|
673 |
+
border-color: {$field_border_color};
|
674 |
+
padding-top: {$field_tb_padding}px;
|
675 |
+
padding-bottom: {$field_tb_padding}px;
|
676 |
+
padding-left: {$field_lr_padding}px;
|
677 |
+
padding-right: {$field_lr_padding}px;
|
678 |
+
min-height: {$field_input_size};
|
679 |
+
font-family: {$input_font_family};
|
680 |
+
font-weight: {$input_font_weight};
|
681 |
+
}
|
682 |
+
|
683 |
+
.wcf-embed-checkout-form .woocommerce .col2-set .col-1,
|
684 |
+
.wcf-embed-checkout-form .woocommerce .col2-set .col-2,
|
685 |
+
.wcf-embed-checkout-form .woocommerce-checkout .shop_table,
|
686 |
+
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
|
687 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment,
|
688 |
+
.wcf-embed-checkout-form .woocommerce form.checkout_coupon
|
689 |
+
{
|
690 |
+
background-color: {$section_bg_color};
|
691 |
+
border-color: {$box_border_color};
|
692 |
+
font-family: {$input_font_family};
|
693 |
+
font-weight: {$input_font_weight};
|
694 |
+
}
|
695 |
+
|
696 |
+
.woocommerce table.shop_table th{
|
697 |
+
color: {$field_label_color};
|
698 |
+
}
|
699 |
+
/*.wcf-embed-checkout-form .woocommerce .woocommerce-info,
|
700 |
+
.wcf-embed-checkout-form .woocommerce-message{
|
701 |
+
border-top-color: {$primary_color};
|
702 |
+
background-color: {$hl_bg_color};
|
703 |
+
}*/
|
704 |
+
.wcf-embed-checkout-form .woocommerce a{
|
705 |
+
color: {$primary_color};
|
706 |
+
}
|
707 |
+
.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
|
708 |
+
color: {$field_color};
|
709 |
+
}
|
710 |
+
.wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
|
711 |
+
color: {$field_color};
|
712 |
+
}
|
713 |
+
.wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
|
714 |
+
color: {$field_color};
|
715 |
+
}
|
716 |
+
.wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
|
717 |
+
color: {$field_color};
|
718 |
+
}
|
719 |
+
.wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
|
720 |
+
color: {$field_color};
|
721 |
+
}
|
722 |
+
.wcf-embed-checkout-form .woocommerce form p.form-row label {
|
723 |
+
color: {$field_label_color};
|
724 |
+
font-family: {$input_font_family};
|
725 |
+
font-weight: {$input_font_weight};
|
726 |
+
}
|
727 |
+
.wcf-embed-checkout-form .woocommerce #order_review button {
|
728 |
+
color: {$submit_color};
|
729 |
+
background: {$submit_bg_color};
|
730 |
+
padding-top: {$submit_tb_padding}px;
|
731 |
+
padding-bottom: {$submit_tb_padding}px;
|
732 |
+
padding-left: {$submit_lr_padding}px;
|
733 |
+
padding-right: {$submit_lr_padding}px;
|
734 |
+
border-color: {$submit_border_color};
|
735 |
+
min-height: {$submit_button_height};
|
736 |
+
font-family: {$button_font_family};
|
737 |
+
font-weight: {$button_font_weight};
|
738 |
+
}
|
739 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
|
740 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
|
741 |
+
background: {$submit_bg_color};
|
742 |
+
border: 1px {$submit_border_color} solid;
|
743 |
+
color: {$submit_color};
|
744 |
+
min-height: {$submit_button_height};
|
745 |
+
font-family: {$button_font_family};
|
746 |
+
font-weight: {$button_font_weight};
|
747 |
+
}
|
748 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
|
749 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
|
750 |
+
.wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
|
751 |
+
.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
|
752 |
+
color: {$submit_hover_color};
|
753 |
+
background-color: {$submit_bg_hover_color};
|
754 |
+
border-color: {$submit_border_hover_color};
|
755 |
+
}
|
756 |
+
.wcf-embed-checkout-form .woocommerce h3,
|
757 |
+
.wcf-embed-checkout-form .woocommerce h3 span,
|
758 |
+
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
|
759 |
+
color: {$section_heading_color};
|
760 |
+
font-family: {$heading_font_family};
|
761 |
+
font-weight: {$heading_font_weight};
|
762 |
+
}
|
763 |
+
.wcf-embed-checkout-form .woocommerce-info::before,
|
764 |
+
.wcf-embed-checkout-form .woocommerce-message::before{
|
765 |
+
color: {$primary_color};
|
766 |
+
}
|
767 |
+
.wcf-embed-checkout-form{
|
768 |
+
font-family: {$base_font_family};
|
769 |
+
}";
|
770 |
+
|
771 |
+
return $output;
|
772 |
+
}
|
773 |
+
|
774 |
+
/**
|
775 |
+
* Get ajax end points.
|
776 |
+
*
|
777 |
+
* @param string $endpoint_url end point URL.
|
778 |
+
* @return string
|
779 |
+
*/
|
780 |
+
function get_ajax_endpoint( $endpoint_url ) {
|
781 |
+
|
782 |
+
global $post;
|
783 |
+
|
784 |
+
if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
|
785 |
+
|
786 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
787 |
+
|
788 |
+
if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
|
789 |
+
|
790 |
+
$query_args = array(
|
791 |
+
'wc-ajax' => '%%endpoint%%',
|
792 |
+
);
|
793 |
+
|
794 |
+
$uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
|
795 |
+
$uri = $uri[0];
|
796 |
+
|
797 |
+
$endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
|
798 |
+
}
|
799 |
+
}
|
800 |
+
}
|
801 |
+
|
802 |
+
return $endpoint_url;
|
803 |
+
}
|
804 |
+
|
805 |
+
|
806 |
+
/**
|
807 |
+
* Save checkout fields.
|
808 |
+
*
|
809 |
+
* @param int $order_id order id.
|
810 |
+
* @param array $posted posted data.
|
811 |
+
* @return void
|
812 |
+
*/
|
813 |
+
function save_checkout_fields( $order_id, $posted ) {
|
814 |
+
|
815 |
+
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
816 |
+
|
817 |
+
$checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
|
818 |
+
|
819 |
+
update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
|
820 |
+
|
821 |
+
/*
|
822 |
+
Custom Field To Do
|
823 |
+
$custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
|
824 |
+
|
825 |
+
if ( 'yes' === $custom_fields ) {
|
826 |
+
|
827 |
+
$billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
|
828 |
+
|
829 |
+
foreach ( $billing_fields as $field => $data ) {
|
830 |
+
|
831 |
+
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
832 |
+
|
833 |
+
if ( isset( $_POST[ $field ] ) ) {
|
834 |
+
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
835 |
+
}
|
836 |
+
}
|
837 |
+
}
|
838 |
+
|
839 |
+
$shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
|
840 |
+
|
841 |
+
foreach ( $shipping_fields as $field => $data ) {
|
842 |
+
|
843 |
+
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
844 |
+
|
845 |
+
if ( isset( $_POST[ $field ] ) ) {
|
846 |
+
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
847 |
+
}
|
848 |
+
}
|
849 |
+
}
|
850 |
+
}
|
851 |
+
*/
|
852 |
+
if ( isset( $_POST['_wcf_flow_id'] ) ) {
|
853 |
+
|
854 |
+
$checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
|
855 |
+
|
856 |
+
update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
|
857 |
+
}
|
858 |
+
}
|
859 |
+
|
860 |
+
}
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Enable Logo In Header Of Checkout Page
|
864 |
+
*
|
865 |
+
* @return void
|
866 |
+
*/
|
867 |
+
function enable_logo_in_header() {
|
868 |
+
global $post;
|
869 |
+
|
870 |
+
if ( _is_wcf_checkout_type() ) {
|
871 |
+
$checkout_id = $post->ID;
|
872 |
+
} else {
|
873 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
874 |
+
}
|
875 |
+
|
876 |
+
$header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
|
877 |
+
$add_image_markup = '';
|
878 |
+
|
879 |
+
if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
|
880 |
+
$add_image_markup = '<div class="wcf-checkout-header-image">';
|
881 |
+
$add_image_markup .= '<img src="' . $header_logo_image . '" />';
|
882 |
+
$add_image_markup .= '</div>';
|
883 |
+
}
|
884 |
+
|
885 |
+
echo $add_image_markup;
|
886 |
+
}
|
887 |
+
|
888 |
+
/**
|
889 |
+
* Add text to the bootom of the checkout page.
|
890 |
+
*
|
891 |
+
* @return void
|
892 |
+
*/
|
893 |
+
function show_cartflows_copyright_message() {
|
894 |
+
$output_string = '';
|
895 |
+
|
896 |
+
$output_string .= '<div class="wcf-footer-primary">';
|
897 |
+
$output_string .= '<div class="wcf-footer-content">';
|
898 |
+
$output_string .= '<p class="wcf-footer-message">';
|
899 |
+
$output_string .= 'Checkout powered by CartFlows';
|
900 |
+
$output_string .= '</p>';
|
901 |
+
$output_string .= '</div>';
|
902 |
+
$output_string .= '</div>';
|
903 |
+
|
904 |
+
echo $output_string;
|
905 |
+
}
|
906 |
+
|
907 |
+
/**
|
908 |
+
* Redirect users to our checkout if hidden param
|
909 |
+
*
|
910 |
+
* @param string $redirect redirect url.
|
911 |
+
* @param object $user user.
|
912 |
+
* @return string
|
913 |
+
*/
|
914 |
+
function after_login_redirect( $redirect, $user ) {
|
915 |
+
|
916 |
+
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
917 |
+
|
918 |
+
$checkout_id = intval( $_POST['_wcf_checkout_id'] );
|
919 |
+
|
920 |
+
$redirect = get_permalink( $checkout_id );
|
921 |
+
}
|
922 |
+
|
923 |
+
return $redirect;
|
924 |
+
}
|
925 |
+
|
926 |
+
/**
|
927 |
+
* Display coupon code field after review order fields.
|
928 |
+
*/
|
929 |
+
function display_custom_coupon_field() {
|
930 |
+
|
931 |
+
$coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
|
932 |
+
|
933 |
+
if ( ! $coupon_enabled ) {
|
934 |
+
return;
|
935 |
+
}
|
936 |
+
|
937 |
+
ob_start();
|
938 |
+
|
939 |
+
?>
|
940 |
+
<div class="wcf-custom-coupon-field">
|
941 |
+
<div class="wcf-coupon-col-1">
|
942 |
+
<span>
|
943 |
+
<input type="text" name="coupon_code" class="input-text cf-coupon-code-input" placeholder="<?php echo $this->coupon_field_placeholder(); ?>" id="coupon_code" value="">
|
944 |
+
</span>
|
945 |
+
</div>
|
946 |
+
<div class="wcf-coupon-col-2">
|
947 |
+
<span>
|
948 |
+
<button type="button" class="button cf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php echo $this->coupon_button_text(); ?></button>
|
949 |
+
</span>
|
950 |
+
</div>
|
951 |
+
</div>
|
952 |
+
|
953 |
+
<?php
|
954 |
+
|
955 |
+
echo ob_get_clean();
|
956 |
+
}
|
957 |
+
|
958 |
+
/**
|
959 |
+
* Apply filter to change the placeholder text of coupon field.
|
960 |
+
*
|
961 |
+
* @return string
|
962 |
+
*/
|
963 |
+
function coupon_field_placeholder() {
|
964 |
+
return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
|
965 |
+
}
|
966 |
+
|
967 |
+
/**
|
968 |
+
* Apply filter to change the button text of coupon field.
|
969 |
+
*
|
970 |
+
* @return string
|
971 |
+
*/
|
972 |
+
function coupon_button_text() {
|
973 |
+
return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
|
974 |
+
}
|
975 |
+
|
976 |
+
/**
|
977 |
+
* Apply coupon on submit of custom coupon form.
|
978 |
+
*/
|
979 |
+
function apply_coupon() {
|
980 |
+
|
981 |
+
check_ajax_referer( 'cf-apply-coupon', 'security' );
|
982 |
+
|
983 |
+
$result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
|
984 |
+
|
985 |
+
echo json_encode( $result );
|
986 |
+
die();
|
987 |
+
}
|
988 |
+
|
989 |
+
/**
|
990 |
+
* Added ajax nonce to localize variable.
|
991 |
+
*
|
992 |
+
* @param array $vars localize variables.
|
993 |
+
*/
|
994 |
+
function add_localize_vars( $vars ) {
|
995 |
+
|
996 |
+
$vars['cf_validate_coupon_nonce'] = wp_create_nonce( 'cf-apply-coupon' );
|
997 |
+
|
998 |
+
$vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
|
999 |
+
|
1000 |
+
return $vars;
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
/**
|
1004 |
+
* Add custom class to the fields to change the UI to three column.
|
1005 |
+
*
|
1006 |
+
* @param array $fields fields.
|
1007 |
+
*/
|
1008 |
+
function add_three_column_layout_fields( $fields ) {
|
1009 |
+
|
1010 |
+
if ( empty( $fields['billing']['billing_address_2'] ) ) {
|
1011 |
+
|
1012 |
+
if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
|
1013 |
+
$fields['billing']['billing_address_1']['class'][] = 'form-row-full';
|
1014 |
+
}
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
if ( ! empty( $fields['billing']['billing_company'] ) ) {
|
1018 |
+
|
1019 |
+
if ( isset( $fields['billing']['billing_company'] ) && is_array( $fields['billing']['billing_company'] ) ) {
|
1020 |
+
$fields['billing']['billing_company']['class'][] = 'form-row-full';
|
1021 |
+
}
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
if ( ! empty( $fields['shipping']['shipping_company'] ) ) {
|
1025 |
+
|
1026 |
+
if ( isset( $fields['shipping']['shipping_company'] ) && is_array( $fields['shipping']['shipping_company'] ) ) {
|
1027 |
+
$fields['shipping']['shipping_company']['class'][] = 'form-row-full';
|
1028 |
+
}
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
if ( ! empty( $fields['billing']['billing_country'] ) ) {
|
1032 |
+
|
1033 |
+
if ( isset( $fields['billing']['billing_country'] ) && is_array( $fields['billing']['billing_country'] ) ) {
|
1034 |
+
$fields['billing']['billing_country']['class'][] = 'form-row-full';
|
1035 |
+
}
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
if ( ! empty( $fields['shipping']['shipping_country'] ) ) {
|
1039 |
+
|
1040 |
+
if ( isset( $fields['shipping']['shipping_country'] ) && is_array( $fields['shipping']['shipping_country'] ) ) {
|
1041 |
+
$fields['shipping']['shipping_country']['class'][] = 'form-row-full';
|
1042 |
+
}
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
if ( ! empty( $fields['billing']['billing_phone'] ) ) {
|
1046 |
+
|
1047 |
+
if ( isset( $fields['billing']['billing_phone'] ) && is_array( $fields['billing']['billing_phone'] ) ) {
|
1048 |
+
$fields['billing']['billing_phone']['class'][] = 'form-row-full';
|
1049 |
+
}
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
if ( ! empty( $fields['billing']['billing_email'] ) ) {
|
1053 |
+
|
1054 |
+
if ( isset( $fields['billing']['billing_email'] ) && is_array( $fields['billing']['billing_email'] ) ) {
|
1055 |
+
$fields['billing']['billing_email']['class'][] = 'form-row-full';
|
1056 |
+
}
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
|
1060 |
+
|
1061 |
+
if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
|
1062 |
+
$fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
|
1063 |
+
}
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
if ( isset( $fields['billing']['billing_city'] ) &&
|
1067 |
+
isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
|
1068 |
+
|
1069 |
+
$fields['billing']['billing_city']['class'][] = 'wcf-column-33';
|
1070 |
+
$fields['billing']['billing_state']['class'][] = 'wcf-column-33';
|
1071 |
+
$fields['billing']['billing_postcode']['class'][] = 'wcf-column-33';
|
1072 |
+
}
|
1073 |
+
|
1074 |
+
if ( isset( $fields['shipping']['shipping_city'] ) &&
|
1075 |
+
isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
|
1076 |
+
|
1077 |
+
$fields['shipping']['shipping_city']['class'][] = 'wcf-column-33';
|
1078 |
+
$fields['shipping']['shipping_state']['class'][] = 'wcf-column-33';
|
1079 |
+
$fields['shipping']['shipping_postcode']['class'][] = 'wcf-column-33';
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
return $fields;
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
/**
|
1086 |
+
* Add opening dev
|
1087 |
+
*
|
1088 |
+
* @since 1.0.0
|
1089 |
+
*/
|
1090 |
+
function order_wrap_div_start() {
|
1091 |
+
|
1092 |
+
echo "<div class='wcf-order-wrap'> ";
|
1093 |
+
}
|
1094 |
+
|
1095 |
+
/**
|
1096 |
+
* Add closing dev
|
1097 |
+
*
|
1098 |
+
* @since 1.0.0
|
1099 |
+
*/
|
1100 |
+
function order_wrap_div_end() {
|
1101 |
+
|
1102 |
+
echo '</div> ';
|
1103 |
+
}
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
/**
|
1107 |
+
* Kicking this off by calling 'get_instance()' method
|
1108 |
+
*/
|
1109 |
+
Cartflows_Checkout_Markup::get_instance();
|
modules/checkout/classes/class-cartflows-checkout-meta.php
CHANGED
@@ -1,759 +1,759 @@
|
|
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 = array(
|
152 |
-
array(
|
153 |
-
'title' => __( 'Shortcodes', 'cartflows' ),
|
154 |
-
'id' => 'wcf-checkout-shortcodes',
|
155 |
-
'class' => 'wcf-checkout-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
156 |
-
'icon' => 'dashicons-editor-code',
|
157 |
-
'help_text' => 'Help Helpppp...',
|
158 |
-
),
|
159 |
-
array(
|
160 |
-
'title' => __( 'Select Product', 'cartflows' ),
|
161 |
-
'id' => 'wcf-checkout-general',
|
162 |
-
'class' => 'wcf-checkout-general' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
163 |
-
'icon' => 'dashicons-info',
|
164 |
-
),
|
165 |
-
array(
|
166 |
-
'title' => __( 'Order Bump', 'cartflows' ),
|
167 |
-
'id' => 'wcf-product-order-bump',
|
168 |
-
'class' => 'wcf-product-order-bump' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
169 |
-
'icon' => 'dashicons-cart',
|
170 |
-
),
|
171 |
-
array(
|
172 |
-
'title' => __( 'Checkout Design', 'cartflows' ),
|
173 |
-
'id' => 'wcf-checkout-style',
|
174 |
-
'class' => 'wcf-checkout-style' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
175 |
-
'icon' => 'dashicons-admin-customizer',
|
176 |
-
),
|
177 |
-
array(
|
178 |
-
'title' => __( 'Checkout Fields', 'cartflows' ),
|
179 |
-
'id' => 'wcf-checkout-custom-fields',
|
180 |
-
'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
181 |
-
'icon' => 'dashicons-welcome-widgets-menus',
|
182 |
-
),
|
183 |
-
array(
|
184 |
-
'title' => __( 'Logo ( Optional )', 'cartflows' ),
|
185 |
-
'id' => 'wcf-checkout-header',
|
186 |
-
'class' => 'wcf-checkout-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
187 |
-
'icon' => 'dashicons-format-image',
|
188 |
-
),
|
189 |
-
);
|
190 |
-
|
191 |
-
?>
|
192 |
-
<div class="wcf-checkout-table wcf-metabox-wrap widefat">
|
193 |
-
<div class="wcf-table-container">
|
194 |
-
<div class="wcf-column-left">
|
195 |
-
<div class="wcf-tab-wrapper">
|
196 |
-
|
197 |
-
<?php foreach ( $tabs as $key => $tab ) { ?>
|
198 |
-
<div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
|
199 |
-
<span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
|
200 |
-
<span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
|
201 |
-
</div>
|
202 |
-
<?php } ?>
|
203 |
-
|
204 |
-
<input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" />
|
205 |
-
</div>
|
206 |
-
</div>
|
207 |
-
<div class="wcf-column-right">
|
208 |
-
<?php $this->tab_shortcodes( $options, $post_id ); ?>
|
209 |
-
<?php $this->tab_general( $options, $post_id ); ?>
|
210 |
-
<?php $this->tab_style( $options, $post_id ); ?>
|
211 |
-
<?php $this->tab_product_bump( $options, $post_id ); ?>
|
212 |
-
<?php $this->tab_custom_fields( $options, $post_id ); ?>
|
213 |
-
<?php $this->tab_header_content( $options, $post_id ); ?>
|
214 |
-
<?php $this->right_column_footer( $options, $post_id ); ?>
|
215 |
-
</div>
|
216 |
-
</div>
|
217 |
-
</div>
|
218 |
-
|
219 |
-
<?php
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Shortcodes tab
|
224 |
-
*
|
225 |
-
* @param array $options options.
|
226 |
-
* @param int $post_id post ID.
|
227 |
-
*/
|
228 |
-
function tab_shortcodes( $options, $post_id ) {
|
229 |
-
?>
|
230 |
-
<div class="wcf-checkout-shortcodes wcf-tab-content widefat">
|
231 |
-
|
232 |
-
<?php
|
233 |
-
|
234 |
-
echo wcf()->meta->get_shortcode_field(
|
235 |
-
array(
|
236 |
-
'label' => 'Checkout Page',
|
237 |
-
'name' => 'wcf-checkout-shortcode',
|
238 |
-
'content' => '[cartflows_checkout]',
|
239 |
-
'help' => __( 'Add this shortcode to your checkout page', 'cartflows' ),
|
240 |
-
)
|
241 |
-
);
|
242 |
-
?>
|
243 |
-
</div>
|
244 |
-
<?php
|
245 |
-
}
|
246 |
-
|
247 |
-
|
248 |
-
/**
|
249 |
-
* General tab
|
250 |
-
*
|
251 |
-
* @param array $options options.
|
252 |
-
* @param int $post_id post ID.
|
253 |
-
*/
|
254 |
-
function tab_general( $options, $post_id ) {
|
255 |
-
?>
|
256 |
-
<div class="wcf-checkout-general wcf-tab-content widefat">
|
257 |
-
|
258 |
-
<?php
|
259 |
-
|
260 |
-
echo wcf()->meta->get_product_selection_repeater(
|
261 |
-
array(
|
262 |
-
'name' => 'wcf-checkout-products',
|
263 |
-
'value' => $options['wcf-checkout-products'],
|
264 |
-
'allow_clear' => true,
|
265 |
-
)
|
266 |
-
);
|
267 |
-
|
268 |
-
do_action( 'cartflows_checkout_general_tab_content', $options, $post_id );
|
269 |
-
|
270 |
-
?>
|
271 |
-
</div>
|
272 |
-
<?php
|
273 |
-
}
|
274 |
-
|
275 |
-
/**
|
276 |
-
* Product bump tab
|
277 |
-
*
|
278 |
-
* @param array $options options.
|
279 |
-
* @param int $post_id post ID.
|
280 |
-
*/
|
281 |
-
function tab_product_bump( $options, $post_id ) {
|
282 |
-
?>
|
283 |
-
<div class="wcf-product-order-bump wcf-tab-content widefat">
|
284 |
-
<?php
|
285 |
-
if ( ! _is_cartflows_pro() ) {
|
286 |
-
|
287 |
-
echo wcf()->meta->get_description_field(
|
288 |
-
array(
|
289 |
-
'name' => 'wcf-upgrade-to-pro',
|
290 |
-
/* translators: %s: link */
|
291 |
-
'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
|
292 |
-
)
|
293 |
-
);
|
294 |
-
}
|
295 |
-
?>
|
296 |
-
|
297 |
-
<?php do_action( 'cartflows_order_bump_tab_content', $options, $post_id ); ?>
|
298 |
-
</div>
|
299 |
-
<?php
|
300 |
-
}
|
301 |
-
/**
|
302 |
-
* Tab custom fields
|
303 |
-
*
|
304 |
-
* @param array $options options.
|
305 |
-
* @param int $post_id post ID.
|
306 |
-
*/
|
307 |
-
function tab_custom_fields( $options, $post_id ) {
|
308 |
-
?>
|
309 |
-
<div class="wcf-checkout-custom-fields wcf-tab-content widefat">
|
310 |
-
<?php
|
311 |
-
/* Custom Checkout Fields Section */
|
312 |
-
|
313 |
-
if ( ! _is_cartflows_pro() ) {
|
314 |
-
|
315 |
-
echo wcf()->meta->get_description_field(
|
316 |
-
array(
|
317 |
-
'name' => 'wcf-upgrade-to-pro',
|
318 |
-
/* translators: %s: link */
|
319 |
-
'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
|
320 |
-
)
|
321 |
-
);
|
322 |
-
}
|
323 |
-
?>
|
324 |
-
<?php do_action( 'cartflows_custom_fields_tab_content', $options, $post_id ); ?>
|
325 |
-
</div>
|
326 |
-
<?php
|
327 |
-
}
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Tab style
|
331 |
-
*
|
332 |
-
* @param array $options options.
|
333 |
-
* @param int $post_id post ID.
|
334 |
-
*/
|
335 |
-
function tab_style( $options, $post_id ) {
|
336 |
-
?>
|
337 |
-
|
338 |
-
<div class="wcf-checkout-style wcf-tab-content widefat">
|
339 |
-
<div class="wcf-cs-fields">
|
340 |
-
<div class="wcf-cs-checkbox-field">
|
341 |
-
<?php
|
342 |
-
|
343 |
-
$layout_pro_option = array();
|
344 |
-
|
345 |
-
if ( ! _is_cartflows_pro() ) {
|
346 |
-
$layout_pro_option = array(
|
347 |
-
'one-column' => __( 'One Column (Available in CartFlows Pro) ', 'cartflows' ),
|
348 |
-
);
|
349 |
-
}
|
350 |
-
|
351 |
-
echo wcf()->meta->get_select_field(
|
352 |
-
array(
|
353 |
-
'label' => __( 'Checkout Skin', 'cartflows' ),
|
354 |
-
'name' => 'wcf-checkout-layout',
|
355 |
-
'value' => $options['wcf-checkout-layout'],
|
356 |
-
'options' => array(
|
357 |
-
'one-column' => __( 'One Column', 'cartflows' ),
|
358 |
-
'two-column' => __( 'Two Column', 'cartflows' ),
|
359 |
-
),
|
360 |
-
'pro-options' => $layout_pro_option,
|
361 |
-
|
362 |
-
)
|
363 |
-
);
|
364 |
-
|
365 |
-
echo wcf()->meta->get_color_picker_field(
|
366 |
-
array(
|
367 |
-
'label' => __( 'Primary Color', 'cartflows' ),
|
368 |
-
'name' => 'wcf-primary-color',
|
369 |
-
'value' => $options['wcf-primary-color'],
|
370 |
-
)
|
371 |
-
);
|
372 |
-
|
373 |
-
echo wcf()->meta->get_font_family_field(
|
374 |
-
array(
|
375 |
-
'for' => 'wcf-base',
|
376 |
-
'label' => __( 'Font Family', 'cartflows' ),
|
377 |
-
'name' => 'wcf-base-font-family',
|
378 |
-
'value' => $options['wcf-base-font-family'],
|
379 |
-
)
|
380 |
-
);
|
381 |
-
|
382 |
-
echo wcf()->meta->get_checkbox_field(
|
383 |
-
array(
|
384 |
-
'label' => __( 'Advance Options', 'cartflows' ),
|
385 |
-
'name' => 'wcf-advance-options-fields',
|
386 |
-
'value' => $options['wcf-advance-options-fields'],
|
387 |
-
'after' => 'Enable',
|
388 |
-
)
|
389 |
-
);
|
390 |
-
?>
|
391 |
-
</div>
|
392 |
-
<div class="wcf-cs-fields-options">
|
393 |
-
<?php
|
394 |
-
echo wcf()->meta->get_section(
|
395 |
-
array(
|
396 |
-
'label' => __( 'Heading', 'cartflows' ),
|
397 |
-
)
|
398 |
-
);
|
399 |
-
|
400 |
-
echo wcf()->meta->get_color_picker_field(
|
401 |
-
array(
|
402 |
-
'label' => __( 'Heading Color', 'cartflows' ),
|
403 |
-
'name' => 'wcf-heading-color',
|
404 |
-
'value' => $options['wcf-heading-color'],
|
405 |
-
)
|
406 |
-
);
|
407 |
-
|
408 |
-
echo wcf()->meta->get_font_family_field(
|
409 |
-
array(
|
410 |
-
'for' => 'wcf-heading',
|
411 |
-
'label' => __( 'Font Family', 'cartflows' ),
|
412 |
-
'name' => 'wcf-heading-font-family',
|
413 |
-
'value' => $options['wcf-heading-font-family'],
|
414 |
-
)
|
415 |
-
);
|
416 |
-
|
417 |
-
echo wcf()->meta->get_font_weight_field(
|
418 |
-
array(
|
419 |
-
'for' => 'wcf-heading',
|
420 |
-
'label' => __( 'Font Weight', 'cartflows' ),
|
421 |
-
'name' => 'wcf-heading-font-weight',
|
422 |
-
'value' => $options['wcf-heading-font-weight'],
|
423 |
-
)
|
424 |
-
);
|
425 |
-
|
426 |
-
echo wcf()->meta->get_section(
|
427 |
-
array(
|
428 |
-
'label' => __( 'Input Fields', 'cartflows' ),
|
429 |
-
)
|
430 |
-
);
|
431 |
-
|
432 |
-
$fields_skin_pro_option = array();
|
433 |
-
|
434 |
-
if ( ! _is_cartflows_pro() ) {
|
435 |
-
$fields_skin_pro_option = array(
|
436 |
-
'skin-one' => __( 'Floating Labels (Available in CartFlows Pro)', 'cartflows' ),
|
437 |
-
);
|
438 |
-
}
|
439 |
-
|
440 |
-
echo wcf()->meta->get_select_field(
|
441 |
-
array(
|
442 |
-
'label' => __( 'Style', 'cartflows' ),
|
443 |
-
'name' => 'wcf-fields-skins',
|
444 |
-
'value' => $options['wcf-fields-skins'],
|
445 |
-
'options' => array(
|
446 |
-
'default' => __( 'Default', 'cartflows' ),
|
447 |
-
'style-one' => __( 'Floating Labels', 'cartflows' ),
|
448 |
-
),
|
449 |
-
'pro-options' => $fields_skin_pro_option,
|
450 |
-
|
451 |
-
)
|
452 |
-
);
|
453 |
-
|
454 |
-
echo wcf()->meta->get_font_family_field(
|
455 |
-
array(
|
456 |
-
'for' => 'wcf-input',
|
457 |
-
'label' => __( 'Font Family', 'cartflows' ),
|
458 |
-
'name' => 'wcf-input-font-family',
|
459 |
-
'value' => $options['wcf-input-font-family'],
|
460 |
-
)
|
461 |
-
);
|
462 |
-
|
463 |
-
echo wcf()->meta->get_font_weight_field(
|
464 |
-
array(
|
465 |
-
'for' => 'wcf-input',
|
466 |
-
'label' => __( 'Font Weight', 'cartflows' ),
|
467 |
-
'name' => 'wcf-input-font-weight',
|
468 |
-
'value' => $options['wcf-input-font-weight'],
|
469 |
-
)
|
470 |
-
);
|
471 |
-
|
472 |
-
echo wcf()->meta->get_select_field(
|
473 |
-
array(
|
474 |
-
'label' => __( 'Size', 'cartflows' ),
|
475 |
-
'name' => 'wcf-input-field-size',
|
476 |
-
'value' => $options['wcf-input-field-size'],
|
477 |
-
'options' => array(
|
478 |
-
'33px' => __( 'Extra Small', 'cartflows' ),
|
479 |
-
'38px' => __( 'Small', 'cartflows' ),
|
480 |
-
'44px' => __( 'Medium', 'cartflows' ),
|
481 |
-
'58px' => __( 'Large', 'cartflows' ),
|
482 |
-
'68px' => __( 'Extra Large', 'cartflows' ),
|
483 |
-
'custom' => __( 'Custom', 'cartflows' ),
|
484 |
-
),
|
485 |
-
)
|
486 |
-
);
|
487 |
-
|
488 |
-
echo wcf()->meta->get_number_field(
|
489 |
-
array(
|
490 |
-
'label' => __( 'Top Bottom Spacing', 'cartflows' ),
|
491 |
-
'name' => 'wcf-field-tb-padding',
|
492 |
-
'value' => $options['wcf-field-tb-padding'],
|
493 |
-
)
|
494 |
-
);
|
495 |
-
|
496 |
-
echo wcf()->meta->get_number_field(
|
497 |
-
array(
|
498 |
-
'label' => __( 'Left Right Spacing', 'cartflows' ),
|
499 |
-
'name' => 'wcf-field-lr-padding',
|
500 |
-
'value' => $options['wcf-field-lr-padding'],
|
501 |
-
)
|
502 |
-
);
|
503 |
-
|
504 |
-
echo wcf()->meta->get_color_picker_field(
|
505 |
-
array(
|
506 |
-
'label' => __( 'Text / Placeholder Color', 'cartflows' ),
|
507 |
-
'name' => 'wcf-field-color',
|
508 |
-
'value' => $options['wcf-field-color'],
|
509 |
-
)
|
510 |
-
);
|
511 |
-
|
512 |
-
echo wcf()->meta->get_color_picker_field(
|
513 |
-
array(
|
514 |
-
'label' => __( 'Background Color', 'cartflows' ),
|
515 |
-
'name' => 'wcf-field-bg-color',
|
516 |
-
'value' => $options['wcf-field-bg-color'],
|
517 |
-
)
|
518 |
-
);
|
519 |
-
|
520 |
-
echo wcf()->meta->get_color_picker_field(
|
521 |
-
array(
|
522 |
-
'label' => __( 'Border Color', 'cartflows' ),
|
523 |
-
'name' => 'wcf-field-border-color',
|
524 |
-
'value' => $options['wcf-field-border-color'],
|
525 |
-
)
|
526 |
-
);
|
527 |
-
echo wcf()->meta->get_color_picker_field(
|
528 |
-
array(
|
529 |
-
'label' => __( 'Label Color', 'cartflows' ),
|
530 |
-
'name' => 'wcf-field-label-color',
|
531 |
-
'value' => $options['wcf-field-label-color'],
|
532 |
-
)
|
533 |
-
);
|
534 |
-
|
535 |
-
?>
|
536 |
-
</div>
|
537 |
-
<div class="wcf-cs-button-options">
|
538 |
-
<?php
|
539 |
-
|
540 |
-
echo wcf()->meta->get_section(
|
541 |
-
array(
|
542 |
-
'label' => __( 'Buttons', 'cartflows' ),
|
543 |
-
)
|
544 |
-
);
|
545 |
-
|
546 |
-
echo wcf()->meta->get_font_family_field(
|
547 |
-
array(
|
548 |
-
'for' => 'wcf-button',
|
549 |
-
'label' => __( 'Font Family', 'cartflows' ),
|
550 |
-
'name' => 'wcf-button-font-family',
|
551 |
-
'value' => $options['wcf-button-font-family'],
|
552 |
-
)
|
553 |
-
);
|
554 |
-
|
555 |
-
echo wcf()->meta->get_font_weight_field(
|
556 |
-
array(
|
557 |
-
'for' => 'wcf-button',
|
558 |
-
'label' => __( 'Font Weight', 'cartflows' ),
|
559 |
-
'name' => 'wcf-button-font-weight',
|
560 |
-
'value' => $options['wcf-button-font-weight'],
|
561 |
-
)
|
562 |
-
);
|
563 |
-
|
564 |
-
echo wcf()->meta->get_select_field(
|
565 |
-
array(
|
566 |
-
'label' => __( 'Size', 'cartflows' ),
|
567 |
-
'name' => 'wcf-input-button-size',
|
568 |
-
'value' => $options['wcf-input-button-size'],
|
569 |
-
'options' => array(
|
570 |
-
'33px' => __( 'Extra Small', 'cartflows' ),
|
571 |
-
'38px' => __( 'Small', 'cartflows' ),
|
572 |
-
'44px' => __( 'Medium', 'cartflows' ),
|
573 |
-
'58px' => __( 'Large', 'cartflows' ),
|
574 |
-
'68px' => __( 'Extra Large', 'cartflows' ),
|
575 |
-
'custom' => __( 'Custom', 'cartflows' ),
|
576 |
-
),
|
577 |
-
)
|
578 |
-
);
|
579 |
-
|
580 |
-
echo wcf()->meta->get_number_field(
|
581 |
-
array(
|
582 |
-
'label' => __( 'Top Bottom Spacing', 'cartflows' ),
|
583 |
-
'name' => 'wcf-submit-tb-padding',
|
584 |
-
'value' => $options['wcf-submit-tb-padding'],
|
585 |
-
)
|
586 |
-
);
|
587 |
-
|
588 |
-
echo wcf()->meta->get_number_field(
|
589 |
-
array(
|
590 |
-
'label' => __( 'Left Right Spacing', 'cartflows' ),
|
591 |
-
'name' => 'wcf-submit-lr-padding',
|
592 |
-
'value' => $options['wcf-submit-lr-padding'],
|
593 |
-
)
|
594 |
-
);
|
595 |
-
|
596 |
-
echo wcf()->meta->get_color_picker_field(
|
597 |
-
array(
|
598 |
-
'label' => __( 'Text Color', 'cartflows' ),
|
599 |
-
'name' => 'wcf-submit-color',
|
600 |
-
'value' => $options['wcf-submit-color'],
|
601 |
-
)
|
602 |
-
);
|
603 |
-
|
604 |
-
echo wcf()->meta->get_color_picker_field(
|
605 |
-
array(
|
606 |
-
'label' => __( 'Text Hover Color', 'cartflows' ),
|
607 |
-
'name' => 'wcf-submit-hover-color',
|
608 |
-
'value' => $options['wcf-submit-hover-color'],
|
609 |
-
)
|
610 |
-
);
|
611 |
-
|
612 |
-
echo wcf()->meta->get_color_picker_field(
|
613 |
-
array(
|
614 |
-
'label' => __( 'Background Color', 'cartflows' ),
|
615 |
-
'name' => 'wcf-submit-bg-color',
|
616 |
-
'value' => $options['wcf-submit-bg-color'],
|
617 |
-
)
|
618 |
-
);
|
619 |
-
|
620 |
-
echo wcf()->meta->get_color_picker_field(
|
621 |
-
array(
|
622 |
-
'label' => __( 'Background Hover Color', 'cartflows' ),
|
623 |
-
'name' => 'wcf-submit-bg-hover-color',
|
624 |
-
'value' => $options['wcf-submit-bg-hover-color'],
|
625 |
-
)
|
626 |
-
);
|
627 |
-
|
628 |
-
echo wcf()->meta->get_color_picker_field(
|
629 |
-
array(
|
630 |
-
'label' => __( 'Border Color', 'cartflows' ),
|
631 |
-
'name' => 'wcf-submit-border-color',
|
632 |
-
'value' => $options['wcf-submit-border-color'],
|
633 |
-
)
|
634 |
-
);
|
635 |
-
|
636 |
-
echo wcf()->meta->get_color_picker_field(
|
637 |
-
array(
|
638 |
-
'label' => __( 'Border Hover Color', 'cartflows' ),
|
639 |
-
'name' => 'wcf-submit-border-hover-color',
|
640 |
-
'value' => $options['wcf-submit-border-hover-color'],
|
641 |
-
)
|
642 |
-
);
|
643 |
-
|
644 |
-
?>
|
645 |
-
</div>
|
646 |
-
<div class="wcf-cs-section-options">
|
647 |
-
<?php
|
648 |
-
|
649 |
-
echo wcf()->meta->get_section(
|
650 |
-
array(
|
651 |
-
'label' => __( 'Sections', 'cartflows' ),
|
652 |
-
)
|
653 |
-
);
|
654 |
-
|
655 |
-
echo wcf()->meta->get_color_picker_field(
|
656 |
-
array(
|
657 |
-
'label' => __( 'Highlight Area Background Color', 'cartflows' ),
|
658 |
-
'name' => 'wcf-hl-bg-color',
|
659 |
-
'value' => $options['wcf-hl-bg-color'],
|
660 |
-
)
|
661 |
-
);
|
662 |
-
|
663 |
-
echo wcf()->meta->get_hidden_field(
|
664 |
-
array(
|
665 |
-
'name' => 'wcf-field-google-font-url',
|
666 |
-
'value' => $options['wcf-field-google-font-url'],
|
667 |
-
)
|
668 |
-
);
|
669 |
-
?>
|
670 |
-
</div>
|
671 |
-
<?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?>
|
672 |
-
</div>
|
673 |
-
</div>
|
674 |
-
<?php
|
675 |
-
}
|
676 |
-
|
677 |
-
|
678 |
-
/**
|
679 |
-
* Tab Header (Used for add logo into header)
|
680 |
-
*
|
681 |
-
* @param array $options options.
|
682 |
-
* @param int $post_id post ID.
|
683 |
-
*/
|
684 |
-
function tab_header_content( $options, $post_id ) {
|
685 |
-
?>
|
686 |
-
|
687 |
-
<div class="wcf-checkout-header wcf-tab-content widefat">
|
688 |
-
<?php
|
689 |
-
|
690 |
-
$layout_pro_option = array();
|
691 |
-
|
692 |
-
echo wcf()->meta->get_image_field(
|
693 |
-
array(
|
694 |
-
'name' => 'wcf-header-logo-image',
|
695 |
-
'value' => $options['wcf-header-logo-image'],
|
696 |
-
'label' => __( 'Header Logo', 'cartflows' ),
|
697 |
-
)
|
698 |
-
);
|
699 |
-
|
700 |
-
echo wcf()->meta->get_number_field(
|
701 |
-
array(
|
702 |
-
'name' => 'wcf-header-logo-width',
|
703 |
-
'value' => $options['wcf-header-logo-width'],
|
704 |
-
'label' => __( 'Logo Width (In px)', 'cartflows' ),
|
705 |
-
)
|
706 |
-
);
|
707 |
-
?>
|
708 |
-
<?php do_action( '
|
709 |
-
</div>
|
710 |
-
<?php
|
711 |
-
}
|
712 |
-
/**
|
713 |
-
* Get metabox options
|
714 |
-
*
|
715 |
-
* @param int $post_id post ID.
|
716 |
-
*/
|
717 |
-
public static function get_meta_option( $post_id ) {
|
718 |
-
|
719 |
-
if ( null === self::$meta_option ) {
|
720 |
-
|
721 |
-
/**
|
722 |
-
* Set metabox options
|
723 |
-
*
|
724 |
-
* @see http://php.net/manual/en/filter.filters.sanitize.php
|
725 |
-
*/
|
726 |
-
self::$meta_option = wcf()->options->get_checkout_fields( $post_id );
|
727 |
-
}
|
728 |
-
|
729 |
-
return self::$meta_option;
|
730 |
-
}
|
731 |
-
|
732 |
-
/**
|
733 |
-
* Metabox Save
|
734 |
-
*
|
735 |
-
* @param number $post_id Post ID.
|
736 |
-
* @return void
|
737 |
-
*/
|
738 |
-
function save_meta_box( $post_id ) {
|
739 |
-
|
740 |
-
// Checks save status.
|
741 |
-
$is_autosave = wp_is_post_autosave( $post_id );
|
742 |
-
$is_revision = wp_is_post_revision( $post_id );
|
743 |
-
|
744 |
-
$is_valid_nonce = ( isset( $_POST['nonce-checkout-step-meta'] ) && wp_verify_nonce( $_POST['nonce-checkout-step-meta'], 'save-nonce-checkout-step-meta' ) ) ? true : false;
|
745 |
-
|
746 |
-
// Exits script depending on save status.
|
747 |
-
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
748 |
-
return;
|
749 |
-
}
|
750 |
-
|
751 |
-
wcf()->options->save_checkout_fields( $post_id );
|
752 |
-
}
|
753 |
-
|
754 |
-
}
|
755 |
-
|
756 |
-
/**
|
757 |
-
* Kicking this off by calling 'get_instance()' method
|
758 |
-
*/
|
759 |
-
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 = array(
|
152 |
+
array(
|
153 |
+
'title' => __( 'Shortcodes', 'cartflows' ),
|
154 |
+
'id' => 'wcf-checkout-shortcodes',
|
155 |
+
'class' => 'wcf-checkout-shortcodes' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
156 |
+
'icon' => 'dashicons-editor-code',
|
157 |
+
'help_text' => 'Help Helpppp...',
|
158 |
+
),
|
159 |
+
array(
|
160 |
+
'title' => __( 'Select Product', 'cartflows' ),
|
161 |
+
'id' => 'wcf-checkout-general',
|
162 |
+
'class' => 'wcf-checkout-general' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
163 |
+
'icon' => 'dashicons-info',
|
164 |
+
),
|
165 |
+
array(
|
166 |
+
'title' => __( 'Order Bump', 'cartflows' ),
|
167 |
+
'id' => 'wcf-product-order-bump',
|
168 |
+
'class' => 'wcf-product-order-bump' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
169 |
+
'icon' => 'dashicons-cart',
|
170 |
+
),
|
171 |
+
array(
|
172 |
+
'title' => __( 'Checkout Design', 'cartflows' ),
|
173 |
+
'id' => 'wcf-checkout-style',
|
174 |
+
'class' => 'wcf-checkout-style' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
175 |
+
'icon' => 'dashicons-admin-customizer',
|
176 |
+
),
|
177 |
+
array(
|
178 |
+
'title' => __( 'Checkout Fields', 'cartflows' ),
|
179 |
+
'id' => 'wcf-checkout-custom-fields',
|
180 |
+
'class' => 'wcf-checkout-custom-fields' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
181 |
+
'icon' => 'dashicons-welcome-widgets-menus',
|
182 |
+
),
|
183 |
+
array(
|
184 |
+
'title' => __( 'Logo ( Optional )', 'cartflows' ),
|
185 |
+
'id' => 'wcf-checkout-header',
|
186 |
+
'class' => 'wcf-checkout-header' === $active_tab ? 'wcf-tab wp-ui-text-highlight active' : 'wcf-tab',
|
187 |
+
'icon' => 'dashicons-format-image',
|
188 |
+
),
|
189 |
+
);
|
190 |
+
|
191 |
+
?>
|
192 |
+
<div class="wcf-checkout-table wcf-metabox-wrap widefat">
|
193 |
+
<div class="wcf-table-container">
|
194 |
+
<div class="wcf-column-left">
|
195 |
+
<div class="wcf-tab-wrapper">
|
196 |
+
|
197 |
+
<?php foreach ( $tabs as $key => $tab ) { ?>
|
198 |
+
<div class="<?php echo esc_attr( $tab['class'] ); ?>" data-tab="<?php echo esc_attr( $tab['id'] ); ?>">
|
199 |
+
<span class="dashicons <?php echo esc_attr( $tab['icon'] ); ?>"></span>
|
200 |
+
<span class="wcf-tab-title"><?php echo esc_html( $tab['title'] ); ?></span>
|
201 |
+
</div>
|
202 |
+
<?php } ?>
|
203 |
+
|
204 |
+
<input type="hidden" id="wcf-active-tab" name="wcf-active-tab" value="<?php echo esc_attr( $active_tab ); ?>" />
|
205 |
+
</div>
|
206 |
+
</div>
|
207 |
+
<div class="wcf-column-right">
|
208 |
+
<?php $this->tab_shortcodes( $options, $post_id ); ?>
|
209 |
+
<?php $this->tab_general( $options, $post_id ); ?>
|
210 |
+
<?php $this->tab_style( $options, $post_id ); ?>
|
211 |
+
<?php $this->tab_product_bump( $options, $post_id ); ?>
|
212 |
+
<?php $this->tab_custom_fields( $options, $post_id ); ?>
|
213 |
+
<?php $this->tab_header_content( $options, $post_id ); ?>
|
214 |
+
<?php $this->right_column_footer( $options, $post_id ); ?>
|
215 |
+
</div>
|
216 |
+
</div>
|
217 |
+
</div>
|
218 |
+
|
219 |
+
<?php
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Shortcodes tab
|
224 |
+
*
|
225 |
+
* @param array $options options.
|
226 |
+
* @param int $post_id post ID.
|
227 |
+
*/
|
228 |
+
function tab_shortcodes( $options, $post_id ) {
|
229 |
+
?>
|
230 |
+
<div class="wcf-checkout-shortcodes wcf-tab-content widefat">
|
231 |
+
|
232 |
+
<?php
|
233 |
+
|
234 |
+
echo wcf()->meta->get_shortcode_field(
|
235 |
+
array(
|
236 |
+
'label' => 'Checkout Page',
|
237 |
+
'name' => 'wcf-checkout-shortcode',
|
238 |
+
'content' => '[cartflows_checkout]',
|
239 |
+
'help' => __( 'Add this shortcode to your checkout page', 'cartflows' ),
|
240 |
+
)
|
241 |
+
);
|
242 |
+
?>
|
243 |
+
</div>
|
244 |
+
<?php
|
245 |
+
}
|
246 |
+
|
247 |
+
|
248 |
+
/**
|
249 |
+
* General tab
|
250 |
+
*
|
251 |
+
* @param array $options options.
|
252 |
+
* @param int $post_id post ID.
|
253 |
+
*/
|
254 |
+
function tab_general( $options, $post_id ) {
|
255 |
+
?>
|
256 |
+
<div class="wcf-checkout-general wcf-tab-content widefat">
|
257 |
+
|
258 |
+
<?php
|
259 |
+
|
260 |
+
echo wcf()->meta->get_product_selection_repeater(
|
261 |
+
array(
|
262 |
+
'name' => 'wcf-checkout-products',
|
263 |
+
'value' => $options['wcf-checkout-products'],
|
264 |
+
'allow_clear' => true,
|
265 |
+
)
|
266 |
+
);
|
267 |
+
|
268 |
+
do_action( 'cartflows_checkout_general_tab_content', $options, $post_id );
|
269 |
+
|
270 |
+
?>
|
271 |
+
</div>
|
272 |
+
<?php
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Product bump tab
|
277 |
+
*
|
278 |
+
* @param array $options options.
|
279 |
+
* @param int $post_id post ID.
|
280 |
+
*/
|
281 |
+
function tab_product_bump( $options, $post_id ) {
|
282 |
+
?>
|
283 |
+
<div class="wcf-product-order-bump wcf-tab-content widefat">
|
284 |
+
<?php
|
285 |
+
if ( ! _is_cartflows_pro() ) {
|
286 |
+
|
287 |
+
echo wcf()->meta->get_description_field(
|
288 |
+
array(
|
289 |
+
'name' => 'wcf-upgrade-to-pro',
|
290 |
+
/* translators: %s: link */
|
291 |
+
'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Order Bump feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
|
292 |
+
)
|
293 |
+
);
|
294 |
+
}
|
295 |
+
?>
|
296 |
+
|
297 |
+
<?php do_action( 'cartflows_order_bump_tab_content', $options, $post_id ); ?>
|
298 |
+
</div>
|
299 |
+
<?php
|
300 |
+
}
|
301 |
+
/**
|
302 |
+
* Tab custom fields
|
303 |
+
*
|
304 |
+
* @param array $options options.
|
305 |
+
* @param int $post_id post ID.
|
306 |
+
*/
|
307 |
+
function tab_custom_fields( $options, $post_id ) {
|
308 |
+
?>
|
309 |
+
<div class="wcf-checkout-custom-fields wcf-tab-content widefat">
|
310 |
+
<?php
|
311 |
+
/* Custom Checkout Fields Section */
|
312 |
+
|
313 |
+
if ( ! _is_cartflows_pro() ) {
|
314 |
+
|
315 |
+
echo wcf()->meta->get_description_field(
|
316 |
+
array(
|
317 |
+
'name' => 'wcf-upgrade-to-pro',
|
318 |
+
/* translators: %s: link */
|
319 |
+
'content' => '<i>' . sprintf( __( 'Upgrade to %1$sCartFlows Pro%2$s for Custom Fields feature', 'cartflows' ), '<a href="https://cartflows.com/" target="_blank">', '</a>' ) . '</i>',
|
320 |
+
)
|
321 |
+
);
|
322 |
+
}
|
323 |
+
?>
|
324 |
+
<?php do_action( 'cartflows_custom_fields_tab_content', $options, $post_id ); ?>
|
325 |
+
</div>
|
326 |
+
<?php
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Tab style
|
331 |
+
*
|
332 |
+
* @param array $options options.
|
333 |
+
* @param int $post_id post ID.
|
334 |
+
*/
|
335 |
+
function tab_style( $options, $post_id ) {
|
336 |
+
?>
|
337 |
+
|
338 |
+
<div class="wcf-checkout-style wcf-tab-content widefat">
|
339 |
+
<div class="wcf-cs-fields">
|
340 |
+
<div class="wcf-cs-checkbox-field">
|
341 |
+
<?php
|
342 |
+
|
343 |
+
$layout_pro_option = array();
|
344 |
+
|
345 |
+
if ( ! _is_cartflows_pro() ) {
|
346 |
+
$layout_pro_option = array(
|
347 |
+
'one-column' => __( 'One Column (Available in CartFlows Pro) ', 'cartflows' ),
|
348 |
+
);
|
349 |
+
}
|
350 |
+
|
351 |
+
echo wcf()->meta->get_select_field(
|
352 |
+
array(
|
353 |
+
'label' => __( 'Checkout Skin', 'cartflows' ),
|
354 |
+
'name' => 'wcf-checkout-layout',
|
355 |
+
'value' => $options['wcf-checkout-layout'],
|
356 |
+
'options' => array(
|
357 |
+
'one-column' => __( 'One Column', 'cartflows' ),
|
358 |
+
'two-column' => __( 'Two Column', 'cartflows' ),
|
359 |
+
),
|
360 |
+
'pro-options' => $layout_pro_option,
|
361 |
+
|
362 |
+
)
|
363 |
+
);
|
364 |
+
|
365 |
+
echo wcf()->meta->get_color_picker_field(
|
366 |
+
array(
|
367 |
+
'label' => __( 'Primary Color', 'cartflows' ),
|
368 |
+
'name' => 'wcf-primary-color',
|
369 |
+
'value' => $options['wcf-primary-color'],
|
370 |
+
)
|
371 |
+
);
|
372 |
+
|
373 |
+
echo wcf()->meta->get_font_family_field(
|
374 |
+
array(
|
375 |
+
'for' => 'wcf-base',
|
376 |
+
'label' => __( 'Font Family', 'cartflows' ),
|
377 |
+
'name' => 'wcf-base-font-family',
|
378 |
+
'value' => $options['wcf-base-font-family'],
|
379 |
+
)
|
380 |
+
);
|
381 |
+
|
382 |
+
echo wcf()->meta->get_checkbox_field(
|
383 |
+
array(
|
384 |
+
'label' => __( 'Advance Options', 'cartflows' ),
|
385 |
+
'name' => 'wcf-advance-options-fields',
|
386 |
+
'value' => $options['wcf-advance-options-fields'],
|
387 |
+
'after' => 'Enable',
|
388 |
+
)
|
389 |
+
);
|
390 |
+
?>
|
391 |
+
</div>
|
392 |
+
<div class="wcf-cs-fields-options">
|
393 |
+
<?php
|
394 |
+
echo wcf()->meta->get_section(
|
395 |
+
array(
|
396 |
+
'label' => __( 'Heading', 'cartflows' ),
|
397 |
+
)
|
398 |
+
);
|
399 |
+
|
400 |
+
echo wcf()->meta->get_color_picker_field(
|
401 |
+
array(
|
402 |
+
'label' => __( 'Heading Color', 'cartflows' ),
|
403 |
+
'name' => 'wcf-heading-color',
|
404 |
+
'value' => $options['wcf-heading-color'],
|
405 |
+
)
|
406 |
+
);
|
407 |
+
|
408 |
+
echo wcf()->meta->get_font_family_field(
|
409 |
+
array(
|
410 |
+
'for' => 'wcf-heading',
|
411 |
+
'label' => __( 'Font Family', 'cartflows' ),
|
412 |
+
'name' => 'wcf-heading-font-family',
|
413 |
+
'value' => $options['wcf-heading-font-family'],
|
414 |
+
)
|
415 |
+
);
|
416 |
+
|
417 |
+
echo wcf()->meta->get_font_weight_field(
|
418 |
+
array(
|
419 |
+
'for' => 'wcf-heading',
|
420 |
+
'label' => __( 'Font Weight', 'cartflows' ),
|
421 |
+
'name' => 'wcf-heading-font-weight',
|
422 |
+
'value' => $options['wcf-heading-font-weight'],
|
423 |
+
)
|
424 |
+
);
|
425 |
+
|
426 |
+
echo wcf()->meta->get_section(
|
427 |
+
array(
|
428 |
+
'label' => __( 'Input Fields', 'cartflows' ),
|
429 |
+
)
|
430 |
+
);
|
431 |
+
|
432 |
+
$fields_skin_pro_option = array();
|
433 |
+
|
434 |
+
if ( ! _is_cartflows_pro() ) {
|
435 |
+
$fields_skin_pro_option = array(
|
436 |
+
'skin-one' => __( 'Floating Labels (Available in CartFlows Pro)', 'cartflows' ),
|
437 |
+
);
|
438 |
+
}
|
439 |
+
|
440 |
+
echo wcf()->meta->get_select_field(
|
441 |
+
array(
|
442 |
+
'label' => __( 'Style', 'cartflows' ),
|
443 |
+
'name' => 'wcf-fields-skins',
|
444 |
+
'value' => $options['wcf-fields-skins'],
|
445 |
+
'options' => array(
|
446 |
+
'default' => __( 'Default', 'cartflows' ),
|
447 |
+
'style-one' => __( 'Floating Labels', 'cartflows' ),
|
448 |
+
),
|
449 |
+
'pro-options' => $fields_skin_pro_option,
|
450 |
+
|
451 |
+
)
|
452 |
+
);
|
453 |
+
|
454 |
+
echo wcf()->meta->get_font_family_field(
|
455 |
+
array(
|
456 |
+
'for' => 'wcf-input',
|
457 |
+
'label' => __( 'Font Family', 'cartflows' ),
|
458 |
+
'name' => 'wcf-input-font-family',
|
459 |
+
'value' => $options['wcf-input-font-family'],
|
460 |
+
)
|
461 |
+
);
|
462 |
+
|
463 |
+
echo wcf()->meta->get_font_weight_field(
|
464 |
+
array(
|
465 |
+
'for' => 'wcf-input',
|
466 |
+
'label' => __( 'Font Weight', 'cartflows' ),
|
467 |
+
'name' => 'wcf-input-font-weight',
|
468 |
+
'value' => $options['wcf-input-font-weight'],
|
469 |
+
)
|
470 |
+
);
|
471 |
+
|
472 |
+
echo wcf()->meta->get_select_field(
|
473 |
+
array(
|
474 |
+
'label' => __( 'Size', 'cartflows' ),
|
475 |
+
'name' => 'wcf-input-field-size',
|
476 |
+
'value' => $options['wcf-input-field-size'],
|
477 |
+
'options' => array(
|
478 |
+
'33px' => __( 'Extra Small', 'cartflows' ),
|
479 |
+
'38px' => __( 'Small', 'cartflows' ),
|
480 |
+
'44px' => __( 'Medium', 'cartflows' ),
|
481 |
+
'58px' => __( 'Large', 'cartflows' ),
|
482 |
+
'68px' => __( 'Extra Large', 'cartflows' ),
|
483 |
+
'custom' => __( 'Custom', 'cartflows' ),
|
484 |
+
),
|
485 |
+
)
|
486 |
+
);
|
487 |
+
|
488 |
+
echo wcf()->meta->get_number_field(
|
489 |
+
array(
|
490 |
+
'label' => __( 'Top Bottom Spacing', 'cartflows' ),
|
491 |
+
'name' => 'wcf-field-tb-padding',
|
492 |
+
'value' => $options['wcf-field-tb-padding'],
|
493 |
+
)
|
494 |
+
);
|
495 |
+
|
496 |
+
echo wcf()->meta->get_number_field(
|
497 |
+
array(
|
498 |
+
'label' => __( 'Left Right Spacing', 'cartflows' ),
|
499 |
+
'name' => 'wcf-field-lr-padding',
|
500 |
+
'value' => $options['wcf-field-lr-padding'],
|
501 |
+
)
|
502 |
+
);
|
503 |
+
|
504 |
+
echo wcf()->meta->get_color_picker_field(
|
505 |
+
array(
|
506 |
+
'label' => __( 'Text / Placeholder Color', 'cartflows' ),
|
507 |
+
'name' => 'wcf-field-color',
|
508 |
+
'value' => $options['wcf-field-color'],
|
509 |
+
)
|
510 |
+
);
|
511 |
+
|
512 |
+
echo wcf()->meta->get_color_picker_field(
|
513 |
+
array(
|
514 |
+
'label' => __( 'Background Color', 'cartflows' ),
|
515 |
+
'name' => 'wcf-field-bg-color',
|
516 |
+
'value' => $options['wcf-field-bg-color'],
|
517 |
+
)
|
518 |
+
);
|
519 |
+
|
520 |
+
echo wcf()->meta->get_color_picker_field(
|
521 |
+
array(
|
522 |
+
'label' => __( 'Border Color', 'cartflows' ),
|
523 |
+
'name' => 'wcf-field-border-color',
|
524 |
+
'value' => $options['wcf-field-border-color'],
|
525 |
+
)
|
526 |
+
);
|
527 |
+
echo wcf()->meta->get_color_picker_field(
|
528 |
+
array(
|
529 |
+
'label' => __( 'Label Color', 'cartflows' ),
|
530 |
+
'name' => 'wcf-field-label-color',
|
531 |
+
'value' => $options['wcf-field-label-color'],
|
532 |
+
)
|
533 |
+
);
|
534 |
+
|
535 |
+
?>
|
536 |
+
</div>
|
537 |
+
<div class="wcf-cs-button-options">
|
538 |
+
<?php
|
539 |
+
|
540 |
+
echo wcf()->meta->get_section(
|
541 |
+
array(
|
542 |
+
'label' => __( 'Buttons', 'cartflows' ),
|
543 |
+
)
|
544 |
+
);
|
545 |
+
|
546 |
+
echo wcf()->meta->get_font_family_field(
|
547 |
+
array(
|
548 |
+
'for' => 'wcf-button',
|
549 |
+
'label' => __( 'Font Family', 'cartflows' ),
|
550 |
+
'name' => 'wcf-button-font-family',
|
551 |
+
'value' => $options['wcf-button-font-family'],
|
552 |
+
)
|
553 |
+
);
|
554 |
+
|
555 |
+
echo wcf()->meta->get_font_weight_field(
|
556 |
+
array(
|
557 |
+
'for' => 'wcf-button',
|
558 |
+
'label' => __( 'Font Weight', 'cartflows' ),
|
559 |
+
'name' => 'wcf-button-font-weight',
|
560 |
+
'value' => $options['wcf-button-font-weight'],
|
561 |
+
)
|
562 |
+
);
|
563 |
+
|
564 |
+
echo wcf()->meta->get_select_field(
|
565 |
+
array(
|
566 |
+
'label' => __( 'Size', 'cartflows' ),
|
567 |
+
'name' => 'wcf-input-button-size',
|
568 |
+
'value' => $options['wcf-input-button-size'],
|
569 |
+
'options' => array(
|
570 |
+
'33px' => __( 'Extra Small', 'cartflows' ),
|
571 |
+
'38px' => __( 'Small', 'cartflows' ),
|
572 |
+
'44px' => __( 'Medium', 'cartflows' ),
|
573 |
+
'58px' => __( 'Large', 'cartflows' ),
|
574 |
+
'68px' => __( 'Extra Large', 'cartflows' ),
|
575 |
+
'custom' => __( 'Custom', 'cartflows' ),
|
576 |
+
),
|
577 |
+
)
|
578 |
+
);
|
579 |
+
|
580 |
+
echo wcf()->meta->get_number_field(
|
581 |
+
array(
|
582 |
+
'label' => __( 'Top Bottom Spacing', 'cartflows' ),
|
583 |
+
'name' => 'wcf-submit-tb-padding',
|
584 |
+
'value' => $options['wcf-submit-tb-padding'],
|
585 |
+
)
|
586 |
+
);
|
587 |
+
|
588 |
+
echo wcf()->meta->get_number_field(
|
589 |
+
array(
|
590 |
+
'label' => __( 'Left Right Spacing', 'cartflows' ),
|
591 |
+
'name' => 'wcf-submit-lr-padding',
|
592 |
+
'value' => $options['wcf-submit-lr-padding'],
|
593 |
+
)
|
594 |
+
);
|
595 |
+
|
596 |
+
echo wcf()->meta->get_color_picker_field(
|
597 |
+
array(
|
598 |
+
'label' => __( 'Text Color', 'cartflows' ),
|
599 |
+
'name' => 'wcf-submit-color',
|
600 |
+
'value' => $options['wcf-submit-color'],
|
601 |
+
)
|
602 |
+
);
|
603 |
+
|
604 |
+
echo wcf()->meta->get_color_picker_field(
|
605 |
+
array(
|
606 |
+
'label' => __( 'Text Hover Color', 'cartflows' ),
|
607 |
+
'name' => 'wcf-submit-hover-color',
|
608 |
+
'value' => $options['wcf-submit-hover-color'],
|
609 |
+
)
|
610 |
+
);
|
611 |
+
|
612 |
+
echo wcf()->meta->get_color_picker_field(
|
613 |
+
array(
|
614 |
+
'label' => __( 'Background Color', 'cartflows' ),
|
615 |
+
'name' => 'wcf-submit-bg-color',
|
616 |
+
'value' => $options['wcf-submit-bg-color'],
|
617 |
+
)
|
618 |
+
);
|
619 |
+
|
620 |
+
echo wcf()->meta->get_color_picker_field(
|
621 |
+
array(
|
622 |
+
'label' => __( 'Background Hover Color', 'cartflows' ),
|
623 |
+
'name' => 'wcf-submit-bg-hover-color',
|
624 |
+
'value' => $options['wcf-submit-bg-hover-color'],
|
625 |
+
)
|
626 |
+
);
|
627 |
+
|
628 |
+
echo wcf()->meta->get_color_picker_field(
|
629 |
+
array(
|
630 |
+
'label' => __( 'Border Color', 'cartflows' ),
|
631 |
+
'name' => 'wcf-submit-border-color',
|
632 |
+
'value' => $options['wcf-submit-border-color'],
|
633 |
+
)
|
634 |
+
);
|
635 |
+
|
636 |
+
echo wcf()->meta->get_color_picker_field(
|
637 |
+
array(
|
638 |
+
'label' => __( 'Border Hover Color', 'cartflows' ),
|
639 |
+
'name' => 'wcf-submit-border-hover-color',
|
640 |
+
'value' => $options['wcf-submit-border-hover-color'],
|
641 |
+
)
|
642 |
+
);
|
643 |
+
|
644 |
+
?>
|
645 |
+
</div>
|
646 |
+
<div class="wcf-cs-section-options">
|
647 |
+
<?php
|
648 |
+
|
649 |
+
echo wcf()->meta->get_section(
|
650 |
+
array(
|
651 |
+
'label' => __( 'Sections', 'cartflows' ),
|
652 |
+
)
|
653 |
+
);
|
654 |
+
|
655 |
+
echo wcf()->meta->get_color_picker_field(
|
656 |
+
array(
|
657 |
+
'label' => __( 'Highlight Area Background Color', 'cartflows' ),
|
658 |
+
'name' => 'wcf-hl-bg-color',
|
659 |
+
'value' => $options['wcf-hl-bg-color'],
|
660 |
+
)
|
661 |
+
);
|
662 |
+
|
663 |
+
echo wcf()->meta->get_hidden_field(
|
664 |
+
array(
|
665 |
+
'name' => 'wcf-field-google-font-url',
|
666 |
+
'value' => $options['wcf-field-google-font-url'],
|
667 |
+
)
|
668 |
+
);
|
669 |
+
?>
|
670 |
+
</div>
|
671 |
+
<?php do_action( 'cartflows_checkout_style_tab_content', $options, $post_id ); ?>
|
672 |
+
</div>
|
673 |
+
</div>
|
674 |
+
<?php
|
675 |
+
}
|
676 |
+
|
677 |
+
|
678 |
+
/**
|
679 |
+
* Tab Header (Used for add logo into header)
|
680 |
+
*
|
681 |
+
* @param array $options options.
|
682 |
+
* @param int $post_id post ID.
|
683 |
+
*/
|
684 |
+
function tab_header_content( $options, $post_id ) {
|
685 |
+
?>
|
686 |
+
|
687 |
+
<div class="wcf-checkout-header wcf-tab-content widefat">
|
688 |
+
<?php
|
689 |
+
|
690 |
+
$layout_pro_option = array();
|
691 |
+
|
692 |
+
echo wcf()->meta->get_image_field(
|
693 |
+
array(
|
694 |
+
'name' => 'wcf-header-logo-image',
|
695 |
+
'value' => $options['wcf-header-logo-image'],
|
696 |
+
'label' => __( 'Header Logo', 'cartflows' ),
|
697 |
+
)
|
698 |
+
);
|
699 |
+
|
700 |
+
echo wcf()->meta->get_number_field(
|
701 |
+
array(
|
702 |
+
'name' => 'wcf-header-logo-width',
|
703 |
+
'value' => $options['wcf-header-logo-width'],
|
704 |
+
'label' => __( 'Logo Width (In px)', 'cartflows' ),
|
705 |
+
)
|
706 |
+
);
|
707 |
+
?>
|
708 |
+
<?php do_action( 'cartflows_checkout_header_tab_content', $options, $post_id ); ?>
|
709 |
+
</div>
|
710 |
+
<?php
|
711 |
+
}
|
712 |
+
/**
|
713 |
+
* Get metabox options
|
714 |
+
*
|
715 |
+
* @param int $post_id post ID.
|
716 |
+
*/
|
717 |
+
public static function get_meta_option( $post_id ) {
|
718 |
+
|
719 |
+
if ( null === self::$meta_option ) {
|
720 |
+
|
721 |
+
/**
|
722 |
+
* Set metabox options
|
723 |
+
*
|
724 |
+
* @see http://php.net/manual/en/filter.filters.sanitize.php
|
725 |
+
*/
|
726 |
+
self::$meta_option = wcf()->options->get_checkout_fields( $post_id );
|
727 |
+
}
|
728 |
+
|
729 |
+
return self::$meta_option;
|
730 |
+
}
|
731 |
+
|
732 |
+
/**
|
733 |
+
* Metabox Save
|
734 |
+
*
|
735 |
+
* @param number $post_id Post ID.
|
736 |
+
* @return void
|
737 |
+
*/
|
738 |
+
function save_meta_box( $post_id ) {
|
739 |
+
|
740 |
+
// Checks save status.
|
741 |
+
$is_autosave = wp_is_post_autosave( $post_id );
|
742 |
+
$is_revision = wp_is_post_revision( $post_id );
|
743 |
+
|
744 |
+
$is_valid_nonce = ( isset( $_POST['nonce-checkout-step-meta'] ) && wp_verify_nonce( $_POST['nonce-checkout-step-meta'], 'save-nonce-checkout-step-meta' ) ) ? true : false;
|
745 |
+
|
746 |
+
// Exits script depending on save status.
|
747 |
+
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
748 |
+
return;
|
749 |
+
}
|
750 |
+
|
751 |
+
wcf()->options->save_checkout_fields( $post_id );
|
752 |
+
}
|
753 |
+
|
754 |
+
}
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Kicking this off by calling 'get_instance()' method
|
758 |
+
*/
|
759 |
+
Cartflows_Checkout_Meta::get_instance();
|
modules/flow/classes/class-cartflows-step-post-type.php
CHANGED
@@ -1,465 +1,465 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Step post type.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Step_Post_Type {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Member Variable
|
25 |
-
*
|
26 |
-
* @var body_classes
|
27 |
-
*/
|
28 |
-
private $body_classes = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Initiator
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
if ( ! isset( self::$instance ) ) {
|
35 |
-
self::$instance = new self;
|
36 |
-
}
|
37 |
-
return self::$instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor
|
42 |
-
*/
|
43 |
-
public function __construct() {
|
44 |
-
|
45 |
-
add_action( 'init', array( $this, 'step_post_type' ) );
|
46 |
-
add_action( 'init', array( $this, 'add_wp_templates_support' ) );
|
47 |
-
add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
|
48 |
-
add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 );
|
49 |
-
add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
|
50 |
-
add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ), 20 );
|
51 |
-
|
52 |
-
add_filter( 'template_include', array( $this, 'load_page_template' ), 99 );
|
53 |
-
}
|
54 |
-
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Trys to load page.php for a header, footer or part theme layout.
|
58 |
-
*
|
59 |
-
* @since 1.0.0
|
60 |
-
* @param string $template The current template to be loaded.
|
61 |
-
* @return string
|
62 |
-
*/
|
63 |
-
function load_page_template( $template ) {
|
64 |
-
|
65 |
-
global $post;
|
66 |
-
|
67 |
-
if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Remove Next/Prev Navigation
|
71 |
-
* add_filter('next_post_link', '__return_empty_string');
|
72 |
-
* add_filter('previous_post_link', '__return_empty_string');
|
73 |
-
*
|
74 |
-
* $page = locate_template( array( 'page.php' ) );
|
75 |
-
*
|
76 |
-
* if ( ! empty( $page ) ) {
|
77 |
-
* return $page;
|
78 |
-
* }
|
79 |
-
*/
|
80 |
-
|
81 |
-
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
82 |
-
|
83 |
-
$page_template = apply_filters( 'cartflows_page_template', $page_template );
|
84 |
-
|
85 |
-
$file = '';
|
86 |
-
|
87 |
-
switch ( $page_template ) {
|
88 |
-
|
89 |
-
case 'cartflows-default':
|
90 |
-
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
91 |
-
$this->body_classes[] = $page_template;
|
92 |
-
break;
|
93 |
-
case 'cartflows-canvas':
|
94 |
-
$file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
|
95 |
-
$this->body_classes[] = $page_template;
|
96 |
-
break;
|
97 |
-
default:
|
98 |
-
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
99 |
-
$this->body_classes[] = 'cartflows-default';
|
100 |
-
break;
|
101 |
-
}
|
102 |
-
|
103 |
-
// Just to be safe, we check if the file exist first.
|
104 |
-
if ( file_exists( $file ) ) {
|
105 |
-
|
106 |
-
/* Add Body Class */
|
107 |
-
add_filter( 'body_class', [ $this, 'body_class' ] );
|
108 |
-
|
109 |
-
return $file;
|
110 |
-
} else {
|
111 |
-
echo $file;
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
return $template;
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Body classes.
|
120 |
-
*
|
121 |
-
* @since 1.0.0
|
122 |
-
* @param array $classes Body classes.
|
123 |
-
* @return array
|
124 |
-
*/
|
125 |
-
function body_class( $classes = [] ) {
|
126 |
-
|
127 |
-
$classes = array_merge( $classes, $this->body_classes );
|
128 |
-
|
129 |
-
return $classes;
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Create custom post type
|
134 |
-
*/
|
135 |
-
function step_post_type() {
|
136 |
-
|
137 |
-
$labels = array(
|
138 |
-
'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
|
139 |
-
'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
|
140 |
-
'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
|
141 |
-
'all_items' => esc_html__( 'All Steps', 'cartflows' ),
|
142 |
-
'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
|
143 |
-
'view_item' => esc_html__( 'View Step', 'cartflows' ),
|
144 |
-
'add_new' => esc_html__( 'Add New', 'cartflows' ),
|
145 |
-
'update_item' => esc_html__( 'Update Step', 'cartflows' ),
|
146 |
-
'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
|
147 |
-
'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
|
148 |
-
);
|
149 |
-
|
150 |
-
$args = array(
|
151 |
-
'labels' => $labels,
|
152 |
-
'public' => true,
|
153 |
-
'query_var' => true,
|
154 |
-
'can_export' => true,
|
155 |
-
'exclude_from_search' => true,
|
156 |
-
'show_ui' => true,
|
157 |
-
'show_in_menu' => false,
|
158 |
-
'show_in_admin_bar' => true,
|
159 |
-
'supports' => array( 'title', 'editor', 'elementor' ),
|
160 |
-
'capability_type' => 'post',
|
161 |
-
'capabilities' => array(
|
162 |
-
'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
|
163 |
-
),
|
164 |
-
'map_meta_cap' => true,
|
165 |
-
);
|
166 |
-
|
167 |
-
register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
|
168 |
-
|
169 |
-
$args = array(
|
170 |
-
'label' => __( 'Step Type', 'cartflows' ),
|
171 |
-
'public' => false,
|
172 |
-
'rewrite' => false,
|
173 |
-
'hierarchical' => false,
|
174 |
-
);
|
175 |
-
|
176 |
-
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
|
177 |
-
|
178 |
-
$args = array(
|
179 |
-
'label' => __( 'Step Flow', 'cartflows' ),
|
180 |
-
'public' => false,
|
181 |
-
'rewrite' => false,
|
182 |
-
'hierarchical' => false,
|
183 |
-
);
|
184 |
-
|
185 |
-
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Register 'Elementor' & 'Beaver Builder' site types.
|
189 |
-
*
|
190 |
-
* @see self::add_terms();
|
191 |
-
*/
|
192 |
-
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
193 |
-
|
194 |
-
$terms = array(
|
195 |
-
array(
|
196 |
-
'name' => __( 'Landing', 'cartflows' ),
|
197 |
-
'args' => array(
|
198 |
-
'slug' => 'landing',
|
199 |
-
),
|
200 |
-
),
|
201 |
-
array(
|
202 |
-
'name' => __( 'Checkout', 'cartflows' ),
|
203 |
-
'args' => array(
|
204 |
-
'slug' => 'checkout',
|
205 |
-
),
|
206 |
-
),
|
207 |
-
array(
|
208 |
-
'name' => __( 'Thank You', 'cartflows' ),
|
209 |
-
'args' => array(
|
210 |
-
'slug' => 'thankyou',
|
211 |
-
),
|
212 |
-
),
|
213 |
-
array(
|
214 |
-
'name' => __( 'Upsell', 'cartflows' ),
|
215 |
-
'args' => array(
|
216 |
-
'slug' => 'upsell',
|
217 |
-
),
|
218 |
-
),
|
219 |
-
array(
|
220 |
-
'name' => __( 'Downsell', 'cartflows' ),
|
221 |
-
'args' => array(
|
222 |
-
'slug' => 'downsell',
|
223 |
-
),
|
224 |
-
),
|
225 |
-
);
|
226 |
-
|
227 |
-
$this->add_terms( $taxonomy, $terms );
|
228 |
-
}
|
229 |
-
|
230 |
-
/**
|
231 |
-
* Add WordPress templates.
|
232 |
-
*
|
233 |
-
* Adds Cartflows templates to steps
|
234 |
-
*
|
235 |
-
* @since 1.0.0
|
236 |
-
* @access public
|
237 |
-
*/
|
238 |
-
function add_wp_templates_support() {
|
239 |
-
add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Add page templates.
|
244 |
-
*
|
245 |
-
* @since 1.0.0
|
246 |
-
* @access public
|
247 |
-
*
|
248 |
-
* @param array $page_templates Array of page templates.
|
249 |
-
*
|
250 |
-
* @param object $wp_theme wp theme.
|
251 |
-
* @param object $post post.
|
252 |
-
*
|
253 |
-
* @return array Page templates.
|
254 |
-
*/
|
255 |
-
function add_page_templates( $page_templates, $wp_theme, $post ) {
|
256 |
-
|
257 |
-
$page_templates = array(
|
258 |
-
'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
|
259 |
-
);
|
260 |
-
|
261 |
-
return $page_templates;
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Have WordPress match postname to any of our public post types.
|
266 |
-
* All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
|
267 |
-
* By default, WordPress only accounts for posts and pages where the slug is /post-name/.
|
268 |
-
*
|
269 |
-
* @param string $query query statement.
|
270 |
-
*/
|
271 |
-
function add_cpt_post_names_to_main_query( $query ) {
|
272 |
-
|
273 |
-
// Bail if this is not the main query.
|
274 |
-
if ( ! $query->is_main_query() ) {
|
275 |
-
return;
|
276 |
-
}
|
277 |
-
|
278 |
-
// Bail if this query doesn't match our very specific rewrite rule.
|
279 |
-
if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) {
|
280 |
-
return;
|
281 |
-
}
|
282 |
-
|
283 |
-
// Bail if we're not querying based on the post name.
|
284 |
-
if ( empty( $query->query['name'] ) ) {
|
285 |
-
return;
|
286 |
-
}
|
287 |
-
|
288 |
-
// Add cartflows step post type to existing post type array.
|
289 |
-
if ( isset( $query->query_vars['post_type'] ) && is_array( $query->query_vars['post_type'] ) ) {
|
290 |
-
|
291 |
-
$post_types = $query->query_vars['post_type'];
|
292 |
-
|
293 |
-
$post_types[] = CARTFLOWS_STEP_POST_TYPE;
|
294 |
-
|
295 |
-
$query->set( 'post_type', $post_types );
|
296 |
-
|
297 |
-
} else {
|
298 |
-
|
299 |
-
// Add CPT to the list of post types WP will include when it queries based on the post name.
|
300 |
-
$query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) );
|
301 |
-
}
|
302 |
-
}
|
303 |
-
|
304 |
-
/**
|
305 |
-
* Modify permalink
|
306 |
-
*
|
307 |
-
* @param string $post_link post link.
|
308 |
-
* @param array $post post data.
|
309 |
-
* @param string $leavename leave name.
|
310 |
-
* @return string
|
311 |
-
*/
|
312 |
-
function post_type_permalinks( $post_link, $post, $leavename ) {
|
313 |
-
|
314 |
-
// If elementor page preview, return post link as it is.
|
315 |
-
if ( isset( $_REQUEST['elementor-preview'] ) ) {
|
316 |
-
return $post_link;
|
317 |
-
}
|
318 |
-
|
319 |
-
$structure = get_option( 'permalink_structure' );
|
320 |
-
|
321 |
-
if ( '/%postname%/' === $structure ) {
|
322 |
-
|
323 |
-
if ( isset( $post->post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) {
|
324 |
-
|
325 |
-
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
|
326 |
-
}
|
327 |
-
}
|
328 |
-
|
329 |
-
return $post_link;
|
330 |
-
}
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Prevent slug duplicated
|
334 |
-
*
|
335 |
-
* @param string $slug post slug.
|
336 |
-
* @param int $post_ID post id.
|
337 |
-
* @param string $post_status post status.
|
338 |
-
* @param string $post_type post type.
|
339 |
-
* @param int $post_parent post parent id.
|
340 |
-
* @param string $original_slug original slug.
|
341 |
-
* @return string
|
342 |
-
*/
|
343 |
-
function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
344 |
-
|
345 |
-
$check_post_types = array(
|
346 |
-
'post',
|
347 |
-
'page',
|
348 |
-
CARTFLOWS_STEP_POST_TYPE,
|
349 |
-
);
|
350 |
-
|
351 |
-
if ( ! in_array( $post_type, $check_post_types ) ) {
|
352 |
-
return $slug;
|
353 |
-
}
|
354 |
-
|
355 |
-
if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
|
356 |
-
// Saving a post, check for duplicates in POST or PAGE post types.
|
357 |
-
$post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
|
358 |
-
$page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
|
359 |
-
|
360 |
-
if ( $post_match || $page_match ) {
|
361 |
-
$slug .= '-2';
|
362 |
-
}
|
363 |
-
} else {
|
364 |
-
|
365 |
-
// Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
|
366 |
-
$custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
|
367 |
-
|
368 |
-
if ( $custom_post_type_match ) {
|
369 |
-
$slug .= '-2';
|
370 |
-
}
|
371 |
-
}
|
372 |
-
|
373 |
-
return $slug;
|
374 |
-
}
|
375 |
-
|
376 |
-
/**
|
377 |
-
* Add Update messages for any custom post type
|
378 |
-
*
|
379 |
-
* @param array $messages Array of default messages.
|
380 |
-
*/
|
381 |
-
function post_update_messages( $messages ) {
|
382 |
-
|
383 |
-
$custom_post_type = get_post_type( get_the_ID() );
|
384 |
-
|
385 |
-
if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
|
386 |
-
|
387 |
-
$obj = get_post_type_object( $custom_post_type );
|
388 |
-
$singular_name = $obj->labels->singular_name;
|
389 |
-
$messages[ $custom_post_type ] = array(
|
390 |
-
0 => '', // Unused. Messages start at index 1.
|
391 |
-
/* translators: %s: singular custom post type name */
|
392 |
-
1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
393 |
-
/* translators: %s: singular custom post type name */
|
394 |
-
2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
|
395 |
-
/* translators: %s: singular custom post type name */
|
396 |
-
3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
|
397 |
-
/* translators: %s: singular custom post type name */
|
398 |
-
4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
399 |
-
/* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
|
400 |
-
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
401 |
-
/* translators: %s: singular custom post type name */
|
402 |
-
6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
|
403 |
-
/* translators: %s: singular custom post type name */
|
404 |
-
7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
|
405 |
-
/* translators: %s: singular custom post type name */
|
406 |
-
8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
|
407 |
-
/* translators: %s: singular custom post type name */
|
408 |
-
9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
|
409 |
-
/* translators: %s: singular custom post type name */
|
410 |
-
10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
|
411 |
-
);
|
412 |
-
}
|
413 |
-
|
414 |
-
return $messages;
|
415 |
-
}
|
416 |
-
|
417 |
-
/**
|
418 |
-
* Add Terms for Taxonomy.
|
419 |
-
*
|
420 |
-
* => Example.
|
421 |
-
*
|
422 |
-
* $taxonomy = '{taxonomy}';
|
423 |
-
* $terms = array(
|
424 |
-
* array(
|
425 |
-
* 'name' => 'Free',
|
426 |
-
* ),
|
427 |
-
* array(
|
428 |
-
* 'name' => 'Premium',
|
429 |
-
* ),
|
430 |
-
* );
|
431 |
-
*
|
432 |
-
* self::add_terms( $taxonomy, $terms );
|
433 |
-
*
|
434 |
-
* @since 1.0.0
|
435 |
-
* @param string $taxonomy Taxonomy Name.
|
436 |
-
* @param array $terms Terms list.
|
437 |
-
* @return void
|
438 |
-
*/
|
439 |
-
function add_terms( $taxonomy = '', $terms = array() ) {
|
440 |
-
|
441 |
-
foreach ( $terms as $key => $term ) {
|
442 |
-
|
443 |
-
$term_exist = term_exists( $term['name'], $taxonomy );
|
444 |
-
|
445 |
-
if ( empty( $term_exist ) ) {
|
446 |
-
|
447 |
-
/**
|
448 |
-
* Add additional args if passed from request.
|
449 |
-
*
|
450 |
-
* @see https://codex.wordpress.org/Function_Reference/wp_insert_term
|
451 |
-
*/
|
452 |
-
if ( array_key_exists( 'args', $term ) ) {
|
453 |
-
wp_insert_term( $term['name'], $taxonomy, $term['args'] );
|
454 |
-
} else {
|
455 |
-
wp_insert_term( $term['name'], $taxonomy );
|
456 |
-
}
|
457 |
-
}
|
458 |
-
}
|
459 |
-
}
|
460 |
-
}
|
461 |
-
|
462 |
-
/**
|
463 |
-
* Kicking this off by calling 'get_instance()' method
|
464 |
-
*/
|
465 |
-
Cartflows_Step_Post_Type::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Step post type.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Step_Post_Type {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Member Variable
|
25 |
+
*
|
26 |
+
* @var body_classes
|
27 |
+
*/
|
28 |
+
private $body_classes = array();
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Initiator
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self;
|
36 |
+
}
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor
|
42 |
+
*/
|
43 |
+
public function __construct() {
|
44 |
+
|
45 |
+
add_action( 'init', array( $this, 'step_post_type' ) );
|
46 |
+
add_action( 'init', array( $this, 'add_wp_templates_support' ) );
|
47 |
+
add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
|
48 |
+
add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 );
|
49 |
+
add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
|
50 |
+
add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ), 20 );
|
51 |
+
|
52 |
+
add_filter( 'template_include', array( $this, 'load_page_template' ), 99 );
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Trys to load page.php for a header, footer or part theme layout.
|
58 |
+
*
|
59 |
+
* @since 1.0.0
|
60 |
+
* @param string $template The current template to be loaded.
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
function load_page_template( $template ) {
|
64 |
+
|
65 |
+
global $post;
|
66 |
+
|
67 |
+
if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Remove Next/Prev Navigation
|
71 |
+
* add_filter('next_post_link', '__return_empty_string');
|
72 |
+
* add_filter('previous_post_link', '__return_empty_string');
|
73 |
+
*
|
74 |
+
* $page = locate_template( array( 'page.php' ) );
|
75 |
+
*
|
76 |
+
* if ( ! empty( $page ) ) {
|
77 |
+
* return $page;
|
78 |
+
* }
|
79 |
+
*/
|
80 |
+
|
81 |
+
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
82 |
+
|
83 |
+
$page_template = apply_filters( 'cartflows_page_template', $page_template );
|
84 |
+
|
85 |
+
$file = '';
|
86 |
+
|
87 |
+
switch ( $page_template ) {
|
88 |
+
|
89 |
+
case 'cartflows-default':
|
90 |
+
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
91 |
+
$this->body_classes[] = $page_template;
|
92 |
+
break;
|
93 |
+
case 'cartflows-canvas':
|
94 |
+
$file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
|
95 |
+
$this->body_classes[] = $page_template;
|
96 |
+
break;
|
97 |
+
default:
|
98 |
+
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
99 |
+
$this->body_classes[] = 'cartflows-default';
|
100 |
+
break;
|
101 |
+
}
|
102 |
+
|
103 |
+
// Just to be safe, we check if the file exist first.
|
104 |
+
if ( file_exists( $file ) ) {
|
105 |
+
|
106 |
+
/* Add Body Class */
|
107 |
+
add_filter( 'body_class', [ $this, 'body_class' ] );
|
108 |
+
|
109 |
+
return $file;
|
110 |
+
} else {
|
111 |
+
echo $file;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
return $template;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Body classes.
|
120 |
+
*
|
121 |
+
* @since 1.0.0
|
122 |
+
* @param array $classes Body classes.
|
123 |
+
* @return array
|
124 |
+
*/
|
125 |
+
function body_class( $classes = [] ) {
|
126 |
+
|
127 |
+
$classes = array_merge( $classes, $this->body_classes );
|
128 |
+
|
129 |
+
return $classes;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Create custom post type
|
134 |
+
*/
|
135 |
+
function step_post_type() {
|
136 |
+
|
137 |
+
$labels = array(
|
138 |
+
'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
|
139 |
+
'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
|
140 |
+
'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
|
141 |
+
'all_items' => esc_html__( 'All Steps', 'cartflows' ),
|
142 |
+
'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
|
143 |
+
'view_item' => esc_html__( 'View Step', 'cartflows' ),
|
144 |
+
'add_new' => esc_html__( 'Add New', 'cartflows' ),
|
145 |
+
'update_item' => esc_html__( 'Update Step', 'cartflows' ),
|
146 |
+
'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
|
147 |
+
'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
|
148 |
+
);
|
149 |
+
|
150 |
+
$args = array(
|
151 |
+
'labels' => $labels,
|
152 |
+
'public' => true,
|
153 |
+
'query_var' => true,
|
154 |
+
'can_export' => true,
|
155 |
+
'exclude_from_search' => true,
|
156 |
+
'show_ui' => true,
|
157 |
+
'show_in_menu' => false,
|
158 |
+
'show_in_admin_bar' => true,
|
159 |
+
'supports' => array( 'title', 'editor', 'elementor' ),
|
160 |
+
'capability_type' => 'post',
|
161 |
+
'capabilities' => array(
|
162 |
+
'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
|
163 |
+
),
|
164 |
+
'map_meta_cap' => true,
|
165 |
+
);
|
166 |
+
|
167 |
+
register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
|
168 |
+
|
169 |
+
$args = array(
|
170 |
+
'label' => __( 'Step Type', 'cartflows' ),
|
171 |
+
'public' => false,
|
172 |
+
'rewrite' => false,
|
173 |
+
'hierarchical' => false,
|
174 |
+
);
|
175 |
+
|
176 |
+
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
|
177 |
+
|
178 |
+
$args = array(
|
179 |
+
'label' => __( 'Step Flow', 'cartflows' ),
|
180 |
+
'public' => false,
|
181 |
+
'rewrite' => false,
|
182 |
+
'hierarchical' => false,
|
183 |
+
);
|
184 |
+
|
185 |
+
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Register 'Elementor' & 'Beaver Builder' site types.
|
189 |
+
*
|
190 |
+
* @see self::add_terms();
|
191 |
+
*/
|
192 |
+
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
193 |
+
|
194 |
+
$terms = array(
|
195 |
+
array(
|
196 |
+
'name' => __( 'Landing', 'cartflows' ),
|
197 |
+
'args' => array(
|
198 |
+
'slug' => 'landing',
|
199 |
+
),
|
200 |
+
),
|
201 |
+
array(
|
202 |
+
'name' => __( 'Checkout', 'cartflows' ),
|
203 |
+
'args' => array(
|
204 |
+
'slug' => 'checkout',
|
205 |
+
),
|
206 |
+
),
|
207 |
+
array(
|
208 |
+
'name' => __( 'Thank You', 'cartflows' ),
|
209 |
+
'args' => array(
|
210 |
+
'slug' => 'thankyou',
|
211 |
+
),
|
212 |
+
),
|
213 |
+
array(
|
214 |
+
'name' => __( 'Upsell', 'cartflows' ),
|
215 |
+
'args' => array(
|
216 |
+
'slug' => 'upsell',
|
217 |
+
),
|
218 |
+
),
|
219 |
+
array(
|
220 |
+
'name' => __( 'Downsell', 'cartflows' ),
|
221 |
+
'args' => array(
|
222 |
+
'slug' => 'downsell',
|
223 |
+
),
|
224 |
+
),
|
225 |
+
);
|
226 |
+
|
227 |
+
$this->add_terms( $taxonomy, $terms );
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Add WordPress templates.
|
232 |
+
*
|
233 |
+
* Adds Cartflows templates to steps
|
234 |
+
*
|
235 |
+
* @since 1.0.0
|
236 |
+
* @access public
|
237 |
+
*/
|
238 |
+
function add_wp_templates_support() {
|
239 |
+
add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Add page templates.
|
244 |
+
*
|
245 |
+
* @since 1.0.0
|
246 |
+
* @access public
|
247 |
+
*
|
248 |
+
* @param array $page_templates Array of page templates.
|
249 |
+
*
|
250 |
+
* @param object $wp_theme wp theme.
|
251 |
+
* @param object $post post.
|
252 |
+
*
|
253 |
+
* @return array Page templates.
|
254 |
+
*/
|
255 |
+
function add_page_templates( $page_templates, $wp_theme, $post ) {
|
256 |
+
|
257 |
+
$page_templates = array(
|
258 |
+
'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
|
259 |
+
);
|
260 |
+
|
261 |
+
return $page_templates;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Have WordPress match postname to any of our public post types.
|
266 |
+
* All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
|
267 |
+
* By default, WordPress only accounts for posts and pages where the slug is /post-name/.
|
268 |
+
*
|
269 |
+
* @param string $query query statement.
|
270 |
+
*/
|
271 |
+
function add_cpt_post_names_to_main_query( $query ) {
|
272 |
+
|
273 |
+
// Bail if this is not the main query.
|
274 |
+
if ( ! $query->is_main_query() ) {
|
275 |
+
return;
|
276 |
+
}
|
277 |
+
|
278 |
+
// Bail if this query doesn't match our very specific rewrite rule.
|
279 |
+
if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) {
|
280 |
+
return;
|
281 |
+
}
|
282 |
+
|
283 |
+
// Bail if we're not querying based on the post name.
|
284 |
+
if ( empty( $query->query['name'] ) ) {
|
285 |
+
return;
|
286 |
+
}
|
287 |
+
|
288 |
+
// Add cartflows step post type to existing post type array.
|
289 |
+
if ( isset( $query->query_vars['post_type'] ) && is_array( $query->query_vars['post_type'] ) ) {
|
290 |
+
|
291 |
+
$post_types = $query->query_vars['post_type'];
|
292 |
+
|
293 |
+
$post_types[] = CARTFLOWS_STEP_POST_TYPE;
|
294 |
+
|
295 |
+
$query->set( 'post_type', $post_types );
|
296 |
+
|
297 |
+
} else {
|
298 |
+
|
299 |
+
// Add CPT to the list of post types WP will include when it queries based on the post name.
|
300 |
+
$query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) );
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Modify permalink
|
306 |
+
*
|
307 |
+
* @param string $post_link post link.
|
308 |
+
* @param array $post post data.
|
309 |
+
* @param string $leavename leave name.
|
310 |
+
* @return string
|
311 |
+
*/
|
312 |
+
function post_type_permalinks( $post_link, $post, $leavename ) {
|
313 |
+
|
314 |
+
// If elementor page preview, return post link as it is.
|
315 |
+
if ( isset( $_REQUEST['elementor-preview'] ) ) {
|
316 |
+
return $post_link;
|
317 |
+
}
|
318 |
+
|
319 |
+
$structure = get_option( 'permalink_structure' );
|
320 |
+
|
321 |
+
if ( '/%postname%/' === $structure ) {
|
322 |
+
|
323 |
+
if ( isset( $post->post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) {
|
324 |
+
|
325 |
+
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
return $post_link;
|
330 |
+
}
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Prevent slug duplicated
|
334 |
+
*
|
335 |
+
* @param string $slug post slug.
|
336 |
+
* @param int $post_ID post id.
|
337 |
+
* @param string $post_status post status.
|
338 |
+
* @param string $post_type post type.
|
339 |
+
* @param int $post_parent post parent id.
|
340 |
+
* @param string $original_slug original slug.
|
341 |
+
* @return string
|
342 |
+
*/
|
343 |
+
function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
344 |
+
|
345 |
+
$check_post_types = array(
|
346 |
+
'post',
|
347 |
+
'page',
|
348 |
+
CARTFLOWS_STEP_POST_TYPE,
|
349 |
+
);
|
350 |
+
|
351 |
+
if ( ! in_array( $post_type, $check_post_types ) ) {
|
352 |
+
return $slug;
|
353 |
+
}
|
354 |
+
|
355 |
+
if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
|
356 |
+
// Saving a post, check for duplicates in POST or PAGE post types.
|
357 |
+
$post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
|
358 |
+
$page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
|
359 |
+
|
360 |
+
if ( $post_match || $page_match ) {
|
361 |
+
$slug .= '-2';
|
362 |
+
}
|
363 |
+
} else {
|
364 |
+
|
365 |
+
// Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
|
366 |
+
$custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
|
367 |
+
|
368 |
+
if ( $custom_post_type_match ) {
|
369 |
+
$slug .= '-2';
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
return $slug;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Add Update messages for any custom post type
|
378 |
+
*
|
379 |
+
* @param array $messages Array of default messages.
|
380 |
+
*/
|
381 |
+
function post_update_messages( $messages ) {
|
382 |
+
|
383 |
+
$custom_post_type = get_post_type( get_the_ID() );
|
384 |
+
|
385 |
+
if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
|
386 |
+
|
387 |
+
$obj = get_post_type_object( $custom_post_type );
|
388 |
+
$singular_name = $obj->labels->singular_name;
|
389 |
+
$messages[ $custom_post_type ] = array(
|
390 |
+
0 => '', // Unused. Messages start at index 1.
|
391 |
+
/* translators: %s: singular custom post type name */
|
392 |
+
1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
393 |
+
/* translators: %s: singular custom post type name */
|
394 |
+
2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
|
395 |
+
/* translators: %s: singular custom post type name */
|
396 |
+
3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
|
397 |
+
/* translators: %s: singular custom post type name */
|
398 |
+
4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
399 |
+
/* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
|
400 |
+
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
401 |
+
/* translators: %s: singular custom post type name */
|
402 |
+
6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
|
403 |
+
/* translators: %s: singular custom post type name */
|
404 |
+
7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
|
405 |
+
/* translators: %s: singular custom post type name */
|
406 |
+
8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
|
407 |
+
/* translators: %s: singular custom post type name */
|
408 |
+
9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
|
409 |
+
/* translators: %s: singular custom post type name */
|
410 |
+
10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
|
411 |
+
);
|
412 |
+
}
|
413 |
+
|
414 |
+
return $messages;
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Add Terms for Taxonomy.
|
419 |
+
*
|
420 |
+
* => Example.
|
421 |
+
*
|
422 |
+
* $taxonomy = '{taxonomy}';
|
423 |
+
* $terms = array(
|
424 |
+
* array(
|
425 |
+
* 'name' => 'Free',
|
426 |
+
* ),
|
427 |
+
* array(
|
428 |
+
* 'name' => 'Premium',
|
429 |
+
* ),
|
430 |
+
* );
|
431 |
+
*
|
432 |
+
* self::add_terms( $taxonomy, $terms );
|
433 |
+
*
|
434 |
+
* @since 1.0.0
|
435 |
+
* @param string $taxonomy Taxonomy Name.
|
436 |
+
* @param array $terms Terms list.
|
437 |
+
* @return void
|
438 |
+
*/
|
439 |
+
function add_terms( $taxonomy = '', $terms = array() ) {
|
440 |
+
|
441 |
+
foreach ( $terms as $key => $term ) {
|
442 |
+
|
443 |
+
$term_exist = term_exists( $term['name'], $taxonomy );
|
444 |
+
|
445 |
+
if ( empty( $term_exist ) ) {
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Add additional args if passed from request.
|
449 |
+
*
|
450 |
+
* @see https://codex.wordpress.org/Function_Reference/wp_insert_term
|
451 |
+
*/
|
452 |
+
if ( array_key_exists( 'args', $term ) ) {
|
453 |
+
wp_insert_term( $term['name'], $taxonomy, $term['args'] );
|
454 |
+
} else {
|
455 |
+
wp_insert_term( $term['name'], $taxonomy );
|
456 |
+
}
|
457 |
+
}
|
458 |
+
}
|
459 |
+
}
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Kicking this off by calling 'get_instance()' method
|
464 |
+
*/
|
465 |
+
Cartflows_Step_Post_Type::get_instance();
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, cart
|
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.0.2
|
8 |
-
Stable tag: 1.1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -94,6 +94,13 @@ Say goodby to using the same ridgid checkout page that everyone else is using. C
|
|
94 |
|
95 |
== Changelog ==
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
= Version 1.1.6 - Thursday, 07th February 2019 =
|
98 |
* Improvement: Added compatibility for a future release of CartFlows Pro's checkout field editor.
|
99 |
* Fix: Permalink conflict with listing theme.
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.0.2
|
8 |
+
Stable tag: 1.1.7.1
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
94 |
|
95 |
== Changelog ==
|
96 |
|
97 |
+
= Version 1.1.7.1 - Monday, 26th February 2019 =
|
98 |
+
* Fix: DIVI importer issue.
|
99 |
+
|
100 |
+
= Version 1.1.7 - Monday, 25th February 2019 =
|
101 |
+
* New: DIVI templates.
|
102 |
+
* Fix: Shipping fields label issue.
|
103 |
+
|
104 |
= Version 1.1.6 - Thursday, 07th February 2019 =
|
105 |
* Improvement: Added compatibility for a future release of CartFlows Pro's checkout field editor.
|
106 |
* Fix: Permalink conflict with listing theme.
|
woocommerce/template/cart/cart-shipping.php
CHANGED
@@ -1,79 +1,79 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Shipping Methods Display
|
4 |
-
*
|
5 |
-
* In 2.1 we show methods per package. This allows for multiple methods per order if so desired.
|
6 |
-
*
|
7 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cart-shipping.php.
|
8 |
-
*
|
9 |
-
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
10 |
-
* (the theme developer) will need to copy the new files to your theme to
|
11 |
-
* maintain compatibility. We try to do this as little as possible, but it does
|
12 |
-
* happen. When this occurs the version of the template file will be bumped and
|
13 |
-
* the readme will list any important changes.
|
14 |
-
*
|
15 |
-
* @see https://docs.woocommerce.com/document/template-structure/
|
16 |
-
* @package WooCommerce/Templates
|
17 |
-
* @version 3.5.0
|
18 |
-
*/
|
19 |
-
|
20 |
-
defined( 'ABSPATH' ) || exit;
|
21 |
-
|
22 |
-
$formatted_destination = isset( $formatted_destination ) ? $formatted_destination : WC()->countries->get_formatted_address( $package['destination'], ', ' );
|
23 |
-
$has_calculated_shipping = ! empty( $has_calculated_shipping );
|
24 |
-
$show_shipping_calculator = ! empty( $show_shipping_calculator );
|
25 |
-
$calculator_text = '';
|
26 |
-
?>
|
27 |
-
<tr class="woocommerce-shipping-totals shipping">
|
28 |
-
<th><?php echo wp_kses_post( $package_name ); ?></th>
|
29 |
-
<td data-title="<?php echo esc_attr( $package_name ); ?>">
|
30 |
-
<?php if ( $available_methods ) : ?>
|
31 |
-
<ul id="shipping_method" class="woocommerce-shipping-methods">
|
32 |
-
<?php foreach ( $available_methods as $method ) : ?>
|
33 |
-
<li>
|
34 |
-
<?php
|
35 |
-
if ( 1 < count( $available_methods ) ) {
|
36 |
-
printf( '<input type="radio" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" %4$s />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ), checked( $method->id, $chosen_method, false ) ); // WPCS: XSS ok.
|
37 |
-
} else {
|
38 |
-
printf( '<input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ) ); // WPCS: XSS ok.
|
39 |
-
}
|
40 |
-
printf( '<label for="shipping_method_%1$s_%2$s">%3$s</label>', $index, esc_attr( sanitize_title( $method->id ) ), wc_cart_totals_shipping_method_label( $method ) ); // WPCS: XSS ok.
|
41 |
-
do_action( 'woocommerce_after_shipping_rate', $method, $index );
|
42 |
-
?>
|
43 |
-
</li>
|
44 |
-
<?php endforeach; ?>
|
45 |
-
</ul>
|
46 |
-
<?php if ( is_cart() ) : ?>
|
47 |
-
<p class="woocommerce-shipping-destination">
|
48 |
-
<?php
|
49 |
-
if ( $formatted_destination ) {
|
50 |
-
// Translators: $s shipping destination.
|
51 |
-
printf( esc_html__( 'Estimate for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' );
|
52 |
-
$calculator_text = __( 'Change address', 'woocommerce' );
|
53 |
-
} else {
|
54 |
-
echo esc_html__( 'This is only an estimate. Prices will be updated during checkout.', 'woocommerce' );
|
55 |
-
}
|
56 |
-
?>
|
57 |
-
</p>
|
58 |
-
<?php endif; ?>
|
59 |
-
<?php
|
60 |
-
elseif ( ! $has_calculated_shipping || ! $formatted_destination ) :
|
61 |
-
esc_html_e( 'Enter your address to view shipping options.', 'woocommerce' );
|
62 |
-
elseif ( ! is_cart() ) :
|
63 |
-
echo wp_kses_post( apply_filters( 'woocommerce_no_shipping_available_html', __( 'There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) );
|
64 |
-
else :
|
65 |
-
// Translators: $s shipping destination.
|
66 |
-
echo wp_kses_post( apply_filters( 'woocommerce_cart_no_shipping_available_html', sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ) ) );
|
67 |
-
$calculator_text = __( 'Enter a different address', 'woocommerce' );
|
68 |
-
endif;
|
69 |
-
?>
|
70 |
-
|
71 |
-
<?php if ( $show_package_details ) : ?>
|
72 |
-
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
|
73 |
-
<?php endif; ?>
|
74 |
-
|
75 |
-
<?php if ( $show_shipping_calculator ) : ?>
|
76 |
-
<?php woocommerce_shipping_calculator( $calculator_text ); ?>
|
77 |
-
<?php endif; ?>
|
78 |
-
</td>
|
79 |
-
</tr>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Shipping Methods Display
|
4 |
+
*
|
5 |
+
* In 2.1 we show methods per package. This allows for multiple methods per order if so desired.
|
6 |
+
*
|
7 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cart-shipping.php.
|
8 |
+
*
|
9 |
+
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
10 |
+
* (the theme developer) will need to copy the new files to your theme to
|
11 |
+
* maintain compatibility. We try to do this as little as possible, but it does
|
12 |
+
* happen. When this occurs the version of the template file will be bumped and
|
13 |
+
* the readme will list any important changes.
|
14 |
+
*
|
15 |
+
* @see https://docs.woocommerce.com/document/template-structure/
|
16 |
+
* @package WooCommerce/Templates
|
17 |
+
* @version 3.5.0
|
18 |
+
*/
|
19 |
+
|
20 |
+
defined( 'ABSPATH' ) || exit;
|
21 |
+
|
22 |
+
$formatted_destination = isset( $formatted_destination ) ? $formatted_destination : WC()->countries->get_formatted_address( $package['destination'], ', ' );
|
23 |
+
$has_calculated_shipping = ! empty( $has_calculated_shipping );
|
24 |
+
$show_shipping_calculator = ! empty( $show_shipping_calculator );
|
25 |
+
$calculator_text = '';
|
26 |
+
?>
|
27 |
+
<tr class="woocommerce-shipping-totals shipping">
|
28 |
+
<th><?php echo wp_kses_post( $package_name ); ?></th>
|
29 |
+
<td data-title="<?php echo esc_attr( $package_name ); ?>">
|
30 |
+
<?php if ( $available_methods ) : ?>
|
31 |
+
<ul id="shipping_method" class="woocommerce-shipping-methods">
|
32 |
+
<?php foreach ( $available_methods as $method ) : ?>
|
33 |
+
<li>
|
34 |
+
<?php
|
35 |
+
if ( 1 < count( $available_methods ) ) {
|
36 |
+
printf( '<input type="radio" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" %4$s />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ), checked( $method->id, $chosen_method, false ) ); // WPCS: XSS ok.
|
37 |
+
} else {
|
38 |
+
printf( '<input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ) ); // WPCS: XSS ok.
|
39 |
+
}
|
40 |
+
printf( '<label for="shipping_method_%1$s_%2$s">%3$s</label>', $index, esc_attr( sanitize_title( $method->id ) ), wc_cart_totals_shipping_method_label( $method ) ); // WPCS: XSS ok.
|
41 |
+
do_action( 'woocommerce_after_shipping_rate', $method, $index );
|
42 |
+
?>
|
43 |
+
</li>
|
44 |
+
<?php endforeach; ?>
|
45 |
+
</ul>
|
46 |
+
<?php if ( is_cart() ) : ?>
|
47 |
+
<p class="woocommerce-shipping-destination">
|
48 |
+
<?php
|
49 |
+
if ( $formatted_destination ) {
|
50 |
+
// Translators: $s shipping destination.
|
51 |
+
printf( esc_html__( 'Estimate for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' );
|
52 |
+
$calculator_text = __( 'Change address', 'woocommerce' );
|
53 |
+
} else {
|
54 |
+
echo esc_html__( 'This is only an estimate. Prices will be updated during checkout.', 'woocommerce' );
|
55 |
+
}
|
56 |
+
?>
|
57 |
+
</p>
|
58 |
+
<?php endif; ?>
|
59 |
+
<?php
|
60 |
+
elseif ( ! $has_calculated_shipping || ! $formatted_destination ) :
|
61 |
+
esc_html_e( 'Enter your address to view shipping options.', 'woocommerce' );
|
62 |
+
elseif ( ! is_cart() ) :
|
63 |
+
echo wp_kses_post( apply_filters( 'woocommerce_no_shipping_available_html', __( 'There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) );
|
64 |
+
else :
|
65 |
+
// Translators: $s shipping destination.
|
66 |
+
echo wp_kses_post( apply_filters( 'woocommerce_cart_no_shipping_available_html', sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ) ) );
|
67 |
+
$calculator_text = __( 'Enter a different address', 'woocommerce' );
|
68 |
+
endif;
|
69 |
+
?>
|
70 |
+
|
71 |
+
<?php if ( $show_package_details ) : ?>
|
72 |
+
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
|
73 |
+
<?php endif; ?>
|
74 |
+
|
75 |
+
<?php if ( $show_shipping_calculator ) : ?>
|
76 |
+
<?php woocommerce_shipping_calculator( $calculator_text ); ?>
|
77 |
+
<?php endif; ?>
|
78 |
+
</td>
|
79 |
+
</tr>
|
woocommerce/template/checkout/form-billing.php
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Checkout billing information form
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-billing.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 |
-
* @author WooThemes
|
15 |
-
* @package WooCommerce/Templates
|
16 |
-
* @version 3.0.9
|
17 |
-
*/
|
18 |
-
|
19 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
-
exit; // Exit if accessed directly.
|
21 |
-
}
|
22 |
-
|
23 |
-
?>
|
24 |
-
<div class="woocommerce-billing-fields">
|
25 |
-
<?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>
|
26 |
-
|
27 |
-
<h3><?php _e( 'Billing & Shipping', 'woocommerce' ); ?></h3>
|
28 |
-
|
29 |
-
<?php else : ?>
|
30 |
-
|
31 |
-
<h3><?php _e( 'Billing details', 'woocommerce' ); ?></h3>
|
32 |
-
|
33 |
-
<?php endif; ?>
|
34 |
-
|
35 |
-
<?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
|
36 |
-
|
37 |
-
<div class="woocommerce-billing-fields__field-wrapper">
|
38 |
-
<?php
|
39 |
-
$fields = $checkout->get_checkout_fields( 'billing' );
|
40 |
-
|
41 |
-
foreach ( $fields as $key => $field ) {
|
42 |
-
if ( isset( $field['country_field'], $fields[ $field['country_field'] ] ) ) {
|
43 |
-
$field['country'] = $checkout->get_value( $field['country_field'] );
|
44 |
-
}
|
45 |
-
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
|
46 |
-
}
|
47 |
-
?>
|
48 |
-
</div>
|
49 |
-
|
50 |
-
<?php do_action( 'woocommerce_after_checkout_billing_form', $checkout ); ?>
|
51 |
-
</div>
|
52 |
-
|
53 |
-
<?php if ( ! is_user_logged_in() && $checkout->is_registration_enabled() ) : ?>
|
54 |
-
<div class="woocommerce-account-fields">
|
55 |
-
<?php if ( ! $checkout->is_registration_required() ) : ?>
|
56 |
-
|
57 |
-
<p class="form-row form-row-wide create-account">
|
58 |
-
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
|
59 |
-
<input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="createaccount" <?php checked( ( true === $checkout->get_value( 'createaccount' ) || ( true === apply_filters( 'woocommerce_create_account_default_checked', false ) ) ), true ); ?> type="checkbox" name="createaccount" value="1" /> <span><?php _e( 'Create an account?', 'woocommerce' ); ?></span>
|
60 |
-
</label>
|
61 |
-
</p>
|
62 |
-
|
63 |
-
<?php endif; ?>
|
64 |
-
|
65 |
-
<?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
|
66 |
-
|
67 |
-
<?php if ( $checkout->get_checkout_fields( 'account' ) ) : ?>
|
68 |
-
|
69 |
-
<div class="create-account">
|
70 |
-
<?php foreach ( $checkout->get_checkout_fields( 'account' ) as $key => $field ) : ?>
|
71 |
-
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
|
72 |
-
<?php endforeach; ?>
|
73 |
-
<div class="clear"></div>
|
74 |
-
</div>
|
75 |
-
|
76 |
-
<?php endif; ?>
|
77 |
-
|
78 |
-
<?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
|
79 |
-
</div>
|
80 |
-
<?php endif; ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Checkout billing information form
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-billing.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 |
+
* @author WooThemes
|
15 |
+
* @package WooCommerce/Templates
|
16 |
+
* @version 3.0.9
|
17 |
+
*/
|
18 |
+
|
19 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
+
exit; // Exit if accessed directly.
|
21 |
+
}
|
22 |
+
|
23 |
+
?>
|
24 |
+
<div class="woocommerce-billing-fields">
|
25 |
+
<?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>
|
26 |
+
|
27 |
+
<h3><?php _e( 'Billing & Shipping', 'woocommerce' ); ?></h3>
|
28 |
+
|
29 |
+
<?php else : ?>
|
30 |
+
|
31 |
+
<h3><?php _e( 'Billing details', 'woocommerce' ); ?></h3>
|
32 |
+
|
33 |
+
<?php endif; ?>
|
34 |
+
|
35 |
+
<?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
|
36 |
+
|
37 |
+
<div class="woocommerce-billing-fields__field-wrapper">
|
38 |
+
<?php
|
39 |
+
$fields = $checkout->get_checkout_fields( 'billing' );
|
40 |
+
|
41 |
+
foreach ( $fields as $key => $field ) {
|
42 |
+
if ( isset( $field['country_field'], $fields[ $field['country_field'] ] ) ) {
|
43 |
+
$field['country'] = $checkout->get_value( $field['country_field'] );
|
44 |
+
}
|
45 |
+
woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
|
46 |
+
}
|
47 |
+
?>
|
48 |
+
</div>
|
49 |
+
|
50 |
+
<?php do_action( 'woocommerce_after_checkout_billing_form', $checkout ); ?>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<?php if ( ! is_user_logged_in() && $checkout->is_registration_enabled() ) : ?>
|
54 |
+
<div class="woocommerce-account-fields">
|
55 |
+
<?php if ( ! $checkout->is_registration_required() ) : ?>
|
56 |
+
|
57 |
+
<p class="form-row form-row-wide create-account">
|
58 |
+
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
|
59 |
+
<input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="createaccount" <?php checked( ( true === $checkout->get_value( 'createaccount' ) || ( true === apply_filters( 'woocommerce_create_account_default_checked', false ) ) ), true ); ?> type="checkbox" name="createaccount" value="1" /> <span><?php _e( 'Create an account?', 'woocommerce' ); ?></span>
|
60 |
+
</label>
|
61 |
+
</p>
|
62 |
+
|
63 |
+
<?php endif; ?>
|
64 |
+
|
65 |
+
<?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
|
66 |
+
|
67 |
+
<?php if ( $checkout->get_checkout_fields( 'account' ) ) : ?>
|
68 |
+
|
69 |
+
<div class="create-account">
|
70 |
+
<?php foreach ( $checkout->get_checkout_fields( 'account' ) as $key => $field ) : ?>
|
71 |
+
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
|
72 |
+
<?php endforeach; ?>
|
73 |
+
<div class="clear"></div>
|
74 |
+
</div>
|
75 |
+
|
76 |
+
<?php endif; ?>
|
77 |
+
|
78 |
+
<?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
|
79 |
+
</div>
|
80 |
+
<?php endif; ?>
|
woocommerce/template/checkout/form-checkout.php
CHANGED
@@ -1,64 +1,64 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Checkout Form
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-checkout.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.5.0
|
16 |
-
*/
|
17 |
-
|
18 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
-
exit;
|
20 |
-
}
|
21 |
-
|
22 |
-
do_action( 'woocommerce_before_checkout_form', $checkout );
|
23 |
-
|
24 |
-
// If checkout registration is disabled and not logged in, the user cannot checkout.
|
25 |
-
if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
|
26 |
-
echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) ) );
|
27 |
-
return;
|
28 |
-
}
|
29 |
-
|
30 |
-
?>
|
31 |
-
|
32 |
-
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
|
33 |
-
|
34 |
-
<?php if ( $checkout->get_checkout_fields() ) : ?>
|
35 |
-
|
36 |
-
<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>
|
37 |
-
|
38 |
-
<div class="col2-set" id="customer_details">
|
39 |
-
<div class="col-1">
|
40 |
-
<?php do_action( 'woocommerce_checkout_billing' ); ?>
|
41 |
-
</div>
|
42 |
-
|
43 |
-
<div class="col-2">
|
44 |
-
<?php do_action( 'woocommerce_checkout_shipping' ); ?>
|
45 |
-
</div>
|
46 |
-
</div>
|
47 |
-
|
48 |
-
<?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
|
49 |
-
|
50 |
-
<?php endif; ?>
|
51 |
-
|
52 |
-
<h3 id="order_review_heading"><?php esc_html_e( 'Your order', 'woocommerce' ); ?></h3>
|
53 |
-
|
54 |
-
<?php do_action( 'woocommerce_checkout_before_order_review' ); ?>
|
55 |
-
|
56 |
-
<div id="order_review" class="woocommerce-checkout-review-order">
|
57 |
-
<?php do_action( 'woocommerce_checkout_order_review' ); ?>
|
58 |
-
</div>
|
59 |
-
|
60 |
-
<?php do_action( 'woocommerce_checkout_after_order_review' ); ?>
|
61 |
-
|
62 |
-
</form>
|
63 |
-
|
64 |
-
<?php do_action( 'woocommerce_after_checkout_form', $checkout ); ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Checkout Form
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-checkout.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.5.0
|
16 |
+
*/
|
17 |
+
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
do_action( 'woocommerce_before_checkout_form', $checkout );
|
23 |
+
|
24 |
+
// If checkout registration is disabled and not logged in, the user cannot checkout.
|
25 |
+
if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
|
26 |
+
echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) ) );
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
|
30 |
+
?>
|
31 |
+
|
32 |
+
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
|
33 |
+
|
34 |
+
<?php if ( $checkout->get_checkout_fields() ) : ?>
|
35 |
+
|
36 |
+
<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>
|
37 |
+
|
38 |
+
<div class="col2-set" id="customer_details">
|
39 |
+
<div class="col-1">
|
40 |
+
<?php do_action( 'woocommerce_checkout_billing' ); ?>
|
41 |
+
</div>
|
42 |
+
|
43 |
+
<div class="col-2">
|
44 |
+
<?php do_action( 'woocommerce_checkout_shipping' ); ?>
|
45 |
+
</div>
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
|
49 |
+
|
50 |
+
<?php endif; ?>
|
51 |
+
|
52 |
+
<h3 id="order_review_heading"><?php esc_html_e( 'Your order', 'woocommerce' ); ?></h3>
|
53 |
+
|
54 |
+
<?php do_action( 'woocommerce_checkout_before_order_review' ); ?>
|
55 |
+
|
56 |
+
<div id="order_review" class="woocommerce-checkout-review-order">
|
57 |
+
<?php do_action( 'woocommerce_checkout_order_review' ); ?>
|
58 |
+
</div>
|
59 |
+
|
60 |
+
<?php do_action( 'woocommerce_checkout_after_order_review' ); ?>
|
61 |
+
|
62 |
+
</form>
|
63 |
+
|
64 |
+
<?php do_action( 'woocommerce_after_checkout_form', $checkout ); ?>
|
woocommerce/template/checkout/form-coupon.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Checkout coupon form
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-coupon.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.4.4
|
16 |
-
*/
|
17 |
-
|
18 |
-
defined( 'ABSPATH' ) || exit;
|
19 |
-
|
20 |
-
if ( ! wc_coupons_enabled() ) { // @codingStandardsIgnoreLine.
|
21 |
-
return;
|
22 |
-
}
|
23 |
-
|
24 |
-
?>
|
25 |
-
<div class="woocommerce-form-coupon-toggle">
|
26 |
-
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_coupon_message', __( 'Have a coupon?', 'woocommerce' ) . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>' ), 'notice' ); ?>
|
27 |
-
</div>
|
28 |
-
|
29 |
-
<form class="checkout_coupon woocommerce-form-coupon" method="post" style="display:none">
|
30 |
-
|
31 |
-
<p><?php esc_html_e( 'If you have a coupon code, please apply it below.', 'woocommerce' ); ?></p>
|
32 |
-
|
33 |
-
<p class="form-row form-row-first">
|
34 |
-
<input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" id="coupon_code" value="" />
|
35 |
-
</p>
|
36 |
-
|
37 |
-
<p class="form-row form-row-last">
|
38 |
-
<button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_html_e( 'Apply coupon', 'woocommerce' ); ?></button>
|
39 |
-
</p>
|
40 |
-
|
41 |
-
<div class="clear"></div>
|
42 |
-
</form>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Checkout coupon form
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-coupon.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.4.4
|
16 |
+
*/
|
17 |
+
|
18 |
+
defined( 'ABSPATH' ) || exit;
|
19 |
+
|
20 |
+
if ( ! wc_coupons_enabled() ) { // @codingStandardsIgnoreLine.
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
?>
|
25 |
+
<div class="woocommerce-form-coupon-toggle">
|
26 |
+
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_coupon_message', __( 'Have a coupon?', 'woocommerce' ) . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>' ), 'notice' ); ?>
|
27 |
+
</div>
|
28 |
+
|
29 |
+
<form class="checkout_coupon woocommerce-form-coupon" method="post" style="display:none">
|
30 |
+
|
31 |
+
<p><?php esc_html_e( 'If you have a coupon code, please apply it below.', 'woocommerce' ); ?></p>
|
32 |
+
|
33 |
+
<p class="form-row form-row-first">
|
34 |
+
<input type="text" name="coupon_code" class="input-text" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" id="coupon_code" value="" />
|
35 |
+
</p>
|
36 |
+
|
37 |
+
<p class="form-row form-row-last">
|
38 |
+
<button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_html_e( 'Apply coupon', 'woocommerce' ); ?></button>
|
39 |
+
</p>
|
40 |
+
|
41 |
+
<div class="clear"></div>
|
42 |
+
</form>
|
woocommerce/template/checkout/form-login.php
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Checkout login form
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/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.4.0
|
16 |
-
*/
|
17 |
-
|
18 |
-
defined( 'ABSPATH' ) || exit;
|
19 |
-
|
20 |
-
if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_login_reminder' ) ) {
|
21 |
-
return;
|
22 |
-
}
|
23 |
-
|
24 |
-
?>
|
25 |
-
<div class="woocommerce-form-login-toggle">
|
26 |
-
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_login_message', __( 'Returning customer?', 'woocommerce' ) ) . ' <a href="#" class="showlogin">' . __( 'Click here to login', 'woocommerce' ) . '</a>', 'notice' ); ?>
|
27 |
-
</div>
|
28 |
-
<?php
|
29 |
-
|
30 |
-
woocommerce_login_form(
|
31 |
-
array(
|
32 |
-
'message' => __( 'If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing & Shipping section.', 'woocommerce' ),
|
33 |
-
'redirect' => wc_get_page_permalink( 'checkout' ),
|
34 |
-
'hidden' => true,
|
35 |
-
)
|
36 |
-
);
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Checkout login form
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/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.4.0
|
16 |
+
*/
|
17 |
+
|
18 |
+
defined( 'ABSPATH' ) || exit;
|
19 |
+
|
20 |
+
if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_login_reminder' ) ) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
?>
|
25 |
+
<div class="woocommerce-form-login-toggle">
|
26 |
+
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_login_message', __( 'Returning customer?', 'woocommerce' ) ) . ' <a href="#" class="showlogin">' . __( 'Click here to login', 'woocommerce' ) . '</a>', 'notice' ); ?>
|
27 |
+
</div>
|
28 |
+
<?php
|
29 |
+
|
30 |
+
woocommerce_login_form(
|
31 |
+
array(
|
32 |
+
'message' => __( 'If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing & Shipping section.', 'woocommerce' ),
|
33 |
+
'redirect' => wc_get_page_permalink( 'checkout' ),
|
34 |
+
'hidden' => true,
|
35 |
+
)
|
36 |
+
);
|
woocommerce/template/checkout/review-order.php
CHANGED
@@ -1,113 +1,113 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Review order table
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/review-order.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 |
-
* @author WooThemes
|
15 |
-
* @package WooCommerce/Templates
|
16 |
-
* @version 3.3.0
|
17 |
-
*/
|
18 |
-
|
19 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
-
exit;
|
21 |
-
}
|
22 |
-
?>
|
23 |
-
<table class="shop_table woocommerce-checkout-review-order-table">
|
24 |
-
<thead>
|
25 |
-
<tr>
|
26 |
-
<th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th>
|
27 |
-
<th class="product-total"><?php _e( 'Total', 'woocommerce' ); ?></th>
|
28 |
-
</tr>
|
29 |
-
</thead>
|
30 |
-
<tbody>
|
31 |
-
<?php
|
32 |
-
do_action( 'woocommerce_review_order_before_cart_contents' );
|
33 |
-
|
34 |
-
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
35 |
-
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
36 |
-
|
37 |
-
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
38 |
-
?>
|
39 |
-
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
40 |
-
<td class="product-name">
|
41 |
-
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; ?>
|
42 |
-
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); ?>
|
43 |
-
<?php echo wc_get_formatted_cart_item_data( $cart_item ); ?>
|
44 |
-
</td>
|
45 |
-
<td class="product-total">
|
46 |
-
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?>
|
47 |
-
</td>
|
48 |
-
</tr>
|
49 |
-
<?php
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
do_action( 'woocommerce_review_order_after_cart_contents' );
|
54 |
-
?>
|
55 |
-
</tbody>
|
56 |
-
<tfoot>
|
57 |
-
|
58 |
-
<tr class="cart-subtotal">
|
59 |
-
<th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
|
60 |
-
<td><?php wc_cart_totals_subtotal_html(); ?></td>
|
61 |
-
</tr>
|
62 |
-
|
63 |
-
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
|
64 |
-
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
|
65 |
-
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
|
66 |
-
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
|
67 |
-
</tr>
|
68 |
-
<?php endforeach; ?>
|
69 |
-
|
70 |
-
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
|
71 |
-
|
72 |
-
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
|
73 |
-
|
74 |
-
<?php wc_cart_totals_shipping_html(); ?>
|
75 |
-
|
76 |
-
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
|
77 |
-
|
78 |
-
<?php endif; ?>
|
79 |
-
|
80 |
-
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
|
81 |
-
<tr class="fee">
|
82 |
-
<th><?php echo esc_html( $fee->name ); ?></th>
|
83 |
-
<td><?php wc_cart_totals_fee_html( $fee ); ?></td>
|
84 |
-
</tr>
|
85 |
-
<?php endforeach; ?>
|
86 |
-
|
87 |
-
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
|
88 |
-
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
|
89 |
-
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
|
90 |
-
<tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
|
91 |
-
<th><?php echo esc_html( $tax->label ); ?></th>
|
92 |
-
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
|
93 |
-
</tr>
|
94 |
-
<?php endforeach; ?>
|
95 |
-
<?php else : ?>
|
96 |
-
<tr class="tax-total">
|
97 |
-
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
|
98 |
-
<td><?php wc_cart_totals_taxes_total_html(); ?></td>
|
99 |
-
</tr>
|
100 |
-
<?php endif; ?>
|
101 |
-
<?php endif; ?>
|
102 |
-
|
103 |
-
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
|
104 |
-
|
105 |
-
<tr class="order-total">
|
106 |
-
<th><?php _e( 'Total', 'woocommerce' ); ?></th>
|
107 |
-
<td><?php wc_cart_totals_order_total_html(); ?></td>
|
108 |
-
</tr>
|
109 |
-
|
110 |
-
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
|
111 |
-
|
112 |
-
</tfoot>
|
113 |
-
</table>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Review order table
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/review-order.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 |
+
* @author WooThemes
|
15 |
+
* @package WooCommerce/Templates
|
16 |
+
* @version 3.3.0
|
17 |
+
*/
|
18 |
+
|
19 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
+
exit;
|
21 |
+
}
|
22 |
+
?>
|
23 |
+
<table class="shop_table woocommerce-checkout-review-order-table">
|
24 |
+
<thead>
|
25 |
+
<tr>
|
26 |
+
<th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th>
|
27 |
+
<th class="product-total"><?php _e( 'Total', 'woocommerce' ); ?></th>
|
28 |
+
</tr>
|
29 |
+
</thead>
|
30 |
+
<tbody>
|
31 |
+
<?php
|
32 |
+
do_action( 'woocommerce_review_order_before_cart_contents' );
|
33 |
+
|
34 |
+
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
35 |
+
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
36 |
+
|
37 |
+
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
|
38 |
+
?>
|
39 |
+
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
|
40 |
+
<td class="product-name">
|
41 |
+
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; ?>
|
42 |
+
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); ?>
|
43 |
+
<?php echo wc_get_formatted_cart_item_data( $cart_item ); ?>
|
44 |
+
</td>
|
45 |
+
<td class="product-total">
|
46 |
+
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?>
|
47 |
+
</td>
|
48 |
+
</tr>
|
49 |
+
<?php
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
do_action( 'woocommerce_review_order_after_cart_contents' );
|
54 |
+
?>
|
55 |
+
</tbody>
|
56 |
+
<tfoot>
|
57 |
+
|
58 |
+
<tr class="cart-subtotal">
|
59 |
+
<th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
|
60 |
+
<td><?php wc_cart_totals_subtotal_html(); ?></td>
|
61 |
+
</tr>
|
62 |
+
|
63 |
+
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
|
64 |
+
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
|
65 |
+
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
|
66 |
+
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
|
67 |
+
</tr>
|
68 |
+
<?php endforeach; ?>
|
69 |
+
|
70 |
+
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
|
71 |
+
|
72 |
+
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
|
73 |
+
|
74 |
+
<?php wc_cart_totals_shipping_html(); ?>
|
75 |
+
|
76 |
+
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
|
77 |
+
|
78 |
+
<?php endif; ?>
|
79 |
+
|
80 |
+
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
|
81 |
+
<tr class="fee">
|
82 |
+
<th><?php echo esc_html( $fee->name ); ?></th>
|
83 |
+
<td><?php wc_cart_totals_fee_html( $fee ); ?></td>
|
84 |
+
</tr>
|
85 |
+
<?php endforeach; ?>
|
86 |
+
|
87 |
+
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
|
88 |
+
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
|
89 |
+
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
|
90 |
+
<tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
|
91 |
+
<th><?php echo esc_html( $tax->label ); ?></th>
|
92 |
+
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
|
93 |
+
</tr>
|
94 |
+
<?php endforeach; ?>
|
95 |
+
<?php else : ?>
|
96 |
+
<tr class="tax-total">
|
97 |
+
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
|
98 |
+
<td><?php wc_cart_totals_taxes_total_html(); ?></td>
|
99 |
+
</tr>
|
100 |
+
<?php endif; ?>
|
101 |
+
<?php endif; ?>
|
102 |
+
|
103 |
+
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
|
104 |
+
|
105 |
+
<tr class="order-total">
|
106 |
+
<th><?php _e( 'Total', 'woocommerce' ); ?></th>
|
107 |
+
<td><?php wc_cart_totals_order_total_html(); ?></td>
|
108 |
+
</tr>
|
109 |
+
|
110 |
+
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
|
111 |
+
|
112 |
+
</tfoot>
|
113 |
+
</table>
|
woocommerce/template/checkout/thankyou.php
CHANGED
@@ -1,87 +1,87 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Thankyou page
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/thankyou.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 |
-
* @author WooThemes
|
15 |
-
* @package WooCommerce/Templates
|
16 |
-
* @version 3.2.0
|
17 |
-
*/
|
18 |
-
|
19 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
-
exit;
|
21 |
-
}
|
22 |
-
?>
|
23 |
-
|
24 |
-
<div class="woocommerce-order">
|
25 |
-
|
26 |
-
<?php if ( $order ) : ?>
|
27 |
-
|
28 |
-
<?php if ( $order->has_status( 'failed' ) ) : ?>
|
29 |
-
|
30 |
-
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"><?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); ?></p>
|
31 |
-
|
32 |
-
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed-actions">
|
33 |
-
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e( 'Pay', 'woocommerce' ); ?></a>
|
34 |
-
<?php if ( is_user_logged_in() ) : ?>
|
35 |
-
<a href="<?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?>" class="button pay"><?php _e( 'My account', 'woocommerce' ); ?></a>
|
36 |
-
<?php endif; ?>
|
37 |
-
</p>
|
38 |
-
|
39 |
-
<?php else : ?>
|
40 |
-
|
41 |
-
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p>
|
42 |
-
|
43 |
-
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
|
44 |
-
|
45 |
-
<li class="woocommerce-order-overview__order order">
|
46 |
-
<?php _e( 'Order number:', 'woocommerce' ); ?>
|
47 |
-
<strong><?php echo $order->get_order_number(); ?></strong>
|
48 |
-
</li>
|
49 |
-
|
50 |
-
<li class="woocommerce-order-overview__date date">
|
51 |
-
<?php _e( 'Date:', 'woocommerce' ); ?>
|
52 |
-
<strong><?php echo wc_format_datetime( $order->get_date_created() ); ?></strong>
|
53 |
-
</li>
|
54 |
-
|
55 |
-
<?php if ( is_user_logged_in() && $order->get_user_id() === get_current_user_id() && $order->get_billing_email() ) : ?>
|
56 |
-
<li class="woocommerce-order-overview__email email">
|
57 |
-
<?php _e( 'Email:', 'woocommerce' ); ?>
|
58 |
-
<strong><?php echo $order->get_billing_email(); ?></strong>
|
59 |
-
</li>
|
60 |
-
<?php endif; ?>
|
61 |
-
|
62 |
-
<li class="woocommerce-order-overview__total total">
|
63 |
-
<?php _e( 'Total:', 'woocommerce' ); ?>
|
64 |
-
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
|
65 |
-
</li>
|
66 |
-
|
67 |
-
<?php if ( $order->get_payment_method_title() ) : ?>
|
68 |
-
<li class="woocommerce-order-overview__payment-method method">
|
69 |
-
<?php _e( 'Payment method:', 'woocommerce' ); ?>
|
70 |
-
<strong><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></strong>
|
71 |
-
</li>
|
72 |
-
<?php endif; ?>
|
73 |
-
|
74 |
-
</ul>
|
75 |
-
|
76 |
-
<?php endif; ?>
|
77 |
-
|
78 |
-
<?php do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() ); ?>
|
79 |
-
<?php do_action( 'woocommerce_thankyou', $order->get_id() ); ?>
|
80 |
-
|
81 |
-
<?php else : ?>
|
82 |
-
|
83 |
-
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p>
|
84 |
-
|
85 |
-
<?php endif; ?>
|
86 |
-
|
87 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Thankyou page
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/thankyou.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 |
+
* @author WooThemes
|
15 |
+
* @package WooCommerce/Templates
|
16 |
+
* @version 3.2.0
|
17 |
+
*/
|
18 |
+
|
19 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
+
exit;
|
21 |
+
}
|
22 |
+
?>
|
23 |
+
|
24 |
+
<div class="woocommerce-order">
|
25 |
+
|
26 |
+
<?php if ( $order ) : ?>
|
27 |
+
|
28 |
+
<?php if ( $order->has_status( 'failed' ) ) : ?>
|
29 |
+
|
30 |
+
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"><?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); ?></p>
|
31 |
+
|
32 |
+
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed-actions">
|
33 |
+
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e( 'Pay', 'woocommerce' ); ?></a>
|
34 |
+
<?php if ( is_user_logged_in() ) : ?>
|
35 |
+
<a href="<?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?>" class="button pay"><?php _e( 'My account', 'woocommerce' ); ?></a>
|
36 |
+
<?php endif; ?>
|
37 |
+
</p>
|
38 |
+
|
39 |
+
<?php else : ?>
|
40 |
+
|
41 |
+
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p>
|
42 |
+
|
43 |
+
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
|
44 |
+
|
45 |
+
<li class="woocommerce-order-overview__order order">
|
46 |
+
<?php _e( 'Order number:', 'woocommerce' ); ?>
|
47 |
+
<strong><?php echo $order->get_order_number(); ?></strong>
|
48 |
+
</li>
|
49 |
+
|
50 |
+
<li class="woocommerce-order-overview__date date">
|
51 |
+
<?php _e( 'Date:', 'woocommerce' ); ?>
|
52 |
+
<strong><?php echo wc_format_datetime( $order->get_date_created() ); ?></strong>
|
53 |
+
</li>
|
54 |
+
|
55 |
+
<?php if ( is_user_logged_in() && $order->get_user_id() === get_current_user_id() && $order->get_billing_email() ) : ?>
|
56 |
+
<li class="woocommerce-order-overview__email email">
|
57 |
+
<?php _e( 'Email:', 'woocommerce' ); ?>
|
58 |
+
<strong><?php echo $order->get_billing_email(); ?></strong>
|
59 |
+
</li>
|
60 |
+
<?php endif; ?>
|
61 |
+
|
62 |
+
<li class="woocommerce-order-overview__total total">
|
63 |
+
<?php _e( 'Total:', 'woocommerce' ); ?>
|
64 |
+
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
|
65 |
+
</li>
|
66 |
+
|
67 |
+
<?php if ( $order->get_payment_method_title() ) : ?>
|
68 |
+
<li class="woocommerce-order-overview__payment-method method">
|
69 |
+
<?php _e( 'Payment method:', 'woocommerce' ); ?>
|
70 |
+
<strong><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></strong>
|
71 |
+
</li>
|
72 |
+
<?php endif; ?>
|
73 |
+
|
74 |
+
</ul>
|
75 |
+
|
76 |
+
<?php endif; ?>
|
77 |
+
|
78 |
+
<?php do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() ); ?>
|
79 |
+
<?php do_action( 'woocommerce_thankyou', $order->get_id() ); ?>
|
80 |
+
|
81 |
+
<?php else : ?>
|
82 |
+
|
83 |
+
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p>
|
84 |
+
|
85 |
+
<?php endif; ?>
|
86 |
+
|
87 |
+
</div>
|
woocommerce/template/notices/error.php
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Show error messages
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/notices/error.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.5.0
|
16 |
-
*/
|
17 |
-
|
18 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
-
exit;
|
20 |
-
}
|
21 |
-
|
22 |
-
if ( ! $messages ) {
|
23 |
-
return;
|
24 |
-
}
|
25 |
-
|
26 |
-
?>
|
27 |
-
<ul class="woocommerce-error" role="alert">
|
28 |
-
<?php foreach ( $messages as $message ) : ?>
|
29 |
-
<li>
|
30 |
-
<?php
|
31 |
-
echo wc_kses_notice( $message );
|
32 |
-
?>
|
33 |
-
</li>
|
34 |
-
<?php endforeach; ?>
|
35 |
-
</ul>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Show error messages
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/notices/error.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.5.0
|
16 |
+
*/
|
17 |
+
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
if ( ! $messages ) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
?>
|
27 |
+
<ul class="woocommerce-error" role="alert">
|
28 |
+
<?php foreach ( $messages as $message ) : ?>
|
29 |
+
<li>
|
30 |
+
<?php
|
31 |
+
echo wc_kses_notice( $message );
|
32 |
+
?>
|
33 |
+
</li>
|
34 |
+
<?php endforeach; ?>
|
35 |
+
</ul>
|
woocommerce/template/notices/notice.php
CHANGED
@@ -1,34 +1,34 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Show messages
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/notices/notice.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.5.0
|
16 |
-
*/
|
17 |
-
|
18 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
-
exit; // Exit if accessed directly.
|
20 |
-
}
|
21 |
-
|
22 |
-
if ( ! $messages ) {
|
23 |
-
return;
|
24 |
-
}
|
25 |
-
|
26 |
-
?>
|
27 |
-
|
28 |
-
<?php foreach ( $messages as $message ) : ?>
|
29 |
-
<div class="woocommerce-info">
|
30 |
-
<?php
|
31 |
-
echo wc_kses_notice( $message );
|
32 |
-
?>
|
33 |
-
</div>
|
34 |
-
<?php endforeach; ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Show messages
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/notices/notice.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.5.0
|
16 |
+
*/
|
17 |
+
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit; // Exit if accessed directly.
|
20 |
+
}
|
21 |
+
|
22 |
+
if ( ! $messages ) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
?>
|
27 |
+
|
28 |
+
<?php foreach ( $messages as $message ) : ?>
|
29 |
+
<div class="woocommerce-info">
|
30 |
+
<?php
|
31 |
+
echo wc_kses_notice( $message );
|
32 |
+
?>
|
33 |
+
</div>
|
34 |
+
<?php endforeach; ?>
|
woocommerce/template/notices/success.php
CHANGED
@@ -1,34 +1,34 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Show messages
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/woocommerce/notices/success.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.5.0
|
16 |
-
*/
|
17 |
-
|
18 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
-
exit;
|
20 |
-
}
|
21 |
-
|
22 |
-
if ( ! $messages ) {
|
23 |
-
return;
|
24 |
-
}
|
25 |
-
|
26 |
-
?>
|
27 |
-
|
28 |
-
<?php foreach ( $messages as $message ) : ?>
|
29 |
-
<div class="woocommerce-message" role="alert">
|
30 |
-
<?php
|
31 |
-
echo wc_kses_notice( $message );
|
32 |
-
?>
|
33 |
-
</div>
|
34 |
-
<?php endforeach; ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Show messages
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/woocommerce/notices/success.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.5.0
|
16 |
+
*/
|
17 |
+
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
if ( ! $messages ) {
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
?>
|
27 |
+
|
28 |
+
<?php foreach ( $messages as $message ) : ?>
|
29 |
+
<div class="woocommerce-message" role="alert">
|
30 |
+
<?php
|
31 |
+
echo wc_kses_notice( $message );
|
32 |
+
?>
|
33 |
+
</div>
|
34 |
+
<?php endforeach; ?>
|