trait Plugin_Upgrader_Trait

A trait to extend the Plugin functionality by providing methods for running tasks on version updates.

Properties

static protected string $upgrades_dir

Methods

init_upgrader()

Check if the Upgraders need to be run, then run them and update the current version if so.

bool
requires_version_upgrade()

Check if the Plugin version is newer than the currently stored version.

run_upgrades()

Find all upgrade Schemas and run them.

update_current_version()

Update the current Plugin version in the database.

static array
sort_upgrade_schemas(array $upgrade_schemas)

Sort Schema actions by version.

static 
execute_schemas(string $current_version, array $upgrade_schemas)

Loop through and execute all Schema actions.

Details

at line 34
final init_upgrader()

Check if the Upgraders need to be run, then run them and update the current version if so.

at line 46
final bool requires_version_upgrade()

Check if the Plugin version is newer than the currently stored version.

Return Value

bool

Whether or not there may be upgrade actions to run.

at line 63
final run_upgrades()

Find all upgrade Schemas and run them.

at line 103
final update_current_version()

Update the current Plugin version in the database.

at line 115
final static array sort_upgrade_schemas(array $upgrade_schemas)

Sort Schema actions by version.

Parameters

array $upgrade_schemas

The Upgrade Schemas.

Return Value

array

The sorted Upgrade Schemas.

at line 142
final static execute_schemas(string $current_version, array $upgrade_schemas)

Loop through and execute all Schema actions.

Parameters

string $current_version

The current stored version; run all actions newer.

array $upgrade_schemas

The upgrade Schema actions.