-
Notifications
You must be signed in to change notification settings - Fork 0
Core Lifecycle
mab056 edited this page Feb 15, 2026
·
3 revisions
src/Core/Activator.php (activate()):
- sets option
ops_health_activated_at(first activation only) - sets option
ops_health_version - registers custom cron interval
every_15_minutes - schedules hook using constant
Scheduler::HOOK_NAME(ops_health_run_checks) if not already scheduled - interval taken from constant
Scheduler::INTERVAL(every_15_minutes)
src/Core/Plugin.php (init()):
- registers admin menu
- registers dashboard widget
- registers HealthScreen styles enqueue
- registers scheduler hooks
src/Services/Scheduler.php:
- cron hook:
ops_health_run_checks(constantHOOK_NAME) - interval:
every_15_minutes(constantINTERVAL) - throttled self-healing via transient
ops_health_cron_check(1h) -
run_checks():- reads previous results (if AlertManager is present)
- executes
run_all() - passes
(current, previous)to AlertManager - protects cron with
catch (\Throwable)
src/Core/Activator.php (deactivate()):
- removes cron hook
ops_health_run_checks - preserves plugin data
src/Core/Uninstaller.php
The uninstall() method detects the installation type and dispatches:
uninstall()
├── is_multisite() → uninstall_network()
│ └── for each blog: switch_to_blog() → uninstall_single() → restore_current_blog()
└── else → uninstall_single()
uninstall_network() uses get_sites( [ 'fields' => 'ids' ] ) to get all blog IDs in the network, then iterates with switch_to_blog()/restore_current_blog() executing uninstall_single() for each blog.
Cleanup performed by uninstall_single():
- plugin options (
ops_health_activated_at,ops_health_version,ops_health_latest_results,ops_health_alert_settings,ops_health_alert_log) - cron hook (
ops_health_run_checks) viawp_clear_scheduled_hook() - fixed transients (
ops_health_cron_check,ops_health_admin_notice,ops_health_alert_notice) - dynamic cooldown transients via
$wpdbquery (LIKE _transient_ops_health_alert_cooldown_%)
uninstall.php has three branches:
-
Autoloader available: loads
Uninstallerand delegates (handles multisite internally) -
Multisite fallback (
elseif is_multisite()): inline blog iteration with$ops_health_prefixed variables -
Single-site fallback (
else): direct inline cleanup
The WP_UNINSTALL_PLUGIN guard ensures the file is only executed during WordPress uninstallation.
For more details on multisite support, see Multisite Support.