document.addEventListener('DOMContentLoaded', function () {
    let admin_url = author_kit_admin_header_vars.author_kit_admin_url;
    const buttons = document.querySelectorAll('#tab-nav-top button');

    const urlParams = new URLSearchParams(window.location.search);
    const currentPage = urlParams.get('page');

    buttons.forEach(function (button) {
        const page = button.getAttribute('data-page');
        const pageUrl = admin_url + encodeURIComponent(page);

        if (page === currentPage) {
            button.classList.add('active');
        }

        button.addEventListener('click', function () {
            window.location.href = pageUrl;
        });
    });
});
