-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle-publication.php
More file actions
executable file
·142 lines (141 loc) · 4.1 KB
/
single-publication.php
File metadata and controls
executable file
·142 lines (141 loc) · 4.1 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
<?php
$post_id = get_the_ID();
$content = get_field( 'publication-content', $post_id );
$publication_date = get_field( 'publication-date', $post_id );
$primary_cat = strl_get_primary_category( $post_id, 'publication_category' );
$downloads = get_field( 'publication-downloads', $post_id );
$header_content = array(
'title' => ! empty( get_the_title( $post_id ) ) ? get_the_title( $post_id ) : '',
'intro' => ! empty( get_field( 'publication-intro', $post_id ) ) ? get_field( 'publication-intro', $post_id ) : '',
'featured-image' => ! empty( get_field( 'settings-group_post-featured-image', $post_id ) ) ? get_field( 'settings-group_post-featured-image', $post_id ) : '',
);
$header_content = array_filter( $header_content, fn ( $value) => ! empty( $value ) );
$contact_person = ! empty( get_field( 'publication-contact-person', $post_id )[0] ) ? get_field( 'publication-contact-person', $post_id )[0] : '';
get_header();
if ( post_password_required() ) {
?>
<div class="grid-container">
<div class="grid-x grid-margin-x">
<div class="cell medium-8">
<?php echo get_the_password_form( $post->ID ); ?>
</div>
</div>
</div>
<?php
} else {
if ( ! empty( $header_content ) ) {
get_template_part(
'blocks/header-image/header-image',
null,
$header_content
);
}
?>
<section class="single-publication-content">
<div class="grid-container">
<div class="grid-x grid-margin-x">
<div class="cell large-8">
<div class="publication-meta">
<div class="categories-wrapper">
<?php
if ( ! empty( $primary_cat ) ) {
$cat_name = ! empty( $primary_cat->name ) ? $primary_cat->name : '';
if ( ! empty( $cat_name ) ) {
?>
<span class="category bg-tertiary">
<?php echo $cat_name; ?>
</span>
<?php
}
}
?>
</div>
<?php
if ( ! empty( $publication_date ) ) {
?>
<span class="date">
<?php
echo sprintf(
// translators: %s is the publication date
__( 'Published on: %s', 'strl-frontend' ),
wp_date( 'd-m-Y', strtotime( $publication_date ) )
);
?>
</span>
<?php
}
?>
</div>
</div>
</div>
</div>
<?php
if ( ! empty( $content ) ) {
?>
<div class="grid-container single-content-container">
<div class="grid-x grid-margin-x grid-margin-y">
<div class="cell small-12 large-8">
<div class="text">
<?php echo apply_filters( 'the_content', $content ); ?>
</div>
</div>
<?php
if ( ! empty( $contact_person ) ) {
?>
<div class="cell small-12 large-4">
<?php
get_template_part(
'blocks/_global/contact-card',
null,
array(
'post_id' => $contact_person,
),
);
?>
</div>
<?php
}
?>
</div>
</div>
<?php
}
if ( ! empty( $downloads ) ) {
?>
<div class="grid-container single-downloads-container">
<div class="grid-x grid-margin-x">
<div class="cell">
<h2><?php _e( 'Downloads', 'strl' ); ?></h2>
</div>
<div class="cell">
<div class="downloads-wrapper">
<?php
foreach ( $downloads as $download ) {
$label = ! empty( $download['label'] ) ? $download['label'] : __( 'Download document', 'strl' );
$download_url = ! empty( $download['download']['url'] ) ? $download['download']['url'] : '';
$file_name = ! empty( $download['download']['filename'] ) ? $download['download']['filename'] : '';
?>
<a class="btn primary" href="<?php echo $download_url; ?>" download>
<?php echo $label; ?>
<i aria-hidden="true" class="fa-solid fa-arrow-down-to-line"></i>
<span class="screen-reader-text">
<?php
// translators: %s is the filename of the download
echo printf( __( 'Download file: %s', 'strl' ), $file_name );
?>
</span>
</a>
<?php
}
?>
</div>
</div>
</div>
</div>
<?php
}
?>
</section>
<?php
}
get_footer();