class-aw-bg-sync.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
class AW_Background_Sync extends aw_WP_Background_Process {
/**
* @var string
*/
protected $action = 'aw_sync_order_to_ac';
/**
* Really long running process
*
* @return int
*/
public function really_long_running_task() {
return sleep( 5 );
}
/**
* Check if the Queue is empty or not
*
* @return int
*/
public function is_empty() {
return $this->is_queue_empty();
}
/**
* Cancel sync
*
* @return int
*/
public function cancel_sync() {
$batch = $this->get_batch();
$batch = $this->delete($batch->key);
wp_clear_scheduled_hook($this->cron_hook_identifier);
}
/**
* Task
*
* Override this method to perform any actions required on each
* queue item. Return the modified item for further processing
* in the next pass through. Or, return false to remove the
* item from the queue.
*
* @param mixed $item Queue item to iterate over
*
* @return mixed
*/
protected function task( $order_id ) {
$this->really_long_running_task();
aw_add_ac_contact( $order_id );
return false;
}
/**
* Complete
*
* Override if applicable, but ensure that the below actions are
* performed, or, call parent::complete().
*/
protected function complete() {
parent::complete();
}
}