Improve Choose Update Source feature based on feedback
Some checks failed
ci/woodpecker/push/woodpecker Pipeline is pending
ci/woodpecker/tag/woodpecker Pipeline is pending
Plugin Asset Update / Push assets to WordPress.org (push) Has been cancelled
Build Release / Build and Create Release (push) Has been cancelled
Build Release / Deploy to WordPress.org (push) Has been cancelled

This commit is contained in:
2025-04-13 13:48:13 +01:00
parent 3ebcaccf98
commit 5e8da5d87b
4 changed files with 70 additions and 23 deletions

View File

@ -50,12 +50,14 @@
margin-left: 10px;
}
/* Remove explicit color to inherit from theme */
.fpden-update-source-toggle {
color: #2271b1;
/* color is now inherited from theme */
}
.fpden-update-source-toggle:hover {
color: #135e96;
/* hover color is now inherited from theme */
text-decoration: underline;
}
/* Source badges */
@ -69,7 +71,7 @@
font-weight: normal;
}
.fpden-source-badge.wordpress {
.fpden-source-badge.wordpress, .fpden-source-badge.wordpress\.org {
background-color: #0073aa;
}

View File

@ -1,13 +1,13 @@
/**
* Update Source Selector
*
*
* Handles the UI for selecting which source to use for plugin updates.
*/
jQuery(document).ready(function($) {
// Open modal when toggle is clicked
$(document).on('click', '.fpden-update-source-toggle', function(e) {
e.preventDefault();
// Add overlay
$('body').append('<div id="fpden-modal-overlay"></div>');
$('#fpden-modal-overlay').css({
@ -19,7 +19,7 @@ jQuery(document).ready(function($) {
'background-color': 'rgba(0,0,0,0.5)',
'z-index': 100000
});
// Position and show modal
var modal = $('#fpden-update-source-modal');
modal.css({
@ -35,7 +35,7 @@ jQuery(document).ready(function($) {
'width': '400px',
'max-width': '90%'
}).show();
// Add close button styles
$('.fpden-close-modal').css({
'position': 'absolute',
@ -46,29 +46,29 @@ jQuery(document).ready(function($) {
'color': '#666'
});
});
// Close modal when clicking overlay or close button
$(document).on('click', '#fpden-modal-overlay, .fpden-close-modal', function() {
$('#fpden-update-source-modal').hide();
$('#fpden-modal-overlay').remove();
});
// Prevent clicks inside modal from closing it
$('#fpden-update-source-modal').on('click', function(e) {
e.stopPropagation();
});
// Handle form submission
$('#fpden-update-source-form').on('submit', function(e) {
e.preventDefault();
var source = $('input[name="update_source"]:checked').val();
// Show loading state
var submitButton = $(this).find('button[type="submit"]');
var originalText = submitButton.text();
submitButton.text('Saving...').prop('disabled', true);
// Save via AJAX
$.post(ajaxurl, {
action: 'fpden_save_update_source',
@ -76,8 +76,22 @@ jQuery(document).ready(function($) {
nonce: fpdenData.updateSourceNonce
}, function(response) {
submitButton.text(originalText).prop('disabled', false);
if (response.success) {
// Update the badge
var badgeText = source.charAt(0).toUpperCase() + source.slice(1);
if (source === 'auto') {
badgeText = 'Auto';
} else if (source === 'wordpress.org') {
badgeText = 'WP.org';
}
// Remove all badge classes and add the new one
var badge = $('.fpden-update-source-toggle .fpden-source-badge');
badge.removeClass('auto wordpress github gitea')
.addClass(source)
.text(badgeText);
// Show success message
var message = $('<div class="fpden-success-message">Update source saved successfully!</div>');
message.css({
@ -85,9 +99,9 @@ jQuery(document).ready(function($) {
'margin-top': '10px',
'text-align': 'center'
});
$('#fpden-update-source-form').append(message);
// Hide message and modal after delay
setTimeout(function() {
message.fadeOut(function() {
@ -104,9 +118,9 @@ jQuery(document).ready(function($) {
'margin-top': '10px',
'text-align': 'center'
});
$('#fpden-update-source-form').append(message);
// Hide message after delay
setTimeout(function() {
message.fadeOut(function() {