Add latest updates card footer filter

This commit is contained in:
Tetrakern 2023-09-10 16:34:15 +02:00
parent 02158a9768
commit 9338a06775
2 changed files with 42 additions and 10 deletions

View File

@ -802,6 +802,22 @@ Filters the query arguments in the `fictioneer_latest_stories` shortcode. The op
---
### `apply_filters( 'fictioneer_filter_shortcode_latest_updates_card_footer', $footer_items, $story, $args, $post )`
Filters the intermediate output array in the `_latest-updates.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:**
* $chapters (string) HTML for the number of chapters.
* $words (string) HTML for the total word count.
* $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_Post) The post object.
---
### `apply_filters( 'fictioneer_filter_shortcode_latest_updates_query_args', $query_args, $args )`
Filters the query arguments in the `fictioneer_latest_updates` shortcode. The optional taxonomy arrays can include categories, tags, fandoms, genres, and characters.

View File

@ -224,21 +224,37 @@ $entries = fictioneer_shortcode_query( $query_args );
<?php if ( ! $args['simple'] ) : ?>
<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_UPDATES_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'] ); ?>
$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_UPDATES_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_shortcode_latest_updates_card_footer',
$footer_items,
$story,
$args,
$post
);
// 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'] ); ?>