<?php
/**
 * View: Widget Settings metabox (Woo-style layout).
 *
 * @package Ilabs\Firevert\Modules\SpectatorViews
 *
 * @var WP_Post $post
 * @var bool    $firevert_spectator_views_visible_admin_only
 * @var string  $firevert_spectator_views_display_position
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Ilabs\Firevert\Modules\SpectatorViews\Services\Type\SectionType;
use Ilabs\Firevert\Modules\SpectatorViews\Services\Type\PositionType;

$positions = PositionType::get_all();
?>

<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="firevert-form">
	<?php wp_nonce_field( 'firevert_spectator_views_save', 'firevert_spectator_views_nonce' ); ?>
	<input type="hidden" name="action" value="firevert_save_spectator_views">
	<input type="hidden" name="section" value="<?php echo esc_attr( SectionType::SETTINGS ); ?>">
	<input type="hidden" name="post_ID" value="<?php echo esc_attr( $post->ID ); ?>">

	<div class="metabox-holder woocommerce">
		<div class="postbox wc-metabox">
			<div class="postbox-header">
				<h2 class="hndle">
					<span><?php esc_html_e( 'General Display Settings', 'firevert' ); ?></span>
				</h2>
			</div>
			<div class="inside">
				<p>
					<label>
						<input type="checkbox" name="firevert_spectator_views_visible_admin_only"
								value="1" <?php checked( true, $firevert_spectator_views_visible_admin_only ); ?> />
						<?php esc_html_e( 'Visibility for admin only', 'firevert' ); ?>
					</label>
				</p>

				<p>
					<label for="firevert_spectator_views_display_position">
						<?php esc_html_e( 'Widget display position', 'firevert' ); ?>
					</label><br/>
					<select name="firevert_spectator_views_display_position" id="firevert_spectator_views_display_position">
						<?php foreach ( $positions as $value => $label ) : ?>
							<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $firevert_spectator_views_display_position, $value ); ?>>
								<?php echo esc_html( $label ); ?>
							</option>
						<?php endforeach; ?>
					</select>
				</p>
			</div>
		</div>
	</div>

	<?php submit_button( __( 'Save', 'firevert' ) ); ?>
</form>
