<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;

$show_navigation = isset($campoal_options['conikal_show_navigation_section_field']) ? $campoal_options['conikal_show_navigation_section_field'] : 0;
$prev_post = get_previous_post();
$next_post = get_next_post();

if ($show_navigation) :
    if ($prev_post || $next_post) { ?>
    <div class="post-navigation-section">
        <nav class="post-navigation">
            <div class="ui padded segment">
                <div class="ui two column grid navigation-post">
                    <div class="ui vertical divider">|</div>
                    <div class="row">
                        <div class="right aligned column previous">
                            <?php if ($prev_post) : ?>
                            <div class="ui medium header">
                                <div class="content">
                                    <div class="sub header">
                                        <?php esc_html_e('Previous petition', 'campoal') ?>
                                    </div>
                                    <a href="<?php echo esc_url(!empty( $prev_post ) ? get_permalink( $prev_post->ID ) : ''); ?>" rel="prev" data-bjax>
                                        <?php echo get_the_title($prev_post->ID); ?>
                                    </a>
                                </div>
                            </div>
                            <a href="<?php echo esc_url(!empty( $prev_post ) ? get_permalink( $prev_post->ID ) : ''); ?>" class="pn-icon" data-bjax><i class="chevron left icon"></i></a>
                            <?php endif; ?>
                        </div>
                        <div class="column next">
                            <?php if ($next_post) : ?>
                            <div class="ui medium header">
                                <div class="content">
                                    <div class="sub header">
                                        <?php esc_html_e('Next petition', 'campoal') ?>
                                    </div>
                                    <a href="<?php echo esc_url(!empty( $next_post ) ? get_permalink( $next_post->ID ) : ''); ?>" rel="next" data-bjax>
                                        <?php echo get_the_title($next_post->ID); ?>
                                    </a>
                                </div>
                            </div>
                            <a href="<?php echo esc_url(!empty( $next_post ) ? get_permalink( $next_post->ID ) : ''); ?>" class="pn-icon" data-bjax><i class="chevron right icon"></i></a>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>
        </nav>
    </div>
    <?php } ?>
<?php endif; ?>
<?php posts_nav_link(); ?>
