1 | <?php declare(strict_types = 1); |
||
2 | |||
3 | /** |
||
4 | * WP Steak |
||
5 | * |
||
6 | * @package App |
||
7 | * |
||
8 | * Plugin Name: WP Steak |
||
9 | * Description: A fully structured plugin. |
||
10 | * Version: 3.0.1 |
||
11 | * Author: Apiki |
||
12 | * Author URI: https://apiki.com/ |
||
13 | * Text Domain: app |
||
14 | * Domain Path: /languages |
||
15 | * Requires PHP: 7.4 |
||
16 | */ |
||
17 | |||
18 | use Cedaro\WP\Plugin\Plugin; |
||
19 | use Cedaro\WP\Plugin\PluginFactory; |
||
20 | use League\Container\Container; |
||
21 | use League\Container\ReflectionContainer; |
||
22 | use Cedaro\WP\Plugin\Provider\I18n; |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
23 | use WPSteak\Providers\I18n as WPSteakI18n; |
||
24 | |||
25 | /** |
||
26 | * Retrieve the main plugin instance. |
||
27 | */ |
||
28 | function wpsteak(): Plugin { |
||
29 | static $instance; |
||
30 | |||
31 | if ( null === $instance ) { |
||
32 | $instance = PluginFactory::create( 'app' ); |
||
33 | } |
||
34 | |||
35 | return $instance; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Load and run the plugin. |
||
40 | */ |
||
41 | function wpsteak_load(): void { |
||
42 | if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
||
43 | require __DIR__ . '/vendor/autoload.php'; |
||
44 | } |
||
45 | |||
46 | $container = new Container(); |
||
47 | |||
48 | // Register the reflection container as a delegate to enable auto wiring. |
||
49 | $container->delegate( |
||
50 | ( new ReflectionContainer() )->cacheResolutions(), |
||
51 | ); |
||
52 | |||
53 | $plugin = wpsteak(); |
||
54 | |||
55 | $plugin->set_container( $container ); |
||
56 | $plugin->register_hooks( $container->get( I18n::class ) ); |
||
57 | $plugin->register_hooks( $container->get( WPSteakI18n::class ) ); |
||
58 | |||
59 | $config = ( require __DIR__ . '/config.php' ); |
||
60 | |||
61 | foreach ( $config['service_providers'] as $service_provider ) { |
||
62 | $container->addServiceProvider( $service_provider ); |
||
63 | } |
||
64 | |||
65 | foreach ( $config['hook_providers'] as $hook_provider ) { |
||
66 | $plugin->register_hooks( $container->get( $hook_provider ) ); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | add_action( 'plugins_loaded', 'wpsteak_load', 0, 0 ); |
||
71 |