2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Partial: Latest Stories Compact
|
|
|
|
*
|
|
|
|
* Renders the (buffered) HTML for the [fictioneer_latest_stories type="compact"] shortcode.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Fictioneer
|
|
|
|
* @since 4.0
|
|
|
|
*
|
2023-08-19 22:22:56 +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['orderby'] Sorting of posts. Default 'date'.
|
|
|
|
* @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'] Array 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-06-09 02:06:45 +02:00
|
|
|
// Setup
|
|
|
|
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' );
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// Prepare query
|
|
|
|
$query_args = array(
|
2023-03-08 13:22:04 +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-08-07 12:07:48 +02:00
|
|
|
'orderby' => $args['orderby'],
|
2023-01-21 01:31:34 +01:00
|
|
|
'order' => $args['order'] ?? 'desc',
|
|
|
|
'posts_per_page' => $args['count'],
|
2023-05-07 01:45:42 +02:00
|
|
|
'meta_query' => array(
|
|
|
|
'relation' => 'OR',
|
|
|
|
array(
|
|
|
|
'key' => 'fictioneer_story_hidden',
|
|
|
|
'value' => '0'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'key' => 'fictioneer_story_hidden',
|
|
|
|
'compare' => 'NOT EXISTS'
|
|
|
|
),
|
|
|
|
),
|
2023-01-21 01:31:34 +01:00
|
|
|
'no_found_rows' => true
|
|
|
|
);
|
|
|
|
|
2023-08-07 12:07:48 +02:00
|
|
|
if ( FICTIONEER_ENABLE_STICKY_CARDS ) {
|
|
|
|
$query_args['meta_key'] = 'fictioneer_story_sticky';
|
|
|
|
$query_args['orderby'] = 'meta_value ' . $query_args['orderby'];
|
|
|
|
}
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// Parameter for author?
|
|
|
|
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author'];
|
|
|
|
|
2023-03-08 13:22:04 +01:00
|
|
|
// Taxonomies?
|
|
|
|
if ( ! empty( $args['taxonomies'] ) ) {
|
2023-03-08 23:24:41 +01:00
|
|
|
$query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args );
|
2023-03-08 13:22:04 +01:00
|
|
|
}
|
|
|
|
|
2023-03-10 16:35:47 +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-03-08 13:22:04 +01:00
|
|
|
// Apply filters
|
2023-03-10 15:20:48 +01:00
|
|
|
$query_args = apply_filters( 'fictioneer_filter_shortcode_latest_stories_query_args', $query_args, $args );
|
2023-03-08 13:22:04 +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-03-08 13:22:04 +01:00
|
|
|
<section class="small-card-block latest-stories _compact <?php echo implode( ' ', $args['classes'] ); ?>">
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php if ( $entries->have_posts() ) : ?>
|
|
|
|
|
|
|
|
<ul class="two-columns _collapse-on-mobile">
|
|
|
|
<?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
|
|
|
$tags = get_option( 'fictioneer_show_tags_on_story_cards' ) ? get_the_tags( $post ) : false;
|
|
|
|
?>
|
|
|
|
|
2023-06-09 21:52:17 +02:00
|
|
|
<li class="card watch-last-clicked _small <?php echo $show_taxonomies ? '_info' : ''; ?>">
|
2023-01-21 01:31:34 +01:00
|
|
|
<div class="card__body polygon">
|
|
|
|
|
2023-06-09 02:06:45 +02:00
|
|
|
<?php if ( $show_taxonomies ) : ?>
|
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
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<div class="card__main _grid _small">
|
|
|
|
|
|
|
|
<?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; ?>
|
|
|
|
|
2023-02-09 10:44:04 +01:00
|
|
|
<h3 class="card__title _small cell-title"><a href="<?php the_permalink(); ?>" class="truncate _1-1"><?php echo $story['title']; ?></a></h3>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-02-09 10:44:04 +01:00
|
|
|
<div class="card__content _small cell-desc truncate _3-3">
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php if ( get_option( 'fictioneer_show_authors' ) ) : ?>
|
2023-06-04 14:02:12 +02:00
|
|
|
<span class="card__by-author"><?php
|
|
|
|
printf( _x( 'by %s —', 'Small card: by {Author} —.', 'fictioneer' ), fictioneer_get_author_node() );
|
2023-01-21 01:31:34 +01:00
|
|
|
?></span>
|
|
|
|
<?php endif; ?>
|
|
|
|
<span><?php
|
|
|
|
$short_description = fictioneer_first_paragraph_as_excerpt( fictioneer_get_content_field( 'fictioneer_story_short_description' ) );
|
|
|
|
echo strlen( $short_description ) < 230 ? get_the_excerpt() : $short_description;
|
|
|
|
?></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card__overlay-infobox escape-last-click">
|
|
|
|
|
2023-06-09 02:06:45 +02:00
|
|
|
<?php if ( $show_taxonomies ) : ?>
|
2023-06-04 01:49:00 +02:00
|
|
|
<div class="card__tag-list _small truncate _2-2">
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
if ( $story['has_taxonomies'] || $tags ) {
|
2023-06-04 01:49:00 +02:00
|
|
|
$output = [];
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
if ( $story['fandoms'] ) {
|
|
|
|
foreach ( $story['fandoms'] as $fandom ) {
|
2023-06-04 01:49:00 +02:00
|
|
|
$output[] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $story['genres'] ) {
|
|
|
|
foreach ( $story['genres'] as $genre ) {
|
2023-06-04 01:49:00 +02:00
|
|
|
$output[] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $tags ) {
|
|
|
|
foreach ( $tags as $tag ) {
|
2023-06-04 01:49:00 +02:00
|
|
|
$output[] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $story['characters'] ) {
|
|
|
|
foreach ( $story['characters'] as $character ) {
|
2023-06-04 01:49:00 +02:00
|
|
|
$output[] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
}
|
2023-06-04 01:49:00 +02:00
|
|
|
|
|
|
|
// Implode with three-per-em spaces around a bullet
|
2023-06-04 02:05:11 +02:00
|
|
|
echo implode( ' • ', $output );
|
2023-01-21 01:31:34 +01:00
|
|
|
} else {
|
|
|
|
?><span class="card__no-taxonomies"><?php _e( 'No taxonomies specified yet.', 'fictioneer' ); ?></span><?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<div class="card__footer _small">
|
2023-06-04 22:17:42 +02:00
|
|
|
|
2023-09-10 14:52:47 +02:00
|
|
|
<div class="card__footer-box _left text-overflow-ellipsis"><?php
|
|
|
|
|
|
|
|
// Build footer items
|
|
|
|
$footer_items = [];
|
|
|
|
|
|
|
|
$footer_items['chapters'] = '<i class="card-footer-icon fa-solid fa-list" title="' .
|
|
|
|
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
|
|
|
|
|
|
|
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
|
|
|
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
|
|
|
|
2023-09-10 18:27:47 +02:00
|
|
|
if ( $args['orderby'] == 'modified' ) {
|
2023-09-10 14:52:47 +02:00
|
|
|
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
|
|
|
esc_attr__( 'Last Updated', 'fictioneer' ) . '"></i> ' .
|
|
|
|
get_the_modified_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post );
|
2023-09-10 18:27:47 +02:00
|
|
|
} else {
|
|
|
|
$footer_items['publish_date'] = '<i class="card-footer-icon fa-solid fa-clock" title="' .
|
|
|
|
esc_attr__( 'Published', 'fictioneer' ) . '"></i> ' .
|
|
|
|
get_the_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post );
|
2023-09-10 14:52:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$footer_items['status'] = '<i class="card-footer-icon ' . $story['icon'] . '"></i> ' .
|
|
|
|
fcntr( $story['status'] );
|
|
|
|
|
|
|
|
// Filer footer items
|
|
|
|
$footer_items = apply_filters(
|
2023-09-10 16:32:56 +02:00
|
|
|
'fictioneer_filter_shortcode_latest_stories_card_footer',
|
2023-09-10 14:52:47 +02:00
|
|
|
$footer_items,
|
|
|
|
$story,
|
|
|
|
$args,
|
2023-09-10 16:32:56 +02:00
|
|
|
$post
|
2023-09-10 14:52:47 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Implode and render footer items
|
|
|
|
echo implode( ' ', $footer_items );
|
|
|
|
|
|
|
|
?></div>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-30 10:42:10 +02:00
|
|
|
<div class="card__footer-box _right rating-letter-label tooltipped" data-tooltip="<?php echo fcntr( $story['rating'], true ); ?>">
|
2023-06-04 22:17:42 +02:00
|
|
|
<?php echo fcntr( $story['rating_letter'] ); ?>
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
2023-06-04 22:17:42 +02:00
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<?php endwhile; ?>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<?php else: ?>
|
|
|
|
|
|
|
|
<div class="no-results"><?php _e( 'No stories have been published yet.', 'fictioneer' ) ?></div>
|
|
|
|
|
|
|
|
<?php endif; wp_reset_postdata(); ?>
|
|
|
|
</section>
|