Revert "API ISsues fixes pluigna dn app, plugin v udapte 1.4.0"

This reverts commit a361dea528.
This commit is contained in:
IGNY8 VPS (Salman)
2026-01-13 05:26:32 +00:00
parent a361dea528
commit 6f64d359fb
9 changed files with 27 additions and 728 deletions

View File

@@ -756,42 +756,8 @@ class Igny8Admin {
public function sanitize_post_status($value) {
$allowed = array('draft', 'publish');
return in_array($value, $allowed, true) ? $value : 'draft';
}
/**
* Clear update cache via AJAX
*
* Fixes the double-update notification bug by clearing WordPress update transients
* and forcing a fresh update check.
*/
public static function clear_update_cache_ajax() {
// Verify nonce
if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'igny8_clear_cache')) {
wp_send_json_error(array('message' => 'Invalid security token'));
return;
}
// Check user permissions
if (!current_user_can('manage_options')) {
wp_send_json_error(array('message' => 'Insufficient permissions'));
return;
}
// 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');
// Clear WordPress object cache
wp_cache_flush();
// Log for debugging
error_log('IGNY8: Update cache cleared manually by admin');
wp_send_json_success(array(
'message' => 'Update cache cleared successfully. WordPress will check for updates on next page load.'
));
}}
}
}
// Register AJAX handlers
add_action('wp_ajax_igny8_test_connection', array('Igny8Admin', 'test_connection'));
@@ -800,4 +766,4 @@ add_action('wp_ajax_igny8_sync_taxonomies', array('Igny8Admin', 'sync_taxonomies
add_action('wp_ajax_igny8_sync_from_igny8', array('Igny8Admin', 'sync_from_igny8'));
add_action('wp_ajax_igny8_collect_site_data', array('Igny8Admin', 'collect_site_data'));
add_action('wp_ajax_igny8_get_stats', array('Igny8Admin', 'get_stats'));
add_action('wp_ajax_igny8_clear_update_cache', array('Igny8Admin', 'clear_update_cache_ajax'));

View File

@@ -236,21 +236,12 @@ foreach ($all_post_types as $pt) {
</div>
</div>
<div style="display: flex; gap: 12px; align-items: center;">
<button type="submit" class="igny8-btn igny8-btn-primary">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 16px; height: 16px;">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
<?php _e('Save Settings', 'igny8-bridge'); ?>
</button>
<button type="button" id="igny8-clear-update-cache" class="igny8-btn" style="background: var(--igny8-surface); border: 1px solid var(--igny8-stroke);">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 16px; height: 16px;">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
<?php _e('Clear Update Cache', 'igny8-bridge'); ?>
</button>
</div>
<button type="submit" class="igny8-btn igny8-btn-primary">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 16px; height: 16px;">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
<?php _e('Save Settings', 'igny8-bridge'); ?>
</button>
</form>
<style>
@@ -292,46 +283,6 @@ jQuery(document).ready(function($) {
card.slideUp(200);
}
});
// Handle clear update cache button
$('#igny8-clear-update-cache').on('click', function(e) {
e.preventDefault();
var $btn = $(this);
var originalText = $btn.html();
$btn.prop('disabled', true).html('<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 16px; height: 16px; animation: spin 1s linear infinite;"><circle cx="12" cy="12" r="10" stroke-width="4" stroke="currentColor" stroke-opacity="0.25"></circle><path fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> Clearing...');
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'igny8_clear_update_cache',
nonce: '<?php echo wp_create_nonce('igny8_clear_cache'); ?>'
},
success: function(response) {
if (response.success) {
$btn.html('<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 16px; height: 16px;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg> Cache Cleared!').css('background', '#10b981').css('color', 'white').css('border-color', '#10b981');
setTimeout(function() {
$btn.prop('disabled', false).html(originalText).css('background', '').css('color', '').css('border-color', '');
}, 2000);
} else {
$btn.html('<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 16px; height: 16px;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg> Failed').css('background', '#ef4444').css('color', 'white');
setTimeout(function() {
$btn.prop('disabled', false).html(originalText).css('background', '').css('color', '');
}, 2000);
}
},
error: function() {
$btn.html('<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 16px; height: 16px;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg> Error').css('background', '#ef4444').css('color', 'white');
setTimeout(function() {
$btn.prop('disabled', false).html(originalText).css('background', '').css('color', '');
}, 2000);
}
});
});
});
</script>

View File

@@ -3,7 +3,7 @@
* Plugin Name: IGNY8 WordPress Bridge
* Plugin URI: https://igny8.com/igny8-wp-bridge
* Description: Lightweight bridge plugin that connects WordPress to IGNY8 API for one-way content publishing.
* Version: 1.4.0
* Version: 1.3.9
* Author: IGNY8
* Author URI: https://igny8.com/
* License: GPL v2 or later
@@ -22,7 +22,7 @@ if (!defined('ABSPATH')) {
}
// Define plugin constants
define('IGNY8_BRIDGE_VERSION', '1.4.0');
define('IGNY8_BRIDGE_VERSION', '1.3.9');
define('IGNY8_BRIDGE_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('IGNY8_BRIDGE_PLUGIN_URL', plugin_dir_url(__FILE__));
define('IGNY8_BRIDGE_PLUGIN_FILE', __FILE__);

View File

@@ -79,11 +79,10 @@ class Igny8RestAPI {
));
// Plugin status endpoint - returns connection status and API key info
// SECURITY: Requires API key authentication
register_rest_route('igny8/v1', '/status', array(
'methods' => 'GET',
'callback' => array($this, 'get_status'),
'permission_callback' => array($this, 'check_permission'), // Requires API key
'permission_callback' => '__return_true', // Public endpoint for health checks
));
// API key verification endpoint - requires valid API key in header
@@ -398,10 +397,6 @@ class Igny8RestAPI {
* @return WP_REST_Response
*/
public function get_status($request) {
// If we reach here, API key was validated by check_permission
// Update last health check timestamp
update_option('igny8_last_api_health_check', time());
$api = new Igny8API();
$api_key = function_exists('igny8_get_secure_option') ? igny8_get_secure_option('igny8_api_key') : get_option('igny8_api_key');
$connection_enabled = igny8_is_connection_enabled();
@@ -409,11 +404,10 @@ class Igny8RestAPI {
$data = array(
'connected' => !empty($api_key) && $api->is_authenticated(),
'has_api_key' => !empty($api_key),
'api_key_validated' => true, // Since check_permission passed
'communication_enabled' => $connection_enabled,
'plugin_version' => defined('IGNY8_BRIDGE_VERSION') ? IGNY8_BRIDGE_VERSION : '1.0.0',
'wordpress_version' => get_bloginfo('version'),
'last_health_check' => time(),
'last_health_check' => get_option('igny8_last_api_health_check', 0),
'health' => (!empty($api_key) && $connection_enabled) ? 'healthy' : 'not_configured'
);

View File

@@ -58,9 +58,6 @@ 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'));
}
@@ -97,24 +94,8 @@ class Igny8_Updater {
'requires_php' => $update_info['requires_php'] ?? '',
);
} else {
// 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' => '',
);
// Remove from response if version is current or newer
unset($transient->response[$plugin_basename]);
}
return $transient;
@@ -161,44 +142,6 @@ 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
*/

View File

@@ -363,24 +363,17 @@ function igny8_get_connection_state() {
$integration_id = get_option('igny8_integration_id');
$last_structure_sync = get_option('igny8_last_structure_sync');
// SECURITY: Must have API key to show ANY connection state
if (empty($api_key)) {
igny8_log_connection_state('not_connected', 'No API key found');
return 'not_connected';
}
// SECURITY: Only show 'connected' if API key is validated
// Check if we have a recent successful API health check (within last hour)
$last_health_check = get_option('igny8_last_api_health_check', 0);
$one_hour_ago = time() - 3600;
if (!empty($api_key) && !empty($integration_id) && !empty($last_structure_sync) && $last_health_check > $one_hour_ago) {
igny8_log_connection_state('connected', 'Fully connected and synced with validated API key');
if (!empty($api_key) && !empty($integration_id) && !empty($last_structure_sync)) {
igny8_log_connection_state('connected', 'Fully connected and synced');
return 'connected';
}
// If we have API key but no recent validation, show as 'configured' not 'connected'
igny8_log_connection_state('configured', 'API key set, validation pending');
igny8_log_connection_state('configured', 'API key set, pending structure sync');
return 'configured';
}