<?php
/**
 * Customizer settings: Go top link
 *
 * @package Multi
 */

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

/**
 * Customizer settings for go to top link
 */
class Multimagazine_Customize_Go_Top_Link {

	/**
	 * Returns up icons.
	 *
	 * @return array
	 */
	private static function get_up_icons() {
		return array(
			'arrow-up'          => __( 'arrow-up', 'multimagazine' ),
			'arrow-med-up'      => __( 'arrow-med-up', 'multimagazine' ),
			'long-arrow-up'     => __( 'long-arrow-up', 'multimagazine' ),
			'arrow-circle-up'   => __( 'arrow-circle-up', 'multimagazine' ),
			'chevron-up'        => __( 'chevron-up', 'multimagazine' ),
			'chevron-circle-up' => __( 'chevron-circle-up', 'multimagazine' ),
		);
	}

	/**
	 * 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(
			'go_top',
			array(
				'title'    => __( 'Go to top link', 'multimagazine' ),
				'priority' => 51,
			)
		);
		do_action( 'multimagazine_customize_go_top', $wp_customize );
	}

	/**
	 * Registers the show mobile setting.
	 */
	public static function register_show_mobile() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_go_top_show_mobile', 'go_top', __( 'Show on mobile', 'multimagazine' ) );
	}

	/**
	 * Registers the show tablet setting.
	 */
	public static function register_show_tablet() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_go_top_show_tablet', 'go_top', __( 'Show on tablet', 'multimagazine' ) );
	}

	/**
	 * Registers the show desktop setting.
	 */
	public static function register_show_desktop() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_go_top_show_desktop', 'go_top', __( 'Show on desktop', 'multimagazine' ) );
	}

	/**
	 * Registers the show label setting.
	 */
	public static function register_show_label() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_go_top_show_label', 'go_top', __( 'Show link label', 'multimagazine' ) );
	}

	/**
	 * Registers the show up setting.
	 */
	public static function register_show_up() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_go_top_show_up', 'go_top', __( 'Show link only when scrolling up', 'multimagazine' ) );
	}

	/**
	 * Registers the animation setting.
	 */
	public static function register_animation() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_go_top_animation',
			'go_top',
			array(
				'slide' => __( 'Slide (default)', 'multimagazine' ),
				'fade'  => __( 'Fade', 'multimagazine' ),
			),
			__( 'Animation', 'multimagazine' )
		);
	}

	/**
	 * Registers the position setting.
	 */
	public static function register_position() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_go_top_position',
			'go_top',
			array(
				'right' => __( 'Right (default)', 'multimagazine' ),
				'left'  => __( 'Left', 'multimagazine' ),
			),
			__( 'Go to top link position', 'multimagazine' )
		);
	}

	/**
	 * Registers the horizontal offset setting.
	 */
	public static function register_horizontal_offset() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_horizontal_offset', 'go_top', 0, 150, 1, __( 'Horizontal offset', 'multimagazine' ), __( 'Number of pixels.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the vertical offset setting.
	 */
	public static function register_vertical_offset() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_vertical_offset', 'go_top', 0, 150, 1, __( 'Vertical offset', 'multimagazine' ), __( 'Number of pixels.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the icon setting.
	 */
	public static function register_icon() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_go_top_icon',
			'go_top',
			self::get_up_icons(),
			__( 'Icon', 'multimagazine' )
		);
	}

	/**
	 * Registers the icon size setting.
	 */
	public static function register_icon_size() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_icon_size', 'go_top', 0, 50, 1, __( 'Icon size', 'multimagazine' ), __( 'Number of pixels.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the color setting.
	 */
	public static function register_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'multi_go_top_color', 'go_top', __( 'Icon color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the hover color setting.
	 */
	public static function register_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'multi_go_top_hover_color', 'go_top', __( 'Icon hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the box size setting.
	 */
	public static function register_box_size() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_box_size', 'go_top', 0, 100, 1, __( 'Box size', 'multimagazine' ), __( 'Number of pixels.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the background color setting.
	 */
	public static function register_background_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'multi_go_top_background_color', 'go_top', __( 'Background color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the background hover color setting.
	 */
	public static function register_background_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'multi_go_top_background_hover_color', 'go_top', __( 'Background hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the border width setting.
	 */
	public static function register_border_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_border_width', 'go_top', 0, 10, 1, __( 'Border width', 'multimagazine' ), __( 'Number of pixels.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border color setting.
	 */
	public static function register_border_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'multi_go_top_border_color', 'go_top', __( 'Border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the border hover color setting.
	 */
	public static function register_border_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_alpha_setting( 'multi_go_top_border_hover_color', 'go_top', __( 'Border hover color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the border radius nw setting.
	 */
	public static function register_border_radius_nw() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_border_radius_nw', 'go_top', 0, 50, 1, __( 'Border top left radius', 'multimagazine' ), __( '% of box size.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border radius ne setting.
	 */
	public static function register_border_radius_ne() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_border_radius_ne', 'go_top', 0, 50, 1, __( 'Border top right radius', 'multimagazine' ), __( '% of box size.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border radius se setting.
	 */
	public static function register_border_radius_se() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_border_radius_se', 'go_top', 0, 50, 1, __( 'Border bottom right radius', 'multimagazine' ), __( '% of box size.', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border radius sw setting.
	 */
	public static function register_border_radius_sw() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_go_top_border_radius_sw', 'go_top', 0, 50, 1, __( 'Border bottom left radius', 'multimagazine' ), __( '% of box size.', 'multimagazine' ), 'postMessage' );
	}
}

add_action( 'customize_register', array( 'Multimagazine_Customize_Go_Top_Link', 'register_section' ) );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_show_mobile' ), 10 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_show_tablet' ), 15 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_show_desktop' ), 20 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_show_label' ), 25 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_show_up' ), 30 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_animation' ), 35 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_position' ), 40 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_horizontal_offset' ), 45 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_vertical_offset' ), 50 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_icon' ), 55 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_icon_size' ), 60 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_color' ), 65 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_hover_color' ), 70 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_box_size' ), 75 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_background_color' ), 80 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_background_hover_color' ), 85 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_border_width' ), 90 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_border_color' ), 95 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_border_hover_color' ), 100 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_border_radius_nw' ), 105 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_border_radius_ne' ), 110 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_border_radius_se' ), 115 );
add_action( 'multimagazine_customize_go_top', array( 'Multimagazine_Customize_Go_Top_Link', 'register_border_radius_sw' ), 120 );
