/** * Hook for widgets registration. * * @return void */ function adventure_tours_register_widgets() { // Make a Wordpress built-in Text widget process shortcodes. add_filter('widget_text', 'shortcode_unautop'); add_filter('widget_text', 'do_shortcode', 11); register_widget('AtWidgetLatestPosts'); register_widget('AtWidgetContactUs'); register_widget('AtWidgetTwitterTweets'); if (class_exists('woocommerce')) { register_widget('AtWidgetTours'); } register_sidebar(array('id' => 'sidebar', 'name' => esc_html__('Sidebar', 'adventure-tours'), 'description' => esc_html__('Sidebar located on the right side of blog page.', 'adventure-tours'), 'before_widget' => '<div id="%1$s" class="widget block-after-indent %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget__title">', 'after_title' => '</h3>')); register_sidebar(array('id' => 'shop-sidebar', 'name' => esc_html__('Shop Sidebar', 'adventure-tours'), 'description' => esc_html__('Sidebar located on the right side on pages related to shop.', 'adventure-tours'), 'before_widget' => '<div id="%1$s" class="widget block-after-indent %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget__title">', 'after_title' => '</h3>')); register_sidebar(array('id' => 'tour-sidebar', 'name' => esc_html__('Tour Sidebar', 'adventure-tours'), 'description' => esc_html__('Sidebar located on the right side on pages related to tour.', 'adventure-tours'), 'before_widget' => '<div id="%1$s" class="widget block-after-indent %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget__title">', 'after_title' => '</h3>')); register_sidebar(array('id' => 'faq-sidebar', 'name' => esc_html__('FAQs', 'adventure-tours'), 'description' => esc_html__('Sidebar located on the FAQ page.', 'adventure-tours'), 'before_widget' => '<div id="%1$s" class="widget block-after-indent %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget__title">', 'after_title' => '</h3>')); register_sidebar(array('id' => 'footer1', 'name' => sprintf(esc_html__('Footer %s', 'adventure-tours'), 1), 'description' => esc_html__('Located in 1st column on 4-columns footer layout.', 'adventure-tours'), 'before_widget' => '<div id="%1$s" class="widget block-after-indent %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget__title">', 'after_title' => '</h3>')); $footerColumnsCount = adventure_tours_get_footer_columns(); if ($footerColumnsCount >= 2) { register_sidebar(array('id' => 'footer2', 'name' => sprintf(esc_html__('Footer %s', 'adventure-tours'), 2), 'description' => esc_html__('Located in 2nd column on 4-columns footer layout.', 'adventure-tours'), 'before_widget' => '<div id="%1$s" class="widget block-after-indent %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget__title">', 'after_title' => '</h3>')); } if ($footerColumnsCount >= 3) { register_sidebar(array('id' => 'footer3', 'name' => sprintf(esc_html__('Footer %s', 'adventure-tours'), 3), 'description' => esc_html__('Located in 3rd column on 4-columns footer layout.', 'adventure-tours'), 'before_widget' => '<div id="%1$s" class="widget block-after-indent %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget__title">', 'after_title' => '</h3>')); } if ($footerColumnsCount >= 4) { register_sidebar(array('id' => 'footer4', 'name' => sprintf(esc_html__('Footer %s', 'adventure-tours'), 4), 'description' => esc_html__('Located in 4th column on 4-columns footer layout.', 'adventure-tours'), 'before_widget' => '<div id="%1$s" class="widget block-after-indent %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget__title">', 'after_title' => '</h3>')); } }
<?php /** * Footer widgets area template. * * @author Themedelight * @package Themedelight/AdventureTours * @version 1.0.0 */ $columnsCount = adventure_tours_get_footer_columns(); $hasActiveArea = false; $curIndex = $columnsCount; while ($curIndex >= 1) { if (is_active_sidebar('footer' . $curIndex)) { $hasActiveArea = true; break; } $curIndex--; } if (!$hasActiveArea) { return ''; } $col_class = $columnsCount <= 4 ? 'col-md-' . 12 / $columnsCount : 'col-md-3'; ?> <div class="container"> <div class="row margin-top margin-bottom footer__widgets-areas"> <?php for ($i = 1; $i <= $columnsCount; $i++) { echo '<div class="' . esc_attr($col_class) . '">'; dynamic_sidebar('footer' . $i); echo '</div>';