Version Description
Download this release
Release Info
Developer | sandesh055 |
Plugin | Funnel Builder by CartFlows – Create High Converting Sales Funnels For WordPress |
Version | 1.1.12 |
Comparing to | |
See all releases |
Code changes from version 1.1.11 to 1.1.12
- assets/css/checkout-template-rtl.css +14 -1
- assets/css/checkout-template.css +14 -1
- cartflows.php +1 -1
- changelog.txt +4 -0
- classes/class-cartflows-admin.php +437 -437
- classes/class-cartflows-helper.php +464 -464
- classes/class-cartflows-loader.php +1 -1
- languages/cartflows.pot +6 -6
- modules/checkout/classes/class-cartflows-checkout-markup.php +1112 -1111
- modules/flow/classes/class-cartflows-step-post-type.php +470 -470
- modules/flow/templates/template-canvas.php +49 -49
- modules/flow/templates/template-default.php +54 -54
- modules/flow/view/meta-flow-steps.php +200 -200
- modules/landing/classes/class-cartflows-landing-markup.php +139 -133
- modules/thankyou/classes/class-cartflows-thankyou-markup.php +274 -273
- readme.txt +6 -2
assets/css/checkout-template-rtl.css
CHANGED
@@ -296,7 +296,7 @@
|
|
296 |
border-left-color: transparent;
|
297 |
border-right-color: transparent;
|
298 |
border-top-color: transparent;
|
299 |
-
border-color: #eaeaea;
|
300 |
position: absolute;
|
301 |
top: -.75em;
|
302 |
right: 0;
|
@@ -898,4 +898,17 @@ a.et_pb_more_button:after{
|
|
898 |
.woocommerce-page input.button.alt:hover:after,
|
899 |
.woocommerce-page input.button:hover:after{
|
900 |
opacity: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
901 |
}
|
296 |
border-left-color: transparent;
|
297 |
border-right-color: transparent;
|
298 |
border-top-color: transparent;
|
299 |
+
border-bottom-color: #eaeaea;
|
300 |
position: absolute;
|
301 |
top: -.75em;
|
302 |
right: 0;
|
898 |
.woocommerce-page input.button.alt:hover:after,
|
899 |
.woocommerce-page input.button:hover:after{
|
900 |
opacity: 0;
|
901 |
+
}
|
902 |
+
|
903 |
+
|
904 |
+
/**
|
905 |
+
* **************************
|
906 |
+
* Thrive Compatibility css
|
907 |
+
* **************************
|
908 |
+
*/
|
909 |
+
|
910 |
+
.thrv_wrapper .wcf-embed-checkout-form div{
|
911 |
+
-webkit-box-sizing: border-box;
|
912 |
+
-moz-box-sizing: border-box;
|
913 |
+
box-sizing: border-box;
|
914 |
}
|
assets/css/checkout-template.css
CHANGED
@@ -296,7 +296,7 @@
|
|
296 |
border-right-color: transparent;
|
297 |
border-left-color: transparent;
|
298 |
border-top-color: transparent;
|
299 |
-
border-color: #eaeaea;
|
300 |
position: absolute;
|
301 |
top: -.75em;
|
302 |
left: 0;
|
@@ -898,4 +898,17 @@ a.et_pb_more_button:after{
|
|
898 |
.woocommerce-page input.button.alt:hover:after,
|
899 |
.woocommerce-page input.button:hover:after{
|
900 |
opacity: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
901 |
}
|
296 |
border-right-color: transparent;
|
297 |
border-left-color: transparent;
|
298 |
border-top-color: transparent;
|
299 |
+
border-bottom-color: #eaeaea;
|
300 |
position: absolute;
|
301 |
top: -.75em;
|
302 |
left: 0;
|
898 |
.woocommerce-page input.button.alt:hover:after,
|
899 |
.woocommerce-page input.button:hover:after{
|
900 |
opacity: 0;
|
901 |
+
}
|
902 |
+
|
903 |
+
|
904 |
+
/**
|
905 |
+
* **************************
|
906 |
+
* Thrive Compatibility css
|
907 |
+
* **************************
|
908 |
+
*/
|
909 |
+
|
910 |
+
.thrv_wrapper .wcf-embed-checkout-form div{
|
911 |
+
-webkit-box-sizing: border-box;
|
912 |
+
-moz-box-sizing: border-box;
|
913 |
+
box-sizing: border-box;
|
914 |
}
|
cartflows.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: CartFlows
|
4 |
* Plugin URI: https://cartflows.com/
|
5 |
* Description: Create beautiful checkout pages & sales flows for WooCommerce.
|
6 |
-
* Version: 1.1.
|
7 |
* Author: CartFlows Inc
|
8 |
* Author URI: https://cartflows.com/
|
9 |
* Text Domain: cartflows
|
3 |
* Plugin Name: CartFlows
|
4 |
* Plugin URI: https://cartflows.com/
|
5 |
* Description: Create beautiful checkout pages & sales flows for WooCommerce.
|
6 |
+
* Version: 1.1.12
|
7 |
* Author: CartFlows Inc
|
8 |
* Author URI: https://cartflows.com/
|
9 |
* Text Domain: cartflows
|
changelog.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
Version 1.1.11 - Tuesday, 19th March 2019
|
2 |
- Fix: Checkbox tick on checkout was not visible in some cases.
|
3 |
- Fix: Width issue of order review.
|
1 |
+
Version 1.1.12 - Friday, 22nd March 2019
|
2 |
+
- New: Added ability to set checkout page as a home page.
|
3 |
+
- Fix: Thrive Architect CSS conflict.
|
4 |
+
|
5 |
Version 1.1.11 - Tuesday, 19th March 2019
|
6 |
- Fix: Checkbox tick on checkout was not visible in some cases.
|
7 |
- Fix: Width issue of order review.
|
classes/class-cartflows-admin.php
CHANGED
@@ -1,437 +1,437 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CartFlows Admin.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Cartflows_Admin.
|
10 |
-
*/
|
11 |
-
class Cartflows_Admin {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Calls on initialization
|
15 |
-
*
|
16 |
-
* @since 1.0.0
|
17 |
-
*/
|
18 |
-
public static function init() {
|
19 |
-
|
20 |
-
self::initialise_plugin();
|
21 |
-
self::init_hooks();
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Init Hooks.
|
26 |
-
*
|
27 |
-
* @since 1.0.0
|
28 |
-
* @return void
|
29 |
-
*/
|
30 |
-
static public function init_hooks() {
|
31 |
-
|
32 |
-
if ( ! is_admin() ) {
|
33 |
-
return;
|
34 |
-
}
|
35 |
-
|
36 |
-
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
|
37 |
-
|
38 |
-
// Add CARTFLOWS menu option to admin.
|
39 |
-
add_action( 'network_admin_menu', __CLASS__ . '::menu' );
|
40 |
-
add_action( 'admin_menu', __CLASS__ . '::menu' );
|
41 |
-
add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
|
42 |
-
|
43 |
-
add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
|
44 |
-
|
45 |
-
// Enqueue admin scripts.
|
46 |
-
if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
|
47 |
-
|
48 |
-
add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
|
49 |
-
|
50 |
-
self::save_settings();
|
51 |
-
}
|
52 |
-
|
53 |
-
/* Global Addmin Script */
|
54 |
-
add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
|
55 |
-
|
56 |
-
add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
|
57 |
-
|
58 |
-
/* Add lite version class to body */
|
59 |
-
add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Initialises the Plugin Name.
|
64 |
-
*
|
65 |
-
* @since 1.0.0
|
66 |
-
* @return void
|
67 |
-
*/
|
68 |
-
static public function initialise_plugin() {
|
69 |
-
|
70 |
-
$name = 'Cartflows';
|
71 |
-
$short_name = 'Cflows';
|
72 |
-
|
73 |
-
define( 'CARTFLOWS_PLUGIN_NAME', $name );
|
74 |
-
define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Renders the admin settings menu.
|
79 |
-
*
|
80 |
-
* @since 1.0.0
|
81 |
-
* @return void
|
82 |
-
*/
|
83 |
-
static public function menu() {
|
84 |
-
|
85 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
86 |
-
return;
|
87 |
-
}
|
88 |
-
|
89 |
-
add_menu_page(
|
90 |
-
'CartFlows',
|
91 |
-
'CartFlows',
|
92 |
-
'manage_options',
|
93 |
-
CARTFLOWS_SLUG,
|
94 |
-
__CLASS__ . '::render',
|
95 |
-
'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
|
96 |
-
39.7
|
97 |
-
);
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Add submenu to admin menu.
|
103 |
-
*
|
104 |
-
* @since 1.0.0
|
105 |
-
*/
|
106 |
-
static function submenu() {
|
107 |
-
|
108 |
-
$parent_slug = CARTFLOWS_SLUG;
|
109 |
-
$page_title = __( 'Settings', 'cartflows' );
|
110 |
-
$menu_title = __( 'Settings', 'cartflows' );
|
111 |
-
$capability = 'manage_options';
|
112 |
-
$menu_slug = 'cartflows_settings';
|
113 |
-
$callback = __CLASS__ . '::render';
|
114 |
-
|
115 |
-
add_submenu_page(
|
116 |
-
$parent_slug,
|
117 |
-
$page_title,
|
118 |
-
$menu_title,
|
119 |
-
$capability,
|
120 |
-
$menu_slug,
|
121 |
-
$callback
|
122 |
-
);
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* Renders the admin settings.
|
127 |
-
*
|
128 |
-
* @since 1.0.0
|
129 |
-
* @return void
|
130 |
-
*/
|
131 |
-
static public function render() {
|
132 |
-
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
133 |
-
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
134 |
-
$action = str_replace( '_', '-', $action );
|
135 |
-
|
136 |
-
// Enable header icon filter below.
|
137 |
-
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
138 |
-
|
139 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Renders the admin settings content.
|
144 |
-
*
|
145 |
-
* @since 1.0.0
|
146 |
-
* @return void
|
147 |
-
*/
|
148 |
-
static public function render_content() {
|
149 |
-
|
150 |
-
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
151 |
-
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
152 |
-
$action = str_replace( '_', '-', $action );
|
153 |
-
$action = 'general';
|
154 |
-
|
155 |
-
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
156 |
-
|
157 |
-
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Save Global Setting options.
|
162 |
-
*
|
163 |
-
* @since 1.0.0
|
164 |
-
*/
|
165 |
-
static public function save_common_settings() {
|
166 |
-
|
167 |
-
if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
|
168 |
-
|
169 |
-
$url = $_SERVER['REQUEST_URI'];
|
170 |
-
$input_settings = array();
|
171 |
-
$new_settings = array();
|
172 |
-
|
173 |
-
if ( isset( $_POST['_cartflows_common'] ) ) {
|
174 |
-
|
175 |
-
$input_settings = $_POST['_cartflows_common'];
|
176 |
-
|
177 |
-
// Loop through the input and sanitize each of the values.
|
178 |
-
foreach ( $input_settings as $key => $val ) {
|
179 |
-
|
180 |
-
if ( is_array( $val ) ) {
|
181 |
-
foreach ( $val as $k => $v ) {
|
182 |
-
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
|
183 |
-
}
|
184 |
-
} else {
|
185 |
-
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
186 |
-
}
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
|
191 |
-
|
192 |
-
$query = array(
|
193 |
-
'message' => 'saved',
|
194 |
-
);
|
195 |
-
|
196 |
-
$redirect_to = add_query_arg( $query, $url );
|
197 |
-
|
198 |
-
wp_redirect( $redirect_to );
|
199 |
-
exit;
|
200 |
-
} // End if statement.
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Check is cartflows admin.
|
205 |
-
*
|
206 |
-
* @since 1.0.0
|
207 |
-
* @return boolean
|
208 |
-
*/
|
209 |
-
static public function is_global_admin() {
|
210 |
-
|
211 |
-
$current_screen = get_current_screen();
|
212 |
-
|
213 |
-
if (
|
214 |
-
is_object( $current_screen ) &&
|
215 |
-
isset( $current_screen->post_type ) &&
|
216 |
-
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
|
217 |
-
CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
|
218 |
-
)
|
219 |
-
) {
|
220 |
-
return true;
|
221 |
-
}
|
222 |
-
return false;
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Check is flow admin.
|
227 |
-
*
|
228 |
-
* @since 1.0.0
|
229 |
-
* @return boolean
|
230 |
-
*/
|
231 |
-
static public function is_flow_edit_admin() {
|
232 |
-
|
233 |
-
$current_screen = get_current_screen();
|
234 |
-
|
235 |
-
if (
|
236 |
-
is_object( $current_screen ) &&
|
237 |
-
isset( $current_screen->post_type ) &&
|
238 |
-
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
|
239 |
-
isset( $current_screen->base ) &&
|
240 |
-
( 'post' === $current_screen->base )
|
241 |
-
) {
|
242 |
-
return true;
|
243 |
-
}
|
244 |
-
return false;
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Global Admin Scripts.
|
249 |
-
*
|
250 |
-
* @since 1.0.0
|
251 |
-
*/
|
252 |
-
static public function global_admin_scripts() {
|
253 |
-
|
254 |
-
$localize = array(
|
255 |
-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
256 |
-
'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
|
257 |
-
);
|
258 |
-
|
259 |
-
wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
|
260 |
-
|
261 |
-
if ( self::is_global_admin() ) {
|
262 |
-
|
263 |
-
// Styles.
|
264 |
-
wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
|
265 |
-
wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
|
266 |
-
|
267 |
-
wp_enqueue_script(
|
268 |
-
'wcf-global-admin',
|
269 |
-
CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
|
270 |
-
array( 'jquery' ),
|
271 |
-
CARTFLOWS_VER,
|
272 |
-
true
|
273 |
-
);
|
274 |
-
|
275 |
-
do_action( 'cartflows_global_admin_scripts' );
|
276 |
-
}
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Global Admin Data.
|
281 |
-
*
|
282 |
-
* @since 1.0.0
|
283 |
-
*/
|
284 |
-
static public function global_admin_data() {
|
285 |
-
|
286 |
-
$current_screen = get_current_screen();
|
287 |
-
|
288 |
-
if ( ! $current_screen ) {
|
289 |
-
return;
|
290 |
-
}
|
291 |
-
|
292 |
-
if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
|
293 |
-
return;
|
294 |
-
}
|
295 |
-
|
296 |
-
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
297 |
-
?>
|
298 |
-
|
299 |
-
<div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
|
300 |
-
<div class="wcf-templates-popup-content">
|
301 |
-
<div class="spinner"></div>
|
302 |
-
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
303 |
-
|
304 |
-
<div id="wcf-remote-flow-actions" class="wcf-template-header">
|
305 |
-
<div class="wcf-template-logo-wrap">
|
306 |
-
<span class="wcf-cartflows-logo-img">
|
307 |
-
<span class="cartflows-logo-icon"></span>
|
308 |
-
</span>
|
309 |
-
<span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
|
310 |
-
</div>
|
311 |
-
<div class="wcf-tab-wrapper">
|
312 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
313 |
-
<div id="wcf-get-started-steps">
|
314 |
-
<ul class="filter-links ">
|
315 |
-
<li>
|
316 |
-
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
317 |
-
</li>
|
318 |
-
<li>
|
319 |
-
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
320 |
-
</li>
|
321 |
-
</ul>
|
322 |
-
</div>
|
323 |
-
<?php } ?>
|
324 |
-
</div>
|
325 |
-
<div class="wcf-popup-close-wrap">
|
326 |
-
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
327 |
-
</div>
|
328 |
-
</div>
|
329 |
-
<!-- <div class="wcf-search-form">
|
330 |
-
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
331 |
-
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
332 |
-
</div> -->
|
333 |
-
|
334 |
-
<div id="wcf-remote-content">
|
335 |
-
<?php if ( 'other' !== $default_page_builder ) { ?>
|
336 |
-
<div id="wcf-ready-templates">
|
337 |
-
<div id="wcf-remote-filters">
|
338 |
-
<div id="wcf-page-builders"></div>
|
339 |
-
<div id="wcf-categories"></div>
|
340 |
-
</div>
|
341 |
-
<div class="wcf-page-builder-notice"></div>
|
342 |
-
<div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
343 |
-
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
344 |
-
</div>
|
345 |
-
<?php } ?>
|
346 |
-
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
347 |
-
<div class="inner">
|
348 |
-
<a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
|
349 |
-
<p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
|
350 |
-
</div>
|
351 |
-
</div>
|
352 |
-
</div>
|
353 |
-
</div>
|
354 |
-
</div>
|
355 |
-
</div>
|
356 |
-
|
357 |
-
<?php
|
358 |
-
}
|
359 |
-
|
360 |
-
/**
|
361 |
-
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
362 |
-
*
|
363 |
-
* @since 1.0.0
|
364 |
-
*/
|
365 |
-
static public function styles_scripts() {
|
366 |
-
|
367 |
-
// Styles.
|
368 |
-
wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
|
369 |
-
wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
|
370 |
-
|
371 |
-
// Script.
|
372 |
-
wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
|
373 |
-
|
374 |
-
$localize = array(
|
375 |
-
'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
|
376 |
-
);
|
377 |
-
|
378 |
-
wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
|
379 |
-
}
|
380 |
-
|
381 |
-
/**
|
382 |
-
* Save All admin settings here
|
383 |
-
*/
|
384 |
-
static public function save_settings() {
|
385 |
-
|
386 |
-
// Only admins can save settings.
|
387 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
388 |
-
return;
|
389 |
-
}
|
390 |
-
|
391 |
-
self::save_common_settings();
|
392 |
-
|
393 |
-
// Let extensions hook into saving.
|
394 |
-
do_action( 'cartflows_admin_settings_save' );
|
395 |
-
}
|
396 |
-
|
397 |
-
/**
|
398 |
-
* Get and return page URL
|
399 |
-
*
|
400 |
-
* @param string $menu_slug Menu name.
|
401 |
-
* @since 1.0.0
|
402 |
-
* @return string page url
|
403 |
-
*/
|
404 |
-
static public function get_page_url( $menu_slug ) {
|
405 |
-
|
406 |
-
$parent_page = self::$default_menu_position;
|
407 |
-
|
408 |
-
if ( strpos( $parent_page, '?' ) !== false ) {
|
409 |
-
$query_var = '&page=' . self::$plugin_slug;
|
410 |
-
} else {
|
411 |
-
$query_var = '?page=' . self::$plugin_slug;
|
412 |
-
}
|
413 |
-
|
414 |
-
$parent_page_url = admin_url( $parent_page . $query_var );
|
415 |
-
|
416 |
-
$url = $parent_page_url . '&action=' . $menu_slug;
|
417 |
-
|
418 |
-
return esc_url( $url );
|
419 |
-
}
|
420 |
-
|
421 |
-
/**
|
422 |
-
* Admin body classes.
|
423 |
-
*
|
424 |
-
* Body classes to be added to <body> tag in admin page
|
425 |
-
*
|
426 |
-
* @param String $classes body classes returned from the filter.
|
427 |
-
* @return String body classes to be added to <body> tag in admin page
|
428 |
-
*/
|
429 |
-
static public function add_admin_body_class( $classes ) {
|
430 |
-
|
431 |
-
$classes .= ' cartflows-' . CARTFLOWS_VER;
|
432 |
-
|
433 |
-
return $classes;
|
434 |
-
}
|
435 |
-
}
|
436 |
-
|
437 |
-
Cartflows_Admin::init();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CartFlows Admin.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Cartflows_Admin.
|
10 |
+
*/
|
11 |
+
class Cartflows_Admin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Calls on initialization
|
15 |
+
*
|
16 |
+
* @since 1.0.0
|
17 |
+
*/
|
18 |
+
public static function init() {
|
19 |
+
|
20 |
+
self::initialise_plugin();
|
21 |
+
self::init_hooks();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Init Hooks.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
static public function init_hooks() {
|
31 |
+
|
32 |
+
if ( ! is_admin() ) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin-fields.php';
|
37 |
+
|
38 |
+
// Add CARTFLOWS menu option to admin.
|
39 |
+
add_action( 'network_admin_menu', __CLASS__ . '::menu' );
|
40 |
+
add_action( 'admin_menu', __CLASS__ . '::menu' );
|
41 |
+
add_action( 'admin_menu', __CLASS__ . '::submenu', 999 );
|
42 |
+
|
43 |
+
add_action( 'cartflows_render_admin_content', __CLASS__ . '::render_content' );
|
44 |
+
|
45 |
+
// Enqueue admin scripts.
|
46 |
+
if ( isset( $_REQUEST['page'] ) && CARTFLOWS_SETTINGS == $_REQUEST['page'] ) {
|
47 |
+
|
48 |
+
add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
|
49 |
+
|
50 |
+
self::save_settings();
|
51 |
+
}
|
52 |
+
|
53 |
+
/* Global Addmin Script */
|
54 |
+
add_action( 'admin_enqueue_scripts', __CLASS__ . '::global_admin_scripts', 20 );
|
55 |
+
|
56 |
+
add_action( 'admin_footer', __CLASS__ . '::global_admin_data', 9555 );
|
57 |
+
|
58 |
+
/* Add lite version class to body */
|
59 |
+
add_action( 'admin_body_class', __CLASS__ . '::add_admin_body_class' );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Initialises the Plugin Name.
|
64 |
+
*
|
65 |
+
* @since 1.0.0
|
66 |
+
* @return void
|
67 |
+
*/
|
68 |
+
static public function initialise_plugin() {
|
69 |
+
|
70 |
+
$name = 'Cartflows';
|
71 |
+
$short_name = 'Cflows';
|
72 |
+
|
73 |
+
define( 'CARTFLOWS_PLUGIN_NAME', $name );
|
74 |
+
define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name );
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Renders the admin settings menu.
|
79 |
+
*
|
80 |
+
* @since 1.0.0
|
81 |
+
* @return void
|
82 |
+
*/
|
83 |
+
static public function menu() {
|
84 |
+
|
85 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
add_menu_page(
|
90 |
+
'CartFlows',
|
91 |
+
'CartFlows',
|
92 |
+
'manage_options',
|
93 |
+
CARTFLOWS_SLUG,
|
94 |
+
__CLASS__ . '::render',
|
95 |
+
'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),
|
96 |
+
39.7
|
97 |
+
);
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Add submenu to admin menu.
|
103 |
+
*
|
104 |
+
* @since 1.0.0
|
105 |
+
*/
|
106 |
+
static function submenu() {
|
107 |
+
|
108 |
+
$parent_slug = CARTFLOWS_SLUG;
|
109 |
+
$page_title = __( 'Settings', 'cartflows' );
|
110 |
+
$menu_title = __( 'Settings', 'cartflows' );
|
111 |
+
$capability = 'manage_options';
|
112 |
+
$menu_slug = 'cartflows_settings';
|
113 |
+
$callback = __CLASS__ . '::render';
|
114 |
+
|
115 |
+
add_submenu_page(
|
116 |
+
$parent_slug,
|
117 |
+
$page_title,
|
118 |
+
$menu_title,
|
119 |
+
$capability,
|
120 |
+
$menu_slug,
|
121 |
+
$callback
|
122 |
+
);
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Renders the admin settings.
|
127 |
+
*
|
128 |
+
* @since 1.0.0
|
129 |
+
* @return void
|
130 |
+
*/
|
131 |
+
static public function render() {
|
132 |
+
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
133 |
+
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
134 |
+
$action = str_replace( '_', '-', $action );
|
135 |
+
|
136 |
+
// Enable header icon filter below.
|
137 |
+
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
138 |
+
|
139 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php';
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Renders the admin settings content.
|
144 |
+
*
|
145 |
+
* @since 1.0.0
|
146 |
+
* @return void
|
147 |
+
*/
|
148 |
+
static public function render_content() {
|
149 |
+
|
150 |
+
$action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( $_GET['action'] ) : '';
|
151 |
+
$action = ( ! empty( $action ) && '' != $action ) ? $action : 'general';
|
152 |
+
$action = str_replace( '_', '-', $action );
|
153 |
+
$action = 'general';
|
154 |
+
|
155 |
+
$header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) );
|
156 |
+
|
157 |
+
include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php';
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Save Global Setting options.
|
162 |
+
*
|
163 |
+
* @since 1.0.0
|
164 |
+
*/
|
165 |
+
static public function save_common_settings() {
|
166 |
+
|
167 |
+
if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( $_POST['cartflows-common-settings-nonce'], 'cartflows-common-settings' ) ) {
|
168 |
+
|
169 |
+
$url = $_SERVER['REQUEST_URI'];
|
170 |
+
$input_settings = array();
|
171 |
+
$new_settings = array();
|
172 |
+
|
173 |
+
if ( isset( $_POST['_cartflows_common'] ) ) {
|
174 |
+
|
175 |
+
$input_settings = $_POST['_cartflows_common'];
|
176 |
+
|
177 |
+
// Loop through the input and sanitize each of the values.
|
178 |
+
foreach ( $input_settings as $key => $val ) {
|
179 |
+
|
180 |
+
if ( is_array( $val ) ) {
|
181 |
+
foreach ( $val as $k => $v ) {
|
182 |
+
$new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : '';
|
183 |
+
}
|
184 |
+
} else {
|
185 |
+
$new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, true );
|
191 |
+
|
192 |
+
$query = array(
|
193 |
+
'message' => 'saved',
|
194 |
+
);
|
195 |
+
|
196 |
+
$redirect_to = add_query_arg( $query, $url );
|
197 |
+
|
198 |
+
wp_redirect( $redirect_to );
|
199 |
+
exit;
|
200 |
+
} // End if statement.
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Check is cartflows admin.
|
205 |
+
*
|
206 |
+
* @since 1.0.0
|
207 |
+
* @return boolean
|
208 |
+
*/
|
209 |
+
static public function is_global_admin() {
|
210 |
+
|
211 |
+
$current_screen = get_current_screen();
|
212 |
+
|
213 |
+
if (
|
214 |
+
is_object( $current_screen ) &&
|
215 |
+
isset( $current_screen->post_type ) &&
|
216 |
+
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ||
|
217 |
+
CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type
|
218 |
+
)
|
219 |
+
) {
|
220 |
+
return true;
|
221 |
+
}
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Check is flow admin.
|
227 |
+
*
|
228 |
+
* @since 1.0.0
|
229 |
+
* @return boolean
|
230 |
+
*/
|
231 |
+
static public function is_flow_edit_admin() {
|
232 |
+
|
233 |
+
$current_screen = get_current_screen();
|
234 |
+
|
235 |
+
if (
|
236 |
+
is_object( $current_screen ) &&
|
237 |
+
isset( $current_screen->post_type ) &&
|
238 |
+
( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) &&
|
239 |
+
isset( $current_screen->base ) &&
|
240 |
+
( 'post' === $current_screen->base )
|
241 |
+
) {
|
242 |
+
return true;
|
243 |
+
}
|
244 |
+
return false;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Global Admin Scripts.
|
249 |
+
*
|
250 |
+
* @since 1.0.0
|
251 |
+
*/
|
252 |
+
static public function global_admin_scripts() {
|
253 |
+
|
254 |
+
$localize = array(
|
255 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
256 |
+
'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ),
|
257 |
+
);
|
258 |
+
|
259 |
+
wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) );
|
260 |
+
|
261 |
+
if ( self::is_global_admin() ) {
|
262 |
+
|
263 |
+
// Styles.
|
264 |
+
wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER );
|
265 |
+
wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' );
|
266 |
+
|
267 |
+
wp_enqueue_script(
|
268 |
+
'wcf-global-admin',
|
269 |
+
CARTFLOWS_URL . 'admin/assets/js/global-admin.js',
|
270 |
+
array( 'jquery' ),
|
271 |
+
CARTFLOWS_VER,
|
272 |
+
true
|
273 |
+
);
|
274 |
+
|
275 |
+
do_action( 'cartflows_global_admin_scripts' );
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Global Admin Data.
|
281 |
+
*
|
282 |
+
* @since 1.0.0
|
283 |
+
*/
|
284 |
+
static public function global_admin_data() {
|
285 |
+
|
286 |
+
$current_screen = get_current_screen();
|
287 |
+
|
288 |
+
if ( ! $current_screen ) {
|
289 |
+
return;
|
290 |
+
}
|
291 |
+
|
292 |
+
if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) {
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
|
296 |
+
$default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
|
297 |
+
?>
|
298 |
+
|
299 |
+
<div id="wcf-remote-flow-importer" class="wcf-templates-popup-overlay">
|
300 |
+
<div class="wcf-templates-popup-content">
|
301 |
+
<div class="spinner"></div>
|
302 |
+
<div class="wcf-templates-wrap wcf-templates-wrap-flows">
|
303 |
+
|
304 |
+
<div id="wcf-remote-flow-actions" class="wcf-template-header">
|
305 |
+
<div class="wcf-template-logo-wrap">
|
306 |
+
<span class="wcf-cartflows-logo-img">
|
307 |
+
<span class="cartflows-logo-icon"></span>
|
308 |
+
</span>
|
309 |
+
<span class="wcf-cartflows-title"><?php _e( 'Flows Library', 'cartflows' ); ?></span>
|
310 |
+
</div>
|
311 |
+
<div class="wcf-tab-wrapper">
|
312 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
313 |
+
<div id="wcf-get-started-steps">
|
314 |
+
<ul class="filter-links ">
|
315 |
+
<li>
|
316 |
+
<a href="#" class="current" data-slug="ready-templates" data-title="<?php _e( 'Ready Templates', 'cartflows' ); ?>"><?php _e( 'Ready Templates', 'cartflows' ); ?></a>
|
317 |
+
</li>
|
318 |
+
<li>
|
319 |
+
<a href="#" data-slug="canvas" data-title="<?php _e( 'Create Your Own', 'cartflows' ); ?>"><?php _e( 'Create Your Own', 'cartflows' ); ?></a>
|
320 |
+
</li>
|
321 |
+
</ul>
|
322 |
+
</div>
|
323 |
+
<?php } ?>
|
324 |
+
</div>
|
325 |
+
<div class="wcf-popup-close-wrap">
|
326 |
+
<span class="close-icon"><span class="wcf-cartflow-icons dashicons dashicons-no"></span></span>
|
327 |
+
</div>
|
328 |
+
</div>
|
329 |
+
<!-- <div class="wcf-search-form">
|
330 |
+
<label class="screen-reader-text" for="wp-filter-search-input"><?php _e( 'Search Sites', 'cartflows' ); ?> </label>
|
331 |
+
<input placeholder="<?php _e( 'Search Flow...', 'cartflows' ); ?>" type="text" aria-describedby="live-search-desc" class="wcf-flow-search-input">
|
332 |
+
</div> -->
|
333 |
+
|
334 |
+
<div id="wcf-remote-content">
|
335 |
+
<?php if ( 'other' !== $default_page_builder ) { ?>
|
336 |
+
<div id="wcf-ready-templates">
|
337 |
+
<div id="wcf-remote-filters">
|
338 |
+
<div id="wcf-page-builders"></div>
|
339 |
+
<div id="wcf-categories"></div>
|
340 |
+
</div>
|
341 |
+
<div class="wcf-page-builder-notice"></div>
|
342 |
+
<div id="wcf-remote-flow-list" class="wcf-remote-list wcf-template-list-wrap"><span class="spinner is-active"></span></div>
|
343 |
+
<div id="wcf-upcoming-page-builders" style="display: none;" class="wcf-remote-list wcf-template-list-wrap"></div>
|
344 |
+
</div>
|
345 |
+
<?php } ?>
|
346 |
+
<div id="wcf-start-from-scratch" style="<?php echo ( 'other' !== $default_page_builder ) ? 'display: none;' : ''; ?>">
|
347 |
+
<div class="inner">
|
348 |
+
<a href="#" class="button button-hero button-primary cartflows-flow-import-blank"><?php _e( 'Design Your Flow', 'cartflows' ); ?></a>
|
349 |
+
<p class="wcf-learn-how"><a href="https://cartflows.com/docs/cartflows-step-types/" target="_blank"><?php _e( 'Learn How', 'cartflows' ); ?> <i class="dashicons dashicons-external"></i></a></p>
|
350 |
+
</div>
|
351 |
+
</div>
|
352 |
+
</div>
|
353 |
+
</div>
|
354 |
+
</div>
|
355 |
+
</div>
|
356 |
+
|
357 |
+
<?php
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
362 |
+
*
|
363 |
+
* @since 1.0.0
|
364 |
+
*/
|
365 |
+
static public function styles_scripts() {
|
366 |
+
|
367 |
+
// Styles.
|
368 |
+
wp_enqueue_style( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/css/admin-menu-settings.css', array(), CARTFLOWS_VER );
|
369 |
+
wp_style_add_data( 'cartflows-admin-settings', 'rtl', 'replace' );
|
370 |
+
|
371 |
+
// Script.
|
372 |
+
wp_enqueue_script( 'cartflows-admin-settings', CARTFLOWS_URL . 'admin/assets/js/admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER );
|
373 |
+
|
374 |
+
$localize = array(
|
375 |
+
'ajax_nonce' => wp_create_nonce( 'cartflows-widget-nonce' ),
|
376 |
+
);
|
377 |
+
|
378 |
+
wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) );
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Save All admin settings here
|
383 |
+
*/
|
384 |
+
static public function save_settings() {
|
385 |
+
|
386 |
+
// Only admins can save settings.
|
387 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
388 |
+
return;
|
389 |
+
}
|
390 |
+
|
391 |
+
self::save_common_settings();
|
392 |
+
|
393 |
+
// Let extensions hook into saving.
|
394 |
+
do_action( 'cartflows_admin_settings_save' );
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Get and return page URL
|
399 |
+
*
|
400 |
+
* @param string $menu_slug Menu name.
|
401 |
+
* @since 1.0.0
|
402 |
+
* @return string page url
|
403 |
+
*/
|
404 |
+
static public function get_page_url( $menu_slug ) {
|
405 |
+
|
406 |
+
$parent_page = self::$default_menu_position;
|
407 |
+
|
408 |
+
if ( strpos( $parent_page, '?' ) !== false ) {
|
409 |
+
$query_var = '&page=' . self::$plugin_slug;
|
410 |
+
} else {
|
411 |
+
$query_var = '?page=' . self::$plugin_slug;
|
412 |
+
}
|
413 |
+
|
414 |
+
$parent_page_url = admin_url( $parent_page . $query_var );
|
415 |
+
|
416 |
+
$url = $parent_page_url . '&action=' . $menu_slug;
|
417 |
+
|
418 |
+
return esc_url( $url );
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Admin body classes.
|
423 |
+
*
|
424 |
+
* Body classes to be added to <body> tag in admin page
|
425 |
+
*
|
426 |
+
* @param String $classes body classes returned from the filter.
|
427 |
+
* @return String body classes to be added to <body> tag in admin page
|
428 |
+
*/
|
429 |
+
static public function add_admin_body_class( $classes ) {
|
430 |
+
|
431 |
+
$classes .= ' cartflows-' . CARTFLOWS_VER;
|
432 |
+
|
433 |
+
return $classes;
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
Cartflows_Admin::init();
|
classes/class-cartflows-helper.php
CHANGED
@@ -1,464 +1,464 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CARTFLOWS Helper.
|
4 |
-
*
|
5 |
-
* @package CARTFLOWS
|
6 |
-
*/
|
7 |
-
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit; // Exit if accessed directly.
|
10 |
-
}
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class Cartflows_Helper.
|
14 |
-
*/
|
15 |
-
class Cartflows_Helper {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Common global data
|
19 |
-
*
|
20 |
-
* @var zapier
|
21 |
-
*/
|
22 |
-
private static $common = null;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Installed Plugins
|
26 |
-
*
|
27 |
-
* @since 1.1.4
|
28 |
-
*
|
29 |
-
* @access private
|
30 |
-
* @var array Installed plugins list.
|
31 |
-
*/
|
32 |
-
private static $installed_plugins = null;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Checkout Fields
|
36 |
-
*
|
37 |
-
* @var checkout_fields
|
38 |
-
*/
|
39 |
-
private static $checkout_fields = null;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Returns an option from the database for
|
43 |
-
* the admin settings page.
|
44 |
-
*
|
45 |
-
* @param string $key The option key.
|
46 |
-
* @param mixed $default Option default value if option is not available.
|
47 |
-
* @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
|
48 |
-
* @return string Return the option value
|
49 |
-
*/
|
50 |
-
public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
|
51 |
-
|
52 |
-
// Get the site-wide option if we're in the network admin.
|
53 |
-
if ( $network_override && is_multisite() ) {
|
54 |
-
$value = get_site_option( $key, $default );
|
55 |
-
} else {
|
56 |
-
$value = get_option( $key, $default );
|
57 |
-
}
|
58 |
-
|
59 |
-
return $value;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Updates an option from the admin settings page.
|
64 |
-
*
|
65 |
-
* @param string $key The option key.
|
66 |
-
* @param mixed $value The value to update.
|
67 |
-
* @param bool $network Whether to allow the network admin setting to be overridden on subsites.
|
68 |
-
* @return mixed
|
69 |
-
*/
|
70 |
-
static public function update_admin_settings_option( $key, $value, $network = false ) {
|
71 |
-
|
72 |
-
// Update the site-wide option since we're in the network admin.
|
73 |
-
if ( $network && is_multisite() ) {
|
74 |
-
update_site_option( $key, $value );
|
75 |
-
} else {
|
76 |
-
update_option( $key, $value );
|
77 |
-
}
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Get single setting
|
83 |
-
*
|
84 |
-
* @since 1.1.4
|
85 |
-
*
|
86 |
-
* @param string $key Option key.
|
87 |
-
* @param string $default Option default value if not exist.
|
88 |
-
* @return mixed
|
89 |
-
*/
|
90 |
-
static public function get_common_setting( $key = '', $default = '' ) {
|
91 |
-
$settings = self::get_common_settings();
|
92 |
-
|
93 |
-
if ( $settings && array_key_exists( $key, $settings ) ) {
|
94 |
-
return $settings[ $key ];
|
95 |
-
}
|
96 |
-
|
97 |
-
return $default;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Get required plugins for page builder
|
102 |
-
*
|
103 |
-
* @since 1.1.4
|
104 |
-
*
|
105 |
-
* @param string $page_builder_slug Page builder slug.
|
106 |
-
* @param string $default Default page builder.
|
107 |
-
* @return array selected page builder required plugins list.
|
108 |
-
*/
|
109 |
-
public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
|
110 |
-
$plugins = self::get_plugins_groupby_page_builders();
|
111 |
-
|
112 |
-
if ( array_key_exists( $page_builder_slug, $plugins ) ) {
|
113 |
-
return $plugins[ $page_builder_slug ];
|
114 |
-
}
|
115 |
-
|
116 |
-
return $plugins[ $default ];
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Get Plugins list by page builder.
|
121 |
-
*
|
122 |
-
* @since 1.1.4
|
123 |
-
*
|
124 |
-
* @return array Required Plugins list.
|
125 |
-
*/
|
126 |
-
public static function get_plugins_groupby_page_builders() {
|
127 |
-
|
128 |
-
$divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
|
129 |
-
$theme_status = 'not-installed';
|
130 |
-
if ( $divi_status ) {
|
131 |
-
if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
|
132 |
-
$theme_status = 'installed';
|
133 |
-
if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
|
134 |
-
$theme_status = 'deactivate';
|
135 |
-
$divi_status = 'activate';
|
136 |
-
} else {
|
137 |
-
$divi_status = '';
|
138 |
-
}
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
$plugins = array(
|
143 |
-
'elementor' => array(
|
144 |
-
'title' => 'Elementor',
|
145 |
-
'plugins' => array(
|
146 |
-
array(
|
147 |
-
'slug' => 'elementor', // For download from wp.org.
|
148 |
-
'init' => 'elementor/elementor.php',
|
149 |
-
'status' => self::get_plugin_status( 'elementor/elementor.php' ),
|
150 |
-
),
|
151 |
-
),
|
152 |
-
),
|
153 |
-
'divi' => array(
|
154 |
-
'title' => 'Divi',
|
155 |
-
'theme-status' => $theme_status,
|
156 |
-
'plugin-status' => $divi_status,
|
157 |
-
'plugins' => array(
|
158 |
-
array(
|
159 |
-
'slug' => 'divi-builder', // For download from wp.org.
|
160 |
-
'init' => 'divi-builder/divi-builder.php',
|
161 |
-
'status' => $divi_status,
|
162 |
-
),
|
163 |
-
),
|
164 |
-
),
|
165 |
-
);
|
166 |
-
|
167 |
-
$plugins['beaver-builder'] = array(
|
168 |
-
'title' => 'Beaver Builder',
|
169 |
-
'plugins' => array(),
|
170 |
-
);
|
171 |
-
|
172 |
-
// Check Pro Exist.
|
173 |
-
if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
|
174 |
-
$plugins['beaver-builder']['plugins'][] = array(
|
175 |
-
'slug' => 'bb-plugin',
|
176 |
-
'init' => 'bb-plugin/fl-builder.php',
|
177 |
-
'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
|
178 |
-
);
|
179 |
-
} else {
|
180 |
-
$plugins['beaver-builder']['plugins'][] = array(
|
181 |
-
'slug' => 'beaver-builder-lite-version', // For download from wp.org.
|
182 |
-
'init' => 'beaver-builder-lite-version/fl-builder.php',
|
183 |
-
'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
|
184 |
-
);
|
185 |
-
}
|
186 |
-
|
187 |
-
if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-ultimate-addon/bb-ultimate-addon.php' ) && ! is_plugin_active( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) {
|
188 |
-
$plugins['beaver-builder']['plugins'][] = array(
|
189 |
-
'slug' => 'bb-ultimate-addon',
|
190 |
-
'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
191 |
-
'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
|
192 |
-
);
|
193 |
-
} else {
|
194 |
-
$plugins['beaver-builder']['plugins'][] = array(
|
195 |
-
'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
|
196 |
-
'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
|
197 |
-
'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
|
198 |
-
);
|
199 |
-
}
|
200 |
-
|
201 |
-
return $plugins;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Get plugin status
|
206 |
-
*
|
207 |
-
* @since 1.1.4
|
208 |
-
*
|
209 |
-
* @param string $plugin_init_file Plguin init file.
|
210 |
-
* @return mixed
|
211 |
-
*/
|
212 |
-
public static function get_plugin_status( $plugin_init_file ) {
|
213 |
-
|
214 |
-
if ( null == self::$installed_plugins ) {
|
215 |
-
self::$installed_plugins = get_plugins();
|
216 |
-
}
|
217 |
-
|
218 |
-
if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
|
219 |
-
return 'install';
|
220 |
-
} elseif ( ! is_plugin_active( $plugin_init_file ) ) {
|
221 |
-
return 'activate';
|
222 |
-
}
|
223 |
-
|
224 |
-
return;
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* Get zapier settings.
|
229 |
-
*
|
230 |
-
* @return array.
|
231 |
-
*/
|
232 |
-
static public function get_common_settings() {
|
233 |
-
|
234 |
-
if ( null === self::$common ) {
|
235 |
-
|
236 |
-
$common_default = apply_filters(
|
237 |
-
'cartflows_common_settings_default',
|
238 |
-
array(
|
239 |
-
'disallow_indexing' => 'disable',
|
240 |
-
'global_checkout' => '',
|
241 |
-
'default_page_builder' => 'elementor',
|
242 |
-
)
|
243 |
-
);
|
244 |
-
|
245 |
-
$common = Cartflows_Helper::get_admin_settings_option( '_cartflows_common', false, true );
|
246 |
-
|
247 |
-
$common = wp_parse_args( $common, $common_default );
|
248 |
-
|
249 |
-
if ( ! did_action( 'wp' ) ) {
|
250 |
-
return $common;
|
251 |
-
} else {
|
252 |
-
self::$common = $common;
|
253 |
-
}
|
254 |
-
}
|
255 |
-
|
256 |
-
return self::$common;
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
* Get Checkout field.
|
261 |
-
*
|
262 |
-
* @param string $key Field key.
|
263 |
-
* @param int $post_id Post id.
|
264 |
-
* @return array.
|
265 |
-
*/
|
266 |
-
static public function get_checkout_fields( $key, $post_id ) {
|
267 |
-
|
268 |
-
$saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
|
269 |
-
|
270 |
-
if ( ! $saved_fields ) {
|
271 |
-
$saved_fields = array();
|
272 |
-
}
|
273 |
-
|
274 |
-
$fields = array_filter( $saved_fields );
|
275 |
-
|
276 |
-
if ( empty( $fields ) ) {
|
277 |
-
if ( 'billing' === $key || 'shipping' === $key ) {
|
278 |
-
|
279 |
-
$fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
|
280 |
-
|
281 |
-
update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
|
282 |
-
}
|
283 |
-
}
|
284 |
-
|
285 |
-
return $fields;
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* Add Checkout field.
|
290 |
-
*
|
291 |
-
* @param string $type Field type.
|
292 |
-
* @param string $field_key Field key.
|
293 |
-
* @param array $field_data Field data.
|
294 |
-
* @param int $post_id Post id.
|
295 |
-
* @return boolean.
|
296 |
-
*/
|
297 |
-
static public function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
|
298 |
-
|
299 |
-
$fields = self::get_checkout_fields( $type, $post_id );
|
300 |
-
|
301 |
-
$fields[ $field_key ] = $field_data;
|
302 |
-
|
303 |
-
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
304 |
-
|
305 |
-
return true;
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* Get checkout fields settings.
|
310 |
-
*
|
311 |
-
* @param string $type Field type.
|
312 |
-
* @param string $field_key Field key.
|
313 |
-
* @param int $post_id Post id.
|
314 |
-
* @return array.
|
315 |
-
*/
|
316 |
-
static public function delete_checkout_field( $type, $field_key, $post_id ) {
|
317 |
-
|
318 |
-
$fields = self::get_checkout_fields( $type, $post_id );
|
319 |
-
|
320 |
-
if ( isset( $fields[ $field_key ] ) ) {
|
321 |
-
unset( $fields[ $field_key ] );
|
322 |
-
}
|
323 |
-
|
324 |
-
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
325 |
-
|
326 |
-
return true;
|
327 |
-
}
|
328 |
-
|
329 |
-
/**
|
330 |
-
* Get checkout fields settings.
|
331 |
-
*
|
332 |
-
* @return array.
|
333 |
-
*/
|
334 |
-
static public function get_checkout_fields_settings() {
|
335 |
-
|
336 |
-
if ( null === self::$checkout_fields ) {
|
337 |
-
$checkout_fields_default = array(
|
338 |
-
'enable_customization' => 'disable',
|
339 |
-
'enable_billing_fields' => 'disable',
|
340 |
-
);
|
341 |
-
|
342 |
-
$billing_fields = self::get_checkout_fields( 'billing' );
|
343 |
-
|
344 |
-
if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
|
345 |
-
|
346 |
-
foreach ( $billing_fields as $key => $value ) {
|
347 |
-
|
348 |
-
$checkout_fields_default[ $key ] = 'enable';
|
349 |
-
}
|
350 |
-
}
|
351 |
-
|
352 |
-
$checkout_fields = Cartflows_Helper::get_admin_settings_option( '_wcf_checkout_fields', false, true );
|
353 |
-
|
354 |
-
self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
|
355 |
-
}
|
356 |
-
|
357 |
-
return self::$checkout_fields;
|
358 |
-
}
|
359 |
-
|
360 |
-
/**
|
361 |
-
* Get meta options
|
362 |
-
*
|
363 |
-
* @since 1.0.0
|
364 |
-
* @param int $post_id Product ID.
|
365 |
-
* @param string $key Meta Key.
|
366 |
-
* @param string $default Default value.
|
367 |
-
* @return string Meta Value.
|
368 |
-
*/
|
369 |
-
static public function get_meta_option( $post_id, $key, $default = '' ) {
|
370 |
-
|
371 |
-
$value = get_post_meta( $post_id, $key, true );
|
372 |
-
|
373 |
-
if ( ! $value ) {
|
374 |
-
$value = $default;
|
375 |
-
}
|
376 |
-
|
377 |
-
return $value;
|
378 |
-
}
|
379 |
-
|
380 |
-
/**
|
381 |
-
* Save meta option
|
382 |
-
*
|
383 |
-
* @since 1.0.0
|
384 |
-
* @param int $post_id Product ID.
|
385 |
-
* @param array $args Arguments array.
|
386 |
-
*/
|
387 |
-
static public function save_meta_option( $post_id, $args = array() ) {
|
388 |
-
|
389 |
-
if ( is_array( $args ) && ! empty( $args ) ) {
|
390 |
-
|
391 |
-
foreach ( $args as $key => $value ) {
|
392 |
-
|
393 |
-
update_post_meta( $post_id, $key, $value );
|
394 |
-
}
|
395 |
-
}
|
396 |
-
}
|
397 |
-
|
398 |
-
/**
|
399 |
-
* Check if Elementor page builder is installed
|
400 |
-
*
|
401 |
-
* @since 1.0.0
|
402 |
-
*
|
403 |
-
* @access public
|
404 |
-
*/
|
405 |
-
static public function _is_elementor_installed() {
|
406 |
-
$path = 'elementor/elementor.php';
|
407 |
-
$plugins = get_plugins();
|
408 |
-
|
409 |
-
return isset( $plugins[ $path ] );
|
410 |
-
}
|
411 |
-
|
412 |
-
/**
|
413 |
-
* Check if Step has product assigned.
|
414 |
-
*
|
415 |
-
* @since 1.0.0
|
416 |
-
* @param int $step_id step ID.
|
417 |
-
*
|
418 |
-
* @access public
|
419 |
-
*/
|
420 |
-
static public function has_product_assigned( $step_id ) {
|
421 |
-
|
422 |
-
$step_type = get_post_meta( $step_id, 'wcf-step-type', true );
|
423 |
-
|
424 |
-
if ( 'checkout' == $step_type ) {
|
425 |
-
$product = get_post_meta( $step_id, 'wcf-checkout-products', true );
|
426 |
-
} else {
|
427 |
-
$product = get_post_meta( $step_id, 'wcf-offer-product', true );
|
428 |
-
}
|
429 |
-
|
430 |
-
if ( ! empty( $product ) ) {
|
431 |
-
return true;
|
432 |
-
}
|
433 |
-
return false;
|
434 |
-
|
435 |
-
}
|
436 |
-
|
437 |
-
/**
|
438 |
-
* Get attributes for cartflows wrap.
|
439 |
-
*
|
440 |
-
* @since 1.1.4
|
441 |
-
*
|
442 |
-
* @access public
|
443 |
-
*/
|
444 |
-
static public function get_cartflows_container_atts() {
|
445 |
-
|
446 |
-
$attributes = apply_filters( 'cartflows_container_atts', array() );
|
447 |
-
$atts_string = '';
|
448 |
-
|
449 |
-
foreach ( $attributes as $key => $value ) {
|
450 |
-
|
451 |
-
if ( ! $value ) {
|
452 |
-
continue;
|
453 |
-
}
|
454 |
-
|
455 |
-
if ( true === $value ) {
|
456 |
-
$atts_string .= esc_html( $key ) . ' ';
|
457 |
-
} else {
|
458 |
-
$atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
|
459 |
-
}
|
460 |
-
}
|
461 |
-
|
462 |
-
return $atts_string;
|
463 |
-
}
|
464 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CARTFLOWS Helper.
|
4 |
+
*
|
5 |
+
* @package CARTFLOWS
|
6 |
+
*/
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class Cartflows_Helper.
|
14 |
+
*/
|
15 |
+
class Cartflows_Helper {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Common global data
|
19 |
+
*
|
20 |
+
* @var zapier
|
21 |
+
*/
|
22 |
+
private static $common = null;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Installed Plugins
|
26 |
+
*
|
27 |
+
* @since 1.1.4
|
28 |
+
*
|
29 |
+
* @access private
|
30 |
+
* @var array Installed plugins list.
|
31 |
+
*/
|
32 |
+
private static $installed_plugins = null;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Checkout Fields
|
36 |
+
*
|
37 |
+
* @var checkout_fields
|
38 |
+
*/
|
39 |
+
private static $checkout_fields = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns an option from the database for
|
43 |
+
* the admin settings page.
|
44 |
+
*
|
45 |
+
* @param string $key The option key.
|
46 |
+
* @param mixed $default Option default value if option is not available.
|
47 |
+
* @param boolean $network_override Whether to allow the network admin setting to be overridden on subsites.
|
48 |
+
* @return string Return the option value
|
49 |
+
*/
|
50 |
+
public static function get_admin_settings_option( $key, $default = false, $network_override = false ) {
|
51 |
+
|
52 |
+
// Get the site-wide option if we're in the network admin.
|
53 |
+
if ( $network_override && is_multisite() ) {
|
54 |
+
$value = get_site_option( $key, $default );
|
55 |
+
} else {
|
56 |
+
$value = get_option( $key, $default );
|
57 |
+
}
|
58 |
+
|
59 |
+
return $value;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Updates an option from the admin settings page.
|
64 |
+
*
|
65 |
+
* @param string $key The option key.
|
66 |
+
* @param mixed $value The value to update.
|
67 |
+
* @param bool $network Whether to allow the network admin setting to be overridden on subsites.
|
68 |
+
* @return mixed
|
69 |
+
*/
|
70 |
+
static public function update_admin_settings_option( $key, $value, $network = false ) {
|
71 |
+
|
72 |
+
// Update the site-wide option since we're in the network admin.
|
73 |
+
if ( $network && is_multisite() ) {
|
74 |
+
update_site_option( $key, $value );
|
75 |
+
} else {
|
76 |
+
update_option( $key, $value );
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Get single setting
|
83 |
+
*
|
84 |
+
* @since 1.1.4
|
85 |
+
*
|
86 |
+
* @param string $key Option key.
|
87 |
+
* @param string $default Option default value if not exist.
|
88 |
+
* @return mixed
|
89 |
+
*/
|
90 |
+
static public function get_common_setting( $key = '', $default = '' ) {
|
91 |
+
$settings = self::get_common_settings();
|
92 |
+
|
93 |
+
if ( $settings && array_key_exists( $key, $settings ) ) {
|
94 |
+
return $settings[ $key ];
|
95 |
+
}
|
96 |
+
|
97 |
+
return $default;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get required plugins for page builder
|
102 |
+
*
|
103 |
+
* @since 1.1.4
|
104 |
+
*
|
105 |
+
* @param string $page_builder_slug Page builder slug.
|
106 |
+
* @param string $default Default page builder.
|
107 |
+
* @return array selected page builder required plugins list.
|
108 |
+
*/
|
109 |
+
public static function get_required_plugins_for_page_builder( $page_builder_slug = '', $default = 'elementor' ) {
|
110 |
+
$plugins = self::get_plugins_groupby_page_builders();
|
111 |
+
|
112 |
+
if ( array_key_exists( $page_builder_slug, $plugins ) ) {
|
113 |
+
return $plugins[ $page_builder_slug ];
|
114 |
+
}
|
115 |
+
|
116 |
+
return $plugins[ $default ];
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get Plugins list by page builder.
|
121 |
+
*
|
122 |
+
* @since 1.1.4
|
123 |
+
*
|
124 |
+
* @return array Required Plugins list.
|
125 |
+
*/
|
126 |
+
public static function get_plugins_groupby_page_builders() {
|
127 |
+
|
128 |
+
$divi_status = self::get_plugin_status( 'divi-builder/divi-builder.php' );
|
129 |
+
$theme_status = 'not-installed';
|
130 |
+
if ( $divi_status ) {
|
131 |
+
if ( true === Cartflows_Compatibility::get_instance()->is_divi_theme_installed() ) {
|
132 |
+
$theme_status = 'installed';
|
133 |
+
if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) {
|
134 |
+
$theme_status = 'deactivate';
|
135 |
+
$divi_status = 'activate';
|
136 |
+
} else {
|
137 |
+
$divi_status = '';
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
$plugins = array(
|
143 |
+
'elementor' => array(
|
144 |
+
'title' => 'Elementor',
|
145 |
+
'plugins' => array(
|
146 |
+
array(
|
147 |
+
'slug' => 'elementor', // For download from wp.org.
|
148 |
+
'init' => 'elementor/elementor.php',
|
149 |
+
'status' => self::get_plugin_status( 'elementor/elementor.php' ),
|
150 |
+
),
|
151 |
+
),
|
152 |
+
),
|
153 |
+
'divi' => array(
|
154 |
+
'title' => 'Divi',
|
155 |
+
'theme-status' => $theme_status,
|
156 |
+
'plugin-status' => $divi_status,
|
157 |
+
'plugins' => array(
|
158 |
+
array(
|
159 |
+
'slug' => 'divi-builder', // For download from wp.org.
|
160 |
+
'init' => 'divi-builder/divi-builder.php',
|
161 |
+
'status' => $divi_status,
|
162 |
+
),
|
163 |
+
),
|
164 |
+
),
|
165 |
+
);
|
166 |
+
|
167 |
+
$plugins['beaver-builder'] = array(
|
168 |
+
'title' => 'Beaver Builder',
|
169 |
+
'plugins' => array(),
|
170 |
+
);
|
171 |
+
|
172 |
+
// Check Pro Exist.
|
173 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) {
|
174 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
175 |
+
'slug' => 'bb-plugin',
|
176 |
+
'init' => 'bb-plugin/fl-builder.php',
|
177 |
+
'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ),
|
178 |
+
);
|
179 |
+
} else {
|
180 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
181 |
+
'slug' => 'beaver-builder-lite-version', // For download from wp.org.
|
182 |
+
'init' => 'beaver-builder-lite-version/fl-builder.php',
|
183 |
+
'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ),
|
184 |
+
);
|
185 |
+
}
|
186 |
+
|
187 |
+
if ( file_exists( WP_PLUGIN_DIR . '/' . 'bb-ultimate-addon/bb-ultimate-addon.php' ) && ! is_plugin_active( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) {
|
188 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
189 |
+
'slug' => 'bb-ultimate-addon',
|
190 |
+
'init' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
191 |
+
'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ),
|
192 |
+
);
|
193 |
+
} else {
|
194 |
+
$plugins['beaver-builder']['plugins'][] = array(
|
195 |
+
'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org.
|
196 |
+
'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php',
|
197 |
+
'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ),
|
198 |
+
);
|
199 |
+
}
|
200 |
+
|
201 |
+
return $plugins;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Get plugin status
|
206 |
+
*
|
207 |
+
* @since 1.1.4
|
208 |
+
*
|
209 |
+
* @param string $plugin_init_file Plguin init file.
|
210 |
+
* @return mixed
|
211 |
+
*/
|
212 |
+
public static function get_plugin_status( $plugin_init_file ) {
|
213 |
+
|
214 |
+
if ( null == self::$installed_plugins ) {
|
215 |
+
self::$installed_plugins = get_plugins();
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) {
|
219 |
+
return 'install';
|
220 |
+
} elseif ( ! is_plugin_active( $plugin_init_file ) ) {
|
221 |
+
return 'activate';
|
222 |
+
}
|
223 |
+
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Get zapier settings.
|
229 |
+
*
|
230 |
+
* @return array.
|
231 |
+
*/
|
232 |
+
static public function get_common_settings() {
|
233 |
+
|
234 |
+
if ( null === self::$common ) {
|
235 |
+
|
236 |
+
$common_default = apply_filters(
|
237 |
+
'cartflows_common_settings_default',
|
238 |
+
array(
|
239 |
+
'disallow_indexing' => 'disable',
|
240 |
+
'global_checkout' => '',
|
241 |
+
'default_page_builder' => 'elementor',
|
242 |
+
)
|
243 |
+
);
|
244 |
+
|
245 |
+
$common = Cartflows_Helper::get_admin_settings_option( '_cartflows_common', false, true );
|
246 |
+
|
247 |
+
$common = wp_parse_args( $common, $common_default );
|
248 |
+
|
249 |
+
if ( ! did_action( 'wp' ) ) {
|
250 |
+
return $common;
|
251 |
+
} else {
|
252 |
+
self::$common = $common;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
return self::$common;
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Get Checkout field.
|
261 |
+
*
|
262 |
+
* @param string $key Field key.
|
263 |
+
* @param int $post_id Post id.
|
264 |
+
* @return array.
|
265 |
+
*/
|
266 |
+
static public function get_checkout_fields( $key, $post_id ) {
|
267 |
+
|
268 |
+
$saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true );
|
269 |
+
|
270 |
+
if ( ! $saved_fields ) {
|
271 |
+
$saved_fields = array();
|
272 |
+
}
|
273 |
+
|
274 |
+
$fields = array_filter( $saved_fields );
|
275 |
+
|
276 |
+
if ( empty( $fields ) ) {
|
277 |
+
if ( 'billing' === $key || 'shipping' === $key ) {
|
278 |
+
|
279 |
+
$fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' );
|
280 |
+
|
281 |
+
update_post_meta( $post_id, 'wcf_fields_' . $key, $fields );
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
return $fields;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Add Checkout field.
|
290 |
+
*
|
291 |
+
* @param string $type Field type.
|
292 |
+
* @param string $field_key Field key.
|
293 |
+
* @param array $field_data Field data.
|
294 |
+
* @param int $post_id Post id.
|
295 |
+
* @return boolean.
|
296 |
+
*/
|
297 |
+
static public function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) {
|
298 |
+
|
299 |
+
$fields = self::get_checkout_fields( $type, $post_id );
|
300 |
+
|
301 |
+
$fields[ $field_key ] = $field_data;
|
302 |
+
|
303 |
+
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
304 |
+
|
305 |
+
return true;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Get checkout fields settings.
|
310 |
+
*
|
311 |
+
* @param string $type Field type.
|
312 |
+
* @param string $field_key Field key.
|
313 |
+
* @param int $post_id Post id.
|
314 |
+
* @return array.
|
315 |
+
*/
|
316 |
+
static public function delete_checkout_field( $type, $field_key, $post_id ) {
|
317 |
+
|
318 |
+
$fields = self::get_checkout_fields( $type, $post_id );
|
319 |
+
|
320 |
+
if ( isset( $fields[ $field_key ] ) ) {
|
321 |
+
unset( $fields[ $field_key ] );
|
322 |
+
}
|
323 |
+
|
324 |
+
update_post_meta( $post_id, 'wcf_fields_' . $type, $fields );
|
325 |
+
|
326 |
+
return true;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Get checkout fields settings.
|
331 |
+
*
|
332 |
+
* @return array.
|
333 |
+
*/
|
334 |
+
static public function get_checkout_fields_settings() {
|
335 |
+
|
336 |
+
if ( null === self::$checkout_fields ) {
|
337 |
+
$checkout_fields_default = array(
|
338 |
+
'enable_customization' => 'disable',
|
339 |
+
'enable_billing_fields' => 'disable',
|
340 |
+
);
|
341 |
+
|
342 |
+
$billing_fields = self::get_checkout_fields( 'billing' );
|
343 |
+
|
344 |
+
if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) {
|
345 |
+
|
346 |
+
foreach ( $billing_fields as $key => $value ) {
|
347 |
+
|
348 |
+
$checkout_fields_default[ $key ] = 'enable';
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
$checkout_fields = Cartflows_Helper::get_admin_settings_option( '_wcf_checkout_fields', false, true );
|
353 |
+
|
354 |
+
self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default );
|
355 |
+
}
|
356 |
+
|
357 |
+
return self::$checkout_fields;
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Get meta options
|
362 |
+
*
|
363 |
+
* @since 1.0.0
|
364 |
+
* @param int $post_id Product ID.
|
365 |
+
* @param string $key Meta Key.
|
366 |
+
* @param string $default Default value.
|
367 |
+
* @return string Meta Value.
|
368 |
+
*/
|
369 |
+
static public function get_meta_option( $post_id, $key, $default = '' ) {
|
370 |
+
|
371 |
+
$value = get_post_meta( $post_id, $key, true );
|
372 |
+
|
373 |
+
if ( ! $value ) {
|
374 |
+
$value = $default;
|
375 |
+
}
|
376 |
+
|
377 |
+
return $value;
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Save meta option
|
382 |
+
*
|
383 |
+
* @since 1.0.0
|
384 |
+
* @param int $post_id Product ID.
|
385 |
+
* @param array $args Arguments array.
|
386 |
+
*/
|
387 |
+
static public function save_meta_option( $post_id, $args = array() ) {
|
388 |
+
|
389 |
+
if ( is_array( $args ) && ! empty( $args ) ) {
|
390 |
+
|
391 |
+
foreach ( $args as $key => $value ) {
|
392 |
+
|
393 |
+
update_post_meta( $post_id, $key, $value );
|
394 |
+
}
|
395 |
+
}
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Check if Elementor page builder is installed
|
400 |
+
*
|
401 |
+
* @since 1.0.0
|
402 |
+
*
|
403 |
+
* @access public
|
404 |
+
*/
|
405 |
+
static public function _is_elementor_installed() {
|
406 |
+
$path = 'elementor/elementor.php';
|
407 |
+
$plugins = get_plugins();
|
408 |
+
|
409 |
+
return isset( $plugins[ $path ] );
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Check if Step has product assigned.
|
414 |
+
*
|
415 |
+
* @since 1.0.0
|
416 |
+
* @param int $step_id step ID.
|
417 |
+
*
|
418 |
+
* @access public
|
419 |
+
*/
|
420 |
+
static public function has_product_assigned( $step_id ) {
|
421 |
+
|
422 |
+
$step_type = get_post_meta( $step_id, 'wcf-step-type', true );
|
423 |
+
|
424 |
+
if ( 'checkout' == $step_type ) {
|
425 |
+
$product = get_post_meta( $step_id, 'wcf-checkout-products', true );
|
426 |
+
} else {
|
427 |
+
$product = get_post_meta( $step_id, 'wcf-offer-product', true );
|
428 |
+
}
|
429 |
+
|
430 |
+
if ( ! empty( $product ) ) {
|
431 |
+
return true;
|
432 |
+
}
|
433 |
+
return false;
|
434 |
+
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Get attributes for cartflows wrap.
|
439 |
+
*
|
440 |
+
* @since 1.1.4
|
441 |
+
*
|
442 |
+
* @access public
|
443 |
+
*/
|
444 |
+
static public function get_cartflows_container_atts() {
|
445 |
+
|
446 |
+
$attributes = apply_filters( 'cartflows_container_atts', array() );
|
447 |
+
$atts_string = '';
|
448 |
+
|
449 |
+
foreach ( $attributes as $key => $value ) {
|
450 |
+
|
451 |
+
if ( ! $value ) {
|
452 |
+
continue;
|
453 |
+
}
|
454 |
+
|
455 |
+
if ( true === $value ) {
|
456 |
+
$atts_string .= esc_html( $key ) . ' ';
|
457 |
+
} else {
|
458 |
+
$atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) );
|
459 |
+
}
|
460 |
+
}
|
461 |
+
|
462 |
+
return $atts_string;
|
463 |
+
}
|
464 |
+
}
|
classes/class-cartflows-loader.php
CHANGED
@@ -115,7 +115,7 @@ if ( ! class_exists( 'Cartflows_Loader' ) ) {
|
|
115 |
define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
|
116 |
define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
|
117 |
define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
|
118 |
-
define( 'CARTFLOWS_VER', '1.1.
|
119 |
define( 'CARTFLOWS_SLUG', 'cartflows' );
|
120 |
define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
|
121 |
|
115 |
define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) );
|
116 |
define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) );
|
117 |
define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) );
|
118 |
+
define( 'CARTFLOWS_VER', '1.1.12' );
|
119 |
define( 'CARTFLOWS_SLUG', 'cartflows' );
|
120 |
define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' );
|
121 |
|
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-03-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -635,13 +635,13 @@ msgstr ""
|
|
635 |
msgid "This product can't be purcahsed"
|
636 |
msgstr ""
|
637 |
|
638 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
639 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
640 |
msgid "Coupon Code"
|
641 |
msgstr ""
|
642 |
|
643 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
644 |
-
#: modules/checkout/classes/class-cartflows-checkout-markup.php:
|
645 |
msgid "Apply"
|
646 |
msgstr ""
|
647 |
|
2 |
# This file is distributed under the same license as the CartFlows package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: CartFlows 1.1.12\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/cartflows\n"
|
7 |
+
"POT-Creation-Date: 2019-03-22 09:55:54+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
635 |
msgid "This product can't be purcahsed"
|
636 |
msgstr ""
|
637 |
|
638 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:948
|
639 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:967
|
640 |
msgid "Coupon Code"
|
641 |
msgstr ""
|
642 |
|
643 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:953
|
644 |
+
#: modules/checkout/classes/class-cartflows-checkout-markup.php:976
|
645 |
msgid "Apply"
|
646 |
msgstr ""
|
647 |
|
modules/checkout/classes/class-cartflows-checkout-markup.php
CHANGED
@@ -1,1111 +1,1112 @@
|
|
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 |
-
/**
|
74 |
-
* Display all WooCommerce notices.
|
75 |
-
*
|
76 |
-
* @since 1.1.5
|
77 |
-
*/
|
78 |
-
function display_woo_notices() {
|
79 |
-
|
80 |
-
if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
|
81 |
-
woocommerce_output_all_notices();
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Redirect from default to the global checkout page
|
88 |
-
*
|
89 |
-
* @since 1.0.0
|
90 |
-
*/
|
91 |
-
function global_checkout_template_redirect() {
|
92 |
-
|
93 |
-
if ( ! is_checkout() ) {
|
94 |
-
return;
|
95 |
-
}
|
96 |
-
|
97 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
98 |
-
return;
|
99 |
-
}
|
100 |
-
|
101 |
-
// redirect only from any non HC checkout pages.
|
102 |
-
$order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
|
103 |
-
$order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
|
104 |
-
|
105 |
-
$common = Cartflows_Helper::get_common_settings();
|
106 |
-
|
107 |
-
$global_checkout = $common['global_checkout'];
|
108 |
-
|
109 |
-
if (
|
110 |
-
// ignore on order-pay.
|
111 |
-
false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
|
112 |
-
// ignore on TY page.
|
113 |
-
false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
|
114 |
-
) {
|
115 |
-
|
116 |
-
if ( '' !== $global_checkout ) {
|
117 |
-
|
118 |
-
$link = get_permalink( $global_checkout );
|
119 |
-
|
120 |
-
if ( ! empty( $link ) ) {
|
121 |
-
|
122 |
-
wp_redirect( $link );
|
123 |
-
die();
|
124 |
-
}
|
125 |
-
}
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Check for checkout flag
|
131 |
-
*
|
132 |
-
* @param bool $is_checkout is checkout.
|
133 |
-
*
|
134 |
-
* @return bool
|
135 |
-
*/
|
136 |
-
function woo_checkout_flag( $is_checkout ) {
|
137 |
-
|
138 |
-
if ( ! is_admin() ) {
|
139 |
-
|
140 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
141 |
-
|
142 |
-
$is_checkout = true;
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
return $is_checkout;
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Render checkout shortcode markup.
|
151 |
-
*
|
152 |
-
* @param array $atts attributes.
|
153 |
-
* @return string
|
154 |
-
*/
|
155 |
-
function checkout_shortcode_markup( $atts ) {
|
156 |
-
|
157 |
-
if ( ! function_exists( 'wc_print_notices' ) ) {
|
158 |
-
return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
|
159 |
-
}
|
160 |
-
|
161 |
-
$atts = shortcode_atts(
|
162 |
-
array(
|
163 |
-
'id' => 0,
|
164 |
-
),
|
165 |
-
$atts
|
166 |
-
);
|
167 |
-
|
168 |
-
$checkout_id = intval( $atts['id'] );
|
169 |
-
|
170 |
-
if ( empty( $checkout_id ) ) {
|
171 |
-
|
172 |
-
if ( ! _is_wcf_checkout_type() ) {
|
173 |
-
|
174 |
-
return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
|
175 |
-
}
|
176 |
-
|
177 |
-
global $post;
|
178 |
-
|
179 |
-
$checkout_id = intval( $post->ID );
|
180 |
-
}
|
181 |
-
|
182 |
-
$output = '';
|
183 |
-
|
184 |
-
ob_start();
|
185 |
-
|
186 |
-
do_action( 'cartflows_checkout_form_before', $checkout_id );
|
187 |
-
|
188 |
-
$checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
|
189 |
-
|
190 |
-
$template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
|
191 |
-
|
192 |
-
$template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
|
193 |
-
|
194 |
-
if ( file_exists( $template_layout ) ) {
|
195 |
-
include $template_layout;
|
196 |
-
} else {
|
197 |
-
include $template_default;
|
198 |
-
}
|
199 |
-
|
200 |
-
$output .= ob_get_clean();
|
201 |
-
|
202 |
-
return $output;
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Configure Cart Data.
|
207 |
-
*
|
208 |
-
* @since 1.0.0
|
209 |
-
*
|
210 |
-
* @return void
|
211 |
-
*/
|
212 |
-
function preconfigured_cart_data() {
|
213 |
-
|
214 |
-
if ( is_admin() ) {
|
215 |
-
return;
|
216 |
-
}
|
217 |
-
|
218 |
-
global $post;
|
219 |
-
|
220 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
221 |
-
|
222 |
-
if ( wp_doing_ajax() ) {
|
223 |
-
|
224 |
-
return;
|
225 |
-
} else {
|
226 |
-
|
227 |
-
if ( _is_wcf_checkout_type() ) {
|
228 |
-
$checkout_id = $post->ID;
|
229 |
-
} else {
|
230 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
231 |
-
}
|
232 |
-
|
233 |
-
do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
|
234 |
-
|
235 |
-
$flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
|
236 |
-
|
237 |
-
if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
|
238 |
-
$products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
|
239 |
-
} else {
|
240 |
-
$products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
|
241 |
-
}
|
242 |
-
|
243 |
-
if ( ! is_array( $products ) ) {
|
244 |
-
|
245 |
-
if ( 'dummy' === $products ) {
|
246 |
-
|
247 |
-
$args = array(
|
248 |
-
'posts_per_page' => 1,
|
249 |
-
'orderby' => 'rand',
|
250 |
-
'post_type' => 'product',
|
251 |
-
'meta_query' => array(
|
252 |
-
// Exclude out of stock products.
|
253 |
-
array(
|
254 |
-
'key' => '_stock_status',
|
255 |
-
'value' => 'outofstock',
|
256 |
-
'compare' => 'NOT IN',
|
257 |
-
),
|
258 |
-
),
|
259 |
-
'tax_query' => array(
|
260 |
-
array(
|
261 |
-
'taxonomy' => 'product_type',
|
262 |
-
'field' => 'slug',
|
263 |
-
'terms' => 'simple',
|
264 |
-
),
|
265 |
-
),
|
266 |
-
);
|
267 |
-
|
268 |
-
$random_product = get_posts( $args );
|
269 |
-
|
270 |
-
if ( isset( $random_product[0]->ID ) ) {
|
271 |
-
$products = array(
|
272 |
-
array(
|
273 |
-
'product' => $random_product[0]->ID,
|
274 |
-
),
|
275 |
-
);
|
276 |
-
} else {
|
277 |
-
return;
|
278 |
-
}
|
279 |
-
} else {
|
280 |
-
return;
|
281 |
-
}
|
282 |
-
}
|
283 |
-
|
284 |
-
if ( is_array( $products ) && count( $products ) < 1 ) {
|
285 |
-
|
286 |
-
return;
|
287 |
-
}
|
288 |
-
/* Empty the current cart */
|
289 |
-
WC()->cart->empty_cart();
|
290 |
-
|
291 |
-
/* Set customer session if not set */
|
292 |
-
if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
|
293 |
-
WC()->session->set_customer_session_cookie( true );
|
294 |
-
}
|
295 |
-
|
296 |
-
$cart_product_count = 0;
|
297 |
-
|
298 |
-
foreach ( $products as $index => $data ) {
|
299 |
-
|
300 |
-
if ( ! isset( $data['product'] ) ) {
|
301 |
-
return;
|
302 |
-
}
|
303 |
-
|
304 |
-
if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
|
305 |
-
break;
|
306 |
-
}
|
307 |
-
|
308 |
-
$product_id = $data['product'];
|
309 |
-
$_product = wc_get_product( $product_id );
|
310 |
-
|
311 |
-
if ( ! empty( $_product ) ) {
|
312 |
-
|
313 |
-
$quantity = 1;
|
314 |
-
|
315 |
-
if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
|
316 |
-
|
317 |
-
if ( $_product->is_type( 'variable' ) ) {
|
318 |
-
|
319 |
-
$default_attributes = $_product->get_default_attributes();
|
320 |
-
|
321 |
-
if ( ! empty( $default_attributes ) ) {
|
322 |
-
|
323 |
-
foreach ( $_product->get_children() as $variation_id ) {
|
324 |
-
|
325 |
-
$single_variation = new WC_Product_Variation( $variation_id );
|
326 |
-
|
327 |
-
if ( $default_attributes == $single_variation->get_attributes() ) {
|
328 |
-
WC()->cart->add_to_cart( $variation_id, $quantity );
|
329 |
-
$cart_product_count++;
|
330 |
-
}
|
331 |
-
}
|
332 |
-
} else {
|
333 |
-
|
334 |
-
$product_childrens = $_product->get_children();
|
335 |
-
|
336 |
-
if ( isset( $product_childrens[0] ) ) {
|
337 |
-
WC()->cart->add_to_cart( $product_childrens[0], $quantity );
|
338 |
-
$cart_product_count++;
|
339 |
-
} else {
|
340 |
-
echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
|
341 |
-
}
|
342 |
-
}
|
343 |
-
} else {
|
344 |
-
WC()->cart->add_to_cart( $product_id, $quantity );
|
345 |
-
$cart_product_count++;
|
346 |
-
}
|
347 |
-
} else {
|
348 |
-
|
349 |
-
echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
|
350 |
-
// WC()->cart->add_to_cart( $product_id, $quantity );.
|
351 |
-
}
|
352 |
-
}
|
353 |
-
}
|
354 |
-
|
355 |
-
do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
|
356 |
-
do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
|
357 |
-
}
|
358 |
-
}
|
359 |
-
}
|
360 |
-
|
361 |
-
/**
|
362 |
-
* Load shortcode data.
|
363 |
-
*
|
364 |
-
* @return void
|
365 |
-
*/
|
366 |
-
function shortcode_load_data() {
|
367 |
-
|
368 |
-
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
369 |
-
|
370 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
|
371 |
-
|
372 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 );
|
373 |
-
|
374 |
-
/* Show notices if cart has errors */
|
375 |
-
add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
|
376 |
-
|
377 |
-
add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
|
378 |
-
|
379 |
-
add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
|
380 |
-
|
381 |
-
// Outputting the hidden field in checkout page.
|
382 |
-
add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
383 |
-
add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
384 |
-
|
385 |
-
remove_all_actions( 'woocommerce_checkout_billing' );
|
386 |
-
remove_all_actions( 'woocommerce_checkout_shipping' );
|
387 |
-
|
388 |
-
// Hook in actions once.
|
389 |
-
add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
|
390 |
-
add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
|
391 |
-
|
392 |
-
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
|
393 |
-
|
394 |
-
add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
|
395 |
-
|
396 |
-
add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
|
397 |
-
|
398 |
-
global $post;
|
399 |
-
|
400 |
-
if ( _is_wcf_checkout_type() ) {
|
401 |
-
$checkout_id = $post->ID;
|
402 |
-
} else {
|
403 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
404 |
-
}
|
405 |
-
|
406 |
-
do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
|
407 |
-
}
|
408 |
-
}
|
409 |
-
|
410 |
-
/**
|
411 |
-
* Render checkout ID hidden field.
|
412 |
-
*
|
413 |
-
* @param array $checkout checkout session data.
|
414 |
-
* @return void
|
415 |
-
*/
|
416 |
-
function checkout_shortcode_post_id( $checkout ) {
|
417 |
-
|
418 |
-
global $post;
|
419 |
-
|
420 |
-
if ( _is_wcf_checkout_type() ) {
|
421 |
-
$checkout_id = $post->ID;
|
422 |
-
} else {
|
423 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
424 |
-
}
|
425 |
-
|
426 |
-
$flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
|
427 |
-
|
428 |
-
echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
|
429 |
-
echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
|
430 |
-
}
|
431 |
-
|
432 |
-
/**
|
433 |
-
* Load shortcode scripts.
|
434 |
-
*
|
435 |
-
* @return void
|
436 |
-
*/
|
437 |
-
function shortcode_scripts() {
|
438 |
-
|
439 |
-
wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
|
440 |
-
wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
|
441 |
-
|
442 |
-
wp_enqueue_script(
|
443 |
-
'wcf-checkout-template',
|
444 |
-
CARTFLOWS_URL . 'assets/js/checkout-template.js',
|
445 |
-
array( 'jquery' ),
|
446 |
-
CARTFLOWS_VER,
|
447 |
-
true
|
448 |
-
);
|
449 |
-
|
450 |
-
do_action( 'cartflows_checkout_scripts' );
|
451 |
-
|
452 |
-
$style = $this->generate_style();
|
453 |
-
|
454 |
-
wp_add_inline_style( 'wcf-checkout-template', $style );
|
455 |
-
|
456 |
-
}
|
457 |
-
|
458 |
-
/**
|
459 |
-
* Load compatibility scripts.
|
460 |
-
*
|
461 |
-
* @return void
|
462 |
-
*/
|
463 |
-
function compatibility_scripts() {
|
464 |
-
|
465 |
-
global $post;
|
466 |
-
|
467 |
-
if ( _is_wcf_checkout_type() ) {
|
468 |
-
$checkout_id = $post->ID;
|
469 |
-
} else {
|
470 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
471 |
-
}
|
472 |
-
|
473 |
-
// Add DIVI Compatibility css if DIVI theme is enabled.
|
474 |
-
if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ||
|
475 |
-
Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id )
|
476 |
-
) {
|
477 |
-
wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
|
478 |
-
wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
|
479 |
-
}
|
480 |
-
|
481 |
-
// Add Flatsome Compatibility css if Flatsome theme is enabled.
|
482 |
-
if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
|
483 |
-
wp_enqueue_style( 'wcf-checkout-template-flatsome', CARTFLOWS_URL . 'assets/css/checkout-template-flatsome.css', '', CARTFLOWS_VER );
|
484 |
-
wp_style_add_data( 'wcf-checkout-template-flatsome', 'rtl', 'replace' );
|
485 |
-
}
|
486 |
-
|
487 |
-
// Add The7 Compatibility css if The7 theme is enabled.
|
488 |
-
if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) {
|
489 |
-
wp_enqueue_style( 'wcf-checkout-template-the-seven', CARTFLOWS_URL . 'assets/css/checkout-template-the-seven.css', '', CARTFLOWS_VER );
|
490 |
-
wp_style_add_data( 'wcf-checkout-template-the-seven', 'rtl', 'replace' );
|
491 |
-
}
|
492 |
-
}
|
493 |
-
|
494 |
-
/**
|
495 |
-
* Generate styles.
|
496 |
-
*
|
497 |
-
* @return string
|
498 |
-
*/
|
499 |
-
function generate_style() {
|
500 |
-
|
501 |
-
global $post;
|
502 |
-
|
503 |
-
if ( _is_wcf_checkout_type() ) {
|
504 |
-
$checkout_id = $post->ID;
|
505 |
-
} else {
|
506 |
-
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
507 |
-
}
|
508 |
-
|
509 |
-
CartFlows_Font_Families::render_fonts( $checkout_id );
|
510 |
-
|
511 |
-
$primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
|
512 |
-
|
513 |
-
$base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
|
514 |
-
|
515 |
-
$header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
|
516 |
-
|
517 |
-
/*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
|
518 |
-
$r = '';
|
519 |
-
$g = '';
|
520 |
-
$b = '';
|
521 |
-
|
522 |
-
$field_tb_padding = '';
|
523 |
-
$field_lr_padding = '';
|
524 |
-
|
525 |
-
$field_heading_color = '';
|
526 |
-
$field_color = '';
|
527 |
-
$field_bg_color = '';
|
528 |
-
$field_border_color = '';
|
529 |
-
$field_label_color = '';
|
530 |
-
$submit_tb_padding = '';
|
531 |
-
$submit_lr_padding = '';
|
532 |
-
$hl_bg_color = '';
|
533 |
-
$field_input_size = '';
|
534 |
-
$box_border_color = '';
|
535 |
-
$section_bg_color = '';
|
536 |
-
$submit_button_height = '';
|
537 |
-
$submit_color = '';
|
538 |
-
$submit_bg_color = $primary_color;
|
539 |
-
$submit_border_color = $primary_color;
|
540 |
-
|
541 |
-
$submit_hover_color = '';
|
542 |
-
$submit_bg_hover_color = $primary_color;
|
543 |
-
$submit_border_hover_color = $primary_color;
|
544 |
-
|
545 |
-
$section_heading_color = '';
|
546 |
-
|
547 |
-
$is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
|
548 |
-
|
549 |
-
$button_font_family = '';
|
550 |
-
$button_font_weight = '';
|
551 |
-
$input_font_family = '';
|
552 |
-
$input_font_weight = '';
|
553 |
-
$heading_font_family = '';
|
554 |
-
$heading_font_weight = '';
|
555 |
-
$base_font_family = $base_font_family;
|
556 |
-
/*$base_font_weight = $base_font_weight;*/
|
557 |
-
|
558 |
-
if ( 'yes' == $is_advance_option ) {
|
559 |
-
|
560 |
-
/**
|
561 |
-
* Get Font Family and Font Weight weight values
|
562 |
-
*/
|
563 |
-
$section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
|
564 |
-
|
565 |
-
$heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
|
566 |
-
$heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
|
567 |
-
$section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
|
568 |
-
$button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
|
569 |
-
$button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
|
570 |
-
$input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
|
571 |
-
$input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
|
572 |
-
$field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
|
573 |
-
$field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
|
574 |
-
$field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
|
575 |
-
|
576 |
-
$field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
|
577 |
-
|
578 |
-
$field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
|
579 |
-
|
580 |
-
$field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
|
581 |
-
|
582 |
-
$field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
|
583 |
-
|
584 |
-
$field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
|
585 |
-
|
586 |
-
$submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
|
587 |
-
|
588 |
-
$submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
|
589 |
-
|
590 |
-
$submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
|
591 |
-
|
592 |
-
$submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
|
593 |
-
|
594 |
-
$submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
|
595 |
-
|
596 |
-
$submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
|
597 |
-
|
598 |
-
$submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
|
599 |
-
|
600 |
-
$submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
|
601 |
-
|
602 |
-
$hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
|
603 |
-
|
604 |
-
$box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
|
605 |
-
|
606 |
-
$submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
|
607 |
-
|
608 |
-
/**
|
609 |
-
* Get font values
|
610 |
-
*/
|
611 |
-
|
612 |
-
if ( 'custom' == $submit_button_height ) {
|
613 |
-
$submit_button_height = '38px';
|
614 |
-
}
|
615 |
-
|
616 |
-
if ( 'custom' == $field_input_size ) {
|
617 |
-
$field_input_size = '38px';
|
618 |
-
}
|
619 |
-
}
|
620 |
-
if ( isset( $primary_color ) ) {
|
621 |
-
|
622 |
-
list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
|
623 |
-
}
|
624 |
-
$output = "
|
625 |
-
.wcf-embed-checkout-form .wcf-checkout-header-image img{
|
626 |
-
width: {$header_logo_width}px;
|
627 |
-
}
|
628 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
|
629 |
-
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
|
630 |
-
color: {$primary_color};
|
631 |
-
}
|
632 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
|
633 |
-
background-color: {$primary_color};
|
634 |
-
}
|
635 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
|
636 |
-
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
|
637 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
|
638 |
-
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
|
639 |
-
border-color: {$primary_color};
|
640 |
-
box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
|
641 |
-
}
|
642 |
-
.wcf-embed-checkout-form .woocommerce-checkout label{
|
643 |
-
color: {$field_label_color};
|
644 |
-
}
|
645 |
-
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
|
646 |
-
background-color: {$hl_bg_color};
|
647 |
-
font-family: {$input_font_family};
|
648 |
-
font-weight: {$input_font_weight};
|
649 |
-
}
|
650 |
-
|
651 |
-
.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
|
652 |
-
.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
|
653 |
-
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
|
654 |
-
{
|
655 |
-
border-color: {$hl_bg_color};
|
656 |
-
border-right-color: transparent;
|
657 |
-
border-left-color: transparent;
|
658 |
-
border-top-color: transparent;
|
659 |
-
position: absolute;
|
660 |
-
}
|
661 |
-
|
662 |
-
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
|
663 |
-
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
|
664 |
-
font-family: {$input_font_family};
|
665 |
-
font-weight: {$input_font_weight};
|
666 |
-
}
|
667 |
-
|
668 |
-
.wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
|
669 |
-
.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
|
670 |
-
.wcf-embed-checkout-form .woocommerce form .form-row textarea,
|
671 |
-
.wcf-embed-checkout-form .select2-container--default .select2-selection--single {
|
672 |
-
color: {$field_color};
|
673 |
-
background: {$field_bg_color};
|
674 |
-
border-color: {$field_border_color};
|
675 |
-
padding-top: {$field_tb_padding}px;
|
676 |
-
padding-bottom: {$field_tb_padding}px;
|
677 |
-
padding-left: {$field_lr_padding}px;
|
678 |
-
padding-right: {$field_lr_padding}px;
|
679 |
-
min-height: {$field_input_size};
|
680 |
-
font-family: {$input_font_family};
|
681 |
-
font-weight: {$input_font_weight};
|
682 |
-
}
|
683 |
-
|
684 |
-
.wcf-embed-checkout-form .woocommerce .col2-set .col-1,
|
685 |
-
.wcf-embed-checkout-form .woocommerce .col2-set .col-2,
|
686 |
-
.wcf-embed-checkout-form .woocommerce-checkout .shop_table,
|
687 |
-
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
|
688 |
-
.wcf-embed-checkout-form .woocommerce-checkout #payment,
|
689 |
-
.wcf-embed-checkout-form .woocommerce form.checkout_coupon
|
690 |
-
{
|
691 |
-
background-color: {$section_bg_color};
|
692 |
-
border-color: {$box_border_color};
|
693 |
-
font-family: {$input_font_family};
|
694 |
-
font-weight: {$input_font_weight};
|
695 |
-
}
|
696 |
-
|
697 |
-
.woocommerce table.shop_table th{
|
698 |
-
color: {$field_label_color};
|
699 |
-
}
|
700 |
-
/*.wcf-embed-checkout-form .woocommerce .woocommerce-info,
|
701 |
-
.wcf-embed-checkout-form .woocommerce-message{
|
702 |
-
border-top-color: {$primary_color};
|
703 |
-
background-color: {$hl_bg_color};
|
704 |
-
}*/
|
705 |
-
.wcf-embed-checkout-form .woocommerce a{
|
706 |
-
color: {$primary_color};
|
707 |
-
}
|
708 |
-
.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
|
709 |
-
color: {$field_color};
|
710 |
-
}
|
711 |
-
.wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
|
712 |
-
color: {$field_color};
|
713 |
-
}
|
714 |
-
.wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
|
715 |
-
color: {$field_color};
|
716 |
-
}
|
717 |
-
.wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
|
718 |
-
color: {$field_color};
|
719 |
-
}
|
720 |
-
.wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
|
721 |
-
color: {$field_color};
|
722 |
-
}
|
723 |
-
.wcf-embed-checkout-form .woocommerce form p.form-row label {
|
724 |
-
color: {$field_label_color};
|
725 |
-
font-family: {$input_font_family};
|
726 |
-
font-weight: {$input_font_weight};
|
727 |
-
}
|
728 |
-
.wcf-embed-checkout-form .woocommerce #order_review button,
|
729 |
-
.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,
|
730 |
-
.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small {
|
731 |
-
color: {$submit_color};
|
732 |
-
background: {$submit_bg_color};
|
733 |
-
padding-top: {$submit_tb_padding}px;
|
734 |
-
padding-bottom: {$submit_tb_padding}px;
|
735 |
-
padding-left: {$submit_lr_padding}px;
|
736 |
-
padding-right: {$submit_lr_padding}px;
|
737 |
-
border-color: {$submit_border_color};
|
738 |
-
min-height: {$submit_button_height};
|
739 |
-
font-family: {$button_font_family};
|
740 |
-
font-weight: {$button_font_weight};
|
741 |
-
}
|
742 |
-
.wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
|
743 |
-
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
|
744 |
-
background: {$submit_bg_color};
|
745 |
-
border: 1px {$submit_border_color} solid;
|
746 |
-
color: {$submit_color};
|
747 |
-
min-height: {$submit_button_height};
|
748 |
-
font-family: {$button_font_family};
|
749 |
-
font-weight: {$button_font_weight};
|
750 |
-
}
|
751 |
-
.wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
|
752 |
-
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
|
753 |
-
.wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
|
754 |
-
.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
|
755 |
-
color: {$submit_hover_color};
|
756 |
-
background-color: {$submit_bg_hover_color};
|
757 |
-
border-color: {$submit_border_hover_color};
|
758 |
-
}
|
759 |
-
.wcf-embed-checkout-form .woocommerce h3,
|
760 |
-
.wcf-embed-checkout-form .woocommerce h3 span,
|
761 |
-
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
|
762 |
-
color: {$section_heading_color};
|
763 |
-
font-family: {$heading_font_family};
|
764 |
-
font-weight: {$heading_font_weight};
|
765 |
-
}
|
766 |
-
.wcf-embed-checkout-form .woocommerce-info::before,
|
767 |
-
.wcf-embed-checkout-form .woocommerce-message::before{
|
768 |
-
color: {$primary_color};
|
769 |
-
}
|
770 |
-
.wcf-embed-checkout-form{
|
771 |
-
font-family: {$base_font_family};
|
772 |
-
}
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
*
|
780 |
-
*
|
781 |
-
* @
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
$uri = $
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
*
|
812 |
-
*
|
813 |
-
* @param
|
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 |
-
* @param
|
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 |
-
$fields['billing']['
|
1073 |
-
$fields['billing']['
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
$fields['shipping']['
|
1081 |
-
$fields['shipping']['
|
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 |
-
|
|
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 |
+
/**
|
74 |
+
* Display all WooCommerce notices.
|
75 |
+
*
|
76 |
+
* @since 1.1.5
|
77 |
+
*/
|
78 |
+
function display_woo_notices() {
|
79 |
+
|
80 |
+
if ( null != WC()->session && function_exists( 'woocommerce_output_all_notices' ) ) {
|
81 |
+
woocommerce_output_all_notices();
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Redirect from default to the global checkout page
|
88 |
+
*
|
89 |
+
* @since 1.0.0
|
90 |
+
*/
|
91 |
+
function global_checkout_template_redirect() {
|
92 |
+
|
93 |
+
if ( ! is_checkout() ) {
|
94 |
+
return;
|
95 |
+
}
|
96 |
+
|
97 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
98 |
+
return;
|
99 |
+
}
|
100 |
+
|
101 |
+
// redirect only from any non HC checkout pages.
|
102 |
+
$order_pay_endpoint = get_option( 'woocommerce_checkout_pay_endpoint', 'order-pay' );
|
103 |
+
$order_received_endpoint = get_option( 'woocommerce_checkout_order_received_endpoint', 'order-received' );
|
104 |
+
|
105 |
+
$common = Cartflows_Helper::get_common_settings();
|
106 |
+
|
107 |
+
$global_checkout = $common['global_checkout'];
|
108 |
+
|
109 |
+
if (
|
110 |
+
// ignore on order-pay.
|
111 |
+
false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_pay_endpoint . '/' ) &&
|
112 |
+
// ignore on TY page.
|
113 |
+
false === mb_strpos( $_SERVER['REQUEST_URI'], '/' . $order_received_endpoint . '/' )
|
114 |
+
) {
|
115 |
+
|
116 |
+
if ( '' !== $global_checkout ) {
|
117 |
+
|
118 |
+
$link = get_permalink( $global_checkout );
|
119 |
+
|
120 |
+
if ( ! empty( $link ) ) {
|
121 |
+
|
122 |
+
wp_redirect( $link );
|
123 |
+
die();
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Check for checkout flag
|
131 |
+
*
|
132 |
+
* @param bool $is_checkout is checkout.
|
133 |
+
*
|
134 |
+
* @return bool
|
135 |
+
*/
|
136 |
+
function woo_checkout_flag( $is_checkout ) {
|
137 |
+
|
138 |
+
if ( ! is_admin() ) {
|
139 |
+
|
140 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
141 |
+
|
142 |
+
$is_checkout = true;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
return $is_checkout;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Render checkout shortcode markup.
|
151 |
+
*
|
152 |
+
* @param array $atts attributes.
|
153 |
+
* @return string
|
154 |
+
*/
|
155 |
+
function checkout_shortcode_markup( $atts ) {
|
156 |
+
|
157 |
+
if ( ! function_exists( 'wc_print_notices' ) ) {
|
158 |
+
return '<p class="woocommerce-notice">' . __( 'WooCommerce functions not exists. If you are in iframe, please reload the iframe', 'cartflows' ) . '</p>';
|
159 |
+
}
|
160 |
+
|
161 |
+
$atts = shortcode_atts(
|
162 |
+
array(
|
163 |
+
'id' => 0,
|
164 |
+
),
|
165 |
+
$atts
|
166 |
+
);
|
167 |
+
|
168 |
+
$checkout_id = intval( $atts['id'] );
|
169 |
+
|
170 |
+
if ( empty( $checkout_id ) ) {
|
171 |
+
|
172 |
+
if ( ! _is_wcf_checkout_type() ) {
|
173 |
+
|
174 |
+
return '<h4>' . __( 'Checkout ID not found', 'cartflows' ) . '</h4>';
|
175 |
+
}
|
176 |
+
|
177 |
+
global $post;
|
178 |
+
|
179 |
+
$checkout_id = intval( $post->ID );
|
180 |
+
}
|
181 |
+
|
182 |
+
$output = '';
|
183 |
+
|
184 |
+
ob_start();
|
185 |
+
|
186 |
+
do_action( 'cartflows_checkout_form_before', $checkout_id );
|
187 |
+
|
188 |
+
$checkout_layout = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-layout' );
|
189 |
+
|
190 |
+
$template_default = CARTFLOWS_CHECKOUT_DIR . 'templates/embed/checkout-template-simple.php';
|
191 |
+
|
192 |
+
$template_layout = apply_filters( 'cartflows_checkout_layout_template', $checkout_layout );
|
193 |
+
|
194 |
+
if ( file_exists( $template_layout ) ) {
|
195 |
+
include $template_layout;
|
196 |
+
} else {
|
197 |
+
include $template_default;
|
198 |
+
}
|
199 |
+
|
200 |
+
$output .= ob_get_clean();
|
201 |
+
|
202 |
+
return $output;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Configure Cart Data.
|
207 |
+
*
|
208 |
+
* @since 1.0.0
|
209 |
+
*
|
210 |
+
* @return void
|
211 |
+
*/
|
212 |
+
function preconfigured_cart_data() {
|
213 |
+
|
214 |
+
if ( is_admin() ) {
|
215 |
+
return;
|
216 |
+
}
|
217 |
+
|
218 |
+
global $post;
|
219 |
+
|
220 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
221 |
+
|
222 |
+
if ( wp_doing_ajax() ) {
|
223 |
+
|
224 |
+
return;
|
225 |
+
} else {
|
226 |
+
|
227 |
+
if ( _is_wcf_checkout_type() ) {
|
228 |
+
$checkout_id = $post->ID;
|
229 |
+
} else {
|
230 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
231 |
+
}
|
232 |
+
|
233 |
+
do_action( 'cartflows_checkout_before_configure_cart', $checkout_id );
|
234 |
+
|
235 |
+
$flow_id = wcf()->utils->get_flow_id_from_step_id( $checkout_id );
|
236 |
+
|
237 |
+
if ( wcf()->flow->is_flow_testmode( $flow_id ) ) {
|
238 |
+
$products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products', 'dummy' );
|
239 |
+
} else {
|
240 |
+
$products = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-checkout-products' );
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( ! is_array( $products ) ) {
|
244 |
+
|
245 |
+
if ( 'dummy' === $products ) {
|
246 |
+
|
247 |
+
$args = array(
|
248 |
+
'posts_per_page' => 1,
|
249 |
+
'orderby' => 'rand',
|
250 |
+
'post_type' => 'product',
|
251 |
+
'meta_query' => array(
|
252 |
+
// Exclude out of stock products.
|
253 |
+
array(
|
254 |
+
'key' => '_stock_status',
|
255 |
+
'value' => 'outofstock',
|
256 |
+
'compare' => 'NOT IN',
|
257 |
+
),
|
258 |
+
),
|
259 |
+
'tax_query' => array(
|
260 |
+
array(
|
261 |
+
'taxonomy' => 'product_type',
|
262 |
+
'field' => 'slug',
|
263 |
+
'terms' => 'simple',
|
264 |
+
),
|
265 |
+
),
|
266 |
+
);
|
267 |
+
|
268 |
+
$random_product = get_posts( $args );
|
269 |
+
|
270 |
+
if ( isset( $random_product[0]->ID ) ) {
|
271 |
+
$products = array(
|
272 |
+
array(
|
273 |
+
'product' => $random_product[0]->ID,
|
274 |
+
),
|
275 |
+
);
|
276 |
+
} else {
|
277 |
+
return;
|
278 |
+
}
|
279 |
+
} else {
|
280 |
+
return;
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
if ( is_array( $products ) && count( $products ) < 1 ) {
|
285 |
+
|
286 |
+
return;
|
287 |
+
}
|
288 |
+
/* Empty the current cart */
|
289 |
+
WC()->cart->empty_cart();
|
290 |
+
|
291 |
+
/* Set customer session if not set */
|
292 |
+
if ( ! is_user_logged_in() && WC()->cart->is_empty() ) {
|
293 |
+
WC()->session->set_customer_session_cookie( true );
|
294 |
+
}
|
295 |
+
|
296 |
+
$cart_product_count = 0;
|
297 |
+
|
298 |
+
foreach ( $products as $index => $data ) {
|
299 |
+
|
300 |
+
if ( ! isset( $data['product'] ) ) {
|
301 |
+
return;
|
302 |
+
}
|
303 |
+
|
304 |
+
if ( apply_filters( 'cartflows_skip_other_products', false, $cart_product_count ) ) {
|
305 |
+
break;
|
306 |
+
}
|
307 |
+
|
308 |
+
$product_id = $data['product'];
|
309 |
+
$_product = wc_get_product( $product_id );
|
310 |
+
|
311 |
+
if ( ! empty( $_product ) ) {
|
312 |
+
|
313 |
+
$quantity = 1;
|
314 |
+
|
315 |
+
if ( ! $_product->is_type( 'grouped' ) && ! $_product->is_type( 'external' ) ) {
|
316 |
+
|
317 |
+
if ( $_product->is_type( 'variable' ) ) {
|
318 |
+
|
319 |
+
$default_attributes = $_product->get_default_attributes();
|
320 |
+
|
321 |
+
if ( ! empty( $default_attributes ) ) {
|
322 |
+
|
323 |
+
foreach ( $_product->get_children() as $variation_id ) {
|
324 |
+
|
325 |
+
$single_variation = new WC_Product_Variation( $variation_id );
|
326 |
+
|
327 |
+
if ( $default_attributes == $single_variation->get_attributes() ) {
|
328 |
+
WC()->cart->add_to_cart( $variation_id, $quantity );
|
329 |
+
$cart_product_count++;
|
330 |
+
}
|
331 |
+
}
|
332 |
+
} else {
|
333 |
+
|
334 |
+
$product_childrens = $_product->get_children();
|
335 |
+
|
336 |
+
if ( isset( $product_childrens[0] ) ) {
|
337 |
+
WC()->cart->add_to_cart( $product_childrens[0], $quantity );
|
338 |
+
$cart_product_count++;
|
339 |
+
} else {
|
340 |
+
echo '<p>' . __( 'Variations Not set', 'cartflows' ) . '</p>';
|
341 |
+
}
|
342 |
+
}
|
343 |
+
} else {
|
344 |
+
WC()->cart->add_to_cart( $product_id, $quantity );
|
345 |
+
$cart_product_count++;
|
346 |
+
}
|
347 |
+
} else {
|
348 |
+
|
349 |
+
echo '<p>' . __( 'This product can\'t be purcahsed', 'cartflows' ) . '</p>';
|
350 |
+
// WC()->cart->add_to_cart( $product_id, $quantity );.
|
351 |
+
}
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
do_action( 'cartflows_checkout_aftet_configure_cart', $checkout_id );
|
356 |
+
do_action( 'cartflows_checkout_after_configure_cart', $checkout_id );
|
357 |
+
}
|
358 |
+
}
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Load shortcode data.
|
363 |
+
*
|
364 |
+
* @return void
|
365 |
+
*/
|
366 |
+
function shortcode_load_data() {
|
367 |
+
|
368 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
369 |
+
|
370 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'shortcode_scripts' ), 21 );
|
371 |
+
|
372 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'compatibility_scripts' ), 101 );
|
373 |
+
|
374 |
+
/* Show notices if cart has errors */
|
375 |
+
add_action( 'woocommerce_cart_has_errors', 'woocommerce_output_all_notices' );
|
376 |
+
|
377 |
+
add_action( 'woocommerce_checkout_after_customer_details', array( $this, 'order_wrap_div_start' ), 99 );
|
378 |
+
|
379 |
+
add_action( 'woocommerce_checkout_after_order_review', array( $this, 'order_wrap_div_end' ), 99 );
|
380 |
+
|
381 |
+
// Outputting the hidden field in checkout page.
|
382 |
+
add_action( 'woocommerce_after_order_notes', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
383 |
+
add_action( 'woocommerce_login_form_end', array( $this, 'checkout_shortcode_post_id' ), 99 );
|
384 |
+
|
385 |
+
remove_all_actions( 'woocommerce_checkout_billing' );
|
386 |
+
remove_all_actions( 'woocommerce_checkout_shipping' );
|
387 |
+
|
388 |
+
// Hook in actions once.
|
389 |
+
add_action( 'woocommerce_checkout_billing', array( WC()->checkout, 'checkout_form_billing' ) );
|
390 |
+
add_action( 'woocommerce_checkout_shipping', array( WC()->checkout, 'checkout_form_shipping' ) );
|
391 |
+
|
392 |
+
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form' );
|
393 |
+
|
394 |
+
add_action( 'woocommerce_checkout_order_review', array( $this, 'display_custom_coupon_field' ) );
|
395 |
+
|
396 |
+
add_filter( 'woocommerce_checkout_fields', array( $this, 'add_three_column_layout_fields' ) );
|
397 |
+
|
398 |
+
global $post;
|
399 |
+
|
400 |
+
if ( _is_wcf_checkout_type() ) {
|
401 |
+
$checkout_id = $post->ID;
|
402 |
+
} else {
|
403 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
404 |
+
}
|
405 |
+
|
406 |
+
do_action( 'cartflows_checkout_before_shortcode', $checkout_id );
|
407 |
+
}
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Render checkout ID hidden field.
|
412 |
+
*
|
413 |
+
* @param array $checkout checkout session data.
|
414 |
+
* @return void
|
415 |
+
*/
|
416 |
+
function checkout_shortcode_post_id( $checkout ) {
|
417 |
+
|
418 |
+
global $post;
|
419 |
+
|
420 |
+
if ( _is_wcf_checkout_type() ) {
|
421 |
+
$checkout_id = $post->ID;
|
422 |
+
} else {
|
423 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
424 |
+
}
|
425 |
+
|
426 |
+
$flow_id = get_post_meta( $checkout_id, 'wcf-flow-id', true );
|
427 |
+
|
428 |
+
echo '<input type="hidden" class="input-hidden _wcf_flow_id" name="_wcf_flow_id" value="' . intval( $flow_id ) . '">';
|
429 |
+
echo '<input type="hidden" class="input-hidden _wcf_checkout_id" name="_wcf_checkout_id" value="' . intval( $checkout_id ) . '">';
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Load shortcode scripts.
|
434 |
+
*
|
435 |
+
* @return void
|
436 |
+
*/
|
437 |
+
function shortcode_scripts() {
|
438 |
+
|
439 |
+
wp_enqueue_style( 'wcf-checkout-template', CARTFLOWS_URL . 'assets/css/checkout-template.css', '', CARTFLOWS_VER );
|
440 |
+
wp_style_add_data( 'wcf-checkout-template', 'rtl', 'replace' );
|
441 |
+
|
442 |
+
wp_enqueue_script(
|
443 |
+
'wcf-checkout-template',
|
444 |
+
CARTFLOWS_URL . 'assets/js/checkout-template.js',
|
445 |
+
array( 'jquery' ),
|
446 |
+
CARTFLOWS_VER,
|
447 |
+
true
|
448 |
+
);
|
449 |
+
|
450 |
+
do_action( 'cartflows_checkout_scripts' );
|
451 |
+
|
452 |
+
$style = $this->generate_style();
|
453 |
+
|
454 |
+
wp_add_inline_style( 'wcf-checkout-template', $style );
|
455 |
+
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Load compatibility scripts.
|
460 |
+
*
|
461 |
+
* @return void
|
462 |
+
*/
|
463 |
+
function compatibility_scripts() {
|
464 |
+
|
465 |
+
global $post;
|
466 |
+
|
467 |
+
if ( _is_wcf_checkout_type() ) {
|
468 |
+
$checkout_id = $post->ID;
|
469 |
+
} else {
|
470 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
471 |
+
}
|
472 |
+
|
473 |
+
// Add DIVI Compatibility css if DIVI theme is enabled.
|
474 |
+
if ( Cartflows_Compatibility::get_instance()->is_divi_enabled() ||
|
475 |
+
Cartflows_Compatibility::get_instance()->is_divi_builder_enabled( $checkout_id )
|
476 |
+
) {
|
477 |
+
wp_enqueue_style( 'wcf-checkout-template-divi', CARTFLOWS_URL . 'assets/css/checkout-template-divi.css', '', CARTFLOWS_VER );
|
478 |
+
wp_style_add_data( 'wcf-checkout-template-divi', 'rtl', 'replace' );
|
479 |
+
}
|
480 |
+
|
481 |
+
// Add Flatsome Compatibility css if Flatsome theme is enabled.
|
482 |
+
if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) {
|
483 |
+
wp_enqueue_style( 'wcf-checkout-template-flatsome', CARTFLOWS_URL . 'assets/css/checkout-template-flatsome.css', '', CARTFLOWS_VER );
|
484 |
+
wp_style_add_data( 'wcf-checkout-template-flatsome', 'rtl', 'replace' );
|
485 |
+
}
|
486 |
+
|
487 |
+
// Add The7 Compatibility css if The7 theme is enabled.
|
488 |
+
if ( Cartflows_Compatibility::get_instance()->is_the_seven_enabled() ) {
|
489 |
+
wp_enqueue_style( 'wcf-checkout-template-the-seven', CARTFLOWS_URL . 'assets/css/checkout-template-the-seven.css', '', CARTFLOWS_VER );
|
490 |
+
wp_style_add_data( 'wcf-checkout-template-the-seven', 'rtl', 'replace' );
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Generate styles.
|
496 |
+
*
|
497 |
+
* @return string
|
498 |
+
*/
|
499 |
+
function generate_style() {
|
500 |
+
|
501 |
+
global $post;
|
502 |
+
|
503 |
+
if ( _is_wcf_checkout_type() ) {
|
504 |
+
$checkout_id = $post->ID;
|
505 |
+
} else {
|
506 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
507 |
+
}
|
508 |
+
|
509 |
+
CartFlows_Font_Families::render_fonts( $checkout_id );
|
510 |
+
|
511 |
+
$primary_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-primary-color' );
|
512 |
+
|
513 |
+
$base_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-family' );
|
514 |
+
|
515 |
+
$header_logo_width = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-width' );
|
516 |
+
|
517 |
+
/*$base_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-base-font-weight' );*/
|
518 |
+
$r = '';
|
519 |
+
$g = '';
|
520 |
+
$b = '';
|
521 |
+
|
522 |
+
$field_tb_padding = '';
|
523 |
+
$field_lr_padding = '';
|
524 |
+
|
525 |
+
$field_heading_color = '';
|
526 |
+
$field_color = '';
|
527 |
+
$field_bg_color = '';
|
528 |
+
$field_border_color = '';
|
529 |
+
$field_label_color = '';
|
530 |
+
$submit_tb_padding = '';
|
531 |
+
$submit_lr_padding = '';
|
532 |
+
$hl_bg_color = '';
|
533 |
+
$field_input_size = '';
|
534 |
+
$box_border_color = '';
|
535 |
+
$section_bg_color = '';
|
536 |
+
$submit_button_height = '';
|
537 |
+
$submit_color = '';
|
538 |
+
$submit_bg_color = $primary_color;
|
539 |
+
$submit_border_color = $primary_color;
|
540 |
+
|
541 |
+
$submit_hover_color = '';
|
542 |
+
$submit_bg_hover_color = $primary_color;
|
543 |
+
$submit_border_hover_color = $primary_color;
|
544 |
+
|
545 |
+
$section_heading_color = '';
|
546 |
+
|
547 |
+
$is_advance_option = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-advance-options-fields' );
|
548 |
+
|
549 |
+
$button_font_family = '';
|
550 |
+
$button_font_weight = '';
|
551 |
+
$input_font_family = '';
|
552 |
+
$input_font_weight = '';
|
553 |
+
$heading_font_family = '';
|
554 |
+
$heading_font_weight = '';
|
555 |
+
$base_font_family = $base_font_family;
|
556 |
+
/*$base_font_weight = $base_font_weight;*/
|
557 |
+
|
558 |
+
if ( 'yes' == $is_advance_option ) {
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Get Font Family and Font Weight weight values
|
562 |
+
*/
|
563 |
+
$section_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-section-bg-color' );
|
564 |
+
|
565 |
+
$heading_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-family' );
|
566 |
+
$heading_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-font-weight' );
|
567 |
+
$section_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-heading-color' );
|
568 |
+
$button_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-family' );
|
569 |
+
$button_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-button-font-weight' );
|
570 |
+
$input_font_family = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-family' );
|
571 |
+
$input_font_weight = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-font-weight' );
|
572 |
+
$field_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-tb-padding' );
|
573 |
+
$field_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-lr-padding' );
|
574 |
+
$field_input_size = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-field-size' );
|
575 |
+
|
576 |
+
$field_heading_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-heading-color' );
|
577 |
+
|
578 |
+
$field_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-color' );
|
579 |
+
|
580 |
+
$field_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-bg-color' );
|
581 |
+
|
582 |
+
$field_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-border-color' );
|
583 |
+
|
584 |
+
$field_label_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-field-label-color' );
|
585 |
+
|
586 |
+
$submit_tb_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-tb-padding' );
|
587 |
+
|
588 |
+
$submit_lr_padding = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-lr-padding' );
|
589 |
+
|
590 |
+
$submit_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-color' );
|
591 |
+
|
592 |
+
$submit_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-color', $primary_color );
|
593 |
+
|
594 |
+
$submit_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-color', $primary_color );
|
595 |
+
|
596 |
+
$submit_border_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-border-hover-color', $primary_color );
|
597 |
+
|
598 |
+
$submit_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-hover-color' );
|
599 |
+
|
600 |
+
$submit_bg_hover_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-submit-bg-hover-color', $primary_color );
|
601 |
+
|
602 |
+
$hl_bg_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-hl-bg-color' );
|
603 |
+
|
604 |
+
$box_border_color = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-box-border-color' );
|
605 |
+
|
606 |
+
$submit_button_height = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-input-button-size' );
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Get font values
|
610 |
+
*/
|
611 |
+
|
612 |
+
if ( 'custom' == $submit_button_height ) {
|
613 |
+
$submit_button_height = '38px';
|
614 |
+
}
|
615 |
+
|
616 |
+
if ( 'custom' == $field_input_size ) {
|
617 |
+
$field_input_size = '38px';
|
618 |
+
}
|
619 |
+
}
|
620 |
+
if ( isset( $primary_color ) ) {
|
621 |
+
|
622 |
+
list($r, $g, $b) = sscanf( $primary_color, '#%02x%02x%02x' );
|
623 |
+
}
|
624 |
+
$output = "
|
625 |
+
.wcf-embed-checkout-form .wcf-checkout-header-image img{
|
626 |
+
width: {$header_logo_width}px;
|
627 |
+
}
|
628 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:checked:before,
|
629 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:checked:before{
|
630 |
+
color: {$primary_color};
|
631 |
+
}
|
632 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:before{
|
633 |
+
background-color: {$primary_color};
|
634 |
+
}
|
635 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=checkbox]:focus,
|
636 |
+
.wcf-embed-checkout-form .woocommerce .woocommerce-shipping-fields [type='checkbox']:focus,
|
637 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:checked:focus,
|
638 |
+
.wcf-embed-checkout-form .woocommerce #payment input[type=radio]:not(:checked):focus{
|
639 |
+
border-color: {$primary_color};
|
640 |
+
box-shadow: 0 0 2px rgba( " . $r . ',' . $g . ',' . $b . ", .8);
|
641 |
+
}
|
642 |
+
.wcf-embed-checkout-form .woocommerce-checkout label{
|
643 |
+
color: {$field_label_color};
|
644 |
+
}
|
645 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box{
|
646 |
+
background-color: {$hl_bg_color};
|
647 |
+
font-family: {$input_font_family};
|
648 |
+
font-weight: {$input_font_weight};
|
649 |
+
}
|
650 |
+
|
651 |
+
.wcf-embed-checkout-form #add_payment_method #payment div.payment_box::before,
|
652 |
+
.wcf-embed-checkout-form .woocommerce-cart #payment div.payment_box::before,
|
653 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment div.payment_box::before
|
654 |
+
{
|
655 |
+
border-bottom-color: {$hl_bg_color};
|
656 |
+
border-right-color: transparent;
|
657 |
+
border-left-color: transparent;
|
658 |
+
border-top-color: transparent;
|
659 |
+
position: absolute;
|
660 |
+
}
|
661 |
+
|
662 |
+
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:checked + label,
|
663 |
+
.wcf-embed-checkout-form .woocommerce #payment [type='radio']:not(:checked) + label{
|
664 |
+
font-family: {$input_font_family};
|
665 |
+
font-weight: {$input_font_weight};
|
666 |
+
}
|
667 |
+
|
668 |
+
.wcf-embed-checkout-form #order_review .wcf-custom-coupon-field input[type='text'],
|
669 |
+
.wcf-embed-checkout-form .woocommerce form .form-row input.input-text,
|
670 |
+
.wcf-embed-checkout-form .woocommerce form .form-row textarea,
|
671 |
+
.wcf-embed-checkout-form .select2-container--default .select2-selection--single {
|
672 |
+
color: {$field_color};
|
673 |
+
background: {$field_bg_color};
|
674 |
+
border-color: {$field_border_color};
|
675 |
+
padding-top: {$field_tb_padding}px;
|
676 |
+
padding-bottom: {$field_tb_padding}px;
|
677 |
+
padding-left: {$field_lr_padding}px;
|
678 |
+
padding-right: {$field_lr_padding}px;
|
679 |
+
min-height: {$field_input_size};
|
680 |
+
font-family: {$input_font_family};
|
681 |
+
font-weight: {$input_font_weight};
|
682 |
+
}
|
683 |
+
|
684 |
+
.wcf-embed-checkout-form .woocommerce .col2-set .col-1,
|
685 |
+
.wcf-embed-checkout-form .woocommerce .col2-set .col-2,
|
686 |
+
.wcf-embed-checkout-form .woocommerce-checkout .shop_table,
|
687 |
+
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading,
|
688 |
+
.wcf-embed-checkout-form .woocommerce-checkout #payment,
|
689 |
+
.wcf-embed-checkout-form .woocommerce form.checkout_coupon
|
690 |
+
{
|
691 |
+
background-color: {$section_bg_color};
|
692 |
+
border-color: {$box_border_color};
|
693 |
+
font-family: {$input_font_family};
|
694 |
+
font-weight: {$input_font_weight};
|
695 |
+
}
|
696 |
+
|
697 |
+
.woocommerce table.shop_table th{
|
698 |
+
color: {$field_label_color};
|
699 |
+
}
|
700 |
+
/*.wcf-embed-checkout-form .woocommerce .woocommerce-info,
|
701 |
+
.wcf-embed-checkout-form .woocommerce-message{
|
702 |
+
border-top-color: {$primary_color};
|
703 |
+
background-color: {$hl_bg_color};
|
704 |
+
}*/
|
705 |
+
.wcf-embed-checkout-form .woocommerce a{
|
706 |
+
color: {$primary_color};
|
707 |
+
}
|
708 |
+
.wcf-embed-checkout-form .select2-container--default .select2-selection--single .select2-selection__rendered {
|
709 |
+
color: {$field_color};
|
710 |
+
}
|
711 |
+
.wcf-embed-checkout-form ::-webkit-input-placeholder { /* Chrome/Opera/Safari */
|
712 |
+
color: {$field_color};
|
713 |
+
}
|
714 |
+
.wcf-embed-checkout-form ::-moz-placeholder { /* Firefox 19+ */
|
715 |
+
color: {$field_color};
|
716 |
+
}
|
717 |
+
.wcf-embed-checkout-form :-ms-input-placeholder { /* IE 10+ */
|
718 |
+
color: {$field_color};
|
719 |
+
}
|
720 |
+
.wcf-embed-checkout-form :-moz-placeholder { /* Firefox 18- */
|
721 |
+
color: {$field_color};
|
722 |
+
}
|
723 |
+
.wcf-embed-checkout-form .woocommerce form p.form-row label {
|
724 |
+
color: {$field_label_color};
|
725 |
+
font-family: {$input_font_family};
|
726 |
+
font-weight: {$input_font_weight};
|
727 |
+
}
|
728 |
+
.wcf-embed-checkout-form .woocommerce #order_review button,
|
729 |
+
.wcf-embed-checkout-form .woocommerce form.woocommerce-form-login .form-row button,
|
730 |
+
.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small {
|
731 |
+
color: {$submit_color};
|
732 |
+
background: {$submit_bg_color};
|
733 |
+
padding-top: {$submit_tb_padding}px;
|
734 |
+
padding-bottom: {$submit_tb_padding}px;
|
735 |
+
padding-left: {$submit_lr_padding}px;
|
736 |
+
padding-right: {$submit_lr_padding}px;
|
737 |
+
border-color: {$submit_border_color};
|
738 |
+
min-height: {$submit_button_height};
|
739 |
+
font-family: {$button_font_family};
|
740 |
+
font-weight: {$button_font_weight};
|
741 |
+
}
|
742 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.woocommerce-form-login .button,
|
743 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button{
|
744 |
+
background: {$submit_bg_color};
|
745 |
+
border: 1px {$submit_border_color} solid;
|
746 |
+
color: {$submit_color};
|
747 |
+
min-height: {$submit_button_height};
|
748 |
+
font-family: {$button_font_family};
|
749 |
+
font-weight: {$button_font_weight};
|
750 |
+
}
|
751 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.login .button:hover,
|
752 |
+
.wcf-embed-checkout-form .woocommerce-checkout form.checkout_coupon .button:hover,
|
753 |
+
.wcf-embed-checkout-form .woocommerce #payment #place_order:hover,
|
754 |
+
.wcf-embed-checkout-form .woocommerce #order_review button.wcf-btn-small:hover{
|
755 |
+
color: {$submit_hover_color};
|
756 |
+
background-color: {$submit_bg_hover_color};
|
757 |
+
border-color: {$submit_border_hover_color};
|
758 |
+
}
|
759 |
+
.wcf-embed-checkout-form .woocommerce h3,
|
760 |
+
.wcf-embed-checkout-form .woocommerce h3 span,
|
761 |
+
.wcf-embed-checkout-form .woocommerce-checkout #order_review_heading{
|
762 |
+
color: {$section_heading_color};
|
763 |
+
font-family: {$heading_font_family};
|
764 |
+
font-weight: {$heading_font_weight};
|
765 |
+
}
|
766 |
+
.wcf-embed-checkout-form .woocommerce-info::before,
|
767 |
+
.wcf-embed-checkout-form .woocommerce-message::before{
|
768 |
+
color: {$primary_color};
|
769 |
+
}
|
770 |
+
.wcf-embed-checkout-form{
|
771 |
+
font-family: {$base_font_family};
|
772 |
+
}
|
773 |
+
img.emoji, img.wp-smiley {}";
|
774 |
+
|
775 |
+
return $output;
|
776 |
+
}
|
777 |
+
|
778 |
+
/**
|
779 |
+
* Get ajax end points.
|
780 |
+
*
|
781 |
+
* @param string $endpoint_url end point URL.
|
782 |
+
* @return string
|
783 |
+
*/
|
784 |
+
function get_ajax_endpoint( $endpoint_url ) {
|
785 |
+
|
786 |
+
global $post;
|
787 |
+
|
788 |
+
if ( ! empty( $post ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
|
789 |
+
|
790 |
+
if ( _is_wcf_checkout_type() || _is_wcf_checkout_shortcode() ) {
|
791 |
+
|
792 |
+
if ( mb_strpos( $endpoint_url, 'checkout' ) === false ) {
|
793 |
+
|
794 |
+
$query_args = array(
|
795 |
+
'wc-ajax' => '%%endpoint%%',
|
796 |
+
);
|
797 |
+
|
798 |
+
$uri = explode( '?', $_SERVER['REQUEST_URI'], 2 );
|
799 |
+
$uri = $uri[0];
|
800 |
+
|
801 |
+
$endpoint_url = esc_url( add_query_arg( $query_args, $uri ) );
|
802 |
+
}
|
803 |
+
}
|
804 |
+
}
|
805 |
+
|
806 |
+
return $endpoint_url;
|
807 |
+
}
|
808 |
+
|
809 |
+
|
810 |
+
/**
|
811 |
+
* Save checkout fields.
|
812 |
+
*
|
813 |
+
* @param int $order_id order id.
|
814 |
+
* @param array $posted posted data.
|
815 |
+
* @return void
|
816 |
+
*/
|
817 |
+
function save_checkout_fields( $order_id, $posted ) {
|
818 |
+
|
819 |
+
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
820 |
+
|
821 |
+
$checkout_id = wc_clean( $_POST['_wcf_checkout_id'] );
|
822 |
+
|
823 |
+
update_post_meta( $order_id, '_wcf_checkout_id', $checkout_id );
|
824 |
+
|
825 |
+
/*
|
826 |
+
Custom Field To Do
|
827 |
+
$custom_fields = get_post_meta( $checkout_id, 'wcf-custom-checkout-fields', true );
|
828 |
+
|
829 |
+
if ( 'yes' === $custom_fields ) {
|
830 |
+
|
831 |
+
$billing_fields = get_post_meta( $checkout_id, 'wcf_fields_billing', true );
|
832 |
+
|
833 |
+
foreach ( $billing_fields as $field => $data ) {
|
834 |
+
|
835 |
+
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
836 |
+
|
837 |
+
if ( isset( $_POST[ $field ] ) ) {
|
838 |
+
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
839 |
+
}
|
840 |
+
}
|
841 |
+
}
|
842 |
+
|
843 |
+
$shipping_fields = get_post_meta( $checkout_id, 'wcf_fields_shipping', true );
|
844 |
+
|
845 |
+
foreach ( $shipping_fields as $field => $data ) {
|
846 |
+
|
847 |
+
if ( isset( $data['custom'] ) && $data['custom'] ) {
|
848 |
+
|
849 |
+
if ( isset( $_POST[ $field ] ) ) {
|
850 |
+
update_post_meta( $order_id, $field, wc_clean( $_POST[ $field ] ) );
|
851 |
+
}
|
852 |
+
}
|
853 |
+
}
|
854 |
+
}
|
855 |
+
*/
|
856 |
+
if ( isset( $_POST['_wcf_flow_id'] ) ) {
|
857 |
+
|
858 |
+
$checkout_id = wc_clean( $_POST['_wcf_flow_id'] );
|
859 |
+
|
860 |
+
update_post_meta( $order_id, '_wcf_flow_id', $checkout_id );
|
861 |
+
}
|
862 |
+
}
|
863 |
+
|
864 |
+
}
|
865 |
+
|
866 |
+
/**
|
867 |
+
* Enable Logo In Header Of Checkout Page
|
868 |
+
*
|
869 |
+
* @return void
|
870 |
+
*/
|
871 |
+
function enable_logo_in_header() {
|
872 |
+
global $post;
|
873 |
+
|
874 |
+
if ( _is_wcf_checkout_type() ) {
|
875 |
+
$checkout_id = $post->ID;
|
876 |
+
} else {
|
877 |
+
$checkout_id = _get_wcf_checkout_id_from_shortcode( $post->post_content );
|
878 |
+
}
|
879 |
+
|
880 |
+
$header_logo_image = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-header-logo-image' );
|
881 |
+
$add_image_markup = '';
|
882 |
+
|
883 |
+
if ( isset( $header_logo_image ) && ! empty( $header_logo_image ) ) {
|
884 |
+
$add_image_markup = '<div class="wcf-checkout-header-image">';
|
885 |
+
$add_image_markup .= '<img src="' . $header_logo_image . '" />';
|
886 |
+
$add_image_markup .= '</div>';
|
887 |
+
}
|
888 |
+
|
889 |
+
echo $add_image_markup;
|
890 |
+
}
|
891 |
+
|
892 |
+
/**
|
893 |
+
* Add text to the bootom of the checkout page.
|
894 |
+
*
|
895 |
+
* @return void
|
896 |
+
*/
|
897 |
+
function show_cartflows_copyright_message() {
|
898 |
+
$output_string = '';
|
899 |
+
|
900 |
+
$output_string .= '<div class="wcf-footer-primary">';
|
901 |
+
$output_string .= '<div class="wcf-footer-content">';
|
902 |
+
$output_string .= '<p class="wcf-footer-message">';
|
903 |
+
$output_string .= 'Checkout powered by CartFlows';
|
904 |
+
$output_string .= '</p>';
|
905 |
+
$output_string .= '</div>';
|
906 |
+
$output_string .= '</div>';
|
907 |
+
|
908 |
+
echo $output_string;
|
909 |
+
}
|
910 |
+
|
911 |
+
/**
|
912 |
+
* Redirect users to our checkout if hidden param
|
913 |
+
*
|
914 |
+
* @param string $redirect redirect url.
|
915 |
+
* @param object $user user.
|
916 |
+
* @return string
|
917 |
+
*/
|
918 |
+
function after_login_redirect( $redirect, $user ) {
|
919 |
+
|
920 |
+
if ( isset( $_POST['_wcf_checkout_id'] ) ) {
|
921 |
+
|
922 |
+
$checkout_id = intval( $_POST['_wcf_checkout_id'] );
|
923 |
+
|
924 |
+
$redirect = get_permalink( $checkout_id );
|
925 |
+
}
|
926 |
+
|
927 |
+
return $redirect;
|
928 |
+
}
|
929 |
+
|
930 |
+
/**
|
931 |
+
* Display coupon code field after review order fields.
|
932 |
+
*/
|
933 |
+
function display_custom_coupon_field() {
|
934 |
+
|
935 |
+
$coupon_enabled = apply_filters( 'woocommerce_coupons_enabled', true );
|
936 |
+
$cf_show_coupon = apply_filters( 'cartflows_show_coupon_field', true );
|
937 |
+
|
938 |
+
if ( ! ( $coupon_enabled && $cf_show_coupon ) ) {
|
939 |
+
return;
|
940 |
+
|
941 |
+
}
|
942 |
+
|
943 |
+
ob_start();
|
944 |
+
?>
|
945 |
+
<div class="wcf-custom-coupon-field">
|
946 |
+
<div class="wcf-coupon-col-1">
|
947 |
+
<span>
|
948 |
+
<input type="text" name="coupon_code" class="input-text cf-coupon-code-input" placeholder="<?php _e( 'Coupon Code', 'cartflows' ); ?>" id="coupon_code" value="">
|
949 |
+
</span>
|
950 |
+
</div>
|
951 |
+
<div class="wcf-coupon-col-2">
|
952 |
+
<span>
|
953 |
+
<button type="button" class="button cf-submit-coupon wcf-btn-small" name="apply_coupon" value="Apply"><?php _e( 'Apply', 'cartflows' ); ?></button>
|
954 |
+
</span>
|
955 |
+
</div>
|
956 |
+
</div>
|
957 |
+
<?php
|
958 |
+
echo ob_get_clean();
|
959 |
+
}
|
960 |
+
|
961 |
+
/**
|
962 |
+
* Apply filter to change the placeholder text of coupon field.
|
963 |
+
*
|
964 |
+
* @return string
|
965 |
+
*/
|
966 |
+
function coupon_field_placeholder() {
|
967 |
+
return apply_filters( 'cartflows_coupon_field_placeholder', __( 'Coupon Code', 'cartflows' ) );
|
968 |
+
}
|
969 |
+
|
970 |
+
/**
|
971 |
+
* Apply filter to change the button text of coupon field.
|
972 |
+
*
|
973 |
+
* @return string
|
974 |
+
*/
|
975 |
+
function coupon_button_text() {
|
976 |
+
return apply_filters( 'cartflows_coupon_button_text', __( 'Apply', 'cartflows' ) );
|
977 |
+
}
|
978 |
+
|
979 |
+
/**
|
980 |
+
* Apply coupon on submit of custom coupon form.
|
981 |
+
*/
|
982 |
+
function apply_coupon() {
|
983 |
+
|
984 |
+
check_ajax_referer( 'cf-apply-coupon', 'security' );
|
985 |
+
|
986 |
+
$result = WC()->cart->add_discount( sanitize_text_field( wp_unslash( $_POST['coupon_code'] ) ) );
|
987 |
+
|
988 |
+
echo json_encode( $result );
|
989 |
+
die();
|
990 |
+
}
|
991 |
+
|
992 |
+
/**
|
993 |
+
* Added ajax nonce to localize variable.
|
994 |
+
*
|
995 |
+
* @param array $vars localize variables.
|
996 |
+
*/
|
997 |
+
function add_localize_vars( $vars ) {
|
998 |
+
|
999 |
+
$vars['cf_validate_coupon_nonce'] = wp_create_nonce( 'cf-apply-coupon' );
|
1000 |
+
|
1001 |
+
$vars['allow_persistance'] = apply_filters( 'cartflows_allow_persistace', 'yes' );
|
1002 |
+
|
1003 |
+
return $vars;
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
/**
|
1007 |
+
* Add custom class to the fields to change the UI to three column.
|
1008 |
+
*
|
1009 |
+
* @param array $fields fields.
|
1010 |
+
*/
|
1011 |
+
function add_three_column_layout_fields( $fields ) {
|
1012 |
+
|
1013 |
+
if ( empty( $fields['billing']['billing_address_2'] ) ) {
|
1014 |
+
|
1015 |
+
if ( isset( $fields['billing']['billing_address_1'] ) && is_array( $fields['billing']['billing_address_1'] ) ) {
|
1016 |
+
$fields['billing']['billing_address_1']['class'][] = 'form-row-full';
|
1017 |
+
}
|
1018 |
+
}
|
1019 |
+
|
1020 |
+
if ( ! empty( $fields['billing']['billing_company'] ) ) {
|
1021 |
+
|
1022 |
+
if ( isset( $fields['billing']['billing_company'] ) && is_array( $fields['billing']['billing_company'] ) ) {
|
1023 |
+
$fields['billing']['billing_company']['class'][] = 'form-row-full';
|
1024 |
+
}
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
if ( ! empty( $fields['shipping']['shipping_company'] ) ) {
|
1028 |
+
|
1029 |
+
if ( isset( $fields['shipping']['shipping_company'] ) && is_array( $fields['shipping']['shipping_company'] ) ) {
|
1030 |
+
$fields['shipping']['shipping_company']['class'][] = 'form-row-full';
|
1031 |
+
}
|
1032 |
+
}
|
1033 |
+
|
1034 |
+
if ( ! empty( $fields['billing']['billing_country'] ) ) {
|
1035 |
+
|
1036 |
+
if ( isset( $fields['billing']['billing_country'] ) && is_array( $fields['billing']['billing_country'] ) ) {
|
1037 |
+
$fields['billing']['billing_country']['class'][] = 'form-row-full';
|
1038 |
+
}
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
if ( ! empty( $fields['shipping']['shipping_country'] ) ) {
|
1042 |
+
|
1043 |
+
if ( isset( $fields['shipping']['shipping_country'] ) && is_array( $fields['shipping']['shipping_country'] ) ) {
|
1044 |
+
$fields['shipping']['shipping_country']['class'][] = 'form-row-full';
|
1045 |
+
}
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
if ( ! empty( $fields['billing']['billing_phone'] ) ) {
|
1049 |
+
|
1050 |
+
if ( isset( $fields['billing']['billing_phone'] ) && is_array( $fields['billing']['billing_phone'] ) ) {
|
1051 |
+
$fields['billing']['billing_phone']['class'][] = 'form-row-full';
|
1052 |
+
}
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
if ( ! empty( $fields['billing']['billing_email'] ) ) {
|
1056 |
+
|
1057 |
+
if ( isset( $fields['billing']['billing_email'] ) && is_array( $fields['billing']['billing_email'] ) ) {
|
1058 |
+
$fields['billing']['billing_email']['class'][] = 'form-row-full';
|
1059 |
+
}
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
if ( empty( $fields['shipping']['shipping_address_2'] ) ) {
|
1063 |
+
|
1064 |
+
if ( isset( $fields['shipping']['shipping_address_1'] ) && is_array( $fields['shipping']['shipping_address_1'] ) ) {
|
1065 |
+
$fields['shipping']['shipping_address_1']['class'][] = 'form-row-full';
|
1066 |
+
}
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
if ( isset( $fields['billing']['billing_city'] ) &&
|
1070 |
+
isset( $fields['billing']['billing_state'] ) && isset( $fields['billing']['billing_postcode'] ) ) {
|
1071 |
+
|
1072 |
+
$fields['billing']['billing_city']['class'][] = 'wcf-column-33';
|
1073 |
+
$fields['billing']['billing_state']['class'][] = 'wcf-column-33';
|
1074 |
+
$fields['billing']['billing_postcode']['class'][] = 'wcf-column-33';
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
if ( isset( $fields['shipping']['shipping_city'] ) &&
|
1078 |
+
isset( $fields['shipping']['shipping_state'] ) && isset( $fields['shipping']['shipping_postcode'] ) ) {
|
1079 |
+
|
1080 |
+
$fields['shipping']['shipping_city']['class'][] = 'wcf-column-33';
|
1081 |
+
$fields['shipping']['shipping_state']['class'][] = 'wcf-column-33';
|
1082 |
+
$fields['shipping']['shipping_postcode']['class'][] = 'wcf-column-33';
|
1083 |
+
}
|
1084 |
+
|
1085 |
+
return $fields;
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
/**
|
1089 |
+
* Add opening dev
|
1090 |
+
*
|
1091 |
+
* @since 1.0.0
|
1092 |
+
*/
|
1093 |
+
function order_wrap_div_start() {
|
1094 |
+
|
1095 |
+
echo "<div class='wcf-order-wrap'> ";
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
/**
|
1099 |
+
* Add closing dev
|
1100 |
+
*
|
1101 |
+
* @since 1.0.0
|
1102 |
+
*/
|
1103 |
+
function order_wrap_div_end() {
|
1104 |
+
|
1105 |
+
echo '</div> ';
|
1106 |
+
}
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
/**
|
1110 |
+
* Kicking this off by calling 'get_instance()' method
|
1111 |
+
*/
|
1112 |
+
Cartflows_Checkout_Markup::get_instance();
|
modules/flow/classes/class-cartflows-step-post-type.php
CHANGED
@@ -1,470 +1,470 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Step post type.
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Initialization
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Step_Post_Type {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Member Variable
|
25 |
-
*
|
26 |
-
* @var body_classes
|
27 |
-
*/
|
28 |
-
private $body_classes = array();
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Initiator
|
32 |
-
*/
|
33 |
-
public static function get_instance() {
|
34 |
-
if ( ! isset( self::$instance ) ) {
|
35 |
-
self::$instance = new self;
|
36 |
-
}
|
37 |
-
return self::$instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor
|
42 |
-
*/
|
43 |
-
public function __construct() {
|
44 |
-
|
45 |
-
add_action( 'init', array( $this, 'step_post_type' ) );
|
46 |
-
add_action( 'init', array( $this, 'add_wp_templates_support' ) );
|
47 |
-
add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
|
48 |
-
add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 );
|
49 |
-
add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
|
50 |
-
add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ), 20 );
|
51 |
-
|
52 |
-
add_filter( 'template_include', array( $this, 'load_page_template' ), 99 );
|
53 |
-
}
|
54 |
-
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Trys to load page.php for a header, footer or part theme layout.
|
58 |
-
*
|
59 |
-
* @since 1.0.0
|
60 |
-
* @param string $template The current template to be loaded.
|
61 |
-
* @return string
|
62 |
-
*/
|
63 |
-
function load_page_template( $template ) {
|
64 |
-
|
65 |
-
global $post;
|
66 |
-
|
67 |
-
if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Remove Next/Prev Navigation
|
71 |
-
* add_filter('next_post_link', '__return_empty_string');
|
72 |
-
* add_filter('previous_post_link', '__return_empty_string');
|
73 |
-
*
|
74 |
-
* $page = locate_template( array( 'page.php' ) );
|
75 |
-
*
|
76 |
-
* if ( ! empty( $page ) ) {
|
77 |
-
* return $page;
|
78 |
-
* }
|
79 |
-
*/
|
80 |
-
|
81 |
-
/* Remove Next / Previous Rel Link */
|
82 |
-
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
83 |
-
add_filter( 'next_post_rel_link', '__return_empty_string' );
|
84 |
-
add_filter( 'previous_post_rel_link', '__return_empty_string' );
|
85 |
-
|
86 |
-
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
87 |
-
|
88 |
-
$page_template = apply_filters( 'cartflows_page_template', $page_template );
|
89 |
-
|
90 |
-
$file = '';
|
91 |
-
|
92 |
-
switch ( $page_template ) {
|
93 |
-
|
94 |
-
case 'cartflows-default':
|
95 |
-
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
96 |
-
$this->body_classes[] = $page_template;
|
97 |
-
break;
|
98 |
-
case 'cartflows-canvas':
|
99 |
-
$file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
|
100 |
-
$this->body_classes[] = $page_template;
|
101 |
-
break;
|
102 |
-
default:
|
103 |
-
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
104 |
-
$this->body_classes[] = 'cartflows-default';
|
105 |
-
break;
|
106 |
-
}
|
107 |
-
|
108 |
-
// Just to be safe, we check if the file exist first.
|
109 |
-
if ( file_exists( $file ) ) {
|
110 |
-
|
111 |
-
/* Add Body Class */
|
112 |
-
add_filter( 'body_class', [ $this, 'body_class' ] );
|
113 |
-
|
114 |
-
return $file;
|
115 |
-
} else {
|
116 |
-
echo $file;
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
return $template;
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Body classes.
|
125 |
-
*
|
126 |
-
* @since 1.0.0
|
127 |
-
* @param array $classes Body classes.
|
128 |
-
* @return array
|
129 |
-
*/
|
130 |
-
function body_class( $classes = [] ) {
|
131 |
-
|
132 |
-
$classes = array_merge( $classes, $this->body_classes );
|
133 |
-
|
134 |
-
return $classes;
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Create custom post type
|
139 |
-
*/
|
140 |
-
function step_post_type() {
|
141 |
-
|
142 |
-
$labels = array(
|
143 |
-
'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
|
144 |
-
'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
|
145 |
-
'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
|
146 |
-
'all_items' => esc_html__( 'All Steps', 'cartflows' ),
|
147 |
-
'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
|
148 |
-
'view_item' => esc_html__( 'View Step', 'cartflows' ),
|
149 |
-
'add_new' => esc_html__( 'Add New', 'cartflows' ),
|
150 |
-
'update_item' => esc_html__( 'Update Step', 'cartflows' ),
|
151 |
-
'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
|
152 |
-
'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
|
153 |
-
);
|
154 |
-
|
155 |
-
$args = array(
|
156 |
-
'labels' => $labels,
|
157 |
-
'public' => true,
|
158 |
-
'query_var' => true,
|
159 |
-
'can_export' => true,
|
160 |
-
'exclude_from_search' => true,
|
161 |
-
'show_ui' => true,
|
162 |
-
'show_in_menu' => false,
|
163 |
-
'show_in_admin_bar' => true,
|
164 |
-
'supports' => array( 'title', 'editor', 'elementor', 'revisions' ),
|
165 |
-
'capability_type' => 'post',
|
166 |
-
'capabilities' => array(
|
167 |
-
'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
|
168 |
-
),
|
169 |
-
'map_meta_cap' => true,
|
170 |
-
);
|
171 |
-
|
172 |
-
register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
|
173 |
-
|
174 |
-
$args = array(
|
175 |
-
'label' => __( 'Step Type', 'cartflows' ),
|
176 |
-
'public' => false,
|
177 |
-
'rewrite' => false,
|
178 |
-
'hierarchical' => false,
|
179 |
-
);
|
180 |
-
|
181 |
-
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
|
182 |
-
|
183 |
-
$args = array(
|
184 |
-
'label' => __( 'Step Flow', 'cartflows' ),
|
185 |
-
'public' => false,
|
186 |
-
'rewrite' => false,
|
187 |
-
'hierarchical' => false,
|
188 |
-
);
|
189 |
-
|
190 |
-
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Register 'Elementor' & 'Beaver Builder' site types.
|
194 |
-
*
|
195 |
-
* @see self::add_terms();
|
196 |
-
*/
|
197 |
-
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
198 |
-
|
199 |
-
$terms = array(
|
200 |
-
array(
|
201 |
-
'name' => __( 'Landing', 'cartflows' ),
|
202 |
-
'args' => array(
|
203 |
-
'slug' => 'landing',
|
204 |
-
),
|
205 |
-
),
|
206 |
-
array(
|
207 |
-
'name' => __( 'Checkout', 'cartflows' ),
|
208 |
-
'args' => array(
|
209 |
-
'slug' => 'checkout',
|
210 |
-
),
|
211 |
-
),
|
212 |
-
array(
|
213 |
-
'name' => __( 'Thank You', 'cartflows' ),
|
214 |
-
'args' => array(
|
215 |
-
'slug' => 'thankyou',
|
216 |
-
),
|
217 |
-
),
|
218 |
-
array(
|
219 |
-
'name' => __( 'Upsell', 'cartflows' ),
|
220 |
-
'args' => array(
|
221 |
-
'slug' => 'upsell',
|
222 |
-
),
|
223 |
-
),
|
224 |
-
array(
|
225 |
-
'name' => __( 'Downsell', 'cartflows' ),
|
226 |
-
'args' => array(
|
227 |
-
'slug' => 'downsell',
|
228 |
-
),
|
229 |
-
),
|
230 |
-
);
|
231 |
-
|
232 |
-
$this->add_terms( $taxonomy, $terms );
|
233 |
-
}
|
234 |
-
|
235 |
-
/**
|
236 |
-
* Add WordPress templates.
|
237 |
-
*
|
238 |
-
* Adds Cartflows templates to steps
|
239 |
-
*
|
240 |
-
* @since 1.0.0
|
241 |
-
* @access public
|
242 |
-
*/
|
243 |
-
function add_wp_templates_support() {
|
244 |
-
add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Add page templates.
|
249 |
-
*
|
250 |
-
* @since 1.0.0
|
251 |
-
* @access public
|
252 |
-
*
|
253 |
-
* @param array $page_templates Array of page templates.
|
254 |
-
*
|
255 |
-
* @param object $wp_theme wp theme.
|
256 |
-
* @param object $post post.
|
257 |
-
*
|
258 |
-
* @return array Page templates.
|
259 |
-
*/
|
260 |
-
function add_page_templates( $page_templates, $wp_theme, $post ) {
|
261 |
-
|
262 |
-
$page_templates = array(
|
263 |
-
'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
|
264 |
-
);
|
265 |
-
|
266 |
-
return $page_templates;
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Have WordPress match postname to any of our public post types.
|
271 |
-
* All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
|
272 |
-
* By default, WordPress only accounts for posts and pages where the slug is /post-name/.
|
273 |
-
*
|
274 |
-
* @param string $query query statement.
|
275 |
-
*/
|
276 |
-
function add_cpt_post_names_to_main_query( $query ) {
|
277 |
-
|
278 |
-
// Bail if this is not the main query.
|
279 |
-
if ( ! $query->is_main_query() ) {
|
280 |
-
return;
|
281 |
-
}
|
282 |
-
|
283 |
-
// Bail if this query doesn't match our very specific rewrite rule.
|
284 |
-
if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) {
|
285 |
-
return;
|
286 |
-
}
|
287 |
-
|
288 |
-
// Bail if we're not querying based on the post name.
|
289 |
-
if ( empty( $query->query['name'] ) ) {
|
290 |
-
return;
|
291 |
-
}
|
292 |
-
|
293 |
-
// Add cartflows step post type to existing post type array.
|
294 |
-
if ( isset( $query->query_vars['post_type'] ) && is_array( $query->query_vars['post_type'] ) ) {
|
295 |
-
|
296 |
-
$post_types = $query->query_vars['post_type'];
|
297 |
-
|
298 |
-
$post_types[] = CARTFLOWS_STEP_POST_TYPE;
|
299 |
-
|
300 |
-
$query->set( 'post_type', $post_types );
|
301 |
-
|
302 |
-
} else {
|
303 |
-
|
304 |
-
// Add CPT to the list of post types WP will include when it queries based on the post name.
|
305 |
-
$query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) );
|
306 |
-
}
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* Modify permalink
|
311 |
-
*
|
312 |
-
* @param string $post_link post link.
|
313 |
-
* @param array $post post data.
|
314 |
-
* @param string $leavename leave name.
|
315 |
-
* @return string
|
316 |
-
*/
|
317 |
-
function post_type_permalinks( $post_link, $post, $leavename ) {
|
318 |
-
|
319 |
-
// If elementor page preview, return post link as it is.
|
320 |
-
if ( isset( $_REQUEST['elementor-preview'] ) ) {
|
321 |
-
return $post_link;
|
322 |
-
}
|
323 |
-
|
324 |
-
$structure = get_option( 'permalink_structure' );
|
325 |
-
|
326 |
-
if ( '/%postname%/' === $structure ) {
|
327 |
-
|
328 |
-
if ( isset( $post->post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) {
|
329 |
-
|
330 |
-
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
|
331 |
-
}
|
332 |
-
}
|
333 |
-
|
334 |
-
return $post_link;
|
335 |
-
}
|
336 |
-
|
337 |
-
/**
|
338 |
-
* Prevent slug duplicated
|
339 |
-
*
|
340 |
-
* @param string $slug post slug.
|
341 |
-
* @param int $post_ID post id.
|
342 |
-
* @param string $post_status post status.
|
343 |
-
* @param string $post_type post type.
|
344 |
-
* @param int $post_parent post parent id.
|
345 |
-
* @param string $original_slug original slug.
|
346 |
-
* @return string
|
347 |
-
*/
|
348 |
-
function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
349 |
-
|
350 |
-
$check_post_types = array(
|
351 |
-
'post',
|
352 |
-
'page',
|
353 |
-
CARTFLOWS_STEP_POST_TYPE,
|
354 |
-
);
|
355 |
-
|
356 |
-
if ( ! in_array( $post_type, $check_post_types ) ) {
|
357 |
-
return $slug;
|
358 |
-
}
|
359 |
-
|
360 |
-
if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
|
361 |
-
// Saving a post, check for duplicates in POST or PAGE post types.
|
362 |
-
$post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
|
363 |
-
$page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
|
364 |
-
|
365 |
-
if ( $post_match || $page_match ) {
|
366 |
-
$slug .= '-2';
|
367 |
-
}
|
368 |
-
} else {
|
369 |
-
|
370 |
-
// Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
|
371 |
-
$custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
|
372 |
-
|
373 |
-
if ( $custom_post_type_match ) {
|
374 |
-
$slug .= '-2';
|
375 |
-
}
|
376 |
-
}
|
377 |
-
|
378 |
-
return $slug;
|
379 |
-
}
|
380 |
-
|
381 |
-
/**
|
382 |
-
* Add Update messages for any custom post type
|
383 |
-
*
|
384 |
-
* @param array $messages Array of default messages.
|
385 |
-
*/
|
386 |
-
function post_update_messages( $messages ) {
|
387 |
-
|
388 |
-
$custom_post_type = get_post_type( get_the_ID() );
|
389 |
-
|
390 |
-
if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
|
391 |
-
|
392 |
-
$obj = get_post_type_object( $custom_post_type );
|
393 |
-
$singular_name = $obj->labels->singular_name;
|
394 |
-
$messages[ $custom_post_type ] = array(
|
395 |
-
0 => '', // Unused. Messages start at index 1.
|
396 |
-
/* translators: %s: singular custom post type name */
|
397 |
-
1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
398 |
-
/* translators: %s: singular custom post type name */
|
399 |
-
2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
|
400 |
-
/* translators: %s: singular custom post type name */
|
401 |
-
3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
|
402 |
-
/* translators: %s: singular custom post type name */
|
403 |
-
4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
404 |
-
/* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
|
405 |
-
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
406 |
-
/* translators: %s: singular custom post type name */
|
407 |
-
6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
|
408 |
-
/* translators: %s: singular custom post type name */
|
409 |
-
7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
|
410 |
-
/* translators: %s: singular custom post type name */
|
411 |
-
8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
|
412 |
-
/* translators: %s: singular custom post type name */
|
413 |
-
9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
|
414 |
-
/* translators: %s: singular custom post type name */
|
415 |
-
10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
|
416 |
-
);
|
417 |
-
}
|
418 |
-
|
419 |
-
return $messages;
|
420 |
-
}
|
421 |
-
|
422 |
-
/**
|
423 |
-
* Add Terms for Taxonomy.
|
424 |
-
*
|
425 |
-
* => Example.
|
426 |
-
*
|
427 |
-
* $taxonomy = '{taxonomy}';
|
428 |
-
* $terms = array(
|
429 |
-
* array(
|
430 |
-
* 'name' => 'Free',
|
431 |
-
* ),
|
432 |
-
* array(
|
433 |
-
* 'name' => 'Premium',
|
434 |
-
* ),
|
435 |
-
* );
|
436 |
-
*
|
437 |
-
* self::add_terms( $taxonomy, $terms );
|
438 |
-
*
|
439 |
-
* @since 1.0.0
|
440 |
-
* @param string $taxonomy Taxonomy Name.
|
441 |
-
* @param array $terms Terms list.
|
442 |
-
* @return void
|
443 |
-
*/
|
444 |
-
function add_terms( $taxonomy = '', $terms = array() ) {
|
445 |
-
|
446 |
-
foreach ( $terms as $key => $term ) {
|
447 |
-
|
448 |
-
$term_exist = term_exists( $term['name'], $taxonomy );
|
449 |
-
|
450 |
-
if ( empty( $term_exist ) ) {
|
451 |
-
|
452 |
-
/**
|
453 |
-
* Add additional args if passed from request.
|
454 |
-
*
|
455 |
-
* @see https://codex.wordpress.org/Function_Reference/wp_insert_term
|
456 |
-
*/
|
457 |
-
if ( array_key_exists( 'args', $term ) ) {
|
458 |
-
wp_insert_term( $term['name'], $taxonomy, $term['args'] );
|
459 |
-
} else {
|
460 |
-
wp_insert_term( $term['name'], $taxonomy );
|
461 |
-
}
|
462 |
-
}
|
463 |
-
}
|
464 |
-
}
|
465 |
-
}
|
466 |
-
|
467 |
-
/**
|
468 |
-
* Kicking this off by calling 'get_instance()' method
|
469 |
-
*/
|
470 |
-
Cartflows_Step_Post_Type::get_instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Step post type.
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Initialization
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Step_Post_Type {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Member Variable
|
25 |
+
*
|
26 |
+
* @var body_classes
|
27 |
+
*/
|
28 |
+
private $body_classes = array();
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Initiator
|
32 |
+
*/
|
33 |
+
public static function get_instance() {
|
34 |
+
if ( ! isset( self::$instance ) ) {
|
35 |
+
self::$instance = new self;
|
36 |
+
}
|
37 |
+
return self::$instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor
|
42 |
+
*/
|
43 |
+
public function __construct() {
|
44 |
+
|
45 |
+
add_action( 'init', array( $this, 'step_post_type' ) );
|
46 |
+
add_action( 'init', array( $this, 'add_wp_templates_support' ) );
|
47 |
+
add_filter( 'post_updated_messages', array( $this, 'post_update_messages' ) );
|
48 |
+
add_filter( 'post_type_link', array( $this, 'post_type_permalinks' ), 10, 3 );
|
49 |
+
add_filter( 'wp_unique_post_slug', array( $this, 'prevent_slug_duplicates' ), 10, 6 );
|
50 |
+
add_action( 'pre_get_posts', array( $this, 'add_cpt_post_names_to_main_query' ), 20 );
|
51 |
+
|
52 |
+
add_filter( 'template_include', array( $this, 'load_page_template' ), 99 );
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Trys to load page.php for a header, footer or part theme layout.
|
58 |
+
*
|
59 |
+
* @since 1.0.0
|
60 |
+
* @param string $template The current template to be loaded.
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
function load_page_template( $template ) {
|
64 |
+
|
65 |
+
global $post;
|
66 |
+
|
67 |
+
if ( 'string' == gettype( $template ) && is_object( $post ) && CARTFLOWS_STEP_POST_TYPE === $post->post_type ) {
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Remove Next/Prev Navigation
|
71 |
+
* add_filter('next_post_link', '__return_empty_string');
|
72 |
+
* add_filter('previous_post_link', '__return_empty_string');
|
73 |
+
*
|
74 |
+
* $page = locate_template( array( 'page.php' ) );
|
75 |
+
*
|
76 |
+
* if ( ! empty( $page ) ) {
|
77 |
+
* return $page;
|
78 |
+
* }
|
79 |
+
*/
|
80 |
+
|
81 |
+
/* Remove Next / Previous Rel Link */
|
82 |
+
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
83 |
+
add_filter( 'next_post_rel_link', '__return_empty_string' );
|
84 |
+
add_filter( 'previous_post_rel_link', '__return_empty_string' );
|
85 |
+
|
86 |
+
$page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true );
|
87 |
+
|
88 |
+
$page_template = apply_filters( 'cartflows_page_template', $page_template );
|
89 |
+
|
90 |
+
$file = '';
|
91 |
+
|
92 |
+
switch ( $page_template ) {
|
93 |
+
|
94 |
+
case 'cartflows-default':
|
95 |
+
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
96 |
+
$this->body_classes[] = $page_template;
|
97 |
+
break;
|
98 |
+
case 'cartflows-canvas':
|
99 |
+
$file = CARTFLOWS_FLOW_DIR . 'templates/template-canvas.php';
|
100 |
+
$this->body_classes[] = $page_template;
|
101 |
+
break;
|
102 |
+
default:
|
103 |
+
$file = CARTFLOWS_FLOW_DIR . 'templates/template-default.php';
|
104 |
+
$this->body_classes[] = 'cartflows-default';
|
105 |
+
break;
|
106 |
+
}
|
107 |
+
|
108 |
+
// Just to be safe, we check if the file exist first.
|
109 |
+
if ( file_exists( $file ) ) {
|
110 |
+
|
111 |
+
/* Add Body Class */
|
112 |
+
add_filter( 'body_class', [ $this, 'body_class' ] );
|
113 |
+
|
114 |
+
return $file;
|
115 |
+
} else {
|
116 |
+
echo $file;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
return $template;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Body classes.
|
125 |
+
*
|
126 |
+
* @since 1.0.0
|
127 |
+
* @param array $classes Body classes.
|
128 |
+
* @return array
|
129 |
+
*/
|
130 |
+
function body_class( $classes = [] ) {
|
131 |
+
|
132 |
+
$classes = array_merge( $classes, $this->body_classes );
|
133 |
+
|
134 |
+
return $classes;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Create custom post type
|
139 |
+
*/
|
140 |
+
function step_post_type() {
|
141 |
+
|
142 |
+
$labels = array(
|
143 |
+
'name' => esc_html_x( 'Steps', 'flow step general name', 'cartflows' ),
|
144 |
+
'singular_name' => esc_html_x( 'Step', 'flow step singular name', 'cartflows' ),
|
145 |
+
'search_items' => esc_html__( 'Search Steps', 'cartflows' ),
|
146 |
+
'all_items' => esc_html__( 'All Steps', 'cartflows' ),
|
147 |
+
'edit_item' => esc_html__( 'Edit Step', 'cartflows' ),
|
148 |
+
'view_item' => esc_html__( 'View Step', 'cartflows' ),
|
149 |
+
'add_new' => esc_html__( 'Add New', 'cartflows' ),
|
150 |
+
'update_item' => esc_html__( 'Update Step', 'cartflows' ),
|
151 |
+
'add_new_item' => esc_html__( 'Add New', 'cartflows' ),
|
152 |
+
'new_item_name' => esc_html__( 'New Step Name', 'cartflows' ),
|
153 |
+
);
|
154 |
+
|
155 |
+
$args = array(
|
156 |
+
'labels' => $labels,
|
157 |
+
'public' => true,
|
158 |
+
'query_var' => true,
|
159 |
+
'can_export' => true,
|
160 |
+
'exclude_from_search' => true,
|
161 |
+
'show_ui' => true,
|
162 |
+
'show_in_menu' => false,
|
163 |
+
'show_in_admin_bar' => true,
|
164 |
+
'supports' => array( 'title', 'editor', 'elementor', 'revisions' ),
|
165 |
+
'capability_type' => 'post',
|
166 |
+
'capabilities' => array(
|
167 |
+
'create_posts' => 'do_not_allow', // Prior to Wordpress 4.5, this was false.
|
168 |
+
),
|
169 |
+
'map_meta_cap' => true,
|
170 |
+
);
|
171 |
+
|
172 |
+
register_post_type( CARTFLOWS_STEP_POST_TYPE, $args );
|
173 |
+
|
174 |
+
$args = array(
|
175 |
+
'label' => __( 'Step Type', 'cartflows' ),
|
176 |
+
'public' => false,
|
177 |
+
'rewrite' => false,
|
178 |
+
'hierarchical' => false,
|
179 |
+
);
|
180 |
+
|
181 |
+
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_TYPE, CARTFLOWS_STEP_POST_TYPE, $args );
|
182 |
+
|
183 |
+
$args = array(
|
184 |
+
'label' => __( 'Step Flow', 'cartflows' ),
|
185 |
+
'public' => false,
|
186 |
+
'rewrite' => false,
|
187 |
+
'hierarchical' => false,
|
188 |
+
);
|
189 |
+
|
190 |
+
register_taxonomy( CARTFLOWS_TAXONOMY_STEP_FLOW, CARTFLOWS_STEP_POST_TYPE, $args );
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Register 'Elementor' & 'Beaver Builder' site types.
|
194 |
+
*
|
195 |
+
* @see self::add_terms();
|
196 |
+
*/
|
197 |
+
$taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE;
|
198 |
+
|
199 |
+
$terms = array(
|
200 |
+
array(
|
201 |
+
'name' => __( 'Landing', 'cartflows' ),
|
202 |
+
'args' => array(
|
203 |
+
'slug' => 'landing',
|
204 |
+
),
|
205 |
+
),
|
206 |
+
array(
|
207 |
+
'name' => __( 'Checkout', 'cartflows' ),
|
208 |
+
'args' => array(
|
209 |
+
'slug' => 'checkout',
|
210 |
+
),
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
'name' => __( 'Thank You', 'cartflows' ),
|
214 |
+
'args' => array(
|
215 |
+
'slug' => 'thankyou',
|
216 |
+
),
|
217 |
+
),
|
218 |
+
array(
|
219 |
+
'name' => __( 'Upsell', 'cartflows' ),
|
220 |
+
'args' => array(
|
221 |
+
'slug' => 'upsell',
|
222 |
+
),
|
223 |
+
),
|
224 |
+
array(
|
225 |
+
'name' => __( 'Downsell', 'cartflows' ),
|
226 |
+
'args' => array(
|
227 |
+
'slug' => 'downsell',
|
228 |
+
),
|
229 |
+
),
|
230 |
+
);
|
231 |
+
|
232 |
+
$this->add_terms( $taxonomy, $terms );
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Add WordPress templates.
|
237 |
+
*
|
238 |
+
* Adds Cartflows templates to steps
|
239 |
+
*
|
240 |
+
* @since 1.0.0
|
241 |
+
* @access public
|
242 |
+
*/
|
243 |
+
function add_wp_templates_support() {
|
244 |
+
add_filter( 'theme_' . CARTFLOWS_STEP_POST_TYPE . '_templates', array( $this, 'add_page_templates' ), 99, 4 );
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Add page templates.
|
249 |
+
*
|
250 |
+
* @since 1.0.0
|
251 |
+
* @access public
|
252 |
+
*
|
253 |
+
* @param array $page_templates Array of page templates.
|
254 |
+
*
|
255 |
+
* @param object $wp_theme wp theme.
|
256 |
+
* @param object $post post.
|
257 |
+
*
|
258 |
+
* @return array Page templates.
|
259 |
+
*/
|
260 |
+
function add_page_templates( $page_templates, $wp_theme, $post ) {
|
261 |
+
|
262 |
+
$page_templates = array(
|
263 |
+
'cartflows-canvas' => _x( 'Template for Page Builders', 'cartflows' ),
|
264 |
+
);
|
265 |
+
|
266 |
+
return $page_templates;
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Have WordPress match postname to any of our public post types.
|
271 |
+
* All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts.
|
272 |
+
* By default, WordPress only accounts for posts and pages where the slug is /post-name/.
|
273 |
+
*
|
274 |
+
* @param string $query query statement.
|
275 |
+
*/
|
276 |
+
function add_cpt_post_names_to_main_query( $query ) {
|
277 |
+
|
278 |
+
// Bail if this is not the main query.
|
279 |
+
if ( ! $query->is_main_query() ) {
|
280 |
+
return;
|
281 |
+
}
|
282 |
+
|
283 |
+
// Bail if this query doesn't match our very specific rewrite rule.
|
284 |
+
if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) {
|
285 |
+
return;
|
286 |
+
}
|
287 |
+
|
288 |
+
// Bail if we're not querying based on the post name.
|
289 |
+
if ( empty( $query->query['name'] ) ) {
|
290 |
+
return;
|
291 |
+
}
|
292 |
+
|
293 |
+
// Add cartflows step post type to existing post type array.
|
294 |
+
if ( isset( $query->query_vars['post_type'] ) && is_array( $query->query_vars['post_type'] ) ) {
|
295 |
+
|
296 |
+
$post_types = $query->query_vars['post_type'];
|
297 |
+
|
298 |
+
$post_types[] = CARTFLOWS_STEP_POST_TYPE;
|
299 |
+
|
300 |
+
$query->set( 'post_type', $post_types );
|
301 |
+
|
302 |
+
} else {
|
303 |
+
|
304 |
+
// Add CPT to the list of post types WP will include when it queries based on the post name.
|
305 |
+
$query->set( 'post_type', array( 'post', 'page', CARTFLOWS_STEP_POST_TYPE ) );
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Modify permalink
|
311 |
+
*
|
312 |
+
* @param string $post_link post link.
|
313 |
+
* @param array $post post data.
|
314 |
+
* @param string $leavename leave name.
|
315 |
+
* @return string
|
316 |
+
*/
|
317 |
+
function post_type_permalinks( $post_link, $post, $leavename ) {
|
318 |
+
|
319 |
+
// If elementor page preview, return post link as it is.
|
320 |
+
if ( isset( $_REQUEST['elementor-preview'] ) ) {
|
321 |
+
return $post_link;
|
322 |
+
}
|
323 |
+
|
324 |
+
$structure = get_option( 'permalink_structure' );
|
325 |
+
|
326 |
+
if ( '/%postname%/' === $structure ) {
|
327 |
+
|
328 |
+
if ( isset( $post->post_type ) && CARTFLOWS_STEP_POST_TYPE == $post->post_type ) {
|
329 |
+
|
330 |
+
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
return $post_link;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Prevent slug duplicated
|
339 |
+
*
|
340 |
+
* @param string $slug post slug.
|
341 |
+
* @param int $post_ID post id.
|
342 |
+
* @param string $post_status post status.
|
343 |
+
* @param string $post_type post type.
|
344 |
+
* @param int $post_parent post parent id.
|
345 |
+
* @param string $original_slug original slug.
|
346 |
+
* @return string
|
347 |
+
*/
|
348 |
+
function prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
|
349 |
+
|
350 |
+
$check_post_types = array(
|
351 |
+
'post',
|
352 |
+
'page',
|
353 |
+
CARTFLOWS_STEP_POST_TYPE,
|
354 |
+
);
|
355 |
+
|
356 |
+
if ( ! in_array( $post_type, $check_post_types ) ) {
|
357 |
+
return $slug;
|
358 |
+
}
|
359 |
+
|
360 |
+
if ( CARTFLOWS_STEP_POST_TYPE == $post_type ) {
|
361 |
+
// Saving a post, check for duplicates in POST or PAGE post types.
|
362 |
+
$post_match = get_page_by_path( $slug, 'OBJECT', 'post' );
|
363 |
+
$page_match = get_page_by_path( $slug, 'OBJECT', 'page' );
|
364 |
+
|
365 |
+
if ( $post_match || $page_match ) {
|
366 |
+
$slug .= '-2';
|
367 |
+
}
|
368 |
+
} else {
|
369 |
+
|
370 |
+
// Saving a POST or PAGE, check for duplicates in CARTFLOWS_STEP_POST_TYPE post type.
|
371 |
+
$custom_post_type_match = get_page_by_path( $slug, 'OBJECT', CARTFLOWS_STEP_POST_TYPE );
|
372 |
+
|
373 |
+
if ( $custom_post_type_match ) {
|
374 |
+
$slug .= '-2';
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
+
return $slug;
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Add Update messages for any custom post type
|
383 |
+
*
|
384 |
+
* @param array $messages Array of default messages.
|
385 |
+
*/
|
386 |
+
function post_update_messages( $messages ) {
|
387 |
+
|
388 |
+
$custom_post_type = get_post_type( get_the_ID() );
|
389 |
+
|
390 |
+
if ( CARTFLOWS_STEP_POST_TYPE == $custom_post_type ) {
|
391 |
+
|
392 |
+
$obj = get_post_type_object( $custom_post_type );
|
393 |
+
$singular_name = $obj->labels->singular_name;
|
394 |
+
$messages[ $custom_post_type ] = array(
|
395 |
+
0 => '', // Unused. Messages start at index 1.
|
396 |
+
/* translators: %s: singular custom post type name */
|
397 |
+
1 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
398 |
+
/* translators: %s: singular custom post type name */
|
399 |
+
2 => sprintf( __( 'Custom %s updated.', 'cartflows' ), $singular_name ),
|
400 |
+
/* translators: %s: singular custom post type name */
|
401 |
+
3 => sprintf( __( 'Custom %s deleted.', 'cartflows' ), $singular_name ),
|
402 |
+
/* translators: %s: singular custom post type name */
|
403 |
+
4 => sprintf( __( '%s updated.', 'cartflows' ), $singular_name ),
|
404 |
+
/* translators: %1$s: singular custom post type name ,%2$s: date and time of the revision */
|
405 |
+
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'cartflows' ), $singular_name, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
406 |
+
/* translators: %s: singular custom post type name */
|
407 |
+
6 => sprintf( __( '%s published.', 'cartflows' ), $singular_name ),
|
408 |
+
/* translators: %s: singular custom post type name */
|
409 |
+
7 => sprintf( __( '%s saved.', 'cartflows' ), $singular_name ),
|
410 |
+
/* translators: %s: singular custom post type name */
|
411 |
+
8 => sprintf( __( '%s submitted.', 'cartflows' ), $singular_name ),
|
412 |
+
/* translators: %s: singular custom post type name */
|
413 |
+
9 => sprintf( __( '%s scheduled for.', 'cartflows' ), $singular_name ),
|
414 |
+
/* translators: %s: singular custom post type name */
|
415 |
+
10 => sprintf( __( '%s draft updated.', 'cartflows' ), $singular_name ),
|
416 |
+
);
|
417 |
+
}
|
418 |
+
|
419 |
+
return $messages;
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Add Terms for Taxonomy.
|
424 |
+
*
|
425 |
+
* => Example.
|
426 |
+
*
|
427 |
+
* $taxonomy = '{taxonomy}';
|
428 |
+
* $terms = array(
|
429 |
+
* array(
|
430 |
+
* 'name' => 'Free',
|
431 |
+
* ),
|
432 |
+
* array(
|
433 |
+
* 'name' => 'Premium',
|
434 |
+
* ),
|
435 |
+
* );
|
436 |
+
*
|
437 |
+
* self::add_terms( $taxonomy, $terms );
|
438 |
+
*
|
439 |
+
* @since 1.0.0
|
440 |
+
* @param string $taxonomy Taxonomy Name.
|
441 |
+
* @param array $terms Terms list.
|
442 |
+
* @return void
|
443 |
+
*/
|
444 |
+
function add_terms( $taxonomy = '', $terms = array() ) {
|
445 |
+
|
446 |
+
foreach ( $terms as $key => $term ) {
|
447 |
+
|
448 |
+
$term_exist = term_exists( $term['name'], $taxonomy );
|
449 |
+
|
450 |
+
if ( empty( $term_exist ) ) {
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Add additional args if passed from request.
|
454 |
+
*
|
455 |
+
* @see https://codex.wordpress.org/Function_Reference/wp_insert_term
|
456 |
+
*/
|
457 |
+
if ( array_key_exists( 'args', $term ) ) {
|
458 |
+
wp_insert_term( $term['name'], $taxonomy, $term['args'] );
|
459 |
+
} else {
|
460 |
+
wp_insert_term( $term['name'], $taxonomy );
|
461 |
+
}
|
462 |
+
}
|
463 |
+
}
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Kicking this off by calling 'get_instance()' method
|
469 |
+
*/
|
470 |
+
Cartflows_Step_Post_Type::get_instance();
|
modules/flow/templates/template-canvas.php
CHANGED
@@ -1,49 +1,49 @@
|
|
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 do_action( 'cartflows_body_top' ); ?>
|
22 |
-
|
23 |
-
<?php
|
24 |
-
|
25 |
-
$atts_string = Cartflows_Helper::get_cartflows_container_atts();
|
26 |
-
|
27 |
-
?>
|
28 |
-
<div class="cartflows-container" <?php echo trim( $atts_string ); ?>>
|
29 |
-
|
30 |
-
<?php
|
31 |
-
do_action( 'cartflows_container_top' );
|
32 |
-
while ( have_posts() ) :
|
33 |
-
|
34 |
-
the_post();
|
35 |
-
the_content();
|
36 |
-
|
37 |
-
endwhile;
|
38 |
-
do_action( 'cartflows_container_bottom' );
|
39 |
-
?>
|
40 |
-
</div>
|
41 |
-
|
42 |
-
<?php do_action( 'cartflows_wp_footer' ); ?>
|
43 |
-
|
44 |
-
<?php wp_footer(); ?>
|
45 |
-
</body>
|
46 |
-
|
47 |
-
</html>
|
48 |
-
|
49 |
-
<?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 do_action( 'cartflows_body_top' ); ?>
|
22 |
+
|
23 |
+
<?php
|
24 |
+
|
25 |
+
$atts_string = Cartflows_Helper::get_cartflows_container_atts();
|
26 |
+
|
27 |
+
?>
|
28 |
+
<div class="cartflows-container" <?php echo trim( $atts_string ); ?>>
|
29 |
+
|
30 |
+
<?php
|
31 |
+
do_action( 'cartflows_container_top' );
|
32 |
+
while ( have_posts() ) :
|
33 |
+
|
34 |
+
the_post();
|
35 |
+
the_content();
|
36 |
+
|
37 |
+
endwhile;
|
38 |
+
do_action( 'cartflows_container_bottom' );
|
39 |
+
?>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<?php do_action( 'cartflows_wp_footer' ); ?>
|
43 |
+
|
44 |
+
<?php wp_footer(); ?>
|
45 |
+
</body>
|
46 |
+
|
47 |
+
</html>
|
48 |
+
|
49 |
+
<?php
|
modules/flow/templates/template-default.php
CHANGED
@@ -1,54 +1,54 @@
|
|
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 do_action( 'cartflows_body_top' ); ?>
|
22 |
-
|
23 |
-
<?php
|
24 |
-
|
25 |
-
$atts_string = Cartflows_Helper::get_cartflows_container_atts();
|
26 |
-
|
27 |
-
?>
|
28 |
-
<div class="cartflows-container" <?php echo trim( $atts_string ); ?>>
|
29 |
-
<?php
|
30 |
-
do_action( 'cartflows_container_top' );
|
31 |
-
?>
|
32 |
-
<div class="cartflows-primary">
|
33 |
-
<?php
|
34 |
-
while ( have_posts() ) :
|
35 |
-
|
36 |
-
the_post();
|
37 |
-
the_content();
|
38 |
-
|
39 |
-
endwhile;
|
40 |
-
?>
|
41 |
-
</div>
|
42 |
-
<?php
|
43 |
-
do_action( 'cartflows_container_bottom' );
|
44 |
-
?>
|
45 |
-
</div>
|
46 |
-
|
47 |
-
<?php do_action( 'cartflows_wp_footer' ); ?>
|
48 |
-
|
49 |
-
<?php wp_footer(); ?>
|
50 |
-
</body>
|
51 |
-
|
52 |
-
</html>
|
53 |
-
|
54 |
-
<?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 do_action( 'cartflows_body_top' ); ?>
|
22 |
+
|
23 |
+
<?php
|
24 |
+
|
25 |
+
$atts_string = Cartflows_Helper::get_cartflows_container_atts();
|
26 |
+
|
27 |
+
?>
|
28 |
+
<div class="cartflows-container" <?php echo trim( $atts_string ); ?>>
|
29 |
+
<?php
|
30 |
+
do_action( 'cartflows_container_top' );
|
31 |
+
?>
|
32 |
+
<div class="cartflows-primary">
|
33 |
+
<?php
|
34 |
+
while ( have_posts() ) :
|
35 |
+
|
36 |
+
the_post();
|
37 |
+
the_content();
|
38 |
+
|
39 |
+
endwhile;
|
40 |
+
?>
|
41 |
+
</div>
|
42 |
+
<?php
|
43 |
+
do_action( 'cartflows_container_bottom' );
|
44 |
+
?>
|
45 |
+
</div>
|
46 |
+
|
47 |
+
<?php do_action( 'cartflows_wp_footer' ); ?>
|
48 |
+
|
49 |
+
<?php wp_footer(); ?>
|
50 |
+
</body>
|
51 |
+
|
52 |
+
</html>
|
53 |
+
|
54 |
+
<?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-logo-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-logo-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/landing/classes/class-cartflows-landing-markup.php
CHANGED
@@ -1,133 +1,139 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Markup
|
4 |
-
*
|
5 |
-
* @package CartFlows
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Checkout Markup
|
10 |
-
*
|
11 |
-
* @since 1.0.0
|
12 |
-
*/
|
13 |
-
class Cartflows_Landing_Markup {
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Member Variable
|
18 |
-
*
|
19 |
-
* @var object instance
|
20 |
-
*/
|
21 |
-
private static $instance;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Initiator
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if ( ! isset( self::$instance ) ) {
|
28 |
-
self::$instance = new self;
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
39 |
-
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
40 |
-
|
41 |
-
if ( is_admin() ) {
|
42 |
-
add_filter( 'wp_dropdown_pages', array( $this, 'wp_dropdown_pages' ) );
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Add landing pages in WordPress reading section.
|
48 |
-
*
|
49 |
-
* @param array $output output.
|
50 |
-
*/
|
51 |
-
function wp_dropdown_pages( $output ) {
|
52 |
-
|
53 |
-
global $pagenow;
|
54 |
-
|
55 |
-
if ( ( 'options-reading.php' === $pagenow || 'customize.php' === $pagenow ) && preg_match( '#page_on_front#', $output ) ) {
|
56 |
-
|
57 |
-
$args = array(
|
58 |
-
'post_type'
|
59 |
-
'
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
if (
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Markup
|
4 |
+
*
|
5 |
+
* @package CartFlows
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Checkout Markup
|
10 |
+
*
|
11 |
+
* @since 1.0.0
|
12 |
+
*/
|
13 |
+
class Cartflows_Landing_Markup {
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Member Variable
|
18 |
+
*
|
19 |
+
* @var object instance
|
20 |
+
*/
|
21 |
+
private static $instance;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Initiator
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if ( ! isset( self::$instance ) ) {
|
28 |
+
self::$instance = new self;
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
39 |
+
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
|
40 |
+
|
41 |
+
if ( is_admin() ) {
|
42 |
+
add_filter( 'wp_dropdown_pages', array( $this, 'wp_dropdown_pages' ) );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Add landing pages in WordPress reading section.
|
48 |
+
*
|
49 |
+
* @param array $output output.
|
50 |
+
*/
|
51 |
+
function wp_dropdown_pages( $output ) {
|
52 |
+
|
53 |
+
global $pagenow;
|
54 |
+
|
55 |
+
if ( ( 'options-reading.php' === $pagenow || 'customize.php' === $pagenow ) && preg_match( '#page_on_front#', $output ) ) {
|
56 |
+
|
57 |
+
$args = array(
|
58 |
+
'post_type' => CARTFLOWS_STEP_POST_TYPE,
|
59 |
+
'numberposts' => 100,
|
60 |
+
'meta_query' => array(
|
61 |
+
'relation' => 'OR',
|
62 |
+
array(
|
63 |
+
'key' => 'wcf-step-type',
|
64 |
+
'value' => 'landing',
|
65 |
+
),
|
66 |
+
array(
|
67 |
+
'key' => 'wcf-step-type',
|
68 |
+
'value' => 'checkout',
|
69 |
+
),
|
70 |
+
),
|
71 |
+
);
|
72 |
+
|
73 |
+
$landing_pages = get_posts( $args );
|
74 |
+
|
75 |
+
if ( is_array( $landing_pages ) && ! empty( $landing_pages ) ) {
|
76 |
+
|
77 |
+
$cartflows_custom_option = '';
|
78 |
+
|
79 |
+
$front_page_id = get_option( 'page_on_front' );
|
80 |
+
|
81 |
+
foreach ( $landing_pages as $key => $landing_page ) {
|
82 |
+
|
83 |
+
$selected = selected( $front_page_id, $landing_page->ID, false );
|
84 |
+
|
85 |
+
$cartflows_custom_option .= "<option value=\"{$landing_page->ID}\"{$selected}>{$landing_page->post_title} ( #{$landing_page->ID} - CartFlows )</option>";
|
86 |
+
}
|
87 |
+
|
88 |
+
$cartflows_custom_option .= '</select>';
|
89 |
+
|
90 |
+
$output = str_replace( '</select>', $cartflows_custom_option, $output );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
return $output;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Set post query.
|
99 |
+
*
|
100 |
+
* @param string $query post query.
|
101 |
+
*/
|
102 |
+
function pre_get_posts( $query ) {
|
103 |
+
|
104 |
+
if ( $query->is_main_query() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
105 |
+
|
106 |
+
$post_type = $query->get( 'post_type' );
|
107 |
+
|
108 |
+
$page_id = $query->get( 'page_id' );
|
109 |
+
|
110 |
+
if ( empty( $post_type ) && ! empty( $page_id ) ) {
|
111 |
+
$query->set( 'post_type', get_post_type( $page_id ) );
|
112 |
+
}
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Redirect to homepage if landing page set as home page.
|
118 |
+
*/
|
119 |
+
function template_redirect() {
|
120 |
+
|
121 |
+
$compatibiliy = Cartflows_Compatibility::get_instance();
|
122 |
+
|
123 |
+
// Do not redirect for page builder preview.
|
124 |
+
if ( $compatibiliy->is_page_builder_preview() ) {
|
125 |
+
return;
|
126 |
+
}
|
127 |
+
|
128 |
+
global $post;
|
129 |
+
|
130 |
+
if ( is_singular() && ! is_front_page() && get_option( 'page_on_front' ) == $post->ID ) {
|
131 |
+
wp_safe_redirect( site_url(), 301 );
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Kicking this off by calling 'get_instance()' method
|
138 |
+
*/
|
139 |
+
Cartflows_Landing_Markup::get_instance();
|
modules/thankyou/classes/class-cartflows-thankyou-markup.php
CHANGED
@@ -1,273 +1,274 @@
|
|
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 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
|
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 |
+
img.emoji, img.wp-smiley {}
|
225 |
+
";
|
226 |
+
|
227 |
+
if ( 'no' == $show_order_review ) {
|
228 |
+
$output .= '
|
229 |
+
.woocommerce-order ul.order_details{
|
230 |
+
display: none;
|
231 |
+
}
|
232 |
+
';
|
233 |
+
}
|
234 |
+
|
235 |
+
if ( 'no' == $show_order_details ) {
|
236 |
+
$output .= '
|
237 |
+
.woocommerce-order .woocommerce-order-details{
|
238 |
+
display: none;
|
239 |
+
}
|
240 |
+
';
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( 'no' == $show_billing_details ) {
|
244 |
+
$output .= '
|
245 |
+
.woocommerce-order .woocommerce-customer-details .woocommerce-column--billing-address{
|
246 |
+
display: none;
|
247 |
+
}
|
248 |
+
';
|
249 |
+
}
|
250 |
+
|
251 |
+
if ( 'no' == $show_shipping_details ) {
|
252 |
+
$output .= '
|
253 |
+
.woocommerce-order .woocommerce-customer-details .woocommerce-column--shipping-address{
|
254 |
+
display: none;
|
255 |
+
}
|
256 |
+
';
|
257 |
+
}
|
258 |
+
|
259 |
+
if ( 'no' == $show_billing_details && 'no' == $show_shipping_details ) {
|
260 |
+
$output .= '
|
261 |
+
.woocommerce-order .woocommerce-customer-details{
|
262 |
+
display: none;
|
263 |
+
}
|
264 |
+
';
|
265 |
+
}
|
266 |
+
|
267 |
+
return $output;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Kicking this off by calling 'get_instance()' method
|
273 |
+
*/
|
274 |
+
Cartflows_Thankyou_Markup::get_instance();
|
readme.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
=== CartFlows ===
|
2 |
Contributors: brainstormforce, wpcrafter
|
3 |
Donate link: https://www.paypal.me/BrainstormForce
|
4 |
Tags: woocommerce, cart
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.1
|
8 |
-
Stable tag: 1.1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -93,6 +93,10 @@ Say goodby to using the same ridgid checkout page that everyone else is using. C
|
|
93 |
|
94 |
== Changelog ==
|
95 |
|
|
|
|
|
|
|
|
|
96 |
= Version 1.1.11 - Tuesday, 19th March 2019 =
|
97 |
* Fix: Checkbox tick on checkout was not visible in some cases.
|
98 |
* Fix: Width issue of order review.
|
1 |
+
=== Funnel Builder by CartFlows - Create High Converting Sales Funnels For WordPress ===
|
2 |
Contributors: brainstormforce, wpcrafter
|
3 |
Donate link: https://www.paypal.me/BrainstormForce
|
4 |
Tags: woocommerce, cart
|
5 |
Requires at least: 4.4
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.1
|
8 |
+
Stable tag: 1.1.12
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
93 |
|
94 |
== Changelog ==
|
95 |
|
96 |
+
= Version 1.1.12 - Friday, 22nd March 2019 =
|
97 |
+
* New: Added ability to set checkout page as a home page.
|
98 |
+
* Fix: Thrive Architect CSS conflict.
|
99 |
+
|
100 |
= Version 1.1.11 - Tuesday, 19th March 2019 =
|
101 |
* Fix: Checkbox tick on checkout was not visible in some cases.
|
102 |
* Fix: Width issue of order review.
|