<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div class="wrap">
	<h1><?php esc_html_e( 'Header & Footer Settings', 'unlock-addons-for-elementor' ); ?></h1>

	<?php if ( isset( $_GET['status'] ) && 'saved' === $_GET['status'] ) : ?>
		<div class="notice notice-success is-dismissible">
			<p><?php esc_html_e( 'Settings updated successfully.', 'unlock-addons-for-elementor' ); ?></p>
		</div>
	<?php endif; ?>

	<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
		<?php wp_nonce_field( 'unlockafe_header_footer_save', 'unlockafe_header_footer_nonce' ); ?>
		<input type="hidden" name="action" value="unlockafe_save_header_footer">

		<table class="form-table">
			<tbody>
				<tr>
					<th scope="row">
						<label for="unlockafe_default_header"><?php esc_html_e( 'Default Header', 'unlock-addons-for-elementor' ); ?></label>
					</th>
					<td>
						<select name="unlockafe_default_header" id="unlockafe_default_header" class="regular-text">
							<option value=""><?php esc_html_e( '— Select Header —', 'unlock-addons-for-elementor' ); ?></option>
							<?php foreach ( $headers as $header ) : ?>
								<option value="<?php echo esc_attr( $header->ID ); ?>" <?php selected( $selected_header, $header->ID ); ?>>
									<?php echo esc_html( $header->post_title ); ?>
								</option>
							<?php endforeach; ?>
						</select>
						<p class="description">
							<?php esc_html_e( 'Choose which header template should load globally across the site.', 'unlock-addons-for-elementor' ); ?>
						</p>
					</td>
				</tr>
				<tr>
					<th scope="row">
						<label for="unlockafe_default_footer"><?php esc_html_e( 'Default Footer', 'unlock-addons-for-elementor' ); ?></label>
					</th>
					<td>
						<select name="unlockafe_default_footer" id="unlockafe_default_footer" class="regular-text">
							<option value=""><?php esc_html_e( '— Select Footer —', 'unlock-addons-for-elementor' ); ?></option>
							<?php foreach ( $footers as $footer ) : ?>
								<option value="<?php echo esc_attr( $footer->ID ); ?>" <?php selected( $selected_footer, $footer->ID ); ?>>
									<?php echo esc_html( $footer->post_title ); ?>
								</option>
							<?php endforeach; ?>
						</select>
						<p class="description">
							<?php esc_html_e( 'Choose which footer template should load globally across the site.', 'unlock-addons-for-elementor' ); ?>
						</p>
					</td>
				</tr>
			</tbody>
		</table>

		<?php submit_button( __( 'Save Settings', 'unlock-addons-for-elementor' ) ); ?>
	</form>
</div>


