forked from DiscipleTools/disciple-tools-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle-template.php
More file actions
185 lines (167 loc) · 9.21 KB
/
single-template.php
File metadata and controls
185 lines (167 loc) · 9.21 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
declare( strict_types=1 );
$dt_post_type = get_post_type();
if ( ! current_user_can( 'access_' . $dt_post_type ) ) {
wp_safe_redirect( '/settings' );
}
( function () {
$post_type = get_post_type();
$post_id = get_the_ID();
if ( !DT_Posts::can_view( $post_type, $post_id )){
get_template_part( "403" );
die();
}
get_header();
dt_print_details_bar(
true,
false,
false,
false,
false,
true,
[]
);
$post_settings = apply_filters( "dt_get_post_type_settings", [], $post_type );
$dt_post = DT_Posts::get_post( $post_type, $post_id );
?>
<div id="content" class="single-template">
<div id="inner-content" class="grid-x grid-margin-x grid-margin-y">
<main id="main" class="xlarge-7 large-7 medium-12 small-12 cell" role="main" style="padding:0">
<div class="cell grid-y grid-margin-y" style="display: block">
<!-- @todo notification section-->
<!--
Main details section
-->
<div id="contact-details" class="small-12 cell grid-margin-y">
<section class="cell bordered-box">
<!--
Name row
-->
<div id="name-row" style="display: flex;">
<div class="item-details-header" style="flex-grow:1; text-align: center">
<span id="title" contenteditable="true" class="title dt_contenteditable"><?php the_title_attribute(); ?></span>
</div>
</div>
<!--
Status Bar
-->
<div class="grid-x grid-margin-x" style="margin-top: 20px">
<?php do_action( 'dt_post_status_bar' ); ?>
</div>
<!--
Details section
-->
<div id="details-section" class="display-fields" style="">
<?php
// let the plugin add section content
do_action( "dt_details_additional_section", 'details', $post_type );
?>
<div class="section-body">
<?php
//setup the order of the tile fields
$order = $custom_tiles[$post_type]['details']["order"] ?? [];
foreach ( $post_settings["fields"] as $key => $option ){
if ( isset( $option["tile"] ) && $option["tile"] === 'details' ){
if ( !in_array( $key, $order )){
$order[] = $key;
}
}
}
foreach ( $order as $field_key ) {
if ( !isset( $post_settings["fields"][$field_key] ) ){
continue;
}
$field = $post_settings["fields"][$field_key];
if ( isset( $field["tile"] ) && $field["tile"] === 'details'){
render_field_for_display( $field_key, $post_settings["fields"], $dt_post );
}
}
?>
</div>
</div>
</section>
</div>
<!--
Tiles Section
-->
<div class="cell small-12">
<div class="grid-x grid-margin-x grid-margin-y grid">
<?php
//get sections added by plugins
$sections = apply_filters( 'dt_details_additional_section_ids', [], $post_type );
//get custom sections
$custom_tiles = dt_get_option( "dt_custom_tiles" );
foreach ( $custom_tiles[$post_type] ?? [] as $tile_key => $tile_options ){
if ( !in_array( $tile_key, $sections ) ){
$sections[] = $tile_key;
}
//remove section if hidden
if ( isset( $tile_options["hidden"] ) && $tile_options["hidden"] == true ){
$index = array_search( $tile_key, $sections );
if ( $index !== false) {
unset( $sections[ $index ] );
}
}
}
foreach ( $sections as $section ){
?>
<section id="<?php echo esc_html( $section ) ?>" class="xlarge-6 large-12 medium-6 cell grid-item">
<div class="bordered-box">
<?php
//setup tile label if see by customizations
if ( isset( $custom_tiles[$post_type][$section]["label"] ) ){ ?>
<h3 class="section-header">
<?php echo esc_html( $custom_tiles[$post_type][$section]["label"] )?>
<button class="section-chevron chevron_down">
<img src="<?php echo esc_html( get_template_directory_uri() . '/dt-assets/images/chevron_down.svg' ) ?>"/>
</button>
<button class="section-chevron chevron_up">
<img src="<?php echo esc_html( get_template_directory_uri() . '/dt-assets/images/chevron_up.svg' ) ?>"/>
</button>
</h3>
<?php }
// let the plugin add section content
do_action( "dt_details_additional_section", $section, $post_type );
?>
<div class="section-body">
<?php
//setup the order of the tile fields
$order = $custom_tiles[$post_type][$section]["order"] ?? [];
foreach ( $post_settings["fields"] as $key => $option ){
if ( isset( $option["tile"] ) && $option["tile"] === $section ){
if ( !in_array( $key, $order )){
$order[] = $key;
}
}
}
foreach ( $order as $field_key ) {
if ( !isset( $post_settings["fields"][$field_key] ) ){
continue;
}
$field = $post_settings["fields"][$field_key];
if ( isset( $field["tile"] ) && $field["tile"] === $section){
render_field_for_display( $field_key, $post_settings["fields"], $dt_post );
}
}
?>
</div>
</div>
</section>
<?php
}
?>
</div>
</div>
</div>
</main>
<aside class="auto cell grid-x">
<section class="comment-activity-section cell"
id="comment-activity-section">
<?php get_template_part( 'dt-assets/parts/loop', 'activity-comment' ); ?>
</section>
</aside>
</div>
</div>
<?php get_template_part( 'dt-assets/parts/modals/modal', 'share' ); ?>
<?php get_footer();
} )();