-
Notifications
You must be signed in to change notification settings - Fork 13
/
Plugin.php
98 lines (85 loc) · 1.88 KB
/
Plugin.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* Primary plugin file.
*
* @package Genesis\CustomBlocks
* @copyright Copyright(c) 2020, Genesis Custom Blocks
* @license http://opensource.org/licenses/GPL-2.0 GNU General Public License, version 2 (GPL-2.0)
*/
namespace Genesis\CustomBlocks;
use Genesis\CustomBlocks\Admin\Admin;
use Genesis\CustomBlocks\Admin\Onboarding;
use Genesis\CustomBlocks\Blocks\Loader;
use Genesis\CustomBlocks\PostTypes\BlockPost;
/**
* Class Plugin
*/
class Plugin extends PluginAbstract {
/**
* Utility methods.
*
* @var Util
*/
protected $util;
/**
* The block post type.
*
* @var BlockPost
*/
public $block_post;
/**
* WP Admin resources.
*
* @var Admin\Admin
*/
public $admin;
/**
* Block loader.
*
* @var Blocks\Loader
*/
public $loader;
/**
* Execute this as early as possible.
*/
public function init() {
$this->util = new Util();
$this->register_component( $this->util );
$this->block_post = new BlockPost();
$this->register_component( $this->block_post );
$this->loader = new Loader();
$this->register_component( $this->loader );
register_activation_hook(
$this->get_file(),
function() {
$onboarding = new Onboarding();
$onboarding->plugin_activation();
}
);
}
/**
* Execute this once plugins are loaded. (not the best place for all hooks)
*/
public function plugin_loaded() {
$this->admin = new Admin();
$this->register_component( $this->admin );
$this->require_helpers();
}
/**
* Requires deprecated functions.
*
* On a later priority to give other plugins the chance to load the functions.
*/
public function require_deprecated() {
if ( ! function_exists( 'block_row' ) ) {
require_once __DIR__ . '/Deprecated.php';
}
}
/**
* Requires helper functions.
*/
private function require_helpers() {
require_once __DIR__ . '/Helpers.php';
require_once __DIR__ . '/BlockApi.php';
}
}