Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f687beb68 | |||
| ef13ce4598 | |||
| d8cdf8deee | |||
| 4d051c19b9 | |||
| 064e082eb8 |
@@ -5,9 +5,17 @@
|
|||||||
* Description: Aktualisiert KGV-Plugins direkt aus den Gitea-Repositories.
|
* Description: Aktualisiert KGV-Plugins direkt aus den Gitea-Repositories.
|
||||||
* Update URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Updater.git
|
* Update URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Updater.git
|
||||||
* Gitea Plugin URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Updater.git
|
* Gitea Plugin URI: https://git.apex-project.de/Wordpress_Plugins/KGV-Updater.git
|
||||||
* Version: 1.0.1
|
* Version: 1.0.5
|
||||||
* Author: Ronny Grobel
|
* Author: Ronny Grobel
|
||||||
* Text Domain: kgv-updater
|
* Text Domain: kgv-updater
|
||||||
|
* License: GPLv2+
|
||||||
|
*
|
||||||
|
* Php Version 5.6
|
||||||
|
*
|
||||||
|
* @package WordPress
|
||||||
|
* @author Ronny Grobel <dgsoft.de@gmail.com>
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
* @version 2026-04-16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
@@ -17,6 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
final class KGV_Updater {
|
final class KGV_Updater {
|
||||||
const GITEA_HOST = 'git.apex-project.de';
|
const GITEA_HOST = 'git.apex-project.de';
|
||||||
const GITEA_TOKEN = '';
|
const GITEA_TOKEN = '';
|
||||||
|
const INSTALLED_TAGS_OPTION = 'kgv_updater_installed_tags';
|
||||||
|
|
||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
|
|
||||||
@@ -31,6 +40,7 @@ final class KGV_Updater {
|
|||||||
private function __construct() {
|
private function __construct() {
|
||||||
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'inject_updates' ) );
|
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'inject_updates' ) );
|
||||||
add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 );
|
add_filter( 'plugins_api', array( $this, 'plugins_api' ), 10, 3 );
|
||||||
|
add_action( 'upgrader_process_complete', array( $this, 'mark_installed_release_tags' ), 10, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function inject_updates( $transient ) {
|
public function inject_updates( $transient ) {
|
||||||
@@ -39,17 +49,22 @@ final class KGV_Updater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$plugins = $this->get_managed_plugins();
|
$plugins = $this->get_managed_plugins();
|
||||||
|
$installed_tags = $this->get_installed_tags();
|
||||||
|
|
||||||
foreach ( $plugins as $plugin_file => $plugin_data ) {
|
foreach ( $plugins as $plugin_file => $plugin_data ) {
|
||||||
$current_version = isset( $plugin_data['Version'] ) ? $plugin_data['Version'] : '';
|
$current_version = isset( $plugin_data['Version'] ) ? $plugin_data['Version'] : '';
|
||||||
$repo_url = isset( $plugin_data['UpdateURI'] ) ? $plugin_data['UpdateURI'] : '';
|
$repo_url = isset( $plugin_data['UpdateURI'] ) ? $plugin_data['UpdateURI'] : '';
|
||||||
$release = $this->get_release_data( $repo_url );
|
$release = $this->get_release_data( $repo_url );
|
||||||
|
$installed_tag = isset( $installed_tags[ $plugin_file ] ) ? (string) $installed_tags[ $plugin_file ] : '';
|
||||||
|
$release_tag = isset( $release['tag'] ) ? (string) $release['tag'] : '';
|
||||||
|
|
||||||
if ( empty( $release['version'] ) ) {
|
if ( empty( $release['version'] ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( version_compare( $release['version'], $current_version, '>' ) ) {
|
$tag_already_installed = '' !== $installed_tag && '' !== $release_tag && 0 === strcasecmp( $installed_tag, $release_tag );
|
||||||
|
|
||||||
|
if ( version_compare( $release['version'], $current_version, '>' ) && ! $tag_already_installed ) {
|
||||||
$transient->response[ $plugin_file ] = (object) array(
|
$transient->response[ $plugin_file ] = (object) array(
|
||||||
'id' => $repo_url,
|
'id' => $repo_url,
|
||||||
'slug' => dirname( $plugin_file ),
|
'slug' => dirname( $plugin_file ),
|
||||||
@@ -74,6 +89,54 @@ final class KGV_Updater {
|
|||||||
return $transient;
|
return $transient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function mark_installed_release_tags( $upgrader, $hook_extra ) {
|
||||||
|
if ( ! is_array( $hook_extra ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $hook_extra['type'] ) || 'plugin' !== $hook_extra['type'] ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $hook_extra['action'] ) || 'update' !== $hook_extra['action'] ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $hook_extra['plugins'] ) || ! is_array( $hook_extra['plugins'] ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$managed_plugins = $this->get_managed_plugins();
|
||||||
|
if ( empty( $managed_plugins ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$update_transient = get_site_transient( 'update_plugins' );
|
||||||
|
|
||||||
|
foreach ( $hook_extra['plugins'] as $plugin_file ) {
|
||||||
|
if ( ! isset( $managed_plugins[ $plugin_file ] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tag = '';
|
||||||
|
|
||||||
|
if ( is_object( $update_transient ) && isset( $update_transient->response[ $plugin_file ] ) && is_object( $update_transient->response[ $plugin_file ] ) ) {
|
||||||
|
$package_url = isset( $update_transient->response[ $plugin_file ]->package ) ? (string) $update_transient->response[ $plugin_file ]->package : '';
|
||||||
|
$tag = $this->extract_tag_from_package_url( $package_url );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( '' === $tag ) {
|
||||||
|
$repo_url = isset( $managed_plugins[ $plugin_file ]['UpdateURI'] ) ? (string) $managed_plugins[ $plugin_file ]['UpdateURI'] : '';
|
||||||
|
$release = $this->get_release_data( $repo_url );
|
||||||
|
$tag = isset( $release['tag'] ) ? (string) $release['tag'] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( '' !== $tag ) {
|
||||||
|
$this->set_installed_tag( $plugin_file, $tag );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function plugins_api( $result, $action, $args ) {
|
public function plugins_api( $result, $action, $args ) {
|
||||||
if ( 'plugin_information' !== $action || empty( $args->slug ) ) {
|
if ( 'plugin_information' !== $action || empty( $args->slug ) ) {
|
||||||
return $result;
|
return $result;
|
||||||
@@ -262,6 +325,35 @@ final class KGV_Updater {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function extract_tag_from_package_url( $package_url ) {
|
||||||
|
if ( '' === $package_url ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = (string) wp_parse_url( $package_url, PHP_URL_PATH );
|
||||||
|
if ( preg_match( '#/archive/([^/]+)\.zip$#i', $path, $matches ) ) {
|
||||||
|
return rawurldecode( $matches[1] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function get_installed_tags() {
|
||||||
|
$tags = get_site_option( self::INSTALLED_TAGS_OPTION, array() );
|
||||||
|
|
||||||
|
return is_array( $tags ) ? $tags : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_installed_tag( $plugin_file, $tag ) {
|
||||||
|
if ( '' === $plugin_file || '' === $tag ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tags = $this->get_installed_tags();
|
||||||
|
$tags[ $plugin_file ] = $tag;
|
||||||
|
update_site_option( self::INSTALLED_TAGS_OPTION, $tags );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KGV_Updater::instance();
|
KGV_Updater::instance();
|
||||||
|
|||||||
52
readme.txt
52
readme.txt
@@ -1,16 +1,44 @@
|
|||||||
KGV Updater - WordPress Plugin
|
=== KGV Updater ===
|
||||||
|
Contributors: ronnygrobel
|
||||||
|
Tags: updater, update uri, gitea, plugin updates, maintenance
|
||||||
|
Requires at least: 6.0
|
||||||
|
Tested up to: 6.8
|
||||||
|
Stable tag: 1.0.5
|
||||||
|
Requires PHP: 7.2
|
||||||
|
License: GPLv2 or later
|
||||||
|
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
|
||||||
Beschreibung:
|
Aktualisiert KGV-Plugins ueber Update-Informationen aus Gitea-Repositories.
|
||||||
KGV Updater prueft KGV-Plugins mit Update URI gegen Gitea-Repositories und stellt Updates im WordPress-Backend bereit.
|
|
||||||
|
|
||||||
Voraussetzung:
|
== Description ==
|
||||||
- Plugins besitzen eine gueltige `Update URI` auf dem Gitea-Server.
|
|
||||||
|
|
||||||
Installation:
|
KGV Updater erweitert den WordPress-Updateprozess fuer KGV-Plugins, die eine gueltige `Update URI` nutzen.
|
||||||
1. Plugin in `wp-content/plugins/KGV-Updater/` ablegen
|
|
||||||
2. In WordPress aktivieren
|
|
||||||
3. Unter `Einstellungen > KGV Updater` optional Host/Token eintragen
|
|
||||||
|
|
||||||
Hinweis:
|
= Features =
|
||||||
- Fuer private Repositories wird ein Gitea Token benoetigt.
|
|
||||||
- Die Pruefergebnisse werden kurzfristig gecacht.
|
* Update-Pruefung fuer KGV-Plugins
|
||||||
|
* Auswertung von Gitea-Repository-Informationen
|
||||||
|
* Konfiguration von Host und Token im Backend
|
||||||
|
* Caching der Pruefergebnisse
|
||||||
|
|
||||||
|
== Installation ==
|
||||||
|
|
||||||
|
1. Plugin in `wp-content/plugins/KGV-Updater/` hochladen.
|
||||||
|
2. Plugin aktivieren.
|
||||||
|
3. Optional Host und Token unter Einstellungen > KGV Updater eintragen.
|
||||||
|
|
||||||
|
== Frequently Asked Questions ==
|
||||||
|
|
||||||
|
= Wird ein Token fuer private Repositories benoetigt? =
|
||||||
|
|
||||||
|
Ja, fuer private Repositories ist ein passender Gitea-Token erforderlich.
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.0.5 =
|
||||||
|
* Versionsabgleich zwischen Plugin-Header und Readme.
|
||||||
|
* WordPress-Readme-Format weiter vereinheitlicht.
|
||||||
|
|
||||||
|
= 1.0.4 =
|
||||||
|
* Aktuelle Version laut Plugin-Header.
|
||||||
|
* Stabilitaets- und Wartungsupdates.
|
||||||
|
|||||||
Reference in New Issue
Block a user