Files
la-components-wp/blocks/club-cards-block/club-cards-block.php
GP_DEV 54eb8e266f init
2025-06-01 12:38:35 +03:00

68 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Блок с клубными картами
*/
// Получение полей ACF
$block_id = 'club-cards-' . $block['id'];
$class_name = 'club-cards-block';
if (!empty($block['className'])) {
$class_name .= ' ' . $block['className'];
}
if (!empty($block['align'])) {
$class_name .= ' align' . $block['align'];
}
// Получение карт для текущего языка
function get_club_cards_for_current_language() {
$current_lang = pll_current_language();
$args = array(
'post_type' => 'club-card',
'posts_per_page' => -1,
'lang' => $current_lang,
'post_status' => 'publish'
);
return get_posts($args);
}
$cards = get_club_cards_for_current_language();
?>
<div id="<?php echo esc_attr($block_id); ?>" class="container mx-auto <?php echo esc_attr($class_name); ?>">
<?php if ($cards): ?>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-[24px]">
<?php foreach ($cards as $card): ?>
<div class="club-card rounded-[8px] overflow-hidden hover:shadow-xl transition-shadow duration-[300ms]">
<?php if (has_post_thumbnail($card->ID)): ?>
<div class="aspect-video overflow-hidden">
<?php echo get_the_post_thumbnail($card->ID, 'medium', ['class' => 'w-full h-full object-cover']); ?>
</div>
<?php endif; ?>
<div class="p-[24px]">
<h3 class="text-[20px] font-semibold mb-[12px]">
<?php echo get_the_title($card->ID); ?>
</h3>
<?php if (get_the_excerpt($card->ID)): ?>
<div class="text-gray-600 mb-[16px]">
<?php echo get_the_excerpt($card->ID); ?>
</div>
<?php endif; ?>
<div class="text-center">
<button data-modal="club-card"
data-card-id="<?php echo $card->ID; ?>"
class="inline-block px-[24px] py-[12px] bg-blue-500 text-white rounded-[6px] hover:bg-blue-600 transition-colors duration-[300ms]">
Подробнее
</button>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>