'',
'name' => '',
'description' => '',
'before_widget' => '',
'before_title' => '
'
);
/* Allow developers to filter the default sidebar arguments. */
$defaults = apply_filters( 'hoot_sidebar_defaults', $defaults );
/* Parse the arguments. */
$args = wp_parse_args( $args, $defaults );
/* Allow developers to filter the sidebar arguments. */
$args = apply_filters( 'hoot_sidebar_args', $args );
/* Remove action. */
remove_action( 'widgets_init', '__return_false', 95 );
/* Register the sidebar. */
return register_sidebar( $args );
}
/* Compatibility for when a theme doesn't register any sidebars. */
add_action( 'widgets_init', '__return_false', 95 );
/**
* Registers footer widget areas.
*
* @since 1.0.0
* @access public
* @return void
*/
function hoot_footer_register_sidebars() {
$columns = hoot_get_footer_columns();
if( $columns ) :
$alphas = range('a', 'z');
for ( $i=0; $i < $columns; $i++ ) :
if ( isset( $alphas[ $i ] ) ) :
hoot_register_sidebar(
array(
'id' => 'footer-' . $alphas[ $i ],
'name' => sprintf( _x( 'Footer %s', 'sidebar', 'brigsby' ), strtoupper( $alphas[ $i ] ) ),
'description' => __( 'You can set footer columns in Theme Options page.', 'brigsby' )
)
);
endif;
endfor;
endif;
}
/* Hook into action */
add_action( 'widgets_init', 'hoot_footer_register_sidebars' );
/**
* Get footer column option.
*
* @since 2.0.0
* @access public
* @return int
*/
function hoot_get_footer_columns() {
$footers = hoot_get_mod( 'footer' );
$columns = ( $footers ) ? intval( substr( $footers, 0, 1 ) ) : false;
$columns = ( is_numeric( $columns ) && 0 < $columns ) ? $columns : false;
return $columns;
}
/**
* Get footer column option.
*
* @since 1.0.0
* @access public
* @deprecated 2.0.0
* @deprecated Use hoot_get_footer_columns()
* @return int
*/
function hoot_get_option_footer() {
_deprecated_function( __FUNCTION__, '2.0.0', 'hoot_get_footer_columns()' );
return hoot_get_footer_columns();
}
/**
* Registers widgetized template widget areas.
*
* @since 1.0.0
* @access public
* @return void
*/
function hoot_widgetized_template_register_sidebars() {
if ( current_theme_supports( 'hoot-widgetized-template' ) ) :
$areas = array();
/* Set up defaults */
$defaults = apply_filters( 'hoot_widgetized_template_widget_areas', array( 'a', 'b', 'c', 'd', 'e' ) );
$locations = array(
__( 'Left', 'brigsby' ),
__( 'Center Left', 'brigsby' ),
__( 'Center', 'brigsby' ),
__( 'Center Right', 'brigsby' ),
__( 'Right', 'brigsby' ),
);
// Get user settings
$sections = hoot_sortlist( hoot_get_mod( 'widgetized_template_sections' ) );
foreach ( $defaults as $key ) {
$id = "area_{$key}";
if ( empty( $sections[$id]['sortitem_hide'] ) ) {
$columns = ( isset( $sections[$id]['columns'] ) ) ? $sections[$id]['columns'] : '';
$count = count( explode( '-', $columns ) ); // empty $columns still returns array of length 1
$location = '';
for ( $c = 1; $c <= $count ; $c++ ) {
switch ( $count ) {
case 2: $location = ($c == 1) ? $locations[0] : $locations[4];
break;
case 3: $location = ($c == 1) ? $locations[0] : (
($c == 2) ? $locations[2] : $locations[4]
);
break;
case 4: $location = ($c == 1) ? $locations[0] : (
($c == 2) ? $locations[1] : (
($c == 3) ? $locations[3] : $locations[4]
)
);
}
$areas[ $id . '_' . $c ] = sprintf( __('Widgetized Template - Area %s %s', 'brigsby'), strtoupper( $key ), $location );
}
}
}
foreach ( $areas as $key => $name ) {
hoot_register_sidebar(
array(
'id' => 'widgetized-template-' . $key,
'name' => $name,
'description' => __( "You can order Widgetized Template areas in Customizer > 'Content' panel > 'Widgetized Template - Modules' section.", 'brigsby' )
)
);
}
endif;
}
/* Hook into action */
add_action( 'widgets_init', 'hoot_widgetized_template_register_sidebars' );