-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
291 lines (245 loc) · 6.37 KB
/
index.php
File metadata and controls
291 lines (245 loc) · 6.37 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?php
/**
* Plugin
*
* @package Plugin
* @version 1.0.0
* @link https://github.com/antibrand/plugin
*
* Plugin Name: plugin
* Plugin URI: https://github.com/antibrand/plugin
* Description: A basic starter plugin for your website management system.
* Version: 1.0.0
* Author:
* Author URI:
* Text Domain: antibrand
* Domain Path: /languages
* Tested up to:
*/
/**
* Renaming the plugin
*
* First change the name of this file to reflect the directory name of your plugin.
*
* Next change the information above in the plugin header, and either change
* the plugin name in the License & Warranty notice or remove it.
*
* Following is a list of strings to find and replace in all plugin files.
*
* 1. Plugin name & namespace
* Find `Plugin` and replace with your plugin name, include
* underscores between words. This will change the primary plugin class name
* and the package name in file headers.
*
* 2. Text domain
* Find antibrand and replace with the new name of your
* primary plugin file (this file).
*
* 3. Constants prefix
* Find `ABP` and replace with something unique to your plugin name. Use
* only uppercase letters.
*
* 4. General prefix
* Find `abp` and replace with something unique to your plugin name. Use
* only lowercase letters. This will change the prefix of all filters and
* settings, and the prefix of functions outside of a class.
*/
/**
* The core plugin class
*
* Defines constants, gets the initialization class file
* plus the activation and deactivation classes.
*
* @since 1.0.0
* @access public
*/
// First check for other classes with the same name.
if ( ! class_exists( 'Plugin' ) ) :
final class Plugin {
/**
* Instance of the class
*
* @since 1.0.0
* @access public
* @return object Returns the instance.
*/
public static function instance() {
// Varialbe for the instance to be used outside the class.
static $instance = null;
if ( is_null( $instance ) ) {
// Set variable for new instance.
$instance = new self;
// Define plugin constants.
$instance->constants();
// Require the core plugin class files.
$instance->dependencies();
}
// Return the instance.
return $instance;
}
/**
* Constructor method
*
* @since 1.0.0
* @access private
* @return self
*/
private function __construct() {}
/**
* Define plugin constants
*
* Change the prefix and the text domain to that
* which suits the needs of your website.
*
* Change the version as appropriate.
*
* @since 1.0.0
* @access private
* @return void
*/
private function constants() {
/**
* Plugin version
*
* Keeping the version at 1.0.0 as this is a starter plugin but
* you may want to start counting as you develop for your use case.
*
* @since 1.0.0
* @return string Returns the latest plugin version.
*/
if ( ! defined( 'ABP_VERSION' ) ) {
define( 'ABP_VERSION', '1.0.0' );
}
/**
* Text domain
*
* @since 1.0.0
* @return string Returns the text domain of the plugin.
*/
if ( ! defined( 'ABP_DOMAIN' ) ) {
define( 'ABP_DOMAIN', 'antibrand' );
}
/**
* Plugin directory path
*
* @since 1.0.0
* @return string Returns the filesystem directory path (with trailing slash)
* for the plugin __FILE__ passed in.
*/
if ( ! defined( 'ABP_PATH' ) ) {
define( 'ABP_PATH', plugin_dir_path( __FILE__ ) );
}
/**
* Plugin directory URL
*
* @since 1.0.0
* @return string Returns the URL directory path (with trailing slash)
* for the plugin __FILE__ passed in.
*/
if ( ! defined( 'ABP_URL' ) ) {
define( 'ABP_URL', plugin_dir_url( __FILE__ ) );
}
/**
* Universal slug
*
* This URL slug is used for various plugin admin & settings pages.
*
* The prefix will change in your search & replace in renaming the plugin.
* Change the second part of the define(), here as 'antibrand',
* to your preferred page slug.
*
* @since 1.0.0
* @return string Returns the URL slug of the admin pages.
*/
if ( ! defined( 'ABP_ADMIN_SLUG' ) ) {
define( 'ABP_ADMIN_SLUG', 'antibrand' );
}
}
/**
* Throw error on object clone.
*
* @since 1.0.0
* @access public
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __( 'This is not allowed.', 'antibrand' ), '1.0.0' );
}
/**
* Disable unserializing of the class.
*
* @since 1.0.0
* @access public
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __( 'This is not allowed.', 'antibrand' ), '1.0.0' );
}
/**
* Require the core plugin class files
*
* @since 1.0.0
* @access private
* @return void Gets the file which contains the plugin initiation class.
*/
private function dependencies() {
// The hub of all other dependency files.
require_once ABP_PATH . 'includes/class-init.php';
// Include the activation class.
require_once ABP_PATH . 'includes/class-activate.php';
// Include the deactivation class.
require_once ABP_PATH . 'includes/class-deactivate.php';
}
}
// End core plugin class.
/**
* Put an instance of the plugin class into a function
*
* @since 1.0.0
* @access public
* @return object Returns the instance of the `Plugin` class.
*/
function abp_plugin() {
return Plugin::instance();
}
// Begin plugin functionality.
abp_plugin();
// End the check for the plugin class.
endif;
// Bail out now if the core class was not run.
if ( ! function_exists( 'abp_plugin' ) ) {
return;
}
/**
* Register the activaction & deactivation hooks.
*
* @since 1.0.0
* @access public
* @return void
*/
register_activation_hook( __FILE__, '\abp_activate_plugin' );
register_deactivation_hook( __FILE__, '\abp_deactivate_plugin' );
/**
* The code that runs during plugin activation.
*
* @since 1.0.0
* @access public
* @return void
*/
function abp_activate_plugin() {
// Run the activation class.
abp_activate();
}
/**
* The code that runs during plugin deactivation.
*
* @since 1.0.0
* @access public
* @return void
*/
function abp_deactivate_plugin() {
// Run the deactivation class.
abp_deactivate();
}