Advertisement
jmgroup

whitespace pro - front-page

Jun 30th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'genesis_meta', 'whitespace_front_page_genesis_meta' );
  4. /**
  5. * Add widget support for homepage. If no widgets active, display the default loop.
  6. *
  7. */
  8. function whitespace_front_page_genesis_meta() {
  9.  
  10. if ( ! is_page() ) {
  11.  
  12. //* Add faux anchors
  13. add_action( 'wp_footer', 'whitespace_script_clickable' );
  14.  
  15. //* Add body class
  16. add_filter( 'body_class', 'whitespace_front_page_body_class' );
  17.  
  18. }
  19. }
  20.  
  21. //* Enqueue scripts for backstretch
  22. add_action( 'wp_enqueue_scripts', 'whitespace_front_page_enqueue_scripts' );
  23. function whitespace_front_page_enqueue_scripts() {
  24.  
  25. $image = get_option( 'whitespace-home-image', sprintf( '%s/images/welcome.jpg', get_stylesheet_directory_uri() ) );
  26.  
  27. //* Load scripts only if custom backstretch image is being used
  28. if ( ! empty( $image ) && is_active_sidebar( 'welcome' ) ) {
  29.  
  30. //* Enqueue Backstretch scripts
  31. wp_enqueue_script( 'whitespace-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
  32. wp_enqueue_script( 'whitespace-backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'whitespace-backstretch' ), '1.0.0' );
  33.  
  34. wp_localize_script( 'whitespace-backstretch-set', 'BackStretchImg', array( 'src' => str_replace( 'http:', '', $image ) ) );
  35.  
  36. }
  37.  
  38. }
  39.  
  40. //* Add JS to allow elements to be faux anchors
  41. function whitespace_script_clickable() {
  42.  
  43. echo '<script type="text/javascript">jQuery(document).ready(function($){$(".content .entry").click(function(){window.location = $(this).find(".entry-title a").attr("href");});});</script>';
  44.  
  45. }
  46.  
  47. //* Add archive body class to the head
  48. function whitespace_front_page_body_class( $classes ) {
  49.  
  50. $classes[] = 'archive';
  51. return $classes;
  52.  
  53. }
  54.  
  55. //* Hook welcome widget area after site header
  56. add_action( 'genesis_after_header', 'whitespace_welcome_widget_area' );
  57. function whitespace_welcome_widget_area() {
  58.  
  59. genesis_widget_area( 'welcome', array(
  60. 'before' => '<div class="welcome">',
  61. 'after' => '</div>',
  62. ) );
  63.  
  64. }
  65.  
  66. //* Relocate entry image
  67. remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
  68.  
  69. //* Run the default Genesis loop
  70. genesis();
  71.  
  72.  
  73. //* Display home image (Featured Image for Posts) above .article-wrap
  74. add_action( 'genesis_entry_header', 'sk_featured_image', 1 );
  75. function sk_featured_image() {
  76.  
  77. if ( ! has_post_thumbnail() ) {
  78. return;
  79. }
  80.  
  81. $image_args = array(
  82. 'size' => 'home-image',
  83. 'format' => 'url'
  84. );
  85.  
  86. // Get the featured image URL
  87. $image = genesis_get_image( $image_args );
  88.  
  89. printf( '<div class="home-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement