diff --git a/gitea-updater.php b/gitea-updater.php index d1901a7..b139654 100644 --- a/gitea-updater.php +++ b/gitea-updater.php @@ -96,12 +96,11 @@ class Gitea_Updater function get_plugins() { - if (!$this->update('plugins')) { - $this->plugins = get_option('gitea_plugins'); - return; + $this->plugins = get_option('gitea_plugins'); + if (!is_array($this->plugins)) { + $this->plugins = array(); } - $this->plugins = array(); $plugins = get_plugins(); foreach ($plugins as $plugin_slug => $plugin) { @@ -109,12 +108,17 @@ class Gitea_Updater if (!empty($plugin['Gitea URI']) && !empty($plugin['Gitea Host'])) { // this is a gitea plugin - $slug = trim(dirname($plugin_slug), '/'); + $local_version = strtolower($plugin['Version']); + + if (isset($this->plugins[$slug]) && !$this->update('plugins')) { + $this->plugins[$slug]['local_version'] = $local_version; + continue; + } + $file = basename($plugin_slug); $host = $this->get_host($plugin['Gitea Host']); $repo = $plugin['Gitea URI']; - $local_version = strtolower($plugin['Version']); $url = $this->get_url($host, $repo, '/raw/master/' . $file); if ($url != false) { @@ -152,9 +156,9 @@ class Gitea_Updater function get_themes() { - if (!$this->update('themes')) { - $this->themes = get_option('gitea_themes'); - return; + $this->themes = get_option('gitea_themes'); + if (!is_array($this->themes)) { + $this->themes = array(); } $this->themes = array(); @@ -165,11 +169,17 @@ class Gitea_Updater if ($theme->get('Gitea Host') != '' && $theme->get('Gitea URI')) { // this is a gitea theme - $slug = $theme->stylesheet; + $local_version = strtolower($theme->get('Version')); + + if (isset($this->themes[$slug]) && !$this->update('themes')) { + $this->themes[$slug]['local_version'] = $local_version; + continue; + } + + $host = $this->get_host($theme->get('Gitea Host')); $repo = $theme->get('Gitea URI'); - $local_version = strtolower($theme->get('Version')); $url = $this->get_url($host, $repo, '/raw/master/style.css'); if ($url != false) {