Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ is pre-1.0 and under active development.

## [Unreleased]

### Fixed
- **Activation fatal error when installed without Composer's `vendor/`:** the
bootstrap only loaded classes via `vendor/autoload.php`, so a distributed zip
that shipped without a `vendor/` directory fataled on activation with
`Uncaught Error: Class "AssetDrips\Db\Schema" not found`. The plugin now falls
back to a minimal built-in PSR-4 autoloader (it has no third-party runtime
dependencies), making it self-contained regardless of how it is packaged.

## [1.0.0] - 2026-06-19

First public release of AssetDrips as an open-source (GPL-2.0-or-later) WordPress
Expand Down
22 changes: 21 additions & 1 deletion assetdrips.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,30 @@
define( 'ASSETDRIPS_DIR', plugin_dir_path( __FILE__ ) );
define( 'ASSETDRIPS_URL', plugin_dir_url( __FILE__ ) );

// Composer autoloader. Required for the PSR-4 AssetDrips\ namespace.
// Load the PSR-4 AssetDrips\ namespace. Prefer Composer's autoloader when a
// vendor/ directory is present (dev checkouts, or a build that bundles it); fall
// back to a minimal self-contained autoloader otherwise. The plugin has no
// third-party runtime dependencies, so mapping AssetDrips\ -> src/ is all that
// is needed for a distributed zip that ships without vendor/. Without this
// fallback, activation fataled with "Class AssetDrips\Db\Schema not found".
$assetdrips_autoload = __DIR__ . '/vendor/autoload.php';
if ( is_readable( $assetdrips_autoload ) ) {
require $assetdrips_autoload;
} else {
spl_autoload_register(
static function ( string $class ): void {
$prefix = 'AssetDrips\\';
$len = strlen( $prefix );
if ( strncmp( $class, $prefix, $len ) !== 0 ) {
return;
}
$relative = str_replace( '\\', '/', substr( $class, $len ) );
$file = __DIR__ . '/src/' . $relative . '.php';
if ( is_readable( $file ) ) {
require $file;
}
}
);
}

/**
Expand Down
Loading