cartflows
/
classes
/
importer
/
batch-process
/
helpers
/
class-wp-background-process-cartflows-sync-library.php
class-wp-background-process-cartflows-sync-library.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.3.0, at classes/importer/batch-process/helpers/class-wp-background-process-cartflows-sync-library.php
| 1 | <?php |
| 2 | /** |
| 3 | * Single Page Background Process |
| 4 | * |
| 5 | * @package Cartflows |
| 6 | * @since 1.6.15 |
| 7 | */ |
| 8 | |
| 9 | // Exit if accessed directly. |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; |
| 12 | } |
| 13 | if ( ! class_exists( 'WP_Background_Process_Cartflows_Sync_Library' ) && class_exists( 'WP_Background_Process' ) ) : |
| 14 | |
| 15 | /** |
| 16 | * Image Background Process |
| 17 | * |
| 18 | * @since 1.6.15 |
| 19 | */ |
| 20 | class WP_Background_Process_Cartflows_Sync_Library extends WP_Background_Process { |
| 21 | |
| 22 | /** |
| 23 | * Image Process |
| 24 | * |
| 25 | * @var string |
| 26 | */ |
| 27 | protected $action = 'cartflows_sync_library'; |
| 28 | |
| 29 | /** |
| 30 | * Task |
| 31 | * |
| 32 | * Override this method to perform any actions required on each |
| 33 | * queue item. Return the modified item for further processing |
| 34 | * in the next pass through. Or, return false to remove the |
| 35 | * item from the queue. |
| 36 | * |
| 37 | * @since 1.6.15 |
| 38 | * |
| 39 | * @param object $object Queue item object. |
| 40 | * @return mixed |
| 41 | */ |
| 42 | protected function task( $object ) { |
| 43 | |
| 44 | // Resolve the instance here instead of reading it from the queue item, as the |
| 45 | // queue is sent as the async request body and must stay free of objects. |
| 46 | /** @var Cartflows_Batch_Processing_Sync_Library $process */ |
| 47 | $process = Cartflows_Batch_Processing_Sync_Library::get_instance(); |
| 48 | $method = isset( $object['method'] ) ? $object['method'] : ''; |
| 49 | |
| 50 | if ( 'import_sites' === $method ) { |
| 51 | wcf()->logger->sync_log( '-------- Importing Sites --------' ); |
| 52 | $page = $object['page']; |
| 53 | wcf()->logger->sync_log( 'Inside Batch ' . $page ); |
| 54 | update_site_option( 'cartflows-batch-status-string', 'Inside Batch ' . $page, 'no' ); |
| 55 | $process->import_sites( $page ); |
| 56 | } |
| 57 | |
| 58 | return false; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Complete |
| 63 | * |
| 64 | * Override if applicable, but ensure that the below actions are |
| 65 | * performed, or, call parent::complete(). |
| 66 | * |
| 67 | * @since 1.6.15 |
| 68 | */ |
| 69 | protected function complete() { |
| 70 | parent::complete(); |
| 71 | |
| 72 | wcf()->logger->sync_log( esc_html__( 'All processes are complete', 'cartflows' ) ); |
| 73 | update_site_option( 'cartflows-batch-status-string', 'All processes are complete', 'no' ); |
| 74 | delete_site_option( 'cartflows-batch-status' ); |
| 75 | update_site_option( 'cartflows-batch-is-complete', 'yes', 'no' ); |
| 76 | |
| 77 | do_action( 'cartflows_site_import_batch_complete' ); |
| 78 | } |
| 79 | |
| 80 | } |
| 81 | |
| 82 | endif; |
| 83 |