fix themes
This commit is contained in:
parent
bd854a504f
commit
fd736b5acd
1 changed files with 46 additions and 44 deletions
|
|
@ -3,7 +3,7 @@
|
|||
* Plugin Name: Gitea Updater
|
||||
* Plugin URI: http://www.paucapo.com
|
||||
* Description: Plugins updater
|
||||
* Version: 0.3.7
|
||||
* Version: 0.3.8
|
||||
* Author: Pau Capó
|
||||
* Author URI: http://www.paucapo.com
|
||||
* Text Domain: gitea
|
||||
|
|
@ -172,56 +172,56 @@ class Gitea_Updater
|
|||
function get_themes()
|
||||
{
|
||||
|
||||
$this->themes = get_option('gitea_themes');
|
||||
if (!is_array($this->themes)) {
|
||||
$this->themes = array();
|
||||
}
|
||||
|
||||
$this->themes = array();
|
||||
$themes = wp_get_themes();
|
||||
|
||||
foreach ($themes as $theme) {
|
||||
|
||||
if ($theme->get('Gitea Host') != '' && $theme->get('Gitea URI')) {
|
||||
$headers = $this->get_file_headers(file_get_contents($theme->get_template_directory().'/style.css'), 'theme');
|
||||
var_dump($headers);
|
||||
if (empty($headers['Gitea Host']) || empty($headers['Gitea URI'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// this is a gitea theme
|
||||
$slug = $theme->stylesheet;
|
||||
$local_version = strtolower($theme->get('Version'));
|
||||
// this is a gitea theme
|
||||
$slug = $theme->get_stylesheet();
|
||||
var_dump($slug);
|
||||
$local_version = strtolower($headers['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');
|
||||
|
||||
$url = $this->get_url($host, $repo, '/raw/master/style.css');
|
||||
if ($url != false) {
|
||||
$new_version = $this->get_version($url, 'plugin');
|
||||
$new_version = $new_version ? $new_version : $local_version;
|
||||
}
|
||||
|
||||
// here we have the remote version from gitea/repo/style.css
|
||||
|
||||
// building the theme data
|
||||
$gitea = array(
|
||||
'slug' => $slug,
|
||||
'name' => $theme->get('Name'),
|
||||
'gitea_host' => $host,
|
||||
'gitea_repo' => $repo,
|
||||
'description' => $theme->get('Description'),
|
||||
'author' => $theme->get('Author'),
|
||||
'url' => $theme->get('AuthorURI'),//$host.$repo,
|
||||
'local_version' => $local_version,
|
||||
'new_version' => $new_version,
|
||||
'package' => $this->get_url($host, $repo, '/archive/master.zip'),
|
||||
);
|
||||
|
||||
$this->themes[$slug] = $gitea;
|
||||
if (isset($this->themes[$slug]) && !$this->update('themes')) {
|
||||
$this->themes[$slug]['local_version'] = $local_version;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$host = $this->get_host($headers['Gitea Host']);
|
||||
$repo = $headers['Gitea URI'];
|
||||
|
||||
$url = $this->get_url($host, $repo, '/raw/master/style.css');
|
||||
$new_version = $local_version;
|
||||
if ($url != false) {
|
||||
$new_version = $this->get_version($url, 'theme');
|
||||
$new_version = $new_version ? $new_version : $local_version;
|
||||
}
|
||||
|
||||
// here we have the remote version from gitea/repo/style.css
|
||||
|
||||
// building the theme data
|
||||
$gitea = array(
|
||||
'slug' => $slug,
|
||||
'name' => $headers['Name'],
|
||||
'gitea_host' => $host,
|
||||
'gitea_repo' => $repo,
|
||||
'description' => $headers['Description'],
|
||||
'author' => $headers['Author'],
|
||||
'url' => $headers['AuthorURI'],
|
||||
'local_version' => $local_version,
|
||||
'new_version' => $new_version,
|
||||
'package' => $this->get_url($host, $repo, '/archive/master.zip'),
|
||||
);
|
||||
|
||||
$this->themes[$slug] = $gitea;
|
||||
|
||||
}
|
||||
|
||||
update_option('gitea_themes', $this->themes);
|
||||
|
|
@ -395,10 +395,12 @@ class Gitea_Updater
|
|||
if (false !== strpos($type, 'plugin')) {
|
||||
$all_headers = $default_plugin_headers;
|
||||
}
|
||||
|
||||
if (false !== strpos($type, 'theme')) {
|
||||
else if (false !== strpos($type, 'theme')) {
|
||||
$all_headers = $default_theme_headers;
|
||||
}
|
||||
else {
|
||||
return [];
|
||||
}
|
||||
|
||||
$file_data = str_replace("\r", "\n", $contents);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue