Skip to content

Commit

Permalink
[dev] Allow widgets display in the footer
Browse files Browse the repository at this point in the history
  • Loading branch information
Fab1en committed Jun 1, 2015
1 parent b19caa7 commit 99dd573
Showing 1 changed file with 41 additions and 19 deletions.
60 changes: 41 additions & 19 deletions inc/footermenu.php
Expand Up @@ -5,18 +5,17 @@
*/
class Skrollr_Footer_Menu {

private $location = 'footer';
private $description = '';
private $menu_id;
private $menu_object;
private $menu_side = 'left';
private $title;
private static $instance;

function __construct(){
self::$instance = $this;
$this->description = __( 'Footer menu', 'skrollr' );
add_action( 'after_setup_theme', array( $this, 'register_nav_menu' ) );
add_filter( 'mediahelper_image_link_size', function($size){ return array(250, 120, true); } );
add_action( 'widgets_init', array( $this, 'register_sidebar' ) );
}

/**
Expand All @@ -32,35 +31,58 @@ static function get_instance() {
* Declare main menu to Wordpress
*/
function register_nav_menu() {
register_nav_menu( $this->location, $this->description );
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $this->location ] ) ) {
$this->menu_id = $locations[ $this->location ];
$this->menu_object = wp_get_nav_menu_object( $locations[ $this->location ] );

// get the custom layout
$this->menu_side = get_theme_mod('footer_menu_layout', 'left');
register_nav_menu( 'footer', __( 'Footer menu', 'skrollr' ) );
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations['footer'] ) ) {
$this->menu_id = $locations['footer'];
$this->menu_object = wp_get_nav_menu_object( $locations['footer'] );
if( has_nav_menu( 'footer' ) ) {
$this->title = $this->menu_object->name;
}
}

// get the custom layout
$this->menu_side = get_theme_mod( 'footer_menu_layout', 'left' );
}

function register_sidebar() {
register_sidebar(array(
'name' => __( 'Footer bar', 'skrollr' ),
'id' => 'footerbar',
'description' => __( 'Displays at the bottom of each page', 'skrollr' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
) );
}

/**
* Display the menu if needed
*/
function display() {
if ( has_nav_menu( 'footer' ) ) {
if ( has_nav_menu( 'footer' ) || is_active_sidebar( 'footerbar' ) ) {
?><div class="block page two-columns clearfix row" id="footer">
<h2 class="col-md-10 col-md-offset-1"><?php echo $this->menu_object->name ?></h2>
<?php if ( !empty( $this->title ) ) : ?>
<h2 class="col-md-10 col-md-offset-1"><?php echo $this->title ?></h2>
<?php endif; ?>

<div class="text-column col-md-5 col-md-offset-1 <?php if( $this->menu_side == 'left' ) echo 'col-md-push-5' ?>">
<?php if ( is_active_sidebar( 'footerbar' ) ) {
dynamic_sidebar( 'footerbar' );
} ?>

</div>

<div class="menu-column col-md-5 <?php if( $this->menu_side == 'left' ) echo 'col-md-pull-5' ?>">
<?php wp_nav_menu( array(
'theme_location' => 'footer',
'container' => 'nav',
'container_class'=> 'footer_menu',
'items_wrap' => '<ul id="%1$s" class="%2$s linesep">%3$s</ul>',
'fallback_cb' => '__return_false',
) ); ?>
<?php if ( has_nav_menu( 'footer' ) ) {
wp_nav_menu( array(
'theme_location' => 'footer',
'container' => 'nav',
'container_class'=> 'footer_menu',
'items_wrap' => '<ul id="%1$s" class="%2$s linesep">%3$s</ul>',
'fallback_cb' => '__return_false',
) );
} ?>
</div>

</div><?php
Expand Down

0 comments on commit 99dd573

Please sign in to comment.