# cartflows/1.0.4/classes/batch-process/class-cartflows-batch-process.php

CartFlows – Funnel Builder &amp; Checkout Plugin for WooCommerce, version 1.0.4. 126 lines.

- Page: https://pluginprobe.com/plugins/cartflows/1.0.4/code/classes/batch-process/class-cartflows-batch-process.php
- Raw: https://pluginprobe.com/plugins/cartflows/1.0.4/raw/classes/batch-process/class-cartflows-batch-process.php
- Modified: 2018-11-30T13:26:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/cartflows/1.0.4/code/classes/batch-process/class-cartflows-batch-process.php#L10-L20`.

```php
<?php
/**
 * Batch Processing
 *
 * @package CartFlows
 * @since 1.0.0
 */

if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :

	/**
	 * CartFlows_Batch_Process
	 *
	 * @since 1.0.0
	 */
	class CartFlows_Batch_Process {

		/**
		 * Instance
		 *
		 * @since 1.0.0
		 * @var object Class object.
		 * @access private
		 */
		private static $instance;

		/**
		 * Process All
		 *
		 * @since 1.0.0
		 * @var object Class object.
		 * @access public
		 */
		public static $process_all;

		/**
		 * Initiator
		 *
		 * @since 1.0.0
		 * @return object initialized object of class.
		 */
		public static function get_instance() {
			if ( ! isset( self::$instance ) ) {
				self::$instance = new self;
			}
			return self::$instance;
		}

		/**
		 * Constructor
		 *
		 * @since 1.0.0
		 */
		public function __construct() {

			// If plugin - 'Elementor' not exist then return.
			if ( class_exists( '\Elementor\Plugin' ) ) {

				// Core Helpers - Image.
				// @todo 	This file is required for Elementor.
				// Once we implement our logic for updating elementor data then we'll delete this file.
				require_once ABSPATH . 'wp-admin/includes/image.php';

				// Core Helpers - Batch Processing.
				require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
				require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';

				// Page Builder.
				require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process-elementor.php';
				require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';

				self::$process_all = new CartFlows_Batch_Process_Elementor();

				// Start image importing after site import complete.
				add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
				add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
			}
		}

		/**
		 * Batch Process Complete.
		 *
		 * @return void
		 */
		public function complete_batch_import() {
			wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
		}

		/**
		 * Start Image Import
		 *
		 * @param integer $post_id Post Id.
		 *
		 * @return void
		 */
		public function start_batch_process( $post_id = '' ) {

			wcf()->logger->import_log( '(✓) BATCH Started!' );
			wcf()->logger->import_log( '(✓) Step ID ' . $post_id );

			// Add "elementor" in import [queue].
			// @todo Remove required `allow_url_fopen` support.
			if ( ini_get( 'allow_url_fopen' ) ) {
				if ( is_plugin_active( 'elementor/elementor.php' ) ) {

					self::$process_all->push_to_queue( $post_id );

					// Dispatch Queue.
					self::$process_all->save()->dispatch();

					wcf()->logger->import_log( '(✓) Dispatch Request..' );
				}
			} else {
				wcf()->logger->import_log( '(✕) Couldn\'t not import image due to allow_url_fopen() is disabled!' );
			}
		}

	}

	/**
	 * Kicking this off by calling 'get_instance()' method
	 */
	CartFlows_Batch_Process::get_instance();

endif;

```
