cleanup, prepare localization, show tokens

This commit is contained in:
Pau Capó 2017-03-15 02:20:56 +01:00
parent 4bd2231777
commit 2a47c356ee
2 changed files with 53 additions and 60 deletions

View file

@ -38,7 +38,6 @@ class Gitea_Updater {
public $themes = array();
public $remote_managemnet = true;
function __construct() {
Gitea_Options::getInstance();
@ -50,9 +49,6 @@ class Gitea_Updater {
// themes checks
add_filter('pre_set_site_transient_update_themes', array($this, 'pre_set_site_transient_update_themes'));
// rename directories
// add_filter('upgrader_source_selection', array($this, 'upgrader_source_selection'), 10, 4);
// extra plugins and themes headers (Gitea Host and Gitea URI)
add_filter('extra_plugin_headers', array($this, 'extra_headers'));
add_filter('extra_theme_headers', array($this, 'extra_headers'));
@ -182,10 +178,10 @@ class Gitea_Updater {
function get_gitea_url($host, $repo, $args = '', $access_token = false) {
if ($access_token === false)
if ($access_token === false) {
$access_token = $this->get_gitea_token($host, $repo);
if (!$access_token) return false;
if (!$access_token) return false;
}
return $host.'api/v1/repos/'.$repo.$args.'?access_token='.$access_token;
}
@ -238,7 +234,7 @@ class Gitea_Updater {
}
function pre_set_site_transient_update_plugins($transient) {
// check if some plugin needs update using the cached data
// check if some plugin needs update
$this->get_gitea_plugins();
@ -247,14 +243,6 @@ class Gitea_Updater {
if (isset($transient->response[$git_plugin['plugin']]))
unset($transient->response[$git_plugin['plugin']]);
if (version_compare($git_plugin['local_version'], $git_plugin['new_version'], '<')) {
// $object = new stdClass;
// $object->slug = $git_plugin['slug'];
// $object->plugin = $git_plugin['plugin'];
// $object->new_version = $git_plugin['new_version'];
// $object->url = $git_plugin['url'];
// $object->package = $git_plugin['package'];
$transient->response[$git_plugin['plugin']] = (object)$git_plugin;
}
@ -281,19 +269,6 @@ class Gitea_Updater {
return $transient;
}
function upgrader_source_selection($source, $remote_source, $upgrader, $hook_extra = null) {
global $wp_filesystem;
$plugin = isset($hook_extra['plugin']) ? $hook_extra['plugin'] : false;
if (isset($this->plugins[$plugin]) && $plugin) {
$new_source = trailingslashit($remote_source).dirname($plugin);
$wp_filesystem->move($source, $new_source);
return trailingslashit($new_source);
}
return $source;
}
function get_file_headers($contents, $type) {
$gitea_headers = array(