-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtakin-template.php
More file actions
62 lines (58 loc) · 2.53 KB
/
takin-template.php
File metadata and controls
62 lines (58 loc) · 2.53 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
<?php
/* Template Name: Mon Pluggin */
get_header();
$takin_current_day = (int) gmdate('j');
$takin_bg_url = get_the_post_thumbnail_url(get_the_ID(), 'full') ?? plugin_dir_url(__FILE__) . '/assets/takin_default.jpg';
$takin_posts = get_posts([
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'numberposts' => 24,
]);
?>
<!-- NEIGE -->
<div class="neige">
<?php
$takin_flocons = 100;
for ($takin_i = 0; $takin_i < $takin_flocons; $takin_i++) {
$takin_size = wp_rand(3, 6);
$takin_duration = wp_rand(6, 16) . 's';
$takin_xstart = wp_rand(-36, 24) . 'px';
$takin_xend = wp_rand(-64, 64) . 'px';
$takin_left = wp_rand(1, 99) . '%';
echo "<span class='flocon' style='--takin_duration: " . esc_attr($takin_duration) . "; --takin_xstart: " . esc_attr($takin_xstart) . "; --takin_xend: " . esc_attr($takin_xend) . "; left: " . esc_attr($takin_left) . "; width: " . esc_attr($takin_size) . "px; height: " . esc_attr($takin_size) . "px;'></span>";
}
?>
</div>
<div class="py-10 min-h-screen bg-cover bg-center"
style="background-image:url('<?php echo esc_url($takin_bg_url); ?>')">
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-6 mx-auto max-w-6xl">
<?php
$takin_index = 1;
foreach ($takin_posts as $takin_post):
setup_postdata($takin_post);
$takin_is_open = ($takin_current_day >= $takin_index);
if ($takin_is_open): ?>
<a href="<?php echo esc_url(get_permalink($takin_post->ID)); ?>"
class="block bg-red-600 text-white p-6 rounded-xl shadow-lg hover:bg-red-700 transition transform hover:scale-105 text-center">
<span class="text-2xl font-bold mb-2">
<?php echo esc_html($takin_index); ?>
</span>
<h2 class="text-sm opacity-90">
<?php echo esc_html(get_the_title($takin_post->ID)); ?>
</h2>
</a>
<?php else: ?>
<div
class="block bg-gray-300/70 backdrop-blur p-6 rounded-xl shadow-inner text-center text-gray-600 cursor-not-allowed">
<div class="text-2xl font-bold mb-2"><?php echo esc_html($takin_index); ?></div>
<div class="text-xl">🔒</div>
</div>
<?php endif;
$takin_index++;
endforeach;
wp_reset_postdata();
?>
</div>
</div>
<?php get_footer(); ?>