Skip to content

Split Admin god-class into focused collaborator classes. - #1992

Open
shadyvb wants to merge 2 commits into
ticket/XWPENG-48-plugin-bootfrom
ticket/XWPENG-49-admin-split
Open

Split Admin god-class into focused collaborator classes.#1992
shadyvb wants to merge 2 commits into
ticket/XWPENG-48-plugin-bootfrom
ticket/XWPENG-49-admin-split

Conversation

@shadyvb

@shadyvb shadyvb commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Fixes XWPENG-49.

Stacks on #1991 (ticket/XWPENG-48-plugin-boot).

Admin had grown into a god-class (~1,900 lines) mixing menu registration, asset loading, screen rendering, Ajax handlers, and purge/erase scheduling. This PR extracts those concerns into six focused collaborator classes while keeping Admin as a thin façade for cross-cutting behaviour (init, capabilities, notices, shared constants, and plugin action links). Hook registration is colocated on each collaborator using named array( $this, 'method' ) callbacks; runtime behaviour and hook names are unchanged.

Summary

  • Admin_Menu — admin menu/submenu registration, screen IDs, and multisite site-access gating.
  • Admin_Assetsadmin_enqueue_scripts, admin body class, and menu CSS.
  • Admin_Screen_Records — records list-table construction and render callback.
  • Admin_Screen_Settings — settings page render, option registration, and feature-request notice.
  • Admin_Ajax — reset, orphan-meta cleanup, filter autocomplete, and redirect confirmation notices.
  • Admin_Purge — TTL auto-purge scheduling (Action Scheduler / WP-Cron), batched erase, orphan-meta reaper, and large-table cron warnings.
  • Admin — retains purge-related constants, capability filters, notice pipeline, init() wiring for Network / Live_Update / Export, and exposes public collaborator properties for Network, Export, and Settings call sites.
  • Call-site updatesNetwork, Export, Settings, and Ability_Purge_Records now target collaborators directly (e.g. $admin->menu, $admin->purge) instead of monolithic Admin methods.
  • Tests — new PHPUnit coverage per collaborator (Admin_Menu_Test, Admin_Assets_Test, Admin_Ajax_Test, Admin_Purge_Test, Admin_Screen_*_Test); Admin_Test slimmed to façade concerns; testcase.php gains helpers for constructing collaborators in isolation.

Checklist

  • Project documentation has been updated to reflect the changes in this pull request, if applicable.
  • I have tested the changes in the local development environment (see contributing.md).
  • I have added phpunit tests.

Release Changelog

  • Internal: Split the Admin god-class into focused collaborator classes to improve testability and maintainability. No user-facing behaviour change.

Release Checklist

  • This pull request is to the master branch.
  • Release version follows semantic versioning. Does it include breaking changes?
  • Update changelog in readme.txt.
  • Bump version in stream.php.
  • Bump Stable tag in readme.txt.
  • Bump version in classes/class-plugin.php.
  • Draft a release on GitHub.

Test plan

  • CI Lint and Test (PHP 8.2 / 8.3 / 8.4) pass
  • CI E2E (PHP 8.2 / 8.3 / 8.4) pass
  • composer lint-php passes on PR-changed files
  • New collaborator PHPUnit suites cover menu, assets, Ajax, purge, and screen rendering
  • Existing Admin_Cron_Purge_Test and Scheduler_Handoff_Test updated for collaborator entry points

Extract menu, assets, screens, Ajax, and purge logic from Admin into
dedicated classes with hook registration colocated per collaborator,
while Admin retains cross-cutting init, caps, notices, and constants.
Bring the new Admin split test classes in line with the tests coding standard so lint stays green after the god-class extraction.
@shadyvb shadyvb changed the title ticket/XWPENG 49 admin split Split Admin god-class into focused collaborator classes. Sep 5, 2026
@shadyvb
shadyvb marked this pull request as ready for review September 6, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant