GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 9cd7e5...74e7fc )
by Chris
16:50
created

PPP_Bitly::ppp_load_bitly()   B

Complexity

Conditions 6
Paths 8

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
nc 8
nop 0
dl 0
loc 24
rs 8.9137
c 0
b 0
f 0
ccs 0
cts 16
cp 0
crap 42
1
<?php
2
3
// Exit if accessed directly
4
if ( !defined( 'ABSPATH' ) ) {
5
	exit;
6
}
7
8
/**
9
 * Bitly Class
10
 *
11
 * Handles all bitly functions
12
 *
13
 */
14
if( !class_exists( 'PPP_Bitly' ) ) {
15
16
	class PPP_Bitly {
17
18
		var $bitly;
19
20
		public function __construct(){
21
			ppp_maybe_start_session();
22
		}
23
24
		/**
25
		 * Include Twitter Class
26
		 *
27
		 * Handles to load twitter class
28
		 */
29
		public function ppp_load_bitly() {
30
				if( !class_exists( 'Bitly' ) ) {
31
					require_once ( PPP_PATH . '/includes/libs/bitly/bitly.php' );
32
				}
33
34
				ppp_set_social_tokens();
35
36
				if ( ! defined( 'bitly_clientid' ) || ! defined( 'bitly_secret' ) ) {
37
					return false;
38
				}
39
40
				global $ppp_social_settings;
41
42
				if ( isset( $ppp_social_settings['bitly'] ) ) {
43
					if ( !defined( 'bitly_accesstoken' ) ) {
44
						define( 'bitly_accesstoken', $ppp_social_settings['bitly']['access_token'] );
45
					}
46
					$this->bitly = new Bitly( bitly_clientid, bitly_secret, bitly_accesstoken );
47
				} else {
48
					$this->bitly = new Bitly( bitly_clientid, bitly_secret );
49
				}
50
51
				return true;
52
		}
53
54
		public function revoke_access() {
55
			global $ppp_social_settings;
56
57
			unset( $ppp_social_settings['bitly'] );
58
59
			update_option( 'ppp_social_settings', $ppp_social_settings );
60
		}
61
62
		/**
63
		 * Get auth codes for Bitly
64
		 *
65
		 */
66
		public function ppp_get_bitly_auth_url () {
67
			//load bitly class
68
			$bitly = $this->ppp_load_bitly();
69
70
			//check bitly class is loaded or not
71
			if( !$bitly ) {
72
				return false;
73
			}
74
75
			$url = $this->bitly->getAuthUrl(  );
76
			return $url;
77
		}
78
79
		public function ppp_make_bitly_link( $link = null ) {
80
			if ( empty( $link ) ) {
81
				return false;
82
			}
83
84
			$bitly = $this->ppp_load_bitly();
85
86
			if ( !$bitly ) {
87
				return false;
88
			}
89
90
			return $this->bitly->shorten( $link );
91
		}
92
93
		public function ppp_bitly_user_info() {
94
			$bitly = $this->ppp_load_bitly();
95
96
			if ( !$bitly ) {
97
				return false;
98
			}
99
100
			return $this->bitly->userInfo( null, null, false );
101
		}
102
103
	}
104
105
}
106