<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
$cookie_notice 			= isset($campoal_options['conikal_cookie_notice_field']) ? $campoal_options['conikal_cookie_notice_field'] : 0;
$cookie_notice_style 	= isset($campoal_options['conikal_cookie_notice_style_field']) ? $campoal_options['conikal_cookie_notice_style_field'] : 'toast';
$cookie_notice_content 	= isset($campoal_options['conikal_cookie_notice_content_field']) ? $campoal_options['conikal_cookie_notice_content_field'] : esc_html__('We use cookies to ensure you get the best experience on our website', 'campoal');
$cookie_notice_display 	= isset($campoal_options['conikal_cookie_notice_display_field']) ? $campoal_options['conikal_cookie_notice_display_field'] : 'fixed';
$cookie_notice_position = isset($campoal_options['conikal_cookie_notice_position_field']) ? $campoal_options['conikal_cookie_notice_position_field'] : 'footer';
$cookie_policy_page 	= conikal_get_assign_page('conikal_cookie_policy_page_field');

// status cookie accept from browser
$accepts_cookies 	= isset($_COOKIE['conikal_accepts_cookies']) ? $_COOKIE['conikal_accepts_cookies'] : 0;
?>
<?php if (!is_user_logged_in()) : ?>
	<?php if ($cookie_notice_style == 'sidebar' && !$accepts_cookies) { ?>
		<div class="ui inline cookie sidebar-cookie-notice<?php echo esc_attr($cookie_notice_display == 'fixed' ? ' fixed' : '') ?><?php echo esc_attr($cookie_notice_position == 'footer' ? ' bottom' : '') ?> nag">
		<span class="title">
			<?php echo wp_kses_post($cookie_notice_content); ?>
			<button class="ui inverted mini circular button" id="accept-cookie"><?php esc_html_e('Accept', 'campoal') ?></button>
			<?php if ($cookie_policy_page) : ?>
				<a href="<?php echo esc_url($cookie_policy_page->link) ?>" class="ui inverted mini circular button" id="ignore-cookie"><?php esc_html_e('Details', 'campoal') ?></a>
			<?php else : ?>
				<button class="ui inverted mini circular button" id="ignore-cookie"><?php esc_html_e('Ignore', 'campoal') ?></button>
			<?php endif; ?>
		</span>
		<i class="close icon"></i>
		</div>

	<?php } else if (!$accepts_cookies) { ?>
		<div class="ui primary toast toast-cookie-notice" id="toast-cookie-notice">
			<div class="content">
				<div class="ui small header">
					<i class="puzzle piece icon"></i>
					<div class="content" id="cookie-notice-content">
						<?php esc_html_e('Cookie policy', 'campoal'); ?>
						<div class="sub header">
							<?php echo wp_kses_post($cookie_notice_content); ?>
						</div>
					</div>
				</div>
			</div>
			<div class="left basic actions">
				<button class="ui positive basic tiny button" id="accept-cookie"><?php esc_html_e('Accept', 'campoal') ?></button>
				<?php if ($cookie_policy_page) : ?>
					<a href="<?php echo esc_url($cookie_policy_page->link) ?>" class="ui tertiary basic tiny button"><?php esc_html_e('Details', 'campoal') ?></a>
				<?php else : ?>
					<button class="ui negative basic tiny button" id="ignore-cookie"><?php esc_html_e('Ignore', 'campoal') ?></button>
				<?php endif; ?>
			</div>
			<i class="close icon"></i>
		</div>
	<?php } ?>
<?php endif; ?>