-
Notifications
You must be signed in to change notification settings - Fork 3
/
page-main.php
238 lines (220 loc) · 7.13 KB
/
page-main.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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/*
* Template name: Strona główna
*/
?>
<?php get_header() ?>
<?php $src = get_template_directory_uri(); ?>
<?php if (have_posts()): ?>
<?php while (have_posts()): the_post(); ?>
<?php
$img = get_field('main_photo');
?>
<div class="row mt20">
<div class="small-12 columns">
<div class="main-photo" style="background-image:url(<?php echo $img['sizes']['w100']; ?>);">
<div class="cont">
<div class="text">
<?php the_field('photo_text'); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row mt60">
<div class="small-12 columns">
<h3 class="subtitle"><span><?php _e('Projects'); ?></span></h3>
</div>
</div>
<div class="row small-up-2 large-up-6 project-list mt40">
<?php
$projects = get_field('projects');
$i = 0;
$notin = [];
if ($projects):
foreach ($projects as $post):
setup_postdata($post);
?>
<?php get_template_part('project-on-list-main'); ?>
<?php
$i++;
$notin[] = get_the_ID();
endforeach;
?>
<?php endif; ?>
<?php
$to_rand = 5 - $i;
if ($to_rand > 0):
$args = array(
'post_type' => 'projects',
'posts_per_page' => $to_rand,
'post__not_in' => $notin,
'tax_query' => array(
array(
'taxonomy' => 'filters',
'field' => 'id',
'terms' => icl_object_id(42, 'filters'),
),
),
);
$query = new WP_Query($args);
?>
<?php if ($query->have_posts()): ?>
<?php while ($query->have_posts()): $query->the_post(); ?>
<?php get_template_part('project-on-list-main'); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php endif; ?>
<div class="column project-box">
<a href="https://forum.kodujdlapolski.pl/c/pomysly" class="add-project">
<img src="<?php echo $src; ?>/images/add-project-icon.png" class="icon" alt="<?php _e('Share a challenge to solve!'); ?>" />
<span><?php _e('Share a challenge to solve!'); ?></span>
</a>
</div>
</div>
<div class="row">
<div class="small-12 columns text-center">
<a href="<?php echo get_permalink(icl_object_id(11, 'page')); ?>" class="btn red"><?php _e('Show all projects'); ?></a>
</div>
</div>
<div class="row mt50">
<div class="small-12 columns">
<h3 class="subtitle"><span><?php _e('Blog'); ?></span></h3>
</div>
</div>
<div class="row post-list mt40">
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
);
$query = new WP_Query($args);
?>
<?php if ($query->have_posts()): ?>
<?php while ($query->have_posts()): $query->the_post(); ?>
<?php get_template_part('post-on-list'); ?>
<?php endwhile; ?>
<?php endif; ?>
<div class="small-12 columns text-center">
<a href="<?php echo get_permalink(icl_object_id(17, 'page')); ?>" class="btn red"><?php _e('Read all posts'); ?></a>
</div>
</div>
<div class="row mt50">
<div class="small-12 columns">
<h3 class="subtitle"><span><?php _e('Koduj dla Polski'); ?></span></h3>
</div>
</div>
<div class="row mt40 stats-list text-center large-text-left show-for-large">
<div class="small-12 medium-6 large-3 columns overflow pt15">
<a href="https://forum.kodujdlapolski.pl/" class="dblock" target="_blank">
<?php
if (false === ($users = get_transient('forum-users'))) {
$json = file_get_contents('https://forum.kodujdlapolski.pl/about.json');
$obj = json_decode($json);
$users = $obj->about->stats->user_count;
set_transient('forum-users', $users, 12 * 3600);
}
?>
<div class="icon">
<img src="<?php echo $src; ?>/images/stats-forum.png" />
</div>
<div class="info">
<div class="number"><?php echo $users; ?></div>
<div class="txt"><?php _e('users on the forum'); ?></div>
</div>
</a>
</div>
<div class="small-12 medium-6 large-3 columns overflow pt15">
<a href="https://forum.kodujdlapolski.pl/c/pomysly" class="dblock" rel="noopener" target="_blank">
<?php
if (false === ($ideas = get_transient('ideas'))) {
$ideas = 0;
for ($i = 0; $i < 50; $i++) {
$json = file_get_contents('https://forum.kodujdlapolski.pl/c/pomysly.json?page=' . $i);
$obj = json_decode($json);
$cur_page = count($obj->topic_list->topics);
if ($cur_page == 0) {
break;
}
$ideas += $cur_page;
}
set_transient('ideas', $ideas, 12 * 3600);
}
?>
<div class="icon">
<img src="<?php echo $src; ?>/images/stats-ideas.png" />
</div>
<div class="info">
<div class="number"><?php echo $ideas; ?></div>
<div class="txt"><?php _e('ideas'); ?></div>
</div>
</a>
</div>
<div class="small-12 medium-6 large-3 columns overflow pt15">
<a href="<?php echo get_permalink(icl_object_id(9, 'page')); ?>" class="dblock">
<?php
if (false === ($cities = get_transient('cities'))) {
$args = '';
$args = array(
'post_type' => 'cities',
'posts_per_page' => -1,
'fields' => 'ids'
);
$query = new WP_Query($args);
$cities = $query->post_count;
set_transient('cities', $cities, 12 * 3600);
}
?>
<div class="icon">
<img src="<?php echo $src; ?>/images/stats-citylab.png" />
</div>
<div class="info">
<div class="number"><?php echo $cities ?></div>
<div class="txt"><?php _e('local groups'); ?></div>
</div>
</a>
</div>
<?php wp_reset_query(); ?>
<div class="small-12 medium-6 large-3 columns overflow pt15">
<a href="<?php echo get_permalink(icl_object_id(11, 'page')); ?>" class="dblock">
<?php
if (false === ($projects = get_transient('projects'))) {
$args = '';
$args = array(
'post_type' => 'projects',
'posts_per_page' => -1,
'fields' => 'ids'
);
$query = new WP_Query($args);
$projects = $query->post_count;
set_transient('projects', $projects, 12 * 3600);
}
?>
<div class="icon">
<img src="<?php echo $src; ?>/images/stats-projects.png" />
</div>
<div class="info">
<div class="number"><?php echo $projects; ?></div>
<div class="txt"><?php _e('projects'); ?></div>
</div>
</a>
<?php wp_reset_query(); ?>
</div>
</div>
<div class="row boxes mt70" id="dzialaj">
<?php foreach (get_field('boxes') as $box): ?>
<div class="small-12 large-4 columns small-pb20 large-pb0">
<div class="content">
<div class="photo">
<a href="<?php echo $box['cta_url']; ?>"><img src="<?php echo $box['photo']['sizes']['large']; ?>" /></a>
</div>
<h3><a href="<?php echo $box['cta_url']; ?>"><?php echo $box['title']; ?></a></h3>
<div class="txt"><?php echo $box['text']; ?></div>
<a href="<?php echo $box['cta_url']; ?>" class="btn red"><?php echo $box['cta_text']; ?></a>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer() ?>