This commit is contained in:
Pau Capó 2017-03-14 21:06:42 +01:00
parent 6632c1ab14
commit 996b5bc50a
2 changed files with 47 additions and 26 deletions

View file

@ -18,16 +18,22 @@ class Gitea_Options {
}
function admin_menu() {
add_options_page('Gitea Updater', 'Gitea Updater', 'manage_options', 'gitea-updater', array($this, 'options_page'));
$options = add_options_page('Gitea Updater', 'Gitea Updater', 'manage_options', 'gitea-updater', array($this, 'options_page'));
add_action('load-'.$options, array($this, 'options_post'));
}
function options_page() {
function options_post() {
if (isset($_GET['force-check'])) {
Gitea_Updater::getInstance()->get_gitea_all();
set_site_transient('update_plugins', null);
set_site_transient('update_themes', null);
}
if (isset($_POST['gitea_options'])) {
update_option('gitea_options', $_POST['gitea_options']);
}
}
function options_page() {
$options = (array)get_option('gitea_options');
$repositories = $this->get_repositories();
$titles = array(
@ -82,7 +88,8 @@ class Gitea_Options {
<a href="<?=admin_url('options-general.php?page=gitea-updater&force-check=1')?>" class="button button-primary"><?=__('Reset Cache')?></a>
</p>
</form>
<textarea style="width:100%" rows="2" onfocus="this.rows=30;" onblur="this.rows=2;" readonly><?php var_dump($options); ?></textarea>
<?=date('d/m/Y H:i:s', get_option('gitea_last_checked'))?>
<textarea style="width:100%" rows="2" onfocus="this.rows=30;" onblur="this.rows=2;" readonly><?php var_dump(get_plugin_updates()); ?></textarea>
</div>
<style>
table.gitea {
@ -120,5 +127,9 @@ class Gitea_Options {
}
static function get() {
return (array)get_option('gitea_options');
}
}