-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharchive.php
432 lines (393 loc) · 21 KB
/
archive.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
<?php get_header();
$site_url = get_site_url();
$current_url = home_url( add_query_arg( array( $_GET ), $wp->request ) );
if ( !empty( $_GET['opensource'] ) ){
$glitch_link = '<li><a class="btn" href="https://glitch.com/@botwiki">Botwiki on Glitch 🎏</a></li>';
$filter_opensource = '&opensource=true';
$narrow_opensource_link = '';
} else {
$glitch_link = '';
$filter_opensource = '';
$narrow_opensource_url = $site_url . '/bot/?' .
( !empty( $_GET['tags'] ) ? 'tags=' . $_GET['tags'] : '' ) .
( !empty( $_GET['networks'] ) ? 'networks=' . $_GET['networks'] : '' ) .
( !empty( $_GET['languages'] ) ? 'languages=' . $_GET['languages'] : '' ) .
'&opensource=true';
global $wp;
$narrow_opensource_url = $current_url . ( strpos( $current_url, '?' ) === false ? '?' : '&' ) . 'opensource=true';
$narrow_opensource_link = '<li><a class="btn" href="' . $narrow_opensource_url . '">Open source bots</a></li>';
}
$network_related_links = '';
if ( !empty( $_GET['networks'] ) ){
if ( $_GET['networks'] === 'twitter-bots' ){
$network_related_links .= '<li><a class="btn" href="/bots/twitterbots/">Learn more</a></li>';
$network_related_links .= '<li><a class="btn" href="/resources/twitterbots/">Tutorials and resources</a></li>';
} elseif ( $_GET['networks'] === 'mastodon' || $_GET['networks'] === 'fediverse' ){
$network_related_links .= '<li><a class="btn" href="/bots/fediverse-bots/">Learn more</a></li>';
$network_related_links .= '<li><a class="btn" href="/resources/fediverse-bots/">Tutorials and resources</a></li>';
}
}
if( is_author() ){
$author_id = get_query_var( 'author' );
$profile_img_url = esc_attr( get_the_author_meta( 'profile-img-url', $user->ID ) );
if ( empty( $profile_img_url ) ){
$profile_img_url = get_avatar_url( $author_id, array( 'size' => 360, 'scheme' => 'https' ) );
}
$background_img_url = esc_attr( get_the_author_meta( 'background-img-url', $author_id ) );
$background_img_dominant_color = esc_attr( get_the_author_meta( 'background-img-dominant-color', $author_id ) );
if ( empty( $background_img_url ) ){
$background_img_url = esc_attr( get_the_author_meta( 'background-img-url', 2 ) );
$background_img_dominant_color = esc_attr( get_the_author_meta( 'background-img-dominant-color', 2 ) );
}
$background_img_dominant_color_css = str_replace( '[', 'background-color:rgb( ', $background_img_dominant_color );
$background_img_dominant_color_css = str_replace( ']', ' )', $background_img_dominant_color_css );
if ( !empty( $background_img_url ) ){ ?>
<div class="thumbnail-wrapper" style="<?php echo $background_img_dominant_color_css; ?>">
<img src="<?php echo $background_img_url; ?>">
</div>
<?php }
if ( user_can( $author_id, 'administrator' ) ){
$botwiki_team_role = get_the_author_meta( 'botwiki-team-role', $author_id );
if ( empty( $botwiki_team_role ) ){
$botwiki_team_role = "Botwiki team member.";
}
}
else{
$botwiki_team_role = "Botwiki contributor.";
}
$botwiki_profile_page_url = get_site_url() . '/author/' . $username;
include( locate_template( 'author-card.php', false, false ) );
} ?>
<main role="main" class="container-fluid m-0 p-0">
<div class="container">
<?php
if( is_author() ){
$nickname = get_the_author_meta( 'nickname', $author_id );
$username = get_the_author_meta( 'user_nicename', $author_id );
$post_type = $wp_query->query['post_type'];
?>
<h1 class="post-title">Browsing <?php
echo ( !empty( $_GET['opensource'] ) ? 'open source' : '' );
?> <?php echo $post_type; ?>s by <a href="/author/<?php echo $username ?>"><?php echo $nickname ?></a><?php
if ( !empty( $_GET['tags'] ) ){ ?>
tagged <a href="<?php echo $site_url . '/tag/' . $_GET['tags'] ;?>">#<?php echo $_GET['tags']; ?></a><?php } ?> ...</h1>
<div class="post-content">
<?php } elseif ( is_tax() ){
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
if ( get_query_var( 'taxonomy' ) === 'programing_language' ) {
if ( !empty( $_GET['opensource'] ) ){
$page_title = "Open-source bots made with " . $term->name;
} else {
$page_title = "Bots made with " . $term->name;
}
} else {
$page_title = "Posts tagged #" . $term->name;
}
?>
<h1 class="post-title"><?php echo $page_title; ?></h1>
<div class="post-content">
<?php
if ( !empty( $term->description ) ){
echo wpautop( $term->description );
}
if ( get_query_var( 'taxonomy' ) === 'programing_language' ) {
$page_title = "Bots made with " . $term->name;
?>
<ul class="btn-list">
<?php
if ( !empty( $_GET['opensource'] ) ){ ?>
<li><a class="btn" href="<?php echo get_term_link( $term ); ?>">Browse all <?php echo $term->name; ?> bots</a></li>
<li><a class="btn" href="/bots/open-source/">Browse all open-source bots</a></li>
<?php } else { ?>
<li><a class="btn" href="<?php echo get_term_link( $term ); ?>?opensource=true">Browse open-source <?php echo $term->name; ?> bots</a></li>
<?php }
}
}
elseif ( $wp_query->query['post_type'] == 'bot' ) {
if ( $_GET['networks'] || $_GET['languages'] || $_GET['tags'] ){
function network_links( $network ){
return "<a href='" . get_site_url() . "/bot/?networks=$network'>#$network</a> ";
}
if ( !empty( $_GET['networks'] ) ){
$networks = implode( ' ', array_map( 'network_links', explode( ',', $_GET['networks'] ) ) );
}
function language_links( $language ){
return "<a href='" . get_site_url() . "/bot/?languages=$language'>#$language</a> ";
}
if ( !empty( $_GET['languages'] ) ){
$languages = implode( ' ', array_map( 'language_links', explode( ',', $_GET['languages'] ) ) );
}
function tag_links( $tag ){
return "<a href='" . get_site_url() . "/bot/?tags=$tag'>#$tag</a> ";
}
if ( !empty( $_GET['tags'] ) ){
$tag_links = implode( ' ', array_map( 'tag_links', explode( ',', $_GET['tags'] ) ) );
}
?>
<h1 class="post-title">Browsing <?php
echo ( !empty( $_GET['opensource'] ) ? 'open source' : '' );
?> bots tagged <?php echo $networks ; echo $languages ; echo rtrim( $tag_links ); ?> ...</h1>
<div class="post-content">
<?php } else {?>
<h1 class="post-title"><?php
if ( !empty( $_GET['opensource'] ) ){ ?>
Browsing <?php
$os_bots = new WP_Query( array(
'post_type' => 'bot',
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_key' => 'bot_source_url',
'meta_value' => array(''),
'meta_compare' => 'NOT IN',
) );
echo number_format( count( $os_bots->posts ) ); ?> open source bots...
<?php } else { ?>
Browsing <?php echo number_format( wp_count_posts( 'bot' )->publish ); ?> bots...
<?php }?></h1>
<div class="post-content">
<ul class="btn-list">
<?php
if ( !empty( $_GET['opensource'] ) ){ ?>
<li><a class="btn" href="/bots/open-source/#browse-bots-by-category">Browse by category</a></li>
<li><a class="btn" href="/bots/open-source/#browse-bots-by-network">Browse by network</a></li>
<!-- <li><a class="btn" href="/random-bot?opensource=true">Random bot</a></li> -->
<li><a class="btn" href="/bots/#bots">What is a bot?</a></li>
<?php } else {?>
<li><a class="btn" href="/bots/#browse-bots-by-category">Browse by category</a></li>
<li><a class="btn" href="/bots/#browse-bots-by-network">Browse by network</a></li>
<li><a class="btn" href="/random-bot">Random bot</a></li>
<li><a class="btn" href="/bots/#bots">What is a bot?</a></li>
<?php
// echo $glitch_link;
// echo $narrow_opensource_link;
// $glitch_link = '';
// $narrow_opensource_link = '';
?>
<?php } ?>
</ul>
<?php } ?>
<?php }
else{ ?>
<h1 class="post-title">Archives</h1>
<div class="post-content">
<?php }
if ( !empty( $_GET['tags'] ) ){
$tags = explode( ',', $_GET['tags'] );
if ( in_array( 'opensource', $tags ) ) { ?>
<ul class="btn-list">
<li><a class="btn" href="/bot/?opensource=true">Browse open-source bots</a></li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
<?php } elseif ( in_array( 'cheapbotsdonequick', $tags ) ) { ?>
<div class="card pt-5 mt-5 mb-2">
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-4 text-center p-l">
<img src="/wp-content/uploads/2018/08/cheap-bots-done-quick.png" class="lazy-load mb-5 wp-post-image" alt="" data-src="" title="Cheap Bots, Done Quick" srcset="/wp-content/uploads/2018/08/cheap-bots-done-quick.png 1920w, /wp-content/uploads/2018/08/cheap-bots-done-quick-250x110.png 250w, /wp-content/uploads/2018/08/cheap-bots-done-quick-768x339.png 768w, /wp-content/uploads/2018/08/cheap-bots-done-quick-700x309.png 700w, /wp-content/uploads/2018/08/cheap-bots-done-quick-120x53.png 120w" />
</div>
<div class="col-sm-12 col-md-8">
<h2>Cheap Bots, Done Quick!</h2>
<?php
$cbdq_description = apply_filters( 'the_content', get_post_field( 'post_content', 8220 ) );
echo substr_replace( $cbdq_description, '', strpos( $cbdq_description, '<ul' ), strpos( $cbdq_description, '/ul>' ) -strpos( $cbdq_description, '<ul' ) + 4);
?>
<ul class="btn-list">
<li>
<a class="btn" href="https://cheapbotsdonequick.com/">Visit</a>
</li>
<li>
<a class="btn" href="/projects/botwiki-interviews/v-buckenham/">Interview</a>
</li>
<li>
<a class="btn" href="https://www.patreon.com/v21/">Support</a>
</li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
</div>
</div>
</div>
</div>
<?php } elseif ( in_array( 'cheapbotstootsweet', $tags ) ) { ?>
<div class="card pt-5 mt-5 mb-2">
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-4 text-center p-l">
<img src="/wp-content/uploads/2022/11/cheapbotstootsweet.png" class="lazy-load mb-5 wp-post-image" alt="" data-src="" title="Cheap Bots, Done Quick" srcset="/wp-content/uploads/2022/11/cheapbotstootsweet.png 1920w, /wp-content/uploads/2022/11/cheapbotstootsweet-250x110.png 250w, /wp-content/uploads/2022/11/cheapbotstootsweet-768x339.png 768w, /wp-content/uploads/2022/11/cheapbotstootsweet-700x309.png 700w, /wp-content/uploads/2022/11/cheapbotstootsweet-120x53.png 120w" />
</div>
<div class="col-sm-12 col-md-8">
<h2>Cheap Bots, Toot Sweet!</h2>
<p><a href="http://cheapbotstootsweet.com/">Cheap Bots, Toot Sweet!</a> is a free website created by <a href="https://twitter.com/BooDooPerson">BooDoo</a> that lets you make Mastodon bots using <a href="http://tracery.io/">Tracery</a>, a text-generating language created by <a href="https://twitter.com/galaxykate">Dr. Kate Compton</a>.</p>
<?php
// $cbdq_description = apply_filters( 'the_content', get_post_field( 'post_content', 8220 ) );
// echo substr_replace( $cbdq_description, '', strpos( $cbdq_description, '<ul' ), strpos( $cbdq_description, '/ul>' ) -strpos( $cbdq_description, '<ul' ) + 4);
?>
<ul class="btn-list">
<li>
<a class="btn" href="https://cheapbotstootsweet.com/">Visit</a>
</li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
</div>
</div>
</div>
</div>
<?php } elseif ( in_array( 'botsin.space', $tags ) || in_array( 'botsin-space', $tags ) ) { ?>
<div class="card pt-5 mt-5 mb-2">
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-4 text-center p-l">
<img src="/wp-content/uploads/2018/08/cheap-bots-done-quick.png" class="lazy-load mb-5 wp-post-image" alt="" data-src="" title="Cheap Bots, Done Quick" srcset="/wp-content/uploads/2018/09/botsin-space-bots-glitch.png 603w, /wp-content/uploads/2018/09/botsin-space-bots-glitch-250x114.png 250w, /wp-content/uploads/2018/09/botsin-space-bots-glitch-120x55.png 120w" />
</div>
<div class="col-sm-12 col-md-8">
<h2>botsin.space</h2>
<p>A Mastodon instance for hosting friendly bots.</p>
<ul class="btn-list">
<li>
<a class="btn" href="https://botsin.space/">Visit site</a>
</li>
<li>
<a class="btn" href="/projects/botwiki-interviews/botwiki-interview-colin-mitchell">Interview with the creator</a>
</li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
</div>
</div>
</div>
</div>
<?php } elseif ( in_array( 'images', $tags ) ) { ?>
<ul class="btn-list">
<li><a class="btn" href="/bot/?tags=images,generative<?php echo $filter_opensource;?>">#images+generative</a></li>
<li><a class="btn" href="/bot/?tags=images,iot<?php echo $filter_opensource;?>">#images+iot</a></li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
<?php } elseif ( in_array( 'text', $tags ) ) { ?>
<ul class="btn-list">
<li><a class="btn" href="/bot/?tags=text,generative<?php echo $filter_opensource;?>">#text+generative</a></li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
<?php } elseif ( in_array( 'generative', $tags ) ) { ?>
<ul class="btn-list">
<li><a class="btn" href="/bot/?tags=generative,images<?php echo $filter_opensource;?>">#generative+images</a></li>
<li><a class="btn" href="/bot/?tags=generative,gif<?php echo $filter_opensource;?>">#generative+gif</a></li>
<li><a class="btn" href="/bot/?tags=generative,emoji<?php echo $filter_opensource;?>">#generative+emoji</a></li>
<li><a class="btn" href="/bot/?tags=generative,text<?php echo $filter_opensource;?>">#generative+text</a></li>
<li><a class="btn" href="/bot/?tags=generative,audio<?php echo $filter_opensource;?>">#generative+audio</a></li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
<?php } elseif ( in_array( 'interactive', $tags ) ) { ?>
<ul class="btn-list">
<li><a class="btn" href="/bot/?tags=interactive,game<?php echo $filter_opensource;?>">#interactive+game</a></li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
<?php } elseif ( in_array( 'iot', $tags ) ) { ?>
<ul class="btn-list">
<li><a class="btn" href="/bot/?tags=iot,images<?php echo $filter_opensource;?>">#iot+images</a></li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
<?php } elseif ( in_array( 'non-english', $tags ) && count( $tags ) > 1 ) { ?>
<ul class="btn-list">
<li><a class="btn" href="/bots/non-english/">Browse all non-English bots</a></li>
</ul>
<?php } elseif ( in_array( 'mbc-winner', $tags ) ) { ?>
<div class="card pt-5 mt-5 mb-2">
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-4 text-center p-l">
<img src="/wp-content/uploads/2018/02/mbc-january-2016.png" class="lazy-load mb-5 wp-post-image" alt="" data-src="" title="Monthly Bot Challenge January 2016" srcset="/wp-content/uploads/2018/02/mbc-january-2016.png 1200w, /wp-content/uploads/2018/02/mbc-january-2016-250x95.png 250w, /wp-content/uploads/2018/02/mbc-january-2016-768x292.png 768w, /wp-content/uploads/2018/02/mbc-january-2016-700x267.png 700w, /wp-content/uploads/2018/02/mbc-january-2016-120x46.png 120w" sizes="( max-width: 1200px ) 100vw, 1200px" />
</div>
<div class="col-sm-12 col-md-8">
<h2 id="monthly-bot-challenge">Monthly Bot Challenge</h2>
<p>Monthly Bot Challenge was a recurring community event dedicated to showcasing friendly, useful, artistic online bots.</p>
<ul class="btn-list">
<li><a class="btn" href="/projects/monthly-bot-challenge/">Read more</a></li>
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
</div>
</div>
</div>
</div>
<?php } else { ?>
<ul class="btn-list">
<?php
echo $network_related_links;
echo $glitch_link;
echo $narrow_opensource_link;
?>
</ul>
<?php }
} ?>
<?php
get_template_part( 'loop' );
if ( !is_author() && $wp_query->query['post_type'] == 'bot' ) {
$networks_term = get_terms( 'network' );
$network_links = array();
if ( $networks_term ){
foreach ( $networks_term as $network ) {
if ( $network->slug !== $_GET['networks'] ){
$badge = '';
if ( in_array( $network->slug, ['twitter-bots', 'mastodon', 'fediverse'])){
$badge = ' <span class="badge badge-secondary">popular</span>';
}
$opensource_filter = !empty( $_GET['opensource'] ) ? '&opensource=true' : '';
$network_links[] .= <<<HTML
<li>
<a class="btn" href="{$site_url}/bot/?networks={$network->slug}$opensource_filter">{$network->name}{$badge}</a>
</li>
HTML;
}
}
include( locate_template( 'support-botwiki.php', false, false ) );
get_template_part( 'pagination' );
?>
<h3 class="mt-2 mb-2 sidebar-header">More networks</h3>
<ul class="btn-list pl-0 pr-0">
<?php
echo join( ' ', $network_links );
?>
</ul>
<?php }
} ?>
</div>
</div>
</main>
<?php get_footer(); ?>