<?php
/**
 * Page title template
 * @since 1.0.0
 * @author Fox
 */
function wp_yellow_hats_page_title(){
    global $smof_data, $wp_yellow_hats_meta, $wp_yellow_hats_base;
    
    if(is_page() && isset($wp_yellow_hats_meta->_cms_page_title) && $wp_yellow_hats_meta->_cms_page_title){
        if(isset($wp_yellow_hats_meta->_cms_page_title_type)){
            $smof_data['page_title_layout'] = $wp_yellow_hats_meta->_cms_page_title_type;
        }
    }

    if (is_page() && isset($wp_yellow_hats_meta->_cms_bg_image_page_title) && $wp_yellow_hats_meta->_cms_bg_image_page_title) {
        $smof_data['bg_image_page_title']['url'] = wp_get_attachment_url($wp_yellow_hats_meta->_cms_bg_image_page_title);
    }

    if (is_singular('teams') && isset($smof_data['bg_image_page_title_team']['url'])) {
        $smof_data['bg_image_page_title']['url'] = $smof_data['bg_image_page_title_team']['url'];
    }

    if (is_singular('services') && isset($smof_data['bg_image_page_title_services']['url'])) {
        $smof_data['bg_image_page_title']['url'] = $smof_data['bg_image_page_title_services']['url'];
    }

    if (is_singular('services') && isset($wp_yellow_hats_meta->_cms_services_bg_page_title_single) && $wp_yellow_hats_meta->_cms_services_bg_page_title_single) {
        $smof_data['bg_image_page_title']['url'] = wp_get_attachment_url($wp_yellow_hats_meta->_cms_services_bg_page_title_single);
    }

    if (is_singular('product') && isset($smof_data['bg_image_page_title_product']['url'])) {
        $smof_data['bg_image_page_title']['url'] = $smof_data['bg_image_page_title_product']['url'];
    }
    if(class_exists('Woocommerce')){
        if (is_woocommerce() && isset($smof_data['bg_image_page_title_product']['url'])) {
            $smof_data['bg_image_page_title']['url'] = $smof_data['bg_image_page_title_product']['url'];
        }
    }

    if($smof_data['page_title_layout']){
        ?>
        <div id="page-title" class="page-title br-style<?php echo ''.$smof_data['page_title_layout']; ?>" style="background-image: url(<?php echo esc_url($smof_data['bg_image_page_title']['url']); ?>);">
            <div class="container">
            <div class="row">
            <?php switch ($smof_data['page_title_layout']){
                case '1':
                    ?>
                        <div id="page-title-text" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">
                            <h1><?php $wp_yellow_hats_base->wp_yellow_hats_get_page_title(); ?></h1>
                        </div>
                        <div id="breadcrumb-text" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center"><?php $wp_yellow_hats_base->wp_yellow_hats_get_breadcrumb(); ?></div>
                    <?php
                    break;
                case '2':
                    ?>
                        <div id="page-title-text" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">
                            <h1><?php $wp_yellow_hats_base->wp_yellow_hats_get_page_title(); ?></h1>
                        </div>
                        <div id="breadcrumb-text" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center"><?php $wp_yellow_hats_base->wp_yellow_hats_get_breadcrumb(); ?></div>
                    <?php
                    break;
                case '3':
                    ?>
                        <div id="page-title-text" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">
                            <h1><?php $wp_yellow_hats_base->wp_yellow_hats_get_page_title(); ?></h1>
                        </div>
                        <div id="breadcrumb-text" class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center"><?php $wp_yellow_hats_base->wp_yellow_hats_get_breadcrumb(); ?></div>
                    <?php
                    break;
                case '4':
                    ?>
                        <div id="page-title-text" class="col-xs-12 col-sm-12 col-md-6 col-lg-6 text-center-md">
                            <h1><?php $wp_yellow_hats_base->wp_yellow_hats_get_page_title(); ?></h1>
                        </div>
                        <div id="breadcrumb-text" class="col-xs-12 col-sm-12 col-md-6 col-lg-6 text-center-md"><?php $wp_yellow_hats_base->wp_yellow_hats_get_breadcrumb(); ?></div>
                    <?php
                    break;
            } ?>
            </div>
            </div>
        </div><!-- #page-title -->
        <?php
    }
}

/**
 * Get Header Layout.
 * 
 * @author Fox
 */
function wp_yellow_hats_header(){
    global $smof_data, $wp_yellow_hats_meta;
    /* header for page */
    if(isset($wp_yellow_hats_meta->_cms_header) && $wp_yellow_hats_meta->_cms_header){
        if(isset($wp_yellow_hats_meta->_cms_header_layout)){
            $smof_data['header_layout'] = $wp_yellow_hats_meta->_cms_header_layout;
        }
    }
    /* load template. */
    get_template_part('inc/header/header', $smof_data['header_layout']);
}
/**
 * Loading.
 * 
 * @author Fox
 */
function wp_yellow_hats_get_page_loading() {
    global $smof_data;
    if($smof_data['enable_page_loadding'] == '1'){
        echo '<div id="cms-loadding"><div class="cms-loader"></div></div>';
    }
}
/**
 * Get Footer Layout.
 * 
 * @author Fox
 */
function wp_yellow_hats_footer(){
    global $smof_data, $wp_yellow_hats_meta;
    /* header for page */
    if(isset($wp_yellow_hats_meta->_cms_footer) && $wp_yellow_hats_meta->_cms_footer){
        if(isset($wp_yellow_hats_meta->_cms_footer_layout)){
            $smof_data['footer_layout'] = $wp_yellow_hats_meta->_cms_footer_layout;
        }
    }
    /* load template. */
    get_template_part('inc/footer/footer', $smof_data['footer_layout']);
}

/**
 * Get menu location ID.
 * 
 * @param string $option
 * @return NULL
 */
function wp_yellow_hats_menu_location($option = '_cms_primary'){
    global $wp_yellow_hats_meta;
    /* get menu id from page setting */
    return (isset($wp_yellow_hats_meta->$option) && $wp_yellow_hats_meta->$option) ? $wp_yellow_hats_meta->$option : null ;
}

/**
 * Add page class
 * 
 * @author Fox
 * @since 1.0.0
 */
function wp_yellow_hats_page_class(){
    global $smof_data, $wp_yellow_hats_meta;
    
    $page_class = '';
    
    if(is_page() && isset($wp_yellow_hats_meta->_cms_page_body_layout) && $wp_yellow_hats_meta->_cms_page_body_layout) {
        $smof_data['body_layout'] = $wp_yellow_hats_meta->_cms_page_body_layout;
    }
    
    if($smof_data['body_layout']){
        $page_class = 'cs-boxed';
    } else {
        $page_class = 'cs-wide';
    }
    
    if (isset($wp_yellow_hats_meta->_cms_show_sidebar_page_left) && $wp_yellow_hats_meta->_cms_show_sidebar_page_left) { 
        $page_class .= ' sidebar-left-active'; 
    }
    
    echo apply_filters('wp_yellow_hats_page_class', $page_class);
}

/**
 * Add main class
 * 
 * @author Fox
 * @since 1.0.0
 */
function wp_yellow_hats_main_class(){
    global $wp_yellow_hats_meta;
    
    $main_class = '';
    /* chect content full width */
    if(isset($wp_yellow_hats_meta->_cms_full_width) && $wp_yellow_hats_meta->_cms_full_width){
        /* full width */
        $main_class = "no-container";
    } else {
        /* boxed */
        $main_class = "container";
    }
    
    echo apply_filters('wp_yellow_hats_main_class', $main_class);
}

/**
 * Archive detail
 * 
 * @author Fox
 * @since 1.0.0
 */
function wp_yellow_hats_archive_detail_top(){
    $post_icon_meta = wp_yellow_hats_post_meta_data();
    ?>
    <?php if(!empty($post_icon_meta->_cms_post_icon)) { ?>
        <div class="icon-single"><i class="<?php echo esc_attr($post_icon_meta->_cms_post_icon); ?>"></i></div>
    <?php } ?>
    <ul>
        <li class="detail-date">
            <a href="<?php echo get_day_link(get_the_time('Y'),get_the_time('m'),get_the_time('d'));?>">
                <span><?php echo get_the_date("M"); ?></span>
                <span class="ft-lo"><?php echo get_the_date("d"); ?></span>
            </a>
        </li>
    </ul>
    <?php
}
function wp_yellow_hats_archive_detail_bottom(){
    ?>
    <ul>
        <?php if(has_category()): ?>
        <li class="detail-terms"><?php the_terms( get_the_ID(), 'category', ''.esc_html__('In: ', 'wp-yellow-hats'), ' , ' ); ?></li>
        <?php endif; ?>
        <li class="detail-author"><?php esc_html_e('By: ', 'wp-yellow-hats'); ?> <?php the_author_posts_link(); ?></li>
        <li class="detail-date">
            <?php esc_html_e('Date: ', 'wp-yellow-hats'); ?>
            <a href="<?php echo get_day_link(get_the_time('Y'),get_the_time('m'),get_the_time('d'));?>">
                <span><?php echo get_the_date(); ?></span>
            </a>
        </li>
        <li class="post-details-right right">
            <ul>
                <li class="comment"><a href="<?php the_permalink(); ?>"><i class="fa fa-comments"></i> <?php echo comments_number('0','1','%'); ?></a></li>
                <li class="counter-view"><i class="fa fa-eye"></i>
                    <?php if(function_exists('wp_yellow_hats_post_views')) { 
                        echo wp_yellow_hats_post_views(get_the_ID()); 
                    }?>
                </li>
            </ul>
        </li>
    </ul>
    <?php
}
function wp_yellow_hats_author_social(){
    global $smof_data;
    ?>
    <ul>
        <?php if(!empty($smof_data['author_facebook'])) { ?> <li><a href="<?php echo esc_url($smof_data['author_facebook']); ?>"><i class="fa fa-facebook"></i></a></li> <?php } ?>
        <?php if(!empty($smof_data['author_twitter'])) { ?> <li><a href="<?php echo esc_url($smof_data['author_twitter']); ?>"><i class="fa fa-twitter"></i></a></li> <?php } ?>
        <?php if(!empty($smof_data['author_youtube'])) { ?> <li><a href="<?php echo esc_url($smof_data['author_youtube']); ?>"><i class="fa fa-youtube-play"></i></a></li> <?php } ?>
        <?php if(!empty($smof_data['author_linkedin'])) { ?> <li><a href="<?php echo esc_url($smof_data['author_linkedin']); ?>"><i class="fa fa-linkedin"></i></a></li> <?php } ?>
        <?php if(!empty($smof_data['author_rss'])) { ?> <li><a href="<?php echo esc_url($smof_data['author_rss']); ?>"><i class="fa fa-rss"></i></a></li> <?php } ?>
    </ul>
    <?php
}

/**
 * Archive readmore
 * 
 * @author Fox
 * @since 1.0.0
 */
function wp_yellow_hats_archive_readmore(){
    echo '<a class="" href="'.get_the_permalink().'" title="'.get_the_title().'" ><i class="fa fa-plus"></i>'.esc_html__('Read More', 'wp-yellow-hats').'</a>';
}

/**
 * Media Audio.
 * 
 * @param string $before
 * @param string $after
 */
function wp_yellow_hats_archive_audio() {
    global $wp_yellow_hats_base;
    /* get shortcode audio. */
    $shortcode = $wp_yellow_hats_base->wp_yellow_hats_get_shortcode_from_content('audio', get_the_content());
    
    if($shortcode != ''){
        echo do_shortcode($shortcode);
        
        return true;
        
    } else {
        if(has_post_thumbnail()){
            the_post_thumbnail();
        }
        
        return false;
    }
    
}

/**
 * Media Video.
 *
 * @param string $before
 * @param string $after
 */
function wp_yellow_hats_archive_video() {
    
    global $wp_embed, $wp_yellow_hats_base;
    /* Get Local Video */
    $local_video = $wp_yellow_hats_base->wp_yellow_hats_get_shortcode_from_content('wpvideo', get_the_content());
    
    /* Get Youtobe or Vimeo */
    $remote_video = $wp_yellow_hats_base->wp_yellow_hats_get_shortcode_from_content('embed', get_the_content());
    
    if($local_video){
        /* view local. */
        echo do_shortcode($local_video);
        
        return true;
        
    } elseif ($remote_video) {
        /* view youtobe or vimeo. */
        echo ''.$wp_embed->run_shortcode($remote_video);
        
        return true;
        
    } elseif (has_post_thumbnail()) {
        /* view thumbnail. */
        the_post_thumbnail();
    } else {
        return false;
    }
    
}

/**
 * Gallerry Images
 * 
 * @author Fox
 * @since 1.0.0
 */
function wp_yellow_hats_archive_gallery(){
    global $wp_yellow_hats_base;
    /* get shortcode gallery. */
    $shortcode = $wp_yellow_hats_base->wp_yellow_hats_get_shortcode_from_content('gallery', get_the_content());
    
    if($shortcode != ''){
        preg_match('/\[gallery.*ids=.(.*).\]/', $shortcode, $ids);
        
        if(!empty($ids)){
        
            $array_id = explode(",", $ids[1]);
            ?>
            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                <div class="carousel-inner">
                <?php $i = 0; ?>
                <?php foreach ($array_id as $image_id): ?>
                    <?php
                    $attachment_image = wp_get_attachment_image_src($image_id, 'full', false);
                    if($attachment_image[0] != ''):?>
                        <div class="item <?php if( $i == 0 ){ echo 'active'; } ?>">
                            <img style="width:100%;" data-src="holder.js" src="<?php echo esc_url($attachment_image[0]);?>" alt="" />
                        </div>
                    <?php $i++; endif; ?>
                <?php endforeach; ?>
                </div>
                <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                    <span class="fa fa-angle-left"></span>
                </a>
                <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                    <span class="fa fa-angle-right"></span>
                </a>
            </div>
            <?php
            
            return true;
        
        } else {
            return false;
        }
    } else {
        if(has_post_thumbnail()){
            the_post_thumbnail();
        }
    }
}

/**
 * Quote Text.
 * 
 * @author Fox
 * @since 1.0.0
 */
function wp_yellow_hats_archive_quote() {
    /* get text. */
    preg_match('/\<blockquote\>(.*)\<\/blockquote\>/', get_the_content(), $blockquote);
    
    if(!empty($blockquote[0])){
        echo ''.$blockquote[0].'';
        return true;
    } else {
        if(has_post_thumbnail()){
            the_post_thumbnail();
        }
        return false;
    }
}

/**
 * List socials share for post.
 * 
 * @since 1.0.0
 */
function wp_yellow_hats_get_socials_share(){
    ?>
    <ul>
    <li><span><?php esc_html_e('Share This Article : ', 'wp-yellow-hats'); ?></span></li>
    <li><a title="Facebook" data-placement="top" data-rel="tooltip" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink();?>"><span class="share-box"><i class="fa fa-facebook"></i></span></a></li>
    <li><a title="Twitter" data-placement="top" data-rel="tooltip" target="_blank" href="https://twitter.com/home?status=<?php esc_html_e('Check out this article', 'wp-yellow-hats');?>:%20<?php the_title();?>%20-%20<?php the_permalink();?>"><span class="share-box"><i class="fa fa-twitter"></i></span></a></li>
    <li><a title="Google Plus" data-placement="top" data-rel="tooltip" target="_blank" href="https://plus.google.com/share?url=<?php the_permalink();?>"><span class="share-box"><i class="fa fa-google-plus"></i></span></a></li>
    <li class="social-pinterest"><a target="_blank" href="https://pinterest.com/pin/create/button/?url=<?php the_permalink();?>"><span class="share-box"><i class="fa fa-pinterest"></i></span></a></li>
    </ul>
    <?php
}

/* 
/**
 * Related Gallery
 * 
 * @since 1.0.0
 */
function wp_yellow_hats_related_gallery() {
    global $post;

    $posttags = get_the_terms($post->ID, 'galeries-category');

    if(empty($posttags)) return ;

    $tags = array();

    foreach ($posttags as $tag) {

        $tags[] = $tag->term_id;
    }

    $query = new WP_Query(array('posts_per_page'=> 10, 'post_type' => 'galeries', 'post_status'=> 'publish', 'tax_query'=>array(array('taxonomy'=>'galeries-category', 'field'=>'id', 'terms'=>$tags))));

    if($query->have_posts()){
        ?> <div class="layout-gallery gallery-full cms-related-gallery clearfix"> <?php
        while ($query->have_posts()): $query->the_post();
        ?>
        <article>
            <div class="cms-grid-item">
                <div class="cms-grid-item-inner cms-gallery-item">
                    <div class="cms-gallery-image">
                        <?php 
                            if(has_post_thumbnail() && !post_password_required() && !is_attachment() &&  wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full', false)):
                                $class = ' has-thumbnail';
                                $thumbnail_url = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full', false);
                                $thumbnail = get_the_post_thumbnail(get_the_ID(),'full');
                            else:
                                $class = ' no-image';
                                $thumbnail_url[0] = CMS_IMAGES.'no-image.jpg';
                                $thumbnail = '<img src="'.esc_url(CMS_IMAGES).'no-image.jpg" alt="'.get_the_title().'" />';
                            endif;
                            echo '<div class="cms-grid-media  has-thumbnail">'.$thumbnail.'</div>';
                        ?>
                        <div class="cms-gallery-image-links">
                            <a href="<?php echo esc_url($thumbnail_url[0]); ?>" class="cms-prettyphoto p-view"><i class="rt-icon-zoom-outline"></i></a>
                            <a class="p-link" title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel=""><i class="rt-icon-location-outline"></i></a>
                        </div>
                    </div>
                    <div class="cms-gallery-description-layout2">
                        <h3><a href="<?php the_permalink() ?>" ><?php the_title();?> </a></h3>
                    </div>
                </div>
            </div>
        </article>
        <?php
        endwhile;
        ?> </div> <?php
    }
    
    wp_reset_postdata();
}

/* Related Post */
function wp_yellow_hats_related_post() {
    global $post;

    $posttags = get_the_category($post->ID);
    
    if(empty($posttags)) return ;
    
    $tags = array();
    
    foreach ($posttags as $tag) {
        
        $tags[] = $tag->term_id;
    }
    
    $query = new WP_Query(array('posts_per_page'=> 3, 'post_type' => 'post', 'post_status'=> 'publish', 'category__in'=>$tags));
    
    if($query->have_posts()){
        ?> 
        <div class="cms-related-post clearfix"> 
            <h3 class="cms-title"><?php esc_html_e('Related Posts','wp-yellow-hats'); ?></h3>
           <div class="cms-related-post-inner row">
        <?php
        while ($query->have_posts()): $query->the_post();
        ?>
            <div class="item <?php echo has_post_thumbnail() ? ' has-feature-img' : ' no-feature-img' ; ?> col-xs-12 col-sm-6 col-md-4 col-lg-4">
                <div class="item-inner">
                    <a href="<?php echo get_the_permalink(); ?>"><?php the_post_thumbnail('wp_yellow_hats_images-sm'); ?></a>
                    <?php if(has_category()): ?>
                        <div class="detail-terms"><?php the_terms( get_the_ID(), 'category', ''.esc_html__('In: ', 'wp-yellow-hats'), ' , ' ); ?></div>
                    <?php endif; ?>
                    <h3 class="title"><a href="<?php echo get_the_permalink(); ?>"><?php the_title(); ?></a></h3>
                </div>
            </div>
        <?php
        endwhile;
        ?> </div></div> <?php
    }
    
    wp_reset_postdata();
}

/* ==========================================================================
   Start Function Theme Check
========================================================================== */
function wp_yellow_hats_page_sidebar(){
    global $wp_yellow_hats_meta;

    return isset($wp_yellow_hats_meta->_cms_show_sidebar) ? $wp_yellow_hats_meta->_cms_show_sidebar : 0 ;
}

function wp_yellow_hats_page_comment() {

    global $smof_data;

    if($smof_data['page_comment'])
        comments_template( '', true );
}

function wp_yellow_hats_header_class() {

    global $smof_data, $wp_yellow_hats_meta;
    $header_layout = '';
    if(isset($wp_yellow_hats_meta->_cms_header) && $wp_yellow_hats_meta->_cms_header){
        if(is_page() && isset($wp_yellow_hats_meta->_cms_header_layout) && $wp_yellow_hats_meta->_cms_header_layout) {
            $smof_data['header_layout'] = $wp_yellow_hats_meta->_cms_header_layout;
        }
    }
    $header_layout = $smof_data['header_layout'];
    return $header_layout;
}

function wp_yellow_hats_body_class() {

    global $smof_data, $wp_yellow_hats_meta;
    $body_custom_class = (isset($wp_yellow_hats_meta->_cms_body_custom_class)) ? $wp_yellow_hats_meta->_cms_body_custom_class : '';
    return $body_custom_class;
}

function wp_yellow_hats_single_post_full_width() {

    global $smof_data, $post, $wp_yellow_hats_meta;
    if(isset($wp_yellow_hats_meta->_cms_post_full_width) && $wp_yellow_hats_meta->_cms_post_full_width != '') {
        $smof_data['post_full_width'] = $wp_yellow_hats_meta->_cms_post_full_width;
    }
    if($smof_data['post_full_width'] == 0) { echo 'post-sidebar'; }
}

function wp_yellow_hats_single_post_sidebar_left() {

    global $smof_data, $post, $wp_yellow_hats_meta;

    if(isset($wp_yellow_hats_meta->_cms_post_sidebar_left) && $wp_yellow_hats_meta->_cms_post_sidebar_left != '') {
        $smof_data['post_sidebar_left'] = $wp_yellow_hats_meta->_cms_post_sidebar_left;
    } ?>
        <div class="single-post-inner <?php if($smof_data['post_sidebar_left']) { echo ' sidebar-left-active'; } ?> clearfix">
            <div id="primary" class="<?php echo esc_attr($smof_data['post_full_width'] ? 'col-xs-12 col-sm-12 col-md-12 col-lg-12 full-width' : 'col-xs-12 col-sm-8 col-md-8 col-lg-8 sidebar-active') ; ?>">
                <div id="content" role="main">
                    <?php get_template_part( 'single-templates/single/content', get_post_format() ); ?>
                    <?php wp_yellow_hats_related_post(); ?>
                    <?php comments_template( '', true ); ?>

                </div><!-- #content -->
            </div><!-- #primary -->
            <?php if(!$smof_data['post_full_width']) : ?>
                <div id="sidebar" class="col-xs-12 col-sm-4 col-md-4 col-lg-4 <?php if($smof_data['post_full_width'] == 1) { echo 'hidden-sidebar'; } ?>">
                    <?php get_sidebar(); ?>
                </div><!-- #sidebar -->
            <?php endif; ?>
        </div>
    <?php
}

function wp_yellow_hats_single_project_layout() {

    global $smof_data, $wp_yellow_hats_meta;
    $project_layout = '';

    if(is_singular('projects') && isset($wp_yellow_hats_meta->_cms_project_layout_show) && $wp_yellow_hats_meta->_cms_project_layout_show){
        if(isset($wp_yellow_hats_meta->_cms_project_layout)){
            $smof_data['project_layout'] = $wp_yellow_hats_meta->_cms_project_layout;
        }
    }

    $project_layout = $smof_data['project_layout'];
    return $project_layout;
}

function wp_yellow_hats_get_id_form() {

    global $smof_data;
    $id_form = '';

    if (!empty($smof_data['get_id_form'])) {
        $id_form = $smof_data['get_id_form'];
    }

    return $id_form;
}

/*  Blog Sidebar */
function wp_yellow_hats_blog_sidebar() {
    global $smof_data, $wp_query, $post, $wp_yellow_hats_meta, $paged;
    if (isset($wp_yellow_hats_meta->_cms_blog_sidebar) && $wp_yellow_hats_meta->_cms_blog_sidebar) {
        $smof_data['blog_sidebar'] = $wp_yellow_hats_meta->_cms_blog_sidebar;
        if(isset($wp_yellow_hats_meta->_cms_blog_sidebar_position)){
            $smof_data['blog_sidebar_position'] = $wp_yellow_hats_meta->_cms_blog_sidebar_position;
        }
    }
    if ($smof_data['blog_sidebar_position'] == 'sidebar-left') { echo 'sidebar-left-active'; }
}

function wp_yellow_hats_blog_sidebar_left() {
    global $smof_data, $wp_query, $post, $wp_yellow_hats_meta, $paged;
    if (isset($wp_yellow_hats_meta->_cms_blog_sidebar) && $wp_yellow_hats_meta->_cms_blog_sidebar) {
        $smof_data['blog_sidebar'] = $wp_yellow_hats_meta->_cms_blog_sidebar;
        if(isset($wp_yellow_hats_meta->_cms_blog_sidebar_position)){
            $smof_data['blog_sidebar_position'] = $wp_yellow_hats_meta->_cms_blog_sidebar_position;
        }
    }
    ?>
    <section id="primary" class="<?php if($smof_data['blog_sidebar'] == '1') { echo 'col-xs-12 col-sm-8 col-md-8 col-lg-8 sidebar-active'; }else  { echo 'col-xs-12 col-sm-12 col-md-12 col-lg-12 page-full-width'; } ?>">
        <div id="content" role="main">
            
            <?php query_posts('post_type=post&showposts='.get_option('posts_per_page').'&paged='.$paged); ?>
            
            <?php if ( have_posts() ) : ?>
                <?php while ( have_posts() ) : the_post();
                    /* Include the post format-specific template for the content. If you want to
                     * this in a child theme then include a file called called content-___.php
                     * (where ___ is the post format) and that will be used instead.
                     */
                     get_template_part( 'single-templates/content/content', get_post_format() );
                endwhile; // end of the loop.?>
                
                <?php wp_yellow_hats_paging_nav(); ?>
                
            <?php else : ?>
            
                <?php get_template_part( 'single-templates/content', 'none' ); ?>
            <?php endif; ?>
        
        </div><!-- #content -->
    </section><!-- #primary -->

    <?php if($smof_data['blog_sidebar'] == '1') { ?>
        <div id="sidebar" class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
            <?php get_sidebar(); ?>
        </div>
    <?php }
}

function wp_yellow_hats_blog_author() {
    global $smof_data, $wp_query, $post, $wp_yellow_hats_meta, $paged;
    if (isset($wp_yellow_hats_meta->_cms_blog_sidebar) && $wp_yellow_hats_meta->_cms_blog_sidebar) {
        $smof_data['blog_sidebar'] = $wp_yellow_hats_meta->_cms_blog_sidebar;
        if(isset($wp_yellow_hats_meta->_cms_blog_sidebar_position)){
            $smof_data['blog_sidebar_position'] = $wp_yellow_hats_meta->_cms_blog_sidebar_position;
        }
    }
    ?>
    <section id="primary" class="<?php if($smof_data['blog_sidebar'] == '1') { echo 'col-xs-12 col-sm-8 col-md-8 col-lg-8 sidebar-active'; }else  { echo 'col-xs-12 col-sm-12 col-md-12 col-lg-12 page-full-width'; } ?>">
        <div id="content" role="main">
            <?php
                if ( have_posts() ) :
                    while ( have_posts() ) : the_post();

                        get_template_part( 'single-templates/content/content', get_post_format() );

                    endwhile; // end of the loop.
                
                    wp_yellow_hats_paging_nav(); ?>
                
            <?php else : ?>
            
                <?php get_template_part( 'single-templates/content', 'none' ); ?>
            <?php endif; ?>
        
        </div><!-- #content -->
    </section><!-- #primary -->

    <?php if($smof_data['blog_sidebar'] == '1') { ?>
        <div id="sidebar" class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
            <?php get_sidebar(); ?>
        </div>
    <?php }
}

/* Call To Action Services */
function wp_yellow_hats_services_cta() {
    global $smof_data;
    if(isset($smof_data['show_cta']) && $smof_data['show_cta']) { ?>
        <div class="single-services-cta col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <div class="cms-cta-wrapper cms-style-default clearfix  cta-right">
                <div class="cms-cta-text text-center-md">
                    <div class="subtext"><?php echo esc_attr($smof_data['cta_subtitle']); ?></div> 
                    <div class="text"><?php echo esc_attr($smof_data['cta_title']); ?></div>
                </div>
                <div class="cms-cta-button text-center-md">
                    <a class=" btn btn size-default" href="<?php echo esc_url($smof_data['cta_btn_url']); ?>">
                        <?php echo esc_attr($smof_data['cta_btn_text']); ?>
                    </a>
                </div>
            </div>
        </div>
    <?php }
}

/* Button Quote */
function wp_yellow_hats_button_quote() {
    global $smof_data;
    
    if($smof_data['show_button_quote'] == '1') {
        if(!empty($smof_data['button_quote_text']) && $smof_data['button_quote_text']) { ?>
            <li class="social-button-free"><span class="get-form-quote"><?php echo esc_attr($smof_data['button_quote_text']); ?></span></li>
        <?php } else { ?>
            <li class="social-button-free"><span class="get-form-quote"><?php echo esc_html__('Get A Quote','wp-yellow-hats'); ?></span></li>
        <?php }
    }
}

/**
 * Body border
 */

function wp_yellow_hats_body_border_class() {
    global $smof_data, $wp_yellow_hats_meta;

    $border_body_class = '';
    if(is_page() && isset($wp_yellow_hats_meta->_cms_page_body_border) && $wp_yellow_hats_meta->_cms_page_body_border){
        $smof_data['body_border'] = $wp_yellow_hats_meta->_cms_page_body_border;
    }
    if ($smof_data['body_border']) { 
        $border_body_class = ' body-border-wrapper '; 
    }

    return $border_body_class;
}

function wp_yellow_hats_body_border() {
    global $smof_data, $wp_yellow_hats_meta, $wp_yellow_hats_base;
    
    if(is_page() && isset($wp_yellow_hats_meta->_cms_page_body_border) && $wp_yellow_hats_meta->_cms_page_body_border){
        if(isset($wp_yellow_hats_meta->_cms_page_body_border_width)){
            $smof_data['body_border_width']['width'] = $wp_yellow_hats_meta->_cms_page_body_border_width;
        }
        if (isset($wp_yellow_hats_meta->_cms_page_body_border_color)) {
            $smof_data['body_border_color'] = $wp_yellow_hats_meta->_cms_page_body_border_color;
        }
    }

    if($smof_data['body_border']) {
        if(!empty($smof_data['body_border_width']['width'])) { ?>
            <span class="body-border body-border-right" style="width: <?php echo esc_attr($smof_data['body_border_width']['width']); ?>; background-color: <?php echo esc_attr($smof_data['body_border_color']); ?>;"></span>
            <span class="body-border body-border-left" style="width: <?php echo esc_attr($smof_data['body_border_width']['width']); ?>; background-color: <?php echo esc_attr($smof_data['body_border_color']); ?>;"></span>
        <?php }
    }
}


/* Login + Register */
function wp_yellow_hats_login_register() {
    if(function_exists('up_get_template_part')): ?>
        <div class="cms-login-wrap cms-popup">
            <div class="cms-form-login">
                <div class="cms-modal-dialog dialog-popup" role="document">
                    <div class="cms-modal-content">
                        <div class="cms-modal-header">
                            <div class="cms-modal-header-innder clearfix">
                                <div class="cms-modal-left">
                                    <span class="lnr lnr-lock"></span>
                                </div>
                                <div class="cms-modal-right">
                                    <span><?php esc_html_e('Welcome', 'wp-yellow-hats'); ?></span>
                                    <h3><?php esc_html_e('SIGN IN', 'wp-yellow-hats'); ?></h3>
                                </div>
                            </div>
                        </div>
                        <div class="cms-modal-body modal-body">
                            <?php  echo do_shortcode('[user-press layout="" form_type="login" is_logged="profile"]'); ?>
                        </div>
                    </div>
                    <div class="more-sign-up white">
                        <span class="form-sign-up"><?php esc_html_e('Dont have an account?','wp-experts');?></span>
                        <a href="javascript:void(0)" class="switch_to_sign_up"> <?php esc_html_e('Sign Up','wp-experts');?></a>
                    </div>
                </div>
            </div>
        </div>
        <div class="cms-register-wrap cms-popup">
            <div class="cms-form-register">
                <div class="cms-modal-dialog dialog-popup" role="document">
                    <div class="cms-modal-content">
                        <div class="cms-modal-header">
                            <div class="cms-modal-header-innder clearfix">
                                <div class="cms-modal-left">
                                    <span class="lnr lnr-lock"></span>
                                </div>
                                <div class="cms-modal-right">
                                    <span><?php esc_html_e('Hellow', 'wp-yellow-hats'); ?></span>
                                    <h3><?php esc_html_e('SIGN UP', 'wp-yellow-hats'); ?></h3>
                                </div>
                            </div>
                        </div>
                        <div class="cms-modal-body modal-body">
                            <?php up_get_template_part('default/form', 'register'); ?>
                        </div>
                    </div>
                    <div class="more-sign-in white">
                        <span class="form-sign-in"><?php esc_html_e('have an account,','wp-experts');?></span>
                        <a href="javascript:void(0)" class="switch_to_login"> <?php esc_html_e('Sign In Here','wp-experts');?></a>
                    </div>
                </div>
            </div>
        </div>
    <?php endif;
}

function wp_yellow_hats_cms_top_social() {

    global $smof_data;

    $cms_top_social = $smof_data['cms_top_social']['enabled'];
    if ($cms_top_social): foreach ($cms_top_social as $key=>$value) {
        switch($key) {
     
            case 'facebook': echo '<li><a href="'.esc_url($smof_data['social_facebook_url']).'"><i class="fa fa-facebook"></i></a></li>';
            break;
     
            case 'twitter': echo '<li><a href="'.esc_url($smof_data['social_twitter_url']).'"><i class="fa fa-twitter"></i></a></li>';
            break;
     
            case 'linkedin': echo '<li><a href="'.esc_url($smof_data['social_inkedin_url']).'"><i class="fa fa-linkedin"></i></a></li>';
            break;
     
            case 'rss': echo '<li><a href="'.esc_url($smof_data['social_rss_url']).'"><i class="fa fa-rss"></i></a></li>';    
            break;  
            
            case 'instagram': echo '<li><a href="'.esc_url($smof_data['social_instagram_url']).'"><i class="fa fa-instagram"></i></a></li>';    
            break;

            case 'google': echo '<li><a href="'.esc_url($smof_data['social_google_url']).'"><i class="fa fa-google-plus"></i></a></li>';    
            break;

            case 'skype': echo '<li><a href="'.esc_url($smof_data['social_skype_url']).'"><i class="fa fa-skype"></i></a></li>';    
            break;

            case 'pinterest': echo '<li><a href="'.esc_url($smof_data['social_pinterest_url']).'"><i class="fa fa-pinterest"></i></a></li>';    
            break;

            case 'vimeo': echo '<li><a href="'.esc_url($smof_data['social_vimeo_url']).'"><i class="fa fa-vimeo-square"></i></a></li>';    
            break;

            case 'youtube': echo '<li><a href="'.esc_url($smof_data['social_youtube_url']).'"><i class="fa fa-youtube"></i></a></li>';    
            break;

            case 'yelp': echo '<li><a href="'.esc_url($smof_data['social_yelp_url']).'"><i class="fa fa-yelp"></i></a></li>';    
            break;

            case 'tumblr': echo '<li><a href="'.esc_url($smof_data['social_tumblr_url']).'"><i class="fa fa-tumblr"></i></a></li>';    
            break;

        }
    }
    endif;
}

/* Menu Popup [Header 19] */
function wp_yellow_hats_menu_popup() {
    global $smof_data, $wp_yellow_hats_meta;
    /* header for page */
    if(isset($wp_yellow_hats_meta->_cms_header) && $wp_yellow_hats_meta->_cms_header){
        if(isset($wp_yellow_hats_meta->_cms_header_layout)){
            $smof_data['header_layout'] = $wp_yellow_hats_meta->_cms_header_layout;
        }
    }
    if ($smof_data['header_layout'] == '19') { ?>
        <div class="cshero-popup-menu">
            <div class="cshero-popup-menu-inner text-center">
                <span class="menu-popup-close lnr lnr-cross"></span>
                <?php
                                
                    $attr = array(
                        'menu' =>wp_yellow_hats_menu_location(),
                        'menu_class' => 'nav-menu menu-main-menu',
                    );
                    
                    $menu_locations = get_nav_menu_locations();
                    
                    if(!empty($menu_locations['primary'])){
                        $attr['theme_location'] = 'primary';
                    }
                    
                    /* enable mega menu. */
                    if(class_exists('HeroMenuWalker')){ $attr['walker'] = new HeroMenuWalker(); }
                    
                    /* main nav. */
                    wp_nav_menu( $attr ); 

                ?>
            </div>
        </div>
    <?php }
}