-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconstants.php
More file actions
231 lines (184 loc) · 6.13 KB
/
constants.php
File metadata and controls
231 lines (184 loc) · 6.13 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
<?php
/*
* Plugin setup
*
* @author Ivijan-Stefan Stipic <creativform@gmail.com>
* @since 8.0.0
*/
if (!defined('WPINC')) {
die("Don't mess with us.");
}
if (!defined('ABSPATH')) {
exit;
}
// Find wp-admin file path
if (!defined('WP_ADMIN_DIR')) {
// Default wp-admin directory
$wp_admin_dir = ABSPATH . 'wp-admin';
// Verify if wp-admin exists
if (!is_dir($wp_admin_dir)) {
// Fallback if wp-admin is not found in the default location
$wp_admin_dir = dirname(WP_CONTENT_DIR) . '/wp-admin';
}
// Define the constant WP_ADMIN_DIR
define('WP_ADMIN_DIR', rtrim($wp_admin_dir, '/\\'));
}
// Enable or disable REST
if (!defined('CFGP_REST_ENABLED')) {
define('CFGP_REST_ENABLED', true);
}
// Main website
if (!defined('CFGP_STORE')) {
define('CFGP_STORE', 'https://wpgeocontroller.com');
}
// Main website code
if (!defined('CFGP_STORE_CODE')) {
define('CFGP_STORE_CODE', 'YR5pv3FU8l78v3N'); // DON'T TOUCH!!!
}
// Plugin root
if (!defined('CFGP_ROOT')) {
define('CFGP_ROOT', rtrim(plugin_dir_path(CFGP_FILE), DIRECTORY_SEPARATOR));
}
// Shell
if (!defined('CFGP_SHELL')) {
define('CFGP_SHELL', CFGP_ROOT . DIRECTORY_SEPARATOR . 'shell');
}
// Library
if (!defined('CFGP_LIBRARY')) {
define('CFGP_LIBRARY', CFGP_ROOT . DIRECTORY_SEPARATOR . 'library');
}
// Includes directory
if (!defined('CFGP_INC')) {
define('CFGP_INC', CFGP_ROOT . DIRECTORY_SEPARATOR . 'inc');
}
// Classes directory
if (!defined('CFGP_CLASS')) {
define('CFGP_CLASS', CFGP_INC . DIRECTORY_SEPARATOR . 'classes');
}
// Plugins directory
if (!defined('CFGP_PLUGINS')) {
define('CFGP_PLUGINS', CFGP_INC . DIRECTORY_SEPARATOR . 'plugins');
}
// Limit ( for the information purposes )
if (!defined('CFGP_LIMIT')) {
define('CFGP_LIMIT', 500);
}
// Developer license ( enable developer license support )
if (!defined('CFGP_DEV_MODE')) {
define('CFGP_DEV_MODE', false);
}
// Session expire in % minutes
if (!defined('CFGP_SESSION')) {
define('CFGP_SESSION', 60); // 30 minutes
}
// W3 total cache setup
if (!defined('W3TC_DYNAMIC_SECURITY')) {
define('W3TC_DYNAMIC_SECURITY', 'cfgeo_' . md5(get_bloginfo('url')));
}
// Disable email notifications
if (!defined('CFGP_DISABLE_NOTIFICATION')) {
define('CFGP_DISABLE_NOTIFICATION', true);
}
// Disable notification for the "License will expire soon"
if (!defined('CFGP_DISABLE_NOTIFICATION_EXPIRE_SOON')) {
define('CFGP_DISABLE_NOTIFICATION_EXPIRE_SOON', true);
}
// Disable notification for the "Lookup expired"
if (!defined('CFGP_DISABLE_NOTIFICATION_LOOKUP_EXPIRED')) {
define('CFGP_DISABLE_NOTIFICATION_LOOKUP_EXPIRED', true);
}
// Disable notification for the "Lookup expires soon"
if (!defined('CFGP_DISABLE_NOTIFICATION_LOOKUP_EXPIRE_SOON')) {
define('CFGP_DISABLE_NOTIFICATION_LOOKUP_EXPIRE_SOON', true);
}
// Plugin URL root
if (!defined('CFGP_URL')) {
define('CFGP_URL', rtrim(plugin_dir_url(CFGP_FILE), '/'));
}
// Assets URL
if (!defined('CFGP_ASSETS')) {
define('CFGP_ASSETS', CFGP_URL . '/assets');
}
// Plugin name
if (!defined('CFGP_NAME')) {
define('CFGP_NAME', 'cf-geoplugin');
}
// Allow deprecated methods (Enabled for some next few versions)
if (!defined('CFGP_ALLOW_DEPRECATED_METHODS')) {
define('CFGP_ALLOW_DEPRECATED_METHODS', true);
}
// Current plugin version ( if change, clear also session cache )
global $cfgp_version;
if (function_exists('get_file_data') && $plugin_data = get_file_data(CFGP_FILE, [
'Version' => 'Version',
], false)) {
$cfgp_version = (string)$plugin_data['Version'];
}
if (!$cfgp_version && preg_match('/\*[\s\t]+?version:[\s\t]+?([0-9.]+)/i', file_get_contents(CFGP_FILE), $v)) {
$cfgp_version = (string)$v[1];
}
if (!defined('CFGP_VERSION')) {
define('CFGP_VERSION', $cfgp_version);
}
// Plugin metabox prefix
if (!defined('CFGP_METABOX')) {
define('CFGP_METABOX', 'cf_geo_metabox_');
}
// Plugin session prefix (controlled by version)
if (!defined('CFGP_PREFIX')) {
define('CFGP_PREFIX', 'cf_geo_' . preg_replace('/[^0-9]/Ui', '', CFGP_VERSION) . '_');
}
// Timestamp
if (!defined('CFGP_TIME')) {
define('CFGP_TIME', time());
}
// Time Format
if (!defined('CFGP_TIME_FORMAT')) {
define('CFGP_TIME_FORMAT', get_option('time_format'));
}
// Date Format
if (!defined('CFGP_DATE_FORMAT')) {
define('CFGP_DATE_FORMAT', get_option('date_format'));
}
// Date Format
if (!defined('CFGP_DATE_TIME_FORMAT')) {
define('CFGP_DATE_TIME_FORMAT', CFGP_DATE_FORMAT . ' ' . CFGP_TIME_FORMAT);
}
// if PHP_VERSION missing
if (!defined('PHP_VERSION') && function_exists('phpversion')) {
define('PHP_VERSION', phpversion());
}
// PHP_VERSION_ID is available as of PHP 5.2.7, if our version is lower than that, then emulate it
if (!defined('PHP_VERSION_ID')) {
$php_version = explode('.', PHP_VERSION);
define('PHP_VERSION_ID', ($php_version[0] * 10000 + $php_version[1] * 100 + $php_version[2]));
$php_version = null;
}
// Fix missing PHP SESSION constant PHP_SESSION_NONE (this is bug on the some Nginx servers)
if (!defined('PHP_SESSION_NONE')) {
define('PHP_SESSION_NONE', -1);
}
// Check if is multisite installation
if (!defined('CFGP_MULTISITE') && defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE && defined('MULTISITE') && MULTISITE) {
define('CFGP_MULTISITE', WP_ALLOW_MULTISITE);
}
if (!defined('CFGP_MULTISITE')) {
// New safer approach
if (!function_exists('is_plugin_active_for_network')) {
include WP_ADMIN_DIR . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'plugin.php';
}
if (file_exists(WP_ADMIN_DIR . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'plugin.php')) {
define('CFGP_MULTISITE', (function_exists('is_plugin_active_for_network') ? is_plugin_active_for_network(CFGP_ROOT . DIRECTORY_SEPARATOR . 'cf-geoplugin.php') : false));
}
}
if (!defined('CFGP_MULTISITE')) {
define('CFGP_MULTISITE', false);
}
// Check is network admin
if (!defined('CFGP_NETWORK_ADMIN')) {
define('CFGP_NETWORK_ADMIN', (function_exists('is_network_admin') && is_network_admin()));
}
// Check is defender activated
if (!defined('CFGP_DEFENDER_ACTIVATED')) {
define('CFGP_DEFENDER_ACTIVATED', false); //- DEBUG
}