PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 3.3.9
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v3.3.9
3.3.9 3.3.8 trunk 1.0 1.1.0 1.10.0 1.11.0 1.11.1 1.12.0 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 All 67 releases
logtivity / assets / logtivity-register.php

logtivity-register.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 3.3.9, at assets/logtivity-register.php

56 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Logtivity Site Registration
5 */
6
7 abstract class Logtivity_Register
8 {
9 /**
10 * Enter your Team API Key here
11 *
12 * @var string
13 */
14 protected static string $teamApi = 'YOUR-TEAM-APIKEY-HERE';
15
16 /**
17 * @var WP_Error|Logtivity_Response|null
18 */
19 protected static $response = null;
20
21 public static function register()
22 {
23 $apiKey = get_option('logtivity_site_api_key');
24 if (empty($apiKey) && is_callable([Logtivity::class, 'registerSite'])) {
25 static::$response = Logtivity::registerSite(static::$teamApi);
26 }
27
28 add_action('admin_notices', [static::class, 'adminMessage']);
29 }
30
31 /**
32 * @return void
33 */
34 public static function adminMessage()
35 {
36 if (static::$response instanceof WP_Error) {
37 $message = static::$response->get_error_message();
38 $status = 'error';
39
40 } elseif (static::$response instanceof Logtivity_Response) {
41 $message = static::$response->message;
42 $status = 'success';
43 }
44
45 if (empty($message) === false) {
46 echo sprintf(
47 '<div class="notice notice-%s"><p>%s</p></div>',
48 $status,
49 $message
50 );
51 }
52 }
53 }
54
55 add_action('init', [Logtivity_Register::class, 'register']);
56