<?php 

add_action( 'admin_menu', 'lifestyle_blogger_menu' );
add_action( 'admin_init', 'lifestyle_blogger_register_settings' );

function lifestyle_blogger_menu() {
    add_menu_page(
        'Theme Options',
        'Theme Option',
        'manage_options',
        'lifestyle_blogger_theme_option',
        'lifestyle_blogger_preloader_page_callback',
        'dashicons-screenoptions',
        30
    );
}

function lifestyle_blogger_register_settings() {
    register_setting( 'lifestyle_blogger_preloader_settings', 'lifestyle_blogger_preloader_toggle' );
}

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


    <?php
}
