<?php
/**
 * Pagination setting
 */

// Pagination setting.
$wp_customize->add_section(
	'news_articles_pagination',
	array(
		'title' => esc_html__( 'Pagination', 'news-articles' ),
		'panel' => 'news_articles_theme_options_panel',
	)
);

// Pagination enable setting.
$wp_customize->add_setting(
	'news_articles_pagination_enable',
	array(
		'default'           => true,
		'sanitize_callback' => 'news_articles_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	new News_Articles_Toggle_Checkbox_Custom_control(
		$wp_customize,
		'news_articles_pagination_enable',
		array(
			'label'    => esc_html__( 'Enable Pagination.', 'news-articles' ),
			'settings' => 'news_articles_pagination_enable',
			'section'  => 'news_articles_pagination',
			'type'     => 'checkbox',
		)
	)
);

// Pagination - Pagination Style.
$wp_customize->add_setting(
	'news_articles_pagination_type',
	array(
		'default'           => 'numeric',
		'sanitize_callback' => 'news_articles_sanitize_select',
	)
);

$wp_customize->add_control(
	'news_articles_pagination_type',
	array(
		'label'           => esc_html__( 'Pagination Style', 'news-articles' ),
		'section'         => 'news_articles_pagination',
		'type'            => 'select',
		'choices'         => array(
			'default'  => __( 'Default (Older/Newer)', 'news-articles' ),
			'numeric'  => __( 'Numeric', 'news-articles' ),
		),
		'active_callback' => function( $control ) {
			return ( $control->manager->get_setting( 'news_articles_pagination_enable' )->value() );
		},
	)
);
