| 1 |
<?php |
| 2 |
/** |
| 3 |
* Divi 5 background import batch processor. |
| 4 |
* |
| 5 |
* Mirrors Wpfnl_Divi_Batch but uses the Divi 5 source class which handles |
| 6 |
* JSON block content format instead of shortcode strings. |
| 7 |
* |
| 8 |
* @package WPFunnels\Batch |
| 9 |
* @since 2.9.1 |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace WPFunnels\Batch; |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
die( 'Direct access forbidden.' ); |
| 16 |
} |
| 17 |
|
| 18 |
use WPFunnels\Batch\DiviV5\Wpfnl_Divi5_Source; |
| 19 |
|
| 20 |
class Wpfnl_Divi5_Batch extends Wpfnl_Background_Task { |
| 21 |
|
| 22 |
/** @var string Unique action key for the background queue. */ |
| 23 |
protected $action = 'wpfunnels_divi5_import_process'; |
| 24 |
|
| 25 |
/** |
| 26 |
* Process a single import item. |
| 27 |
* |
| 28 |
* @param array{post_id: int, content: string|array} $item |
| 29 |
* @return false Always return false to remove item from queue. |
| 30 |
*/ |
| 31 |
protected function task( $item ) { |
| 32 |
$source = new Wpfnl_Divi5_Source(); |
| 33 |
$source->import_single_template( |
| 34 |
(int) ( $item['post_id'] ?? 0 ), |
| 35 |
$item['content'] ?? '' |
| 36 |
); |
| 37 |
return false; |
| 38 |
} |
| 39 |
|
| 40 |
/** @inheritDoc */ |
| 41 |
protected function complete() { |
| 42 |
parent::complete(); |
| 43 |
do_action( 'wpfunnels/wpfnl_import_complete' ); |
| 44 |
} |
| 45 |
} |
| 46 |
|