<?php
/**
 * Post Navigation Function
 *
 * @since Intimate 1.0.0
 *
 * @param null
 * @return void
 *
 */
if (!function_exists('intimate_posts_navigation')) :
    function intimate_posts_navigation()
    {
        global $intimate_theme_options;
        $intimate_pagination_option = $intimate_theme_options['intimate-pagination-options'];
        if ('numeric' == $intimate_pagination_option) {
            echo "<div class='pagination'>";
            global $wp_query;
            $big = 999999999; // need an unlikely integer
            /*
             * paginate_links() returns null when there is one page or fewer,
             * and the arrows are markup, so they are not handed to translators.
             */
            $intimate_links = paginate_links( array(
                'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
                'format' => '?paged=%#%',
                'current' => max( 1, get_query_var( 'paged' ) ),
                'total' => $wp_query->max_num_pages,
                'prev_text' => '<i class="fa fa-angle-left" aria-hidden="true"></i><span class="screen-reader-text">' . esc_html__( 'Previous page', 'intimate' ) . '</span>',
                'next_text' => '<i class="fa fa-angle-right" aria-hidden="true"></i><span class="screen-reader-text">' . esc_html__( 'Next page', 'intimate' ) . '</span>',
            ) );

            if ( $intimate_links ) {
                echo wp_kses_post( $intimate_links );
            }
            echo "</div>";
        } elseif ('ajax' == $intimate_pagination_option) {
            $page_number = get_query_var('paged');
            if ($page_number == 0) {
                $output_page = 2;
            } else {
                $output_page = $page_number + 1;
            }
            printf(
                '<div class="ajax-pagination text-center"><div class="show-more" data-number="%1$s"><i class="fa fa-refresh" aria-hidden="true"></i>%2$s</div><div id="free-temp-post"></div></div>',
                esc_attr( $output_page ),
                esc_html__( 'View More', 'intimate' )
            );
        } else {
            return false;
        }
    }
endif;
add_action('intimate_action_navigation', 'intimate_posts_navigation', 10);