2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Partial: Story Card
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Fictioneer
|
|
|
|
* @since 4.0
|
|
|
|
*
|
2023-06-07 23:23:19 +02:00
|
|
|
* @internal $args['show_type'] Whether to show the post type label. Unsafe.
|
|
|
|
* @internal $args['cache'] Whether to account for active caching. Unsafe.
|
|
|
|
* @internal $args['hide_author'] Whether to hide the author. Unsafe.
|
|
|
|
* @internal $args['show_latest'] Whether to show (up to) the latest 3 chapters. Unsafe.
|
|
|
|
* @internal $args['order'] Current order. Default 'desc'. Unsafe.
|
|
|
|
* @internal $args['orderby'] Current orderby. Default 'modified'. Unsafe.
|
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
|
|
|
|
$story = fictioneer_get_story_data( $post->ID );
|
2023-08-08 01:51:03 +02:00
|
|
|
$latest = $args['show_latest'] ?? false;
|
2023-01-21 01:31:34 +01:00
|
|
|
$chapter_ids = array_slice( $story['chapter_ids'], $latest ? -3 : 0, 3, true ); // Does not include hidden or non-chapters
|
2023-08-08 01:51:03 +02:00
|
|
|
$chapter_count = count( $chapter_ids );
|
2023-11-30 16:03:53 +01:00
|
|
|
$excerpt = fictioneer_first_paragraph_as_excerpt(
|
|
|
|
fictioneer_get_content_field( 'fictioneer_story_short_description', $post->ID )
|
|
|
|
);
|
2023-08-08 01:51:03 +02:00
|
|
|
$excerpt = empty( $excerpt ) ? __( 'No description provided yet.', 'fictioneer' ) : $excerpt;
|
|
|
|
$tags = false;
|
|
|
|
|
|
|
|
if (
|
|
|
|
get_option( 'fictioneer_show_tags_on_story_cards' ) &&
|
|
|
|
! get_option( 'fictioneer_hide_taxonomies_on_story_cards' )
|
|
|
|
) {
|
|
|
|
$tags = get_the_tags();
|
2023-02-04 16:15:25 +01:00
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Flags
|
2023-08-08 01:51:03 +02:00
|
|
|
$hide_author = $args['hide_author'] ?? false && ! get_option( 'fictioneer_show_authors' );
|
2023-01-21 01:31:34 +01:00
|
|
|
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' ) && ( $story['has_taxonomies'] || $tags );
|
2023-08-08 01:51:03 +02:00
|
|
|
$show_type = $args['show_type'] ?? false;
|
|
|
|
$is_sticky = FICTIONEER_ENABLE_STICKY_CARDS &&
|
2023-11-30 16:03:53 +01:00
|
|
|
get_post_meta( $post->ID, 'fictioneer_story_sticky', true ) && ! is_search() && ! is_archive();
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
2023-06-09 23:19:18 +02:00
|
|
|
<li
|
2023-12-02 00:00:13 +01:00
|
|
|
id="story-card-<?php echo $post->ID; ?>"
|
2023-08-08 01:51:03 +02:00
|
|
|
class="card <?php echo $is_sticky ? '_sticky' : ''; ?>"
|
2023-06-09 23:19:18 +02:00
|
|
|
data-story-id="<?php echo $post->ID; ?>"
|
|
|
|
data-check-id="<?php echo $post->ID; ?>"
|
|
|
|
>
|
2023-01-21 01:31:34 +01:00
|
|
|
<div class="card__body polygon">
|
|
|
|
|
|
|
|
<div class="card__header _large">
|
|
|
|
|
|
|
|
<?php if ( $show_type ) : ?>
|
|
|
|
<div class="card__label"><?php _ex( 'Story', 'Story card label.', 'fictioneer' ); ?></div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
2024-01-18 21:44:29 +01:00
|
|
|
<h3 class="card__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
|
|
|
|
2023-08-08 01:51:03 +02:00
|
|
|
<?php if ( $is_sticky ) : ?>
|
2023-02-04 16:15:25 +01:00
|
|
|
<div class="card__sticky-icon" title="<?php echo esc_attr__( 'Sticky', 'fictioneer' ); ?>"><i class="fa-solid fa-thumbtack"></i></div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
2023-12-02 00:00:13 +01:00
|
|
|
<?php echo fictioneer_get_card_controls( $post->ID ); ?>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card__main _grid _large">
|
|
|
|
|
2023-08-08 01:51:03 +02:00
|
|
|
<?php
|
|
|
|
// Thumbnail
|
|
|
|
if ( has_post_thumbnail() ) {
|
|
|
|
printf(
|
|
|
|
'<a href="%1$s" title="%2$s" class="card__image cell-img" %3$s>%4$s</a>',
|
|
|
|
get_the_post_thumbnail_url( null, 'full' ),
|
|
|
|
sprintf( __( '%s Thumbnail', 'fictioneer' ), $story['title'] ),
|
|
|
|
fictioneer_get_lightbox_attribute(),
|
|
|
|
get_the_post_thumbnail( null, 'cover' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Content
|
|
|
|
printf(
|
|
|
|
'<div class="card__content cell-desc truncate %1$s">%2$s<span>%3$s</span></div>',
|
|
|
|
$chapter_count > 2 ? '_3-4' : '_4-4',
|
|
|
|
$hide_author ? '' : sprintf(
|
|
|
|
'<span class="card__by-author show-below-desktop">%s</span> ',
|
|
|
|
sprintf(
|
|
|
|
_x( 'by %s —', 'Large card: by {Author} —.', 'fictioneer' ),
|
|
|
|
fictioneer_get_author_node()
|
|
|
|
)
|
|
|
|
),
|
|
|
|
$excerpt
|
|
|
|
);
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php if ( $chapter_count > 0 ): ?>
|
2023-01-21 01:31:34 +01:00
|
|
|
<ol class="card__link-list cell-list">
|
2023-08-04 01:33:12 +02:00
|
|
|
<?php
|
|
|
|
// Prepare
|
|
|
|
$chapter_query_args = array(
|
|
|
|
'post_type' => 'fcn_chapter',
|
|
|
|
'post_status' => 'publish',
|
2023-08-21 00:57:56 +02:00
|
|
|
'post__in' => fictioneer_rescue_array_zero( $chapter_ids ),
|
2023-08-26 21:11:29 +02:00
|
|
|
'orderby' => 'post__in',
|
2023-08-04 01:33:12 +02:00
|
|
|
'posts_per_page' => -1,
|
|
|
|
'no_found_rows' => true, // Improve performance
|
|
|
|
'update_post_term_cache' => false // Improve performance
|
|
|
|
);
|
|
|
|
|
|
|
|
$chapters = new WP_Query( $chapter_query_args );
|
|
|
|
?>
|
|
|
|
<?php foreach ( $chapters->posts as $chapter ) : ?>
|
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
|
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
|
|
|
|
2023-08-08 01:51:03 +02:00
|
|
|
if ( empty( $list_title ) ) {
|
2023-08-04 01:33:12 +02:00
|
|
|
echo fictioneer_get_safe_title( $chapter->ID );
|
2023-08-08 01:51:03 +02:00
|
|
|
} else {
|
2023-10-08 15:28:23 +02:00
|
|
|
echo $list_title;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
?></a>
|
|
|
|
</div>
|
2023-06-06 13:44:16 +02:00
|
|
|
<div class="card__right">
|
|
|
|
<?php
|
2023-08-08 01:51:03 +02:00
|
|
|
printf(
|
|
|
|
'%1$s<span class="hide-below-480"> %2$s</span><span class="separator-dot"> • </span>%3$s',
|
2023-11-30 17:10:19 +01:00
|
|
|
fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) ),
|
2023-08-08 01:51:03 +02:00
|
|
|
__( 'Words', 'fictioneer' ),
|
|
|
|
strtotime( '-1 days' ) < strtotime( get_the_date( '', $chapter->ID ) ) ?
|
2023-08-17 00:40:44 +02:00
|
|
|
__( 'New', 'fictioneer' ) : get_the_time( FICTIONEER_CARD_STORY_LI_DATE, $chapter->ID )
|
2023-08-08 01:51:03 +02:00
|
|
|
);
|
2023-06-06 13:44:16 +02:00
|
|
|
?>
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</ol>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<?php if ( $show_taxonomies ) : ?>
|
2023-06-04 01:49:00 +02:00
|
|
|
<div class="card__tag-list cell-tax">
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
2023-08-08 01:51:03 +02:00
|
|
|
$taxonomies = array_merge(
|
|
|
|
$story['fandoms'] ? fictioneer_generate_card_tags( $story['fandoms'], '_fandom' ) : [],
|
|
|
|
$story['genres'] ? fictioneer_generate_card_tags( $story['genres'], '_genre' ) : [],
|
|
|
|
$tags ? fictioneer_generate_card_tags( $tags ) : [],
|
|
|
|
$story['characters'] ? fictioneer_generate_card_tags( $story['characters'], '_character' ) : []
|
|
|
|
);
|
2023-06-04 01:49:00 +02:00
|
|
|
|
|
|
|
// Implode with three-per-em spaces around a bullet
|
2023-08-08 01:51:03 +02:00
|
|
|
echo implode( ' • ', $taxonomies );
|
2023-01-21 01:31:34 +01:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card__footer">
|
|
|
|
|
2023-08-30 10:42:10 +02:00
|
|
|
<div class="card__footer-box _left text-overflow-ellipsis"><?php
|
2023-08-30 02:32:39 +02:00
|
|
|
// Build footer items
|
|
|
|
$footer_items = [];
|
|
|
|
|
2023-11-14 19:20:54 +01:00
|
|
|
if ( $story['status'] !== 'Oneshot' || $story['chapter_count'] > 1 ) {
|
|
|
|
$footer_items['chapters'] = '<i class="card-footer-icon fa-solid fa-list" title="' .
|
|
|
|
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
|
|
|
}
|
2023-08-30 02:32:39 +02:00
|
|
|
|
2023-08-30 10:42:10 +02:00
|
|
|
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
|
|
|
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
2023-08-30 02:32:39 +02:00
|
|
|
|
|
|
|
if ( ( $args['orderby'] ?? 0 ) === 'date' ) {
|
2023-08-30 10:42:10 +02:00
|
|
|
$footer_items['publish_date'] = '<i class="card-footer-icon fa-solid fa-clock" title="' .
|
2023-08-30 02:32:39 +02:00
|
|
|
esc_attr__( 'Published', 'fictioneer' ) .'"></i> ' . get_the_date( FICTIONEER_CARD_STORY_FOOTER_DATE );
|
|
|
|
} else {
|
2023-08-30 10:42:10 +02:00
|
|
|
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
2023-08-30 02:32:39 +02:00
|
|
|
esc_attr__( 'Last Updated', 'fictioneer' ) .'"></i> ' . get_the_modified_date( FICTIONEER_CARD_STORY_FOOTER_DATE );
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-30 02:32:39 +02:00
|
|
|
if ( ! $hide_author ) {
|
2023-08-30 10:42:10 +02:00
|
|
|
$footer_items['author'] = '<i class="card-footer-icon fa-solid fa-circle-user hide-below-desktop"></i> ' .
|
2023-08-30 02:32:39 +02:00
|
|
|
fictioneer_get_author_node( get_the_author_meta( 'ID' ), 'hide-below-desktop' );
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-30 10:42:10 +02:00
|
|
|
$footer_items['comments'] = '<i class="card-footer-icon fa-solid fa-message hide-below-480" title="' .
|
2023-08-30 02:32:39 +02:00
|
|
|
esc_attr__( 'Comments', 'fictioneer' ) . '"></i> <span class="hide-below-480" title="' .
|
|
|
|
esc_attr__( 'Comments', 'fictioneer' ) . '">' . $story['comment_count'] . '</span>';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-30 10:42:10 +02:00
|
|
|
$footer_items['status'] = '<i class="card-footer-icon ' . $story['icon'] . '"></i> ' . fcntr( $story['status'] );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-30 02:32:39 +02:00
|
|
|
// Filer footer items
|
2023-09-10 18:36:12 +02:00
|
|
|
$footer_items = apply_filters( 'fictioneer_filter_story_card_footer', $footer_items, $post, $story, $args );
|
2023-06-04 22:17:42 +02:00
|
|
|
|
2023-08-30 02:32:39 +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 _large tooltipped" data-tooltip="<?php echo fcntr( $story['rating'], true ); ?>">
|
2023-01-21 01:31:34 +01:00
|
|
|
<span class="hide-below-480"><?php echo fcntr( $story['rating'] ); ?></span>
|
|
|
|
<span class="show-below-480"><?php echo fcntr( $story['rating_letter'] ); ?></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|