-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplugin.php
More file actions
157 lines (141 loc) · 3.17 KB
/
Copy pathplugin.php
File metadata and controls
157 lines (141 loc) · 3.17 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
namespace TheAminul\PageFlash;
use TheAminul\PageFlash\AssetsManager\AssetsManager;
use TheAminul\PageFlash\Admin\Admin;
use TheAminul\PageFlash\Landmark;
use TheAminul\PageFlash\Compatibility\Compatibility;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* PageFlash plugin.
*
* The main plugin handler class is responsible for initializing PageFlash. The
* class registers all the init_landmark required to run the plugin.
*
* @since PageFlash 1.0.0
*/
final class Plugin {
/**
* Instance
*
* @since PageFlash 1.0.0
* @access private
* @static
*
* @var Plugin The single instance of the class.
*/
private static $_instance = null;
/**
* Instance
*
* Ensures only one instance of the class is loaded or can be loaded.
*
* @since PageFlash 1.0.0
* @access public
*
* @return Plugin An instance of the class.
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Register autoload.
*
* PageFlash autoload loads all the classes needed to run the plugin.
*
* @since 1.6.0
* @access private
*/
private function register_autoload() {
if ( WP_DEBUG && PAGEFLASH_ENV === 'development' ) {
if ( ! file_exists( PAGEFLASH_PATH . 'vendor/autoload.php' ) ) {
require_once PAGEFLASH_PATH . 'autoload.php';
} else {
require_once PAGEFLASH_PATH . 'vendor/autoload.php';
}
} else {
require_once PAGEFLASH_PATH . 'autoload.php';
}
}
/**
* Initialize the assets manager.
*
* This method initializes the assets manager for your PageFlash plugin.
*
* @since PageFlash 1.0.0
* @access private
*/
private function init_assets() {
new AssetsManager();
}
/**
* Initialize admin Landmark.
*
* This method initializes the admin-related Landmark for your PageFlash plugin.
*
* @since PageFlash 1.0.0
* @access private
*/
private function init_admin() {
if ( is_admin() ) {
// Initialize your admin-related Landmark here
new Admin();
}
}
/**
* Init init_landmark.
*
* Initialize PageFlash init_landmark. Register actions, run setting manager,
* initialize all the init_landmark that run PageFlash, and if in the admin page,
* initialize admin init_landmark.
*
* @since PageFlash 1.0.0
* @access private
*/
private function init_landmark() {
new Landmark\Landmark();
}
/**
* Initialize compatibility modules.
*
* This method initializes compatibility handlers for third-party plugins.
*
* @since PageFlash 1.2.0
* @access private
*/
private function init_compatibility() {
new Compatibility();
}
/**
* Init.
*
* Initialize PageFlash Plugin. Register PageFlash support for all the
* supported post types and initialize PageFlash init_landmark.
*
* @since PageFlash 1.0.0
* @access private
*/
private function init() {
$this->register_autoload();
$this->init_assets();
$this->init_admin();
$this->init_landmark();
$this->init_compatibility();
}
/**
* Plugin class constructor
*
* @since PageFlash 1.0.0
* @access public
*/
public function __construct() {
// Init plugin.
$this->init();
}
}
// Instantiate Plugin Class
Plugin::instance();