<?php 

add_action( 'admin_menu', 'cctv_security_system_menu' );
add_action( 'admin_init', 'cctv_security_system_register_settings' );

function cctv_security_system_menu() {
    add_menu_page(
        'Theme Options',
        'Theme Option',
        'manage_options',
        'cctv_security_system_theme_option',
        'cctv_security_system_preloader_page_callback',
        'dashicons-screenoptions',
        30
    );
}

function cctv_security_system_register_settings() {
    register_setting( 'cctv_security_system_preloader_settings', 'cctv_security_system_preloader_toggle' );
}

function cctv_security_system_preloader_page_callback() {
    ?>
    <div class="menu-box">
        <h2><?php echo esc_html('Preloader Setting','cctv-security-system'); ?></h2>
        <form method="post" action="options.php">
            <?php settings_fields( 'cctv_security_system_preloader_settings' ); ?>
            <?php $toggle = get_option( 'cctv_security_system_preloader_toggle', 'off' ); ?>
            <label for="cctv_security_system_preloader_toggle">
                <input type="checkbox" id="cctv_security_system_preloader_toggle" name="cctv_security_system_preloader_toggle" <?php checked( $toggle, 'on' ); ?> />
                <?php echo esc_html('Enable Preloader','cctv-security-system'); ?>
            </label>
            <?php submit_button(); ?>
        </form>
    </div>
    


    <?php
}
