123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <?php
- /**
- * This file adds all the settings for the home page of the Captivating theme.
- *
- * @package Captivating
- * @link http://restored316designs.com/themes
- * @author Lauren Gaige // Restored 316 LLC
- * @copyright Copyright (c) 2015, Restored 316 LLC, Released 08/09/2017
- * @license GPL-2.0+
- */
- //* Add widget support for homepage. If no widgets active, display the default loop.
- add_action( 'genesis_meta', 'captivating_front_page_genesis_meta' );
- function captivating_front_page_genesis_meta() {
- if ( is_active_sidebar( 'home-featured' ) || is_active_sidebar( 'home-above-content' )|| is_active_sidebar( 'home-below-content' ) ) {
-
- //* Enqueue scripts
- add_action( 'wp_enqueue_scripts', 'captivating_enqueue_captivating_script' );
- function captivating_enqueue_captivating_script() {
- wp_enqueue_style( 'captivating-front-styles', get_stylesheet_directory_uri() . '/style-front.css', array(), CHILD_THEME_VERSION );
- }
- //* Add body class
- add_filter( 'body_class', 'captivating_front_page_body_class' );
-
- //* Force full width content layout
- add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
-
- //* Add widgets on top of the front page in the featured space
- add_action( 'genesis_after_header', 'captivating_front_page_featured_widgets' );
-
- //* Add widgets on top of the front page
- add_action( 'genesis_before_loop', 'captivating_front_page_top_widgets' );
-
- $blog = get_option( 'captivating_blog_setting', 'true' );
- if ( $blog === 'true' ) {
- //* Add opening markup for blog section
- add_action( 'genesis_before_loop', 'captivating_front_page_blog_open' );
- //* Add closing markup for blog section
- add_action( 'genesis_after_loop', 'captivating_front_page_blog_close' );
-
- } else {
- //* Remove the default Genesis loop
- remove_action( 'genesis_loop', 'genesis_do_loop' );
- }
-
- //* Add widgets on bottom of the front page
- add_action( 'genesis_after_loop', 'captivating_front_page_bottom_widgets' );
- }
- }
- //* Add slick carosel
- wp_enqueue_style( 'slick-styles', get_stylesheet_directory_uri() . '/css/slick.css' );
- wp_enqueue_script( 'slick-js', get_stylesheet_directory_uri() . '/js/slick.min.js', array( 'jquery' ), '1.6.0', true );
- wp_enqueue_script( 'slick-init', get_stylesheet_directory_uri() . '/js/slick-init.js', array( 'slick-js' ), '1.0.0', true );
- wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css' );
- //* Add body class to the head
- function captivating_front_page_body_class( $classes ) {
- $classes[] = 'front-page';
- return $classes;
- }
- //* Add widgets on front page
- function captivating_front_page_featured_widgets() {
- if ( get_query_var( 'paged' ) >= 2 )
- return;
- genesis_widget_area( 'Home Featured', array(
- 'before' => '<div id="home-featured" class="home-featured"><div class="wrap">',
- 'after' => '</div></div>',
- ) );
-
- genesis_widget_area( 'site-wide-cta', array(
- 'before' => '<div class="site-wide-cta widget-area"><div class="wrap">',
- 'after' => '</div></div>',
- ) );
- }
- //* Add widgets on front page
- function captivating_front_page_top_widgets() {
- if ( get_query_var( 'paged' ) >= 2 )
- return;
- genesis_widget_area( 'Home Above Content', array(
- 'before' => '<div id="home-above-content" class="home-above-content"><div class="wrap">',
- 'after' => '</div></div>',
- ) );
- }
- //* Add widgets on front page
- function captivating_front_page_bottom_widgets() {
- if ( get_query_var( 'paged' ) >= 2 )
- return;
-
- genesis_widget_area( 'Home Below Content', array(
- 'before' => '<div id="home-below-content" class="home-below-content"><div class="wrap">',
- 'after' => '</div></div>',
- ) );
- }
- //* Add opening markup for blog section
- function captivating_front_page_blog_open() {
- $blog_text = get_option( 'captivating_blog_text', __( 'Latest from the Blog', 'captivating' ) );
-
- if ( 'posts' == get_option( 'show_on_front' ) ) {
- echo '<div class="home-blog widget"><div class="wrap">';
- if ( ! empty( $blog_text ) ) {
- echo '<h4 class="widget-title">' . $blog_text . '</h4>';
- }
- }
- }
- //* Add closing markup for blog section
- function captivating_front_page_blog_close() {
- if ( 'posts' == get_option( 'show_on_front' ) ) {
- echo '</div></div>';
- }
- }
- //* Add archive body class to the head
- add_filter( 'body_class', 'captivating_add_archive_body_class' );
- function captivating_add_archive_body_class( $classes ) {
- $classes[] = 'captivating-blog';
- return $classes;
- }
-
- //* Remove Featured image (if set in Theme Settings)
- add_filter( 'genesis_pre_get_option_content_archive_thumbnail', 'captivating_no_post_image' );
- function captivating_no_post_image() {
- return '0';
- }
- //* Show Excerpts regardless of Theme Settings
- add_filter( 'genesis_pre_get_option_content_archive', 'captivating_show_excerpts' );
- function captivating_show_excerpts() {
- return 'excerpts';
- }
- //* Modify the length of post excerpts
- add_filter( 'excerpt_length', 'captivating_excerpt_length' );
- function captivating_excerpt_length( $length ) {
- return 60; // pull first 50 words
- }
- //* Modify the Excerpt read more link
- add_filter('excerpt_more', 'captivating_new_excerpt_more');
- function captivating_new_excerpt_more($more) {
- return '... <br><a class="more-link" href="' . get_permalink() . '">Read More</a>';
- }
- //* Make sure content limit (if set in Theme Settings) doesn't apply
- add_filter( 'genesis_pre_get_option_content_archive_limit', 'captivating_no_content_limit' );
- function captivating_no_content_limit() {
- return '0';
- }
- //* Display centered wide featured image for First Post and left aligned thumbnail for the next five
- add_action( 'genesis_entry_header', 'captivating_show_featured_image', 8 );
- function captivating_show_featured_image() {
- if ( ! has_post_thumbnail() ) {
- return;
- }
- global $wp_query;
- if( ( $wp_query->current_post <= 0 ) ) {
- $image_args = array(
- 'size' => 'horizontal-entry-image',
- 'attr' => array(
- 'class' => 'aligncenter',
- ),
- );
-
- } else {
- $image_args = array(
- 'size' => 'square-entry-image',
- 'attr' => array(
- 'class' => 'alignleft',
- ),
- );
- }
- $image = genesis_get_image( $image_args );
- echo '<div class="home-featured-image"><a href="' . get_permalink() . '">' . $image .'</a></div>';
-
- }
- //* Remove entry meta
- remove_action( 'genesis_entry_header', 'genesis_post_info', 9 );
- //* Run the default Genesis loop
- genesis();
|