<?php
/**
 * Header Builder Options
 *
 * @package Code4rest
 */

namespace Code4rest;

use Code4rest\Theme_Customizer;
use function Code4rest\code4rest;

ob_start(); ?>
<div class="code4rest-compontent-custom fonts-flush-button wp-clearfix">
	<span class="customize-control-title">
		<?php esc_html_e( 'Flush Local Fonts Cache', 'code4rest' ); ?>
	</span>
	<span class="description customize-control-description">
		<?php esc_html_e( 'Click the button to reset the local fonts cache', 'code4rest' ); ?>
	</span>
	<input type="button" class="button code4rest-flush-local-fonts-button" name="code4rest-flush-local-fonts-button" value="<?php esc_attr_e( 'Flush Local Font Files', 'code4rest' ); ?>" />
</div>
<?php
$code4rest_flush_button = ob_get_clean();

Theme_Customizer::add_settings(
	array(
		'enable_scroll_to_id' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'general_performance',
			'default'      => code4rest()->default( 'enable_scroll_to_id' ),
			'label'        => esc_html__( 'Enable Scroll To ID', 'code4rest' ),
		),
		'lightbox' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'general_performance',
			'default'      => code4rest()->default( 'lightbox' ),
			'label'        => esc_html__( 'Enable Lightbox', 'code4rest' ),
		),
		'load_fonts_local' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'general_performance',
			'default'      => code4rest()->default( 'load_fonts_local' ),
			'label'        => esc_html__( 'Load Google Fonts Locally', 'code4rest' ),
		),
		'preload_fonts_local' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'general_performance',
			'default'      => code4rest()->default( 'preload_fonts_local' ),
			'label'        => esc_html__( 'Preload Local Fonts', 'code4rest' ),
			'context'      => array(
				array(
					'setting'    => 'load_fonts_local',
					'operator'   => '==',
					'value'      => true,
				),
			),
		),
		'load_fonts_local_flush' => array(
			'control_type' => 'code4rest_blank_control',
			'section'      => 'general_performance',
			'settings'     => false,
			'description'  => $code4rest_flush_button,
			'context'      => array(
				array(
					'setting'    => 'load_fonts_local',
					'operator'   => '==',
					'value'      => true,
				),
			),
		),
		'enable_preload' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'general_performance',
			'default'      => code4rest()->default( 'enable_preload' ),
			'label'        => esc_html__( 'Enable CSS Preload', 'code4rest' ),
		),
	)
);
