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( 'plugin' => __('Plugins'), 'theme' => __('Themes'), ); ?>

Gitea Updater

Install Results

install($_POST['gitea_install']); ?>

Access Tokens

The access token from a repository always have priority over the global.

$packages) : ?>
$items) : ?> $package) : ?>

Install from URL

plugins: themes:
$plugin) { $plugin['url'] = $plugin['gitea_host'].$plugin['gitea_repo']; $repositories[$plugin['gitea_host']]['plugin'][$slug] = $plugin; } foreach ($themes as $slug => $theme) { $theme['url'] = $theme['gitea_host'].$theme['gitea_repo']; $repositories[$plugin['gitea_host']]['theme'][$slug] = $theme; } return $repositories; } static function get() { return (array)get_option('gitea_options'); } function install($data) { $url = parse_url($data['url']); $host = $url['scheme'].'://'.$url['host'].'/'; $repo = str_replace('.git', '', trim($url['path'], '/')); $updater = Gitea_Updater::getInstance(); $package = $updater->get_gitea_url($host, $repo, '/archive/master.zip', $data['access_token']); if ($data['type'] == 'plugin') { add_filter('install_plugin_complete_actions', array($this, 'installed'), 10, 3); $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) ); $upgrader->install($package); remove_filter('install_plugin_complete_actions', array($this, 'installed'), 10, 3); } elseif ($data['type'] == 'theme') { add_filter('install_theme_complete_actions', array($this, 'installed'), 10, 3); $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'theme', 'api') ) ); $upgrader->install($package); remove_filter('install_theme_complete_actions', array($this, 'installed'), 10, 3); } } function installed($install_actions, $api, $file) { $return = '' . __( 'Return' ) . ''; if (isset($install_actions['plugins_page'])) $install_actions['plugins_page'] = $return; if (isset($install_actions['themes_page'])) $install_actions['themes_page'] = $return; return $install_actions; } }