<?php
namespace NeoRename\NeoGlobal; if (!defined("ABSPATH")) { die("neoWP direct access not allowed"); }

function echo_switch_for_option($option_name, $label_text = "", $only_enabled_if_pro = false, $js_function_on_change = null) {
    ?><!-- Schalter für Option <?php echo esc_attr($option_name) ?> --><?php 
    $is_checked = \NeoRename\NeoGlobal\get_or_set_option($option_name);
    if ($only_enabled_if_pro) { $is_checked = false; }
    ?><neo-switch-neo-rename 
        data-switch-for-option-name="<?php echo esc_attr($option_name)?>"
        <?php if ($is_checked) { echo " checked"; }?>
        <?php if ($only_enabled_if_pro) { echo " only-enabled-if-pro"; }?>
        label="<?php echo esc_attr($label_text);?>"
        onchange="return window.neoChangeSwitchForOptionNeoRename(this, <?php echo esc_attr($js_function_on_change ?? 'null')?>)"
    ></neo-switch-neo-rename><?php
    \NeoRename\NeoGlobal\add_action_hook("admin_footer", function () {
        \NeoRename\NeoGlobal\enqueue_js("_global-web-component-neo-switch-for-option.js");
    });
}
