fictioneer/partials/_card-post.php

100 lines
2.9 KiB
PHP
Raw Normal View History

2023-01-21 01:31:34 +01:00
<?php
/**
* Partial: Post 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.
2023-01-21 01:31:34 +01:00
*/
?>
<?php
// No direct access!
defined( 'ABSPATH' ) OR exit;
2023-01-21 01:31:34 +01:00
// Setup
$title = fictioneer_get_safe_title( get_the_ID() );
$tags = get_the_tags();
$categories = wp_get_post_categories( get_the_ID() );
2023-08-08 10:49:46 +02:00
$show_type = $args['show_type'] ?? false;
2023-01-21 01:31:34 +01:00
?>
<li id="post-card-<?php the_ID(); ?>" class="card">
<div class="card__body polygon">
<div class="card__header _large">
<?php if ( $show_type ) : ?>
<div class="card__label"><?php _ex( 'Blog', 'Blog card label.', 'fictioneer' ); ?></div>
<?php endif; ?>
<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
</div>
<div class="card__main _grid _large">
2023-08-08 10:49:46 +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' ), $title ),
fictioneer_get_lightbox_attribute(),
get_the_post_thumbnail( null, 'cover' )
);
}
?>
2023-01-21 01:31:34 +01:00
2023-08-08 10:49:46 +02:00
<div class="card__content cell-desc truncate _4-4"><span><?php the_excerpt(); ?></span></div>
2023-01-21 01:31:34 +01:00
<?php if ( $categories || $tags ) : ?>
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-06-04 01:49:00 +02:00
$output = [];
2023-01-21 01:31:34 +01:00
if ( $categories ) {
foreach ( $categories as $cat ) {
$output[] = '<a href="' . get_category_link( $cat ) . '" class="tag-pill _inline _category">' . get_category( $cat )->name . '</a>';
2023-01-21 01:31:34 +01:00
}
}
if ( $tags ) {
foreach ( $tags as $tag ) {
$output[] = "<a href='" . get_tag_link( $tag ) . "' class='tag-pill _inline'>{$tag->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
echo implode( '&#8196;&bull;&#8196;', $output );
2023-01-21 01:31:34 +01:00
?>
</div>
<?php endif; ?>
</div>
<div class="card__footer">
2023-08-08 10:49:46 +02:00
2023-01-21 01:31:34 +01:00
<div class="card__left text-overflow-ellipsis">
2023-08-08 10:49:46 +02:00
2023-01-21 01:31:34 +01:00
<?php if ( get_option( 'fictioneer_show_authors' ) ) : ?>
2023-07-09 18:16:55 +02:00
<i class="fa-solid fa-circle-user"></i>
2023-01-21 01:31:34 +01:00
<?php fictioneer_the_author_node( get_the_author_meta( 'ID' ) ); ?>
<?php endif; ?>
2023-08-08 10:49:46 +02:00
<i class="fa-solid fa-clock" title="<?php esc_attr_e( 'Published', 'fictioneer' ) ?>"></i>
<?php the_time( FICTIONEER_CARD_POST_FOOTER_DATE ); ?>
2023-08-08 10:49:46 +02:00
2023-01-21 01:31:34 +01:00
<i class="fa-solid fa-message" title="<?php esc_attr_e( 'Comments', 'fictioneer' ) ?>"></i>
2023-06-04 22:17:42 +02:00
<?php echo get_comments_number(); ?>
2023-08-08 10:49:46 +02:00
2023-01-21 01:31:34 +01:00
</div>
2023-08-08 10:49:46 +02:00
2023-01-21 01:31:34 +01:00
</div>
</div>
</li>