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
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:
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -160,6 +160,38 @@ class Updater {
|
||||
return '';
|
||||
});
|
||||
|
||||
// Add filter to trigger Git Updater cache refresh when a version update is detected
|
||||
\add_filter('site_transient_update_plugins', function($transient) {
|
||||
// Check if our plugin has an update
|
||||
$plugin_basename = \plugin_basename($this->plugin_file);
|
||||
if (isset($transient->response) && isset($transient->response[$plugin_basename])) {
|
||||
// Check if Git Updater is active by looking for its functions
|
||||
if (function_exists('\\Fragen\\Git_Updater\\flush_git_updater_cache') ||
|
||||
class_exists('\\Fragen\\Git_Updater\\API\\API')) {
|
||||
|
||||
// Try to call the flush cache function if it exists
|
||||
if (function_exists('\\Fragen\\Git_Updater\\flush_git_updater_cache')) {
|
||||
\Fragen\Git_Updater\flush_git_updater_cache();
|
||||
} elseif (class_exists('\\Fragen\\Git_Updater\\API\\API')) {
|
||||
// Try to use the API class if available
|
||||
try {
|
||||
$api = new \Fragen\Git_Updater\API\API();
|
||||
if (method_exists($api, 'flush_cache_site_transient')) {
|
||||
$api->flush_cache_site_transient();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Silently fail if API class can't be instantiated
|
||||
}
|
||||
}
|
||||
|
||||
// Also delete the update plugins transient to force a refresh
|
||||
\delete_site_transient('update_plugins');
|
||||
}
|
||||
}
|
||||
|
||||
return $transient;
|
||||
});
|
||||
|
||||
// Initialize Git Updater Lite
|
||||
if (class_exists('\\Fragen\\Git_Updater\\Lite')) {
|
||||
(new \Fragen\Git_Updater\Lite($this->plugin_file))->run();
|
||||
|
@ -961,7 +961,7 @@ function fpden_add_update_source_modal() {
|
||||
// Modal HTML
|
||||
?>
|
||||
<div id="fpden-update-source-modal">
|
||||
<a href="#" class="fpden-close-modal">×</a>
|
||||
<a href="#" class="fpden-close-modal" aria-label="Close modal">×</a>
|
||||
<h2>Choose Update Source</h2>
|
||||
<p>Select where you want to receive plugin updates from:</p>
|
||||
|
||||
@ -975,23 +975,22 @@ function fpden_add_update_source_modal() {
|
||||
<label>
|
||||
<input type="radio" name="update_source" value="wordpress.org" <?php checked($current_source, 'wordpress.org'); ?>>
|
||||
WordPress.org
|
||||
<span class="fpden-source-description">Updates from the official WordPress.org plugin repository. May have a delay due to approval process.</span>
|
||||
<span class="fpden-source-description">Updates from the official WordPress.org plugin repository. Will have a version update delay due to allow for the WP.org policy review and approval process. Best for unmonitored auto-updates.</span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="radio" name="update_source" value="github" <?php checked($current_source, 'github'); ?>>
|
||||
GitHub
|
||||
<span class="fpden-source-description">Updates directly from GitHub. Requires Git Updater plugin. Usually has the latest version first.</span>
|
||||
<span class="fpden-source-description">Update directly from the GitHub repo main branch for the latest stable release. Git Updater plugin must be installed & active. Best for monitored updates, where the latest features and fixes are required as soon as they are merged into the main branch.</span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="radio" name="update_source" value="gitea" <?php checked($current_source, 'gitea'); ?>>
|
||||
Gitea
|
||||
<span class="fpden-source-description">Updates from Gitea. Requires Git Updater plugin. Usually has the latest version first.</span>
|
||||
<span class="fpden-source-description">Update directly from the Gitea repo main branch for the latest stable release. Git Updater plugin must be installed & active. Best for monitored updates, where the latest features and fixes are required as soon as they are merged into the main branch, and independence from big-tech.</span>
|
||||
</label>
|
||||
|
||||
<div class="fpden-submit-container">
|
||||
<button type="button" class="button fpden-close-modal">Cancel</button>
|
||||
<button type="submit" class="button button-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user