Plugin Directory

Changeset 3625928


Ignore:
Timestamp:
07/28/2026 01:05:24 PM (4 months ago)
Author:
lukegarry
Message:

Added trash counter.

Location:
optistate
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • optistate/tags/1.5.0/assets/js/admin.js

    r3625722 r3625928  
    8282        let completed = false;
    8383        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));
    8686        const visibilityHandler = () => {
    8787            if (document.hidden) {
    … …  
    940940                        timeout: 30000,
    941941                        success: function(response) {
    942                             if (response?.success && response.data.status === 'starting') {
     942                            if ((response == null ? undefined : response.success) && response.data.status === 'starting') {
    943943                                let currentDbSizeBytes = 0;
    944944                                if (statsCache && statsCache.total_db_size_bytes) {
    … …  
    952952                                pollBackupStatus(response.data.transient_key, $btn);
    953953                            } 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');
    955955                                $btn.prop('disabled', false).html(`↪ <strong>${__('Create Backup Now', 'optistate')}</strong>`);
    956956                                $backupSpinner.hide();
    … …  
    959959                        },
    960960                        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');
    962962                            $btn.prop('disabled', false).html(`↪ <strong>${__('Create Backup Now', 'optistate')}</strong>`);
    963963                            $backupSpinner.hide();
    … …  
    981981                    filename: filename
    982982                }).done(function(response) {
    983                     if (response?.success) {
     983                    if ((response == null ? undefined : response.success)) {
    984984                        showToast(response.data.message, 'success');
    985985                        debouncedLoadOptimizationLog();
    … …  
    991991                        });
    992992                    } 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');
    994994                        $btn.prop('disabled', false);
    995995                    }
    … …  
    997997                    let msg;
    998998                    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);
    10001000                        showToast(msg, 'warning');
    10011001                    } else {
    … …  
    10651065                    timeout: 300000,
    10661066                    success: function(response) {
    1067                         if (response?.success) {
     1067                        if ((response == null ? undefined : response.success)) {
    10681068                            showToast(getRestoreTimeEstimate(sizeInBytes) || __('Restore initiated!', 'optistate'), 'info');
    10691069                            $restoreRecoveryNotice.hide().removeClass('os-display-none').fadeIn(300);
    … …  
    10771077                            }
    10781078                        } 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');
    10801080                            $btn.html(`<span class="dashicons dashicons-backup"></span> ${__('Restore', 'optistate')}`);
    10811081                            resetRestoreUI();
    … …  
    10831083                    },
    10841084                    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');
    10861086                        resetRestoreUI();
    10871087                    }
    … …  
    11581158                    return;
    11591159                }
    1160                 if (response?.success) {
     1160                if ((response == null ? undefined : response.success)) {
    11611161                    const data = response.data;
    11621162                    if (data.status === 'decompressing') {
    … …  
    11851185                    }
    11861186                } 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) || '';
    11891189                    if (code === 'duplicate_chunk') {
    11901190                        currentUpload.retryCount = 0;
    … …  
    12071207                    return;
    12081208                }
    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) || '';
    12111211                if (errCode === 'duplicate_chunk') {
    12121212                    currentUpload.retryCount = 0;
    … …  
    14511451                    timeout: 1800000,
    14521452                    success: function(response) {
    1453                         if (response?.success) {
     1453                        if ((response == null ? undefined : response.success)) {
    14541454                            showToast(getRestoreTimeEstimate(sizeInBytes) || __('Restore initiated!', 'optistate'), 'info');
    14551455                            $restoreRecoveryNotice.hide().removeClass('os-display-none').fadeIn(300);
    … …  
    14631463                            }
    14641464                        } 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');
    14661466                            resetRestoreUI();
    14671467                        }
    14681468                    },
    14691469                    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');
    14711471                        resetRestoreUI();
    14721472                    }
    … …  
    14961496                isSaveAction: true,
    14971497                onSuccess: function(response) {
    1498                     if (response?.success) {
     1498                    if ((response == null ? undefined : response.success)) {
    14991499                        showToast(__('Maximum backups setting saved successfully!', 'optistate'), 'success');
    15001500                        debouncedLoadOptimizationLog();
    15011501                    } 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');
    15031503                    }
    15041504                }
    … …  
    15311531                isSaveAction: true,
    15321532                onSuccess: function(response) {
    1533                     if (response?.success) {
     1533                    if ((response == null ? undefined : response.success)) {
    15341534                        showToast(response.data.message, 'success');
    15351535                        if (response.data) updateUIAfterSave(response.data);
    15361536                        debouncedLoadOptimizationLog();
    15371537                    } 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');
    15391539                    }
    15401540                }
    … …  
    17231723}
    17241724        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);
    17261726        showToast(errorMsg, xhr.status === 429 ? 'warning' : 'error');
    17271727        isProcessing = false;
    … …  
    18961896            nonce: optistate_Ajax.nonce
    18971897        }).done(response => {
    1898             if (response?.success && response.data) displayOptimizationLog(response.data);
     1898            if ((response == null ? undefined : response.success) && response.data) displayOptimizationLog(response.data);
    18991899        });
    19001900    }
    … …  
    20622062            if (!itemType) return;
    20632063            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;
    20652065            var displayItemName = itemCount > 0 ? esc_html(itemName) + ' <strong>(' + itemCount.toLocaleString() + ')</strong>' : esc_html(itemName);
    20662066            var title = isSafe ? '🧹 ' + __('Confirm Cleanup', 'optistate') : '⚠️ ' + __('Warning: Permanent Deletion', 'optistate');
    … …  
    22712271                            }, 1500);
    22722272                        } 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');
    22742274                        }
    22752275                    }).fail(function(xhr) {
    … …  
    23522352                        });
    23532353                    } 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');
    23552355                        resetOneClickButton($btn);
    23562356                    }
    23572357                },
    23582358                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');
    23602360                    resetOneClickButton($btn);
    23612361                }
    … …  
    25152515            transient_key: transient_key
    25162516        }).done(function(response) {
    2517             if (response?.success && response.data) {
     2517            if ((response == null ? undefined : response.success) && response.data) {
    25182518                const data = response.data;
    25192519                if (data.status === 'running') {
    … …  
    25362536                    }
    25372537                    let detailsHtml = `<div class="optistate-success">${message}</div>`;
    2538                     if (results.details?.length > 0) {
     2538                    if ((results.details == null ? undefined : results.details.length) > 0) {
    25392539                        detailsHtml += `<div class="optistate-details os-details-container"><strong>${__('Table Analysis Details:', 'optistate')}</strong><ul class="os-m-5-0">`;
    25402540                        results.details.forEach(d => {
    … …  
    25732573                }
    25742574            } 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');
    25762576                isProcessing = false;
    25772577                $('.optistate-advanced-op-btn').prop('disabled', false);
    … …  
    25962596            manual_refresh: 1
    25972597        }).done(function(response) {
    2598             if (response?.success && response.data) {
     2598            if ((response == null ? undefined : response.success) && response.data) {
    25992599                displayOptimizationLog(response.data);
    26002600                showToast(__('Activity Log refreshed', 'optistate'), 'info');
    … …  
    26412641            timeout: 60000,
    26422642            success: function(response) {
    2643                 if (response?.success && response.data) {
     2643                if ((response == null ? undefined : response.success) && response.data) {
    26442644                    displayHealthScore(response.data);
    26452645                    if (forceRefresh) {
    … …  
    26502650                    }
    26512651                } 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'));
    26532653                }
    26542654            },
    26552655            error: function(xhr) {
    26562656                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');
    26582658                    return;
    26592659                }
    26602660                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)) {
    26622662                    errorMsg = xhr.responseJSON.data.message;
    26632663                }
    … …  
    27002700        const $recommendations = $('#health-score-recommendations-list');
    27012701        $recommendations.empty();
    2702         if (scoreData.recommendations?.length > 0) {
     2702        if ((scoreData.recommendations == null ? undefined : scoreData.recommendations.length) > 0) {
    27032703            scoreData.recommendations.forEach(rec => {
    27042704                if (!rec.message || !rec.urgency) return;
    … …  
    27502750                nonce: optistate_Ajax.nonce
    27512751            }).done(function(response) {
    2752                 if (response?.success && response.data) {
     2752                if ((response == null ? undefined : response.success) && response.data) {
    27532753                    displayTableAnalysis(response.data);
    27542754                    $results.slideDown(300);
    27552755                    $btn.find('.dashicons').removeClass('dashicons-search').addClass('dashicons-arrow-up-alt2');
    27562756                } else {
    2757                     showToast(response?.data || __('Failed to analyze tables', 'optistate'), 'error');
     2757                    showToast((response == null ? undefined : response.data) || __('Failed to analyze tables', 'optistate'), 'error');
    27582758                }
    27592759            }).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');
    27612761            }).always(function() {
    27622762                $loading.fadeOut(200);
    … …  
    27822782                    table_name: tableName
    27832783                }).done(function(response) {
    2784                     if (response?.success) {
     2784                    if ((response == null ? undefined : response.success)) {
    27852785                        showToast(response.data.message, 'success');
    27862786                        $btn.closest('.optistate-table-item').css('background-color', '#ffcccc').fadeOut(600, function() {
    … …  
    27902790                        loadTrashItems();
    27912791                    } 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');
    27932793                        $btn.prop('disabled', false).html(`<span class="dashicons dashicons-trash"></span> ${__('Delete Table', 'optistate')}`);
    27942794                    }
    … …  
    28302830            nextBatch();
    28312831        };
    2832         if (data.core_tables?.length > 0) {
     2832        if ((data.core_tables == null ? undefined : data.core_tables.length) > 0) {
    28332833            const coreCategory = document.createElement('div');
    28342834            coreCategory.className = 'optistate-table-category core-tables';
    … …  
    28372837            renderChunked(data.core_tables, coreCategory, true);
    28382838        }
    2839         if (data.plugin_tables?.length > 0) {
     2839        if ((data.plugin_tables == null ? undefined : data.plugin_tables.length) > 0) {
    28402840            const pluginCategory = document.createElement('div');
    28412841            pluginCategory.className = 'optistate-table-category plugin-tables';
    … …  
    28742874                nonce: optistate_Ajax.nonce
    28752875            }).done(function(response) {
    2876                 if (response?.success) {
     2876                if ((response == null ? undefined : response.success)) {
    28772877                    const recs = response.data.recommendations;
    28782878                    if (recs.length === 0) {
    … …  
    28882888                    $results.slideDown(300);
    28892889                } else {
    2890                     showToast(response?.data?.message || 'Analysis failed', 'error');
     2890                    showToast((response == null || response.data == null ? undefined : response.data.message) || 'Analysis failed', 'error');
    28912891                }
    28922892            }).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');
    28942894            }).always(() => {
    28952895                $loading.fadeOut(200);
    … …  
    30093009                    }
    30103010                }).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');
    30123012                    showToast(msg, 'error');
    30133013                    $btn.prop('disabled', false).html(__('🗑 Delete All', 'optistate'));
    … …  
    31503150                if (response.success) renderIntegrityResults(response.data);
    31513151                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(() => {
    31533153                $loading.fadeOut(200);
    31543154                $btn.prop('disabled', false);
    … …  
    32383238            const $elements = initCacheStatsElements();
    32393239            const update = () => {
    3240                 const data = response?.success ? response.data : null;
     3240                const data = (response == null ? undefined : response.success) ? response.data : null;
    32413241                const errorText = __('Error', 'optistate');
    32423242                $elements.fileCount.text(data ? (typeof data.file_count === 'number' ? data.file_count.toLocaleString() : data.file_count) : errorText);
    … …  
    33373337            isSaveAction: true,
    33383338            onSuccess: function(response) {
    3339                 if (response?.success) {
     3339                if ((response == null ? undefined : response.success)) {
    33403340                    showToast(successMessage, 'success');
    33413341                    debouncedLoadOptimizationLog();
    33423342                } 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');
    33443344                }
    33453345            }
    … …  
    33673367            nonce: optistate_Ajax.nonce
    33683368        }).done(function(response) {
    3369             if (response?.success && response.data) {
     3369            if ((response == null ? undefined : response.success) && response.data) {
    33703370                displayPerformanceFeatures(
    33713371                    response.data.definitions,
    … …  
    35303530            }
    35313531        }).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');
    35333533            const type = xhr.status === 429 ? 'warning' : 'error';
    35343534            showToast(msg, type);
    … …  
    42354235                        nonce: optistate_Ajax.nonce
    42364236                    }).done(res => {
    4237                         if (res?.success) {
     4237                        if ((res == null ? undefined : res.success)) {
    42384238                            showToast(res.data.message || __('Cache successfully purged!', 'optistate'), 'success');
    42394239                            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'))
    42424242                    .always(() => {
    42434243                        $btn.prop('disabled', false).html(`🗑️ ${__('Purge All Cache', 'optistate')}`);
    … …  
    42614261                nonce: optistate_Ajax.nonce
    42624262            }).done(res => {
    4263                 if (res?.success) {
     4263                if ((res == null ? undefined : res.success)) {
    42644264                    showToast(res.data.message, 'info');
    42654265                    $('#preload-status-text').html(`<strong>${__('Preload stopped by user.', 'optistate')}</strong>`);
    … …  
    42734273                }
    42744274            }).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');
    42764276                $btn.prop('disabled', false).html(`🟥 ${__('Stop', 'optistate')}`);
    42774277                isPreloadCancelled = false;
    … …  
    42914291            return {
    42924292                writable: false,
    4293                 message: data?.message || __('Network error', 'optistate'),
    4294                 exists: data?.exists
     4293                message: (data == null ? undefined : data.message) || __('Network error', 'optistate'),
     4294                exists: (data == null ? undefined : data.exists)
    42954295            };
    42964296        });
    … …  
    43334333            nonce: optistate_Ajax.nonce
    43344334        }).done(res => {
    4335             if (res?.success) {
     4335            if ((res == null ? undefined : res.success)) {
    43364336                showToast(res.data.message, 'info');
    43374337                pollPreloadStatus();
    … …  
    43854385                    }), 4000);
    43864386                } 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));
    43884388        });
    43894389        $('#optistate-settings-file-input').on('change', function() {
    … …  
    45914591            }).fail((xhr) => {
    45924592                $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');
    45944594            });
    45954595        });
    … …  
    46734673                showToast(
    46744674                    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')),
    46774677                    xhr.status === 429 ? 'warning' : 'error'
    46784678                );
    … …  
    47234723
    47244724            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) {
    47264726                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>`;
    47274727                data.preview.forEach(item => {
    47284728                    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>`;
    47294729                });
    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);
    47314731                if (data.total_matches > occurrencesShown) {
    47324732                    previewHtml += `<tr><td colspan="4" class="os-text-center"><em>${sprintf(__('%s more matches...', 'optistate'), (data.total_matches - occurrencesShown).toLocaleString())}</em></td></tr>`;
    … …  
    49394939
    49404940            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({
    49434943                    borderLeft: `4px solid ${val <= thresholds.good ? '#28a745' : (val <= thresholds.needsImprovement ? '#ffa400' : '#dc3545')}`,
    49444944                    paddingLeft: '11px'
    … …  
    49924992
    49934993            const $recsList = $('#optistate-psi-recommendations-list');
    4994             if (data.recommendations?.length > 0) {
     4994            if ((data.recommendations == null ? undefined : data.recommendations.length) > 0) {
    49954995                const colors = {
    49964996                    high: '#C13048',
    … …  
    50615061            nonce: optistate_Ajax.nonce
    50625062        }).done(function(response) {
    5063             if (response?.success && response.data) {
     5063            if ((response == null ? undefined : response.success) && response.data) {
    50645064                const data = response.data;
    50655065                if (data.status === 'running') {
    … …  
    51065106            nonce: optistate_BackupMgr.nonce
    51075107        }).done(function(response) {
    5108             if (response?.success && response.data) {
     5108            if ((response == null ? undefined : response.success) && response.data) {
    51095109                if (response.data.status === 'running' && response.data.transient_key) {
    51105110                    $(SELECTORS.globalButtons).prop('disabled', true);
    … …  
    51615161        loadCacheStats(function(response) {
    51625162            $btn.prop('disabled', false);
    5163             if (response?.success) {
     5163            if ((response == null ? undefined : response.success)) {
    51645164                showToast(__('Cache statistics refreshed successfully.', 'optistate'), 'success');
    51655165            } else {
    … …  
    51905190        const items = Array.isArray(payload) ? payload : (Array.isArray(data.items) ? data.items : []);
    51915191        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        }
    51925200        const $list = $('#optistate-trash-list');
    51935201        let $actions = $('#optistate-trash-actions');
  • optistate/tags/1.5.0/includes/class-optistate-admin-interface.php

    r3625722 r3625928  
    210210     "optistate"
    211211 ); ?></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()
    213213); ?>" class="os-input-password-padded" placeholder="<?php esc_attr_e(
    214214    "Enter API Key",
    … …  
    320320    "Refresh Cleanup Data",
    321321    "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",
    324382    "optistate"
    325383); ?></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(
    352384    $manual_base . "#ch-4-1"
    353385); ?>" 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  
    185185    public function ajax_upload_restore_file(): void
    186186    {
    187         if (!$this->main_plugin->verify_ajax_request('optistate_backup_nonce')) {
     187        if (!$this->main_plugin->verify_ajax_request(OPTISTATE::BACKUP_NONCE_ACTION)) {
    188188            return;
    189189        }
  • optistate/tags/1.5.0/includes/class-optistate-cleanup-functions.php

    r3625722 r3625928  
    21472147            wp_using_ext_object_cache()
    21482148        ) {
    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                );
    21522154                return $flushed_transient && $flushed_site_transient ? 1 : 0;
    21532155            } elseif (function_exists("wp_cache_flush")) {
  • optistate/tags/1.5.0/includes/class-optistate-search-replace.php

    r3625722 r3625928  
    13811381        $network_id = is_multisite() ? (int) get_current_network_id() : 0;
    13821382        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()) {
    13881384                wp_cache_flush_group("options");
    13891385                if ($network_id > 0) {
  • optistate/trunk/assets/js/admin.js

    r3625722 r3625928  
    8282        let completed = false;
    8383        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));
    8686        const visibilityHandler = () => {
    8787            if (document.hidden) {
    … …  
    940940                        timeout: 30000,
    941941                        success: function(response) {
    942                             if (response?.success && response.data.status === 'starting') {
     942                            if ((response == null ? undefined : response.success) && response.data.status === 'starting') {
    943943                                let currentDbSizeBytes = 0;
    944944                                if (statsCache && statsCache.total_db_size_bytes) {
    … …  
    952952                                pollBackupStatus(response.data.transient_key, $btn);
    953953                            } 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');
    955955                                $btn.prop('disabled', false).html(`↪ <strong>${__('Create Backup Now', 'optistate')}</strong>`);
    956956                                $backupSpinner.hide();
    … …  
    959959                        },
    960960                        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');
    962962                            $btn.prop('disabled', false).html(`↪ <strong>${__('Create Backup Now', 'optistate')}</strong>`);
    963963                            $backupSpinner.hide();
    … …  
    981981                    filename: filename
    982982                }).done(function(response) {
    983                     if (response?.success) {
     983                    if ((response == null ? undefined : response.success)) {
    984984                        showToast(response.data.message, 'success');
    985985                        debouncedLoadOptimizationLog();
    … …  
    991991                        });
    992992                    } 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');
    994994                        $btn.prop('disabled', false);
    995995                    }
    … …  
    997997                    let msg;
    998998                    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);
    10001000                        showToast(msg, 'warning');
    10011001                    } else {
    … …  
    10651065                    timeout: 300000,
    10661066                    success: function(response) {
    1067                         if (response?.success) {
     1067                        if ((response == null ? undefined : response.success)) {
    10681068                            showToast(getRestoreTimeEstimate(sizeInBytes) || __('Restore initiated!', 'optistate'), 'info');
    10691069                            $restoreRecoveryNotice.hide().removeClass('os-display-none').fadeIn(300);
    … …  
    10771077                            }
    10781078                        } 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');
    10801080                            $btn.html(`<span class="dashicons dashicons-backup"></span> ${__('Restore', 'optistate')}`);
    10811081                            resetRestoreUI();
    … …  
    10831083                    },
    10841084                    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');
    10861086                        resetRestoreUI();
    10871087                    }
    … …  
    11581158                    return;
    11591159                }
    1160                 if (response?.success) {
     1160                if ((response == null ? undefined : response.success)) {
    11611161                    const data = response.data;
    11621162                    if (data.status === 'decompressing') {
    … …  
    11851185                    }
    11861186                } 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) || '';
    11891189                    if (code === 'duplicate_chunk') {
    11901190                        currentUpload.retryCount = 0;
    … …  
    12071207                    return;
    12081208                }
    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) || '';
    12111211                if (errCode === 'duplicate_chunk') {
    12121212                    currentUpload.retryCount = 0;
    … …  
    14511451                    timeout: 1800000,
    14521452                    success: function(response) {
    1453                         if (response?.success) {
     1453                        if ((response == null ? undefined : response.success)) {
    14541454                            showToast(getRestoreTimeEstimate(sizeInBytes) || __('Restore initiated!', 'optistate'), 'info');
    14551455                            $restoreRecoveryNotice.hide().removeClass('os-display-none').fadeIn(300);
    … …  
    14631463                            }
    14641464                        } 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');
    14661466                            resetRestoreUI();
    14671467                        }
    14681468                    },
    14691469                    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');
    14711471                        resetRestoreUI();
    14721472                    }
    … …  
    14961496                isSaveAction: true,
    14971497                onSuccess: function(response) {
    1498                     if (response?.success) {
     1498                    if ((response == null ? undefined : response.success)) {
    14991499                        showToast(__('Maximum backups setting saved successfully!', 'optistate'), 'success');
    15001500                        debouncedLoadOptimizationLog();
    15011501                    } 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');
    15031503                    }
    15041504                }
    … …  
    15311531                isSaveAction: true,
    15321532                onSuccess: function(response) {
    1533                     if (response?.success) {
     1533                    if ((response == null ? undefined : response.success)) {
    15341534                        showToast(response.data.message, 'success');
    15351535                        if (response.data) updateUIAfterSave(response.data);
    15361536                        debouncedLoadOptimizationLog();
    15371537                    } 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');
    15391539                    }
    15401540                }
    … …  
    17231723}
    17241724        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);
    17261726        showToast(errorMsg, xhr.status === 429 ? 'warning' : 'error');
    17271727        isProcessing = false;
    … …  
    18961896            nonce: optistate_Ajax.nonce
    18971897        }).done(response => {
    1898             if (response?.success && response.data) displayOptimizationLog(response.data);
     1898            if ((response == null ? undefined : response.success) && response.data) displayOptimizationLog(response.data);
    18991899        });
    19001900    }
    … …  
    20622062            if (!itemType) return;
    20632063            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;
    20652065            var displayItemName = itemCount > 0 ? esc_html(itemName) + ' <strong>(' + itemCount.toLocaleString() + ')</strong>' : esc_html(itemName);
    20662066            var title = isSafe ? '🧹 ' + __('Confirm Cleanup', 'optistate') : '⚠️ ' + __('Warning: Permanent Deletion', 'optistate');
    … …  
    22712271                            }, 1500);
    22722272                        } 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');
    22742274                        }
    22752275                    }).fail(function(xhr) {
    … …  
    23522352                        });
    23532353                    } 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');
    23552355                        resetOneClickButton($btn);
    23562356                    }
    23572357                },
    23582358                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');
    23602360                    resetOneClickButton($btn);
    23612361                }
    … …  
    25152515            transient_key: transient_key
    25162516        }).done(function(response) {
    2517             if (response?.success && response.data) {
     2517            if ((response == null ? undefined : response.success) && response.data) {
    25182518                const data = response.data;
    25192519                if (data.status === 'running') {
    … …  
    25362536                    }
    25372537                    let detailsHtml = `<div class="optistate-success">${message}</div>`;
    2538                     if (results.details?.length > 0) {
     2538                    if ((results.details == null ? undefined : results.details.length) > 0) {
    25392539                        detailsHtml += `<div class="optistate-details os-details-container"><strong>${__('Table Analysis Details:', 'optistate')}</strong><ul class="os-m-5-0">`;
    25402540                        results.details.forEach(d => {
    … …  
    25732573                }
    25742574            } 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');
    25762576                isProcessing = false;
    25772577                $('.optistate-advanced-op-btn').prop('disabled', false);
    … …  
    25962596            manual_refresh: 1
    25972597        }).done(function(response) {
    2598             if (response?.success && response.data) {
     2598            if ((response == null ? undefined : response.success) && response.data) {
    25992599                displayOptimizationLog(response.data);
    26002600                showToast(__('Activity Log refreshed', 'optistate'), 'info');
    … …  
    26412641            timeout: 60000,
    26422642            success: function(response) {
    2643                 if (response?.success && response.data) {
     2643                if ((response == null ? undefined : response.success) && response.data) {
    26442644                    displayHealthScore(response.data);
    26452645                    if (forceRefresh) {
    … …  
    26502650                    }
    26512651                } 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'));
    26532653                }
    26542654            },
    26552655            error: function(xhr) {
    26562656                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');
    26582658                    return;
    26592659                }
    26602660                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)) {
    26622662                    errorMsg = xhr.responseJSON.data.message;
    26632663                }
    … …  
    27002700        const $recommendations = $('#health-score-recommendations-list');
    27012701        $recommendations.empty();
    2702         if (scoreData.recommendations?.length > 0) {
     2702        if ((scoreData.recommendations == null ? undefined : scoreData.recommendations.length) > 0) {
    27032703            scoreData.recommendations.forEach(rec => {
    27042704                if (!rec.message || !rec.urgency) return;
    … …  
    27502750                nonce: optistate_Ajax.nonce
    27512751            }).done(function(response) {
    2752                 if (response?.success && response.data) {
     2752                if ((response == null ? undefined : response.success) && response.data) {
    27532753                    displayTableAnalysis(response.data);
    27542754                    $results.slideDown(300);
    27552755                    $btn.find('.dashicons').removeClass('dashicons-search').addClass('dashicons-arrow-up-alt2');
    27562756                } else {
    2757                     showToast(response?.data || __('Failed to analyze tables', 'optistate'), 'error');
     2757                    showToast((response == null ? undefined : response.data) || __('Failed to analyze tables', 'optistate'), 'error');
    27582758                }
    27592759            }).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');
    27612761            }).always(function() {
    27622762                $loading.fadeOut(200);
    … …  
    27822782                    table_name: tableName
    27832783                }).done(function(response) {
    2784                     if (response?.success) {
     2784                    if ((response == null ? undefined : response.success)) {
    27852785                        showToast(response.data.message, 'success');
    27862786                        $btn.closest('.optistate-table-item').css('background-color', '#ffcccc').fadeOut(600, function() {
    … …  
    27902790                        loadTrashItems();
    27912791                    } 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');
    27932793                        $btn.prop('disabled', false).html(`<span class="dashicons dashicons-trash"></span> ${__('Delete Table', 'optistate')}`);
    27942794                    }
    … …  
    28302830            nextBatch();
    28312831        };
    2832         if (data.core_tables?.length > 0) {
     2832        if ((data.core_tables == null ? undefined : data.core_tables.length) > 0) {
    28332833            const coreCategory = document.createElement('div');
    28342834            coreCategory.className = 'optistate-table-category core-tables';
    … …  
    28372837            renderChunked(data.core_tables, coreCategory, true);
    28382838        }
    2839         if (data.plugin_tables?.length > 0) {
     2839        if ((data.plugin_tables == null ? undefined : data.plugin_tables.length) > 0) {
    28402840            const pluginCategory = document.createElement('div');
    28412841            pluginCategory.className = 'optistate-table-category plugin-tables';
    … …  
    28742874                nonce: optistate_Ajax.nonce
    28752875            }).done(function(response) {
    2876                 if (response?.success) {
     2876                if ((response == null ? undefined : response.success)) {
    28772877                    const recs = response.data.recommendations;
    28782878                    if (recs.length === 0) {
    … …  
    28882888                    $results.slideDown(300);
    28892889                } else {
    2890                     showToast(response?.data?.message || 'Analysis failed', 'error');
     2890                    showToast((response == null || response.data == null ? undefined : response.data.message) || 'Analysis failed', 'error');
    28912891                }
    28922892            }).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');
    28942894            }).always(() => {
    28952895                $loading.fadeOut(200);
    … …  
    30093009                    }
    30103010                }).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');
    30123012                    showToast(msg, 'error');
    30133013                    $btn.prop('disabled', false).html(__('🗑 Delete All', 'optistate'));
    … …  
    31503150                if (response.success) renderIntegrityResults(response.data);
    31513151                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(() => {
    31533153                $loading.fadeOut(200);
    31543154                $btn.prop('disabled', false);
    … …  
    32383238            const $elements = initCacheStatsElements();
    32393239            const update = () => {
    3240                 const data = response?.success ? response.data : null;
     3240                const data = (response == null ? undefined : response.success) ? response.data : null;
    32413241                const errorText = __('Error', 'optistate');
    32423242                $elements.fileCount.text(data ? (typeof data.file_count === 'number' ? data.file_count.toLocaleString() : data.file_count) : errorText);
    … …  
    33373337            isSaveAction: true,
    33383338            onSuccess: function(response) {
    3339                 if (response?.success) {
     3339                if ((response == null ? undefined : response.success)) {
    33403340                    showToast(successMessage, 'success');
    33413341                    debouncedLoadOptimizationLog();
    33423342                } 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');
    33443344                }
    33453345            }
    … …  
    33673367            nonce: optistate_Ajax.nonce
    33683368        }).done(function(response) {
    3369             if (response?.success && response.data) {
     3369            if ((response == null ? undefined : response.success) && response.data) {
    33703370                displayPerformanceFeatures(
    33713371                    response.data.definitions,
    … …  
    35303530            }
    35313531        }).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');
    35333533            const type = xhr.status === 429 ? 'warning' : 'error';
    35343534            showToast(msg, type);
    … …  
    42354235                        nonce: optistate_Ajax.nonce
    42364236                    }).done(res => {
    4237                         if (res?.success) {
     4237                        if ((res == null ? undefined : res.success)) {
    42384238                            showToast(res.data.message || __('Cache successfully purged!', 'optistate'), 'success');
    42394239                            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'))
    42424242                    .always(() => {
    42434243                        $btn.prop('disabled', false).html(`🗑️ ${__('Purge All Cache', 'optistate')}`);
    … …  
    42614261                nonce: optistate_Ajax.nonce
    42624262            }).done(res => {
    4263                 if (res?.success) {
     4263                if ((res == null ? undefined : res.success)) {
    42644264                    showToast(res.data.message, 'info');
    42654265                    $('#preload-status-text').html(`<strong>${__('Preload stopped by user.', 'optistate')}</strong>`);
    … …  
    42734273                }
    42744274            }).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');
    42764276                $btn.prop('disabled', false).html(`🟥 ${__('Stop', 'optistate')}`);
    42774277                isPreloadCancelled = false;
    … …  
    42914291            return {
    42924292                writable: false,
    4293                 message: data?.message || __('Network error', 'optistate'),
    4294                 exists: data?.exists
     4293                message: (data == null ? undefined : data.message) || __('Network error', 'optistate'),
     4294                exists: (data == null ? undefined : data.exists)
    42954295            };
    42964296        });
    … …  
    43334333            nonce: optistate_Ajax.nonce
    43344334        }).done(res => {
    4335             if (res?.success) {
     4335            if ((res == null ? undefined : res.success)) {
    43364336                showToast(res.data.message, 'info');
    43374337                pollPreloadStatus();
    … …  
    43854385                    }), 4000);
    43864386                } 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));
    43884388        });
    43894389        $('#optistate-settings-file-input').on('change', function() {
    … …  
    45914591            }).fail((xhr) => {
    45924592                $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');
    45944594            });
    45954595        });
    … …  
    46734673                showToast(
    46744674                    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')),
    46774677                    xhr.status === 429 ? 'warning' : 'error'
    46784678                );
    … …  
    47234723
    47244724            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) {
    47264726                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>`;
    47274727                data.preview.forEach(item => {
    47284728                    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>`;
    47294729                });
    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);
    47314731                if (data.total_matches > occurrencesShown) {
    47324732                    previewHtml += `<tr><td colspan="4" class="os-text-center"><em>${sprintf(__('%s more matches...', 'optistate'), (data.total_matches - occurrencesShown).toLocaleString())}</em></td></tr>`;
    … …  
    49394939
    49404940            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({
    49434943                    borderLeft: `4px solid ${val <= thresholds.good ? '#28a745' : (val <= thresholds.needsImprovement ? '#ffa400' : '#dc3545')}`,
    49444944                    paddingLeft: '11px'
    … …  
    49924992
    49934993            const $recsList = $('#optistate-psi-recommendations-list');
    4994             if (data.recommendations?.length > 0) {
     4994            if ((data.recommendations == null ? undefined : data.recommendations.length) > 0) {
    49954995                const colors = {
    49964996                    high: '#C13048',
    … …  
    50615061            nonce: optistate_Ajax.nonce
    50625062        }).done(function(response) {
    5063             if (response?.success && response.data) {
     5063            if ((response == null ? undefined : response.success) && response.data) {
    50645064                const data = response.data;
    50655065                if (data.status === 'running') {
    … …  
    51065106            nonce: optistate_BackupMgr.nonce
    51075107        }).done(function(response) {
    5108             if (response?.success && response.data) {
     5108            if ((response == null ? undefined : response.success) && response.data) {
    51095109                if (response.data.status === 'running' && response.data.transient_key) {
    51105110                    $(SELECTORS.globalButtons).prop('disabled', true);
    … …  
    51615161        loadCacheStats(function(response) {
    51625162            $btn.prop('disabled', false);
    5163             if (response?.success) {
     5163            if ((response == null ? undefined : response.success)) {
    51645164                showToast(__('Cache statistics refreshed successfully.', 'optistate'), 'success');
    51655165            } else {
    … …  
    51905190        const items = Array.isArray(payload) ? payload : (Array.isArray(data.items) ? data.items : []);
    51915191        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        }
    51925200        const $list = $('#optistate-trash-list');
    51935201        let $actions = $('#optistate-trash-actions');
  • optistate/trunk/includes/class-optistate-admin-interface.php

    r3625722 r3625928  
    210210     "optistate"
    211211 ); ?></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()
    213213); ?>" class="os-input-password-padded" placeholder="<?php esc_attr_e(
    214214    "Enter API Key",
    … …  
    320320    "Refresh Cleanup Data",
    321321    "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",
    324382    "optistate"
    325383); ?></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(
    352384    $manual_base . "#ch-4-1"
    353385); ?>" 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  
    185185    public function ajax_upload_restore_file(): void
    186186    {
    187         if (!$this->main_plugin->verify_ajax_request('optistate_backup_nonce')) {
     187        if (!$this->main_plugin->verify_ajax_request(OPTISTATE::BACKUP_NONCE_ACTION)) {
    188188            return;
    189189        }
  • optistate/trunk/includes/class-optistate-cleanup-functions.php

    r3625722 r3625928  
    21472147            wp_using_ext_object_cache()
    21482148        ) {
    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                );
    21522154                return $flushed_transient && $flushed_site_transient ? 1 : 0;
    21532155            } elseif (function_exists("wp_cache_flush")) {
  • optistate/trunk/includes/class-optistate-search-replace.php

    r3625722 r3625928  
    13811381        $network_id = is_multisite() ? (int) get_current_network_id() : 0;
    13821382        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()) {
    13881384                wp_cache_flush_group("options");
    13891385                if ($network_id > 0) {
Note: See TracChangeset for help on using the changeset viewer.