<?php 

function green_vegetable_store_add_admin_menu() {
    add_menu_page(
        'Theme Settings', // Page title
        'Theme Settings', // Menu title
        'manage_options', // Capability
        'green-vegetable-store-theme-settings', // Menu slug
        'green_vegetable_store_settings_page' // Function to display the page
    );
}
add_action( 'admin_menu', 'green_vegetable_store_add_admin_menu' );

function green_vegetable_store_settings_page() {
    ?>
    <div class="wrap">
        <h1><?php esc_html_e( 'Theme Settings', 'green-vegetable-store' ); ?></h1>
        <form action="options.php" method="post">
            <?php
            settings_fields( 'green_vegetable_store_settings_group' );
            do_settings_sections( 'green-vegetable-store-theme-settings' );
            submit_button();
            ?>
        </form>
    </div>
    <?php
}

function green_vegetable_store_register_settings() {
    register_setting( 'green_vegetable_store_settings_group', 'green_vegetable_store_enable_animations' );

    add_settings_section(
        'green_vegetable_store_settings_section',
        __( 'Animation Settings', 'green-vegetable-store' ),
        null,
        'green-vegetable-store-theme-settings'
    );

    add_settings_field(
        'green_vegetable_store_enable_animations',
        __( 'Enable Animations', 'green-vegetable-store' ),
        'green_vegetable_store_enable_animations_callback',
        'green-vegetable-store-theme-settings',
        'green_vegetable_store_settings_section'
    );
}
add_action( 'admin_init', 'green_vegetable_store_register_settings' );

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

