diff --git a/admin/js/seoprostack-admin.js b/admin/js/seoprostack-admin.js index c48182f..41656e0 100644 --- a/admin/js/seoprostack-admin.js +++ b/admin/js/seoprostack-admin.js @@ -30,7 +30,7 @@ jQuery(document).ready(function($) { // Handle option updates function updateOption(option, value) { return $.ajax({ - url: ajaxurl, + url: wpSeoProStack.ajaxurl, type: 'POST', data: { action: 'wp_seoprostack_update_option', @@ -45,70 +45,70 @@ jQuery(document).ready(function($) { return response; }); } - // Toggle sections + // Toggle sections $('.seoprostack-toggle-header').on('click', function() { - $(this).toggleClass('active'); - $(this).next('.seoprostack-toggle-settings').slideToggle(300); - }); + $(this).toggleClass('active'); + $(this).next('.seoprostack-toggle-settings').slideToggle(300); + }); - // Tabs functionality (if not using WP default tabs) - $('.seoprostack-tab-nav a').on('click', function(e) { + // Tabs functionality (if not using WP default tabs) + $('.seoprostack-tab-nav a').on('click', function(e) { + e.preventDefault(); + var targetTab = $(this).attr('href').substring(1); + + // Update active tab + $('.seoprostack-tab-nav a').removeClass('active'); + $(this).addClass('active'); + + // Show target tab content + $('.seoprostack-tab-content').hide(); + $('#' + targetTab).show(); + + // Update URL without refreshing + if (history.pushState) { + var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?page=seoprostack&tab=' + targetTab; + window.history.pushState({path: newUrl}, '', newUrl); + } + }); + + // Pro Plugins Tab + if ($('#pro-plugins').length) { + // Category filter + $('.seoprostack-category-filter a').on('click', function(e) { e.preventDefault(); - var targetTab = $(this).attr('href').substring(1); - // Update active tab - $('.seoprostack-tab-nav a').removeClass('active'); + var category = $(this).data('category'); + + // Update active filter + $('.seoprostack-category-filter a').removeClass('active'); $(this).addClass('active'); - // Show target tab content - $('.seoprostack-tab-content').hide(); - $('#' + targetTab).show(); + // Show loading + $('#seoprostack-plugins-grid').addClass('loading'); - // Update URL without refreshing - if (history.pushState) { - var newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?page=seoprostack&tab=' + targetTab; - window.history.pushState({path: newUrl}, '', newUrl); - } - }); - - // Pro Plugins Tab - if ($('#pro-plugins').length) { - // Category filter - $('.seoprostack-category-filter a').on('click', function(e) { - e.preventDefault(); - - var category = $(this).data('category'); - - // Update active filter - $('.seoprostack-category-filter a').removeClass('active'); - $(this).addClass('active'); - - // Show loading - $('#seoprostack-plugins-grid').addClass('loading'); - - // Load plugins - $.ajax({ - url: wpSeoProStack.ajaxurl, - type: 'POST', - data: { - action: 'wp_seoprostack_get_plugins', - category: category, - nonce: wpSeoProStack.nonce - }, - success: function(response) { - $('#seoprostack-plugins-grid').removeClass('loading'); - - if (response.success) { - renderPlugins(response.data.plugins); - } else { - $('#seoprostack-plugins-grid').html('