Improve wp acorn compability

This commit is contained in:
Jan-Niclas Loosen
2026-06-29 19:54:12 +02:00
parent 7f3fd36186
commit 102abe7927
28 changed files with 4090 additions and 1980 deletions
+22 -25
View File
@@ -1,42 +1,39 @@
<?php
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken;
use Illuminate\Support\Facades\Blade;
use AcornPlugin\Acorn\BootCoordinator;
use AcornPlugin\Acorn\LivewireAssets;
use Roots\Acorn\Application;
include_once 'vendor/autoload.php';
include_once __DIR__ . '/vendor/autoload.php';
// Plugin requires WP Acorn
if (! class_exists( Application::class)) {
if (! class_exists(Application::class)) {
wp_die(
__('You need to install Acorn to use this site.', 'domain'),
esc_html__('You need to install Acorn to use this site.', 'acorn-starter'),
'',
[
'link_url' => 'https://roots.io/acorn/docs/installation/',
'link_text' => __('Acorn Docs: Installation', 'domain'),
'link_url' => 'https://roots.io/acorn/docs/installation/',
'link_text' => esc_html__('Acorn Docs: Installation', 'acorn-starter'),
]
);
}
add_action('after_setup_theme', function () {
$coordinator = new BootCoordinator();
// Another Acorn plugin already booted the framework this request. Our
// provider is auto-discovered (composer.json extra.acorn.providers), so
// there is nothing left to do.
if (! $coordinator->shouldBoot()) {
return;
}
Application::configure()
->withProviders([
])
->withMiddleware(function (Middleware $middleware) {
})
->withRouting(wordpress: true)
->withRouting(wordpress: true)
->boot();
$coordinator->markBooted();
// Livewire assets are a global concern — emit once, from the elected owner.
LivewireAssets::registerOnce();
}, 0);
// Insert code injection to the document head
add_action('wp_head', function () {
echo view('injections.head')->render();
});
// Insert code injection to the document footer
add_action('wp_footer', function () {
echo view('injections.footer')->render();
});