Changeset 3625928
- Timestamp:
- 07/28/2026 01:05:24 PM (4 months ago)
- Location:
- optistate
- Files:
-
- 10 edited
-
tags/1.5.0/assets/js/admin.js (modified) (57 diffs)
-
tags/1.5.0/includes/class-optistate-admin-interface.php (modified) (2 diffs)
-
tags/1.5.0/includes/class-optistate-backup-upload.php (modified) (1 diff)
-
tags/1.5.0/includes/class-optistate-cleanup-functions.php (modified) (1 diff)
-
tags/1.5.0/includes/class-optistate-search-replace.php (modified) (1 diff)
-
trunk/assets/js/admin.js (modified) (57 diffs)
-
trunk/includes/class-optistate-admin-interface.php (modified) (2 diffs)
-
trunk/includes/class-optistate-backup-upload.php (modified) (1 diff)
-
trunk/includes/class-optistate-cleanup-functions.php (modified) (1 diff)
-
trunk/includes/class-optistate-search-replace.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
optistate/tags/1.5.0/assets/js/admin.js
r3625722 r3625928 82 82 let completed = false; 83 83 const isBackupAction = /backup|restore|decompression/.test(action); 84 const targetUrl = config.url || (isBackupAction && optistate_BackupMgr?.ajax_url ? optistate_BackupMgr.ajax_url : (optistate_Ajax?.ajaxurl|| ajaxurl));85 const targetNonce = baseData.nonce || (isBackupAction ? optistate_BackupMgr?.nonce : optistate_Ajax?.nonce);84 const targetUrl = config.url || (isBackupAction && (optistate_BackupMgr == null ? undefined : optistate_BackupMgr.ajax_url) ? optistate_BackupMgr.ajax_url : ((optistate_Ajax == null ? undefined : optistate_Ajax.ajaxurl) || ajaxurl)); 85 const targetNonce = baseData.nonce || (isBackupAction ? (optistate_BackupMgr == null ? undefined : optistate_BackupMgr.nonce) : (optistate_Ajax == null ? undefined : optistate_Ajax.nonce)); 86 86 const visibilityHandler = () => { 87 87 if (document.hidden) { … … 940 940 timeout: 30000, 941 941 success: function(response) { 942 if ( response?.success&& response.data.status === 'starting') {942 if ((response == null ? undefined : response.success) && response.data.status === 'starting') { 943 943 let currentDbSizeBytes = 0; 944 944 if (statsCache && statsCache.total_db_size_bytes) { … … 952 952 pollBackupStatus(response.data.transient_key, $btn); 953 953 } else { 954 showToast( response?.data?.message|| __('Backup failed to start.', 'optistate'), 'error');954 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Backup failed to start.', 'optistate'), 'error'); 955 955 $btn.prop('disabled', false).html(`↪ <strong>${__('Create Backup Now', 'optistate')}</strong>`); 956 956 $backupSpinner.hide(); … … 959 959 }, 960 960 error: function(xhr) { 961 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('An error occurred while creating the backup.', 'optistate'), xhr.status === 429 ? 'warning' : 'error');961 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('An error occurred while creating the backup.', 'optistate'), xhr.status === 429 ? 'warning' : 'error'); 962 962 $btn.prop('disabled', false).html(`↪ <strong>${__('Create Backup Now', 'optistate')}</strong>`); 963 963 $backupSpinner.hide(); … … 981 981 filename: filename 982 982 }).done(function(response) { 983 if ( response?.success) {983 if ((response == null ? undefined : response.success)) { 984 984 showToast(response.data.message, 'success'); 985 985 debouncedLoadOptimizationLog(); … … 991 991 }); 992 992 } else { 993 showToast( response?.data?.message|| __('Failed to delete backup.', 'optistate'), 'error');993 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to delete backup.', 'optistate'), 'error'); 994 994 $btn.prop('disabled', false); 995 995 } … … 997 997 let msg; 998 998 if (xhr.status === 429) { 999 msg = xhr.responseJSON?.data?.message|| getRateLimitMessage(false);999 msg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false); 1000 1000 showToast(msg, 'warning'); 1001 1001 } else { … … 1065 1065 timeout: 300000, 1066 1066 success: function(response) { 1067 if ( response?.success) {1067 if ((response == null ? undefined : response.success)) { 1068 1068 showToast(getRestoreTimeEstimate(sizeInBytes) || __('Restore initiated!', 'optistate'), 'info'); 1069 1069 $restoreRecoveryNotice.hide().removeClass('os-display-none').fadeIn(300); … … 1077 1077 } 1078 1078 } else { 1079 showToast( response?.data?.message|| __('Failed to initiate safety backup.', 'optistate'), 'error');1079 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to initiate safety backup.', 'optistate'), 'error'); 1080 1080 $btn.html(`<span class="dashicons dashicons-backup"></span> ${__('Restore', 'optistate')}`); 1081 1081 resetRestoreUI(); … … 1083 1083 }, 1084 1084 error: function(xhr) { 1085 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message || getRateLimitMessage(false)) : (xhr.responseJSON?.data?.message|| __('Failed to initiate safety backup (network error).', 'optistate')), xhr.status === 429 ? 'warning' : 'error');1085 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Failed to initiate safety backup (network error).', 'optistate')), xhr.status === 429 ? 'warning' : 'error'); 1086 1086 resetRestoreUI(); 1087 1087 } … … 1158 1158 return; 1159 1159 } 1160 if ( response?.success) {1160 if ((response == null ? undefined : response.success)) { 1161 1161 const data = response.data; 1162 1162 if (data.status === 'decompressing') { … … 1185 1185 } 1186 1186 } else { 1187 const code = response?.data?.code|| '';1188 const msg = response?.data?.message|| '';1187 const code = (response == null || response.data == null ? undefined : response.data.code) || ''; 1188 const msg = (response == null || response.data == null ? undefined : response.data.message) || ''; 1189 1189 if (code === 'duplicate_chunk') { 1190 1190 currentUpload.retryCount = 0; … … 1207 1207 return; 1208 1208 } 1209 const errCode = xhr.responseJSON?.data?.code|| '';1210 const errorMsg = xhr.responseJSON?.data?.message|| '';1209 const errCode = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.code) || ''; 1210 const errorMsg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || ''; 1211 1211 if (errCode === 'duplicate_chunk') { 1212 1212 currentUpload.retryCount = 0; … … 1451 1451 timeout: 1800000, 1452 1452 success: function(response) { 1453 if ( response?.success) {1453 if ((response == null ? undefined : response.success)) { 1454 1454 showToast(getRestoreTimeEstimate(sizeInBytes) || __('Restore initiated!', 'optistate'), 'info'); 1455 1455 $restoreRecoveryNotice.hide().removeClass('os-display-none').fadeIn(300); … … 1463 1463 } 1464 1464 } else { 1465 showToast( response?.data?.message|| __('Restore failed to start.', 'optistate'), 'error');1465 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Restore failed to start.', 'optistate'), 'error'); 1466 1466 resetRestoreUI(); 1467 1467 } 1468 1468 }, 1469 1469 error: function(xhr) { 1470 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message || getRateLimitMessage(false)) : (xhr.responseJSON?.data?.message|| __('Restore failed to start. Please try again.', 'optistate')), xhr.status === 429 ? 'warning' : 'error');1470 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Restore failed to start. Please try again.', 'optistate')), xhr.status === 429 ? 'warning' : 'error'); 1471 1471 resetRestoreUI(); 1472 1472 } … … 1496 1496 isSaveAction: true, 1497 1497 onSuccess: function(response) { 1498 if ( response?.success) {1498 if ((response == null ? undefined : response.success)) { 1499 1499 showToast(__('Maximum backups setting saved successfully!', 'optistate'), 'success'); 1500 1500 debouncedLoadOptimizationLog(); 1501 1501 } else { 1502 showToast( response?.data?.message|| __('Failed to save setting.', 'optistate'), 'error');1502 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to save setting.', 'optistate'), 'error'); 1503 1503 } 1504 1504 } … … 1531 1531 isSaveAction: true, 1532 1532 onSuccess: function(response) { 1533 if ( response?.success) {1533 if ((response == null ? undefined : response.success)) { 1534 1534 showToast(response.data.message, 'success'); 1535 1535 if (response.data) updateUIAfterSave(response.data); 1536 1536 debouncedLoadOptimizationLog(); 1537 1537 } else { 1538 showToast( response?.data?.message|| __('Failed to save settings.', 'optistate'), 'error');1538 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to save settings.', 'optistate'), 'error'); 1539 1539 } 1540 1540 } … … 1723 1723 } 1724 1724 else if (xhr.status === 403) errorMsg = __('Security session expired. Please refresh the page.', 'optistate'); 1725 else errorMsg = xhr.responseJSON?.data?.message|| customMsg || sprintf(__('An error occurred (Status: %d). Please try again.', 'optistate'), xhr.status);1725 else errorMsg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || customMsg || sprintf(__('An error occurred (Status: %d). Please try again.', 'optistate'), xhr.status); 1726 1726 showToast(errorMsg, xhr.status === 429 ? 'warning' : 'error'); 1727 1727 isProcessing = false; … … 1896 1896 nonce: optistate_Ajax.nonce 1897 1897 }).done(response => { 1898 if ( response?.success&& response.data) displayOptimizationLog(response.data);1898 if ((response == null ? undefined : response.success) && response.data) displayOptimizationLog(response.data); 1899 1899 }); 1900 1900 } … … 2062 2062 if (!itemType) return; 2063 2063 var itemName = labels[itemType] || itemType; 2064 var itemCount = statsCache?.[itemType]? parseInt(statsCache[itemType], 10) : 0;2064 var itemCount = (statsCache == null ? undefined : statsCache[itemType]) ? parseInt(statsCache[itemType], 10) : 0; 2065 2065 var displayItemName = itemCount > 0 ? esc_html(itemName) + ' <strong>(' + itemCount.toLocaleString() + ')</strong>' : esc_html(itemName); 2066 2066 var title = isSafe ? '🧹 ' + __('Confirm Cleanup', 'optistate') : '⚠️ ' + __('Warning: Permanent Deletion', 'optistate'); … … 2271 2271 }, 1500); 2272 2272 } else { 2273 showToast( optResponse?.data?.message|| __('Optimization failed.', 'optistate'), 'error');2273 showToast((optResponse == null || optResponse.data == null ? undefined : optResponse.data.message) || __('Optimization failed.', 'optistate'), 'error'); 2274 2274 } 2275 2275 }).fail(function(xhr) { … … 2352 2352 }); 2353 2353 } else { 2354 showToast( response?.data?.message|| __('Failed to start backup.', 'optistate'), 'error');2354 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to start backup.', 'optistate'), 'error'); 2355 2355 resetOneClickButton($btn); 2356 2356 } 2357 2357 }, 2358 2358 error: function(xhr) { 2359 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('An error occurred while creating the backup.', 'optistate'), xhr.status === 429 ? 'warning' : 'error');2359 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('An error occurred while creating the backup.', 'optistate'), xhr.status === 429 ? 'warning' : 'error'); 2360 2360 resetOneClickButton($btn); 2361 2361 } … … 2515 2515 transient_key: transient_key 2516 2516 }).done(function(response) { 2517 if ( response?.success&& response.data) {2517 if ((response == null ? undefined : response.success) && response.data) { 2518 2518 const data = response.data; 2519 2519 if (data.status === 'running') { … … 2536 2536 } 2537 2537 let detailsHtml = `<div class="optistate-success">${message}</div>`; 2538 if ( results.details?.length> 0) {2538 if ((results.details == null ? undefined : results.details.length) > 0) { 2539 2539 detailsHtml += `<div class="optistate-details os-details-container"><strong>${__('Table Analysis Details:', 'optistate')}</strong><ul class="os-m-5-0">`; 2540 2540 results.details.forEach(d => { … … 2573 2573 } 2574 2574 } else { 2575 showToast( response?.data?.message|| __('An unknown error occurred.', 'optistate'), 'error');2575 showToast((response == null || response.data == null ? undefined : response.data.message) || __('An unknown error occurred.', 'optistate'), 'error'); 2576 2576 isProcessing = false; 2577 2577 $('.optistate-advanced-op-btn').prop('disabled', false); … … 2596 2596 manual_refresh: 1 2597 2597 }).done(function(response) { 2598 if ( response?.success&& response.data) {2598 if ((response == null ? undefined : response.success) && response.data) { 2599 2599 displayOptimizationLog(response.data); 2600 2600 showToast(__('Activity Log refreshed', 'optistate'), 'info'); … … 2641 2641 timeout: 60000, 2642 2642 success: function(response) { 2643 if ( response?.success&& response.data) {2643 if ((response == null ? undefined : response.success) && response.data) { 2644 2644 displayHealthScore(response.data); 2645 2645 if (forceRefresh) { … … 2650 2650 } 2651 2651 } else { 2652 showHealthScoreError( response?.data?.message|| __('Failed to load health score', 'optistate'));2652 showHealthScoreError((response == null || response.data == null ? undefined : response.data.message) || __('Failed to load health score', 'optistate')); 2653 2653 } 2654 2654 }, 2655 2655 error: function(xhr) { 2656 2656 if (xhr.status === 429) { 2657 showToast( xhr.responseJSON?.data?.message|| getRateLimitMessage(false), 'warning');2657 showToast((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false), 'warning'); 2658 2658 return; 2659 2659 } 2660 2660 let errorMsg = __('Network error loading health score', 'optistate'); 2661 if ( xhr.responseJSON?.data?.message) {2661 if ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message)) { 2662 2662 errorMsg = xhr.responseJSON.data.message; 2663 2663 } … … 2700 2700 const $recommendations = $('#health-score-recommendations-list'); 2701 2701 $recommendations.empty(); 2702 if ( scoreData.recommendations?.length> 0) {2702 if ((scoreData.recommendations == null ? undefined : scoreData.recommendations.length) > 0) { 2703 2703 scoreData.recommendations.forEach(rec => { 2704 2704 if (!rec.message || !rec.urgency) return; … … 2750 2750 nonce: optistate_Ajax.nonce 2751 2751 }).done(function(response) { 2752 if ( response?.success&& response.data) {2752 if ((response == null ? undefined : response.success) && response.data) { 2753 2753 displayTableAnalysis(response.data); 2754 2754 $results.slideDown(300); 2755 2755 $btn.find('.dashicons').removeClass('dashicons-search').addClass('dashicons-arrow-up-alt2'); 2756 2756 } else { 2757 showToast( response?.data|| __('Failed to analyze tables', 'optistate'), 'error');2757 showToast((response == null ? undefined : response.data) || __('Failed to analyze tables', 'optistate'), 'error'); 2758 2758 } 2759 2759 }).fail(function(xhr) { 2760 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('Network error while analyzing tables', 'optistate'), xhr.status === 429 ? 'warning' : 'error');2760 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('Network error while analyzing tables', 'optistate'), xhr.status === 429 ? 'warning' : 'error'); 2761 2761 }).always(function() { 2762 2762 $loading.fadeOut(200); … … 2782 2782 table_name: tableName 2783 2783 }).done(function(response) { 2784 if ( response?.success) {2784 if ((response == null ? undefined : response.success)) { 2785 2785 showToast(response.data.message, 'success'); 2786 2786 $btn.closest('.optistate-table-item').css('background-color', '#ffcccc').fadeOut(600, function() { … … 2790 2790 loadTrashItems(); 2791 2791 } else { 2792 showToast( response?.data?.message|| __('Failed to delete table.', 'optistate'), 'error');2792 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to delete table.', 'optistate'), 'error'); 2793 2793 $btn.prop('disabled', false).html(`<span class="dashicons dashicons-trash"></span> ${__('Delete Table', 'optistate')}`); 2794 2794 } … … 2830 2830 nextBatch(); 2831 2831 }; 2832 if ( data.core_tables?.length> 0) {2832 if ((data.core_tables == null ? undefined : data.core_tables.length) > 0) { 2833 2833 const coreCategory = document.createElement('div'); 2834 2834 coreCategory.className = 'optistate-table-category core-tables'; … … 2837 2837 renderChunked(data.core_tables, coreCategory, true); 2838 2838 } 2839 if ( data.plugin_tables?.length> 0) {2839 if ((data.plugin_tables == null ? undefined : data.plugin_tables.length) > 0) { 2840 2840 const pluginCategory = document.createElement('div'); 2841 2841 pluginCategory.className = 'optistate-table-category plugin-tables'; … … 2874 2874 nonce: optistate_Ajax.nonce 2875 2875 }).done(function(response) { 2876 if ( response?.success) {2876 if ((response == null ? undefined : response.success)) { 2877 2877 const recs = response.data.recommendations; 2878 2878 if (recs.length === 0) { … … 2888 2888 $results.slideDown(300); 2889 2889 } else { 2890 showToast( response?.data?.message|| 'Analysis failed', 'error');2890 showToast((response == null || response.data == null ? undefined : response.data.message) || 'Analysis failed', 'error'); 2891 2891 } 2892 2892 }).fail(function(xhr) { 2893 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('Network error analyzing indexes.', 'optistate'), xhr.status === 429 ? 'warning' : 'error');2893 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('Network error analyzing indexes.', 'optistate'), xhr.status === 429 ? 'warning' : 'error'); 2894 2894 }).always(() => { 2895 2895 $loading.fadeOut(200); … … 3009 3009 } 3010 3010 }).fail(function(xhr) { 3011 const msg = xhr.responseJSON?.data?.message|| __('Network error.', 'optistate');3011 const msg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error.', 'optistate'); 3012 3012 showToast(msg, 'error'); 3013 3013 $btn.prop('disabled', false).html(__('🗑 Delete All', 'optistate')); … … 3150 3150 if (response.success) renderIntegrityResults(response.data); 3151 3151 else showToast(response.data.message || 'Scan failed', 'error'); 3152 }).fail(xhr => showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('Network error.', 'optistate'), xhr.status === 429 ? 'warning' : 'error')).always(() => {3152 }).fail(xhr => showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('Network error.', 'optistate'), xhr.status === 429 ? 'warning' : 'error')).always(() => { 3153 3153 $loading.fadeOut(200); 3154 3154 $btn.prop('disabled', false); … … 3238 3238 const $elements = initCacheStatsElements(); 3239 3239 const update = () => { 3240 const data = response?.success? response.data : null;3240 const data = (response == null ? undefined : response.success) ? response.data : null; 3241 3241 const errorText = __('Error', 'optistate'); 3242 3242 $elements.fileCount.text(data ? (typeof data.file_count === 'number' ? data.file_count.toLocaleString() : data.file_count) : errorText); … … 3337 3337 isSaveAction: true, 3338 3338 onSuccess: function(response) { 3339 if ( response?.success) {3339 if ((response == null ? undefined : response.success)) { 3340 3340 showToast(successMessage, 'success'); 3341 3341 debouncedLoadOptimizationLog(); 3342 3342 } else { 3343 showToast( response?.data?.message|| __('Failed to save settings.', 'optistate'), 'error');3343 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to save settings.', 'optistate'), 'error'); 3344 3344 } 3345 3345 } … … 3367 3367 nonce: optistate_Ajax.nonce 3368 3368 }).done(function(response) { 3369 if ( response?.success&& response.data) {3369 if ((response == null ? undefined : response.success) && response.data) { 3370 3370 displayPerformanceFeatures( 3371 3371 response.data.definitions, … … 3530 3530 } 3531 3531 }).fail(function(xhr) { 3532 const msg = xhr.responseJSON?.data?.message|| __('Network error.', 'optistate');3532 const msg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error.', 'optistate'); 3533 3533 const type = xhr.status === 429 ? 'warning' : 'error'; 3534 3534 showToast(msg, type); … … 4235 4235 nonce: optistate_Ajax.nonce 4236 4236 }).done(res => { 4237 if ( res?.success) {4237 if ((res == null ? undefined : res.success)) { 4238 4238 showToast(res.data.message || __('Cache successfully purged!', 'optistate'), 'success'); 4239 4239 if (res.data.trigger_preload) setTimeout(() => startPreload(), 1000); 4240 } else showToast( res?.data?.message|| __('An error occurred.', 'optistate'), 'error');4241 }).fail(xhr => showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('Network error.', 'optistate'), xhr.status === 429 ? 'warning' : 'error'))4240 } else showToast((res == null || res.data == null ? undefined : res.data.message) || __('An error occurred.', 'optistate'), 'error'); 4241 }).fail(xhr => showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('Network error.', 'optistate'), xhr.status === 429 ? 'warning' : 'error')) 4242 4242 .always(() => { 4243 4243 $btn.prop('disabled', false).html(`🗑️ ${__('Purge All Cache', 'optistate')}`); … … 4261 4261 nonce: optistate_Ajax.nonce 4262 4262 }).done(res => { 4263 if ( res?.success) {4263 if ((res == null ? undefined : res.success)) { 4264 4264 showToast(res.data.message, 'info'); 4265 4265 $('#preload-status-text').html(`<strong>${__('Preload stopped by user.', 'optistate')}</strong>`); … … 4273 4273 } 4274 4274 }).fail(xhr => { 4275 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message || getRateLimitMessage(false)) : (xhr.responseJSON?.data?.message|| __('Network error', 'optistate')), xhr.status === 429 ? 'warning' : 'error');4275 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error', 'optistate')), xhr.status === 429 ? 'warning' : 'error'); 4276 4276 $btn.prop('disabled', false).html(`🟥 ${__('Stop', 'optistate')}`); 4277 4277 isPreloadCancelled = false; … … 4291 4291 return { 4292 4292 writable: false, 4293 message: data?.message|| __('Network error', 'optistate'),4294 exists: data?.exists4293 message: (data == null ? undefined : data.message) || __('Network error', 'optistate'), 4294 exists: (data == null ? undefined : data.exists) 4295 4295 }; 4296 4296 }); … … 4333 4333 nonce: optistate_Ajax.nonce 4334 4334 }).done(res => { 4335 if ( res?.success) {4335 if ((res == null ? undefined : res.success)) { 4336 4336 showToast(res.data.message, 'info'); 4337 4337 pollPreloadStatus(); … … 4385 4385 }), 4000); 4386 4386 } else $status.html(`<p class="optistate-error">✗ ${res.data.message || 'Export failed'}</p>`); 4387 }).fail(xhr => $status.html(`<p class="optistate-error">✗ ${ xhr.responseJSON?.data?.message|| (xhr.status === 429 ? getRateLimitMessage(false) : __('Network error', 'optistate'))}</p>`)).always(() => $btn.prop('disabled', false));4387 }).fail(xhr => $status.html(`<p class="optistate-error">✗ ${(xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || (xhr.status === 429 ? getRateLimitMessage(false) : __('Network error', 'optistate'))}</p>`)).always(() => $btn.prop('disabled', false)); 4388 4388 }); 4389 4389 $('#optistate-settings-file-input').on('change', function() { … … 4591 4591 }).fail((xhr) => { 4592 4592 $checkbox.prop('disabled', false).prop('checked', !isChecked); 4593 showToast(xhr.status === 429 ? getRateLimitMessage(true) : ( xhr.responseJSON?.data?.message|| __('Network error.', 'optistate')), xhr.status === 429 ? 'warning' : 'error');4593 showToast(xhr.status === 429 ? getRateLimitMessage(true) : ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error.', 'optistate')), xhr.status === 429 ? 'warning' : 'error'); 4594 4594 }); 4595 4595 }); … … 4673 4673 showToast( 4674 4674 xhr.status === 429 ? 4675 ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) :4676 ( xhr.responseJSON?.data?.message|| __('Network error.', 'optistate')),4675 ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : 4676 ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error.', 'optistate')), 4677 4677 xhr.status === 429 ? 'warning' : 'error' 4678 4678 ); … … 4723 4723 4724 4724 let previewHtml = ''; 4725 if (data.total_matches > 0 && data.preview?.length> 0) {4725 if (data.total_matches > 0 && (data.preview == null ? undefined : data.preview.length) > 0) { 4726 4726 previewHtml += `<div class="os-search-container"><table class="widefat striped os-border-none"><thead><tr><th>${__('Table', 'optistate')}</th><th>${__('Column', 'optistate')}</th><th>${__('ID', 'optistate')}</th><th>${__('Content Preview', 'optistate')}</th></tr></thead><tbody>`; 4727 4727 data.preview.forEach(item => { 4728 4728 previewHtml += `<tr><td>${esc_html(item.table)}</td><td>${esc_html(item.column)}</td><td>${esc_html(item.id)}</td><td class="os-font-12-mono">${item.content}</td></tr>`; 4729 4729 }); 4730 const occurrencesShown = data.preview_occurrences !== undefined ? data.preview_occurrences : ( data.preview?.length|| 0);4730 const occurrencesShown = data.preview_occurrences !== undefined ? data.preview_occurrences : ((data.preview == null ? undefined : data.preview.length) || 0); 4731 4731 if (data.total_matches > occurrencesShown) { 4732 4732 previewHtml += `<tr><td colspan="4" class="os-text-center"><em>${sprintf(__('%s more matches...', 'optistate'), (data.total_matches - occurrencesShown).toLocaleString())}</em></td></tr>`; … … 4939 4939 4940 4940 const updateMetric = (id, metric, thresholds) => { 4941 const val = metric?.value|| 0;4942 $(id).text(`→ ${ metric?.display|| 'N/A'}`).closest('.optistate-targeted-card').css({4941 const val = (metric == null ? undefined : metric.value) || 0; 4942 $(id).text(`→ ${(metric == null ? undefined : metric.display) || 'N/A'}`).closest('.optistate-targeted-card').css({ 4943 4943 borderLeft: `4px solid ${val <= thresholds.good ? '#28a745' : (val <= thresholds.needsImprovement ? '#ffa400' : '#dc3545')}`, 4944 4944 paddingLeft: '11px' … … 4992 4992 4993 4993 const $recsList = $('#optistate-psi-recommendations-list'); 4994 if ( data.recommendations?.length> 0) {4994 if ((data.recommendations == null ? undefined : data.recommendations.length) > 0) { 4995 4995 const colors = { 4996 4996 high: '#C13048', … … 5061 5061 nonce: optistate_Ajax.nonce 5062 5062 }).done(function(response) { 5063 if ( response?.success&& response.data) {5063 if ((response == null ? undefined : response.success) && response.data) { 5064 5064 const data = response.data; 5065 5065 if (data.status === 'running') { … … 5106 5106 nonce: optistate_BackupMgr.nonce 5107 5107 }).done(function(response) { 5108 if ( response?.success&& response.data) {5108 if ((response == null ? undefined : response.success) && response.data) { 5109 5109 if (response.data.status === 'running' && response.data.transient_key) { 5110 5110 $(SELECTORS.globalButtons).prop('disabled', true); … … 5161 5161 loadCacheStats(function(response) { 5162 5162 $btn.prop('disabled', false); 5163 if ( response?.success) {5163 if ((response == null ? undefined : response.success)) { 5164 5164 showToast(__('Cache statistics refreshed successfully.', 'optistate'), 'success'); 5165 5165 } else { … … 5190 5190 const items = Array.isArray(payload) ? payload : (Array.isArray(data.items) ? data.items : []); 5191 5191 const total = Number.isFinite(data.total) ? data.total : items.length; 5192 const $countSpan = $('#optistate-trash-count'); 5193 if ($countSpan.length) { 5194 if (total > 0) { 5195 $countSpan.text('(' + total.toLocaleString() + ')'); 5196 } else { 5197 $countSpan.text(''); 5198 } 5199 } 5192 5200 const $list = $('#optistate-trash-list'); 5193 5201 let $actions = $('#optistate-trash-actions'); -
optistate/tags/1.5.0/includes/class-optistate-admin-interface.php
r3625722 r3625928 210 210 "optistate" 211 211 ); ?></label> <div class="os-flex-gap-10"> <div class="os-flex-1-relative"> <input type="password" id="optistate_pagespeed_key" value="<?php echo esc_attr( 212 $ settings["pagespeed_api_key"] ?? ""212 $plugin->settings_manager->get_pagespeed_api_key() 213 213 ); ?>" class="os-input-password-padded" placeholder="<?php esc_attr_e( 214 214 "Enter API Key", … … 320 320 "Refresh Cleanup Data", 321 321 "optistate" 322 ); ?></button> </div> </div> <div class="optistate-card os-mt-20"> <h2> <span><span class="dashicons dashicons-plugins-checked"></span> <?php esc_html_e( 323 "Legacy Plugin Data Scanner", 322 ); ?></button> </div> </div> <div class="optistate-card os-mt-20"> 323 <h2> 324 <span><span class="dashicons dashicons-plugins-checked"></span> <?php esc_html_e( 325 "Legacy Plugin Data Scanner", 326 "optistate" 327 ); ?></span> 328 <a href="<?php echo esc_url( 329 $manual_base . "#ch-5-4" 330 ); ?>" class="optistate-info-link os-no-decoration" target="_blank" rel="noopener noreferrer" title="<?php esc_attr_e( 331 "Read the Manual", 332 "optistate" 333 ); ?>"><span class="dashicons dashicons-info"></span></a> 334 </h2> 335 <p class="os-mb-15-lh-relaxed"> 336 🕵️ <?php esc_html_e( 337 "Detects data left behind by plugins/themes you have uninstalled.", 338 "optistate" 339 ); ?><br> 340 📉 <?php esc_html_e( 341 'Removing "Ghost Data" can significantly reduce database size and slightly improve your site\'s speed.', 342 "optistate" 343 ); ?><br> 344 🧩 <?php esc_html_e( 345 "Also run the Database Structure Analysis tool (Advanced tab) to identify and remove any additional unused tables.", 346 "optistate" 347 ); ?> 348 </p> 349 <button type="button" class="button button-secondary os-mb-5" id="optistate-scan-legacy-btn">🔎 <?php esc_html_e( 350 "Scan for Ghost Data", 351 "optistate" 352 ); ?></button> 353 <div id="optistate-legacy-results" class="os-display-none"></div> 354 <br><br><hr> 355 <div class="optistate-trash-section"> 356 <?php 357 $trash_count = $this->main_plugin->trash_manager->count_trash_items(); 358 $trash_label = 359 $trash_count > 0 360 ? sprintf( 361 __("Trash (%s) - Recover Deleted Items", "optistate"), 362 number_format_i18n($trash_count) 363 ) 364 : __("Trash - Recover Deleted Items", "optistate"); 365 ?> 366 <h3> 367 <span class="dashicons dashicons-trash"></span> 368 <?php esc_html_e("Trash", "optistate"); ?> 369 <span id="optistate-trash-count"></span> 370 - <?php esc_html_e("Recover Deleted Items", "optistate"); ?> 371 </h3> 372 <p class="os-mb-15"> 373 🕓 <?php esc_html_e( 374 "Deleted folders/tables/options/metas are moved here and kept for 14 days. You can restore them if needed.", 375 "optistate" 376 ); ?> 377 </p> 378 <div id="optistate-trash-list" class="os-mt-15"></div> 379 </div> 380 </div><div id="tab-backups" class="optistate-tab-content"> <div class="optistate-card"> <h2> <span><span class="dashicons dashicons-database-export"></span> <?php esc_html_e( 381 "Create a Database Backup", 324 382 "optistate" 325 383 ); ?></span> <a href="<?php echo esc_url( 326 $manual_base . "#ch-5-4"327 ); ?>" class="optistate-info-link os-no-decoration" target="_blank" rel="noopener noreferrer" title="<?php esc_attr_e(328 "Read the Manual",329 "optistate"330 ); ?>"><span class="dashicons dashicons-info"></span></a> </h2> <p class="os-mb-15-lh-relaxed"> 🕵️ <?php esc_html_e(331 "Detects data left behind by plugins/themes you have uninstalled.",332 "optistate"333 ); ?><br> 📉 <?php esc_html_e(334 'Removing "Ghost Data" can significantly reduce database size and slightly improve your site\'s speed.',335 "optistate"336 ); ?><br> 🧩 <?php esc_html_e(337 "Also run the Database Structure Analysis tool (Advanced tab) to identify and remove any additional unused tables.",338 "optistate"339 ); ?> </p> <button type="button" class="button button-secondary os-mb-5" id="optistate-scan-legacy-btn">🔎 <?php esc_html_e(340 "Scan for Ghost Data",341 "optistate"342 ); ?></button> <div id="optistate-legacy-results" class="os-display-none"></div> <br><br><hr> <div class="optistate-trash-section"> <h3><span class="dashicons dashicons-trash"></span> <?php esc_html_e(343 "Trash (Recover Deleted Items)",344 "optistate"345 ); ?></h3> <p class="os-mb-15"> 🕓 <?php esc_html_e(346 "Deleted folders/tables/options/metas are moved here and kept for 14 days. You can restore them if needed.",347 "optistate"348 ); ?> </p> <div id="optistate-trash-list" class="os-mt-15"></div> </div> </div> </div><div id="tab-backups" class="optistate-tab-content"> <div class="optistate-card"> <h2> <span><span class="dashicons dashicons-database-export"></span> <?php esc_html_e(349 "Create a Database Backup",350 "optistate"351 ); ?></span> <a href="<?php echo esc_url(352 384 $manual_base . "#ch-4-1" 353 385 ); ?>" class="optistate-info-link os-no-decoration" target="_blank" rel="noopener noreferrer" title="<?php esc_attr_e( -
optistate/tags/1.5.0/includes/class-optistate-backup-upload.php
r3625722 r3625928 185 185 public function ajax_upload_restore_file(): void 186 186 { 187 if (!$this->main_plugin->verify_ajax_request( 'optistate_backup_nonce')) {187 if (!$this->main_plugin->verify_ajax_request(OPTISTATE::BACKUP_NONCE_ACTION)) { 188 188 return; 189 189 } -
optistate/tags/1.5.0/includes/class-optistate-cleanup-functions.php
r3625722 r3625928 2147 2147 wp_using_ext_object_cache() 2148 2148 ) { 2149 if (function_exists("wp_cache_flush_group")) { 2150 $flushed_transient = (bool) wp_cache_flush_group("transient"); 2151 $flushed_site_transient = (bool) wp_cache_flush_group("site-transient"); 2149 if (OPTISTATE_Utils::can_flush_cache_group()) { 2150 $flushed_transient = (bool) wp_cache_flush_group("transient"); 2151 $flushed_site_transient = (bool) wp_cache_flush_group( 2152 "site-transient" 2153 ); 2152 2154 return $flushed_transient && $flushed_site_transient ? 1 : 0; 2153 2155 } elseif (function_exists("wp_cache_flush")) { -
optistate/tags/1.5.0/includes/class-optistate-search-replace.php
r3625722 r3625928 1381 1381 $network_id = is_multisite() ? (int) get_current_network_id() : 0; 1382 1382 if ($overflow) { 1383 $can_flush_group = 1384 function_exists("wp_cache_supports") && 1385 function_exists("wp_cache_flush_group") && 1386 wp_cache_supports("flush_group"); 1387 if ($can_flush_group) { 1383 if (OPTISTATE_Utils::can_flush_cache_group()) { 1388 1384 wp_cache_flush_group("options"); 1389 1385 if ($network_id > 0) { -
optistate/trunk/assets/js/admin.js
r3625722 r3625928 82 82 let completed = false; 83 83 const isBackupAction = /backup|restore|decompression/.test(action); 84 const targetUrl = config.url || (isBackupAction && optistate_BackupMgr?.ajax_url ? optistate_BackupMgr.ajax_url : (optistate_Ajax?.ajaxurl|| ajaxurl));85 const targetNonce = baseData.nonce || (isBackupAction ? optistate_BackupMgr?.nonce : optistate_Ajax?.nonce);84 const targetUrl = config.url || (isBackupAction && (optistate_BackupMgr == null ? undefined : optistate_BackupMgr.ajax_url) ? optistate_BackupMgr.ajax_url : ((optistate_Ajax == null ? undefined : optistate_Ajax.ajaxurl) || ajaxurl)); 85 const targetNonce = baseData.nonce || (isBackupAction ? (optistate_BackupMgr == null ? undefined : optistate_BackupMgr.nonce) : (optistate_Ajax == null ? undefined : optistate_Ajax.nonce)); 86 86 const visibilityHandler = () => { 87 87 if (document.hidden) { … … 940 940 timeout: 30000, 941 941 success: function(response) { 942 if ( response?.success&& response.data.status === 'starting') {942 if ((response == null ? undefined : response.success) && response.data.status === 'starting') { 943 943 let currentDbSizeBytes = 0; 944 944 if (statsCache && statsCache.total_db_size_bytes) { … … 952 952 pollBackupStatus(response.data.transient_key, $btn); 953 953 } else { 954 showToast( response?.data?.message|| __('Backup failed to start.', 'optistate'), 'error');954 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Backup failed to start.', 'optistate'), 'error'); 955 955 $btn.prop('disabled', false).html(`↪ <strong>${__('Create Backup Now', 'optistate')}</strong>`); 956 956 $backupSpinner.hide(); … … 959 959 }, 960 960 error: function(xhr) { 961 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('An error occurred while creating the backup.', 'optistate'), xhr.status === 429 ? 'warning' : 'error');961 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('An error occurred while creating the backup.', 'optistate'), xhr.status === 429 ? 'warning' : 'error'); 962 962 $btn.prop('disabled', false).html(`↪ <strong>${__('Create Backup Now', 'optistate')}</strong>`); 963 963 $backupSpinner.hide(); … … 981 981 filename: filename 982 982 }).done(function(response) { 983 if ( response?.success) {983 if ((response == null ? undefined : response.success)) { 984 984 showToast(response.data.message, 'success'); 985 985 debouncedLoadOptimizationLog(); … … 991 991 }); 992 992 } else { 993 showToast( response?.data?.message|| __('Failed to delete backup.', 'optistate'), 'error');993 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to delete backup.', 'optistate'), 'error'); 994 994 $btn.prop('disabled', false); 995 995 } … … 997 997 let msg; 998 998 if (xhr.status === 429) { 999 msg = xhr.responseJSON?.data?.message|| getRateLimitMessage(false);999 msg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false); 1000 1000 showToast(msg, 'warning'); 1001 1001 } else { … … 1065 1065 timeout: 300000, 1066 1066 success: function(response) { 1067 if ( response?.success) {1067 if ((response == null ? undefined : response.success)) { 1068 1068 showToast(getRestoreTimeEstimate(sizeInBytes) || __('Restore initiated!', 'optistate'), 'info'); 1069 1069 $restoreRecoveryNotice.hide().removeClass('os-display-none').fadeIn(300); … … 1077 1077 } 1078 1078 } else { 1079 showToast( response?.data?.message|| __('Failed to initiate safety backup.', 'optistate'), 'error');1079 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to initiate safety backup.', 'optistate'), 'error'); 1080 1080 $btn.html(`<span class="dashicons dashicons-backup"></span> ${__('Restore', 'optistate')}`); 1081 1081 resetRestoreUI(); … … 1083 1083 }, 1084 1084 error: function(xhr) { 1085 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message || getRateLimitMessage(false)) : (xhr.responseJSON?.data?.message|| __('Failed to initiate safety backup (network error).', 'optistate')), xhr.status === 429 ? 'warning' : 'error');1085 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Failed to initiate safety backup (network error).', 'optistate')), xhr.status === 429 ? 'warning' : 'error'); 1086 1086 resetRestoreUI(); 1087 1087 } … … 1158 1158 return; 1159 1159 } 1160 if ( response?.success) {1160 if ((response == null ? undefined : response.success)) { 1161 1161 const data = response.data; 1162 1162 if (data.status === 'decompressing') { … … 1185 1185 } 1186 1186 } else { 1187 const code = response?.data?.code|| '';1188 const msg = response?.data?.message|| '';1187 const code = (response == null || response.data == null ? undefined : response.data.code) || ''; 1188 const msg = (response == null || response.data == null ? undefined : response.data.message) || ''; 1189 1189 if (code === 'duplicate_chunk') { 1190 1190 currentUpload.retryCount = 0; … … 1207 1207 return; 1208 1208 } 1209 const errCode = xhr.responseJSON?.data?.code|| '';1210 const errorMsg = xhr.responseJSON?.data?.message|| '';1209 const errCode = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.code) || ''; 1210 const errorMsg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || ''; 1211 1211 if (errCode === 'duplicate_chunk') { 1212 1212 currentUpload.retryCount = 0; … … 1451 1451 timeout: 1800000, 1452 1452 success: function(response) { 1453 if ( response?.success) {1453 if ((response == null ? undefined : response.success)) { 1454 1454 showToast(getRestoreTimeEstimate(sizeInBytes) || __('Restore initiated!', 'optistate'), 'info'); 1455 1455 $restoreRecoveryNotice.hide().removeClass('os-display-none').fadeIn(300); … … 1463 1463 } 1464 1464 } else { 1465 showToast( response?.data?.message|| __('Restore failed to start.', 'optistate'), 'error');1465 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Restore failed to start.', 'optistate'), 'error'); 1466 1466 resetRestoreUI(); 1467 1467 } 1468 1468 }, 1469 1469 error: function(xhr) { 1470 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message || getRateLimitMessage(false)) : (xhr.responseJSON?.data?.message|| __('Restore failed to start. Please try again.', 'optistate')), xhr.status === 429 ? 'warning' : 'error');1470 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Restore failed to start. Please try again.', 'optistate')), xhr.status === 429 ? 'warning' : 'error'); 1471 1471 resetRestoreUI(); 1472 1472 } … … 1496 1496 isSaveAction: true, 1497 1497 onSuccess: function(response) { 1498 if ( response?.success) {1498 if ((response == null ? undefined : response.success)) { 1499 1499 showToast(__('Maximum backups setting saved successfully!', 'optistate'), 'success'); 1500 1500 debouncedLoadOptimizationLog(); 1501 1501 } else { 1502 showToast( response?.data?.message|| __('Failed to save setting.', 'optistate'), 'error');1502 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to save setting.', 'optistate'), 'error'); 1503 1503 } 1504 1504 } … … 1531 1531 isSaveAction: true, 1532 1532 onSuccess: function(response) { 1533 if ( response?.success) {1533 if ((response == null ? undefined : response.success)) { 1534 1534 showToast(response.data.message, 'success'); 1535 1535 if (response.data) updateUIAfterSave(response.data); 1536 1536 debouncedLoadOptimizationLog(); 1537 1537 } else { 1538 showToast( response?.data?.message|| __('Failed to save settings.', 'optistate'), 'error');1538 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to save settings.', 'optistate'), 'error'); 1539 1539 } 1540 1540 } … … 1723 1723 } 1724 1724 else if (xhr.status === 403) errorMsg = __('Security session expired. Please refresh the page.', 'optistate'); 1725 else errorMsg = xhr.responseJSON?.data?.message|| customMsg || sprintf(__('An error occurred (Status: %d). Please try again.', 'optistate'), xhr.status);1725 else errorMsg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || customMsg || sprintf(__('An error occurred (Status: %d). Please try again.', 'optistate'), xhr.status); 1726 1726 showToast(errorMsg, xhr.status === 429 ? 'warning' : 'error'); 1727 1727 isProcessing = false; … … 1896 1896 nonce: optistate_Ajax.nonce 1897 1897 }).done(response => { 1898 if ( response?.success&& response.data) displayOptimizationLog(response.data);1898 if ((response == null ? undefined : response.success) && response.data) displayOptimizationLog(response.data); 1899 1899 }); 1900 1900 } … … 2062 2062 if (!itemType) return; 2063 2063 var itemName = labels[itemType] || itemType; 2064 var itemCount = statsCache?.[itemType]? parseInt(statsCache[itemType], 10) : 0;2064 var itemCount = (statsCache == null ? undefined : statsCache[itemType]) ? parseInt(statsCache[itemType], 10) : 0; 2065 2065 var displayItemName = itemCount > 0 ? esc_html(itemName) + ' <strong>(' + itemCount.toLocaleString() + ')</strong>' : esc_html(itemName); 2066 2066 var title = isSafe ? '🧹 ' + __('Confirm Cleanup', 'optistate') : '⚠️ ' + __('Warning: Permanent Deletion', 'optistate'); … … 2271 2271 }, 1500); 2272 2272 } else { 2273 showToast( optResponse?.data?.message|| __('Optimization failed.', 'optistate'), 'error');2273 showToast((optResponse == null || optResponse.data == null ? undefined : optResponse.data.message) || __('Optimization failed.', 'optistate'), 'error'); 2274 2274 } 2275 2275 }).fail(function(xhr) { … … 2352 2352 }); 2353 2353 } else { 2354 showToast( response?.data?.message|| __('Failed to start backup.', 'optistate'), 'error');2354 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to start backup.', 'optistate'), 'error'); 2355 2355 resetOneClickButton($btn); 2356 2356 } 2357 2357 }, 2358 2358 error: function(xhr) { 2359 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('An error occurred while creating the backup.', 'optistate'), xhr.status === 429 ? 'warning' : 'error');2359 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('An error occurred while creating the backup.', 'optistate'), xhr.status === 429 ? 'warning' : 'error'); 2360 2360 resetOneClickButton($btn); 2361 2361 } … … 2515 2515 transient_key: transient_key 2516 2516 }).done(function(response) { 2517 if ( response?.success&& response.data) {2517 if ((response == null ? undefined : response.success) && response.data) { 2518 2518 const data = response.data; 2519 2519 if (data.status === 'running') { … … 2536 2536 } 2537 2537 let detailsHtml = `<div class="optistate-success">${message}</div>`; 2538 if ( results.details?.length> 0) {2538 if ((results.details == null ? undefined : results.details.length) > 0) { 2539 2539 detailsHtml += `<div class="optistate-details os-details-container"><strong>${__('Table Analysis Details:', 'optistate')}</strong><ul class="os-m-5-0">`; 2540 2540 results.details.forEach(d => { … … 2573 2573 } 2574 2574 } else { 2575 showToast( response?.data?.message|| __('An unknown error occurred.', 'optistate'), 'error');2575 showToast((response == null || response.data == null ? undefined : response.data.message) || __('An unknown error occurred.', 'optistate'), 'error'); 2576 2576 isProcessing = false; 2577 2577 $('.optistate-advanced-op-btn').prop('disabled', false); … … 2596 2596 manual_refresh: 1 2597 2597 }).done(function(response) { 2598 if ( response?.success&& response.data) {2598 if ((response == null ? undefined : response.success) && response.data) { 2599 2599 displayOptimizationLog(response.data); 2600 2600 showToast(__('Activity Log refreshed', 'optistate'), 'info'); … … 2641 2641 timeout: 60000, 2642 2642 success: function(response) { 2643 if ( response?.success&& response.data) {2643 if ((response == null ? undefined : response.success) && response.data) { 2644 2644 displayHealthScore(response.data); 2645 2645 if (forceRefresh) { … … 2650 2650 } 2651 2651 } else { 2652 showHealthScoreError( response?.data?.message|| __('Failed to load health score', 'optistate'));2652 showHealthScoreError((response == null || response.data == null ? undefined : response.data.message) || __('Failed to load health score', 'optistate')); 2653 2653 } 2654 2654 }, 2655 2655 error: function(xhr) { 2656 2656 if (xhr.status === 429) { 2657 showToast( xhr.responseJSON?.data?.message|| getRateLimitMessage(false), 'warning');2657 showToast((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false), 'warning'); 2658 2658 return; 2659 2659 } 2660 2660 let errorMsg = __('Network error loading health score', 'optistate'); 2661 if ( xhr.responseJSON?.data?.message) {2661 if ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message)) { 2662 2662 errorMsg = xhr.responseJSON.data.message; 2663 2663 } … … 2700 2700 const $recommendations = $('#health-score-recommendations-list'); 2701 2701 $recommendations.empty(); 2702 if ( scoreData.recommendations?.length> 0) {2702 if ((scoreData.recommendations == null ? undefined : scoreData.recommendations.length) > 0) { 2703 2703 scoreData.recommendations.forEach(rec => { 2704 2704 if (!rec.message || !rec.urgency) return; … … 2750 2750 nonce: optistate_Ajax.nonce 2751 2751 }).done(function(response) { 2752 if ( response?.success&& response.data) {2752 if ((response == null ? undefined : response.success) && response.data) { 2753 2753 displayTableAnalysis(response.data); 2754 2754 $results.slideDown(300); 2755 2755 $btn.find('.dashicons').removeClass('dashicons-search').addClass('dashicons-arrow-up-alt2'); 2756 2756 } else { 2757 showToast( response?.data|| __('Failed to analyze tables', 'optistate'), 'error');2757 showToast((response == null ? undefined : response.data) || __('Failed to analyze tables', 'optistate'), 'error'); 2758 2758 } 2759 2759 }).fail(function(xhr) { 2760 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('Network error while analyzing tables', 'optistate'), xhr.status === 429 ? 'warning' : 'error');2760 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('Network error while analyzing tables', 'optistate'), xhr.status === 429 ? 'warning' : 'error'); 2761 2761 }).always(function() { 2762 2762 $loading.fadeOut(200); … … 2782 2782 table_name: tableName 2783 2783 }).done(function(response) { 2784 if ( response?.success) {2784 if ((response == null ? undefined : response.success)) { 2785 2785 showToast(response.data.message, 'success'); 2786 2786 $btn.closest('.optistate-table-item').css('background-color', '#ffcccc').fadeOut(600, function() { … … 2790 2790 loadTrashItems(); 2791 2791 } else { 2792 showToast( response?.data?.message|| __('Failed to delete table.', 'optistate'), 'error');2792 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to delete table.', 'optistate'), 'error'); 2793 2793 $btn.prop('disabled', false).html(`<span class="dashicons dashicons-trash"></span> ${__('Delete Table', 'optistate')}`); 2794 2794 } … … 2830 2830 nextBatch(); 2831 2831 }; 2832 if ( data.core_tables?.length> 0) {2832 if ((data.core_tables == null ? undefined : data.core_tables.length) > 0) { 2833 2833 const coreCategory = document.createElement('div'); 2834 2834 coreCategory.className = 'optistate-table-category core-tables'; … … 2837 2837 renderChunked(data.core_tables, coreCategory, true); 2838 2838 } 2839 if ( data.plugin_tables?.length> 0) {2839 if ((data.plugin_tables == null ? undefined : data.plugin_tables.length) > 0) { 2840 2840 const pluginCategory = document.createElement('div'); 2841 2841 pluginCategory.className = 'optistate-table-category plugin-tables'; … … 2874 2874 nonce: optistate_Ajax.nonce 2875 2875 }).done(function(response) { 2876 if ( response?.success) {2876 if ((response == null ? undefined : response.success)) { 2877 2877 const recs = response.data.recommendations; 2878 2878 if (recs.length === 0) { … … 2888 2888 $results.slideDown(300); 2889 2889 } else { 2890 showToast( response?.data?.message|| 'Analysis failed', 'error');2890 showToast((response == null || response.data == null ? undefined : response.data.message) || 'Analysis failed', 'error'); 2891 2891 } 2892 2892 }).fail(function(xhr) { 2893 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('Network error analyzing indexes.', 'optistate'), xhr.status === 429 ? 'warning' : 'error');2893 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('Network error analyzing indexes.', 'optistate'), xhr.status === 429 ? 'warning' : 'error'); 2894 2894 }).always(() => { 2895 2895 $loading.fadeOut(200); … … 3009 3009 } 3010 3010 }).fail(function(xhr) { 3011 const msg = xhr.responseJSON?.data?.message|| __('Network error.', 'optistate');3011 const msg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error.', 'optistate'); 3012 3012 showToast(msg, 'error'); 3013 3013 $btn.prop('disabled', false).html(__('🗑 Delete All', 'optistate')); … … 3150 3150 if (response.success) renderIntegrityResults(response.data); 3151 3151 else showToast(response.data.message || 'Scan failed', 'error'); 3152 }).fail(xhr => showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('Network error.', 'optistate'), xhr.status === 429 ? 'warning' : 'error')).always(() => {3152 }).fail(xhr => showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('Network error.', 'optistate'), xhr.status === 429 ? 'warning' : 'error')).always(() => { 3153 3153 $loading.fadeOut(200); 3154 3154 $btn.prop('disabled', false); … … 3238 3238 const $elements = initCacheStatsElements(); 3239 3239 const update = () => { 3240 const data = response?.success? response.data : null;3240 const data = (response == null ? undefined : response.success) ? response.data : null; 3241 3241 const errorText = __('Error', 'optistate'); 3242 3242 $elements.fileCount.text(data ? (typeof data.file_count === 'number' ? data.file_count.toLocaleString() : data.file_count) : errorText); … … 3337 3337 isSaveAction: true, 3338 3338 onSuccess: function(response) { 3339 if ( response?.success) {3339 if ((response == null ? undefined : response.success)) { 3340 3340 showToast(successMessage, 'success'); 3341 3341 debouncedLoadOptimizationLog(); 3342 3342 } else { 3343 showToast( response?.data?.message|| __('Failed to save settings.', 'optistate'), 'error');3343 showToast((response == null || response.data == null ? undefined : response.data.message) || __('Failed to save settings.', 'optistate'), 'error'); 3344 3344 } 3345 3345 } … … 3367 3367 nonce: optistate_Ajax.nonce 3368 3368 }).done(function(response) { 3369 if ( response?.success&& response.data) {3369 if ((response == null ? undefined : response.success) && response.data) { 3370 3370 displayPerformanceFeatures( 3371 3371 response.data.definitions, … … 3530 3530 } 3531 3531 }).fail(function(xhr) { 3532 const msg = xhr.responseJSON?.data?.message|| __('Network error.', 'optistate');3532 const msg = (xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error.', 'optistate'); 3533 3533 const type = xhr.status === 429 ? 'warning' : 'error'; 3534 3534 showToast(msg, type); … … 4235 4235 nonce: optistate_Ajax.nonce 4236 4236 }).done(res => { 4237 if ( res?.success) {4237 if ((res == null ? undefined : res.success)) { 4238 4238 showToast(res.data.message || __('Cache successfully purged!', 'optistate'), 'success'); 4239 4239 if (res.data.trigger_preload) setTimeout(() => startPreload(), 1000); 4240 } else showToast( res?.data?.message|| __('An error occurred.', 'optistate'), 'error');4241 }).fail(xhr => showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) : __('Network error.', 'optistate'), xhr.status === 429 ? 'warning' : 'error'))4240 } else showToast((res == null || res.data == null ? undefined : res.data.message) || __('An error occurred.', 'optistate'), 'error'); 4241 }).fail(xhr => showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : __('Network error.', 'optistate'), xhr.status === 429 ? 'warning' : 'error')) 4242 4242 .always(() => { 4243 4243 $btn.prop('disabled', false).html(`🗑️ ${__('Purge All Cache', 'optistate')}`); … … 4261 4261 nonce: optistate_Ajax.nonce 4262 4262 }).done(res => { 4263 if ( res?.success) {4263 if ((res == null ? undefined : res.success)) { 4264 4264 showToast(res.data.message, 'info'); 4265 4265 $('#preload-status-text').html(`<strong>${__('Preload stopped by user.', 'optistate')}</strong>`); … … 4273 4273 } 4274 4274 }).fail(xhr => { 4275 showToast(xhr.status === 429 ? ( xhr.responseJSON?.data?.message || getRateLimitMessage(false)) : (xhr.responseJSON?.data?.message|| __('Network error', 'optistate')), xhr.status === 429 ? 'warning' : 'error');4275 showToast(xhr.status === 429 ? ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error', 'optistate')), xhr.status === 429 ? 'warning' : 'error'); 4276 4276 $btn.prop('disabled', false).html(`🟥 ${__('Stop', 'optistate')}`); 4277 4277 isPreloadCancelled = false; … … 4291 4291 return { 4292 4292 writable: false, 4293 message: data?.message|| __('Network error', 'optistate'),4294 exists: data?.exists4293 message: (data == null ? undefined : data.message) || __('Network error', 'optistate'), 4294 exists: (data == null ? undefined : data.exists) 4295 4295 }; 4296 4296 }); … … 4333 4333 nonce: optistate_Ajax.nonce 4334 4334 }).done(res => { 4335 if ( res?.success) {4335 if ((res == null ? undefined : res.success)) { 4336 4336 showToast(res.data.message, 'info'); 4337 4337 pollPreloadStatus(); … … 4385 4385 }), 4000); 4386 4386 } else $status.html(`<p class="optistate-error">✗ ${res.data.message || 'Export failed'}</p>`); 4387 }).fail(xhr => $status.html(`<p class="optistate-error">✗ ${ xhr.responseJSON?.data?.message|| (xhr.status === 429 ? getRateLimitMessage(false) : __('Network error', 'optistate'))}</p>`)).always(() => $btn.prop('disabled', false));4387 }).fail(xhr => $status.html(`<p class="optistate-error">✗ ${(xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || (xhr.status === 429 ? getRateLimitMessage(false) : __('Network error', 'optistate'))}</p>`)).always(() => $btn.prop('disabled', false)); 4388 4388 }); 4389 4389 $('#optistate-settings-file-input').on('change', function() { … … 4591 4591 }).fail((xhr) => { 4592 4592 $checkbox.prop('disabled', false).prop('checked', !isChecked); 4593 showToast(xhr.status === 429 ? getRateLimitMessage(true) : ( xhr.responseJSON?.data?.message|| __('Network error.', 'optistate')), xhr.status === 429 ? 'warning' : 'error');4593 showToast(xhr.status === 429 ? getRateLimitMessage(true) : ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error.', 'optistate')), xhr.status === 429 ? 'warning' : 'error'); 4594 4594 }); 4595 4595 }); … … 4673 4673 showToast( 4674 4674 xhr.status === 429 ? 4675 ( xhr.responseJSON?.data?.message|| getRateLimitMessage(false)) :4676 ( xhr.responseJSON?.data?.message|| __('Network error.', 'optistate')),4675 ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || getRateLimitMessage(false)) : 4676 ((xhr.responseJSON == null || xhr.responseJSON.data == null ? undefined : xhr.responseJSON.data.message) || __('Network error.', 'optistate')), 4677 4677 xhr.status === 429 ? 'warning' : 'error' 4678 4678 ); … … 4723 4723 4724 4724 let previewHtml = ''; 4725 if (data.total_matches > 0 && data.preview?.length> 0) {4725 if (data.total_matches > 0 && (data.preview == null ? undefined : data.preview.length) > 0) { 4726 4726 previewHtml += `<div class="os-search-container"><table class="widefat striped os-border-none"><thead><tr><th>${__('Table', 'optistate')}</th><th>${__('Column', 'optistate')}</th><th>${__('ID', 'optistate')}</th><th>${__('Content Preview', 'optistate')}</th></tr></thead><tbody>`; 4727 4727 data.preview.forEach(item => { 4728 4728 previewHtml += `<tr><td>${esc_html(item.table)}</td><td>${esc_html(item.column)}</td><td>${esc_html(item.id)}</td><td class="os-font-12-mono">${item.content}</td></tr>`; 4729 4729 }); 4730 const occurrencesShown = data.preview_occurrences !== undefined ? data.preview_occurrences : ( data.preview?.length|| 0);4730 const occurrencesShown = data.preview_occurrences !== undefined ? data.preview_occurrences : ((data.preview == null ? undefined : data.preview.length) || 0); 4731 4731 if (data.total_matches > occurrencesShown) { 4732 4732 previewHtml += `<tr><td colspan="4" class="os-text-center"><em>${sprintf(__('%s more matches...', 'optistate'), (data.total_matches - occurrencesShown).toLocaleString())}</em></td></tr>`; … … 4939 4939 4940 4940 const updateMetric = (id, metric, thresholds) => { 4941 const val = metric?.value|| 0;4942 $(id).text(`→ ${ metric?.display|| 'N/A'}`).closest('.optistate-targeted-card').css({4941 const val = (metric == null ? undefined : metric.value) || 0; 4942 $(id).text(`→ ${(metric == null ? undefined : metric.display) || 'N/A'}`).closest('.optistate-targeted-card').css({ 4943 4943 borderLeft: `4px solid ${val <= thresholds.good ? '#28a745' : (val <= thresholds.needsImprovement ? '#ffa400' : '#dc3545')}`, 4944 4944 paddingLeft: '11px' … … 4992 4992 4993 4993 const $recsList = $('#optistate-psi-recommendations-list'); 4994 if ( data.recommendations?.length> 0) {4994 if ((data.recommendations == null ? undefined : data.recommendations.length) > 0) { 4995 4995 const colors = { 4996 4996 high: '#C13048', … … 5061 5061 nonce: optistate_Ajax.nonce 5062 5062 }).done(function(response) { 5063 if ( response?.success&& response.data) {5063 if ((response == null ? undefined : response.success) && response.data) { 5064 5064 const data = response.data; 5065 5065 if (data.status === 'running') { … … 5106 5106 nonce: optistate_BackupMgr.nonce 5107 5107 }).done(function(response) { 5108 if ( response?.success&& response.data) {5108 if ((response == null ? undefined : response.success) && response.data) { 5109 5109 if (response.data.status === 'running' && response.data.transient_key) { 5110 5110 $(SELECTORS.globalButtons).prop('disabled', true); … … 5161 5161 loadCacheStats(function(response) { 5162 5162 $btn.prop('disabled', false); 5163 if ( response?.success) {5163 if ((response == null ? undefined : response.success)) { 5164 5164 showToast(__('Cache statistics refreshed successfully.', 'optistate'), 'success'); 5165 5165 } else { … … 5190 5190 const items = Array.isArray(payload) ? payload : (Array.isArray(data.items) ? data.items : []); 5191 5191 const total = Number.isFinite(data.total) ? data.total : items.length; 5192 const $countSpan = $('#optistate-trash-count'); 5193 if ($countSpan.length) { 5194 if (total > 0) { 5195 $countSpan.text('(' + total.toLocaleString() + ')'); 5196 } else { 5197 $countSpan.text(''); 5198 } 5199 } 5192 5200 const $list = $('#optistate-trash-list'); 5193 5201 let $actions = $('#optistate-trash-actions'); -
optistate/trunk/includes/class-optistate-admin-interface.php
r3625722 r3625928 210 210 "optistate" 211 211 ); ?></label> <div class="os-flex-gap-10"> <div class="os-flex-1-relative"> <input type="password" id="optistate_pagespeed_key" value="<?php echo esc_attr( 212 $ settings["pagespeed_api_key"] ?? ""212 $plugin->settings_manager->get_pagespeed_api_key() 213 213 ); ?>" class="os-input-password-padded" placeholder="<?php esc_attr_e( 214 214 "Enter API Key", … … 320 320 "Refresh Cleanup Data", 321 321 "optistate" 322 ); ?></button> </div> </div> <div class="optistate-card os-mt-20"> <h2> <span><span class="dashicons dashicons-plugins-checked"></span> <?php esc_html_e( 323 "Legacy Plugin Data Scanner", 322 ); ?></button> </div> </div> <div class="optistate-card os-mt-20"> 323 <h2> 324 <span><span class="dashicons dashicons-plugins-checked"></span> <?php esc_html_e( 325 "Legacy Plugin Data Scanner", 326 "optistate" 327 ); ?></span> 328 <a href="<?php echo esc_url( 329 $manual_base . "#ch-5-4" 330 ); ?>" class="optistate-info-link os-no-decoration" target="_blank" rel="noopener noreferrer" title="<?php esc_attr_e( 331 "Read the Manual", 332 "optistate" 333 ); ?>"><span class="dashicons dashicons-info"></span></a> 334 </h2> 335 <p class="os-mb-15-lh-relaxed"> 336 🕵️ <?php esc_html_e( 337 "Detects data left behind by plugins/themes you have uninstalled.", 338 "optistate" 339 ); ?><br> 340 📉 <?php esc_html_e( 341 'Removing "Ghost Data" can significantly reduce database size and slightly improve your site\'s speed.', 342 "optistate" 343 ); ?><br> 344 🧩 <?php esc_html_e( 345 "Also run the Database Structure Analysis tool (Advanced tab) to identify and remove any additional unused tables.", 346 "optistate" 347 ); ?> 348 </p> 349 <button type="button" class="button button-secondary os-mb-5" id="optistate-scan-legacy-btn">🔎 <?php esc_html_e( 350 "Scan for Ghost Data", 351 "optistate" 352 ); ?></button> 353 <div id="optistate-legacy-results" class="os-display-none"></div> 354 <br><br><hr> 355 <div class="optistate-trash-section"> 356 <?php 357 $trash_count = $this->main_plugin->trash_manager->count_trash_items(); 358 $trash_label = 359 $trash_count > 0 360 ? sprintf( 361 __("Trash (%s) - Recover Deleted Items", "optistate"), 362 number_format_i18n($trash_count) 363 ) 364 : __("Trash - Recover Deleted Items", "optistate"); 365 ?> 366 <h3> 367 <span class="dashicons dashicons-trash"></span> 368 <?php esc_html_e("Trash", "optistate"); ?> 369 <span id="optistate-trash-count"></span> 370 - <?php esc_html_e("Recover Deleted Items", "optistate"); ?> 371 </h3> 372 <p class="os-mb-15"> 373 🕓 <?php esc_html_e( 374 "Deleted folders/tables/options/metas are moved here and kept for 14 days. You can restore them if needed.", 375 "optistate" 376 ); ?> 377 </p> 378 <div id="optistate-trash-list" class="os-mt-15"></div> 379 </div> 380 </div><div id="tab-backups" class="optistate-tab-content"> <div class="optistate-card"> <h2> <span><span class="dashicons dashicons-database-export"></span> <?php esc_html_e( 381 "Create a Database Backup", 324 382 "optistate" 325 383 ); ?></span> <a href="<?php echo esc_url( 326 $manual_base . "#ch-5-4"327 ); ?>" class="optistate-info-link os-no-decoration" target="_blank" rel="noopener noreferrer" title="<?php esc_attr_e(328 "Read the Manual",329 "optistate"330 ); ?>"><span class="dashicons dashicons-info"></span></a> </h2> <p class="os-mb-15-lh-relaxed"> 🕵️ <?php esc_html_e(331 "Detects data left behind by plugins/themes you have uninstalled.",332 "optistate"333 ); ?><br> 📉 <?php esc_html_e(334 'Removing "Ghost Data" can significantly reduce database size and slightly improve your site\'s speed.',335 "optistate"336 ); ?><br> 🧩 <?php esc_html_e(337 "Also run the Database Structure Analysis tool (Advanced tab) to identify and remove any additional unused tables.",338 "optistate"339 ); ?> </p> <button type="button" class="button button-secondary os-mb-5" id="optistate-scan-legacy-btn">🔎 <?php esc_html_e(340 "Scan for Ghost Data",341 "optistate"342 ); ?></button> <div id="optistate-legacy-results" class="os-display-none"></div> <br><br><hr> <div class="optistate-trash-section"> <h3><span class="dashicons dashicons-trash"></span> <?php esc_html_e(343 "Trash (Recover Deleted Items)",344 "optistate"345 ); ?></h3> <p class="os-mb-15"> 🕓 <?php esc_html_e(346 "Deleted folders/tables/options/metas are moved here and kept for 14 days. You can restore them if needed.",347 "optistate"348 ); ?> </p> <div id="optistate-trash-list" class="os-mt-15"></div> </div> </div> </div><div id="tab-backups" class="optistate-tab-content"> <div class="optistate-card"> <h2> <span><span class="dashicons dashicons-database-export"></span> <?php esc_html_e(349 "Create a Database Backup",350 "optistate"351 ); ?></span> <a href="<?php echo esc_url(352 384 $manual_base . "#ch-4-1" 353 385 ); ?>" class="optistate-info-link os-no-decoration" target="_blank" rel="noopener noreferrer" title="<?php esc_attr_e( -
optistate/trunk/includes/class-optistate-backup-upload.php
r3625722 r3625928 185 185 public function ajax_upload_restore_file(): void 186 186 { 187 if (!$this->main_plugin->verify_ajax_request( 'optistate_backup_nonce')) {187 if (!$this->main_plugin->verify_ajax_request(OPTISTATE::BACKUP_NONCE_ACTION)) { 188 188 return; 189 189 } -
optistate/trunk/includes/class-optistate-cleanup-functions.php
r3625722 r3625928 2147 2147 wp_using_ext_object_cache() 2148 2148 ) { 2149 if (function_exists("wp_cache_flush_group")) { 2150 $flushed_transient = (bool) wp_cache_flush_group("transient"); 2151 $flushed_site_transient = (bool) wp_cache_flush_group("site-transient"); 2149 if (OPTISTATE_Utils::can_flush_cache_group()) { 2150 $flushed_transient = (bool) wp_cache_flush_group("transient"); 2151 $flushed_site_transient = (bool) wp_cache_flush_group( 2152 "site-transient" 2153 ); 2152 2154 return $flushed_transient && $flushed_site_transient ? 1 : 0; 2153 2155 } elseif (function_exists("wp_cache_flush")) { -
optistate/trunk/includes/class-optistate-search-replace.php
r3625722 r3625928 1381 1381 $network_id = is_multisite() ? (int) get_current_network_id() : 0; 1382 1382 if ($overflow) { 1383 $can_flush_group = 1384 function_exists("wp_cache_supports") && 1385 function_exists("wp_cache_flush_group") && 1386 wp_cache_supports("flush_group"); 1387 if ($can_flush_group) { 1383 if (OPTISTATE_Utils::can_flush_cache_group()) { 1388 1384 wp_cache_flush_group("options"); 1389 1385 if ($network_id > 0) {
Note:
See TracChangeset
for help on using the changeset viewer.