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

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

/**
 * Customizer settings for forms
 */
class Multimagazine_Customize_Forms {

	/**
	 * 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(
			'multi_forms',
			array(
				'title'    => __( 'Forms', 'multimagazine' ),
				'priority' => 38,
			)
		);
		do_action( 'multimagazine_customize_multi_forms', $wp_customize );
	}

	/**
	 * Registers the label color setting.
	 */
	public static function register_label_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_label_color', 'multi_forms', __( 'Form label color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the label position setting.
	 */
	public static function register_label_position() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_form_label_position',
			'multi_forms',
			array(
				''                    => __( 'Default', 'multimagazine' ),
				'over-field'          => __( 'Over field', 'multimagazine' ),
				'across-field-border' => __( 'Across field border', 'multimagazine' ),
				'inside-field'        => __( 'Inside field', 'multimagazine' ),
			),
			__( 'Floating label position', 'multimagazine' ),
			__( 'Applies to fields with labels within elements with appropriate CSS class', 'multimagazine' )
		);
	}

	/**
	 * Registers the label background color setting.
	 */
	public static function register_label_background_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_label_background_color', 'multi_forms', __( 'Floating label background color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the label font size setting.
	 */
	public static function register_label_font_size() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_form_label_font_size', 'multi_forms', 5, 30, 1, __( 'Floating label font size', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the label line height setting.
	 */
	public static function register_label_line_height() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_form_label_line_height', 'multi_forms', 5, 60, 1, __( 'Floating label line height', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the input height setting.
	 */
	public static function register_input_height() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_input_height', 'multi_forms', 20, 80, 1, __( 'Form input and select height', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border top width setting.
	 */
	public static function register_border_top_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_form_border_top_width', 'multi_forms', 0, 10, 1, __( 'Form field top border width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border top color setting.
	 */
	public static function register_border_top_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_border_top_color', 'multi_forms', __( 'Form field top border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the border right width setting.
	 */
	public static function register_border_right_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_form_border_right_width', 'multi_forms', 0, 10, 1, __( 'Form field right border width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border right color setting.
	 */
	public static function register_border_right_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_border_right_color', 'multi_forms', __( 'Form field right border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the border bottom width setting.
	 */
	public static function register_border_bottom_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_form_border_bottom_width', 'multi_forms', 0, 10, 1, __( 'Form field bottom border width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border bottom color setting.
	 */
	public static function register_border_bottom_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_border_bottom_color', 'multi_forms', __( 'Form field bottom border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the border left width setting.
	 */
	public static function register_border_left_width() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_form_border_left_width', 'multi_forms', 0, 10, 1, __( 'Form field left border width', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the border left color setting.
	 */
	public static function register_border_left_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_border_left_color', 'multi_forms', __( 'Form field left border color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the border color focus setting.
	 */
	public static function register_border_color_focus() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_border_color_focus', 'multi_forms', __( 'Form field border color on focus', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the border radius setting.
	 */
	public static function register_border_radius() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_form_border_radius', 'multi_forms', 0, 100, 1, __( 'Form field border radius', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}

	/**
	 * Registers the text color setting.
	 */
	public static function register_text_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_text_color', 'multi_forms', __( 'Form text color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the placeholder color setting.
	 */
	public static function register_placeholder_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_placeholder_color', 'multi_forms', __( 'Form placeholder text color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the bg color setting.
	 */
	public static function register_bg_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_form_bg_color', 'multi_forms', __( 'Form background color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the mainmenu searchform background color setting.
	 */
	public static function register_mainmenu_searchform_background_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_mainmenu_searchform_background_color', 'multi_forms', __( 'Header search form background on mobile', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the mainmenu searchform input background color setting.
	 */
	public static function register_mainmenu_searchform_input_background_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_mainmenu_searchform_input_background_color', 'multi_forms', __( 'Header search form input background on mobile', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the search border radius setting.
	 */
	public static function register_search_border_radius() {
		global $multimagazine_customize;
		$multimagazine_customize->range_setting( 'multi_search_border_radius', 'multi_forms', 0, 100, 1, __( 'Search form border radius', 'multimagazine' ), __( 'Number of pixels', 'multimagazine' ), 'postMessage' );
	}
}

add_action( 'customize_register', array( 'Multimagazine_Customize_Forms', 'register_section' ) );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_label_color' ), 10 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_label_position' ), 15 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_label_background_color' ), 20 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_label_font_size' ), 25 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_label_line_height' ), 30 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_input_height' ), 35 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_top_width' ), 40 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_top_color' ), 45 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_right_width' ), 50 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_right_color' ), 55 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_bottom_width' ), 60 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_bottom_color' ), 65 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_left_width' ), 70 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_left_color' ), 75 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_color_focus' ), 80 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_border_radius' ), 85 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_text_color' ), 90 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_placeholder_color' ), 95 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_bg_color' ), 100 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_mainmenu_searchform_background_color' ), 105 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_mainmenu_searchform_input_background_color' ), 110 );
add_action( 'multimagazine_customize_multi_forms', array( 'Multimagazine_Customize_Forms', 'register_search_border_radius' ), 115 );
