<?php
$title = $this->getSetting('gdprc_permission_bar_title');
$desc = $this->getSetting('gdprc_permission_bar_desc');
$privacyPolicyLink = $this->getLink('gdprc_privacy_policy_page');
$closeLabel = $this->getSetting('gdprc_permission_bar_close_label');

if ((\gdprc_user_is_logged_in() || empty($this->getSetting('gdpr_consent_maintenance_mode'))) && $this->getSetting('gdprc_permission_bar_enable')):
    ?>
    <?php echo \apply_filters('gdprc_bar_before', ''); ?>
	<div id="gdprc_bar" class="<?php if ($this->getSetting('gdprc_permission_bar_top')) {
        echo 'top';
    }
    echo $this->getEffectsClasses(); ?>">
		<div class="container container_gdprc_bar">
			<div class="gdprc_content">
                <?php echo \apply_filters('gdprc_bar_header', ($title ? '<h3 class="gdprc_content__title">'.$title.'</h3>' : '').($desc ? '<p class="gdprc_content__desc">'.$desc.'</p>' : '')); ?>
                <?php echo \apply_filters('gdprc_bar_links_before', '', '<span class="gdprc_content__link_separator"> | </span>'); ?>
                <?php if ($privacyPolicyLink && $privacyLabel = $this->getSetting('gdprc_permission_bar_privacy_label')) : ?>
					<a href="<?php echo $privacyPolicyLink; ?>" class="gdprc_content__link gdprc_link"><?php echo $privacyLabel; ?></a>

                    <?php if ($closeLabel && \strlen($closeLabel) > 1 && $this->getSetting('gdprc_permission_bar_behavior_accept_all')): ?>
						<span class="gdprc_content__link_separator"> | </span>
                    <?php endif; ?>
                <?php endif; ?>

                <?php if ($closeLabel && $this->getSetting('gdprc_permission_bar_behavior_accept_all')): ?>
                    <?php if (\strlen($closeLabel) === 1): ?>
						<a href="#" class="gdprc_action__close gdprc_button gdprc_action__close--corner"><?php echo(\strtolower($closeLabel) == "x" ? "" : $closeLabel); ?></a>
                    <?php else: ?>
						<a href="#" class="gdprc_action__close gdprc_link"><?php echo $closeLabel; ?></a>
                    <?php endif; ?>
                <?php endif; ?>

                <?php echo \apply_filters('gdprc_bar_links_after', '', '<span class="gdprc_content__link_separator"> | </span>'); ?>
			</div>

			<div class="gdprc_actions">
                <?php
                $consentInterfaceLink = $this->getLink('gdprc_consent_interface_page');
                if (empty($consentInterfaceLink)) {
                    $consentInterfaceLink = '/wp-admin/edit.php?post_type=gdprc_consent&page=options-general.php%3Fpage%3Dgdpr-consent-settings&gdpr-settings=not-configured';
                }
                $consentInterfaceLabel = $this->getSetting('gdprc_permission_bar_settings_label');
                ?>

                <?php if ($this->getSetting('gdprc_permission_bar_behavior_accept_all')) : ?>
                    <?php echo \apply_filters('gdprc_bar_acceptall_before', ''); ?>
					<button class='gdprc_action__bar_save_all gdprc_button gdprc_action button'><?php echo $this->getSetting('gdprc_permission_bar_accept_label') ?></button>

                    <?php if ($consentInterfaceLink && $consentInterfaceLabel): ?>
						<a href="<?php echo $consentInterfaceLink; ?>" class="gdprc_action__settings gdprc_link gdprc_action"><?php echo $consentInterfaceLabel; ?></a>
                    <?php endif; ?>
                    <?php echo \apply_filters('gdprc_bar_acceptall_after', ''); ?>
                <?php else: ?>
                    <?php echo \apply_filters('gdprc_bar_actions_before', ''); ?>
                    <?php if ($consentInterfaceLink && $consentInterfaceLabel): ?>
						<a href="<?php echo $consentInterfaceLink; ?>" class="gdprc_action__settings_href">
							<button class="gdprc_action__settings gdprc_button gdprc_action button"><?php echo $consentInterfaceLabel; ?></button>
						</a>
                    <?php endif; ?>

                    <?php if ($closeLabel = $this->getSetting('gdprc_permission_bar_close_label')): ?>
                        <?php if (\strlen($closeLabel) === 1): ?>
							<a href="#" class="gdprc_action__close gdprc_button gdprc_action gdprc_action__close--corner"><?php echo(\strtolower($closeLabel) == "x" ? "" : $closeLabel); ?></a>
                        <?php else: ?>
							<a href="#" class="gdprc_action__close gdprc_link gdprc_action"><?php echo $closeLabel; ?></a>
                        <?php endif; ?>
                    <?php endif; ?>
                    <?php echo \apply_filters('gdprc_bar_actions_after', ''); ?>
                <?php endif; ?>
			</div>
		</div>
        <?php if ($this->getSetting('gdprc_permission_bar_consents_enable')): ?>
            <?php echo \apply_filters('gdprc_bar_settings_before', ''); ?>
			<div class="container container_gdprc_bar__settings">
                <?php echo \apply_filters('gdprc_bar_settings', \str_replace('gdprc_action__save_all', 'gdprc_action__bar_save_all', \do_shortcode('[gdpr_consent_settings suffix="bar"]'))); ?>
			</div>
            <?php echo \apply_filters('gdprc_bar_settings_after', ''); ?>
        <?php endif; ?>
	</div>
    <?php echo \apply_filters('gdprc_bar_after', ''); ?>
    <?php include __DIR__.'/ThemeStyle.php'; ?>
<?php endif; ?>