From ef00a51301b9dc9829e609be067feea579b19779 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Thu, 17 Aug 2023 16:39:31 +0200 Subject: [PATCH] Account for unpublished story parent or chapter --- includes/functions/hooks/_chapter_hooks.php | 35 +++++++++++++++++++-- partials/_chapter-header.php | 25 ++++++++++----- single-fcn_chapter.php | 9 ++++-- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/includes/functions/hooks/_chapter_hooks.php b/includes/functions/hooks/_chapter_hooks.php index d273bf21..55623fae 100644 --- a/includes/functions/hooks/_chapter_hooks.php +++ b/includes/functions/hooks/_chapter_hooks.php @@ -198,6 +198,13 @@ add_action( 'fictioneer_chapter_actions_top_left', 'fictioneer_chapter_resize_bu */ function fictioneer_chapter_nav_buttons( $args, $location ) { + $post_status = get_post_status( get_the_ID() ); + + // Do not render on hidden posts + if ( $post_status !== 'publish' ) { + return; + } + // Start HTML ---> ?> @@ -251,6 +258,12 @@ add_action( 'fictioneer_chapter_actions_top_center', 'fictioneer_chapter_formatt function fictioneer_chapter_subscribe_button() { $subscribe_buttons = fictioneer_get_subscribe_options(); + $post_status = get_post_status( get_the_ID() ); + + // Do not render on hidden posts + if ( $post_status !== 'publish' ) { + return; + } if ( ! empty( $subscribe_buttons ) ) { // Start HTML ---> ?> @@ -290,7 +303,7 @@ function fictioneer_chapter_fullscreen_buttons() { add_action( 'fictioneer_chapter_actions_top_center', 'fictioneer_chapter_fullscreen_buttons', 20 ); // ============================================================================= -// CHAPTER BACK TO STORY BUTTON +// CHAPTER INDEX POPUP MENU // ============================================================================= /** @@ -302,8 +315,17 @@ add_action( 'fictioneer_chapter_actions_top_center', 'fictioneer_chapter_fullscr */ function fictioneer_chapter_index_popup_menu( $args ) { - // Abort if... - if ( ! $args['story_post'] ) return; + $post_status = get_post_status( get_the_ID() ); + + // Do not render on hidden posts + if ( $post_status !== 'publish' ) { + return; + } + + // Abort if there is no story assigned + if ( ! $args['story_post'] ) { + return; + } // Start HTML ---> ?>