forked from Tetrakern/fictioneer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
682 lines (523 loc) · 19.6 KB
/
functions.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
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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
<?php
// =============================================================================
// DEBUG
// =============================================================================
function fictioneer_display_execution_time() {
// Abort on AJAX
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
// Abort on REST
if ( strpos( $_SERVER['REQUEST_URI'], 'wp-json' ) !== false ) {
return;
}
echo '<!-- Execution Time: ' . microtime( true ) - WP_START_TIMESTAMP . ' seconds -->';
}
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
// This should be set, but just to make sure...
if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
define( 'WP_START_TIMESTAMP', microtime(true) );
}
add_action( 'shutdown', 'fictioneer_display_execution_time' );
}
// =============================================================================
// CONSTANTS/SETTINGS
// =============================================================================
// Version
define( 'FICTIONEER_VERSION', '5.11.0' );
define( 'FICTIONEER_MAJOR_VERSION', '5' );
define( 'FICTIONEER_RELEASE_TAG', 'v5.11.0' );
if ( ! defined( 'CHILD_VERSION' ) ) {
define( 'CHILD_VERSION', null );
}
if ( ! defined( 'CHILD_NAME' ) ) {
define( 'CHILD_NAME', null );
}
/*
* Endpoints
*/
// Endpoint: OAuth 2.0
if ( ! defined( 'FICTIONEER_OAUTH_ENDPOINT' ) ) {
define( 'FICTIONEER_OAUTH_ENDPOINT', 'oauth2' );
}
// Endpoint: EPUBs
if ( ! defined( 'FICTIONEER_EPUB_ENDPOINT' ) ) {
define( 'FICTIONEER_EPUB_ENDPOINT', 'download-epub' );
}
// Endpoint: Logout (disable with false)
if ( ! defined( 'FICTIONEER_LOGOUT_ENDPOINT' ) ) {
define( 'FICTIONEER_LOGOUT_ENDPOINT', 'fictioneer-logout' );
}
/*
* Strings
*/
// String: CSS name of the primary font
if ( ! defined( 'FICTIONEER_PRIMARY_FONT_CSS' ) ) {
define( 'FICTIONEER_PRIMARY_FONT_CSS', get_theme_mod( 'primary_font_family_value', 'Open Sans' ) );
}
// String: Display name of the primary font
if ( ! defined( 'FICTIONEER_PRIMARY_FONT_NAME' ) ) {
define( 'FICTIONEER_PRIMARY_FONT_NAME', get_theme_mod( 'primary_font_family_value', 'Open Sans' ) );
}
// String: TTS regex (used to split text into sentences)
if ( ! defined( 'FICTIONEER_TTS_REGEX' ) ) {
// Note: Because lookbehind assertions do not work in Safari, the script uses a little
// detour to preserve punctuation marks: text.replace(regex, '$1|').split('|')
define( 'FICTIONEER_TTS_REGEX', '([.!?:"\'\u201C\u201D])\s+(?=[A-Z"\'\u201C\u201D])' );
}
// String: Default list of allowed mime types for upload restrictions
define(
'FICTIONEER_DEFAULT_UPLOAD_MIME_TYPE_RESTRICTIONS',
'image/jpeg, image/png, image/webp, image/avif, image/gif, application/pdf, application/epub+zip, application/rtf, text/plain, image/svg+xml'
);
// String: Font Awesome CDN URL
if ( ! defined( 'FICTIONEER_FA_CDN' ) ) {
define( 'FICTIONEER_FA_CDN', 'https://use.fontawesome.com/releases/v6.5.1/css/all.css' );
}
// String: Font Awesome CDN integrity (generated by https://www.srihash.org/)
if ( ! defined( 'FICTIONEER_FA_INTEGRITY' ) ) {
define(
'FICTIONEER_FA_INTEGRITY',
'sha384-t1nt8BQoYMLFN5p42tRAtuAAFQaCQODekUVeKKZrEnEyp4H2R0RHFz0KWpmj7i8g'
);
}
// String: Story page footer date format below 480px
if ( ! defined( 'FICTIONEER_DISCORD_EMBED_COLOR' ) ) {
define( 'FICTIONEER_DISCORD_EMBED_COLOR', '9692513' );
}
// String: Truncation ellipsis
if ( ! defined( 'FICTIONEER_TRUNCATION_ELLIPSIS' ) ) {
define( 'FICTIONEER_TRUNCATION_ELLIPSIS', '…' );
}
// String: Age confirmation redirect
if ( ! defined( 'FICTIONEER_AGE_CONFIRMATION_REDIRECT' ) ) {
define( 'FICTIONEER_AGE_CONFIRMATION_REDIRECT', 'https://search.brave.com/' );
}
/*
* Date Strings
*/
$short_date = get_option( 'fictioneer_subitem_short_date_format', 'M j' ) ?: 'M j';
$long_date = get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y";
// String: Latest Updates shortcode list item date format
if ( ! defined( 'FICTIONEER_LATEST_UPDATES_LI_DATE' ) ) {
define( 'FICTIONEER_LATEST_UPDATES_LI_DATE', $short_date );
}
// String: Latest Updates shortcode footer date format
if ( ! defined( 'FICTIONEER_LATEST_UPDATES_FOOTER_DATE' ) ) {
define( 'FICTIONEER_LATEST_UPDATES_FOOTER_DATE', $long_date );
}
// String: Latest Chapters shortcode footer date format
if ( ! defined( 'FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE' ) ) {
define( 'FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE', $long_date );
}
// String: Latest Stories shortcode footer date format
if ( ! defined( 'FICTIONEER_LATEST_STORIES_FOOTER_DATE' ) ) {
define( 'FICTIONEER_LATEST_STORIES_FOOTER_DATE', $long_date );
}
// String: Story card list item date format
if ( ! defined( 'FICTIONEER_CARD_STORY_LI_DATE' ) ) {
define( 'FICTIONEER_CARD_STORY_LI_DATE', $long_date );
}
// String: Story card footer date format
if ( ! defined( 'FICTIONEER_CARD_STORY_FOOTER_DATE' ) ) {
define( 'FICTIONEER_CARD_STORY_FOOTER_DATE', $long_date );
}
// String: Chapter card footer date format
if ( ! defined( 'FICTIONEER_CARD_CHAPTER_FOOTER_DATE' ) ) {
define( 'FICTIONEER_CARD_CHAPTER_FOOTER_DATE', $long_date );
}
// String: Collection card list item date format
if ( ! defined( 'FICTIONEER_CARD_COLLECTION_LI_DATE' ) ) {
define( 'FICTIONEER_CARD_COLLECTION_LI_DATE', $long_date );
}
// String: Collection card footer date format
if ( ! defined( 'FICTIONEER_CARD_COLLECTION_FOOTER_DATE' ) ) {
define( 'FICTIONEER_CARD_COLLECTION_FOOTER_DATE', $long_date );
}
// String: Post card footer date format
if ( ! defined( 'FICTIONEER_CARD_POST_FOOTER_DATE' ) ) {
define( 'FICTIONEER_CARD_POST_FOOTER_DATE', $long_date );
}
// String: Page card footer date format
if ( ! defined( 'FICTIONEER_CARD_PAGE_FOOTER_DATE' ) ) {
define( 'FICTIONEER_CARD_PAGE_FOOTER_DATE', $long_date );
}
// String: Article card footer date format
if ( ! defined( 'FICTIONEER_CARD_ARTICLE_FOOTER_DATE' ) ) {
define( 'FICTIONEER_CARD_ARTICLE_FOOTER_DATE', $long_date );
}
// String: Story page footer date format below 480px
if ( ! defined( 'FICTIONEER_STORY_FOOTER_B480_DATE' ) ) {
define( 'FICTIONEER_STORY_FOOTER_B480_DATE', $long_date );
}
/*
* Integers
*/
// Integer: Commentcode expiration timer in seconds (-1 for infinite)
if ( ! defined( 'FICTIONEER_COMMENTCODE_TTL' ) ) {
define( 'FICTIONEER_COMMENTCODE_TTL', 600 );
}
// Integer: AJAX cache TTL in milliseconds
if ( ! defined( 'FICTIONEER_AJAX_TTL' ) ) {
define( 'FICTIONEER_AJAX_TTL', 60000 );
}
// Integer: AJAX login cache TTL in milliseconds
if ( ! defined( 'FICTIONEER_AJAX_LOGIN_TTL' ) ) {
define( 'FICTIONEER_AJAX_LOGIN_TTL', 15000 );
}
// Integer: AJAX POST debounce rate in milliseconds
if ( ! defined( 'FICTIONEER_AJAX_POST_DEBOUNCE_RATE' ) ) {
define( 'FICTIONEER_AJAX_POST_DEBOUNCE_RATE', 700 );
}
// Integer: Author search keyword limit (use simple text input if exceeded)
if ( ! defined( 'FICTIONEER_AUTHOR_KEYWORD_SEARCH_LIMIT' ) ) {
define( 'FICTIONEER_AUTHOR_KEYWORD_SEARCH_LIMIT', 100 );
}
// Integer: Update check timeout
if ( ! defined( 'FICTIONEER_UPDATE_CHECK_TIMEOUT' ) ) {
define( 'FICTIONEER_UPDATE_CHECK_TIMEOUT', 43200 ); // 12 hours
}
// Integer: Storygraph API cache TTL
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_CACHE_TTL' ) ) {
define( 'FICTIONEER_API_STORYGRAPH_CACHE_TTL', 3600 );
}
// Integer: Storygraph API number of stories per page
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_STORIES_PER_PAGE' ) ) {
define( 'FICTIONEER_API_STORYGRAPH_STORIES_PER_PAGE', 10 );
}
// Integer: Maximum number of displayed custom pages
if ( ! defined( 'FICTIONEER_MAX_CUSTOM_PAGES_PER_STORY' ) ) {
define( 'FICTIONEER_MAX_CUSTOM_PAGES_PER_STORY', 4 );
}
// Integer: The number of chapter before and after folding in chapter lists
if ( ! defined( 'FICTIONEER_CHAPTER_FOLDING_THRESHOLD' ) ) {
define( 'FICTIONEER_CHAPTER_FOLDING_THRESHOLD', 5 );
}
// Integer: Expiration time for shortcode Transients (0 for infinite, -1 to disable)
if ( ! defined( 'FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION' ) ) {
define( 'FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION', 300 );
}
// Integer: Timeout between refreshes of story comment counts (0 for always)
if ( ! defined( 'FICTIONEER_STORY_COMMENT_COUNT_TIMEOUT' ) ) {
define( 'FICTIONEER_STORY_COMMENT_COUNT_TIMEOUT', 900 );
}
// Integer: Requests per minute
if ( ! defined( 'FICTIONEER_REQUESTS_PER_MINUTE' ) ) {
define( 'FICTIONEER_REQUESTS_PER_MINUTE', 5 );
}
// Integer: Maximum number of IDs in 'post__in' and 'post__not_in' query arguments
// to prevent performance degradation. If exceeded, the whole argument will be
// ignored in certain queries, which account for.
if ( ! defined( 'FICTIONEER_QUERY_ID_ARRAY_LIMIT' ) ) {
define( 'FICTIONEER_QUERY_ID_ARRAY_LIMIT', 100 );
}
// Integer: After how many seconds after saving is a post considered "old"
if ( ! defined( 'FICTIONEER_OLD_POST_THRESHOLD' ) ) {
define( 'FICTIONEER_OLD_POST_THRESHOLD', 30 );
}
/*
* Booleans
*/
// Prevent warnings
if ( ! defined( 'WP_DEBUG' ) ) {
define( 'WP_DEBUG', false );
}
// Boolean: Theme cache purging on post update
if ( ! defined( 'FICTIONEER_CACHE_PURGE_ASSIST' ) ) {
define( 'FICTIONEER_CACHE_PURGE_ASSIST', true );
}
// Boolean: Theme relationship cache purging on post update
if ( ! defined( 'FICTIONEER_RELATIONSHIP_PURGE_ASSIST' ) ) {
define( 'FICTIONEER_RELATIONSHIP_PURGE_ASSIST', true );
}
// Boolean: Cache chapter lists on story pages as Transients
if ( ! defined( 'FICTIONEER_CHAPTER_LIST_TRANSIENTS' ) ) {
define( 'FICTIONEER_CHAPTER_LIST_TRANSIENTS', true );
}
// Boolean: Menu items for search
if ( ! defined( 'FICTIONEER_SHOW_SEARCH_IN_MENUS' ) ) {
define( 'FICTIONEER_SHOW_SEARCH_IN_MENUS', true );
}
// Boolean: Base theme switch in site settings
if ( ! defined( 'FICTIONEER_THEME_SWITCH' ) ) {
define( 'FICTIONEER_THEME_SWITCH', true );
}
// Boolean: Attachment pages
if ( ! defined( 'FICTIONEER_ATTACHMENT_PAGES' ) ) {
define( 'FICTIONEER_ATTACHMENT_PAGES', false );
}
// Boolean: Show OAuth ID Hashes (admin only)
if ( ! defined( 'FICTIONEER_SHOW_OAUTH_HASHES' ) ) {
define( 'FICTIONEER_SHOW_OAUTH_HASHES', false );
}
// Boolean: Show AJAX comment submission disallowed content keys
if ( ! defined( 'FICTIONEER_DISALLOWED_KEY_NOTICE' ) ) {
define( 'FICTIONEER_DISALLOWED_KEY_NOTICE', true );
}
// Boolean: Only allow assigned chapters in stories
// Warning: The chapter navigation always refers to the parent story!
if ( ! defined( 'FICTIONEER_FILTER_STORY_CHAPTERS' ) ) {
define( 'FICTIONEER_FILTER_STORY_CHAPTERS', true );
}
// Boolean: Only show the full comment form after clicking into it
if ( ! defined( 'FICTIONEER_COLLAPSE_COMMENT_FORM' ) ) {
define( 'FICTIONEER_COLLAPSE_COMMENT_FORM', true );
}
// Boolean: Storygraph API image nodes
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_IMAGES' ) ) {
define( 'FICTIONEER_API_STORYGRAPH_IMAGES', true );
}
// Boolean: Storygraph API hotlink permission
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_HOTLINK' ) ) {
define( 'FICTIONEER_API_STORYGRAPH_HOTLINK', false );
}
// Boolean: Storygraph API with chapters in /stories
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_CHAPTERS' ) ) {
define( 'FICTIONEER_API_STORYGRAPH_CHAPTERS', true );
}
// Boolean: Storygraph API Transients caching
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_TRANSIENTS' ) ) {
define( 'FICTIONEER_API_STORYGRAPH_TRANSIENTS', true );
}
// Boolean: Enable sticky cards
if ( ! defined( 'FICTIONEER_ENABLE_STICKY_CARDS' ) ) {
define( 'FICTIONEER_ENABLE_STICKY_CARDS', true );
}
// Boolean: Enable story data meta cache
if ( ! defined( 'FICTIONEER_ENABLE_STORY_DATA_META_CACHE' ) ) {
define( 'FICTIONEER_ENABLE_STORY_DATA_META_CACHE', true );
}
// Boolean: Enable nav menu Transients
if ( ! defined( 'FICTIONEER_ENABLE_MENU_TRANSIENTS' ) ) {
define( 'FICTIONEER_ENABLE_MENU_TRANSIENTS', true );
}
// Boolean: Order stories by last updated chapter timestamp
if ( ! defined( 'FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER' ) ) {
define( 'FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER', false );
}
// Boolean: Enable tracking of chapter changes in stories
if ( ! defined( 'FICTIONEER_ENABLE_STORY_CHANGELOG' ) ) {
define( 'FICTIONEER_ENABLE_STORY_CHANGELOG', true );
}
// Boolean: Enable showing of outdated browsers' missing features
if ( ! defined( 'FICTIONEER_ENABLE_BROWSER_NOTES' ) ) {
define( 'FICTIONEER_ENABLE_BROWSER_NOTES', true );
}
/*
* Arrays
*/
// Array: Example collection of Font Awesome icons
if ( ! defined( 'FICTIONEER_EXAMPLE_CHAPTER_ICONS' ) ) {
define(
'FICTIONEER_EXAMPLE_CHAPTER_ICONS',
['fa-solid fa-book', 'fa-solid fa-star', 'fa-solid fa-heart', 'fa-solid fa-bomb', 'fa-solid fa-wine-glass',
'fa-solid fa-face-smile', 'fa-solid fa-shield', 'fa-solid fa-ghost', 'fa-solid fa-gear', 'fa-solid fa-droplet',
'fa-solid fa-fire', 'fa-solid fa-radiation', 'fa-solid fa-lemon', 'fa-solid fa-globe', 'fa-solid fa-flask',
'fa-solid fa-snowflake', 'fa-solid fa-cookie-bite', 'fa-solid fa-circle', 'fa-solid fa-square', 'fa-solid fa-moon',
'fa-solid fa-brain', 'fa-solid fa-diamond', 'fa-solid fa-virus', 'fa-solid fa-horse-head', 'fa-solid fa-certificate',
'fa-solid fa-scroll', 'fa-solid fa-spa', 'fa-solid fa-skull']
);
}
// =============================================================================
// FAST REQUESTS
//
// This is significantly faster than even the REST API because it skips most of
// the theme initialization and the init() action. However, this also means you
// cannot use any actions and filters not loaded at this point.
// =============================================================================
require_once __DIR__ . '/includes/functions/_fast_requests.php';
// =============================================================================
// GLOBAL
// =============================================================================
/**
* Provides various utility functions.
*/
require_once __DIR__ . '/includes/functions/_utility.php';
/**
* Modify WordPress functions via hooks.
*/
require_once __DIR__ . '/includes/functions/_wordpress_mods.php';
/**
* Actions whenever a post is created or updated.
*/
require_once __DIR__ . '/includes/functions/_post_updates.php';
/**
* Set up the theme customizer.
*/
require_once __DIR__ . '/includes/functions/_customizer.php';
if ( is_customize_preview() ) {
require_once __DIR__ . '/includes/functions/_customizer-settings.php';
}
/**
* Set up the theme.
*/
require_once __DIR__ . '/includes/functions/_theme_setup.php';
/**
* Add custom post types.
*/
require_once __DIR__ . '/includes/functions/_cpt_and_taxonomies.php';
/**
* Caches and Transients.
*/
require_once __DIR__ . '/includes/functions/_caching_and_transients.php';
/**
* Add custom shortcodes.
*/
require_once __DIR__ . '/includes/functions/_shortcodes.php';
/**
* Generate sitemap.
*/
require_once __DIR__ . '/includes/functions/_sitemap.php';
/**
* Add SEO features to the site.
*/
require_once __DIR__ . '/includes/functions/_seo.php';
/**
* Communicate with the Discord API.
*/
require_once __DIR__ . '/includes/functions/_discord.php';
/**
* Generate ePUBs for stories.
*/
if ( get_option( 'fictioneer_enable_epubs' ) ) {
require_once __DIR__ . '/includes/functions/_epub.php';
}
/**
* Log-in and register subscribers via OAuth 2.0.
*/
require_once __DIR__ . '/includes/functions/_oauth.php';
/**
* Handle comments.
*/
require_once __DIR__ . '/includes/functions/comments/_comments_controller.php'; // Used in REST
require_once __DIR__ . '/includes/functions/comments/_story_comments.php'; // Used in REST
if ( strpos( $_SERVER['REQUEST_URI'], 'wp-json/fictioneer/' ) !== false ) {
require_once __DIR__ . '/includes/functions/comments/_comments_threads.php';
}
if ( is_admin() ) {
// Required for AJAX
require_once __DIR__ . '/includes/functions/comments/_comments_ajax.php';
require_once __DIR__ . '/includes/functions/comments/_comments_form.php';
require_once __DIR__ . '/includes/functions/comments/_comments_threads.php';
require_once __DIR__ . '/includes/functions/comments/_comments_moderation.php';
}
function fictioneer_conditional_require_comments() {
if ( comments_open() ) {
require_once __DIR__ . '/includes/functions/comments/_comments_form.php';
require_once __DIR__ . '/includes/functions/comments/_comments_threads.php';
require_once __DIR__ . '/includes/functions/comments/_comments_moderation.php';
}
}
add_action( 'wp', 'fictioneer_conditional_require_comments' );
/**
* Add functions for users.
*/
require_once __DIR__ . '/includes/functions/users/_user_data.php';
/**
* Add functions to handle avatars.
*/
require_once __DIR__ . '/includes/functions/users/_avatars.php';
/**
* Add the follow feature.
*/
if ( get_option( 'fictioneer_enable_follows' ) ) {
require_once __DIR__ . '/includes/functions/users/_follows.php';
}
/**
* Add the reminders feature.
*/
if ( get_option( 'fictioneer_enable_reminders' ) ) {
require_once __DIR__ . '/includes/functions/users/_reminders.php';
}
/**
* Add the checkmarks features.
*/
if ( get_option( 'fictioneer_enable_checkmarks' ) ) {
require_once __DIR__ . '/includes/functions/users/_checkmarks.php';
}
/**
* Add the bookmarks feature.
*/
if ( get_option( 'fictioneer_enable_bookmarks' ) && is_admin() ) {
// Only used for AJAX
require_once __DIR__ . '/includes/functions/users/_bookmarks.php';
}
/**
* Add content helper functions.
*/
require_once __DIR__ . '/includes/functions/_content_helpers.php';
/**
* Add content query functions.
*/
require_once __DIR__ . '/includes/functions/_query_helpers.php';
/**
* Add content helper functions.
*/
require_once __DIR__ . '/includes/functions/_roles.php';
/**
* Add forms.
*/
require_once __DIR__ . '/includes/functions/_forms.php';
/**
* Add API.
*/
if ( get_option( 'fictioneer_enable_storygraph_api' ) ) {
require_once __DIR__ . '/includes/functions/_api.php';
}
/**
* Add search.
*/
require_once __DIR__ . '/includes/functions/_search.php';
/**
* Generate SEO schema graphs.
*/
if ( get_option( 'fictioneer_enable_seo' ) && ! fictioneer_seo_plugin_active() ) {
require_once __DIR__ . '/includes/functions/_schemas.php';
}
// =============================================================================
// ADMIN ONLY
// =============================================================================
if ( is_admin() ) {
/**
* Functions only required in the admin panel.
*/
require_once __DIR__ . '/includes/functions/_admin.php';
}
// =============================================================================
// FRONTEND ONLY
// =============================================================================
if ( ! is_admin() ) {
/**
* Add general hooks.
*/
require_once __DIR__ . '/includes/functions/hooks/_general_hooks.php';
/**
* Add post and page hooks.
*/
function fictioneer_conditional_require_frontend_hooks() {
if ( is_page_template( 'stories.php' ) || is_singular( 'fcn_story' ) ) {
require_once __DIR__ . '/includes/functions/hooks/_story_hooks.php';
}
if ( is_page_template( 'chapters.php' ) || is_singular( 'fcn_chapter' ) ) {
require_once __DIR__ . '/includes/functions/hooks/_chapter_hooks.php';
}
if ( is_page_template( 'recommendations.php' ) || is_singular( 'fcn_recommendation' ) ) {
require_once __DIR__ . '/includes/functions/hooks/_recommendation_hooks.php';
}
if ( is_page_template( 'collections.php' ) || is_singular( 'fcn_collection' ) ) {
require_once __DIR__ . '/includes/functions/hooks/_collection_hooks.php';
}
if ( is_page_template( 'user-profile.php' ) ) {
require_once __DIR__ . '/includes/functions/hooks/_profile_hooks.php';
}
if ( is_singular( 'post' ) ) {
require_once __DIR__ . '/includes/functions/hooks/_post_hooks.php';
}
}
add_action( 'wp', 'fictioneer_conditional_require_frontend_hooks' );
/**
* Add mobile menu hooks.
*/
require_once __DIR__ . '/includes/functions/hooks/_mobile_menu_hooks.php';
}
?>