<?php 

function travel_holiday_spots_add_admin_menu() {
    add_menu_page(
        'Theme Settings', // Page title
        'Theme Settings', // Menu title
        'manage_options', // Capability
        'travel-holiday-spots-theme-settings', // Menu slug
        'travel_holiday_spots_settings_page' // Function to display the page
    );
}
add_action( 'admin_menu', 'travel_holiday_spots_add_admin_menu' );

function travel_holiday_spots_settings_page() {
    ?>
    <div class="wrap">
        <h1><?php esc_html_e( 'Theme Settings', 'travel-holiday-spots' ); ?></h1>
        <form action="options.php" method="post">
            <?php
            settings_fields( 'travel_holiday_spots_settings_group' );
            do_settings_sections( 'travel-holiday-spots-theme-settings' );
            submit_button();
            ?>
        </form>
    </div>
    <?php
}

function travel_holiday_spots_register_settings() {
    register_setting( 'travel_holiday_spots_settings_group', 'travel_holiday_spots_enable_animations' );

    add_settings_section(
        'travel_holiday_spots_settings_section',
        __( 'Animation Settings', 'travel-holiday-spots' ),
        null,
        'travel-holiday-spots-theme-settings'
    );

    add_settings_field(
        'travel_holiday_spots_enable_animations',
        __( 'Enable Animations', 'travel-holiday-spots' ),
        'travel_holiday_spots_enable_animations_callback',
        'travel-holiday-spots-theme-settings',
        'travel_holiday_spots_settings_section'
    );
}
add_action( 'admin_init', 'travel_holiday_spots_register_settings' );

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

