diff --git a/functions.php b/functions.php index 897c90c8..d8fd5c86 100644 --- a/functions.php +++ b/functions.php @@ -206,7 +206,7 @@ if ( ! defined( 'FICTIONEER_CHAPTER_FOLDING_THRESHOLD' ) ) { // Integer: Expiration time for shortcode Transients (0 for infinite, -1 to disable) if ( ! defined( 'FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION' ) ) { - define( 'FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION', 300 ); + define( 'FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION', -1 ); } // Integer: Timeout between refreshes of story comment counts (0 for always) diff --git a/includes/functions/_query_helpers.php b/includes/functions/_query_helpers.php index b2a47270..f8e4687e 100644 --- a/includes/functions/_query_helpers.php +++ b/includes/functions/_query_helpers.php @@ -52,7 +52,7 @@ if ( ! function_exists( 'fictioneer_get_card_list' ) ) { $the_card_args = array_merge( $the_card_args, $card_args ); // Query (but not if 'post__in' is set and empty) - if ( ! ( isset( $query_args['post__in'] ) && empty( $the_query_args['post__in'] ) ) ) { + if ( empty( $the_query_args['post__in'] ?? 0 ) ) { $query = new WP_Query( $the_query_args ); // Prime author cache diff --git a/includes/functions/_shortcodes.php b/includes/functions/_shortcodes.php index 8d4ff191..d75e8a60 100644 --- a/includes/functions/_shortcodes.php +++ b/includes/functions/_shortcodes.php @@ -934,7 +934,9 @@ function fictioneer_shortcode_chapter_list( $attr ) { $empty = fictioneer_minify_html( ob_get_clean() ); // Abort if... - if ( empty( $attr['story_id'] ) && empty( $attr['chapter_ids'] ) ) return $empty; + if ( empty( $attr['story_id'] ) && empty( $attr['chapter_ids'] ) ) { + return $empty; + } // Setup $count = max( -1, intval( $attr['count'] ?? -1 ) ); @@ -965,23 +967,30 @@ function fictioneer_shortcode_chapter_list( $attr ) { } // Extra classes - if ( $hide_icons ) $classes[] = '_no-icons'; - if ( ! empty( $attr['class'] ) ) $classes[] = esc_attr( wp_strip_all_tags( $attr['class'] ) ); + if ( $hide_icons ) { + $classes[] = '_no-icons'; + } - // Apply offset - if ( ! $group ) $chapters = array_slice( $chapters, $offset ); + if ( ! empty( $attr['class'] ) ) { + $classes[] = esc_attr( wp_strip_all_tags( $attr['class'] ) ); + } - // Apply count - if ( ! $group ) $chapters = $count > 0 ? array_slice( $chapters, 0, $count ) : $chapters; + // Apply offset and count + if ( ! $group ) { + $chapters = array_slice( $chapters, $offset ); + $chapters = $count > 0 ? array_slice( $chapters, 0, $count ) : $chapters; + } // Check array for items - if ( empty( $chapters ) ) return $empty; + if ( empty( $chapters ) ) { + return $empty; + } // Query chapters $query_args = array( 'post_type' => 'fcn_chapter', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $chapters ), + 'post__in' => $chapters, // Cannot be empty! 'ignore_sticky_posts' => true, 'orderby' => 'post__in', // Preserve order from meta box 'posts_per_page' => -1, // Get all chapters (this can be hundreds) @@ -1005,7 +1014,9 @@ function fictioneer_shortcode_chapter_list( $attr ) { $chapter_query = fictioneer_shortcode_query( $query_args ); // Check query for items - if ( ! $chapter_query->have_posts() ) return $empty; + if ( ! $chapter_query->have_posts() ) { + return $empty; + } // Buffer ob_start(); diff --git a/includes/functions/hooks/_post_hooks.php b/includes/functions/hooks/_post_hooks.php index 17c9f726..7cd5945e 100644 --- a/includes/functions/hooks/_post_hooks.php +++ b/includes/functions/hooks/_post_hooks.php @@ -43,13 +43,17 @@ function fictioneer_post_featured_list( $post_id ) { global $post; // Abort if... - if ( post_password_required() ) return; + if ( post_password_required() ) { + return; + } // Setup $featured = fictioneer_get_field( 'fictioneer_post_featured', $post_id ); // Abort if... - if ( empty( $featured ) ) return; + if ( empty( $featured ) ) { + return; + } // Query $query_args = array( @@ -64,7 +68,9 @@ function fictioneer_post_featured_list( $post_id ) { $featured_query = new WP_Query( $query_args ); // Abort if... - if ( empty( $featured_query->posts ) ) return; + if ( empty( $featured_query->posts ) ) { + return; + } // Prime author cache if ( function_exists( 'update_post_author_caches' ) ) { diff --git a/includes/functions/users/_checkmarks.php b/includes/functions/users/_checkmarks.php index 7b511453..1c9210df 100644 --- a/includes/functions/users/_checkmarks.php +++ b/includes/functions/users/_checkmarks.php @@ -258,7 +258,7 @@ function fictioneer_ajax_get_finished_list() { $list_items = fictioneer_get_card_list( 'story', array( - 'post__in' => fictioneer_post__in( $post_ids ), + 'post__in' => $post_ids, 'paged' => $page, 'order' => $order ), diff --git a/includes/functions/users/_follows.php b/includes/functions/users/_follows.php index 84f454be..c7fd831d 100644 --- a/includes/functions/users/_follows.php +++ b/includes/functions/users/_follows.php @@ -417,7 +417,7 @@ function fictioneer_ajax_get_follows_list() { $list_items = fictioneer_get_card_list( 'story', array( - 'post__in' => fictioneer_post__in( $post_ids ), + 'post__in' => $post_ids, 'paged' => $page, 'order' => $order ), diff --git a/includes/functions/users/_reminders.php b/includes/functions/users/_reminders.php index 94750f28..080edeb8 100644 --- a/includes/functions/users/_reminders.php +++ b/includes/functions/users/_reminders.php @@ -187,7 +187,7 @@ function fictioneer_ajax_get_reminders_list() { $list_items = fictioneer_get_card_list( 'story', array( - 'post__in' => fictioneer_post__in( $post_ids ), + 'post__in' => $post_ids, 'paged' => $page, 'order' => $order ), diff --git a/partials/_latest-chapters-compact.php b/partials/_latest-chapters-compact.php index 1ba05e82..125c1263 100644 --- a/partials/_latest-chapters-compact.php +++ b/partials/_latest-chapters-compact.php @@ -29,7 +29,7 @@ $query_args = array( 'post_type' => 'fcn_chapter', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'order' => $args['order'] ?? 'desc', 'orderby' => $args['orderby'] ?? 'date', 'posts_per_page' => $args['count'], diff --git a/partials/_latest-chapters.php b/partials/_latest-chapters.php index c5b85fd2..a8c72ee1 100644 --- a/partials/_latest-chapters.php +++ b/partials/_latest-chapters.php @@ -30,7 +30,7 @@ $query_args = array( 'post_type' => 'fcn_chapter', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'orderby' => $args['orderby'] ?? 'date', 'order' => $args['order'] ?? 'desc', 'posts_per_page' => $args['count'], diff --git a/partials/_latest-posts.php b/partials/_latest-posts.php index 4de3f7a0..eb35d345 100644 --- a/partials/_latest-posts.php +++ b/partials/_latest-posts.php @@ -25,7 +25,7 @@ $query_args = array( 'post_type' => 'post', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'has_password' => false, 'orderby' => 'date', 'order' => 'DESC', diff --git a/partials/_latest-recommendations-compact.php b/partials/_latest-recommendations-compact.php index ba1e53a1..293c2fbe 100644 --- a/partials/_latest-recommendations-compact.php +++ b/partials/_latest-recommendations-compact.php @@ -29,7 +29,7 @@ $show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_recommendation_c $query_args = array ( 'post_type' => 'fcn_recommendation', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'orderby' => $args['orderby'] ?? 'date', 'order' => $args['order'] ?? 'desc', 'posts_per_page' => $args['count'], diff --git a/partials/_latest-recommendations.php b/partials/_latest-recommendations.php index ba5be67f..c7d86d8c 100644 --- a/partials/_latest-recommendations.php +++ b/partials/_latest-recommendations.php @@ -30,7 +30,7 @@ $show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_recommendation_c $query_args = array ( 'post_type' => 'fcn_recommendation', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'orderby' => $args['orderby'] ?? 'date', 'order' => $args['order'] ?? 'desc', 'posts_per_page' => $args['count'], diff --git a/partials/_latest-stories-compact.php b/partials/_latest-stories-compact.php index 96d244da..d840f2cd 100644 --- a/partials/_latest-stories-compact.php +++ b/partials/_latest-stories-compact.php @@ -30,7 +30,7 @@ $show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' ); $query_args = array( 'post_type' => 'fcn_story', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'orderby' => $args['orderby'], 'order' => $args['order'] ?? 'desc', 'posts_per_page' => $args['count'], diff --git a/partials/_latest-stories.php b/partials/_latest-stories.php index 1c2bd518..dd8f5e11 100644 --- a/partials/_latest-stories.php +++ b/partials/_latest-stories.php @@ -27,7 +27,7 @@ $query_args = array( 'post_type' => 'fcn_story', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'orderby' => $args['orderby'], 'order' => $args['order'] ?? 'desc', 'posts_per_page' => $args['count'], diff --git a/partials/_latest-updates-compact.php b/partials/_latest-updates-compact.php index ae23839b..85fd834b 100644 --- a/partials/_latest-updates-compact.php +++ b/partials/_latest-updates-compact.php @@ -33,7 +33,7 @@ $card_counter = 0; $query_args = array( 'post_type' => 'fcn_story', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'meta_key' => 'fictioneer_chapters_added', 'orderby' => 'meta_value', 'order' => $args['order'] ?? 'desc', diff --git a/partials/_latest-updates.php b/partials/_latest-updates.php index ac216bc0..5e55a0c1 100644 --- a/partials/_latest-updates.php +++ b/partials/_latest-updates.php @@ -35,7 +35,7 @@ $card_counter = 0; $query_args = array( 'post_type' => 'fcn_story', 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'meta_key' => 'fictioneer_chapters_added', 'orderby' => 'meta_value', 'order' => $args['order'] ?? 'desc', diff --git a/partials/_showcase.php b/partials/_showcase.php index 731c5029..8c5fbde1 100644 --- a/partials/_showcase.php +++ b/partials/_showcase.php @@ -11,17 +11,17 @@ * @subpackage Fictioneer * @since 4.0 * - * @internal $args['type'] Post type if the showcase. - * @internal $args['count'] Maximum number of items. Default 8. - * @internal $args['order'] Order direction. Default 'DESC'. - * @internal $args['orderby'] Order argument. Default 'date'. - * @internal $args['author'] Author provided by the shortcode. - * @internal $args['post_ids'] Array of post IDs. Default empty. - * @internal $args['excluded_cats'] Array of category IDs to exclude. Default empty. - * @internal $args['excluded_tags'] Array of tag IDs to exclude. Default empty. - * @internal $args['taxonomies'] Array of taxonomy arrays. Default empty. - * @internal $args['relation'] Relationship between taxonomies. - * @internal $args['classes'] Additional classes. + * @internal $args['type'] Post type if the showcase. + * @internal $args['count'] Maximum number of items. Default 8. + * @internal $args['order'] Order direction. Default 'DESC'. + * @internal $args['orderby'] Order argument. Default 'date'. + * @internal $args['author'] Author provided by the shortcode. + * @internal $args['post_ids'] Array of post IDs. Default empty. + * @internal $args['excluded_cats'] Array of category IDs to exclude. Default empty. + * @internal $args['excluded_tags'] Array of tag IDs to exclude. Default empty. + * @internal $args['taxonomies'] Array of taxonomy arrays. Default empty. + * @internal $args['relation'] Relationship between taxonomies. + * @internal $args['classes'] Additional classes. */ ?> @@ -31,7 +31,7 @@ $query_args = array ( 'post_type' => $args['type'], 'post_status' => 'publish', - 'post__in' => fictioneer_post__in( $args['post_ids'] ), + 'post__in' => $args['post_ids'], // May be empty! 'order' => $args['order'] ?? 'DESC', 'orderby' => $args['orderby'] ?? 'date', 'posts_per_page' => $args['count'] ?? 8, diff --git a/singular-bookshelf.php b/singular-bookshelf.php index 61612846..106cd022 100644 --- a/singular-bookshelf.php +++ b/singular-bookshelf.php @@ -164,7 +164,7 @@ $tabs[ $current_tab ]['classes'][] = '_current'; $list_items = fictioneer_get_card_list( 'story', array( - 'post__in' => fictioneer_post__in( $tabs[ $current_tab ]['post_ids'] ), + 'post__in' => $tabs[ $current_tab ]['post_ids'], 'paged' => $current_page, 'order' => $order ),