Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
To incorporate Minimum Pro’s Home Featured Widget Areas in eleven40 Pro. We are restricting the code to homepage and a couple of selected Pages (IDs 2 and 83).
<?php
//* Start the engine
include_once( get_template_directory() . '/lib/init.php' );
//* Set Localization (do not remove)
load_child_theme_textdomain( 'eleven40', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'eleven40' ) );
//* Child theme (do not remove)
define( 'CHILD_THEME_NAME', __( 'eleven40 Pro Theme', 'eleven40' ) );
define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/eleven40/' );
define( 'CHILD_THEME_VERSION', '2.0' );
//* Add HTML5 markup structure
add_theme_support( 'html5' );
//* Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );
//* Load Lora and Oswald Google fonts
add_action( 'wp_enqueue_scripts', 'eleven40_google_fonts' );
function eleven40_google_fonts() {
wp_enqueue_style( 'google-font', '//fonts.googleapis.com/css?family=Lora:400,700|Oswald:400', array(), PARENT_THEME_VERSION );
}
//* Add new featured image size
add_image_size( 'grid-featured', 270, 100, TRUE );
//* Add support for custom header
add_theme_support( 'custom-header', array(
'width' => 320,
'height' => 65,
'header-selector' => '.site-header .title-area',
'header-text' => false
) );
//* Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'nav',
'subnav',
'site-inner',
'footer-widgets',
'footer',
'featured'
) );
//* Add support for additional color styles
add_theme_support( 'genesis-style-selector', array(
'eleven40-pro-blue' => __( 'eleven40 Pro Blue', 'eleven40' ),
'eleven40-pro-green' => __( 'eleven40 Pro Green', 'eleven40' ),
'eleven40-pro-red' => __( 'eleven40 Pro Red', 'eleven40' )
) );
//* Reposition the site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
add_action( 'genesis_before_content_sidebar_wrap', 'genesis_seo_site_description' );
//* Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_nav' );
//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_subnav' );
//* Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );
genesis_register_sidebar( array(
'id' => 'featured-1',
'name' => __( 'Featured 1', 'eleven40' ),
'description' => __( 'This is the featured 1 section.', 'eleven40' ),
) );
genesis_register_sidebar( array(
'id' => 'featured-2',
'name' => __( 'Featured 2', 'eleven40' ),
'description' => __( 'This is the featured 2 section.', 'eleven40' ),
) );
genesis_register_sidebar( array(
'id' => 'featured-3',
'name' => __( 'Featured 3', 'eleven40' ),
'description' => __( 'This is the featured 3 section.', 'eleven40' ),
) );
genesis_register_sidebar( array(
'id' => 'featured-4',
'name' => __( 'Featured 4', 'eleven40' ),
'description' => __( 'This is the featured 4 section.', 'eleven40' ),
) );
//* Add widget support if widgets are being used
add_action( 'genesis_meta', 'eleven40_pro_genesis_meta' );
function eleven40_pro_genesis_meta() {
if ( is_home() || is_page( array(2, 83) ) && ( is_active_sidebar( 'featured-1' ) || is_active_sidebar( 'featured-2' ) || is_active_sidebar( 'featured-3' ) || is_active_sidebar( 'featured-4' ) ) ) {
//* Add featured Widget areas
add_action( 'genesis_before_content_sidebar_wrap', 'eleven40_pro_featured', 15 );
}
}
//* Add markup for featured widgets
function eleven40_pro_featured() {
printf( '<div %s>', genesis_attr( 'featured' ) );
genesis_structural_wrap( 'featured' );
genesis_widget_area( 'featured-1', array(
'before'=> '<div class="featured-1 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'featured-2', array(
'before'=> '<div class="featured-2 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'featured-3', array(
'before'=> '<div class="featured-3 widget-area">',
'after' => '</div>',
) );
genesis_widget_area( 'featured-4', array(
'before'=> '<div class="featured-4 widget-area">',
'after' => '</div>',
) );
genesis_structural_wrap( 'featured', 'close' );
echo '</div>'; //* end .featured
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment