<?php
/**
 *
 * Pagination Functions
 *
 * @package Aviation Industry
 */

/**
 * Pagination for archive.
 */
function aviation_industry_render_posts_pagination() {
    // Get the setting to check if pagination is enabled
    $aviation_industry_is_pagination_enabled = get_theme_mod( 'aviation_industry_enable_pagination', true );

    // Check if pagination is enabled
    if ( $aviation_industry_is_pagination_enabled ) {
        // Get the selected pagination type from the Customizer
        $aviation_industry_pagination_type = get_theme_mod( 'aviation_industry_theme_pagination_type', 'numeric' );

        // Check if the pagination type is "newer_older" (Previous/Next) or "numeric"
        if ( 'newer_older' === $aviation_industry_pagination_type ) :
            // Display "Newer/Older" pagination (Previous/Next navigation)
            the_posts_navigation(
                array(
                    'prev_text' => __( '&laquo; Newer', 'aviation-industry' ),  // Change the label for "previous"
                    'next_text' => __( 'Older &raquo;', 'aviation-industry' ),  // Change the label for "next"
                    'screen_reader_text' => __( 'Posts navigation', 'aviation-industry' ),
                )
            );
        else :
            // Display numeric pagination (Page numbers)
            the_posts_pagination(
                array(
                    'prev_text' => __( '&laquo; Previous', 'aviation-industry' ),
                    'next_text' => __( 'Next &raquo;', 'aviation-industry' ),
                    'type'      => 'list', // Display as <ul> <li> tags
                    'screen_reader_text' => __( 'Posts navigation', 'aviation-industry' ),
                )
            );
        endif;
    }
}
add_action( 'aviation_industry_posts_pagination', 'aviation_industry_render_posts_pagination', 10 );