-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.php
74 lines (63 loc) · 2.29 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
<?php
/*
Plugin Name: Plugin Boilerplate
Plugin URI: https://github.com/unFocus/unfocus-plugin-boilerplates
Description: A Collection of Boilerplates and Libraries to take care of the annoying and mundaine tasks of WordPress Plugin development.
Author: unFocus Projects
Author URI: http://www.unfocus.com/
Version: 2012.07.23-17.37
License: GPLv2 or later
Text Domain: plugin-boilerplate
Network: false
*/
/* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
class Plugin_Boilerplate {
static $version;
static $file = __FILE__;
const OPTION = 'Plugin_Boilerplate';
function __construct() {
self::upgrade_check();
register_activation_hook( __FILE__, array( __CLASS__, 'activate' ) );
register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivate' ) );
register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
add_action( 'init', array( __CLASS__, 'init' ) );
}
function init() {
//Debug_Bar_Extender::instance()->trace_var( get_option( self::OPTION ) );
}
function upgrade_check() {
$data = get_file_data( __FILE__, array ( 'version' ) );
self::$version = $data[ 0 ];
$options = get_option( self::OPTION );
if ( ! isset( $options[ 'version' ] ) || version_compare( self::$version, $options[ 'version' ], '>' ) )
self::upgrade();
}
function upgrade() {
$options = get_option( self::OPTION );
if ( ! $options ) $options = array();
$options[ 'version' ] = self::$version;
update_option( self::OPTION, $options );
}
function activate() {
//self::loaded(); // call any methods that register CPTs
flush_rewrite_rules();
}
function deactivate() {
flush_rewrite_rules();
}
function uninstall() {
delete_option( self::OPTION );
self::deactivate();
}
}
new Plugin_Boilerplate();