/**
* The template to display single post
*
* @package TRIPSTER
* @since TRIPSTER 1.0
*/
// Full post loading
$full_post_loading = tripster_get_value_gp( 'action' ) == 'full_post_loading';
// Prev post loading
$prev_post_loading = tripster_get_value_gp( 'action' ) == 'prev_post_loading';
$prev_post_loading_type = tripster_get_theme_option( 'posts_navigation_scroll_which_block' );
// Position of the related posts
$tripster_related_position = tripster_get_theme_option( 'related_position' );
// Type of the prev/next posts navigation
$tripster_posts_navigation = tripster_get_theme_option( 'posts_navigation' );
$tripster_prev_post = false;
// Rewrite style of the single post if current post loading via AJAX and featured image and title is not in the content
if ( ( $full_post_loading
||
( $prev_post_loading && 'article' == $prev_post_loading_type )
)
&&
! in_array( tripster_get_theme_option( 'single_style' ), array( 'style-6' ) )
) {
tripster_storage_set_array( 'options_meta', 'single_style', 'style-6' );
}
while ( have_posts() ) {
the_post();
// Type of the prev/next posts navigation
if ( 'scroll' == $tripster_posts_navigation ) {
$tripster_prev_post = get_previous_post( true ); // Get post from same category
if ( ! $tripster_prev_post ) {
$tripster_prev_post = get_previous_post( false ); // Get post from any category
if ( ! $tripster_prev_post ) {
$tripster_posts_navigation = 'links';
}
}
}
// Override some theme options to display featured image, title and post meta in the dynamic loaded posts
if ( $full_post_loading || ( $prev_post_loading && $tripster_prev_post ) ) {
tripster_sc_layouts_showed( 'featured', false );
tripster_sc_layouts_showed( 'title', false );
tripster_sc_layouts_showed( 'postmeta', false );
}
// If related posts should be inside the content
if ( strpos( $tripster_related_position, 'inside' ) === 0 ) {
ob_start();
}
// Display post's content
get_template_part( apply_filters( 'tripster_filter_get_template_part', 'templates/content', 'single-' . tripster_get_theme_option( 'single_style' ) ), 'single-' . tripster_get_theme_option( 'single_style' ) );
// If related posts should be inside the content
if ( strpos( $tripster_related_position, 'inside' ) === 0 ) {
$tripster_content = ob_get_contents();
ob_end_clean();
ob_start();
do_action( 'tripster_action_related_posts' );
$tripster_related_content = ob_get_contents();
ob_end_clean();
$tripster_related_position_inside = max( 0, min( 9, tripster_get_theme_option( 'related_position_inside' ) ) );
if ( 0 == $tripster_related_position_inside ) {
$tripster_related_position_inside = mt_rand( 1, 9 );
}
$tripster_p_number = 0;
$tripster_related_inserted = false;
for ( $i = 0; $i < strlen( $tripster_content ) - 3; $i++ ) {
if ( '<' == $tripster_content[ $i ] && 'p' == $tripster_content[ $i + 1 ] && in_array( $tripster_content[ $i + 2 ], array( '>', ' ' ) ) ) {
$tripster_p_number++;
if ( $tripster_related_position_inside == $tripster_p_number ) {
$tripster_related_inserted = true;
$tripster_content = ( $i > 0 ? substr( $tripster_content, 0, $i ) : '' )
. $tripster_related_content
. substr( $tripster_content, $i );
}
}
}
if ( ! $tripster_related_inserted ) {
$tripster_content .= $tripster_related_content;
}
tripster_show_layout( $tripster_content );
}
// Comments
do_action( 'tripster_action_before_comments' );
comments_template();
do_action( 'tripster_action_after_comments' );
// Related posts
if ( 'below_content' == $tripster_related_position
&& ( 'scroll' != $tripster_posts_navigation || tripster_get_theme_option( 'posts_navigation_scroll_hide_related' ) == 0 )
&& ( ! $full_post_loading || tripster_get_theme_option( 'open_full_post_hide_related' ) == 0 )
) {
do_action( 'tripster_action_related_posts' );
}
// Post navigation: type 'scroll'
if ( 'scroll' == $tripster_posts_navigation && ! $full_post_loading ) {
?>