<?php
/**
 * Template part for displaying single post next/prev posts
 */
if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly

if( rivax_get_option('single-post-next-prev-posts') ) {
    $previous_post = get_previous_post();
    $next_post = get_next_post();

    if( $next_post || $previous_post ) {
        ?>
        <div class="single-next-prev-posts-container">

            <div class="single-next-prev-posts">
                <div class="next-prev-row">
                    <div class="next-prev-col">
                        <?php
                        if( $previous_post ) {
                            ?>
                            <div class="post-wrapper prev-post">
                                <div class="image">
	                                <?php echo get_the_post_thumbnail($previous_post->ID, 'thumbnail', array( 'title' => get_the_title() )); ?>
                                </div>
                                <div class="content">
                                    <div class="next-prev-label">
                                        <span class="icon"><i class="ri-right-arrow-1"></i></span>
                                        <span class="text"><?php echo rivax_get_option('translate-previous')?: esc_html__('Previous Post', 'newsfy'); ?></span>
                                    </div>
                                    <h3 class="title">
                                        <span><?php echo esc_html(get_the_title($previous_post->ID)); ?></span>
                                    </h3>
                                </div>
                                <a class="rivax-position-cover" href="<?php echo esc_url(get_permalink($previous_post->ID)); ?>"></a>
                            </div>
                            <?php
                        }
                        ?>
                    </div>
                    <div class="next-prev-col">
                        <?php
                        if( $next_post ) {
                            ?>
                            <div class="post-wrapper next-post">
                                <div class="image">
	                                <?php echo get_the_post_thumbnail($next_post->ID, 'thumbnail', array( 'title' => get_the_title() )); ?>
                                </div>
                                <div class="content">
                                    <div class="next-prev-label">
                                        <span class="text"><?php echo rivax_get_option('translate-next')?: esc_html__('Next Post', 'newsfy'); ?></span>
                                        <span class="icon"><i class="ri-right-arrow-1"></i></span>
                                    </div>
                                    <h3 class="title">
                                        <span><?php echo esc_html(get_the_title($next_post->ID)); ?></span>
                                    </h3>
                                </div>
                                <a class="rivax-position-cover" href="<?php echo esc_url(get_permalink($next_post->ID)); ?>"></a>
                            </div>
                            <?php
                        }
                        ?>
                    </div>
                </div>
            </div>
        </div>
        <?php
    }
}