-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
singular-story.php
110 lines (84 loc) · 2.8 KB
/
singular-story.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* Template Name: Story Page
*
* @package WordPress
* @subpackage Fictioneer
* @since 5.14.0
* @see comments.php
*/
// Setup
$post_id = get_the_ID();
$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;
}
// Wrapper classes
$wrapper_classes = [];
if ( $render_story_header && $cover_position === 'top-left-overflow' && $show_thumbnail ) {
$wrapper_classes[] = '_no-padding-top';
}
// Header
get_header(
null,
array(
'no_index' => get_post_meta( $story_id, 'fictioneer_story_hidden', true ) ? 1 : 0
)
);
?>
<main id="main" class="main singular">
<?php do_action( 'fictioneer_main', 'singular-story' ); ?>
<div class="main__wrapper <?php echo implode( ' ', $wrapper_classes ); ?>">
<?php do_action( 'fictioneer_main_wrapper' ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
// Setup
$title = fictioneer_get_safe_title( $post_id, 'singular-story' );
$this_breadcrumb = [ $title, get_the_permalink() ];
?>
<article id="singular-<?php echo $post_id; ?>" class="singular__article">
<?php
// Render story header
if ( $render_story_header ) {
get_template_part(
'partials/_story-header',
null,
array(
'story_data' => fictioneer_get_story_data( $story_id ),
'story_id' => $story_id,
'context' => 'shortcode'
)
);
}
?>
<section class="singular__content content-section"><?php the_content(); ?></section>
<footer class="singular__footer"><?php do_action( 'fictioneer_singular_footer' ); ?></footer>
</article>
<?php do_action( 'fictioneer_before_comments' ); ?>
<?php if ( comments_open() && ! post_password_required() ) : ?>
<section class="singular__comments comment-section">
<?php comments_template(); ?>
</section>
<?php endif; ?>
<?php endwhile; ?>
</div>
<?php do_action( 'fictioneer_main_end', 'singular-story' ); ?>
</main>
<?php
// Footer arguments
$footer_args = array(
'post_type' => 'page',
'post_id' => $post_id,
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)
);
// Add current breadcrumb
$footer_args['breadcrumbs'][] = $this_breadcrumb;
// Get footer with breadcrumbs
get_footer( null, $footer_args );
?>