forked from wp-plugins/all-in-one-event-calendar
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconstants.php
More file actions
525 lines (472 loc) · 14.6 KB
/
Copy pathconstants.php
File metadata and controls
525 lines (472 loc) · 14.6 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
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
<?php
use Osec\Command\ExportEvents;
/* phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols */
if (! defined('ABSPATH')) {
exit;
}
/**
* Define required constants, if these have not been defined already.
*
* @param string $osec_base_dir Sanitized, absolute, path to Osec base dir
*
* @return void Method does not return
* @uses plugins_url To determine absolute URI to plug-ins' folder
* @uses get_option To fetch 'home' URI value
*
* @uses plugin_basename To determine plug-in folder+file name
*/
function osec_initiate_constants($osec_base_dir, $osec_base_url)
{
// ===============
// = Plugin Path =
// ===============
if (! defined('OSEC_PATH')) {
define('OSEC_PATH', trailingslashit($osec_base_dir));
}
// ===============
// = Plugin Name =
// ===============
if (! defined('OSEC_PLUGIN_NAME')) {
define('OSEC_PLUGIN_NAME', 'open-source-event-calendar');
}
// ===============
// = Plugin Short Name =
// ===============
// if ( ! defined('OSEC_PLUGIN_SHORT_NAME')) {
// define('OSEC_PLUGIN_SHORT_NAME', 'osec');
// }
// ==================
// = Plugin Version =
// ==================
if (! defined('OSEC_VERSION')) {
define('OSEC_VERSION', '1.1.9');
}
// =================
// = Language Path =
// =================
if (! defined('OSEC_LANGUAGE_PATH')) {
define('OSEC_LANGUAGE_PATH', OSEC_PLUGIN_NAME . '/languages/');
}
// ==============
// = Plugin Url =
// ==============
if (! defined('OSEC_URL')) {
define('OSEC_URL', $osec_base_url);
}
// ===============
// = ADMIN PATH =
// ===============
if (! defined('OSEC_ADMIN_PATH')) {
define(
'OSEC_ADMIN_PATH',
OSEC_PATH . 'public/admin/'
);
}
// ===============
// = ADMIN URL =
// ===============
if (! defined('OSEC_ADMIN_URL')) {
define(
'OSEC_ADMIN_URL',
OSEC_URL . '/public/admin/'
);
}
// ======================
// = Default theme name =
// ======================
if (! defined('OSEC_DEFAULT_THEME_NAME')) {
define('OSEC_DEFAULT_THEME_NAME', 'plana');
}
// ======================
// = Root theme name =
// ======================
if (! defined('OSEC_ROOT_THEME_NAME')) {
define('OSEC_ROOT_THEME_NAME', 'vortex');
}
// ================
// = THEME FOLDER =
// ================
if (! defined('OSEC_THEME_FOLDER')) {
define('OSEC_THEME_FOLDER', 'osec_themes');
}
// =======================
// = DEFAULT THEME PATH =
// =======================
if (! defined('OSEC_DEFAULT_THEME_ROOT')) {
define(
'OSEC_DEFAULT_THEME_ROOT',
OSEC_PATH . 'public/' . OSEC_THEME_FOLDER
);
}
// =======================
// = DEFAULT THEME PATH =
// =======================
if (! defined('OSEC_DEFAULT_THEME_PATH')) {
define(
'OSEC_DEFAULT_THEME_PATH',
OSEC_DEFAULT_THEME_ROOT . '/' . OSEC_DEFAULT_THEME_NAME
);
}
// ==========================
// = DEFAULT fallback image =
// ==========================
if (! defined('OSEC_DEFAULT_IMAGE')) {
define(
'OSEC_DEFAULT_IMAGE',
OSEC_PATH . 'public/osec-fallback-image.png'
);
}
// ===================
// = Theme URL =
// ===================
if (! defined('OSEC_THEMES_URL')) {
define(
'OSEC_THEMES_URL',
OSEC_URL . '/public/' . OSEC_THEME_FOLDER
);
}
// =====================
// = Core themes =
// =====================
if (! defined('OSEC_CORE_THEMES')) {
define('OSEC_CORE_THEMES', 'vortex,umbra,gamma,plana');
}
// ===================
// = Theme URL =
// ===================
if (! defined('OSEC_THEMES_URL')) {
define('OSEC_THEMES_URL', OSEC_URL . '/public/' . OSEC_THEME_FOLDER . '/');
}
// =================
// = Admin CSS URL =
// =================
if (! defined('OSEC_ADMIN_THEME_CSS_URL')) {
define('OSEC_ADMIN_THEME_CSS_URL', OSEC_URL . '/public/admin/css/');
}
// =================
// = Admin Font URL =
// =================
if (! defined('OSEC_ADMIN_THEME_FONT_URL')) {
define('OSEC_ADMIN_THEME_FONT_URL', OSEC_URL . '/public/admin/font/');
}
// =================
// = Admin Js URL =
// =================
if (! defined('OSEC_ADMIN_THEME_JS_URL')) {
define('OSEC_ADMIN_THEME_JS_URL', OSEC_URL . '/public/js/');
}
// =============
// = POST TYPE =
// =============
if (! defined('OSEC_POST_TYPE')) {
define('OSEC_POST_TYPE', 'osec_event');
}
// ==============
// = SCRIPT URL =
// ==============
if (! defined('OSEC_SCRIPT_URL')) {
define(
'OSEC_SCRIPT_URL',
get_option('home') . '/?plugin=' . OSEC_PLUGIN_NAME
);
}
// =========================================
// = BASE URL FOR ALL CALENDAR ADMIN PAGES =
// =========================================
if (! defined('OSEC_ADMIN_BASE_URL')) {
define('OSEC_ADMIN_BASE_URL', 'edit.php?post_type=' . OSEC_POST_TYPE);
}
// ==============
// = EXPORT URL =
// ==============
if (! defined('OSEC_EXPORT_URL')) {
// ====================================================
// = Convert http:// to webcal:// in OSEC_SCRIPT_URL =
// = (webcal:// protocol does not support https://) =
// ====================================================
$webcal_url = str_replace(['http://', 'https://'], 'webcal://', OSEC_SCRIPT_URL);
define(
'OSEC_EXPORT_URL',
$webcal_url . '&controller=' . ExportEvents::EXPORT_CONTROLLER . '&action=export_events'
);
unset($webcal_url);
}
// ====================
// = SPECIAL SETTINGS =
// ====================
//
// If i choose to use the calendar url as the base for events permalinks,
// i must specify another name for the events archive.
//
if (! defined('OSEC_ALTERNATIVE_ARCHIVE_URL')) {
define('OSEC_ALTERNATIVE_ARCHIVE_URL', 'osec_events_archive');
}
// =====================
// = Default theme url =
// =====================
if (! defined('OSEC_DEFAULT_THEME_URL')) {
define('OSEC_DEFAULT_THEME_URL', OSEC_THEMES_URL . '/' . OSEC_DEFAULT_THEME_NAME . '/');
}
// ===================
// = CSS Folder name =
// ===================
if (! defined('OSEC_CSS_FOLDER')) {
define('OSEC_CSS_FOLDER', 'css');
}
// ==================
// = JS Folder name =
// ==================
if (! defined('OSEC_JS_FOLDER')) {
define('OSEC_JS_FOLDER', 'js');
}
// =====================
// = Image folder name =
// =====================
if (! defined('OSEC_IMG_FOLDER')) {
define('OSEC_IMG_FOLDER', 'img');
}
// =======================
// = Admin theme JS path =
// =======================
if (! defined('OSEC_ADMIN_THEME_JS_PATH')) {
define('OSEC_ADMIN_THEME_JS_PATH', OSEC_PATH . 'public/' . OSEC_JS_FOLDER . '/');
}
// =================
// = Admin IMG URL =
// =================
if (! defined('OSEC_ADMIN_THEME_IMG_URL')) {
define('OSEC_ADMIN_THEME_IMG_URL', OSEC_URL . '/public/admin/' . OSEC_IMG_FOLDER);
}
// ===============
// = DEBUG MODE =
// ===============
//
// Enable debug mode, Including TWIG debug
// which means, that extra output may appear at places
// and you can use {{ dump() }} in twig files.
// Do set to "FALSE" on production sites!
//
if (! defined('OSEC_DEBUG')) {
define('OSEC_DEBUG', false);
}
//
// Do not compress and add debug maps at css compile.
// Do set to "FALSE" on production sites!
//
if (! defined('OSEC_DEBUG_CSS')) {
define('OSEC_DEBUG_CSS', false);
}
// ================
// = DEBUG VENDOR =
// ================
//
// Let non-fatal Errors in /vendor crash fatal when OSEC_DEBUG enabled.
if (! defined('OSEC_DEBUG_VENDOR')) {
define('OSEC_DEBUG_VENDOR', false);
}
// ============================
// = FILE CACHE DEFAULT PATH ==
// ============================
//
// Must be Writeable. Fallback is wp-content/Uploads/....
//
if (! defined('OSEC_FILE_CACHE_DEFAULT_PATH')) {
define(
'OSEC_FILE_CACHE_DEFAULT_PATH',
OSEC_PATH . 'cache/'
);
}
// ================================
// = WP-UPLOADS CACHE DIRECTORY ==
// ================================
//
// In case OSEC_FILE_CACHE_DEFAULT_PATH is not writable,
// we try to use wp-content/uploads/OSEC_FILE_CACHE_WP_UPLOAD_DIR
//
if (! defined('OSEC_FILE_CACHE_WP_UPLOAD_DIR')) {
define('OSEC_FILE_CACHE_WP_UPLOAD_DIR', str_replace('-', '_', OSEC_PLUGIN_NAME . '_cache/'));
}
// =======================
// = ENABLE FILE CACHE ==
// =======================
//
// Enabling/Disabling any cache will require to recompile
// the theme by reenabling it or updating theme color options.
//
// File cache by default will use
// plugindir/cache cache/css/f9d016b4_osec_compiled.css.
//
if (! defined('OSEC_ENABLE_CACHE_FILE')) {
define('OSEC_ENABLE_CACHE_FILE', true);
}
// =======================
// = ENABLE ACPU CACHE ==
// =======================
//
// ACPU and DB cache will deliver CSS on a different url than file cache.
// E.g: yourdomain.tld/?osec-css-cache=1728977613
//
if (! defined('OSEC_ENABLE_CACHE_APCU')) {
define('OSEC_ENABLE_CACHE_APCU', true);
}
// Defines amount of needed free memory to compile LESS files.
if (! defined('OSEC_LESS_MIN_AVAIL_MEMORY')) {
define('OSEC_LESS_MIN_AVAIL_MEMORY', '24M');
}
// Defines if LESS files are parsed at every request
if (! defined('OSEC_PARSE_LESS_FILES_AT_EVERY_REQUEST')) {
define('OSEC_PARSE_LESS_FILES_AT_EVERY_REQUEST', false);
}
// ================================================
// = Force WordPress updates command link =
// ================================================
if (! defined('OSEC_FORCE_UPDATES_URL')) {
define(
'OSEC_FORCE_UPDATES_URL',
OSEC_ADMIN_BASE_URL . '&osec_force_updates=true'
);
}
/**
* This string in query indicates serialized variables.
* @see \Osec\Http\Request\WordpressAdaptor.
*
* @replaces Ai1ec_Uri::DIRECTION_SEPARATOR
*/
if (! defined('OSEC_URI_DIRECTION_SEPARATOR')) {
define(
'OSEC_URI_DIRECTION_SEPARATOR',
'~'
);
}
// ================================================
// Uninstall Plugin Data, purge on Uninstall (Purge)
//
// Set to clean up DB and caches on plugin uninstall.
// Some things might be left if you did SWITCH caches.
// ================================================
if (! defined('OSEC_UNINSTALL_PLUGIN_DATA')) {
define('OSEC_UNINSTALL_PLUGIN_DATA', false);
}
/**
* Shortcode.
*/
if (! defined('OSEC_SHORTCODE')) {
define(
'OSEC_SHORTCODE',
'osec'
);
}
// Lets globalize Table names for now.
if (! defined('OSEC_DB__EVENTS')) {
define(
'OSEC_DB__EVENTS',
'osec_events'
);
}
if (! defined('OSEC_DB__FEEDS')) {
define(
'OSEC_DB__FEEDS',
'osec_event_feeds'
);
}
if (! defined('OSEC_DB__INSTANCES')) {
define(
'OSEC_DB__INSTANCES',
'osec_event_instances'
);
}
if (! defined('OSEC_DB__META')) {
define(
'OSEC_DB__META',
'osec_event_category_meta'
);
}
/**
* Define the timeframe for recurring events.
*
* Relative time frame.
* Don't get excessive, it affects performance,
* @see https://www.php.net/manual/en/datetime.formats.php#datetime.formats.relative
*/
if (! defined('OSEC_REOCCURRENCE_TIMEFRAME')) {
define(
'OSEC_REOCCURRENCE_TIMEFRAME',
'+ 3years'
);
}
/**
* Define Excerpt length in words
*
* Applies to autogenerated, pre-more-tag-text and custom excerpts (when enabled).
*/
if (! defined('OSEC_EXCERPT_LENGTH_WORDS')) {
define(
'OSEC_EXCERPT_LENGTH_WORDS',
35
);
}
/**
* Leaflet version
*
* @see osec_leaflet_library_alter.
*/
if (! defined('OSEC_LEAFLET_VERSION')) {
define(
'OSEC_LEAFLET_VERSION',
'1.9.4'
);
}
/**
* Experimental.
*
* Define how address is saved/displayed after location search.
* @see https://nominatim.org/release-docs/develop/api/Lookup/
*
* E.g:
* separator, translating into a comma.
* ISO3166-2-lvl4: "DE-BE"
* amenity: "Berghain"
* road: "Am Wriezener Bahnhof"
* house_number: "65"
* postcode: "10243"
* city: "Berlin"
* quarter: "Andreasviertel"
* suburb: "Friedrichshain"
* state: "Bayern"
* borough: "Friedrichshain-Kreuzberg"
* country: "Deutschland"
* country_code: "de"
*/
if (! defined('OSEC_GEOCODE_TO_ADDRESS_TEMPLATE')) {
define(
'OSEC_GEOCODE_TO_ADDRESS_TEMPLATE',
'road,house_number,separator,borough|suburb,separator,postcode,city,separator,state,separator,country'
);
}
//
// Allow your users to keep te old calendar feed uri
//
// e.g. ?plugin=all-in-one-event-calendar&controller=ai1ec_exporter_controller&action=export_events&no_html=true
//
if (! defined('OSEC_LEGACY_FEED_URIS')) {
define(
'OSEC_LEGACY_FEED_URIS',
false
);
}
//
// Fallback on serialized cost format.
//
// All in one used php serialize to store the cost fields in DB.
// This has been migrated to Json for security considerations.
// Enabling OSEC_LEGACY_COST_SERIALIZED will support the old data
// format.
//
if (! defined('OSEC_LEGACY_COST_SERIALIZED')) {
define('OSEC_LEGACY_COST_SERIALIZED', false);
}
// Defines if backward (<= 2.1.5) theme compatibility is enabled or not.
if (defined('AI1EC_THEME_COMPATIBILITY_FER')) {
throw new Exception('Backward compatibility to ali1ec (<= 2.1.5) is not supported.');
}
}