Improve wp acorn compability
This commit is contained in:
+22
-25
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user