2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// CONSTANTS/SETTINGS
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
// Version
|
2024-06-19 23:17:15 +02:00
|
|
|
define( 'FICTIONEER_VERSION', '5.20.3' );
|
2023-01-21 01:31:34 +01:00
|
|
|
define( 'FICTIONEER_MAJOR_VERSION', '5' );
|
2024-06-19 23:17:15 +02:00
|
|
|
define( 'FICTIONEER_RELEASE_TAG', 'v5.20.3' );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
if ( ! defined( 'CHILD_VERSION' ) ) {
|
2024-01-29 14:52:56 +01:00
|
|
|
define( 'CHILD_VERSION', null );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! defined( 'CHILD_NAME' ) ) {
|
2024-01-29 14:52:56 +01:00
|
|
|
define( 'CHILD_NAME', null );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2024-05-16 14:27:37 +02:00
|
|
|
/*
|
|
|
|
* Locations
|
|
|
|
*/
|
|
|
|
|
2024-05-16 20:35:05 +02:00
|
|
|
if ( ! defined( 'FICTIONEER_MU_REGISTRATION' ) ) {
|
|
|
|
define(
|
|
|
|
'FICTIONEER_MU_REGISTRATION',
|
|
|
|
strpos( $_SERVER['REQUEST_URI'], 'wp-signup.php' ) !== false ||
|
|
|
|
strpos( $_SERVER['REQUEST_URI'], 'wp-activate.php' ) !== false
|
|
|
|
);
|
2024-05-16 14:27:37 +02:00
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
/*
|
|
|
|
* 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' );
|
|
|
|
}
|
|
|
|
|
2024-06-18 02:36:55 +02:00
|
|
|
/**
|
|
|
|
* Adds route to OAuth 2.0 script
|
|
|
|
*
|
|
|
|
* @since 4.0.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_add_oauth2_endpoint() {
|
|
|
|
add_rewrite_endpoint( FICTIONEER_OAUTH_ENDPOINT, EP_ROOT );
|
|
|
|
}
|
|
|
|
add_action( 'init', 'fictioneer_add_oauth2_endpoint', 10 );
|
|
|
|
|
2024-06-18 12:00:24 +02:00
|
|
|
/**
|
|
|
|
* Adds route to ePUB script
|
|
|
|
*
|
|
|
|
* @since 4.0.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fictioneer_add_epub_download_endpoint() {
|
|
|
|
add_rewrite_endpoint( FICTIONEER_EPUB_ENDPOINT, EP_ROOT );
|
|
|
|
}
|
|
|
|
add_action( 'init', 'fictioneer_add_epub_download_endpoint', 10 );
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
/*
|
|
|
|
* Strings
|
|
|
|
*/
|
|
|
|
|
|
|
|
// String: CSS name of the primary font
|
2023-02-08 20:54:54 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_PRIMARY_FONT_CSS' ) ) {
|
2024-02-07 22:56:39 +01:00
|
|
|
define( 'FICTIONEER_PRIMARY_FONT_CSS', get_theme_mod( 'primary_font_family_value', 'Open Sans' ) );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// String: Display name of the primary font
|
|
|
|
if ( ! defined( 'FICTIONEER_PRIMARY_FONT_NAME' ) ) {
|
2024-02-07 22:56:39 +01:00
|
|
|
define( 'FICTIONEER_PRIMARY_FONT_NAME', get_theme_mod( 'primary_font_family_value', 'Open Sans' ) );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2023-06-15 14:18:52 +02:00
|
|
|
// String: TTS regex (used to split text into sentences)
|
|
|
|
if ( ! defined( 'FICTIONEER_TTS_REGEX' ) ) {
|
2023-07-09 12:08:34 +02:00
|
|
|
// 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])' );
|
2023-06-15 14:18:52 +02:00
|
|
|
}
|
|
|
|
|
2023-08-13 15:05:54 +02:00
|
|
|
// 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'
|
|
|
|
);
|
|
|
|
|
2023-11-10 17:22:35 +01:00
|
|
|
// String: Font Awesome CDN URL
|
|
|
|
if ( ! defined( 'FICTIONEER_FA_CDN' ) ) {
|
2024-06-05 14:43:04 +02:00
|
|
|
define( 'FICTIONEER_FA_CDN', 'https://use.fontawesome.com/releases/v6.5.2/css/all.css' );
|
2023-11-10 17:22:35 +01:00
|
|
|
}
|
|
|
|
|
2024-01-23 11:23:11 +01:00
|
|
|
// String: Font Awesome CDN integrity (generated by https://www.srihash.org/)
|
2023-11-10 17:22:35 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_FA_INTEGRITY' ) ) {
|
|
|
|
define(
|
|
|
|
'FICTIONEER_FA_INTEGRITY',
|
2024-06-05 14:43:04 +02:00
|
|
|
'sha384-PPIZEGYM1v8zp5Py7UjFb79S58UeqCL9pYVnVPURKEqvioPROaVAJKKLzvH2rDnI'
|
2023-11-10 17:22:35 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-01-22 16:19:10 +01:00
|
|
|
// 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/' );
|
|
|
|
}
|
|
|
|
|
2024-05-23 20:30:08 +02:00
|
|
|
// String: Default chapter icon Font Awesome classes
|
|
|
|
if ( ! defined( 'FICTIONEER_DEFAULT_CHAPTER_ICON' ) ) {
|
|
|
|
define( 'FICTIONEER_DEFAULT_CHAPTER_ICON', 'fa-solid fa-book' );
|
|
|
|
}
|
|
|
|
|
2023-06-06 22:01:29 +02:00
|
|
|
/*
|
|
|
|
* 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";
|
|
|
|
|
2023-06-06 20:04:45 +02:00
|
|
|
// String: Latest Updates shortcode list item date format
|
|
|
|
if ( ! defined( 'FICTIONEER_LATEST_UPDATES_LI_DATE' ) ) {
|
2023-06-06 22:01:29 +02:00
|
|
|
define( 'FICTIONEER_LATEST_UPDATES_LI_DATE', $short_date );
|
2023-06-06 20:04:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// String: Latest Updates shortcode footer date format
|
|
|
|
if ( ! defined( 'FICTIONEER_LATEST_UPDATES_FOOTER_DATE' ) ) {
|
2023-06-06 22:01:29 +02:00
|
|
|
define( 'FICTIONEER_LATEST_UPDATES_FOOTER_DATE', $long_date );
|
2023-06-06 20:04:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// String: Latest Chapters shortcode footer date format
|
|
|
|
if ( ! defined( 'FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE' ) ) {
|
2023-06-06 22:01:29 +02:00
|
|
|
define( 'FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE', $long_date );
|
2023-06-06 20:04:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// String: Latest Stories shortcode footer date format
|
|
|
|
if ( ! defined( 'FICTIONEER_LATEST_STORIES_FOOTER_DATE' ) ) {
|
2023-06-06 22:01:29 +02:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2023-06-06 22:31:07 +02:00
|
|
|
// String: Story card footer date format
|
|
|
|
if ( ! defined( 'FICTIONEER_CARD_STORY_FOOTER_DATE' ) ) {
|
|
|
|
define( 'FICTIONEER_CARD_STORY_FOOTER_DATE', $long_date );
|
|
|
|
}
|
|
|
|
|
2023-06-06 22:01:29 +02:00
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
|
2023-06-06 22:31:07 +02:00
|
|
|
// String: Collection card footer date format
|
|
|
|
if ( ! defined( 'FICTIONEER_CARD_COLLECTION_FOOTER_DATE' ) ) {
|
|
|
|
define( 'FICTIONEER_CARD_COLLECTION_FOOTER_DATE', $long_date );
|
|
|
|
}
|
|
|
|
|
2023-06-06 22:01:29 +02:00
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
|
2023-09-15 22:46:30 +02:00
|
|
|
// String: Article card footer date format
|
|
|
|
if ( ! defined( 'FICTIONEER_CARD_ARTICLE_FOOTER_DATE' ) ) {
|
|
|
|
define( 'FICTIONEER_CARD_ARTICLE_FOOTER_DATE', $long_date );
|
|
|
|
}
|
|
|
|
|
2023-06-06 22:01:29 +02:00
|
|
|
// String: Story page footer date format below 480px
|
|
|
|
if ( ! defined( 'FICTIONEER_STORY_FOOTER_B480_DATE' ) ) {
|
|
|
|
define( 'FICTIONEER_STORY_FOOTER_B480_DATE', $long_date );
|
2023-06-06 15:34:08 +02:00
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
/*
|
|
|
|
* Integers
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Integer: Commentcode expiration timer in seconds (-1 for infinite)
|
2023-02-08 20:54:54 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_COMMENTCODE_TTL' ) ) {
|
|
|
|
define( 'FICTIONEER_COMMENTCODE_TTL', 600 );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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' ) ) {
|
2024-04-26 13:22:40 +02:00
|
|
|
define( 'FICTIONEER_AUTHOR_KEYWORD_SEARCH_LIMIT', 300 );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2023-01-27 13:13:05 +01:00
|
|
|
// Integer: Update check timeout
|
|
|
|
if ( ! defined( 'FICTIONEER_UPDATE_CHECK_TIMEOUT' ) ) {
|
2023-02-22 13:56:46 +01:00
|
|
|
define( 'FICTIONEER_UPDATE_CHECK_TIMEOUT', 43200 ); // 12 hours
|
2023-01-27 13:13:05 +01:00
|
|
|
}
|
|
|
|
|
2023-02-13 22:48:17 +01:00
|
|
|
// Integer: Storygraph API cache TTL
|
|
|
|
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_CACHE_TTL' ) ) {
|
|
|
|
define( 'FICTIONEER_API_STORYGRAPH_CACHE_TTL', 3600 );
|
|
|
|
}
|
|
|
|
|
2023-02-16 13:52:23 +01:00
|
|
|
// Integer: Storygraph API number of stories per page
|
|
|
|
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_STORIES_PER_PAGE' ) ) {
|
|
|
|
define( 'FICTIONEER_API_STORYGRAPH_STORIES_PER_PAGE', 10 );
|
|
|
|
}
|
|
|
|
|
2023-06-10 18:23:04 +02:00
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
|
2023-08-06 12:59:58 +02:00
|
|
|
// Integer: Expiration time for shortcode Transients (0 for infinite, -1 to disable)
|
2023-08-03 13:17:32 +02:00
|
|
|
if ( ! defined( 'FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION' ) ) {
|
2023-08-17 01:32:30 +02:00
|
|
|
define( 'FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION', 300 );
|
2023-08-03 13:17:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-07 14:21:45 +02:00
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
|
2023-09-01 21:36:18 +02:00
|
|
|
// Integer: Requests per minute
|
|
|
|
if ( ! defined( 'FICTIONEER_REQUESTS_PER_MINUTE' ) ) {
|
|
|
|
define( 'FICTIONEER_REQUESTS_PER_MINUTE', 5 );
|
|
|
|
}
|
|
|
|
|
2024-01-29 00:00:44 +01:00
|
|
|
// 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 );
|
2023-11-12 14:23:44 +01:00
|
|
|
}
|
|
|
|
|
2024-01-10 13:27:16 +01:00
|
|
|
// Integer: After how many seconds after saving is a post considered "old"
|
|
|
|
if ( ! defined( 'FICTIONEER_OLD_POST_THRESHOLD' ) ) {
|
|
|
|
define( 'FICTIONEER_OLD_POST_THRESHOLD', 30 );
|
|
|
|
}
|
|
|
|
|
2024-04-27 12:52:25 +02:00
|
|
|
// Integer: Time until a user's Patreon data expires in seconds
|
|
|
|
if ( ! defined( 'FICTIONEER_PATREON_EXPIRATION_TIME' ) ) {
|
|
|
|
define( 'FICTIONEER_PATREON_EXPIRATION_TIME', WEEK_IN_SECONDS );
|
|
|
|
}
|
|
|
|
|
2024-05-19 17:37:39 +02:00
|
|
|
// Integer: Time until a cached partial expired
|
|
|
|
if ( ! defined( 'FICTIONEER_PARTIAL_CACHE_EXPIRATION_TIME' ) ) {
|
|
|
|
define( 'FICTIONEER_PARTIAL_CACHE_EXPIRATION_TIME', 4 * HOUR_IN_SECONDS );
|
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
/*
|
|
|
|
* Booleans
|
|
|
|
*/
|
|
|
|
|
2023-08-21 21:32:52 +02:00
|
|
|
// Prevent warnings
|
|
|
|
if ( ! defined( 'WP_DEBUG' ) ) {
|
|
|
|
define( 'WP_DEBUG', false );
|
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// Boolean: Theme cache purging on post update
|
2023-02-08 20:54:54 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_CACHE_PURGE_ASSIST' ) ) {
|
|
|
|
define( 'FICTIONEER_CACHE_PURGE_ASSIST', true );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Boolean: Theme relationship cache purging on post update
|
2023-02-08 20:54:54 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_RELATIONSHIP_PURGE_ASSIST' ) ) {
|
|
|
|
define( 'FICTIONEER_RELATIONSHIP_PURGE_ASSIST', true );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2023-02-08 20:10:16 +01:00
|
|
|
// Boolean: Cache chapter lists on story pages as Transients
|
2023-02-18 11:04:39 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_CHAPTER_LIST_TRANSIENTS' ) ) {
|
|
|
|
define( 'FICTIONEER_CHAPTER_LIST_TRANSIENTS', true );
|
2023-02-08 20:02:59 +01:00
|
|
|
}
|
|
|
|
|
2023-02-08 20:54:54 +01:00
|
|
|
// Boolean: Menu items for search
|
|
|
|
if ( ! defined( 'FICTIONEER_SHOW_SEARCH_IN_MENUS' ) ) {
|
|
|
|
define( 'FICTIONEER_SHOW_SEARCH_IN_MENUS', true );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2023-02-08 20:54:54 +01:00
|
|
|
// Boolean: Base theme switch in site settings
|
2023-01-21 01:31:34 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_THEME_SWITCH' ) ) {
|
|
|
|
define( 'FICTIONEER_THEME_SWITCH', true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Boolean: Attachment pages
|
|
|
|
if ( ! defined( 'FICTIONEER_ATTACHMENT_PAGES' ) ) {
|
|
|
|
define( 'FICTIONEER_ATTACHMENT_PAGES', false );
|
|
|
|
}
|
|
|
|
|
2023-02-08 19:55:16 +01:00
|
|
|
// Boolean: Show OAuth ID Hashes (admin only)
|
2023-01-21 01:31:34 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_SHOW_OAUTH_HASHES' ) ) {
|
|
|
|
define( 'FICTIONEER_SHOW_OAUTH_HASHES', false );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Boolean: Show AJAX comment submission disallowed content keys
|
2023-02-08 20:54:54 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_DISALLOWED_KEY_NOTICE' ) ) {
|
|
|
|
define( 'FICTIONEER_DISALLOWED_KEY_NOTICE', true );
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2023-01-28 16:11:02 +01:00
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
|
2023-02-16 22:31:31 +01:00
|
|
|
// Boolean: Only show the full comment form after clicking into it
|
|
|
|
if ( ! defined( 'FICTIONEER_COLLAPSE_COMMENT_FORM' ) ) {
|
|
|
|
define( 'FICTIONEER_COLLAPSE_COMMENT_FORM', true );
|
|
|
|
}
|
|
|
|
|
2023-02-18 12:10:45 +01:00
|
|
|
// Boolean: Storygraph API image nodes
|
2023-02-18 01:01:10 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_IMAGES' ) ) {
|
|
|
|
define( 'FICTIONEER_API_STORYGRAPH_IMAGES', true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Boolean: Storygraph API hotlink permission
|
2023-02-13 22:48:17 +01:00
|
|
|
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_HOTLINK' ) ) {
|
|
|
|
define( 'FICTIONEER_API_STORYGRAPH_HOTLINK', false );
|
|
|
|
}
|
|
|
|
|
2023-02-18 01:14:48 +01:00
|
|
|
// Boolean: Storygraph API with chapters in /stories
|
|
|
|
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_CHAPTERS' ) ) {
|
|
|
|
define( 'FICTIONEER_API_STORYGRAPH_CHAPTERS', true );
|
|
|
|
}
|
|
|
|
|
2023-02-18 01:44:05 +01:00
|
|
|
// Boolean: Storygraph API Transients caching
|
|
|
|
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_TRANSIENTS' ) ) {
|
2023-02-18 13:54:06 +01:00
|
|
|
define( 'FICTIONEER_API_STORYGRAPH_TRANSIENTS', true );
|
2023-02-18 01:44:05 +01:00
|
|
|
}
|
|
|
|
|
2023-08-20 01:19:44 +02:00
|
|
|
// Boolean: Enable sticky cards
|
2023-08-07 12:07:48 +02:00
|
|
|
if ( ! defined( 'FICTIONEER_ENABLE_STICKY_CARDS' ) ) {
|
|
|
|
define( 'FICTIONEER_ENABLE_STICKY_CARDS', true );
|
|
|
|
}
|
|
|
|
|
2023-08-14 20:55:59 +02:00
|
|
|
// Boolean: Enable story data meta cache
|
|
|
|
if ( ! defined( 'FICTIONEER_ENABLE_STORY_DATA_META_CACHE' ) ) {
|
|
|
|
define( 'FICTIONEER_ENABLE_STORY_DATA_META_CACHE', true );
|
|
|
|
}
|
|
|
|
|
2023-08-23 22:02:12 +02:00
|
|
|
// Boolean: Enable nav menu Transients
|
|
|
|
if ( ! defined( 'FICTIONEER_ENABLE_MENU_TRANSIENTS' ) ) {
|
2023-08-26 06:15:59 +02:00
|
|
|
define( 'FICTIONEER_ENABLE_MENU_TRANSIENTS', true );
|
2023-08-23 22:02:12 +02:00
|
|
|
}
|
|
|
|
|
2023-10-28 16:17:56 +02:00
|
|
|
// Boolean: Order stories by last updated chapter timestamp
|
|
|
|
if ( ! defined( 'FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER' ) ) {
|
|
|
|
define( 'FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER', false );
|
|
|
|
}
|
|
|
|
|
2023-11-08 20:03:19 +01:00
|
|
|
// Boolean: Enable tracking of chapter changes in stories
|
|
|
|
if ( ! defined( 'FICTIONEER_ENABLE_STORY_CHANGELOG' ) ) {
|
|
|
|
define( 'FICTIONEER_ENABLE_STORY_CHANGELOG', true );
|
|
|
|
}
|
|
|
|
|
2024-03-07 00:19:40 +01:00
|
|
|
// Boolean: Defer scripts
|
|
|
|
if ( ! defined( 'FICTIONEER_DEFER_SCRIPTS' ) ) {
|
|
|
|
define( 'FICTIONEER_DEFER_SCRIPTS', true );
|
|
|
|
}
|
|
|
|
|
2024-03-08 11:46:24 +01:00
|
|
|
// Boolean: Asynchronous loading via onload pattern
|
|
|
|
if ( ! defined( 'FICTIONEER_ENABLE_ASYNC_ONLOAD_PATTERN' ) ) {
|
|
|
|
define( 'FICTIONEER_ENABLE_ASYNC_ONLOAD_PATTERN', true );
|
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// =============================================================================
|
|
|
|
// GLOBAL
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides various utility functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once __DIR__ . '/includes/functions/_utility.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modify WordPress functions via hooks.
|
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_setup-wordpress.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-20 17:32:07 +02:00
|
|
|
/**
|
|
|
|
* Actions whenever a post is created or updated.
|
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_service-posts.php';
|
2023-08-20 17:32:07 +02:00
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
/**
|
|
|
|
* Set up the theme customizer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once __DIR__ . '/includes/functions/_customizer.php';
|
|
|
|
|
2023-08-09 12:29:57 +02:00
|
|
|
if ( is_customize_preview() ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/_customizer-settings.php';
|
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
/**
|
|
|
|
* Set up the theme.
|
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_setup-theme.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add custom post types.
|
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_setup-types-and-terms.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
2024-04-13 16:54:33 +02:00
|
|
|
* Cache plugins and Transients.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_service-caching.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
2023-08-22 22:51:47 +02:00
|
|
|
* Add custom shortcodes.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_setup-shortcodes.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate sitemap.
|
|
|
|
*/
|
|
|
|
|
2024-06-18 12:05:27 +02:00
|
|
|
if ( get_option( 'fictioneer_enable_sitemap' ) ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/_module-sitemap.php';
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add SEO features to the site.
|
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_module-seo.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
2024-06-18 22:13:10 +02:00
|
|
|
* Generate ePUBs for stories (only in ePUB context).
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2023-08-09 02:46:23 +02:00
|
|
|
if ( get_option( 'fictioneer_enable_epubs' ) ) {
|
2024-06-18 12:00:24 +02:00
|
|
|
if ( wp_doing_ajax() && ( $_GET['action'] ?? 0 ) === 'fictioneer_ajax_download_epub' ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/_module-epub.php';
|
|
|
|
} else {
|
|
|
|
add_action(
|
|
|
|
'template_redirect',
|
|
|
|
function () {
|
|
|
|
if ( ! is_null( get_query_var( FICTIONEER_EPUB_ENDPOINT, null ) ) ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/_module-epub.php';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
1
|
|
|
|
);
|
|
|
|
}
|
2023-08-09 02:46:23 +02:00
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
2024-06-18 02:36:55 +02:00
|
|
|
* Log-in and register via OAuth 2.0.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2024-06-18 02:36:55 +02:00
|
|
|
add_action(
|
|
|
|
'template_redirect',
|
|
|
|
function () {
|
|
|
|
if ( ! is_null( get_query_var( FICTIONEER_OAUTH_ENDPOINT, null ) ) ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/_module-oauth.php';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
1
|
|
|
|
);
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle comments.
|
|
|
|
*/
|
|
|
|
|
2023-08-22 10:29:53 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/comments/_comments_controller.php'; // Used in REST
|
|
|
|
require_once __DIR__ . '/includes/functions/comments/_story_comments.php'; // Used in REST
|
|
|
|
|
2023-08-25 23:57:24 +02:00
|
|
|
if ( strpos( $_SERVER['REQUEST_URI'], 'wp-json/fictioneer/' ) !== false ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/comments/_comments_threads.php';
|
|
|
|
}
|
|
|
|
|
2024-06-24 15:33:48 +02:00
|
|
|
if ( wp_doing_ajax() ) {
|
2023-08-22 10:29:53 +02:00
|
|
|
// 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' );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
2024-06-18 20:21:33 +02:00
|
|
|
* Add helpers for users.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2024-06-18 20:21:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_helpers-users.php';
|
|
|
|
|
|
|
|
/**
|
2024-06-18 22:13:10 +02:00
|
|
|
* Add AJAX functions for users.
|
2024-06-18 20:21:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
add_action(
|
|
|
|
'init',
|
|
|
|
function() {
|
|
|
|
if ( wp_doing_ajax() ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/users/_user-ajax.php';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
1
|
|
|
|
);
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the follow feature.
|
|
|
|
*/
|
|
|
|
|
2023-08-08 20:33:24 +02:00
|
|
|
if ( get_option( 'fictioneer_enable_follows' ) ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/users/_follows.php';
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
2023-08-08 20:33:24 +02:00
|
|
|
* Add the reminders feature.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2023-08-08 20:33:24 +02:00
|
|
|
if ( get_option( 'fictioneer_enable_reminders' ) ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/users/_reminders.php';
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the checkmarks features.
|
|
|
|
*/
|
|
|
|
|
2023-08-08 20:33:24 +02:00
|
|
|
if ( get_option( 'fictioneer_enable_checkmarks' ) ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/users/_checkmarks.php';
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
2023-08-08 20:33:24 +02:00
|
|
|
* Add the bookmarks feature.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2023-08-09 12:29:57 +02:00
|
|
|
if ( get_option( 'fictioneer_enable_bookmarks' ) && is_admin() ) {
|
|
|
|
// Only used for AJAX
|
|
|
|
require_once __DIR__ . '/includes/functions/users/_bookmarks.php';
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add content helper functions.
|
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_helpers-templates.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add content query functions.
|
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_helpers-query.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
2024-03-30 12:36:56 +01:00
|
|
|
* Add role functions.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_setup-roles.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-02-08 14:46:09 +01:00
|
|
|
/**
|
2024-06-18 22:13:10 +02:00
|
|
|
* Add API (only for REST requests).
|
2023-02-08 14:46:09 +01:00
|
|
|
*/
|
|
|
|
|
2023-08-09 02:46:23 +02:00
|
|
|
if ( get_option( 'fictioneer_enable_storygraph_api' ) ) {
|
2024-06-18 10:09:13 +02:00
|
|
|
add_action(
|
|
|
|
'rest_api_init',
|
|
|
|
function () {
|
|
|
|
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/_api.php';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
1
|
|
|
|
);
|
2023-08-09 02:46:23 +02:00
|
|
|
}
|
2023-02-08 14:46:09 +01:00
|
|
|
|
2023-08-08 10:36:47 +02:00
|
|
|
/**
|
2024-06-18 22:13:10 +02:00
|
|
|
* Add search (only in search context).
|
2023-08-08 10:36:47 +02:00
|
|
|
*/
|
|
|
|
|
2024-06-18 11:13:31 +02:00
|
|
|
add_action(
|
|
|
|
'pre_get_posts',
|
|
|
|
function ( $query ) {
|
|
|
|
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/_module-search.php';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
1
|
|
|
|
);
|
2023-08-08 10:36:47 +02:00
|
|
|
|
2023-09-04 23:14:44 +02:00
|
|
|
/**
|
|
|
|
* Generate SEO schema graphs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( get_option( 'fictioneer_enable_seo' ) && ! fictioneer_seo_plugin_active() ) {
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_module-schemas.php';
|
2023-09-04 23:14:44 +02:00
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// =============================================================================
|
|
|
|
// ADMIN ONLY
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
if ( is_admin() ) {
|
|
|
|
|
|
|
|
/**
|
2024-06-18 22:13:10 +02:00
|
|
|
* Functions only required in admin context.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2024-04-13 16:54:33 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/_setup-admin.php';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-06-18 09:56:32 +02:00
|
|
|
/**
|
|
|
|
* Process AJAX form submits.
|
|
|
|
*/
|
|
|
|
|
2024-06-25 11:41:30 +02:00
|
|
|
if ( wp_doing_ajax() ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/_module-forms.php';
|
|
|
|
}
|
2024-06-18 09:56:32 +02:00
|
|
|
|
2024-06-18 10:58:11 +02:00
|
|
|
/**
|
|
|
|
* Communicate with the Discord API.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once __DIR__ . '/includes/functions/_module-discord.php';
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// FRONTEND ONLY
|
|
|
|
// =============================================================================
|
|
|
|
|
|
|
|
if ( ! is_admin() ) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add general hooks.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once __DIR__ . '/includes/functions/hooks/_general_hooks.php';
|
|
|
|
|
|
|
|
/**
|
2023-08-09 03:15:42 +02:00
|
|
|
* Add post and page hooks.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
2023-08-09 12:29:57 +02:00
|
|
|
function fictioneer_conditional_require_frontend_hooks() {
|
2024-05-09 23:56:51 +02:00
|
|
|
if (
|
|
|
|
is_page_template( 'stories.php' ) ||
|
|
|
|
is_page_template( 'singular-story.php' ) ||
|
|
|
|
is_page_template( 'singular-mirror-story.php' ) ||
|
|
|
|
is_singular( 'fcn_story' )
|
|
|
|
) {
|
2023-08-09 03:15:42 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/hooks/_story_hooks.php';
|
2023-08-09 12:29:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( is_page_template( 'chapters.php' ) || is_singular( 'fcn_chapter' ) ) {
|
2023-08-09 03:15:42 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/hooks/_chapter_hooks.php';
|
2023-08-09 12:29:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( is_page_template( 'recommendations.php' ) || is_singular( 'fcn_recommendation' ) ) {
|
2023-08-09 03:15:42 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/hooks/_recommendation_hooks.php';
|
2023-08-09 12:29:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( is_page_template( 'collections.php' ) || is_singular( 'fcn_collection' ) ) {
|
2023-08-09 03:15:42 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/hooks/_collection_hooks.php';
|
2023-08-09 12:29:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( is_page_template( 'user-profile.php' ) ) {
|
2023-08-09 03:15:42 +02:00
|
|
|
require_once __DIR__ . '/includes/functions/hooks/_profile_hooks.php';
|
2023-08-09 12:29:57 +02:00
|
|
|
}
|
2023-08-09 03:15:42 +02:00
|
|
|
|
2023-08-09 12:29:57 +02:00
|
|
|
if ( is_singular( 'post' ) ) {
|
|
|
|
require_once __DIR__ . '/includes/functions/hooks/_post_hooks.php';
|
2023-08-09 03:15:42 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-09 12:29:57 +02:00
|
|
|
add_action( 'wp', 'fictioneer_conditional_require_frontend_hooks' );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add mobile menu hooks.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once __DIR__ . '/includes/functions/hooks/_mobile_menu_hooks.php';
|
|
|
|
}
|