<?php 

function recipe_blogs_add_admin_menu() {
    add_menu_page(
        'Theme Settings', // Page title
        'Theme Settings', // Menu title
        'manage_options', // Capability
        'recipe-blogs-theme-settings', // Menu slug
        'recipe_blogs_settings_page' // Function to display the page
    );
}
add_action( 'admin_menu', 'recipe_blogs_add_admin_menu' );

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

function recipe_blogs_register_settings() {
    register_setting( 'recipe_blogs_settings_group', 'recipe_blogs_enable_animations' );

    add_settings_section(
        'recipe_blogs_settings_section',
        __( 'Animation Settings', 'recipe-blogs' ),
        null,
        'recipe-blogs-theme-settings'
    );

    add_settings_field(
        'recipe_blogs_enable_animations',
        __( 'Enable Animations', 'recipe-blogs' ),
        'recipe_blogs_enable_animations_callback',
        'recipe-blogs-theme-settings',
        'recipe_blogs_settings_section'
    );
}
add_action( 'admin_init', 'recipe_blogs_register_settings' );

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

