rename functions
This commit is contained in:
parent
67981c517d
commit
222bbaf084
2 changed files with 24 additions and 26 deletions
|
|
@ -55,12 +55,12 @@ class Gitea_Updater {
|
|||
|
||||
}
|
||||
|
||||
function get_gitea_all() {
|
||||
$this->get_gitea_plugins();
|
||||
$this->get_gitea_themes();
|
||||
function get_all() {
|
||||
$this->get_plugins();
|
||||
$this->get_themes();
|
||||
}
|
||||
|
||||
function get_gitea_plugins() {
|
||||
function get_plugins() {
|
||||
$this->plugins = array();
|
||||
$plugins = get_plugins();
|
||||
|
||||
|
|
@ -72,13 +72,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 +96,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 +109,7 @@ class Gitea_Updater {
|
|||
|
||||
}
|
||||
|
||||
function get_gitea_themes() {
|
||||
function get_themes() {
|
||||
$this->themes = array();
|
||||
$themes = wp_get_themes();
|
||||
|
||||
|
|
@ -120,13 +120,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 +143,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 +156,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 +176,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 +197,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 +236,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 +254,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) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue