| 1 |
<?php |
| 2 |
/** |
| 3 |
* Addon Interface. |
| 4 |
* |
| 5 |
* @version 1.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace StoreEngine\Interfaces; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
interface AddonInterface { |
| 15 |
|
| 16 |
/** |
| 17 |
* Initialize singleton addon. |
| 18 |
* |
| 19 |
* @return AddonInterface |
| 20 |
*/ |
| 21 |
public static function init(); |
| 22 |
|
| 23 |
/** |
| 24 |
* Define constants. |
| 25 |
* Developers are encourage to use Class Constants |
| 26 |
* |
| 27 |
* @return void |
| 28 |
*/ |
| 29 |
public function define_constants(); |
| 30 |
|
| 31 |
/** |
| 32 |
* Loads the addon. |
| 33 |
* |
| 34 |
* @return void |
| 35 |
*/ |
| 36 |
public function init_addon(); |
| 37 |
|
| 38 |
/** |
| 39 |
* Trigger once during addon activation. |
| 40 |
* |
| 41 |
* @return void |
| 42 |
*/ |
| 43 |
public function addon_activation_hook(); |
| 44 |
|
| 45 |
/** |
| 46 |
* Trigger once during addon deactivation. |
| 47 |
* |
| 48 |
* @return void |
| 49 |
*/ |
| 50 |
public function addon_deactivation_hook(); |
| 51 |
|
| 52 |
/** |
| 53 |
* Current schema version of the addon's own tables. |
| 54 |
* |
| 55 |
* Return a version string (e.g. a STOREENGINE_<ADDON>_DB_VERSION constant). |
| 56 |
* Bump it whenever the addon's schema files change so the central manager |
| 57 |
* (Addons::sync_addon_schemas) reruns install_tables(). Return an empty |
| 58 |
* string when the addon has no tables of its own. |
| 59 |
* |
| 60 |
* @return string |
| 61 |
*/ |
| 62 |
public function get_db_version(): string; |
| 63 |
|
| 64 |
/** |
| 65 |
* (Re)create the addon's tables via dbDelta. |
| 66 |
* |
| 67 |
* Called by the central schema manager when get_db_version() differs from |
| 68 |
* the stored value. Must be idempotent. |
| 69 |
* |
| 70 |
* @return void |
| 71 |
*/ |
| 72 |
public function install_tables(): void; |
| 73 |
} |
| 74 |
|