-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
single-fcn_story.php
141 lines (109 loc) · 4.09 KB
/
single-fcn_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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* Custom Post Type: Story
*
* Shows the details a single story.
*
* @package WordPress
* @subpackage Fictioneer
* @since 1.0
* @see partials/_story-header.php
* @see partials/_story-footer.php
*/
// Setup
$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' && $show_thumbnail ) {
$wrapper_classes[] = '_no-padding-top';
}
// Header
get_header(
null,
array(
'type' => 'fcn_story',
'no_index' => get_post_meta( $post_id, 'fictioneer_story_hidden', true ) ? 1 : 0
)
);
?>
<main id="main" class="main story <?php echo get_option( 'fictioneer_enable_checkmarks' ) ? '' : '_no-checkmarks'; ?>">
<?php do_action( 'fictioneer_main', 'story' ); ?>
<div class="main__wrapper <?php echo implode( ' ', $wrapper_classes ); ?>">
<?php
do_action( 'fictioneer_main_wrapper' );
// Setup
$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', $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' => $post_id,
'password_required' => $password_required
);
?>
<article id="post-<?php echo $post_id; ?>" class="story__article" data-id="<?php echo $post_id; ?>" data-age-rating="<?php echo strtolower( $story['rating'] ); ?>">
<?php
// Render article header
get_template_part( 'partials/_story-header', null, $hook_args );
// Hook after header
do_action( 'fictioneer_story_after_header', $hook_args );
?>
<section class="story__summary content-section"><?php
if ( $password_required ) {
if ( $password_note ) {
echo '<div class="story__password-note infobox">' . $password_note . '</div>';
}
if ( get_option( 'fictioneer_show_protected_excerpt' ) ) {
echo '<p class="story__forced-excerpt">' . fictioneer_get_forced_excerpt( $post_id, 512 ) . '</p>';
}
}
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 )
);
}
the_content();
?></section>
<?php
// Renders copyright notice, tags, actions, and chapters
do_action( 'fictioneer_story_after_content', $hook_args );
// Render footer partial
get_template_part( 'partials/_story-footer', null, $hook_args );
?>
</article>
<?php do_action( 'fictioneer_story_after_article', $hook_args ); ?>
</div>
<?php do_action( 'fictioneer_main_end', 'story' ); ?>
</main>
<?php
// Footer arguments
$footer_args = array(
'post_type' => 'fcn_story',
'post_id' => $post_id,
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)
);
// Add stories list breadcrumb (if set)
$stories_page_id = intval( get_option( 'fictioneer_stories_page', -1 ) ?: -1 );
if ( $stories_page_id > 0 ) {
$stories_page_title = trim( get_the_title( $stories_page_id ) );
$stories_page_title = empty( $stories_page_title ) ? __( 'Stories', 'fictioneer' ) : $stories_page_title;
$footer_args['breadcrumbs'][] = array(
$stories_page_title,
fictioneer_get_assigned_page_link( 'fictioneer_stories_page' )
);
}
// Add current breadcrumb
$footer_args['breadcrumbs'][] = $this_breadcrumb;
// Get footer with breadcrumbs
get_footer( null, $footer_args );
?>