<?php
/**
 * Tattoopress post hook functions
 *
 * @package WordPress
 * @subpackage Tattoopress
 * @version 3.3.4
 */

defined( 'ABSPATH' ) || exit;

if ( ! function_exists( 'tattoopress_single_header_post_meta' ) ) {
	/**
	 * Header post meta
	 */
	function tattoopress_single_header_post_meta() {

		global $post, $wp_query;
		$post_id    = get_the_ID();
		$output     = '';
		$desc       = '';
		$subheading = tattoopress_get_the_subheading();
		if ( tattoopress_is_home_as_blog() ) {
			$desc = '';
		}

		/* Search result count */
		if ( is_search() ) {

			global $wp_query;

			if ( $wp_query && is_object( $wp_query ) && isset( $wp_query->found_posts ) ) {
				$subheading = sprintf(
				/* translators: 1: number of comments, 2: post title */
					_n(
						'%d result',
						'%d results',
						'tattoopress'
					),
					$wp_query->found_posts
				);
			}
		}
		if ( is_tax() ) {

			$queried_object = get_queried_object();

			if ( is_object( $queried_object ) && isset( $queried_object->name ) ) {
				$desc = get_queried_object()->description;
			}
		}

		if ( is_category() ) {
			$cat_id = get_the_category();
			$desc   = category_description( $cat_id[0] );
		}

		if ( $desc ) {
			$output .= '<div class="description">' . sanitize_text_field( apply_filters( 'tattoopress_post_description', $desc ) ) . '</div><!--.description-->';
		}

		if ( $subheading ) {
			$output .= '<div class="subheading">' . apply_filters( 'tattoopress_post_subheading', $subheading ) . '</div>';
		}

		if ( is_singular( 'post' ) ) {

			if ( 'human_diff' === tattoopress_get_theme_mod( 'date_format' ) ) {
				/* translators: %s: the date */
				$output .= sprintf( esc_html__( 'Posted %s', 'tattoopress' ), tattoopress_entry_date( false ) );
			} else {
				/* translators: %s: the date */
				$output .= sprintf( esc_html__( 'Posted On %s', 'tattoopress' ), tattoopress_entry_date( false ) );
			}

			if ( tattoopress_get_first_category() ) {
				$output .= '<span class="post-meta-separator"></span>';

				$output .= sprintf(
					/* translators: 1: first category URL, 2: the first category name as title attribute, 3: the first category name */
					tattoopress_kses( __( 'In <a href="%1$s" title="View all posts in the %2$s category">%3$s</a>', 'tattoopress' ) ),
					esc_url( tattoopress_get_first_category_url() ),
					esc_attr( tattoopress_get_first_category() ),
					esc_attr( tattoopress_get_first_category() )
				);
			}

			if (
			is_multi_author() &&
			get_the_author() ) {
				$output .= '<span class="post-meta-separator"></span>';

				$output .= '<span class="author-meta">';

				$output .= sprintf(
					'<span id="post-title-author">by <span class="author vcard">
				<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span></span>',
					esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
					esc_attr( sprintf( __( 'View all posts by %s', 'tattoopress' ), get_the_author() ) ),
					get_the_author()
				);
				$output .= '</span>';
			}
		} // end if post.

		elseif ( is_singular( 'work' ) ) {

			$output .= get_the_term_list( $post_id, 'work_type', esc_html__( 'In', 'tattoopress' ) . ' ', esc_html__( ', ', 'tattoopress' ), '' );

		} elseif ( is_singular( 'gallery' ) ) {

			$term_list = get_the_term_list( $post_id, 'gallery_type', esc_html__( 'In', 'tattoopress' ) . ' ', esc_html__( ', ', 'tattoopress' ), '' );

			$output .= $term_list;

			if ( $term_list ) {
				$output .= '<span class="post-meta-separator"></span>';
			}

			$output .= sprintf(
				__( '<a class="scroll link" href="#content">%d Photos</a>', 'tattoopress' ),
				tattoopress_get_first_gallery_image_count()
			);

		} elseif ( is_singular( 'product' ) ) {

			$output .= get_the_term_list(
				$post_id,
				'product_cat',
				esc_html__( 'In', 'tattoopress' ) . ' ',
				esc_html__( ', ', 'tattoopress' )
			);

		}

		echo tattoopress_kses( $output );
	}
	add_action( 'tattoopress_hero_meta', 'tattoopress_single_header_post_meta' );
} // end function check

/**
 * Add custom post meta above and below the post content
 */
function tattoopress_add_custom_post_meta() {
	if ( is_singular( 'post' ) ) {
		if ( ! tattoopress_is_vc() || 'wvc-single-post-sidebar' === tattoopress_get_single_post_wvc_layout() ) {
			tattoopress_get_extra_meta();
		}
	}
}
add_action( 'tattoopress_post_content_start', 'tattoopress_add_custom_post_meta' );

/**
 * Add share buttons above and below the post content
 */
function tattoopress_add_share_buttons() {

	if ( function_exists( 'wolf_share' ) && function_exists( 'wolf_share_get_option' ) ) {

		$enabled_post_types = ( wolf_share_get_option( 'post_types' ) ) ? wolf_share_get_option( 'post_types' ) : array();
		$current_post_type  = get_post_type();

		if ( isset( $enabled_post_types[ $current_post_type ] ) ) {

			if ( is_singular( 'product' ) ) {
				echo '<hr>';
			}

			wp_enqueue_style( 'socicon' );

			wolf_share();
		}
	}
}
add_action( 'tattoopress_share', 'tattoopress_add_share_buttons' );
add_action( 'tattoopress_post_content_end', 'tattoopress_add_share_buttons', 15 );
add_action( 'tattoopress_work_meta', 'tattoopress_add_share_buttons', 15 ); // display in single work.
add_action( 'woocommerce_share', 'tattoopress_add_share_buttons' ); // display in single product.
add_action( 'wpm_playlist_post_end', 'tattoopress_add_share_buttons' ); // display in single playlist.

/**
 * Add work taxonomy above title
 *
 * @return void
 */
function tattoopress_add_work_taxonomy( $template_args ) {
	extract(
		wp_parse_args(
			$template_args,
			array(
				'layout'                    => '',
				'overlay_color'             => 'auto',
				'overlay_custom_color'      => '',
				'overlay_opacity'           => 88,
				'overlay_text_color'        => '',
				'overlay_text_custom_color' => '',
				'work_is_gallery'           => '',
				'custom_thumbnail_size'     => '',
			)
		)
	);

	$text_style = '';

	if ( $overlay_text_color && 'overlay' === $layout ) {
		$text_color = tattoopress_convert_color_class_to_hex_value( $overlay_text_color, $overlay_text_custom_color );
		if ( $text_color ) {
			$text_style .= 'color:' . tattoopress_sanitize_color( $text_color ) . ';';
		}
	}
	?>
	<div style="<?php echo tattoopress_esc_style_attr( $text_style ); ?>" class="entry-taxonomy">
		<?php echo get_the_term_list( get_the_ID(), 'work_type', '', ' <span class="work-taxonomy-separator">/</span> ', '' ); ?>
	</div><!-- .entry-taxonomy -->
	<?php
}
add_action( 'tattoopress_work_grid_summary_end', 'tattoopress_add_work_taxonomy', 10, 1 );
add_action( 'tattoopress_work_masonry_summary_end', 'tattoopress_add_work_taxonomy', 10, 1 );
add_action( 'tattoopress_work_metro_summary_end', 'tattoopress_add_work_taxonomy', 10, 1 );

/**
 * Set work entry background image
 *
 * @param array $template_args The display options.
 */
function tattoopress_set_work_entry_background( $template_args, $display = 'grid' ) {
	$thumbnail_size        = ( isset( $template_args['thumbnail_size'] ) ) ? $template_args['thumbnail_size'] : 'standard';
	$custom_thumbnail_size = ( isset( $template_args['custom_thumbnail_size'] ) ) ? $template_args['custom_thumbnail_size'] : null;

	if ( 'custom' === $thumbnail_size && $custom_thumbnail_size ) {
		$thumbnail_size = $custom_thumbnail_size;
	} else {
		$thumbnail_size = tattoopress_convert_img_size_name( $thumbnail_size );
	}

	$padding_bottom = tattoopress_convert_img_dimension_percent_ratio( $thumbnail_size );
	if ( 'masonry' === $display ) {
		?>
		<div class="entry-image">
			<?php
				/**
				 * Thumbnail
				 */

				the_post_thumbnail( $thumbnail_size );
			?>
		</div>
		<?php
	} elseif ( 'metro' === $display ) {
		?>
			<div class="entry-image">
				<div class="entry-cover">
					<?php
						$metro_size = apply_filters( 'tattoopress_metro_thumbnail_size', '680x680' );

						if ( $featured || tattoopress_is_latest_post( 'work' ) ) {
							$metro_size = 'large';
						}

						$size = ( tattoopress_is_gif( get_post_thumbnail_id() ) ) ? 'full' : $metro_size;

						echo tattoopress_background_img( array( 'background_img_size' => $size ) );
						remove_filter( 'tattoopress_metro_thumbnail_size', 10, 1 );
					?>
				</div><!-- entry-cover -->
			</div>
		<?php
	} else {
		echo '<div class="entry-image"><div class="entry-cover" style="padding-bottom:' . esc_attr( $padding_bottom ) . '">';
		if ( tattoopress_is_gif( get_post_thumbnail_id() ) ) {
			echo tattoopress_background_img( array( 'background_img_size' => 'full' ) );
		} else {
			tattoopress_resized_thumbnail( $thumbnail_size, 'img-bg' );
		}
		echo '</div></div>';
	}
}
add_action( 'tattoopress_work_bg', 'tattoopress_set_work_entry_background', 10, 2 );

/**
 * Output author box
 */
function tattoopress_output_author_box() {

	if ( 'yes' === tattoopress_get_theme_mod( 'post_author_box', 'yes' ) ) {
		if ( 'post' === get_post_type() ) {
			get_template_part( tattoopress_get_template_dirname() . '/components/post/author' );
		}
	}
}
add_action( 'tattoopress_post_content_after', 'tattoopress_output_author_box' );

/**
 * Output related posts
 */
function tattoopress_output_related_posts() {

	if ( 'yes' === tattoopress_get_theme_mod( 'post_related_posts', 'yes' ) ) {
		if ( 'post' === get_post_type() ) {
			get_template_part( tattoopress_get_template_dirname() . '/components/post/related', 'posts' );
		}
	}
}
add_action( 'tattoopress_post_content_after', 'tattoopress_output_related_posts', 20 );

/**
 * Output related posts
 */
function tattoopress_output_related_post_content() {
	?>
	<div class="entry-box">
		<div class="entry-container">
			<a href="<?php the_permalink(); ?>" class="entry-link">
				<?php the_post_thumbnail( apply_filters( 'tattoopress_related_post_thumbnail_size', 'medium_large' ), array( 'class' => 'entry-bg cover' ) ); ?>
				<div class="entry-overlay"></div>
				<div class="entry-inner">
					<div class="entry-summary">
						<?php the_title( '<h4 class="entry-title">', '</h4>' ); ?>
						<span class="entry-date">
							<?php tattoopress_entry_date(); ?>
						</span>
					</div><!-- .entry-summary -->
				</div><!-- .entry-inner -->
			</a>
		</div><!-- .entry-container -->
	</div><!-- .entry-box -->
	<?php
}
add_action( 'tattoopress_related_post_content', 'tattoopress_output_related_post_content' );

/**
 * Remove share buttons filter
 *
 * This is will allow more control for where we want to output the share buttons
 */
function tattoopress_remove_share_buttons_filter() {
	remove_filter( 'the_content', 'wolf_share_output_social_buttons' );
}
add_action( 'init', 'tattoopress_remove_share_buttons_filter' );

/**
 * Remove custom post meta filter
 *
 * This is will allow more control for where we want to output the share buttons
 */
function tattoopress_remove_custom_post_meta_filter() {
	remove_filter( 'the_content', 'wolf_output_custom_post_meta' );
}
add_action( 'init', 'tattoopress_remove_custom_post_meta_filter' );

/**
 * Newsletter form
 */
function tattoopress_add_newsletter_form() {

	if (
		function_exists( 'wvc_mailchimp' )
		&& tattoopress_get_theme_mod( 'newsletter_form_single_blog_post' )
		&& is_singular( 'post' )
	) {
		$list_id = wolf_vc_get_option( 'mailchimp', 'default_mailchimp_list_id' );
		?>
		<section class="newsletter-container entry-section clearfix">
			<div class="newsletter-signup">
				<?php
				echo wvc_mailchimp( // WCS XSS ok.
					array(
						'size'                => 'large',
						'submit_button_class' => apply_filters( 'tattoopress_mc_submit_button_class', 'theme-button-outline' ),
					)
				);
				?>
			</div><!-- .newsletter-signup -->
		</section><!-- .newsletter-container -->
		<?php
	}

	if (
		function_exists( 'wolf_core_mailchimp' )
		&& tattoopress_get_theme_mod( 'newsletter_form_single_blog_post' )
		&& is_singular( 'post' )
	) {
		$list_id = wolf_core_get_option( 'mailchimp', 'default_mailchimp_list_id' );
		?>
		<section class="newsletter-container entry-section clearfix">
			<div class="newsletter-signup">
				<?php
				echo wolf_core_mailchimp( // WCS XSS ok.
					array(
						'size'                => 'large',
						'submit_button_class' => apply_filters( 'tattoopress_mc_submit_button_class', 'theme-button-outline' ),
					)
				);
				?>
			</div><!-- .newsletter-signup -->
		</section><!-- .newsletter-container -->
		<?php
	}
}
add_action( 'tattoopress_post_content_after', 'tattoopress_add_newsletter_form', 12 );

/**
 * Output single post pagination
 */
function tattoopress_output_single_post_pagination() {

	if ( is_singular( 'event' ) || is_singular( 'proof_gallery' ) || is_singular( 'attachment' ) ) {
		return; // event are ordered by custom date so it's better to hide the pagination.
	}

	if ( apply_filters( 'tattoopress_disable_single_post_pagination', false ) ) {
		return;
	}

	global $post;
	$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
	$next     = get_adjacent_post( false, '', false );

	if ( ! $next && ! $previous || ! is_single() || 'wvc_content_block' === get_post_type() ) {
		return;
	}

	$index_url = tattoopress_get_blog_url();
	$index_id  = tattoopress_get_blog_index_id();

	if ( 'work' === get_post_type() && function_exists( 'wolf_portfolio_get_page_id' ) && function_exists( 'wolf_get_portfolio_url' ) ) {
		$index_id  = wolf_portfolio_get_page_id();
		$index_url = wolf_get_portfolio_url();
	}

	if ( 'gallery' === get_post_type() && function_exists( 'wolf_albums_get_page_id' ) && function_exists( 'wolf_get_albums_url' ) ) {
		$index_id  = wolf_albums_get_page_id();
		$index_url = wolf_get_albums_url();
	}

	if ( 'video' === get_post_type() && function_exists( 'wolf_videos_get_page_id' ) && function_exists( 'wolf_get_videos_url' ) ) {
		$index_id  = wolf_videos_get_page_id();
		$index_url = wolf_get_videos_url();
	}

	if ( 'event' === get_post_type() && function_exists( 'wolf_events_get_page_id' ) && function_exists( 'wolf_get_events_url' ) ) {
		$index_id  = wolf_events_get_page_id();
		$index_url = wolf_get_events_url();
	}

	if ( 'release' === get_post_type() && function_exists( 'wolf_discography_get_page_id' ) && function_exists( 'wolf_discography_get_page_link' ) ) {
		$index_id  = wolf_discography_get_page_id();
		$index_url = wolf_discography_get_page_link();
	}

	if ( 'product' === get_post_type() && function_exists( 'tattoopress_get_woocommerce_shop_page_id' ) ) {
		$index_id  = tattoopress_get_woocommerce_shop_page_id();
		$index_url = get_permalink( tattoopress_get_woocommerce_shop_page_id() );
	}

	$prev_post = get_previous_post();
	$next_post = get_next_post();

	$prev_post_id = ( is_object( $prev_post ) && isset( $prev_post->ID ) ) ? $prev_post->ID : null;
	$next_post_id = ( is_object( $next_post ) && isset( $next_post->ID ) ) ? $next_post->ID : null;

	$index_post_featured_img_id = ( $index_id && get_post_thumbnail_id( $index_id ) ) ? get_post_thumbnail_id( $index_id ) : tattoopress_get_hero_image_id();
	$prev_post_featured_img_id  = ( $prev_post_id ) ? get_post_thumbnail_id( $prev_post_id ) : null;
	$next_post_featured_img_id  = ( $next_post_id ) ? get_post_thumbnail_id( $next_post_id ) : null;

	$index_class = 'nav-index';
	$prev_class  = 'nav-previous';
	$next_class  = 'nav-next';

	if ( apply_filters( 'tattoopress_enable_single_post_pagination_backgrounds', true ) ) {
		if ( $index_post_featured_img_id && tattoopress_background_img( array( 'background_img' => $index_post_featured_img_id ) ) ) {
			$index_class .= ' nav-has-bg';
		}

		if ( $prev_post_featured_img_id && tattoopress_background_img( array( 'background_img' => $prev_post_featured_img_id ) ) ) {
			$prev_class .= ' nav-has-bg';
		}

		if ( $next_post_featured_img_id && tattoopress_background_img( array( 'background_img' => $next_post_featured_img_id ) ) ) {
			$next_class .= ' nav-has-bg';
		}
	}
	?>
	<nav class="single-post-pagination clearfix">
		<div class="<?php echo tattoopress_sanitize_html_classes( $prev_class ); ?>">
			<?php
			if ( apply_filters( 'tattoopress_enable_single_post_pagination_backgrounds', true ) ) {
				/**
				 * BG
				 */
				echo tattoopress_background_img( array( 'background_img' => $prev_post_featured_img_id ) );
			}
			?>
			<?php previous_post_link( '%link', '<span class="nav-label"><i class="meta-icon single-pagination-prev" aria-hidden="true"></i> ' . esc_html__( 'Previous', 'tattoopress' ) . '</span><span class="meta-nav"></span> %title' ); ?>
		</div><!-- .nav-previous -->
		<div class="<?php echo tattoopress_sanitize_html_classes( $index_class ); ?>">
			<?php
			if ( apply_filters( 'tattoopress_enable_single_post_pagination_backgrounds', true ) ) {
				/**
				 * BG
				 */
				echo tattoopress_background_img( array( 'background_img' => $index_post_featured_img_id ) );
			}
			?>
			<a href="<?php echo esc_url( $index_url ); ?>">
				<!-- <i class="fa fa-th-large" aria-hidden="true"></i> -->
				<span class="nav-index-icon"> <?php esc_html_e( 'Main Page', 'tattoopress' ); ?></span>
			</a>
		</div>
		<div class="<?php echo tattoopress_sanitize_html_classes( $next_class ); ?>">
			<?php
			if ( apply_filters( 'tattoopress_enable_single_post_pagination_backgrounds', true ) ) {
				/**
				 * BG
				 */
				echo tattoopress_background_img( array( 'background_img' => $next_post_featured_img_id ) );
			}
			?>
			<?php next_post_link( '%link', '<span class="nav-label">' . esc_html__( 'Next', 'tattoopress' ) . ' <i class="meta-icon single-pagination-next" aria-hidden="true"></i></span> %title <span class="meta-nav"></span>' ); ?>
		</div><!-- .nav-next -->
	</nav><!-- .single-post-pagination -->
	<?php
}
add_action( 'tattoopress_before_footer_block', 'tattoopress_output_single_post_pagination', 14 );

/**
 * Output categories & tags below single post content
 */
function tattoopress_ouput_single_post_taxonomy() {

	if ( 'post' !== get_post_type() ) {
		return;
	}

	echo '<div class="single-post-taxonomy-container clearfix">';
		echo '<span class="single-post-taxonomy categories single-post-categories">';
			the_category( ' ' );
		echo '</span>';
		the_tags( '<span class="single-post-taxonomy tagcloud single-post-tagcloud">', '', '</span>' );
	echo '</div><!-- .single-post-taxonomy -->';

}
add_action( 'tattoopress_post_content_end', 'tattoopress_ouput_single_post_taxonomy' );

/**
 * Output modern grid slideshow arrows
 */
function tattoopress_output_post_grid_slideshow_arrows() {
	?>
	<div class="slideshow-gallery-direction-nav">
		<a href="#" class="slideshow-gallery-direction-nav-prev">
			<span class="slideshow-gallery-direction-nav-prev-icon"></span>
		</a>
		<a href="#" class="slideshow-gallery-direction-nav-next">
			<span class="slideshow-gallery-direction-nav-next-icon"></span>
		</a>
	</div>
	<?php
}
add_action( 'tattoopress_post_grid_slideshow_arrows', 'tattoopress_output_post_grid_slideshow_arrows' );

/**
 * Add custom post meta above and below the post content
 */
function tattoopress_add_vc_post_custom_post_meta() {
	if ( is_singular( 'post' ) ) {
		if ( 'wvc-single-post-fullwidth' === tattoopress_get_single_post_wvc_layout() ) {
			tattoopress_get_extra_meta();
		}
	}
}
add_action( 'tattoopress_post_content_end', 'tattoopress_add_vc_post_custom_post_meta' );

/**
 * Output single post bottom separator
 */
function tattoopress_ouput_single_post_end_separator() {

	echo '<hr class="single-post-bottom-line">';

}
add_action( 'tattoopress_post_content_end', 'tattoopress_ouput_single_post_end_separator', 100 );

/**
 * Output work single post meta
 */
function tattoopress_ouput_work_meta() {
	/**
	 * Work meta
	 */
	if ( function_exists( 'tattoopress_work_meta' ) ) {
		tattoopress_work_meta();
	}

}
add_action( 'tattoopress_work_meta', 'tattoopress_ouput_work_meta' );

/**
 * Output release single post meta
 */
function tattoopress_ouput_release_meta() {
	/**
	 * Release meta
	 */
	if ( function_exists( 'tattoopress_release_meta' ) ) {
		tattoopress_release_meta();
	}

}
add_action( 'tattoopress_release_meta', 'tattoopress_ouput_release_meta' );

/**
 * Output artist single post meta
 */
function tattoopress_ouput_artist_meta() {

	if ( function_exists( 'tattoopress_artist_meta' ) ) {
		tattoopress_artist_meta();
	}

}
add_action( 'tattoopress_artist_meta', 'tattoopress_ouput_artist_meta' );

/**
 * Output artist single post content
 */
function tattoopress_ouput_artist_content() {

	if ( function_exists( 'tattoopress_artist_content' ) ) {
		tattoopress_artist_content();
	}

}
add_action( 'tattoopress_artist_content', 'tattoopress_ouput_artist_content' );

/**
 * Output post grid summary
 */
function tattoopress_output_post_grid_summary() {

	$format = get_post_format();

	if ( tattoopress_is_short_post_format() || 'audio' === $format ) {
		?>
		<div class="entry-image">
			<div class="entry-cover">
				<?php
					echo tattoopress_background_img(
						array(
							'background_img_size'  => 'large',
							'placeholder_fallback' => true,
						)
					);
				?>
			</div><!-- entry-cover -->
		</div>
		<?php
	}

	if ( 'image' === $format && tattoopress_is_instagram_post() ) {

		echo tattoopress_get_instagram_image();

		if ( tattoopress_get_author_instagram_username() ) {
			echo '<span class="insta-username">' . tattoopress_get_author_instagram_username() . '</span>';
		}
	} elseif ( 'gallery' === $format && tattoopress_background_slideshow() ) {

		echo tattoopress_background_slideshow(
			array(
				'slideshow_image_size' => '1200x1024',
				'slideshow_img_count'  => 3,
			)
		);

		do_action( 'tattoopress_post_grid_slideshow_arrows' );

		tattoopress_post_grid_entry_title();

	} elseif ( 'video' === $format ) {

		if ( tattoopress_background_video() ) { // if we can get a video background
			echo tattoopress_background_video();
		}
		tattoopress_post_grid_entry_title();

	} elseif ( 'audio' === $format && tattoopress_featured_media() ) {

		tattoopress_post_grid_entry_title();

	} elseif ( 'aside' === $format || 'status' === $format ) {

		tattoopress_post_grid_entry_title( tattoopress_sample( get_the_content(), 30 ) );

	} elseif ( 'quote' === $format ) {

		tattoopress_post_grid_entry_title( tattoopress_get_first_quote() );

	} elseif ( 'link' === $format ) {

		tattoopress_post_grid_entry_title();

	} else { // most likely standard format.
		?>
	<div class="entry-image">
		<div class="entry-cover">
			<?php
				echo tattoopress_background_img(
					array(
						'background_img_size'  => 'large',
						'placeholder_fallback' => true,
					)
				);
			?>
		</div><!-- entry-cover -->
	</div>
		<?php tattoopress_post_grid_entry_title(); ?>
		<?php
	}
}
add_action( 'tattoopress_post_grid_summary', 'tattoopress_output_post_grid_summary' );

/**
 * Post Grid classic excerpt
 */
function tattoopress_output_post_grid_classic_excerpt( $post_excerpt_length ) {

	if ( 'full' === $post_excerpt_length ) :
		?>
		<p><?php echo tattoopress_sample( get_the_excerpt(), 1000 ); ?></p>
	<?php else : ?>
		<p><?php echo tattoopress_sample( get_the_excerpt(), tattoopress_get_excerpt_lenght() ); ?></p>
		<?php
	endif;
}
add_action( 'tattoopress_post_grid_classic_excerpt', 'tattoopress_output_post_grid_classic_excerpt', 10, 1 );
add_action( 'tattoopress_post_grid_excerpt', 'tattoopress_output_post_grid_classic_excerpt', 10, 1 );

/**
 * Post Grid classic excerpt
 */
function tattoopress_output_post_masonry_excerpt( $post_excerpt_length ) {

	if ( 'full' === $post_excerpt_length ) :
		?>
		<p><?php echo tattoopress_sample( get_the_excerpt(), 1000 ); ?></p>
	<?php elseif ( is_numeric( $post_excerpt_length ) ) : ?>
		<p><?php echo tattoopress_sample( get_the_excerpt(), absint( $post_excerpt_length ) ); ?></p>
	<?php else : ?>
		<p><?php echo tattoopress_sample( get_the_excerpt(), tattoopress_get_excerpt_lenght() ); ?></p>
		<?php
	endif;
}
add_action( 'tattoopress_post_masonry_excerpt', 'tattoopress_output_post_masonry_excerpt', 10, 1 );
add_action( 'tattoopress_post_metro_excerpt', 'tattoopress_output_post_masonry_excerpt', 10, 1 );
add_action( 'tattoopress_post_search_excerpt', 'tattoopress_output_post_masonry_excerpt', 10, 1 );

/**
 * Output the excerpt
 *
 * @param string $post_excerpt_type
 */
function tattoopress_output_the_excerpt( $post_excerpt_type ) {

	/* Case page builder is used */
	if ( preg_match( '#vc_row#', get_the_content() ) || tattoopress_is_elementor_page() ) {

		$content = ( get_the_excerpt() ) ? get_the_excerpt() : get_the_content();
		echo '<p>' . tattoopress_sample( $content, 100 ) . '...</p>';

		if ( $content ) {
			echo '<p>' . tattoopress_more_button() . '</p>';
		}

	} else {

		if ( 'auto' === $post_excerpt_type ) {

			echo '<p>';
			echo get_the_excerpt();
			echo '</p>';

		} else {
			echo tattoopress_content( tattoopress_more_text() );
		}
	}
}
add_action( 'tattoopress_the_excerpt', 'tattoopress_output_the_excerpt', 10, 1 );
