-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.php
55 lines (45 loc) · 1.59 KB
/
core.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 declare(strict_types=1);
/**
* Plugin Name: Tribe Storage
* Plugin URI: https://tri.be
* Description: Replace the WordPress filesystem with Flypress adapters. Allows the use of multiple cloud storage providers.
* Author: Modern Tribe
* Author URI: https://tri.be
* Text Domain: tribe-storage
* Version: 2.5.5
* Requires at least: 5.6
* Requires PHP: 7.3
*/
use DI\ContainerBuilder;
use Tribe\Storage\Core;
use Tribe\Storage\Plugin\Plugin_Loader;
// Require the vendor folder via multiple locations
$autoloaders = (array) apply_filters( 'tribe/storage/autoloaders', [
trailingslashit( WP_CONTENT_DIR ) . '../vendor/autoload.php',
trailingslashit( WP_CONTENT_DIR ) . 'vendor/autoload.php',
trailingslashit( __DIR__ ) . 'vendor/autoload.php',
] );
$autoload = current( array_filter( $autoloaders, 'file_exists' ) );
require_once $autoload;
// Start the core plugin
add_action( 'plugins_loaded', static function (): void {
tribe_storage()->init();
}, 1, 0 );
/**
* Shorthand to get the instance of our main core plugin class.
*
* @return mixed
*
* @throws \Exception
*/
function tribe_storage(): Core {
$builder = new ContainerBuilder();
$plugin_loader = Plugin_Loader::get_instance();
// Load plugin container definitions
foreach ( $plugin_loader->definition_providers() as $definition_provider ) {
$builder->addDefinitions( $definition_provider->get_definitions() );
}
$builder->addDefinitions( __DIR__ . '/config.php' );
$container = $builder->build();
return Core::instance( $container, $plugin_loader );
}