From 2a47c356eef1822fb9efbf21bb4629400e55e459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Cap=C3=B3?= Date: Wed, 15 Mar 2017 02:20:56 +0100 Subject: [PATCH] cleanup, prepare localization, show tokens --- gitea-options.php | 80 +++++++++++++++++++++++++++++------------------ gitea-updater.php | 33 +++---------------- 2 files changed, 53 insertions(+), 60 deletions(-) diff --git a/gitea-options.php b/gitea-options.php index bd3f7dd..8eb617a 100644 --- a/gitea-options.php +++ b/gitea-options.php @@ -40,7 +40,7 @@ class Gitea_Options { function options_page() { $options = (array)get_option('gitea_options'); $repositories = $this->get_repositories(); - $titles = array( + $types = array( 'plugin' => __('Plugins'), 'theme' => __('Themes'), ); @@ -52,21 +52,24 @@ class Gitea_Options {
-

Install Results

+

install($_POST['gitea_install']); ?>
+ + +
-

Access Tokens

+

-

The access token from a repository always have priority over the global.

+

$packages) : ?>
@@ -76,7 +79,7 @@ class Gitea_Options { - + @@ -84,7 +87,7 @@ class Gitea_Options { - + $package) : ?> @@ -95,7 +98,7 @@ class Gitea_Options { - + @@ -105,8 +108,8 @@ class Gitea_Options {

- - + +

@@ -115,42 +118,44 @@ class Gitea_Options {
-

Install from URL

+

+

http:// or https:// links, It\'s not working with ssh:// links!', 'gitea')?>

+
- +
- + - +
- + - +
- +
@@ -165,12 +170,15 @@ class Gitea_Options { themes:
- + */ ?> + install($package); - remove_filter('install_plugin_complete_actions', array($this, 'installed'), 10, 3); + remove_filter('install_plugin_complete_actions', array($this, 'install_actions')); } elseif ($data['type'] == 'theme') { - add_filter('install_theme_complete_actions', array($this, 'installed'), 10, 3); + add_filter('install_theme_complete_actions', array($this, 'install_actions')); $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'theme', 'api') ) ); $upgrader->install($package); - remove_filter('install_theme_complete_actions', array($this, 'installed'), 10, 3); + remove_filter('install_theme_complete_actions', array($this, 'install_actions')); } } - function installed($install_actions, $api, $file) { - $return = '' . __( 'Return' ) . ''; - - if (isset($install_actions['plugins_page'])) $install_actions['plugins_page'] = $return; - if (isset($install_actions['themes_page'])) $install_actions['themes_page'] = $return; - - + function install_actions($install_actions) { + unset($install_actions['plugins_page'], $install_actions['themes_page']); + $install_actions['gitea_page'] = '' . __( 'Return', 'gitea' ) . ''; return $install_actions; } + } diff --git a/gitea-updater.php b/gitea-updater.php index 614e07d..66f0b23 100644 --- a/gitea-updater.php +++ b/gitea-updater.php @@ -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(