TS\WonderfulRelations\System\ChildPlugin\AbstractChildPlugin is the abstract base class every Wonderful Relations child plugin (and the mother plugin itself) extends. It owns the entire boot- and lifecycle flow so a concrete provider only has to declare what makes it unique.

Required override

abstract protected static function make_context(): ChildPluginContext;

Return an immutable ChildPluginContext that describes the plugin. The result is cached and bound to the subclass once per process.

Constructor responsibilities

new YourPlugin() is invoked from the plugin’s main file. The constructor:

  1. Registers register_activation_hook( $main_file, [static::class, 'activate'] ).
  2. For the mother plugin (as_mother()), registers the deactivation hook and listens for plugins_loaded to install the kernel.
  3. For child plugins, registers a deactivation hook lazily and listens for the WR mother’s wonderful_relations_plugin_loaded action so modules boot only after WR is initialized.
  4. Calls the optional on_boot() template method for one-shot setup that needs to run on every request (e.g. setting WordPress timezone, hooking into upgrader_process_complete).

Template methods

You can override these without touching the boot flow:

  • protected function on_boot(): void — invoked from the constructor on every request.
  • protected static function on_activate(): void — mother-only post-activation hook (run once when the user activates the plugin).
  • protected static function on_deactivate(): void — runs after a child plugin is deactivated. The mother runs it after the cascade signal.

Static accessors

Mirrors the legacy Plugin.php API so existing Modules code keeps working without changes:

Static callReturns
static::context()The bound ChildPluginContext
static::version()Plugin version
static::slug()Plugin slug
static::textdomain()Configured textdomain
static::plugin_title()Human-readable title
static::main_file()Absolute path of the main plugin file
static::plugin_name()folder/file.php style identifier
static::root_dir()…/your-plugin/src/
static::base_dir()your-plugin
static::get_db_version()Stored DB version (option <plugin>_db_version)
static::has_database_config()true if src/Database/Config/config.json exists
static::is_update_pending()true while DB version lags behind plugin version

Update notice

When is_update_pending() is true, AbstractChildPlugin automatically registers a non-dismissible red admin banner that links to the Update Center. Modules are not booted while the update is pending — see Kernel for the gating logic.