Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | Funnel Builder by CartFlows – Create High Converting Sales Funnels For WordPress |
Version | 1.1.5 |
Comparing to | |
See all releases |
Code changes from version 1.1.4 to 1.1.5
- assets/css/import-rtl.css +5 -1
- assets/css/import.css +5 -1
- assets/js/import.js +3 -3
- assets/js/rest-api.js +1 -3
- cartflows.php +24 -24
- changelog.txt +4 -0
- classes/batch-process/class-cartflows-batch-process.php +244 -244
- classes/batch-process/class-cartflows-importer-beaver-builder.php +229 -229
- classes/batch-process/class-cartflows-importer-elementor.php +69 -69
- classes/class-cartflows-admin-fields.php +198 -198
- classes/class-cartflows-admin.php +420 -420
- classes/class-cartflows-bb-compatibility.php +76 -76
- classes/class-cartflows-compatibility.php +355 -355
- classes/class-cartflows-helper.php +432 -410
- classes/class-cartflows-importer.php +1432 -1419
- classes/class-cartflows-loader.php +419 -419
- includes/admin/cartflows-general.php +142 -142
- languages/cartflows.pot +31 -14
- modules/checkout/classes/class-cartflows-checkout-markup.php +1033 -1021
- modules/flow/templates/template-canvas.php +47 -47
- modules/flow/templates/template-default.php +51 -51
- modules/flow/view/meta-flow-steps.php +200 -200
- modules/thankyou/classes/class-cartflows-thankyou-markup.php +273 -273
- readme.txt +16 -13
assets/css/import-rtl.css
CHANGED
@@ -983,4 +983,8 @@ html.wcf-popup-open{
|
|
983 |
.admin_page_flow_exporter .notice,
|
984 |
.admin_page_flow_importer .notice {
|
985 |
margin: 1em 0 0 0;
|
986 |
-
}
|
|
|
|
|
|
|
|
983 |
.admin_page_flow_exporter .notice,
|
984 |
.admin_page_flow_importer .notice {
|
985 |
margin: 1em 0 0 0;
|
986 |
+
}
|
987 |
+
|
988 |
+
.cartflows-website-unreachable {
|
989 |
+
padding: 1em 2em;
|
990 |
+
}
|
assets/css/import.css
CHANGED
@@ -983,4 +983,8 @@ html.wcf-popup-open{
|
|
983 |
.admin_page_flow_exporter .notice,
|
984 |
.admin_page_flow_importer .notice {
|
985 |
margin: 1em 0 0 0;
|
986 |
-
}
|
|
|
|
|
|
|
|
983 |
.admin_page_flow_exporter .notice,
|
984 |
.admin_page_flow_importer .notice {
|
985 |
margin: 1em 0 0 0;
|
986 |
+
}
|
987 |
+
|
988 |
+
.cartflows-website-unreachable {
|
989 |
+
padding: 1em 2em;
|
990 |
+
}
|
assets/js/import.js
CHANGED
@@ -329,9 +329,9 @@ var CartFlowsAjaxQueue = (function() {
|
|
329 |
},
|
330 |
|
331 |
_api_request_failed: function( event, data, jqXHR, textStatus ) {
|
332 |
-
if( 'error' == textStatus
|
333 |
-
if( ! $('#wcf-
|
334 |
-
$('#wcf-ready-templates').
|
335 |
}
|
336 |
}
|
337 |
},
|
329 |
},
|
330 |
|
331 |
_api_request_failed: function( event, data, jqXHR, textStatus ) {
|
332 |
+
if( 'error' == textStatus ) {
|
333 |
+
if( ! $('#wcf-remote-content-failed').length ) {
|
334 |
+
$('#wcf-ready-templates').html( wp.template('cartflows-website-unreachable') );
|
335 |
}
|
336 |
}
|
337 |
},
|
assets/js/rest-api.js
CHANGED
@@ -91,8 +91,7 @@
|
|
91 |
|
92 |
var data = {
|
93 |
args : options.args,
|
94 |
-
|
95 |
-
items : JSON.parse( XHR.responseText ),
|
96 |
items_count : XHR.getResponseHeader('x-wp-total') || 0,
|
97 |
callback : options.callback,
|
98 |
|
@@ -153,7 +152,6 @@
|
|
153 |
// Set API Request Data.
|
154 |
var data = {
|
155 |
url : CartFlowsAPI._api_url + args.slug,
|
156 |
-
cache : false,
|
157 |
args : args,
|
158 |
callback : callback,
|
159 |
|
91 |
|
92 |
var data = {
|
93 |
args : options.args,
|
94 |
+
items : ( XHR.responseText ) ? JSON.parse( XHR.responseText ) : '',
|
|
|
95 |
items_count : XHR.getResponseHeader('x-wp-total') || 0,
|
96 |
callback : options.callback,
|
97 |
|
152 |
// Set API Request Data.
|
153 |
var data = {
|
154 |
url : CartFlowsAPI._api_url + args.slug,
|
|
|
155 |
args : args,
|
156 |
callback : callback,
|
157 |
|
cartflows.php
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: CartFlows
|
4 |
-
* Plugin URI: https://cartflows.com/
|
5 |
-
* Description: Create beautiful checkout pages & sales flows for WooCommerce.
|
6 |
-
* Version: 1.1.
|
7 |
-
* Author: CartFlows Inc
|
8 |
-
* Author URI: https://cartflows.com/
|
9 |
-
* Text Domain: cartflows
|
10 |
-
* WC requires at least: 3.0
|
11 |
-
* WC tested up to: 3.5.1
|
12 |
-
*
|
13 |
-
* @package CartFlows
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Set constants.
|
18 |
-
*/
|
19 |
-
define( 'CARTFLOWS_FILE', __FILE__ );
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Extensions
|
23 |
-
*/
|
24 |
-
require_once 'classes/class-cartflows-loader.php';
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: CartFlows
|
4 |
+
* Plugin URI: https://cartflows.com/
|
5 |
+
* Description: Create beautiful checkout pages & sales flows for WooCommerce.
|
6 |
+
* Version: 1.1.5
|
7 |
+
* Author: CartFlows Inc
|
8 |
+
* Author URI: https://cartflows.com/
|
9 |
+
* Text Domain: cartflows
|
10 |
+
* WC requires at least: 3.0
|
11 |
+
* WC tested up to: 3.5.1
|
12 |
+
*
|
13 |
+
* @package CartFlows
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Set constants.
|
18 |
+
*/
|
19 |
+
define( 'CARTFLOWS_FILE', __FILE__ );
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Extensions
|
23 |
+
*/
|
24 |
+
require_once 'classes/class-cartflows-loader.php';
|
changelog.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
Version 1.1.4 - Tuesday, 22nd January 2019
|
2 |
- New: Beaver Builder templates.
|
3 |
- Improvement: Better error handling on the checkout page.
|
1 |
+
Version 1.1.5 - Wednesday, 23rd January 2019
|
2 |
+
- Fix: Beaver Builder Pro version conflict while installing templates.
|
3 |
+
- Fix: Elementor builder white screen while editing checkout page and cart is empty.
|
4 |
+
|
5 |
Version 1.1.4 - Tuesday, 22nd January 2019
|
6 |
- New: Beaver Builder templates.
|
7 |
- Improvement: Better error handling on the checkout page.
|
classes/batch-process/class-cartflows-batch-process.php
CHANGED
@@ -1,244 +1,244 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Batch Processing
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows_Batch_Process
|
13 |
-
*
|
14 |
-
* @since 1.0.0
|
15 |
-
*/
|
16 |
-
class CartFlows_Batch_Process {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @since 1.0.0
|
22 |
-
* @var object Class object.
|
23 |
-
* @access private
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Elementor Batch Instance
|
29 |
-
*
|
30 |
-
* @since 1.1.1 Updated instance name with elementor specific.
|
31 |
-
*
|
32 |
-
* @since 1.0.0
|
33 |
-
* @var object Class object.
|
34 |
-
* @access public
|
35 |
-
*/
|
36 |
-
public static $batch_instance_elementor;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Beaver Builder Batch Instance
|
40 |
-
*
|
41 |
-
* @since 1.1.1
|
42 |
-
* @var object Class object.
|
43 |
-
* @access public
|
44 |
-
*/
|
45 |
-
public static $batch_instance_bb;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Initiator
|
49 |
-
*
|
50 |
-
* @since 1.0.0
|
51 |
-
* @return object initialized object of class.
|
52 |
-
*/
|
53 |
-
public static function get_instance() {
|
54 |
-
if ( ! isset( self::$instance ) ) {
|
55 |
-
self::$instance = new self;
|
56 |
-
}
|
57 |
-
return self::$instance;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Constructor
|
62 |
-
*
|
63 |
-
* @since 1.0.0
|
64 |
-
*/
|
65 |
-
public function __construct() {
|
66 |
-
|
67 |
-
// Not BB or Elementor then avoid importer.
|
68 |
-
if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
|
69 |
-
return;
|
70 |
-
}
|
71 |
-
|
72 |
-
// Core Helpers - Image.
|
73 |
-
require_once ABSPATH . 'wp-admin/includes/image.php';
|
74 |
-
|
75 |
-
// Core Helpers - Batch Processing.
|
76 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-cartflows-importer-image.php';
|
77 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
|
78 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';
|
79 |
-
|
80 |
-
// Elementor.
|
81 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
82 |
-
// Add "elementor" in import [queue].
|
83 |
-
// @todo Remove required `allow_url_fopen` support.
|
84 |
-
if ( ini_get( 'allow_url_fopen' ) ) {
|
85 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
|
86 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor-batch.php';
|
87 |
-
self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
// Beaver Builder.
|
92 |
-
if ( class_exists( 'FLBuilder' ) ) {
|
93 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder.php';
|
94 |
-
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder-batch.php';
|
95 |
-
self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
|
96 |
-
}
|
97 |
-
|
98 |
-
// Start image importing after site import complete.
|
99 |
-
add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
|
100 |
-
add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
|
101 |
-
add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
|
102 |
-
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Added .svg files as supported format in the uploader.
|
107 |
-
*
|
108 |
-
* @since 1.1.4
|
109 |
-
*
|
110 |
-
* @param array $mimes Already supported mime types.
|
111 |
-
*/
|
112 |
-
public function custom_upload_mimes( $mimes ) {
|
113 |
-
|
114 |
-
// Allow SVG files.
|
115 |
-
$mimes['svg'] = 'image/svg+xml';
|
116 |
-
$mimes['svgz'] = 'image/svg+xml';
|
117 |
-
|
118 |
-
// Allow XML files.
|
119 |
-
$mimes['xml'] = 'text/xml';
|
120 |
-
|
121 |
-
return $mimes;
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Add SVG image support
|
126 |
-
*
|
127 |
-
* @since 1.1.4
|
128 |
-
*
|
129 |
-
* @param array $response Attachment response.
|
130 |
-
* @param object $attachment Attachment object.
|
131 |
-
* @param array $meta Attachment meta data.
|
132 |
-
*/
|
133 |
-
function add_svg_image_support( $response, $attachment, $meta ) {
|
134 |
-
if ( ! function_exists( 'simplexml_load_file' ) ) {
|
135 |
-
return $response;
|
136 |
-
}
|
137 |
-
|
138 |
-
if ( ! empty( $response['sizes'] ) ) {
|
139 |
-
return $response;
|
140 |
-
}
|
141 |
-
|
142 |
-
if ( 'image/svg+xml' !== $response['mime'] ) {
|
143 |
-
return $response;
|
144 |
-
}
|
145 |
-
|
146 |
-
$svg_path = get_attached_file( $attachment->ID );
|
147 |
-
|
148 |
-
$dimensions = self::get_svg_dimensions( $svg_path );
|
149 |
-
|
150 |
-
$response['sizes'] = array(
|
151 |
-
'full' => array(
|
152 |
-
'url' => $response['url'],
|
153 |
-
'width' => $dimensions->width,
|
154 |
-
'height' => $dimensions->height,
|
155 |
-
'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
|
156 |
-
),
|
157 |
-
);
|
158 |
-
|
159 |
-
return $response;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Get SVG Dimensions
|
164 |
-
*
|
165 |
-
* @since 1.1.4.
|
166 |
-
*
|
167 |
-
* @param string $svg SVG file path.
|
168 |
-
* @return array Return SVG file height & width for valid SVG file.
|
169 |
-
*/
|
170 |
-
public static function get_svg_dimensions( $svg ) {
|
171 |
-
|
172 |
-
$svg = simplexml_load_file( $svg );
|
173 |
-
|
174 |
-
if ( false === $svg ) {
|
175 |
-
$width = '0';
|
176 |
-
$height = '0';
|
177 |
-
} else {
|
178 |
-
$attributes = $svg->attributes();
|
179 |
-
$width = (string) $attributes->width;
|
180 |
-
$height = (string) $attributes->height;
|
181 |
-
}
|
182 |
-
|
183 |
-
return (object) array(
|
184 |
-
'width' => $width,
|
185 |
-
'height' => $height,
|
186 |
-
);
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Batch Process Complete.
|
191 |
-
*
|
192 |
-
* @return void
|
193 |
-
*/
|
194 |
-
public function complete_batch_import() {
|
195 |
-
wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Start Image Import
|
200 |
-
*
|
201 |
-
* @param integer $post_id Post Id.
|
202 |
-
*
|
203 |
-
* @return void
|
204 |
-
*/
|
205 |
-
public function start_batch_process( $post_id = '' ) {
|
206 |
-
|
207 |
-
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
208 |
-
|
209 |
-
wcf()->logger->import_log( '(✓) BATCH Started!' );
|
210 |
-
wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
|
211 |
-
|
212 |
-
// Add "elementor" in import [queue].
|
213 |
-
if ( 'beaver-builder' === $default_page_builder && self::$batch_instance_bb ) {
|
214 |
-
|
215 |
-
// Add to queue.
|
216 |
-
self::$batch_instance_bb->push_to_queue( $post_id );
|
217 |
-
|
218 |
-
// Dispatch Queue.
|
219 |
-
self::$batch_instance_bb->save()->dispatch();
|
220 |
-
|
221 |
-
wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
|
222 |
-
|
223 |
-
} elseif ( 'elementor' === $default_page_builder && self::$batch_instance_elementor ) {
|
224 |
-
|
225 |
-
// Add to queue.
|
226 |
-
self::$batch_instance_elementor->push_to_queue( $post_id );
|
227 |
-
|
228 |
-
// Dispatch Queue.
|
229 |
-
self::$batch_instance_elementor->save()->dispatch();
|
230 |
-
|
231 |
-
wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
|
232 |
-
} else {
|
233 |
-
wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
|
234 |
-
}
|
235 |
-
}
|
236 |
-
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Kicking this off by calling 'get_instance()' method
|
241 |
-
*/
|
242 |
-
CartFlows_Batch_Process::get_instance();
|
243 |
-
|
244 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Batch Processing
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows_Batch_Process
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class CartFlows_Batch_Process {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @var object Class object.
|
23 |
+
* @access private
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Elementor Batch Instance
|
29 |
+
*
|
30 |
+
* @since 1.1.1 Updated instance name with elementor specific.
|
31 |
+
*
|
32 |
+
* @since 1.0.0
|
33 |
+
* @var object Class object.
|
34 |
+
* @access public
|
35 |
+
*/
|
36 |
+
public static $batch_instance_elementor;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Beaver Builder Batch Instance
|
40 |
+
*
|
41 |
+
* @since 1.1.1
|
42 |
+
* @var object Class object.
|
43 |
+
* @access public
|
44 |
+
*/
|
45 |
+
public static $batch_instance_bb;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Initiator
|
49 |
+
*
|
50 |
+
* @since 1.0.0
|
51 |
+
* @return object initialized object of class.
|
52 |
+
*/
|
53 |
+
public static function get_instance() {
|
54 |
+
if ( ! isset( self::$instance ) ) {
|
55 |
+
self::$instance = new self;
|
56 |
+
}
|
57 |
+
return self::$instance;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Constructor
|
62 |
+
*
|
63 |
+
* @since 1.0.0
|
64 |
+
*/
|
65 |
+
public function __construct() {
|
66 |
+
|
67 |
+
// Not BB or Elementor then avoid importer.
|
68 |
+
if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
|
72 |
+
// Core Helpers - Image.
|
73 |
+
require_once ABSPATH . 'wp-admin/includes/image.php';
|
74 |
+
|
75 |
+
// Core Helpers - Batch Processing.
|
76 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-cartflows-importer-image.php';
|
77 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
|
78 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';
|
79 |
+
|
80 |
+
// Elementor.
|
81 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
82 |
+
// Add "elementor" in import [queue].
|
83 |
+
// @todo Remove required `allow_url_fopen` support.
|
84 |
+
if ( ini_get( 'allow_url_fopen' ) ) {
|
85 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
|
86 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor-batch.php';
|
87 |
+
self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
// Beaver Builder.
|
92 |
+
if ( class_exists( 'FLBuilder' ) ) {
|
93 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder.php';
|
94 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder-batch.php';
|
95 |
+
self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
|
96 |
+
}
|
97 |
+
|
98 |
+
// Start image importing after site import complete.
|
99 |
+
add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
|
100 |
+
add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
|
101 |
+
add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) );
|
102 |
+
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Added .svg files as supported format in the uploader.
|
107 |
+
*
|
108 |
+
* @since 1.1.4
|
109 |
+
*
|
110 |
+
* @param array $mimes Already supported mime types.
|
111 |
+
*/
|
112 |
+
public function custom_upload_mimes( $mimes ) {
|
113 |
+
|
114 |
+
// Allow SVG files.
|
115 |
+
$mimes['svg'] = 'image/svg+xml';
|
116 |
+
$mimes['svgz'] = 'image/svg+xml';
|
117 |
+
|
118 |
+
// Allow XML files.
|
119 |
+
$mimes['xml'] = 'text/xml';
|
120 |
+
|
121 |
+
return $mimes;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Add SVG image support
|
126 |
+
*
|
127 |
+
* @since 1.1.4
|
128 |
+
*
|
129 |
+
* @param array $response Attachment response.
|
130 |
+
* @param object $attachment Attachment object.
|
131 |
+
* @param array $meta Attachment meta data.
|
132 |
+
*/
|
133 |
+
function add_svg_image_support( $response, $attachment, $meta ) {
|
134 |
+
if ( ! function_exists( 'simplexml_load_file' ) ) {
|
135 |
+
return $response;
|
136 |
+
}
|
137 |
+
|
138 |
+
if ( ! empty( $response['sizes'] ) ) {
|
139 |
+
return $response;
|
140 |
+
}
|
141 |
+
|
142 |
+
if ( 'image/svg+xml' !== $response['mime'] ) {
|
143 |
+
return $response;
|
144 |
+
}
|
145 |
+
|
146 |
+
$svg_path = get_attached_file( $attachment->ID );
|
147 |
+
|
148 |
+
$dimensions = self::get_svg_dimensions( $svg_path );
|
149 |
+
|
150 |
+
$response['sizes'] = array(
|
151 |
+
'full' => array(
|
152 |
+
'url' => $response['url'],
|
153 |
+
'width' => $dimensions->width,
|
154 |
+
'height' => $dimensions->height,
|
155 |
+
'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
|
156 |
+
),
|
157 |
+
);
|
158 |
+
|
159 |
+
return $response;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Get SVG Dimensions
|
164 |
+
*
|
165 |
+
* @since 1.1.4.
|
166 |
+
*
|
167 |
+
* @param string $svg SVG file path.
|
168 |
+
* @return array Return SVG file height & width for valid SVG file.
|
169 |
+
*/
|
170 |
+
public static function get_svg_dimensions( $svg ) {
|
171 |
+
|
172 |
+
$svg = simplexml_load_file( $svg );
|
173 |
+
|
174 |
+
if ( false === $svg ) {
|
175 |
+
$width = '0';
|
176 |
+
$height = '0';
|
177 |
+
} else {
|
178 |
+
$attributes = $svg->attributes();
|
179 |
+
$width = (string) $attributes->width;
|
180 |
+
$height = (string) $attributes->height;
|
181 |
+
}
|
182 |
+
|
183 |
+
return (object) array(
|
184 |
+
'width' => $width,
|
185 |
+
'height' => $height,
|
186 |
+
);
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Batch Process Complete.
|
191 |
+
*
|
192 |
+
* @return void
|
193 |
+
*/
|
194 |
+
public function complete_batch_import() {
|
195 |
+
wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Start Image Import
|
200 |
+
*
|
201 |
+
* @param integer $post_id Post Id.
|
202 |
+
*
|
203 |
+
* @return void
|
204 |
+
*/
|
205 |
+
public function start_batch_process( $post_id = '' ) {
|
206 |
+
|
207 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
208 |
+
|
209 |
+
wcf()->logger->import_log( '(✓) BATCH Started!' );
|
210 |
+
wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
|
211 |
+
|
212 |
+
// Add "elementor" in import [queue].
|
213 |
+
if ( 'beaver-builder' === $default_page_builder && self::$batch_instance_bb ) {
|
214 |
+
|
215 |
+
// Add to queue.
|
216 |
+
self::$batch_instance_bb->push_to_queue( $post_id );
|
217 |
+
|
218 |
+
// Dispatch Queue.
|
219 |
+
self::$batch_instance_bb->save()->dispatch();
|
220 |
+
|
221 |
+
wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
|
222 |
+
|
223 |
+
} elseif ( 'elementor' === $default_page_builder && self::$batch_instance_elementor ) {
|
224 |
+
|
225 |
+
// Add to queue.
|
226 |
+
self::$batch_instance_elementor->push_to_queue( $post_id );
|
227 |
+
|
228 |
+
// Dispatch Queue.
|
229 |
+
self::$batch_instance_elementor->save()->dispatch();
|
230 |
+
|
231 |
+
wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
|
232 |
+
} else {
|
233 |
+
wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Kicking this off by calling 'get_instance()' method
|
241 |
+
*/
|
242 |
+
CartFlows_Batch_Process::get_instance();
|
243 |
+
|
244 |
+
endif;
|
classes/batch-process/class-cartflows-importer-beaver-builder.php
CHANGED
@@ -1,229 +1,229 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Beaver Builder Importer
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
* @since 1.1.1
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! class_exists( 'CartFlows_Importer_Beaver_Builder' ) ) :
|
10 |
-
|
11 |
-
/**
|
12 |
-
* CartFlows Import Beaver Builder
|
13 |
-
*
|
14 |
-
* @since 1.1.1
|
15 |
-
*/
|
16 |
-
class CartFlows_Importer_Beaver_Builder {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Instance
|
20 |
-
*
|
21 |
-
* @since 1.1.1
|
22 |
-
* @access private
|
23 |
-
* @var object Class object.
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Initiator
|
29 |
-
*
|
30 |
-
* @since 1.1.1
|
31 |
-
* @return object initialized object of class.
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
|
35 |
-
if ( ! isset( self::$instance ) ) {
|
36 |
-
self::$instance = new self;
|
37 |
-
}
|
38 |
-
return self::$instance;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Constructor
|
43 |
-
*
|
44 |
-
* @since 1.1.1
|
45 |
-
*/
|
46 |
-
public function __construct() {
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Update post meta.
|
51 |
-
*
|
52 |
-
* @param integer $post_id Post ID.
|
53 |
-
* @return void
|
54 |
-
*/
|
55 |
-
public function import_single_post( $post_id = 0 ) {
|
56 |
-
|
57 |
-
$data = get_post_meta( $post_id, '_fl_builder_data', true );
|
58 |
-
if ( ! empty( $data ) ) {
|
59 |
-
|
60 |
-
$data = $this->get_import_data( $data );
|
61 |
-
|
62 |
-
// Update page builder data.
|
63 |
-
update_post_meta( $post_id, '_fl_builder_data', $data );
|
64 |
-
update_post_meta( $post_id, '_fl_builder_draft', $data );
|
65 |
-
|
66 |
-
// Clear all cache.
|
67 |
-
FLBuilderModel::delete_asset_cache_for_all_posts();
|
68 |
-
} else {
|
69 |
-
wcf()->logger->import_log( '(✕) Not have "Beaver Builder" Data. Post meta _fl_builder_data is empty!' );
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Update post meta.
|
75 |
-
*
|
76 |
-
* @param array $data Page builder data.
|
77 |
-
* @return mixed
|
78 |
-
*/
|
79 |
-
public function get_import_data( $data ) {
|
80 |
-
|
81 |
-
if ( empty( $data ) ) {
|
82 |
-
return array();
|
83 |
-
}
|
84 |
-
|
85 |
-
foreach ( $data as $key => $el ) {
|
86 |
-
|
87 |
-
// Import 'row' images.
|
88 |
-
if ( 'row' === $el->type ) {
|
89 |
-
$data[ $key ]->settings = self::import_row_images( $el->settings );
|
90 |
-
}
|
91 |
-
|
92 |
-
// Import 'module' images.
|
93 |
-
if ( 'module' === $el->type ) {
|
94 |
-
$data[ $key ]->settings = self::import_module_images( $el->settings );
|
95 |
-
}
|
96 |
-
|
97 |
-
// Import 'column' images.
|
98 |
-
if ( 'column' === $el->type ) {
|
99 |
-
$data[ $key ]->settings = self::import_column_images( $el->settings );
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
return $data;
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Import Module Images.
|
108 |
-
*
|
109 |
-
* @param object $settings Module settings object.
|
110 |
-
* @return object
|
111 |
-
*/
|
112 |
-
public static function import_module_images( $settings ) {
|
113 |
-
|
114 |
-
/**
|
115 |
-
* 1) Set photos.
|
116 |
-
*/
|
117 |
-
$settings = self::import_photo( $settings );
|
118 |
-
|
119 |
-
/**
|
120 |
-
* 2) Set `$settings->data` for Only type 'image-icon'
|
121 |
-
*
|
122 |
-
* @todo Remove the condition `'image-icon' === $settings->type` if `$settings->data` is used only for the Image Icon.
|
123 |
-
*/
|
124 |
-
if (
|
125 |
-
isset( $settings->data ) &&
|
126 |
-
isset( $settings->photo ) && ! empty( $settings->photo ) &&
|
127 |
-
'image-icon' === $settings->type
|
128 |
-
) {
|
129 |
-
$settings->data = FLBuilderPhoto::get_attachment_data( $settings->photo );
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* 3) Set `list item` module images
|
134 |
-
*/
|
135 |
-
if ( isset( $settings->add_list_item ) ) {
|
136 |
-
foreach ( $settings->add_list_item as $key => $value ) {
|
137 |
-
$settings->add_list_item[ $key ] = self::import_photo( $value );
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
return $settings;
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Import Column Images.
|
146 |
-
*
|
147 |
-
* @param object $settings Column settings object.
|
148 |
-
* @return object
|
149 |
-
*/
|
150 |
-
public static function import_column_images( $settings ) {
|
151 |
-
|
152 |
-
// 1) Set BG Images.
|
153 |
-
$settings = self::import_bg_image( $settings );
|
154 |
-
|
155 |
-
return $settings;
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Import Row Images.
|
160 |
-
*
|
161 |
-
* @param object $settings Row settings object.
|
162 |
-
* @return object
|
163 |
-
*/
|
164 |
-
public static function import_row_images( $settings ) {
|
165 |
-
|
166 |
-
// 1) Set BG Images.
|
167 |
-
$settings = self::import_bg_image( $settings );
|
168 |
-
|
169 |
-
return $settings;
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Helper: Import BG Images.
|
174 |
-
*
|
175 |
-
* @param object $settings Row settings object.
|
176 |
-
* @return object
|
177 |
-
*/
|
178 |
-
public static function import_bg_image( $settings ) {
|
179 |
-
|
180 |
-
if (
|
181 |
-
( ! empty( $settings->bg_image ) && ! empty( $settings->bg_image_src ) )
|
182 |
-
) {
|
183 |
-
$image = array(
|
184 |
-
'url' => $settings->bg_image_src,
|
185 |
-
'id' => $settings->bg_image,
|
186 |
-
);
|
187 |
-
|
188 |
-
$downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
|
189 |
-
|
190 |
-
$settings->bg_image_src = $downloaded_image['url'];
|
191 |
-
$settings->bg_image = $downloaded_image['id'];
|
192 |
-
}
|
193 |
-
|
194 |
-
return $settings;
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Helper: Import Photo.
|
199 |
-
*
|
200 |
-
* @param object $settings Row settings object.
|
201 |
-
* @return object
|
202 |
-
*/
|
203 |
-
public static function import_photo( $settings ) {
|
204 |
-
|
205 |
-
if ( ! empty( $settings->photo ) && ! empty( $settings->photo_src ) ) {
|
206 |
-
|
207 |
-
$image = array(
|
208 |
-
'url' => $settings->photo_src,
|
209 |
-
'id' => $settings->photo,
|
210 |
-
);
|
211 |
-
|
212 |
-
$downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
|
213 |
-
|
214 |
-
$settings->photo_src = $downloaded_image['url'];
|
215 |
-
$settings->photo = $downloaded_image['id'];
|
216 |
-
}
|
217 |
-
|
218 |
-
return $settings;
|
219 |
-
}
|
220 |
-
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Initialize class object with 'get_instance()' method
|
226 |
-
*/
|
227 |
-
CartFlows_Importer_Beaver_Builder::get_instance();
|
228 |
-
|
229 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Beaver Builder Importer
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.1.1
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_Importer_Beaver_Builder' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows Import Beaver Builder
|
13 |
+
*
|
14 |
+
* @since 1.1.1
|
15 |
+
*/
|
16 |
+
class CartFlows_Importer_Beaver_Builder {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.1.1
|
22 |
+
* @access private
|
23 |
+
* @var object Class object.
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initiator
|
29 |
+
*
|
30 |
+
* @since 1.1.1
|
31 |
+
* @return object initialized object of class.
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
|
35 |
+
if ( ! isset( self::$instance ) ) {
|
36 |
+
self::$instance = new self;
|
37 |
+
}
|
38 |
+
return self::$instance;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor
|
43 |
+
*
|
44 |
+
* @since 1.1.1
|
45 |
+
*/
|
46 |
+
public function __construct() {
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Update post meta.
|
51 |
+
*
|
52 |
+
* @param integer $post_id Post ID.
|
53 |
+
* @return void
|
54 |
+
*/
|
55 |
+
public function import_single_post( $post_id = 0 ) {
|
56 |
+
|
57 |
+
$data = get_post_meta( $post_id, '_fl_builder_data', true );
|
58 |
+
if ( ! empty( $data ) ) {
|
59 |
+
|
60 |
+
$data = $this->get_import_data( $data );
|
61 |
+
|
62 |
+
// Update page builder data.
|
63 |
+
update_post_meta( $post_id, '_fl_builder_data', $data );
|
64 |
+
update_post_meta( $post_id, '_fl_builder_draft', $data );
|
65 |
+
|
66 |
+
// Clear all cache.
|
67 |
+
FLBuilderModel::delete_asset_cache_for_all_posts();
|
68 |
+
} else {
|
69 |
+
wcf()->logger->import_log( '(✕) Not have "Beaver Builder" Data. Post meta _fl_builder_data is empty!' );
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Update post meta.
|
75 |
+
*
|
76 |
+
* @param array $data Page builder data.
|
77 |
+
* @return mixed
|
78 |
+
*/
|
79 |
+
public function get_import_data( $data ) {
|
80 |
+
|
81 |
+
if ( empty( $data ) ) {
|
82 |
+
return array();
|
83 |
+
}
|
84 |
+
|
85 |
+
foreach ( $data as $key => $el ) {
|
86 |
+
|
87 |
+
// Import 'row' images.
|
88 |
+
if ( 'row' === $el->type ) {
|
89 |
+
$data[ $key ]->settings = self::import_row_images( $el->settings );
|
90 |
+
}
|
91 |
+
|
92 |
+
// Import 'module' images.
|
93 |
+
if ( 'module' === $el->type ) {
|
94 |
+
$data[ $key ]->settings = self::import_module_images( $el->settings );
|
95 |
+
}
|
96 |
+
|
97 |
+
// Import 'column' images.
|
98 |
+
if ( 'column' === $el->type ) {
|
99 |
+
$data[ $key ]->settings = self::import_column_images( $el->settings );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
return $data;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Import Module Images.
|
108 |
+
*
|
109 |
+
* @param object $settings Module settings object.
|
110 |
+
* @return object
|
111 |
+
*/
|
112 |
+
public static function import_module_images( $settings ) {
|
113 |
+
|
114 |
+
/**
|
115 |
+
* 1) Set photos.
|
116 |
+
*/
|
117 |
+
$settings = self::import_photo( $settings );
|
118 |
+
|
119 |
+
/**
|
120 |
+
* 2) Set `$settings->data` for Only type 'image-icon'
|
121 |
+
*
|
122 |
+
* @todo Remove the condition `'image-icon' === $settings->type` if `$settings->data` is used only for the Image Icon.
|
123 |
+
*/
|
124 |
+
if (
|
125 |
+
isset( $settings->data ) &&
|
126 |
+
isset( $settings->photo ) && ! empty( $settings->photo ) &&
|
127 |
+
'image-icon' === $settings->type
|
128 |
+
) {
|
129 |
+
$settings->data = FLBuilderPhoto::get_attachment_data( $settings->photo );
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* 3) Set `list item` module images
|
134 |
+
*/
|
135 |
+
if ( isset( $settings->add_list_item ) ) {
|
136 |
+
foreach ( $settings->add_list_item as $key => $value ) {
|
137 |
+
$settings->add_list_item[ $key ] = self::import_photo( $value );
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return $settings;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Import Column Images.
|
146 |
+
*
|
147 |
+
* @param object $settings Column settings object.
|
148 |
+
* @return object
|
149 |
+
*/
|
150 |
+
public static function import_column_images( $settings ) {
|
151 |
+
|
152 |
+
// 1) Set BG Images.
|
153 |
+
$settings = self::import_bg_image( $settings );
|
154 |
+
|
155 |
+
return $settings;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Import Row Images.
|
160 |
+
*
|
161 |
+
* @param object $settings Row settings object.
|
162 |
+
* @return object
|
163 |
+
*/
|
164 |
+
public static function import_row_images( $settings ) {
|
165 |
+
|
166 |
+
// 1) Set BG Images.
|
167 |
+
$settings = self::import_bg_image( $settings );
|
168 |
+
|
169 |
+
return $settings;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Helper: Import BG Images.
|
174 |
+
*
|
175 |
+
* @param object $settings Row settings object.
|
176 |
+
* @return object
|
177 |
+
*/
|
178 |
+
public static function import_bg_image( $settings ) {
|
179 |
+
|
180 |
+
if (
|
181 |
+
( ! empty( $settings->bg_image ) && ! empty( $settings->bg_image_src ) )
|
182 |
+
) {
|
183 |
+
$image = array(
|
184 |
+
'url' => $settings->bg_image_src,
|
185 |
+
'id' => $settings->bg_image,
|
186 |
+
);
|
187 |
+
|
188 |
+
$downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
|
189 |
+
|
190 |
+
$settings->bg_image_src = $downloaded_image['url'];
|
191 |
+
$settings->bg_image = $downloaded_image['id'];
|
192 |
+
}
|
193 |
+
|
194 |
+
return $settings;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Helper: Import Photo.
|
199 |
+
*
|
200 |
+
* @param object $settings Row settings object.
|
201 |
+
* @return object
|
202 |
+
*/
|
203 |
+
public static function import_photo( $settings ) {
|
204 |
+
|
205 |
+
if ( ! empty( $settings->photo ) && ! empty( $settings->photo_src ) ) {
|
206 |
+
|
207 |
+
$image = array(
|
208 |
+
'url' => $settings->photo_src,
|
209 |
+
'id' => $settings->photo,
|
210 |
+
);
|
211 |
+
|
212 |
+
$downloaded_image = CartFlows_Import_Image::get_instance()->import( $image );
|
213 |
+
|
214 |
+
$settings->photo_src = $downloaded_image['url'];
|
215 |
+
$settings->photo = $downloaded_image['id'];
|
216 |
+
}
|
217 |
+
|
218 |
+
return $settings;
|
219 |
+
}
|
220 |
+
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Initialize class object with 'get_instance()' method
|
226 |
+
*/
|
227 |
+
CartFlows_Importer_Beaver_Builder::get_instance();
|
228 |
+
|
229 |
+
endif;
|
classes/batch-process/class-cartflows-importer-elementor.php
CHANGED
@@ -1,69 +1,69 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Elementor Importer
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
namespace Elementor\TemplateLibrary;
|
9 |
-
|
10 |
-
use Elementor\Core\Base\Document;
|
11 |
-
use Elementor\DB;
|
12 |
-
use Elementor\Core\Settings\Page\Manager as PageSettingsManager;
|
13 |
-
use Elementor\Core\Settings\Manager as SettingsManager;
|
14 |
-
use Elementor\Core\Settings\Page\Model;
|
15 |
-
use Elementor\Editor;
|
16 |
-
use Elementor\Plugin;
|
17 |
-
use Elementor\Settings;
|
18 |
-
use Elementor\Utils;
|
19 |
-
|
20 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
21 |
-
exit; // Exit if accessed directly.
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Elementor template library local source.
|
26 |
-
*
|
27 |
-
* Elementor template library local source handler class is responsible for
|
28 |
-
* handling local Elementor templates saved by the user locally on his site.
|
29 |
-
*
|
30 |
-
* @since 1.0.0
|
31 |
-
*/
|
32 |
-
class CartFlows_Importer_Elementor extends Source_Local {
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Import single template
|
36 |
-
*
|
37 |
-
* @param int $post_id post ID.
|
38 |
-
*/
|
39 |
-
public function import_single_template( $post_id ) {
|
40 |
-
|
41 |
-
$rest_content = get_post_meta( $post_id, '_elementor_data', true );
|
42 |
-
|
43 |
-
if ( empty( $rest_content ) ) {
|
44 |
-
$data = __( 'Invalid content.', 'cartflows' );
|
45 |
-
wcf()->logger->import_log( '(✕) ' . $data );
|
46 |
-
}
|
47 |
-
|
48 |
-
$rest_content = add_magic_quotes( $rest_content );
|
49 |
-
$content = json_decode( $rest_content, true );
|
50 |
-
|
51 |
-
if ( ! is_array( $content ) ) {
|
52 |
-
$data = __( 'Invalid content. Expected an array.', 'cartflows' );
|
53 |
-
wcf()->logger->import_log( '(✕) ' . $data );
|
54 |
-
wcf()->logger->import_log( $content );
|
55 |
-
} else {
|
56 |
-
|
57 |
-
wcf()->logger->import_log( '(✓) Processing Request..' );
|
58 |
-
|
59 |
-
// Import the data.
|
60 |
-
$content = $this->process_export_import_content( $content, 'on_import' );
|
61 |
-
|
62 |
-
// Update content.
|
63 |
-
update_metadata( 'post', $post_id, '_elementor_data', $content );
|
64 |
-
|
65 |
-
wcf()->logger->import_log( '(✓) Process Complete' );
|
66 |
-
}
|
67 |
-
|
68 |
-
}
|
69 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Elementor Importer
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace Elementor\TemplateLibrary;
|
9 |
+
|
10 |
+
use Elementor\Core\Base\Document;
|
11 |
+
use Elementor\DB;
|
12 |
+
use Elementor\Core\Settings\Page\Manager as PageSettingsManager;
|
13 |
+
use Elementor\Core\Settings\Manager as SettingsManager;
|
14 |
+
use Elementor\Core\Settings\Page\Model;
|
15 |
+
use Elementor\Editor;
|
16 |
+
use Elementor\Plugin;
|
17 |
+
use Elementor\Settings;
|
18 |
+
use Elementor\Utils;
|
19 |
+
|
20 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
21 |
+
exit; // Exit if accessed directly.
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Elementor template library local source.
|
26 |
+
*
|
27 |
+
* Elementor template library local source handler class is responsible for
|
28 |
+
* handling local Elementor templates saved by the user locally on his site.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
*/
|
32 |
+
class CartFlows_Importer_Elementor extends Source_Local {
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Import single template
|
36 |
+
*
|
37 |
+
* @param int $post_id post ID.
|
38 |
+
*/
|
39 |
+
public function import_single_template( $post_id ) {
|
40 |
+
|
41 |
+
$rest_content = get_post_meta( $post_id, '_elementor_data', true );
|
42 |
+
|
43 |
+
if ( empty( $rest_content ) ) {
|
44 |
+
$data = __( 'Invalid content.', 'cartflows' );
|
45 |
+
wcf()->logger->import_log( '(✕) ' . $data );
|
46 |
+
}
|
47 |
+
|
48 |
+
$rest_content = add_magic_quotes( $rest_content );
|
49 |
+
$content = json_decode( $rest_content, true );
|
50 |
+
|
51 |
+
if ( ! is_array( $content ) ) {
|
52 |
+
$data = __( 'Invalid content. Expected an array.', 'cartflows' );
|
53 |
+
wcf()->logger->import_log( '(✕) ' . $data );
|
54 |
+
wcf()->logger->import_log( $content );
|
55 |
+
} else {
|
56 |
+
|
57 |
+
wcf()->logger->import_log( '(✓) Processing Request..' );
|
58 |
+
|
59 |
+
// Import the data.
|
60 |
+
$content = $this->process_export_import_content( $content, 'on_import' );
|
61 |
+
|
62 |
+
// Update content.
|
63 |
+
update_metadata( 'post', $post_id, '_elementor_data', $content );
|
64 |
+
|
65 |
+
wcf()->logger->import_log( '(✓) Process Complete' );
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
+
}
|
classes/class-cartflows-admin-fields.php
CHANGED
@@ -1,198 +1,198 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CARTFLOWS Admin Fields.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Cartflows_Admin_Fields.
|
10 |
-
*/
|
11 |
-
class Cartflows_Admin_Fields {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Text Field
|
15 |
-
*
|
16 |
-
* @param array $args Args.
|
17 |
-
* @return string
|
18 |
-
*/
|
19 |
-
static public function text_field( $args ) {
|
20 |
-
|
21 |
-
$id = $args['id'];
|
22 |
-
$name = $args['name'];
|
23 |
-
$title = $args['title'];
|
24 |
-
$value = $args['value'];
|
25 |
-
|
26 |
-
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
27 |
-
$output .= '<label for="' . $id . '">' . $title . '</label>';
|
28 |
-
$output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
|
29 |
-
$output .= '</div>';
|
30 |
-
|
31 |
-
return $output;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* URL Field
|
36 |
-
*
|
37 |
-
* @param array $args Args.
|
38 |
-
* @return string
|
39 |
-
*/
|
40 |
-
static public function url_field( $args ) {
|
41 |
-
|
42 |
-
$id = $args['id'];
|
43 |
-
$name = $args['name'];
|
44 |
-
$title = $args['title'];
|
45 |
-
$value = $args['value'];
|
46 |
-
|
47 |
-
$output = '<div class="form-field">';
|
48 |
-
$output .= '<label for="' . $id . '">' . $title . '</label>';
|
49 |
-
$output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
|
50 |
-
$output .= '</div>';
|
51 |
-
|
52 |
-
return $output;
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Checkbox Field
|
57 |
-
*
|
58 |
-
* @param array $args Args.
|
59 |
-
* @return string
|
60 |
-
*/
|
61 |
-
static public function checkobox_field( $args ) {
|
62 |
-
|
63 |
-
$id = $args['id'];
|
64 |
-
$name = $args['name'];
|
65 |
-
$title = $args['title'];
|
66 |
-
$value = $args['value'];
|
67 |
-
|
68 |
-
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
69 |
-
$output .= '<label for="' . $id . '">';
|
70 |
-
$output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
|
71 |
-
$output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
|
72 |
-
$output .= $title;
|
73 |
-
$output .= '</label>';
|
74 |
-
$output .= '</div>';
|
75 |
-
|
76 |
-
return $output;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Select Field
|
81 |
-
*
|
82 |
-
* @since 1.1.4
|
83 |
-
*
|
84 |
-
* @param array $args Args.
|
85 |
-
* @return string
|
86 |
-
*/
|
87 |
-
static public function select_field( $args ) {
|
88 |
-
|
89 |
-
$id = $args['id'];
|
90 |
-
$name = $args['name'];
|
91 |
-
$title = $args['title'];
|
92 |
-
$description = $args['description'];
|
93 |
-
$value = $args['value'];
|
94 |
-
$options = $args['options'];
|
95 |
-
|
96 |
-
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
97 |
-
|
98 |
-
$output .= '<div class="form-field-label">';
|
99 |
-
$output .= $title;
|
100 |
-
$output .= '</div>';
|
101 |
-
|
102 |
-
$output .= '<div class="form-field-data">';
|
103 |
-
$output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
|
104 |
-
foreach ( $options as $option_value => $option_title ) {
|
105 |
-
$output .= '<option value="' . $option_value . '" ' . selected( $value, $option_value, false ) . '>' . $option_title . '</option>';
|
106 |
-
}
|
107 |
-
$output .= '</select>';
|
108 |
-
$output .= '</div>';
|
109 |
-
|
110 |
-
$output .= '<div class="form-field-desc">';
|
111 |
-
$output .= '<p>';
|
112 |
-
$output .= $description;
|
113 |
-
$output .= '</p>';
|
114 |
-
$output .= '</div>';
|
115 |
-
$output .= '</div>';
|
116 |
-
|
117 |
-
return $output;
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Checkout Selection Field
|
122 |
-
*
|
123 |
-
* @param array $args Args.
|
124 |
-
* @return string
|
125 |
-
*/
|
126 |
-
static public function flow_checkout_selection_field( $args ) {
|
127 |
-
|
128 |
-
$id = $args['id'];
|
129 |
-
$name = $args['name'];
|
130 |
-
$title = $args['title'];
|
131 |
-
$value = $args['value'];
|
132 |
-
|
133 |
-
$checkout_steps = get_posts(
|
134 |
-
array(
|
135 |
-
'posts_per_page' => -1,
|
136 |
-
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
137 |
-
'post_status' => 'publish',
|
138 |
-
'orderby' => 'ID',
|
139 |
-
'order' => 'ASC',
|
140 |
-
'tax_query' => array(
|
141 |
-
array(
|
142 |
-
'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
|
143 |
-
'field' => 'slug',
|
144 |
-
'terms' => 'checkout',
|
145 |
-
),
|
146 |
-
),
|
147 |
-
)
|
148 |
-
);
|
149 |
-
|
150 |
-
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
151 |
-
|
152 |
-
$output .= '<div class="form-field-label">';
|
153 |
-
$output .= '<label for="' . $id . '">';
|
154 |
-
$output .= $title;
|
155 |
-
$output .= '</label>';
|
156 |
-
$output .= '</div>';
|
157 |
-
|
158 |
-
$output .= '<div class="form-field-data">';
|
159 |
-
$output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
|
160 |
-
|
161 |
-
if ( ! empty( $checkout_steps ) ) {
|
162 |
-
$output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
|
163 |
-
} else {
|
164 |
-
|
165 |
-
$output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
|
166 |
-
}
|
167 |
-
|
168 |
-
foreach ( $checkout_steps as $index => $step_data ) {
|
169 |
-
|
170 |
-
$output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
|
171 |
-
}
|
172 |
-
|
173 |
-
$output .= '</select>';
|
174 |
-
$output .= '</div>';
|
175 |
-
|
176 |
-
if ( '' !== $value ) {
|
177 |
-
$output .= '<div class="form-field-actions">';
|
178 |
-
$output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
|
179 |
-
$output .= '<span class="dashicons dashicons-edit"></span>';
|
180 |
-
$output .= '<span class="">Edit</span>';
|
181 |
-
$output .= '</a>';
|
182 |
-
$output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
|
183 |
-
$output .= '<span class="dashicons dashicons-visibility"></span>';
|
184 |
-
$output .= '<span class="">View</span>';
|
185 |
-
$output .= '</a>';
|
186 |
-
$output .= '</div>';
|
187 |
-
}
|
188 |
-
|
189 |
-
$output .= '<div class="form-field-desc">';
|
190 |
-
/* translators: %s: link */
|
191 |
-
$output .= '<p>' . sprintf( __( 'Be sure not to add any product in above selected Global Checkout step. Please read information about how to set up Global Checkout %1$shere%2$s.', 'cartflows' ), '<a href="https://cartflows.com/docs/global-checkout/" target="_blank">', '</a>' ) . '</p>';
|
192 |
-
$output .= '</div>';
|
193 |
-
|
194 |
-
$output .= '</div>';
|
195 |
-
|
196 |
-
return $output;
|
197 |
-
}
|
198 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CARTFLOWS Admin Fields.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Cartflows_Admin_Fields.
|
10 |
+
*/
|
11 |
+
class Cartflows_Admin_Fields {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Text Field
|
15 |
+
*
|
16 |
+
* @param array $args Args.
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
static public function text_field( $args ) {
|
20 |
+
|
21 |
+
$id = $args['id'];
|
22 |
+
$name = $args['name'];
|
23 |
+
$title = $args['title'];
|
24 |
+
$value = $args['value'];
|
25 |
+
|
26 |
+
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
27 |
+
$output .= '<label for="' . $id . '">' . $title . '</label>';
|
28 |
+
$output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_attr( $value ) . '">';
|
29 |
+
$output .= '</div>';
|
30 |
+
|
31 |
+
return $output;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* URL Field
|
36 |
+
*
|
37 |
+
* @param array $args Args.
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
static public function url_field( $args ) {
|
41 |
+
|
42 |
+
$id = $args['id'];
|
43 |
+
$name = $args['name'];
|
44 |
+
$title = $args['title'];
|
45 |
+
$value = $args['value'];
|
46 |
+
|
47 |
+
$output = '<div class="form-field">';
|
48 |
+
$output .= '<label for="' . $id . '">' . $title . '</label>';
|
49 |
+
$output .= '<input type="text" name="' . $name . '" id="' . $id . '" class="placeholder placeholder-active" value="' . esc_url( $value ) . '">';
|
50 |
+
$output .= '</div>';
|
51 |
+
|
52 |
+
return $output;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Checkbox Field
|
57 |
+
*
|
58 |
+
* @param array $args Args.
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
static public function checkobox_field( $args ) {
|
62 |
+
|
63 |
+
$id = $args['id'];
|
64 |
+
$name = $args['name'];
|
65 |
+
$title = $args['title'];
|
66 |
+
$value = $args['value'];
|
67 |
+
|
68 |
+
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
69 |
+
$output .= '<label for="' . $id . '">';
|
70 |
+
$output .= '<input type="hidden" id="wcf_hid_' . $id . '" name="' . $name . '" value="disable">';
|
71 |
+
$output .= '<input type="checkbox" id="wcf_' . $id . '" name="' . $name . '" value="enable" ' . checked( $value, 'enable', false ) . '>';
|
72 |
+
$output .= $title;
|
73 |
+
$output .= '</label>';
|
74 |
+
$output .= '</div>';
|
75 |
+
|
76 |
+
return $output;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Select Field
|
81 |
+
*
|
82 |
+
* @since 1.1.4
|
83 |
+
*
|
84 |
+
* @param array $args Args.
|
85 |
+
* @return string
|
86 |
+
*/
|
87 |
+
static public function select_field( $args ) {
|
88 |
+
|
89 |
+
$id = $args['id'];
|
90 |
+
$name = $args['name'];
|
91 |
+
$title = $args['title'];
|
92 |
+
$description = $args['description'];
|
93 |
+
$value = $args['value'];
|
94 |
+
$options = $args['options'];
|
95 |
+
|
96 |
+
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
97 |
+
|
98 |
+
$output .= '<div class="form-field-label">';
|
99 |
+
$output .= $title;
|
100 |
+
$output .= '</div>';
|
101 |
+
|
102 |
+
$output .= '<div class="form-field-data">';
|
103 |
+
$output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
|
104 |
+
foreach ( $options as $option_value => $option_title ) {
|
105 |
+
$output .= '<option value="' . $option_value . '" ' . selected( $value, $option_value, false ) . '>' . $option_title . '</option>';
|
106 |
+
}
|
107 |
+
$output .= '</select>';
|
108 |
+
$output .= '</div>';
|
109 |
+
|
110 |
+
$output .= '<div class="form-field-desc">';
|
111 |
+
$output .= '<p>';
|
112 |
+
$output .= $description;
|
113 |
+
$output .= '</p>';
|
114 |
+
$output .= '</div>';
|
115 |
+
$output .= '</div>';
|
116 |
+
|
117 |
+
return $output;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Checkout Selection Field
|
122 |
+
*
|
123 |
+
* @param array $args Args.
|
124 |
+
* @return string
|
125 |
+
*/
|
126 |
+
static public function flow_checkout_selection_field( $args ) {
|
127 |
+
|
128 |
+
$id = $args['id'];
|
129 |
+
$name = $args['name'];
|
130 |
+
$title = $args['title'];
|
131 |
+
$value = $args['value'];
|
132 |
+
|
133 |
+
$checkout_steps = get_posts(
|
134 |
+
array(
|
135 |
+
'posts_per_page' => -1,
|
136 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
137 |
+
'post_status' => 'publish',
|
138 |
+
'orderby' => 'ID',
|
139 |
+
'order' => 'ASC',
|
140 |
+
'tax_query' => array(
|
141 |
+
array(
|
142 |
+
'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE,
|
143 |
+
'field' => 'slug',
|
144 |
+
'terms' => 'checkout',
|
145 |
+
),
|
146 |
+
),
|
147 |
+
)
|
148 |
+
);
|
149 |
+
|
150 |
+
$output = '<div class="form-field" id="form-field-' . $id . '">';
|
151 |
+
|
152 |
+
$output .= '<div class="form-field-label">';
|
153 |
+
$output .= '<label for="' . $id . '">';
|
154 |
+
$output .= $title;
|
155 |
+
$output .= '</label>';
|
156 |
+
$output .= '</div>';
|
157 |
+
|
158 |
+
$output .= '<div class="form-field-data">';
|
159 |
+
$output .= '<select id="wcf_' . $id . '" name="' . $name . '">';
|
160 |
+
|
161 |
+
if ( ! empty( $checkout_steps ) ) {
|
162 |
+
$output .= '<option value="">' . __( 'Select', 'cartflows' ) . '</option>';
|
163 |
+
} else {
|
164 |
+
|
165 |
+
$output .= '<option value="">' . __( 'No Checkout Steps', 'cartflows' ) . '</option>';
|
166 |
+
}
|
167 |
+
|
168 |
+
foreach ( $checkout_steps as $index => $step_data ) {
|
169 |
+
|
170 |
+
$output .= '<option value="' . $step_data->ID . '" ' . selected( $value, $step_data->ID, false ) . '>' . $step_data->post_title . ' (#' . $step_data->ID . ') </option>';
|
171 |
+
}
|
172 |
+
|
173 |
+
$output .= '</select>';
|
174 |
+
$output .= '</div>';
|
175 |
+
|
176 |
+
if ( '' !== $value ) {
|
177 |
+
$output .= '<div class="form-field-actions">';
|
178 |
+
$output .= '<a href="' . get_edit_post_link( $value ) . '" target="_blank" class="" title="Edit">';
|
179 |
+
$output .= '<span class="dashicons dashicons-edit"></span>';
|
180 |
+
$output .= '<span class="">Edit</span>';
|
181 |
+
$output .= '</a>';
|
182 |
+
$output .= '<a href="' . get_permalink( $value ) . '" target="_blank" class="" title="View">';
|
183 |
+
$output .= '<span class="dashicons dashicons-visibility"></span>';
|
184 |
+
$output .= '<span class="">View</span>';
|
185 |
+
$output .= '</a>';
|
186 |
+
$output .= '</div>';
|
187 |
+
}
|
188 |
+
|
189 |
+
$output .= '<div class="form-field-desc">';
|
190 |
+
/* translators: %s: link */
|
191 |
+
$output .= '<p>' . sprintf( __( 'Be sure not to add any product in above selected Global Checkout step. Please read information about how to set up Global Checkout %1$shere%2$s.', 'cartflows' ), '<a href="https://cartflows.com/docs/global-checkout/" target="_blank">', '</a>' ) . '</p>';
|
192 |
+
$output .= '</div>';
|
193 |
+
|
194 |
+
$output .= '</div>';
|
195 |
+
|
196 |
+
return $output;
|
197 |
+
}
|
198 |
+
}
|
classes/class-cartflows-admin.php
CHANGED
@@ -1,420 +1,420 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Admin.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Cartflows_Admin.
|
10 |
-
*/
|
11 |
-
class Cartflows_Admin {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Calls on initialization
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
*/
|
18 |
-
public static function init() {
|
19 |
-
|
20 |
-
self::initialise_plugin();
|
21 |
-
self::init_hooks();
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Init Hooks.
|
26 |
-
*
|
27 |
-
* @since 1.0.0
|
28 |
-
* @return void
|
29 |
-
*/
|
30 |
-
static public function init_hooks() {
|
31 |
-
|
32 |
-
if ( ! is_admin() ) {
|
33 |
-
return;
|
34 |
-
}
|
35 |
-
|
36 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
|
37 |
-
|
38 |
-
// Add CARTFLOWS menu option to admin.
|
39 |
-
add_action( 'network_admin_menu', __CLASS__ . '::menu' );
|
40 |
-
add_action( 'admin_menu', __CLASS__ . '::menu' );
|
41 |
-
add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
|
42 |
-
|
43 |
-
add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
|
44 |
-
|
45 |
-
// Enqueue admin scripts.
|
46 |
-
if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
|
47 |
-
|
48 |
-
add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
|
49 |
-
|
50 |
-
self::save_settings();
|
51 |
-
}
|
52 |
-
|
53 |
-
/* Global Addmin Script */
|
54 |
-
add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
|
55 |
-
|
56 |
-
add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Initialises the Plugin Name.
|
61 |
-
*
|
62 |
-
* @since 1.0.0
|
63 |
-
* @return void
|
64 |
-
*/
|
65 |
-
static public function initialise_plugin() {
|
66 |
-
|
67 |
-
$name = 'Cartflows';
|
68 |
-
$short_name = 'Cflows';
|
69 |
-
|
70 |
-
define( 'CARTFLOWS_PLUGIN_NAME', $name );
|
71 |
-
define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Renders the admin settings menu.
|
76 |
-
*
|
77 |
-
* @since 1.0.0
|
78 |
-
* @return void
|
79 |
-
*/
|
80 |
-
static public function menu() {
|
81 |
-
|
82 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
83 |
-
return;
|
84 |
-
}
|
85 |
-
|
86 |
-
add_menu_page(
|
87 |
-
'CartFlows',
|
88 |
-
'CartFlows',
|
89 |
-
'manage_options',
|
90 |
-
CARTFLOWS_SLUG,
|
91 |
-
__CLASS__ . '::render',
|
92 |
-
'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
|
93 |
-
39.7
|
94 |
-
);
|
95 |
-
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Add submenu to admin menu.
|
100 |
-
*
|
101 |
-
* @since 1.0.0
|
102 |
-
*/
|
103 |
-
static function submenu() {
|
104 |
-
|
105 |
-
$parent_slug = CARTFLOWS_SLUG;
|
106 |
-
$page_title = __( 'Settings', 'cartflows' );
|
107 |
-
$menu_title = __( 'Settings', 'cartflows' );
|
108 |
-
$capability = 'manage_options';
|
109 |
-
$menu_slug = 'cartflows_settings';
|
110 |
-
$callback = __CLASS__ . '::render';
|
111 |
-
|
112 |
-
add_submenu_page(
|
113 |
-
$parent_slug,
|
114 |
-
$page_title,
|
115 |
-
$menu_title,
|
116 |
-
$capability,
|
117 |
-
$menu_slug,
|
118 |
-
$callback
|
119 |
-
);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Renders the admin settings.
|
124 |
-
*
|
125 |
-
* @since 1.0.0
|
126 |
-
* @return void
|
127 |
-
*/
|
128 |
-
static public function render() {
|
129 |
-
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
130 |
-
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
131 |
-
$action = str_replace( '_', '-', $action );
|
132 |
-
|
133 |
-
// Enable header icon filter below.
|
134 |
-
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
135 |
-
|
136 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Renders the admin settings content.
|
141 |
-
*
|
142 |
-
* @since 1.0.0
|
143 |
-
* @return void
|
144 |
-
*/
|
145 |
-
static public function render_content() {
|
146 |
-
|
147 |
-
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
148 |
-
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
149 |
-
$action = str_replace( '_', '-', $action );
|
150 |
-
$action = 'general';
|
151 |
-
|
152 |
-
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
153 |
-
|
154 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Save Global Setting options.
|
159 |
-
*
|
160 |
-
* @since 1.0.0
|
161 |
-
*/
|
162 |
-
static public function save_common_settings() {
|
163 |
-
|
164 |
-
if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
|
165 |
-
|
166 |
-
$url = $_SERVER['REQUEST_URI'];
|
167 |
-
$input_settings = array();
|
168 |
-
$new_settings = array();
|
169 |
-
|
170 |
-
if ( isset( $_POST['_cartflows_common'] ) ) {
|
171 |
-
|
172 |
-
$input_settings = $_POST['_cartflows_common'];
|
173 |
-
|
174 |
-
// Loop through the input and sanitize each of the values.
|
175 |
-
foreach ( $input_settings as $key => $val ) {
|
176 |
-
|
177 |
-
if ( is_array( $val ) ) {
|
178 |
-
foreach ( $val as $k => $v ) {
|
179 |
-
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
|
180 |
-
}
|
181 |
-
} else {
|
182 |
-
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
|
188 |
-
|
189 |
-
$query = array(
|
190 |
-
'message' => 'saved',
|
191 |
-
);
|
192 |
-
|
193 |
-
$redirect_to = add_query_arg( $query, $url );
|
194 |
-
|
195 |
-
wp_redirect( $redirect_to );
|
196 |
-
exit;
|
197 |
-
} // End if statement.
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Check is cartflows admin.
|
202 |
-
*
|
203 |
-
* @since 1.0.0
|
204 |
-
* @return boolean
|
205 |
-
*/
|
206 |
-
static public function is_global_admin() {
|
207 |
-
|
208 |
-
$current_screen = get_current_screen();
|
209 |
-
|
210 |
-
if (
|
211 |
-
is_object( $current_screen ) &&
|
212 |
-
isset( $current_screen->post_type ) &&
|
213 |
-
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
|
214 |
-
CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
|
215 |
-
)
|
216 |
-
) {
|
217 |
-
return true;
|
218 |
-
}
|
219 |
-
return false;
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Check is flow admin.
|
224 |
-
*
|
225 |
-
* @since 1.0.0
|
226 |
-
* @return boolean
|
227 |
-
*/
|
228 |
-
static public function is_flow_edit_admin() {
|
229 |
-
|
230 |
-
$current_screen = get_current_screen();
|
231 |
-
|
232 |
-
if (
|
233 |
-
is_object( $current_screen ) &&
|
234 |
-
isset( $current_screen->post_type ) &&
|
235 |
-
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
|
236 |
-
isset( $current_screen->base ) &&
|
237 |
-
( 'post' === $current_screen->base )
|
238 |
-
) {
|
239 |
-
return true;
|
240 |
-
}
|
241 |
-
return false;
|
242 |
-
}
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Global Admin Scripts.
|
246 |
-
*
|
247 |
-
* @since 1.0.0
|
248 |
-
*/
|
249 |
-
static public function global_admin_scripts() {
|
250 |
-
|
251 |
-
$localize = array(
|
252 |
-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
253 |
-
'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
|
254 |
-
);
|
255 |
-
|
256 |
-
wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
|
257 |
-
|
258 |
-
if ( self::is_global_admin() ) {
|
259 |
-
|
260 |
-
// Styles.
|
261 |
-
wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
|
262 |
-
wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
|
263 |
-
|
264 |
-
wp_enqueue_script(
|
265 |
-
'wcf-global-admin',
|
266 |
-
CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
|
267 |
-
array( 'jquery' ),
|
268 |
-
CARTFLOWS_VER,
|
269 |
-
true
|
270 |
-
);
|
271 |
-
|
272 |
-
do_action( 'cartflows_global_admin_scripts' );
|
273 |
-
}
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Global Admin Data.
|
278 |
-
*
|
279 |
-
* @since 1.0.0
|
280 |
-
*/
|
281 |
-
static public function global_admin_data() {
|
282 |
-
|
283 |
-
$current_screen = get_current_screen();
|
284 |
-
|
285 |
-
if ( ! $current_screen ) {
|
286 |
-
return;
|
287 |
-
}
|
288 |
-
|
289 |
-
if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
|
290 |
-
return;
|
291 |
-
}
|
292 |
-
|
293 |
-
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
294 |
-
?>
|
295 |
-
|
296 |
-
<div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
|
297 |
-
<div class="wcf-templates-popup-content">
|
298 |
-
<div class="spinner"></div>
|
299 |
-
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
300 |
-
|
301 |
-
<div id="wcf-remote-flow-actions" class="wcf-template-header">
|
302 |
-
<div class="wcf-template-logo-wrap">
|
303 |
-
<span class="wcf-cartflows-logo-img">
|
304 |
-
<span class="cartflows-icon"></span>
|
305 |
-
</span>
|
306 |
-
<span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
|
307 |
-
</div>
|
308 |
-
<div class="wcf-tab-wrapper">
|
309 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
310 |
-
<div id="wcf-get-started-steps">
|
311 |
-
<ul class="filter-links ">
|
312 |
-
<li>
|
313 |
-
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
314 |
-
</li>
|
315 |
-
<li>
|
316 |
-
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
317 |
-
</li>
|
318 |
-
</ul>
|
319 |
-
</div>
|
320 |
-
<?php } ?>
|
321 |
-
</div>
|
322 |
-
<div class="wcf-popup-close-wrap">
|
323 |
-
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
324 |
-
</div>
|
325 |
-
</div>
|
326 |
-
<!-- <div class="wcf-search-form">
|
327 |
-
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
328 |
-
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
329 |
-
</div> -->
|
330 |
-
|
331 |
-
<div id="wcf-remote-content">
|
332 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
333 |
-
<div id="wcf-ready-templates">
|
334 |
-
<div id="wcf-remote-filters">
|
335 |
-
<div id="wcf-page-builders"></div>
|
336 |
-
<div id="wcf-categories"></div>
|
337 |
-
</div>
|
338 |
-
<div class="wcf-page-builder-notice"></div>
|
339 |
-
<div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
340 |
-
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
341 |
-
</div>
|
342 |
-
<?php } ?>
|
343 |
-
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
344 |
-
<div class="inner">
|
345 |
-
<a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
|
346 |
-
<p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
|
347 |
-
</div>
|
348 |
-
</div>
|
349 |
-
</div>
|
350 |
-
</div>
|
351 |
-
</div>
|
352 |
-
</div>
|
353 |
-
|
354 |
-
<?php
|
355 |
-
}
|
356 |
-
|
357 |
-
/**
|
358 |
-
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
359 |
-
*
|
360 |
-
* @since 1.0.0
|
361 |
-
*/
|
362 |
-
static public function styles_scripts() {
|
363 |
-
|
364 |
-
// Styles.
|
365 |
-
wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
|
366 |
-
wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
|
367 |
-
|
368 |
-
// Script.
|
369 |
-
wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
|
370 |
-
|
371 |
-
$localize = array(
|
372 |
-
'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
|
373 |
-
);
|
374 |
-
|
375 |
-
wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
|
376 |
-
}
|
377 |
-
|
378 |
-
/**
|
379 |
-
* Save All admin settings here
|
380 |
-
*/
|
381 |
-
static public function save_settings() {
|
382 |
-
|
383 |
-
// Only admins can save settings.
|
384 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
385 |
-
return;
|
386 |
-
}
|
387 |
-
|
388 |
-
self::save_common_settings();
|
389 |
-
|
390 |
-
// Let extensions hook into saving.
|
391 |
-
do_action( 'cartflows_admin_settings_save' );
|
392 |
-
}
|
393 |
-
|
394 |
-
/**
|
395 |
-
* Get and return page URL
|
396 |
-
*
|
397 |
-
* @param string $menu_slug Menu name.
|
398 |
-
* @since 1.0.0
|
399 |
-
* @return string page url
|
400 |
-
*/
|
401 |
-
static public function get_page_url( $menu_slug ) {
|
402 |
-
|
403 |
-
$parent_page = self::$default_menu_position;
|
404 |
-
|
405 |
-
if ( strpos( $parent_page, '?' ) !== false ) {
|
406 |
-
$query_var = '&page=' . self::$plugin_slug;
|
407 |
-
} else {
|
408 |
-
$query_var = '?page=' . self::$plugin_slug;
|
409 |
-
}
|
410 |
-
|
411 |
-
$parent_page_url = admin_url( $parent_page . $query_var );
|
412 |
-
|
413 |
-
$url = $parent_page_url . '&action=' . $menu_slug;
|
414 |
-
|
415 |
-
return esc_url( $url );
|
416 |
-
}
|
417 |
-
|
418 |
-
}
|
419 |
-
|
420 |
-
Cartflows_Admin::init();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Admin.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Cartflows_Admin.
|
10 |
+
*/
|
11 |
+
class Cartflows_Admin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Calls on initialization
|
15 |
+
*
|
16 |
+
* @since 1.0.0
|
17 |
+
*/
|
18 |
+
public static function init() {
|
19 |
+
|
20 |
+
self::initialise_plugin();
|
21 |
+
self::init_hooks();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Init Hooks.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
static public function init_hooks() {
|
31 |
+
|
32 |
+
if ( ! is_admin() ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
|
37 |
+
|
38 |
+
// Add CARTFLOWS menu option to admin.
|
39 |
+
add_action( 'network_admin_menu', __CLASS__ . '::menu' );
|
40 |
+
add_action( 'admin_menu', __CLASS__ . '::menu' );
|
41 |
+
add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
|
42 |
+
|
43 |
+
add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
|
44 |
+
|
45 |
+
// Enqueue admin scripts.
|
46 |
+
if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
|
47 |
+
|
48 |
+
add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
|
49 |
+
|
50 |
+
self::save_settings();
|
51 |
+
}
|
52 |
+
|
53 |
+
/* Global Addmin Script */
|
54 |
+
add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
|
55 |
+
|
56 |
+
add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Initialises the Plugin Name.
|
61 |
+
*
|
62 |
+
* @since 1.0.0
|
63 |
+
* @return void
|
64 |
+
*/
|
65 |
+
static public function initialise_plugin() {
|
66 |
+
|
67 |
+
$name = 'Cartflows';
|
68 |
+
$short_name = 'Cflows';
|
69 |
+
|
70 |
+
define( 'CARTFLOWS_PLUGIN_NAME', $name );
|
71 |
+
define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Renders the admin settings menu.
|
76 |
+
*
|
77 |
+
* @since 1.0.0
|
78 |
+
* @return void
|
79 |
+
*/
|
80 |
+
static public function menu() {
|
81 |
+
|
82 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
add_menu_page(
|
87 |
+
'CartFlows',
|
88 |
+
'CartFlows',
|
89 |
+
'manage_options',
|
90 |
+
CARTFLOWS_SLUG,
|
91 |
+
__CLASS__ . '::render',
|
92 |
+
'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
|
93 |
+
39.7
|
94 |
+
);
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Add submenu to admin menu.
|
100 |
+
*
|
101 |
+
* @since 1.0.0
|
102 |
+
*/
|
103 |
+
static function submenu() {
|
104 |
+
|
105 |
+
$parent_slug = CARTFLOWS_SLUG;
|
106 |
+
$page_title = __( 'Settings', 'cartflows' );
|
107 |
+
$menu_title = __( 'Settings', 'cartflows' );
|
108 |
+
$capability = 'manage_options';
|
109 |
+
$menu_slug = 'cartflows_settings';
|
110 |
+
$callback = __CLASS__ . '::render';
|
111 |
+
|
112 |
+
add_submenu_page(
|
113 |
+
$parent_slug,
|
114 |
+
$page_title,
|
115 |
+
$menu_title,
|
116 |
+
$capability,
|
117 |
+
$menu_slug,
|
118 |
+
$callback
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Renders the admin settings.
|
124 |
+
*
|
125 |
+
* @since 1.0.0
|
126 |
+
* @return void
|
127 |
+
*/
|
128 |
+
static public function render() {
|
129 |
+
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
130 |
+
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
131 |
+
$action = str_replace( '_', '-', $action );
|
132 |
+
|
133 |
+
// Enable header icon filter below.
|
134 |
+
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
135 |
+
|
136 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Renders the admin settings content.
|
141 |
+
*
|
142 |
+
* @since 1.0.0
|
143 |
+
* @return void
|
144 |
+
*/
|
145 |
+
static public function render_content() {
|
146 |
+
|
147 |
+
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
148 |
+
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
149 |
+
$action = str_replace( '_', '-', $action );
|
150 |
+
$action = 'general';
|
151 |
+
|
152 |
+
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
153 |
+
|
154 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Save Global Setting options.
|
159 |
+
*
|
160 |
+
* @since 1.0.0
|
161 |
+
*/
|
162 |
+
static public function save_common_settings() {
|
163 |
+
|
164 |
+
if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
|
165 |
+
|
166 |
+
$url = $_SERVER['REQUEST_URI'];
|
167 |
+
$input_settings = array();
|
168 |
+
$new_settings = array();
|
169 |
+
|
170 |
+
if ( isset( $_POST['_cartflows_common'] ) ) {
|
171 |
+
|
172 |
+
$input_settings = $_POST['_cartflows_common'];
|
173 |
+
|
174 |
+
// Loop through the input and sanitize each of the values.
|
175 |
+
foreach ( $input_settings as $key => $val ) {
|
176 |
+
|
177 |
+
if ( is_array( $val ) ) {
|
178 |
+
foreach ( $val as $k => $v ) {
|
179 |
+
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
|
180 |
+
}
|
181 |
+
} else {
|
182 |
+
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
|
188 |
+
|
189 |
+
$query = array(
|
190 |
+
'message' => 'saved',
|
191 |
+
);
|
192 |
+
|
193 |
+
$redirect_to = add_query_arg( $query, $url );
|
194 |
+
|
195 |
+
wp_redirect( $redirect_to );
|
196 |
+
exit;
|
197 |
+
} // End if statement.
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Check is cartflows admin.
|
202 |
+
*
|
203 |
+
* @since 1.0.0
|
204 |
+
* @return boolean
|
205 |
+
*/
|
206 |
+
static public function is_global_admin() {
|
207 |
+
|
208 |
+
$current_screen = get_current_screen();
|
209 |
+
|
210 |
+
if (
|
211 |
+
is_object( $current_screen ) &&
|
212 |
+
isset( $current_screen->post_type ) &&
|
213 |
+
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
|
214 |
+
CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
|
215 |
+
)
|
216 |
+
) {
|
217 |
+
return true;
|
218 |
+
}
|
219 |
+
return false;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Check is flow admin.
|
224 |
+
*
|
225 |
+
* @since 1.0.0
|
226 |
+
* @return boolean
|
227 |
+
*/
|
228 |
+
static public function is_flow_edit_admin() {
|
229 |
+
|
230 |
+
$current_screen = get_current_screen();
|
231 |
+
|
232 |
+
if (
|
233 |
+
is_object( $current_screen ) &&
|
234 |
+
isset( $current_screen->post_type ) &&
|
235 |
+
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
|
236 |
+
isset( $current_screen->base ) &&
|
237 |
+
( 'post' === $current_screen->base )
|
238 |
+
) {
|
239 |
+
return true;
|
240 |
+
}
|
241 |
+
return false;
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Global Admin Scripts.
|
246 |
+
*
|
247 |
+
* @since 1.0.0
|
248 |
+
*/
|
249 |
+
static public function global_admin_scripts() {
|
250 |
+
|
251 |
+
$localize = array(
|
252 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
253 |
+
'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
|
254 |
+
);
|
255 |
+
|
256 |
+
wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
|
257 |
+
|
258 |
+
if ( self::is_global_admin() ) {
|
259 |
+
|
260 |
+
// Styles.
|
261 |
+
wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
|
262 |
+
wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
|
263 |
+
|
264 |
+
wp_enqueue_script(
|
265 |
+
'wcf-global-admin',
|
266 |
+
CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
|
267 |
+
array( 'jquery' ),
|
268 |
+
CARTFLOWS_VER,
|
269 |
+
true
|
270 |
+
);
|
271 |
+
|
272 |
+
do_action( 'cartflows_global_admin_scripts' );
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Global Admin Data.
|
278 |
+
*
|
279 |
+
* @since 1.0.0
|
280 |
+
*/
|
281 |
+
static public function global_admin_data() {
|
282 |
+
|
283 |
+
$current_screen = get_current_screen();
|
284 |
+
|
285 |
+
if ( ! $current_screen ) {
|
286 |
+
return;
|
287 |
+
}
|
288 |
+
|
289 |
+
if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
|
290 |
+
return;
|
291 |
+
}
|
292 |
+
|
293 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
294 |
+
?>
|
295 |
+
|
296 |
+
<div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
|
297 |
+
<div class="wcf-templates-popup-content">
|
298 |
+
<div class="spinner"></div>
|
299 |
+
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
300 |
+
|
301 |
+
<div id="wcf-remote-flow-actions" class="wcf-template-header">
|
302 |
+
<div class="wcf-template-logo-wrap">
|
303 |
+
<span class="wcf-cartflows-logo-img">
|
304 |
+
<span class="cartflows-icon"></span>
|
305 |
+
</span>
|
306 |
+
<span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
|
307 |
+
</div>
|
308 |
+
<div class="wcf-tab-wrapper">
|
309 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
310 |
+
<div id="wcf-get-started-steps">
|
311 |
+
<ul class="filter-links ">
|
312 |
+
<li>
|
313 |
+
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
314 |
+
</li>
|
315 |
+
<li>
|
316 |
+
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
317 |
+
</li>
|
318 |
+
</ul>
|
319 |
+
</div>
|
320 |
+
<?php } ?>
|
321 |
+
</div>
|
322 |
+
<div class="wcf-popup-close-wrap">
|
323 |
+
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
324 |
+
</div>
|
325 |
+
</div>
|
326 |
+
<!-- <div class="wcf-search-form">
|
327 |
+
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
328 |
+
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
329 |
+
</div> -->
|
330 |
+
|
331 |
+
<div id="wcf-remote-content">
|
332 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
333 |
+
<div id="wcf-ready-templates">
|
334 |
+
<div id="wcf-remote-filters">
|
335 |
+
<div id="wcf-page-builders"></div>
|
336 |
+
<div id="wcf-categories"></div>
|
337 |
+
</div>
|
338 |
+
<div class="wcf-page-builder-notice"></div>
|
339 |
+
<div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
340 |
+
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
341 |
+
</div>
|
342 |
+
<?php } ?>
|
343 |
+
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
344 |
+
<div class="inner">
|
345 |
+
<a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
|
346 |
+
<p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
|
347 |
+
</div>
|
348 |
+
</div>
|
349 |
+
</div>
|
350 |
+
</div>
|
351 |
+
</div>
|
352 |
+
</div>
|
353 |
+
|
354 |
+
<?php
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
359 |
+
*
|
360 |
+
* @since 1.0.0
|
361 |
+
*/
|
362 |
+
static public function styles_scripts() {
|
363 |
+
|
364 |
+
// Styles.
|
365 |
+
wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
|
366 |
+
wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
|
367 |
+
|
368 |
+
// Script.
|
369 |
+
wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
|
370 |
+
|
371 |
+
$localize = array(
|
372 |
+
'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
|
373 |
+
);
|
374 |
+
|
375 |
+
wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
|
376 |
+
}
|
377 |
+
|
378 |
+
/**
|
379 |
+
* Save All admin settings here
|
380 |
+
*/
|
381 |
+
static public function save_settings() {
|
382 |
+
|
383 |
+
// Only admins can save settings.
|
384 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
385 |
+
return;
|
386 |
+
}
|
387 |
+
|
388 |
+
self::save_common_settings();
|
389 |
+
|
390 |
+
// Let extensions hook into saving.
|
391 |
+
do_action( 'cartflows_admin_settings_save' );
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Get and return page URL
|
396 |
+
*
|
397 |
+
* @param string $menu_slug Menu name.
|
398 |
+
* @since 1.0.0
|
399 |
+
* @return string page url
|
400 |
+
*/
|
401 |
+
static public function get_page_url( $menu_slug ) {
|
402 |
+
|
403 |
+
$parent_page = self::$default_menu_position;
|
404 |
+
|
405 |
+
if ( strpos( $parent_page, '?' ) !== false ) {
|
406 |
+
$query_var = '&page=' . self::$plugin_slug;
|
407 |
+
} else {
|
408 |
+
$query_var = '?page=' . self::$plugin_slug;
|
409 |
+
}
|
410 |
+
|
411 |
+
$parent_page_url = admin_url( $parent_page . $query_var );
|
412 |
+
|
413 |
+
$url = $parent_page_url . '&action=' . $menu_slug;
|
414 |
+
|
415 |
+
return esc_url( $url );
|
416 |
+
}
|
417 |
+
|
418 |
+
}
|
419 |
+
|
420 |
+
Cartflows_Admin::init();
|
classes/class-cartflows-bb-compatibility.php
CHANGED
@@ -1,76 +1,76 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Beaver Builder page builder compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! class_exists( 'Cartflows_BB_Compatibility' ) ) :
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class for Beaver Builder page builder compatibility
|
12 |
-
*/
|
13 |
-
class Cartflows_BB_Compatibility {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Member Variable
|
17 |
-
*
|
18 |
-
* @var instance
|
19 |
-
*/
|
20 |
-
private static $instance;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Initiator
|
24 |
-
*
|
25 |
-
* @since 1.1.4
|
26 |
-
*/
|
27 |
-
public static function get_instance() {
|
28 |
-
if ( ! isset( self::$instance ) ) {
|
29 |
-
self::$instance = new self;
|
30 |
-
}
|
31 |
-
return self::$instance;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Constructor
|
36 |
-
*
|
37 |
-
* @since 1.1.4
|
38 |
-
*/
|
39 |
-
public function __construct() {
|
40 |
-
add_filter( 'fl_builder_post_types', array( $this, 'post_types' ) );
|
41 |
-
add_action( 'admin_init', array( $this, 'disable_rediraction' ), 99 );
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Disable Beaver Builder Redirection after plugin install.
|
46 |
-
*
|
47 |
-
* @since 1.1.4
|
48 |
-
*
|
49 |
-
* @return void
|
50 |
-
*/
|
51 |
-
function disable_rediraction() {
|
52 |
-
delete_transient( '_fl_builder_activation_admin_notice' );
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Add beaver builder support for step post type.
|
57 |
-
*
|
58 |
-
* @since 1.1.4
|
59 |
-
*
|
60 |
-
* @param array $post_types container Post types.
|
61 |
-
* @return array
|
62 |
-
*/
|
63 |
-
public function post_types( $post_types ) {
|
64 |
-
|
65 |
-
$post_types[] = 'cartflows_step';
|
66 |
-
|
67 |
-
return $post_types;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Kicking this off by calling 'get_instance()' method
|
73 |
-
*/
|
74 |
-
Cartflows_BB_Compatibility::get_instance();
|
75 |
-
|
76 |
-
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Beaver Builder page builder compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! class_exists( 'Cartflows_BB_Compatibility' ) ) :
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class for Beaver Builder page builder compatibility
|
12 |
+
*/
|
13 |
+
class Cartflows_BB_Compatibility {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Member Variable
|
17 |
+
*
|
18 |
+
* @var instance
|
19 |
+
*/
|
20 |
+
private static $instance;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Initiator
|
24 |
+
*
|
25 |
+
* @since 1.1.4
|
26 |
+
*/
|
27 |
+
public static function get_instance() {
|
28 |
+
if ( ! isset( self::$instance ) ) {
|
29 |
+
self::$instance = new self;
|
30 |
+
}
|
31 |
+
return self::$instance;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Constructor
|
36 |
+
*
|
37 |
+
* @since 1.1.4
|
38 |
+
*/
|
39 |
+
public function __construct() {
|
40 |
+
add_filter( 'fl_builder_post_types', array( $this, 'post_types' ) );
|
41 |
+
add_action( 'admin_init', array( $this, 'disable_rediraction' ), 99 );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Disable Beaver Builder Redirection after plugin install.
|
46 |
+
*
|
47 |
+
* @since 1.1.4
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
function disable_rediraction() {
|
52 |
+
delete_transient( '_fl_builder_activation_admin_notice' );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add beaver builder support for step post type.
|
57 |
+
*
|
58 |
+
* @since 1.1.4
|
59 |
+
*
|
60 |
+
* @param array $post_types container Post types.
|
61 |
+
* @return array
|
62 |
+
*/
|
63 |
+
public function post_types( $post_types ) {
|
64 |
+
|
65 |
+
$post_types[] = 'cartflows_step';
|
66 |
+
|
67 |
+
return $post_types;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Kicking this off by calling 'get_instance()' method
|
73 |
+
*/
|
74 |
+
Cartflows_BB_Compatibility::get_instance();
|
75 |
+
|
76 |
+
endif;
|
classes/class-cartflows-compatibility.php
CHANGED
@@ -1,355 +1,355 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Page builder compatibility
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! class_exists( 'Cartflows_Compatibility' ) ) {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class for page builder compatibility
|
12 |
-
*/
|
13 |
-
class Cartflows_Compatibility {
|
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 |
-
$this->load_files();
|
38 |
-
|
39 |
-
// Override post meta.
|
40 |
-
add_action( 'wp', array( $this, 'override_meta' ), 0 );
|
41 |
-
|
42 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'load_fontawesome' ), 10000 );
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Load page builder compatibility files
|
47 |
-
*/
|
48 |
-
public function load_files() {
|
49 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
50 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-elementor-compatibility.php';
|
51 |
-
}
|
52 |
-
|
53 |
-
if ( $this->is_divi_enabled() ) {
|
54 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-divi-compatibility.php';
|
55 |
-
}
|
56 |
-
|
57 |
-
if ( $this->is_bb_enabled() ) {
|
58 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-bb-compatibility.php';
|
59 |
-
}
|
60 |
-
|
61 |
-
if ( class_exists( 'TCB_Post' ) ) {
|
62 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-thrive-compatibility.php';
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Check if it is beaver builder enabled.
|
68 |
-
*
|
69 |
-
* @since 1.1.4
|
70 |
-
*/
|
71 |
-
public function is_bb_enabled() {
|
72 |
-
|
73 |
-
if ( class_exists( 'FLBuilderModel' ) ) {
|
74 |
-
return true;
|
75 |
-
}
|
76 |
-
|
77 |
-
return false;
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Check if elementor preview mode is on.
|
82 |
-
*/
|
83 |
-
public function is_elementor_preview_mode() {
|
84 |
-
|
85 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
86 |
-
|
87 |
-
if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
|
88 |
-
return true;
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
return false;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Get Current Theme.
|
97 |
-
*/
|
98 |
-
public function get_current_theme() {
|
99 |
-
|
100 |
-
$theme_name = '';
|
101 |
-
$theme = wp_get_theme();
|
102 |
-
|
103 |
-
if ( isset( $theme->parent_theme ) && '' != $theme->parent_theme || null != $theme->parent_theme ) {
|
104 |
-
$theme_name = $theme->parent_theme;
|
105 |
-
} else {
|
106 |
-
$theme_name = $theme->name;
|
107 |
-
}
|
108 |
-
|
109 |
-
return $theme_name;
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Check if it is beaver builder preview mode
|
114 |
-
*/
|
115 |
-
public function is_bb_preview_mode() {
|
116 |
-
|
117 |
-
if ( class_exists( 'FLBuilderModel' ) ) {
|
118 |
-
if ( FLBuilderModel::is_builder_active() ) {
|
119 |
-
return true;
|
120 |
-
} else {
|
121 |
-
return false;
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
return false;
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Check for page builder preview mode.
|
130 |
-
*/
|
131 |
-
public function is_page_builder_preview() {
|
132 |
-
|
133 |
-
if ( $this->is_elementor_preview_mode() || $this->is_bb_preview_mode() ) {
|
134 |
-
return true;
|
135 |
-
}
|
136 |
-
|
137 |
-
return false;
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Check if divi builder enabled for post id.
|
142 |
-
*
|
143 |
-
* @param int $post_id post id.
|
144 |
-
*/
|
145 |
-
public function is_divi_builder_enabled( $post_id ) {
|
146 |
-
|
147 |
-
if ( function_exists( 'et_pb_is_pagebuilder_used' ) && et_pb_is_pagebuilder_used( $post_id ) ) {
|
148 |
-
return true;
|
149 |
-
}
|
150 |
-
|
151 |
-
return false;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Check if compatibility theme enabled.
|
156 |
-
*/
|
157 |
-
function is_compatibility_theme_enabled() {
|
158 |
-
|
159 |
-
$theme = wp_get_theme();
|
160 |
-
|
161 |
-
$is_compatibility = false;
|
162 |
-
|
163 |
-
if ( $this->is_divi_enabled( $theme ) || $this->is_flatsome_enabled( $theme ) ) {
|
164 |
-
|
165 |
-
$is_compatibility = true;
|
166 |
-
}
|
167 |
-
|
168 |
-
return apply_filters( 'cartflows_is_compatibility_theme', $is_compatibility );
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Check if divi builder enabled for post id.
|
173 |
-
*
|
174 |
-
* @param object $theme theme data.
|
175 |
-
* @return boolean
|
176 |
-
*/
|
177 |
-
function is_divi_enabled( $theme = false ) {
|
178 |
-
|
179 |
-
if ( ! $theme ) {
|
180 |
-
$theme = wp_get_theme();
|
181 |
-
}
|
182 |
-
|
183 |
-
if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme ) {
|
184 |
-
return true;
|
185 |
-
}
|
186 |
-
|
187 |
-
return false;
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Check if Flatsome enabled for post id.
|
192 |
-
*
|
193 |
-
* @param object $theme theme data.
|
194 |
-
* @return boolean
|
195 |
-
*/
|
196 |
-
function is_flatsome_enabled( $theme = false ) {
|
197 |
-
|
198 |
-
if ( ! $theme ) {
|
199 |
-
$theme = wp_get_theme();
|
200 |
-
}
|
201 |
-
|
202 |
-
if ( 'Flatsome' == $theme->name || 'Flatsome' == $theme->parent_theme ) {
|
203 |
-
return true;
|
204 |
-
}
|
205 |
-
|
206 |
-
return false;
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Check if OceanWp enabled for post id.
|
211 |
-
*
|
212 |
-
* @param object $theme theme data.
|
213 |
-
* @return boolean
|
214 |
-
*/
|
215 |
-
function is_oceanwp_enabled( $theme = false ) {
|
216 |
-
|
217 |
-
if ( ! $theme ) {
|
218 |
-
$theme = wp_get_theme();
|
219 |
-
}
|
220 |
-
|
221 |
-
if ( 'OceanWP' == $theme->name || 'OceanWP' == $theme->parent_theme ) {
|
222 |
-
return true;
|
223 |
-
}
|
224 |
-
|
225 |
-
return false;
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Check for thrive architect edit page.
|
230 |
-
*
|
231 |
-
* @param int $post_id post id.
|
232 |
-
*/
|
233 |
-
public function is_thrive_edit_page( $post_id ) {
|
234 |
-
|
235 |
-
if ( true === $this->is_thrive_builder_page( $post_id ) ) {
|
236 |
-
return true;
|
237 |
-
} else {
|
238 |
-
return false;
|
239 |
-
}
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Check if the page being rendered is the main ID on the editor page.
|
244 |
-
*
|
245 |
-
* @since 1.0.0
|
246 |
-
* @param String $post_id Post ID which is to be rendered.
|
247 |
-
* @return boolean True if current if is being rendered is not being edited.
|
248 |
-
*/
|
249 |
-
private function is_thrive_builder_page( $post_id ) {
|
250 |
-
$tve = ( isset( $_GET['tve'] ) && 'true' == $_GET['tve'] ) ? true : false;
|
251 |
-
$post = isset( $_GET['post'] ) ? sanitize_text_field( $_GET['post'] ) : false;
|
252 |
-
|
253 |
-
return ( true == $tve && $post_id !== $post );
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Overwrite meta for page
|
258 |
-
*/
|
259 |
-
public function override_meta() {
|
260 |
-
|
261 |
-
// don't override meta for `elementor_library` post type.
|
262 |
-
if ( 'elementor_library' == get_post_type() ) {
|
263 |
-
return;
|
264 |
-
}
|
265 |
-
|
266 |
-
if ( ! is_singular() ) {
|
267 |
-
return;
|
268 |
-
}
|
269 |
-
|
270 |
-
global $post;
|
271 |
-
$post_id = $post->ID;
|
272 |
-
$post_type = get_post_type();
|
273 |
-
|
274 |
-
if ( 'cartflows_step' == $post_type && ( $this->is_elementor_preview_mode()
|
275 |
-
|| $this->is_bb_preview_mode() || $this->is_thrive_edit_page( $post_id )
|
276 |
-
|| $this->is_divi_builder_enabled( $post_id ) ) ) {
|
277 |
-
|
278 |
-
if ( '' == $post->post_content ) {
|
279 |
-
|
280 |
-
$this->overwrite_template( $post_id );
|
281 |
-
}
|
282 |
-
}
|
283 |
-
}
|
284 |
-
|
285 |
-
/**
|
286 |
-
* Assign cartflow canvas template to page.
|
287 |
-
*
|
288 |
-
* @param int $post_id post ID.
|
289 |
-
*/
|
290 |
-
public function overwrite_template( $post_id ) {
|
291 |
-
|
292 |
-
$template = 'cartflows-canvas';
|
293 |
-
$key = '_wp_page_template';
|
294 |
-
|
295 |
-
$record_exists = get_post_meta( $post_id, $key, true );
|
296 |
-
|
297 |
-
if ( 'cartflows-canvas' == $record_exists ) {
|
298 |
-
return;
|
299 |
-
}
|
300 |
-
|
301 |
-
// As elementor doesn't allow update post meta using update_post_meta, run wpdb query to update post meta.
|
302 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
303 |
-
|
304 |
-
global $wpdb;
|
305 |
-
|
306 |
-
if ( '' == $record_exists || ! $record_exists ) {
|
307 |
-
|
308 |
-
$wpdb->insert(
|
309 |
-
$wpdb->prefix . 'postmeta',
|
310 |
-
array(
|
311 |
-
'post_id' => $post_id,
|
312 |
-
'meta_key' => $key,
|
313 |
-
'meta_value' => $template, // ... and so on
|
314 |
-
)
|
315 |
-
);
|
316 |
-
} else {
|
317 |
-
|
318 |
-
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND post_id = %s;", $template, $key, $post_id ) );
|
319 |
-
}
|
320 |
-
} else {
|
321 |
-
|
322 |
-
update_post_meta( $post_id, $key, $template );
|
323 |
-
}
|
324 |
-
}
|
325 |
-
|
326 |
-
/**
|
327 |
-
* Load font awesome style from oceanwp on checkout page.
|
328 |
-
*/
|
329 |
-
public function load_fontawesome() {
|
330 |
-
|
331 |
-
$theme = get_template();
|
332 |
-
|
333 |
-
if ( 'oceanwp' == strtolower( $theme ) && wcf()->utils->is_step_post_type() ) {
|
334 |
-
|
335 |
-
$load_fa = apply_filters( 'cartflows_maybe_load_font_awesome', true );
|
336 |
-
|
337 |
-
if ( $load_fa ) {
|
338 |
-
|
339 |
-
wp_enqueue_style( 'font-awesome', OCEANWP_CSS_DIR_URI . 'third/font-awesome.min.css', false );
|
340 |
-
}
|
341 |
-
|
342 |
-
$custom_css = '
|
343 |
-
#oceanwp-cart-sidebar-wrap,
|
344 |
-
#owp-qv-wrap{
|
345 |
-
display: none;
|
346 |
-
}';
|
347 |
-
|
348 |
-
wp_add_inline_style( 'wcf-frontend-global', $custom_css );
|
349 |
-
}
|
350 |
-
}
|
351 |
-
}
|
352 |
-
}
|
353 |
-
|
354 |
-
Cartflows_Compatibility::get_instance();
|
355 |
-
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Page builder compatibility
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! class_exists( 'Cartflows_Compatibility' ) ) {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class for page builder compatibility
|
12 |
+
*/
|
13 |
+
class Cartflows_Compatibility {
|
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 |
+
$this->load_files();
|
38 |
+
|
39 |
+
// Override post meta.
|
40 |
+
add_action( 'wp', array( $this, 'override_meta' ), 0 );
|
41 |
+
|
42 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'load_fontawesome' ), 10000 );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Load page builder compatibility files
|
47 |
+
*/
|
48 |
+
public function load_files() {
|
49 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
50 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-elementor-compatibility.php';
|
51 |
+
}
|
52 |
+
|
53 |
+
if ( $this->is_divi_enabled() ) {
|
54 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-divi-compatibility.php';
|
55 |
+
}
|
56 |
+
|
57 |
+
if ( $this->is_bb_enabled() ) {
|
58 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-bb-compatibility.php';
|
59 |
+
}
|
60 |
+
|
61 |
+
if ( class_exists( 'TCB_Post' ) ) {
|
62 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-thrive-compatibility.php';
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Check if it is beaver builder enabled.
|
68 |
+
*
|
69 |
+
* @since 1.1.4
|
70 |
+
*/
|
71 |
+
public function is_bb_enabled() {
|
72 |
+
|
73 |
+
if ( class_exists( 'FLBuilderModel' ) ) {
|
74 |
+
return true;
|
75 |
+
}
|
76 |
+
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Check if elementor preview mode is on.
|
82 |
+
*/
|
83 |
+
public function is_elementor_preview_mode() {
|
84 |
+
|
85 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
86 |
+
|
87 |
+
if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
|
88 |
+
return true;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
return false;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Get Current Theme.
|
97 |
+
*/
|
98 |
+
public function get_current_theme() {
|
99 |
+
|
100 |
+
$theme_name = '';
|
101 |
+
$theme = wp_get_theme();
|
102 |
+
|
103 |
+
if ( isset( $theme->parent_theme ) && '' != $theme->parent_theme || null != $theme->parent_theme ) {
|
104 |
+
$theme_name = $theme->parent_theme;
|
105 |
+
} else {
|
106 |
+
$theme_name = $theme->name;
|
107 |
+
}
|
108 |
+
|
109 |
+
return $theme_name;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Check if it is beaver builder preview mode
|
114 |
+
*/
|
115 |
+
public function is_bb_preview_mode() {
|
116 |
+
|
117 |
+
if ( class_exists( 'FLBuilderModel' ) ) {
|
118 |
+
if ( FLBuilderModel::is_builder_active() ) {
|
119 |
+
return true;
|
120 |
+
} else {
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
return false;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Check for page builder preview mode.
|
130 |
+
*/
|
131 |
+
public function is_page_builder_preview() {
|
132 |
+
|
133 |
+
if ( $this->is_elementor_preview_mode() || $this->is_bb_preview_mode() ) {
|
134 |
+
return true;
|
135 |
+
}
|
136 |
+
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Check if divi builder enabled for post id.
|
142 |
+
*
|
143 |
+
* @param int $post_id post id.
|
144 |
+
*/
|
145 |
+
public function is_divi_builder_enabled( $post_id ) {
|
146 |
+
|
147 |
+
if ( function_exists( 'et_pb_is_pagebuilder_used' ) && et_pb_is_pagebuilder_used( $post_id ) ) {
|
148 |
+
return true;
|
149 |
+
}
|
150 |
+
|
151 |
+
return false;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Check if compatibility theme enabled.
|
156 |
+
*/
|
157 |
+
function is_compatibility_theme_enabled() {
|
158 |
+
|
159 |
+
$theme = wp_get_theme();
|
160 |
+
|
161 |
+
$is_compatibility = false;
|
162 |
+
|
163 |
+
if ( $this->is_divi_enabled( $theme ) || $this->is_flatsome_enabled( $theme ) ) {
|
164 |
+
|
165 |
+
$is_compatibility = true;
|
166 |
+
}
|
167 |
+
|
168 |
+
return apply_filters( 'cartflows_is_compatibility_theme', $is_compatibility );
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Check if divi builder enabled for post id.
|
173 |
+
*
|
174 |
+
* @param object $theme theme data.
|
175 |
+
* @return boolean
|
176 |
+
*/
|
177 |
+
function is_divi_enabled( $theme = false ) {
|
178 |
+
|
179 |
+
if ( ! $theme ) {
|
180 |
+
$theme = wp_get_theme();
|
181 |
+
}
|
182 |
+
|
183 |
+
if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme ) {
|
184 |
+
return true;
|
185 |
+
}
|
186 |
+
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Check if Flatsome enabled for post id.
|
192 |
+
*
|
193 |
+
* @param object $theme theme data.
|
194 |
+
* @return boolean
|
195 |
+
*/
|
196 |
+
function is_flatsome_enabled( $theme = false ) {
|
197 |
+
|
198 |
+
if ( ! $theme ) {
|
199 |
+
$theme = wp_get_theme();
|
200 |
+
}
|
201 |
+
|
202 |
+
if ( 'Flatsome' == $theme->name || 'Flatsome' == $theme->parent_theme ) {
|
203 |
+
return true;
|
204 |
+
}
|
205 |
+
|
206 |
+
return false;
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Check if OceanWp enabled for post id.
|
211 |
+
*
|
212 |
+
* @param object $theme theme data.
|
213 |
+
* @return boolean
|
214 |
+
*/
|
215 |
+
function is_oceanwp_enabled( $theme = false ) {
|
216 |
+
|
217 |
+
if ( ! $theme ) {
|
218 |
+
$theme = wp_get_theme();
|
219 |
+
}
|
220 |
+
|
221 |
+
if ( 'OceanWP' == $theme->name || 'OceanWP' == $theme->parent_theme ) {
|
222 |
+
return true;
|
223 |
+
}
|
224 |
+
|
225 |
+
return false;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Check for thrive architect edit page.
|
230 |
+
*
|
231 |
+
* @param int $post_id post id.
|
232 |
+
*/
|
233 |
+
public function is_thrive_edit_page( $post_id ) {
|
234 |
+
|
235 |
+
if ( true === $this->is_thrive_builder_page( $post_id ) ) {
|
236 |
+
return true;
|
237 |
+
} else {
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Check if the page being rendered is the main ID on the editor page.
|
244 |
+
*
|
245 |
+
* @since 1.0.0
|
246 |
+
* @param String $post_id Post ID which is to be rendered.
|
247 |
+
* @return boolean True if current if is being rendered is not being edited.
|
248 |
+
*/
|
249 |
+
private function is_thrive_builder_page( $post_id ) {
|
250 |
+
$tve = ( isset( $_GET['tve'] ) && 'true' == $_GET['tve'] ) ? true : false;
|
251 |
+
$post = isset( $_GET['post'] ) ? sanitize_text_field( $_GET['post'] ) : false;
|
252 |
+
|
253 |
+
return ( true == $tve && $post_id !== $post );
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Overwrite meta for page
|
258 |
+
*/
|
259 |
+
public function override_meta() {
|
260 |
+
|
261 |
+
// don't override meta for `elementor_library` post type.
|
262 |
+
if ( 'elementor_library' == get_post_type() ) {
|
263 |
+
return;
|
264 |
+
}
|
265 |
+
|
266 |
+
if ( ! is_singular() ) {
|
267 |
+
return;
|
268 |
+
}
|
269 |
+
|
270 |
+
global $post;
|
271 |
+
$post_id = $post->ID;
|
272 |
+
$post_type = get_post_type();
|
273 |
+
|
274 |
+
if ( 'cartflows_step' == $post_type && ( $this->is_elementor_preview_mode()
|
275 |
+
|| $this->is_bb_preview_mode() || $this->is_thrive_edit_page( $post_id )
|
276 |
+
|| $this->is_divi_builder_enabled( $post_id ) ) ) {
|
277 |
+
|
278 |
+
if ( '' == $post->post_content ) {
|
279 |
+
|
280 |
+
$this->overwrite_template( $post_id );
|
281 |
+
}
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Assign cartflow canvas template to page.
|
287 |
+
*
|
288 |
+
* @param int $post_id post ID.
|
289 |
+
*/
|
290 |
+
public function overwrite_template( $post_id ) {
|
291 |
+
|
292 |
+
$template = 'cartflows-canvas';
|
293 |
+
$key = '_wp_page_template';
|
294 |
+
|
295 |
+
$record_exists = get_post_meta( $post_id, $key, true );
|
296 |
+
|
297 |
+
if ( 'cartflows-canvas' == $record_exists ) {
|
298 |
+
return;
|
299 |
+
}
|
300 |
+
|
301 |
+
// As elementor doesn't allow update post meta using update_post_meta, run wpdb query to update post meta.
|
302 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
303 |
+
|
304 |
+
global $wpdb;
|
305 |
+
|
306 |
+
if ( '' == $record_exists || ! $record_exists ) {
|
307 |
+
|
308 |
+
$wpdb->insert(
|
309 |
+
$wpdb->prefix . 'postmeta',
|
310 |
+
array(
|
311 |
+
'post_id' => $post_id,
|
312 |
+
'meta_key' => $key,
|
313 |
+
'meta_value' => $template, // ... and so on
|
314 |
+
)
|
315 |
+
);
|
316 |
+
} else {
|
317 |
+
|
318 |
+
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND post_id = %s;", $template, $key, $post_id ) );
|
319 |
+
}
|
320 |
+
} else {
|
321 |
+
|
322 |
+
update_post_meta( $post_id, $key, $template );
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Load font awesome style from oceanwp on checkout page.
|
328 |
+
*/
|
329 |
+
public function load_fontawesome() {
|
330 |
+
|
331 |
+
$theme = get_template();
|
332 |
+
|
333 |
+
if ( 'oceanwp' == strtolower( $theme ) && wcf()->utils->is_step_post_type() ) {
|
334 |
+
|
335 |
+
$load_fa = apply_filters( 'cartflows_maybe_load_font_awesome', true );
|
336 |
+
|
337 |
+
if ( $load_fa ) {
|
338 |
+
|
339 |
+
wp_enqueue_style( 'font-awesome', OCEANWP_CSS_DIR_URI . 'third/font-awesome.min.css', false );
|
340 |
+
}
|
341 |
+
|
342 |
+
$custom_css = '
|
343 |
+
#oceanwp-cart-sidebar-wrap,
|
344 |
+
#owp-qv-wrap{
|
345 |
+
display: none;
|
346 |
+
}';
|
347 |
+
|
348 |
+
wp_add_inline_style( 'wcf-frontend-global', $custom_css );
|
349 |
+
}
|
350 |
+
}
|
351 |
+
}
|
352 |
+
}
|
353 |
+
|
354 |
+
Cartflows_Compatibility::get_instance();
|
355 |
+
|
classes/class-cartflows-helper.php
CHANGED
@@ -1,410 +1,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 |
-
|
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 |
-
* @param
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
$plugins = array(
|
129 |
+
'elementor' => array(
|
130 |
+
'title' => 'Elementor',
|
131 |
+
'plugins' => array(
|
132 |
+
array(
|
133 |
+
'slug' => 'elementor', // For download from wp.org.
|
134 |
+
'init' => 'elementor/elementor.php',
|
135 |
+
'status' => self::get_plugin_status( 'elementor/elementor.php' ),
|
136 |
+
),
|
137 |
+
),
|
138 |
+
),
|
139 |
+
);
|
140 |
+
|
141 |
+
$plugins['beaver-builder'] = array(
|
142 |
+
'title' => 'Beaver Builder',
|
143 |
+
'plugins' => array(),
|
144 |
+
);
|
145 |
+
|
146 |
+
// Check Pro Exist.
|
147 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
|
148 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
149 |
+
'slug' => 'bb-plugin',
|
150 |
+
'init' => 'bb-plugin/fl-builder.php',
|
151 |
+
'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
|
152 |
+
);
|
153 |
+
} else {
|
154 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
155 |
+
'slug' => 'beaver-builder-lite-version', // For download from wp.org.
|
156 |
+
'init' => 'beaver-builder-lite-version/fl-builder.php',
|
157 |
+
'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
|
158 |
+
);
|
159 |
+
}
|
160 |
+
|
161 |
+
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' ) ) {
|
162 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
163 |
+
'slug' => 'bb-ultimate-addon',
|
164 |
+
'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
165 |
+
'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
|
166 |
+
);
|
167 |
+
} else {
|
168 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
169 |
+
'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
|
170 |
+
'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
|
171 |
+
'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
|
172 |
+
);
|
173 |
+
}
|
174 |
+
|
175 |
+
return $plugins;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Get plugin status
|
180 |
+
*
|
181 |
+
* @since 1.1.4
|
182 |
+
*
|
183 |
+
* @param string $plugin_init_file Plguin init file.
|
184 |
+
* @return mixed
|
185 |
+
*/
|
186 |
+
public static function get_plugin_status( $plugin_init_file ) {
|
187 |
+
|
188 |
+
if ( null == self::$installed_plugins ) {
|
189 |
+
self::$installed_plugins = get_plugins();
|
190 |
+
}
|
191 |
+
|
192 |
+
if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
|
193 |
+
return 'install';
|
194 |
+
} elseif ( ! is_plugin_active( $plugin_init_file ) ) {
|
195 |
+
return 'activate';
|
196 |
+
}
|
197 |
+
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Get zapier settings.
|
203 |
+
*
|
204 |
+
* @return array.
|
205 |
+
*/
|
206 |
+
static public function get_common_settings() {
|
207 |
+
|
208 |
+
if ( null === self::$common ) {
|
209 |
+
|
210 |
+
$common_default = apply_filters(
|
211 |
+
'cartflows_common_settings_default',
|
212 |
+
array(
|
213 |
+
'disallow_indexing' => 'disable',
|
214 |
+
'global_checkout' => '',
|
215 |
+
'default_page_builder' => 'elementor',
|
216 |
+
)
|
217 |
+
);
|
218 |
+
|
219 |
+
$common = Cartflows_Helper::get_admin_settings_option( '_cartflows_common', false, true );
|
220 |
+
|
221 |
+
self::$common = wp_parse_args( $common, $common_default );
|
222 |
+
}
|
223 |
+
|
224 |
+
return self::$common;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Get Checkout field.
|
229 |
+
*
|
230 |
+
* @param string $key Field key.
|
231 |
+
* @param int $post_id Post id.
|
232 |
+
* @return array.
|
233 |
+
*/
|
234 |
+
static public function get_checkout_fields( $key, $post_id ) {
|
235 |
+
|
236 |
+
$saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
|
237 |
+
|
238 |
+
if ( ! $saved_fields ) {
|
239 |
+
$saved_fields = array();
|
240 |
+
}
|
241 |
+
|
242 |
+
$fields = array_filter( $saved_fields );
|
243 |
+
|
244 |
+
if ( empty( $fields ) ) {
|
245 |
+
if ( 'billing' === $key || 'shipping' === $key ) {
|
246 |
+
|
247 |
+
$fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
|
248 |
+
|
249 |
+
update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
return $fields;
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Add Checkout field.
|
258 |
+
*
|
259 |
+
* @param string $type Field type.
|
260 |
+
* @param string $field_key Field key.
|
261 |
+
* @param array $field_data Field data.
|
262 |
+
* @param int $post_id Post id.
|
263 |
+
* @return boolean.
|
264 |
+
*/
|
265 |
+
static public function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
|
266 |
+
|
267 |
+
$fields = self::get_checkout_fields( $type, $post_id );
|
268 |
+
|
269 |
+
$fields[ $field_key ] = $field_data;
|
270 |
+
|
271 |
+
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
272 |
+
|
273 |
+
return true;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Get checkout fields settings.
|
278 |
+
*
|
279 |
+
* @param string $type Field type.
|
280 |
+
* @param string $field_key Field key.
|
281 |
+
* @param int $post_id Post id.
|
282 |
+
* @return array.
|
283 |
+
*/
|
284 |
+
static public function delete_checkout_field( $type, $field_key, $post_id ) {
|
285 |
+
|
286 |
+
$fields = self::get_checkout_fields( $type, $post_id );
|
287 |
+
|
288 |
+
if ( isset( $fields[ $field_key ] ) ) {
|
289 |
+
unset( $fields[ $field_key ] );
|
290 |
+
}
|
291 |
+
|
292 |
+
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
293 |
+
|
294 |
+
return true;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Get checkout fields settings.
|
299 |
+
*
|
300 |
+
* @return array.
|
301 |
+
*/
|
302 |
+
static public function get_checkout_fields_settings() {
|
303 |
+
|
304 |
+
if ( null === self::$checkout_fields ) {
|
305 |
+
$checkout_fields_default = array(
|
306 |
+
'enable_customization' => 'disable',
|
307 |
+
'enable_billing_fields' => 'disable',
|
308 |
+
);
|
309 |
+
|
310 |
+
$billing_fields = self::get_checkout_fields( 'billing' );
|
311 |
+
|
312 |
+
if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
|
313 |
+
|
314 |
+
foreach ( $billing_fields as $key => $value ) {
|
315 |
+
|
316 |
+
$checkout_fields_default[ $key ] = 'enable';
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
$checkout_fields = Cartflows_Helper::get_admin_settings_option( '_wcf_checkout_fields', false, true );
|
321 |
+
|
322 |
+
self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
|
323 |
+
}
|
324 |
+
|
325 |
+
return self::$checkout_fields;
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Get meta options
|
330 |
+
*
|
331 |
+
* @since 1.0.0
|
332 |
+
* @param int $post_id Product ID.
|
333 |
+
* @param string $key Meta Key.
|
334 |
+
* @param string $default Default value.
|
335 |
+
* @return string Meta Value.
|
336 |
+
*/
|
337 |
+
static public function get_meta_option( $post_id, $key, $default = '' ) {
|
338 |
+
|
339 |
+
$value = get_post_meta( $post_id, $key, true );
|
340 |
+
|
341 |
+
if ( ! $value ) {
|
342 |
+
$value = $default;
|
343 |
+
}
|
344 |
+
|
345 |
+
return $value;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Save meta option
|
350 |
+
*
|
351 |
+
* @since 1.0.0
|
352 |
+
* @param int $post_id Product ID.
|
353 |
+
* @param array $args Arguments array.
|
354 |
+
*/
|
355 |
+
static public function save_meta_option( $post_id, $args = array() ) {
|
356 |
+
|
357 |
+
if ( is_array( $args ) && ! empty( $args ) ) {
|
358 |
+
|
359 |
+
foreach ( $args as $key => $value ) {
|
360 |
+
|
361 |
+
update_post_meta( $post_id, $key, $value );
|
362 |
+
}
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
/**
|
367 |
+
* Check if Elementor page builder is installed
|
368 |
+
*
|
369 |
+
* @since 1.0.0
|
370 |
+
*
|
371 |
+
* @access public
|
372 |
+
*/
|
373 |
+
static public function _is_elementor_installed() {
|
374 |
+
$path = 'elementor/elementor.php';
|
375 |
+
$plugins = get_plugins();
|
376 |
+
|
377 |
+
return isset( $plugins[ $path ] );
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Check if Step has product assigned.
|
382 |
+
*
|
383 |
+
* @since 1.0.0
|
384 |
+
* @param int $step_id step ID.
|
385 |
+
*
|
386 |
+
* @access public
|
387 |
+
*/
|
388 |
+
static public function has_product_assigned( $step_id ) {
|
389 |
+
|
390 |
+
$step_type = get_post_meta( $step_id, 'wcf-step-type', true );
|
391 |
+
|
392 |
+
if ( 'checkout' == $step_type ) {
|
393 |
+
$product = get_post_meta( $step_id, 'wcf-checkout-products', true );
|
394 |
+
} else {
|
395 |
+
$product = get_post_meta( $step_id, 'wcf-offer-product', true );
|
396 |
+
}
|
397 |
+
|
398 |
+
if ( ! empty( $product ) ) {
|
399 |
+
return true;
|
400 |
+
}
|
401 |
+
return false;
|
402 |
+
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Get attributes for cartflows wrap.
|
407 |
+
*
|
408 |
+
* @since 1.1.4
|
409 |
+
*
|
410 |
+
* @access public
|
411 |
+
*/
|
412 |
+
static public function get_cartflows_container_atts() {
|
413 |
+
|
414 |
+
$attributes = apply_filters( 'cartflows_container_atts', array() );
|
415 |
+
$atts_string = '';
|
416 |
+
|
417 |
+
foreach ( $attributes as $key => $value ) {
|
418 |
+
|
419 |
+
if ( ! $value ) {
|
420 |
+
continue;
|
421 |
+
}
|
422 |
+
|
423 |
+
if ( true === $value ) {
|
424 |
+
$atts_string .= esc_html( $key ) . ' ';
|
425 |
+
} else {
|
426 |
+
$atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
return $atts_string;
|
431 |
+
}
|
432 |
+
}
|
classes/class-cartflows-importer.php
CHANGED
@@ -1,1419 +1,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-export-' . date( 'm-d-Y' ) . '.json' );
|
120 |
-
header( 'Expires: 0' );
|
121 |
-
|
122 |
-
echo json_encode( $flows );
|
123 |
-
exit;
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Export flow markup
|
128 |
-
*
|
129 |
-
* @since 1.1.4
|
130 |
-
*/
|
131 |
-
function exporter_markup() {
|
132 |
-
include_once CARTFLOWS_DIR . 'includes/exporter.php';
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Import flow markup
|
137 |
-
*
|
138 |
-
* @since 1.1.4
|
139 |
-
*/
|
140 |
-
function importer_markup() {
|
141 |
-
include_once CARTFLOWS_DIR . 'includes/importer.php';
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Export flow
|
146 |
-
*
|
147 |
-
* @since 1.1.4
|
148 |
-
*/
|
149 |
-
function export() {
|
150 |
-
if ( empty( $_POST['cartflows-action'] ) || 'export' != $_POST['cartflows-action'] ) {
|
151 |
-
return;
|
152 |
-
}
|
153 |
-
|
154 |
-
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
155 |
-
return;
|
156 |
-
}
|
157 |
-
|
158 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
159 |
-
return;
|
160 |
-
}
|
161 |
-
|
162 |
-
$flows = $this->get_all_flow_export_data();
|
163 |
-
$flows = apply_filters( 'cartflows_export_data', $flows );
|
164 |
-
|
165 |
-
nocache_headers();
|
166 |
-
header( 'Content-Type: application/json; charset=utf-8' );
|
167 |
-
header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
|
168 |
-
header( 'Expires: 0' );
|
169 |
-
|
170 |
-
echo json_encode( $flows );
|
171 |
-
exit;
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Get flow export data
|
176 |
-
*
|
177 |
-
* @since 1.1.4
|
178 |
-
*
|
179 |
-
* @param integer $flow_id Flow ID.
|
180 |
-
* @return array
|
181 |
-
*/
|
182 |
-
function get_flow_export_data( $flow_id ) {
|
183 |
-
|
184 |
-
$valid_step_meta_keys = array(
|
185 |
-
'_wp_page_template',
|
186 |
-
'_thumbnail_id',
|
187 |
-
'classic-editor-remember',
|
188 |
-
);
|
189 |
-
|
190 |
-
$new_steps = array();
|
191 |
-
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
192 |
-
if ( $steps ) {
|
193 |
-
foreach ( $steps as $key => $step ) {
|
194 |
-
|
195 |
-
// Add step post meta.
|
196 |
-
$new_all_meta = array();
|
197 |
-
$all_meta = get_post_meta( $step['id'] );
|
198 |
-
if ( is_array( $all_meta ) ) {
|
199 |
-
foreach ( $all_meta as $meta_key => $value ) {
|
200 |
-
if ( substr( $meta_key, 0, strlen( 'wcf' ) ) === 'wcf' ) {
|
201 |
-
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
202 |
-
} elseif ( in_array( $meta_key, $valid_step_meta_keys ) ) {
|
203 |
-
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
204 |
-
}
|
205 |
-
}
|
206 |
-
}
|
207 |
-
|
208 |
-
// Add single step.
|
209 |
-
$new_steps[] = array(
|
210 |
-
'title' => get_the_title( $step['id'] ),
|
211 |
-
'type' => $step['type'],
|
212 |
-
'meta' => $new_all_meta,
|
213 |
-
);
|
214 |
-
}
|
215 |
-
}
|
216 |
-
|
217 |
-
// Add single flow.
|
218 |
-
return array(
|
219 |
-
'title' => get_the_title( $flow_id ),
|
220 |
-
'steps' => $new_steps,
|
221 |
-
);
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Get all flow export data
|
226 |
-
*
|
227 |
-
* @since 1.1.4
|
228 |
-
*/
|
229 |
-
function get_all_flow_export_data() {
|
230 |
-
|
231 |
-
$query_args = array(
|
232 |
-
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
233 |
-
|
234 |
-
// Query performance optimization.
|
235 |
-
'fields' => 'ids',
|
236 |
-
'no_found_rows' => true,
|
237 |
-
'posts_per_page' => -1,
|
238 |
-
);
|
239 |
-
|
240 |
-
$query = new WP_Query( $query_args );
|
241 |
-
$flows = array();
|
242 |
-
if ( $query->posts ) {
|
243 |
-
foreach ( $query->posts as $key => $post_id ) {
|
244 |
-
$flows[] = $this->get_flow_export_data( $post_id );
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
-
return $flows;
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* Import our exported file
|
253 |
-
*
|
254 |
-
* @since 1.1.4
|
255 |
-
*/
|
256 |
-
function import() {
|
257 |
-
if ( empty( $_POST['cartflows-action'] ) || 'import' != $_POST['cartflows-action'] ) {
|
258 |
-
return;
|
259 |
-
}
|
260 |
-
|
261 |
-
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
262 |
-
return;
|
263 |
-
}
|
264 |
-
|
265 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
266 |
-
return;
|
267 |
-
}
|
268 |
-
|
269 |
-
$filename = $_FILES['file']['name'];
|
270 |
-
$file_info = explode( '.', $filename );
|
271 |
-
$extension = end( $file_info );
|
272 |
-
|
273 |
-
if ( 'json' != $extension ) {
|
274 |
-
wp_die( __( 'Please upload a valid .json file', 'cartflows' ) );
|
275 |
-
}
|
276 |
-
|
277 |
-
$file = $_FILES['file']['tmp_name'];
|
278 |
-
|
279 |
-
if ( empty( $file ) ) {
|
280 |
-
wp_die( __( 'Please upload a file to import', 'cartflows' ) );
|
281 |
-
}
|
282 |
-
|
283 |
-
// Retrieve the settings from the file and convert the JSON object to an array.
|
284 |
-
$flows = json_decode( file_get_contents( $file ), true );
|
285 |
-
|
286 |
-
if ( $flows ) {
|
287 |
-
|
288 |
-
foreach ( $flows as $key => $flow ) {
|
289 |
-
|
290 |
-
$flow_title = $flow['title'];
|
291 |
-
if ( post_exists( $flow['title'] ) ) {
|
292 |
-
$flow_title = $flow['title'] . ' Copy';
|
293 |
-
}
|
294 |
-
|
295 |
-
// Create post object.
|
296 |
-
$new_flow_args = array(
|
297 |
-
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
298 |
-
'post_title' => $flow_title,
|
299 |
-
'post_status' => 'draft',
|
300 |
-
);
|
301 |
-
|
302 |
-
// Insert the post into the database.
|
303 |
-
$flow_id = wp_insert_post( $new_flow_args );
|
304 |
-
|
305 |
-
if ( $flow['steps'] ) {
|
306 |
-
foreach ( $flow['steps'] as $key => $step ) {
|
307 |
-
$new_step_id = wp_insert_post(
|
308 |
-
array(
|
309 |
-
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
310 |
-
'post_title' => $step['title'],
|
311 |
-
'post_status' => 'draft',
|
312 |
-
'meta_input' => $step['meta'],
|
313 |
-
)
|
314 |
-
);
|
315 |
-
|
316 |
-
// Insert post meta.
|
317 |
-
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
318 |
-
|
319 |
-
$step_taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
320 |
-
$current_term = term_exists( $step['type'], $step_taxonomy );
|
321 |
-
|
322 |
-
// // Set type object.
|
323 |
-
$data = get_term( $current_term['term_id'], $step_taxonomy );
|
324 |
-
$step_slug = $data->slug;
|
325 |
-
wp_set_object_terms( $new_step_id, $data->slug, $step_taxonomy );
|
326 |
-
|
327 |
-
// Set type.
|
328 |
-
update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
|
329 |
-
|
330 |
-
// Set flow.
|
331 |
-
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
332 |
-
|
333 |
-
CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step['title'], $step_slug );
|
334 |
-
}
|
335 |
-
}
|
336 |
-
}
|
337 |
-
}
|
338 |
-
|
339 |
-
add_action( 'admin_notices', array( $this, 'imported_successfully' ) );
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Imported notice
|
344 |
-
*
|
345 |
-
* @since 1.1.4
|
346 |
-
*/
|
347 |
-
function imported_successfully() {
|
348 |
-
?>
|
349 |
-
<div class="notice notice-success">
|
350 |
-
<p><?php _e( 'Successfully imported flows.', 'cartflows' ); ?></p>
|
351 |
-
</div>
|
352 |
-
<?php
|
353 |
-
}
|
354 |
-
|
355 |
-
/**
|
356 |
-
* Clear Cache.
|
357 |
-
*
|
358 |
-
* @since 1.0.0
|
359 |
-
*/
|
360 |
-
public function clear_cache() {
|
361 |
-
// Clear 'Elementor' file cache.
|
362 |
-
if ( class_exists( '\Elementor\Plugin' ) ) {
|
363 |
-
Elementor\Plugin::$instance->files_manager->clear_cache();
|
364 |
-
}
|
365 |
-
}
|
366 |
-
|
367 |
-
/**
|
368 |
-
* JS Templates
|
369 |
-
*
|
370 |
-
* @since 1.0.0
|
371 |
-
*
|
372 |
-
* @return void
|
373 |
-
*/
|
374 |
-
function js_templates() {
|
375 |
-
|
376 |
-
// Loading Templates.
|
377 |
-
?>
|
378 |
-
<script type="text/template" id="tmpl-cartflows-step-loading">
|
379 |
-
<div class="template-message-block cartflows-step-loading">
|
380 |
-
<h2>
|
381 |
-
<span class="spinner"></span>
|
382 |
-
<?php _e( 'Loading Steps', 'cartflows' ); ?>
|
383 |
-
</h2>
|
384 |
-
<p class="description"><?php _e( 'Getting steps from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
|
385 |
-
</div>
|
386 |
-
</script>
|
387 |
-
|
388 |
-
<?php
|
389 |
-
// Search Templates.
|
390 |
-
?>
|
391 |
-
<script type="text/template" id="tmpl-cartflows-searching-templates">
|
392 |
-
<div class="template-message-block cartflows-searching-templates">
|
393 |
-
<h2>
|
394 |
-
<span class="spinner"></span>
|
395 |
-
<?php _e( 'Searching Template..', 'cartflows' ); ?>
|
396 |
-
</h2>
|
397 |
-
<p class="description"><?php _e( 'Getting templates from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
|
398 |
-
</div>
|
399 |
-
</script>
|
400 |
-
|
401 |
-
<?php
|
402 |
-
// CartFlows Importing Template.
|
403 |
-
?>
|
404 |
-
<script type="text/template" id="tmpl-cartflows-step-importing">
|
405 |
-
<div class="template-message-block cartflows-step-importing">
|
406 |
-
<h2><span class="spinner"></span> <?php _e( 'Importing..', 'cartflows' ); ?></h2>
|
407 |
-
</div>
|
408 |
-
</script>
|
409 |
-
|
410 |
-
<?php
|
411 |
-
// CartFlows Imported.
|
412 |
-
?>
|
413 |
-
<script type="text/template" id="tmpl-cartflows-step-imported">
|
414 |
-
<div class="template-message-block cartflows-step-imported">
|
415 |
-
<h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
|
416 |
-
<p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span></p></div>
|
417 |
-
</script>
|
418 |
-
|
419 |
-
<?php
|
420 |
-
// No templates.
|
421 |
-
?>
|
422 |
-
<script type="text/template" id="tmpl-cartflows-no-steps">
|
423 |
-
<div class="cartflows-no-steps">
|
424 |
-
<div class="template-message-block">
|
425 |
-
<h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
|
426 |
-
<p class="description"></p>
|
427 |
-
</div>
|
428 |
-
</div>
|
429 |
-
</script>
|
430 |
-
|
431 |
-
<?php
|
432 |
-
// No templates.
|
433 |
-
?>
|
434 |
-
<script type="text/template" id="tmpl-cartflows-no-flows">
|
435 |
-
<div class="cartflows-no-flows">
|
436 |
-
<div class="template-message-block">
|
437 |
-
<h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
|
438 |
-
<p class="description"></p>
|
439 |
-
</div>
|
440 |
-
</div>
|
441 |
-
</script>
|
442 |
-
|
443 |
-
<?php
|
444 |
-
// Error handling.
|
445 |
-
?>
|
446 |
-
<script type="text/template" id="tmpl-templator-error">
|
447 |
-
<div class="notice notice-error"><p>{{ data }}</p></div>
|
448 |
-
</script>
|
449 |
-
|
450 |
-
<?php
|
451 |
-
// Redirect to Elementor.
|
452 |
-
?>
|
453 |
-
<script type="text/template" id="tmpl-templator-redirect-to-elementor">
|
454 |
-
<div class="template-message-block templator-redirect-to-elementor">
|
455 |
-
<h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
|
456 |
-
<p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span><br/><br/><?php _e( 'Redirecting to the Elementor edit window.', 'cartflows' ); ?> </p></div>
|
457 |
-
</script>
|
458 |
-
|
459 |
-
<?php
|
460 |
-
/**
|
461 |
-
* Responsive Buttons
|
462 |
-
*/
|
463 |
-
?>
|
464 |
-
<script type="text/template" id="tmpl-cartflows-responsive-view">
|
465 |
-
<span class="responsive-view">
|
466 |
-
<span class="actions">
|
467 |
-
<a class="desktop" href="#"><span data-view="desktop " class="active dashicons dashicons-desktop"></span></a>
|
468 |
-
<a class="tablet" href="#"><span data-view="tablet" class="dashicons dashicons-tablet"></span></a>
|
469 |
-
<a class="mobile" href="#"><span data-view="mobile" class="dashicons dashicons-smartphone"></span></a>
|
470 |
-
</span>
|
471 |
-
</span>
|
472 |
-
</script>
|
473 |
-
|
474 |
-
<?php
|
475 |
-
// Templates data.
|
476 |
-
?>
|
477 |
-
<script type="text/template" id="tmpl-cartflows-flows-list">
|
478 |
-
|
479 |
-
<# console.log( data.items.length ) #>
|
480 |
-
<# console.log( data.items ) #>
|
481 |
-
<# if ( data.items.length ) { #>
|
482 |
-
<# for ( key in data.items ) { #>
|
483 |
-
<#
|
484 |
-
var flow_steps = [];
|
485 |
-
if( data.items[ key ].flow_steps ) {
|
486 |
-
flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
|
487 |
-
return value['id'];
|
488 |
-
});
|
489 |
-
}
|
490 |
-
#>
|
491 |
-
<div class="inner">
|
492 |
-
<div class="template">
|
493 |
-
<span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
|
494 |
-
<div class="template-screenshot">
|
495 |
-
<# if( data.items[ key ].featured_image_url ) { #>
|
496 |
-
<img src="{{ data.items[ key ].featured_image_url }}" />
|
497 |
-
<# } else { #>
|
498 |
-
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
|
499 |
-
<# } #>
|
500 |
-
</div>
|
501 |
-
<a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>flow={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
|
502 |
-
<# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
|
503 |
-
<span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
|
504 |
-
<# } #>
|
505 |
-
</span>
|
506 |
-
<div class="template-id-container">
|
507 |
-
<h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
|
508 |
-
<div class="template-actions">
|
509 |
-
|
510 |
-
<#
|
511 |
-
if( data.items[ key ].page_builder.slug ) {
|
512 |
-
required_plugin_group = data.items[ key ].page_builder.slug;
|
513 |
-
} else {
|
514 |
-
required_plugin_group = '';
|
515 |
-
}
|
516 |
-
|
517 |
-
if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
|
518 |
-
import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
|
519 |
-
} else {
|
520 |
-
import_btn_title = 'Import';
|
521 |
-
} #>
|
522 |
-
|
523 |
-
<# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
|
524 |
-
<a data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
|
525 |
-
<# } else if( CartFlowsImportVars._is_pro_active ) { #>
|
526 |
-
<a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
|
527 |
-
<# } else { #>
|
528 |
-
<a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
|
529 |
-
<# } #>
|
530 |
-
</div>
|
531 |
-
</div>
|
532 |
-
</div>
|
533 |
-
</div>
|
534 |
-
<# } #>
|
535 |
-
<# } #>
|
536 |
-
</script>
|
537 |
-
|
538 |
-
<?php
|
539 |
-
// Empty Step.
|
540 |
-
?>
|
541 |
-
<script type="text/template" id="tmpl-cartflows-create-blank-step">
|
542 |
-
<div class="inner">
|
543 |
-
<div class="template">
|
544 |
-
<span class="thumbnail site-preview cartflows-flow-preview">
|
545 |
-
<div class="template-screenshot">
|
546 |
-
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
|
547 |
-
</div>
|
548 |
-
<div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
|
549 |
-
</span>
|
550 |
-
<div class="template-id-container">
|
551 |
-
<h3 class="template-name"> Blank </h3>
|
552 |
-
<div class="template-actions">
|
553 |
-
<a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create', 'cartflows' ); ?></a>
|
554 |
-
</div>
|
555 |
-
</div>
|
556 |
-
</div>
|
557 |
-
</div>
|
558 |
-
</script>
|
559 |
-
|
560 |
-
<?php
|
561 |
-
// Templates data.
|
562 |
-
?>
|
563 |
-
<script type="text/template" id="tmpl-cartflows-steps-list">
|
564 |
-
<# if ( data.items.length ) { #>
|
565 |
-
<# for ( key in data.items ) { #>
|
566 |
-
<#
|
567 |
-
var flow_steps = [];
|
568 |
-
if( data.items[ key ].flow_steps ) {
|
569 |
-
flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
|
570 |
-
return value['id'];
|
571 |
-
});
|
572 |
-
}
|
573 |
-
#>
|
574 |
-
<div class="inner">
|
575 |
-
<div class="template">
|
576 |
-
<span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
|
577 |
-
<div class="template-screenshot">
|
578 |
-
<# if( data.items[ key ].featured_image_url ) { #>
|
579 |
-
<img src="{{ data.items[ key ].featured_image_url }}" />
|
580 |
-
<# } else { #>
|
581 |
-
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
|
582 |
-
<# } #>
|
583 |
-
</div>
|
584 |
-
<div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
|
585 |
-
<a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>step={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
|
586 |
-
<# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
|
587 |
-
<span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
|
588 |
-
<# } #>
|
589 |
-
</span>
|
590 |
-
<div class="template-id-container">
|
591 |
-
<h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
|
592 |
-
<div class="template-actions">
|
593 |
-
|
594 |
-
<#
|
595 |
-
|
596 |
-
var step_slug = data.items[ key ].step_type.slug || '';
|
597 |
-
var step_title = data.items[ key ].step_type.name || '';
|
598 |
-
var import_btn_title = 'Import';
|
599 |
-
|
600 |
-
var required_plugin_group = '';
|
601 |
-
if( data.items[ key ].page_builder ) {
|
602 |
-
required_plugin_group = data.items[ key ].page_builder.slug;
|
603 |
-
|
604 |
-
if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
|
605 |
-
import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
|
606 |
-
}
|
607 |
-
}
|
608 |
-
#>
|
609 |
-
|
610 |
-
<# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
|
611 |
-
<a data-slug="{{step_slug}}" data-title="{{step_title}}" data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
|
612 |
-
<# } else if( CartFlowsImportVars._is_pro_active ) { #>
|
613 |
-
<a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
|
614 |
-
<# } else { #>
|
615 |
-
<a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
|
616 |
-
<# } #>
|
617 |
-
</div>
|
618 |
-
</div>
|
619 |
-
</div>
|
620 |
-
</div>
|
621 |
-
<# } #>
|
622 |
-
<# } #>
|
623 |
-
</script>
|
624 |
-
|
625 |
-
<?php
|
626 |
-
/**
|
627 |
-
* TMPL -
|
628 |
-
*/
|
629 |
-
?>
|
630 |
-
<script type="text/template" id="tmpl-cartflows-
|
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 |
-
|
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 |
-
// Flow
|
773 |
-
'
|
774 |
-
'
|
775 |
-
'id',
|
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 |
-
// Step
|
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 |
-
wcf()->logger->import_log( '
|
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 |
-
wcf()->logger->import_log( '
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Admin
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
* @since 1.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'CartFlows_Importer' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* CartFlows Import
|
13 |
+
*
|
14 |
+
* @since 1.0.0
|
15 |
+
*/
|
16 |
+
class CartFlows_Importer {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.0.0
|
22 |
+
* @access private
|
23 |
+
* @var object Class object.
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initiator
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @return object initialized object of class.
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self;
|
36 |
+
}
|
37 |
+
|
38 |
+
return self::$instance;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor
|
43 |
+
*
|
44 |
+
* @since 1.0.0
|
45 |
+
*/
|
46 |
+
public function __construct() {
|
47 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
|
48 |
+
add_action( 'wp_ajax_cartflows_load_steps', array( $this, 'load_templates' ) );
|
49 |
+
add_action( 'wp_ajax_cartflows_step_import', array( $this, 'import_step' ) );
|
50 |
+
add_action( 'wp_ajax_cartflows_create_flow', array( $this, 'create_flow' ) );
|
51 |
+
add_action( 'wp_ajax_cartflows_default_flow', array( $this, 'create_default_flow' ) );
|
52 |
+
add_action( 'wp_ajax_cartflows_step_create_blank', array( $this, 'step_create_blank' ) );
|
53 |
+
add_action( 'wp_ajax_cartflows_import_flow_step', array( $this, 'import_flow' ) );
|
54 |
+
add_action( 'admin_footer', array( $this, 'js_templates' ) );
|
55 |
+
add_action( 'cartflows_import_complete', array( $this, 'clear_cache' ) );
|
56 |
+
|
57 |
+
add_filter( 'cartflows_admin_js_localize', array( $this, 'localize_vars' ) );
|
58 |
+
|
59 |
+
add_action( 'wp_ajax_cartflows_activate_plugin', array( $this, 'activate_plugin' ) );
|
60 |
+
|
61 |
+
add_action( 'admin_menu', array( $this, 'add_to_menus' ) );
|
62 |
+
add_action( 'admin_init', array( $this, 'export' ) );
|
63 |
+
add_action( 'admin_init', array( $this, 'import' ) );
|
64 |
+
add_filter( 'post_row_actions', array( $this, 'export_link' ), 10, 2 );
|
65 |
+
add_action( 'admin_action_cartflows_export_flow', array( $this, 'export_flow' ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Add the export link to action list for flows row actions
|
70 |
+
*
|
71 |
+
* @since 1.1.4
|
72 |
+
*
|
73 |
+
* @param array $actions Actions array.
|
74 |
+
* @param object $post Post object.
|
75 |
+
*
|
76 |
+
* @return array
|
77 |
+
*/
|
78 |
+
function export_link( $actions, $post ) {
|
79 |
+
if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) {
|
80 |
+
$actions['export'] = '<a href="' . wp_nonce_url( 'admin.php?action=cartflows_export_flow&post=' . $post->ID, basename( __FILE__ ), 'flow_export_nonce' ) . '" title="' . __( 'Export this flow', 'cartflows' ) . '" rel="permalink">' . __( 'Export', 'cartflows' ) . '</a>';
|
81 |
+
}
|
82 |
+
return $actions;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add menus
|
87 |
+
*
|
88 |
+
* @since 1.1.4
|
89 |
+
*/
|
90 |
+
function add_to_menus() {
|
91 |
+
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Export', 'cartflows' ), __( 'Flow Export', 'cartflows' ), 'export', 'flow_exporter', array( $this, 'exporter_markup' ) );
|
92 |
+
add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Import', 'cartflows' ), __( 'Flow Import', 'cartflows' ), 'import', 'flow_importer', array( $this, 'importer_markup' ) );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Export flow with steps and its meta
|
97 |
+
*
|
98 |
+
* @since 1.1.4
|
99 |
+
*/
|
100 |
+
function export_flow() {
|
101 |
+
|
102 |
+
if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_export_flow' == $_REQUEST['action'] ) ) ) {
|
103 |
+
wp_die( __( 'No post to export has been supplied!', 'cartflows' ) );
|
104 |
+
}
|
105 |
+
|
106 |
+
if ( ! isset( $_GET['flow_export_nonce'] ) || ! wp_verify_nonce( $_GET['flow_export_nonce'], basename( __FILE__ ) ) ) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
+
// Get the original post id.
|
111 |
+
$flow_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
|
112 |
+
|
113 |
+
$flows = array();
|
114 |
+
$flows[] = $this->get_flow_export_data( $flow_id );
|
115 |
+
$flows = apply_filters( 'cartflows_export_data', $flows );
|
116 |
+
|
117 |
+
nocache_headers();
|
118 |
+
header( 'Content-Type: application/json; charset=utf-8' );
|
119 |
+
header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
|
120 |
+
header( 'Expires: 0' );
|
121 |
+
|
122 |
+
echo json_encode( $flows );
|
123 |
+
exit;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Export flow markup
|
128 |
+
*
|
129 |
+
* @since 1.1.4
|
130 |
+
*/
|
131 |
+
function exporter_markup() {
|
132 |
+
include_once CARTFLOWS_DIR . 'includes/exporter.php';
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Import flow markup
|
137 |
+
*
|
138 |
+
* @since 1.1.4
|
139 |
+
*/
|
140 |
+
function importer_markup() {
|
141 |
+
include_once CARTFLOWS_DIR . 'includes/importer.php';
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Export flow
|
146 |
+
*
|
147 |
+
* @since 1.1.4
|
148 |
+
*/
|
149 |
+
function export() {
|
150 |
+
if ( empty( $_POST['cartflows-action'] ) || 'export' != $_POST['cartflows-action'] ) {
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
|
154 |
+
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
|
162 |
+
$flows = $this->get_all_flow_export_data();
|
163 |
+
$flows = apply_filters( 'cartflows_export_data', $flows );
|
164 |
+
|
165 |
+
nocache_headers();
|
166 |
+
header( 'Content-Type: application/json; charset=utf-8' );
|
167 |
+
header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . date( 'm-d-Y' ) . '.json' );
|
168 |
+
header( 'Expires: 0' );
|
169 |
+
|
170 |
+
echo json_encode( $flows );
|
171 |
+
exit;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Get flow export data
|
176 |
+
*
|
177 |
+
* @since 1.1.4
|
178 |
+
*
|
179 |
+
* @param integer $flow_id Flow ID.
|
180 |
+
* @return array
|
181 |
+
*/
|
182 |
+
function get_flow_export_data( $flow_id ) {
|
183 |
+
|
184 |
+
$valid_step_meta_keys = array(
|
185 |
+
'_wp_page_template',
|
186 |
+
'_thumbnail_id',
|
187 |
+
'classic-editor-remember',
|
188 |
+
);
|
189 |
+
|
190 |
+
$new_steps = array();
|
191 |
+
$steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
192 |
+
if ( $steps ) {
|
193 |
+
foreach ( $steps as $key => $step ) {
|
194 |
+
|
195 |
+
// Add step post meta.
|
196 |
+
$new_all_meta = array();
|
197 |
+
$all_meta = get_post_meta( $step['id'] );
|
198 |
+
if ( is_array( $all_meta ) ) {
|
199 |
+
foreach ( $all_meta as $meta_key => $value ) {
|
200 |
+
if ( substr( $meta_key, 0, strlen( 'wcf' ) ) === 'wcf' ) {
|
201 |
+
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
202 |
+
} elseif ( in_array( $meta_key, $valid_step_meta_keys ) ) {
|
203 |
+
$new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] );
|
204 |
+
}
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
// Add single step.
|
209 |
+
$new_steps[] = array(
|
210 |
+
'title' => get_the_title( $step['id'] ),
|
211 |
+
'type' => $step['type'],
|
212 |
+
'meta' => $new_all_meta,
|
213 |
+
);
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
// Add single flow.
|
218 |
+
return array(
|
219 |
+
'title' => get_the_title( $flow_id ),
|
220 |
+
'steps' => $new_steps,
|
221 |
+
);
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Get all flow export data
|
226 |
+
*
|
227 |
+
* @since 1.1.4
|
228 |
+
*/
|
229 |
+
function get_all_flow_export_data() {
|
230 |
+
|
231 |
+
$query_args = array(
|
232 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
233 |
+
|
234 |
+
// Query performance optimization.
|
235 |
+
'fields' => 'ids',
|
236 |
+
'no_found_rows' => true,
|
237 |
+
'posts_per_page' => -1,
|
238 |
+
);
|
239 |
+
|
240 |
+
$query = new WP_Query( $query_args );
|
241 |
+
$flows = array();
|
242 |
+
if ( $query->posts ) {
|
243 |
+
foreach ( $query->posts as $key => $post_id ) {
|
244 |
+
$flows[] = $this->get_flow_export_data( $post_id );
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
return $flows;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Import our exported file
|
253 |
+
*
|
254 |
+
* @since 1.1.4
|
255 |
+
*/
|
256 |
+
function import() {
|
257 |
+
if ( empty( $_POST['cartflows-action'] ) || 'import' != $_POST['cartflows-action'] ) {
|
258 |
+
return;
|
259 |
+
}
|
260 |
+
|
261 |
+
if ( ! wp_verify_nonce( $_POST['cartflows-action-nonce'], 'cartflows-action-nonce' ) ) {
|
262 |
+
return;
|
263 |
+
}
|
264 |
+
|
265 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
266 |
+
return;
|
267 |
+
}
|
268 |
+
|
269 |
+
$filename = $_FILES['file']['name'];
|
270 |
+
$file_info = explode( '.', $filename );
|
271 |
+
$extension = end( $file_info );
|
272 |
+
|
273 |
+
if ( 'json' != $extension ) {
|
274 |
+
wp_die( __( 'Please upload a valid .json file', 'cartflows' ) );
|
275 |
+
}
|
276 |
+
|
277 |
+
$file = $_FILES['file']['tmp_name'];
|
278 |
+
|
279 |
+
if ( empty( $file ) ) {
|
280 |
+
wp_die( __( 'Please upload a file to import', 'cartflows' ) );
|
281 |
+
}
|
282 |
+
|
283 |
+
// Retrieve the settings from the file and convert the JSON object to an array.
|
284 |
+
$flows = json_decode( file_get_contents( $file ), true );
|
285 |
+
|
286 |
+
if ( $flows ) {
|
287 |
+
|
288 |
+
foreach ( $flows as $key => $flow ) {
|
289 |
+
|
290 |
+
$flow_title = $flow['title'];
|
291 |
+
if ( post_exists( $flow['title'] ) ) {
|
292 |
+
$flow_title = $flow['title'] . ' Copy';
|
293 |
+
}
|
294 |
+
|
295 |
+
// Create post object.
|
296 |
+
$new_flow_args = array(
|
297 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
298 |
+
'post_title' => $flow_title,
|
299 |
+
'post_status' => 'draft',
|
300 |
+
);
|
301 |
+
|
302 |
+
// Insert the post into the database.
|
303 |
+
$flow_id = wp_insert_post( $new_flow_args );
|
304 |
+
|
305 |
+
if ( $flow['steps'] ) {
|
306 |
+
foreach ( $flow['steps'] as $key => $step ) {
|
307 |
+
$new_step_id = wp_insert_post(
|
308 |
+
array(
|
309 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
310 |
+
'post_title' => $step['title'],
|
311 |
+
'post_status' => 'draft',
|
312 |
+
'meta_input' => $step['meta'],
|
313 |
+
)
|
314 |
+
);
|
315 |
+
|
316 |
+
// Insert post meta.
|
317 |
+
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
318 |
+
|
319 |
+
$step_taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
320 |
+
$current_term = term_exists( $step['type'], $step_taxonomy );
|
321 |
+
|
322 |
+
// // Set type object.
|
323 |
+
$data = get_term( $current_term['term_id'], $step_taxonomy );
|
324 |
+
$step_slug = $data->slug;
|
325 |
+
wp_set_object_terms( $new_step_id, $data->slug, $step_taxonomy );
|
326 |
+
|
327 |
+
// Set type.
|
328 |
+
update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
|
329 |
+
|
330 |
+
// Set flow.
|
331 |
+
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
332 |
+
|
333 |
+
CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step['title'], $step_slug );
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
add_action( 'admin_notices', array( $this, 'imported_successfully' ) );
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Imported notice
|
344 |
+
*
|
345 |
+
* @since 1.1.4
|
346 |
+
*/
|
347 |
+
function imported_successfully() {
|
348 |
+
?>
|
349 |
+
<div class="notice notice-success">
|
350 |
+
<p><?php _e( 'Successfully imported flows.', 'cartflows' ); ?></p>
|
351 |
+
</div>
|
352 |
+
<?php
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Clear Cache.
|
357 |
+
*
|
358 |
+
* @since 1.0.0
|
359 |
+
*/
|
360 |
+
public function clear_cache() {
|
361 |
+
// Clear 'Elementor' file cache.
|
362 |
+
if ( class_exists( '\Elementor\Plugin' ) ) {
|
363 |
+
Elementor\Plugin::$instance->files_manager->clear_cache();
|
364 |
+
}
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* JS Templates
|
369 |
+
*
|
370 |
+
* @since 1.0.0
|
371 |
+
*
|
372 |
+
* @return void
|
373 |
+
*/
|
374 |
+
function js_templates() {
|
375 |
+
|
376 |
+
// Loading Templates.
|
377 |
+
?>
|
378 |
+
<script type="text/template" id="tmpl-cartflows-step-loading">
|
379 |
+
<div class="template-message-block cartflows-step-loading">
|
380 |
+
<h2>
|
381 |
+
<span class="spinner"></span>
|
382 |
+
<?php _e( 'Loading Steps', 'cartflows' ); ?>
|
383 |
+
</h2>
|
384 |
+
<p class="description"><?php _e( 'Getting steps from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
|
385 |
+
</div>
|
386 |
+
</script>
|
387 |
+
|
388 |
+
<?php
|
389 |
+
// Search Templates.
|
390 |
+
?>
|
391 |
+
<script type="text/template" id="tmpl-cartflows-searching-templates">
|
392 |
+
<div class="template-message-block cartflows-searching-templates">
|
393 |
+
<h2>
|
394 |
+
<span class="spinner"></span>
|
395 |
+
<?php _e( 'Searching Template..', 'cartflows' ); ?>
|
396 |
+
</h2>
|
397 |
+
<p class="description"><?php _e( 'Getting templates from the cloud. Please wait for the moment.', 'cartflows' ); ?></p>
|
398 |
+
</div>
|
399 |
+
</script>
|
400 |
+
|
401 |
+
<?php
|
402 |
+
// CartFlows Importing Template.
|
403 |
+
?>
|
404 |
+
<script type="text/template" id="tmpl-cartflows-step-importing">
|
405 |
+
<div class="template-message-block cartflows-step-importing">
|
406 |
+
<h2><span class="spinner"></span> <?php _e( 'Importing..', 'cartflows' ); ?></h2>
|
407 |
+
</div>
|
408 |
+
</script>
|
409 |
+
|
410 |
+
<?php
|
411 |
+
// CartFlows Imported.
|
412 |
+
?>
|
413 |
+
<script type="text/template" id="tmpl-cartflows-step-imported">
|
414 |
+
<div class="template-message-block cartflows-step-imported">
|
415 |
+
<h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
|
416 |
+
<p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span></p></div>
|
417 |
+
</script>
|
418 |
+
|
419 |
+
<?php
|
420 |
+
// No templates.
|
421 |
+
?>
|
422 |
+
<script type="text/template" id="tmpl-cartflows-no-steps">
|
423 |
+
<div class="cartflows-no-steps">
|
424 |
+
<div class="template-message-block">
|
425 |
+
<h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
|
426 |
+
<p class="description"></p>
|
427 |
+
</div>
|
428 |
+
</div>
|
429 |
+
</script>
|
430 |
+
|
431 |
+
<?php
|
432 |
+
// No templates.
|
433 |
+
?>
|
434 |
+
<script type="text/template" id="tmpl-cartflows-no-flows">
|
435 |
+
<div class="cartflows-no-flows">
|
436 |
+
<div class="template-message-block">
|
437 |
+
<h2><?php _e( 'Coming Soon!', 'cartflows' ); ?></h2>
|
438 |
+
<p class="description"></p>
|
439 |
+
</div>
|
440 |
+
</div>
|
441 |
+
</script>
|
442 |
+
|
443 |
+
<?php
|
444 |
+
// Error handling.
|
445 |
+
?>
|
446 |
+
<script type="text/template" id="tmpl-templator-error">
|
447 |
+
<div class="notice notice-error"><p>{{ data }}</p></div>
|
448 |
+
</script>
|
449 |
+
|
450 |
+
<?php
|
451 |
+
// Redirect to Elementor.
|
452 |
+
?>
|
453 |
+
<script type="text/template" id="tmpl-templator-redirect-to-elementor">
|
454 |
+
<div class="template-message-block templator-redirect-to-elementor">
|
455 |
+
<h2><span class="dashicons dashicons-yes"></span> <?php _e( 'Imported', 'cartflows' ); ?></h2>
|
456 |
+
<p class="description"><?php _e( 'Thanks for patience', 'cartflows' ); ?> <span class="dashicons dashicons-smiley"></span><br/><br/><?php _e( 'Redirecting to the Elementor edit window.', 'cartflows' ); ?> </p></div>
|
457 |
+
</script>
|
458 |
+
|
459 |
+
<?php
|
460 |
+
/**
|
461 |
+
* Responsive Buttons
|
462 |
+
*/
|
463 |
+
?>
|
464 |
+
<script type="text/template" id="tmpl-cartflows-responsive-view">
|
465 |
+
<span class="responsive-view">
|
466 |
+
<span class="actions">
|
467 |
+
<a class="desktop" href="#"><span data-view="desktop " class="active dashicons dashicons-desktop"></span></a>
|
468 |
+
<a class="tablet" href="#"><span data-view="tablet" class="dashicons dashicons-tablet"></span></a>
|
469 |
+
<a class="mobile" href="#"><span data-view="mobile" class="dashicons dashicons-smartphone"></span></a>
|
470 |
+
</span>
|
471 |
+
</span>
|
472 |
+
</script>
|
473 |
+
|
474 |
+
<?php
|
475 |
+
// Templates data.
|
476 |
+
?>
|
477 |
+
<script type="text/template" id="tmpl-cartflows-flows-list">
|
478 |
+
|
479 |
+
<# console.log( data.items.length ) #>
|
480 |
+
<# console.log( data.items ) #>
|
481 |
+
<# if ( data.items.length ) { #>
|
482 |
+
<# for ( key in data.items ) { #>
|
483 |
+
<#
|
484 |
+
var flow_steps = [];
|
485 |
+
if( data.items[ key ].flow_steps ) {
|
486 |
+
flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
|
487 |
+
return value['id'];
|
488 |
+
});
|
489 |
+
}
|
490 |
+
#>
|
491 |
+
<div class="inner">
|
492 |
+
<div class="template">
|
493 |
+
<span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
|
494 |
+
<div class="template-screenshot">
|
495 |
+
<# if( data.items[ key ].featured_image_url ) { #>
|
496 |
+
<img src="{{ data.items[ key ].featured_image_url }}" />
|
497 |
+
<# } else { #>
|
498 |
+
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
|
499 |
+
<# } #>
|
500 |
+
</div>
|
501 |
+
<a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>flow={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
|
502 |
+
<# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
|
503 |
+
<span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
|
504 |
+
<# } #>
|
505 |
+
</span>
|
506 |
+
<div class="template-id-container">
|
507 |
+
<h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
|
508 |
+
<div class="template-actions">
|
509 |
+
|
510 |
+
<#
|
511 |
+
if( data.items[ key ].page_builder.slug ) {
|
512 |
+
required_plugin_group = data.items[ key ].page_builder.slug;
|
513 |
+
} else {
|
514 |
+
required_plugin_group = '';
|
515 |
+
}
|
516 |
+
|
517 |
+
if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
|
518 |
+
import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
|
519 |
+
} else {
|
520 |
+
import_btn_title = 'Import';
|
521 |
+
} #>
|
522 |
+
|
523 |
+
<# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
|
524 |
+
<a data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
|
525 |
+
<# } else if( CartFlowsImportVars._is_pro_active ) { #>
|
526 |
+
<a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
|
527 |
+
<# } else { #>
|
528 |
+
<a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
|
529 |
+
<# } #>
|
530 |
+
</div>
|
531 |
+
</div>
|
532 |
+
</div>
|
533 |
+
</div>
|
534 |
+
<# } #>
|
535 |
+
<# } #>
|
536 |
+
</script>
|
537 |
+
|
538 |
+
<?php
|
539 |
+
// Empty Step.
|
540 |
+
?>
|
541 |
+
<script type="text/template" id="tmpl-cartflows-create-blank-step">
|
542 |
+
<div class="inner">
|
543 |
+
<div class="template">
|
544 |
+
<span class="thumbnail site-preview cartflows-flow-preview">
|
545 |
+
<div class="template-screenshot">
|
546 |
+
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/start-scratch.jpg" />
|
547 |
+
</div>
|
548 |
+
<div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
|
549 |
+
</span>
|
550 |
+
<div class="template-id-container">
|
551 |
+
<h3 class="template-name"> Blank </h3>
|
552 |
+
<div class="template-actions">
|
553 |
+
<a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create', 'cartflows' ); ?></a>
|
554 |
+
</div>
|
555 |
+
</div>
|
556 |
+
</div>
|
557 |
+
</div>
|
558 |
+
</script>
|
559 |
+
|
560 |
+
<?php
|
561 |
+
// Templates data.
|
562 |
+
?>
|
563 |
+
<script type="text/template" id="tmpl-cartflows-steps-list">
|
564 |
+
<# if ( data.items.length ) { #>
|
565 |
+
<# for ( key in data.items ) { #>
|
566 |
+
<#
|
567 |
+
var flow_steps = [];
|
568 |
+
if( data.items[ key ].flow_steps ) {
|
569 |
+
flow_steps = data.items[ key ].flow_steps.map(function(value,index) {
|
570 |
+
return value['id'];
|
571 |
+
});
|
572 |
+
}
|
573 |
+
#>
|
574 |
+
<div class="inner">
|
575 |
+
<div class="template">
|
576 |
+
<span class="thumbnail site-preview cartflows-preview-flow-steps" data-flow-steps="{{ JSON.stringify( data.items[ key ].flow_steps ) }}" data-title="{{ data.items[ key ].title.rendered }}">
|
577 |
+
<div class="template-screenshot">
|
578 |
+
<# if( data.items[ key ].featured_image_url ) { #>
|
579 |
+
<img src="{{ data.items[ key ].featured_image_url }}" />
|
580 |
+
<# } else { #>
|
581 |
+
<img src="<?php echo esc_attr( CARTFLOWS_URL ); ?>assets/images/400x400.jpg" />
|
582 |
+
<# } #>
|
583 |
+
</div>
|
584 |
+
<div id="wcf_create_notice" class=""><a href="https://cartflows.com/" target="_blank"></a></div>
|
585 |
+
<a href="<?php echo CARTFLOWS_TEMPLATES_URL . 'preview/?'; ?>step={{ data.items[ key ].id }}&title={{{ data.items[ key ].title.rendered }}}" class="preview" target="_blank">Preview <i class="dashicons dashicons-external"></i></a>
|
586 |
+
<# if( data.items[ key ].flow_type && 'pro' === data.items[ key ].flow_type.slug ) { #>
|
587 |
+
<span class="wcf-flow-type pro"><?php _e( 'Pro', 'cartflows' ); ?></span>
|
588 |
+
<# } #>
|
589 |
+
</span>
|
590 |
+
<div class="template-id-container">
|
591 |
+
<h3 class="template-name"> {{{ data.items[ key ].title.rendered }}} </h3>
|
592 |
+
<div class="template-actions">
|
593 |
+
|
594 |
+
<#
|
595 |
+
|
596 |
+
var step_slug = data.items[ key ].step_type.slug || '';
|
597 |
+
var step_title = data.items[ key ].step_type.name || '';
|
598 |
+
var import_btn_title = 'Import';
|
599 |
+
|
600 |
+
var required_plugin_group = '';
|
601 |
+
if( data.items[ key ].page_builder ) {
|
602 |
+
required_plugin_group = data.items[ key ].page_builder.slug;
|
603 |
+
|
604 |
+
if( data.items[ key ].page_builder.slug && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug] && CartFlowsImportVars.required_plugins[data.items[ key ].page_builder.slug].button_title ) {
|
605 |
+
import_btn_title = CartFlowsImportVars.required_plugins[ data.items[ key ].page_builder.slug ].button_title;
|
606 |
+
}
|
607 |
+
}
|
608 |
+
#>
|
609 |
+
|
610 |
+
<# if( data.items[ key ].licence_status && 'valid' === data.items[ key ].licence_status ) { #>
|
611 |
+
<a data-slug="{{step_slug}}" data-title="{{step_title}}" data-flow-steps="{{ flow_steps }}" data-required-plugin-group="{{required_plugin_group}}" href="#" class="button button-primary cartflows-step-import" data-template-id="{{ data.items[ key ].id }}">{{ import_btn_title }}</a>
|
612 |
+
<# } else if( CartFlowsImportVars._is_pro_active ) { #>
|
613 |
+
<a target="_blank" href="<?php echo esc_url( admin_url( 'plugins.php?cartflows-license-popup' ) ); ?>" class="button button-primary"><?php _e( 'Activate License', 'cartflows' ); ?></a>
|
614 |
+
<# } else { #>
|
615 |
+
<a target="_blank" href="<?php echo esc_url( CARTFLOWS_DOMAIN_URL ); ?>" class="button button-primary"><?php _e( 'Get Pro', 'cartflows' ); ?></a>
|
616 |
+
<# } #>
|
617 |
+
</div>
|
618 |
+
</div>
|
619 |
+
</div>
|
620 |
+
</div>
|
621 |
+
<# } #>
|
622 |
+
<# } #>
|
623 |
+
</script>
|
624 |
+
|
625 |
+
<?php
|
626 |
+
/**
|
627 |
+
* TMPL - Website Unreachable
|
628 |
+
*/
|
629 |
+
?>
|
630 |
+
<script type="text/template" id="tmpl-cartflows-website-unreachable">
|
631 |
+
<div class="postbox cartflows-website-unreachable">
|
632 |
+
<h2><?php _e( 'Under Maintenance..', 'cartflows' ); ?></h2>
|
633 |
+
<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>
|
634 |
+
<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>
|
635 |
+
</div>
|
636 |
+
</script>
|
637 |
+
|
638 |
+
<?php
|
639 |
+
/**
|
640 |
+
* TMPL - Filters
|
641 |
+
*/
|
642 |
+
?>
|
643 |
+
<script type="text/template" id="tmpl-cartflows-page-builder-notice">
|
644 |
+
<?php
|
645 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
646 |
+
$page_builder = Cartflows_Helper::get_required_plugins_for_page_builder( Cartflows_Helper::get_common_setting( 'default_page_builder' ) );
|
647 |
+
$title = $page_builder['title'];
|
648 |
+
?>
|
649 |
+
<div class="wcf-page-builder-message">
|
650 |
+
<p><a href="#" data-slug="<?php echo $default_page_builder; ?>" class="wcf-install-plugin">Please click here and activate <?php echo $title; ?></a> to see CartFlows templates. If you prefer another page builder tool, you can <a href="<?php echo esc_url( admin_url( 'admin.php?page=' . CARTFLOWS_SETTINGS . '&action=common-settings#form-field-wcf_default_page_builder' ) ); ?>" target="blank">select it here</a>.</p>
|
651 |
+
<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>
|
652 |
+
<p>We plan to add design templates made with more page builder shortly!</p>
|
653 |
+
</div>
|
654 |
+
</script>
|
655 |
+
|
656 |
+
<?php
|
657 |
+
/**
|
658 |
+
* TMPL - Filters
|
659 |
+
*/
|
660 |
+
?>
|
661 |
+
<script type="text/template" id="tmpl-cartflows-term-filters-dropdown">
|
662 |
+
<# if ( data ) { #>
|
663 |
+
<select class="{{ data.args.wrapper_class }} {{ data.args.class }}">
|
664 |
+
<# if ( data.args.show_all ) { #>
|
665 |
+
<option value="all"> <?php _e( 'All', 'cartflows' ); ?> </option>
|
666 |
+
<# } #>
|
667 |
+
<# if ( CartFlowsImportVars.step_type === data.args.remote_slug ) { #>
|
668 |
+
<option value=""> <?php _e( 'Select Step Type', 'cartflows' ); ?> </option>
|
669 |
+
<# } #>
|
670 |
+
<# for ( key in data.items ) { #>
|
671 |
+
<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>
|
672 |
+
<# } #>
|
673 |
+
</select>
|
674 |
+
<# } #>
|
675 |
+
</script>
|
676 |
+
|
677 |
+
<script type="text/template" id="tmpl-cartflows-term-filters">
|
678 |
+
|
679 |
+
<# if ( data ) { #>
|
680 |
+
|
681 |
+
<?php /* <# if ( CartFlowsImportVars.flow_page_builder === data.args.remote_slug || CartFlowsImportVars.step_page_builder === data.args.remote_slug ) { #> */ ?>
|
682 |
+
<ul class="{{ data.args.wrapper_class }} {{ data.args.class }}">
|
683 |
+
|
684 |
+
<# if ( data.args.show_all ) { #>
|
685 |
+
<li>
|
686 |
+
<a href="#" data-group="all"> All </a>
|
687 |
+
</li>
|
688 |
+
<# } #>
|
689 |
+
|
690 |
+
<# for ( key in data.items ) { #>
|
691 |
+
<li>
|
692 |
+
<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>
|
693 |
+
</li>
|
694 |
+
<# } #>
|
695 |
+
|
696 |
+
</ul>
|
697 |
+
|
698 |
+
<?php
|
699 |
+
|
700 |
+
/*
|
701 |
+
<# } else { #>
|
702 |
+
<select class="{{ data.args.wrapper_class }} {{ data.args.class }}">
|
703 |
+
|
704 |
+
<# if ( data.args.show_all ) { #>
|
705 |
+
<option value="all"> <?php _e( 'All', 'cartflows' ); ?> </option>
|
706 |
+
<# } #>
|
707 |
+
|
708 |
+
<# if ( CartFlowsImportVars.step_type === data.args.remote_slug ) { #>
|
709 |
+
<option value=""> <?php _e( 'Select Step Type', 'cartflows' ); ?> </option>
|
710 |
+
<# } #>
|
711 |
+
|
712 |
+
<# for ( key in data.items ) { #>
|
713 |
+
<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>
|
714 |
+
<# } #>
|
715 |
+
|
716 |
+
</select>
|
717 |
+
*/
|
718 |
+
?>
|
719 |
+
|
720 |
+
<?php /* <# } #> */ ?>
|
721 |
+
|
722 |
+
<# } #>
|
723 |
+
</script>
|
724 |
+
|
725 |
+
<?php
|
726 |
+
// Step Type.
|
727 |
+
?>
|
728 |
+
<script type="text/template" id="tmpl-cartflows-step-types">
|
729 |
+
<ul class="wcf-tab nav-tabs">
|
730 |
+
<# if( data.items_count ) { #>
|
731 |
+
<# for( key in data.items ) { #>
|
732 |
+
<# console.log( data.items[ key ].id ) #>
|
733 |
+
<li data-slug="{{data.items[ key ].slug}}" data-title="{{ data.items[ key ].name }}">
|
734 |
+
<a href="#{{{ data.items[ key ].slug }}}">{{{ data.items[ key ].name }}}</a>
|
735 |
+
</li>
|
736 |
+
<# } #>
|
737 |
+
<# } #>
|
738 |
+
</ul>
|
739 |
+
</script>
|
740 |
+
|
741 |
+
<?php
|
742 |
+
// Add to library button.
|
743 |
+
?>
|
744 |
+
<script type="text/template" id="tmpl-templator-add-to-library">
|
745 |
+
<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>
|
746 |
+
</script>
|
747 |
+
<?php
|
748 |
+
}
|
749 |
+
|
750 |
+
/**
|
751 |
+
* Enqueue scripts
|
752 |
+
*
|
753 |
+
* @since 1.0.0
|
754 |
+
*
|
755 |
+
* @hook admin_enqueue_scripts
|
756 |
+
* @param string $hook Current page hook.
|
757 |
+
*/
|
758 |
+
function scripts( $hook = '' ) {
|
759 |
+
|
760 |
+
if ( ! self::is_supported_post( get_current_screen()->post_type ) ) {
|
761 |
+
return;
|
762 |
+
}
|
763 |
+
|
764 |
+
wp_enqueue_script( 'cartflows-rest-api', CARTFLOWS_URL . 'assets/js/rest-api.js', array( 'jquery' ), CARTFLOWS_VER, true );
|
765 |
+
wp_enqueue_style( 'cartflows-import', CARTFLOWS_URL . 'assets/css/import.css', null, CARTFLOWS_VER, 'all' );
|
766 |
+
wp_style_add_data( 'cartflows-import', 'rtl', 'replace' );
|
767 |
+
wp_enqueue_script( 'cartflows-import', CARTFLOWS_URL . 'assets/js/import.js', array( 'jquery', 'wp-util', 'cartflows-rest-api', 'updates' ), CARTFLOWS_VER, true );
|
768 |
+
|
769 |
+
$localize_vars = array(
|
770 |
+
'_is_pro_active' => _is_cartflows_pro(),
|
771 |
+
|
772 |
+
// Flow and its rest fields.
|
773 |
+
'flow' => CARTFLOWS_FLOW_POST_TYPE,
|
774 |
+
'flow_fields' => array(
|
775 |
+
'id',
|
776 |
+
'title',
|
777 |
+
'flow_type',
|
778 |
+
'page_builder',
|
779 |
+
'flow_steps',
|
780 |
+
'licence_status',
|
781 |
+
'featured_image_url',
|
782 |
+
'featured_media', // @required for field `featured_image_url`.
|
783 |
+
),
|
784 |
+
|
785 |
+
// Flow type and rest fields.
|
786 |
+
'flow_type' => CARTFLOWS_TAXONOMY_FLOW_CATEGORY,
|
787 |
+
'flow_type_fields' => array(
|
788 |
+
'id',
|
789 |
+
'name',
|
790 |
+
'slug',
|
791 |
+
),
|
792 |
+
|
793 |
+
// Flow page builder and rest fields.
|
794 |
+
'flow_page_builder' => CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER,
|
795 |
+
'flow_page_builder_fields' => array(
|
796 |
+
'id',
|
797 |
+
'name',
|
798 |
+
'slug',
|
799 |
+
),
|
800 |
+
|
801 |
+
// Step page builder and rest fields.
|
802 |
+
'step_page_builder' => CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER,
|
803 |
+
'step_page_builder_fields' => array(
|
804 |
+
'id',
|
805 |
+
'name',
|
806 |
+
'slug',
|
807 |
+
),
|
808 |
+
|
809 |
+
// Step and its rest fields.
|
810 |
+
'step' => CARTFLOWS_STEP_POST_TYPE,
|
811 |
+
'step_fields' => array(
|
812 |
+
'title',
|
813 |
+
'featured_image_url',
|
814 |
+
'featured_media', // @required for field `featured_image_url`.
|
815 |
+
'id',
|
816 |
+
'flow_type',
|
817 |
+
'step_type',
|
818 |
+
'page_builder',
|
819 |
+
'licence_status',
|
820 |
+
),
|
821 |
+
|
822 |
+
// Step type and its rest fields.
|
823 |
+
'step_type' => CARTFLOWS_TAXONOMY_STEP_TYPE,
|
824 |
+
'step_type_fields' => array(
|
825 |
+
'id',
|
826 |
+
'name',
|
827 |
+
'slug',
|
828 |
+
),
|
829 |
+
|
830 |
+
'domain_url' => CARTFLOWS_DOMAIN_URL,
|
831 |
+
'server_url' => CARTFLOWS_TEMPLATES_URL,
|
832 |
+
'server_rest_url' => CARTFLOWS_TEMPLATES_URL . 'wp-json/wp/v2/',
|
833 |
+
'site_url' => site_url(),
|
834 |
+
'import_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_importer' ),
|
835 |
+
'export_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_exporter' ),
|
836 |
+
'admin_url' => admin_url(),
|
837 |
+
'licence_args' => CartFlows_API::get_instance()->get_licence_args(),
|
838 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
839 |
+
'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false,
|
840 |
+
|
841 |
+
'required_plugins' => Cartflows_Helper::get_plugins_groupby_page_builders(),
|
842 |
+
|
843 |
+
'default_page_builder' => Cartflows_Helper::get_common_setting( 'default_page_builder' ),
|
844 |
+
);
|
845 |
+
|
846 |
+
// var_dump(Cartflows_Helper::get_common_setting( 'default_page_builder' ));
|
847 |
+
// wp_die( );
|
848 |
+
// Add thickbox.
|
849 |
+
add_thickbox();
|
850 |
+
|
851 |
+
wp_localize_script( 'cartflows-import', 'CartFlowsImportVars', $localize_vars );
|
852 |
+
wp_localize_script( 'cartflows-rest-api', 'CartFlowsImportVars', $localize_vars );
|
853 |
+
}
|
854 |
+
|
855 |
+
/**
|
856 |
+
* Load Template
|
857 |
+
*
|
858 |
+
* @since 1.0.0
|
859 |
+
*
|
860 |
+
* @hook cartflows_load_steps
|
861 |
+
* @return void
|
862 |
+
*/
|
863 |
+
function load_templates() {
|
864 |
+
|
865 |
+
check_ajax_referer( 'cf-load-steps', 'security' );
|
866 |
+
|
867 |
+
$args = ( isset( $_POST['args'] ) ) ? array_map( 'sanitize_text_field', $_POST['args'] ) : array();
|
868 |
+
$templates = CartFlows_API::get_instance()->get_templates( $args );
|
869 |
+
|
870 |
+
if ( $templates['templates_count'] ) {
|
871 |
+
wp_send_json_success( $templates );
|
872 |
+
} else {
|
873 |
+
wp_send_json_error( $templates );
|
874 |
+
}
|
875 |
+
wp_die();
|
876 |
+
}
|
877 |
+
|
878 |
+
/**
|
879 |
+
* Import.
|
880 |
+
*
|
881 |
+
* @since 1.0.0
|
882 |
+
*
|
883 |
+
* @hook wp_ajax_cartflows_import_flow_step
|
884 |
+
* @return void
|
885 |
+
*/
|
886 |
+
function import_flow() {
|
887 |
+
|
888 |
+
check_ajax_referer( 'cf-import-flow-step', 'security' );
|
889 |
+
|
890 |
+
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
891 |
+
$template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
|
892 |
+
|
893 |
+
wcf()->logger->import_log( '------------------------------------' );
|
894 |
+
wcf()->logger->import_log( 'STARTED! Importing FLOW' );
|
895 |
+
wcf()->logger->import_log( '------------------------------------' );
|
896 |
+
wcf()->logger->import_log( '(✓) Creating new step from remote step [' . $template_id . '] for FLOW ' . get_the_title( $flow_id ) . ' [' . $flow_id . ']' );
|
897 |
+
|
898 |
+
$response = CartFlows_API::get_instance()->get_template( $template_id );
|
899 |
+
|
900 |
+
if ( false === $response['success'] ) {
|
901 |
+
wcf()->logger->import_log( '(✕) Failed to fetch remote data.' );
|
902 |
+
wp_send_json_error( $response );
|
903 |
+
}
|
904 |
+
|
905 |
+
wcf()->logger->import_log( '(✓) Successfully getting remote step response ' . json_encode( $response ) );
|
906 |
+
|
907 |
+
$new_step_id = wp_insert_post(
|
908 |
+
array(
|
909 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
910 |
+
'post_title' => $response['title'],
|
911 |
+
'post_content' => '',
|
912 |
+
'post_status' => 'publish',
|
913 |
+
)
|
914 |
+
);
|
915 |
+
|
916 |
+
if ( is_wp_error( $new_step_id ) ) {
|
917 |
+
wcf()->logger->import_log( '(✕) Failed to create new step for flow ' . $flow_id );
|
918 |
+
wp_send_json_error( $new_step_id );
|
919 |
+
}
|
920 |
+
|
921 |
+
wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id );
|
922 |
+
// insert post meta.
|
923 |
+
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
924 |
+
wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' );
|
925 |
+
|
926 |
+
/**
|
927 |
+
* Import & Set type.
|
928 |
+
*/
|
929 |
+
$term = isset( $response['data']['step_type'] ) ? $response['data']['step_type'] : '';
|
930 |
+
$term_slug = '';
|
931 |
+
if ( $term ) {
|
932 |
+
|
933 |
+
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
934 |
+
$term_exist = term_exists( $term->name, $taxonomy );
|
935 |
+
|
936 |
+
if ( empty( $term_exist ) ) {
|
937 |
+
$terms = array(
|
938 |
+
array(
|
939 |
+
'name' => $term->name,
|
940 |
+
),
|
941 |
+
);
|
942 |
+
|
943 |
+
Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
|
944 |
+
wcf()->logger->import_log( '(✓) Created new term ' . $term->name );
|
945 |
+
}
|
946 |
+
|
947 |
+
$current_term = term_exists( $term->name, $taxonomy );
|
948 |
+
|
949 |
+
// Set type object.
|
950 |
+
$data = get_term( $current_term['term_id'], $taxonomy );
|
951 |
+
$term_slug = $data->slug;
|
952 |
+
$term_name = $data->name;
|
953 |
+
wp_set_object_terms( $new_step_id, $term_slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
954 |
+
wcf()->logger->import_log( '(✓) Assigned existing term ' . $term_name . ' to the template ' . $new_step_id );
|
955 |
+
|
956 |
+
// Set type.
|
957 |
+
update_post_meta( $new_step_id, 'wcf-step-type', $term_slug );
|
958 |
+
wcf()->logger->import_log( '(✓) Updated term ' . $term_name . ' to the post meta wcf-step-type.' );
|
959 |
+
}
|
960 |
+
|
961 |
+
// Set flow.
|
962 |
+
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
963 |
+
wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
|
964 |
+
|
965 |
+
/**
|
966 |
+
* Update steps for the current flow.
|
967 |
+
*/
|
968 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
969 |
+
|
970 |
+
if ( ! is_array( $flow_steps ) ) {
|
971 |
+
$flow_steps = array();
|
972 |
+
}
|
973 |
+
|
974 |
+
$flow_steps[] = array(
|
975 |
+
'id' => $new_step_id,
|
976 |
+
'title' => $response['title'],
|
977 |
+
'type' => $term_slug,
|
978 |
+
);
|
979 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
980 |
+
wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
|
981 |
+
|
982 |
+
// Import Post Meta.
|
983 |
+
self::import_post_meta( $new_step_id, $response );
|
984 |
+
|
985 |
+
wcf()->logger->import_log( '(✓) Importing step "' . get_the_title( $new_step_id ) . '" [' . $new_step_id . '] for FLOW "' . get_the_title( $flow_id ) . '" [' . $flow_id . ']' );
|
986 |
+
wcf()->logger->import_log( '------------------------------------' );
|
987 |
+
wcf()->logger->import_log( 'COMPLETE! Importing FLOW' );
|
988 |
+
wcf()->logger->import_log( '------------------------------------' );
|
989 |
+
|
990 |
+
do_action( 'cartflows_import_complete' );
|
991 |
+
wcf()->logger->import_log( '(✓) BATCH STARTED for step ' . $new_step_id . ' for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' );
|
992 |
+
|
993 |
+
// Batch Process.
|
994 |
+
do_action( 'cartflows_after_template_import', $new_step_id, $response );
|
995 |
+
|
996 |
+
/**
|
997 |
+
* End
|
998 |
+
*/
|
999 |
+
wp_send_json_success( $new_step_id );
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
/**
|
1003 |
+
* Import Step.
|
1004 |
+
*
|
1005 |
+
* @since 1.0.0
|
1006 |
+
* @hook wp_ajax_cartflows_step_import
|
1007 |
+
*
|
1008 |
+
* @return void
|
1009 |
+
*/
|
1010 |
+
function create_default_flow() {
|
1011 |
+
|
1012 |
+
check_ajax_referer( 'cf-default-flow', 'security' );
|
1013 |
+
|
1014 |
+
// Create post object.
|
1015 |
+
$new_flow_post = array(
|
1016 |
+
'post_content' => '',
|
1017 |
+
'post_status' => 'publish',
|
1018 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
1019 |
+
);
|
1020 |
+
|
1021 |
+
// Insert the post into the database.
|
1022 |
+
$flow_id = wp_insert_post( $new_flow_post );
|
1023 |
+
|
1024 |
+
if ( is_wp_error( $flow_id ) ) {
|
1025 |
+
wp_send_json_error( $flow_id->get_error_message() );
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
$flow_steps = array();
|
1029 |
+
|
1030 |
+
$steps_data = array(
|
1031 |
+
'landing' => __( 'Landing Page', 'cartflows' ),
|
1032 |
+
'checkout' => __( 'Checkout Page', 'cartflows' ),
|
1033 |
+
'thankyou' => __( 'Thank You Page', 'cartflows' ),
|
1034 |
+
);
|
1035 |
+
|
1036 |
+
foreach ( $steps_data as $slug => $title ) {
|
1037 |
+
|
1038 |
+
$post_content = '';
|
1039 |
+
|
1040 |
+
switch ( $slug ) {
|
1041 |
+
case 'checkout':
|
1042 |
+
$post_content = '';
|
1043 |
+
break;
|
1044 |
+
case 'thankyou':
|
1045 |
+
$post_content = '';
|
1046 |
+
break;
|
1047 |
+
default:
|
1048 |
+
$post_content = '';
|
1049 |
+
break;
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
$step_id = wp_insert_post(
|
1053 |
+
array(
|
1054 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
1055 |
+
'post_title' => $title,
|
1056 |
+
'post_content' => $post_content,
|
1057 |
+
'post_status' => 'publish',
|
1058 |
+
)
|
1059 |
+
);
|
1060 |
+
|
1061 |
+
if ( is_wp_error( $step_id ) ) {
|
1062 |
+
wp_send_json_error( $step_id->get_error_message() );
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
if ( $step_id ) {
|
1066 |
+
|
1067 |
+
$flow_steps[] = array(
|
1068 |
+
'id' => $step_id,
|
1069 |
+
'title' => $title,
|
1070 |
+
'type' => $slug,
|
1071 |
+
);
|
1072 |
+
|
1073 |
+
// insert post meta.
|
1074 |
+
update_post_meta( $step_id, 'wcf-flow-id', $flow_id );
|
1075 |
+
update_post_meta( $step_id, 'wcf-step-type', $slug );
|
1076 |
+
|
1077 |
+
wp_set_object_terms( $step_id, $slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
1078 |
+
wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
1079 |
+
}
|
1080 |
+
}
|
1081 |
+
|
1082 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1083 |
+
|
1084 |
+
wp_send_json_success( $flow_id );
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
/**
|
1088 |
+
* Create Flow
|
1089 |
+
*
|
1090 |
+
* @return void
|
1091 |
+
*/
|
1092 |
+
function create_flow() {
|
1093 |
+
|
1094 |
+
check_ajax_referer( 'cf-create-flow', 'security' );
|
1095 |
+
|
1096 |
+
// Create post object.
|
1097 |
+
$new_flow_post = array(
|
1098 |
+
'post_content' => '',
|
1099 |
+
'post_status' => 'publish',
|
1100 |
+
'post_type' => CARTFLOWS_FLOW_POST_TYPE,
|
1101 |
+
);
|
1102 |
+
|
1103 |
+
// Insert the post into the database.
|
1104 |
+
$flow_id = wp_insert_post( $new_flow_post );
|
1105 |
+
|
1106 |
+
if ( is_wp_error( $flow_id ) ) {
|
1107 |
+
wp_send_json_error( $flow_id->get_error_message() );
|
1108 |
+
}
|
1109 |
+
|
1110 |
+
wp_send_json_success( $flow_id );
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
/**
|
1114 |
+
* Create Step
|
1115 |
+
*
|
1116 |
+
* @return void
|
1117 |
+
*/
|
1118 |
+
function import_step() {
|
1119 |
+
|
1120 |
+
check_ajax_referer( 'cf-step-import', 'security' );
|
1121 |
+
|
1122 |
+
$template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : '';
|
1123 |
+
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1124 |
+
$step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
|
1125 |
+
$step_type = isset( $_POST['step_type'] ) ? sanitize_title( $_POST['step_type'] ) : '';
|
1126 |
+
$step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( $_POST['step_custom_title'] ) : $step_title;
|
1127 |
+
|
1128 |
+
$cartflow_meta = Cartflows_Flow_Meta::get_instance();
|
1129 |
+
|
1130 |
+
$post_id = $cartflow_meta->create_step( $flow_id, $step_type, $step_custom_title );
|
1131 |
+
|
1132 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1133 |
+
wcf()->logger->import_log( 'STARTED! Importing STEP' );
|
1134 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1135 |
+
|
1136 |
+
if ( empty( $template_id ) || empty( $post_id ) ) {
|
1137 |
+
/* translators: %s: template ID */
|
1138 |
+
$data = sprintf( __( 'Invalid template id %1$s or post id %2$s.', 'cartflows' ), $template_id, $post_id );
|
1139 |
+
wcf()->logger->import_log( $data );
|
1140 |
+
wp_send_json_error( $data );
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
wcf()->logger->import_log( 'Remote Step ' . $template_id . ' for local flow "' . get_the_title( $post_id ) . '" [' . $post_id . ']' );
|
1144 |
+
|
1145 |
+
$response = CartFlows_API::get_instance()->get_template( $template_id );
|
1146 |
+
|
1147 |
+
// Import Post Meta.
|
1148 |
+
self::import_post_meta( $post_id, $response );
|
1149 |
+
|
1150 |
+
do_action( 'cartflows_import_complete' );
|
1151 |
+
|
1152 |
+
// Batch Process.
|
1153 |
+
do_action( 'cartflows_after_template_import', $post_id, $response );
|
1154 |
+
|
1155 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1156 |
+
wcf()->logger->import_log( 'COMPLETE! Importing Step' );
|
1157 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1158 |
+
|
1159 |
+
wp_send_json_success( $post_id );
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
/**
|
1163 |
+
* Import Step.
|
1164 |
+
*
|
1165 |
+
* @since 1.0.0
|
1166 |
+
* @hook wp_ajax_cartflows_step_create_blank
|
1167 |
+
*
|
1168 |
+
* @return void
|
1169 |
+
*/
|
1170 |
+
function step_create_blank() {
|
1171 |
+
|
1172 |
+
check_ajax_referer( 'cf-step-create-blank', 'security' );
|
1173 |
+
|
1174 |
+
$flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : '';
|
1175 |
+
$step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( $_POST['step_type'] ) : '';
|
1176 |
+
$step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( $_POST['step_title'] ) : '';
|
1177 |
+
|
1178 |
+
if ( empty( $flow_id ) || empty( $step_type ) ) {
|
1179 |
+
/* translators: %s: flow ID */
|
1180 |
+
$data = sprintf( __( 'Invalid flow id %1$s OR step type %2$s.', 'cartflows' ), $flow_id, $step_type );
|
1181 |
+
wcf()->logger->import_log( $data );
|
1182 |
+
wp_send_json_error( $data );
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1186 |
+
wcf()->logger->import_log( 'STARTED! Creating Blank STEP for Flow ' . $flow_id );
|
1187 |
+
|
1188 |
+
$step_type_title = str_replace( '-', ' ', $step_type );
|
1189 |
+
$step_type_slug = strtolower( str_replace( '-', ' ', $step_type ) );
|
1190 |
+
|
1191 |
+
$new_step_id = wp_insert_post(
|
1192 |
+
array(
|
1193 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
1194 |
+
'post_title' => $step_title,
|
1195 |
+
'post_content' => '',
|
1196 |
+
'post_status' => 'publish',
|
1197 |
+
)
|
1198 |
+
);
|
1199 |
+
|
1200 |
+
// insert post meta.
|
1201 |
+
update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id );
|
1202 |
+
|
1203 |
+
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
1204 |
+
$term_exist = term_exists( $step_type_title, $taxonomy );
|
1205 |
+
|
1206 |
+
if ( empty( $term_exist ) ) {
|
1207 |
+
$terms = array(
|
1208 |
+
array(
|
1209 |
+
'name' => $step_type_title,
|
1210 |
+
),
|
1211 |
+
);
|
1212 |
+
|
1213 |
+
Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms );
|
1214 |
+
wcf()->logger->import_log( '(✓) Created new term ' . $step_type_title );
|
1215 |
+
}
|
1216 |
+
|
1217 |
+
$current_term = term_exists( $step_type_title, $taxonomy );
|
1218 |
+
|
1219 |
+
// Set type object.
|
1220 |
+
$data = get_term( $current_term['term_id'], $taxonomy );
|
1221 |
+
$step_slug = $data->slug;
|
1222 |
+
wp_set_object_terms( $new_step_id, $data->slug, CARTFLOWS_TAXONOMY_STEP_TYPE );
|
1223 |
+
wcf()->logger->import_log( '(✓) Assigned existing term ' . $step_type_title . ' to the template ' . $new_step_id );
|
1224 |
+
|
1225 |
+
// Set type.
|
1226 |
+
update_post_meta( $new_step_id, 'wcf-step-type', $data->slug );
|
1227 |
+
wcf()->logger->import_log( '(✓) Updated term ' . $data->name . ' to the post meta wcf-step-type.' );
|
1228 |
+
|
1229 |
+
// Set flow.
|
1230 |
+
wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW );
|
1231 |
+
wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id );
|
1232 |
+
|
1233 |
+
CartFlows_Importer::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step_type_title, $step_slug );
|
1234 |
+
|
1235 |
+
wcf()->logger->import_log( 'COMPLETE! Creating Blank STEP for Flow ' . $flow_id );
|
1236 |
+
wcf()->logger->import_log( '------------------------------------' );
|
1237 |
+
|
1238 |
+
wp_send_json_success( $new_step_id );
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
/**
|
1242 |
+
* Import Post Meta
|
1243 |
+
*
|
1244 |
+
* @since 1.0.0
|
1245 |
+
*
|
1246 |
+
* @param integer $post_id Post ID.
|
1247 |
+
* @param array $response Post meta.
|
1248 |
+
* @return void
|
1249 |
+
*/
|
1250 |
+
public static function import_post_meta( $post_id, $response ) {
|
1251 |
+
|
1252 |
+
$metadata = (array) $response['post_meta'];
|
1253 |
+
|
1254 |
+
foreach ( $metadata as $meta_key => $meta_value ) {
|
1255 |
+
$meta_value = isset( $meta_value[0] ) ? $meta_value[0] : '';
|
1256 |
+
|
1257 |
+
if ( $meta_value ) {
|
1258 |
+
|
1259 |
+
if ( is_serialized( $meta_value, true ) ) {
|
1260 |
+
$raw_data = maybe_unserialize( stripslashes( $meta_value ) );
|
1261 |
+
} elseif ( is_array( $meta_value ) ) {
|
1262 |
+
$raw_data = json_decode( stripslashes( $meta_value ), true );
|
1263 |
+
} else {
|
1264 |
+
$raw_data = $meta_value;
|
1265 |
+
}
|
1266 |
+
|
1267 |
+
if ( '_elementor_data' === $meta_key ) {
|
1268 |
+
if ( is_array( $raw_data ) ) {
|
1269 |
+
$raw_data = wp_slash( json_encode( $raw_data ) );
|
1270 |
+
} else {
|
1271 |
+
$raw_data = wp_slash( $raw_data );
|
1272 |
+
}
|
1273 |
+
}
|
1274 |
+
if ( '_elementor_data' !== $meta_key && '_elementor_draft' !== $meta_key && '_fl_builder_data' !== $meta_key && '_fl_builder_draft' !== $meta_key ) {
|
1275 |
+
if ( is_array( $raw_data ) ) {
|
1276 |
+
wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . json_encode( $raw_data ) );
|
1277 |
+
} else {
|
1278 |
+
if ( ! is_object( $raw_data ) ) {
|
1279 |
+
wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data );
|
1280 |
+
}
|
1281 |
+
}
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
update_post_meta( $post_id, $meta_key, $raw_data );
|
1285 |
+
}
|
1286 |
+
}
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
/**
|
1290 |
+
* Import Template for Elementor
|
1291 |
+
*
|
1292 |
+
* @since 1.0.0
|
1293 |
+
*
|
1294 |
+
* @param integer $post_id Post ID.
|
1295 |
+
* @param array $response Post meta.
|
1296 |
+
* @param array $page_build_data Page build data.
|
1297 |
+
* @return void
|
1298 |
+
*/
|
1299 |
+
public static function import_template_elementor( $post_id, $response, $page_build_data ) {
|
1300 |
+
if ( ! is_plugin_active( 'elementor/elementor.php' ) ) {
|
1301 |
+
$data = __( 'Elementor is not activated. Please activate plugin Elementor Page Builder to import the step.', 'cartflows' );
|
1302 |
+
wcf()->logger->import_log( $data );
|
1303 |
+
wp_send_json_error( $data );
|
1304 |
+
}
|
1305 |
+
|
1306 |
+
require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
|
1307 |
+
|
1308 |
+
wcf()->logger->import_log( '# Started "importing page builder data" for step ' . $post_id );
|
1309 |
+
|
1310 |
+
$obj = new \Elementor\TemplateLibrary\CartFlows_Importer_Elementor();
|
1311 |
+
$obj->import_single_template( $post_id );
|
1312 |
+
|
1313 |
+
wcf()->logger->import_log( '# Complete "importing page builder data" for step ' . $post_id );
|
1314 |
+
}
|
1315 |
+
|
1316 |
+
/**
|
1317 |
+
* Supported post types
|
1318 |
+
*
|
1319 |
+
* @since 1.0.0
|
1320 |
+
*
|
1321 |
+
* @return array Supported post types.
|
1322 |
+
*/
|
1323 |
+
public static function supported_post_types() {
|
1324 |
+
return apply_filters(
|
1325 |
+
'cartflows_supported_post_types',
|
1326 |
+
array(
|
1327 |
+
CARTFLOWS_FLOW_POST_TYPE,
|
1328 |
+
)
|
1329 |
+
);
|
1330 |
+
}
|
1331 |
+
|
1332 |
+
/**
|
1333 |
+
* Check supported post type
|
1334 |
+
*
|
1335 |
+
* @since 1.0.0
|
1336 |
+
*
|
1337 |
+
* @param string $post_type Post type.
|
1338 |
+
* @return boolean Supported post type status.
|
1339 |
+
*/
|
1340 |
+
public static function is_supported_post( $post_type = '' ) {
|
1341 |
+
if ( in_array( $post_type, self::supported_post_types() ) ) {
|
1342 |
+
return true;
|
1343 |
+
}
|
1344 |
+
|
1345 |
+
return false;
|
1346 |
+
}
|
1347 |
+
|
1348 |
+
/**
|
1349 |
+
* Set steps to the flow
|
1350 |
+
*
|
1351 |
+
* @param integer $flow_id Flow ID.
|
1352 |
+
* @param integer $new_step_id New step ID.
|
1353 |
+
* @param string $step_title Flow Type.
|
1354 |
+
* @param string $step_slug Flow Type.
|
1355 |
+
*/
|
1356 |
+
function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) {
|
1357 |
+
// Update steps for the current flow.
|
1358 |
+
$flow_steps = get_post_meta( $flow_id, 'wcf-steps', true );
|
1359 |
+
|
1360 |
+
if ( ! is_array( $flow_steps ) ) {
|
1361 |
+
$flow_steps = array();
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
$flow_steps[] = array(
|
1365 |
+
'id' => $new_step_id,
|
1366 |
+
'title' => $step_title,
|
1367 |
+
'type' => $step_slug,
|
1368 |
+
);
|
1369 |
+
update_post_meta( $flow_id, 'wcf-steps', $flow_steps );
|
1370 |
+
wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . json_encode( $flow_steps ) );
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
/**
|
1374 |
+
* Localize variables in admin
|
1375 |
+
*
|
1376 |
+
* @param array $vars variables.
|
1377 |
+
*/
|
1378 |
+
function localize_vars( $vars ) {
|
1379 |
+
|
1380 |
+
$ajax_actions = array(
|
1381 |
+
'cf_step_import',
|
1382 |
+
'cf_load_steps',
|
1383 |
+
'cf_create_flow',
|
1384 |
+
'cf_default_flow',
|
1385 |
+
'cf_step_create_blank',
|
1386 |
+
'cf_import_flow_step',
|
1387 |
+
);
|
1388 |
+
|
1389 |
+
foreach ( $ajax_actions as $action ) {
|
1390 |
+
|
1391 |
+
$vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) );
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
return $vars;
|
1395 |
+
}
|
1396 |
+
|
1397 |
+
/**
|
1398 |
+
* Ajax action to activate plugin
|
1399 |
+
*/
|
1400 |
+
public function activate_plugin() {
|
1401 |
+
|
1402 |
+
$plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( $_POST['plugin_init'] ) : '';
|
1403 |
+
|
1404 |
+
$activate = activate_plugin( $plugin_init, '', false, true );
|
1405 |
+
|
1406 |
+
if ( is_wp_error( $activate ) ) {
|
1407 |
+
wp_send_json_error(
|
1408 |
+
array(
|
1409 |
+
'success' => false,
|
1410 |
+
'message' => $activate->get_error_message(),
|
1411 |
+
'init' => $plugin_init,
|
1412 |
+
)
|
1413 |
+
);
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
wp_send_json_success(
|
1417 |
+
array(
|
1418 |
+
'success' => true,
|
1419 |
+
'message' => __( 'Plugin Successfully Activated', 'cartflows' ),
|
1420 |
+
'init' => $plugin_init,
|
1421 |
+
)
|
1422 |
+
);
|
1423 |
+
}
|
1424 |
+
|
1425 |
+
}
|
1426 |
+
|
1427 |
+
/**
|
1428 |
+
* Initialize class object with 'get_instance()' method
|
1429 |
+
*/
|
1430 |
+
CartFlows_Importer::get_instance();
|
1431 |
+
|
1432 |
+
endif;
|
classes/class-cartflows-loader.php
CHANGED
@@ -1,419 +1,419 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Loader.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class Cartflows_Loader.
|
12 |
-
*/
|
13 |
-
final class Cartflows_Loader {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Member Variable
|
17 |
-
*
|
18 |
-
* @var instance
|
19 |
-
*/
|
20 |
-
private static $instance = null;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Member Variable
|
24 |
-
*
|
25 |
-
* @var utils
|
26 |
-
*/
|
27 |
-
public $utils = null;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Member Variable
|
31 |
-
*
|
32 |
-
* @var logger
|
33 |
-
*/
|
34 |
-
public $logger = null;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Member Variable
|
38 |
-
*
|
39 |
-
* @var session
|
40 |
-
*/
|
41 |
-
public $session = null;
|
42 |
-
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Member Variable
|
46 |
-
*
|
47 |
-
* @var options
|
48 |
-
*/
|
49 |
-
public $options = null;
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Member Variable
|
53 |
-
*
|
54 |
-
* @var meta
|
55 |
-
*/
|
56 |
-
public $meta = null;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Member Variable
|
60 |
-
*
|
61 |
-
* @var flow
|
62 |
-
*/
|
63 |
-
public $flow = null;
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Initiator
|
67 |
-
*/
|
68 |
-
public static function get_instance() {
|
69 |
-
|
70 |
-
if ( is_null( self::$instance ) ) {
|
71 |
-
|
72 |
-
self::$instance = new self;
|
73 |
-
|
74 |
-
/**
|
75 |
-
* CartFlows loaded.
|
76 |
-
*
|
77 |
-
* Fires when Cartflows was fully loaded and instantiated.
|
78 |
-
*
|
79 |
-
* @since 1.0.0
|
80 |
-
*/
|
81 |
-
do_action( 'cartflows_loaded' );
|
82 |
-
}
|
83 |
-
|
84 |
-
return self::$instance;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Constructor
|
89 |
-
*/
|
90 |
-
public function __construct() {
|
91 |
-
|
92 |
-
$this->define_constants();
|
93 |
-
|
94 |
-
// Activation hook.
|
95 |
-
register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) );
|
96 |
-
|
97 |
-
// deActivation hook.
|
98 |
-
register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) );
|
99 |
-
|
100 |
-
add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 );
|
101 |
-
|
102 |
-
add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) );
|
103 |
-
|
104 |
-
// Update compatibility.
|
105 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* Defines all constants
|
110 |
-
*
|
111 |
-
* @since 1.0.0
|
112 |
-
*/
|
113 |
-
public function define_constants() {
|
114 |
-
|
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 |
-
|
122 |
-
define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' );
|
123 |
-
define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' );
|
124 |
-
|
125 |
-
if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) {
|
126 |
-
define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' );
|
127 |
-
}
|
128 |
-
define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' );
|
129 |
-
define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' );
|
130 |
-
define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' );
|
131 |
-
define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' );
|
132 |
-
|
133 |
-
if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) {
|
134 |
-
define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' );
|
135 |
-
}
|
136 |
-
if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER' ) ) {
|
137 |
-
define( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER', 'cartflows_flow_page_builder' );
|
138 |
-
}
|
139 |
-
if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) {
|
140 |
-
define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' );
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Loads plugin files.
|
146 |
-
*
|
147 |
-
* @since 1.0.0
|
148 |
-
*
|
149 |
-
* @return void
|
150 |
-
*/
|
151 |
-
function load_plugin() {
|
152 |
-
|
153 |
-
if ( ! function_exists( 'WC' ) ) {
|
154 |
-
add_action( 'admin_notices', array( $this, 'fails_to_load' ) );
|
155 |
-
return;
|
156 |
-
}
|
157 |
-
|
158 |
-
$this->load_helper_files_components();
|
159 |
-
$this->load_core_files();
|
160 |
-
$this->load_core_components();
|
161 |
-
|
162 |
-
/**
|
163 |
-
* CartFlows Init.
|
164 |
-
*
|
165 |
-
* Fires when Cartflows is instantiated.
|
166 |
-
*
|
167 |
-
* @since 1.0.0
|
168 |
-
*/
|
169 |
-
do_action( 'cartflows_init' );
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Load Helper Files and Components.
|
174 |
-
*
|
175 |
-
* @since 1.0.0
|
176 |
-
*
|
177 |
-
* @return void
|
178 |
-
*/
|
179 |
-
function load_helper_files_components() {
|
180 |
-
|
181 |
-
/* Public Utils */
|
182 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php';
|
183 |
-
|
184 |
-
/* Public Session */
|
185 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-session.php';
|
186 |
-
|
187 |
-
/* Public Global namespace functions */
|
188 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
|
189 |
-
|
190 |
-
/* Admin Helper */
|
191 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
|
192 |
-
|
193 |
-
/* Meta Default Values */
|
194 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php';
|
195 |
-
|
196 |
-
$this->utils = Cartflows_Utils::get_instance();
|
197 |
-
$this->session = Cartflows_Session::get_instance();
|
198 |
-
$this->options = Cartflows_Default_Meta::get_instance();
|
199 |
-
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Load Core Files.
|
204 |
-
*
|
205 |
-
* @since 1.0.0
|
206 |
-
*
|
207 |
-
* @return void
|
208 |
-
*/
|
209 |
-
function load_core_files() {
|
210 |
-
|
211 |
-
/* Page builder compatibilty class */
|
212 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php';
|
213 |
-
|
214 |
-
/* Admin Meta Fields*/
|
215 |
-
include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php';
|
216 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php';
|
217 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php';
|
218 |
-
|
219 |
-
/* Cloning */
|
220 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php';
|
221 |
-
|
222 |
-
/* Admin Settings */
|
223 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php';
|
224 |
-
|
225 |
-
/* Core Modules */
|
226 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php';
|
227 |
-
|
228 |
-
/* Frontend Global */
|
229 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php';
|
230 |
-
require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php';
|
231 |
-
|
232 |
-
/* Modules */
|
233 |
-
include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php';
|
234 |
-
include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php';
|
235 |
-
include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php';
|
236 |
-
include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php';
|
237 |
-
|
238 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php';
|
239 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php';
|
240 |
-
|
241 |
-
include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php';
|
242 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php';
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Load Core Components.
|
247 |
-
*
|
248 |
-
* @since 1.0.0
|
249 |
-
*
|
250 |
-
* @return void
|
251 |
-
*/
|
252 |
-
function load_core_components() {
|
253 |
-
|
254 |
-
$this->meta = Cartflows_Meta_Fields::get_instance();
|
255 |
-
$this->logger = Cartflows_Logger::get_instance();
|
256 |
-
$this->flow = Cartflows_Flow_Frontend::get_instance();
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
* Load CartFlows Pro Text Domain.
|
261 |
-
* This will load the translation textdomain depending on the file priorities.
|
262 |
-
* 1. Global Languages /wp-content/languages/cartflows/ folder
|
263 |
-
* 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder
|
264 |
-
*
|
265 |
-
* @since 1.0.3
|
266 |
-
* @return void
|
267 |
-
*/
|
268 |
-
public function load_cf_textdomain() {
|
269 |
-
|
270 |
-
// Default languages directory for CartFlows Pro.
|
271 |
-
$lang_dir = CARTFLOWS_DIR . 'languages/';
|
272 |
-
|
273 |
-
/**
|
274 |
-
* Filters the languages directory path to use for CartFlows Pro.
|
275 |
-
*
|
276 |
-
* @param string $lang_dir The languages directory path.
|
277 |
-
*/
|
278 |
-
$lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir );
|
279 |
-
|
280 |
-
// Traditional WordPress plugin locale filter.
|
281 |
-
global $wp_version;
|
282 |
-
|
283 |
-
$get_locale = get_locale();
|
284 |
-
|
285 |
-
if ( $wp_version >= 4.7 ) {
|
286 |
-
$get_locale = get_user_locale();
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Language Locale for CartFlows Pro
|
291 |
-
*
|
292 |
-
* @var $get_locale The locale to use.
|
293 |
-
* Uses get_user_locale()` in WordPress 4.7 or greater,
|
294 |
-
* otherwise uses `get_locale()`.
|
295 |
-
*/
|
296 |
-
$locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' );
|
297 |
-
$mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale );
|
298 |
-
|
299 |
-
// Setup paths to current locale file.
|
300 |
-
$mofile_local = $lang_dir . $mofile;
|
301 |
-
$mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
|
302 |
-
|
303 |
-
if ( file_exists( $mofile_global ) ) {
|
304 |
-
// Look in global /wp-content/languages/cartflows/ folder.
|
305 |
-
load_textdomain( 'cartflows', $mofile_global );
|
306 |
-
} elseif ( file_exists( $mofile_local ) ) {
|
307 |
-
// Look in local /wp-content/plugins/cartflows/languages/ folder.
|
308 |
-
load_textdomain( 'cartflows', $mofile_local );
|
309 |
-
} else {
|
310 |
-
// Load the default language files.
|
311 |
-
load_plugin_textdomain( 'cartflows', false, $lang_dir );
|
312 |
-
}
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Fires admin notice when Elementor is not installed and activated.
|
317 |
-
*
|
318 |
-
* @since 1.0.0
|
319 |
-
*
|
320 |
-
* @return void
|
321 |
-
*/
|
322 |
-
public function fails_to_load() {
|
323 |
-
|
324 |
-
$screen = get_current_screen();
|
325 |
-
|
326 |
-
if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
|
327 |
-
return;
|
328 |
-
}
|
329 |
-
|
330 |
-
$class = 'notice notice-error';
|
331 |
-
/* translators: %s: html tags */
|
332 |
-
$message = sprintf( __( 'The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '<strong>', '</strong>' );
|
333 |
-
|
334 |
-
$plugin = 'woocommerce/woocommerce.php';
|
335 |
-
|
336 |
-
if ( _is_woo_installed() ) {
|
337 |
-
if ( ! current_user_can( 'activate_plugins' ) ) {
|
338 |
-
return;
|
339 |
-
}
|
340 |
-
|
341 |
-
$action_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin );
|
342 |
-
$button_label = __( 'Activate WooCommerce', 'cartflows' );
|
343 |
-
|
344 |
-
} else {
|
345 |
-
if ( ! current_user_can( 'install_plugins' ) ) {
|
346 |
-
return;
|
347 |
-
}
|
348 |
-
|
349 |
-
$action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
|
350 |
-
$button_label = __( 'Install WooCommerce', 'cartflows' );
|
351 |
-
}
|
352 |
-
|
353 |
-
$button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
|
354 |
-
|
355 |
-
printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
|
356 |
-
}
|
357 |
-
|
358 |
-
/**
|
359 |
-
* Activation Reset
|
360 |
-
*/
|
361 |
-
function activation_reset() {
|
362 |
-
|
363 |
-
include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php';
|
364 |
-
include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php';
|
365 |
-
|
366 |
-
Cartflows_Flow_Post_Type::get_instance()->flow_post_type();
|
367 |
-
Cartflows_Step_Post_Type::get_instance()->step_post_type();
|
368 |
-
flush_rewrite_rules();
|
369 |
-
}
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Deactivation Reset
|
373 |
-
*/
|
374 |
-
function deactivation_reset() {
|
375 |
-
}
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Logger Class Instance
|
379 |
-
*/
|
380 |
-
function logger() {
|
381 |
-
return Cartflows_Logger::get_instance();
|
382 |
-
}
|
383 |
-
|
384 |
-
|
385 |
-
}
|
386 |
-
|
387 |
-
/**
|
388 |
-
* Prepare if class 'Cartflows_Loader' exist.
|
389 |
-
* Kicking this off by calling 'get_instance()' method
|
390 |
-
*/
|
391 |
-
Cartflows_Loader::get_instance();
|
392 |
-
}
|
393 |
-
|
394 |
-
/**
|
395 |
-
* Get global class.
|
396 |
-
*
|
397 |
-
* @return object
|
398 |
-
*/
|
399 |
-
function wcf() {
|
400 |
-
return Cartflows_Loader::get_instance();
|
401 |
-
}
|
402 |
-
|
403 |
-
if ( ! function_exists( '_is_woo_installed' ) ) {
|
404 |
-
|
405 |
-
/**
|
406 |
-
* Is woocommerce plugin installed.
|
407 |
-
*
|
408 |
-
* @since 1.0.0
|
409 |
-
*
|
410 |
-
* @access public
|
411 |
-
*/
|
412 |
-
function _is_woo_installed() {
|
413 |
-
|
414 |
-
$path = 'woocommerce/woocommerce.php';
|
415 |
-
$plugins = get_plugins();
|
416 |
-
|
417 |
-
return isset( $plugins[ $path ] );
|
418 |
-
}
|
419 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Loader.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Cartflows_Loader.
|
12 |
+
*/
|
13 |
+
final class Cartflows_Loader {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Member Variable
|
17 |
+
*
|
18 |
+
* @var instance
|
19 |
+
*/
|
20 |
+
private static $instance = null;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Member Variable
|
24 |
+
*
|
25 |
+
* @var utils
|
26 |
+
*/
|
27 |
+
public $utils = null;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Member Variable
|
31 |
+
*
|
32 |
+
* @var logger
|
33 |
+
*/
|
34 |
+
public $logger = null;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Member Variable
|
38 |
+
*
|
39 |
+
* @var session
|
40 |
+
*/
|
41 |
+
public $session = null;
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Member Variable
|
46 |
+
*
|
47 |
+
* @var options
|
48 |
+
*/
|
49 |
+
public $options = null;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Member Variable
|
53 |
+
*
|
54 |
+
* @var meta
|
55 |
+
*/
|
56 |
+
public $meta = null;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Member Variable
|
60 |
+
*
|
61 |
+
* @var flow
|
62 |
+
*/
|
63 |
+
public $flow = null;
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Initiator
|
67 |
+
*/
|
68 |
+
public static function get_instance() {
|
69 |
+
|
70 |
+
if ( is_null( self::$instance ) ) {
|
71 |
+
|
72 |
+
self::$instance = new self;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* CartFlows loaded.
|
76 |
+
*
|
77 |
+
* Fires when Cartflows was fully loaded and instantiated.
|
78 |
+
*
|
79 |
+
* @since 1.0.0
|
80 |
+
*/
|
81 |
+
do_action( 'cartflows_loaded' );
|
82 |
+
}
|
83 |
+
|
84 |
+
return self::$instance;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Constructor
|
89 |
+
*/
|
90 |
+
public function __construct() {
|
91 |
+
|
92 |
+
$this->define_constants();
|
93 |
+
|
94 |
+
// Activation hook.
|
95 |
+
register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) );
|
96 |
+
|
97 |
+
// deActivation hook.
|
98 |
+
register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) );
|
99 |
+
|
100 |
+
add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 );
|
101 |
+
|
102 |
+
add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) );
|
103 |
+
|
104 |
+
// Update compatibility.
|
105 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php';
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Defines all constants
|
110 |
+
*
|
111 |
+
* @since 1.0.0
|
112 |
+
*/
|
113 |
+
public function define_constants() {
|
114 |
+
|
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.5' );
|
119 |
+
define( 'CARTFLOWS_SLUG', 'cartflows' );
|
120 |
+
define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
|
121 |
+
|
122 |
+
define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' );
|
123 |
+
define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' );
|
124 |
+
|
125 |
+
if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) {
|
126 |
+
define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' );
|
127 |
+
}
|
128 |
+
define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' );
|
129 |
+
define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' );
|
130 |
+
define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' );
|
131 |
+
define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' );
|
132 |
+
|
133 |
+
if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) {
|
134 |
+
define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' );
|
135 |
+
}
|
136 |
+
if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER' ) ) {
|
137 |
+
define( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER', 'cartflows_flow_page_builder' );
|
138 |
+
}
|
139 |
+
if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) {
|
140 |
+
define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' );
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Loads plugin files.
|
146 |
+
*
|
147 |
+
* @since 1.0.0
|
148 |
+
*
|
149 |
+
* @return void
|
150 |
+
*/
|
151 |
+
function load_plugin() {
|
152 |
+
|
153 |
+
if ( ! function_exists( 'WC' ) ) {
|
154 |
+
add_action( 'admin_notices', array( $this, 'fails_to_load' ) );
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
|
158 |
+
$this->load_helper_files_components();
|
159 |
+
$this->load_core_files();
|
160 |
+
$this->load_core_components();
|
161 |
+
|
162 |
+
/**
|
163 |
+
* CartFlows Init.
|
164 |
+
*
|
165 |
+
* Fires when Cartflows is instantiated.
|
166 |
+
*
|
167 |
+
* @since 1.0.0
|
168 |
+
*/
|
169 |
+
do_action( 'cartflows_init' );
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Load Helper Files and Components.
|
174 |
+
*
|
175 |
+
* @since 1.0.0
|
176 |
+
*
|
177 |
+
* @return void
|
178 |
+
*/
|
179 |
+
function load_helper_files_components() {
|
180 |
+
|
181 |
+
/* Public Utils */
|
182 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php';
|
183 |
+
|
184 |
+
/* Public Session */
|
185 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-session.php';
|
186 |
+
|
187 |
+
/* Public Global namespace functions */
|
188 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php';
|
189 |
+
|
190 |
+
/* Admin Helper */
|
191 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php';
|
192 |
+
|
193 |
+
/* Meta Default Values */
|
194 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php';
|
195 |
+
|
196 |
+
$this->utils = Cartflows_Utils::get_instance();
|
197 |
+
$this->session = Cartflows_Session::get_instance();
|
198 |
+
$this->options = Cartflows_Default_Meta::get_instance();
|
199 |
+
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Load Core Files.
|
204 |
+
*
|
205 |
+
* @since 1.0.0
|
206 |
+
*
|
207 |
+
* @return void
|
208 |
+
*/
|
209 |
+
function load_core_files() {
|
210 |
+
|
211 |
+
/* Page builder compatibilty class */
|
212 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php';
|
213 |
+
|
214 |
+
/* Admin Meta Fields*/
|
215 |
+
include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php';
|
216 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php';
|
217 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php';
|
218 |
+
|
219 |
+
/* Cloning */
|
220 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php';
|
221 |
+
|
222 |
+
/* Admin Settings */
|
223 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php';
|
224 |
+
|
225 |
+
/* Core Modules */
|
226 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php';
|
227 |
+
|
228 |
+
/* Frontend Global */
|
229 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php';
|
230 |
+
require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php';
|
231 |
+
|
232 |
+
/* Modules */
|
233 |
+
include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php';
|
234 |
+
include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php';
|
235 |
+
include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php';
|
236 |
+
include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php';
|
237 |
+
|
238 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php';
|
239 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php';
|
240 |
+
|
241 |
+
include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php';
|
242 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php';
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Load Core Components.
|
247 |
+
*
|
248 |
+
* @since 1.0.0
|
249 |
+
*
|
250 |
+
* @return void
|
251 |
+
*/
|
252 |
+
function load_core_components() {
|
253 |
+
|
254 |
+
$this->meta = Cartflows_Meta_Fields::get_instance();
|
255 |
+
$this->logger = Cartflows_Logger::get_instance();
|
256 |
+
$this->flow = Cartflows_Flow_Frontend::get_instance();
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Load CartFlows Pro Text Domain.
|
261 |
+
* This will load the translation textdomain depending on the file priorities.
|
262 |
+
* 1. Global Languages /wp-content/languages/cartflows/ folder
|
263 |
+
* 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder
|
264 |
+
*
|
265 |
+
* @since 1.0.3
|
266 |
+
* @return void
|
267 |
+
*/
|
268 |
+
public function load_cf_textdomain() {
|
269 |
+
|
270 |
+
// Default languages directory for CartFlows Pro.
|
271 |
+
$lang_dir = CARTFLOWS_DIR . 'languages/';
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Filters the languages directory path to use for CartFlows Pro.
|
275 |
+
*
|
276 |
+
* @param string $lang_dir The languages directory path.
|
277 |
+
*/
|
278 |
+
$lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir );
|
279 |
+
|
280 |
+
// Traditional WordPress plugin locale filter.
|
281 |
+
global $wp_version;
|
282 |
+
|
283 |
+
$get_locale = get_locale();
|
284 |
+
|
285 |
+
if ( $wp_version >= 4.7 ) {
|
286 |
+
$get_locale = get_user_locale();
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Language Locale for CartFlows Pro
|
291 |
+
*
|
292 |
+
* @var $get_locale The locale to use.
|
293 |
+
* Uses get_user_locale()` in WordPress 4.7 or greater,
|
294 |
+
* otherwise uses `get_locale()`.
|
295 |
+
*/
|
296 |
+
$locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' );
|
297 |
+
$mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale );
|
298 |
+
|
299 |
+
// Setup paths to current locale file.
|
300 |
+
$mofile_local = $lang_dir . $mofile;
|
301 |
+
$mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
|
302 |
+
|
303 |
+
if ( file_exists( $mofile_global ) ) {
|
304 |
+
// Look in global /wp-content/languages/cartflows/ folder.
|
305 |
+
load_textdomain( 'cartflows', $mofile_global );
|
306 |
+
} elseif ( file_exists( $mofile_local ) ) {
|
307 |
+
// Look in local /wp-content/plugins/cartflows/languages/ folder.
|
308 |
+
load_textdomain( 'cartflows', $mofile_local );
|
309 |
+
} else {
|
310 |
+
// Load the default language files.
|
311 |
+
load_plugin_textdomain( 'cartflows', false, $lang_dir );
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Fires admin notice when Elementor is not installed and activated.
|
317 |
+
*
|
318 |
+
* @since 1.0.0
|
319 |
+
*
|
320 |
+
* @return void
|
321 |
+
*/
|
322 |
+
public function fails_to_load() {
|
323 |
+
|
324 |
+
$screen = get_current_screen();
|
325 |
+
|
326 |
+
if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
|
327 |
+
return;
|
328 |
+
}
|
329 |
+
|
330 |
+
$class = 'notice notice-error';
|
331 |
+
/* translators: %s: html tags */
|
332 |
+
$message = sprintf( __( 'The %1$sCartFlows%2$s plugin requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '<strong>', '</strong>' );
|
333 |
+
|
334 |
+
$plugin = 'woocommerce/woocommerce.php';
|
335 |
+
|
336 |
+
if ( _is_woo_installed() ) {
|
337 |
+
if ( ! current_user_can( 'activate_plugins' ) ) {
|
338 |
+
return;
|
339 |
+
}
|
340 |
+
|
341 |
+
$action_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin );
|
342 |
+
$button_label = __( 'Activate WooCommerce', 'cartflows' );
|
343 |
+
|
344 |
+
} else {
|
345 |
+
if ( ! current_user_can( 'install_plugins' ) ) {
|
346 |
+
return;
|
347 |
+
}
|
348 |
+
|
349 |
+
$action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' );
|
350 |
+
$button_label = __( 'Install WooCommerce', 'cartflows' );
|
351 |
+
}
|
352 |
+
|
353 |
+
$button = '<p><a href="' . $action_url . '" class="button-primary">' . $button_label . '</a></p><p></p>';
|
354 |
+
|
355 |
+
printf( '<div class="%1$s"><p>%2$s</p>%3$s</div>', esc_attr( $class ), $message, $button );
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Activation Reset
|
360 |
+
*/
|
361 |
+
function activation_reset() {
|
362 |
+
|
363 |
+
include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php';
|
364 |
+
include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php';
|
365 |
+
|
366 |
+
Cartflows_Flow_Post_Type::get_instance()->flow_post_type();
|
367 |
+
Cartflows_Step_Post_Type::get_instance()->step_post_type();
|
368 |
+
flush_rewrite_rules();
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Deactivation Reset
|
373 |
+
*/
|
374 |
+
function deactivation_reset() {
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Logger Class Instance
|
379 |
+
*/
|
380 |
+
function logger() {
|
381 |
+
return Cartflows_Logger::get_instance();
|
382 |
+
}
|
383 |
+
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Prepare if class 'Cartflows_Loader' exist.
|
389 |
+
* Kicking this off by calling 'get_instance()' method
|
390 |
+
*/
|
391 |
+
Cartflows_Loader::get_instance();
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Get global class.
|
396 |
+
*
|
397 |
+
* @return object
|
398 |
+
*/
|
399 |
+
function wcf() {
|
400 |
+
return Cartflows_Loader::get_instance();
|
401 |
+
}
|
402 |
+
|
403 |
+
if ( ! function_exists( '_is_woo_installed' ) ) {
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Is woocommerce plugin installed.
|
407 |
+
*
|
408 |
+
* @since 1.0.0
|
409 |
+
*
|
410 |
+
* @access public
|
411 |
+
*/
|
412 |
+
function _is_woo_installed() {
|
413 |
+
|
414 |
+
$path = 'woocommerce/woocommerce.php';
|
415 |
+
$plugins = get_plugins();
|
416 |
+
|
417 |
+
return isset( $plugins[ $path ] );
|
418 |
+
}
|
419 |
+
}
|
includes/admin/cartflows-general.php
CHANGED
@@ -1,142 +1,142 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* General settings
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
$settings = Cartflows_Helper::get_common_settings();
|
9 |
-
|
10 |
-
?>
|
11 |
-
|
12 |
-
<form method="post" class="wrap wcf-clear" action="" >
|
13 |
-
<div class="wrap wcf-addon-wrap wcf-clear wcf-container">
|
14 |
-
<input type="hidden" name="action" value="wcf_save_common_settings">
|
15 |
-
<h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
|
16 |
-
|
17 |
-
<div id="poststuff">
|
18 |
-
<div id="post-body" class="columns-2">
|
19 |
-
<div id="post-body-content">
|
20 |
-
<div class="postbox introduction">
|
21 |
-
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
22 |
-
<span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
|
23 |
-
</h2>
|
24 |
-
<div class="inside">
|
25 |
-
<div class="iframe-wrap">
|
26 |
-
<iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
27 |
-
</div>
|
28 |
-
<p>
|
29 |
-
<?php
|
30 |
-
esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
|
31 |
-
?>
|
32 |
-
</p>
|
33 |
-
</div>
|
34 |
-
</div>
|
35 |
-
|
36 |
-
<div class="general-settings-form postbox">
|
37 |
-
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
38 |
-
<span><?php _e( 'General Settings', 'cartflows' ); ?></span>
|
39 |
-
</h2>
|
40 |
-
<div class="inside">
|
41 |
-
<div class="form-wrap">
|
42 |
-
<?php
|
43 |
-
|
44 |
-
do_action( 'cartflows_before_settings_fields', $settings );
|
45 |
-
|
46 |
-
echo Cartflows_Admin_Fields::checkobox_field(
|
47 |
-
array(
|
48 |
-
'id' => 'wcf_disallow_indexing',
|
49 |
-
'name' => '_cartflows_common[disallow_indexing]',
|
50 |
-
'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
|
51 |
-
'value' => $settings['disallow_indexing'],
|
52 |
-
)
|
53 |
-
);
|
54 |
-
echo Cartflows_Admin_Fields::flow_checkout_selection_field(
|
55 |
-
array(
|
56 |
-
'id' => 'wcf_global_checkout',
|
57 |
-
'name' => '_cartflows_common[global_checkout]',
|
58 |
-
'title' => __( 'Global Checkout', 'cartflows' ),
|
59 |
-
'value' => $settings['global_checkout'],
|
60 |
-
)
|
61 |
-
);
|
62 |
-
|
63 |
-
echo Cartflows_Admin_Fields::select_field(
|
64 |
-
array(
|
65 |
-
'id' => 'wcf_default_page_builder',
|
66 |
-
'name' => '_cartflows_common[default_page_builder]',
|
67 |
-
'title' => __( 'Show Templates designed with', 'cartflows' ),
|
68 |
-
'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
|
69 |
-
'value' => $settings['default_page_builder'],
|
70 |
-
'options' => array(
|
71 |
-
'elementor' => __( 'Elementor', 'cartflows' ),
|
72 |
-
'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
|
73 |
-
'other' => __( 'Other', 'cartflows' ),
|
74 |
-
),
|
75 |
-
)
|
76 |
-
);
|
77 |
-
|
78 |
-
do_action( 'cartflows_after_settings_fields', $settings );
|
79 |
-
|
80 |
-
?>
|
81 |
-
</div>
|
82 |
-
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
|
83 |
-
<?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
|
84 |
-
</div>
|
85 |
-
</div>
|
86 |
-
</div>
|
87 |
-
<div class="postbox-container" id="postbox-container-1">
|
88 |
-
<div id="side-sortables">
|
89 |
-
|
90 |
-
<div class="postbox">
|
91 |
-
<h2 class="hndle">
|
92 |
-
<span class="dashicons dashicons-book"></span>
|
93 |
-
<span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
|
94 |
-
</h2>
|
95 |
-
<div class="inside">
|
96 |
-
<p>
|
97 |
-
<?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
|
98 |
-
</p>
|
99 |
-
<p>
|
100 |
-
<a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
|
101 |
-
</p>
|
102 |
-
</div>
|
103 |
-
</div>
|
104 |
-
|
105 |
-
<div class="postbox">
|
106 |
-
<h2 class="hndle">
|
107 |
-
<span class="dashicons dashicons-groups"></span>
|
108 |
-
<span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
|
109 |
-
</h2>
|
110 |
-
<div class="inside">
|
111 |
-
<p>
|
112 |
-
<?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
|
113 |
-
</p>
|
114 |
-
<p>
|
115 |
-
<a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
|
116 |
-
</p>
|
117 |
-
</div>
|
118 |
-
</div>
|
119 |
-
|
120 |
-
<div class="postbox">
|
121 |
-
<h2 class="hndle">
|
122 |
-
<span class="dashicons dashicons-sos"></span>
|
123 |
-
<span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
|
124 |
-
</h2>
|
125 |
-
<div class="inside">
|
126 |
-
<p>
|
127 |
-
<?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
|
128 |
-
</p>
|
129 |
-
<p>
|
130 |
-
<a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
|
131 |
-
</p>
|
132 |
-
</div>
|
133 |
-
</div>
|
134 |
-
|
135 |
-
</div>
|
136 |
-
</div>
|
137 |
-
</div>
|
138 |
-
<!-- /post-body -->
|
139 |
-
<br class="clear">
|
140 |
-
</div>
|
141 |
-
</div>
|
142 |
-
</form>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* General settings
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
$settings = Cartflows_Helper::get_common_settings();
|
9 |
+
|
10 |
+
?>
|
11 |
+
|
12 |
+
<form method="post" class="wrap wcf-clear" action="" >
|
13 |
+
<div class="wrap wcf-addon-wrap wcf-clear wcf-container">
|
14 |
+
<input type="hidden" name="action" value="wcf_save_common_settings">
|
15 |
+
<h1 class="screen-reader-text"><?php _e( 'General Settings', 'cartflows' ); ?></h1>
|
16 |
+
|
17 |
+
<div id="poststuff">
|
18 |
+
<div id="post-body" class="columns-2">
|
19 |
+
<div id="post-body-content">
|
20 |
+
<div class="postbox introduction">
|
21 |
+
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
22 |
+
<span><?php _e( 'Getting Started', 'cartflows' ); ?></span>
|
23 |
+
</h2>
|
24 |
+
<div class="inside">
|
25 |
+
<div class="iframe-wrap">
|
26 |
+
<iframe width="560" height="315" src="https://www.youtube.com/embed/SlE0moPKjMY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
27 |
+
</div>
|
28 |
+
<p>
|
29 |
+
<?php
|
30 |
+
esc_attr_e( 'Modernizing WordPress eCommerce!', 'cartflows' );
|
31 |
+
?>
|
32 |
+
</p>
|
33 |
+
</div>
|
34 |
+
</div>
|
35 |
+
|
36 |
+
<div class="general-settings-form postbox">
|
37 |
+
<h2 class="hndle wcf-normal-cusror ui-sortable-handle">
|
38 |
+
<span><?php _e( 'General Settings', 'cartflows' ); ?></span>
|
39 |
+
</h2>
|
40 |
+
<div class="inside">
|
41 |
+
<div class="form-wrap">
|
42 |
+
<?php
|
43 |
+
|
44 |
+
do_action( 'cartflows_before_settings_fields', $settings );
|
45 |
+
|
46 |
+
echo Cartflows_Admin_Fields::checkobox_field(
|
47 |
+
array(
|
48 |
+
'id' => 'wcf_disallow_indexing',
|
49 |
+
'name' => '_cartflows_common[disallow_indexing]',
|
50 |
+
'title' => __( 'Disallow search engines from indexing flows', 'cartflows' ),
|
51 |
+
'value' => $settings['disallow_indexing'],
|
52 |
+
)
|
53 |
+
);
|
54 |
+
echo Cartflows_Admin_Fields::flow_checkout_selection_field(
|
55 |
+
array(
|
56 |
+
'id' => 'wcf_global_checkout',
|
57 |
+
'name' => '_cartflows_common[global_checkout]',
|
58 |
+
'title' => __( 'Global Checkout', 'cartflows' ),
|
59 |
+
'value' => $settings['global_checkout'],
|
60 |
+
)
|
61 |
+
);
|
62 |
+
|
63 |
+
echo Cartflows_Admin_Fields::select_field(
|
64 |
+
array(
|
65 |
+
'id' => 'wcf_default_page_builder',
|
66 |
+
'name' => '_cartflows_common[default_page_builder]',
|
67 |
+
'title' => __( 'Show Templates designed with', 'cartflows' ),
|
68 |
+
'description' => __( 'CartFlows offers flow templates that can be imported in one click. These templates are available in few different page builders. Please choose your preferred page builder from the list so you will only see templates that are made using that page builder..', 'cartflows' ),
|
69 |
+
'value' => $settings['default_page_builder'],
|
70 |
+
'options' => array(
|
71 |
+
'elementor' => __( 'Elementor', 'cartflows' ),
|
72 |
+
'beaver-builder' => __( 'Beaver Builder', 'cartflows' ),
|
73 |
+
'other' => __( 'Other', 'cartflows' ),
|
74 |
+
),
|
75 |
+
)
|
76 |
+
);
|
77 |
+
|
78 |
+
do_action( 'cartflows_after_settings_fields', $settings );
|
79 |
+
|
80 |
+
?>
|
81 |
+
</div>
|
82 |
+
<?php submit_button( __( 'Save Changes', 'cartflows' ), 'cartflows-common-setting-save-btn button-primary button', 'submit', false ); ?>
|
83 |
+
<?php wp_nonce_field( 'cartflows-common-settings', 'cartflows-common-settings-nonce' ); ?>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
</div>
|
87 |
+
<div class="postbox-container" id="postbox-container-1">
|
88 |
+
<div id="side-sortables">
|
89 |
+
|
90 |
+
<div class="postbox">
|
91 |
+
<h2 class="hndle">
|
92 |
+
<span class="dashicons dashicons-book"></span>
|
93 |
+
<span><?php esc_html_e( 'Knowledge Base', 'cartflows' ); ?></span>
|
94 |
+
</h2>
|
95 |
+
<div class="inside">
|
96 |
+
<p>
|
97 |
+
<?php esc_html_e( 'Not sure how something works? Take a peek at the knowledge base and learn.', 'cartflows' ); ?>
|
98 |
+
</p>
|
99 |
+
<p>
|
100 |
+
<a href="<?php echo esc_url( 'https://cartflows.com/docs' ); ?>" target="_blank" rel="noopener"><?php _e( 'Visit Knowledge Base »', 'cartflows' ); ?></a>
|
101 |
+
</p>
|
102 |
+
</div>
|
103 |
+
</div>
|
104 |
+
|
105 |
+
<div class="postbox">
|
106 |
+
<h2 class="hndle">
|
107 |
+
<span class="dashicons dashicons-groups"></span>
|
108 |
+
<span><?php esc_html_e( 'Community', 'cartflows' ); ?></span>
|
109 |
+
</h2>
|
110 |
+
<div class="inside">
|
111 |
+
<p>
|
112 |
+
<?php esc_html_e( 'Join the community of super helpful CartFlows users. Say hello, ask questions, give feedback and help each other!', 'cartflows' ); ?>
|
113 |
+
</p>
|
114 |
+
<p>
|
115 |
+
<a href="<?php echo esc_url( 'https://www.facebook.com/groups/cartflows/' ); ?>" target="_blank" rel="noopener"><?php _e( 'Join Our Facebook Group »', 'cartflows' ); ?></a>
|
116 |
+
</p>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
|
120 |
+
<div class="postbox">
|
121 |
+
<h2 class="hndle">
|
122 |
+
<span class="dashicons dashicons-sos"></span>
|
123 |
+
<span><?php esc_html_e( 'Five Star Support', 'cartflows' ); ?></span>
|
124 |
+
</h2>
|
125 |
+
<div class="inside">
|
126 |
+
<p>
|
127 |
+
<?php esc_html_e( 'Got a question? Get in touch with CartFlows developers. We\'re happy to help!', 'cartflows' ); ?>
|
128 |
+
</p>
|
129 |
+
<p>
|
130 |
+
<a href="<?php echo esc_url( 'https://cartflows.com/contact' ); ?>" target="_blank" rel="noopener"><?php _e( 'Submit a Ticket »', 'cartflows' ); ?></a>
|
131 |
+
</p>
|
132 |
+
</div>
|
133 |
+
</div>
|
134 |
+
|
135 |
+
</div>
|
136 |
+
</div>
|
137 |
+
</div>
|
138 |
+
<!-- /post-body -->
|
139 |
+
<br class="clear">
|
140 |
+
</div>
|
141 |
+
</div>
|
142 |
+
</form>
|
languages/cartflows.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the CartFlows package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: CartFlows 1.1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
|
7 |
-
"POT-Creation-Date: 2019-01-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -197,50 +197,67 @@ msgstr ""
|
|
197 |
msgid "Create"
|
198 |
msgstr ""
|
199 |
|
200 |
-
#: classes/class-cartflows-importer.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
msgid "All"
|
202 |
msgstr ""
|
203 |
|
204 |
-
#: classes/class-cartflows-importer.php:
|
205 |
msgid "Select Step Type"
|
206 |
msgstr ""
|
207 |
|
208 |
-
#: classes/class-cartflows-importer.php:
|
209 |
msgid "Import from Cloud"
|
210 |
msgstr ""
|
211 |
|
212 |
-
#: classes/class-cartflows-importer.php:
|
213 |
#: modules/flow/classes/class-cartflows-flow-meta.php:224
|
214 |
msgid "Landing Page"
|
215 |
msgstr ""
|
216 |
|
217 |
-
#: classes/class-cartflows-importer.php:
|
218 |
#: modules/flow/classes/class-cartflows-flow-meta.php:225
|
219 |
msgid "Checkout Page"
|
220 |
msgstr ""
|
221 |
|
222 |
-
#: classes/class-cartflows-importer.php:
|
223 |
#: modules/flow/classes/class-cartflows-flow-meta.php:226
|
224 |
msgid "Thank You Page"
|
225 |
msgstr ""
|
226 |
|
227 |
-
#: classes/class-cartflows-importer.php:
|
228 |
#. translators: %s: template ID
|
229 |
msgid "Invalid template id %1$s or post id %2$s."
|
230 |
msgstr ""
|
231 |
|
232 |
-
#: classes/class-cartflows-importer.php:
|
233 |
#. translators: %s: flow ID
|
234 |
msgid "Invalid flow id %1$s OR step type %2$s."
|
235 |
msgstr ""
|
236 |
|
237 |
-
#: classes/class-cartflows-importer.php:
|
238 |
msgid ""
|
239 |
"Elementor is not activated. Please activate plugin Elementor Page Builder "
|
240 |
"to import the step."
|
241 |
msgstr ""
|
242 |
|
243 |
-
#: classes/class-cartflows-importer.php:
|
244 |
msgid "Plugin Successfully Activated"
|
245 |
msgstr ""
|
246 |
|
@@ -539,11 +556,11 @@ msgstr ""
|
|
539 |
msgid "This product can't be purcahsed"
|
540 |
msgstr ""
|
541 |
|
542 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
543 |
msgid "Coupon Code"
|
544 |
msgstr ""
|
545 |
|
546 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
547 |
msgid "Apply"
|
548 |
msgstr ""
|
549 |
|
2 |
# This file is distributed under the same license as the CartFlows package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: CartFlows 1.1.5\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
|
7 |
+
"POT-Creation-Date: 2019-01-23 11:14:41+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
197 |
msgid "Create"
|
198 |
msgstr ""
|
199 |
|
200 |
+
#: classes/class-cartflows-importer.php:632
|
201 |
+
msgid "Under Maintenance.."
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: classes/class-cartflows-importer.php:633
|
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:634
|
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:665
|
218 |
msgid "All"
|
219 |
msgstr ""
|
220 |
|
221 |
+
#: classes/class-cartflows-importer.php:668
|
222 |
msgid "Select Step Type"
|
223 |
msgstr ""
|
224 |
|
225 |
+
#: classes/class-cartflows-importer.php:745
|
226 |
msgid "Import from Cloud"
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: classes/class-cartflows-importer.php:1031
|
230 |
#: modules/flow/classes/class-cartflows-flow-meta.php:224
|
231 |
msgid "Landing Page"
|
232 |
msgstr ""
|
233 |
|
234 |
+
#: classes/class-cartflows-importer.php:1032
|
235 |
#: modules/flow/classes/class-cartflows-flow-meta.php:225
|
236 |
msgid "Checkout Page"
|
237 |
msgstr ""
|
238 |
|
239 |
+
#: classes/class-cartflows-importer.php:1033
|
240 |
#: modules/flow/classes/class-cartflows-flow-meta.php:226
|
241 |
msgid "Thank You Page"
|
242 |
msgstr ""
|
243 |
|
244 |
+
#: classes/class-cartflows-importer.php:1138
|
245 |
#. translators: %s: template ID
|
246 |
msgid "Invalid template id %1$s or post id %2$s."
|
247 |
msgstr ""
|
248 |
|
249 |
+
#: classes/class-cartflows-importer.php:1180
|
250 |
#. translators: %s: flow ID
|
251 |
msgid "Invalid flow id %1$s OR step type %2$s."
|
252 |
msgstr ""
|
253 |
|
254 |
+
#: classes/class-cartflows-importer.php:1301
|
255 |
msgid ""
|
256 |
"Elementor is not activated. Please activate plugin Elementor Page Builder "
|
257 |
"to import the step."
|
258 |
msgstr ""
|
259 |
|
260 |
+
#: classes/class-cartflows-importer.php:1419
|
261 |
msgid "Plugin Successfully Activated"
|
262 |
msgstr ""
|
263 |
|
556 |
msgid "This product can't be purcahsed"
|
557 |
msgstr ""
|
558 |
|
559 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:920
|
560 |
msgid "Coupon Code"
|
561 |
msgstr ""
|
562 |
|
563 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:929
|
564 |
msgid "Apply"
|
565 |
msgstr ""
|
566 |
|
modules/checkout/classes/class-cartflows-checkout-markup.php
CHANGED
@@ -1,1021 +1,1033 @@
|
|
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', '
|
44 |
-
|
45 |
-
/* Checkout Shortcode */
|
46 |
-
add_shortcode( 'cartflows_checkout', array( $this, 'checkout_shortcode_markup' ) );
|
47 |
-
|
48 |
-
/* Preconfigured cart data */
|
49 |
-
add_action( 'wp', array( $this, 'preconfigured_cart_data' ), 1 );
|
50 |
-
|
51 |
-
/* Embed Checkout */
|
52 |
-
add_action( 'wp', array( $this, 'shortcode_load_data' ), 999 );
|
53 |
-
|
54 |
-
/* Ajax Endpoint */
|
55 |
-
add_filter( 'woocommerce_ajax_get_endpoint', array( $this, 'get_ajax_endpoint' ) );
|
56 |
-
|
57 |
-
add_filter( 'cartflows_add_before_main_section', array( $this, 'enable_logo_in_header' ) );
|
58 |
-
|
59 |
-
add_filter( 'cartflows_primary_container_bottom', array( $this, 'show_cartflows_copyright_message' ) );
|
60 |
-
|
61 |
-
add_filter( 'woocommerce_login_redirect', array( $this, 'after_login_redirect' ), 10, 2 );
|
62 |
-
|
63 |
-
add_action( 'wp_ajax_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
|
64 |
-
add_action( 'wp_ajax_nopriv_cf_woo_apply_coupon', array( $this, 'apply_coupon' ) );
|
65 |
-
|
66 |
-
add_filter( 'global_cartflows_js_localize', array( $this, 'add_localize_vars' ) );
|
67 |
-
|
68 |
-
/* Global Checkout */
|
69 |
-
add_action( 'template_redirect', array( $this, 'global_checkout_template_redirect' ), 1 );
|
70 |
-
}
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
*
|
75 |
-
*
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
if (
|
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 |
-
|
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 |
-
array(
|
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 |
-
add_action( '
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
add_action( '
|
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 |
-
.wcf-embed-checkout-form .
|
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 |
-
.wcf-embed-checkout-form
|
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 |
-
.woocommerce
|
653 |
-
|
654 |
-
|
655 |
-
.wcf-embed-checkout-form .woocommerce
|
656 |
-
.wcf-embed-checkout-form .woocommerce
|
657 |
-
|
658 |
-
background-color: {$
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
}
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
color: {$
|
671 |
-
}
|
672 |
-
.wcf-embed-checkout-form
|
673 |
-
color: {$
|
674 |
-
}
|
675 |
-
.wcf-embed-checkout-form
|
676 |
-
color: {$field_color};
|
677 |
-
}
|
678 |
-
.wcf-embed-checkout-form
|
679 |
-
color: {$
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
font-family: {$
|
693 |
-
font-weight: {$
|
694 |
-
}
|
695 |
-
.wcf-embed-checkout-form .woocommerce
|
696 |
-
|
697 |
-
background: {$submit_bg_color};
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
.wcf-embed-checkout-form .woocommerce
|
708 |
-
|
709 |
-
background
|
710 |
-
border
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
.wcf-embed-checkout-form .woocommerce-
|
720 |
-
|
721 |
-
color: {$
|
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 |
-
foreach ( $
|
798 |
-
|
799 |
-
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
800 |
-
|
801 |
-
if ( isset( $_POST[ $field ] ) ) {
|
802 |
-
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
803 |
-
}
|
804 |
-
}
|
805 |
-
}
|
806 |
-
|
807 |
-
|
808 |
-
|
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 |
-
* @param array $
|
961 |
-
*/
|
962 |
-
function
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_order_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 |
+
return;
|
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 |
+
/* Show notices if cart has errors */
|
372 |
+
add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
|
373 |
+
|
374 |
+
add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
|
375 |
+
|
376 |
+
add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
|
377 |
+
|
378 |
+
// Outputting the hidden field in checkout page.
|
379 |
+
add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
380 |
+
add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
381 |
+
|
382 |
+
remove_all_actions( 'woocommerce_checkout_billing' );
|
383 |
+
remove_all_actions( 'woocommerce_checkout_shipping' );
|
384 |
+
|
385 |
+
// Hook in actions once.
|
386 |
+
add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
|
387 |
+
add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
|
388 |
+
|
389 |
+
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
|
390 |
+
|
391 |
+
add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
|
392 |
+
|
393 |
+
add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
|
394 |
+
|
395 |
+
global $post;
|
396 |
+
|
397 |
+
if ( _is_wcf_checkout_type() ) {
|
398 |
+
$checkout_id = $post->ID;
|
399 |
+
} else {
|
400 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
401 |
+
}
|
402 |
+
|
403 |
+
do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Render checkout ID hidden field.
|
409 |
+
*
|
410 |
+
* @param array $checkout checkout session data.
|
411 |
+
* @return void
|
412 |
+
*/
|
413 |
+
function checkout_shortcode_post_id( $checkout ) {
|
414 |
+
|
415 |
+
global $post;
|
416 |
+
|
417 |
+
if ( _is_wcf_checkout_type() ) {
|
418 |
+
$checkout_id = $post->ID;
|
419 |
+
} else {
|
420 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
421 |
+
}
|
422 |
+
|
423 |
+
$flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
|
424 |
+
|
425 |
+
echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
|
426 |
+
echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Load shortcode scripts.
|
431 |
+
*
|
432 |
+
* @return void
|
433 |
+
*/
|
434 |
+
function shortcode_scripts() {
|
435 |
+
|
436 |
+
wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
|
437 |
+
wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
|
438 |
+
|
439 |
+
if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
|
440 |
+
wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
|
441 |
+
wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
|
442 |
+
}
|
443 |
+
|
444 |
+
wp_enqueue_script(
|
445 |
+
'wcf-checkout-template',
|
446 |
+
CARTFLOWS_URL . 'assets/js/checkout-template.js',
|
447 |
+
array( 'jquery' ),
|
448 |
+
CARTFLOWS_VER,
|
449 |
+
true
|
450 |
+
);
|
451 |
+
|
452 |
+
do_action( 'cartflows_checkout_scripts' );
|
453 |
+
|
454 |
+
$style = $this->generate_style();
|
455 |
+
|
456 |
+
wp_add_inline_style( 'wcf-checkout-template', $style );
|
457 |
+
|
458 |
+
}
|
459 |
+
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Generate styles.
|
463 |
+
*
|
464 |
+
* @return string
|
465 |
+
*/
|
466 |
+
function generate_style() {
|
467 |
+
|
468 |
+
global $post;
|
469 |
+
|
470 |
+
if ( _is_wcf_checkout_type() ) {
|
471 |
+
$checkout_id = $post->ID;
|
472 |
+
} else {
|
473 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
474 |
+
}
|
475 |
+
|
476 |
+
CartFlows_Font_Families::render_fonts( $checkout_id );
|
477 |
+
|
478 |
+
$primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
|
479 |
+
|
480 |
+
$base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
|
481 |
+
|
482 |
+
$header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
|
483 |
+
|
484 |
+
/*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
|
485 |
+
$r = '';
|
486 |
+
$g = '';
|
487 |
+
$b = '';
|
488 |
+
|
489 |
+
$field_tb_padding = '';
|
490 |
+
$field_lr_padding = '';
|
491 |
+
|
492 |
+
$field_heading_color = '';
|
493 |
+
$field_color = '';
|
494 |
+
$field_bg_color = '';
|
495 |
+
$field_border_color = '';
|
496 |
+
$field_label_color = '';
|
497 |
+
$submit_tb_padding = '';
|
498 |
+
$submit_lr_padding = '';
|
499 |
+
$hl_bg_color = '';
|
500 |
+
$field_input_size = '';
|
501 |
+
$box_border_color = '';
|
502 |
+
$section_bg_color = '';
|
503 |
+
$submit_button_height = '';
|
504 |
+
$submit_color = '';
|
505 |
+
$submit_bg_color = $primary_color;
|
506 |
+
$submit_border_color = $primary_color;
|
507 |
+
|
508 |
+
$submit_hover_color = '';
|
509 |
+
$submit_bg_hover_color = $primary_color;
|
510 |
+
$submit_border_hover_color = $primary_color;
|
511 |
+
|
512 |
+
$section_heading_color = '';
|
513 |
+
|
514 |
+
$is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
|
515 |
+
|
516 |
+
$button_font_family = '';
|
517 |
+
$button_font_weight = '';
|
518 |
+
$input_font_family = '';
|
519 |
+
$input_font_weight = '';
|
520 |
+
$heading_font_family = '';
|
521 |
+
$heading_font_weight = '';
|
522 |
+
$base_font_family = $base_font_family;
|
523 |
+
/*$base_font_weight = $base_font_weight;*/
|
524 |
+
|
525 |
+
if ( 'yes' == $is_advance_option ) {
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Get Font Family and Font Weight weight values
|
529 |
+
*/
|
530 |
+
$section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
|
531 |
+
|
532 |
+
$heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
|
533 |
+
$heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
|
534 |
+
$section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
|
535 |
+
$button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
|
536 |
+
$button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
|
537 |
+
$input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
|
538 |
+
$input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
|
539 |
+
$field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
|
540 |
+
$field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
|
541 |
+
$field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
|
542 |
+
|
543 |
+
$field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
|
544 |
+
|
545 |
+
$field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
|
546 |
+
|
547 |
+
$field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
|
548 |
+
|
549 |
+
$field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
|
550 |
+
|
551 |
+
$field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
|
552 |
+
|
553 |
+
$submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
|
554 |
+
|
555 |
+
$submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
|
556 |
+
|
557 |
+
$submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
|
558 |
+
|
559 |
+
$submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
|
560 |
+
|
561 |
+
$submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
|
562 |
+
|
563 |
+
$submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
|
564 |
+
|
565 |
+
$submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
|
566 |
+
|
567 |
+
$submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
|
568 |
+
|
569 |
+
$hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
|
570 |
+
|
571 |
+
$box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
|
572 |
+
|
573 |
+
$submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
|
574 |
+
|
575 |
+
/**
|
576 |
+
* Get font values
|
577 |
+
*/
|
578 |
+
|
579 |
+
if ( 'custom' == $submit_button_height ) {
|
580 |
+
$submit_button_height = '38px';
|
581 |
+
}
|
582 |
+
|
583 |
+
if ( 'custom' == $field_input_size ) {
|
584 |
+
$field_input_size = '38px';
|
585 |
+
}
|
586 |
+
}
|
587 |
+
if ( isset( $primary_color ) ) {
|
588 |
+
|
589 |
+
list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
|
590 |
+
}
|
591 |
+
$output = "
|
592 |
+
.wcf-embed-checkout-form .wcf-checkout-header-image img{
|
593 |
+
width: {$header_logo_width}px;
|
594 |
+
}
|
595 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
|
596 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
|
597 |
+
color: {$primary_color};
|
598 |
+
}
|
599 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
|
600 |
+
background-color: {$primary_color};
|
601 |
+
}
|
602 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
|
603 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
|
604 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
|
605 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
|
606 |
+
border-color: {$primary_color};
|
607 |
+
box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
|
608 |
+
}
|
609 |
+
.wcf-embed-checkout-form .woocommerce-checkout label{
|
610 |
+
color: {$field_label_color};
|
611 |
+
}
|
612 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
|
613 |
+
background-color: {$hl_bg_color};
|
614 |
+
font-family: {$input_font_family};
|
615 |
+
font-weight: {$input_font_weight};
|
616 |
+
}
|
617 |
+
|
618 |
+
.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
|
619 |
+
.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
|
620 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
|
621 |
+
{
|
622 |
+
border-color: {$hl_bg_color};
|
623 |
+
border-right-color: transparent;
|
624 |
+
border-left-color: transparent;
|
625 |
+
border-top-color: transparent;
|
626 |
+
position: absolute;
|
627 |
+
}
|
628 |
+
|
629 |
+
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
|
630 |
+
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
|
631 |
+
font-family: {$input_font_family};
|
632 |
+
font-weight: {$input_font_weight};
|
633 |
+
}
|
634 |
+
|
635 |
+
.wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
|
636 |
+
.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
|
637 |
+
.wcf-embed-checkout-form .woocommerce form .form-row textarea,
|
638 |
+
.wcf-embed-checkout-form .select2-container--default .select2-selection--single {
|
639 |
+
color: {$field_color};
|
640 |
+
background: {$field_bg_color};
|
641 |
+
border-color: {$field_border_color};
|
642 |
+
padding-top: {$field_tb_padding}px;
|
643 |
+
padding-bottom: {$field_tb_padding}px;
|
644 |
+
padding-left: {$field_lr_padding}px;
|
645 |
+
padding-right: {$field_lr_padding}px;
|
646 |
+
min-height: {$field_input_size};
|
647 |
+
font-family: {$input_font_family};
|
648 |
+
font-weight: {$input_font_weight};
|
649 |
+
}
|
650 |
+
|
651 |
+
.wcf-embed-checkout-form .woocommerce .col2-set .col-1,
|
652 |
+
.wcf-embed-checkout-form .woocommerce .col2-set .col-2,
|
653 |
+
.wcf-embed-checkout-form .woocommerce-checkout .shop_table,
|
654 |
+
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
|
655 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment,
|
656 |
+
.wcf-embed-checkout-form .woocommerce form.checkout_coupon
|
657 |
+
{
|
658 |
+
background-color: {$section_bg_color};
|
659 |
+
border-color: {$box_border_color};
|
660 |
+
font-family: {$input_font_family};
|
661 |
+
font-weight: {$input_font_weight};
|
662 |
+
}
|
663 |
+
|
664 |
+
.woocommerce table.shop_table th{
|
665 |
+
color: {$field_label_color};
|
666 |
+
}
|
667 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-info,
|
668 |
+
.wcf-embed-checkout-form .woocommerce-message{
|
669 |
+
border-top-color: {$primary_color};
|
670 |
+
background-color: {$hl_bg_color};
|
671 |
+
}
|
672 |
+
.wcf-embed-checkout-form .woocommerce a{
|
673 |
+
color: {$primary_color};
|
674 |
+
}
|
675 |
+
.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
|
676 |
+
color: {$field_color};
|
677 |
+
}
|
678 |
+
.wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
|
679 |
+
color: {$field_color};
|
680 |
+
}
|
681 |
+
.wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
|
682 |
+
color: {$field_color};
|
683 |
+
}
|
684 |
+
.wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
|
685 |
+
color: {$field_color};
|
686 |
+
}
|
687 |
+
.wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
|
688 |
+
color: {$field_color};
|
689 |
+
}
|
690 |
+
.wcf-embed-checkout-form .woocommerce form p.form-row label {
|
691 |
+
color: {$field_label_color};
|
692 |
+
font-family: {$input_font_family};
|
693 |
+
font-weight: {$input_font_weight};
|
694 |
+
}
|
695 |
+
.wcf-embed-checkout-form .woocommerce #order_review button {
|
696 |
+
color: {$submit_color};
|
697 |
+
background: {$submit_bg_color};
|
698 |
+
padding-top: {$submit_tb_padding}px;
|
699 |
+
padding-bottom: {$submit_tb_padding}px;
|
700 |
+
padding-left: {$submit_lr_padding}px;
|
701 |
+
padding-right: {$submit_lr_padding}px;
|
702 |
+
border-color: {$submit_border_color};
|
703 |
+
min-height: {$submit_button_height};
|
704 |
+
font-family: {$button_font_family};
|
705 |
+
font-weight: {$button_font_weight};
|
706 |
+
}
|
707 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
|
708 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
|
709 |
+
background: {$submit_bg_color};
|
710 |
+
border: 1px {$submit_border_color} solid;
|
711 |
+
color: {$submit_color};
|
712 |
+
min-height: {$submit_button_height};
|
713 |
+
font-family: {$button_font_family};
|
714 |
+
font-weight: {$button_font_weight};
|
715 |
+
}
|
716 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
|
717 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
|
718 |
+
.wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
|
719 |
+
.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
|
720 |
+
color: {$submit_hover_color};
|
721 |
+
background-color: {$submit_bg_hover_color};
|
722 |
+
border-color: {$submit_border_hover_color};
|
723 |
+
}
|
724 |
+
.wcf-embed-checkout-form .woocommerce h3,
|
725 |
+
.wcf-embed-checkout-form .woocommerce h3 span,
|
726 |
+
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
|
727 |
+
color: {$section_heading_color};
|
728 |
+
font-family: {$heading_font_family};
|
729 |
+
font-weight: {$heading_font_weight};
|
730 |
+
}
|
731 |
+
.wcf-embed-checkout-form .woocommerce-info::before,
|
732 |
+
.wcf-embed-checkout-form .woocommerce-message::before{
|
733 |
+
color: {$primary_color};
|
734 |
+
}
|
735 |
+
.wcf-embed-checkout-form{
|
736 |
+
font-family: {$base_font_family};
|
737 |
+
}";
|
738 |
+
|
739 |
+
return $output;
|
740 |
+
}
|
741 |
+
|
742 |
+
/**
|
743 |
+
* Get ajax end points.
|
744 |
+
*
|
745 |
+
* @param string $endpoint_url end point URL.
|
746 |
+
* @return string
|
747 |
+
*/
|
748 |
+
function get_ajax_endpoint( $endpoint_url ) {
|
749 |
+
|
750 |
+
global $post;
|
751 |
+
|
752 |
+
if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
|
753 |
+
|
754 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
755 |
+
|
756 |
+
if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
|
757 |
+
|
758 |
+
$query_args = array(
|
759 |
+
'wc-ajax' => '%%endpoint%%',
|
760 |
+
);
|
761 |
+
|
762 |
+
$uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
|
763 |
+
$uri = $uri[0];
|
764 |
+
|
765 |
+
$endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
|
766 |
+
}
|
767 |
+
}
|
768 |
+
}
|
769 |
+
|
770 |
+
return $endpoint_url;
|
771 |
+
}
|
772 |
+
|
773 |
+
|
774 |
+
/**
|
775 |
+
* Save checkout fields.
|
776 |
+
*
|
777 |
+
* @param int $order_id order id.
|
778 |
+
* @param array $posted posted data.
|
779 |
+
* @return void
|
780 |
+
*/
|
781 |
+
function save_checkout_fields( $order_id, $posted ) {
|
782 |
+
|
783 |
+
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
784 |
+
|
785 |
+
$checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
|
786 |
+
|
787 |
+
update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
|
788 |
+
|
789 |
+
/*
|
790 |
+
Custom Field To Do
|
791 |
+
$custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
|
792 |
+
|
793 |
+
if ( 'yes' === $custom_fields ) {
|
794 |
+
|
795 |
+
$billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
|
796 |
+
|
797 |
+
foreach ( $billing_fields as $field => $data ) {
|
798 |
+
|
799 |
+
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
800 |
+
|
801 |
+
if ( isset( $_POST[ $field ] ) ) {
|
802 |
+
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
803 |
+
}
|
804 |
+
}
|
805 |
+
}
|
806 |
+
|
807 |
+
$shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
|
808 |
+
|
809 |
+
foreach ( $shipping_fields as $field => $data ) {
|
810 |
+
|
811 |
+
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
812 |
+
|
813 |
+
if ( isset( $_POST[ $field ] ) ) {
|
814 |
+
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
815 |
+
}
|
816 |
+
}
|
817 |
+
}
|
818 |
+
}
|
819 |
+
*/
|
820 |
+
if ( isset( $_POST['_wcf_flow_id'] ) ) {
|
821 |
+
|
822 |
+
$checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
|
823 |
+
|
824 |
+
update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
|
825 |
+
}
|
826 |
+
}
|
827 |
+
|
828 |
+
}
|
829 |
+
|
830 |
+
/**
|
831 |
+
* Enable Logo In Header Of Checkout Page
|
832 |
+
*
|
833 |
+
* @return void
|
834 |
+
*/
|
835 |
+
function enable_logo_in_header() {
|
836 |
+
global $post;
|
837 |
+
|
838 |
+
if ( _is_wcf_checkout_type() ) {
|
839 |
+
$checkout_id = $post->ID;
|
840 |
+
} else {
|
841 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
842 |
+
}
|
843 |
+
|
844 |
+
$header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
|
845 |
+
$add_image_markup = '';
|
846 |
+
|
847 |
+
if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
|
848 |
+
$add_image_markup = '<div class="wcf-checkout-header-image">';
|
849 |
+
$add_image_markup .= '<img src="' . $header_logo_image . '" />';
|
850 |
+
$add_image_markup .= '</div>';
|
851 |
+
}
|
852 |
+
|
853 |
+
echo $add_image_markup;
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Add text to the bootom of the checkout page.
|
858 |
+
*
|
859 |
+
* @return void
|
860 |
+
*/
|
861 |
+
function show_cartflows_copyright_message() {
|
862 |
+
$output_string = '';
|
863 |
+
|
864 |
+
$output_string .= '<div class="wcf-footer-primary">';
|
865 |
+
$output_string .= '<div class="wcf-footer-content">';
|
866 |
+
$output_string .= '<p class="wcf-footer-message">';
|
867 |
+
$output_string .= 'Checkout powered by CartFlows';
|
868 |
+
$output_string .= '</p>';
|
869 |
+
$output_string .= '</div>';
|
870 |
+
$output_string .= '</div>';
|
871 |
+
|
872 |
+
echo $output_string;
|
873 |
+
}
|
874 |
+
|
875 |
+
/**
|
876 |
+
* Redirect users to our checkout if hidden param
|
877 |
+
*
|
878 |
+
* @param string $redirect redirect url.
|
879 |
+
* @param object $user user.
|
880 |
+
* @return string
|
881 |
+
*/
|
882 |
+
function after_login_redirect( $redirect, $user ) {
|
883 |
+
|
884 |
+
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
885 |
+
|
886 |
+
$checkout_id = intval( $_POST['_wcf_checkout_id'] );
|
887 |
+
|
888 |
+
$redirect = get_permalink( $checkout_id );
|
889 |
+
}
|
890 |
+
|
891 |
+
return $redirect;
|
892 |
+
}
|
893 |
+
|
894 |
+
/**
|
895 |
+
* Display coupon code field after review order fields.
|
896 |
+
*/
|
897 |
+
function display_custom_coupon_field() {
|
898 |
+
|
899 |
+
$coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
|
900 |
+
|
901 |
+
if ( ! $coupon_enabled ) {
|
902 |
+
return;
|
903 |
+
}
|
904 |
+
|
905 |
+
ob_start();
|
906 |
+
|
907 |
+
?>
|
908 |
+
<div class="wcf-custom-coupon-field">
|
909 |
+
<div class="wcf-coupon-col-1">
|
910 |
+
<span>
|
911 |
+
<input type="text" name="coupon_code" class="input-text cf-coupon-code-input" placeholder="<?php echo $this->coupon_field_placeholder(); ?>" id="coupon_code" value="">
|
912 |
+
</span>
|
913 |
+
</div>
|
914 |
+
<div class="wcf-coupon-col-2">
|
915 |
+
<span>
|
916 |
+
<button type="button" class="button cf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php echo $this->coupon_button_text(); ?></button>
|
917 |
+
</span>
|
918 |
+
</div>
|
919 |
+
</div>
|
920 |
+
|
921 |
+
<?php
|
922 |
+
|
923 |
+
echo ob_get_clean();
|
924 |
+
}
|
925 |
+
|
926 |
+
/**
|
927 |
+
* Apply filter to change the placeholder text of coupon field.
|
928 |
+
*
|
929 |
+
* @return string
|
930 |
+
*/
|
931 |
+
function coupon_field_placeholder() {
|
932 |
+
return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
|
933 |
+
}
|
934 |
+
|
935 |
+
/**
|
936 |
+
* Apply filter to change the button text of coupon field.
|
937 |
+
*
|
938 |
+
* @return string
|
939 |
+
*/
|
940 |
+
function coupon_button_text() {
|
941 |
+
return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
|
942 |
+
}
|
943 |
+
|
944 |
+
/**
|
945 |
+
* Apply coupon on submit of custom coupon form.
|
946 |
+
*/
|
947 |
+
function apply_coupon() {
|
948 |
+
|
949 |
+
check_ajax_referer( 'cf-apply-coupon', 'security' );
|
950 |
+
|
951 |
+
$result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
|
952 |
+
|
953 |
+
echo json_encode( $result );
|
954 |
+
die();
|
955 |
+
}
|
956 |
+
|
957 |
+
/**
|
958 |
+
* Added ajax nonce to localize variable.
|
959 |
+
*
|
960 |
+
* @param array $vars localize variables.
|
961 |
+
*/
|
962 |
+
function add_localize_vars( $vars ) {
|
963 |
+
|
964 |
+
$vars['cf_validate_coupon_nonce'] = wp_create_nonce( 'cf-apply-coupon' );
|
965 |
+
|
966 |
+
return $vars;
|
967 |
+
}
|
968 |
+
|
969 |
+
/**
|
970 |
+
* Add custom class to the fields to change the UI to three column.
|
971 |
+
*
|
972 |
+
* @param array $fields fields.
|
973 |
+
*/
|
974 |
+
function add_three_column_layout_fields( $fields ) {
|
975 |
+
|
976 |
+
if ( empty( $fields['billing']['billing_address_2'] ) ) {
|
977 |
+
|
978 |
+
if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
|
979 |
+
$fields['billing']['billing_address_1']['class'][] = 'form-row-full';
|
980 |
+
}
|
981 |
+
}
|
982 |
+
|
983 |
+
if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
|
984 |
+
|
985 |
+
if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
|
986 |
+
$fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
|
987 |
+
}
|
988 |
+
}
|
989 |
+
|
990 |
+
if ( isset( $fields['billing']['billing_city'] ) &&
|
991 |
+
isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
|
992 |
+
|
993 |
+
$fields['billing']['billing_city']['class'] = array( 'wcf-form-col-3' );
|
994 |
+
$fields['billing']['billing_state']['class'] = array( 'wcf-form-col-3' );
|
995 |
+
$fields['billing']['billing_postcode']['class'] = array( 'wcf-form-col-3' );
|
996 |
+
}
|
997 |
+
|
998 |
+
if ( isset( $fields['shipping']['shipping_city'] ) &&
|
999 |
+
isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
|
1000 |
+
|
1001 |
+
$fields['shipping']['shipping_city']['class'] = array( 'wcf-form-col-3' );
|
1002 |
+
$fields['shipping']['shipping_state']['class'] = array( 'wcf-form-col-3' );
|
1003 |
+
$fields['shipping']['shipping_postcode']['class'] = array( 'wcf-form-col-3' );
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
return $fields;
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
/**
|
1010 |
+
* Add opening dev
|
1011 |
+
*
|
1012 |
+
* @since 1.0.0
|
1013 |
+
*/
|
1014 |
+
function order_wrap_div_start() {
|
1015 |
+
|
1016 |
+
echo "<div class='wcf-order-wrap'> ";
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
/**
|
1020 |
+
* Add closing dev
|
1021 |
+
*
|
1022 |
+
* @since 1.0.0
|
1023 |
+
*/
|
1024 |
+
function order_wrap_div_end() {
|
1025 |
+
|
1026 |
+
echo '</div> ';
|
1027 |
+
}
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
/**
|
1031 |
+
* Kicking this off by calling 'get_instance()' method
|
1032 |
+
*/
|
1033 |
+
Cartflows_Checkout_Markup::get_instance();
|
modules/flow/templates/template-canvas.php
CHANGED
@@ -1,47 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template Name: No Header Footer
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
?>
|
9 |
-
|
10 |
-
<!DOCTYPE html>
|
11 |
-
<html <?php language_attributes(); ?> class="no-js">
|
12 |
-
<head>
|
13 |
-
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
14 |
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
15 |
-
<link rel="profile" href="http://gmpg.org/xfn/11">
|
16 |
-
<?php wp_head(); ?>
|
17 |
-
</head>
|
18 |
-
|
19 |
-
<body <?php body_class(); ?>>
|
20 |
-
|
21 |
-
<?php
|
22 |
-
|
23 |
-
$atts_string = Cartflows_Helper::get_cartflows_container_atts();
|
24 |
-
|
25 |
-
?>
|
26 |
-
<div class="cartflows-container" <?php echo trim( $atts_string ); ?>>
|
27 |
-
|
28 |
-
<?php
|
29 |
-
do_action( 'cartflows_container_top' );
|
30 |
-
while ( have_posts() ) :
|
31 |
-
|
32 |
-
the_post();
|
33 |
-
the_content();
|
34 |
-
|
35 |
-
endwhile;
|
36 |
-
do_action( 'cartflows_container_bottom' );
|
37 |
-
?>
|
38 |
-
</div>
|
39 |
-
|
40 |
-
<?php do_action( 'cartflows_wp_footer' ); ?>
|
41 |
-
|
42 |
-
<?php wp_footer(); ?>
|
43 |
-
</body>
|
44 |
-
|
45 |
-
</html>
|
46 |
-
|
47 |
-
<?php
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template Name: No Header Footer
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
?>
|
9 |
+
|
10 |
+
<!DOCTYPE html>
|
11 |
+
<html <?php language_attributes(); ?> class="no-js">
|
12 |
+
<head>
|
13 |
+
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
14 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
15 |
+
<link rel="profile" href="http://gmpg.org/xfn/11">
|
16 |
+
<?php wp_head(); ?>
|
17 |
+
</head>
|
18 |
+
|
19 |
+
<body <?php body_class(); ?>>
|
20 |
+
|
21 |
+
<?php
|
22 |
+
|
23 |
+
$atts_string = Cartflows_Helper::get_cartflows_container_atts();
|
24 |
+
|
25 |
+
?>
|
26 |
+
<div class="cartflows-container" <?php echo trim( $atts_string ); ?>>
|
27 |
+
|
28 |
+
<?php
|
29 |
+
do_action( 'cartflows_container_top' );
|
30 |
+
while ( have_posts() ) :
|
31 |
+
|
32 |
+
the_post();
|
33 |
+
the_content();
|
34 |
+
|
35 |
+
endwhile;
|
36 |
+
do_action( 'cartflows_container_bottom' );
|
37 |
+
?>
|
38 |
+
</div>
|
39 |
+
|
40 |
+
<?php do_action( 'cartflows_wp_footer' ); ?>
|
41 |
+
|
42 |
+
<?php wp_footer(); ?>
|
43 |
+
</body>
|
44 |
+
|
45 |
+
</html>
|
46 |
+
|
47 |
+
<?php
|
modules/flow/templates/template-default.php
CHANGED
@@ -1,51 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template Name: No Header Footer
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
?>
|
9 |
-
|
10 |
-
<!DOCTYPE html>
|
11 |
-
<html <?php language_attributes(); ?> class="no-js">
|
12 |
-
<head>
|
13 |
-
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
14 |
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
15 |
-
<link rel="profile" href="http://gmpg.org/xfn/11">
|
16 |
-
<?php wp_head(); ?>
|
17 |
-
</head>
|
18 |
-
|
19 |
-
<body <?php body_class(); ?>>
|
20 |
-
<?php
|
21 |
-
|
22 |
-
$atts_string = Cartflows_Helper::get_cartflows_container_atts();
|
23 |
-
|
24 |
-
?>
|
25 |
-
<div class="cartflows-container" <?php echo trim( $atts_string ); ?>>
|
26 |
-
<?php
|
27 |
-
do_action( 'cartflows_container_top' );
|
28 |
-
?>
|
29 |
-
<div class="cartflows-primary">
|
30 |
-
<?php
|
31 |
-
while ( have_posts() ) :
|
32 |
-
|
33 |
-
the_post();
|
34 |
-
the_content();
|
35 |
-
|
36 |
-
endwhile;
|
37 |
-
?>
|
38 |
-
</div>
|
39 |
-
<?php
|
40 |
-
do_action( 'cartflows_container_bottom' );
|
41 |
-
?>
|
42 |
-
</div>
|
43 |
-
|
44 |
-
<?php do_action( 'cartflows_wp_footer' ); ?>
|
45 |
-
|
46 |
-
<?php wp_footer(); ?>
|
47 |
-
</body>
|
48 |
-
|
49 |
-
</html>
|
50 |
-
|
51 |
-
<?php
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template Name: No Header Footer
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
?>
|
9 |
+
|
10 |
+
<!DOCTYPE html>
|
11 |
+
<html <?php language_attributes(); ?> class="no-js">
|
12 |
+
<head>
|
13 |
+
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
14 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
15 |
+
<link rel="profile" href="http://gmpg.org/xfn/11">
|
16 |
+
<?php wp_head(); ?>
|
17 |
+
</head>
|
18 |
+
|
19 |
+
<body <?php body_class(); ?>>
|
20 |
+
<?php
|
21 |
+
|
22 |
+
$atts_string = Cartflows_Helper::get_cartflows_container_atts();
|
23 |
+
|
24 |
+
?>
|
25 |
+
<div class="cartflows-container" <?php echo trim( $atts_string ); ?>>
|
26 |
+
<?php
|
27 |
+
do_action( 'cartflows_container_top' );
|
28 |
+
?>
|
29 |
+
<div class="cartflows-primary">
|
30 |
+
<?php
|
31 |
+
while ( have_posts() ) :
|
32 |
+
|
33 |
+
the_post();
|
34 |
+
the_content();
|
35 |
+
|
36 |
+
endwhile;
|
37 |
+
?>
|
38 |
+
</div>
|
39 |
+
<?php
|
40 |
+
do_action( 'cartflows_container_bottom' );
|
41 |
+
?>
|
42 |
+
</div>
|
43 |
+
|
44 |
+
<?php do_action( 'cartflows_wp_footer' ); ?>
|
45 |
+
|
46 |
+
<?php wp_footer(); ?>
|
47 |
+
</body>
|
48 |
+
|
49 |
+
</html>
|
50 |
+
|
51 |
+
<?php
|
modules/flow/view/meta-flow-steps.php
CHANGED
@@ -1,200 +1,200 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* View Flow steps
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
9 |
-
|
10 |
-
$get_steps = array(
|
11 |
-
'landing' => __( 'Landing', 'cartflows' ),
|
12 |
-
'checkout' => __( 'Checkout', 'cartflows' ),
|
13 |
-
'thankyou' => __( 'Thank You', 'cartflows' ),
|
14 |
-
'upsell' => __( 'Upsell', 'cartflows' ),
|
15 |
-
'downsell' => __( 'Downsell', 'cartflows' ),
|
16 |
-
|
17 |
-
);
|
18 |
-
|
19 |
-
?>
|
20 |
-
<div class="wcf-flow-steps-meta-box">
|
21 |
-
<div class="wcf-flow-settings">
|
22 |
-
<?php do_action( 'cartflows_above_flow_steps' ); ?>
|
23 |
-
<div class="wcf-flow-steps-wrap">
|
24 |
-
<div class="wcf-flow-steps-container">
|
25 |
-
<?php if ( is_array( $options['steps'] ) ) { ?>
|
26 |
-
<?php foreach ( $options['steps'] as $index => $data ) { ?>
|
27 |
-
<?php
|
28 |
-
$term_slug = '';
|
29 |
-
$term_name = '';
|
30 |
-
$step_wrap_class = '';
|
31 |
-
$has_product_assigned = true;
|
32 |
-
$is_global_checkout = '';
|
33 |
-
$common = '';
|
34 |
-
|
35 |
-
if ( isset( $data['type'] ) ) {
|
36 |
-
$term_slug = $data['type'];
|
37 |
-
$term_name = $get_steps[ $data['type'] ];
|
38 |
-
}
|
39 |
-
|
40 |
-
if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) {
|
41 |
-
$step_wrap_class .= ' invalid-step';
|
42 |
-
}
|
43 |
-
|
44 |
-
if ( isset( $_GET['highlight-step-id'] ) && $_GET['highlight-step-id'] == $data['id'] ) {
|
45 |
-
$step_wrap_class .= ' wcf-new-step-highlight';
|
46 |
-
}
|
47 |
-
|
48 |
-
if ( 'checkout' === $term_slug ) {
|
49 |
-
|
50 |
-
$common = Cartflows_Helper::get_common_settings();
|
51 |
-
|
52 |
-
$is_global_checkout = (int) $common['global_checkout'];
|
53 |
-
|
54 |
-
if ( $data['id'] === $is_global_checkout ) {
|
55 |
-
$step_wrap_class .= ' wcf-global-checkout';
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) {
|
60 |
-
|
61 |
-
$has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] );
|
62 |
-
|
63 |
-
if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
|
64 |
-
$step_wrap_class .= ' wcf-no-product-step';
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
?>
|
69 |
-
<div class="wcf-step-wrap <?php echo $step_wrap_class; ?>" data-id="<?php echo $data['id']; ?>" data-term-slug="<?php echo esc_attr( $term_slug ); ?>">
|
70 |
-
<div class="wcf-step">
|
71 |
-
<div class="wcf-step-left-content">
|
72 |
-
<span class="dashicons dashicons-menu"></span>
|
73 |
-
<span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span>
|
74 |
-
<span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span>
|
75 |
-
|
76 |
-
<?php
|
77 |
-
if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
|
78 |
-
?>
|
79 |
-
<span class="wcf-no-product-badge"><?php _e( 'No Product Assigned', 'cartflows' ); ?></span>
|
80 |
-
<?php
|
81 |
-
} elseif ( ( $has_product_assigned ) && ( $data['id'] === $is_global_checkout ) ) {
|
82 |
-
?>
|
83 |
-
<span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout - Remove selected checkout product', 'cartflows' ); ?></span>
|
84 |
-
<?php
|
85 |
-
} elseif ( ( ! $has_product_assigned ) && $data['id'] === $is_global_checkout ) {
|
86 |
-
?>
|
87 |
-
<span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout', 'cartflows' ); ?></span>
|
88 |
-
<?php
|
89 |
-
}
|
90 |
-
?>
|
91 |
-
|
92 |
-
<input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>">
|
93 |
-
</div>
|
94 |
-
<div class="wcf-steps-action-buttons">
|
95 |
-
<a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'View Step', 'cartflows' ); ?>" >
|
96 |
-
<span class="dashicons dashicons-visibility"></span>
|
97 |
-
<span class="wcf-step-act-btn-text">View</span>
|
98 |
-
</a>
|
99 |
-
<a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Edit Step', 'cartflows' ); ?>" >
|
100 |
-
<span class="dashicons dashicons-edit"></span>
|
101 |
-
<span class="wcf-step-act-btn-text">Edit</span>
|
102 |
-
</a>
|
103 |
-
<a href="<?php echo wp_nonce_url( 'admin.php?action=cartflows_clone_step&post=' . $data['id'], 'step_clone', 'step_clone_nonce' ); ?>" class="wcf-step-clone wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
|
104 |
-
<span class="dashicons dashicons-admin-page"></span>
|
105 |
-
<span class="wcf-step-act-btn-text">Clone</span>
|
106 |
-
</a>
|
107 |
-
<a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
|
108 |
-
<span class="dashicons dashicons-trash"></span>
|
109 |
-
<span class="wcf-step-act-btn-text">Delete</span>
|
110 |
-
</a>
|
111 |
-
</div>
|
112 |
-
</div>
|
113 |
-
</div><!-- .wcf-step-wrap -->
|
114 |
-
<?php } ?>
|
115 |
-
<?php } ?>
|
116 |
-
</div><!-- .wcf-flow-steps-container -->
|
117 |
-
</div> <!-- .wcf-flow-steps-wrap -->
|
118 |
-
<div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap -->
|
119 |
-
<?php do_action( 'cartflows_bellow_flow_steps' ); ?>
|
120 |
-
<div class='wcf-add-new-step-btn-wrap'>
|
121 |
-
<button class='wcf-trigger-popup button button-primary'>
|
122 |
-
<?php echo __( 'Add New Step', 'cartflows' ); ?>
|
123 |
-
</button>
|
124 |
-
</div>
|
125 |
-
</div><!-- .wcf-flow-buttons-wrap -->
|
126 |
-
</div><!-- .wcf-flow-settings -->
|
127 |
-
|
128 |
-
<div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay">
|
129 |
-
<div class="wcf-templates-popup-content">
|
130 |
-
<div class="spinner"></div>
|
131 |
-
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
132 |
-
|
133 |
-
<div id="wcf-remote-step-actions" class="wcf-template-header">
|
134 |
-
<div class="wcf-template-logo-wrap">
|
135 |
-
<span class="wcf-cartflows-logo-img">
|
136 |
-
<span class="cartflows-icon"></span>
|
137 |
-
</span>
|
138 |
-
<span class="wcf-cartflows-title"><?php _e( 'Steps Library', 'cartflows' ); ?></span>
|
139 |
-
</div>
|
140 |
-
<div class="wcf-tab-wrapper">
|
141 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
142 |
-
<div id="wcf-get-started-steps">
|
143 |
-
<ul class="filter-links ">
|
144 |
-
<li>
|
145 |
-
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
146 |
-
</li>
|
147 |
-
<li>
|
148 |
-
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
149 |
-
</li>
|
150 |
-
</ul>
|
151 |
-
</div>
|
152 |
-
<?php } ?>
|
153 |
-
</div>
|
154 |
-
<div class="wcf-popup-close-wrap">
|
155 |
-
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
156 |
-
</div>
|
157 |
-
</div>
|
158 |
-
|
159 |
-
<!--<div class="wcf-search-form">
|
160 |
-
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
161 |
-
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
162 |
-
</div>-->
|
163 |
-
|
164 |
-
<div id="wcf-remote-content">
|
165 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
166 |
-
<div id="wcf-ready-templates">
|
167 |
-
<div id="wcf-remote-filters">
|
168 |
-
<div id="wcf-page-builders"></div>
|
169 |
-
<div id="wcf-categories"></div>
|
170 |
-
</div>
|
171 |
-
<div class="wcf-page-builder-notice"></div>
|
172 |
-
<div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
173 |
-
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
174 |
-
</div>
|
175 |
-
<?php } ?>
|
176 |
-
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
177 |
-
<div class="inner">
|
178 |
-
<div id="wcf-scratch-steps-categories">
|
179 |
-
<select class="step-type-filter-links filter-links">
|
180 |
-
<option value="" class="current"> Select Step Type </option>
|
181 |
-
<option value="52" data-group="52" class="Landing" data-slug="landing" data-title="Landing">Landing</option>
|
182 |
-
<option value="53" data-group="53" class="Checkout" data-slug="checkout" data-title="Checkout">Checkout</option>
|
183 |
-
<option value="55" data-group="55" class="Upsell" data-slug="upsell" data-title="Upsell">Upsell</option>
|
184 |
-
<option value="56" data-group="56" class="Downsell" data-slug="downsell" data-title="Downsell">Downsell</option>
|
185 |
-
<option value="54" data-group="54" class="Thank You" data-slug="thankyou" data-title="Thank You">Thank You</option>
|
186 |
-
</select>
|
187 |
-
</div>
|
188 |
-
<a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create Step', 'cartflows' ); ?></a>
|
189 |
-
<?php if ( ! _is_cartflows_pro() ) { ?>
|
190 |
-
<div class="wcf-template-notice"><p><?php echo __( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div>
|
191 |
-
<?php } ?>
|
192 |
-
<p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
|
193 |
-
</div>
|
194 |
-
</div>
|
195 |
-
</div>
|
196 |
-
</div>
|
197 |
-
</div>
|
198 |
-
</div><!-- .wcf-templates-popup-overlay -->
|
199 |
-
</div>
|
200 |
-
<?php
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* View Flow steps
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
9 |
+
|
10 |
+
$get_steps = array(
|
11 |
+
'landing' => __( 'Landing', 'cartflows' ),
|
12 |
+
'checkout' => __( 'Checkout', 'cartflows' ),
|
13 |
+
'thankyou' => __( 'Thank You', 'cartflows' ),
|
14 |
+
'upsell' => __( 'Upsell', 'cartflows' ),
|
15 |
+
'downsell' => __( 'Downsell', 'cartflows' ),
|
16 |
+
|
17 |
+
);
|
18 |
+
|
19 |
+
?>
|
20 |
+
<div class="wcf-flow-steps-meta-box">
|
21 |
+
<div class="wcf-flow-settings">
|
22 |
+
<?php do_action( 'cartflows_above_flow_steps' ); ?>
|
23 |
+
<div class="wcf-flow-steps-wrap">
|
24 |
+
<div class="wcf-flow-steps-container">
|
25 |
+
<?php if ( is_array( $options['steps'] ) ) { ?>
|
26 |
+
<?php foreach ( $options['steps'] as $index => $data ) { ?>
|
27 |
+
<?php
|
28 |
+
$term_slug = '';
|
29 |
+
$term_name = '';
|
30 |
+
$step_wrap_class = '';
|
31 |
+
$has_product_assigned = true;
|
32 |
+
$is_global_checkout = '';
|
33 |
+
$common = '';
|
34 |
+
|
35 |
+
if ( isset( $data['type'] ) ) {
|
36 |
+
$term_slug = $data['type'];
|
37 |
+
$term_name = $get_steps[ $data['type'] ];
|
38 |
+
}
|
39 |
+
|
40 |
+
if ( ! _is_cartflows_pro() && ( 'upsell' === $term_slug || 'downsell' === $term_slug ) ) {
|
41 |
+
$step_wrap_class .= ' invalid-step';
|
42 |
+
}
|
43 |
+
|
44 |
+
if ( isset( $_GET['highlight-step-id'] ) && $_GET['highlight-step-id'] == $data['id'] ) {
|
45 |
+
$step_wrap_class .= ' wcf-new-step-highlight';
|
46 |
+
}
|
47 |
+
|
48 |
+
if ( 'checkout' === $term_slug ) {
|
49 |
+
|
50 |
+
$common = Cartflows_Helper::get_common_settings();
|
51 |
+
|
52 |
+
$is_global_checkout = (int) $common['global_checkout'];
|
53 |
+
|
54 |
+
if ( $data['id'] === $is_global_checkout ) {
|
55 |
+
$step_wrap_class .= ' wcf-global-checkout';
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
if ( 'upsell' === $term_slug || 'downsell' === $term_slug || 'checkout' === $term_slug ) {
|
60 |
+
|
61 |
+
$has_product_assigned = Cartflows_Helper::has_product_assigned( $data['id'] );
|
62 |
+
|
63 |
+
if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
|
64 |
+
$step_wrap_class .= ' wcf-no-product-step';
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
?>
|
69 |
+
<div class="wcf-step-wrap <?php echo $step_wrap_class; ?>" data-id="<?php echo $data['id']; ?>" data-term-slug="<?php echo esc_attr( $term_slug ); ?>">
|
70 |
+
<div class="wcf-step">
|
71 |
+
<div class="wcf-step-left-content">
|
72 |
+
<span class="dashicons dashicons-menu"></span>
|
73 |
+
<span><?php echo wp_trim_words( get_the_title( $data['id'] ), 3 ); ?></span>
|
74 |
+
<span class="wcf-flow-badge"><?php echo esc_attr( $term_name ); ?></span>
|
75 |
+
|
76 |
+
<?php
|
77 |
+
if ( ( ! $has_product_assigned ) && ( $data['id'] != $is_global_checkout ) ) {
|
78 |
+
?>
|
79 |
+
<span class="wcf-no-product-badge"><?php _e( 'No Product Assigned', 'cartflows' ); ?></span>
|
80 |
+
<?php
|
81 |
+
} elseif ( ( $has_product_assigned ) && ( $data['id'] === $is_global_checkout ) ) {
|
82 |
+
?>
|
83 |
+
<span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout - Remove selected checkout product', 'cartflows' ); ?></span>
|
84 |
+
<?php
|
85 |
+
} elseif ( ( ! $has_product_assigned ) && $data['id'] === $is_global_checkout ) {
|
86 |
+
?>
|
87 |
+
<span class="wcf-global-checkout-badge"><?php _e( 'Global Checkout', 'cartflows' ); ?></span>
|
88 |
+
<?php
|
89 |
+
}
|
90 |
+
?>
|
91 |
+
|
92 |
+
<input type="hidden" class="wcf-steps-hidden" name="wcf-steps[]" value="<?php echo $data['id']; ?>">
|
93 |
+
</div>
|
94 |
+
<div class="wcf-steps-action-buttons">
|
95 |
+
<a href="<?php echo get_permalink( $data['id'] ); ?>" target="_blank" class="wcf-step-view wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'View Step', 'cartflows' ); ?>" >
|
96 |
+
<span class="dashicons dashicons-visibility"></span>
|
97 |
+
<span class="wcf-step-act-btn-text">View</span>
|
98 |
+
</a>
|
99 |
+
<a href="<?php echo get_edit_post_link( $data['id'] ); ?>" class="wcf-step-edit wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Edit Step', 'cartflows' ); ?>" >
|
100 |
+
<span class="dashicons dashicons-edit"></span>
|
101 |
+
<span class="wcf-step-act-btn-text">Edit</span>
|
102 |
+
</a>
|
103 |
+
<a href="<?php echo wp_nonce_url( 'admin.php?action=cartflows_clone_step&post=' . $data['id'], 'step_clone', 'step_clone_nonce' ); ?>" class="wcf-step-clone wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Clone Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
|
104 |
+
<span class="dashicons dashicons-admin-page"></span>
|
105 |
+
<span class="wcf-step-act-btn-text">Clone</span>
|
106 |
+
</a>
|
107 |
+
<a href="#" class="wcf-step-delete wcf-action-button wp-ui-text-highlight" title="<?php echo __( 'Delete Step', 'cartflows' ); ?>" data-id="<?php echo $data['id']; ?>">
|
108 |
+
<span class="dashicons dashicons-trash"></span>
|
109 |
+
<span class="wcf-step-act-btn-text">Delete</span>
|
110 |
+
</a>
|
111 |
+
</div>
|
112 |
+
</div>
|
113 |
+
</div><!-- .wcf-step-wrap -->
|
114 |
+
<?php } ?>
|
115 |
+
<?php } ?>
|
116 |
+
</div><!-- .wcf-flow-steps-container -->
|
117 |
+
</div> <!-- .wcf-flow-steps-wrap -->
|
118 |
+
<div class="wcf-flow-buttons-wrap"> <!-- .wcf-flow-buttons-wrap -->
|
119 |
+
<?php do_action( 'cartflows_bellow_flow_steps' ); ?>
|
120 |
+
<div class='wcf-add-new-step-btn-wrap'>
|
121 |
+
<button class='wcf-trigger-popup button button-primary'>
|
122 |
+
<?php echo __( 'Add New Step', 'cartflows' ); ?>
|
123 |
+
</button>
|
124 |
+
</div>
|
125 |
+
</div><!-- .wcf-flow-buttons-wrap -->
|
126 |
+
</div><!-- .wcf-flow-settings -->
|
127 |
+
|
128 |
+
<div id="wcf-remote-step-importer" class="wcf-templates-popup-overlay">
|
129 |
+
<div class="wcf-templates-popup-content">
|
130 |
+
<div class="spinner"></div>
|
131 |
+
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
132 |
+
|
133 |
+
<div id="wcf-remote-step-actions" class="wcf-template-header">
|
134 |
+
<div class="wcf-template-logo-wrap">
|
135 |
+
<span class="wcf-cartflows-logo-img">
|
136 |
+
<span class="cartflows-icon"></span>
|
137 |
+
</span>
|
138 |
+
<span class="wcf-cartflows-title"><?php _e( 'Steps Library', 'cartflows' ); ?></span>
|
139 |
+
</div>
|
140 |
+
<div class="wcf-tab-wrapper">
|
141 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
142 |
+
<div id="wcf-get-started-steps">
|
143 |
+
<ul class="filter-links ">
|
144 |
+
<li>
|
145 |
+
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
146 |
+
</li>
|
147 |
+
<li>
|
148 |
+
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
149 |
+
</li>
|
150 |
+
</ul>
|
151 |
+
</div>
|
152 |
+
<?php } ?>
|
153 |
+
</div>
|
154 |
+
<div class="wcf-popup-close-wrap">
|
155 |
+
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
156 |
+
</div>
|
157 |
+
</div>
|
158 |
+
|
159 |
+
<!--<div class="wcf-search-form">
|
160 |
+
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
161 |
+
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
162 |
+
</div>-->
|
163 |
+
|
164 |
+
<div id="wcf-remote-content">
|
165 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
166 |
+
<div id="wcf-ready-templates">
|
167 |
+
<div id="wcf-remote-filters">
|
168 |
+
<div id="wcf-page-builders"></div>
|
169 |
+
<div id="wcf-categories"></div>
|
170 |
+
</div>
|
171 |
+
<div class="wcf-page-builder-notice"></div>
|
172 |
+
<div id="wcf-remote-step-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
173 |
+
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
174 |
+
</div>
|
175 |
+
<?php } ?>
|
176 |
+
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
177 |
+
<div class="inner">
|
178 |
+
<div id="wcf-scratch-steps-categories">
|
179 |
+
<select class="step-type-filter-links filter-links">
|
180 |
+
<option value="" class="current"> Select Step Type </option>
|
181 |
+
<option value="52" data-group="52" class="Landing" data-slug="landing" data-title="Landing">Landing</option>
|
182 |
+
<option value="53" data-group="53" class="Checkout" data-slug="checkout" data-title="Checkout">Checkout</option>
|
183 |
+
<option value="55" data-group="55" class="Upsell" data-slug="upsell" data-title="Upsell">Upsell</option>
|
184 |
+
<option value="56" data-group="56" class="Downsell" data-slug="downsell" data-title="Downsell">Downsell</option>
|
185 |
+
<option value="54" data-group="54" class="Thank You" data-slug="thankyou" data-title="Thank You">Thank You</option>
|
186 |
+
</select>
|
187 |
+
</div>
|
188 |
+
<a href="#" class="button button-primary cartflows-step-import-blank"><?php _e( 'Create Step', 'cartflows' ); ?></a>
|
189 |
+
<?php if ( ! _is_cartflows_pro() ) { ?>
|
190 |
+
<div class="wcf-template-notice"><p><?php echo __( 'You need a Cartflows Pro version to import Upsell / Downsell', 'cartflows' ); ?></p></div>
|
191 |
+
<?php } ?>
|
192 |
+
<p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
</div>
|
196 |
+
</div>
|
197 |
+
</div>
|
198 |
+
</div><!-- .wcf-templates-popup-overlay -->
|
199 |
+
</div>
|
200 |
+
<?php
|
modules/thankyou/classes/class-cartflows-thankyou-markup.php
CHANGED
@@ -1,273 +1,273 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Front end and markup
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Checkout Markup
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Thankyou_Markup {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Member Variable
|
17 |
-
*
|
18 |
-
* @var object instance
|
19 |
-
*/
|
20 |
-
private static $instance;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Initiator
|
24 |
-
*/
|
25 |
-
public static function get_instance() {
|
26 |
-
if ( ! isset( self::$instance ) ) {
|
27 |
-
self::$instance = new self;
|
28 |
-
}
|
29 |
-
return self::$instance;
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Constructor
|
34 |
-
*/
|
35 |
-
public function __construct() {
|
36 |
-
|
37 |
-
/* Downsell Shortcode */
|
38 |
-
add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );
|
39 |
-
|
40 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'thank_you_scripts' ), 21 );
|
41 |
-
|
42 |
-
add_action( 'woocommerce_is_order_received_page', array( $this, 'set_order_received_page' ) );
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Order shortcode markup
|
48 |
-
*
|
49 |
-
* @param array $atts attributes.
|
50 |
-
* @since 1.0.0
|
51 |
-
*/
|
52 |
-
function cartflows_order_details_shortcode_markup( $atts ) {
|
53 |
-
|
54 |
-
$output = '';
|
55 |
-
|
56 |
-
if ( _is_wcf_thankyou_type() ) {
|
57 |
-
|
58 |
-
/* Remove order item link */
|
59 |
-
add_filter( 'woocommerce_order_item_permalink', '__return_false' );
|
60 |
-
|
61 |
-
if ( ! function_exists( 'wc_print_notices' ) ) {
|
62 |
-
return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
|
63 |
-
}
|
64 |
-
|
65 |
-
$order = false;
|
66 |
-
|
67 |
-
if ( ! isset( $_GET['wcf-order'] ) && wcf()->flow->is_flow_testmode() ) {
|
68 |
-
|
69 |
-
$args = array(
|
70 |
-
'limit' => 1,
|
71 |
-
'order' => 'DESC',
|
72 |
-
'post_type' => 'shop_order',
|
73 |
-
'status' => array( 'completed', 'processing' ),
|
74 |
-
);
|
75 |
-
|
76 |
-
$latest_order = wc_get_orders( $args );
|
77 |
-
|
78 |
-
$order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;
|
79 |
-
|
80 |
-
if ( $order_id > 0 ) {
|
81 |
-
|
82 |
-
$order = wc_get_order( $order_id );
|
83 |
-
|
84 |
-
if ( ! $order ) {
|
85 |
-
$order = false;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
} else {
|
89 |
-
if ( ! isset( $_GET['wcf-order'] ) ) {
|
90 |
-
return '<p class="woocommerce-notice">Order not found. You cannot access this page directly.</p>';
|
91 |
-
}
|
92 |
-
|
93 |
-
// Get the order.
|
94 |
-
$order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] ) );
|
95 |
-
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) ) ); // WPCS: input var ok, CSRF ok.
|
96 |
-
|
97 |
-
if ( $order_id > 0 ) {
|
98 |
-
|
99 |
-
$order = wc_get_order( $order_id );
|
100 |
-
|
101 |
-
if ( ! $order || $order->get_order_key() !== $order_key ) {
|
102 |
-
$order = false;
|
103 |
-
}
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
// Empty awaiting payment session.
|
108 |
-
unset( WC()->session->order_awaiting_payment );
|
109 |
-
|
110 |
-
if ( null !== WC()->session ) {
|
111 |
-
|
112 |
-
if ( ! isset( WC()->cart ) || '' === WC()->cart ) {
|
113 |
-
WC()->cart = new WC_Cart();
|
114 |
-
}
|
115 |
-
|
116 |
-
if ( ! WC()->cart->is_empty() ) {
|
117 |
-
// wc_empty_cart();
|
118 |
-
// Empty current cart.
|
119 |
-
WC()->cart->empty_cart( true );
|
120 |
-
|
121 |
-
wc_clear_notices();
|
122 |
-
}
|
123 |
-
|
124 |
-
wc_print_notices();
|
125 |
-
}
|
126 |
-
|
127 |
-
ob_start();
|
128 |
-
echo "<div class='wcf-thankyou-wrap'>";
|
129 |
-
wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
|
130 |
-
echo '</div>';
|
131 |
-
$output = ob_get_clean();
|
132 |
-
}
|
133 |
-
|
134 |
-
return $output;
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Load Thank You scripts.
|
139 |
-
*
|
140 |
-
* @return void
|
141 |
-
*/
|
142 |
-
function thank_you_scripts() {
|
143 |
-
|
144 |
-
if ( _is_wcf_thankyou_type() ) {
|
145 |
-
|
146 |
-
do_action( 'cartflows_thank_you_scripts' );
|
147 |
-
|
148 |
-
$style = $this->generate_thank_you_style();
|
149 |
-
|
150 |
-
wp_add_inline_style( 'wcf-frontend-global', $style );
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Set thank you as a order received page.
|
156 |
-
*
|
157 |
-
* @param boolean $is_order_page order page.
|
158 |
-
* @return boolean
|
159 |
-
*/
|
160 |
-
function set_order_received_page( $is_order_page ) {
|
161 |
-
|
162 |
-
if ( _is_wcf_thankyou_type() ) {
|
163 |
-
|
164 |
-
$is_order_page = true;
|
165 |
-
}
|
166 |
-
|
167 |
-
return $is_order_page;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Generate Thank You Styles.
|
172 |
-
*
|
173 |
-
* @return string
|
174 |
-
*/
|
175 |
-
function generate_thank_you_style() {
|
176 |
-
|
177 |
-
global $post;
|
178 |
-
|
179 |
-
if ( _is_wcf_thankyou_type() ) {
|
180 |
-
$thank_you_id = $post->ID;
|
181 |
-
} else {
|
182 |
-
$thank_you_id = _get_wcf_thankyou_id( $post->post_content );
|
183 |
-
}
|
184 |
-
|
185 |
-
CartFlows_Font_Families::render_fonts( $thank_you_id );
|
186 |
-
|
187 |
-
$text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text-color' );
|
188 |
-
$text_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-family' );
|
189 |
-
$heading_text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-color' );
|
190 |
-
$heading_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-family' );
|
191 |
-
$heading_font_weight = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-wt' );
|
192 |
-
$container_width = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-container-width' );
|
193 |
-
$section_bg_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-section-bg-color' );
|
194 |
-
|
195 |
-
$show_order_review = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-overview-section' );
|
196 |
-
|
197 |
-
$show_order_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-details-section' );
|
198 |
-
|
199 |
-
$show_billing_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-billing-section' );
|
200 |
-
|
201 |
-
$show_shipping_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-shipping-section' );
|
202 |
-
|
203 |
-
$output = "
|
204 |
-
.wcf-thankyou-wrap{
|
205 |
-
color: {$text_color};
|
206 |
-
font-family: {$text_font_family};
|
207 |
-
max-width:{$container_width}px;
|
208 |
-
}
|
209 |
-
|
210 |
-
.woocommerce-order h2.woocommerce-column__title,
|
211 |
-
.woocommerce-order h2.woocommerce-order-details__title,
|
212 |
-
.woocommerce-order .woocommerce-thankyou-order-received,
|
213 |
-
.woocommerce-order-details h2 {
|
214 |
-
color: {$heading_text_color};
|
215 |
-
font-family: {$heading_font_family};
|
216 |
-
font-weight: {$heading_font_weight};
|
217 |
-
}
|
218 |
-
|
219 |
-
.woocommerce-order ul.order_details,
|
220 |
-
.woocommerce-order .woocommerce-order-details,
|
221 |
-
.woocommerce-order .woocommerce-customer-details{
|
222 |
-
background-color: {$section_bg_color}
|
223 |
-
}
|
224 |
-
";
|
225 |
-
|
226 |
-
if ( 'no' == $show_order_review ) {
|
227 |
-
$output .= '
|
228 |
-
.woocommerce-order ul.order_details{
|
229 |
-
display: none;
|
230 |
-
}
|
231 |
-
';
|
232 |
-
}
|
233 |
-
|
234 |
-
if ( 'no' == $show_order_details ) {
|
235 |
-
$output .= '
|
236 |
-
.woocommerce-order .woocommerce-order-details{
|
237 |
-
display: none;
|
238 |
-
}
|
239 |
-
';
|
240 |
-
}
|
241 |
-
|
242 |
-
if ( 'no' == $show_billing_details ) {
|
243 |
-
$output .= '
|
244 |
-
.woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
|
245 |
-
display: none;
|
246 |
-
}
|
247 |
-
';
|
248 |
-
}
|
249 |
-
|
250 |
-
if ( 'no' == $show_shipping_details ) {
|
251 |
-
$output .= '
|
252 |
-
.woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
|
253 |
-
display: none;
|
254 |
-
}
|
255 |
-
';
|
256 |
-
}
|
257 |
-
|
258 |
-
if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
|
259 |
-
$output .= '
|
260 |
-
.woocommerce-order .woocommerce-customer-details{
|
261 |
-
display: none;
|
262 |
-
}
|
263 |
-
';
|
264 |
-
}
|
265 |
-
|
266 |
-
return $output;
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
/**
|
271 |
-
* Kicking this off by calling 'get_instance()' method
|
272 |
-
*/
|
273 |
-
Cartflows_Thankyou_Markup::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Front end and markup
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Checkout Markup
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Thankyou_Markup {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Member Variable
|
17 |
+
*
|
18 |
+
* @var object instance
|
19 |
+
*/
|
20 |
+
private static $instance;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Initiator
|
24 |
+
*/
|
25 |
+
public static function get_instance() {
|
26 |
+
if ( ! isset( self::$instance ) ) {
|
27 |
+
self::$instance = new self;
|
28 |
+
}
|
29 |
+
return self::$instance;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Constructor
|
34 |
+
*/
|
35 |
+
public function __construct() {
|
36 |
+
|
37 |
+
/* Downsell Shortcode */
|
38 |
+
add_shortcode( 'cartflows_order_details', array( $this, 'cartflows_order_details_shortcode_markup' ) );
|
39 |
+
|
40 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'thank_you_scripts' ), 21 );
|
41 |
+
|
42 |
+
add_action( 'woocommerce_is_order_received_page', array( $this, 'set_order_received_page' ) );
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Order shortcode markup
|
48 |
+
*
|
49 |
+
* @param array $atts attributes.
|
50 |
+
* @since 1.0.0
|
51 |
+
*/
|
52 |
+
function cartflows_order_details_shortcode_markup( $atts ) {
|
53 |
+
|
54 |
+
$output = '';
|
55 |
+
|
56 |
+
if ( _is_wcf_thankyou_type() ) {
|
57 |
+
|
58 |
+
/* Remove order item link */
|
59 |
+
add_filter( 'woocommerce_order_item_permalink', '__return_false' );
|
60 |
+
|
61 |
+
if ( ! function_exists( 'wc_print_notices' ) ) {
|
62 |
+
return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
|
63 |
+
}
|
64 |
+
|
65 |
+
$order = false;
|
66 |
+
|
67 |
+
if ( ! isset( $_GET['wcf-order'] ) && wcf()->flow->is_flow_testmode() ) {
|
68 |
+
|
69 |
+
$args = array(
|
70 |
+
'limit' => 1,
|
71 |
+
'order' => 'DESC',
|
72 |
+
'post_type' => 'shop_order',
|
73 |
+
'status' => array( 'completed', 'processing' ),
|
74 |
+
);
|
75 |
+
|
76 |
+
$latest_order = wc_get_orders( $args );
|
77 |
+
|
78 |
+
$order_id = ( ! empty( $latest_order ) ) ? current( $latest_order )->get_id() : 0;
|
79 |
+
|
80 |
+
if ( $order_id > 0 ) {
|
81 |
+
|
82 |
+
$order = wc_get_order( $order_id );
|
83 |
+
|
84 |
+
if ( ! $order ) {
|
85 |
+
$order = false;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
} else {
|
89 |
+
if ( ! isset( $_GET['wcf-order'] ) ) {
|
90 |
+
return '<p class="woocommerce-notice">Order not found. You cannot access this page directly.</p>';
|
91 |
+
}
|
92 |
+
|
93 |
+
// Get the order.
|
94 |
+
$order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['wcf-order'] ) ? 0 : intval( $_GET['wcf-order'] ) );
|
95 |
+
$order_key = apply_filters( 'woocommerce_thankyou_order_key', empty( $_GET['wcf-key'] ) ? '' : wc_clean( wp_unslash( $_GET['wcf-key'] ) ) ); // WPCS: input var ok, CSRF ok.
|
96 |
+
|
97 |
+
if ( $order_id > 0 ) {
|
98 |
+
|
99 |
+
$order = wc_get_order( $order_id );
|
100 |
+
|
101 |
+
if ( ! $order || $order->get_order_key() !== $order_key ) {
|
102 |
+
$order = false;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
// Empty awaiting payment session.
|
108 |
+
unset( WC()->session->order_awaiting_payment );
|
109 |
+
|
110 |
+
if ( null !== WC()->session ) {
|
111 |
+
|
112 |
+
if ( ! isset( WC()->cart ) || '' === WC()->cart ) {
|
113 |
+
WC()->cart = new WC_Cart();
|
114 |
+
}
|
115 |
+
|
116 |
+
if ( ! WC()->cart->is_empty() ) {
|
117 |
+
// wc_empty_cart();
|
118 |
+
// Empty current cart.
|
119 |
+
WC()->cart->empty_cart( true );
|
120 |
+
|
121 |
+
wc_clear_notices();
|
122 |
+
}
|
123 |
+
|
124 |
+
wc_print_notices();
|
125 |
+
}
|
126 |
+
|
127 |
+
ob_start();
|
128 |
+
echo "<div class='wcf-thankyou-wrap'>";
|
129 |
+
wc_get_template( 'checkout/thankyou.php', array( 'order' => $order ) );
|
130 |
+
echo '</div>';
|
131 |
+
$output = ob_get_clean();
|
132 |
+
}
|
133 |
+
|
134 |
+
return $output;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Load Thank You scripts.
|
139 |
+
*
|
140 |
+
* @return void
|
141 |
+
*/
|
142 |
+
function thank_you_scripts() {
|
143 |
+
|
144 |
+
if ( _is_wcf_thankyou_type() ) {
|
145 |
+
|
146 |
+
do_action( 'cartflows_thank_you_scripts' );
|
147 |
+
|
148 |
+
$style = $this->generate_thank_you_style();
|
149 |
+
|
150 |
+
wp_add_inline_style( 'wcf-frontend-global', $style );
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Set thank you as a order received page.
|
156 |
+
*
|
157 |
+
* @param boolean $is_order_page order page.
|
158 |
+
* @return boolean
|
159 |
+
*/
|
160 |
+
function set_order_received_page( $is_order_page ) {
|
161 |
+
|
162 |
+
if ( _is_wcf_thankyou_type() ) {
|
163 |
+
|
164 |
+
$is_order_page = true;
|
165 |
+
}
|
166 |
+
|
167 |
+
return $is_order_page;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Generate Thank You Styles.
|
172 |
+
*
|
173 |
+
* @return string
|
174 |
+
*/
|
175 |
+
function generate_thank_you_style() {
|
176 |
+
|
177 |
+
global $post;
|
178 |
+
|
179 |
+
if ( _is_wcf_thankyou_type() ) {
|
180 |
+
$thank_you_id = $post->ID;
|
181 |
+
} else {
|
182 |
+
$thank_you_id = _get_wcf_thankyou_id( $post->post_content );
|
183 |
+
}
|
184 |
+
|
185 |
+
CartFlows_Font_Families::render_fonts( $thank_you_id );
|
186 |
+
|
187 |
+
$text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-text-color' );
|
188 |
+
$text_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-font-family' );
|
189 |
+
$heading_text_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-color' );
|
190 |
+
$heading_font_family = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-family' );
|
191 |
+
$heading_font_weight = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-heading-font-wt' );
|
192 |
+
$container_width = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-container-width' );
|
193 |
+
$section_bg_color = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-tq-section-bg-color' );
|
194 |
+
|
195 |
+
$show_order_review = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-overview-section' );
|
196 |
+
|
197 |
+
$show_order_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-details-section' );
|
198 |
+
|
199 |
+
$show_billing_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-billing-section' );
|
200 |
+
|
201 |
+
$show_shipping_details = wcf()->options->get_thankyou_meta_value( $thank_you_id, 'wcf-show-shipping-section' );
|
202 |
+
|
203 |
+
$output = "
|
204 |
+
.wcf-thankyou-wrap{
|
205 |
+
color: {$text_color};
|
206 |
+
font-family: {$text_font_family};
|
207 |
+
max-width:{$container_width}px;
|
208 |
+
}
|
209 |
+
|
210 |
+
.woocommerce-order h2.woocommerce-column__title,
|
211 |
+
.woocommerce-order h2.woocommerce-order-details__title,
|
212 |
+
.woocommerce-order .woocommerce-thankyou-order-received,
|
213 |
+
.woocommerce-order-details h2 {
|
214 |
+
color: {$heading_text_color};
|
215 |
+
font-family: {$heading_font_family};
|
216 |
+
font-weight: {$heading_font_weight};
|
217 |
+
}
|
218 |
+
|
219 |
+
.woocommerce-order ul.order_details,
|
220 |
+
.woocommerce-order .woocommerce-order-details,
|
221 |
+
.woocommerce-order .woocommerce-customer-details{
|
222 |
+
background-color: {$section_bg_color}
|
223 |
+
}
|
224 |
+
";
|
225 |
+
|
226 |
+
if ( 'no' == $show_order_review ) {
|
227 |
+
$output .= '
|
228 |
+
.woocommerce-order ul.order_details{
|
229 |
+
display: none;
|
230 |
+
}
|
231 |
+
';
|
232 |
+
}
|
233 |
+
|
234 |
+
if ( 'no' == $show_order_details ) {
|
235 |
+
$output .= '
|
236 |
+
.woocommerce-order .woocommerce-order-details{
|
237 |
+
display: none;
|
238 |
+
}
|
239 |
+
';
|
240 |
+
}
|
241 |
+
|
242 |
+
if ( 'no' == $show_billing_details ) {
|
243 |
+
$output .= '
|
244 |
+
.woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
|
245 |
+
display: none;
|
246 |
+
}
|
247 |
+
';
|
248 |
+
}
|
249 |
+
|
250 |
+
if ( 'no' == $show_shipping_details ) {
|
251 |
+
$output .= '
|
252 |
+
.woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
|
253 |
+
display: none;
|
254 |
+
}
|
255 |
+
';
|
256 |
+
}
|
257 |
+
|
258 |
+
if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
|
259 |
+
$output .= '
|
260 |
+
.woocommerce-order .woocommerce-customer-details{
|
261 |
+
display: none;
|
262 |
+
}
|
263 |
+
';
|
264 |
+
}
|
265 |
+
|
266 |
+
return $output;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Kicking this off by calling 'get_instance()' method
|
272 |
+
*/
|
273 |
+
Cartflows_Thankyou_Markup::get_instance();
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce, cart
|
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.0.2
|
8 |
-
Stable tag: 1.1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -93,25 +93,29 @@ Say goodby to using the same ridgid checkout page that everyone else is using. C
|
|
93 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
94 |
|
95 |
== Changelog ==
|
96 |
-
Version 1.1.
|
|
|
|
|
|
|
|
|
97 |
* New: Beaver Builder templates.
|
98 |
* Improvement: Better error handling on the checkout page.
|
99 |
* Fix: Product variants were not getting aligned properly in the order summary.
|
100 |
* Fix: Divi builder conflict.
|
101 |
|
102 |
-
Version 1.1.3 - Tuesday, 15th January 2019
|
103 |
* New: Import / Export the flows
|
104 |
* Improvement: Pixel Caffeine plugin pixel compatibility added.
|
105 |
* Improvement: Filter introduced to change the coupon field placeholder & button text.
|
106 |
* Fix: Clone option conflict with Duplicate post and Duplicate page plugin.
|
107 |
* Fix: Cart is not empty after purchase.
|
108 |
|
109 |
-
Version 1.1.2 - Friday, 4th January 2019
|
110 |
* Fix: Import Cloud Template option not visible in thrive visual editor.
|
111 |
* Fix: Oceanwp css conflict with checkout layout.
|
112 |
* Fix: WC error notice in elementor preview mode when Elementor pro is not active/installed.
|
113 |
|
114 |
-
Version 1.1.1 - Wednesday, 2nd January 2019
|
115 |
* Improvement: Added compatibility for a future release of CartFlows Pro.
|
116 |
* Improvement: Minor CSS and HTML changes.
|
117 |
* Fix: Flatsome UX builder compatibility added.
|
@@ -119,32 +123,31 @@ Version 1.1.1 - Wednesday, 2nd January 2019
|
|
119 |
* Fix: Divi CSS issue.
|
120 |
* Fix: Other minor bugs.
|
121 |
|
122 |
-
Version 1.1.0.1 - Friday, 7th December 2018
|
123 |
* Fix: Checkout breaking issue.
|
124 |
|
125 |
-
Version 1.1.0 - Wednesday, 5th December 2018
|
126 |
* New: Ready for Order Bump Positions.
|
127 |
* Improvement: PixelYourSite compatibility added.
|
128 |
* Fix: Elementor preview not working for some permalinks.
|
129 |
* Fix: Checkout field label alignment issue.
|
130 |
* Fix: Long field text overlap on mobile.
|
131 |
|
132 |
-
|
133 |
-
Version 1.0.4 - Friday, 23rd November 2018
|
134 |
* Fix: Thank you page style meta option issue.
|
135 |
|
136 |
-
Version 1.0.3 - Friday, 23rd November 2018
|
137 |
* Improvement: Optimized flow and step import.
|
138 |
* Fix: Elementor page preview not working if landing page is set as homepage.
|
139 |
* Fix: Landing page issue when set as home-page. Used Home url instead of Site url.
|
140 |
|
141 |
-
Version 1.0.2 - Wednesday, 21st November 2018
|
142 |
* Fix: Address fields misalignment on checkout page.
|
143 |
|
144 |
-
Version 1.0.1 - Wednesday, 21st November 2018
|
145 |
* New: Checkout persistence remember data
|
146 |
* Fix: Link issue in Beaver Builder
|
147 |
* Fix: Unwanted fields on checkout page.
|
148 |
|
149 |
-
Version 1.0.0 - Monday, 19th November 2018
|
150 |
* Initial Release
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.0.2
|
8 |
+
Stable tag: 1.1.5
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
93 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
94 |
|
95 |
== Changelog ==
|
96 |
+
= Version 1.1.5 - Wednesday, 23rd January 2019 =
|
97 |
+
* Fix: Beaver Builder Pro version conflict while installing templates.
|
98 |
+
* Fix: Elementor builder white screen while editing checkout page and cart is empty.
|
99 |
+
|
100 |
+
= Version 1.1.4 - Tuesday, 22nd January 2019 =
|
101 |
* New: Beaver Builder templates.
|
102 |
* Improvement: Better error handling on the checkout page.
|
103 |
* Fix: Product variants were not getting aligned properly in the order summary.
|
104 |
* Fix: Divi builder conflict.
|
105 |
|
106 |
+
= Version 1.1.3 - Tuesday, 15th January 2019 =
|
107 |
* New: Import / Export the flows
|
108 |
* Improvement: Pixel Caffeine plugin pixel compatibility added.
|
109 |
* Improvement: Filter introduced to change the coupon field placeholder & button text.
|
110 |
* Fix: Clone option conflict with Duplicate post and Duplicate page plugin.
|
111 |
* Fix: Cart is not empty after purchase.
|
112 |
|
113 |
+
= Version 1.1.2 - Friday, 4th January 2019 =
|
114 |
* Fix: Import Cloud Template option not visible in thrive visual editor.
|
115 |
* Fix: Oceanwp css conflict with checkout layout.
|
116 |
* Fix: WC error notice in elementor preview mode when Elementor pro is not active/installed.
|
117 |
|
118 |
+
= Version 1.1.1 - Wednesday, 2nd January 2019 =
|
119 |
* Improvement: Added compatibility for a future release of CartFlows Pro.
|
120 |
* Improvement: Minor CSS and HTML changes.
|
121 |
* Fix: Flatsome UX builder compatibility added.
|
123 |
* Fix: Divi CSS issue.
|
124 |
* Fix: Other minor bugs.
|
125 |
|
126 |
+
= Version 1.1.0.1 - Friday, 7th December 2018 =
|
127 |
* Fix: Checkout breaking issue.
|
128 |
|
129 |
+
= Version 1.1.0 - Wednesday, 5th December 2018 =
|
130 |
* New: Ready for Order Bump Positions.
|
131 |
* Improvement: PixelYourSite compatibility added.
|
132 |
* Fix: Elementor preview not working for some permalinks.
|
133 |
* Fix: Checkout field label alignment issue.
|
134 |
* Fix: Long field text overlap on mobile.
|
135 |
|
136 |
+
= Version 1.0.4 - Friday, 23rd November 2018 =
|
|
|
137 |
* Fix: Thank you page style meta option issue.
|
138 |
|
139 |
+
= Version 1.0.3 - Friday, 23rd November 2018 =
|
140 |
* Improvement: Optimized flow and step import.
|
141 |
* Fix: Elementor page preview not working if landing page is set as homepage.
|
142 |
* Fix: Landing page issue when set as home-page. Used Home url instead of Site url.
|
143 |
|
144 |
+
= Version 1.0.2 - Wednesday, 21st November 2018 =
|
145 |
* Fix: Address fields misalignment on checkout page.
|
146 |
|
147 |
+
= Version 1.0.1 - Wednesday, 21st November 2018 =
|
148 |
* New: Checkout persistence remember data
|
149 |
* Fix: Link issue in Beaver Builder
|
150 |
* Fix: Unwanted fields on checkout page.
|
151 |
|
152 |
+
= Version 1.0.0 - Monday, 19th November 2018 =
|
153 |
* Initial Release
|