Skip to content

Extract Alerts admin UI and trigger engine into collaborators. - #1995

Open
shadyvb wants to merge 2 commits into
ticket/XWPENG-51-settings-splitfrom
ticket/XWPENG-52-alerts-split
Open

Extract Alerts admin UI and trigger engine into collaborators.#1995
shadyvb wants to merge 2 commits into
ticket/XWPENG-51-settings-splitfrom
ticket/XWPENG-52-alerts-split

Conversation

@shadyvb

@shadyvb shadyvb commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Fixes XWPENG-52.

Extracts two collaborators from the monolithic Alerts class so admin UI concerns and record-matching logic can be unit-tested without booting WordPress. Alerts remains the registry for alert types, triggers, and post-type registration; it wires Alerts_Admin_UI and Alerts_Trigger_Engine as public properties so in-plugin callers can reach them directly.

Alerts_Admin_UI owns the Alerts admin experience: submenu registration, network-admin menu URL rewriting, script enqueue on the alerts list screen, meta-box/AJAX form rendering (display_*_box, load_alerts_settings, save_new_alert, get_actions, get_new_alert_triggers_notifications), and alert-specific action links.

Alerts_Trigger_Engine owns record matching: hooks wp_stream_record_inserted, hydrates enabled alerts, and exposes matching_alerts() so filtering logic (including the wp_stream_alert_trigger_check filter via Alert::check_record()) is testable in isolation before send_alert() runs.

Alerts_List quick-edit now delegates display callbacks to $plugin->alerts->admin_ui. Integration tests in Alerts_Test were updated to call the collaborators; new Brain Monkey unit suites cover notification-value mapping, form output, menu URL rewriting, script enqueue guards, matching_alerts() filtering, and check_records() hydration/send behavior.

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

N/A — internal refactor with no user-facing behavior 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.

…s, AJAX, and record matching can be unit-tested without booting WordPress.
@shadyvb shadyvb changed the title ticket/XWPENG 52 alerts split Extract Alerts admin UI and trigger engine into collaborators. Sep 5, 2026
@shadyvb
shadyvb marked this pull request as ready for review September 6, 2026 20:27
Move WP_Query and WP_Roles stubs into dedicated files, add phpcs:ignore
for intentional $GLOBALS overrides in menu tests, and fix foreach closing
comment formatting so lint-tests passes in CI.
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