<?php

/**
 * Customizer metadata and share settings
 *
 * @package wpstream-theme
 */

/**
 * Function to add metadata and share settings to the customizer.
 *
 * @param WP_Customize_Manager $wp_customize Customizer object.
 */

function wpstream_add_metadata_share_settings( $wp_customize ) {
	$section_background_color = get_theme_mod( 'wpstream_theme_style_white' ) ? '#f0f0f3' : '#151120';

	$wp_customize->add_section(
		'wpstream_metadata_share_settings',
		array(
			'title' => esc_html__( 'Views, likes, and share settings', 'hello-wpstream' ),
			'panel' => 'wpstream_general_design',
		)
	);

	$wp_customize->add_setting(
		'wpstream_metadata_share_text_color',
		array(
			'default'           => '#000000',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_metadata_share_text_color',
			array(
				'label'    => esc_html__( 'Text color', 'hello-wpstream' ),
				'section'  => 'wpstream_metadata_share_settings',
				'settings' => 'wpstream_metadata_share_text_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_metadata_share_hover_text_color',
		array(
			'default'           => '#f1f1f1',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_metadata_share_hover_text_color',
			array(
				'label'    => esc_html__( 'Hover text color', 'hello-wpstream' ),
				'section'  => 'wpstream_metadata_share_settings',
				'settings' => 'wpstream_metadata_share_hover_text_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_metadata_share_background_color',
		array(
			'default'           => '#ffffffa8',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_metadata_share_background_color',
			array(
				'label'    => esc_html__( 'Background color', 'hello-wpstream' ),
				'section'  => 'wpstream_metadata_share_settings',
				'settings' => 'wpstream_metadata_share_background_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_metadata_share_hover_background_color',
		array(
			'default'           => '#ffffffa8',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_metadata_share_hover_background_color',
			array(
				'label'    => esc_html__( 'Hover background color', 'hello-wpstream' ),
				'section'  => 'wpstream_metadata_share_settings',
				'settings' => 'wpstream_metadata_share_hover_background_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_metadata_share_section_background_color',
		array(
			'default'           => $section_background_color,
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_metadata_share_section_background_color',
			array(
				'label'    => esc_html__( 'Section background color', 'hello-wpstream' ),
				'section'  => 'wpstream_metadata_share_settings',
				'settings' => 'wpstream_metadata_share_section_background_color',
			)
		)
	);
}

/**
 * Function to get metadata share settings as variables for CSS.
 *
 * @return array[]
 */
function wpstream_get_metadata_share_settings() {
	return array(
		array(
			'value' => get_theme_mod( 'wpstream_metadata_share_text_color' ),
			'var'   => '--wpstream-metadata-share-text-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_metadata_share_hover_text_color' ),
			'var'   => '--wpstream-metadata-share-hover-text-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_metadata_share_background_color' ),
			'var'   => '--wpstream-metadata-share-background-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_metadata_share_hover_background_color' ),
			'var'   => '--wpstream-metadata-share-hover-background-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_metadata_share_section_background_color' ),
			'var'   => '--wpstream-metadata-share-section-background-color',
		),
	);
}
