diff --git a/kgv-updater.php b/kgv-updater.php index 9923590..2ef00c6 100644 --- a/kgv-updater.php +++ b/kgv-updater.php @@ -3,6 +3,8 @@ * Plugin Name: KGV Updater * Plugin URI: https://apex-project.de/ * Description: Aktualisiert KGV-Plugins direkt aus den Gitea-Repositories. + * Update URI: https://git.apex-project.de/RonnyG/KGV-Updater + * Gitea Plugin URI: https://git.apex-project.de/RonnyG/KGV-Updater * Version: 1.0.0 * Author: Ronny Grobel * Text Domain: kgv-updater @@ -13,8 +15,8 @@ if ( ! defined( 'ABSPATH' ) ) { } final class KGV_Updater { - const OPTION_TOKEN = 'kgv_updater_gitea_token'; - const OPTION_HOST = 'kgv_updater_gitea_host'; + const GITEA_HOST = 'git.apex-project.de'; + const GITEA_TOKEN = ''; private static $instance = null; @@ -29,72 +31,6 @@ final class KGV_Updater { private function __construct() { add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'inject_updates' ) ); add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 ); - add_action( 'admin_menu', array( $this, 'register_settings_page' ) ); - add_action( 'admin_init', array( $this, 'register_settings' ) ); - } - - public function register_settings() { - register_setting( - 'kgv_updater_settings', - self::OPTION_TOKEN, - array( - 'type' => 'string', - 'sanitize_callback' => 'sanitize_text_field', - 'default' => '', - ) - ); - - register_setting( - 'kgv_updater_settings', - self::OPTION_HOST, - array( - 'type' => 'string', - 'sanitize_callback' => 'sanitize_text_field', - 'default' => 'git.apex-project.de', - ) - ); - } - - public function register_settings_page() { - add_options_page( - 'KGV Updater', - 'KGV Updater', - 'manage_options', - 'kgv-updater', - array( $this, 'render_settings_page' ) - ); - } - - public function render_settings_page() { - if ( ! current_user_can( 'manage_options' ) ) { - return; - } - ?> -
-

KGV Updater

-

Prueft KGV-Plugins mit Update URI auf neue Versionen in Gitea.

-
- - - - - - - - - - - - -
-
- get_gitea_host(); + $host = self::GITEA_HOST; $managed = array(); foreach ( $plugins as $plugin_file => $plugin_data ) { - if ( plugin_basename( __FILE__ ) === $plugin_file ) { - continue; - } - $update_uri = isset( $plugin_data['UpdateURI'] ) ? trim( (string) $plugin_data['UpdateURI'] ) : ''; $name = isset( $plugin_data['Name'] ) ? (string) $plugin_data['Name'] : ''; @@ -219,7 +151,7 @@ final class KGV_Updater { 'User-Agent' => 'KGV-Updater/1.0', ); - $token = trim( (string) get_option( self::OPTION_TOKEN, '' ) ); + $token = trim( (string) self::GITEA_TOKEN ); if ( '' !== $token ) { $headers['Authorization'] = 'token ' . $token; } @@ -313,10 +245,6 @@ final class KGV_Updater { ); } - private function get_gitea_host() { - $host = trim( (string) get_option( self::OPTION_HOST, 'git.apex-project.de' ) ); - return '' !== $host ? $host : 'git.apex-project.de'; - } } KGV_Updater::instance();