From 5036bf6a9b5fe212b0f10c76cb410a240f003a23 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Mon, 31 Aug 2020 09:21:16 -0700 Subject: [PATCH] fix(autoload): register fallback autoload as needed (#255) x-ref #254 --- CHANGELOG.md | 3 +++ soil.php | 10 +++++++--- src/autoload.php | 13 +++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/autoload.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d568d0d..b7b5c0b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 4.0.1: August 31st, 2020 +* Add fallback autoloader when Composer isn't present + ### 4.0.0: August 29th, 2020 * BREAKING CHANGE - Refactor entire code base * Add options support for modules diff --git a/soil.php b/soil.php index e43b0883..5c404d71 100644 --- a/soil.php +++ b/soil.php @@ -4,7 +4,7 @@ * Plugin Name: Soil * Plugin URI: https://roots.io/plugins/soil/ * Description: A collection of modules to apply theme-agnostic front-end modifications to WordPress. - * Version: 4.0.0 + * Version: 4.0.1 * Author: Roots * Author URI: https://roots.io/ * GitHub Plugin URI: https://github.com/roots/soil @@ -15,9 +15,13 @@ namespace Roots\Soil; -require_once __DIR__ . '/vendor/autoload.php'; - add_action('plugins_loaded', function () { + if (!class_exists(Soil::class)) { + require_once file_exists($autoloader = __DIR__ . '/vendor/autoload.php') + ? $autoloader + : __DIR__ . '/src/autoload.php'; + } + $modules = Soil::discoverModules(); add_action('after_setup_theme', new Soil($modules), 100); diff --git a/src/autoload.php b/src/autoload.php new file mode 100644 index 00000000..12767a22 --- /dev/null +++ b/src/autoload.php @@ -0,0 +1,13 @@ +