-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
abp01-plugin-header.php
469 lines (415 loc) · 12.5 KB
/
abp01-plugin-header.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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<?php
/**
* Copyright (c) 2014-2024 Alexandru Boia and Contributors
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* The WP Trip Summary plug-in header defines all the required constants
*
* @package WP-Trip-Summary
*/
defined('ABSPATH') or die;
/**
* Marker constant for establihing that
* WP Trip Summary core has been loaded.
* All other files must check for the existence
* of this constant and die if it's not present.
*
* @var boolean
*/
define('ABP01_LOADED', true);
/**
* The absolute path to the plug-in's installation directory.
* Eg. /whatever/public_html/wp-content/plugins/wp-trip-summary.
*
* @var string
*/
define('ABP01_PLUGIN_ROOT', __DIR__);
/**
* The absolute path to this file - the plug-in header file
*
* @var string
*/
define('ABP01_PLUGIN_HEADER', __FILE__);
/**
* The absolute path to the main plug-in file - abp01-plugin-main.php
*
* @var string
*/
define('ABP01_PLUGIN_MAIN', ABP01_PLUGIN_ROOT . '/abp01-plugin-main.php');
/**
* The absolute path to the plug-in's functions file - abp01-plugin-functions.php
*
* @var string
*/
define('ABP01_PLUGIN_FUNCTIONS', ABP01_PLUGIN_ROOT . '/abp01-plugin-functions.php');
/**
* The name of the directory in which the plug-in is installed.
* Eg. wp-trip-summary.
*
* @var string
*/
define('ABP01_PLUGIN_ROOT_NAME', basename(ABP01_PLUGIN_ROOT));
/**
* The absolute path to the plug-in's library - lib - directory.
* This is where all the PHP dependencies are stored.
* Eg. /whatever/public_html/wp-content/plugins/wp-trip-summary/lib.
*
* @var string
*/
define('ABP01_LIB_DIR', ABP01_PLUGIN_ROOT . '/lib');
/**
* Absolute path to the composer "vendor" directory
*
* @var string
*/
define('ABP01_VENDOR_DIR', ABP01_PLUGIN_ROOT . '/vendor');
/**
* The absolute path to the plug-in's library - lag - directory.
* This is where all the translation files (.po, .mo, .pot) are stored.
* Eg. /whatever/public_html/wp-content/plugins/wp-trip-summary/lang.
*
* @var string
*/
define('ABP01_LANG_DIR', ABP01_PLUGIN_ROOT . '/lang');
/**
* The current version of WP-Trip-Summary.
* Eg. 0.2.5.
*
* @var string
*/
define('ABP01_VERSION', '0.3.2');
if (!defined('ABP01_MAX_EXECUTION_TIME_MINUTES')) {
/**
* The maximum time to which the execution time limit can be raised when required.
* For instance, when uploading and processing a track.
* Defaults to 10 minutes.
*
* @var int
*/
define('ABP01_MAX_EXECUTION_TIME_MINUTES', 10);
}
if (!defined('ABP01_DISABLE_MINIFIED')) {
/**
* Whether or not to disabled script and style minification.
* This is not yet used.
* Defaults to false.
*
* @var boolean
*/
define('ABP01_DISABLE_MINIFIED', false);
}
/**
* The action name used with admin-ajax.php when saving trip summary information
* (data on the Info tab).
*
* @var string
*/
define('ABP01_ACTION_EDIT', 'abp01_edit_info');
/**
* The action name used with admin-ajax.php when removing trip summary information
* (data on the Info tab).
*
* @var string
*/
define('ABP01_ACTION_CLEAR_INFO', 'abp01_clear_info');
/**
* The action name used with admin-ajax.php when removing the trip summary track
* (data on the Map tab).
*
* @var string
*/
define('ABP01_ACTION_CLEAR_TRACK', 'abp01_clear_track');
/**
* The action name used with admin-ajax.php when uploading the trip summary track
* (data on the Map tab).
*
* @var string
*/
define('ABP01_ACTION_UPLOAD_TRACK', 'abp01_upload_track');
/**
* The action name used with admin-ajax.php when retrieving
* the trip summary track json data.
*
* @var string
*/
define('ABP01_ACTION_GET_TRACK', 'abp01_get_track');
/**
* The action name used with admin-ajax.php when saving plug-in settings.
*
* @var string
*/
define('ABP01_ACTION_SAVE_SETTINGS', 'abp01_save_settings');
/**
* The action name used with admin-ajax.php when executing maintenance tools.
*
* @var string
*/
define('ABP01_ACTION_EXEC_MAINTENANCE_TOOL', 'abp01_exec_maintenance_tool');
/**
* The action name used with admin-ajax.php when reading log file contents.
*
* @var string
*/
define('ABP01_ACTION_GET_LOG_FILE_CONTENTS', 'abp01_get_log_file_contents');
/**
* The action name used with admin-ajax.php when downloading log files.
*
* @var string
*/
define('ABP01_ACTION_DOWNLOAD_LOG_FILE', 'abp01_download_log_file');
/**
* The action name used with admin-ajax.php when deleting log files.
*
* @var string
*/
define('ABP01_ACTION_DELETE_LOG_FILE', 'abp01_delete_log_file');
/**
* The action name used with admin-ajax.php when downloading the GPS track.
*
* @var string
*/
define('ABP01_ACTION_DOWNLOAD_TRACK', 'abp01_download_track');
/**
* The action name used with admin-ajax.php when retrieving
* the list of lookup data items.
*
* @var string
*/
define('ABP01_ACTION_GET_LOOKUP', 'abp01_get_lookup');
/**
* The action name used with admin-ajax.php when removing a lookup data item.
*
* @var string
*/
define('ABP01_ACTION_DELETE_LOOKUP', 'abp01_delete_lookup');
/**
* The action name used with admin-ajax.php when creating a new a lookup data item.
*
* @var string
*/
define('ABP01_ACTION_ADD_LOOKUP', 'abp01_add_lookup');
/**
* The action name used with admin-ajax.php when editing an existing a lookup data item.
*
* @var string
*/
define('ABP01_ACTION_EDIT_LOOKUP', 'abp01_edit_lookup');
/**
* The action name used with admin-ajax.php when retrieving help contents for a given locale
*
* @var string
*/
define('ABP01_ACTION_GET_HELP_FOR_LOCALE', 'abp01_get_help_for_locale');
/**
* The action name used with admin-ajax.php when retrieving audit log contents for a given post
*
* @var string
*/
define('ABP01_ACTION_GET_AUDIT_LOG_FOR_POST', 'abp01_get_audit_log_for_post');
/**
* The action name used with admin-ajax.php when saving route log entry for a given post
*
* @var string
*/
define('ABP01_ACTION_SAVE_ROUTE_LOG_ENTRY_FOR_POST', 'abp01_save_route_log_entry_for_post');
/**
* The action name used with admin-ajax.php when deleting a single route log entry for a given post
*
* @var string
*/
define('ABP01_ACTION_DELETE_ROUTE_LOG_ENTRY_FOR_POST', 'abp01_delete_route_log_entry_for_post');
/**
* The action name used with admin-ajax.php when deleting all route log entries for a given post
*
* @var string
*/
define('ABP01_ACTION_DELETE_ALL_ROUTE_LOG_ENTRIES_FOR_POST', 'abp01_delete_all_route_log_entrie_for_post');
/**
* The action name used with admin-ajax.php when fetching a log entry's data from the admin panel
*
* @var string
*/
define('ABP01_ACTION_GET_ADMIN_LOG_ENTRY_FOR_POST', 'abp01_get_admin_log_entry_for_post');
/**
* The name of the file upload file that,
* albeit hidden from view, is used to
* upload the track file to the server
*
* @var string
*/
define('ABP01_TRACK_UPLOAD_KEY', 'abp01_track_file');
if (!defined('ABP01_TRACK_UPLOAD_CHUNK_SIZE')) {
/**
* The chunk size is the maxim file chunk, expressed in bytes,
* that can be uploaded in one sitting.
* If a file is larger than this size, it will be split in multiple chunks,
* which will be uploaded in sequence.
* Can be overridden in wp-config.php.
*
* @var int
*/
define('ABP01_TRACK_UPLOAD_CHUNK_SIZE', 102400);
}
if (!defined('ABP01_TRACK_UPLOAD_MAX_FILE_SIZE')) {
/**
* The maximum size, in bytes, the the plug-in allows for the track file.
* That is, track files larger than this are rejected.
* Defaults to 10485760 or wp_max_upload_size(), whichever is larger.
*
* @var int
*/
define('ABP01_TRACK_UPLOAD_MAX_FILE_SIZE', max(wp_max_upload_size(), 10485760));
}
/**
* Slug used for main menu mentry, which corresponds to the plug-in settings page.
*
* @var string
*/
define('ABP01_MAIN_MENU_SLUG', 'abp01-trip-summary-settings');
/**
* Slug used for lookup data management page sub-menu mentry.
*
* @var string
*/
define('ABP01_LOOKUP_SUBMENU_SLUG', 'abp01-trip-summary-lookup');
/**
* Slug used for help page sub-menu mentry.
*
* @var string
*/
define('ABP01_HELP_SUBMENU_SLUG', 'abp01-trip-summary-help');
/**
* Slug used for about page sub-menu mentry.
*
* @var string
*/
define('ABP01_ABOUT_SUBMENU_SLUG', 'abp01-trip-summary-about');
/**
* Slug used for maintenance page sub-menu mentry.
*
* @var string
*/
define('ABP01_MAINTENANCE_SUBMENU_SLUG', 'abp01-trip-summary-maintenance');
/**
* Value used to signify a successful/OK/all-good situation.
*
* @var int
*/
define('ABP01_STATUS_OK', 0);
/**
* Value used to signify an error/danger/something missing situation.
*
* @var int
*/
define('ABP01_STATUS_ERR', 1);
/**
* Value used to signify a situation that could be better,
* but not is not quite an error, nor dangerous.
*
* @var int
*/
define('ABP01_STATUS_WARN', 2);
if (!defined('ABP01_POST_TRIP_SUMMARY_DATA_CACHE_EXPIRATION_SECONDS')) {
/**
* The number of seconds that trip summary data is cached.
* Defaults to 600 (10 minutes).
*
* @var int
*/
define('ABP01_POST_TRIP_SUMMARY_DATA_CACHE_EXPIRATION_SECONDS', 600);
}
/**
* The name of the global javascript variable used to
* store the Leaflet instance used by this plug-in.
*
* @var string
*/
define('ABP01_WRAPPED_LEAFLET_CONTEXT', 'abp01Leaflet');
if (!defined('ABP01_WRAPPED_SCRIPT_MAX_AGE')) {
/**
* The maximum age, in seconds, used to compute the HTTP cache headers
* when sending the contents of the wrapped leaflet plug-in scripts.
* Defauls to 31 days, in seconds: 44640.
*
* @var int
*/
define('ABP01_WRAPPED_SCRIPT_MAX_AGE', 31 * 24 * 60);
}
if (!defined('ABP01_WRAPPED_SCRIPT_MAX_MEMORY')) {
/**
* The memory limit thay may pe consumed by the leaflet plug-in script wrapper,
* abp01-plugin-leaflet-plugins-wrapper.php.
* Before running, the script wrapper attempts to set
* the memory limit to this value.
* Value may be expressed as integers (in which case they express bytes),
* or as shorthand values, as described here: https://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
* Defaults to '256M'.
*
* @var int|string
*/
define('ABP01_WRAPPED_SCRIPT_MAX_MEMORY', '256M');
}
if (!defined('ABP01_WRAPPED_SCRIPT_MAX_EXECUTION_TIME_MINUTES')) {
/**
* The maximum time to which the execution time limit for the leaflet plug-in script wrapper,
* abp01-plugin-leaflet-plugins-wrapper.php.
* Before running, the script wrapper attempts to set
* the execution time limit to this value.
* Defaults to 1 minute.
*
* @var int
*/
define('ABP01_WRAPPED_SCRIPT_MAX_EXECUTION_TIME_MINUTES', 1);
}
if (!defined('ABP01_VIEWER_SHORTCODE')) {
/**
* The shortcode used to include the viewer at any point in the blog post contents.
* Can be set in wp-config.php.
* Default is 'abp01_trip_summary_viewer'.
*
* @var string
*/
define('ABP01_VIEWER_SHORTCODE', 'abp01_trip_summary_viewer');
}
if (!defined('ABP01_TRIP_TYPE_STATS_SHORTCODE')) {
/**
* Default is 'abp01_trip_stats'
*
* @var string
*/
define('ABP01_TRIP_TYPE_STATS_SHORTCODE', 'abp01_trip_type_stats');
}
if (!defined('ABP01_TRIP_STATS_SHORTCODE')) {
/**
* Default is 'abp01_trip_stats'
*
* @var string
*/
define('ABP01_TRIP_STATS_SHORTCODE', 'abp01_trip_stats');
}