<?php
/**
 * The template for displaying the footer.
 *
 * Contains the closing of the id=main div and all content after
 *
 * @package CookAndMeal
 */
?>
<?php

// Footer shortcode block option
$show_footer_shortcodeblock = true;

if(get_theme_mod('footer_shortcodeblock_homepage', true) == true && is_front_page()) {
  $show_footer_shortcodeblock = true;
}
if(get_theme_mod('footer_shortcodeblock_homepage', true) == true && !is_front_page()) {
  $show_footer_shortcodeblock = false;
}

// Footer shortcode block option
$show_footer_htmlblock = true;

if(get_theme_mod('footer_htmlblock_homepage', true) == true && is_front_page()) {
  $show_footer_htmlblock = true;
}
if(get_theme_mod('footer_htmlblock_homepage', true) == true && !is_front_page()) {
  $show_footer_htmlblock = false;
}

?>

<?php
// Site Above Footer Banner
cookandmeal_banner_display('above_footer');
?>

<?php if($show_footer_shortcodeblock): ?>

<?php cookandmeal_footer_shortcode_display(); ?>

<?php endif; ?>

<?php if($show_footer_htmlblock): ?>

<?php cookandmeal_footer_htmlblock_display(); ?>

<?php endif; ?>

<?php

$footer_add_class = 'footer-'.get_theme_mod('footer_style', 'white');

?>

<?php if ( is_active_sidebar( 'footer-sidebar' ) ) : ?>
<div class="footer-sidebar-wrapper <?php echo esc_attr($footer_add_class); ?>">
  <div class="footer-sidebar sidebar container footer-sidebar-container">
    <div class="footer-separator"></div>
    <ul id="footer-sidebar">
      <?php dynamic_sidebar( 'footer-sidebar' ); ?>
    </ul>
  </div>
</div>
<?php endif; ?>

<?php if(get_theme_mod('footer_socialicons', true) || get_theme_mod('footer_menu', true) || get_theme_mod('footer_copyright','', 'cookandmeal') !== ''): ?>
<div class="footer-wrapper">
  <footer class="main-footer <?php echo esc_attr($footer_add_class); ?>">
    <div class="container">
      <div class="footer-separator"></div>
      <?php
      // Site Footer Banner
      cookandmeal_banner_display('footer');
      ?>

      <?php if(get_theme_mod('footer_socialicons', false)): ?>
      <div class="footer-social">
        <?php cookandmeal_social_display(true, 5); ?>
      </div>
      <?php endif; ?>

      <?php if(get_theme_mod('footer_menu', true)): ?>
      <div class="footer-menu" role="navigation">
      <?php
        wp_nav_menu(array(
          'theme_location'  => 'footer',
          'menu_class'      => 'footer-links',
          'fallback_cb'    => false,
        ));
      ?>
      </div>
      <?php endif; ?>

      <div class="footer-copyright">
          <?php
            echo wp_kses_post(get_theme_mod('footer_copyright',''));
          ?>
      </div>

    </div>
  </footer>
</div>
<?php endif; ?>

<?php if ( get_theme_mod( 'button_backtotop', true ) == true ):?>
<a class="scroll-to-top" aria-label="<?php echo esc_attr__('Scroll to top', 'cookandmeal'); ?>" href="#top"></a>
<?php endif; ?>

<?php wp_footer(); ?>
</body>
</html>
