class-dependencies.php
7.09 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
<?php
namespace um;
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Ultimate Member Dependency Checker
*
* Checks if Ultimate Member plugin is enabled
*/
if ( ! class_exists( 'um\Dependencies' ) ) {
/**
* Class Dependencies
*
* @package um
*/
class Dependencies {
/**
* @var
*/
private static $active_plugins;
/**
* For backward compatibility checking
*
* @var array
*/
public $ext_required_version = array(
'bbpress' => '2.0.7',
'followers' => '2.1.6',
'forumwp' => '2.0.4',
'friends' => '2.1.4',
'frontend-posting' => '1.0.0',
'google-authenticator' => '1.0.0',
'groups' => '2.1.7',
'instagram' => '2.0.5',
'jobboardwp' => '1.0.0',
'mailchimp' => '2.2.0',
'messaging' => '2.2.5',
'mycred' => '2.1.6',
'notices' => '2.0.5',
'notifications' => '2.1.3',
'online' => '2.1.1',
'private-content' => '2.0.5',
'profile-completeness' => '2.1.2',
'profile-tabs' => '1.0.0',
'recaptcha' => '2.1.2',
'reviews' => '2.1.5',
'social-activity' => '2.2.0',
'social-login' => '2.2.0',
'terms-conditions' => '2.1.1',
'unsplash' => '2.0.2',
'user-bookmarks' => '2.0.2',
'user-locations' => '1.0.0',
'user-notes' => '1.0.0',
'user-photos' => '2.0.4',
'user-tags' => '2.1.0',
'verified-users' => '2.0.5',
'woocommerce' => '2.1.9',
/*????*/
'restrict-content' => '2.0',
/*alpha*/
'user-exporter' => '1.0.0',
/*in development*/
'filesharing' => '1.0.0',
'beaver-builder' => '2.0',
'user-events' => '1.0.0',
);
/**
* Get all active plugins
*/
public static function init() {
self::$active_plugins = (array) get_option( 'active_plugins', array() );
if ( is_multisite() )
self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
}
/**
* @return mixed
*/
public function get_active_plugins() {
if ( ! self::$active_plugins ) self::init();
return self::$active_plugins;
}
/**
* Check if UltimateMember core plugin is active
*
* @return bool
*/
public static function ultimatemember_active_check() {
if ( ! self::$active_plugins ) self::init();
return in_array( 'ultimate-member/ultimate-member.php', self::$active_plugins ) || array_key_exists( 'ultimate-member/ultimate-member.php', self::$active_plugins );
}
/**
* Check if bbPress plugin is active
*
* @return bool
*/
public static function bbpress_active_check() {
if ( ! self::$active_plugins ) self::init();
return in_array( 'bbpress/bbpress.php', self::$active_plugins ) || array_key_exists( 'bbpress/bbpress.php', self::$active_plugins );
}
/**
* Check if ForumWP plugin is active
*
* @return bool
*/
public static function forumwp_active_check() {
if ( ! self::$active_plugins ) self::init();
return in_array( 'forumwp/forumwp.php', self::$active_plugins ) || array_key_exists( 'forumwp/forumwp.php', self::$active_plugins );
}
/**
* Check if JobBoardWP plugin is active
*
* @return bool
*/
public static function jobboardwp_active_check() {
if ( ! self::$active_plugins ) self::init();
return in_array( 'jobboardwp/jobboardwp.php', self::$active_plugins ) || array_key_exists( 'jobboardwp/jobboardwp.php', self::$active_plugins );
}
/**
* Check if myCRED plugin is active
*
* @return bool
*/
public static function mycred_active_check() {
if ( ! self::$active_plugins ) self::init();
return in_array( 'mycred/mycred.php', self::$active_plugins ) || array_key_exists( 'mycred/mycred.php', self::$active_plugins );
}
/**
* Check if Woocommerce plugin is active
*
* @return bool
*/
public static function woocommerce_active_check() {
if ( ! self::$active_plugins ) self::init();
return in_array( 'woocommerce/woocommerce.php', self::$active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', self::$active_plugins );
}
/**
* Compare UM core and extension versions
*
* @param string $um_required_ver
* @param string $ext_ver
* @param string $ext_key
* @param string $ext_title
* @return bool
*/
public function compare_versions( $um_required_ver, $ext_ver, $ext_key, $ext_title ) {
if ( version_compare( ultimatemember_version, $um_required_ver, '<' )
|| empty( $this->ext_required_version[$ext_key] )
|| version_compare( $this->ext_required_version[$ext_key], $ext_ver, '>' ) ) {
$message = '';
if ( version_compare( ultimatemember_version, $um_required_ver, '<' ) ) {
$message = sprintf( __( 'This version of <strong>"%s"</strong> requires the core <strong>%s</strong> plugin to be <strong>%s</strong> or higher.', 'ultimate-member' ), $ext_title, ultimatemember_plugin_name, $um_required_ver ) .
'<br />' .
sprintf( __( 'Please update <strong>%s</strong> to the latest version.', 'ultimate-member' ), ultimatemember_plugin_name );
} elseif ( empty( $this->ext_required_version[$ext_key] ) || version_compare( $this->ext_required_version[$ext_key], $ext_ver, '>' ) ) {
$message = sprintf( __( 'Sorry, but this version of <strong>%s</strong> does not work with extension <strong>"%s" %s</strong> version.', 'ultimate-member' ), ultimatemember_plugin_name, $ext_title, $ext_ver ) .
'<br />' .
sprintf( __( 'Please update extension <strong>"%s"</strong> to the latest version.', 'ultimate-member' ), $ext_title );
}
return $message;
} else {
//check correct folder name for extensions
if ( ! self::$active_plugins ) self::init();
if ( ! in_array( "um-{$ext_key}/um-{$ext_key}.php", self::$active_plugins ) && ! array_key_exists( "um-{$ext_key}/um-{$ext_key}.php", self::$active_plugins ) ) {
$message = sprintf( __( 'Please check <strong>"%s" %s</strong> extension\'s folder name.', 'ultimate-member' ), $ext_title, $ext_ver ) .
'<br />' .
sprintf( __( 'Correct folder name is <strong>"%s"</strong>', 'ultimate-member' ), "um-{$ext_key}" );
return $message;
}
}
return true;
}
/**
* @param string $extension_version Extension version
* @return mixed
*/
public static function php_version_check( $extension_version ) {
return version_compare( phpversion(), $extension_version, '>=' );
}
}
}
if ( ! function_exists( 'is_um_active' ) ) {
/**
* Check UltimateMember core is active
*
* @return bool active - true | inactive - false
*/
function is_um_active() {
return Dependencies::ultimatemember_active_check();
}
}