<?php
/*
The file contain functions for footer sections.
*/

function theguard_set_footer_sidebar_layout() {
	global $secretlab, $theguard_layout;

	$sl_sidebar_layout = isset($theguard_layout[$secretlab['theguard_pagetype_prefix'] . 'sidebar-layout']) ? $theguard_layout[$secretlab['theguard_pagetype_prefix'] . 'sidebar-layout'] : 1;
	if ($sl_sidebar_layout == 2 or $sl_sidebar_layout == 4) {
		echo '<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 widget-area">';
		if ($secretlab['theguard_page_type'] == '') $prefix = ''; else $prefix = '_';
		if (isset($theguard_layout[$secretlab['theguard_page_type'] . $prefix . 'right_sidebar_widgets'])) {
			dynamic_sidebar($theguard_layout[$secretlab['theguard_page_type'] . $prefix . 'right_sidebar_widgets']);
		}
		else {
			dynamic_sidebar($secretlab['theguard_page_type'] . '_default_right_sidebar');
		}
		echo '</div>';
	}
	
}


// Copyright date and text
if ( ! function_exists( 'theguard_copyright' ) ) {
    function theguard_copyright()
    {
        global $secretlab;
        if (isset ($secretlab['copyr-text'])) {
            $sl_copyright = $secretlab['copyr-text'];
            if (!empty($sl_copyright)) {
                echo '&copy; ' . date('Y') . ' ' . esc_attr($sl_copyright);
            }
        } else {
            echo '&copy; ' . date('Y');
        }
    }
}

// Social buttons
if ( ! function_exists( 'theguard_socialbuttons_footer' ) ) {
    function theguard_socialbuttons_footer()
    {
        global $secretlab;
        if (isset ($secretlab['social-footer'])) {
            $sl_social_footer = $secretlab['social-footer'];
            if ($sl_social_footer == 1) {
                echo '<ul class="socialbartransparent">';
                if (isset ($secretlab['social_link_facebook'])) {
                    $sl_fb = $secretlab['social_link_facebook'];
                    if (!empty($sl_fb)) {
                        echo '<li><a href="' . esc_url($sl_fb) . '" target="_blank"><i class="fa fa-facebook"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_twitter'])) {
                    $sl_tw = $secretlab['social_link_twitter'];
                    if (!empty($sl_tw)) {
                        echo '<li><a href="' . esc_url($sl_tw) . '" target="_blank"><i class="fa fa-twitter"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_myspace'])) {
                    $sl_myspace = $secretlab['social_link_myspace'];
                    if (!empty($sl_myspace)) {
                        echo '<li><a href="' . esc_url($sl_myspace) . '" target="_blank"><i class="fa fa-user"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_linkedin'])) {
                    $sl_linkedin = $secretlab['social_link_linkedin'];
                    if (!empty($sl_linkedin)) {
                        echo '<li><a href="' . esc_url($sl_linkedin) . '" target="_blank"><i class="fa fa-linkedin"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_google'])) {
                    $sl_google = $secretlab['social_link_google'];
                    if (!empty($sl_google)) {
                        echo '<li><a href="' . esc_url($sl_google) . '" target="_blank"><i class="fa fa-google-plus"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_tumblr'])) {
                    $sl_tumblr = $secretlab['social_link_tumblr'];
                    if (!empty($sl_tumblr)) {
                        echo '<li><a href="' . esc_url($sl_tumblr) . '" target="_blank"><i class="fa fa-tumblr"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_pinterest'])) {
                    $sl_pinterest = $secretlab['social_link_pinterest'];
                    if (!empty($sl_pinterest)) {
                        echo '<li><a href="' . esc_url($sl_pinterest) . '" target="_blank"><i class="fa fa-pinterest-p"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_youtube'])) {
                    $sl_youtube = $secretlab['social_link_youtube'];
                    if (!empty($sl_youtube)) {
                        echo '<li><a href="' . esc_url($sl_youtube) . '" target="_blank"><i class="fa fa-youtube-play"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_instagram'])) {
                    $sl_instagram = $secretlab['social_link_instagram'];
                    if (!empty($sl_instagram)) {
                        echo '<li><a href="' . esc_url($sl_instagram) . '" target="_blank"><i class="fa fa-instagram"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_vkcom'])) {
                    $sl_vkcom = $secretlab['social_link_vkcom'];
                    if (!empty($sl_vkcom)) {
                        echo '<li><a href="' . esc_url($sl_vkcom) . '" target="_blank"><i class="fa fa-vk"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_reddit'])) {
                    $sl_reddit = $secretlab['social_link_reddit'];
                    if (!empty($sl_reddit)) {
                        echo '<li><a href="' . esc_url($sl_reddit) . '" target="_blank"><i class="fa fa-reddit-alien"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_blogger'])) {
                    $sl_blogger = $secretlab['social_link_blogger'];
                    if (!empty($sl_blogger)) {
                        echo '<li><a href="' . esc_url($sl_blogger) . '" target="_blank"><i class="fa fa-pencil"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_wordpress'])) {
                    $sl_wordpress = $secretlab['social_link_wordpress'];
                    if (!empty($sl_wordpress)) {
                        echo '<li><a href="' . esc_url($sl_wordpress) . '" target="_blank"><i class="fa fa-wordpress"></i></a></li>';
                    }
                }
                if (isset ($secretlab['social_link_behance'])) {
                    $sl_behance = $secretlab['social_link_behance'];
                    if (!empty($sl_behance)) {
                        echo '<li><a href="' . esc_url($sl_behance) . '" target="_blank"><i class="fa fa-behance"></i></a></li>';
                    }
                }
                echo '</ul>';
            }
        }
    }
}

// footer logo dispay
if ( ! function_exists( 'theguard_footer_logo' ) ) {
    function theguard_footer_logo()
    {
        global $secretlab;
        if (isset ($secretlab['logo-footer'])) {
            $sl_footer_logo = $secretlab['logo-footer']['url'];
            if (!empty($sl_footer_logo)) {
                echo '<img src="' . esc_url($sl_footer_logo) . '" alt="';
                if (isset ($secretlab['comp-name'])) {
                    echo esc_attr($secretlab['comp-name']);
                }
                echo '" />';
            }
        } else {
            echo '<a href="/"><img src="' . esc_url(get_template_directory_uri()) . '/images/logo.png" class="logo" alt="'.esc_attr__( 'The Guard WordPress Theme', 'the-guard' ).'" /></a>';
        }
    }
}


if ( ! function_exists( 'theguard_footer_close_boxedlayout' ) ) {
    function theguard_footer_close_boxedlayout() {
        global $secretlab, $theguard_layout;
        if (isset ($theguard_layout[$secretlab['theguard_design_layout']])) {
            $sl_design_layout = $theguard_layout[$secretlab['theguard_design_layout']];
            if ($sl_design_layout == 2) {
                echo '</div></div></div>';
            }
        }
        if (isset ($secretlab['footer-nested'])) {
            if ($secretlab['footer-nested'] == 1) {
                if (isset ($secretlab['footer-nested-ace-js'])) {
                    if (strlen($secretlab['footer-nested-ace-js']) > 0 && $secretlab['footer-nested-ace-js'] != 'function hello() { alert ("HELLO"); }') {
                        echo '<script type="text/javascript">' . $secretlab['footer-nested-ace-js'] . '</script>';
                    }
                }
            }
        }
        if (isset ($secretlab['footer-nested'])) {
            if ($secretlab['footer-nested'] == 1) {
                if (isset ($secretlab['footer-nested-ace-css'])) {
                    if (strlen($secretlab['footer-nested-ace-css']) > 0 && $secretlab['footer-nested-ace-css'] != 'body { margin : 0; padding : 0; }') {
                        echo '<style type="text/css">' . $secretlab['footer-nested-ace-css'] . '</style>';
                    }
                }
            }
        }
    }
}
// Title for tab #1
function theguard_footer_tab_title1() {
    global $secretlab;
    if (isset ($secretlab['tab_title_f1'])) {
        echo esc_html($secretlab['tab_title_f1']);
    }
}

// Title for tab #2
function theguard_footer_tab_title2() {
    global $secretlab;
    if (isset ($secretlab['tab_title_f2'])) {
        echo esc_html($secretlab['tab_title_f2']);
    }
}
// Additional CSS class for Security Design #2
function sell_footer_sec2_class() {
    global $secretlab;
    $sl_design_css = isset($secretlab['design-css']) ? $secretlab['design-css'] : 1;
    if ( $sl_design_css == 1 ) {

    }
    if ( $sl_design_css == 2 ) {
        echo ' sec2des';
    }
}
// Switch between footers
function sell_footer_switch() {
    global $secretlab;

    echo '<footer class="fsect';
    sell_footer_sec2_class();
    echo '">';
    if (isset ($secretlab['footer-type-layout'])) {
                if ($secretlab['footer-type-layout'] == 1) {
                    sell_footer_1();
                } else {
                    sell_footer_2();
                }
        }
    echo '</footer>';
}
// Footer #1
if ( ! function_exists( 'sell_footer_1' ) ) {
    function sell_footer_1() {

        echo '
<div class="ftabs">
    <div class="container">
        <div class="row">
            <div class="col-md-12 pl60 pr60">
                <ul class="nav-tabs text-center" role="tablist">';
                    if ( is_active_sidebar( 'botttom_sidebar_one' ) ) {
                        echo '<li role="presentation" class="active"><a href="#firsttab" aria-controls="firsttab" role="tab" data-toggle="tab">';
                        theguard_footer_tab_title1();
                        echo '</a></li>';
                    }
                    if ( is_active_sidebar( 'botttom_sidebar_two' ) ) {
                                echo '<li role="presentation"><a href="#secondtab" aria-controls="secondtab" role="tab" data-toggle="tab">';
                                theguard_footer_tab_title2();
                                echo '</a></li>';
                    }
                echo '</ul>
                <div class="tab-content">';
                        if ( is_active_sidebar( 'botttom_sidebar_one' ) ) {
                            echo '<div role="tabpanel" class="tab-pane fade in active" id="firsttab">';
                            dynamic_sidebar('botttom_sidebar_one');
                            echo '</div>';
                        }
                        if ( is_active_sidebar( 'botttom_sidebar_two' ) ) {
                            echo '<div role="tabpanel" class="tab-pane fade" id="secondtab">';
                            dynamic_sidebar('botttom_sidebar_two');
                            echo '</div>';
                        }
                echo '</div>
            </div>
        </div>
    </div>
</div>
<div class="footer">
    <div class="container">
        <div class="row">
            <div class="col-md-12 text-center">
                <div class="social">';
                    theguard_socialbuttons_footer();
                echo '</div>
                <div class="copyright">';
                    theguard_copyright();
                echo '</div>
            </div>
        </div>
    </div>
</div>';
    }
}
// Footer #2
if ( ! function_exists( 'sell_footer_2' ) ) {
    function sell_footer_2() {

        if ( is_active_sidebar( 'botttom_sidebar_f2' ) ) {
            echo '
        <div class="f_widgets">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">';
            dynamic_sidebar('botttom_sidebar_f2');
            echo '
                    </div>
                </div>
            </div>
        </div>';
        }
        echo '<div class="footer">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                        <div class="copyright col-md-4 col-sm-6 col-xs-12">';
                        theguard_copyright();
                    echo '</div>
                        <div class="social col-md-4 col-sm-6 col-xs-12">';
                            theguard_socialbuttons_footer();
                    echo '</div>
                        <div class="btt col-md-4 col-sm-6 col-xs-12">';
                        theguard_scroll_button();
                    echo '</div>
                    </div>
                </div>
            </div>
        </div>';
    }
}
?>
