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

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

/**
 * Customizer settings for subheader
 */
class Multimagazine_Customize_Subheader {

	/**
	 * 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(
			'subheader',
			array(
				'title'    => __( 'Subheader', 'multimagazine' ),
				'priority' => 36,
			)
		);
		do_action( 'multimagazine_customize_subheader', $wp_customize );
	}

	/**
	 * Registers the show subheader setting.
	 */
	public static function register_show_subheader() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_show_subheader', 'subheader', __( 'Show subheader (may be overwritten by post/page settings)', 'multimagazine' ) );
	}

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

	/**
	 * Registers the image setting.
	 */
	public static function register_image() {
		global $multimagazine_customize;
		$multimagazine_customize->cropped_image_setting( 'multi_subheader_image', 'subheader', __( 'Background image', 'multimagazine' ) );
	}

	/**
	 * Registers the image position setting.
	 */
	public static function register_image_position() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_subheader_image_position',
			'subheader',
			array(
				'top-left'      => __( 'top left', 'multimagazine' ),
				'top-center'    => __( 'top middle', 'multimagazine' ),
				'top-right'     => __( 'top right', 'multimagazine' ),
				'center-left'   => __( 'center left', 'multimagazine' ),
				'center-center' => __( 'center middle', 'multimagazine' ),
				'center-right'  => __( 'center right', 'multimagazine' ),
				'bottom-left'   => __( 'bottom left', 'multimagazine' ),
				'bottom-center' => __( 'bottom middle', 'multimagazine' ),
				'bottom-right'  => __( 'bottom right', 'multimagazine' ),
			),
			__( 'Subheader background position', 'multimagazine' )
		);
	}

	/**
	 * Registers the background size setting.
	 */
	public static function register_background_size() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_subheader_background_size',
			'subheader',
			array(
				'auto'                             => __( 'auto', 'multimagazine' ),
				'cover'                            => __( 'cover', 'multimagazine' ),
				'contain'                          => __( 'contain', 'multimagazine' ),
				'var(--subheader-custom-bg-size )' => __( 'custom', 'multimagazine' ),
			),
			__( 'Subheader background size', 'multimagazine' ),
			'',
			'postMessage'
		);
	}

	/**
	 * Registers the custom background size setting.
	 */
	public static function register_custom_background_size() {
		global $multimagazine_customize;
		$multimagazine_customize->text_setting( 'multi_subheader_custom_background_size', 'subheader', __( 'Custom background size', 'multimagazine' ), __( 'Any CSS-compatible background-size value, applicable only if the background size is set to "custom"', 'multimagazine' ) );
	}

	/**
	 * Registers the parallax setting.
	 */
	public static function register_parallax() {
		global $multimagazine_customize;
		$multimagazine_customize->checkbox_setting( 'multi_subheader_parallax', 'subheader', __( 'Parallax effect', 'multimagazine' ) );
	}

	/**
	 * Registers the title setting.
	 */
	public static function register_title() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_subheader_title',
			'subheader',
			array(
				''                        => __( 'Leave titles in default places', 'multimagazine' ),
				'left middle subheader'   => __( 'left middle', 'multimagazine' ),
				'center middle subheader' => __( 'center middle', 'multimagazine' ),
				'right middle subheader'  => __( 'right middle', 'multimagazine' ),
				'left bottom subheader'   => __( 'left bottom', 'multimagazine' ),
				'center bottom subheader' => __( 'center bottom', 'multimagazine' ),
				'right bottom subheader'  => __( 'right bottom', 'multimagazine' ),
			),
			__( 'Show page title in subheader', 'multimagazine' )
		);
	}

	/**
	 * Registers the breadcrumbs setting.
	 */
	public static function register_breadcrumbs() {
		global $multimagazine_customize;
		$multimagazine_customize->select_setting(
			'multi_subheader_breadcrumbs',
			'subheader',
			array(
				''                        => __( 'Leave breadcrumbs in default places', 'multimagazine' ),
				'left middle subheader'   => __( 'left middle', 'multimagazine' ),
				'center middle subheader' => __( 'center middle', 'multimagazine' ),
				'right middle subheader'  => __( 'right middle', 'multimagazine' ),
				'left bottom subheader'   => __( 'left bottom', 'multimagazine' ),
				'center bottom subheader' => __( 'center bottom', 'multimagazine' ),
				'right bottom subheader'  => __( 'right bottom', 'multimagazine' ),
			),
			__( 'Show breadcrumbs in subheader', 'multimagazine' )
		);
	}

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

	/**
	 * Registers the link color setting.
	 */
	public static function register_link_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_subheader_link_color', 'subheader', __( 'Link color', 'multimagazine' ), '', 'postMessage' );
	}

	/**
	 * Registers the link hover color setting.
	 */
	public static function register_link_hover_color() {
		global $multimagazine_customize;
		$multimagazine_customize->color_setting( 'multi_subheader_link_hover_color', 'subheader', __( 'Link hover color', 'multimagazine' ), '', 'postMessage' );
	}
}

add_action( 'customize_register', array( 'Multimagazine_Customize_Subheader', 'register_section' ) );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_show_subheader' ), 10 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_background_color' ), 15 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_image' ), 20 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_image_position' ), 25 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_background_size' ), 30 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_custom_background_size' ), 35 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_parallax' ), 40 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_title' ), 45 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_breadcrumbs' ), 50 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_text_color' ), 55 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_link_color' ), 60 );
add_action( 'multimagazine_customize_subheader', array( 'Multimagazine_Customize_Subheader', 'register_link_hover_color' ), 65 );
