<?php
/**
 * Privacy Bar Template.
 *
 * @author     ThemeFusion
 * @copyright  (c) Copyright by ThemeFusion
 * @link       https://avada.com
 * @package    Avada
 * @subpackage Core
 */

// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
	exit( 'Direct script access denied.' );
}

$show_lifespan          = '1' === Avada()->settings->get( 'privacy_bar_show_lifespan' );
$show_cookie_desc       = '1' === Avada()->settings->get( 'privacy_bar_show_cookie_desc' );
$desc_toggle            = $show_cookie_desc && '1' === Avada()->settings->get( 'privacy_bar_desc_toggle' );
$show_group_toggle      = '1' === Avada()->settings->get( 'privacy_bar_show_group_toggle' );
$group_has_items        = static function( $column ) {
	$type = isset( $column['type'] ) ? $column['type'] : '';
	$key  = isset( $column['key'] ) ? $column['key'] : $type;

	if ( 'embeds' === $type ) {
		$embeds = Avada()->privacy_embeds->get_embed_types();
		if ( is_array( $embeds ) ) {
			foreach ( $embeds as $embed ) {
				if ( ! ( isset( $embed['category'] ) && 'embeds' !== $embed['category'] ) ) {
					return true;
				}
			}
		}
		return false;
	}

	if ( 'statistics' === $type || 'tracking' === $type ) {
		$embed_defaults = Avada()->privacy_embeds->get_embed_defaults();
		$embed_options  = Avada()->settings->get( 'privacy_embed_types' );
		if ( Avada()->settings->get( 'privacy_embeds' ) && is_array( $embed_options ) ) {
			foreach ( $embed_options as $embed_id ) {
				if ( isset( $embed_defaults[ $embed_id ]['category'] ) && $type === $embed_defaults[ $embed_id ]['category'] ) {
					return true;
				}
			}
		}
		$snippets = Avada()->privacy_embeds->get_custom_snippets();
		if ( is_array( $snippets ) ) {
			foreach ( $snippets as $snippet ) {
				if ( ! empty( $snippet['label'] ) && isset( $snippet['category'] ) && $type === $snippet['category'] ) {
					return true;
				}
			}
		}
		return false;
	}

	$snippets = Avada()->privacy_embeds->get_custom_snippets();
	if ( is_array( $snippets ) ) {
		foreach ( $snippets as $snippet ) {
			if ( ! empty( $snippet['label'] ) && isset( $snippet['category'] ) && $key === $snippet['category'] ) {
				return true;
			}
		}
	}
	return false;
};
$group_master_input     = static function( $column ) use ( $show_group_toggle, $group_has_items ) {
	$category = isset( $column['type'] ) ? $column['type'] : '';
	if ( ! $show_group_toggle || 'necessary' === $category || ! $group_has_items( $column ) ) {
		return '';
	}
	return '<input type="checkbox" class="awb-privacy-group-master-input" data-category="' . esc_attr( $category ) . '" aria-label="' . esc_attr__( 'Toggle all items in this group', 'Avada' ) . '">';
};
$desc_toggle_btn        = $desc_toggle ? '<button type="button" class="awb-privacy-desc-toggle awb-rotate" aria-expanded="false" aria-label="' . esc_attr__( 'Toggle description', 'Avada' ) . '"><i class="awb-icon-angle-up"></i></button>' : '';
$consent_item_style     = Avada()->settings->get( 'privacy_bar_consent_item_style' );
$main_layout            = Avada()->settings->get( 'privacy_bar_main_layout' );
$layout_class           = 'edges' === $main_layout ? ' awb-bar-layout-edges' : ( 'stacked' === $main_layout ? ' awb-bar-layout-stacked' : '' );
$bar_class              = 'fusion-privacy-bar fusion-privacy-bar-bottom' . ( $desc_toggle ? ' awb-desc-collapsed' : '' ) . ( 'toggle' === $consent_item_style ? ' fusion-privacy-form--toggle' : '' ) . $layout_class;
$privacy_expiry         = (int) Avada()->settings->get( 'privacy_expiry' );
/* translators: %s: number of days */
$embed_lifespan         = $show_lifespan ? sprintf( _n( '%s day', '%s days', $privacy_expiry, 'Avada' ), $privacy_expiry ) : '';
$settings_text          = Avada()->settings->get( 'privacy_bar_more_text' );
$button_text            = Avada()->settings->get( 'privacy_bar_button_text' );
$button_alt_text        = Avada()->settings->get( 'privacy_bar_update_text' );
$text                   = Avada()->settings->get( 'privacy_bar_text' );
$content                = Avada()->privacy_embeds->get_privacy_content();
$content_count          = is_array( $content ) ? count( $content ) : 0;
$column_size            = 0 !== $content_count ? floor( 12 / $content_count ) : 0;
$more                   = '0' !== Avada()->settings->get( 'privacy_bar_more' ) && 0 !== $content_count;
$reject_button          = Avada()->settings->get( 'privacy_bar_reject' );
$reject_button_text     = Avada()->settings->get( 'privacy_bar_reject_text' );
$accept_all_button      = Avada()->settings->get( 'privacy_bar_accept_all' );
$accept_all_button_text = Avada()->settings->get( 'privacy_bar_accept_all_text' );
$more_style             = Avada()->settings->get( 'privacy_bar_more_style' );
$layout                 = Avada()->settings->get( 'privacy_bar_content_layout' );
?>
<div class="<?php echo esc_attr( $bar_class ); ?>">
	<div class="fusion-privacy-bar-main">
		<span><?php echo do_shortcode( $text ); ?>
			<?php if ( $more && 'link' === $more_style ) : ?>
				<a href="#" class="fusion-privacy-bar-learn-more awb-rotate"><?php echo esc_attr( $settings_text ); ?> <i class="awb-icon-angle-up" aria-hidden="true"></i></a>
			<?php endif; ?>
		</span>
		<div class="fusion-privacy-bar-buttons">
			<?php if ( $more && 'link_buttons' === $more_style ) : ?>
			<a href="#" class="fusion-privacy-bar-learn-more awb-rotate"><?php echo esc_attr( $settings_text ); ?> <i class="awb-icon-angle-up" aria-hidden="true"></i></a>
			<?php endif; ?>
			<?php if ( $more && 'button' === $more_style ) : ?>
			<a href="#" class="fusion-privacy-bar-learn-more fusion-button fusion-button-default fusion-button-default-size fusion-button-span-no">
				<?php echo esc_html( $settings_text ); ?>
			</a>
			<?php endif; ?>
			<a href="#" class="fusion-privacy-bar-acceptance fusion-button fusion-button-default fusion-button-default-size fusion-button-span-no" data-alt-text="<?php echo esc_attr( $button_alt_text ); ?>" data-orig-text="<?php echo esc_attr( $button_text ); ?>"<?php if ( 'contextual' === Avada()->settings->get( 'privacy_bar_button_save' ) ) : ?> style="display:none;"<?php endif; ?>>
				<?php echo esc_html( $button_text ); ?>
			</a>
			<?php if ( $accept_all_button ) : ?>
			<a href="#" class="fusion-privacy-bar-accept-all fusion-button fusion-button-default fusion-button-default-size fusion-button-span-no">
				<?php echo esc_html( $accept_all_button_text ); ?>
			</a>
			<?php endif; ?>
			<?php if ( $reject_button ) : ?>
			<a href="#" class="fusion-privacy-bar-reject fusion-button fusion-button-default fusion-button-default-size fusion-button-span-no">
				<?php echo esc_html( $reject_button_text ); ?>
			</a>
			<?php endif; ?>
		</div>
	</div>
	<?php if ( $more ) : ?>
	<div class="fusion-privacy-bar-full">
		<div class="fusion-row awb-layout-<?php echo esc_attr( $layout ); ?>">
			<?php if ( 'tabs' === $layout ) : ?>
				<div class="fusion-tabs fusion-tabs-classic fusion-tabs-horizontal">
					<ul class="nav-tabs nav">
						<?php foreach ( $content as $key => $column ) : ?>
							<li class="<?php echo 0 === $key ? 'active' : ''; ?>">
								<a href="#privacy-tab-<?php echo esc_attr( $key ); ?>" class="tab-link" data-toggle="tab"><?php echo esc_html( $column['title'] ); ?></a>
								<?php echo $group_master_input( $column ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
							</li>
						<?php endforeach; ?>
					</ul>
					<div class="tab-content">
						<?php foreach ( $content as $key => $column ) : ?>
							<div class="tab-pane fade <?php echo 0 === $key ? 'in active' : ''; ?>" id="privacy-tab-<?php echo esc_attr( $key ); ?>">
								<?php if ( '' !== $column['description'] ) : ?>
									<?php echo $column['description']; // phpcs:ignore WordPress.Security.EscapeOutput ?>
								<?php endif; ?>

								<?php if ( 'embeds' === $column['type'] && Avada()->settings->get( 'privacy_embeds' ) ) : ?>
									<?php $embeds = Avada()->privacy_embeds->get_embed_types(); ?>
									<ul class="fusion-privacy-choices">
									<?php if ( is_array( $embeds ) ) : ?>
										<?php foreach ( $embeds as $id => $embed ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride ?>
											<?php $selected = Avada()->privacy_embeds->is_selected( $id ) ? 'checked' : ''; ?>
											<?php
											$is_categorized = isset( $embed['category'] ) && 'embeds' !== $embed['category'];
											if ( ! $is_categorized ) : ?>
												<li>
													<label for="bar-tab-<?php echo esc_attr( $id ); ?>">
														<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $id ); ?>" <?php echo esc_attr( $selected ); ?> id="bar-tab-<?php echo esc_attr( $id ); ?>">
														<span class="label-text">
															<?php echo esc_html( $embed['label'] ); ?>
															<?php $lifespan = ! empty( $embed['lifespan'] ) ? $embed['lifespan'] : $embed_lifespan; ?>
															<?php if ( $show_lifespan && ! empty( $lifespan ) ) : ?>
																<span class="awb-cookie-lifespan"><?php echo esc_html( $lifespan ); ?></span>
															<?php endif; ?>
														</span>
													</label>
													<?php $embed_desc = Avada()->privacy_embeds->get_embed_description( $id, $embed ); ?>
												<?php if ( $show_cookie_desc && ! empty( $embed_desc ) ) : ?>
													<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $embed_desc ); ?></p>
												<?php endif; ?>
											</li>
										<?php endif; ?>
									<?php endforeach; ?>
								<?php endif; ?>
								</ul>
							<?php elseif ( 'necessary' === $column['type'] && Avada()->settings->get( 'privacy_embeds' ) ) : ?>
									<ul class="fusion-privacy-choices">
										<?php if ( '1' === Avada()->settings->get( 'privacy_bar_show_wp_cookies' ) ) : ?>
										<?php foreach ( Avada()->privacy_embeds->get_default_wp_cookies() as $cookie_name => $cookie_data ) : ?>
										<li class="is-necessary">
											<label for="bar-tab-<?php echo esc_attr( $cookie_name ); ?>" style="pointer-events:none;">
												<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $cookie_name ); ?>" checked="checked" disabled="disabled" id="bar-tab-<?php echo esc_attr( $cookie_name ); ?>">
												<span class="label-text">
													<?php echo esc_html( $cookie_name ); ?>
													<?php if ( $show_lifespan && ! empty( $cookie_data['lifespan'] ) ) : ?>
														<span class="awb-cookie-lifespan"><?php echo esc_html( $cookie_data['lifespan'] ); ?></span>
													<?php endif; ?>
												</span>
											</label>
											<?php if ( $show_cookie_desc && ! empty( $cookie_data['description'] ) ) : ?>
												<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $cookie_data['description'] ); ?></p>
											<?php endif; ?>
										</li>
										<?php endforeach; ?>
										<?php foreach ( Avada()->privacy_embeds->get_plugin_necessary_cookies() as $cookie_name => $cookie_data ) : ?>
										<li class="is-necessary">
											<label for="bar-tab-<?php echo esc_attr( $cookie_name ); ?>" style="pointer-events:none;">
												<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $cookie_name ); ?>" checked="checked" disabled="disabled" id="bar-tab-<?php echo esc_attr( $cookie_name ); ?>">
												<span class="label-text">
													<?php echo esc_html( $cookie_name ); ?>
													<?php if ( $show_lifespan && ! empty( $cookie_data['lifespan'] ) ) : ?>
														<span class="awb-cookie-lifespan"><?php echo esc_html( $cookie_data['lifespan'] ); ?></span>
													<?php endif; ?>
												</span>
											</label>
											<?php if ( $show_cookie_desc && ! empty( $cookie_data['description'] ) ) : ?>
												<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $cookie_data['description'] ); ?></p>
											<?php endif; ?>
										</li>
										<?php endforeach; ?>
										<?php endif; ?>
										<?php
										$snippets = Avada()->privacy_embeds->get_custom_snippets();
										if ( is_array( $snippets ) ) :
											foreach ( $snippets as $index => $snippet ) :
												if ( 'necessary' === $snippet['category'] ) :
													$snip_key = Avada()->privacy_embeds->get_snippet_key( $index ); ?>
													<li class="is-necessary">
														<label for="bar-tab-<?php echo esc_attr( $snip_key ); ?>" style="pointer-events:none;">
															<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $snip_key ); ?>" checked="checked" disabled="disabled" id="bar-tab-<?php echo esc_attr( $snip_key ); ?>">
															<span class="label-text">
																<?php echo esc_html( $snippet['label'] ); ?>
																<?php if ( $show_lifespan && ! empty( $snippet['lifespan'] ) ) : ?>
																	<span class="awb-cookie-lifespan"><?php echo esc_html( $snippet['lifespan'] ); ?></span>
																<?php endif; ?>
															</span>
														</label>
														<?php if ( $show_cookie_desc && ! empty( $snippet['snippet_description'] ) ) : ?>
															<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $snippet['snippet_description'] ); ?></p>
														<?php endif; ?>
													</li>
												<?php endif;
											endforeach;
										endif;
										?>
									</ul>
								<?php elseif ( 'statistics' === $column['type'] ) : ?>
									<?php
									$embed_defaults = Avada()->privacy_embeds->get_embed_defaults();
									$embed_options  = Avada()->settings->get( 'privacy_embed_types' );
									$snippets       = Avada()->privacy_embeds->get_custom_snippets();
									?>
									<ul class="fusion-privacy-choices">
										<?php if ( Avada()->settings->get( 'privacy_embeds' ) && is_array( $embed_options ) ) : ?>
											<?php foreach ( $embed_options as $embed_id ) : ?>
												<?php if ( ! isset( $embed_defaults[ $embed_id ]['category'] ) || 'statistics' !== $embed_defaults[ $embed_id ]['category'] ) : ?>
													<?php continue; ?>
												<?php endif; ?>
												<?php
												$gcm_embed     = $embed_defaults[ $embed_id ];
												$gcm_selected  = Avada()->privacy_embeds->is_selected( $embed_id ) ? 'checked' : '';
												$gcm_label_opt = Avada()->settings->get( 'privacy_' . $embed_id . '_label' );
												$gcm_label     = ( '' === $gcm_label_opt ) ? $gcm_embed['label'] : $gcm_label_opt;
												$gcm_desc      = Avada()->settings->get( 'privacy_' . $embed_id . '_description' );
												?>
												<li>
													<label for="bar-tab-<?php echo esc_attr( $embed_id ); ?>">
														<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $embed_id ); ?>" <?php echo esc_attr( $gcm_selected ); ?> id="bar-tab-<?php echo esc_attr( $embed_id ); ?>">
														<span class="label-text">
															<?php echo esc_html( $gcm_label ); ?>
															<?php if ( $show_lifespan && ! empty( $embed_lifespan ) ) : ?>
																<span class="awb-cookie-lifespan"><?php echo esc_html( $embed_lifespan ); ?></span>
															<?php endif; ?>
														</span>
													</label>
													<?php if ( $show_cookie_desc && ! empty( $gcm_desc ) ) : ?>
														<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $gcm_desc ); ?></p>
													<?php endif; ?>
												</li>
											<?php endforeach; ?>
										<?php endif; ?>
										<?php if ( is_array( $snippets ) ) : ?>
											<?php foreach ( $snippets as $index => $snippet ) : ?>
												<?php if ( 'statistics' !== $snippet['category'] || empty( $snippet['label'] ) ) : ?>
													<?php continue; ?>
												<?php endif; ?>
												<?php
												$snip_key     = Avada()->privacy_embeds->get_snippet_key( $index );
												$snip_checked = Avada()->privacy_embeds->is_selected( $snip_key ) ? 'checked' : '';
												?>
												<li>
													<label for="bar-tab-<?php echo esc_attr( $snip_key ); ?>">
														<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $snip_key ); ?>" <?php echo esc_attr( $snip_checked ); ?> id="bar-tab-<?php echo esc_attr( $snip_key ); ?>">
														<span class="label-text">
															<?php echo esc_html( $snippet['label'] ); ?>
															<?php if ( $show_lifespan && ! empty( $snippet['lifespan'] ) ) : ?>
																<span class="awb-cookie-lifespan"><?php echo esc_html( $snippet['lifespan'] ); ?></span>
															<?php endif; ?>
														</span>
													</label>
													<?php if ( $show_cookie_desc && ! empty( $snippet['snippet_description'] ) ) : ?>
														<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $snippet['snippet_description'] ); ?></p>
													<?php endif; ?>
												</li>
											<?php endforeach; ?>
										<?php endif; ?>
									</ul>
								<?php elseif ( 'tracking' === $column['type'] ) : ?>
									<?php
									$embed_defaults = Avada()->privacy_embeds->get_embed_defaults();
									$embed_options  = Avada()->settings->get( 'privacy_embed_types' );
									$privacy_embeds = Avada()->settings->get( 'privacy_embeds' );
									$snippets       = Avada()->privacy_embeds->get_custom_snippets();
									?>
									<ul class="fusion-privacy-choices">
										<?php if ( $privacy_embeds && is_array( $embed_options ) ) : ?>
											<?php foreach ( $embed_options as $embed_id ) : ?>
												<?php if ( ! isset( $embed_defaults[ $embed_id ]['category'] ) || 'tracking' !== $embed_defaults[ $embed_id ]['category'] ) : continue; endif; ?>
												<?php
												$gcm_embed     = isset( $embed_defaults[ $embed_id ] ) ? $embed_defaults[ $embed_id ] : [];
												$gcm_selected  = Avada()->privacy_embeds->is_selected( $embed_id ) ? 'checked' : '';
												$gcm_label_opt = Avada()->settings->get( 'privacy_' . $embed_id . '_label' );
												$gcm_label     = ( '' === $gcm_label_opt ) ? ( isset( $gcm_embed['label'] ) ? $gcm_embed['label'] : $embed_id ) : $gcm_label_opt;
												$gcm_desc      = Avada()->settings->get( 'privacy_' . $embed_id . '_description' );
												?>
												<li>
													<label for="bar-tab-<?php echo esc_attr( $embed_id ); ?>">
														<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $embed_id ); ?>" <?php echo esc_attr( $gcm_selected ); ?> id="bar-tab-<?php echo esc_attr( $embed_id ); ?>">
														<span class="label-text">
															<?php echo esc_html( $gcm_label ); ?>
															<?php if ( $show_lifespan && ! empty( $embed_lifespan ) ) : ?>
																<span class="awb-cookie-lifespan"><?php echo esc_html( $embed_lifespan ); ?></span>
															<?php endif; ?>
														</span>
													</label>
													<?php if ( $show_cookie_desc && ! empty( $gcm_desc ) ) : ?>
														<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $gcm_desc ); ?></p>
													<?php endif; ?>
												</li>
											<?php endforeach; ?>
										<?php endif; ?>
										<?php if ( is_array( $snippets ) ) : ?>
											<?php foreach ( $snippets as $index => $snippet ) : ?>
												<?php if ( 'tracking' !== $snippet['category'] || empty( $snippet['label'] ) ) : continue; endif; ?>
												<?php
												$snip_key     = Avada()->privacy_embeds->get_snippet_key( $index );
												$snip_checked = Avada()->privacy_embeds->is_selected( $snip_key ) ? 'checked' : '';
												?>
												<li>
													<label for="bar-tab-<?php echo esc_attr( $snip_key ); ?>">
														<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $snip_key ); ?>" <?php echo esc_attr( $snip_checked ); ?> id="bar-tab-<?php echo esc_attr( $snip_key ); ?>">
														<span class="label-text">
															<?php echo esc_html( $snippet['label'] ); ?>
															<?php if ( $show_lifespan && ! empty( $snippet['lifespan'] ) ) : ?>
																<span class="awb-cookie-lifespan"><?php echo esc_html( $snippet['lifespan'] ); ?></span>
															<?php endif; ?>
														</span>
													</label>
													<?php if ( $show_cookie_desc && ! empty( $snippet['snippet_description'] ) ) : ?>
														<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $snippet['snippet_description'] ); ?></p>
													<?php endif; ?>
												</li>
											<?php endforeach; ?>
										<?php endif; ?>
									</ul>
								<?php else : ?>
									<?php
									$snippets = Avada()->privacy_embeds->get_custom_snippets();
									$col_key   = isset( $column['key'] ) ? $column['key'] : $column['type'];
									$col_snips = [];
									if ( is_array( $snippets ) ) {
										foreach ( $snippets as $_idx => $_snip ) {
											if ( ! empty( $_snip['label'] ) && isset( $_snip['category'] ) && $col_key === $_snip['category'] ) {
												$col_snips[ $_idx ] = $_snip;
											}
										}
									}
									?>
									<?php if ( ! empty( $col_snips ) ) : ?>
									<ul class="fusion-privacy-choices">
										<?php foreach ( $col_snips as $_idx => $_snip ) : ?>
											<?php
											$snip_key     = Avada()->privacy_embeds->get_snippet_key( $_idx );
											$snip_checked = Avada()->privacy_embeds->is_selected( $snip_key ) ? 'checked' : '';
											?>
											<li>
												<label for="bar-tab-<?php echo esc_attr( $snip_key ); ?>">
													<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $snip_key ); ?>" <?php echo esc_attr( $snip_checked ); ?> id="bar-tab-<?php echo esc_attr( $snip_key ); ?>">
													<span class="label-text">
														<?php echo esc_html( $_snip['label'] ); ?>
														<?php if ( $show_lifespan && ! empty( $_snip['lifespan'] ) ) : ?>
															<span class="awb-cookie-lifespan"><?php echo esc_html( $_snip['lifespan'] ); ?></span>
														<?php endif; ?>
													</span>
												</label>
												<?php if ( $show_cookie_desc && ! empty( $_snip['snippet_description'] ) ) : ?>
													<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $_snip['snippet_description'] ); ?></p>
												<?php endif; ?>
											</li>
										<?php endforeach; ?>
									</ul>
									<?php endif; ?>
								<?php endif; ?>
							</div>
						<?php endforeach; ?>
					</div>
				</div>
			<?php // Column layout. ?>
			<?php else : ?>
				<?php $col_class = 'col-lg-' . $column_size . ' col-md-' . $column_size . ' col-sm-' . $column_size; ?>
				<div class="fusion-columns row fusion-columns-<?php echo esc_attr( $content_count ); ?> columns columns-<?php echo esc_attr( $content_count ); ?>">
					<?php foreach ( $content as $key => $column ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride ?>
					<div class="fusion-column <?php echo esc_attr( $col_class ); ?>">
						<?php if ( '' !== $column['title'] ) : ?>
							<div class="fusion-privacy-group-heading">
								<h4 class="column-title"><?php echo esc_html( $column['title'] ); ?></h4>
								<?php echo $group_master_input( $column ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
							</div>
						<?php else : ?>
							<?php $master_input_html = $group_master_input( $column ); ?>
							<?php if ( '' !== $master_input_html ) : ?>
								<div class="fusion-privacy-group-heading">
									<?php echo $master_input_html; // phpcs:ignore WordPress.Security.EscapeOutput ?>
								</div>
							<?php endif; ?>
						<?php endif; ?>

						<?php if ( '' !== $column['description'] ) : ?>
							<?php echo $column['description']; // phpcs:ignore WordPress.Security.EscapeOutput ?>
						<?php endif; ?>

						<?php if ( 'embeds' === $column['type'] && Avada()->settings->get( 'privacy_embeds' ) ) : ?>
							<?php $embeds = Avada()->privacy_embeds->get_embed_types(); ?>

							<ul class="fusion-privacy-choices">

							<?php if ( is_array( $embeds ) ) : ?>
								<?php foreach ( $embeds as $id => $embed ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride ?>
									<?php $selected = Avada()->privacy_embeds->is_selected( $id ) ? 'checked' : ''; ?>

									<?php 
									$is_categorized = isset( $embed['category'] ) && 'embeds' !== $embed['category'];
									if ( ! $is_categorized ) : ?>
										<li>
											<label for="bar-<?php echo esc_attr( $id ); ?>">
												<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $id ); ?>" <?php echo esc_attr( $selected ); ?> id="bar-<?php echo esc_attr( $id ); ?>">
												<span class="label-text">
													<?php echo esc_html( $embed['label'] ); ?>
													<?php $lifespan = ! empty( $embed['lifespan'] ) ? $embed['lifespan'] : $embed_lifespan; ?>
													<?php if ( $show_lifespan && ! empty( $lifespan ) ) : ?>
														<span class="awb-cookie-lifespan"><?php echo esc_html( $lifespan ); ?></span>
													<?php endif; ?>
												</span>
											</label>
											<?php $embed_desc = Avada()->privacy_embeds->get_embed_description( $id, $embed ); ?>
											<?php if ( $show_cookie_desc && ! empty( $embed_desc ) ) : ?>
												<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $embed_desc ); ?></p>
											<?php endif; ?>
										</li>
									<?php endif; ?>

								<?php endforeach; ?>
							<?php endif; ?>

							</ul>

						<?php elseif ( 'necessary' === $column['type'] && Avada()->settings->get( 'privacy_embeds' ) ) : ?>
							<ul class="fusion-privacy-choices">
								<?php if ( '1' === Avada()->settings->get( 'privacy_bar_show_wp_cookies' ) ) : ?>
								<?php foreach ( Avada()->privacy_embeds->get_default_wp_cookies() as $cookie_name => $cookie_data ) : ?>
								<li class="is-necessary">
									<label for="bar-<?php echo esc_attr( $cookie_name ); ?>" style="pointer-events:none;">
										<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $cookie_name ); ?>" checked="checked" disabled="disabled" id="bar-<?php echo esc_attr( $cookie_name ); ?>">
										<span class="label-text">
											<?php echo esc_html( $cookie_name ); ?>
											<?php if ( $show_lifespan && ! empty( $cookie_data['lifespan'] ) ) : ?>
												<span class="awb-cookie-lifespan"><?php echo esc_html( $cookie_data['lifespan'] ); ?></span>
											<?php endif; ?>
										</span>
									</label>
									<?php if ( $show_cookie_desc && ! empty( $cookie_data['description'] ) ) : ?>
										<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $cookie_data['description'] ); ?></p>
									<?php endif; ?>
								</li>
								<?php endforeach; ?>
								<?php foreach ( Avada()->privacy_embeds->get_plugin_necessary_cookies() as $cookie_name => $cookie_data ) : ?>
								<li class="is-necessary">
									<label for="bar-<?php echo esc_attr( $cookie_name ); ?>" style="pointer-events:none;">
										<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $cookie_name ); ?>" checked="checked" disabled="disabled" id="bar-<?php echo esc_attr( $cookie_name ); ?>">
										<span class="label-text">
											<?php echo esc_html( $cookie_name ); ?>
											<?php if ( $show_lifespan && ! empty( $cookie_data['lifespan'] ) ) : ?>
												<span class="awb-cookie-lifespan"><?php echo esc_html( $cookie_data['lifespan'] ); ?></span>
											<?php endif; ?>
										</span>
									</label>
									<?php if ( $show_cookie_desc && ! empty( $cookie_data['description'] ) ) : ?>
										<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $cookie_data['description'] ); ?></p>
									<?php endif; ?>
								</li>
								<?php endforeach; ?>
								<?php endif; ?>
								<?php
								$snippets = Avada()->privacy_embeds->get_custom_snippets();
								if ( is_array( $snippets ) ) :
									foreach ( $snippets as $index => $snippet ) :
										if ( 'necessary' === $snippet['category'] ) :
											$snip_key = Avada()->privacy_embeds->get_snippet_key( $index ); ?>
											<li class="is-necessary">
												<label for="bar-<?php echo esc_attr( $snip_key ); ?>" style="pointer-events:none;">
													<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $snip_key ); ?>" checked="checked" disabled="disabled" id="bar-<?php echo esc_attr( $snip_key ); ?>">
													<span class="label-text">
														<?php echo esc_html( $snippet['label'] ); ?>
														<?php if ( $show_lifespan && ! empty( $snippet['lifespan'] ) ) : ?>
															<span class="awb-cookie-lifespan"><?php echo esc_html( $snippet['lifespan'] ); ?></span>
														<?php endif; ?>
													</span>
												</label>
												<?php if ( $show_cookie_desc && ! empty( $snippet['snippet_description'] ) ) : ?>
													<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $snippet['snippet_description'] ); ?></p>
												<?php endif; ?>
											</li>
										<?php endif;
									endforeach;
								endif;
								?>
							</ul>
						<?php elseif ( 'statistics' === $column['type'] ) : ?>
							<?php
							$embed_defaults = Avada()->privacy_embeds->get_embed_defaults();
							$embed_options  = Avada()->settings->get( 'privacy_embed_types' );
							$snippets       = Avada()->privacy_embeds->get_custom_snippets();
							?>
							<ul class="fusion-privacy-choices">
								<?php if ( Avada()->settings->get( 'privacy_embeds' ) && is_array( $embed_options ) ) : ?>
									<?php foreach ( $embed_options as $embed_id ) : ?>
										<?php if ( ! isset( $embed_defaults[ $embed_id ]['category'] ) || 'statistics' !== $embed_defaults[ $embed_id ]['category'] ) : ?>
											<?php continue; ?>
										<?php endif; ?>
										<?php
										$gcm_embed     = $embed_defaults[ $embed_id ];
										$gcm_selected  = Avada()->privacy_embeds->is_selected( $embed_id ) ? 'checked' : '';
										$gcm_label_opt = Avada()->settings->get( 'privacy_' . $embed_id . '_label' );
										$gcm_label     = ( '' === $gcm_label_opt ) ? $gcm_embed['label'] : $gcm_label_opt;
										$gcm_desc      = Avada()->settings->get( 'privacy_' . $embed_id . '_description' );
										?>
										<li>
											<label for="bar-<?php echo esc_attr( $embed_id ); ?>">
												<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $embed_id ); ?>" <?php echo esc_attr( $gcm_selected ); ?> id="bar-<?php echo esc_attr( $embed_id ); ?>">
												<span class="label-text">
													<?php echo esc_html( $gcm_label ); ?>
													<?php if ( $show_lifespan && ! empty( $embed_lifespan ) ) : ?>
														<span class="awb-cookie-lifespan"><?php echo esc_html( $embed_lifespan ); ?></span>
													<?php endif; ?>
												</span>
											</label>
											<?php if ( $show_cookie_desc && ! empty( $gcm_desc ) ) : ?>
												<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $gcm_desc ); ?></p>
											<?php endif; ?>
										</li>
									<?php endforeach; ?>
								<?php endif; ?>
								<?php if ( is_array( $snippets ) ) : ?>
									<?php foreach ( $snippets as $index => $snippet ) : ?>
										<?php if ( 'statistics' !== $snippet['category'] || empty( $snippet['label'] ) ) : ?>
											<?php continue; ?>
										<?php endif; ?>
										<?php
										$snip_key     = Avada()->privacy_embeds->get_snippet_key( $index );
										$snip_checked = Avada()->privacy_embeds->is_selected( $snip_key ) ? 'checked' : '';
										?>
										<li>
											<label for="bar-<?php echo esc_attr( $snip_key ); ?>">
												<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $snip_key ); ?>" <?php echo esc_attr( $snip_checked ); ?> id="bar-<?php echo esc_attr( $snip_key ); ?>">
												<span class="label-text">
													<?php echo esc_html( $snippet['label'] ); ?>
													<?php if ( $show_lifespan && ! empty( $snippet['lifespan'] ) ) : ?>
														<span class="awb-cookie-lifespan"><?php echo esc_html( $snippet['lifespan'] ); ?></span>
													<?php endif; ?>
												</span>
											</label>
											<?php if ( $show_cookie_desc && ! empty( $snippet['snippet_description'] ) ) : ?>
												<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $snippet['snippet_description'] ); ?></p>
											<?php endif; ?>
										</li>
									<?php endforeach; ?>
								<?php endif; ?>
							</ul>

						<?php elseif ( 'tracking' === $column['type'] ) : ?>
							<?php
							$embed_defaults = Avada()->privacy_embeds->get_embed_defaults();
							$embed_options  = Avada()->settings->get( 'privacy_embed_types' );
							$privacy_embeds = Avada()->settings->get( 'privacy_embeds' );
							$snippets       = Avada()->privacy_embeds->get_custom_snippets();
							?>
							<ul class="fusion-privacy-choices">
								<?php if ( $privacy_embeds && is_array( $embed_options ) ) : ?>
									<?php foreach ( $embed_options as $embed_id ) : ?>
										<?php if ( ! isset( $embed_defaults[ $embed_id ]['category'] ) || 'tracking' !== $embed_defaults[ $embed_id ]['category'] ) : continue; endif; ?>
										<?php
										$gcm_embed     = isset( $embed_defaults[ $embed_id ] ) ? $embed_defaults[ $embed_id ] : [];
										$gcm_selected  = Avada()->privacy_embeds->is_selected( $embed_id ) ? 'checked' : '';
										$gcm_label_opt = Avada()->settings->get( 'privacy_' . $embed_id . '_label' );
										$gcm_label     = ( '' === $gcm_label_opt ) ? ( isset( $gcm_embed['label'] ) ? $gcm_embed['label'] : $embed_id ) : $gcm_label_opt;
										$gcm_desc      = Avada()->settings->get( 'privacy_' . $embed_id . '_description' );
										?>
										<li>
											<label for="bar-<?php echo esc_attr( $embed_id ); ?>">
												<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $embed_id ); ?>" <?php echo esc_attr( $gcm_selected ); ?> id="bar-<?php echo esc_attr( $embed_id ); ?>">
												<span class="label-text">
													<?php echo esc_html( $gcm_label ); ?>
													<?php if ( $show_lifespan && ! empty( $embed_lifespan ) ) : ?>
														<span class="awb-cookie-lifespan"><?php echo esc_html( $embed_lifespan ); ?></span>
													<?php endif; ?>
												</span>
											</label>
											<?php if ( $show_cookie_desc && ! empty( $gcm_desc ) ) : ?>
												<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $gcm_desc ); ?></p>
											<?php endif; ?>
										</li>
									<?php endforeach; ?>
								<?php endif; ?>
								<?php if ( is_array( $snippets ) ) : ?>
									<?php foreach ( $snippets as $index => $snippet ) : ?>
										<?php if ( 'tracking' !== $snippet['category'] || empty( $snippet['label'] ) ) : continue; endif; ?>
										<?php
										$snip_key     = Avada()->privacy_embeds->get_snippet_key( $index );
										$snip_checked = Avada()->privacy_embeds->is_selected( $snip_key ) ? 'checked' : '';
										?>
										<li>
											<label for="bar-<?php echo esc_attr( $snip_key ); ?>">
												<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $snip_key ); ?>" <?php echo esc_attr( $snip_checked ); ?> id="bar-<?php echo esc_attr( $snip_key ); ?>">
												<span class="label-text">
													<?php echo esc_html( $snippet['label'] ); ?>
													<?php if ( $show_lifespan && ! empty( $snippet['lifespan'] ) ) : ?>
														<span class="awb-cookie-lifespan"><?php echo esc_html( $snippet['lifespan'] ); ?></span>
													<?php endif; ?>
												</span>
											</label>
											<?php if ( $show_cookie_desc && ! empty( $snippet['snippet_description'] ) ) : ?>
												<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $snippet['snippet_description'] ); ?></p>
											<?php endif; ?>
										</li>
									<?php endforeach; ?>
								<?php endif; ?>
							</ul>
						<?php else : ?>
							<?php
							$snippets  = Avada()->privacy_embeds->get_custom_snippets();
							$col_key   = isset( $column['key'] ) ? $column['key'] : $column['type'];
							$col_snips = [];
							if ( is_array( $snippets ) ) {
								foreach ( $snippets as $_idx => $_snip ) {
									if ( ! empty( $_snip['label'] ) && isset( $_snip['category'] ) && $col_key === $_snip['category'] ) {
										$col_snips[ $_idx ] = $_snip;
									}
								}
							}
							?>
							<?php if ( ! empty( $col_snips ) ) : ?>
							<ul class="fusion-privacy-choices">
								<?php foreach ( $col_snips as $_idx => $_snip ) : ?>
									<?php
									$snip_key     = Avada()->privacy_embeds->get_snippet_key( $_idx );
									$snip_checked = Avada()->privacy_embeds->is_selected( $snip_key ) ? 'checked' : '';
									?>
									<li>
										<label for="bar-<?php echo esc_attr( $snip_key ); ?>">
											<input name="consents[]" type="checkbox" value="<?php echo esc_attr( $snip_key ); ?>" <?php echo esc_attr( $snip_checked ); ?> id="bar-<?php echo esc_attr( $snip_key ); ?>">
											<span class="label-text">
												<?php echo esc_html( $_snip['label'] ); ?>
												<?php if ( $show_lifespan && ! empty( $_snip['lifespan'] ) ) : ?>
													<span class="awb-cookie-lifespan"><?php echo esc_html( $_snip['lifespan'] ); ?></span>
												<?php endif; ?>
											</span>
										</label>
										<?php if ( $show_cookie_desc && ! empty( $_snip['snippet_description'] ) ) : ?>
											<?php echo $desc_toggle_btn; ?><p class="awb-cookie-description"><?php echo esc_html( $_snip['snippet_description'] ); ?></p>
										<?php endif; ?>
									</li>
								<?php endforeach; ?>
							</ul>
							<?php endif; ?>
						<?php endif; ?>

					</div>
					<?php endforeach; ?>
				</div>
			<?php endif; ?>
		</div>
	</div>
	<?php endif; ?>
</div>
