<?php
/**
 * Form setting slide switch.
 *
 * @package MacaHold
 *
 * @var string $maca_hold_switch_id
 * @var string $maca_hold_switch_name
 * @var bool   $maca_hold_switch_checked
 * @var string $maca_hold_switch_label
 * @var string $maca_hold_switch_description Optional description below the label.
 */

defined( 'ABSPATH' ) || exit;

if ( empty( $maca_hold_switch_id ) || empty( $maca_hold_switch_name ) || ! isset( $maca_hold_switch_checked ) || ! isset( $maca_hold_switch_label ) ) {
	return;
}

$maca_hold_switch_description = isset( $maca_hold_switch_description ) ? (string) $maca_hold_switch_description : '';
?>
<div class="maca-hold-setting-switch-row">
	<label class="maca-hold-switch maca-hold-switch--setting" for="<?php echo esc_attr( $maca_hold_switch_id ); ?>">
		<input
			type="checkbox"
			id="<?php echo esc_attr( $maca_hold_switch_id ); ?>"
			name="<?php echo esc_attr( $maca_hold_switch_name ); ?>"
			value="1"
			<?php checked( $maca_hold_switch_checked ); ?>
		/>
		<span class="maca-hold-switch-slider" aria-hidden="true"></span>
		<span class="screen-reader-text"><?php echo esc_html( $maca_hold_switch_label ); ?></span>
	</label>
	<div class="maca-hold-setting-switch-copy">
		<span class="maca-hold-setting-switch-label"><?php echo esc_html( $maca_hold_switch_label ); ?></span>
		<?php if ( '' !== $maca_hold_switch_description ) : ?>
			<p class="description"><?php echo esc_html( $maca_hold_switch_description ); ?></p>
		<?php endif; ?>
	</div>
</div>
