Completed
Push — master ( 42ba23...5fbbab )
by Julien
03:55
created

functions-aweber.php ➔ wpbo_is_aweber_ready()   C

Complexity

Conditions 8
Paths 17

Size

Total Lines 30
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 15
c 1
b 0
f 0
nc 17
nop 0
dl 0
loc 30
rs 5.3846
1
<?php
2
/**
3
 * BetterOptin Provider Aweber
4
 *
5
 * @package   BetterOptin/Provider/Aweber
6
 * @author    ThemeAvenue <[email protected]>
7
 * @license   GPL-2.0+
8
 * @link      http://themeavenue.net
9
 * @copyright 2015 ThemeAvenue
10
 */
11
12
// If this file is called directly, abort.
13
if ( ! defined( 'WPINC' ) ) {
14
	die;
15
}
16
17
/**
18
 * Get Aweber lists
19
 *
20
 * Helper function to get Aweber subscribers lists
21
 *
22
 * @since 2.0
23
 * @return array
24
 */
25
function wpbo_aw_get_lists() {
26
27
	$aweber = new WPBO_Aweber();
28
29
	if ( $aweber->is_error() ) {
30
		return array();
31
	}
32
33
	return $aweber->get_lists();
34
35
}
36
37
/**
38
 * Check if Aweber settings are correct.
39
 *
40
 * @since  1.0.0
41
 * @return boolean True if Aweber integration is ready to work
42
 */
43
function wpbo_is_aweber_ready() {
44
45
	$tokens = maybe_unserialize( get_option( 'wpbo_aweber_tokens' ) );
46
47
	if ( ! is_array( $tokens ) ) {
48
		return false;
49
	}
50
51
	$access_token  = isset( $tokens[0] ) ? trim( $tokens[0] ) : '';
52
	$access_secret = isset( $tokens[1] ) ? trim( $tokens[1] ) : '';
53
54
	if ( empty( $access_token ) || empty( $access_secret ) ) {
55
		return false;
56
	}
57
58
	$auth_code = trim( wpbo_get_option( 'aw_auth_code', '' ) );
59
60
	if ( empty( $auth_code ) ) {
61
		return false;
62
	}
63
64
	$list_id = wpbo_get_option( 'aw_list_id', '' );
65
66
	if ( empty( $list_id ) ) {
67
		return false;
68
	}
69
70
	return true;
71
72
}