<?php 

function waterproofing_services_add_admin_menu() {
    add_menu_page(
        'Theme Settings', // Page title
        'Theme Settings', // Menu title
        'manage_options', // Capability
        'waterproofing-services-theme-settings', // Menu slug
        'waterproofing_services_settings_page' // Function to display the page
    );
}
add_action( 'admin_menu', 'waterproofing_services_add_admin_menu' );

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

function waterproofing_services_register_settings() {
    register_setting( 'waterproofing_services_settings_group', 'waterproofing_services_enable_animations' );

    add_settings_section(
        'waterproofing_services_settings_section',
        __( 'Animation Settings', 'waterproofing-services' ),
        null,
        'waterproofing-services-theme-settings'
    );

    add_settings_field(
        'waterproofing_services_enable_animations',
        __( 'Enable Animations', 'waterproofing-services' ),
        'waterproofing_services_enable_animations_callback',
        'waterproofing-services-theme-settings',
        'waterproofing_services_settings_section'
    );
}
add_action( 'admin_init', 'waterproofing_services_register_settings' );

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

