options = maybe_unserialize( get_option( THEMESLUG . '_options' ) );
add_action( 'widgets_init', array( $this, 'register_static_sidebar' ) );
if ( isset( $this->options['footer_layout'] ) && 'hide_footer' !== $this->options['footer_layout'] ) {
add_action( 'widgets_init', array( $this, 'register_dynamic_footer_sidebars' ) );
}
}
/**
* Registering default (static sidebar) which will be always available.
* We will use this sidebar on the right/left side of the content.
*/
public function register_static_sidebar() {
$sidebar_args = array(
'name' => __( 'Sidebar', THEMESLUG ),
'id' => 'sidebar',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
);
register_sidebar( $sidebar_args );
}
/**
* Registering dynamic footer sidebars. Number of sidebars available for the footer will
* depend from the option 'footer_layout' selected within footer section on administrator side
*/
function register_dynamic_footer_sidebars() {
$footer_type = $this->options['footer_layout'];
$footer_sidebar_number = 1;
$footer_sidebar_name = '';
if ( 'full_width' === $footer_type ) {
$footer_sidebar_number = 1;
$footer_sidebar_name = __( 'Footer Section', THEMESLUG );
} else if ( '2_widget_area' === $footer_type ) {
$footer_sidebar_number = 2;
$footer_sidebar_name = __( 'Footer Section', THEMESLUG ) . ' %d';
} else if ( '3_widget_area' === $footer_type ) {
$footer_sidebar_number = 3;
$footer_sidebar_name = __( 'Footer Section', THEMESLUG ) . ' %d';
} else if ( '4_widget_area' === $footer_type ) {
$footer_sidebar_number = 4;
$footer_sidebar_name = __( 'Footer Section', THEMESLUG ) . ' %d';
}
$footer_sidebar_args = array(
'name' => $footer_sidebar_name,
'id' => 'footer_sidebar',
'class' => '',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
);
register_sidebars( $footer_sidebar_number, $footer_sidebar_args );
}
}
new Digitalmind_Sidebars();