PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 1.1.1
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v1.1.1
3.3.0 3.2.1 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 All 162 releases
cartflows / classes / batch-process / class-cartflows-batch-process.php

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

157 lines 4.1 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 if ( ! class_exists( 'CartFlows_Batch_Process' ) ) :
10
11 /**
12 * CartFlows_Batch_Process
13 *
14 * @since 1.0.0
15 */
16 class CartFlows_Batch_Process {
17
18 /**
19 * Instance
20 *
21 * @since 1.0.0
22 * @var object Class object.
23 * @access private
24 */
25 private static $instance;
26
27 /**
28 * Elementor Batch Instance
29 *
30 * @since 1.1.1 Updated instance name with elementor specific.
31 *
32 * @since 1.0.0
33 * @var object Class object.
34 * @access public
35 */
36 public static $batch_instance_elementor;
37
38 /**
39 * Beaver Builder Batch Instance
40 *
41 * @since 1.1.1
42 * @var object Class object.
43 * @access public
44 */
45 public static $batch_instance_bb;
46
47 /**
48 * Initiator
49 *
50 * @since 1.0.0
51 * @return object initialized object of class.
52 */
53 public static function get_instance() {
54 if ( ! isset( self::$instance ) ) {
55 self::$instance = new self;
56 }
57 return self::$instance;
58 }
59
60 /**
61 * Constructor
62 *
63 * @since 1.0.0
64 */
65 public function __construct() {
66
67 // Not BB or Elementor then avoid importer.
68 if ( ! class_exists( '\Elementor\Plugin' ) && ! class_exists( 'FLBuilder' ) ) {
69 return;
70 }
71
72 // Core Helpers - Image.
73 require_once ABSPATH . 'wp-admin/includes/image.php';
74
75 // Core Helpers - Batch Processing.
76 require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-cartflows-importer-image.php';
77 require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-async-request.php';
78 require_once CARTFLOWS_DIR . 'classes/batch-process/helpers/class-wp-background-process.php';
79
80 // Elementor.
81 if ( class_exists( '\Elementor\Plugin' ) ) {
82 // Add "elementor" in import [queue].
83 // @todo Remove required `allow_url_fopen` support.
84 if ( ini_get( 'allow_url_fopen' ) ) {
85 require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php';
86 require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor-batch.php';
87 self::$batch_instance_elementor = new Cartflows_Importer_Elementor_Batch();
88 }
89 }
90
91 // Beaver Builder.
92 if ( class_exists( 'FLBuilder' ) ) {
93 require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder.php';
94 require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-beaver-builder-batch.php';
95 self::$batch_instance_bb = new Cartflows_Importer_Beaver_Builder_Batch();
96 }
97
98 // Start image importing after site import complete.
99 add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) );
100 add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) );
101 }
102
103 /**
104 * Batch Process Complete.
105 *
106 * @return void
107 */
108 public function complete_batch_import() {
109 wcf()->logger->import_log( '(✓) BATCH Process Complete!' );
110 }
111
112 /**
113 * Start Image Import
114 *
115 * @param integer $post_id Post Id.
116 *
117 * @return void
118 */
119 public function start_batch_process( $post_id = '' ) {
120
121 wcf()->logger->import_log( '(✓) BATCH Started!' );
122 wcf()->logger->import_log( '(✓) Step ID ' . $post_id );
123
124 // Add "elementor" in import [queue].
125 if ( self::$batch_instance_bb ) {
126
127 // Add to queue.
128 self::$batch_instance_bb->push_to_queue( $post_id );
129
130 // Dispatch Queue.
131 self::$batch_instance_bb->save()->dispatch();
132
133 wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' );
134
135 } elseif ( self::$batch_instance_elementor ) {
136
137 // Add to queue.
138 self::$batch_instance_elementor->push_to_queue( $post_id );
139
140 // Dispatch Queue.
141 self::$batch_instance_elementor->save()->dispatch();
142
143 wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' );
144 } else {
145 wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' );
146 }
147 }
148
149 }
150
151 /**
152 * Kicking this off by calling 'get_instance()' method
153 */
154 CartFlows_Batch_Process::get_instance();
155
156 endif;
157