<?php
/**
 * Customizer settings: pagination
 *
 * @package Multi
 */

if ( ! defined( 'ABSPATH' ) ) {
	die;
}

/**
 * Customizer settings for pagination
 */
class Multimagazine_Customize_Pagination {

	/**
	 * Registers the section and fires the extension hook.
	 *
	 * @param WP_Customize_Manager $wp_customize Customizer manager instance.
	 */
	public static function register_section( $wp_customize ) {
		$wp_customize->add_panel(
			'pagination',
			array(
				'title'    => __( 'Pagination', 'multimagazine' ),
				'priority' => 61,
			)
		);

		$wp_customize->add_section(
			'pagination_general',
			array(
				'title' => __( 'General settings', 'multimagazine' ),
				'panel' => 'pagination',
			)
		);
		do_action( 'multimagazine_customize_pagination_general', $wp_customize );

		$wp_customize->add_section(
			'pagination_default',
			array(
				'title' => __( 'Dots default state', 'multimagazine' ),
				'panel' => 'pagination',
			)
		);
		do_action( 'multimagazine_customize_pagination_default', $wp_customize );

		$wp_customize->add_section(
			'pagination_active',
			array(
				'title' => __( 'Dots active state', 'multimagazine' ),
				'panel' => 'pagination',
			)
		);
		do_action( 'multimagazine_customize_pagination_active', $wp_customize );

		$wp_customize->add_section(
			'pagination_hover',
			array(
				'title' => __( 'Dots mouse over state', 'multimagazine' ),
				'panel' => 'pagination',
			)
		);
		do_action( 'multimagazine_customize_pagination_hover', $wp_customize );
	}

	/* General section */

	/**
	 * Registers the current page color setting.
	 */
	public static function register_current_page_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_pagination_current_page_color', 'pagination_general', __( 'Current page link color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the pagination style setting.
	 */
	public static function register_pagination_style() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_pagination_style',
			'pagination_general',
			array(
				'standard' => __( 'Standard (default)', 'multimagazine' ),
				'modern'   => __( 'Modern', 'multimagazine' ),
			),
			__( 'Post list pagination style', 'multimagazine' )
		);
	}

	/**
	 * Registers the dot valign setting.
	 */
	public static function register_dot_valign() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'pagination_dot_valign',
			'pagination_general',
			array(
				'top'    => __( 'Top', 'multimagazine' ),
				'middle' => __( 'Middle (default)', 'multimagazine' ),
				'bottom' => __( 'Bottom', 'multimagazine' ),
			),
			__( 'Dots vertical align', 'multimagazine' )
		);
	}

	/**
	 * Registers the dot border position setting.
	 */
	public static function register_dot_border_position() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'pagination_dot_border_position',
			'pagination_general',
			array(
				'inside'  => __( 'Inside (default)', 'multimagazine' ),
				'outside' => __( 'Outside', 'multimagazine' ),
			),
			__( 'Pagination dot border position', 'multimagazine' )
		);
	}

	/**
	 * Registers the dot spacing setting.
	 */
	public static function register_dot_spacing() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_spacing', 'pagination_general', 0, 100, 1, __( 'Pagination dot spacing', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the line width setting.
	 */
	public static function register_line_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_line_width', 'pagination_general', 0, 100, 1, __( 'Pagination line width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the line color setting.
	 */
	public static function register_line_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'pagination_line_color', 'pagination_general', __( 'Pagination line color', 'multimagazine' ), '', 'postMessage' );
	}

	/* Default section */

	/**
	 * Registers the dot width setting.
	 */
	public static function register_dot_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_width', 'pagination_default', 0, 100, 1, __( 'Pagination dot width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the dot height setting.
	 */
	public static function register_dot_height() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_height', 'pagination_default', 0, 100, 1, __( 'Pagination dot height', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the dot color setting.
	 */
	public static function register_dot_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'pagination_dot_color', 'pagination_default', __( 'Pagination dot color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the dot border color setting.
	 */
	public static function register_dot_border_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'pagination_dot_border_color', 'pagination_default', __( 'Pagination dot border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the dot border width setting.
	 */
	public static function register_dot_border_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_border_width', 'pagination_default', 0, 10, 1, __( 'Pagination dot border width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the dot border radius setting.
	 */
	public static function register_dot_border_radius() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_border_radius', 'pagination_default', 0, 100, 1, __( 'Pagination dot border radius', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/* Active section */

	/**
	 * Registers the dot active width setting.
	 */
	public static function register_dot_active_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_active_width', 'pagination_active', 0, 100, 1, __( 'Pagination dot width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the dot active height setting.
	 */
	public static function register_dot_active_height() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_active_height', 'pagination_active', 0, 100, 1, __( 'Pagination dot height', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the dot active color setting.
	 */
	public static function register_dot_active_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'pagination_dot_active_color', 'pagination_active', __( 'Pagination dot color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the dot active border color setting.
	 */
	public static function register_dot_active_border_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'pagination_dot_active_border_color', 'pagination_active', __( 'Pagination dot border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the dot active border width setting.
	 */
	public static function register_dot_active_border_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_active_border_width', 'pagination_active', 0, 10, 1, __( 'Pagination dot border width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the dot active border radius setting.
	 */
	public static function register_dot_active_border_radius() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_active_border_radius', 'pagination_active', 0, 100, 1, __( 'Pagination dot border radius', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/* Hover section */

	/**
	 * Registers the dot hover color setting.
	 */
	public static function register_dot_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'pagination_dot_hover_color', 'pagination_hover', __( 'Pagination dot hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the dot hover border color setting.
	 */
	public static function register_dot_hover_border_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'pagination_dot_hover_border_color', 'pagination_hover', __( 'Pagination dot border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the dot hover border width setting.
	 */
	public static function register_dot_hover_border_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'pagination_dot_hover_border_width', 'pagination_hover', 0, 10, 1, __( 'Pagination dot border width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}
}

add_action( 'customize_register', array( 'Multimagazine_Customize_Pagination', 'register_section' ) );
add_action( 'multimagazine_customize_pagination_general', array( 'Multimagazine_Customize_Pagination', 'register_current_page_color' ), 10 );
add_action( 'multimagazine_customize_pagination_general', array( 'Multimagazine_Customize_Pagination', 'register_pagination_style' ), 15 );
add_action( 'multimagazine_customize_pagination_general', array( 'Multimagazine_Customize_Pagination', 'register_dot_valign' ), 20 );
add_action( 'multimagazine_customize_pagination_general', array( 'Multimagazine_Customize_Pagination', 'register_dot_border_position' ), 25 );
add_action( 'multimagazine_customize_pagination_general', array( 'Multimagazine_Customize_Pagination', 'register_dot_spacing' ), 30 );
add_action( 'multimagazine_customize_pagination_general', array( 'Multimagazine_Customize_Pagination', 'register_line_width' ), 35 );
add_action( 'multimagazine_customize_pagination_general', array( 'Multimagazine_Customize_Pagination', 'register_line_color' ), 40 );
add_action( 'multimagazine_customize_pagination_default', array( 'Multimagazine_Customize_Pagination', 'register_dot_width' ), 10 );
add_action( 'multimagazine_customize_pagination_default', array( 'Multimagazine_Customize_Pagination', 'register_dot_height' ), 15 );
add_action( 'multimagazine_customize_pagination_default', array( 'Multimagazine_Customize_Pagination', 'register_dot_color' ), 20 );
add_action( 'multimagazine_customize_pagination_default', array( 'Multimagazine_Customize_Pagination', 'register_dot_border_color' ), 25 );
add_action( 'multimagazine_customize_pagination_default', array( 'Multimagazine_Customize_Pagination', 'register_dot_border_width' ), 30 );
add_action( 'multimagazine_customize_pagination_default', array( 'Multimagazine_Customize_Pagination', 'register_dot_border_radius' ), 35 );
add_action( 'multimagazine_customize_pagination_active', array( 'Multimagazine_Customize_Pagination', 'register_dot_active_width' ), 10 );
add_action( 'multimagazine_customize_pagination_active', array( 'Multimagazine_Customize_Pagination', 'register_dot_active_height' ), 15 );
add_action( 'multimagazine_customize_pagination_active', array( 'Multimagazine_Customize_Pagination', 'register_dot_active_color' ), 20 );
add_action( 'multimagazine_customize_pagination_active', array( 'Multimagazine_Customize_Pagination', 'register_dot_active_border_color' ), 25 );
add_action( 'multimagazine_customize_pagination_active', array( 'Multimagazine_Customize_Pagination', 'register_dot_active_border_width' ), 30 );
add_action( 'multimagazine_customize_pagination_active', array( 'Multimagazine_Customize_Pagination', 'register_dot_active_border_radius' ), 35 );
add_action( 'multimagazine_customize_pagination_hover', array( 'Multimagazine_Customize_Pagination', 'register_dot_hover_color' ), 10 );
add_action( 'multimagazine_customize_pagination_hover', array( 'Multimagazine_Customize_Pagination', 'register_dot_hover_border_color' ), 15 );
add_action( 'multimagazine_customize_pagination_hover', array( 'Multimagazine_Customize_Pagination', 'register_dot_hover_border_width' ), 20 );
