null, 'header-right' => null, 'sidebar' => null, 'sidebar-alt' => null, ); foreach ( $defaults as $default => $location ) { if ( ! array_key_exists( $default, $config ) ) { unregister_sidebar( $default ); if ( 'after-entry' === $default ) { remove_theme_support( 'genesis-after-entry-widget-area' ); } } } } add_action( 'after_setup_theme', 'child_theme_add_widget_areas' ); /** * Add custom widget areas defined in config. * * @since 1.0.0 * * @return void */ function child_theme_add_widget_areas() { $config = child_theme_get_config( 'widget-areas' ); foreach ( $config as $id => $location ) { if ( is_numeric( str_replace( 'footer-', '', $id ) ) ) { add_theme_support( 'genesis-footer-widgets', str_replace( 'footer-', '', $id ) ); } elseif ( 'after-entry' !== $id ) { $name = ucwords( str_replace( '-', ' ', $id ) ); $description = $name . ' widget area'; if ( 'front-page-1' === $id ) { genesis_register_sidebar( array( 'name' => $name, 'description' => $description, 'id' => $id, 'before_title' => '

', 'after_title' => '

', ) ); } else { genesis_register_sidebar( array( 'name' => $name, 'description' => $description, 'id' => $id, ) ); } if ( ! empty( $location ) && true === apply_filters( "child_theme_{$id}", true ) ) { add_action( $location, function () use ( $id ) { if ( 'front-page-1' === $id ) { ob_start(); the_custom_header_markup(); $custom_header = ob_get_clean(); genesis_widget_area( $id, array( 'before' => '', 'before_title' => '

', 'after_title' => '

', ) ); } else { genesis_widget_area( $id, array( 'before' => '
', 'after' => '
', ) ); } } ); } } } } //add_action( 'genesis_meta', 'child_theme_front_page_widgets' ); /** * Display front page widget areas if active. * * @since 1.0.0 * * @return void */ function child_theme_front_page_widgets() { if ( ! is_front_page() || ! child_theme_has_front_page_widgets() ) { return; } add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' ); add_filter( 'genesis_markup_content-sidebar-wrap', '__return_null' ); remove_theme_support( 'hero-section' ); remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', function () { do_action( 'front_page_widgets' ); } ); } add_action( 'genesis_before', 'child_theme_footer_credits_widget' ); /** * Display footer credits widget area if active. * * @since 1.0.0 * * @return void */ function child_theme_footer_credits_widget() { if ( ! is_active_sidebar( 'footer-credits' ) ) { return; } remove_action( 'genesis_footer', 'genesis_do_footer' ); }