<?php
/**
 * The Portfolio template to display the content
 *
 * Used for index/archive/search.
 *
 * @package HYGIA
 * @since HYGIA 1.0
 */

$hygia_template_args = get_query_var( 'hygia_template_args' );
if ( is_array( $hygia_template_args ) ) {
	$hygia_columns    = empty( $hygia_template_args['columns'] ) ? 2 : max( 1, $hygia_template_args['columns'] );
	$hygia_blog_style = array( $hygia_template_args['type'], $hygia_columns );
    $hygia_columns_class = hygia_get_column_class( 1, $hygia_columns, ! empty( $hygia_template_args['columns_tablet']) ? $hygia_template_args['columns_tablet'] : '', ! empty($hygia_template_args['columns_mobile']) ? $hygia_template_args['columns_mobile'] : '' );
} else {
	$hygia_template_args = array();
	$hygia_blog_style = explode( '_', hygia_get_theme_option( 'blog_style' ) );
	$hygia_columns    = empty( $hygia_blog_style[1] ) ? 2 : max( 1, $hygia_blog_style[1] );
    $hygia_columns_class = hygia_get_column_class( 1, $hygia_columns );
}

$hygia_post_format = get_post_format();
$hygia_post_format = empty( $hygia_post_format ) ? 'standard' : str_replace( 'post-format-', '', $hygia_post_format );

?><div class="
<?php
if ( ! empty( $hygia_template_args['slider'] ) ) {
	echo ' slider-slide swiper-slide';
} else {
	echo ( hygia_is_blog_style_use_masonry( $hygia_blog_style[0] ) ? 'masonry_item masonry_item-1_' . esc_attr( $hygia_columns ) : esc_attr( $hygia_columns_class ));
}
?>
"><article id="post-<?php the_ID(); ?>" 
	<?php
	post_class(
		'post_item post_item_container post_format_' . esc_attr( $hygia_post_format )
		. ' post_layout_portfolio'
		. ' post_layout_portfolio_' . esc_attr( $hygia_columns )
		. ( 'portfolio' != $hygia_blog_style[0] ? ' ' . esc_attr( $hygia_blog_style[0] )  . '_' . esc_attr( $hygia_columns ) : '' )
	);
	hygia_add_blog_animation( $hygia_template_args );
	?>
>
<?php

	// Sticky label
	if ( is_sticky() && ! is_paged() ) {
		?><span class="post_label label_sticky"></span><?php
	}

	$hygia_hover   = ! empty( $hygia_template_args['hover'] ) && ! hygia_is_inherit( $hygia_template_args['hover'] )
								? $hygia_template_args['hover']
								: hygia_get_theme_option( 'image_hover' );

	if ( 'dots' == $hygia_hover ) {
		$hygia_post_link = empty( $hygia_template_args['no_links'] )
								? ( ! empty( $hygia_template_args['link'] )
									? $hygia_template_args['link']
									: get_permalink()
									)
								: '';
		$hygia_target    = ! empty( $hygia_post_link ) && hygia_is_external_url( $hygia_post_link ) && function_exists( 'hygia_external_links_target' )
								? hygia_external_links_target()
								: '';
	}
	
	// Meta parts
	$hygia_components = ! empty( $hygia_template_args['meta_parts'] )
							? ( is_array( $hygia_template_args['meta_parts'] )
								? $hygia_template_args['meta_parts']
								: explode( ',', $hygia_template_args['meta_parts'] )
								)
							: hygia_array_get_keys_by_value( hygia_get_theme_option( 'meta_parts' ) );

	// Featured image
	hygia_show_post_featured( apply_filters( 'hygia_filter_args_featured', 
        array(
			'hover'         => $hygia_hover,
			'no_links'      => ! empty( $hygia_template_args['no_links'] ),
			'thumb_size'    => ! empty( $hygia_template_args['thumb_size'] )
								? $hygia_template_args['thumb_size']
								: hygia_get_thumb_size(
									hygia_is_blog_style_use_masonry( $hygia_blog_style[0] )
										? (	strpos( hygia_get_theme_option( 'body_style' ), 'full' ) !== false || $hygia_columns < 3
											? 'masonry-big'
											: 'masonry'
											)
										: (	strpos( hygia_get_theme_option( 'body_style' ), 'full' ) !== false || $hygia_columns < 3
											? 'square'
											: 'square'
											)
								),
			'thumb_bg' => hygia_is_blog_style_use_masonry( $hygia_blog_style[0] ) ? false : true,
			'show_no_image' => true,
			'meta_parts'    => $hygia_components,
			'class'         => 'dots' == $hygia_hover ? 'hover_with_info' : '',
			'post_info'     => 'dots' == $hygia_hover
										? '<div class="post_info"><h5 class="post_title">'
											. ( ! empty( $hygia_post_link )
												? '<a href="' . esc_url( $hygia_post_link ) . '"' . ( ! empty( $target ) ? $target : '' ) . '>'
												: ''
												)
												. esc_html( get_the_title() ) 
											. ( ! empty( $hygia_post_link )
												? '</a>'
												: ''
												)
											. '</h5></div>'
										: '',
            'thumb_ratio'   => 'info' == $hygia_hover ?  '100:102' : '',
        ),
        'content-portfolio',
        $hygia_template_args
    ) );
	?>
</article></div><?php
// Need opening PHP-tag above, because <article> is a inline-block element (used as column)!