/** * Filter the dynamic sidebars and alter the BS col classes for the footer wigets * @param array $params * @return array */ function footer_widgets_params($params) { static $counter = 0; static $first_row = true; $footer_widgets_layout_array = CargoPressHelpers::footer_widgets_layout_array(); if ('footer-widgets' === $params[0]['id']) { // 'before_widget' contains __col-num__, see inc/theme-sidebars.php $params[0]['before_widget'] = str_replace('__col-num__', $footer_widgets_layout_array[$counter], $params[0]['before_widget']); // first widget in the any non-first row if (false === $first_row && 0 === $counter) { $params[0]['before_widget'] = '</div><div class="row">' . $params[0]['before_widget']; } $counter++; } end($footer_widgets_layout_array); if ($counter > key($footer_widgets_layout_array)) { $counter = 0; $first_row = false; } return $params; }
/** * Register sidebars for CargoPress * * @package CargoPress */ function cargopress_sidebars() { // Blog Sidebar register_sidebar(array('name' => _x('Blog Sidebar', 'backend', 'cargopress-pt'), 'id' => 'blog-sidebar', 'description' => _x('Sidebar on the blog layout.', 'backend', 'cargopress-pt'), 'class' => 'blog sidebar', 'before_widget' => '<div class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4 class="sidebar__headings">', 'after_title' => '</h4>')); // Regular Page Sidebar register_sidebar(array('name' => _x('Regular Page Sidebar', 'backend', 'cargopress-pt'), 'id' => 'regular-page-sidebar', 'description' => _x('Sidebar on the regular page.', 'backend', 'cargopress-pt'), 'class' => 'sidebar', 'before_widget' => '<div class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4 class="sidebar__headings">', 'after_title' => '</h4>')); // woocommerce shop sidebar if (CargoPressHelpers::is_woocommerce_active()) { register_sidebar(array('name' => _x('Shop Sidebar', 'backend', 'cargopress-pt'), 'id' => 'shop-sidebar', 'description' => _x('Sidebar for the shop page', 'backend', 'cargopress-pt'), 'class' => 'sidebar', 'before_widget' => '<div class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h4 class="sidebar__headings">', 'after_title' => '</h4>')); } // Header register_sidebar(array('name' => _x('Header', 'backend', 'cargopress-pt'), 'id' => 'header-widgets', 'description' => _x('Header area for Icon Box and Social Icons widgets.', 'backend', 'cargopress-pt'), 'before_widget' => '<div class="widget %2$s">', 'after_widget' => '</div>')); // Navigation register_sidebar(array('name' => _x('Navigation', 'backend', 'cargopress-pt'), 'id' => 'navigation-widgets', 'description' => _x('Navigation area for Social Icons widgets.', 'backend', 'cargopress-pt'), 'before_widget' => '<div class="widget %2$s">', 'after_widget' => '</div>')); // Footer $footer_widgets_num = count(CargoPressHelpers::footer_widgets_layout_array()); // only register if not 0 if ($footer_widgets_num > 0) { register_sidebar(array('name' => _x('Footer', 'backend', 'cargopress-pt'), 'id' => 'footer-widgets', 'description' => sprintf(_x('Footer area works best with %d widgets. This number can be changed in the Appearance → Customize → Theme Options → Footer.', 'backend', 'cargopress-pt'), $footer_widgets_num), 'before_widget' => '<div class="col-xs-12 col-md-__col-num__"><div class="widget %2$s">', 'after_widget' => '</div></div>', 'before_title' => '<h6 class="footer-top__headings">', 'after_title' => '</h6>')); } }
<?php /** * Footer * * @package CargoPress */ $footer_widgets_layout = CargoPressHelpers::footer_widgets_layout_array(); ?> <footer class="footer" role="contentinfo"> <?php if (!empty($footer_widgets_layout) && is_active_sidebar('footer-widgets')) { ?> <div class="footer-top"> <div class="container"> <div class="row"> <?php dynamic_sidebar('footer-widgets'); ?> </div> </div> </div> <?php } ?> <div class="footer-bottom"> <div class="container"> <div class="footer-bottom__left"> <?php echo apply_filters('cargopress/footer_left_txt', get_theme_mod('footer_left_txt', ''));