front-page.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. /**
  3. * This file adds all the settings for the home page of the Captivating theme.
  4. *
  5. * @package Captivating
  6. * @link http://restored316designs.com/themes
  7. * @author Lauren Gaige // Restored 316 LLC
  8. * @copyright Copyright (c) 2015, Restored 316 LLC, Released 08/09/2017
  9. * @license GPL-2.0+
  10. */
  11. //* Add widget support for homepage. If no widgets active, display the default loop.
  12. add_action( 'genesis_meta', 'captivating_front_page_genesis_meta' );
  13. function captivating_front_page_genesis_meta() {
  14. if ( is_active_sidebar( 'home-featured' ) || is_active_sidebar( 'home-above-content' )|| is_active_sidebar( 'home-below-content' ) ) {
  15. //* Enqueue scripts
  16. add_action( 'wp_enqueue_scripts', 'captivating_enqueue_captivating_script' );
  17. function captivating_enqueue_captivating_script() {
  18. wp_enqueue_style( 'captivating-front-styles', get_stylesheet_directory_uri() . '/style-front.css', array(), CHILD_THEME_VERSION );
  19. }
  20. //* Add body class
  21. add_filter( 'body_class', 'captivating_front_page_body_class' );
  22. //* Force full width content layout
  23. add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
  24. //* Add widgets on top of the front page in the featured space
  25. add_action( 'genesis_after_header', 'captivating_front_page_featured_widgets' );
  26. //* Add widgets on top of the front page
  27. add_action( 'genesis_before_loop', 'captivating_front_page_top_widgets' );
  28. $blog = get_option( 'captivating_blog_setting', 'true' );
  29. if ( $blog === 'true' ) {
  30. //* Add opening markup for blog section
  31. add_action( 'genesis_before_loop', 'captivating_front_page_blog_open' );
  32. //* Add closing markup for blog section
  33. add_action( 'genesis_after_loop', 'captivating_front_page_blog_close' );
  34. } else {
  35. //* Remove the default Genesis loop
  36. remove_action( 'genesis_loop', 'genesis_do_loop' );
  37. }
  38. //* Add widgets on bottom of the front page
  39. add_action( 'genesis_after_loop', 'captivating_front_page_bottom_widgets' );
  40. }
  41. }
  42. //* Add slick carosel
  43. wp_enqueue_style( 'slick-styles', get_stylesheet_directory_uri() . '/css/slick.css' );
  44. wp_enqueue_script( 'slick-js', get_stylesheet_directory_uri() . '/js/slick.min.js', array( 'jquery' ), '1.6.0', true );
  45. wp_enqueue_script( 'slick-init', get_stylesheet_directory_uri() . '/js/slick-init.js', array( 'slick-js' ), '1.0.0', true );
  46. wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css' );
  47. //* Add body class to the head
  48. function captivating_front_page_body_class( $classes ) {
  49. $classes[] = 'front-page';
  50. return $classes;
  51. }
  52. //* Add widgets on front page
  53. function captivating_front_page_featured_widgets() {
  54. if ( get_query_var( 'paged' ) >= 2 )
  55. return;
  56. genesis_widget_area( 'Home Featured', array(
  57. 'before' => '<div id="home-featured" class="home-featured"><div class="wrap">',
  58. 'after' => '</div></div>',
  59. ) );
  60. genesis_widget_area( 'site-wide-cta', array(
  61. 'before' => '<div class="site-wide-cta widget-area"><div class="wrap">',
  62. 'after' => '</div></div>',
  63. ) );
  64. }
  65. //* Add widgets on front page
  66. function captivating_front_page_top_widgets() {
  67. if ( get_query_var( 'paged' ) >= 2 )
  68. return;
  69. genesis_widget_area( 'Home Above Content', array(
  70. 'before' => '<div id="home-above-content" class="home-above-content"><div class="wrap">',
  71. 'after' => '</div></div>',
  72. ) );
  73. }
  74. //* Add widgets on front page
  75. function captivating_front_page_bottom_widgets() {
  76. if ( get_query_var( 'paged' ) >= 2 )
  77. return;
  78. genesis_widget_area( 'Home Below Content', array(
  79. 'before' => '<div id="home-below-content" class="home-below-content"><div class="wrap">',
  80. 'after' => '</div></div>',
  81. ) );
  82. }
  83. //* Add opening markup for blog section
  84. function captivating_front_page_blog_open() {
  85. $blog_text = get_option( 'captivating_blog_text', __( 'Latest from the Blog', 'captivating' ) );
  86. if ( 'posts' == get_option( 'show_on_front' ) ) {
  87. echo '<div class="home-blog widget"><div class="wrap">';
  88. if ( ! empty( $blog_text ) ) {
  89. echo '<h4 class="widget-title">' . $blog_text . '</h4>';
  90. }
  91. }
  92. }
  93. //* Add closing markup for blog section
  94. function captivating_front_page_blog_close() {
  95. if ( 'posts' == get_option( 'show_on_front' ) ) {
  96. echo '</div></div>';
  97. }
  98. }
  99. //* Add archive body class to the head
  100. add_filter( 'body_class', 'captivating_add_archive_body_class' );
  101. function captivating_add_archive_body_class( $classes ) {
  102. $classes[] = 'captivating-blog';
  103. return $classes;
  104. }
  105. //* Remove Featured image (if set in Theme Settings)
  106. add_filter( 'genesis_pre_get_option_content_archive_thumbnail', 'captivating_no_post_image' );
  107. function captivating_no_post_image() {
  108. return '0';
  109. }
  110. //* Show Excerpts regardless of Theme Settings
  111. add_filter( 'genesis_pre_get_option_content_archive', 'captivating_show_excerpts' );
  112. function captivating_show_excerpts() {
  113. return 'excerpts';
  114. }
  115. //* Modify the length of post excerpts
  116. add_filter( 'excerpt_length', 'captivating_excerpt_length' );
  117. function captivating_excerpt_length( $length ) {
  118. return 60; // pull first 50 words
  119. }
  120. //* Modify the Excerpt read more link
  121. add_filter('excerpt_more', 'captivating_new_excerpt_more');
  122. function captivating_new_excerpt_more($more) {
  123. return '... <br><a class="more-link" href="' . get_permalink() . '">Read More</a>';
  124. }
  125. //* Make sure content limit (if set in Theme Settings) doesn't apply
  126. add_filter( 'genesis_pre_get_option_content_archive_limit', 'captivating_no_content_limit' );
  127. function captivating_no_content_limit() {
  128. return '0';
  129. }
  130. //* Display centered wide featured image for First Post and left aligned thumbnail for the next five
  131. add_action( 'genesis_entry_header', 'captivating_show_featured_image', 8 );
  132. function captivating_show_featured_image() {
  133. if ( ! has_post_thumbnail() ) {
  134. return;
  135. }
  136. global $wp_query;
  137. if( ( $wp_query->current_post <= 0 ) ) {
  138. $image_args = array(
  139. 'size' => 'horizontal-entry-image',
  140. 'attr' => array(
  141. 'class' => 'aligncenter',
  142. ),
  143. );
  144. } else {
  145. $image_args = array(
  146. 'size' => 'square-entry-image',
  147. 'attr' => array(
  148. 'class' => 'alignleft',
  149. ),
  150. );
  151. }
  152. $image = genesis_get_image( $image_args );
  153. echo '<div class="home-featured-image"><a href="' . get_permalink() . '">' . $image .'</a></div>';
  154. }
  155. //* Remove entry meta
  156. remove_action( 'genesis_entry_header', 'genesis_post_info', 9 );
  157. //* Run the default Genesis loop
  158. genesis();