Move chapter actions and footer to hooks

This commit is contained in:
Tetrakern 2024-07-31 11:35:06 +02:00
parent 57c747c187
commit f84c92fa52
3 changed files with 58 additions and 26 deletions

View File

@ -392,6 +392,7 @@ Fires right after the content section in the `single-fcn_chapter.php` template,
**Hooked Actions:**
* `fictioneer_chapter_afterword( $args )` Chapter afterword. Priority 10.
* `fictioneer_chapter_support_links( $args )` Support links set for the chapter/story/author. Priority 20.
* `fictioneer_chapter_footer( $args )` Chapter footer. Priority 99.
---
@ -435,6 +436,7 @@ Fires between the top actions sections and chapter header (title and authors) in
* $next_index (int|boolean) Index of next chapter or false if outside bounds.
**Hooked Actions:**
* `fictioneer_chapter_top_actions( $args )` Chapter top action row. Priority 1.
* `fictioneer_chapter_global_note( $args )` Story-wide note if provided. Priority 5.
* `fictioneer_chapter_foreword( $args )` Chapter foreword if provided. Priority 10.
* `fictioneer_chapter_warnings( $args )` Chapter warnings if provided. Priority 20.

View File

@ -83,6 +83,60 @@ function fictioneer_chapters_list( $args ) {
}
add_action( 'fictioneer_chapters_after_content', 'fictioneer_chapters_list', 30 );
// =============================================================================
// CHAPTER ACTIONS
// =============================================================================
/**
* Outputs the HTML for the chapter top actions
*
* @since 5.21.2
*
* @param array $args Hook args passed-through.
*/
function fictioneer_chapter_top_actions( $args ) {
// Start HTML ---> ?>
<div class="chapter__actions chapter__actions--top" data-nosnippet>
<div class="chapter__actions-container chapter__actions-left"><?php
do_action( 'fictioneer_chapter_actions_top_left', $args, 'top' );
?></div>
<div class="chapter__actions-container chapter__actions-center"><?php
do_action( 'fictioneer_chapter_actions_top_center', $args, 'top' );
?></div>
<div class="chapter__actions-container chapter__actions-right"><?php
do_action( 'fictioneer_chapter_actions_top_right', $args, 'top' );
?></div>
</div>
<?php // <--- End HTML
}
add_action( 'fictioneer_chapter_before_header', 'fictioneer_chapter_top_actions', 1 );
/**
* Outputs the HTML for the chapter footer
*
* @since 5.21.2
*
* @param array $args Hook args passed-through.
*/
function fictioneer_chapter_footer( $args ) {
// Start HTML ---> ?>
<footer class="chapter__footer chapter__actions chapter__actions--bottom padding-bottom chapter-end" data-nosnippet>
<div class="chapter__actions-container chapter__actions-left"><?php
do_action( 'fictioneer_chapter_actions_bottom_left', $args, 'bottom' );
?></div>
<div class="chapter__actions-container chapter__actions-center"><?php
do_action( 'fictioneer_chapter_actions_bottom_center', $args, 'bottom' );
?></div>
<div class="chapter__actions-container chapter__actions-right"><?php
do_action( 'fictioneer_chapter_actions_bottom_right', $args, 'bottom' );
?></div>
</footer>
<?php // <--- End HTML
}
add_action( 'fictioneer_chapter_after_content', 'fictioneer_chapter_footer', 99 );
// =============================================================================
// CHAPTER GLOBAL NOTE
// =============================================================================

View File

@ -134,20 +134,8 @@ get_header(
<article id="ch-<?php echo $post_id; ?>" data-author-id="<?php echo get_the_author_meta( 'ID' ); ?>" class="chapter__article padding-left padding-right <?php echo $password_required ? '_password' : ''; ?>" data-age-rating="<?php echo strtolower( $age_rating ); ?>">
<div class="chapter__actions chapter__actions--top" data-nosnippet>
<div class="chapter__actions-container chapter__actions-left"><?php
do_action( 'fictioneer_chapter_actions_top_left', $hook_args, 'top' );
?></div>
<div class="chapter__actions-container chapter__actions-center"><?php
do_action( 'fictioneer_chapter_actions_top_center', $hook_args, 'top' );
?></div>
<div class="chapter__actions-container chapter__actions-right"><?php
do_action( 'fictioneer_chapter_actions_top_right', $hook_args, 'top' );
?></div>
</div>
<?php
// Before chapter article header (includes foreword and warnings)
// Before chapter article header; includes the actions row, foreword, and warnings
do_action( 'fictioneer_chapter_before_header', $hook_args );
// Render article header
@ -187,22 +175,10 @@ get_header(
?></section>
<?php
// After chapter content; includes the afterword and support box
// After chapter content; includes the footer, afterword, and support box
do_action( 'fictioneer_chapter_after_content', $hook_args );
?>
<footer class="chapter__footer chapter__actions chapter__actions--bottom padding-bottom chapter-end" data-nosnippet>
<div class="chapter__actions-container chapter__actions-left"><?php
do_action( 'fictioneer_chapter_actions_bottom_left', $hook_args, 'bottom' );
?></div>
<div class="chapter__actions-container chapter__actions-center"><?php
do_action( 'fictioneer_chapter_actions_bottom_center', $hook_args, 'bottom' );
?></div>
<div class="chapter__actions-container chapter__actions-right"><?php
do_action( 'fictioneer_chapter_actions_bottom_right', $hook_args, 'bottom' );
?></div>
</footer>
</article>
<?php