From 245370cbe9c59eada6a796d71d85df63dc934b43 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Fri, 27 Jun 2025 19:08:47 -0700 Subject: [PATCH] add Git Updater Lite based updater for packages (#131) --- inc/namespace.php | 1 + inc/updater/namespace.php | 73 +++++++++++++++++++++++++++++++++++++++ plugin.php | 1 + 3 files changed, 75 insertions(+) create mode 100644 inc/updater/namespace.php diff --git a/inc/namespace.php b/inc/namespace.php index cc5a90a..e85ccd8 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -36,6 +36,7 @@ function bootstrap() { Pings\bootstrap(); Salts\bootstrap(); Settings\bootstrap(); + Updater\bootstrap(); User_Notification\bootstrap(); Version_Check\bootstrap(); diff --git a/inc/updater/namespace.php b/inc/updater/namespace.php new file mode 100644 index 0000000..41a2b3a --- /dev/null +++ b/inc/updater/namespace.php @@ -0,0 +1,73 @@ + $plugin ) { + if ( empty( $plugin['UpdateURI'] ) ) { + continue; + } + $plugin_id = get_file_data( $plugin_path . $file, [ 'PluginID' => 'Plugin ID' ] )['PluginID']; + + if ( ! empty( $plugin_id ) ) { + $package_arr[] = $plugin_path . $file; + } + } + + $theme_path = WP_CONTENT_DIR . '/themes/'; + $themes = wp_get_themes(); + foreach ( $themes as $file => $theme ) { + if ( empty( $theme->get( 'UpdateURI' ) ) ) { + continue; + } + $theme_id = get_file_data( $theme_path . $file . '/style.css', [ 'ThemeID' => 'Theme ID' ] )['ThemeID']; + + if ( ! empty( $theme_id ) ) { + $package_arr[] = $theme_path . $file . '/style.css'; + } + } + + run( $package_arr ); +} + +/** + * Run Git Updater Lite for potential packages. + * + * @return void + */ +function run( $package_arr ) { + foreach ( $package_arr as $package ) { + ( new Git_Updater\Lite( $package ) )->run(); + } +} diff --git a/plugin.php b/plugin.php index 12d03e7..187b95f 100644 --- a/plugin.php +++ b/plugin.php @@ -31,6 +31,7 @@ require_once __DIR__ . '/inc/importers/namespace.php'; require_once __DIR__ . '/inc/pings/namespace.php'; require_once __DIR__ . '/inc/salts/namespace.php'; require_once __DIR__ . '/inc/settings/namespace.php'; +require_once __DIR__ . '/inc/updater/namespace.php'; require_once __DIR__ . '/inc/user-notification/namespace.php'; require_once __DIR__ . '/inc/version-check/namespace.php';