bug fix and solve multiple petitions when using IWP

This commit is contained in:
Pau Capó 2018-03-04 00:10:29 +01:00
parent df5e6384f2
commit f5251da21e

View file

@ -3,7 +3,7 @@
* Plugin Name: Gitea Updater * Plugin Name: Gitea Updater
* Plugin URI: http://www.paucapo.com * Plugin URI: http://www.paucapo.com
* Description: Plugins updater * Description: Plugins updater
* Version: 0.3.2 * Version: 0.3.3
* Author: Pau Capó * Author: Pau Capó
* Author URI: http://www.paucapo.com * Author URI: http://www.paucapo.com
* Text Domain: gitea * Text Domain: gitea
@ -82,9 +82,16 @@ class Gitea_Updater
function update($type) function update($type)
{ {
// disable cache in case of a force-check from admin site
if (isset($_GET['force-check'])) { if (isset($_GET['force-check'])) {
return true; return true;
} }
// small hack for multiple checks when asked throw IWP
foreach ($_POST as $key => $value) {
if (substr($key, 0, 5) == '_IWP_') {
$this->cache = 30;
}
}
$last_update = get_option('gitea_' . $type . '_updated'); $last_update = get_option('gitea_' . $type . '_updated');
return ($last_update + $this->cache) < time(); return ($last_update + $this->cache) < time();
} }
@ -93,6 +100,7 @@ class Gitea_Updater
{ {
if (!$this->update('plugins')) { if (!$this->update('plugins')) {
$this->plugins = get_option('gitea_plugins');
return; return;
} }
@ -148,6 +156,7 @@ class Gitea_Updater
{ {
if (!$this->update('themes')) { if (!$this->update('themes')) {
$this->themes = get_option('gitea_themes');
return; return;
} }