2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Partial: Latest Updates Compact
|
|
|
|
*
|
|
|
|
* Renders the (buffered) HTML for the [fictioneer_latest_updates type="compact"]
|
|
|
|
* shortcode. Looks for the 'fictioneer_chapters_added' meta property and only
|
|
|
|
* updates when the items in the chapters list increase. Admittedly, this can be
|
|
|
|
* exploited by removing and re-adding chapters.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Fictioneer
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 4.3.0
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
2024-01-28 00:11:56 +01:00
|
|
|
* @internal $args['type'] Type argument passed from shortcode ('compact').
|
2023-09-15 15:15:45 +02:00
|
|
|
* @internal $args['count'] Number of posts provided by the shortcode.
|
|
|
|
* @internal $args['author'] Author provided by the shortcode.
|
|
|
|
* @internal $args['order'] Order of posts. Default 'DESC'.
|
|
|
|
* @internal $args['post_ids'] Array of post IDs. Default empty.
|
2023-09-16 23:41:30 +02:00
|
|
|
* @internal $args['author_ids'] Array of author IDs. Default empty.
|
|
|
|
* @internal $args['excluded_authors'] Array of author IDs to exclude. Default empty.
|
2023-09-15 15:15:45 +02:00
|
|
|
* @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['ignore_protected'] Whether to ignore protected posts. Default false.
|
|
|
|
* @internal $args['taxonomies'] Array of taxonomy arrays. Default empty.
|
|
|
|
* @internal $args['relation'] Relationship between taxonomies.
|
2023-09-15 22:42:34 +02:00
|
|
|
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
2023-08-20 20:21:48 +02:00
|
|
|
// No direct access!
|
|
|
|
defined( 'ABSPATH' ) OR exit;
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// Setup
|
|
|
|
$card_counter = 0;
|
|
|
|
|
|
|
|
// Prepare query
|
|
|
|
$query_args = array(
|
2023-09-15 14:00:44 +02:00
|
|
|
'fictioneer_query_name' => 'latest_updates_compact',
|
2023-03-09 02:03:09 +01:00
|
|
|
'post_type' => 'fcn_story',
|
|
|
|
'post_status' => 'publish',
|
2023-08-17 01:32:02 +02:00
|
|
|
'post__in' => $args['post_ids'], // May be empty!
|
2023-09-16 13:25:38 +02:00
|
|
|
'order' => $args['order'],
|
2023-01-21 01:31:34 +01:00
|
|
|
'orderby' => 'meta_value',
|
2023-09-16 13:25:38 +02:00
|
|
|
'meta_key' => 'fictioneer_chapters_added',
|
2023-09-16 22:59:43 +02:00
|
|
|
'posts_per_page' => $args['count'] + 4, // Account for non-eligible posts!
|
2024-01-28 18:59:23 +01:00
|
|
|
'no_found_rows' => true,
|
|
|
|
'update_post_term_cache' => false
|
|
|
|
);
|
|
|
|
|
|
|
|
// Use extended meta query?
|
2024-01-28 19:55:54 +01:00
|
|
|
if ( get_option( 'fictioneer_disable_extended_story_list_meta_queries' ) ) {
|
2024-01-28 20:45:32 +01:00
|
|
|
$query_args['meta_key'] = 'fictioneer_story_hidden';
|
|
|
|
$query_args['meta_value'] = '0';
|
2024-01-28 18:59:23 +01:00
|
|
|
} else {
|
|
|
|
$query_args['meta_query'] = array(
|
2024-01-28 19:55:54 +01:00
|
|
|
'relation' => 'OR',
|
2024-01-28 18:59:23 +01:00
|
|
|
array(
|
|
|
|
'key' => 'fictioneer_story_hidden',
|
|
|
|
'value' => '0'
|
2024-01-28 19:55:54 +01:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'key' => 'fictioneer_story_hidden',
|
|
|
|
'compare' => 'NOT EXISTS'
|
2024-01-28 18:59:23 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-09-16 13:25:38 +02:00
|
|
|
// Author?
|
2023-09-17 01:28:14 +02:00
|
|
|
if ( ! empty( $args['author'] ) ) {
|
2023-09-16 13:25:38 +02:00
|
|
|
$query_args['author_name'] = $args['author'];
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-09-16 22:59:43 +02:00
|
|
|
// Author IDs?
|
|
|
|
if ( ! empty( $args['author_ids'] ) ) {
|
|
|
|
$query_args['author__in'] = $args['author_ids'];
|
|
|
|
}
|
|
|
|
|
2023-03-08 23:24:41 +01:00
|
|
|
// Taxonomies?
|
|
|
|
if ( ! empty( $args['taxonomies'] ) ) {
|
|
|
|
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
|
|
|
}
|
|
|
|
|
2023-03-10 17:09:46 +01:00
|
|
|
// Excluded tags?
|
|
|
|
if ( ! empty( $args['excluded_tags'] ) ) {
|
|
|
|
$query_args['tag__not_in'] = $args['excluded_tags'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Excluded categories?
|
|
|
|
if ( ! empty( $args['excluded_cats'] ) ) {
|
|
|
|
$query_args['category__not_in'] = $args['excluded_cats'];
|
|
|
|
}
|
|
|
|
|
2023-09-16 22:59:43 +02:00
|
|
|
// Excluded authors?
|
|
|
|
if ( ! empty( $args['excluded_authors'] ) ) {
|
|
|
|
$query_args['author__not_in'] = $args['excluded_authors'];
|
|
|
|
}
|
|
|
|
|
2023-09-15 15:15:45 +02:00
|
|
|
// Ignore protected?
|
|
|
|
if ( $args['ignore_protected'] ) {
|
|
|
|
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|
|
|
}
|
|
|
|
|
2023-03-09 11:08:23 +01:00
|
|
|
// Apply filters
|
2023-03-10 15:20:48 +01:00
|
|
|
$query_args = apply_filters( 'fictioneer_filter_shortcode_latest_updates_query_args', $query_args, $args );
|
2023-03-09 11:08:23 +01:00
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// Query stories
|
2023-08-03 13:17:32 +02:00
|
|
|
$entries = fictioneer_shortcode_query( $query_args );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-09-15 15:15:45 +02:00
|
|
|
// Remove temporary filters
|
|
|
|
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
?>
|
|
|
|
|
2023-09-15 22:42:34 +02:00
|
|
|
<section class="small-card-block latest-updates <?php echo $args['classes']; ?>">
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php if ( $entries->have_posts() ) : ?>
|
|
|
|
|
2024-01-19 14:55:50 +01:00
|
|
|
<ul class="grid-columns _collapse-on-mobile">
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php while ( $entries->have_posts() ) : $entries->the_post(); ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// Setup
|
2023-08-05 18:31:39 +02:00
|
|
|
$story = fictioneer_get_story_data( $post->ID, false ); // Does not refresh comment count!
|
2023-01-21 01:31:34 +01:00
|
|
|
$chapter_list = [];
|
|
|
|
$chapter_excerpt; // Set inside inner loop
|
|
|
|
$chapter_title; // Set inside inner loop
|
|
|
|
|
|
|
|
// Skip if no chapters
|
2023-08-28 10:43:04 +02:00
|
|
|
if ( $story['chapter_count'] < 1 ) {
|
|
|
|
continue;
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Search for viable chapters...
|
|
|
|
$search_list = array_reverse( $story['chapter_ids'] );
|
|
|
|
|
|
|
|
foreach ( $search_list as $chapter_id ) {
|
2023-11-30 16:03:53 +01:00
|
|
|
if ( get_post_meta( $chapter_id, 'fictioneer_chapter_hidden', true ) ) {
|
2023-08-28 10:43:04 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
$chapter_list[] = $chapter_id;
|
|
|
|
break; // Only one needed
|
|
|
|
}
|
|
|
|
|
|
|
|
// No viable chapters
|
2023-08-28 10:43:04 +02:00
|
|
|
if ( count( $chapter_list ) < 1 ) {
|
|
|
|
continue;
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Count actually rendered cards to account for buffer
|
2023-09-16 13:25:38 +02:00
|
|
|
if ( ++$card_counter > $args['count'] ) {
|
|
|
|
break;
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
?>
|
|
|
|
|
2023-06-09 21:52:17 +02:00
|
|
|
<li class="card watch-last-clicked _small _info">
|
2023-01-21 01:31:34 +01:00
|
|
|
<div class="card__body polygon">
|
|
|
|
|
2023-06-11 19:24:16 +02:00
|
|
|
<button class="card__info-toggle toggle-last-clicked" aria-label="<?php esc_attr_e( 'Open info box', 'fictioneer' ); ?>"><i class="fa-solid fa-chevron-down"></i></button>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
<div class="card__main _grid _small">
|
|
|
|
|
2024-01-28 00:42:09 +01:00
|
|
|
<?php do_action( 'fictioneer_shortcode_latest_updates_card_body', $post, $story, $args ); ?>
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php if ( has_post_thumbnail() ) : ?>
|
|
|
|
<a href="<?php the_post_thumbnail_url( 'full' ); ?>" title="<?php echo esc_attr( sprintf( __( '%s Thumbnail', 'fictioneer' ), $story['title'] ) ); ?>" class="card__image cell-img" <?php echo fictioneer_get_lightbox_attribute(); ?>><?php echo get_the_post_thumbnail( $post, 'snippet', ['class' => 'no-auto-lightbox'] ); ?></a>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
2024-01-18 21:44:29 +01:00
|
|
|
<h3 class="card__title _small cell-title"><a href="<?php the_permalink(); ?>" class="truncate _1-1"><?php
|
|
|
|
if ( ! empty( $post->post_password ) ) {
|
|
|
|
echo '<i class="fa-solid fa-lock protected-icon"></i> ';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $story['title'];
|
|
|
|
?></a></h3>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-01-19 14:13:17 +01:00
|
|
|
<div class="card__content _small cell-desc">
|
2024-01-19 22:24:08 +01:00
|
|
|
<div class="truncate _cq-1-2">
|
2024-01-19 14:13:17 +01:00
|
|
|
<?php if ( get_option( 'fictioneer_show_authors' ) ) : ?>
|
|
|
|
<span class="card__by-author"><?php
|
|
|
|
printf( _x( 'by %s —', 'Small card: by {Author} —.', 'fictioneer' ), fictioneer_get_author_node() );
|
|
|
|
?></span>
|
|
|
|
<?php endif; ?>
|
|
|
|
<span><?php
|
|
|
|
$short_description = fictioneer_first_paragraph_as_excerpt(
|
|
|
|
fictioneer_get_content_field( 'fictioneer_story_short_description', $post->ID )
|
|
|
|
);
|
|
|
|
echo strlen( $short_description ) < 230 ? get_the_excerpt() : $short_description;
|
2023-06-04 14:02:12 +02:00
|
|
|
?></span>
|
2024-01-19 14:13:17 +01:00
|
|
|
</div>
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<ol class="card__link-list _small cell-list">
|
|
|
|
<?php foreach ( $chapter_list as $chapter_id ) : ?>
|
|
|
|
<?php
|
|
|
|
// Chapter title
|
2023-11-30 16:03:53 +01:00
|
|
|
$list_title = get_post_meta( $chapter_id, 'fictioneer_chapter_list_title', true );
|
2023-10-08 15:28:23 +02:00
|
|
|
$list_title = trim( wp_strip_all_tags( $list_title ) );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
if ( empty( $list_title ) ) {
|
|
|
|
$chapter_title = fictioneer_get_safe_title( $chapter_id );
|
|
|
|
} else {
|
2023-10-08 15:28:23 +02:00
|
|
|
$chapter_title = $list_title;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Chapter excerpt
|
2024-01-19 22:24:08 +01:00
|
|
|
$chapter_excerpt = fictioneer_get_forced_excerpt( $chapter_id, 768 );
|
2023-01-21 01:31:34 +01:00
|
|
|
?>
|
2023-08-30 10:42:10 +02:00
|
|
|
<li class="card__link-list-item">
|
2023-01-21 01:31:34 +01:00
|
|
|
<div class="card__left text-overflow-ellipsis">
|
|
|
|
<i class="fa-solid fa-caret-right"></i>
|
2023-09-18 13:20:45 +02:00
|
|
|
<a href="<?php the_permalink( $chapter_id ); ?>" class="card__link-list-link"><?php
|
|
|
|
echo $chapter_title;
|
|
|
|
?></a>
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
2023-06-06 13:43:49 +02:00
|
|
|
<div class="card__right">
|
2023-06-04 20:45:25 +02:00
|
|
|
<?php
|
2023-11-30 17:10:19 +01:00
|
|
|
echo fictioneer_shorten_number( fictioneer_get_word_count( $chapter_id ) );
|
2023-06-06 13:43:49 +02:00
|
|
|
echo '<span class="separator-dot"> • </span>';
|
2023-06-06 20:04:45 +02:00
|
|
|
echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter_id )
|
2023-06-04 20:45:25 +02:00
|
|
|
?>
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card__overlay-infobox _excerpt escape-last-click">
|
2024-01-19 22:24:08 +01:00
|
|
|
<div class="card__excerpt"><strong><?php echo $chapter_title; ?>:</strong> <?php echo $chapter_excerpt; ?></div>
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<?php endwhile; ?>
|
|
|
|
</ul>
|
|
|
|
|
2023-11-30 17:52:19 +01:00
|
|
|
<?php else : ?>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-09-16 13:25:38 +02:00
|
|
|
<div class="no-results"><?php _e( 'Nothing to show.', 'fictioneer' ); ?></div>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
<?php endif; wp_reset_postdata(); ?>
|
|
|
|
</section>
|