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 theUpdaterclass 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 structuretestGetPackageAssetUrlFallbackForNonStandardInstallation()- Tests fallback behaviortestGetPackageAssetUrlWithMultiplePlugins()- Tests simultaneous multi-plugin usage
Technical Details
The bug occurred because:
- PHP's autoloader loads classes from the first registered vendor directory
__DIR__in a shared class always points to that first location- Multiple plugin instances would all resolve to the same (incorrect) asset path
- This caused 404 errors and "wpGithubUpdaterCheckUpdates is not defined" JavaScript errors
The fix:
- Uses
$this->config->pluginFilewhich is unique per plugin instance - Constructs the standard vendor path:
vendor/silverassist/wp-github-updater - Verifies the path exists before using it
- 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
- README: Installation and usage guide
- CHANGELOG: Complete version history
- Examples: Integration examples
- API Docs: Comprehensive PHPDoc 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.