actions.php ➔ give_trigger_donation_receipt()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.1406

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 1
dl 0
loc 9
ccs 3
cts 4
cp 0.75
crap 3.1406
rs 9.9666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Email Actions.
4
 *
5
 * @package     Give
6
 * @subpackage  Emails
7
 * @copyright   Copyright (c) 2016, WordImpress
8
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
9
 * @since       1.0
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Triggers a donation receipt to be sent after the payment status is updated.
19
 *
20
 * @since 1.0
21
 *
22
 * @param int $payment_id Payment ID
23
 *
24
 * @return void
25
 */
26
function give_trigger_donation_receipt( $payment_id ) {
27
	// Make sure we don't send a receipt while editing a donation.
28 42
	if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) {
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
29
		return;
30
	}
31
32
	// Send email.
33 42
	give_email_donation_receipt( $payment_id );
34 42
}
35
36
add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999, 1 );