<?php
/**
 * The default template for displaying pagination
 *
 * Used for both single and index/archive/catefory.
 *
 * @package Elazi Lite
 * @since Elazi Lite 1.0.0
 */

if (!is_singular() && current_theme_supports('loop-pagination')) {
    global $wp_query, $wp_rewrite;

    $total = $wp_query->max_num_pages;
    if ($total > 1) {
        $current = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1;

        $pagination_args = array(
            'base' => @add_query_arg('paged', '%#%'),
            'format' => '',
            'current' => $current,
            'total' => $total,
            'end_size' => 2,
            'mid_size' => 1,
            'type' => 'list',
            'prev_next' => TRUE,
            'prev_text' => '<i class="fa fa-angle-double-left"></i>',
            'next_text' => '<i class="fa fa-angle-double-right"></i>'
        );

        if ($wp_rewrite->using_permalinks())
            $pagination_args['base'] = user_trailingslashit(trailingslashit(remove_query_arg('s', get_pagenum_link(1))) . 'page/%#%/', 'paged');

        if (!empty($wp_query->query_vars['s']))
            $pagination_args['add_args'] = array('s' => urlencode(get_query_var('s')));

        ?>
            <div class="pagination clearfix">
                <?php echo paginate_links($pagination_args); ?>   
            </div>
            <!-- pagination -->
        <?php            
    }
}