<?php 

function candles_shop_add_admin_menu() {
    add_menu_page(
        'Theme Settings', // Page title
        'Theme Settings', // Menu title
        'manage_options', // Capability
        'candles-shop-theme-settings', // Menu slug
        'candles_shop_settings_page' // Function to display the page
    );
}
add_action( 'admin_menu', 'candles_shop_add_admin_menu' );

function candles_shop_settings_page() {
    ?>
    <div class="wrap">
        <h1><?php esc_html_e( 'Theme Settings', 'candles-shop' ); ?></h1>
        <form action="options.php" method="post">
            <?php
            settings_fields( 'candles_shop_settings_group' );
            do_settings_sections( 'candles-shop-theme-settings' );
            submit_button();
            ?>
        </form>
    </div>
    <?php
}

function candles_shop_register_settings() {
    register_setting( 'candles_shop_settings_group', 'candles_shop_enable_animations' );

    add_settings_section(
        'candles_shop_settings_section',
        __( 'Animation Settings', 'candles-shop' ),
        null,
        'candles-shop-theme-settings'
    );

    add_settings_field(
        'candles_shop_enable_animations',
        __( 'Enable Animations', 'candles-shop' ),
        'candles_shop_enable_animations_callback',
        'candles-shop-theme-settings',
        'candles_shop_settings_section'
    );
}
add_action( 'admin_init', 'candles_shop_register_settings' );

function candles_shop_enable_animations_callback() {
    $checked = get_option( 'candles_shop_enable_animations', true );
    ?>
    <input type="checkbox" name="candles_shop_enable_animations" value="1" <?php checked( 1, $checked ); ?> />
    <?php
}

