<?php
if (!defined('WPINC')) {
    die();
}

$checked = false;

if (isset($value)) {
    if (is_bool($value)) {
        $checked = $value;
    } elseif (is_numeric($value)) {
        $checked = (bool) $value;
    } elseif (is_string($value)) {
        $normalised = strtolower(trim($value));
        $checked = in_array($normalised, ['on', 'true', '1', 'yes'], true);
    }
}

if (!isset($value) && isset($default_checked)) {
    $checked = (bool) $default_checked;
}
?>
<label class="estatebud-toggle-switch">
  <input type="checkbox" name="<?php echo esc_attr($variable_name ?? ''); ?>" value="true"<?php checked($checked); ?>>
  <span class="slider"></span>
</label>