<?php
/**
 * The main template file.
 *
 * Used as the fallback template for blog archives and other listings.
 *
 * @package Eronex
 * @since 0.0.1
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
get_header();
$p_id              = get_the_ID();
$general_container = eronex_option( 'eronex_container_layout', 'container' );
$archive_container = eronex_option( 'eronex_archive_container_layout', $general_container );
$archive_container = ! empty( $archive_container ) ? $archive_container : $general_container;
$meta_container    = get_post_meta( $p_id, 'eronex_container_layout', true );
$container         = ! empty( $meta_container ) ? $meta_container : $archive_container;

$layout = eronex_option( 'eronex_archive_post_layout', 'list' );

$general_sidebar = eronex_option( 'eronex_sidebar_layout', 'right' );
$archive_sidebar = eronex_option( 'eronex_archive_sidebar_layout', $general_sidebar );
$meta_sidebar    = get_post_meta( $p_id, 'eronex_sidebar_layout', true );
$sidebar         = ! empty( $meta_sidebar ) ? $meta_sidebar : $archive_sidebar;
?>
<div class="eronex-content-inner">
    <div class="eronex-<?php echo esc_attr( $container ); ?>">
        <div class="eronex-row">
            <main class="eronex-main">
                <div class="eronex-archive-layout-<?php echo esc_attr( $layout ); ?>">
                    <?php
                    /**
                     * Fires to output the archive post loop.
                     *
                     * @since 0.0.1
                     */
                    do_action( 'eronex_archive_loop' );
                    ?>
                </div>
            </main>
            <?php if ( 'none' !== $sidebar ) { ?>
                <aside class="eronex-aside eronex-aside-<?php echo esc_attr( $sidebar ); ?>">
                    <?php
                    /**
                     * Fires to output the sidebar markup.
                     *
                     * @since 0.0.1
                     */
                    do_action( 'eronex_sidebar' );
                    ?>
                </aside>
            <?php } ?>
        </div>
    </div>
</div>
<?php
get_footer();
