Test Failed
Pull Request — master (#2668)
by Devin
07:48
created

Give_Async_Process::handle()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 21
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 2
nop 0
dl 0
loc 21
rs 9.0534
c 0
b 0
f 0
1
<?php
2
/**
3
 * Background Process
4
 *
5
 * Uses https://github.com/A5hleyRich/wp-background-processing to handle DB
6
 * updates in the background.
7
 *
8
 * @class    Give_Async_Request
9
 * @version  2.0.0
10
 * @package  Give/Classes
11
 * @category Class
12
 * @author   WordImpress
13
 */
14
if ( ! defined( 'ABSPATH' ) ) {
15
	exit;
16
}
17
18
/**
19
 * Give_Background_Updater Class.
20
 */
21
class Give_Async_Process extends WP_Async_Request {
22
	/**
23
	 * Prefix
24
	 *
25
	 *
26
	 * @var string
27
	 * @access protected
28
	 */
29
	protected $prefix = 'give';
30
31
	/**
32
	 * Dispatch updater.
33
	 *
34
	 * Updater will still run via cron job if this fails for any reason.
35
	 */
36
	public function dispatch() {
37
		/* @var WP_Async_Request $dispatched */
38
		parent::dispatch();
39
	}
40
41
	/**
42
	 * Handle
43
	 *
44
	 * Override this method to perform any actions required
45
	 * during the async request.
46
	 */
47
	protected function handle() {
48
		/*
49
		 * $data = array(
50
		 *  'hook'     => '', // required
51
		 *  'data' => {mixed} // required
52
		 * )
53
		 */
54
55
		$_post = give_clean( $_POST );
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
56
57
		if ( empty( $_post ) || empty( $_post['data'] ) || empty( $_post['hook'] ) ) {
58
			exit();
59
		}
60
61
		/**
62
		 * Fire the hook.
63
		 */
64
		do_action( $_post['hook'], $_post['data'] );
65
66
		exit();
67
	}
68
}
69