<?php

/**
 * Customizer comments settings
 *
 * @package wpstream-theme
 */

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

function wpstream_add_comments_settings( $wp_customize ) {

	$default_text_color = get_theme_mod('wpstream_theme_style_white') ? '#f0f0f3' : '#151120';
	$wp_customize->add_section(
		'wpstream_comments_settings',
		array(
			'title'    => esc_html__( 'Comments settings', 'hello-wpstream' ),
			'panel'    => 'wpstream_general_design',
		)
	);

	$wp_customize->add_setting(
		'wpstream_comments_text_color',
		array(
			'default'           => $default_text_color,
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_comments_text_color',
			array(
				'label'    => esc_html__( 'Text color', 'hello-wpstream' ),
				'section'  => 'wpstream_comments_settings',
				'settings' => 'wpstream_comments_text_color',
			)
		)
	);

	$wp_customize->add_setting(
		'wpstream_comments_background_color',
		array(
			'default'           => '#ffffff',
			'sanitize_callback' => 'sanitize_hex_color',
		)
	);
	$wp_customize->add_control(
		new WP_Customize_Color_Control(
			$wp_customize,
			'wpstream_comments_background_color',
			array(
				'label'    => esc_html__( 'Background color', 'hello-wpstream' ),
				'section'  => 'wpstream_comments_settings',
				'settings' => 'wpstream_comments_background_color',
			)
		)
	);
}

/**
 * Function to get comments settings as variables for CSS.
 *
 * @return array[]
 */
function wpstream_get_comments_settings() {
	return array(
		array(
			'value' => get_theme_mod( 'wpstream_comments_text_color' ),
			'var'   => '--wpstream-comments-text-color',
		),
		array(
			'value' => get_theme_mod( 'wpstream_comments_background_color' ),
			'var'   => '--wpstream-comments-background-color',
		),
	);
}