From 7b45efd5e6f81e30611ea7ce59de51913d54f3a6 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Sat, 17 Aug 2024 13:54:49 +0200 Subject: [PATCH] Fix page overflow on story pages if thumbnail is missing or hidden --- single-fcn_story.php | 22 +++++++++------------- singular-story.php | 3 ++- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/single-fcn_story.php b/single-fcn_story.php index dca6fe35..b9cc694f 100644 --- a/single-fcn_story.php +++ b/single-fcn_story.php @@ -17,11 +17,12 @@ $post_id = $args['post_id'] ?? get_the_ID(); $post = get_post( $post_id ); $password_required = post_password_required(); $cover_position = get_theme_mod( 'story_cover_position', 'top-left-overflow' ); +$show_thumbnail = has_post_thumbnail( $post_id ) && ! get_post_meta( $post_id, 'fictioneer_story_no_thumbnail', true ); // Wrapper classes $wrapper_classes = []; -if ( $cover_position === 'top-left-overflow' ) { +if ( $cover_position === 'top-left-overflow' && $show_thumbnail ) { $wrapper_classes[] = '_no-padding-top'; } @@ -46,22 +47,21 @@ get_header( do_action( 'fictioneer_main_wrapper' ); // Setup - $story_id = $post_id; - $story = fictioneer_get_story_data( $story_id ); + $story = fictioneer_get_story_data( $post_id ); $epub_name = sanitize_file_name( strtolower( get_the_title() ) ); $this_breadcrumb = [ $story['title'], get_the_permalink() ]; - $password_note = fictioneer_get_content_field( 'fictioneer_story_password_note', $story_id ); + $password_note = fictioneer_get_content_field( 'fictioneer_story_password_note', $post_id ); $cover_position = get_theme_mod( 'story_cover_position', 'top-left-overflow' ); // Arguments for hooks and templates/etc. $hook_args = array( 'story_data' => $story, - 'story_id' => $story_id, + 'story_id' => $post_id, 'password_required' => $password_required ); ?> -
+
' . fictioneer_get_forced_excerpt( $story_id, 512 ) . '

'; + echo '

' . fictioneer_get_forced_excerpt( $post_id, 512 ) . '

'; } } - if ( - in_array( $cover_position, ['float-left', 'float-right'] ) && - has_post_thumbnail( $story_id ) && - ! get_post_meta( $story_id, 'fictioneer_story_no_thumbnail', true ) - ) { + if ( in_array( $cover_position, ['float-left', 'float-right'] ) && $show_thumbnail ) { echo fictioneer_get_story_page_cover( $hook_args['story_data'], array( 'classes' => '_in-content _' . $cover_position ) @@ -116,7 +112,7 @@ get_header( // Footer arguments $footer_args = array( 'post_type' => 'fcn_story', - 'post_id' => $story_id, + 'post_id' => $post_id, 'breadcrumbs' => array( [fcntr( 'frontpage' ), get_home_url()] ) diff --git a/singular-story.php b/singular-story.php index 0f2ce5b3..c7ab0197 100644 --- a/singular-story.php +++ b/singular-story.php @@ -15,6 +15,7 @@ $story_id = get_post_meta( $post_id, 'fictioneer_template_story_id', true ); $story_id = fictioneer_validate_id( $story_id, 'fcn_story' ); $cover_position = get_theme_mod( 'story_cover_position', 'top-left-overflow' ); $render_story_header = get_post_meta( $post_id, 'fictioneer_template_show_story_header', true ); +$show_thumbnail = has_post_thumbnail( $story_id ) && ! get_post_meta( $story_id, 'fictioneer_story_no_thumbnail', true ); if ( ! $story_id ) { $render_story_header = false; @@ -23,7 +24,7 @@ if ( ! $story_id ) { // Wrapper classes $wrapper_classes = []; -if ( $render_story_header && $cover_position === 'top-left-overflow' ) { +if ( $render_story_header && $cover_position === 'top-left-overflow' && $show_thumbnail ) { $wrapper_classes[] = '_no-padding-top'; }