2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Partial: Post Collection
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Fictioneer
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 4.0.0
|
2023-01-21 01:31:34 +01:00
|
|
|
*
|
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['order'] Current order. Default 'desc'. Unsafe.
|
|
|
|
* @internal $args['orderby'] Current orderby. Default 'modified'. Unsafe.
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2023-08-20 20:21:48 +02:00
|
|
|
// No direct access!
|
|
|
|
defined( 'ABSPATH' ) OR exit;
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// Setup
|
2024-05-17 17:46:54 +02:00
|
|
|
$post_id = $post->ID;
|
|
|
|
$list_title = trim( get_post_meta( $post_id, 'fictioneer_collection_list_title', true ) );
|
|
|
|
$title = empty( $list_title ) ? fictioneer_get_safe_title( $post_id, 'card-collection' ) : $list_title;
|
2024-07-20 23:13:26 +02:00
|
|
|
$excerpt = fictioneer_first_paragraph_as_excerpt(
|
|
|
|
fictioneer_get_content_field( 'fictioneer_collection_description', $post_id )
|
|
|
|
);
|
|
|
|
$excerpt = empty( $excerpt ) ? fictioneer_get_excerpt( $post_id ) : $excerpt;
|
2024-05-17 17:46:54 +02:00
|
|
|
$statistics = fictioneer_get_collection_statistics( $post_id );
|
|
|
|
$items = get_post_meta( $post_id, 'fictioneer_collection_items', true );
|
2023-01-21 01:31:34 +01:00
|
|
|
$items = empty( $items ) ? [] : $items;
|
2024-02-11 23:55:32 +01:00
|
|
|
$card_classes = [];
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Taxonomies
|
2023-08-08 00:15:26 +02:00
|
|
|
$tags = false;
|
|
|
|
$fandoms = false;
|
|
|
|
$characters = false;
|
|
|
|
$genres = false;
|
|
|
|
|
|
|
|
if (
|
|
|
|
get_option( 'fictioneer_show_tags_on_collection_cards' ) &&
|
|
|
|
! get_option( 'fictioneer_hide_taxonomies_on_collection_cards' )
|
|
|
|
) {
|
|
|
|
$tags = get_the_tags();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! get_option( 'fictioneer_hide_taxonomies_on_collection_cards' ) ) {
|
2024-05-17 17:46:54 +02:00
|
|
|
$fandoms = get_the_terms( $post_id, 'fcn_fandom' );
|
|
|
|
$characters = get_the_terms( $post_id, 'fcn_character' );
|
|
|
|
$genres = get_the_terms( $post_id, 'fcn_genre' );
|
2023-08-08 00:15:26 +02:00
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Flags
|
2024-08-23 23:12:24 +02:00
|
|
|
$show_terms = ! get_option( 'fictioneer_hide_taxonomies_on_collection_cards' ) && ( $fandoms || $characters || $genres || $tags );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-08 00:15:26 +02:00
|
|
|
// Query featured posts
|
|
|
|
if ( ! empty( $items ) ) {
|
|
|
|
$items = new WP_Query(
|
|
|
|
array(
|
|
|
|
'post_type' => 'any',
|
|
|
|
'post_status' => 'publish',
|
2024-05-14 22:59:02 +02:00
|
|
|
'post__in' => $items ?: [0], // Must not be empty!
|
2023-08-08 00:15:26 +02:00
|
|
|
'ignore_sticky_posts' => true,
|
|
|
|
'orderby' => 'modified',
|
2024-01-26 14:40:56 +01:00
|
|
|
'posts_per_page' => 3,
|
2023-08-08 00:15:26 +02:00
|
|
|
'update_post_meta_cache' => false, // Improve performance
|
|
|
|
'update_post_term_cache' => false, // Improve performance
|
|
|
|
'no_found_rows' => true // Improve performance
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$items = $items->posts;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2024-02-12 00:27:58 +01:00
|
|
|
// Extra classes
|
2024-02-12 01:40:38 +01:00
|
|
|
if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
|
|
|
$card_classes[] = '_' . get_theme_mod( 'card_style' );
|
2024-02-12 00:27:58 +01:00
|
|
|
}
|
|
|
|
|
2024-05-14 18:40:52 +02:00
|
|
|
if ( get_theme_mod( 'card_image_style', 'default' ) !== 'default' ) {
|
|
|
|
$card_classes[] = '_' . get_theme_mod( 'card_image_style' );
|
|
|
|
}
|
|
|
|
|
2024-08-23 23:12:24 +02:00
|
|
|
if ( ! $show_terms ) {
|
|
|
|
$card_classes[] = '_no-tax';
|
|
|
|
}
|
|
|
|
|
2024-03-04 01:54:53 +01:00
|
|
|
// Card attributes
|
|
|
|
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-collection' );
|
|
|
|
$card_attributes = '';
|
|
|
|
|
|
|
|
foreach ( $attributes as $key => $value ) {
|
|
|
|
$card_attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
|
|
|
|
}
|
|
|
|
|
2024-03-16 14:49:51 +01:00
|
|
|
// Thumbnail attributes
|
|
|
|
$thumbnail_args = array(
|
|
|
|
'alt' => sprintf( __( '%s Thumbnail', 'fictioneer' ), $title ),
|
|
|
|
'class' => 'no-auto-lightbox'
|
|
|
|
);
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
?>
|
|
|
|
|
2024-05-17 17:46:54 +02:00
|
|
|
<li id="collection-card-<?php echo $post_id; ?>" class="post-<?php echo $post_id; ?> card _large _collection <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
2023-01-21 01:31:34 +01:00
|
|
|
<div class="card__body polygon">
|
|
|
|
|
2024-05-14 10:05:05 +02:00
|
|
|
<div class="card__main _grid _large">
|
2023-08-08 01:51:03 +02:00
|
|
|
|
2024-05-14 10:05:05 +02:00
|
|
|
<div class="card__header _large">
|
2023-08-08 01:51:03 +02:00
|
|
|
|
2024-05-14 10:05:05 +02:00
|
|
|
<?php if ( $args['show_type'] ?? false ) : ?>
|
|
|
|
<div class="card__label"><?php _ex( 'Collection', 'Collection card label.', 'fictioneer' ); ?></div>
|
|
|
|
<?php endif; ?>
|
2023-08-08 01:51:03 +02:00
|
|
|
|
2024-05-14 10:05:05 +02:00
|
|
|
<h3 class="card__title"><a href="<?php the_permalink(); ?>" class="truncate _1-1"><?php echo $title; ?></a></h3>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-05-14 10:05:05 +02:00
|
|
|
</div>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-08 01:51:03 +02:00
|
|
|
<?php
|
2024-01-27 22:32:10 +01:00
|
|
|
// Action hook
|
|
|
|
do_action( 'fictioneer_large_card_body_collection', $post, $items, $args );
|
|
|
|
|
2023-08-08 01:51:03 +02:00
|
|
|
// Thumbnail
|
2024-05-14 18:40:52 +02:00
|
|
|
if ( has_post_thumbnail() && get_theme_mod( 'card_image_style', 'default' ) !== 'none' ) {
|
2023-08-08 01:51:03 +02:00
|
|
|
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' ), $title ),
|
|
|
|
fictioneer_get_lightbox_attribute(),
|
2024-03-16 14:49:51 +01:00
|
|
|
get_the_post_thumbnail( null, 'cover', $thumbnail_args )
|
2023-08-08 01:51:03 +02:00
|
|
|
);
|
|
|
|
}
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-08 01:51:03 +02:00
|
|
|
// Content
|
|
|
|
printf(
|
2024-01-19 14:13:17 +01:00
|
|
|
'<div class="card__content cell-desc"><div class="truncate %1$s"><span>%2$s</span></div></div>',
|
2024-01-19 22:24:08 +01:00
|
|
|
count( $items ) > 2 ? '_cq-4-3' : '_4-4',
|
2024-07-20 23:13:26 +02:00
|
|
|
fictioneer_truncate( $excerpt ?: __( 'No description provided yet.', 'fictioneer' ), 512 )
|
2023-08-08 01:51:03 +02:00
|
|
|
);
|
|
|
|
?>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-08-08 01:51:03 +02:00
|
|
|
<?php if ( ! empty( $items ) ) : ?>
|
2023-01-21 01:31:34 +01:00
|
|
|
<ol class="card__link-list cell-list">
|
2023-08-08 01:51:03 +02:00
|
|
|
<?php foreach ( $items as $item ) : ?>
|
2024-02-06 14:18:37 +01:00
|
|
|
<?php
|
|
|
|
// Extra classes
|
|
|
|
$list_item_classes = [];
|
|
|
|
|
|
|
|
if ( ! empty( $item->post_password ) ) {
|
|
|
|
$list_item_classes[] = '_password';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<li class="card__link-list-item <?php echo implode( ' ', $list_item_classes ); ?>">
|
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( $item->ID ); ?>" class="card__link-list-link"><?php
|
2023-08-08 01:51:03 +02:00
|
|
|
$list_title = $item->post_type == 'fcn_chapter' ?
|
2023-11-30 16:03:53 +01:00
|
|
|
get_post_meta( $item->ID, 'fictioneer_chapter_list_title', true ) : 0;
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
if ( $list_title ) {
|
|
|
|
echo wp_strip_all_tags( $list_title );
|
|
|
|
} else {
|
2024-03-01 12:39:42 +01:00
|
|
|
echo fictioneer_get_safe_title( $item->ID, 'card-collection-list' );
|
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(
|
2024-05-29 00:06:28 +02:00
|
|
|
'<span class="type">%1$s</span><span class="separator-dot"> • </span><span class="date">%2$s</span>',
|
2023-08-08 01:51:03 +02:00
|
|
|
get_post_type_object( $item->post_type )->labels->singular_name,
|
|
|
|
get_the_modified_date( FICTIONEER_CARD_COLLECTION_LI_DATE, $item->ID )
|
|
|
|
);
|
2023-06-06 13:44:16 +02:00
|
|
|
?>
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</ol>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
2024-08-23 23:35:49 +02:00
|
|
|
<?php
|
|
|
|
if ( $show_terms ) {
|
|
|
|
$terms = array_merge(
|
|
|
|
$fandoms ? fictioneer_get_term_nodes( $fandoms, '_inline _fandom' ) : [],
|
|
|
|
$genres ? fictioneer_get_term_nodes( $genres, '_inline _genre' ) : [],
|
|
|
|
$tags ? fictioneer_get_term_nodes( $tags, '_inline _tag' ) : [],
|
|
|
|
$characters ? fictioneer_get_term_nodes( $characters, '_inline _character' ) : []
|
|
|
|
);
|
|
|
|
|
|
|
|
$terms = apply_filters(
|
|
|
|
'fictioneer_filter_card_collection_terms',
|
|
|
|
$terms, $post, $args, null
|
|
|
|
);
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php if ( $show_terms && $terms ) : ?>
|
|
|
|
<div class="card__tag-list cell-tax"><?php
|
|
|
|
// Implode with separator
|
|
|
|
echo implode( fictioneer_get_bullet_separator( 'collection-card' ), $terms );
|
|
|
|
?></div>
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
|
2024-05-13 23:26:51 +02:00
|
|
|
<div class="card__footer cell-footer">
|
|
|
|
<div class="card__footer-box text-overflow-ellipsis"><?php
|
|
|
|
// Build footer items
|
|
|
|
$footer_items = [];
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-07-28 12:50:45 +02:00
|
|
|
$footer_items['stories'] = '<span class="card__footer-stories"><i class="card-footer-icon fa-solid fa-book" title="' . esc_attr__( 'Stories', 'fictioneer' ) . '"></i> ' . $statistics['story_count'] . '</span>';
|
2023-08-30 02:32:39 +02:00
|
|
|
|
2024-07-28 12:50:45 +02:00
|
|
|
$footer_items['chapters'] = '<span class="card__footer-chapters"><i class="card-footer-icon fa-solid fa-list" title="' . esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $statistics['chapter_count'] . '</span>';
|
2023-08-30 02:32:39 +02:00
|
|
|
|
2024-07-28 12:50:45 +02:00
|
|
|
$footer_items['words'] = '<span class="card__footer-words"><i class="card-footer-icon fa-solid fa-font" title="' . esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . fictioneer_shorten_number( $statistics['word_count'] ) . '</span>';
|
2023-08-30 02:32:39 +02:00
|
|
|
|
2024-05-13 23:26:51 +02:00
|
|
|
if ( ( $args['orderby'] ?? 0 ) === 'date' ) {
|
2024-07-28 12:50:45 +02:00
|
|
|
$footer_items['publish_date'] = '<span class="card__footer-publish-date"><i class="card-footer-icon fa-solid fa-clock" title="' . esc_attr__( 'Published', 'fictioneer' ) .'"></i> ' . get_the_date( FICTIONEER_CARD_COLLECTION_FOOTER_DATE ) . '</span>';
|
2024-05-13 23:26:51 +02:00
|
|
|
} else {
|
2024-07-28 12:50:45 +02:00
|
|
|
$footer_items['modified_date'] = '<span class="card__footer-modified-date"><i class="card-footer-icon fa-regular fa-clock" title="' . esc_attr__( 'Last Updated', 'fictioneer' ) .'"></i> ' . get_the_modified_date( FICTIONEER_CARD_COLLECTION_FOOTER_DATE ) . '</span>';
|
2024-05-13 23:26:51 +02:00
|
|
|
}
|
2023-08-30 02:32:39 +02:00
|
|
|
|
2024-07-28 12:50:45 +02:00
|
|
|
$footer_items['comments'] = '<span class="card__footer-comments"><i class="card-footer-icon fa-solid fa-message" title="' . esc_attr__( 'Comments', 'fictioneer' ) . '"></i> ' . $statistics['comment_count'] . '</span>';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-05-13 23:26:51 +02:00
|
|
|
// Filter footer items
|
|
|
|
$footer_items = apply_filters( 'fictioneer_filter_collection_card_footer', $footer_items, $post, $args, $items );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-05-13 23:26:51 +02:00
|
|
|
// Implode and render footer items
|
|
|
|
echo implode( ' ', $footer_items );
|
|
|
|
?></div>
|
|
|
|
</div>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|