Skip to content

WP GitHub Updater v1.3.1

Latest

Choose a tag to compare

@github-actions github-actions released this 02 Mar 17:50
· 3 commits to main since this release

What's New in v1.3.1

Fixed

  • Multi-Plugin Asset URL Resolution: Fixed getPackageAssetUrl() method to correctly resolve asset URLs when multiple plugins use the package simultaneously. Previously, PHP's autoloader would load the Updater class from the first registered vendor directory, causing __DIR__ to always resolve to that location and resulting in 404 errors for JavaScript assets in other plugins.
  • Plugin-Specific Path Resolution: Changed to use $this->config->pluginFile-based resolution instead of __DIR__, ensuring each plugin instance loads assets from its own vendor directory.
  • Fallback Support: Maintained backward compatibility with __DIR__-based fallback for non-standard installations or development environments.

Added

  • Comprehensive Multi-Plugin Tests: Added three new unit tests specifically for multi-plugin scenarios:
    • testGetPackageAssetUrlWithStandardVendorStructure() - Tests standard Composer vendor structure
    • testGetPackageAssetUrlFallbackForNonStandardInstallation() - Tests fallback behavior
    • testGetPackageAssetUrlWithMultiplePlugins() - Tests simultaneous multi-plugin usage

Technical Details

The bug occurred because:

  1. PHP's autoloader loads classes from the first registered vendor directory
  2. __DIR__ in a shared class always points to that first location
  3. Multiple plugin instances would all resolve to the same (incorrect) asset path
  4. This caused 404 errors and "wpGithubUpdaterCheckUpdates is not defined" JavaScript errors

The fix:

  1. Uses $this->config->pluginFile which is unique per plugin instance
  2. Constructs the standard vendor path: vendor/silverassist/wp-github-updater
  3. Verifies the path exists before using it
  4. Falls back to __DIR__-based resolution for non-standard setups

📦 Package Information

  • Package Name: wp-github-updater
  • Version: 1.3.1
  • Namespace: SilverAssist\WpGithubUpdater
  • License: PolyForm Noncommercial 1.0.0
  • PHP Version: 8.2+
  • WordPress Version: 6.0+

🚀 Installation via Composer

composer require silverassist/wp-github-updater:^1.3.1

📋 Basic Usage

use SilverAssist\WpGithubUpdater\UpdaterConfig;
use SilverAssist\WpGithubUpdater\Updater;

// Configure the updater
$config = new UpdaterConfig(__FILE__, 'owner/repository', [
    'text_domain' => 'my-plugin-textdomain',
]);

// Initialize the updater
$updater = new Updater($config);

// Built-in update check button (v1.3.0+)
echo '<button onclick="' . $updater->enqueueCheckUpdatesScript() . '">Check Updates</button>';

✨ Key Features

  • 🔄 Automatic WordPress plugin updates from GitHub releases
  • � Built-in "Check Updates" JavaScript with admin notices (v1.3.0+)
  • �🌍 Configurable internationalization (i18n) support
  • 📋 WordPress admin integration with update notifications
  • 🔒 Secure GitHub API communication with proper error handling
  • ⚡ Efficient caching system for version checks
  • 🧪 Comprehensive PHPUnit test suite
  • 📝 PSR-12 + WordPress coding standards compliance
  • 🎯 Modern PHP 8+ architecture with strict typing

📚 Documentation

🔧 Requirements

  • PHP 8.2 or higher
  • WordPress 6.0 or higher
  • Composer for package management
  • GitHub repository with releases for updates

🐛 Issues & Support

Found a bug or need help? Please open an issue on GitHub.