forked from Tetrakern/fictioneer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsingle-fcn_recommendation.php
110 lines (79 loc) · 2.82 KB
/
single-fcn_recommendation.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
/**
* Custom Post Type: Recommendation
*
* Shows a single recommendation.
*
* @package WordPress
* @subpackage Fictioneer
* @since 4.0.0
* @see partials/_recommendation-header.php
*/
// Setup
$password_required = post_password_required();
// Header
get_header( null, array( 'type' => 'fcn_recommendation' ) );
?>
<main id="main" class="main recommendation">
<?php do_action( 'fictioneer_main', 'recommendation' ); ?>
<div class="main__wrapper">
<?php do_action( 'fictioneer_main_wrapper' ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
// Setup
$title = fictioneer_get_safe_title( $post->ID, 'single-recommendation' );
$this_breadcrumb = [ $title, get_the_permalink() ];
// Arguments for hooks and templates/etc.
$hook_args = array(
'recommendation' => $post,
'recommendation_id' => $post->ID,
'title' => $title
);
?>
<article id="recommendation-<?php the_ID(); ?>" class="recommendation__article">
<?php
// Render article header
get_template_part( 'partials/_recommendation-header', null, $hook_args );
// Hook after header
if ( ! $password_required ) {
do_action( 'fictioneer_recommendation_after_header', $hook_args );
}
// Thumbnail
if ( has_post_thumbnail() && ! $password_required ) {
echo fictioneer_get_recommendation_page_cover( $post );
}
?>
<section class="recommendation__content content-section"><?php the_content(); ?></section>
<?php if ( ! $password_required ) : ?>
<?php do_action( 'fictioneer_recommendation_after_content', $hook_args ); ?>
<footer class="recommendation__footer"><?php do_action( 'fictioneer_recommendation_footer', $hook_args ); ?></footer>
<?php endif; ?>
</article>
<?php endwhile; ?>
</div>
<?php do_action( 'fictioneer_main_end', 'recommendation' ); ?>
</main>
<?php
// Footer arguments
$footer_args = array(
'post_type' => 'fcn_recommendation',
'post_id' => get_the_ID(),
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)
);
// Add recommendations list breadcrumb (if set)
$rec_page_id = intval( get_option( 'fictioneer_recommendations_page', -1 ) ?: -1 );
if ( $rec_page_id > 0 ) {
$rec_page_title = trim( get_the_title( $rec_page_id ) );
$rec_page_title = empty( $rec_page_title ) ? __( 'Recommendations', 'fictioneer' ) : $rec_page_title;
$footer_args['breadcrumbs'][] = array(
$rec_page_title,
fictioneer_get_assigned_page_link( 'fictioneer_recommendations_page' )
);
}
// Add current breadcrumb
$footer_args['breadcrumbs'][] = $this_breadcrumb;
// Get footer with breadcrumbs
get_footer( null, $footer_args );
?>