-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkonomi.php
55 lines (42 loc) · 1.23 KB
/
konomi.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
48
49
50
51
52
53
54
55
<?php
/**
* Plugin Name: Konomi
* Author: Guido Scialfa
* Description: A WordPress plugin to save posts as favorite using the new Interactive API.
* Author URI: https://guidoscialfa.com/
*/
// phpcs:disable PSR1.Files.SideEffects
declare(strict_types=1);
namespace Widoz\Wp\Konomi;
use Inpsyde\Modularity;
function package(): Modularity\Package
{
/** @var Modularity\Package|null $package */
static $package = null;
$projectRoot = __DIR__;
// phpcs:disable Squiz.PHP.InnerFunctions.NotAllowed
function autoload(string $projectRoot): void
{
// phpcs:enable Squiz.PHP.InnerFunctions.NotAllowed
$autoloadFile = "{$projectRoot}/vendor/autoload.php";
if (!\is_readable($autoloadFile)) {
return;
}
/** @psalm-suppress UnresolvableInclude */
require_once $autoloadFile;
}
if (!$package) {
autoload($projectRoot);
$properties = Modularity\Properties\PluginProperties::new(__FILE__);
$package = Modularity\Package::new($properties);
}
return $package;
}
\add_action(
'plugins_loaded',
static function () {
$package = package();
$properties = $package->properties();
$package->boot();
}
);