-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.php
47 lines (37 loc) · 1.01 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Plugin Name: Kensaku
* Author: Guido Scialfa
* Description: The WordPress plugin to develop the Kensaku entities search library.
* Author URI: https://guidoscialfa.com/
*/
declare(strict_types=1);
namespace SpaghettiDojo\Kensaku;
use Inpsyde\Modularity;
use SpaghettiDojo\Kensaku;
function package(): Modularity\Package
{
/** @var Modularity\Package|null $package */
static $package = null;
$projectRoot = __DIR__;
function autoload(string $projectRoot): void
{
$autoloadFile = "{$projectRoot}/vendor/autoload.php";
if (!\is_readable($autoloadFile)) {
return;
}
/** @psalm-suppress UnresolvableInclude */
require_once $autoloadFile;
}
if (!$package) {
autoload($projectRoot);
$package = Kensaku\Library::new(\plugin_dir_url(__FILE__))->package();
}
return $package;
}
\add_action(
'plugins_loaded',
fn() => package()
->addModule(Kensaku\Modules\E2e\Module::new())
->boot()
);