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.
|
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:**
|
**$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.
|
* $publish_date (string) – Conditional. HTML for the publish date.
|
||||||
* $modified_date (string) – Conditional. HTML for the modified date.
|
* $modified_date (string) – Conditional. HTML for the modified date.
|
||||||
* $comments (string) – HTML for the number of comments.
|
* $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:**
|
**$footer_items:**
|
||||||
* $chapters (string) – HTML for the number of chapters.
|
* $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.
|
* $publish_date (string) – Conditional. HTML for the publish date.
|
||||||
* $modified_date (string) – Conditional. HTML for the modified date.
|
* $modified_date (string) – Conditional. HTML for the modified date.
|
||||||
* $status (string) – HTML for the status.
|
* $status (string) – HTML for the status.
|
||||||
@ -1161,7 +1161,7 @@ Filters the intermediate output array in the `_latest-updates.php` partial befor
|
|||||||
|
|
||||||
**$footer_items:**
|
**$footer_items:**
|
||||||
* $chapters (string) – HTML for the number of chapters.
|
* $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.
|
* $modified_date (string) – Conditional. HTML for the modified date.
|
||||||
* $status (string) – HTML for the status.
|
* $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' );
|
$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!
|
$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 );
|
$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';
|
$grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid';
|
||||||
$card_classes = [];
|
$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; ?>>
|
<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">
|
<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">
|
<div class="card__main <?php echo $grid_or_vertical; ?> _small">
|
||||||
|
|
||||||
@ -232,24 +235,30 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-overflow-ellipsis">
|
<div class="card__words-on-date text-overflow-ellipsis">
|
||||||
<?php
|
<?php
|
||||||
printf(
|
if ( $words > 0 ) {
|
||||||
_x( '%1$s Words on %2$s', 'Small card: {n} Words on {Date}.', 'fictioneer' ),
|
printf(
|
||||||
fictioneer_shorten_number( fictioneer_get_word_count( $post_id ) ),
|
_x( '%1$s Words on %2$s', 'Small card: {n} Words on {Date}.', 'fictioneer' ),
|
||||||
get_the_time( FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE )
|
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>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card__overlay-infobox _excerpt escape-last-click">
|
<?php if ( $words > 0 ) : ?>
|
||||||
<div class="card__excerpt"><?php
|
<div class="card__overlay-infobox _excerpt escape-last-click">
|
||||||
echo fictioneer_get_forced_excerpt( $post, $args['vertical'] ? 512 : 256 );
|
<div class="card__excerpt"><?php
|
||||||
?></div>
|
echo fictioneer_get_forced_excerpt( $post, $args['vertical'] ? 512 : 256 );
|
||||||
</div>
|
?></div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -135,6 +135,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
$chapter_rating = get_post_meta( $post_id, 'fictioneer_chapter_rating', true );
|
$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!
|
$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 );
|
$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';
|
$grid_or_vertical = $args['vertical'] ? '_vertical' : '_grid';
|
||||||
$card_classes = [];
|
$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 );
|
$spoiler_note = apply_filters( 'fictioneer_filter_obfuscation_string', $spoiler_note, $post );
|
||||||
?>
|
?>
|
||||||
<?php if ( ! $args['spoiler'] ) : ?>
|
<?php if ( strlen( str_replace( '…', '', $excerpt ) ) > 2 ) : ?>
|
||||||
<span data-click="toggle-obfuscation" tabindex="0">
|
<?php if ( ! $args['spoiler'] ) : ?>
|
||||||
<span class="obfuscated"> <?php echo $spoiler_note; ?></span>
|
<span data-click="toggle-obfuscation" tabindex="0">
|
||||||
<span class="clean"><?php
|
<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 $args['source'] ? '— ' : '';
|
||||||
echo $excerpt;
|
echo $excerpt;
|
||||||
?></span>
|
?></span></span>
|
||||||
</span>
|
<?php endif; ?>
|
||||||
<?php else : ?>
|
|
||||||
<span><span class="clean"><?php
|
|
||||||
echo $args['source'] ? '— ' : '';
|
|
||||||
echo $excerpt;
|
|
||||||
?></span></span>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -269,9 +272,11 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
// Build footer items
|
// Build footer items
|
||||||
$footer_items = [];
|
$footer_items = [];
|
||||||
|
|
||||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
if ( $words > 0 ) {
|
||||||
esc_attr__( 'Words', 'fictioneer' ) . '"></i> ' .
|
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||||
fictioneer_shorten_number( fictioneer_get_word_count( $post_id ) );
|
esc_attr__( 'Words', 'fictioneer' ) . '"></i> ' .
|
||||||
|
fictioneer_shorten_number( fictioneer_get_word_count( $post_id ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( $args['orderby'] == 'modified' ) {
|
if ( $args['orderby'] == 'modified' ) {
|
||||||
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
$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'];
|
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
if ( $story['word_count'] > 0 ) {
|
||||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
$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' ) {
|
if ( $args['orderby'] == 'modified' ) {
|
||||||
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
$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'];
|
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
if ( $story['word_count'] > 0 ) {
|
||||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
$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' ) {
|
if ( $args['orderby'] == 'modified' ) {
|
||||||
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
$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;
|
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
|
||||||
$truncate_factor = $args['vertical'] ? '_2-2' : '_cq-1-2';
|
$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; ?>>
|
<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">
|
<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">
|
<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 ) ) {
|
if ( ! empty( $chapter->post_password ) ) {
|
||||||
$list_item_classes[] = '_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 ); ?>">
|
<li class="card__link-list-item <?php echo implode( ' ', $list_item_classes ); ?>">
|
||||||
<div class="card__left text-overflow-ellipsis">
|
<div class="card__left text-overflow-ellipsis">
|
||||||
@ -295,12 +298,13 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
</div>
|
</div>
|
||||||
<div class="card__right">
|
<div class="card__right">
|
||||||
<?php
|
<?php
|
||||||
if ( $args['words'] ) {
|
$words = $args['words'] ? fictioneer_get_word_count( $chapter->ID ) : 0;
|
||||||
echo '<span class="words">' .
|
|
||||||
fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) ) . '</span>';
|
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>';
|
echo '<span class="separator-dot"> • </span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,9 +320,11 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card__overlay-infobox _excerpt escape-last-click">
|
<?php if ( $show_excerpt ) : ?>
|
||||||
<div class="card__excerpt"><strong><?php echo $chapter_title; ?>:</strong> <?php echo $chapter_excerpt; ?></div>
|
<div class="card__overlay-infobox _excerpt escape-last-click">
|
||||||
</div>
|
<div class="card__excerpt"><strong><?php echo $chapter_title; ?>:</strong> <?php echo $chapter_excerpt; ?></div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -304,12 +304,13 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
|||||||
<?php if ( $args['words'] || $args['date'] ) : ?>
|
<?php if ( $args['words'] || $args['date'] ) : ?>
|
||||||
<div class="card__right">
|
<div class="card__right">
|
||||||
<?php
|
<?php
|
||||||
if ( $args['words'] ) {
|
$words = $args['words'] ? fictioneer_get_word_count( $chapter->ID ) : 0;
|
||||||
echo '<span class="words">' .
|
|
||||||
fictioneer_shorten_number( fictioneer_get_word_count( $chapter->ID ) ) . '</span>';
|
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>';
|
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="' .
|
$footer_items['chapters'] = '<i class="card-footer-icon fa-solid fa-list" title="' .
|
||||||
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
|
||||||
|
|
||||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
if ( $story['word_count'] > 0 ) {
|
||||||
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
|
$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="' .
|
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
||||||
esc_attr__( 'Last Updated', 'fictioneer' ) . '"></i> ' .
|
esc_attr__( 'Last Updated', 'fictioneer' ) . '"></i> ' .
|
||||||
|
Loading…
x
Reference in New Issue
Block a user