Update settings UI: reorder tabs, clarify examples, and improve notifications

This commit is contained in:
Marcus Quinn
2025-03-16 03:32:52 +00:00
parent 08659f8efd
commit f35e6639c8
3 changed files with 48 additions and 30 deletions

View File

@ -609,27 +609,28 @@ input:checked + .wp-toggle-slider:before {
} }
/* Settings Notification */ /* Settings Notification */
.wp-status { .wp-setting-notification {
position: relative !important;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
margin-left: 15px; margin-left: 10px;
transform: none;
top: auto;
right: auto;
background: #00a32a; background: #00a32a;
color: white; color: white;
padding: 4px 12px; padding: 3px 10px;
border-radius: 12px; border-radius: 12px;
font-size: 13px; font-size: 12px;
font-weight: 500; font-weight: 500;
z-index: 100; animation: fadeIn 0.3s ease-in-out;
} }
.wp-status.error { .wp-setting-notification.error {
background: #d63638; background: #d63638;
} }
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.wpa-loading-overlay { .wpa-loading-overlay {
position: absolute; position: absolute;
top: 0; top: 0;

View File

@ -1,14 +1,21 @@
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// Function to show notification // Function to show notification
function showNotification(message, isError = false) { function showNotification(message, element, isError = false) {
// Remove any existing notification // Remove any existing notifications
$('.wp-status').remove(); $('.wp-setting-notification').remove();
// Create and append the new notification // Create notification element
var $notification = $('<span class="wp-status' + (isError ? ' error' : '') + '">' + message + '</span>'); var $notification = $('<span class="wp-setting-notification' + (isError ? ' error' : '') + '">' + message + '</span>');
// If element is provided, show notification next to it
if (element) {
$(element).after($notification);
} else {
// Fallback to header if no element provided
$('.wp-allstars-header h1').after($notification); $('.wp-allstars-header h1').after($notification);
}
// Remove the notification after 2 seconds // Fade out after delay
setTimeout(function() { setTimeout(function() {
$notification.fadeOut(300, function() { $notification.fadeOut(300, function() {
$(this).remove(); $(this).remove();
@ -17,7 +24,7 @@ jQuery(document).ready(function($) {
} }
// Handle option updates // Handle option updates
function updateOption(option, value) { function updateOption(option, value, element) {
return $.ajax({ return $.ajax({
url: ajaxurl, url: ajaxurl,
type: 'POST', type: 'POST',
@ -51,13 +58,14 @@ jQuery(document).ready(function($) {
var $input = $(this); var $input = $(this);
var option = $input.attr('name'); var option = $input.attr('name');
var value = $input.is(':checked') ? 1 : 0; var value = $input.is(':checked') ? 1 : 0;
var $label = $input.closest('.wp-setting-left').find('label');
updateOption(option, value) updateOption(option, value)
.then(function() { .then(function() {
showNotification('Saved'); showNotification('Saved', $label);
}) })
.catch(function() { .catch(function() {
showNotification('Error saving settings', true); showNotification('Error saving settings', $label, true);
}); });
}); });
} }
@ -92,14 +100,15 @@ jQuery(document).ready(function($) {
var $input = $(this); var $input = $(this);
var option = $input.attr('name'); var option = $input.attr('name');
var value = $input.val(); var value = $input.val();
var $label = $input.prev('label');
updateOption(option, value) updateOption(option, value)
.then(function() { .then(function() {
showNotification('Setting saved'); showNotification('Saved', $label);
}) })
.catch(function(error) { .catch(function(error) {
console.error('Error:', error); console.error('Error:', error);
showNotification('Error saving setting', true); showNotification('Error saving setting', $label, true);
}); });
}); });
} }

View File

@ -636,12 +636,12 @@ function wp_allstars_settings_page() {
<a href="?page=wp-allstars&tab=general" class="nav-tab <?php echo $active_tab == 'general' ? 'nav-tab-active' : ''; ?>"> <a href="?page=wp-allstars&tab=general" class="nav-tab <?php echo $active_tab == 'general' ? 'nav-tab-active' : ''; ?>">
<?php esc_html_e('General', 'wp-allstars'); ?> <?php esc_html_e('General', 'wp-allstars'); ?>
</a> </a>
<a href="?page=wp-allstars&tab=workflow" class="nav-tab <?php echo $active_tab == 'workflow' ? 'nav-tab-active' : ''; ?>">
<?php esc_html_e('Workflow', 'wp-allstars'); ?>
</a>
<a href="?page=wp-allstars&tab=advanced" class="nav-tab <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>"> <a href="?page=wp-allstars&tab=advanced" class="nav-tab <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>">
<?php esc_html_e('Advanced', 'wp-allstars'); ?> <?php esc_html_e('Advanced', 'wp-allstars'); ?>
</a> </a>
<a href="?page=wp-allstars&tab=workflow" class="nav-tab <?php echo $active_tab == 'workflow' ? 'nav-tab-active' : ''; ?>">
<?php esc_html_e('Workflow', 'wp-allstars'); ?>
</a>
<a href="?page=wp-allstars&tab=recommended" class="nav-tab <?php echo $active_tab == 'recommended' ? 'nav-tab-active' : ''; ?>"> <a href="?page=wp-allstars&tab=recommended" class="nav-tab <?php echo $active_tab == 'recommended' ? 'nav-tab-active' : ''; ?>">
<?php esc_html_e('Free Plugins', 'wp-allstars'); ?> <?php esc_html_e('Free Plugins', 'wp-allstars'); ?>
</a> </a>
@ -972,12 +972,12 @@ function wp_allstars_settings_page() {
<span class="wp-toggle-slider"></span> <span class="wp-toggle-slider"></span>
</div> </div>
<label for="wp_allstars_simple_setting" class="wp-setting-label"> <label for="wp_allstars_simple_setting" class="wp-setting-label">
<?php esc_html_e('Simple Toggle Setting', 'wp-allstars'); ?> <?php esc_html_e('Example: Simple Toggle', 'wp-allstars'); ?>
</label> </label>
</div> </div>
</div> </div>
<p class="wp-setting-description"> <p class="wp-setting-description">
<?php esc_html_e('This is an example of a simple toggle setting without an expandable panel.', 'wp-allstars'); ?> <?php esc_html_e('This is an example of a simple toggle setting without an expandable panel. Currently for demonstration purposes only.', 'wp-allstars'); ?>
</p> </p>
</div> </div>
</div> </div>
@ -1001,16 +1001,24 @@ function wp_allstars_settings_page() {
<span class="wp-toggle-slider"></span> <span class="wp-toggle-slider"></span>
</div> </div>
<label for="wp_allstars_auto_upload_images"> <label for="wp_allstars_auto_upload_images">
<?php esc_html_e('Enable Auto Upload Images', 'wp-allstars'); ?> <?php esc_html_e('Example: Expandable Panel', 'wp-allstars'); ?>
</label> </label>
</div> </div>
</div> </div>
<p class="wp-setting-description"> <p class="wp-setting-description">
<?php esc_html_e('Import images that have external URLs into your Media Library when saving. Consider disabling during large data imports with many external image URLs.', 'wp-allstars'); ?> <?php esc_html_e('This is an example of an expandable panel setting. Currently for demonstration purposes only - no actual functionality.', 'wp-allstars'); ?>
</p> </p>
</div> </div>
<div class="wp-allstars-toggle-settings"> <div class="wp-allstars-toggle-settings">
<!-- Additional settings content here --> <div class="wp-allstars-setting-row">
<label for="example_text"><?php esc_html_e('Example Text Field', 'wp-allstars'); ?></label>
<input type="text"
id="example_text"
name="example_text"
value="Example value"
/>
<p class="description"><?php esc_html_e('This is an example text field for demonstration purposes.', 'wp-allstars'); ?></p>
</div>
</div> </div>
</div> </div>
</div> </div>