<?php

/**
 * Layout: Tag Cloud.
 *
 * @link    https://aiopodcasting.com
 * @since   1.0.0
 *
 * @package AiO_Podcast_Studio
 */

// Exit if accessed directly
if ( ! defined( 'WPINC' ) ) {
	die;
}

$args = array( 
	'taxonomy'   => 'aiopod_tags',
	'number'     => 0, 
	'show_count' => (int) $attributes['show_count'], 
	'echo'       => false 
);

if ( ! empty( $attributes['include'] ) ) { // Include tag IDs
	$args['include'] = array_map( 'intval', explode( ',', $attributes['include'] ) );
}

if ( ! empty( $attributes['exclude'] ) ) { // Exclude tag IDs
	$args['exclude'] = array_map( 'intval', explode( ',', $attributes['exclude'] ) );
}

$args = apply_filters( 'aiopod_tags_args', $args, $attributes );
$html = wp_tag_cloud( $args );

// Render HTML output
if ( ! empty( $html ) ) {
	echo '<div class="aiopod aiopod-tags aiopod-tags--layout-cloud">';
	echo $html; 
	echo '</div>';
} elseif ( 0 === (int) $attributes['hide_if_empty'] ) {
	echo '<div class="aiopod aiopod-tags aiopod-tags--layout-cloud">';
	echo '<div class="aiopod-tags__empty aiopod-text-muted">';
	echo esc_html__( 'No tags found.', 'aio-podcast-studio' );
	echo '</div>';
	echo '</div>';
}
