| 1 |
<?php |
| 2 |
/** |
| 3 |
* Batch processing |
| 4 |
* |
| 5 |
* @package WPFunnels\Batch\Elementor |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WPFunnels\Batch\Elementor; |
| 9 |
|
| 10 |
use WPFunnels\Batch\Divi\Wpfnl_Divi_Source; |
| 11 |
use WPFunnels\Batch\Gutenberg\Wpfnl_Gutenberg_Batch; |
| 12 |
use WPFunnels\Batch\Gutenberg\Wpfnl_Gutenberg_Source; |
| 13 |
use WPFunnels\Batch\Wpfnl_Divi_Batch; |
| 14 |
use WPFunnels\Batch\Wpfnl_Divi5_Batch; |
| 15 |
use WPFunnels\Batch\Wpfnl_Elementor_Batch; |
| 16 |
use WPFunnels\Batch\Wpfnl_Bricks_Batch; |
| 17 |
use WPFunnels\Traits\SingletonTrait; |
| 18 |
use WPFunnels\Wpfnl_functions; |
| 19 |
/** |
| 20 |
* Batch processing |
| 21 |
* |
| 22 |
* @since 1.0.1 |
| 23 |
*/ |
| 24 |
class Wpfnl_Batch { |
| 25 |
|
| 26 |
use SingletonTrait; |
| 27 |
|
| 28 |
/** |
| 29 |
* Elementor batch instance |
| 30 |
* |
| 31 |
* @var Wpfnl_Elementor_Batch |
| 32 |
*/ |
| 33 |
protected $elementor_batch; |
| 34 |
|
| 35 |
/** |
| 36 |
* Elementor source object |
| 37 |
* |
| 38 |
* @var Wpfnl_Elementor_Source |
| 39 |
*/ |
| 40 |
protected $elementor_source; |
| 41 |
|
| 42 |
/** |
| 43 |
* Gutenberg batch instance |
| 44 |
* |
| 45 |
* @var Wpfnl_Gutenberg_Batch |
| 46 |
*/ |
| 47 |
protected $gutenberg_batch; |
| 48 |
|
| 49 |
/** |
| 50 |
* Gutenberg source object |
| 51 |
* |
| 52 |
* @var Wpfnl_Gutenberg_Source |
| 53 |
*/ |
| 54 |
protected $gutenberg_source; |
| 55 |
|
| 56 |
/** |
| 57 |
* Divi batch instance |
| 58 |
* |
| 59 |
* @var Wpfnl_Divi_Batch |
| 60 |
*/ |
| 61 |
protected $divi_batch; |
| 62 |
|
| 63 |
/** |
| 64 |
* Bricks batch instance |
| 65 |
* |
| 66 |
* @var Wpfnl_Bricks_Batch |
| 67 |
*/ |
| 68 |
protected $bricks_batch; |
| 69 |
|
| 70 |
/** |
| 71 |
* Divi source object |
| 72 |
* |
| 73 |
* @var Wpfnl_Divi_Source |
| 74 |
*/ |
| 75 |
protected $divi_source; |
| 76 |
|
| 77 |
/** |
| 78 |
* Bricks source object |
| 79 |
* |
| 80 |
* @var Wpfnl_Bricks_Source |
| 81 |
*/ |
| 82 |
protected $bricks_source; |
| 83 |
|
| 84 |
|
| 85 |
/** |
| 86 |
* Oxygen source object |
| 87 |
* |
| 88 |
* @var Oxygen source |
| 89 |
*/ |
| 90 |
protected $oxygen_source; |
| 91 |
|
| 92 |
/** |
| 93 |
* Class constructor. |
| 94 |
* |
| 95 |
* Initializes the appropriate batch object based on the page builder type. |
| 96 |
* Sets up the 'wpfunnels_after_step_import' action hook for processing. |
| 97 |
* |
| 98 |
* @since 1.0.0 |
| 99 |
*/ |
| 100 |
public function __construct() { |
| 101 |
$page_builder = Wpfnl_functions::get_builder_type(); |
| 102 |
|
| 103 |
if ( 'elementor' === $page_builder ) { |
| 104 |
$this->elementor_batch = new Wpfnl_Elementor_Batch(); |
| 105 |
} |
| 106 |
|
| 107 |
if ( 'gutenberg' === $page_builder ) { |
| 108 |
$this->gutenberg_batch = new Wpfnl_Gutenberg_Batch(); |
| 109 |
} |
| 110 |
|
| 111 |
if ( 'divi-builder' === $page_builder ) { |
| 112 |
$this->divi_batch = Wpfnl_functions::is_divi5_active() |
| 113 |
? new Wpfnl_Divi5_Batch() |
| 114 |
: new Wpfnl_Divi_Batch(); |
| 115 |
} |
| 116 |
|
| 117 |
if ( 'bricks' === $page_builder ) { |
| 118 |
$this->bricks_batch = new Wpfnl_Bricks_Batch(); |
| 119 |
} |
| 120 |
|
| 121 |
add_action( 'wpfunnels_after_step_import', array( $this, 'start_processing' ), 10, 2 ); |
| 122 |
} |
| 123 |
|
| 124 |
/** |
| 125 |
* Start the batch import process |
| 126 |
* |
| 127 |
* @param int $step_id funnel step id. |
| 128 |
* @param string $builder active page builder. |
| 129 |
* |
| 130 |
* @since 1.0.0 |
| 131 |
*/ |
| 132 |
public function start_processing( $step_id = 0, $builder = 'elementor' ) { |
| 133 |
if ( $step_id && !Wpfnl_functions::maybe_duplicate_step( $step_id ) ) { |
| 134 |
if ( 'elementor' === $builder && class_exists( '\Elementor\Plugin' ) ) { |
| 135 |
$this->elementor_batch->push_to_queue( $step_id ); |
| 136 |
$this->elementor_batch->save()->dispatch(); |
| 137 |
} |
| 138 |
|
| 139 |
if ( 'gutenberg' === $builder ) { |
| 140 |
$this->gutenberg_batch->push_to_queue( $step_id ); |
| 141 |
$this->gutenberg_batch->save()->dispatch(); |
| 142 |
} |
| 143 |
|
| 144 |
if ( 'divi-builder' === $builder ) { |
| 145 |
$this->divi_batch->push_to_queue( $step_id ); |
| 146 |
$this->divi_batch->save()->dispatch(); |
| 147 |
} |
| 148 |
|
| 149 |
if ( 'bricks' === $builder ) { |
| 150 |
$this->bricks_batch->push_to_queue( $step_id ); |
| 151 |
$this->bricks_batch->save()->dispatch(); |
| 152 |
} |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
|