API ISsues fixes pluigna dn app, plugin v udapte 1.4.0
This commit is contained in:
@@ -58,6 +58,9 @@ class Igny8_Updater {
|
||||
add_filter('pre_set_site_transient_update_plugins', array($this, 'check_for_updates'));
|
||||
add_filter('plugins_api', array($this, 'plugin_info'), 10, 3);
|
||||
|
||||
// Clear update cache after plugin is updated
|
||||
add_action('upgrader_process_complete', array($this, 'clear_update_cache'), 10, 2);
|
||||
|
||||
// Add custom styling for plugin details popup
|
||||
add_action('admin_enqueue_scripts', array($this, 'enqueue_plugin_details_styles'));
|
||||
}
|
||||
@@ -94,8 +97,24 @@ class Igny8_Updater {
|
||||
'requires_php' => $update_info['requires_php'] ?? '',
|
||||
);
|
||||
} else {
|
||||
// Remove from response if version is current or newer
|
||||
unset($transient->response[$plugin_basename]);
|
||||
// CRITICAL FIX: Explicitly mark as no update by removing from response
|
||||
// and adding to no_update to prevent false update notifications
|
||||
if (isset($transient->response[$plugin_basename])) {
|
||||
unset($transient->response[$plugin_basename]);
|
||||
}
|
||||
|
||||
// Mark plugin as checked with no update available
|
||||
if (!isset($transient->no_update)) {
|
||||
$transient->no_update = array();
|
||||
}
|
||||
|
||||
$transient->no_update[$plugin_basename] = (object) array(
|
||||
'slug' => $this->plugin_slug,
|
||||
'plugin' => $plugin_basename,
|
||||
'new_version' => $this->version,
|
||||
'url' => $update_info['info_url'] ?? '',
|
||||
'package' => '',
|
||||
);
|
||||
}
|
||||
|
||||
return $transient;
|
||||
@@ -142,6 +161,44 @@ class Igny8_Updater {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear update cache after plugin update completes
|
||||
*
|
||||
* Fixes the double-update notification bug by forcing WordPress
|
||||
* to re-check for updates with the new version number
|
||||
*
|
||||
* @param WP_Upgrader $upgrader WP_Upgrader instance
|
||||
* @param array $hook_extra Extra arguments passed to hooked filters
|
||||
*/
|
||||
public function clear_update_cache($upgrader, $hook_extra) {
|
||||
// Check if this is a plugin update
|
||||
if (!isset($hook_extra['type']) || $hook_extra['type'] !== 'plugin') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if our plugin was updated
|
||||
$plugin_basename = plugin_basename($this->plugin_file);
|
||||
$updated_plugins = array();
|
||||
|
||||
if (isset($hook_extra['plugin'])) {
|
||||
$updated_plugins[] = $hook_extra['plugin'];
|
||||
} elseif (isset($hook_extra['plugins'])) {
|
||||
$updated_plugins = $hook_extra['plugins'];
|
||||
}
|
||||
|
||||
// If our plugin was updated, force WordPress to recheck updates
|
||||
if (in_array($plugin_basename, $updated_plugins, true)) {
|
||||
// Delete the update_plugins transient to force a fresh check
|
||||
delete_site_transient('update_plugins');
|
||||
|
||||
// Also clear any cached update info
|
||||
wp_cache_delete('igny8_update_check', 'igny8');
|
||||
|
||||
// Log the cache clear for debugging
|
||||
error_log('IGNY8: Cleared update cache after plugin update to version ' . $this->version);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue custom styles for plugin details popup
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user