2023-01-21 01:31:34 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Partial: Recommendation 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['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
|
|
|
|
$title = fictioneer_get_safe_title( get_the_ID() );
|
|
|
|
$urls = array_merge(
|
|
|
|
explode( "\n", fictioneer_get_field( 'fictioneer_recommendation_urls' ) ),
|
|
|
|
explode( "\n", fictioneer_get_field( 'fictioneer_recommendation_support' ) )
|
|
|
|
);
|
2023-08-08 09:37:57 +02:00
|
|
|
$excerpt = get_the_excerpt();
|
|
|
|
$one_sentence = fictioneer_get_field( 'fictioneer_recommendation_one_sentence' ) ?? '';
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Sanitize
|
|
|
|
$urls = array_map( 'wp_strip_all_tags', $urls );
|
|
|
|
|
|
|
|
// 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' ) ) {
|
|
|
|
$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-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// Flags
|
|
|
|
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_recommendation_cards' ) && ( $tags || $genres || $fandoms || $characters );
|
2023-08-08 09:37:57 +02:00
|
|
|
$show_type = $args['show_type'] ?? false;
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<li id="recommendation-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( 'Recommendation', 'Recommendation card label.', 'fictioneer' ); ?></div>
|
|
|
|
<?php endif; ?>
|
2023-02-09 10:44:04 +01: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
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card__main _grid _large">
|
|
|
|
|
2023-08-08 09:37:57 +02:00
|
|
|
<?php
|
|
|
|
// Thumbnail
|
|
|
|
if ( has_post_thumbnail() ) {
|
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(),
|
|
|
|
get_the_post_thumbnail( null, 'cover' )
|
2023-01-21 01:31:34 +01:00
|
|
|
);
|
2023-08-08 09:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Content
|
|
|
|
printf(
|
|
|
|
'<div class="card__content cell-desc truncate _4-4"><span class="card__by-author">%1$s</span> <span>%2$s</span></div>',
|
|
|
|
sprintf(
|
|
|
|
_x( 'by %s —', 'Large card: by {Author} —.', 'fictioneer' ),
|
|
|
|
fictioneer_get_field( 'fictioneer_recommendation_author' )
|
|
|
|
),
|
|
|
|
strlen( $one_sentence ) < strlen( $excerpt ) ? $excerpt : wp_strip_all_tags( $one_sentence, true )
|
|
|
|
);
|
|
|
|
?>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
<?php if ( count( $urls ) > 0 ): ?>
|
|
|
|
<ol class="card__link-list cell-list">
|
|
|
|
<?php foreach ( $urls as $url ) : ?>
|
|
|
|
<li>
|
|
|
|
<div class="card__left text-overflow-ellipsis">
|
|
|
|
<i class="fa-solid fa-square-up-right"></i>
|
|
|
|
<?php
|
|
|
|
$tuple = explode( '|', $url );
|
|
|
|
$tuple = array_map( 'trim', $tuple );
|
|
|
|
?>
|
|
|
|
<a href="<?php echo esc_url( $tuple[1] ); ?>" rel="noopener" target="_blank"><?php echo $tuple[0]; ?></a>
|
|
|
|
</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 09:37:57 +02:00
|
|
|
$taxonomies = array_merge(
|
|
|
|
$fandoms ? fictioneer_generate_card_tags( $fandoms, '_fandom' ) : [],
|
|
|
|
$genres ? fictioneer_generate_card_tags( $genres, '_genre' ) : [],
|
|
|
|
$tags ? fictioneer_generate_card_tags( $tags ) : [],
|
|
|
|
$characters ? fictioneer_generate_card_tags( $characters, '_character' ) : []
|
|
|
|
);
|
2023-06-04 01:49:00 +02:00
|
|
|
|
|
|
|
// Implode with three-per-em spaces around a bullet
|
2023-08-08 09:37:57 +02:00
|
|
|
echo implode( ' • ', $taxonomies );
|
2023-01-21 01:31:34 +01:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</li>
|