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

$verse_template_args = get_query_var( 'verse_template_args' );
if ( is_array( $verse_template_args ) ) {
	$verse_columns    = empty( $verse_template_args['columns'] ) ? 2 : max( 1, $verse_template_args['columns'] );
	$verse_blog_style = array( $verse_template_args['type'], $verse_columns );
} else {
	$verse_template_args = array();
	$verse_blog_style = explode( '_', verse_get_theme_option( 'blog_style' ) );
	$verse_columns    = empty( $verse_blog_style[1] ) ? 2 : max( 1, $verse_blog_style[1] );
}
$verse_blog_id       = verse_get_custom_blog_id( join( '_', $verse_blog_style ) );
$verse_blog_style[0] = str_replace( 'blog-custom-', '', $verse_blog_style[0] );
$verse_expanded      = ! verse_sidebar_present() && verse_get_theme_option( 'expand_content' ) == 'expand';
$verse_components    = ! empty( $verse_template_args['meta_parts'] )
							? ( is_array( $verse_template_args['meta_parts'] )
								? join( ',', $verse_template_args['meta_parts'] )
								: $verse_template_args['meta_parts']
								)
							: verse_array_get_keys_by_value( verse_get_theme_option( 'meta_parts' ) );
$verse_post_format   = get_post_format();
$verse_post_format   = empty( $verse_post_format ) ? 'standard' : str_replace( 'post-format-', '', $verse_post_format );

$verse_blog_meta     = verse_get_custom_layout_meta( $verse_blog_id );
$verse_custom_style  = ! empty( $verse_blog_meta['scripts_required'] ) ? $verse_blog_meta['scripts_required'] : 'none';

if ( ! empty( $verse_template_args['slider'] ) || $verse_columns > 1 || ! verse_is_off( $verse_custom_style ) ) {
	?><div class="
		<?php
		if ( ! empty( $verse_template_args['slider'] ) ) {
			echo 'slider-slide swiper-slide';
		} else {
			echo esc_attr( ( verse_is_off( $verse_custom_style ) ? 'column' : sprintf( '%1$s_item %1$s_item', $verse_custom_style ) ) . "-1_{$verse_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( $verse_post_format )
					. ' post_layout_custom post_layout_custom_' . esc_attr( $verse_columns )
					. ' post_layout_' . esc_attr( $verse_blog_style[0] )
					. ' post_layout_' . esc_attr( $verse_blog_style[0] ) . '_' . esc_attr( $verse_columns )
					. ( ! verse_is_off( $verse_custom_style )
						? ' post_layout_' . esc_attr( $verse_custom_style )
							. ' post_layout_' . esc_attr( $verse_custom_style ) . '_' . esc_attr( $verse_columns )
						: ''
						)
		);
	verse_add_blog_animation( $verse_template_args );
	?>
>
	<?php
	// Sticky label
	if ( is_sticky() && ! is_paged() ) {
		?>
		<span class="post_label label_sticky"></span>
		<?php
	}
	// Custom layout
	do_action( 'verse_action_show_layout', $verse_blog_id, get_the_ID() );
	?>
</article><?php
if ( ! empty( $verse_template_args['slider'] ) || $verse_columns > 1 || ! verse_is_off( $verse_custom_style ) ) {
	?></div><?php
	// Need opening PHP-tag above just after </div>, because <div> is a inline-block element (used as column)!
}
