File tree Expand file tree Collapse file tree 5 files changed +46
-20
lines changed
Expand file tree Collapse file tree 5 files changed +46
-20
lines changed Original file line number Diff line number Diff line change 2121
2222define ('SimpleAnalytics \\PLUGIN_URL ' , plugin_dir_url (__FILE__ ));
2323define ('SimpleAnalytics \\PLUGIN_PATH ' , plugin_dir_path (__FILE__ ));
24+ define ('SimpleAnalytics \\ENTRYPOINT_FILE ' , __FILE__ );
2425
2526/**
2627 * @note Manual loading rather than Composer to avoid potential conflict with plugins/themes that ship older autoloader.
2728 */
2829require __DIR__ . '/src/Support/SvgIcon.php ' ;
2930require __DIR__ . '/helpers.php ' ;
31+ require __DIR__ . '/src/PluginLifecycle.php ' ;
3032require __DIR__ . '/src/Plugin.php ' ;
3133require __DIR__ . '/src/Setting.php ' ;
3234require __DIR__ . '/src/SettingName.php ' ;
Original file line number Diff line number Diff line change 1111
1212class Plugin
1313{
14- public function boot (): void
14+ use PluginLifecycle;
15+
16+ protected function onBoot (): void
1517 {
16- add_action ('init ' , $ this ->onInit (...));
17- is_admin () && $ this ->defineAdminPage ();
18+ if (is_admin ()) $ this ->defineAdminPage ();
19+ }
20+
21+ public function onActivation (): void
22+ {
23+
24+ }
25+
26+ public function onDeactivation (): void
27+ {
28+
1829 }
1930
2031 public function onInit (): void
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SimpleAnalytics ;
4+
5+ trait PluginLifecycle
6+ {
7+ public function boot (): void
8+ {
9+ $ this ->onBoot ();
10+ add_action ('init ' , $ this ->onInit (...));
11+ register_activation_hook (ENTRYPOINT_FILE , $ this ->onActivation (...));
12+ register_deactivation_hook (ENTRYPOINT_FILE , $ this ->onDeactivation (...));
13+ }
14+
15+ abstract protected function onBoot (): void ;
16+
17+ abstract public function onInit (): void ;
18+
19+ abstract public function onActivation (): void ;
20+
21+ abstract public function onDeactivation (): void ;
22+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SimpleAnalytics ;
4+
5+ readonly class SettingsData
6+ {
7+
8+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments