2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Partial: Recommendation Card
|
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
$title = fictioneer_get_safe_title( $post_id, 'card-recommendation' );
|
2023-10-02 00:02:12 +02:00
|
|
|
$links = array_merge(
|
2024-05-17 17:46:54 +02:00
|
|
|
fictioneer_url_list_to_array( get_post_meta( $post_id, 'fictioneer_recommendation_urls', true ) ),
|
|
|
|
fictioneer_url_list_to_array( get_post_meta( $post_id, 'fictioneer_recommendation_support', true ) )
|
2023-01-21 01:31:34 +01:00
|
|
|
);
|
2023-08-08 09:37:57 +02:00
|
|
|
$excerpt = get_the_excerpt();
|
2024-05-17 17:46:54 +02:00
|
|
|
$one_sentence = get_post_meta( $post_id, 'fictioneer_recommendation_one_sentence', true );
|
2024-02-11 23:55:32 +01:00
|
|
|
$card_classes = [];
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Taxonomies
|
2023-08-08 09:37:57 +02:00
|
|
|
$tags = false;
|
|
|
|
$fandoms = false;
|
|
|
|
$characters = false;
|
|
|
|
$genres = false;
|
|
|
|
|
|
|
|
if (
|
|
|
|
get_option( 'fictioneer_show_tags_on_recommendation_cards' ) &&
|
|
|
|
! get_option( 'fictioneer_hide_taxonomies_on_recommendation_cards' )
|
|
|
|
) {
|
|
|
|
$tags = get_the_tags();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! get_option( 'fictioneer_hide_taxonomies_on_recommendation_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 09:37:57 +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_recommendation_cards' ) && ( $tags || $genres || $fandoms || $characters );
|
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 ) {
|
2024-05-14 18:40:52 +02:00
|
|
|
$card_classes[] = '_no-tax';
|
|
|
|
}
|
|
|
|
|
2024-03-04 01:54:53 +01:00
|
|
|
// Card attributes
|
|
|
|
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-recommendation' );
|
|
|
|
$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="recommendation-card-<?php echo $post_id; ?>" class="post-<?php echo $post_id; ?> card _recommendation _large _no-footer <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
2023-01-21 01:31:34 +01:00
|
|
|
<div class="card__body polygon">
|
|
|
|
|
|
|
|
<div class="card__main _grid _large">
|
|
|
|
|
2024-05-14 10:05:05 +02:00
|
|
|
<div class="card__header _large">
|
|
|
|
<?php if ( $args['show_type'] ?? false ) : ?>
|
|
|
|
<div class="card__label"><?php _ex( 'Recommendation', 'Recommendation card label.', 'fictioneer' ); ?></div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<h3 class="card__title"><a href="<?php the_permalink(); ?>" class="truncate _1-1"><?php echo $title; ?></a></h3>
|
|
|
|
</div>
|
|
|
|
|
2023-08-08 09:37:57 +02:00
|
|
|
<?php
|
2024-01-27 22:32:10 +01:00
|
|
|
// Action hook
|
|
|
|
do_action( 'fictioneer_large_card_body_recommendation', $post, $args );
|
|
|
|
|
2023-08-08 09:37:57 +02:00
|
|
|
// Thumbnail
|
2024-05-14 18:40:52 +02:00
|
|
|
if ( has_post_thumbnail() && get_theme_mod( 'card_image_style', 'default' ) !== 'none' ) {
|
2023-01-21 01:31:34 +01:00
|
|
|
printf(
|
2023-08-08 09:37:57 +02:00
|
|
|
'<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-01-21 01:31:34 +01:00
|
|
|
);
|
2023-08-08 09:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Content
|
|
|
|
printf(
|
2024-05-13 23:26:51 +02:00
|
|
|
'<div class="card__content cell-desc"><div class="truncate %s"><span class="card__by-author">%s</span> <span>%s</span></div></div>',
|
|
|
|
count( $links ) > 3 ? '_3-4' : '_4-4',
|
2023-08-08 09:37:57 +02:00
|
|
|
sprintf(
|
|
|
|
_x( 'by %s —', 'Large card: by {Author} —.', 'fictioneer' ),
|
2024-05-17 17:46:54 +02:00
|
|
|
get_post_meta( $post_id, 'fictioneer_recommendation_author', true )
|
2023-08-08 09:37:57 +02:00
|
|
|
),
|
2024-09-01 17:01:19 +02:00
|
|
|
mb_strlen( $one_sentence ) < mb_strlen( $excerpt ) ? $excerpt : wp_strip_all_tags( $one_sentence, true )
|
2023-08-08 09:37:57 +02:00
|
|
|
);
|
|
|
|
?>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2023-10-02 00:02:12 +02:00
|
|
|
<?php if ( count( $links ) > 0 ): ?>
|
2023-01-21 01:31:34 +01:00
|
|
|
<ol class="card__link-list cell-list">
|
2023-10-02 00:02:12 +02:00
|
|
|
<?php foreach ( $links as $link ) : ?>
|
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-square-up-right"></i>
|
2023-10-02 00:02:12 +02:00
|
|
|
<a href="<?php echo esc_url( $link['url'] ); ?>" rel="noopener" target="_blank" class="card__link-list-link"><?php echo $link['name']; ?></a>
|
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_recommendation_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( 'recommendation-card' ), $terms );
|
|
|
|
?></div>
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|