diff --git a/assets/css/update-source-selector.css b/assets/css/update-source-selector.css index 7d38651..212483a 100644 --- a/assets/css/update-source-selector.css +++ b/assets/css/update-source-selector.css @@ -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; } diff --git a/assets/js/update-source-selector.js b/assets/js/update-source-selector.js index 4e38e37..b59a9d9 100644 --- a/assets/js/update-source-selector.js +++ b/assets/js/update-source-selector.js @@ -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('
'); $('#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 = $(' '); 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() { diff --git a/includes/Updater.php b/includes/Updater.php index 819953e..5ee2aee 100644 --- a/includes/Updater.php +++ b/includes/Updater.php @@ -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(); diff --git a/wp-fix-plugin-does-not-exist-notices.php b/wp-fix-plugin-does-not-exist-notices.php index b45f033..5732792 100644 --- a/wp-fix-plugin-does-not-exist-notices.php +++ b/wp-fix-plugin-does-not-exist-notices.php @@ -961,7 +961,7 @@ function fpden_add_update_source_modal() { // Modal HTML ?>