-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate-showcase.php
58 lines (52 loc) · 2.03 KB
/
template-showcase.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
<?php
/* Template Name: Bot Showcase */
global $helpers;
get_header();
$post_id = get_the_ID();
?>
<main role="main" class="container-fluid m-0 p-0">
<div class="container">
<article id="post-<?php echo $post_id; ?>" <?php post_class(); ?>>
<h1 class="post-title text-center"><?php the_title(); ?></h1>
<div class="post-content">
<?php
echo get_post_field( 'post_content', $post_id );
// TODO: Get a list of specific bots by ID
global $wpdb;
$result = $wpdb->get_results( "SELECT * FROM wp_posts WHERE post_content LIKE '%wp:lazyblock/bot-output%' AND post_type = 'bot' AND post_status = 'publish'" );
if ( $result ){
foreach ( $result as $bot ){
$blocks = parse_blocks( $bot->post_content );
$bot_slug = $bot->post_name;
?>
<h2 id="<?php echo $bot_slug; ?>" class="text-center">
<a href="/bot/<?php echo $bot_slug; ?>"><?php echo $bot->post_title; ?></a>
</h2>
<?php
foreach ( $blocks as $block ) {
if ( $block['blockName'] === 'lazyblock/bot-output' ){
$bot_output = $block['attrs']['bot-output'];
echo '<div class="bot-showcase">';
echo str_replace( '</body></html>', '', render_block( $block ) );
echo '</div>';
}
}
}
}
?>
<ul class="btn-list mt-5">
<li>
<a class="btn" href="/bots/">Browse all bots</a>
</li>
<li>
<a class="btn" href="https://mastodon.social/@botwiki">@botwiki</a>
</li>
<li>
<a class="btn" href="https://botsin.space/@newonbotwiki">@newonbotwiki</a>
</li>
</ul>
</div>
</article>
</div>
</main>
<?php get_footer(); ?>