diff --git a/admin/css/wp-allstars-admin.css b/admin/css/wp-allstars-admin.css index 816b975..4480eb2 100644 --- a/admin/css/wp-allstars-admin.css +++ b/admin/css/wp-allstars-admin.css @@ -14,6 +14,7 @@ align-items: center; justify-content: space-between; width: auto; + position: relative; } .wp-allstars-header h1 { @@ -41,45 +42,45 @@ .nav-tab-wrapper, .wrap h2.nav-tab-wrapper { border-bottom: 1px solid #c3c4c7; - margin: 0; - padding-top: 9px; - padding-bottom: 0; - line-height: inherit; - margin-bottom: 20px; + margin: 0 -20px; + padding: 0 20px; + background: #fff; + position: sticky; + top: 32px; + z-index: 100; } .nav-tab { - float: left; - border: 1px solid #c3c4c7; - border-bottom: none; - margin-left: 0.5em; - padding: 8px 12px; + margin: 0; + padding: 12px 20px; font-size: 14px; - line-height: 1.71428571; - font-weight: 600; - background: #f0f0f1; + line-height: 2; + font-weight: 400; + background: transparent; color: #50575e; text-decoration: none; white-space: nowrap; + border: none; + border-bottom: 2px solid transparent; + display: inline-block; transition: all 0.2s ease; } .nav-tab:hover, .nav-tab:focus { - background-color: #fff; - color: #1d2327; - border-color: #8c8f94; + color: #2271b1; + background: transparent; + border-color: #2271b1; } .nav-tab-active, .nav-tab-active:focus, .nav-tab-active:focus:active, .nav-tab-active:hover { - border-bottom: 1px solid #f0f0f1; - background: #f0f0f1; + border-bottom: 2px solid #2271b1; + background: transparent; color: #2271b1; - margin-bottom: -1px; - box-shadow: none; + font-weight: 600; } /* Toggle Switches */ @@ -331,4 +332,42 @@ input:checked + .wp-toggle-slider:before { margin-top: 10px; padding: 12px; } +} + +/* Settings Notification */ +.wp-status { + position: absolute !important; + right: 20px; + top: 50%; + transform: translateY(-50%); + background: #00a32a; + color: white; + padding: 6px 12px; + border-radius: 12px; + font-size: 13px; + font-weight: 500; + z-index: 100; +} + +.wp-status.error { + background: #d63638; +} + +/* Settings Container */ +.wp-list-table-container { + position: relative; + min-height: 400px; +} + +.wpa-loading-overlay { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(255, 255, 255, 0.8); + z-index: 10; + display: flex; + align-items: center; + justify-content: center; } \ No newline at end of file diff --git a/admin/js/wp-allstars-admin.js b/admin/js/wp-allstars-admin.js index 3d62d35..f540608 100644 --- a/admin/js/wp-allstars-admin.js +++ b/admin/js/wp-allstars-admin.js @@ -1,35 +1,66 @@ jQuery(document).ready(function($) { + // Function to show notification + function showNotification(message, isError = false) { + // Remove any existing notifications + $('.wp-status').remove(); + + // Add notification to header + var $notification = $('' + message + ''); + $('.wp-allstars-header').append($notification); + + // Fade out and remove after delay + setTimeout(function() { + $notification.fadeOut(300, function() { + $(this).remove(); + }); + }, 2000); + } + + // Handle all settings changes + function updateOption(option, value) { + return $.post(wpAllstars.ajaxurl, { + action: 'wp_allstars_update_option', + option: option, + value: value, + nonce: wpAllstars.nonce + }).then(function(response) { + if (!response.success) { + throw new Error(response.data || 'Error saving setting'); + } + return response; + }); + } + // Toggle switch functionality $('.wp-allstars-toggle input[type="checkbox"]').on('change', function() { var $input = $(this); var option = $input.attr('name'); var value = $input.is(':checked') ? 1 : 0; - // Remove any existing status messages - $('.wp-status').remove(); + updateOption(option, value) + .then(function() { + showNotification('Setting saved'); + }) + .catch(function(error) { + console.error('Error:', error); + showNotification('Error saving setting', true); + }); + }); + + // Handle text, number, and textarea inputs + $('.wp-allstars-setting-row input[type="text"], .wp-allstars-setting-row input[type="number"], .wp-allstars-setting-row textarea').on('change', function() { + var $input = $(this); + var option = $input.attr('name'); + var value = $input.val(); - // Add a small notification that fades out - var $notification = $('Setting saved'); - $('body').append($notification); - - $.post(wpAllstars.ajaxurl, { - action: 'wp_allstars_update_option', - option: option, - value: value, - nonce: wpAllstars.nonce - }, function(response) { - 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); - }); + updateOption(option, value) + .then(function() { + showNotification('Setting saved'); + }) + .catch(function(error) { + console.error('Error:', error); + showNotification('Error saving setting', true); + }); }); // Expand/collapse settings functionality @@ -48,21 +79,4 @@ jQuery(document).ready(function($) { $settings.slideDown(200); } }); - - // Save settings on form submit - $('form').on('submit', function() { - // Remove any existing status messages - $('.wp-status').remove(); - - // Add a small notification that fades out - var $notification = $('Settings saved'); - $('body').append($notification); - - // 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 2f7db04..1da1949 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -507,28 +507,16 @@ function wp_allstars_settings_page() {