PluginProbe
Import Export Menu / trunk
Import Export Menu vtrunk
trunk 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 2.0.1 2.0.2 2.0.3 3.0.0
import-export-menu / includes / Plugin.php

Plugin.php in Import Export Menu trunk, at includes/Plugin.php

90 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main plugin bootstrap class.
4 *
5 * @link https://yukyhendiawan.com
6 * @since 2.1.0
7 *
8 * @package Import_Export_Menu
9 */
10
11 declare(strict_types=1);
12
13 namespace ImportExportMenu;
14
15 use ImportExportMenu\Admin\Controller as AdminController;
16 use ImportExportMenu\Frontend\Controller as FrontendController;
17 use ImportExportMenu\Modules\Conditional\ConditionalModule;
18 use ImportExportMenu\Modules\Export\ExportModule;
19 use ImportExportMenu\Modules\Import\ImportModule;
20 use ImportExportMenu\Modules\Menus\MenusModule;
21 use ImportExportMenu\Modules\ModuleInterface;
22 use ImportExportMenu\Modules\ModuleLoader;
23 use ImportExportMenu\Options\Framework as OptionsFramework;
24 use ImportExportMenu\Options\Settings as OptionsSettings;
25
26 defined( 'ABSPATH' ) || exit;
27
28 /**
29 * Wires the plugin's components together and lets each one register its own hooks.
30 *
31 * @since 2.1.0
32 */
33 final class Plugin {
34
35 /**
36 * Plugin handle used as i18n text-domain and asset handle prefix.
37 *
38 * @var string
39 */
40 private $name;
41
42 /**
43 * Plugin version, propagated to assets for cache busting.
44 *
45 * @var string
46 */
47 private $version;
48
49 /**
50 * Capture plugin metadata used by all components.
51 *
52 * @param string $name Plugin handle.
53 * @param string $version Plugin version.
54 */
55 public function __construct( string $name, string $version ) {
56 $this->name = $name;
57 $this->version = $version;
58 }
59
60 /**
61 * Instantiate components and let each one register its own hooks.
62 */
63 public function run(): void {
64 ( new I18n() )->register_hooks();
65
66 ( new AdminController() )->register_hooks();
67 ( new FrontendController( $this->name, $this->version ) )->register_hooks();
68
69 OptionsFramework::create( $this->name, $this->version )->register_hooks();
70 ( new OptionsSettings() )->register_hooks();
71
72 add_filter( 'import_export_menu_modules_register', array( $this, 'register_free_modules' ) );
73 ( new ModuleLoader() )->register_hooks();
74 }
75
76 /**
77 * Contribute the bundled Free feature modules to the loader.
78 *
79 * @param ModuleInterface[] $modules Modules collected so far.
80 * @return ModuleInterface[]
81 */
82 public function register_free_modules( array $modules ): array {
83 $modules[] = new MenusModule();
84 $modules[] = new ExportModule();
85 $modules[] = new ImportModule();
86 $modules[] = new ConditionalModule();
87 return $modules;
88 }
89 }
90