'header-aside', 'name' => __( 'Header', 'bizznis' ), 'description' => __( 'This is the widget area in the header.', 'bizznis' ), '_bizznis_builtin' => true, ) ); bizznis_register_sidebar( array( 'id' => 'sidebar', 'name' => __( 'Primary Sidebar', 'bizznis' ), 'description' => __( 'This is the primary sidebar if you are using a two or three column site layout option.', 'bizznis' ), '_bizznis_builtin' => true, ) ); bizznis_register_sidebar( array( 'id' => 'sidebar-alt', 'name' => __( 'Secondary Sidebar', 'bizznis' ), 'description' => __( 'This is the secondary sidebar if you are using a three column site layout option.', 'bizznis' ), '_bizznis_builtin' => true, ) ); bizznis_register_sidebar( array( 'id' => 'home', 'name' => __( 'Home', 'bizznis' ), 'description' => __( 'This is the widget area that replaces default content loop on the homepage.', 'bizznis' ), '_bizznis_builtin' => true, ) ); } /** * Register footer widget areas based on the number of widget areas the user wishes to create * with 'add_theme_support()'. * * @since 1.0.0 */ add_action( 'after_setup_theme', 'bizznis_register_footer_widget_areas' ); function bizznis_register_footer_widget_areas() { $footer_widgets = get_theme_support( 'bizznis-footer-widgets' ); if ( ! $footer_widgets || ! isset( $footer_widgets[0] ) || ! is_numeric( $footer_widgets[0] ) ) { return; } $footer_widgets = (int) $footer_widgets[0]; $counter = 1; while ( $counter <= $footer_widgets ) { bizznis_register_sidebar( array( 'id' => sprintf( 'footer-%d', $counter ), 'name' => sprintf( __( 'Footer %d', 'bizznis' ), $counter ), 'description' => sprintf( __( 'Footer %d widget area.', 'bizznis' ), $counter ), '_bizznis_builtin' => true, ) ); $counter++; } } /** * Echo primary sidebar default content. * * @since 1.0.0 */ add_action( 'bizznis_sidebar', 'bizznis_do_sidebar' ); function bizznis_do_sidebar() { # Only shows if sidebar is empty, and current user has the ability to edit theme options (manage widgets). if ( ! dynamic_sidebar( 'sidebar' ) && current_user_can( 'edit_theme_options' ) ) { bizznis_default_widget_area_content( __( 'Primary Sidebar Widget Area', 'bizznis' ) ); } } /** * Echo alternate sidebar default content. * * @since 1.0.0 */ add_action( 'bizznis_sidebar_alt', 'bizznis_do_sidebar_alt' ); function bizznis_do_sidebar_alt() { # Only shows if sidebar is empty, and current user has the ability to edit theme options (manage widgets). if ( ! dynamic_sidebar( 'sidebar-alt' ) && current_user_can( 'edit_theme_options' ) ) { bizznis_default_widget_area_content( __( 'Secondary Sidebar Widget Area', 'bizznis' ) ); } } /** * Template for default widget area content. * * @since 1.0.0 */ function bizznis_default_widget_area_content( $name ) { echo '
'; echo '
'; printf( '

%s

', esc_html( $name ) ); echo '

'; printf( __( 'This is the %s. You can add content to this area by visiting your Widgets Panel and adding new widgets to this area.', 'bizznis' ), $name, admin_url( 'widgets.php' ) ); echo '

'; echo '
'; echo '
'; }