-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbp-xprofile-custom-field-types.php
181 lines (155 loc) · 3.72 KB
/
bp-xprofile-custom-field-types.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/**
* BuddyPress Xprofile Custom Field Types
*
* @package BuddyPress Xprofile Custom Field Types
* @copyright Copyright (c) 2018, Brajesh Singh
* @license https://www.gnu.org/licenses/gpl.html GNU Public License
* @author Brajesh Singh
* @since 1.0.0
*/
/**
* Plugin Name: BuddyPress Xprofile Custom Field Types
* Plugin URI: https://buddydev.com/plugins/buddypress-xprofile-custom-field-types/
* Description: Have all the extra field types at your disposal.
* Version: 1.2.7
* Requires PHP: 5.3
* Author: BuddyDev
* Author URI: https://buddydev.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: bp-xprofile-custom-field-types
* Domain Path: /languages
*/
use BPXProfileCFTR\Bootstrap\Autoloader;
use BPXProfileCFTR\Bootstrap\Bootstrapper;
use BPXProfileCFTR\Core\Data_Store;
// Do not allow direct access over web.
defined( 'ABSPATH' ) || exit;
/**
* Class BP_Xprofile_CFTR
*
* @property-read string $path absolute path to the plugin directory.
* @property-read string $url absolute url to the plugin directory.
* @property-read string $basename plugin base name.
* @property-read string $version plugin version.
* @property-read Data_Store $data temporary data store.
*/
class BP_Xprofile_CFTR {
/**
* Plugin Version.
*
* @var string
*/
private $version = '1.2.7';
/**
* Class instance
*
* @var static
*/
private static $instance = null;
/**
* Plugins directory path
*
* @var string
*/
private $path;
/**
* Plugins directory url
*
* @var string
*/
private $url;
/**
* Plugin Basename.
*
* @var string
*/
private $basename;
/**
* Temporary data store object.
*
* @var Data_Store
*/
private $data = null;
/**
* Protected properties. These properties are inaccessible via magic method.
*
* @var array
*/
private static $protected = array( 'instance' );
/**
* Constructor.
*/
private function __construct() {
$this->bootstrap();
$this->setup();
}
/**
* Get class instance
*
* @return static
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Bootstrap the core.
*/
private function bootstrap() {
// Setup general properties.
$this->path = plugin_dir_path( __FILE__ );
$this->url = plugin_dir_url( __FILE__ );
$this->basename = plugin_basename( __FILE__ );
// Load autoloader.
require_once $this->path . 'src/bootstrap/class-autoloader.php';
// Register autoloader.
spl_autoload_register( new Autoloader( 'BPXProfileCFTR\\', __DIR__ . '/src/' ) );
register_activation_hook( __FILE__, array( $this, 'on_activation' ) );
register_deactivation_hook( __FILE__, array( $this, 'on_deactivation' ) );
}
/**
* Load plugin core files and assets.
*/
private function setup() {
$this->data = new Data_Store();
Bootstrapper::boot();
}
/**
* On activation create table
*/
public function on_activation() {
update_option( 'bpxcftr_notices', array() );
}
/**
* On deactivation create table
*/
public function on_deactivation() {
delete_option( 'bpxcftr_notices' );
}
/**
* Magic method for accessing property as readonly(It's a lie, references can be updated).
*
* @param string $name property name.
*
* @return mixed|null
*/
public function __get( $name ) {
if ( ! in_array( $name, self::$protected, true ) && property_exists( $this, $name ) ) {
return $this->{$name};
}
return null;
}
}
/**
* Return object of class
*
* @return BP_Xprofile_CFTR
*/
function bp_xprofile_cftr() {
return BP_Xprofile_CFTR::get_instance();
}
bp_xprofile_cftr();