Add filter to latest stories card footer

This commit is contained in:
Tetrakern 2023-09-10 14:52:47 +02:00
parent 8c568e81ac
commit 96c74a84cb
3 changed files with 81 additions and 20 deletions

View File

@ -755,6 +755,23 @@ Filters the query arguments in the `fictioneer_latest_recommendations` shortcode
---
### `apply_filters( 'fictioneer_filter_latest_stories_card_footer', $footer_items, $story, $args, $query )`
Filters the intermediate output arrays in the `_latest-stories.php` and `_latest-stories-compact.php` partials before they are imploded and rendered. Contains statistics with icons such as the number of chapters, words, dates, and so forth.
**$footer_items:**
* $chapters (string) HTML for the number of chapters.
* $words (string) HTML for the total word count.
* $publish_date (string) Conditional. HTML for the publish date.
* $modified_date (string) Conditional. HTML for the modified date.
* $status (status) HTML for the status.
**Parameters**
* $story (array) Collection of story post data.
* $args (array) Arguments passed to the partial.
* $story (WP_Query) Query of the shortcode.
---
### `apply_filters( 'fictioneer_filter_shortcode_latest_stories_query_args', $query_args, $args )`
Filters the query arguments in the `fictioneer_latest_stories` shortcode. The optional taxonomy arrays can include categories, tags, fandoms, genres, and characters.

View File

@ -168,21 +168,43 @@ $entries = fictioneer_shortcode_query( $query_args );
<div class="card__footer _small">
<div class="card__footer-box _left text-overflow-ellipsis">
<div class="card__footer-box _left text-overflow-ellipsis"><?php
<i class="card-footer-icon fa-solid fa-list" title="<?php esc_attr_e( 'Chapters', 'fictioneer' ); ?>"></i>
<?php echo $story['chapter_count']; ?>
// Build footer items
$footer_items = [];
<i class="card-footer-icon fa-solid fa-font" title="<?php esc_attr_e( 'Total Words', 'fictioneer' ); ?>"></i>
<?php echo $story['word_count_short']; ?>
$footer_items['chapters'] = '<i class="card-footer-icon fa-solid fa-list" title="' .
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
<i class="card-footer-icon fa-regular fa-clock" title="<?php esc_attr_e( 'Last Updated', 'fictioneer' ); ?>"></i>
<?php echo get_the_modified_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post ); ?>
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
<i class="card-footer-icon <?php echo $story['icon']; ?>"></i>
<?php echo fcntr( $story['status'] ); ?>
if ( $args['orderby'] == 'date' ) {
$footer_items['publish_date'] = '<i class="card-footer-icon fa-solid fa-clock" title="' .
esc_attr__( 'Published', 'fictioneer' ) . '"></i> ' .
get_the_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post );
} else {
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
esc_attr__( 'Last Updated', 'fictioneer' ) . '"></i> ' .
get_the_modified_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post );
}
</div>
$footer_items['status'] = '<i class="card-footer-icon ' . $story['icon'] . '"></i> ' .
fcntr( $story['status'] );
// Filer footer items
$footer_items = apply_filters(
'fictioneer_filter_latest_stories_card_footer',
$footer_items,
$story,
$args,
$entries
);
// Implode and render footer items
echo implode( ' ', $footer_items );
?></div>
<div class="card__footer-box _right rating-letter-label tooltipped" data-tooltip="<?php echo fcntr( $story['rating'], true ); ?>">
<?php echo fcntr( $story['rating_letter'] ); ?>

View File

@ -161,21 +161,43 @@ $entries = fictioneer_shortcode_query( $query_args );
<div class="card__footer _small">
<div class="card__footer-box _left text-overflow-ellipsis">
<div class="card__footer-box _left text-overflow-ellipsis"><?php
<i class="card-footer-icon fa-solid fa-list" title="<?php esc_attr_e( 'Chapters', 'fictioneer' ); ?>"></i>
<?php echo $story['chapter_count']; ?>
// Build footer items
$footer_items = [];
<i class="card-footer-icon fa-solid fa-font" title="<?php esc_attr_e( 'Total Words', 'fictioneer' ); ?>"></i>
<?php echo $story['word_count_short']; ?>
$footer_items['chapters'] = '<i class="card-footer-icon fa-solid fa-list" title="' .
esc_attr__( 'Chapters', 'fictioneer' ) . '"></i> ' . $story['chapter_count'];
<i class="card-footer-icon fa-regular fa-clock" title="<?php esc_attr_e( 'Last Updated', 'fictioneer' ); ?>"></i>
<?php echo get_the_modified_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post ); ?>
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
esc_attr__( 'Total Words', 'fictioneer' ) . '"></i> ' . $story['word_count_short'];
<i class="card-footer-icon <?php echo $story['icon']; ?>"></i>
<?php echo fcntr( $story['status'] ); ?>
if ( $args['orderby'] == 'date' ) {
$footer_items['publish_date'] = '<i class="card-footer-icon fa-solid fa-clock" title="' .
esc_attr__( 'Published', 'fictioneer' ) . '"></i> ' .
get_the_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post );
} else {
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
esc_attr__( 'Last Updated', 'fictioneer' ) . '"></i> ' .
get_the_modified_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post );
}
</div>
$footer_items['status'] = '<i class="card-footer-icon ' . $story['icon'] . '"></i> ' .
fcntr( $story['status'] );
// Filer footer items
$footer_items = apply_filters(
'fictioneer_filter_latest_stories_card_footer',
$footer_items,
$story,
$args,
$entries
);
// Implode and render footer items
echo implode( ' ', $footer_items );
?></div>
<div class="card__footer-box _right rating-letter-label tooltipped" data-tooltip="<?php echo fcntr( $story['rating'], true ); ?>">
<?php echo fcntr( $story['rating_letter'] ); ?>