# Dead Code Audit — multilingual-press-zone

Generated: 2026-03-14

---

## Recommended Changes

Organized into 5 phases by risk level. Each phase should be a separate commit.

---

### Phase 1: Delete Test/Debug Artifacts (zero risk)

These files have no callers and no autoload references. Pure cleanup.

**Delete these files:**

```
rm tmp/verify-database.php
rm tmp/test-implementation.php
rm tmp/test-entities.php
rm tmp/test-cache-manager.php
rm tmp/test-cache-unit.php
rm tmp/test-language-manager.php
rm tmp/verify-language-manager.php
rm tmp/quick-verify.php
rm tmp/simple-test.php
rm tmp/test-frontend-components.php
rm tmp/verify-frontend-files.php
rm tmp/test-activation.php
rm tmp/verify-fix-wp.php
rm tests/verify-dashboard-stats.php
rm tests/performance/load-test.php
rm admin/src/components/test-sortable.js
rm admin/src/components/SortableList.example.js
rm admin/src/components/LinkSelector.example.js
```

**Total: 18 files**

---

### Phase 2: Delete Dead PHP Subsystems (low risk — never instantiated, autoloaded on demand but never demanded)

These entire directories/files are never instantiated anywhere. The autoloader only loads them if someone `new`s them, and nobody does.

**Delete entire directories:**

```
rm -r includes/Security/          # 5 files: SQLInjectionPrevention, XSSPrevention, InputValidator, OutputEscaper, CSRFProtection
rm -r includes/Database/          # 5 files: ArchiveManager, CompressionManager, IndexOptimizer, QueryRouter, PartitionManager
rm -r includes/Compatibility/     # 5 files: CompatibilityManager, ACFIntegration, WooCommerceIntegration, ElementorIntegration, YoastSEOIntegration
rm -r includes/Glossary/          # 1 file: GlossaryManager
rm -r includes/TranslationMemory/ # 2 files: MemoryManager, FuzzyMatcher
```

**Delete individual files:**

```
rm includes/Core/SentryIntegration.php    # init() never called, placeholder DSN
rm includes/Performance/CDNIntegration.php # Never instantiated, references undefined functions
rm includes/Performance/ConnectionPool.php # Full mysqli pool, never instantiated
rm includes/API/TeamController.php         # Dead REST controller, never registered (TeamRestController is the live one)
```

**Total: 21 files**

---

### Phase 3: Delete Dead Admin Controllers (low risk — replaced by SPA architecture)

These server-rendered page controllers were replaced by the SPA. They are never instantiated.

**Delete these files:**

```
rm includes/Admin/DashboardController.php
rm includes/Admin/AnalyticsController.php
rm includes/Admin/LicensingController.php
rm includes/Admin/TranslationsController.php
rm includes/Admin/LanguagesController.php
rm includes/Admin/SettingsController.php
rm includes/Admin/MigrationController.php
rm includes/Admin/OnboardingWizard.php
```

**Edit `includes/Admin/MenuController.php`:**
- Remove the 6 nullable property declarations (lines ~41–66) for the deleted controllers
- Remove the dead private method `isPluginPage()` (lines ~215–223)
- Keep `getAvailableLanguages()` — it's the live copy (the duplicate in the now-deleted LanguagesController goes away with the file deletion)

**Total: 8 files deleted, 1 file edited**

---

### Phase 4: Clean Up Plugin.php and Dead JS (medium risk — changes active code paths)

#### 4a. Remove unused property instantiations from `Plugin.php`

**Edit `includes/Core/Plugin.php`:**
- Remove property declarations for `$activityTracker`, `$performanceMetrics`, `$timeTracker` (lines 55, 65, 70)
- Remove their instantiation in `loadDependencies()` (lines 138–144)
- These objects are constructed every request but never read — pure waste

**Note:** Do NOT delete the Team classes themselves (`ActivityTracker`, `PerformanceMetrics`, `TimeTracker`) — they are used by `TeamRestController` which instantiates them independently.

#### 4b. Remove dead JS pages and components

**Delete these files:**

```
rm admin/src/pages/TeamDashboard.js
rm admin/src/pages/WorkflowDashboard.js
rm admin/src/pages/my-assignments.js
rm admin/src/components/FormField.js
```

**Note on `admin/src/pages/analytics.js`:** Keep this file. Even though the standalone page route redirects to dashboard, the analytics _section_ (`admin/src/sections/analytics-dashboard.js`) is actively embedded in the dashboard. The standalone page may be wired up later. Low value deletion with potential breakage if the section imports from it.

#### 4c. Clean up main.js

**Edit `admin/src/main.js`:**
- Remove the `renderAnalytics()` method definition (~line 461) — never called
- Remove the static import of `LicensingPage` (line ~79) and the `window.MultilingualPressZone.LicensingPage` export — the dynamic import in `renderLicensing()` is the live path
- This reduces main bundle size

**Total: 4 files deleted, 2 files edited**

---

### Phase 5: Clean Up DatabasePool Read-Replica (low priority — not harmful, just unused)

**Edit `includes/Core/DatabasePool.php`:**
- Remove `$read_connection` property
- Remove `get_reader()` method
- Remove `connect_reader()` method

Nobody calls `get_reader()`. If read-replica support is needed in the future, it can be re-added.

**Total: 1 file edited**

---

### NOT Recommended for Deletion

| Item | Reason to Keep |
|------|---------------|
| `includes/Team/ActivityTracker.php` | Used by `TeamRestController` (it instantiates its own copy) |
| `includes/Team/PerformanceMetrics.php` | Used by `TeamRestController` |
| `includes/Team/TimeTracker.php` | Used by `TeamRestController` |
| `includes/Workflow/ProgressReporter.php` | Used by `Plugin.php` — property IS read (passed to controllers) |
| `includes/Performance/ObjectCache.php` | Used internally by `AsyncJobProcessor` |
| `includes/Performance/QueueManager.php` | Used by `AsyncJobProcessor` |
| `includes/CLI/CacheCommand.php` | Conditionally loaded under WP-CLI — legitimate |
| `admin/src/pages/analytics.js` | Analytics section is embedded in dashboard; low-value removal |
| `includes/Core/DatabasePartitioner.php` | Needs separate verification |
| `includes/API/DashboardController.php` | Active — registered at Plugin.php line 853 (different from `Admin\DashboardController`) |

---

### Duplicate REST Namespace (Informational — No Deletion)

Both `Admin\DashboardRestController` and `API\DashboardController` register routes under `multilingual-press-zone/v1/dashboard/`. They serve different sub-paths (`/stats` vs `/progress`, `/velocity`, etc.) so there's no actual collision. But consider consolidating into one controller class for clarity. This is a refactor, not dead code.

---

## Summary

| Phase | Files Deleted | Files Edited | Risk |
|-------|-------------|-------------|------|
| 1. Test artifacts | 18 | 0 | Zero |
| 2. Dead PHP subsystems | 21 | 0 | Low |
| 3. Dead admin controllers | 8 | 1 | Low |
| 4. Plugin.php + dead JS | 4 | 2 | Medium |
| 5. DatabasePool cleanup | 0 | 1 | Low |
| **Total** | **51** | **4** | |

After all phases: **rebuild JS** (`cd admin && npm run build`) to reflect the removed imports and dead code elimination.
