Make story footer meta data filterable
This commit is contained in:
parent
20c5a0dba6
commit
c6e1ba771c
16
FILTERS.md
16
FILTERS.md
@ -1411,6 +1411,22 @@ Filters the arguments for the story chapter posts query, an utility function cal
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_story_footer_meta', $meta_output, $args, $post )`
|
||||
Filters the intermediate output array of story meta data in the `_story-footer.php` partial before it is imploded and rendered. Contains the status, publish date, word count, age rating, and checkmark (if enabled).
|
||||
|
||||
**meta_output:**
|
||||
* $status (string) – HTML snippet for the status.
|
||||
* $date (string) – HTML snippet for the date.
|
||||
* $words (string) – HTML snippet for the word count.
|
||||
* $rating (string) – HTML snippet for the age rating.
|
||||
* $checkmark (string) – HTML snippet for the checkmark.
|
||||
|
||||
**Parameters:**
|
||||
* $args (array) – Relevant story data: 'story_id' (int) and 'story_data' (array).
|
||||
* $post (WP_Post) – The post object of the story.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_story_identity', $output, $story_id, $story )`
|
||||
Filters the intermediate output array in the `_story-header.php` partial before it is imploded and rendered. Contains the HTML for the story title (safe) and author meta nodes (see `fictioneer_get_story_author_nodes()`).
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
* @package WordPress
|
||||
* @subpackage Fictioneer
|
||||
* @since 4.7.0
|
||||
* @since 5.17.0 - Turned meta data into filterable array.
|
||||
* @see single-fcn_story.php
|
||||
*
|
||||
* @internal $args['story_data'] Story data from fictioneer_get_story_data().
|
||||
@ -34,6 +35,27 @@ $story_id = $args['story_id'];
|
||||
$story = $args['story_data'];
|
||||
$post = get_post( $story_id );
|
||||
$show_log = $story['chapter_count'] > 0 && FICTIONEER_ENABLE_STORY_CHANGELOG && get_option( 'fictioneer_show_story_changelog' );
|
||||
$meta_output = [];
|
||||
|
||||
// Status
|
||||
$meta_output['status'] = '<span class="story__meta-item story__status"><i class="' . $story['icon'] . '"></i> ' . $story['status'] . '</span>';
|
||||
|
||||
// Date
|
||||
$meta_output['date'] = '<span class="story__meta-item story__date _published" title="' . esc_attr__( 'Published', 'fictioneer' ) . '"><i class="fa-solid fa-clock"></i> <span class="hide-below-480">' . get_the_time( get_option( 'date_format' ), $post ) . '</span><span class="show-below-480">' . get_the_time( FICTIONEER_STORY_FOOTER_B480_DATE, $post ) . '</span></span>';
|
||||
|
||||
// Words
|
||||
$meta_output['words'] = '<span class="story__meta-item story__words" title="' . esc_attr__( 'Total Words', 'fictioneer' ) . '"><i class="fa-solid fa-font"></i> ' . $story['word_count_short'] . '</span>';
|
||||
|
||||
// Rating
|
||||
$meta_output['rating'] = '<span class="story__meta-item story__rating" title="' . esc_attr__( 'Rating', 'fictioneer' ) . '"><i class="fa-solid fa-exclamation-circle"></i> ' . $story['rating'] . '</span>';
|
||||
|
||||
// Checkmark
|
||||
if ( $story['chapter_count'] > 0 ) {
|
||||
$meta_output['checkmark'] = '<button class="story__meta-item checkmark story__meta-checkmark" data-type="story" data-story-id="' . $story_id . '" data-id="' . $story_id . '" data-status="' . esc_attr( $story['status'] ) . '" role="checkbox" aria-checked="false" aria-label="' . sprintf( esc_attr__( 'Story checkmark for %s.', 'fictioneer' ), $story['title'] ) . '"><i class="fa-solid fa-check"></i></button>';
|
||||
}
|
||||
|
||||
// Filter
|
||||
$meta_output = apply_filters( 'fictioneer_filter_story_footer_meta', $meta_output, $args, $post );
|
||||
|
||||
?>
|
||||
|
||||
@ -45,35 +67,5 @@ $show_log = $story['chapter_count'] > 0 && FICTIONEER_ENABLE_STORY_CHANGELOG &&
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="story__meta">
|
||||
<span class="story__meta-item story__status">
|
||||
<i class="<?php echo $story['icon']; ?>"></i>
|
||||
<?php echo $story['status']; ?>
|
||||
</span>
|
||||
<span class="story__meta-item story__date _published" title="<?php esc_attr_e( 'Published', 'fictioneer' ); ?>">
|
||||
<i class="fa-solid fa-clock"></i>
|
||||
<span class="hide-below-480"><?php the_time( get_option( 'date_format' ) ); ?></span>
|
||||
<span class="show-below-480"><?php the_time( FICTIONEER_STORY_FOOTER_B480_DATE ); ?></span>
|
||||
</span>
|
||||
<span class="story__meta-item story__words" title="<?php esc_attr_e( 'Total Words', 'fictioneer' ); ?>">
|
||||
<i class="fa-solid fa-font"></i>
|
||||
<?php echo $story['word_count_short']; ?>
|
||||
</span>
|
||||
<span class="story__meta-item story__rating" title="<?php esc_attr_e( 'Rating', 'fictioneer' ); ?>">
|
||||
<i class="fa-solid fa-exclamation-circle"></i>
|
||||
<?php echo $story['rating']; ?>
|
||||
</span>
|
||||
<?php if ( $story['chapter_count'] > 0 ): ?>
|
||||
<button
|
||||
class="story__meta-item checkmark story__meta-checkmark"
|
||||
data-type="story"
|
||||
data-story-id="<?php echo $story_id; ?>"
|
||||
data-id="<?php echo $story_id; ?>"
|
||||
data-status="<?php echo esc_attr( $story['status'] ); ?>"
|
||||
role="checkbox"
|
||||
aria-checked="false"
|
||||
aria-label="<?php printf( esc_attr__( 'Story checkmark for %s.', 'fictioneer' ), $story['title'] ); ?>"
|
||||
><i class="fa-solid fa-check"></i></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="story__meta"><?php echo implode( '', $meta_output ); ?></div>
|
||||
</footer>
|
||||
|
Loading…
x
Reference in New Issue
Block a user