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

$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 );
} 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_blog_id       = hygia_get_custom_blog_id( join( '_', $hygia_blog_style ) );
$hygia_blog_style[0] = str_replace( 'blog-custom-', '', $hygia_blog_style[0] );
$hygia_expanded      = ! hygia_sidebar_present() && hygia_get_theme_option( 'expand_content' ) == 'expand';
$hygia_components    = ! empty( $hygia_template_args['meta_parts'] )
							? ( is_array( $hygia_template_args['meta_parts'] )
								? join( ',', $hygia_template_args['meta_parts'] )
								: $hygia_template_args['meta_parts']
								)
							: hygia_array_get_keys_by_value( hygia_get_theme_option( 'meta_parts' ) );
$hygia_post_format   = get_post_format();
$hygia_post_format   = empty( $hygia_post_format ) ? 'standard' : str_replace( 'post-format-', '', $hygia_post_format );

$hygia_blog_meta     = hygia_get_custom_layout_meta( $hygia_blog_id );
$hygia_custom_style  = ! empty( $hygia_blog_meta['scripts_required'] ) ? $hygia_blog_meta['scripts_required'] : 'none';

if ( ! empty( $hygia_template_args['slider'] ) || $hygia_columns > 1 || ! hygia_is_off( $hygia_custom_style ) ) {
	?><div class="
		<?php
		if ( ! empty( $hygia_template_args['slider'] ) ) {
			echo 'slider-slide swiper-slide';
		} else {
			echo esc_attr( ( hygia_is_off( $hygia_custom_style ) ? 'column' : sprintf( '%1$s_item %1$s_item', $hygia_custom_style ) ) . "-1_{$hygia_columns}" );
		}
		?>
	">
	<?php
}
?>
<article id="post-<?php the_ID(); ?>" data-post-id="<?php the_ID(); ?>"
	<?php
	post_class(
			'post_item post_item_container post_format_' . esc_attr( $hygia_post_format )
					. ' post_layout_custom post_layout_custom_' . esc_attr( $hygia_columns )
					. ' post_layout_' . esc_attr( $hygia_blog_style[0] )
					. ' post_layout_' . esc_attr( $hygia_blog_style[0] ) . '_' . esc_attr( $hygia_columns )
					. ( ! hygia_is_off( $hygia_custom_style )
						? ' post_layout_' . esc_attr( $hygia_custom_style )
							. ' post_layout_' . esc_attr( $hygia_custom_style ) . '_' . 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
	}
	// Custom layout
	do_action( 'hygia_action_show_layout', $hygia_blog_id, get_the_ID() );
	?>
</article><?php
if ( ! empty( $hygia_template_args['slider'] ) || $hygia_columns > 1 || ! hygia_is_off( $hygia_custom_style ) ) {
	?></div><?php
	// Need opening PHP-tag above just after </div>, because <div> is a inline-block element (used as column)!
}
