PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.12.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.12.0
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 / Services / Logtivity_Register_Site.php

Logtivity_Register_Site.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 1.12.0, at Services/Logtivity_Register_Site.php

37 lines 804 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Logtivity_Register_Site
4 {
5 public static function execute($data = [])
6 {
7 $logtivity_options = new Logtivity_Options;
8
9 if ($logtivity_options->getApiKey()) {
10 return new WP_Error(
11 'logtivity_register_site_error',
12 __('You cannot register a site that already has an API Key.', 'logtivity')
13 );
14 }
15
16 $response = json_decode(
17 (new Logtivity_Api)->setApiKey($data['team_api_key'])
18 ->post('/sites', [
19 'name' => $data['name'] ?? home_url(),
20 'url' => $data['url'] ?? home_url(),
21 ])
22 );
23
24 if ($response && property_exists($response, 'message')) {
25 return wp_send_json(['response' => $response->message]);
26 }
27
28 $logtivity_options->update(
29 array_merge(
30 $data,
31 [
32 'logtivity_site_api_key' => $response->api_key
33 ]
34 )
35 );
36 }
37 }