| @@ -1,19 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -// 0 - none. | |
| 3 | + | |
| 4 | + | |
| 5 | +// 0 - none | |
| 4 | 6 | define( 'GEDEBUG_NONE', 0 ); |
| 5 | 7 | |
| 6 | -// 1 - call logging only. | |
| 8 | +// 1 - call logging only | |
| 7 | 9 | define( 'GEDEBUG_CALL', 1 ); |
| 8 | 10 | |
| 9 | -// 2 - calls, and responses. | |
| 11 | +// 2 - calls, and responses | |
| 10 | 12 | define( 'GEDEBUG_RESP', 2 ); |
| 11 | 13 | |
| 12 | -// Selected debug level. | |
| 13 | -if ( ! defined( 'GITHUB_API_LEVEL' ) ) { | |
| 14 | - define( 'GITHUB_API_LEVEL', GEDEBUG_NONE ); | |
| 15 | -} | |
| 14 | +// Selected debug level | |
| 15 | +define( 'GITHUB_API_LEVEL', GEDEBUG_NONE ); | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * This class contains all the functions that actually retrieve information from the GitHub API |
| @@ -54,10 +54,12 @@ | ||
| 54 | 54 | * with GitHub(http://developer.github.com/v3/oauth/) use the filters here to |
| 55 | 55 | * provide the credentials. |
| 56 | 56 | */ |
| 57 | 57 | public function set_credentials() { |
| 58 | + | |
| 58 | 59 | $this->client_id = apply_filters( 'github-embed-client-id', $this->client_id ); |
| 59 | 60 | $this->client_secret = apply_filters( 'github-embed-client-secret', $this->client_secret ); |
| 61 | + | |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | 64 | |
| 63 | 65 | |
| @@ -103,8 +105,11 @@ | ||
| 103 | 105 | public function get_repo( $owner, $repository ) { |
| 104 | 106 | |
| 105 | 107 | $this->log( "get_repo( $owner, $repository )", GEDEBUG_CALL ); |
| 106 | 108 | |
| 109 | + $owner = trim( $owner, '/' ); | |
| 110 | + $repository = trim( $repository, '/' ); | |
| 111 | + | |
| 107 | 112 | $results = $this->call_api( "https://api.github.com/repos/$owner/$repository" ); |
| 108 | 113 | |
| 109 | 114 | return json_decode( $results['body'] ); |
| 110 | 115 | |
| @@ -121,8 +126,11 @@ | ||
| 121 | 126 | public function get_repo_commits( $owner, $repository ) { |
| 122 | 127 | |
| 123 | 128 | $this->log( "get_repo_commits( $owner, $repository )", GEDEBUG_CALL ); |
| 124 | 129 | |
| 130 | + $owner = trim( $owner, '/' ); | |
| 131 | + $repository = trim( $repository, '/' ); | |
| 132 | + | |
| 125 | 133 | $results = $this->call_api( "https://api.github.com/repos/$owner/$repository/commits" ); |
| 126 | 134 | |
| 127 | 135 | return json_decode( $results['body'] ); |
| 128 | 136 | |
| @@ -140,8 +148,11 @@ | ||
| 140 | 148 | public function get_repo_milestone_summary( $owner, $repository, $milestone ) { |
| 141 | 149 | |
| 142 | 150 | $this->log( "get_repo_milestone_summary( $owner, $repository, $milestone )", GEDEBUG_CALL ); |
| 143 | 151 | |
| 152 | + $owner = trim( $owner, '/' ); | |
| 153 | + $repo = trim( $repository, '/' ); | |
| 154 | + | |
| 144 | 155 | $results = $this->call_api( "https://api.github.com/repos/$owner/$repository/milestones/$milestone" ); |
| 145 | 156 | |
| 146 | 157 | return json_decode( $results['body'] ); |
| 147 | 158 | |
| @@ -152,8 +163,11 @@ | ||
| 152 | 163 | public function get_repo_contributors( $owner, $repository ) { |
| 153 | 164 | |
| 154 | 165 | $this->log( "get_repo_contributors( $owner, $repository )", GEDEBUG_CALL ); |
| 155 | 166 | |
| 167 | + $owner = trim( $owner, '/' ); | |
| 168 | + $repo = trim( $repository, '/' ); | |
| 169 | + | |
| 156 | 170 | $results = $this->call_api( "https://api.github.com/repos/$owner/$repository/stats/contributors" ); |
| 157 | 171 | |
| 158 | 172 | return json_decode( $results['body'] ); |
| 159 | 173 | |
| @@ -168,8 +182,10 @@ | ||
| 168 | 182 | */ |
| 169 | 183 | public function get_user( $user ) { |
| 170 | 184 | |
| 171 | 185 | $this->log( "get_user( $user )", GEDEBUG_CALL ); |
| 186 | + | |
| 187 | + $user = trim( $user, '/' ); | |
| 172 | 188 | |
| 173 | 189 | $results = $this->call_api( "https://api.github.com/users/$user" ); |
| 174 | 190 | |
| 175 | 191 | return json_decode( $results['body'] ); |