<?php
/**
 * General, site-wide customizer settings
 *
 * @package Multi
 */

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

/**
 * Customizer settings for general theme options
 */
class Multimagazine_Customize_General {

	/**
	 * 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_section(
			'general',
			array(
				'title'    => __( 'General', 'multimagazine' ),
				'priority' => 25,
			)
		);
		do_action( 'multimagazine_customize_general', $wp_customize );
	}

	/**
	 * Registers the fancy borders setting.
	 */
	public static function register_fancy_borders() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_fancy_borders', 'general', __( 'Show fancy borders on images', 'multimagazine' ) );
	}

	/**
	 * Registers the image hover setting.
	 */
	public static function register_image_hover() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_image_hover',
			'general',
			array(
				'img-hover-lightup'      => __( 'Light up (default)', 'multimagazine' ),
				'img-hover-zoom'         => __( 'Zoom', 'multimagazine' ),
				'img-hover-zoom-lightup' => __( 'Light up and zoom', 'multimagazine' ),
				'img-hover-shine'        => __( 'Shine', 'multimagazine' ),
				'none'                   => __( 'None', 'multimagazine' ),
			),
			__( 'Hover effect on linked images', 'multimagazine' )
		);
	}

	/**
	 * Registers the underlined heading style setting.
	 */
	public static function register_underlined_heading_style() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_underlined_heading_style',
			'general',
			array(
				1  => __( 'Heading style 1', 'multimagazine' ),
				2  => __( 'Heading style 2', 'multimagazine' ),
				3  => __( 'Heading style 3', 'multimagazine' ),
				4  => __( 'Heading style 4', 'multimagazine' ),
				5  => __( 'Heading style 5', 'multimagazine' ),
				6  => __( 'Heading style 6', 'multimagazine' ),
				7  => __( 'Heading style 7', 'multimagazine' ),
				8  => __( 'Heading style 8', 'multimagazine' ),
				9  => __( 'Heading style 9', 'multimagazine' ),
				10 => __( 'Heading style 10', 'multimagazine' ),
			),
			__( 'Special heading style', 'multimagazine' )
		);
	}

	/**
	 * Registers the icon set setting.
	 */
	public static function register_icon_set() {
		global $multimagazine_customize;
		$fonts = array( 'font-awesome' => __( 'Font Awesome', 'multimagazine' ) );
		$fonts = apply_filters( 'multimagazine_icon_sets', $fonts );
		$multimagazine_customize->select_setting(
			'multi_icon_set',
			'general',
			$fonts,
			__( 'Choose icon set', 'multimagazine' ),
			__( 'Icon set used for general theme elements (arrows, navigation, search, cart, comment, check, etc.) . ', 'multimagazine' )
		);
	}

	/**
	 * Registers the tabs style setting.
	 */
	public static function register_tabs_style() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_tabs_style',
			'general',
			array(
				'default'     => __( 'Default', 'multimagazine' ),
				'alternative' => __( 'Alternative', 'multimagazine' ),
			),
			__( 'Tabs style', 'multimagazine' )
		);
	}

	/**
	 * Adds the scrollbars heading.
	 */
	public static function register_scrollbars_heading() {
		multimagazine_add_heading( 'multi_scrollbars_title', 'general', __( 'Scrollbars', 'multimagazine' ) );
	}

	/**
	 * Registers the customize scrollbars setting.
	 */
	public static function register_customize_scrollbars() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_customize_scrollbars', 'general', __( 'Customize scrollbars', 'multimagazine' ) );
	}

	/**
	 * Registers the scrollbar background color setting.
	 */
	public static function register_scrollbar_background_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'multi_scrollbar_background_color', 'general', __( 'Scrollbar track color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the scrollbar handle color setting.
	 */
	public static function register_scrollbar_handle_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'multi_scrollbar_handle_color', 'general', __( 'Scrollbar handle color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the scrollbar width setting.
	 */
	public static function register_scrollbar_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_scrollbar_width', 'general', 0, 30, 1, __( 'Scrollbar width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}
}

add_action( 'customize_register', array( 'Multimagazine_Customize_General', 'register_section' ) );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_fancy_borders' ), 10 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_image_hover' ), 15 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_underlined_heading_style' ), 20 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_icon_set' ), 25 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_tabs_style' ), 30 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_scrollbars_heading' ), 35 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_customize_scrollbars' ), 40 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_scrollbar_background_color' ), 45 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_scrollbar_handle_color' ), 50 );
add_action( 'multimagazine_customize_general', array( 'Multimagazine_Customize_General', 'register_scrollbar_width' ), 55 );
