<?php

/**
 * Customizer dashboard options
 *
 * @package wpstream-theme
 */

/**
 * Function to add dashboard options to the customizer.
 *
 * @param $wp_customize
 */
function wpstream_dashboard_settings( $wp_customize ) {
	$wp_customize->add_section(
		'wpstream_dashboard_options',
		array(
			'title' => esc_html__( 'Dashboard options', 'hello-wpstream' ),
			'panel' => 'wpstream_general_design',
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_menu_item_color',
		array(
			'default'           => '#F1F1F1',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_menu_item_color',
			array(
				'label'    => esc_html__( 'Menu item color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_menu_item_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_menu_item_color_hover',
		array(
			'default'           => '#F1F1F1',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_menu_item_color_hover',
			array(
				'label'    => esc_html__( 'Menu item hover color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_menu_item_color_hover',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_menu_item_background_color',
		array(
			'default'           => '#151120',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_menu_item_background_color',
			array(
				'label'    => esc_html__( 'Menu item background color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_menu_item_background_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_menu_item_hover_background_color',
		array(
			'default'           => '#4e2ee5',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_menu_item_hover_background_color',
			array(
				'label'    => esc_html__( 'Menu item hover background color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_menu_item_hover_background_color',
			)
		)
	);

	$wp_customize->add_control(
		new Wpstream_Separator_Control(
			$wp_customize,
			array(
				'section' => 'wpstream_dashboard_options',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_button_background_color',
		array(
			'default'           => '#4e2ee5',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_button_background_color',
			array(
				'label'    => esc_html__( 'Button background color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_button_background_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_button_hover_background_color',
		array(
			'default'           => '#4e2ee5',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_button_hover_background_color',
			array(
				'label'    => esc_html__( 'Button hover background color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_button_hover_background_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_button_arrow_color',
		array(
			'default'           => '#f1f1f1',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_button_arrow_color',
			array(
				'label'    => esc_html__( 'Button arrow color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_button_arrow_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_button_arrow_hover_color',
		array(
			'default'           => '#151120',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_button_arrow_hover_color',
			array(
				'label'    => esc_html__( 'Button arrow hover color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_button_arrow_hover_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_button_arrow_background_color',
		array(
			'default'           => '#4e2ee5',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_button_arrow_background_color',
			array(
				'label'    => esc_html__( 'Button arrow background color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_button_arrow_background_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_dashboard_options_button_arrow_hover_background_color',
		array(
			'default'           => '#f1f1f1',
			'sanitize_callback' => 'sanitize_text_field',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_dashboard_options_button_arrow_hover_background_color',
			array(
				'label'    => esc_html__( 'Button arrow hover background color', 'hello-wpstream' ),
				'section'  => 'wpstream_dashboard_options',
				'settings' => 'wpstream_dashboard_options_button_arrow_hover_background_color',
			)
		)
	);
}

/**
 * Function that returns the dashboard style options as variables for CSS.
 *
 * @return array[]
 */
function wpstream_get_dashboard_style_options() {
	return array(
		// Menu item text and background color
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_menu_item_color' ),
			'var'   => '--wpstream-dashboard-options-menu-item-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_menu_item_color_hover' ),
			'var'   => '--wpstream-dashboard-options-menu-item-color-hover',
		),
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_menu_item_background_color' ),
			'var'   => '--wpstream-dashboard-options-menu-item-background-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_menu_item_hover_background_color' ),
			'var'   => '--wpstream-dashboard-options-menu-item-background-color-hover',
		),

		// Button background color
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_button_background_color' ),
			'var'   => '--wpstream-dashboard-options-button-background-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_button_hover_background_color' ),
			'var'   => '--wpstream-dashboard-options-button-hover-background-color',
		),

		// Button arrow color
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_button_arrow_color' ),
			'var'   => '--wpstream-dashboard-options-button-arrow-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_button_arrow_hover_color' ),
			'var'   => '--wpstream-dashboard-options-button-arrow-hover-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_button_arrow_background_color' ),
			'var'   => '--wpstream-dashboard-options-button-arrow-background-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_dashboard_options_button_arrow_hover_background_color' ),
			'var'   => '--wpstream-dashboard-options-button-arrow-hover-background-color',
		),
	);
}