Advertisement
srikat

front-page.php

Oct 25th, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.83 KB | None | 0 0
  1. <?php
  2.  
  3. //* Enqueue scripts
  4. add_action( 'wp_enqueue_scripts', 'minimum_front_page_enqueue_scripts' );
  5. function minimum_front_page_enqueue_scripts() {
  6.  
  7.     //* Load scripts only if custom background is being used
  8.     if ( ! get_background_image() )
  9.         return;
  10.  
  11.     //* Enqueue Backstretch scripts
  12.     wp_enqueue_script( 'minimum-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
  13.     wp_enqueue_script( 'minimum-backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'minimum-backstretch' ), '1.0.0' );
  14.     wp_localize_script( 'minimum-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) );
  15.  
  16.     //* Add custom body class
  17.     add_filter( 'body_class', 'minimum_add_body_class' );
  18.  
  19. }
  20.  
  21. //* Minimum custom body class
  22. function minimum_add_body_class( $classes ) {
  23.     $classes[] = 'minimum';
  24.         return $classes;
  25. }
  26.  
  27. //* Add widget support for homepage if widgets are being used
  28. add_action( 'genesis_meta', 'minimum_front_page_genesis_meta' );
  29. function minimum_front_page_genesis_meta() {
  30.  
  31.     if ( is_home() ) {
  32.  
  33.         //* Remove entry meta in entry footer and Genesis loop
  34.         remove_action( 'genesis_loop', 'genesis_do_loop' );
  35.  
  36.         //* Add Genesis grid loop
  37.         add_action( 'genesis_loop', 'minimum_grid_loop_helper' );
  38.  
  39.         //* Remove entry footer functions
  40.         remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
  41.         remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
  42.         remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
  43.  
  44.         //* Force full width content layout
  45.         add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
  46.  
  47.     }
  48.  
  49.     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' ) ) {
  50.  
  51.         //* Add Home featured Widget areas
  52.         add_action( 'genesis_before_content_sidebar_wrap', 'minimum_home_featured', 15 );
  53.  
  54.         //* Show Portfolio entries above content on homepage
  55.         add_action( 'genesis_before_content_sidebar_wrap', 'sk_portfolio_entries', 16 );
  56.  
  57.     }
  58. }
  59.  
  60. //* Add markup for homepage widgets
  61. function minimum_home_featured() {
  62.  
  63.     printf( '<div %s>', genesis_attr( 'home-featured' ) );
  64.     genesis_structural_wrap( 'home-featured' );
  65.  
  66.         genesis_widget_area( 'home-featured-1', array(
  67.             'before'=> '<div class="home-featured-1 widget-area">',
  68.             'after' => '</div>',
  69.         ) );
  70.  
  71.         genesis_widget_area( 'home-featured-2', array(
  72.             'before'=> '<div class="home-featured-2 widget-area">',
  73.             'after' => '</div>',
  74.         ) );
  75.  
  76.         genesis_widget_area( 'home-featured-3', array(
  77.             'before'=> '<div class="home-featured-3 widget-area">',
  78.             'after' => '</div>',
  79.         ) );
  80.  
  81.         genesis_widget_area( 'home-featured-4', array(
  82.             'before'=> '<div class="home-featured-4 widget-area">',
  83.             'after' => '</div>',
  84.         ) );
  85.  
  86.     genesis_structural_wrap( 'home-featured', 'close' );
  87.     echo '</div>'; //* end .home-featured
  88.  
  89. }
  90.  
  91. function sk_portfolio_entries() {
  92.  
  93.     echo '<div class="home-portfolio"><div class="wrap"><h1 itemprop="headline" class="entry-title">From the Portfolio</h1>' . do_shortcode('[display-posts post_type="portfolio" image_size="portfolio" posts_per_page="4" wrapper="div"]') . '<div class="full-portfolio-link"><a href="http://genesis.dev/portfolio/">View our full Portfolio ยป</a></div></div></div>';
  94.  
  95. }
  96.  
  97. //* Genesis grid loop
  98. function minimum_grid_loop_helper() {
  99.  
  100.     if ( function_exists( 'genesis_grid_loop' ) ) {
  101.         genesis_grid_loop( array(
  102.             'features'              => 0,
  103.             'feature_image_size'    => 0,
  104.             'feature_content_limit' => 0,
  105.             'grid_image_size'       => 0,
  106.             'grid_content_limit'    => 250,
  107.             'more'                  => __( '[Read more]', 'minimum' ),
  108.         ) );
  109.     } else {
  110.  
  111.         genesis_standard_loop();
  112.  
  113.     }
  114.  
  115. }
  116.  
  117. //* Run the Genesis loop
  118. genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement