PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / trunk
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce vtrunk
3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.20 1.1.21 All 160 releases
cartflows / classes / importer / batch-process / class-cartflows-batch-process.php

class-cartflows-batch-process.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce trunk, at classes/importer/batch-process/class-cartflows-batch-process.php

700 lines 21.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Batch Processing
4 *
5 * @package CartFlows
6 * @since 1.0.0
7 */
8
9 // Exit if accessed directly.
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13 if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :
14
15 /**
16 * CartFlows_Batch_Process
17 *
18 * @since 1.0.0
19 */
20 class CartFlows_Batch_Process {
21
22 /**
23 * Instance
24 *
25 * @since 1.0.0
26 * @var object Class object.
27 * @access private
28 */
29 private static $instance;
30
31 /**
32 * Elementor Batch Instance
33 *
34 * @since 1.1.1 Updated instance name with elementor specific.
35 *
36 * @since 1.0.0
37 * @var object Class object.
38 * @access public
39 */
40 public static $batch_instance_elementor;
41
42 /**
43 * Beaver Builder Batch Instance
44 *
45 * @since 1.1.1
46 * @var object Class object.
47 * @access public
48 */
49 public static $batch_instance_bb;
50
51 /**
52 * Divi Batch Instance
53 *
54 * @since 1.1.1
55 * @var object Class object.
56 * @access public
57 */
58 public static $batch_instance_divi;
59
60 /**
61 * Gutenberg Batch Instance
62 *
63 * @since 1.5.9
64 * @var object Class object.
65 * @access public
66 */
67 public static $batch_instance_gb;
68
69 /**
70 * Sites Importer
71 *
72 * @since 1.6.15
73 * @var object Class object.
74 * @access public
75 */
76 public static $process_site_importer;
77
78 /**
79 * Last Export Checksums
80 *
81 * @since 1.6.15
82 * @var object Class object.
83 * @access public
84 */
85 public $last_export_checksums;
86
87 /**
88 * Set the
89 *
90 * @since 2.0.8
91 * @var bool True/False flag to get the status of import process.
92 * @access public
93 */
94 public static $is_wcf_template_import;
95
96 /**
97 * Initiator
98 *
99 * @since 1.0.0
100 * @return object initialized object of class.
101 */
102 public static function get_instance() {
103 if ( ! isset( self::$instance ) ) {
104 self::$instance = new self();
105 }
106 return self::$instance;
107 }
108
109 /**
110 * Constructor
111 *
112 * @since 1.0.0
113 */
114 public function __construct() {
115
116 // Not BB or Elementor then avoid importer.
117 // if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
118 // return;
119 // }
120 // Core Helpers - Image.
121 require_once ABSPATH . 'wp-admin/includes/image.php';
122
123 // Core Helpers - Batch Processing.
124 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/helpers/class-cartflows-importer-image.php';
125 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/helpers/class-wp-async-request.php';
126 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/helpers/class-wp-background-process.php';
127
128 $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
129
130 // Elementor.
131 if ( ( 'elementor' === $default_page_builder ) && class_exists( '\Elementor\Plugin' ) ) {
132 // Add "elementor" in import [queue].
133 // @todo Remove required `allow_url_fopen` support.
134 if ( ini_get( 'allow_url_fopen' ) ) {
135 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-importer-elementor.php';
136 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-importer-elementor-batch.php';
137 self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
138 }
139 }
140
141 // Beaver Builder.
142 if ( ( 'beaver-builder' === $default_page_builder ) && class_exists( 'FLBuilder' ) ) {
143 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-importer-beaver-builder.php';
144 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-importer-beaver-builder-batch.php';
145 self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
146 }
147
148 // Divi.
149 if ( ( 'other' === $default_page_builder ) && ( class_exists( 'ET_Builder_Plugin' ) || Cartflows_Compatibility::get_instance()->is_divi_enabled() ) ) {
150 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-importer-divi.php';
151 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-importer-divi-batch.php';
152 self::$batch_instance_divi = new Cartflows_Importer_Divi_Batch();
153 }
154
155 // Gutenberg.
156 if ( ( 'gutenberg' === $default_page_builder ) ) {
157 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-importer-gutenberg.php';
158 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-importer-gutenberg-batch.php';
159 self::$batch_instance_gb = new Cartflows_Importer_Gutenberg_Batch();
160 }
161
162 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/class-cartflows-batch-processing-sync-library.php';
163 require_once CARTFLOWS_DIR . 'classes/importer/batch-process/helpers/class-wp-background-process-cartflows-sync-library.php';
164 self::$process_site_importer = new WP_Background_Process_Cartflows_Sync_Library();
165
166 // Start image importing after site import complete.
167 add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
168 add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
169 add_filter( 'upload_mimes', array( $this, 'wcf_custom_upload_mimes' ) ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.upload_mimes
170 add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 );
171 add_action( 'cartflows_before_elementor_import_single_template', array( $this, 'enable_unfiltered_upload_elementor' ) );
172 add_action( 'admin_head', array( $this, 'start_importer' ) );
173 }
174
175 /**
176 * Start Importer
177 *
178 * @since 1.6.15
179 * @return void
180 */
181 public function start_importer() {
182
183 $is_fresh_site = get_site_option( 'cartflows-fresh-site', '' );
184
185 // Process initially for the fresh user.
186 if ( isset( $_GET['reset'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'cartflows_batch_reset' ) ) {
187
188 // Process import.
189 $this->process_batch();
190
191 } elseif ( empty( $is_fresh_site ) ) {
192
193 // First time user save the data of sites, pages, categories etc from the JSON file.
194 $dir = CARTFLOWS_DIR . 'admin-core/assets/importer-data';
195 $list_files = list_files( $dir );
196 if ( ! empty( $list_files ) ) {
197 $list_files = array_map( 'basename', $list_files );
198
199 foreach ( $list_files as $key => $file_name ) {
200 $data = file_get_contents( $dir . '/' . $file_name );
201 if ( ! empty( $data ) ) {
202 $option_name = str_replace( '.json', '', $file_name );
203 update_site_option( $option_name, json_decode( $data, true ) );
204 }
205 }
206 }
207
208 // Also, Trigger the batch to get latest data.
209 // If batch failed then user have at least the data from the JSON file.
210 $this->process_batch();
211
212 update_site_option( 'cartflows-fresh-site', 'yes', 'no' );
213
214 // If not fresh user then trigger batch import on the transient and option
215 // Only on the Astra Sites page.
216 } else {
217
218 $current_screen = get_current_screen();
219
220 // Bail if not on Astra Sites screen.
221 if ( ! is_object( $current_screen ) && null === $current_screen ) {
222 return;
223 }
224
225 if ( 'toplevel_page_cartflows' === $current_screen->id || 'cartflows_page_cartflows_settings' === $current_screen->id ) {
226
227 // Process import.
228 $this->process_batch();
229 }
230 }
231 }
232
233 /**
234 * Update Latest Checksums
235 *
236 * Store latest checksum after batch complete.
237 *
238 * @param string $templates templates category to fetch.
239 * @since 1.6.15
240 * @return void
241 */
242 public function update_latest_checksums( $templates = '' ) {
243 $suffix = 'store-checkout' === $templates ? 'store-checkout-' : '';
244 wcf()->logger->sync_log( 'Checkusms updated' );
245 $latest_checksums = get_site_option( 'cartflows-' . $suffix . 'last-export-checksums-latest', '' );
246 update_site_option( 'cartflows-' . $suffix . 'last-export-checksums', $latest_checksums, 'no' );
247 }
248
249 /**
250 * Added .svg files as supported format in the uploader.
251 *
252 * @since 1.1.4
253 *
254 * @param array $mimes Already supported mime types.
255 */
256 public function wcf_custom_upload_mimes( $mimes ) {
257 // Return if the current user don't have the access to upload the files.
258 if ( ! current_user_can( 'cartflows_manage_flows_steps' ) && ! current_user_can( 'unfiltered_upload' ) ) {
259 return $mimes;
260 }
261 // Only add the SVG support if and only if the CartFlows import is complete OR in progress.
262 if ( false === get_transient( 'cartflows_is_wcf_template_import' ) ) {
263 return $mimes;
264 }
265 // Allow SVG files.
266 $mimes['svg'] = 'image/svg+xml';
267 $mimes['svgz'] = 'image/svg+xml';
268
269 // Allow XML files.
270 $mimes['xml'] = 'text/xml';
271
272 return $mimes;
273 }
274
275 /**
276 * Add SVG image support
277 *
278 * @since 1.1.4
279 *
280 * @param array $response Attachment response.
281 * @param object $attachment Attachment object.
282 * @param array $meta Attachment meta data.
283 */
284 public function add_svg_image_support( $response, $attachment, $meta ) {
285 if ( ! function_exists( 'simplexml_load_file' ) ) {
286 return $response;
287 }
288
289 if ( ! empty( $response['sizes'] ) ) {
290 return $response;
291 }
292
293 if ( 'image/svg+xml' !== $response['mime'] ) {
294 return $response;
295 }
296
297 $svg_path = get_attached_file( $attachment->ID );
298
299 $dimensions = self::get_svg_dimensions( $svg_path );
300
301 $response['sizes'] = array(
302 'full' => array(
303 'url' => $response['url'],
304 'width' => $dimensions->width,
305 'height' => $dimensions->height,
306 'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait',
307 ),
308 );
309
310 return $response;
311 }
312
313 /**
314 * Get SVG Dimensions
315 *
316 * @since 1.1.4.
317 *
318 * @param string $svg SVG file path.
319 * @return array Return SVG file height & width for valid SVG file.
320 */
321 public static function get_svg_dimensions( $svg ) {
322
323 // Security: Disable external entity loading to prevent XXE attacks.
324 $previous_value = libxml_disable_entity_loader( true ); // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated
325 $svg = simplexml_load_file( $svg, 'SimpleXMLElement', LIBXML_NONET | LIBXML_NOENT );
326 libxml_disable_entity_loader( $previous_value ); // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated
327
328 if ( false === $svg ) {
329 $width = '0';
330 $height = '0';
331 } else {
332 $attributes = $svg->attributes();
333 $width = (string) $attributes->width;
334 $height = (string) $attributes->height;
335 }
336
337 return (object) array(
338 'width' => $width,
339 'height' => $height,
340 );
341 }
342
343 /**
344 * Batch Process Complete.
345 *
346 * @return void
347 */
348 public function complete_batch_import() {
349 wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
350 }
351
352 /**
353 * Start Image Import
354 *
355 * @param integer $post_id Post Id.
356 *
357 * @return void
358 */
359 public function start_batch_process( $post_id = '' ) {
360
361 $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' );
362
363 wcf()->logger->import_log( '(✓) BATCH Started!' );
364 wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
365
366 // Add "elementor" in import [queue].
367 if ( 'beaver-builder' === $default_page_builder && self::$batch_instance_bb ) {
368
369 // Add to queue.
370 self::$batch_instance_bb->push_to_queue( $post_id );
371
372 // Dispatch Queue.
373 self::$batch_instance_bb->save()->dispatch();
374
375 wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
376
377 } elseif ( 'elementor' === $default_page_builder && self::$batch_instance_elementor ) {
378
379 // Add to queue.
380 self::$batch_instance_elementor->push_to_queue( $post_id );
381
382 // Dispatch Queue.
383 self::$batch_instance_elementor->save()->dispatch();
384
385 wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
386 } elseif ( 'divi' === $default_page_builder && self::$batch_instance_divi ) {
387
388 // Add to queue.
389 self::$batch_instance_divi->push_to_queue( $post_id );
390
391 // Dispatch Queue.
392 self::$batch_instance_divi->save()->dispatch();
393
394 wcf()->logger->import_log( '(✓) Dispatch "Divi" Request..' );
395 } elseif ( 'gutenberg' === $default_page_builder && self::$batch_instance_gb ) {
396
397 // Add to queue.
398 self::$batch_instance_gb->push_to_queue( $post_id );
399
400 // Dispatch Queue.
401 self::$batch_instance_gb->save()->dispatch();
402
403 wcf()->logger->import_log( '(✓) Dispatch "Gutenberg" Request..' );
404 } else {
405 wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
406 }
407 }
408
409 /**
410 * Set Last Exported Checksum
411 *
412 * @param string $templates templates category to fetch.
413 * @since 1.6.15
414 * @return string Checksums Status.
415 */
416 public function set_last_export_checksums( $templates = '' ) {
417
418 if ( ! empty( $this->last_export_checksums ) ) {
419 return $this->last_export_checksums;
420 }
421
422 $api_args = array(
423 'timeout' => 60, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
424 );
425
426 wcf()->logger->sync_log( wcf()->get_site_url() . 'wp-json/cartflows-server/v1/get-last-export-checksums' );
427
428 $response = wp_remote_get( wcf()->get_site_url() . 'wp-json/cartflows-server/v1/get-last-export-checksums', $api_args );
429 if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
430 $result = json_decode( wp_remote_retrieve_body( $response ), true );
431
432 // Set last export checksums.
433 if ( ! empty( $result['last_export_checksums'] ) ) {
434 $suffix = 'store-checkout' === $templates ? 'store-checkout-' : '';
435 update_site_option( 'cartflows-' . $suffix . 'last-export-checksums-latest', $result['last_export_checksums'], 'no' );
436
437 $this->last_export_checksums = $result['last_export_checksums'];
438 }
439 }
440
441 return $this->last_export_checksums;
442 }
443
444 /**
445 * Get Last Exported Checksum Status
446 *
447 * @param string $templates templates category to fetch.
448 * @since 1.6.15
449 * @return string Checksums Status.
450 */
451 public function get_last_export_checksums( $templates = '' ) {
452 $suffix = 'store-checkout' === $templates ? 'store-checkout-' : '';
453
454 $old_last_export_checksums = get_site_option( 'cartflows-' . $suffix . 'last-export-checksums', '' );
455
456 $new_last_export_checksums = $this->set_last_export_checksums( $templates );
457
458 $checksums_status = 'no';
459
460 if ( empty( $old_last_export_checksums ) ) {
461 $checksums_status = 'yes';
462 }
463
464 if ( $new_last_export_checksums != $old_last_export_checksums ) {
465 $checksums_status = 'yes';
466 }
467
468 return apply_filters( 'cartflows_checksums_status', $checksums_status );
469 }
470
471 /**
472 * Check Cron Status
473 *
474 * Gets the current cron status by performing a test spawn. Cached for one hour when all is well.
475 *
476 * @since 1.6.15
477 *
478 * @param bool $cache Whether to use the cached result from previous calls.
479 * @return true|WP_Error Boolean true if the cron spawner is working as expected, or a WP_Error object if not.
480 */
481 public function test_cron( $cache = true ) {
482 global $wp_version;
483
484 if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
485 return new WP_Error( 'wp_portfolio_cron_error', esc_html__( 'ERROR! Cron schedules are disabled by setting constant DISABLE_WP_CRON to true.<br/>To start the import process please enable the cron by setting the constant to false. E.g. define( \'DISABLE_WP_CRON\', false );', 'cartflows' ) );
486 }
487
488 if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
489 return new WP_Error( 'wp_portfolio_cron_error', esc_html__( 'ERROR! Cron schedules are disabled by setting constant ALTERNATE_WP_CRON to true.<br/>To start the import process please enable the cron by setting the constant to false. E.g. define( \'ALTERNATE_WP_CRON\', false );', 'cartflows' ) );
490 }
491
492 $cached_status = get_transient( 'cartflows-cron-test-ok' );
493
494 if ( $cache && $cached_status ) {
495 return true;
496 }
497
498 $sslverify = version_compare( $wp_version, 4.0, '<' );
499 $doing_wp_cron = sprintf( '%.22F', microtime( true ) );
500
501 $cron_request = apply_filters(
502 'cron_request',
503 array(
504 'url' => site_url( 'wp-cron.php?doing_wp_cron=' . $doing_wp_cron ),
505 'key' => $doing_wp_cron,
506 'args' => array(
507 'timeout' => 3,
508 'blocking' => true,
509 'sslverify' => apply_filters( 'https_local_ssl_verify', $sslverify ),
510 ),
511 )
512 );
513
514 $cron_request['args']['blocking'] = true;
515
516 $result = wp_remote_post( $cron_request['url'], $cron_request['args'] );
517
518 if ( is_wp_error( $result ) ) {
519 return $result;
520 } elseif ( wp_remote_retrieve_response_code( $result ) >= 300 ) {
521 return new WP_Error(
522 'unexpected_http_response_code',
523 sprintf(
524 /* translators: 1: The HTTP response code. */
525 __( 'Unexpected HTTP response code: %s', 'cartflows' ),
526 intval( wp_remote_retrieve_response_code( $result ) )
527 )
528 );
529 } else {
530 set_transient( 'cartflows-cron-test-ok', 1, 3600 );
531 return true;
532 }
533 }
534
535 /**
536 * Get Blocks Total Requests
537 *
538 * @since 1.6.15
539 * @param string $page_builder_slug Page builder slug.
540 * @param string $templates templates category to fetch.
541 * @return integer
542 */
543 public function get_total_requests( $page_builder_slug = '', $templates = '' ) {
544 $page_builder_slug = ( ! empty( $page_builder_slug ) ) ? $page_builder_slug : wcf()->get_site_slug();
545
546 update_site_option( 'cartflows-batch-status-string', 'Getting Total Blocks', 'no' );
547
548 $api_args = array(
549 'timeout' => 60, //phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
550 );
551
552 $url = wcf()->get_site_url( $page_builder_slug ) . 'wp-json/cartflows-server/v1/get-total-flows/';
553 wcf()->logger->sync_log( $url );
554
555 $response = wp_remote_get( $url, $api_args );
556
557 /* Check one more time */
558 if ( is_wp_error( $response ) ) {
559 $response = wp_remote_get( $url, $api_args );
560 }
561
562 if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
563 $total_requests = json_decode( wp_remote_retrieve_body( $response ), true );
564
565 $suffix = 'store-checkout' === $templates ? 'store-checkout-' : '';
566
567 if ( isset( $total_requests['pages'] ) ) {
568 update_site_option( 'cartflows-batch-status-string', 'Updated requests ' . $total_requests['pages'], 'no' );
569
570 update_site_option( 'cartflows-' . $suffix . $page_builder_slug . '-requests', $total_requests['pages'], 'no' );
571
572 return $total_requests['pages'];
573 }
574 } else {
575
576 wcf()->logger->sync_log( 'Client\'s server is blocking requests. May be client\'s server firewall is blocking request. Make sure a firewall or any kind of secuirty pluging is blocking requests or not?' );
577
578 /* Fallback default data if client server is blocking requests */
579 $total_requests = array(
580 'no_of_items' => 15,
581 'pages' => 1,
582 'per_page' => 100,
583 );
584
585 update_site_option( 'cartflows-batch-status-string', 'Updated requests ' . $total_requests['pages'], 'no' );
586
587 update_site_option( 'cartflows-' . $page_builder_slug . '-requests', $total_requests['pages'], 'no' );
588
589 return $total_requests['pages'];
590 }
591 }
592
593 /**
594 * Process Batch
595 *
596 * @since 1.6.15
597 * @param string $templates templates category to fetch.
598 * @return mixed
599 */
600 public function process_batch( $templates = '' ) {
601
602 if ( 'other' === wcf()->get_site_slug() ) {
603 if ( defined( 'WP_CLI' ) ) {
604 WP_CLI::error( 'Invalid page builder! Please select the page builder to start sync process.' );
605 } else {
606 return;
607 }
608 }
609
610 if ( 'no' === $this->get_last_export_checksums( $templates ) ) {
611 if ( defined( 'WP_CLI' ) ) {
612 WP_CLI::line( 'Library is up to date!' );
613 }
614 return;
615 }
616
617 $status = $this->test_cron();
618 if ( is_wp_error( $status ) ) {
619 if ( defined( 'WP_CLI' ) ) {
620 WP_CLI::line( 'Error! Batch Not Start due to disabled cron events!' );
621 }
622 update_site_option( 'cartflows-batch-status-string', 'Error! Batch Not Start due to disabled cron events!', 'no' );
623
624 if ( defined( 'WP_CLI' ) ) {
625 WP_CLI::line( 'Error! Batch Not Start due to disabled cron events!' );
626 } else {
627 // For non- WP CLI request return to prevent the request.
628 return;
629 }
630 }
631
632 // Get count.
633 $total_requests = $this->get_total_requests();
634 if ( $total_requests ) {
635 if ( defined( 'WP_CLI' ) ) {
636 WP_CLI::line( 'Total Requests ' . $total_requests );
637 }
638
639 for ( $page = 1; $page <= $total_requests; $page++ ) {
640
641 if ( defined( 'WP_CLI' ) ) {
642 WP_CLI::line( 'Added page ' . $page . ' in queue.' );
643 }
644
645 if ( defined( 'WP_CLI' ) ) {
646 Cartflows_Batch_Processing_Sync_Library::get_instance()->import_sites( $page, $templates );
647 } else {
648 self::$process_site_importer->push_to_queue(
649 array(
650 'page' => $page,
651 'template' => $templates,
652 'instance' => Cartflows_Batch_Processing_Sync_Library::get_instance(),
653 'method' => 'import_sites',
654 )
655 );
656 }
657 }
658 }
659
660 if ( defined( 'WP_CLI' ) ) {
661 WP_CLI::line( 'Sync Process Complete.' );
662 } else {
663 // Dispatch Queue.
664 self::$process_site_importer->save()->dispatch();
665 }
666 }
667
668 /**
669 * Enable the unfiltered upload of the elementor to upload the SVG files.
670 *
671 * @since 1.10.0
672 */
673 public function enable_unfiltered_upload_elementor() {
674
675 add_filter( 'elementor/files/allow_unfiltered_upload', '__return_true' );
676 }
677
678 /**
679 * Set the flat for import process is in progress or not.
680 * This flag will be used to add a support of extra files for uploading to the website directory while importing the ready-made templates.
681 *
682 * @param bool $bool The default state is false.
683 * @return void
684 */
685 public static function set_is_wcf_template_import( $bool = false ) {
686 if ( $bool ) {
687 set_transient( 'cartflows_is_wcf_template_import', $bool, HOUR_IN_SECONDS );
688 } else {
689 delete_transient( 'cartflows_is_wcf_template_import' ); // Delete the option if $bool is false.
690 }
691 }
692 }
693
694 /**
695 * Kicking this off by calling 'get_instance()' method
696 */
697 CartFlows_Batch_Process::get_instance();
698
699 endif;
700