-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase-projects.php
More file actions
201 lines (137 loc) · 4.31 KB
/
base-projects.php
File metadata and controls
201 lines (137 loc) · 4.31 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!doctype html>
<html class="no-js" <?php language_attributes(); ?>>
<?php
global $DAMN;
/**
* Single Post
* Use the DAMN Constructor
*/
$DAMN = new DAMN ();
$Wustache = new Cloudoki\Wustache\Template ();
$post = get_post ();
# Issue numbers
$latest_number = (int) !$DAMN->latest?
get_field ('magazine_number', 'magazine_' . $DAMN->latest_issue->term_id):
$DAMN->issue->number;
$template_path = 'projects/';
# Template required data
$next_issue = null;
if( !$DAMN->latest && $DAMN->issue ){
$next_issue = $DAMN->issue->number +1;
}
$prev_issue = null;
if( $DAMN->issue && $DAMN->issue->number > $latest_number-10 ){
$prev_issue = $DAMN->issue->number -1;
}
$parameters = (object)[
'background-color' => get_field ('background_color'),
'header-color' => get_field ('header_color'),
'issue' => $DAMN->issue,
'issued' => $DAMN->issued,
'next_issue' => $next_issue,
'prev_issue' => $prev_issue,
'history' => range ($latest_number, $latest_number-10),
'theme_path' => get_template_directory_uri(),
'template' => $template_path . (get_post_meta ($post->ID, '_template_slug', true)?: '.default'),
'contrast' => get_post_meta ($post->ID, '_template_contrast', true) != 'dark',
'navigation' => wp_nav_menu (
[
'theme_location' => 'primary_navigation',
'depth' => 1,
'echo' => false
])
];
# Date
if ( get_field('start_date') ) {
$parameters->date = get_field('start_date');
}
if( get_field('start_date') && get_field('end_date') ){
$parameters->date = "From ". get_field('start_date') ." until " . get_field('end_date');
}
# Ad
if ( $DAMN->issue && !$DAMN->issue->brand && function_exists ('adrotate_group'))
$parameters->advert = adrotate_group (3);
# External Links
$parameters->external_links = [];
if(get_field ('external_links'))
while( has_sub_field('external_links'))
$parameters->external_links[] = ['url'=> get_sub_field ('url')];
# The Post
$parameters->post = $post;
# Tags
$parameters->tags = get_the_tags ();
# Categories
$parameters->categories = get_the_category ($post->ID);
# Video
$parameters->has_video = has_post_video ($post->ID);
if ($parameters->has_video)
$parameters->video = get_the_post_video($post->ID, '100%');
$title_arr = explode( ' ' , get_the_title() );
# Custom Title
$custom_title = $title_arr[0] . ' ';
for ($i=0; $i < count( $title_arr ) ; $i++) {
if ( $i >= 1 ){
$custom_title .= '<span class="project-title-span">' . $title_arr[$i] . '</span> ';
}
}
$parameters->custom_title = trim($custom_title);
$parameters->text_area = get_field( 'text_area' );
$parameters->sponsor_name = get_field( 'sponsor_name' );
$parameters->sponsor_information = get_field( 'sponsor_information' );
$tag_name = get_field( 'project_tag', 'option' );
$tag = get_term_by('name', $tag_name, 'post_tag');
# Get Posts
$args = array( 'post_type' => 'post', 'tag__in' => $tag ? array( $tag->term_id ) : null );
$query = new WP_Query( $args );
if( $query->found_posts > 5 ){
$parameters->load_more = true;
} else {
$parameters->load_more = false;
}
if( $query->have_posts() ){
$x = 1;
while ( $query->have_posts() ) {
if( $x >= 6 ){
break;
}
$query->the_post();
global $post;
if( $x % 2 == 0 ){
$post->even = true;
$post->float = 'left';
} else {
$post->even = false;
$post->float = 'right';
}
$post->permalink = get_permalink();
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), 'large' );
$url = $thumb['0'];
$post->thumb_url = $url;
$post->place = get_field( 'city_country' );
$post->designers = get_field( 'designers' );
$parameters->rel_posts[] = $post;
$x++;
}
} wp_reset_postdata(); wp_reset_query();
# Load Head
get_template_part('templates/head');
?>
<body class="single-events single-projects" <?php body_class ($parameters->contrast? 'positive-contrast templated': 'templated'); ?>>
<div id="search-bar" class="collapse event-search-bar">
<div class="container">
<?php get_template_part('templates/search-form'); ?>
</div>
</div>
<?php
# Hold off DAMN+
/**
* Code is Poetry.
*/
do_action ('the_template', $parameters); // Handled comfortably by Wustache.
do_action('get_footer');
get_template_part('templates/footer');
wp_footer();
?>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-565b1d483536298e" async="async"></script>
</body>
</html>