diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/gitea-options.php b/gitea-options.php index f8ba112..8b524a6 100644 --- a/gitea-options.php +++ b/gitea-options.php @@ -36,7 +36,7 @@ class Gitea_Options { function options_post() { if (isset($_GET['force-check'])) { - Gitea_Updater::getInstance()->get_gitea_all(); + Gitea_Updater::getInstance()->get_all(); set_site_transient('update_plugins', null); set_site_transient('update_themes', null); } @@ -69,8 +69,6 @@ class Gitea_Options { - -
@@ -149,7 +147,7 @@ class Gitea_Options { - + @@ -174,8 +172,9 @@ class Gitea_Options {
- plugins: - themes: + : +
+ :
*/ ?> @@ -213,7 +212,7 @@ class Gitea_Options { $repo = str_replace('.git', '', trim($url['path'], '/')); $updater = Gitea_Updater::getInstance(); - $package = $updater->get_gitea_url($host, $repo, '/archive/master.zip', $data['access_token']); + $package = $updater->get_url($host, $repo, '/archive/master.zip', $data['access_token']); if ($data['type'] == 'plugin') { diff --git a/gitea-updater.php b/gitea-updater.php index 66f0b23..a086a07 100644 --- a/gitea-updater.php +++ b/gitea-updater.php @@ -6,6 +6,7 @@ Description: Plugins updater Version: 0.1.1 Author: Pau Capó Author URI: http://www.paucapo.com +Text Domain: gitea Gitea Host: https://git.paucapo.com Gitea URI: wp/gitea-updater */ @@ -40,6 +41,8 @@ class Gitea_Updater { function __construct() { + add_action('plugins_loaded', array($this, 'plugins_loaded')); + Gitea_Options::getInstance(); // plugins checks @@ -55,12 +58,16 @@ class Gitea_Updater { } - function get_gitea_all() { - $this->get_gitea_plugins(); - $this->get_gitea_themes(); + function plugins_loaded() { + load_plugin_textdomain('gitea', FALSE, basename( dirname( __FILE__ ) ) . '/languages/'); } - function get_gitea_plugins() { + function get_all() { + $this->get_plugins(); + $this->get_themes(); + } + + function get_plugins() { $this->plugins = array(); $plugins = get_plugins(); @@ -72,13 +79,13 @@ class Gitea_Updater { $slug = trim(dirname($plugin_slug), '/'); $file = basename($plugin_slug); - $host = $this->get_gitea_host($plugin['Gitea Host']); + $host = $this->get_host($plugin['Gitea Host']); $repo = $plugin['Gitea URI']; $local_version = strtolower($plugin['Version']); - $url = $this->get_gitea_url($host, $repo, '/raw/master/'.$file); + $url = $this->get_url($host, $repo, '/raw/master/'.$file); if ($url != false) { - $new_version = $this->get_gitea_version($url, 'plugin'); + $new_version = $this->get_version($url, 'plugin'); $new_version = $new_version ? $new_version : $local_version; } @@ -96,7 +103,7 @@ class Gitea_Updater { 'url' => $host.$repo, 'local_version' => $local_version, 'new_version' => $new_version, - 'package' => $this->get_gitea_url($host, $repo, '/archive/master.zip'), + 'package' => $this->get_url($host, $repo, '/archive/master.zip'), ); $this->plugins[$slug] = $gitea; @@ -109,7 +116,7 @@ class Gitea_Updater { } - function get_gitea_themes() { + function get_themes() { $this->themes = array(); $themes = wp_get_themes(); @@ -120,13 +127,13 @@ class Gitea_Updater { // this is a gitea theme $slug = $theme->stylesheet; - $host = $this->get_gitea_host($theme->get('Gitea Host')); + $host = $this->get_host($theme->get('Gitea Host')); $repo = $theme->get('Gitea URI'); $local_version = strtolower($theme->get('Version')); - $url = $this->get_gitea_url($host, $repo, '/raw/master/style.css'); + $url = $this->get_url($host, $repo, '/raw/master/style.css'); if ($url != false) { - $new_version = $this->get_gitea_version($url, 'plugin'); + $new_version = $this->get_version($url, 'plugin'); $new_version = $new_version ? $new_version : $local_version; } @@ -143,7 +150,7 @@ class Gitea_Updater { 'url' => $theme->get('AuthorURI'),//$host.$repo, 'local_version' => $local_version, 'new_version' => $new_version, - 'package' => $this->get_gitea_url($host, $repo, '/archive/master.zip'), + 'package' => $this->get_url($host, $repo, '/archive/master.zip'), ); $this->themes[$slug] = $gitea; @@ -156,11 +163,11 @@ class Gitea_Updater { } - function get_gitea_host($host) { + function get_host($host) { return rtrim($host, '/').'/'; } - function get_gitea_token($host, $repo) { + function get_token($host, $repo) { $options = Gitea_Options::get(); $token = ''; @@ -176,17 +183,17 @@ class Gitea_Updater { return !empty($token) ? $token : false; } - function get_gitea_url($host, $repo, $args = '', $access_token = false) { + function get_url($host, $repo, $args = '', $access_token = false) { if ($access_token === false) { - $access_token = $this->get_gitea_token($host, $repo); + $access_token = $this->get_token($host, $repo); if (!$access_token) return false; } return $host.'api/v1/repos/'.$repo.$args.'?access_token='.$access_token; } - function get_gitea_file($url) { + function get_file($url) { $request = wp_remote_get($url); if (is_wp_error($request) || 200 != wp_remote_retrieve_response_code($request)) { @@ -197,9 +204,9 @@ class Gitea_Updater { return $request; } - function get_gitea_version($url, $type) { + function get_version($url, $type) { - $request = $this->get_gitea_file($url); + $request = $this->get_file($url); if (!$request) return false; @@ -236,7 +243,7 @@ class Gitea_Updater { function pre_set_site_transient_update_plugins($transient) { // check if some plugin needs update - $this->get_gitea_plugins(); + $this->get_plugins(); foreach ($this->plugins as $plugin => $git_plugin) { @@ -254,7 +261,7 @@ class Gitea_Updater { function pre_set_site_transient_update_themes($transient) { // check if some theme needs update - $this->get_gitea_themes(); + $this->get_themes(); foreach ($this->themes as $theme => $git_theme) { diff --git a/languages/gitea-ca.mo b/languages/gitea-ca.mo new file mode 100644 index 0000000..9bc41ca Binary files /dev/null and b/languages/gitea-ca.mo differ diff --git a/languages/gitea-ca.po b/languages/gitea-ca.po new file mode 100644 index 0000000..ffec4e7 --- /dev/null +++ b/languages/gitea-ca.po @@ -0,0 +1,100 @@ +msgid "" +msgstr "" +"Project-Id-Version: Gitea Updater\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-15 12:02+0000\n" +"PO-Revision-Date: 2017-03-15 12:10+0000\n" +"Last-Translator: Pau Capó \n" +"Language-Team: Catalan\n" +"Language: ca\n" +"Plural-Forms: nplurals=2; plural=n != 1\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Loco - https://localise.biz/" + +#: gitea-options.php:78 +msgid "" +"The access token from a repository always have priority over the global." +msgstr "El token d'accés d'un repositori sempre té prioritat envers el global." + +#: gitea-options.php:131 +msgid "" +"Only with http:// or https:// links, It's not " +"working with ssh:// links!" +msgstr "" +"Només enllaços http:// o https://, Els enllaços " +"ssh:// no funcionen!" + +#: gitea-options.php:140 +msgid "Plugins" +msgstr "Extensions" + +#: gitea-options.php:141 +msgid "Themes" +msgstr "Temes" + +#. Author of the plugin +msgid "Pau Capó" +msgstr "Pau Capó" + +#: gitea-options.php:64 +msgid "Install Results" +msgstr "Resultats de la instal·lació" + +#: gitea-options.php:75 +msgid "Access Tokens" +msgstr "Tokens d'accés" + +#: gitea-options.php:90 +msgid "Global Access Token" +msgstr "Token d'accés global" + +#: gitea-options.php:103 gitea-options.php:155 +msgid "Access Token" +msgstr "Token d'accés" + +#: gitea-options.php:117 +msgid "Save Changes" +msgstr "Guarda els canvis" + +#: gitea-options.php:118 +msgid "Reset Cache" +msgstr "Reinicia cache" + +#: gitea-options.php:127 +msgid "Install from URL" +msgstr "Instal·la de URL" + +#: gitea-options.php:136 +msgid "Type" +msgstr "Tipus" + +#: gitea-options.php:147 +msgid "Repository URL" +msgstr "URL del repositori" + +#: gitea-options.php:150 +msgid "https://host/org/repo or https://host/org/repo.git" +msgstr "https://host/org/repo o https://host/org/repo.git" + +#: gitea-options.php:164 +msgid "Install Now" +msgstr "Instal·la" + +#: gitea-options.php:240 +msgid "Return" +msgstr "Torna" + +#. Name of the plugin +msgid "Gitea Updater" +msgstr "Gitea Updater" + +#. Description of the plugin +msgid "Plugins updater" +msgstr "Plugins updater" + +#. URI of the plugin +#. Author URI of the plugin +msgid "http://www.paucapo.com" +msgstr "http://www.paucapo.com" diff --git a/languages/gitea-es_ES.mo b/languages/gitea-es_ES.mo new file mode 100644 index 0000000..e4a2347 Binary files /dev/null and b/languages/gitea-es_ES.mo differ diff --git a/languages/gitea-es_ES.po b/languages/gitea-es_ES.po new file mode 100644 index 0000000..7f192d5 --- /dev/null +++ b/languages/gitea-es_ES.po @@ -0,0 +1,102 @@ +msgid "" +msgstr "" +"Project-Id-Version: Gitea Updater\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-15 12:02+0000\n" +"PO-Revision-Date: 2017-03-15 12:05+0000\n" +"Last-Translator: Pau Capó \n" +"Language-Team: Spanish (Spain)\n" +"Language: es-ES\n" +"Plural-Forms: nplurals=2; plural=n != 1\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Loco - https://localise.biz/" + +#. Name of the plugin +msgid "Gitea Updater" +msgstr "Gitea Updater" + +#. Description of the plugin +msgid "Plugins updater" +msgstr "Plugins updater" + +#. URI of the plugin +#. Author URI of the plugin +msgid "http://www.paucapo.com" +msgstr "http://www.paucapo.com" + +#. Author of the plugin +msgid "Pau Capó" +msgstr "Pau Capó" + +#: gitea-options.php:150 +msgid "https://host/org/repo or https://host/org/repo.git" +msgstr "https://host/org/repo o https://host/org/repo.git" + +#: gitea-options.php:64 +msgid "Install Results" +msgstr "Resultados de la instalación" + +#: gitea-options.php:75 +msgid "Access Tokens" +msgstr "Tokens de acceso" + +#: gitea-options.php:78 +msgid "" +"The access token from a repository always have priority over the global." +msgstr "" +"El token de acceso de un repositorio siempre tiene prioridad por encima del " +"global." + +#: gitea-options.php:90 +msgid "Global Access Token" +msgstr "Token de acceso global" + +#: gitea-options.php:103 gitea-options.php:155 +msgid "Access Token" +msgstr "Token de acceso" + +#: gitea-options.php:117 +msgid "Save Changes" +msgstr "Guardar cambios" + +#: gitea-options.php:118 +msgid "Reset Cache" +msgstr "Reiniciar cache" + +#: gitea-options.php:127 +msgid "Install from URL" +msgstr "Instalar de URL" + +#: gitea-options.php:131 +msgid "" +"Only with http:// or https:// links, It's not " +"working with ssh:// links!" +msgstr "" +"Solo enlaces http:// o https://, no funciona con " +"enlaces ssh://!" + +#: gitea-options.php:136 +msgid "Type" +msgstr "Tipo" + +#: gitea-options.php:140 +msgid "Plugins" +msgstr "Plugins" + +#: gitea-options.php:141 +msgid "Themes" +msgstr "Temas" + +#: gitea-options.php:147 +msgid "Repository URL" +msgstr "URL del repositorio" + +#: gitea-options.php:164 +msgid "Install Now" +msgstr "Instalar" + +#: gitea-options.php:240 +msgid "Return" +msgstr "Volver" diff --git a/languages/gitea.pot b/languages/gitea.pot new file mode 100644 index 0000000..b574a71 --- /dev/null +++ b/languages/gitea.pot @@ -0,0 +1,99 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-15 12:02+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: \n" +"Language: \n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Loco - https://localise.biz/" + +#: gitea-options.php:64 +msgid "Install Results" +msgstr "" + +#: gitea-options.php:75 +msgid "Access Tokens" +msgstr "" + +#: gitea-options.php:78 +msgid "" +"The access token from a repository always have priority over the global." +msgstr "" + +#: gitea-options.php:90 +msgid "Global Access Token" +msgstr "" + +#: gitea-options.php:103 gitea-options.php:155 +msgid "Access Token" +msgstr "" + +#: gitea-options.php:117 +msgid "Save Changes" +msgstr "" + +#: gitea-options.php:118 +msgid "Reset Cache" +msgstr "" + +#: gitea-options.php:127 +msgid "Install from URL" +msgstr "" + +#: gitea-options.php:131 +msgid "" +"Only with http:// or https:// links, It's not " +"working with ssh:// links!" +msgstr "" + +#: gitea-options.php:136 +msgid "Type" +msgstr "" + +#: gitea-options.php:140 +msgid "Plugins" +msgstr "" + +#: gitea-options.php:141 +msgid "Themes" +msgstr "" + +#: gitea-options.php:147 +msgid "Repository URL" +msgstr "" + +#: gitea-options.php:150 +msgid "https://host/org/repo or https://host/org/repo.git" +msgstr "" + +#: gitea-options.php:164 +msgid "Install Now" +msgstr "" + +#: gitea-options.php:240 +msgid "Return" +msgstr "" + +#. Name of the plugin +msgid "Gitea Updater" +msgstr "" + +#. Description of the plugin +msgid "Plugins updater" +msgstr "" + +#. URI of the plugin +#. Author URI of the plugin +msgid "http://www.paucapo.com" +msgstr "" + +#. Author of the plugin +msgid "Pau Capó" +msgstr ""