forked from toxcox/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin-template_init.php
48 lines (38 loc) · 1.71 KB
/
plugin-template_init.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
<?php
/*
"WordPress Plugin Template" Copyright (C) 2011 Michael Simpson (email : [email protected])
This file is part of WordPress Plugin Template.
WordPress Plugin Template is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Contact Form to Database Extension.
If not, see <http://www.gnu.org/licenses/>.
*/
function PluginTemplate_init($file) {
require_once('PluginTemplate_Plugin.php');
$aPlugin = new PluginTemplate_Plugin();
// Install the plugin
// NOTE: this file gets run each time you *activate* the plugin.
// So in WP when you "install" the plugin, all that does it dump its files in the plugin-templates directory
// but it does not call any of its code.
// So here, the plugin tracks whether or not it has run its install operation, and we ensure it is run only once
// on the first activation
if (!$aPlugin->isInstalled()) {
$aPlugin->install();
}
else {
// Perform any version-upgrade activities prior to activation (e.g. database changes)
$aPlugin->upgrade();
}
// Add callbacks to hooks
$aPlugin->addActionsAndFilters();
if (!$file) {
$file = __FILE__;
}
// Register the Plugin Activation Hook
register_activation_hook($file, array(&$aPlugin, 'activate'));
// Register the Plugin Deactivation Hook
register_deactivation_hook($file, array(&$aPlugin, 'deactivate'));
}