<?php

namespace WooSwatches\Modules;

use WooSwatches\Base\Module;

final class Advanced_Settings extends Module {

	public function __construct() {
		parent::__construct();
	}

	public function default_settings() {
		return array(
			'clear_reselect'         => true,
			'disable_out_of_stock'   => false,
			'clickable_out_of_stock' => true,
			'disable_attr_style'     => 'fade_with_cross',
			'attr_img_size'          => 'thumbnail',
			'exclude_cat'            => []
		);
	}

	public function validate_settings( $settings ) {

		$settings['clear_reselect']         = wp_validate_boolean( $settings['clear_reselect'] );
		$settings['attr_img_size']          = sanitize_key( $settings['attr_img_size'] );
		$settings['disable_out_of_stock']   = wp_validate_boolean( $settings['disable_out_of_stock'] );
		$settings['clickable_out_of_stock'] = wp_validate_boolean( $settings['clickable_out_of_stock'] );
		$settings['disable_attr_style']     = sanitize_key( $settings['disable_attr_style'] );
		$settings['exclude_cat']            = array_map( 'intval', (array) $settings['exclude_cat'] );

		return $settings;
	}
}
