Skip to content

Instantly share code, notes, and snippets.

Created May 26, 2013 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c629ba0484caf050fb8a to your computer and use it in GitHub Desktop.
Save anonymous/c629ba0484caf050fb8a to your computer and use it in GitHub Desktop.
/** Register widget areas **/
genesis_register_sidebar( array(
'id' => 'welcome-slider',
'name' => __( 'welcome - Slider', 'executive' ),
'description' => __( 'This is the slider section on the welcome page.', 'executive' ),
) );
genesis_register_sidebar( array(
'id' => 'welcome-top',
'name' => __( 'welcome - Top', 'executive' ),
'description' => __( 'This is the top section of the welcome page.', 'executive' ),
) );
genesis_register_sidebar( array(
'id' => 'welcome-cta',
'name' => __( 'welcome - Call To Action', 'executive' ),
'description' => __( 'This is the call to action section on the welcome page.', 'executive' ),
) );
genesis_register_sidebar( array(
'id' => 'welcome-middle',
'name' => __( 'welcome - Middle', 'executive' ),
'description' => __( 'This is the middle section of the welcome page.', 'executive' ),
) );
}
<?php
add_action( 'genesis_meta', 'executive_welcome_genesis_meta' );
/**
* Add widget support for homepage. If no widgets active, display the default loop.
*
*/
function executive_welcome_genesis_meta() {
if ( is_active_sidebar( 'welcome-slider' ) || is_active_sidebar( 'welcome-top' ) || is_active_sidebar( 'welcome-cta' ) || is_active_sidebar( 'welcome-middle' ) ) {
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'executive_welcome_sections' );
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
add_filter( 'body_class', 'executive_body_class' );
add_action( 'genesis_after', 'executive_slider_excerpt_position' );
/** Add body class to welcome page **/
function executive_body_class( $classes ) {
$classes[] = 'executive-welcome';
return $classes;
}
/** Moves the slider pager if the sidebars are active and the screen is wide enough */
function executive_slider_excerpt_position() {
?>
<script type="text/javascript">
jQuery(document).ready(function() {
if (jQuery(".slide-excerpt").length > 0) {
jQuery(".flex-control-nav").addClass("nav-pos-excerpt");
}
});
</script>
<?php
}
}
}
function executive_welcome_sections() {
if ( is_active_sidebar( 'welcome-slider' ) || is_active_sidebar( 'welcome-top' ) || is_active_sidebar( 'welcome-cta' ) || is_active_sidebar( 'welcome-middle' ) ) {
genesis_widget_area( 'welcome-slider', array(
'before' => '<div class="welcome-slider widget-area">',
) );
genesis_widget_area( 'welcome-top', array(
'before' => '<div class="welcome-top widget-area">',
) );
genesis_widget_area( 'welcome-cta', array(
'before' => '<div class="welcome-cta widget-area">',
) );
genesis_widget_area( 'welcome-middle', array(
'before' => '<div class="welcome-middle widget-area">',
) );
}
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment