forked from milsdev/wordpress-plugin-sarcofag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
41 lines (32 loc) · 1.24 KB
/
index.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
<?php
/*
Plugin Name: Sarcofag
Plugin URI: http://milsdev.com/#portfolio
Description: OOP wrapper for the WordPress
Version: 0.0-alpha
Author: Mil's
Author URI: http://milsdev.com/
*/
$loader = include ABSPATH . '/vendor/autoload.php';
$loader->setPsr4('Sarcofag\\', [ __DIR__ . '/src' ]);
$containerBuilder = new DI\ContainerBuilder();
$containerBuilder->addDefinitions(__DIR__ . '/config/di.inc.php');
$activePlugins = get_option('active_plugins');
foreach ($activePlugins as $activePlugin) {
$pluginDiConfig = WP_PLUGIN_DIR . '/' . trim(dirname($activePlugin), '/') . '/config/di.inc.php';
if (!file_exists($pluginDiConfig)) continue;
$containerBuilder->addDefinitions(require $pluginDiConfig);
}
if (file_exists(get_template_directory() . '/src/config/di.inc.php')) {
$containerBuilder->addDefinitions(require get_template_directory() . '/src/config/di.inc.php');
}
$di = $containerBuilder->build();
foreach ($di->get('autoloader.paths') as $namespace => $autoloaderPaths) {
if (is_array($autoloaderPaths)) {
$autoloaderPaths = array_map('realpath', $autoloaderPaths);
} else {
$autoloaderPaths = [realpath($autoloaderPaths)];
}
$loader->setPsr4($namespace, $autoloaderPaths);
}
$di->get('EventManager');