| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/successkpi/wp-content/themes/successkpi/blocks/resource-tiles-block/ |
Upload File : |
<?php
if (function_exists('render_block_preview_image') && render_block_preview_image($block, 'Resource Tiles block preview')) {
return;
}
// Load Model and View
require_once(dirname(__FILE__) . '/query.php');
require_once(dirname(__FILE__) . '/template.php');
// Get Block Settings
// ACF may return post_type_source as an array (multi-select) or a string — handle both
$post_type_source_raw = get_field('post_type_source');
if (is_array($post_type_source_raw)) {
// Filter to non-empty values
$post_type_source_raw = array_filter($post_type_source_raw);
$post_type_source = !empty($post_type_source_raw) ? array_values($post_type_source_raw) : array('post');
} elseif (!empty($post_type_source_raw)) {
$post_type_source = $post_type_source_raw;
} else {
$post_type_source = 'post';
}
if (is_array($post_type_source)) {
if (count($post_type_source) === 1) {
$post_type_for_js = $post_type_source[0];
} else {
$post_type_for_js = implode(',', $post_type_source);
}
} else {
$post_type_for_js = $post_type_source;
}
$posts_per_page = (int) (get_field('posts_per_page') ?: 6);
$type_label = get_field('type_label') ?: '';
$cta_text = get_field('cta_text') ?: 'Read More';
$block_id = $block['id'];
// --- INITIAL RENDER ---
$query = get_resource_query($post_type_source, $posts_per_page, 1);
$className = 'blogs-card-grid-block sk-section-spacing' . ($block['className'] ?? '');
?>
<section class="<?php echo esc_attr($className); ?>" id="block-<?php echo $block_id; ?>"
data-ajax-url="<?php echo esc_url(admin_url('admin-ajax.php')); ?>"
data-post-type="<?php echo esc_attr($post_type_for_js); ?>" data-per-page="<?php echo esc_attr($posts_per_page); ?>"
data-type-label="<?php echo esc_attr($type_label); ?>"
data-cta-text="<?php echo esc_attr($cta_text); ?>">
<div class="container">
<?php $resource_heading = get_field('resource_heading');
if (isset($resource_heading) && !empty($resource_heading)): ?>
<h2><?php echo esc_html($resource_heading); ?></h2>
<?php endif; ?>
<div class="blog-cards" id="cards-container-<?php echo $block_id; ?>">
<?php
if ($query->have_posts()):
while ($query->have_posts()):
$query->the_post();
render_resource_card(get_the_ID(), $cta_text, $type_label);
endwhile;
wp_reset_postdata();
else:
echo '<p>No posts found.</p>';
endif;
?>
</div>
<div class="sk-pagination" id="pagination-container-<?php echo $block_id; ?>">
<?php render_resource_pagination($query->max_num_pages, 1); ?>
</div>
<?php
$has_awards = false;
$award_items = get_field('award_items');
if (!empty($award_items)) :
if (!empty($award_items)) {
foreach ($award_items as $item) {
if (!empty($item['award_image'])) {
$has_awards = true;
break;
}
}
}
endif;
if ($has_awards) : ?>
<div class="award-list-wrapper">
<?php $awards_heading = get_field('awards_heading');
if (!empty($awards_heading)): ?>
<h2><?php echo esc_html($awards_heading) ?></h2>
<?php endif; ?>
<div class="awards-list">
<?php foreach ($award_items as $item) :
$award_image = $item['award_image'] ?? '';
$award_link = $item['award_link'] ?? '';
if (!$award_image) {
continue;
}
$image_url = $award_image['sizes']['medium_large'] ?? $award_image['url'];
$image_alt = $award_image['alt'] ?: $award_image['title'];
?>
<?php if (!empty($award_link)) : ?>
<a href="<?php echo esc_url($award_link); ?>">
<?php endif; ?>
<img
src="<?php echo esc_url($image_url); ?>"
alt="<?php echo esc_attr($image_alt); ?>"
width="100%"
height="auto"
loading="lazy">
<?php if (!empty($award_link)) : ?>
</a>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
</section>