Skip to content

Commit 6ce0c0c

Browse files
committed
plugin update from github on process
1 parent 49968f5 commit 6ce0c0c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

includes/PDUpdater.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function initialize()
9292
add_filter('pre_set_site_transient_update_plugins', [$this, 'modify_transient'], 10, 1);
9393
add_filter('plugins_api', [$this, 'plugin_popup'], 10, 3);
9494
add_filter('upgrader_post_install', [$this, 'after_install'], 10, 3);
95+
add_filter("http_request_args", [$this, "addHeaders"], 10, 3);
9596
}
9697

9798
public function modify_transient($transient)
@@ -174,4 +175,17 @@ public function after_install($response, $hook_extra, $result)
174175

175176
return $result;
176177
}
178+
179+
public function addHeaders($parsed_args, $url)
180+
{
181+
if (empty($parsed_args['headers'])) {
182+
$parsed_args['headers'] = [];
183+
}
184+
185+
if (strpos($url, "https://api.github.com/repos/{$this->username}/{$this->repository}") !== FALSE) {
186+
$parsed_args['headers']['Authorization'] = "token $this->authorize_token";
187+
188+
}
189+
return $parsed_args;
190+
}
177191
}

0 commit comments

Comments
 (0)