<?php
/**
 * Render: bw/sponsor-tiers.
 *
 * @var array $attributes Block attributes.
 *
 * @package Kadence-Child
 */

defined( 'ABSPATH' ) || exit;

$groups = pv_get_sponsors_by_tier( isset( $attributes['year'] ) ? (string) $attributes['year'] : '' );
if ( ! $groups ) {
    return;
}
$show_headings = ! isset( $attributes['showHeadings'] ) || $attributes['showHeadings'];
?>
<div <?php echo get_block_wrapper_attributes( array( 'class' => 'pv-sponsor-tiers' ) ); // phpcs:ignore WordPress.Security.EscapeOutput ?>>
    <?php foreach ( $groups as $group ) : ?>
        <section class="pv-sponsor-tier pv-sponsor-tier--<?php echo esc_attr( $group['term']->slug ); ?>">
            <?php if ( $show_headings ) : ?>
                <h6 class="pv-sponsor-tier__heading"><?php echo esc_html( $group['settings']['heading'] ); ?></h6>
            <?php endif; ?>
            <ul class="pv-partner-logos pv-partner-logos--cols-<?php echo esc_attr( $group['columns'] ); ?>">
                <?php foreach ( $group['posts'] as $post_item ) {
                    echo pv_render_partner_logo( $post_item ); // phpcs:ignore WordPress.Security.EscapeOutput -- escaped in component.
                } ?>
            </ul>
        </section>
    <?php endforeach; ?>
</div>
