diff --git a/admin/js/wpa-superstar-admin.js b/admin/js/wpa-superstar-admin.js index 472f321..e7d1b23 100644 --- a/admin/js/wpa-superstar-admin.js +++ b/admin/js/wpa-superstar-admin.js @@ -3,19 +3,31 @@ jQuery(document).ready(function($) { var $input = $(this); var option = $input.attr('name'); var value = $input.is(':checked') ? 1 : 0; + + // Remove any existing status messages + $('.wpa-status').remove(); + + // Add a small notification that fades out + var $notification = $('Setting saved'); + $('body').append($notification); + $.post(wpaSuperstar.ajaxurl, { action: 'wpa_superstar_update_option', option: option, value: value, nonce: wpaSuperstar.nonce }, function(response) { - if (response.success) { - $input.next('.wpa-status').remove(); - $input.after('Saved'); - setTimeout(function() { $('.wpa-status').fadeOut(); }, 2000); - } else { + if (!response.success) { console.error('Error:', response); + $notification.css('background', '#d63638').text('Error saving setting'); } + + // Fade out and remove the notification after 2 seconds + setTimeout(function() { + $notification.fadeOut(300, function() { + $(this).remove(); + }); + }, 2000); }); }); }); \ No newline at end of file diff --git a/admin/settings.php b/admin/settings.php index 652cb5e..33f98ea 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -49,7 +49,7 @@ function wpa_superstar_settings_page() { -
+
@@ -108,9 +108,7 @@ function wpa_superstar_settings_page() {

- - -
+