Add Choose Update Source feature
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:
@ -3,12 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
#### [2.1.1] - 2025-04-13
|
||||
#### Added
|
||||
- New "Choose Update Source" feature allowing users to select their preferred update source (WordPress.org, GitHub, or Gitea)
|
||||
- Modal dialog with detailed information about each update source option
|
||||
- Visual indicator showing the currently selected update source
|
||||
|
||||
#### Fixed
|
||||
- Updated heading styles in CHANGELOG.md for better readability
|
||||
- Corrected dates in changelog to use 2025 instead of 2024
|
||||
|
||||
#### Improved
|
||||
- Documentation improvements for better clarity
|
||||
- Enhanced Git Updater integration with user-selectable update sources
|
||||
|
||||
#### [2.1.0] - 2025-04-13
|
||||
#### Changed
|
||||
|
19
README.md
19
README.md
@ -76,6 +76,21 @@ If you've installed this plugin from GitHub or Gitea, you'll need Git Updater to
|
||||
3. Click the "Refresh Cache" button to ensure Git Updater recognizes the latest version
|
||||
4. Updates will now appear in your WordPress dashboard when available
|
||||
|
||||
### Choosing Your Update Source
|
||||
|
||||
This plugin allows you to choose where you want to receive updates from:
|
||||
|
||||
1. In the Plugins list, find "Fix 'Plugin file does not exist' Notices"
|
||||
2. Click the "Choose Update Source" link next to the plugin
|
||||
3. Select your preferred update source:
|
||||
- **Auto-detect** (default): Automatically determines the source based on installation origin
|
||||
- **WordPress.org**: Updates from the official WordPress.org repository (may have delays due to approval process)
|
||||
- **GitHub**: Updates directly from GitHub (usually has the latest version first)
|
||||
- **Gitea**: Updates from Gitea (usually has the latest version first)
|
||||
4. Click "Save" to apply your preference
|
||||
|
||||
> **Note:** GitHub and Gitea options require the Git Updater plugin to be installed and activated.
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
### Is it safe to remove plugin references?
|
||||
@ -186,9 +201,13 @@ The plugin works by:
|
||||
## Changelog
|
||||
|
||||
### 2.1.1
|
||||
* Added: New "Choose Update Source" feature allowing users to select their preferred update source (WordPress.org, GitHub, or Gitea)
|
||||
* Added: Modal dialog with detailed information about each update source option
|
||||
* Added: Visual indicator showing the currently selected update source
|
||||
* Fixed: Updated heading styles in CHANGELOG.md for better readability
|
||||
* Fixed: Corrected dates in changelog to use 2025 instead of 2024
|
||||
* Improved: Documentation improvements for better clarity
|
||||
* Improved: Enhanced Git Updater integration with user-selectable update sources
|
||||
|
||||
### 2.1.0
|
||||
* Minor version bump for Git Updater compatibility
|
||||
|
86
assets/css/update-source-selector.css
Normal file
86
assets/css/update-source-selector.css
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Update Source Selector Styles
|
||||
*/
|
||||
#fpden-update-source-modal {
|
||||
display: none;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
#fpden-update-source-modal h2 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 15px;
|
||||
font-size: 1.3em;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#fpden-update-source-modal p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#fpden-update-source-form label {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#fpden-update-source-form label:hover {
|
||||
background-color: #f0f0f1;
|
||||
}
|
||||
|
||||
#fpden-update-source-form input[type="radio"] {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.fpden-source-description {
|
||||
display: block;
|
||||
margin-left: 24px;
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.fpden-submit-container {
|
||||
margin-top: 20px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.fpden-submit-container button {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.fpden-update-source-toggle {
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.fpden-update-source-toggle:hover {
|
||||
color: #135e96;
|
||||
}
|
||||
|
||||
/* Source badges */
|
||||
.fpden-source-badge {
|
||||
display: inline-block;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-size: 0.8em;
|
||||
margin-left: 5px;
|
||||
color: white;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.fpden-source-badge.wordpress {
|
||||
background-color: #0073aa;
|
||||
}
|
||||
|
||||
.fpden-source-badge.github {
|
||||
background-color: #24292e;
|
||||
}
|
||||
|
||||
.fpden-source-badge.gitea {
|
||||
background-color: #609926;
|
||||
}
|
||||
|
||||
.fpden-source-badge.auto {
|
||||
background-color: #666;
|
||||
}
|
119
assets/js/update-source-selector.js
Normal file
119
assets/js/update-source-selector.js
Normal file
@ -0,0 +1,119 @@
|
||||
/**
|
||||
* 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({
|
||||
'position': 'fixed',
|
||||
'top': 0,
|
||||
'left': 0,
|
||||
'width': '100%',
|
||||
'height': '100%',
|
||||
'background-color': 'rgba(0,0,0,0.5)',
|
||||
'z-index': 100000
|
||||
});
|
||||
|
||||
// Position and show modal
|
||||
var modal = $('#fpden-update-source-modal');
|
||||
modal.css({
|
||||
'position': 'fixed',
|
||||
'top': '50%',
|
||||
'left': '50%',
|
||||
'transform': 'translate(-50%, -50%)',
|
||||
'background-color': '#fff',
|
||||
'padding': '20px',
|
||||
'border-radius': '5px',
|
||||
'box-shadow': '0 0 10px rgba(0,0,0,0.5)',
|
||||
'z-index': 100001,
|
||||
'width': '400px',
|
||||
'max-width': '90%'
|
||||
}).show();
|
||||
|
||||
// Add close button styles
|
||||
$('.fpden-close-modal').css({
|
||||
'position': 'absolute',
|
||||
'top': '10px',
|
||||
'right': '10px',
|
||||
'cursor': 'pointer',
|
||||
'font-size': '20px',
|
||||
'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',
|
||||
source: source,
|
||||
nonce: fpdenData.updateSourceNonce
|
||||
}, function(response) {
|
||||
submitButton.text(originalText).prop('disabled', false);
|
||||
|
||||
if (response.success) {
|
||||
// Show success message
|
||||
var message = $('<div class="fpden-success-message">Update source saved successfully!</div>');
|
||||
message.css({
|
||||
'color': 'green',
|
||||
'margin-top': '10px',
|
||||
'text-align': 'center'
|
||||
});
|
||||
|
||||
$('#fpden-update-source-form').append(message);
|
||||
|
||||
// Hide message and modal after delay
|
||||
setTimeout(function() {
|
||||
message.fadeOut(function() {
|
||||
$(this).remove();
|
||||
$('#fpden-update-source-modal').hide();
|
||||
$('#fpden-modal-overlay').remove();
|
||||
});
|
||||
}, 1500);
|
||||
} else {
|
||||
// Show error message
|
||||
var message = $('<div class="fpden-error-message">Error saving update source.</div>');
|
||||
message.css({
|
||||
'color': 'red',
|
||||
'margin-top': '10px',
|
||||
'text-align': 'center'
|
||||
});
|
||||
|
||||
$('#fpden-update-source-form').append(message);
|
||||
|
||||
// Hide message after delay
|
||||
setTimeout(function() {
|
||||
message.fadeOut(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -61,7 +61,15 @@ class Updater {
|
||||
* @return string Installation source: 'github', 'gitea', or 'wordpress.org'
|
||||
*/
|
||||
private function determine_installation_source() {
|
||||
// Default to WordPress.org
|
||||
// Check for user preference first
|
||||
$user_preference = \get_option('fpden_update_source', 'auto');
|
||||
|
||||
// If not set to auto, use the user preference
|
||||
if ($user_preference !== 'auto') {
|
||||
return $user_preference;
|
||||
}
|
||||
|
||||
// Otherwise, auto-detect as before
|
||||
$source = 'wordpress.org';
|
||||
|
||||
// Check if the plugin was installed from GitHub
|
||||
|
23
readme.txt
23
readme.txt
@ -93,6 +93,21 @@ If you've installed this plugin from GitHub or Gitea, you'll need Git Updater to
|
||||
3. Click the "Refresh Cache" button to ensure Git Updater recognizes the latest version
|
||||
4. Updates will now appear in your WordPress dashboard when available
|
||||
|
||||
= Choosing Your Update Source =
|
||||
|
||||
This plugin allows you to choose where you want to receive updates from:
|
||||
|
||||
1. In the Plugins list, find "Fix 'Plugin file does not exist' Notices"
|
||||
2. Click the "Choose Update Source" link next to the plugin
|
||||
3. Select your preferred update source:
|
||||
* **Auto-detect** (default): Automatically determines the source based on installation origin
|
||||
* **WordPress.org**: Updates from the official WordPress.org repository (may have delays due to approval process)
|
||||
* **GitHub**: Updates directly from GitHub (usually has the latest version first)
|
||||
* **Gitea**: Updates from Gitea (usually has the latest version first)
|
||||
4. Click "Save" to apply your preference
|
||||
|
||||
**Note:** GitHub and Gitea options require the Git Updater plugin to be installed and activated.
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Is it safe to remove plugin references? =
|
||||
@ -150,9 +165,13 @@ Manually editing the WordPress database is risky and requires technical knowledg
|
||||
== Changelog ==
|
||||
|
||||
= 2.1.1 =
|
||||
* Added: New "Choose Update Source" feature allowing users to select their preferred update source (WordPress.org, GitHub, or Gitea)
|
||||
* Added: Modal dialog with detailed information about each update source option
|
||||
* Added: Visual indicator showing the currently selected update source
|
||||
* Fixed: Updated heading styles in CHANGELOG.md for better readability
|
||||
* Fixed: Corrected dates in changelog to use 2025 instead of 2024
|
||||
* Updated: Documentation improvements for better clarity
|
||||
* Improved: Documentation improvements for better clarity
|
||||
* Improved: Enhanced Git Updater integration with user-selectable update sources
|
||||
|
||||
= 2.1.0 =
|
||||
* Minor version bump for Git Updater compatibility
|
||||
@ -482,7 +501,7 @@ Manually editing the WordPress database is risky and requires technical knowledg
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 2.1.1 =
|
||||
Fixed dates in changelog and improved documentation formatting.
|
||||
Added new "Choose Update Source" feature allowing you to select where to receive plugin updates from (WordPress.org, GitHub, or Gitea).
|
||||
|
||||
= 2.1.0 =
|
||||
Minor version bump with improved Git Updater compatibility and error handling.
|
||||
|
@ -40,6 +40,15 @@ add_action('plugins_loaded', 'fpden_init_git_updater_fixes');
|
||||
* It uses named functions instead of anonymous functions for better compatibility
|
||||
*/
|
||||
function fpden_init_git_updater_fixes() {
|
||||
// Add filter for plugin action links to add our update source selector
|
||||
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'fpden_add_update_source_link');
|
||||
|
||||
// Add AJAX handler for saving update source
|
||||
add_action('wp_ajax_fpden_save_update_source', 'fpden_save_update_source');
|
||||
|
||||
// Add the update source modal to admin footer
|
||||
add_action('admin_footer', 'fpden_add_update_source_modal');
|
||||
|
||||
// Fix for Git Updater looking for 'master' branch instead of 'main'
|
||||
add_filter('gu_get_repo_branch', 'fpden_override_branch', 999, 3);
|
||||
|
||||
@ -876,6 +885,150 @@ class Fix_Plugin_Does_Not_Exist_Notices {
|
||||
// Initialize the plugin class.
|
||||
new Fix_Plugin_Does_Not_Exist_Notices();
|
||||
|
||||
/**
|
||||
* Add the "Choose Update Source" link to plugin action links
|
||||
*
|
||||
* @param array $links Array of plugin action links
|
||||
* @return array Modified array of plugin action links
|
||||
*/
|
||||
function fpden_add_update_source_link($links) {
|
||||
if (!current_user_can('manage_options')) {
|
||||
return $links;
|
||||
}
|
||||
|
||||
// Get current update source
|
||||
$current_source = get_option('fpden_update_source', 'auto');
|
||||
|
||||
// Add a badge to show the current source
|
||||
$badge_class = 'fpden-source-badge ' . $current_source;
|
||||
$badge_text = ucfirst($current_source);
|
||||
if ($current_source === 'auto') {
|
||||
$badge_text = 'Auto';
|
||||
} elseif ($current_source === 'wordpress.org') {
|
||||
$badge_text = 'WP.org';
|
||||
}
|
||||
|
||||
// Add the link with the badge
|
||||
$update_source_link = '<a href="#" class="fpden-update-source-toggle">Choose Update Source <span class="' . $badge_class . '">' . $badge_text . '</span></a>';
|
||||
$links[] = $update_source_link;
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the update source modal to the admin footer
|
||||
*/
|
||||
function fpden_add_update_source_modal() {
|
||||
if (!is_admin() || !current_user_can('manage_options')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only show on plugins page
|
||||
$screen = get_current_screen();
|
||||
if (!$screen || $screen->id !== 'plugins') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get current source
|
||||
$current_source = get_option('fpden_update_source', 'auto');
|
||||
|
||||
// Enqueue the CSS and JS
|
||||
wp_enqueue_style(
|
||||
'fpden-update-source-selector',
|
||||
FPDEN_PLUGIN_URL . 'assets/css/update-source-selector.css',
|
||||
array(),
|
||||
FPDEN_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'fpden-update-source-selector',
|
||||
FPDEN_PLUGIN_URL . 'assets/js/update-source-selector.js',
|
||||
array('jquery'),
|
||||
FPDEN_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
// Add nonce to the existing fpdenData object or create it if it doesn't exist
|
||||
$nonce = wp_create_nonce('fpden_update_source');
|
||||
wp_localize_script(
|
||||
'fpden-update-source-selector',
|
||||
'fpdenData',
|
||||
array(
|
||||
'updateSourceNonce' => $nonce,
|
||||
)
|
||||
);
|
||||
|
||||
// Modal HTML
|
||||
?>
|
||||
<div id="fpden-update-source-modal">
|
||||
<a href="#" class="fpden-close-modal">×</a>
|
||||
<h2>Choose Update Source</h2>
|
||||
<p>Select where you want to receive plugin updates from:</p>
|
||||
|
||||
<form id="fpden-update-source-form">
|
||||
<label>
|
||||
<input type="radio" name="update_source" value="auto" <?php checked($current_source, 'auto'); ?>>
|
||||
Auto-detect (recommended)
|
||||
<span class="fpden-source-description">Automatically determines the update source based on where the plugin was installed from.</span>
|
||||
</label>
|
||||
|
||||
<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>
|
||||
</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>
|
||||
</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>
|
||||
</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>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle AJAX request to save update source
|
||||
*/
|
||||
function fpden_save_update_source() {
|
||||
// Check nonce
|
||||
check_ajax_referer('fpden_update_source', 'nonce');
|
||||
|
||||
// Check permissions
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_send_json_error('Permission denied');
|
||||
}
|
||||
|
||||
// Get and sanitize source
|
||||
$source = isset($_POST['source']) ? sanitize_text_field($_POST['source']) : 'auto';
|
||||
|
||||
// Validate source
|
||||
$valid_sources = ['auto', 'wordpress.org', 'github', 'gitea'];
|
||||
if (!in_array($source, $valid_sources)) {
|
||||
$source = 'auto';
|
||||
}
|
||||
|
||||
// Save option
|
||||
update_option('fpden_update_source', $source);
|
||||
|
||||
// Clear update cache
|
||||
delete_site_transient('update_plugins');
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
// This function was previously deactivating all plugins except our plugin and Git Updater
|
||||
// It has been disabled to allow other plugins to be activated
|
||||
// Uncomment the following code if you need to troubleshoot plugin conflicts
|
||||
|
Reference in New Issue
Block a user