Test Failed
Push — issues/370 ( 51cc5e...d56982 )
by Ravinder
05:20
created

backward-compatibility.php ➔ __give_v20_bc_user_address()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 3
nop 4
dl 0
loc 14
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * Get donor address from donor meta instead of user meta
4
 *
5
 * @since 2.0
6
 *
7
 * @param $meta_value
8
 * @param $user_id
9
 * @param $meta_key
10
 * @param $single
11
 *
12
 * @return string|array
13
 */
14
function __give_v20_bc_user_address( $meta_value, $user_id, $meta_key, $single ) {
15
	if (
16
		give_has_upgrade_completed( 'v20_upgrades_user_address' ) &&
17
		'_give_user_address' === $meta_key
18
	) {
19
		$meta_value = give_get_donor_address( $user_id );
20
21
		if ( $single ) {
22
			$meta_value = array( $meta_value );
23
		}
24
	}
25
26
	return $meta_value;
27
}
28
29
add_filter( 'get_user_metadata', '__give_v20_bc_user_address', 10, 4 );