Skip 0 words and empty excerpts on small cards
This commit is contained in:
parent
5ef94c9fc8
commit
5e31172da7
@ -975,7 +975,7 @@ Filters the WP_Query arguments in the `fictioneer_blog` shortcode.
|
||||
Filters the intermediate output array in the `_latest-chapters.php` partial before it is imploded and rendered. Contains statistics with icons such as the number of chapters, words, dates, and so forth.
|
||||
|
||||
**$footer_items:**
|
||||
* $words (string) – HTML for the total word count.
|
||||
* $words (string|null) – HTML for the total word count (if more than 0).
|
||||
* $publish_date (string) – Conditional. HTML for the publish date.
|
||||
* $modified_date (string) – Conditional. HTML for the modified date.
|
||||
* $comments (string) – HTML for the number of comments.
|
||||
@ -1100,7 +1100,7 @@ Filters the intermediate output arrays in the `_latest-stories.php` and `_latest
|
||||
|
||||
**$footer_items:**
|
||||
* $chapters (string) – HTML for the number of chapters.
|
||||
* $words (string) – HTML for the total word count.
|
||||
* $words (string|null) – HTML for the total word count (if more than 0).
|
||||
* $publish_date (string) – Conditional. HTML for the publish date.
|
||||
* $modified_date (string) – Conditional. HTML for the modified date.
|
||||
* $status (string) – HTML for the status.
|
||||
@ -1161,7 +1161,7 @@ Filters the intermediate output array in the `_latest-updates.php` partial befor
|
||||
|
||||
**$footer_items:**
|
||||
* $chapters (string) – HTML for the number of chapters.
|
||||
* $words (string) – HTML for the total word count.
|
||||
* $words (string|null) – HTML for the total word count (if more than 0).
|
||||
* $modified_date (string) – Conditional. HTML for the modified date.
|
||||
* $status (string) – HTML for the status.
|
||||
|
||||
|
@ -133,6 +133,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$title = fictioneer_get_safe_title( $post_id, 'shortcode-latest-chapters-compact' );
|
||||
$story = $story_id ? fictioneer_get_story_data( $story_id, false ) : null; // Does not refresh comment count!
|
||||
$text_icon = get_post_meta( $post_id, 'fictioneer_chapter_text_icon', true );
|
||||
$words = fictioneer_get_word_count( $post_id );
|
||||
$grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid';
|
||||
$card_classes = [];
|
||||
|
||||
@ -177,7 +178,9 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
<li class="post-<?php echo $post_id; ?> card watch-last-clicked _small _info _chapter _compact _no-footer <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<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 if ( $words > 0 ) : ?>
|
||||
<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; ?>
|
||||
|
||||
<div class="card__main <?php echo $grid_or_vertical; ?> _small">
|
||||
|
||||
@ -232,24 +235,30 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="text-overflow-ellipsis">
|
||||
<div class="card__words-on-date text-overflow-ellipsis">
|
||||
<?php
|
||||
printf(
|
||||
_x( '%1$s Words on %2$s', 'Small card: {n} Words on {Date}.', 'fictioneer' ),
|
||||
fictioneer_shorten_number( fictioneer_get_word_count( $post_id ) ),
|
||||
get_the_time( FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE )
|
||||
);
|
||||
if ( $words > 0 ) {
|
||||
printf(
|
||||
_x( '%1$s Words on %2$s', 'Small card: {n} Words on {Date}.', 'fictioneer' ),
|
||||
fictioneer_shorten_number( fictioneer_get_word_count( $post_id ) ),
|
||||
get_the_time( FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE )
|
||||
);
|
||||
} else {
|
||||
the_time( FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card__overlay-infobox _excerpt escape-last-click">
|
||||
<div class="card__excerpt"><?php
|
||||
echo fictioneer_get_forced_excerpt( $post, $args['vertical'] ? 512 : 256 );
|
||||
?></div>
|
||||
</div>
|
||||
<?php if ( $words > 0 ) : ?>
|
||||
<div class="card__overlay-infobox _excerpt escape-last-click">
|
||||
<div class="card__excerpt"><?php
|
||||
echo fictioneer_get_forced_excerpt( $post, $args['vertical'] ? 512 : 256 );
|
||||
?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
|
@ -135,6 +135,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$chapter_rating = get_post_meta( $post_id, 'fictioneer_chapter_rating', true );
|
||||
$story = $story_id ? fictioneer_get_story_data( $story_id, false ) : null; // Does not refresh comment count!
|
||||
$text_icon = get_post_meta( $post_id, 'fictioneer_chapter_text_icon', true );
|
||||
$words = fictioneer_get_word_count( $post_id );
|
||||
$grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid';
|
||||
$card_classes = [];
|
||||
|
||||
@ -244,19 +245,21 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
);
|
||||
$spoiler_note = apply_filters( 'fictioneer_filter_obfuscation_string', $spoiler_note, $post );
|
||||
?>
|
||||
<?php if ( ! $args['spoiler'] ) : ?>
|
||||
<span data-click="toggle-obfuscation" tabindex="0">
|
||||
<span class="obfuscated"> <?php echo $spoiler_note; ?></span>
|
||||
<span class="clean"><?php
|
||||
<?php if ( strlen( str_replace( '…', '', $excerpt ) ) > 2 ) : ?>
|
||||
<?php if ( ! $args['spoiler'] ) : ?>
|
||||
<span data-click="toggle-obfuscation" tabindex="0">
|
||||
<span class="obfuscated"> <?php echo $spoiler_note; ?></span>
|
||||
<span class="clean"><?php
|
||||
echo $args['source'] ? '— ' : '';
|
||||
echo $excerpt;
|
||||
?></span>
|
||||
</span>
|
||||
<?php else : ?>
|
||||
<span><span class="clean"><?php
|
||||
echo $args['source'] ? '— ' : '';
|
||||
echo $excerpt;
|
||||
?></span>
|
||||
</span>
|
||||
<?php else : ?>
|
||||
<span><span class="clean"><?php
|
||||
echo $args['source'] ? '— ' : '';
|
||||
echo $excerpt;
|
||||
?></span></span>
|
||||
?></span></span>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -269,9 +272,11 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
// Build footer items
|
||||
$footer_items = [];
|
||||
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Words', 'fictioneer' ) . '"></i> ' .
|
||||
fictioneer_shorten_number( fictioneer_get_word_count( $post_id ) );
|
||||
if ( $words > 0 ) {
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Words', 'fictioneer' ) . '"></i> ' .
|
||||
fictioneer_shorten_number( fictioneer_get_word_count( $post_id ) );
|
||||
}
|
||||
|
||||
if ( $args['orderby'] == 'modified' ) {
|
||||
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
||||
|
@ -280,8 +280,10 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
||||
}
|
||||
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
||||
if ( $story['word_count'] > 0 ) {
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
||||
}
|
||||
|
||||
if ( $args['orderby'] == 'modified' ) {
|
||||
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
||||
|
@ -266,8 +266,10 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
||||
}
|
||||
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
||||
if ( $story['word_count'] > 0 ) {
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
||||
}
|
||||
|
||||
if ( $args['orderby'] == 'modified' ) {
|
||||
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
||||
|
@ -194,6 +194,10 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
break;
|
||||
}
|
||||
|
||||
// Chapter excerpt
|
||||
$chapter_excerpt = fictioneer_get_forced_excerpt( $chapter_list[0]->ID, 768 );
|
||||
$show_excerpt = strlen( str_replace( '…', '', $chapter_excerpt ) ) > 2;
|
||||
|
||||
// Truncate factor
|
||||
$truncate_factor = $args['vertical'] ? '_2-2' : '_cq-1-2';
|
||||
|
||||
@ -216,7 +220,9 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
<li class="post-<?php echo $post_id; ?> card watch-last-clicked _small _info _story-update _compact _no-footer <?php echo implode( ' ', $card_classes ); ?>" <?php echo $card_attributes; ?>>
|
||||
<div class="card__body polygon">
|
||||
|
||||
<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 if ( $show_excerpt ) : ?>
|
||||
<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; ?>
|
||||
|
||||
<div class="card__main <?php echo $grid_or_vertical; ?> _small">
|
||||
|
||||
@ -282,9 +288,6 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
if ( ! empty( $chapter->post_password ) ) {
|
||||
$list_item_classes[] = '_password';
|
||||
}
|
||||
|
||||
// Chapter excerpt
|
||||
$chapter_excerpt = fictioneer_get_forced_excerpt( $chapter->ID, 768 );
|
||||
?>
|
||||
<li class="card__link-list-item <?php echo implode( ' ', $list_item_classes ); ?>">
|
||||
<div class="card__left text-overflow-ellipsis">
|
||||
@ -295,12 +298,13 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
</div>
|
||||
<div class="card__right">
|
||||
<?php
|
||||
if ( $args['words'] ) {
|
||||
echo '<span class="words">' .
|
||||
fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) ) . '</span>';
|
||||
$words = $args['words'] ? fictioneer_get_word_count( $chapter->ID ) : 0;
|
||||
|
||||
if ( $words ) {
|
||||
echo '<span class="words _words-' . $words . '">' . fictioneer_shorten_number( $words ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['words'] && $args['date'] ) {
|
||||
if ( $words && $args['date'] ) {
|
||||
echo '<span class="separator-dot"> • </span>';
|
||||
}
|
||||
|
||||
@ -316,9 +320,11 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card__overlay-infobox _excerpt escape-last-click">
|
||||
<div class="card__excerpt"><strong><?php echo $chapter_title; ?>:</strong> <?php echo $chapter_excerpt; ?></div>
|
||||
</div>
|
||||
<?php if ( $show_excerpt ) : ?>
|
||||
<div class="card__overlay-infobox _excerpt escape-last-click">
|
||||
<div class="card__excerpt"><strong><?php echo $chapter_title; ?>:</strong> <?php echo $chapter_excerpt; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
|
@ -304,12 +304,13 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
<?php if ( $args['words'] || $args['date'] ) : ?>
|
||||
<div class="card__right">
|
||||
<?php
|
||||
if ( $args['words'] ) {
|
||||
echo '<span class="words">' .
|
||||
fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) ) . '</span>';
|
||||
$words = $args['words'] ? fictioneer_get_word_count( $chapter->ID ) : 0;
|
||||
|
||||
if ( $words ) {
|
||||
echo '<span class="words _words-' . $words . '">' . fictioneer_shorten_number( $words ) . '</span>';
|
||||
}
|
||||
|
||||
if ( $args['words'] && $args['date'] ) {
|
||||
if ( $words && $args['date'] ) {
|
||||
echo '<span class="separator-dot"> • </span>';
|
||||
}
|
||||
|
||||
@ -376,8 +377,10 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
$footer_items['chapters'] = '<i class="card-footer-icon fa-solid fa-list" title="' .
|
||||
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
||||
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
||||
if ( $story['word_count'] > 0 ) {
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
||||
}
|
||||
|
||||
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
||||
esc_attr__( 'Last Updated', 'fictioneer' ) . '"></i> ' .
|
||||
|
Loading…
x
Reference in New Issue
Block a user