<?php
// preset for single post


if (get_post_type() == 'jaw-gallery') {
    get_header('gallery');
    echo jaw_get_template_part('single-gallery', 'custom-posts');
    get_footer('gallery');
} else {
    get_header();
    $terms = get_the_category();
    if (isset($terms[0]->term_id)) {
        $term_id = $terms[0]->term_id;
    } else {
        $term_id = 0;
    }
    jwLayout::get();
    $jaw_single_preset = jwOpt::get_option('single_preset'); //nejvic default - TO
    $jaw_single_preset = jwOpt::checkDefaultPreset(array(
                                                get_post_meta(get_the_ID(), 'jaw_single_preset_val', true), ///nejdrive se kouknu je-li neco nastaveno v singlu
                                                jwOpt::get_option('single_preset', $jaw_single_preset, 'category', $term_id), //pokud neni nic  v singlu, zkontrolujinastaveni pro kategorii
                                                $jaw_single_preset), // a pokud neni nic ani v kategorii, tak vezmu nastaveni z TO viz řádek 18
                                            'single');
    $jaw_single_color_preset = jwOpt::checkDefaultPreset(array(jwOpt::get_option('content_color', '_default', 'category', $term_id), jwOpt::get_option('main_color')),'color');
    $jaw_class = array();
    $jaw_class[] = 'post-preset-' . $jaw_single_color_preset;
    $jaw_class[] = jwLayout::content_class();
    $jaw_class[] = jwLayout::content_layout();

    ?>
    <!-- Row for main content area -->
    <div id="content" class="<?php echo esc_attr(implode(' ', $jaw_class)); ?>" >
    <?php
    echo jwUtils::customizer_preview_preset("Single", $jaw_single_color_preset);
    ?>
        <div class="post-box  builder-section <?php echo esc_attr('post-'.jwOpt::getPresetValue('post_layout_style', 'bar_type_1', 'single', $jaw_single_preset)); ?>" >
            <?php
            jaw_template_set_var('single_preset', $jaw_single_preset);
            $id = get_the_ID() . "-". get_query_var('page');
            echo jaw_get_template_cache('single-post', 'blog', '',$id,'slow',true);
            ?>	
        </div><!-- End Content row -->
    </div>
    <?php
    get_sidebar();
    get_footer();
}