Refactor shortcode and card tags
This commit is contained in:
parent
6965ce7fb0
commit
3532f9bd23
@ -831,6 +831,8 @@ Renders a multi-column grid of paginated medium cards ordered by publishing date
|
||||
* **seamless:** Whether to remove the gap between the image and frame. Default `false` (Customizer setting).
|
||||
* **thumbnail:** Whether to show the thumbnail/cover image. Default `true` (Customizer setting).
|
||||
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
|
||||
* **terms:** Either `inline`, `pills`, or `none`. Default `inline`.
|
||||
* **max_terms:** Maximum number of shown taxonomies. Default `10`.
|
||||
* **date_format:** String to override the [date format](https://wordpress.org/documentation/article/customize-date-and-time-format/). Default `''`.
|
||||
* **footer:** Whether to show the footer (if any). Default `true`.
|
||||
* **footer_author:** Whether to show the post author. Default `true`.
|
||||
@ -1149,8 +1151,8 @@ Renders a multi-column grid of small cards, showing the latest four stories orde
|
||||
* **lightbox:** Whether clicking on the thumbnail/cover image opens the lightbox or post link. Default `true`.
|
||||
* **infobox:** Whether to show the info box and toggle on compact versions. Default `true`.
|
||||
* **date_format:** String to override the [date format](https://wordpress.org/documentation/article/customize-date-and-time-format/). Default `''`.
|
||||
* **terms:** Either `inline`, `pills`, or `none` (only in `list`). Default `inline`.
|
||||
* **max_terms:** Maximum number of shown taxonomies (only in `list`). Default `10`.
|
||||
* **terms:** Either `inline`, `pills`, or `none`. Default `inline`.
|
||||
* **max_terms:** Maximum number of shown taxonomies. Default `10`.
|
||||
* **footer:** Whether to show the footer (if any). Default `true`.
|
||||
* **footer_author:** Whether to show the author. Default `true`.
|
||||
* **footer_chapters:** Whether to show the chapter count (not in `list`). Default `true`.
|
||||
@ -1227,8 +1229,8 @@ Renders a multi-column grid of small cards, showing the latest four updated stor
|
||||
* **date:** Whether to show the date of chapter items. Default `true`.
|
||||
* **date_format:** String to override the [date format](https://wordpress.org/documentation/article/customize-date-and-time-format/). Default `''`.
|
||||
* **nested_date_format:** String to override any nested [date formats](https://wordpress.org/documentation/article/customize-date-and-time-format/). Default `''`.
|
||||
* **terms:** Either `inline`, `pills`, or `none` (only in `list`). Default `inline`.
|
||||
* **max_terms:** Maximum number of shown taxonomies (only in `list`). Default `10`.
|
||||
* **terms:** Either `inline`, `pills`, or `none`. Default `inline`.
|
||||
* **max_terms:** Maximum number of shown taxonomies. Default `10`.
|
||||
* **footer:** Whether to show the footer (if any). Default `true`.
|
||||
* **footer_author:** Whether to show the story/chapter author. Default `true`.
|
||||
* **footer_chapters:** Whether to show the story chapter count (not in `list`). Default `true`.
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1814,12 +1814,12 @@ if ( ! function_exists( 'fictioneer_get_card_controls' ) ) {
|
||||
// GENERATE CARD TAGS
|
||||
// =============================================================================
|
||||
|
||||
if ( ! function_exists( 'fictioneer_generate_card_terms' ) ) {
|
||||
if ( ! function_exists( 'fictioneer_get_term_nodes' ) ) {
|
||||
/**
|
||||
* Returns array of card tags with HTML markup
|
||||
*
|
||||
* @since 5.5.3
|
||||
* @since 5.23.3 - Refactored into fictioneer_generate_card_terms().
|
||||
* @since 5.23.3 - Refactored into fictioneer_get_term_nodes().
|
||||
*
|
||||
* @param array $items Array of terms.
|
||||
* @param string $classes Optional. CSS classes to add.
|
||||
@ -1827,7 +1827,7 @@ if ( ! function_exists( 'fictioneer_generate_card_terms' ) ) {
|
||||
* @return array Array of output-ready tags.
|
||||
*/
|
||||
|
||||
function fictioneer_generate_card_terms( $items, $classes = '' ) {
|
||||
function fictioneer_get_term_nodes( $items, $classes = '' ) {
|
||||
$tags = [];
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
|
@ -601,7 +601,7 @@ function fictioneer_shortcode_latest_stories( $attr ) {
|
||||
|
||||
// Terms
|
||||
$args['terms'] = fictioneer_sanitize_query_var( $attr['terms'] ?? 0, ['inline', 'pills', 'none', 'false'], 'inline' );
|
||||
$args['max_terms'] = absint( $attr['max_terms'] ?? 10 );
|
||||
$args['max_terms'] = absint( ( $attr['max_terms'] ?? 10 ) ?: 10 );
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
@ -700,7 +700,7 @@ function fictioneer_shortcode_latest_story_updates( $attr ) {
|
||||
|
||||
// Terms
|
||||
$args['terms'] = fictioneer_sanitize_query_var( $attr['terms'] ?? 0, ['inline', 'pills', 'none', 'false'], 'inline' );
|
||||
$args['max_terms'] = absint( $attr['max_terms'] ?? 10 );
|
||||
$args['max_terms'] = absint( ( $attr['max_terms'] ?? 10 ) ?: 10 );
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
@ -783,6 +783,10 @@ function fictioneer_shortcode_latest_recommendations( $attr ) {
|
||||
// Type
|
||||
$type = sanitize_text_field( $attr['type'] ?? 'default' );
|
||||
|
||||
// Terms
|
||||
$args['terms'] = fictioneer_sanitize_query_var( $attr['terms'] ?? 0, ['inline', 'pills', 'none', 'false'], 'inline' );
|
||||
$args['max_terms'] = absint( ( $attr['max_terms'] ?? 10 ) ?: 10 );
|
||||
|
||||
// Transient?
|
||||
if ( FICTIONEER_SHORTCODE_TRANSIENTS_ENABLED ) {
|
||||
$base = serialize( $args ) . serialize( $attr );
|
||||
@ -1610,6 +1614,10 @@ function fictioneer_shortcode_article_cards( $attr ) {
|
||||
// Defaults
|
||||
$args = fictioneer_get_default_shortcode_args( $attr );
|
||||
|
||||
// Terms
|
||||
$args['terms'] = fictioneer_sanitize_query_var( $attr['terms'] ?? 0, ['inline', 'pills', 'none', 'false'], 'inline' );
|
||||
$args['max_terms'] = absint( ( $attr['max_terms'] ?? 10 ) ?: 10 );
|
||||
|
||||
// Post type(s)...
|
||||
$post_types = sanitize_text_field( $attr['post_type'] ?? 'post' );
|
||||
$post_types = fictioneer_explode_list( $post_types );
|
||||
|
@ -25,6 +25,8 @@
|
||||
* @internal $args['relation'] Relationship between taxonomies. Default 'AND'.
|
||||
* @internal $args['lightbox'] Whether the image is opened in the lightbox. Default true.
|
||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true.
|
||||
* @internal $args['terms'] Either inline, pills, none, or false. Default inline.
|
||||
* @internal $args['max_terms'] Maximum number of shown taxonomies. Default 10.
|
||||
* @internal $args['date_format'] String to override the date format. Default empty.
|
||||
* @internal $args['footer'] Whether to show the footer. Default true.
|
||||
* @internal $args['footer_author'] Whether to show the post author. Default true.
|
||||
@ -37,6 +39,9 @@
|
||||
// No direct access!
|
||||
defined( 'ABSPATH' ) OR exit;
|
||||
|
||||
// Setup
|
||||
$show_terms = ! in_array( $args['terms'], ['none', 'false'] );
|
||||
|
||||
// Arguments
|
||||
$query_args = array(
|
||||
'fictioneer_query_name' => 'article_cards',
|
||||
@ -45,7 +50,8 @@ $query_args = array(
|
||||
'post__in' => $args['post_ids'], // May be empty!
|
||||
'order' => $args['order'],
|
||||
'orderby' => $args['orderby'],
|
||||
'ignore_sticky_posts' => $args['ignore_sticky']
|
||||
'ignore_sticky_posts' => $args['ignore_sticky'],
|
||||
'update_post_term_cache' => $show_terms // Improve performance
|
||||
);
|
||||
|
||||
// Pagination or count?
|
||||
@ -132,11 +138,11 @@ $pag_args = array(
|
||||
$story_id = ( $post->post_type === 'fcn_story' ) ? $post_id : null;
|
||||
$title = fictioneer_get_safe_title( $post_id, 'card-article' );
|
||||
$permalink = get_permalink();
|
||||
$categories = wp_get_post_categories( $post_id );
|
||||
$tags = get_the_tags();
|
||||
$fandoms = get_the_terms( $post, 'fcn_fandom' );
|
||||
$characters = get_the_terms( $post, 'fcn_character' );
|
||||
$genres = get_the_terms( $post, 'fcn_genre' );
|
||||
$categories = $show_terms ? get_the_terms( $post_id, 'category' ) : [];
|
||||
$tags = $show_terms ? get_the_tags() : [];
|
||||
$fandoms = $show_terms ? get_the_terms( $post, 'fcn_fandom' ) : [];
|
||||
$characters = $show_terms ? get_the_terms( $post, 'fcn_character' ) : [];
|
||||
$genres = $show_terms ? get_the_terms( $post, 'fcn_genre' ) : [];
|
||||
$card_classes = [];
|
||||
|
||||
// Chapter story?
|
||||
@ -221,42 +227,26 @@ $pag_args = array(
|
||||
<div class="card__tag-list cell-tax _small _scrolling">
|
||||
<div class="card__h-scroll">
|
||||
<?php
|
||||
$terms = [];
|
||||
$variant = $args['terms'] === 'pills' ? '_pill' : '_inline';
|
||||
|
||||
if ( $categories ) {
|
||||
foreach ( $categories as $cat ) {
|
||||
$terms[ $cat ] = '<a href="' . get_category_link( $cat ) . '" class="tag-pill _inline _category">' . get_category( $cat )->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = array_merge(
|
||||
$categories ? fictioneer_get_term_nodes( $categories, '_inline _category' ) : [],
|
||||
$fandoms ? fictioneer_get_term_nodes( $fandoms, "{$variant} _fandom" ) : [],
|
||||
$genres ? fictioneer_get_term_nodes( $genres, "{$variant} _genre" ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, "{$variant} _tag" ) : [],
|
||||
$characters ? fictioneer_get_term_nodes( $characters, "{$variant} _character" ) : []
|
||||
);
|
||||
|
||||
if ( $fandoms ) {
|
||||
foreach ( $fandoms as $fandom ) {
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $genres ) {
|
||||
foreach ( $genres as $genre ) {
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $characters ) {
|
||||
foreach ( $characters as $character ) {
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_article_cards_terms', $terms, $post, $args, null );
|
||||
$terms = apply_filters(
|
||||
'fictioneer_filter_shortcode_article_cards_terms',
|
||||
$terms, $post, $args, null
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-recommendations' ), $terms );
|
||||
echo implode(
|
||||
fictioneer_get_bullet_separator( 'article-cards', $args['terms'] === 'pills' ),
|
||||
array_slice( $terms, 0, $args['max_terms'] )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -51,7 +51,7 @@ if ( ! get_option( 'fictioneer_hide_taxonomies_on_chapter_cards' ) ) {
|
||||
|
||||
// Flags
|
||||
$hide_author = $args['hide_author'] ?? false && ! get_option( 'fictioneer_show_authors' );
|
||||
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_chapter_cards' ) && ( $tags || $fandoms || $characters || $genres );
|
||||
$show_terms = ! get_option( 'fictioneer_hide_taxonomies_on_chapter_cards' ) && ( $tags || $fandoms || $characters || $genres );
|
||||
|
||||
// Extra classes
|
||||
if ( $story_unpublished ) {
|
||||
@ -66,6 +66,10 @@ if ( get_theme_mod( 'card_image_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_image_style' );
|
||||
}
|
||||
|
||||
if ( ! $show_terms ) {
|
||||
$card_classes[] = '_no-tax';
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-chapter' );
|
||||
$card_attributes = '';
|
||||
@ -210,18 +214,18 @@ $thumbnail_args = array(
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $show_taxonomies ) : ?>
|
||||
<?php if ( $show_terms ) : ?>
|
||||
<div class="card__tag-list cell-tax">
|
||||
<?php
|
||||
$taxonomies = array_merge(
|
||||
$fandoms ? fictioneer_generate_card_terms( $fandoms, '_inline _fandom' ) : [],
|
||||
$genres ? fictioneer_generate_card_terms( $genres, '_inline _genre' ) : [],
|
||||
$tags ? fictioneer_generate_card_terms( $tags, '_inline _tag' ) : [],
|
||||
$characters ? fictioneer_generate_card_terms( $characters, '_inline _character' ) : []
|
||||
$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' ) : []
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-chapter' ), $taxonomies );
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-chapter' ), $terms );
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -49,7 +49,7 @@ if ( ! get_option( 'fictioneer_hide_taxonomies_on_collection_cards' ) ) {
|
||||
}
|
||||
|
||||
// Flags
|
||||
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_collection_cards' ) && ( $fandoms || $characters || $genres || $tags );
|
||||
$show_terms = ! get_option( 'fictioneer_hide_taxonomies_on_collection_cards' ) && ( $fandoms || $characters || $genres || $tags );
|
||||
|
||||
// Query featured posts
|
||||
if ( ! empty( $items ) ) {
|
||||
@ -79,6 +79,10 @@ if ( get_theme_mod( 'card_image_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_image_style' );
|
||||
}
|
||||
|
||||
if ( ! $show_terms ) {
|
||||
$card_classes[] = '_no-tax';
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-collection' );
|
||||
$card_attributes = '';
|
||||
@ -172,18 +176,18 @@ $thumbnail_args = array(
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $show_taxonomies ) : ?>
|
||||
<?php if ( $show_terms ) : ?>
|
||||
<div class="card__tag-list cell-tax">
|
||||
<?php
|
||||
$taxonomies = array_merge(
|
||||
$fandoms ? fictioneer_generate_card_terms( $fandoms, '_inline _fandom' ) : [],
|
||||
$genres ? fictioneer_generate_card_terms( $genres, '_inline _genre' ) : [],
|
||||
$tags ? fictioneer_generate_card_terms( $tags, '_inline _tag' ) : [],
|
||||
$characters ? fictioneer_generate_card_terms( $characters, '_inline _character' ) : []
|
||||
$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' ) : []
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-collection' ), $taxonomies );
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-collection' ), $terms );
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -79,13 +79,13 @@ $thumbnail_args = array(
|
||||
<?php if ( $categories || $tags ) : ?>
|
||||
<div class="card__tag-list cell-tax">
|
||||
<?php
|
||||
$taxonomies = array_merge(
|
||||
$categories ? fictioneer_generate_card_terms( $categories, '_inline _category' ) : [],
|
||||
$tags ? fictioneer_generate_card_terms( $tags, '_inline _tag' ) : []
|
||||
$terms = array_merge(
|
||||
$categories ? fictioneer_get_term_nodes( $categories, '_inline _category' ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, '_inline _tag' ) : []
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-card' ), $taxonomies );
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-card' ), $terms );
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -47,7 +47,7 @@ if ( ! get_option( 'fictioneer_hide_taxonomies_on_recommendation_cards' ) ) {
|
||||
}
|
||||
|
||||
// Flags
|
||||
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_recommendation_cards' ) && ( $tags || $genres || $fandoms || $characters );
|
||||
$show_terms = ! get_option( 'fictioneer_hide_taxonomies_on_recommendation_cards' ) && ( $tags || $genres || $fandoms || $characters );
|
||||
|
||||
// Extra classes
|
||||
if ( get_theme_mod( 'card_style', 'default' ) !== 'default' ) {
|
||||
@ -58,7 +58,7 @@ if ( get_theme_mod( 'card_image_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_image_style' );
|
||||
}
|
||||
|
||||
if ( ! $show_taxonomies ) {
|
||||
if ( ! $show_terms ) {
|
||||
$card_classes[] = '_no-tax';
|
||||
}
|
||||
|
||||
@ -130,18 +130,18 @@ $thumbnail_args = array(
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $show_taxonomies ) : ?>
|
||||
<?php if ( $show_terms ) : ?>
|
||||
<div class="card__tag-list cell-tax">
|
||||
<?php
|
||||
$taxonomies = array_merge(
|
||||
$fandoms ? fictioneer_generate_card_terms( $fandoms, '_inline _fandom' ) : [],
|
||||
$genres ? fictioneer_generate_card_terms( $genres, '_inline _genre' ) : [],
|
||||
$tags ? fictioneer_generate_card_terms( $tags, '_inline _tag' ) : [],
|
||||
$characters ? fictioneer_generate_card_terms( $characters, '_inline _character' ) : []
|
||||
$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' ) : []
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-recommendation' ), $taxonomies );
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-recommendation' ), $terms );
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -59,7 +59,7 @@ if (
|
||||
|
||||
// Flags
|
||||
$hide_author = $args['hide_author'] ?? false && ! get_option( 'fictioneer_show_authors' );
|
||||
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' ) && ( $story['has_taxonomies'] || $tags );
|
||||
$show_terms = ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' ) && ( $story['has_taxonomies'] || $tags );
|
||||
$is_sticky = FICTIONEER_ENABLE_STICKY_CARDS &&
|
||||
get_post_meta( $post_id, 'fictioneer_story_sticky', true ) && ! is_search() && ! is_archive();
|
||||
|
||||
@ -76,6 +76,10 @@ if ( get_theme_mod( 'card_image_style', 'default' ) !== 'default' ) {
|
||||
$card_classes[] = '_' . get_theme_mod( 'card_image_style' );
|
||||
}
|
||||
|
||||
if ( ! $show_terms ) {
|
||||
$card_classes[] = '_no-tax';
|
||||
}
|
||||
|
||||
// Card attributes
|
||||
$attributes = apply_filters( 'fictioneer_filter_card_attributes', [], $post, 'card-story' );
|
||||
$card_attributes = '';
|
||||
@ -214,18 +218,18 @@ if ( $card_cache_active ) {
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $show_taxonomies ) : ?>
|
||||
<?php if ( $show_terms ) : ?>
|
||||
<div class="card__tag-list cell-tax">
|
||||
<?php
|
||||
$taxonomies = array_merge(
|
||||
$story['fandoms'] ? fictioneer_generate_card_terms( $story['fandoms'], '_inline _fandom' ) : [],
|
||||
$story['genres'] ? fictioneer_generate_card_terms( $story['genres'], '_inline _genre' ) : [],
|
||||
$tags ? fictioneer_generate_card_terms( $tags, '_inline _tag' ) : [],
|
||||
$story['characters'] ? fictioneer_generate_card_terms( $story['characters'], '_inline _character' ) : []
|
||||
$terms = array_merge(
|
||||
$story['fandoms'] ? fictioneer_get_term_nodes( $story['fandoms'], '_inline _fandom' ) : [],
|
||||
$story['genres'] ? fictioneer_get_term_nodes( $story['genres'], '_inline _genre' ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, '_inline _tag' ) : [],
|
||||
$story['characters'] ? fictioneer_get_term_nodes( $story['characters'], '_inline _character' ) : []
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-story' ), $taxonomies );
|
||||
echo implode( fictioneer_get_bullet_separator( 'post-story' ), $terms );
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -26,6 +26,8 @@
|
||||
* @internal $args['aspect_ratio'] Aspect ratio for the image. Only with vertical.
|
||||
* @internal $args['lightbox'] Whether the image is opened in the lightbox. Default true.
|
||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
||||
* @internal $args['terms'] Either inline, pills, none, or false. Default inline.
|
||||
* @internal $args['max_terms'] Maximum number of shown taxonomies. Default 10.
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['infobox'] Whether to show the info box and toggle.
|
||||
*/
|
||||
@ -35,7 +37,8 @@
|
||||
defined( 'ABSPATH' ) OR exit;
|
||||
|
||||
// Setup
|
||||
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_recommendation_cards' );
|
||||
$show_terms = ! in_array( $args['terms'], ['none', 'false'] ) &&
|
||||
! get_option( 'fictioneer_hide_taxonomies_on_recommendation_cards' );
|
||||
|
||||
// Prepare query
|
||||
$query_args = array (
|
||||
@ -46,6 +49,7 @@ $query_args = array (
|
||||
'order' => $args['order'],
|
||||
'orderby' => $args['orderby'],
|
||||
'posts_per_page' => $args['count'],
|
||||
'update_post_term_cache' => $show_terms, // Improve performance
|
||||
'no_found_rows' => true
|
||||
);
|
||||
|
||||
@ -106,15 +110,15 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$post_id = $post->ID;
|
||||
$title = fictioneer_get_safe_title( $post_id, 'shortcode-latest-recommendations-compact' );
|
||||
$one_sentence = get_post_meta( $post_id, 'fictioneer_recommendation_one_sentence', true );
|
||||
$fandoms = get_the_terms( $post, 'fcn_fandom' );
|
||||
$characters = get_the_terms( $post, 'fcn_character' );
|
||||
$genres = get_the_terms( $post, 'fcn_genre' );
|
||||
$fandoms = $show_terms ? get_the_terms( $post, 'fcn_fandom' ) : [];
|
||||
$characters = $show_terms ? get_the_terms( $post, 'fcn_character' ) : [];
|
||||
$genres = $show_terms ? get_the_terms( $post, 'fcn_genre' ) : [];
|
||||
$tags = get_option( 'fictioneer_show_tags_on_recommendation_cards' ) ? get_the_tags( $post ) : false;
|
||||
$grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid';
|
||||
$card_classes = [];
|
||||
|
||||
// Extra classes
|
||||
if ( $show_taxonomies ) {
|
||||
if ( $show_terms ) {
|
||||
$card_classes[] = '_info';
|
||||
}
|
||||
|
||||
@ -152,7 +156,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
<li class="post-<?php echo $post_id; ?> card watch-last-clicked _small _recommendation _compact _no-footer <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<?php if ( $show_taxonomies && $args['infobox'] ) : ?>
|
||||
<?php if ( $show_terms && $args['infobox'] ) : ?>
|
||||
<button class="card__info-toggle toggle-last-clicked" aria-label="<?php esc_attr_e( 'Open info box', 'fictioneer' ); ?>"><i class="fa-solid fa-chevron-down"></i></button>
|
||||
<?php endif; ?>
|
||||
|
||||
@ -199,41 +203,30 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ( $show_taxonomies && $args['infobox'] ) : ?>
|
||||
<?php if ( $show_terms && $args['infobox'] ) : ?>
|
||||
<div class="card__overlay-infobox escape-last-click">
|
||||
<div class="card__tag-list _small">
|
||||
<div class="card__tag-list _small <?php echo $args['terms'] === 'pills' ? '_pills' : ''; ?>">
|
||||
<?php
|
||||
if ( $fandoms || $characters || $genres || $tags ) {
|
||||
$terms = [];
|
||||
if ( $fandoms || $genres || $tags || $characters ) {
|
||||
$variant = $args['terms'] === 'pills' ? '_pill' : '_inline';
|
||||
|
||||
if ( $fandoms ) {
|
||||
foreach ( $fandoms as $fandom ) {
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = array_merge(
|
||||
$fandoms ? fictioneer_get_term_nodes( $fandoms, "{$variant} _fandom" ) : [],
|
||||
$genres ? fictioneer_get_term_nodes( $genres, "{$variant} _genre" ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, "{$variant} _tag" ) : [],
|
||||
$characters ? fictioneer_get_term_nodes( $characters, "{$variant} _character" ) : []
|
||||
);
|
||||
|
||||
if ( $genres ) {
|
||||
foreach ( $genres as $genre ) {
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $characters ) {
|
||||
foreach ( $characters as $character ) {
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_recommendations_terms', $terms, $post, $args, null );
|
||||
$terms = apply_filters(
|
||||
'fictioneer_filter_shortcode_latest_recommendations_terms',
|
||||
$terms, $post, $args, null
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-recommendations' ), $terms );
|
||||
echo implode(
|
||||
fictioneer_get_bullet_separator( 'latest-recommendations-compact', $args['terms'] === 'pills' ),
|
||||
array_slice( $terms, 0, $args['max_terms'] )
|
||||
);
|
||||
} else {
|
||||
?><span class="card__no-taxonomies"><?php _e( 'No taxonomies specified yet.', 'fictioneer' ); ?></span><?php
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
* @internal $args['vertical'] Whether to show the vertical variant.
|
||||
* @internal $args['seamless'] Whether to render the image seamless. Default false (Customizer).
|
||||
* @internal $args['aspect_ratio'] Aspect ratio for the image. Only with vertical.
|
||||
* @internal $args['terms'] Either inline, pills, none, or false. Default inline.
|
||||
* @internal $args['max_terms'] Maximum number of shown taxonomies. Default 10.
|
||||
* @internal $args['lightbox'] Whether the image is opened in the lightbox. Default true.
|
||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
@ -217,39 +219,28 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
<?php if ( $show_taxonomies ) : ?>
|
||||
<div class="card__tag-list _small _scrolling cell-tax">
|
||||
<div class="card__h-scroll">
|
||||
<div class="card__h-scroll <?php echo $args['terms'] === 'pills' ? '_pills' : ''; ?>">
|
||||
<?php
|
||||
if ( $fandoms || $characters || $genres || $tags ) {
|
||||
$terms = [];
|
||||
$variant = $args['terms'] === 'pills' ? '_pill' : '_inline';
|
||||
|
||||
if ( $fandoms ) {
|
||||
foreach ( $fandoms as $fandom ) {
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = array_merge(
|
||||
$fandoms ? fictioneer_get_term_nodes( $fandoms, "{$variant} _fandom" ) : [],
|
||||
$genres ? fictioneer_get_term_nodes( $genres, "{$variant} _genre" ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, "{$variant} _tag" ) : [],
|
||||
$characters ? fictioneer_get_term_nodes( $characters, "{$variant} _character" ) : []
|
||||
);
|
||||
|
||||
if ( $genres ) {
|
||||
foreach ( $genres as $genre ) {
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $characters ) {
|
||||
foreach ( $characters as $character ) {
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_recommendations_terms', $terms, $post, $args, null );
|
||||
$terms = apply_filters(
|
||||
'fictioneer_filter_shortcode_latest_recommendations_terms',
|
||||
$terms, $post, $args, null
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-recommendations' ), $terms );
|
||||
echo implode(
|
||||
fictioneer_get_bullet_separator( 'latest-recommendations', $args['terms'] === 'pills' ),
|
||||
array_slice( $terms, 0, $args['max_terms'] )
|
||||
);
|
||||
} else {
|
||||
?><span class="card__no-taxonomies"><?php _e( 'No taxonomies specified yet.', 'fictioneer' ); ?></span><?php
|
||||
}
|
||||
|
@ -30,6 +30,8 @@
|
||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
||||
* @internal $args['classes'] String of additional CSS classes. Default empty.
|
||||
* @internal $args['infobox'] Whether to show the info box and toggle. Default true.
|
||||
* @internal $args['terms'] Either inline, pills, none, or false. Default inline.
|
||||
* @internal $args['max_terms'] Maximum number of shown taxonomies. Default 10.
|
||||
* @internal $args['footer_chapters'] Whether to show the chapter count. Default true.
|
||||
* @internal $args['footer_words'] Whether to show the word count. Default true.
|
||||
* @internal $args['footer_date'] Whether to show the date. Default true.
|
||||
@ -42,7 +44,8 @@
|
||||
defined( 'ABSPATH' ) OR exit;
|
||||
|
||||
// Setup
|
||||
$show_taxonomies = ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' );
|
||||
$show_terms = ! in_array( $args['terms'], ['none', 'false'] ) &&
|
||||
! get_option( 'fictioneer_hide_taxonomies_on_story_cards' );
|
||||
|
||||
// Prepare query
|
||||
$query_args = array(
|
||||
@ -53,6 +56,7 @@ $query_args = array(
|
||||
'order' => $args['order'],
|
||||
'orderby' => $args['orderby'],
|
||||
'posts_per_page' => $args['count'],
|
||||
'update_post_term_cache' => $show_terms, // Improve performance
|
||||
'no_found_rows' => true
|
||||
);
|
||||
|
||||
@ -131,7 +135,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$post_id = $post->ID;
|
||||
$story = fictioneer_get_story_data( $post_id, false ); // Does not refresh comment count!
|
||||
$story_link = get_post_meta( $post_id, 'fictioneer_story_redirect_link', true ) ?: get_permalink( $post_id );
|
||||
$tags = get_option( 'fictioneer_show_tags_on_story_cards' ) ? get_the_tags( $post ) : false;
|
||||
$tags = ( $show_terms && get_option( 'fictioneer_show_tags_on_story_cards' ) ) ? get_the_tags( $post ) : false;
|
||||
$is_sticky = FICTIONEER_ENABLE_STICKY_CARDS && get_post_meta( $post_id, 'fictioneer_story_sticky', true );
|
||||
$grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid';
|
||||
$card_classes = [];
|
||||
@ -143,7 +147,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$short_description = mb_strlen( $short_description, 'UTF-8' ) < 30 ? get_the_excerpt() : $short_description;
|
||||
|
||||
// Extra classes
|
||||
if ( $show_taxonomies ) {
|
||||
if ( $show_terms ) {
|
||||
$card_classes[] = '_info';
|
||||
}
|
||||
|
||||
@ -262,40 +266,29 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
<?php if ( $args['infobox'] ) : ?>
|
||||
<div class="card__overlay-infobox escape-last-click">
|
||||
|
||||
<?php if ( $show_taxonomies ) : ?>
|
||||
<div class="card__tag-list _small">
|
||||
<?php if ( $show_terms ) : ?>
|
||||
<div class="card__tag-list _small <?php echo $args['terms'] === 'pills' ? '_pills' : ''; ?>">
|
||||
<?php
|
||||
if ( $story['has_taxonomies'] || $tags ) {
|
||||
$terms = [];
|
||||
$variant = $args['terms'] === 'pills' ? '_pill' : '_inline';
|
||||
|
||||
if ( $story['fandoms'] ) {
|
||||
foreach ( $story['fandoms'] as $fandom ) {
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = array_merge(
|
||||
$story['fandoms'] ? fictioneer_get_term_nodes( $story['fandoms'], "{$variant} _fandom" ) : [],
|
||||
$story['genres'] ? fictioneer_get_term_nodes( $story['genres'], "{$variant} _genre" ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, "{$variant} _tag" ) : [],
|
||||
$story['characters'] ? fictioneer_get_term_nodes( $story['characters'], "{$variant} _character" ) : []
|
||||
);
|
||||
|
||||
if ( $story['genres'] ) {
|
||||
foreach ( $story['genres'] as $genre ) {
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['characters'] ) {
|
||||
foreach ( $story['characters'] as $character ) {
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_stories_terms', $terms, $post, $args, $story );
|
||||
$terms = apply_filters(
|
||||
'fictioneer_filter_shortcode_latest_stories_terms',
|
||||
$terms, $post, $args, $story
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-recommendations' ), $terms );
|
||||
echo implode(
|
||||
fictioneer_get_bullet_separator( 'latest-stories-compact', $args['terms'] === 'pills' ),
|
||||
array_slice( $terms, 0, $args['max_terms'] )
|
||||
);
|
||||
} else {
|
||||
?><span class="card__no-taxonomies"><?php _e( 'No taxonomies specified yet.', 'fictioneer' ); ?></span><?php
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$post_id = $post->ID;
|
||||
$story = fictioneer_get_story_data( $post_id, false ); // Does not refresh comment count!
|
||||
$permalink = get_post_meta( $post_id, 'fictioneer_story_redirect_link', true ) ?: get_permalink( $post_id );
|
||||
$tags = get_option( 'fictioneer_show_tags_on_story_cards' ) ? get_the_tags( $post ) : false;
|
||||
$tags = ( $show_terms && get_option( 'fictioneer_show_tags_on_story_cards' ) ) ? get_the_tags( $post ) : false;
|
||||
$is_sticky = FICTIONEER_ENABLE_STICKY_CARDS && get_post_meta( $post_id, 'fictioneer_story_sticky', true );
|
||||
|
||||
// Thumbnail
|
||||
@ -278,37 +278,25 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
<?php if ( $show_terms && ( $story['has_taxonomies'] || $tags ) ) : ?>
|
||||
<div class="post-list-item__tax <?php echo $args['terms'] === 'pills' ? '_pills' : ''; ?>"><?php
|
||||
$inline = $args['terms'] === 'pills' ? '' : '_inline';
|
||||
$terms = [];
|
||||
$variant = $args['terms'] === 'pills' ? '' : '_inline';
|
||||
|
||||
if ( $story['fandoms'] ) {
|
||||
foreach ( $story['fandoms'] as $fandom ) {
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill ' . $inline . ' _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = array_merge(
|
||||
$story['fandoms'] ? fictioneer_get_term_nodes( $story['fandoms'], "{$variant} _fandom" ) : [],
|
||||
$story['genres'] ? fictioneer_get_term_nodes( $story['genres'], "{$variant} _genre" ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, "{$variant} _tag" ) : [],
|
||||
$story['characters'] ? fictioneer_get_term_nodes( $story['characters'], "{$variant} _character" ) : []
|
||||
);
|
||||
|
||||
if ( $story['genres'] ) {
|
||||
foreach ( $story['genres'] as $genre ) {
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill ' . $inline . ' _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = apply_filters(
|
||||
'fictioneer_filter_shortcode_latest_stories_terms',
|
||||
$terms, $post, $args, $story
|
||||
);
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill ' . $inline . '">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['characters'] ) {
|
||||
foreach ( $story['characters'] as $character ) {
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill ' . $inline . ' _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_stories_terms', $terms, $post, $args, $story );
|
||||
$separator = $args['terms'] === 'pills' ? '' : fictioneer_get_bullet_separator( 'latest-stories-list' );
|
||||
|
||||
echo implode( $separator, array_slice( $terms, 0, $args['max_terms'] ) );
|
||||
// Implode with separator
|
||||
echo implode(
|
||||
fictioneer_get_bullet_separator( 'latest-stories-list', $args['terms'] === 'pills' ),
|
||||
array_slice( $terms, 0, $args['max_terms'] )
|
||||
);
|
||||
?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
* @internal $args['aspect_ratio'] Aspect ratio for the image. Only with vertical.
|
||||
* @internal $args['lightbox'] Whether the image is opened in the lightbox. Default true.
|
||||
* @internal $args['thumbnail'] Whether the image is rendered. Default true (Customizer).
|
||||
* @internal $args['terms'] Either inline, pills, none, or false. Default inline.
|
||||
* @internal $args['max_terms'] Maximum number of shown taxonomies. Default 10.
|
||||
* @internal $args['footer'] Whether to show the footer. Default true.
|
||||
* @internal $args['date_format'] String to override the date format. Default empty.
|
||||
* @internal $args['footer_chapters'] Whether to show the chapter count. Default true.
|
||||
@ -42,6 +44,10 @@
|
||||
// No direct access!
|
||||
defined( 'ABSPATH' ) OR exit;
|
||||
|
||||
// Setup
|
||||
$show_terms = ! in_array( $args['terms'], ['none', 'false'] ) &&
|
||||
! get_option( 'fictioneer_hide_taxonomies_on_story_cards' );
|
||||
|
||||
// Prepare query
|
||||
$query_args = array(
|
||||
'fictioneer_query_name' => 'latest_stories',
|
||||
@ -51,6 +57,7 @@ $query_args = array(
|
||||
'order' => $args['order'],
|
||||
'orderby' => $args['orderby'],
|
||||
'posts_per_page' => $args['count'],
|
||||
'update_post_term_cache' => $show_terms, // Improve performance
|
||||
'no_found_rows' => true
|
||||
);
|
||||
|
||||
@ -129,7 +136,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$post_id = $post->ID;
|
||||
$story = fictioneer_get_story_data( $post_id, false ); // Does not refresh comment count!
|
||||
$story_link = get_post_meta( $post_id, 'fictioneer_story_redirect_link', true ) ?: get_permalink( $post_id );
|
||||
$tags = get_option( 'fictioneer_show_tags_on_story_cards' ) ? get_the_tags( $post ) : false;
|
||||
$tags = ( $show_terms && get_option( 'fictioneer_show_tags_on_story_cards' ) ) ? get_the_tags( $post ) : false;
|
||||
$is_sticky = FICTIONEER_ENABLE_STICKY_CARDS && get_post_meta( $post_id, 'fictioneer_story_sticky', true );
|
||||
$grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid';
|
||||
$card_classes = [];
|
||||
@ -245,41 +252,30 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' ) ) : ?>
|
||||
<?php if ( $show_terms ) : ?>
|
||||
<div class="card__tag-list _small _scrolling cell-tax">
|
||||
<div class="card__h-scroll">
|
||||
<div class="card__h-scroll <?php echo $args['terms'] === 'pills' ? '_pills' : ''; ?>">
|
||||
<?php
|
||||
if ( $story['has_taxonomies'] || $tags ) {
|
||||
$terms = [];
|
||||
$variant = $args['terms'] === 'pills' ? '_pill' : '_inline';
|
||||
|
||||
if ( $story['fandoms'] ) {
|
||||
foreach ( $story['fandoms'] as $fandom ) {
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = array_merge(
|
||||
$story['fandoms'] ? fictioneer_get_term_nodes( $story['fandoms'], "{$variant} _fandom" ) : [],
|
||||
$story['genres'] ? fictioneer_get_term_nodes( $story['genres'], "{$variant} _genre" ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, "{$variant} _tag" ) : [],
|
||||
$story['characters'] ? fictioneer_get_term_nodes( $story['characters'], "{$variant} _character" ) : []
|
||||
);
|
||||
|
||||
if ( $story['genres'] ) {
|
||||
foreach ( $story['genres'] as $genre ) {
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['characters'] ) {
|
||||
foreach ( $story['characters'] as $character ) {
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_stories_terms', $terms, $post, $args, $story );
|
||||
$terms = apply_filters(
|
||||
'fictioneer_filter_shortcode_latest_stories_terms',
|
||||
$terms, $post, $args, $story
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-stories' ), $terms );
|
||||
echo implode(
|
||||
fictioneer_get_bullet_separator( 'latest-stories', $args['terms'] === 'pills' ),
|
||||
array_slice( $terms, 0, $args['max_terms'] )
|
||||
);
|
||||
} else {
|
||||
?><span class="card__no-taxonomies"><?php _e( 'No taxonomies specified yet.', 'fictioneer' ); ?></span><?php
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$post_id = $post->ID;
|
||||
$story = fictioneer_get_story_data( $post_id, false ); // Does not refresh comment count!
|
||||
$permalink = get_post_meta( $post_id, 'fictioneer_story_redirect_link', true ) ?: get_permalink( $post_id );
|
||||
$tags = get_option( 'fictioneer_show_tags_on_story_cards' ) ? get_the_tags( $post ) : false;
|
||||
$tags = ( $show_terms && get_option( 'fictioneer_show_tags_on_story_cards' ) ) ? get_the_tags( $post ) : false;
|
||||
$chapter_list = [];
|
||||
|
||||
// Skip if no chapters
|
||||
@ -314,37 +314,25 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
<?php if ( $show_terms && ( $story['has_taxonomies'] || $tags ) ) : ?>
|
||||
<div class="post-list-item__tax <?php echo $args['terms'] === 'pills' ? '_pills' : ''; ?>"><?php
|
||||
$inline = $args['terms'] === 'pills' ? '' : '_inline';
|
||||
$terms = [];
|
||||
$variant = $args['terms'] === 'pills' ? '' : '_inline';
|
||||
|
||||
if ( $story['fandoms'] ) {
|
||||
foreach ( $story['fandoms'] as $fandom ) {
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill ' . $inline . ' _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = array_merge(
|
||||
$story['fandoms'] ? fictioneer_get_term_nodes( $story['fandoms'], "{$variant} _fandom" ) : [],
|
||||
$story['genres'] ? fictioneer_get_term_nodes( $story['genres'], "{$variant} _genre" ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, "{$variant} _tag" ) : [],
|
||||
$story['characters'] ? fictioneer_get_term_nodes( $story['characters'], "{$variant} _character" ) : []
|
||||
);
|
||||
|
||||
if ( $story['genres'] ) {
|
||||
foreach ( $story['genres'] as $genre ) {
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill ' . $inline . ' _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = apply_filters(
|
||||
'fictioneer_filter_shortcode_latest_updates_terms',
|
||||
$terms, $post, $args, $story
|
||||
);
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill ' . $inline . '">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['characters'] ) {
|
||||
foreach ( $story['characters'] as $character ) {
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill ' . $inline . ' _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_updates_terms', $terms, $post, $args, $story );
|
||||
$separator = $args['terms'] === 'pills' ? '' : fictioneer_get_bullet_separator( 'latest-updates-list' );
|
||||
|
||||
echo implode( $separator, array_slice( $terms, 0, $args['max_terms'] ) );
|
||||
// Implode with separator
|
||||
echo implode(
|
||||
fictioneer_get_bullet_separator( 'latest-stories-list', $args['terms'] === 'pills' ),
|
||||
array_slice( $terms, 0, $args['max_terms'] )
|
||||
);
|
||||
?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* @internal $args['words'] Whether to show the word count of chapter items. Default true.
|
||||
* @internal $args['date'] Whether to show the date of chapter items. Default true.
|
||||
* @internal $args['terms'] Either inline, pills, none, or false. Default inline.
|
||||
* @internal $args['max_terms'] Maximum number of taxonomies terms. Default 10.
|
||||
* @internal $args['max_terms'] Maximum number of shown taxonomies. Default 10.
|
||||
* @internal $args['date_format'] String to override the date format. Default empty.
|
||||
* @internal $args['nested_date_format'] String to override the date format of nested items. Default empty.
|
||||
* @internal $args['footer'] Whether to show the footer. Default true.
|
||||
@ -150,7 +150,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$post_id = $post->ID;
|
||||
$story = fictioneer_get_story_data( $post_id, false ); // Does not refresh comment count!
|
||||
$story_link = get_post_meta( $post_id, 'fictioneer_story_redirect_link', true ) ?: get_permalink( $post_id );
|
||||
$tags = get_option( 'fictioneer_show_tags_on_story_cards' ) ? get_the_tags( $post ) : false;
|
||||
$tags = ( $show_terms && get_option( 'fictioneer_show_tags_on_story_cards' ) ) ? get_the_tags( $post ) : false;
|
||||
$grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid';
|
||||
$chapter_list = [];
|
||||
$card_classes = [];
|
||||
@ -370,39 +370,28 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
<?php if ( $show_terms ) : ?>
|
||||
<div class="card__tag-list _small _scrolling cell-tax">
|
||||
<div class="card__h-scroll">
|
||||
<div class="card__h-scroll <?php echo $args['terms'] === 'pills' ? '_pills' : ''; ?>">
|
||||
<?php
|
||||
if ( $story['has_taxonomies'] || $tags ) {
|
||||
$terms = [];
|
||||
$variant = $args['terms'] === 'pills' ? '_pill' : '_inline';
|
||||
|
||||
if ( $story['fandoms'] ) {
|
||||
foreach ( $story['fandoms'] as $fandom ) {
|
||||
$terms[ $fandom->term_id ] = '<a href="' . get_tag_link( $fandom ) . '" class="tag-pill _inline _fandom">' . $fandom->name . '</a>';
|
||||
}
|
||||
}
|
||||
$terms = array_merge(
|
||||
$story['fandoms'] ? fictioneer_get_term_nodes( $story['fandoms'], "{$variant} _fandom" ) : [],
|
||||
$story['genres'] ? fictioneer_get_term_nodes( $story['genres'], "{$variant} _genre" ) : [],
|
||||
$tags ? fictioneer_get_term_nodes( $tags, "{$variant} _tag" ) : [],
|
||||
$story['characters'] ? fictioneer_get_term_nodes( $story['characters'], "{$variant} _character" ) : []
|
||||
);
|
||||
|
||||
if ( $story['genres'] ) {
|
||||
foreach ( $story['genres'] as $genre ) {
|
||||
$terms[ $genre->term_id ] = '<a href="' . get_tag_link( $genre ) . '" class="tag-pill _inline _genre">' . $genre->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $tags ) {
|
||||
foreach ( $tags as $tag ) {
|
||||
$terms[ $tag->term_id ] = '<a href="' . get_tag_link( $tag ) . '" class="tag-pill _inline">' . $tag->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $story['characters'] ) {
|
||||
foreach ( $story['characters'] as $character ) {
|
||||
$terms[ $character->term_id ] = '<a href="' . get_tag_link( $character ) . '" class="tag-pill _inline _character">' . $character->name . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$terms = apply_filters( 'fictioneer_filter_shortcode_latest_updates_terms', $terms, $post, $args, $story );
|
||||
$terms = apply_filters(
|
||||
'fictioneer_filter_shortcode_latest_updates_terms',
|
||||
$terms, $post, $args, $story
|
||||
);
|
||||
|
||||
// Implode with separator
|
||||
echo implode( fictioneer_get_bullet_separator( 'latest-updates' ), $terms );
|
||||
echo implode(
|
||||
fictioneer_get_bullet_separator( 'latest-updates', $args['terms'] === 'pills' ),
|
||||
array_slice( $terms, 0, $args['max_terms'] )
|
||||
);
|
||||
} else {
|
||||
?><span class="card__no-taxonomies"><?php _e( 'No taxonomies specified yet.', 'fictioneer' ); ?></span><?php
|
||||
}
|
||||
|
@ -444,6 +444,13 @@
|
||||
line-height: 1.5;
|
||||
padding: 0 1px; // Visually more "embedded"
|
||||
|
||||
&._pills {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
&._scrolling {
|
||||
--card-tags-margin-top: 0;
|
||||
position: relative;
|
||||
@ -465,7 +472,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
:is(.tag-pill._inline, a) {
|
||||
:is(.tag-pill._inline, a):not(._pill) {
|
||||
font-size: inherit;
|
||||
display: inline-block;
|
||||
}
|
||||
@ -482,6 +489,12 @@
|
||||
width: 0;
|
||||
display: none;
|
||||
}
|
||||
|
||||
&._pills {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin: 6px 0 2px;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
|
@ -252,11 +252,6 @@ body:not(.is-editor):not(.is-admin) {
|
||||
}
|
||||
}
|
||||
|
||||
.separator-dot {
|
||||
color: var(--fg-800);
|
||||
font-family: var(--ff-base);
|
||||
}
|
||||
|
||||
.tooltipped {
|
||||
position: relative;
|
||||
|
||||
@ -395,8 +390,13 @@ html:not(.logged-in) body:not(.logged-in) .hide-if-logged-out,
|
||||
clip-path: var(--header-polygon);
|
||||
}
|
||||
|
||||
.separator-dot {
|
||||
color: var(--fg-800);
|
||||
font-family: var(--ff-base);
|
||||
}
|
||||
|
||||
.pseudo-separator > *:where(:not(:first-child))::before {
|
||||
content: var(--post-list-separator, '• ');
|
||||
content: var(--pseudo-separator, '• ');
|
||||
color: var(--post-list-meta-divider-color, var(--fg-800));
|
||||
font-family: var(--ff-base);
|
||||
margin: 0 .125em;
|
||||
|
Loading…
x
Reference in New Issue
Block a user