<?php 

add_action( 'admin_menu', 'radiant_blogger_menu' );
add_action( 'admin_init', 'radiant_blogger_register_settings' );

function radiant_blogger_menu() {
    add_menu_page(
        'Theme Options',
        'Theme Option',
        'manage_options',
        'radiant_blogger_theme_option',
        'radiant_blogger_preloader_page_callback',
        'dashicons-screenoptions',
        30
    );
}

function radiant_blogger_register_settings() {
    register_setting( 'radiant_blogger_preloader_settings', 'radiant_blogger_preloader_toggle' );
}

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


    <?php
}
