File tree Expand file tree Collapse file tree 6 files changed +36
-10
lines changed
Expand file tree Collapse file tree 6 files changed +36
-10
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 \\PLUGIN_BASENAME ' , plugin_basename (__FILE__ ));
2425define ('SimpleAnalytics \\ENTRYPOINT_FILE ' , __FILE__ );
2526
2627/**
4344require __DIR__ . '/src/Actions/Action.php ' ;
4445require __DIR__ . '/src/Actions/AddInactiveComment.php ' ;
4546require __DIR__ . '/src/Actions/AddNoScriptTag.php ' ;
47+ require __DIR__ . '/src/Actions/AddPluginSettingsLink.php ' ;
4648require __DIR__ . '/src/Support/Str.php ' ;
4749require __DIR__ . '/src/Settings/Block.php ' ;
4850require __DIR__ . '/src/Settings/Blocks/CalloutBlock.php ' ;
Original file line number Diff line number Diff line change 22
33namespace SimpleAnalytics \Actions ;
44
5- abstract class Action
5+ trait Action
66{
7- protected string $ hook ;
8-
9- abstract public function handle ();
10-
117 protected function hook (): string
128 {
139 return $ this ->hook ;
Original file line number Diff line number Diff line change 22
33namespace SimpleAnalytics \Actions ;
44
5- class AddInactiveComment extends Action
5+ class AddInactiveComment
66{
7+ use Action;
8+
79 protected string $ hook = 'wp_footer ' ;
810
9- #[\Override]
1011 public function handle (): void
1112 {
1213 echo "<!-- Simple Analytics: Not logging requests from admins --> \n" ;
Original file line number Diff line number Diff line change 55use SimpleAnalytics \Setting ;
66use SimpleAnalytics \SettingName ;
77
8- class AddNoScriptTag extends Action
8+ class AddNoScriptTag
99{
10+ use Action;
11+
1012 protected string $ hook = 'wp_footer ' ;
1113
12- #[\Override]
1314 public function handle (): void
1415 {
1516 echo sprintf ("<noscript><img src= \"%s \" alt= \"\" referrerpolicy= \"no-referrer-when-downgrade \"></noscript> \n" , $ this ->getCustomDomain ());
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SimpleAnalytics \Actions ;
4+
5+ use const SimpleAnalytics \PLUGIN_BASENAME ;
6+
7+ /**
8+ * Adds a "Settings" link to the installed plugin list page.
9+ */
10+ class AddPluginSettingsLink
11+ {
12+ use Action;
13+
14+ protected string $ hook = 'plugin_action_links_ ' . PLUGIN_BASENAME ;
15+
16+ public function handle ($ links ): array
17+ {
18+ $ link = '<a href="options-general.php?page=simpleanalytics"> ' . __ ('Settings ' , 'simpleanalytics ' ) . '</a> ' ;
19+
20+ return [$ link ] + $ links ;
21+ }
22+ }
Original file line number Diff line number Diff line change 55use SimpleAnalytics \Settings \{Page , Tab };
66use SimpleAnalytics \Actions \AddInactiveComment ;
77use SimpleAnalytics \Actions \AddNoScriptTag ;
8+ use SimpleAnalytics \Actions \AddPluginSettingsLink ;
89use SimpleAnalytics \Scripts \AnalyticsScript ;
910use SimpleAnalytics \Scripts \AutomatedEventsScript ;
1011use SimpleAnalytics \Scripts \InactiveScript ;
@@ -16,7 +17,10 @@ final class Plugin
1617 #[\Override]
1718 protected function onBoot (): void
1819 {
19- if (is_admin ()) $ this ->defineAdminPage ();
20+ if (is_admin ()) {
21+ $ this ->defineAdminPage ();
22+ AddPluginSettingsLink::register ();
23+ }
2024 }
2125
2226 #[\Override]
You can’t perform that action at this time.
0 commit comments