<?php
/**
 * The Template for displaying Layout 5
 *
 * @author      Elicus Technologies <hello@elicus.com>
 * @link        https://www.elicus.com/
 * @copyright   2024 Elicus Technologies Private Limited
 * @version     1.0.0
 */

$output .= '<article id="post-' . $post_id . '" class="swiper-slide ' . $post_classes . '" >';

// Post Featured Image Wrapper.
if ( '' !== $thumb && 'on' === $show_thumbnail ) {
	$output .= '<div class="aioc_portfolio_image_wrapper">';
	$output .= '<a href="' . esc_url( get_the_permalink( $post_id ) ) . '" class="aioc_portfolio_carousel_image_link">';
	$output .= isset( $overlay_output ) ? $overlay_output : '';
	$output .= et_core_intentionally_unescaped( $thumb, 'html' );
	$output .= '</a>';
	$output .= '</div> <!-- aioc_portfolio_image_wrapper -->';
}

// Post Content Wrapper.
$output .= '<div class="aioc_portfolio_content_wrapper">';

// Post Meta.
if ( 'on' === $show_categories ) {
    $categories = ( isset( $category_background_color ) && '' !== $category_background_color ) ? get_the_term_list( $post_id, 'project_category', '', ' ', '' ) : get_the_term_list( $post_id, 'project_category', '', ', ', '' );

    $output    .= sprintf(
        '<p class="aioc_portfolio_carousel_meta">%1$s</p>',
        (
            'on' === $show_categories && '' !== $categories ?
            et_get_safe_localization(
                sprintf(
                    '<span class="aioc_portfolio_carousel_post_categories">%1$s</span>',
                    $categories
                )
            ) :
            ''
        )
    );
}

// Post Title.
$output .= '<' . esc_html( $processed_title_level ) . ' class="aioc_portfolio_carousel_post_title"><a href="' . esc_url( get_the_permalink( $post_id ) ) . '">' . esc_html( get_the_title( $post_id ) ) . '</a></' . esc_html( $processed_title_level ) . '>';

// Post Excerpt or Content.
if ( 'on' === $show_excerpt ) {
	if ( has_excerpt() && '' !== trim( get_the_excerpt( $post_id ) ) && 0 !== intval( $excerpt_length ) ) {
		$excerpt = wpautop( aioc_strip_shortcodes( get_the_excerpt( $post_id ) ) );
		if ( '' !== $excerpt ) {
			$output .= '<div class="aioc_portfolio_carousel_content">' . $excerpt . '</div>';
		}
	} else {
		if ( 0 !== intval( $excerpt_length ) ) {
			$excerpt = wpautop( strip_shortcodes( aioc_truncate_post( $excerpt_length, false, $post_id, true ) ) );
			if ( '' !== $excerpt ) {
				$output .= '<div class="aioc_portfolio_carousel_content">' . $excerpt . '</div>';
			}
		}
	}
	if ( 'on' === $show_read_more ) {
		$read_more = sprintf(
			'<div class="aioc_portfolio_carousel_button_link">%1$s</div>',
			et_core_intentionally_unescaped( $read_more_html, 'html' )
		);
		$output   .= et_core_intentionally_unescaped( $read_more, 'html' );
	}
}

$output .= '</div> <!-- aioc_portfolio_content_wrapper -->';

$output .= '</article>';
