-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-bp-beta-tester.php
157 lines (141 loc) · 3.04 KB
/
class-bp-beta-tester.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
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
/**
* A plugin to switch between stable, beta or RC versions of BuddyPress.
*
* @package bp-beta-tester
* @author The BuddyPress Community
* @license GPL-2.0+
* @link https://buddypress.org
*
* @wordpress-plugin
* Plugin Name: BP Beta Tester
* Plugin URI: https://github.com/buddypress/bp-beta-tester
* Description: A plugin to switch between stable, beta or RC versions of BuddyPress.
* Version: 1.3.0
* Author: The BuddyPress Community
* Author URI: https://buddypress.org
* Text Domain: bp-beta-tester
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages/
* Network: True
* GitHub Plugin URI: https://github.com/buddypress/bp-beta-tester
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* Main Class
*
* @since 1.0.0
*/
final class BP_Beta_Tester {
/**
* Instance of this class.
*
* @since 1.0.0
*
* @var object
*/
protected static $instance = null;
/**
* Used to store dynamic properties.
*
* @since 1.3.0
*
* @var array
*/
private $data = array();
/**
* Initialize the plugin
*
* @since 1.0.0
*/
private function __construct() {
$this->inc();
}
/**
* Magic method for checking the existence of a plugin global variable.
*
* @since 1.3.0
*
* @param string $key Key to check the set status for.
* @return bool
*/
public function __isset( $key ) {
return isset( $this->data[ $key ] );
}
/**
* Magic method for getting a plugin global variable.
*
* @since 1.3.0
*
* @param string $key Key to return the value for.
* @return mixed
*/
public function __get( $key ) {
$retval = null;
if ( isset( $this->data[ $key ] ) ) {
$retval = $this->data[ $key ];
}
return $retval;
}
/**
* Magic method for setting a plugin global variable.
*
* @since 1.3.0
*
* @param string $key Key to set a value for.
* @param mixed $value Value to set.
*/
public function __set( $key, $value ) {
$this->data[ $key ] = $value;
}
/**
* Magic method for unsetting a plugin global variable.
*
* @since 1.3.0
*
* @param string $key Key to unset a value for.
*/
public function __unset( $key ) {
if ( isset( $this->data[ $key ] ) ) {
unset( $this->data[ $key ] );
}
}
/**
* Return an instance of this class.
*
* @since 1.0.0
*/
public static function start() {
// If the single instance hasn't been set, set it now.
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Load needed files.
*
* @since 1.0.0
*/
private function inc() {
$inc_path = plugin_dir_path( __FILE__ ) . 'inc/';
require $inc_path . 'globals.php';
require $inc_path . 'functions.php';
}
}
/**
* Start plugin.
*
* @since 1.0.0
*
* @return BP_Beta_Tester The main instance of the plugin.
*/
function bp_beta_tester() {
if ( ! is_admin() ) {
return;
}
return BP_Beta_Tester::start();
}
add_action( 'plugins_loaded', 'bp_beta_tester', 8 );