Documentation

PluginLifecycle
in package

FinalYes

Plugin activation/deactivation registrar.

Wires the WordPress plugin lifecycle to the adapter's own setup/teardown, routing every native call through LifecycleSupport so the platform coupling stays in the Support seam. On deactivation it calls CronRegistrar::unregister() so scheduled WP-Cron events do not survive the plugin being switched off.

Optional activation/deactivation callbacks let a consumer run extra setup/teardown (e.g. seeding options, dropping tables) on top of the built-in cron cleanup.

Table of Contents

Properties

$cronRegistrar  : CronRegistrar
$onActivate  : array<int, callable>
$onDeactivate  : array<int, callable>
$pluginFile  : string

Methods

__construct()  : mixed
activate()  : void
Activation entry point: runs registered activation callbacks.
deactivate()  : void
Deactivation entry point: runs registered deactivation callbacks, then clears every scheduled cron event so nothing survives deactivation.
onActivate()  : void
Add an extra callback to run on plugin activation.
onDeactivate()  : void
Add an extra callback to run on plugin deactivation (before cron cleanup).
register()  : void
Register the activation and deactivation hooks with WordPress.

Properties

Methods

__construct()

public __construct(string $pluginFile, CronRegistrar $cronRegistrar) : mixed
Parameters
$pluginFile : string

absolute path to the plugin's main file (the value WordPress keys its lifecycle hooks on)

$cronRegistrar : CronRegistrar

activate()

Activation entry point: runs registered activation callbacks.

public activate() : void

deactivate()

Deactivation entry point: runs registered deactivation callbacks, then clears every scheduled cron event so nothing survives deactivation.

public deactivate() : void

onActivate()

Add an extra callback to run on plugin activation.

public onActivate(callable $callback) : void
Parameters
$callback : callable

onDeactivate()

Add an extra callback to run on plugin deactivation (before cron cleanup).

public onDeactivate(callable $callback) : void
Parameters
$callback : callable

register()

Register the activation and deactivation hooks with WordPress.

public register() : void
On this page

Search results