Advertisement
srikat

front-page.php

Oct 18th, 2013
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.87 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 even/odd post class
  28. add_filter( 'post_class', 'minimum_even_odd_portfolio_post_class' );
  29. function minimum_even_odd_portfolio_post_class( $classes ) {
  30.  
  31.     global $wp_query;
  32.     $classes[] = ($wp_query->current_post % 2 == 0) ? 'portfolio-odd' : 'portfolio-even';
  33.     return $classes;
  34.  
  35. }
  36.  
  37. function minimum_portfolio_grid() {
  38.  
  39.     if ( $image = genesis_get_image( 'format=url&size=portfolio' ) ) {
  40.         printf( '<div class="portfolio-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
  41.  
  42.     }
  43.  
  44. }
  45.  
  46. //* Add widget support for homepage if widgets are being used
  47. add_action( 'genesis_meta', 'minimum_front_page_genesis_meta' );
  48. function minimum_front_page_genesis_meta() {
  49.  
  50.     if ( is_home() ) {
  51.  
  52.         //* Remove the entry meta in the entry header
  53.         remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
  54.         remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
  55.         remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
  56.  
  57.         //* Remove the entry content
  58.         remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
  59.  
  60.         //* Remove the entry image
  61.         remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
  62.  
  63.         //* Add the featured image after post title
  64.         add_action( 'genesis_entry_content', 'minimum_portfolio_grid' );
  65.  
  66.         //* Remove entry footer functions
  67.         remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
  68.         remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
  69.         remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
  70.  
  71.         //* Force full width content layout
  72.         add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
  73.  
  74.     }
  75.  
  76.     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' ) ) {
  77.  
  78.         //* Add Home featured Widget areas
  79.         add_action( 'genesis_before_content_sidebar_wrap', 'minimum_home_featured', 15 );
  80.  
  81.     }
  82. }
  83.  
  84. //* Add markup for homepage widgets
  85. function minimum_home_featured() {
  86.  
  87.     printf( '<div %s>', genesis_attr( 'home-featured' ) );
  88.     genesis_structural_wrap( 'home-featured' );
  89.  
  90.         genesis_widget_area( 'home-featured-1', array(
  91.             'before' => '<div class="home-featured-1 widget-area">',
  92.             'after'  => '</div>',
  93.         ) );
  94.  
  95.         genesis_widget_area( 'home-featured-2', array(
  96.             'before' => '<div class="home-featured-2 widget-area">',
  97.             'after'  => '</div>',
  98.         ) );
  99.  
  100.         genesis_widget_area( 'home-featured-3', array(
  101.             'before' => '<div class="home-featured-3 widget-area">',
  102.             'after'  => '</div>',
  103.         ) );
  104.  
  105.         genesis_widget_area( 'home-featured-4', array(
  106.             'before' => '<div class="home-featured-4 widget-area">',
  107.             'after'  => '</div>',
  108.         ) );
  109.  
  110.     genesis_structural_wrap( 'home-featured', 'close' );
  111.     echo '</div>'; //* end .home-featured
  112.  
  113. }
  114.  
  115. //* Run the Genesis loop
  116. genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement