<?php 

function web_designer_portfolio_add_admin_menu() {
    add_menu_page(
        'Theme Settings', // Page title
        'Theme Settings', // Menu title
        'manage_options', // Capability
        'web-designer-portfolio-theme-settings', // Menu slug
        'web_designer_portfolio_settings_page' // Function to display the page
    );
}
add_action( 'admin_menu', 'web_designer_portfolio_add_admin_menu' );

function web_designer_portfolio_settings_page() {
    ?>
    <div class="wrap">
        <h1><?php esc_html_e( 'Theme Settings', 'web-designer-portfolio' ); ?></h1>
        <form action="options.php" method="post">
            <?php
            settings_fields( 'web_designer_portfolio_settings_group' );
            do_settings_sections( 'web-designer-portfolio-theme-settings' );
            submit_button();
            ?>
        </form>
    </div>
    <?php
}

function web_designer_portfolio_register_settings() {
    register_setting( 'web_designer_portfolio_settings_group', 'web_designer_portfolio_enable_animations' );

    add_settings_section(
        'web_designer_portfolio_settings_section',
        __( 'Animation Settings', 'web-designer-portfolio' ),
        null,
        'web-designer-portfolio-theme-settings'
    );

    add_settings_field(
        'web_designer_portfolio_enable_animations',
        __( 'Enable Animations', 'web-designer-portfolio' ),
        'web_designer_portfolio_enable_animations_callback',
        'web-designer-portfolio-theme-settings',
        'web_designer_portfolio_settings_section'
    );
}
add_action( 'admin_init', 'web_designer_portfolio_register_settings' );

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

