Spring cleaning
Renamed and reordered things for more clarity and efficiency.
This commit is contained in:
parent
d6b78ebc21
commit
f39a259516
@ -594,9 +594,9 @@ Most of the theme’s configuration is found here, the options being largely sel
|
||||
* **Enable OAuth 2.0 authentication:** Allows visitors to register with social media accounts, but be aware of the implications! You will need to flush your permalinks after enabling.
|
||||
* **Enable AJAX comment form/section:** If you have trouble with caching. Try the form first to save resources.
|
||||
* **Enable AJAX user authentication:** If you have trouble with [Nonces](https://developer.wordpress.org/apis/security/nonces/) and/or users not being properly logged-in. Use this as *last resort* to bypass the cache.
|
||||
* **Disable theme comment {…}:** If you want to use different comments. Disables most of the other comment options as well.
|
||||
* **Disable theme comment \[…]:** If you want to use different comments. Disables most of the other comment options as well.
|
||||
* **Show story changelog button:** Opens modal with timestamped chapter changes; located under the chapter list.
|
||||
* **Disable extended story/chapter list meta queries:** Makes list pages and shortcodes faster, but increases the size of your database by one row for each story/chapter. Fine unless you have thousands of posts.
|
||||
* **Disable extended \[story|chapter] list meta queries:** Makes list pages and shortcodes faster, but increases the size of your database by one row for each story/chapter. Fine unless you have *thousands* of posts.
|
||||
|
||||
### Roles Tab
|
||||
|
||||
@ -1177,7 +1177,7 @@ Fictioneer loads the free version of [Font Awesome 6.4.2](https://fontawesome.co
|
||||
|
||||
### Constants
|
||||
|
||||
Some options are not available in the settings because tempering with them can break the theme or result in unexpected behavior. Those options are defined via constants in the **function.php**. If you want to change them, you need a [child theme](https://developer.wordpress.org/themes/advanced-topics/child-themes/) or access to your **wp-config.php**. Just override them in the child theme’s own **function.php**, but only if you know what you are doing!
|
||||
Some options are not available in the settings because tempering with them can break the theme or result in unexpected behavior. Those options are defined via constants in the **function.php**. If you want to change them, you need a [child theme](https://developer.wordpress.org/themes/advanced-topics/child-themes/) or access to your **wp-config.php**. Just override them in the child theme’s own **function.php** or config, but only if you know what you are doing!
|
||||
|
||||
```php
|
||||
define( 'CONSTANT_NAME', value );
|
||||
@ -1185,8 +1185,8 @@ define( 'CONSTANT_NAME', value );
|
||||
|
||||
| Constant | Type | Explanation
|
||||
| :--- | :---: | :---
|
||||
| CHILD_VERSION | string\|boolean | Version number of the child theme. Default `false`.
|
||||
| CHILD_NAME | string\|boolean | Name of the child theme. Default `false`.
|
||||
| CHILD_VERSION | string\|null | Version number of the child theme. Default `null`.
|
||||
| CHILD_NAME | string\|null | Name of the child theme. Default `null`.
|
||||
| FICTIONEER_OAUTH_ENDPOINT | string | URI slug to call the OAuth script. Default `'oauth2'`.
|
||||
| FICTIONEER_EPUB_ENDPOINT | string | URI slug to call the ePUB script. Default `'download-epub'`.
|
||||
| FICTIONEER_LOGOUT_ENDPOINT | string | URI slug to call the logout script. Default `'fictioneer-logout'`.
|
||||
|
@ -37,11 +37,11 @@ define( 'FICTIONEER_MAJOR_VERSION', '5' );
|
||||
define( 'FICTIONEER_RELEASE_TAG', 'v5.9.3' );
|
||||
|
||||
if ( ! defined( 'CHILD_VERSION' ) ) {
|
||||
define( 'CHILD_VERSION', false );
|
||||
define( 'CHILD_VERSION', null );
|
||||
}
|
||||
|
||||
if ( ! defined( 'CHILD_NAME' ) ) {
|
||||
define( 'CHILD_NAME', false );
|
||||
define( 'CHILD_NAME', null );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -303,10 +303,10 @@ if ( ! function_exists( 'fictioneer_api_request_story' ) ) {
|
||||
|
||||
// Return cache if still valid
|
||||
if ( FICTIONEER_API_STORYGRAPH_TRANSIENTS ) {
|
||||
$cache = get_transient( 'fictioneer_storygraph_story_' . $story_id );
|
||||
$transient_cache = get_transient( 'fictioneer_storygraph_story_' . $story_id );
|
||||
|
||||
if ( ! empty( $cache ) ) {
|
||||
return rest_ensure_response( $cache );
|
||||
if ( ! empty( $transient_cache ) ) {
|
||||
return rest_ensure_response( $transient_cache );
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,10 +381,10 @@ if ( ! function_exists( 'fictioneer_api_request_stories' ) ) {
|
||||
|
||||
// Return cache if still valid
|
||||
if ( FICTIONEER_API_STORYGRAPH_TRANSIENTS ) {
|
||||
$cache = get_transient( 'fictioneer_storygraph_stories_' . $page );
|
||||
$transient_cache = get_transient( 'fictioneer_storygraph_stories_' . $page );
|
||||
|
||||
if ( ! empty( $cache ) ) {
|
||||
return rest_ensure_response( $cache );
|
||||
if ( ! empty( $transient_cache ) ) {
|
||||
return rest_ensure_response( $transient_cache );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -988,18 +988,18 @@ if ( ! function_exists( 'fictioneer_get_chapter_list_items' ) ) {
|
||||
*/
|
||||
|
||||
function fictioneer_get_chapter_list_items( $story_id, $data, $current_index ) {
|
||||
// Meta-cache?
|
||||
// Meta cache?
|
||||
if ( ! fictioneer_caching_active() ) {
|
||||
$last_story_update = get_post_modified_time( 'U', true, $story_id );
|
||||
$cache = get_post_meta( $story_id, 'fictioneer_story_chapter_index_html', true );
|
||||
$meta_cache = get_post_meta( $story_id, 'fictioneer_story_chapter_index_html', true );
|
||||
|
||||
if ( $cache && is_array( $cache ) && array_key_exists( 'html', $cache ) ) {
|
||||
if ( $meta_cache && is_array( $meta_cache ) && array_key_exists( 'html', $meta_cache ) ) {
|
||||
// ... still up-to-date and valid?
|
||||
if (
|
||||
( $cache['timestamp'] ?? 0 ) == $last_story_update &&
|
||||
( $cache['valid_until'] ?? 0 ) > time()
|
||||
( $meta_cache['timestamp'] ?? 0 ) == $last_story_update &&
|
||||
( $meta_cache['valid_until'] ?? 0 ) > time()
|
||||
) {
|
||||
return $cache['html'];
|
||||
return $meta_cache['html'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,11 +304,11 @@ if ( ! function_exists( 'fictioneer_get_seo_title' ) ) {
|
||||
return esc_html( _x( 'Archive', 'SEO fallback archive title.', 'fictioneer' ) );
|
||||
}
|
||||
|
||||
// Cached title?
|
||||
$cache = get_post_meta( $post_id, 'fictioneer_seo_title_cache', true );
|
||||
// Meta cache for title?
|
||||
$meta_cache = get_post_meta( $post_id, 'fictioneer_seo_title_cache', true );
|
||||
|
||||
if ( ! empty( $cache ) && ! $skip_cache ) {
|
||||
return $cache;
|
||||
if ( ! empty( $meta_cache ) && ! $skip_cache ) {
|
||||
return $meta_cache;
|
||||
}
|
||||
|
||||
// Start building...
|
||||
@ -459,11 +459,11 @@ if ( ! function_exists( 'fictioneer_get_seo_description' ) ) {
|
||||
return esc_html( sprintf( __( 'Archived posts on %s.', 'fictioneer' ), get_bloginfo( 'name' ) ) );
|
||||
}
|
||||
|
||||
// Cached description?
|
||||
$cache = get_post_meta( $post_id, 'fictioneer_seo_description_cache', true );
|
||||
// Meta cache for description?
|
||||
$meta_cache = get_post_meta( $post_id, 'fictioneer_seo_description_cache', true );
|
||||
|
||||
if ( ! empty( $cache ) && ! $skip_cache ) {
|
||||
return $cache;
|
||||
if ( ! empty( $meta_cache ) && ! $skip_cache ) {
|
||||
return $meta_cache;
|
||||
}
|
||||
|
||||
// Start building...
|
||||
@ -548,12 +548,12 @@ if ( ! function_exists( 'fictioneer_get_seo_image' ) ) {
|
||||
$image_id = $default_id;
|
||||
}
|
||||
|
||||
// Cached image? Except for site default, which can globally change!
|
||||
// Meta cache for image? Except for site default, which can globally change!
|
||||
if ( ! $use_default ) {
|
||||
$cache = get_post_meta( $post_id, 'fictioneer_seo_og_image_cache', true );
|
||||
$meta_cache = get_post_meta( $post_id, 'fictioneer_seo_og_image_cache', true );
|
||||
|
||||
if ( $cache ) {
|
||||
return $cache;
|
||||
if ( $meta_cache ) {
|
||||
return $meta_cache;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,7 +352,7 @@ function fictioneer_get_shortcode_tax_query( $args ) {
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_showcase( $attr ) {
|
||||
@ -445,7 +445,7 @@ add_shortcode( 'fictioneer_showcase', 'fictioneer_shortcode_showcase' );
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_chapters( $attr ) {
|
||||
@ -524,7 +524,7 @@ add_shortcode( 'fictioneer_chapter_cards', 'fictioneer_shortcode_latest_chapters
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_stories( $attr ) {
|
||||
@ -595,7 +595,7 @@ add_shortcode( 'fictioneer_story_cards', 'fictioneer_shortcode_latest_stories' )
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_story_updates( $attr ) {
|
||||
@ -669,7 +669,7 @@ add_shortcode( 'fictioneer_update_cards', 'fictioneer_shortcode_latest_story_upd
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_recommendations( $attr ) {
|
||||
@ -736,7 +736,7 @@ add_shortcode( 'fictioneer_recommendation_cards', 'fictioneer_shortcode_latest_r
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_latest_posts( $attr ) {
|
||||
@ -783,7 +783,7 @@ add_shortcode( 'fictioneer_latest_post', 'fictioneer_shortcode_latest_posts' );
|
||||
* @param string|null $attr['count'] Optional. Maximum number of items. Default -1 (all).
|
||||
* @param string|null $attr['show_empty'] Optional. Whether to show the "no bookmarks" message. Default false.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_bookmarks( $attr ) {
|
||||
@ -818,7 +818,7 @@ add_shortcode( 'fictioneer_bookmarks', 'fictioneer_shortcode_bookmarks' );
|
||||
*
|
||||
* @since 4.7.0
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_cookie_buttons( $attr ) {
|
||||
@ -1106,7 +1106,7 @@ add_shortcode( 'fictioneer_chapter_list', 'fictioneer_shortcode_chapter_list' );
|
||||
* @param string|null $attr["check_{$i}"] Optional. Up to 6 extra checkbox field(s).
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_contact_form( $attr ) {
|
||||
@ -1210,7 +1210,7 @@ add_shortcode( 'fictioneer_contact_form', 'fictioneer_shortcode_contact_form' );
|
||||
* @param string|null $attr['placeholder'] Optional. Placeholder text.
|
||||
* @param string|null $attr['type'] Optional. Default post type to query.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_search( $attr ) {
|
||||
@ -1268,7 +1268,7 @@ add_shortcode( 'fictioneer_search', 'fictioneer_shortcode_search' );
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_blog( $attr ) {
|
||||
@ -1424,7 +1424,7 @@ add_shortcode( 'fictioneer_blog', 'fictioneer_shortcode_blog' );
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
* @return string The captured shortcode HTML.
|
||||
*/
|
||||
|
||||
function fictioneer_shortcode_article_cards( $attr ) {
|
||||
|
@ -255,34 +255,34 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
|
||||
function fictioneer_get_story_data( $story_id, $show_comments = true, $args = [] ) {
|
||||
$story_id = fictioneer_validate_id( $story_id, 'fcn_story' );
|
||||
$old_data = false;
|
||||
$meta_cache = null;
|
||||
|
||||
if ( empty( $story_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check cache
|
||||
// Meta cache?
|
||||
if ( FICTIONEER_ENABLE_STORY_DATA_META_CACHE ) {
|
||||
$old_data = get_post_meta( $story_id, 'fictioneer_story_data_collection', true );
|
||||
$meta_cache = get_post_meta( $story_id, 'fictioneer_story_data_collection', true );
|
||||
}
|
||||
|
||||
if ( ! empty( $old_data ) && $old_data['last_modified'] >= get_the_modified_time( 'U', $story_id ) ) {
|
||||
if ( $meta_cache && ( $meta_cache['last_modified'] ?? 0) >= get_the_modified_time( 'U', $story_id ) ) {
|
||||
// Return cached data without refreshing the comment count
|
||||
if ( ! $show_comments ) {
|
||||
return $old_data;
|
||||
return $meta_cache;
|
||||
}
|
||||
|
||||
// Time to refresh comment count?
|
||||
$comment_count_delay = ( $old_data['comment_count_timestamp'] ?? 0 ) + FICTIONEER_STORY_COMMENT_COUNT_TIMEOUT;
|
||||
$comment_count_delay = ( $meta_cache['comment_count_timestamp'] ?? 0 ) + FICTIONEER_STORY_COMMENT_COUNT_TIMEOUT;
|
||||
$refresh_comments = $comment_count_delay < time() ||
|
||||
( $args['refresh_comment_count'] ?? 0 ) || fictioneer_caching_active();
|
||||
|
||||
// Refresh comment count
|
||||
if ( $refresh_comments ) {
|
||||
// Use old count as fallback
|
||||
$comment_count = $old_data['comment_count'];
|
||||
$comment_count = $meta_cache['comment_count'];
|
||||
|
||||
if ( count( $old_data['chapter_ids'] ) > 0 ) {
|
||||
if ( count( $meta_cache['chapter_ids'] ) > 0 ) {
|
||||
// Counting the stored comment count of chapters is typically
|
||||
// faster than querying and counting all comments.
|
||||
$chapters = fictioneer_get_story_chapter_posts( $story_id );
|
||||
@ -296,11 +296,11 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
$old_data['comment_count'] = $comment_count;
|
||||
$old_data['comment_count_timestamp'] = time();
|
||||
$meta_cache['comment_count'] = $comment_count;
|
||||
$meta_cache['comment_count_timestamp'] = time();
|
||||
|
||||
// Update meta cache and purge
|
||||
update_post_meta( $story_id, 'fictioneer_story_data_collection', $old_data );
|
||||
update_post_meta( $story_id, 'fictioneer_story_data_collection', $meta_cache );
|
||||
|
||||
if ( function_exists( 'fictioneer_purge_post_cache' ) ) {
|
||||
fictioneer_purge_post_cache( $story_id );
|
||||
@ -308,7 +308,7 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
}
|
||||
|
||||
// Return cached data
|
||||
return $old_data;
|
||||
return $meta_cache;
|
||||
}
|
||||
|
||||
// Setup
|
||||
@ -323,7 +323,7 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
$chapter_count = 0;
|
||||
$word_count = 0;
|
||||
$comment_count = 0;
|
||||
$chapter_ids = [];
|
||||
$visible_chapter_ids = [];
|
||||
|
||||
// Assign correct icon
|
||||
if ( $status != 'Ongoing' ) {
|
||||
@ -355,7 +355,7 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
}
|
||||
|
||||
// ... but they are still listed!
|
||||
$chapter_ids[] = $chapter->ID;
|
||||
$visible_chapter_ids[] = $chapter->ID;
|
||||
}
|
||||
|
||||
// Count ALL comments
|
||||
@ -383,16 +383,18 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
'title' => fictioneer_get_safe_title( $story_id ),
|
||||
'rating' => get_post_meta( $story_id, 'fictioneer_story_rating', true ),
|
||||
'rating_letter' => get_post_meta( $story_id, 'fictioneer_story_rating', true )[0],
|
||||
'chapter_ids' => $chapter_ids,
|
||||
'chapter_ids' => $visible_chapter_ids,
|
||||
'last_modified' => get_the_modified_time( 'U', $story_id ),
|
||||
'comment_count' => $comment_count,
|
||||
'comment_count_timestamp' => time()
|
||||
);
|
||||
|
||||
// Update meta cache if enabled
|
||||
if ( FICTIONEER_ENABLE_STORY_DATA_META_CACHE ) {
|
||||
update_post_meta( $story_id, 'fictioneer_story_data_collection', $result );
|
||||
}
|
||||
|
||||
// Done
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -530,11 +532,11 @@ if ( ! function_exists( 'fictioneer_get_collection_statistics' ) ) {
|
||||
*/
|
||||
|
||||
function fictioneer_get_collection_statistics( $collection_id ) {
|
||||
// Cache?
|
||||
$cache = get_post_meta( $collection_id, 'fictioneer_collection_statistics_cache', true );
|
||||
// Meta cache?
|
||||
$meta_cache = get_post_meta( $collection_id, 'fictioneer_collection_statistics_cache', true );
|
||||
|
||||
if ( ! empty( $cache ) && ( $cache['valid_until'] ?? 0 ) > time() ) {
|
||||
return $cache;
|
||||
if ( ! empty( $meta_cache ) && ( $meta_cache['valid_until'] ?? 0 ) > time() ) {
|
||||
return $meta_cache;
|
||||
}
|
||||
|
||||
// Setup
|
||||
@ -617,10 +619,10 @@ if ( ! function_exists( 'fictioneer_get_collection_statistics' ) ) {
|
||||
'valid_until' => time() + 900 // 15 minutes
|
||||
);
|
||||
|
||||
// Set cache
|
||||
// Update meta cache
|
||||
update_post_meta( $collection_id, 'fictioneer_collection_statistics_cache', $statistics );
|
||||
|
||||
// Return result
|
||||
// Done
|
||||
return $statistics;
|
||||
}
|
||||
}
|
||||
@ -2222,11 +2224,11 @@ if ( ! function_exists( 'fictioneer_get_stories_total_word_count' ) ) {
|
||||
|
||||
function fictioneer_get_stories_total_word_count() {
|
||||
// Look for cached value
|
||||
$cached_word_count = get_transient( 'fictioneer_stories_total_word_count' );
|
||||
$transient_word_count_cache = get_transient( 'fictioneer_stories_total_word_count' );
|
||||
|
||||
// Return cached value if found
|
||||
if ( $cached_word_count ) {
|
||||
return $cached_word_count;
|
||||
if ( $transient_word_count_cache ) {
|
||||
return $transient_word_count_cache;
|
||||
}
|
||||
|
||||
// Setup
|
||||
@ -2251,7 +2253,7 @@ if ( ! function_exists( 'fictioneer_get_stories_total_word_count' ) ) {
|
||||
}
|
||||
|
||||
// Cache for next time
|
||||
set_transient( 'fictioneer_stories_total_word_count', $word_count );
|
||||
set_transient( 'fictioneer_stories_total_word_count', $word_count, 900 );
|
||||
|
||||
// Return newly calculated value
|
||||
return $word_count;
|
||||
|
@ -478,8 +478,12 @@ add_action( 'fictioneer_story_after_content', 'fictioneer_story_pages', 42 );
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param array $args['story_data'] Collection of story data.
|
||||
* @param int $args['story_id'] The story post ID.
|
||||
* @param array $args {
|
||||
* Array of arguments.
|
||||
*
|
||||
* @type array $story_data Pre-compiled array of story data.
|
||||
* @type int $story_id ID of the story.
|
||||
* }
|
||||
*/
|
||||
|
||||
function fictioneer_story_chapters( $args ) {
|
||||
@ -490,6 +494,15 @@ function fictioneer_story_chapters( $args ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for cached chapters output
|
||||
$chapters_html = FICTIONEER_CHAPTER_LIST_TRANSIENTS ?
|
||||
get_transient( 'fictioneer_story_chapter_list_' . $args['story_id'] ) : null;
|
||||
|
||||
if ( ! empty( $chapters_html ) ) {
|
||||
echo $chapters_html;
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup
|
||||
$story_id = $args['story_id'];
|
||||
$story = $args['story_data'];
|
||||
@ -500,14 +513,6 @@ function fictioneer_story_chapters( $args ) {
|
||||
$disable_folding = get_post_meta( $story_id, 'fictioneer_story_disable_collapse', true );
|
||||
$collapse_groups = get_option( 'fictioneer_collapse_groups_by_default' );
|
||||
|
||||
// Check for cached chapters output
|
||||
$chapters_html = FICTIONEER_CHAPTER_LIST_TRANSIENTS ? get_transient( 'fictioneer_story_chapter_list_' . $story_id ) : null;
|
||||
|
||||
if ( ! empty( $chapters_html ) ) {
|
||||
echo $chapters_html;
|
||||
return;
|
||||
}
|
||||
|
||||
// Capture output
|
||||
ob_start();
|
||||
|
||||
|
@ -723,7 +723,7 @@
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
'fictioneer_disable_extended_story_list_meta_queries',
|
||||
__( 'Faster, but adds rows to your database, which can slow down your site if you have thousands of posts.', 'fictioneer' )
|
||||
__( 'Faster, but adds one row per story to your database, which can slow down your site if you have thousands.', 'fictioneer' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
@ -732,7 +732,7 @@
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
'fictioneer_disable_extended_chapter_list_meta_queries',
|
||||
__( 'Faster, but adds rows to your database, which can slow down your site if you have thousands of posts.', 'fictioneer' )
|
||||
__( 'Faster, but adds one row per chapter to your database, which can slow down your site if you have thousands.', 'fictioneer' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
@ -296,12 +296,12 @@ function fictioneer_ajax_get_follows_notifications() {
|
||||
// Last story/chapter update on site
|
||||
$last_update = fictioneer_get_last_fiction_update();
|
||||
|
||||
// Check for cached HTML
|
||||
// Meta cache for HTML?
|
||||
if ( ! empty( $last_update ) ) {
|
||||
$cache = get_user_meta( $user->ID, 'fictioneer_user_follows_cache', true );
|
||||
$meta_cache = get_user_meta( $user->ID, 'fictioneer_user_follows_cache', true );
|
||||
|
||||
if ( ! empty( $cache ) && array_key_exists( $last_update, $cache ) ) {
|
||||
$html = $cache[ $last_update ] . '<!-- Cached on ' . $cache['timestamp'] . ' -->';
|
||||
if ( ! empty( $meta_cache ) && array_key_exists( $last_update, $meta_cache ) ) {
|
||||
$html = $meta_cache[ $last_update ] . '<!-- Cached on ' . $meta_cache['timestamp'] . ' -->';
|
||||
|
||||
wp_send_json_success( array( 'html' => $html ) );
|
||||
}
|
||||
@ -351,7 +351,7 @@ function fictioneer_ajax_get_follows_notifications() {
|
||||
|
||||
$html = fictioneer_minify_html( ob_get_clean() );
|
||||
|
||||
// Cache for next time
|
||||
// Update meta cache
|
||||
if ( ! empty( $last_update ) ) {
|
||||
update_user_meta(
|
||||
$user->ID,
|
||||
|
@ -17,9 +17,7 @@
|
||||
|
||||
// Setup
|
||||
$no_params = empty( array_filter( $_GET ) );
|
||||
$simple_mode = $args['simple'] ?? false;
|
||||
$cache_mode = $args['cache'] ?? false;
|
||||
$show_advanced = ! get_option( 'fictioneer_disable_theme_search' ) && ! $simple_mode;
|
||||
$show_advanced = ! get_option( 'fictioneer_disable_theme_search' ) && ! ( $args['simple'] ?? 0 );
|
||||
$placeholder = $args['placeholder'] ?? _x( 'Search keywords or phrase', 'Advanced search placeholder.', 'fictioneer' );
|
||||
$post_type = sanitize_text_field( $_GET['post_type'] ?? $args['preselect_type'] ?? 'any' );
|
||||
|
||||
@ -126,7 +124,7 @@ if ( $show_advanced ) {
|
||||
<?php if ( $show_advanced ) : ?>
|
||||
|
||||
<div class="search-form__current">
|
||||
<?php if ( $is_advanced_search && ! $cache_mode ) : ?>
|
||||
<?php if ( $is_advanced_search && ! ( $args['cache'] ?? 0 ) ) : ?>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
|
Loading…
x
Reference in New Issue
Block a user