Skip to content

Instantly share code, notes, and snippets.

@ameeker
Created May 20, 2014 16:53
Show Gist options
  • Save ameeker/20c39f195b521bab9bf7 to your computer and use it in GitHub Desktop.
Save ameeker/20c39f195b521bab9bf7 to your computer and use it in GitHub Desktop.
Structural wraps
<?php
//* Enqueue scripts
// add_action( 'wp_enqueue_scripts', 'minimum_front_page_enqueue_scripts' );
function minimum_front_page_enqueue_scripts() {
//* Load scripts only if custom background is being used
if ( ! get_background_image() )
return;
//* Enqueue Backstretch scripts
wp_enqueue_script( 'minimum-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'minimum-backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'minimum-backstretch' ), '1.0.0' );
wp_localize_script( 'minimum-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) );
//* Add custom body class
add_filter( 'body_class', 'minimum_add_body_class' );
}
//* Minimum custom body class
function minimum_add_body_class( $classes ) {
$classes[] = 'minimum';
return $classes;
}
//* Add widget support for homepage if widgets are being used
add_action( 'genesis_meta', 'minimum_front_page_genesis_meta' );
function minimum_front_page_genesis_meta() {
if ( is_home() ) {
//* Remove entry meta in entry footer and Genesis loop
remove_action( 'genesis_loop', 'genesis_do_loop' );
//* Remove entry footer functions
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
//* Force full width content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
}
if ( is_active_sidebar( 'home-featured-1' ) || is_active_sidebar( 'home-featured-2' ) || is_active_sidebar( 'home-featured-3' ) || is_active_sidebar( 'home-featured-4' ) || is_active_sidebar( 'home-featured-5' ) || is_active_sidebar( 'home-featured-6' ) || is_active_sidebar( 'home-middle-1' ) || is_active_sidebar( 'home-middle-2' ) || is_active_sidebar( 'home-bottom-1' ) || is_active_sidebar( 'home-bottom-2' ) || is_active_sidebar( 'home-bottom-3' ) || is_active_sidebar( 'home-bottom-4' ) || is_active_sidebar( 'home-bottom-5' )) {
//* Add Home featured Widget areas
add_action( 'genesis_before_content_sidebar_wrap', 'minimum_home_featured', 15 );
add_action( 'genesis_before_content_sidebar_wrap', 'minimum_home_middle', 15 );
add_action( 'genesis_before_content_sidebar_wrap', 'minimum_home_bottom', 15 );
}
}
//* Add markup for homepage widgets
function minimum_home_featured() {
printf( '<div %s>', genesis_attr( 'home-featured' ) );
genesis_structural_wrap( 'home-featured' );
genesis_widget_area( 'home-featured-1', array(
'before' => '<div class="home-featured-1 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'home-featured-2', array(
'before' => '<div class="home-featured-2 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'home-featured-3', array(
'before' => '<div class="home-featured-3 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'home-featured-4', array(
'before' => '<div class="home-featured-4 widget-area">',
'after' => '</div>',
) );
genesis_structural_wrap( 'home-featured', 'close' );
echo '</div>'; //* end .home-featured
}
//* Add markup for homepage widgets
function minimum_home_middle() {
printf( '<div %s>', genesis_attr( 'home-middle' ) );
genesis_structural_wrap( 'home-middle' );
genesis_widget_area( 'home-middle-1', array(
'before' => '<div class="home-middle-1 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'home-middle-2', array(
'before' => '<div class="home-middle-2 widget-area">',
'after' => '</div>',
) );
genesis_structural_wrap( 'home-middle', 'close' );
echo '</div>'; //* end .home-middle
}
//* Add markup for homepage widgets
function minimum_home_bottom() {
printf( '<div %s>', genesis_attr( 'home-bottom' ) );
genesis_structural_wrap( 'home-bottom' );
genesis_widget_area( 'home-bottom-1', array(
'before' => '<div class="home-bottom-1 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'home-bottom-2', array(
'before' => '<div class="home-bottom-2 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'home-bottom-3', array(
'before' => '<div class="home-bottom-3 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'home-bottom-4', array(
'before' => '<div class="home-bottom-4 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'home-bottom-5', array(
'before' => '<div class="home-bottom-5 widget-area">',
'after' => '</div>',
) );
genesis_structural_wrap( 'home-bottom', 'close' );
echo '</div>'; //* end .home-bottom
}
//* Run the Genesis loop
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment