page = add_options_page('Gitea Updater', 'Gitea Updater', 'manage_options', 'gitea-updater', array($this, 'options_page')); add_action('load-' . $this->page, array($this, 'options_post')); } function enqueue_assets($hook) { if ($hook != $this->page) return; wp_enqueue_style('gitea-updater', plugins_url('/assets/style.css', __FILE__)); wp_enqueue_script('gitea-js', plugins_url('/assets/script.js', __FILE__), array('jquery'), null, true); } function options_post() { if (isset($_GET['force-check'])) { Gitea_Updater::getInstance()->get_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(); $types = array( 'plugin' => __('Plugins'), 'theme' => __('Themes'), ); ?>

Gitea Updater

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

http:// or https:// links, It\'s not working with ssh:// links!', 'gitea') ?>

:
:
*/ ?> $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[$theme['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_url($host, $repo, '/archive/master.zip', $data['access_token']); if ($data['type'] == 'plugin') { add_filter('install_plugin_complete_actions', array($this, 'install_actions')); $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, 'install_actions')); } elseif ($data['type'] == 'theme') { add_filter('install_theme_complete_actions', array($this, 'install_actions')); $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, 'install_actions')); } } function install_actions($install_actions) { unset($install_actions['plugins_page'], $install_actions['themes_page']); $install_actions['gitea_page'] = '' . __('Return', 'gitea') . ''; return $install_actions; } }