| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @package Logtivity |
| 5 |
* @contact logtivity.io, hello@logtivity.io |
| 6 |
* @copyright 2025-2026 Logtivity. All rights reserved |
| 7 |
* @license https://www.gnu.org/licenses/gpl.html GNU/GPL |
| 8 |
* |
| 9 |
* This file is part of Logtivity. |
| 10 |
* |
| 11 |
* Logtivity is free software: you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License as published by |
| 13 |
* the Free Software Foundation, either version 2 of the License, or |
| 14 |
* (at your option) any later version. |
| 15 |
* |
| 16 |
* Logtivity is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with Logtivity. If not, see <https://www.gnu.org/licenses/>. |
| 23 |
*/ |
| 24 |
|
| 25 |
/** |
| 26 |
* @var string $fileName |
| 27 |
* @var array $vars |
| 28 |
* @var array $value |
| 29 |
* @var string $key |
| 30 |
* @var array $options |
| 31 |
*/ |
| 32 |
|
| 33 |
$api = new Logtivity_Api(); |
| 34 |
$apiKey = $api->getApiKey(); |
| 35 |
$latestResponse = $api->getLatestResponse(); |
| 36 |
$status = $api->getConnectionStatus(); |
| 37 |
|
| 38 |
echo logtivity_view('_admin-header', compact('options')); |
| 39 |
?> |
| 40 |
|
| 41 |
<div class="postbox logtivity-register"> |
| 42 |
<div class="inside"> |
| 43 |
<h1 style="padding-top: 20px; margin-bottom: 0;">Register This Site</h1> |
| 44 |
|
| 45 |
<?php if ($apiKey) : ?> |
| 46 |
<div class="logtivity-notice logtivity-notice-info"> |
| 47 |
<h2>The API Key has already been set</h2> |
| 48 |
</div> |
| 49 |
|
| 50 |
<?php else : ?> |
| 51 |
|
| 52 |
<div class="logtivity-notice logtivity-notice-info" style="width: fit-content; margin-bottom: 20px;"> |
| 53 |
<div> |
| 54 |
If you already have an account with Logtivity, you can register this site using your team API |
| 55 |
key. |
| 56 |
<br> |
| 57 |
You can find this value by logging into your account and navigating to the |
| 58 |
<?php echo sprintf( |
| 59 |
'<a href="%s" target="_blank">%s</a>.', |
| 60 |
logtivity_get_app_url() . '/team-settings', |
| 61 |
'Team Settings page' |
| 62 |
); |
| 63 |
?> |
| 64 |
</div> |
| 65 |
</div> |
| 66 |
|
| 67 |
<form action="<?php echo admin_url('admin-ajax.php'); ?>" |
| 68 |
id="logtivity-register-site" |
| 69 |
method="post"> |
| 70 |
<?php wp_nonce_field('logtivity_register_site', 'logtivity_register_site') ?> |
| 71 |
<input type="hidden" name="action" value="logtivity_register_site"> |
| 72 |
|
| 73 |
<table> |
| 74 |
<tbody> |
| 75 |
<tr class="user-user-login-wrap"> |
| 76 |
<th scope="row"> |
| 77 |
<label for="logtivity_team_api_key">Team API Key</label> |
| 78 |
</th> |
| 79 |
|
| 80 |
<td> |
| 81 |
<input id="logtivity_team_api_key" |
| 82 |
name="logtivity_team_api_key" |
| 83 |
type="text" |
| 84 |
class="regular-text"> |
| 85 |
</td> |
| 86 |
</tr> |
| 87 |
</tbody> |
| 88 |
</table> |
| 89 |
|
| 90 |
<p class="submit"> |
| 91 |
<input id="submit" |
| 92 |
name="submit" |
| 93 |
type="submit" |
| 94 |
class="button button-primary" |
| 95 |
value="Register Site"> |
| 96 |
</p> |
| 97 |
</form> |
| 98 |
<?php endif; ?> |
| 99 |
|
| 100 |
<div id="logtivity-register-response" role="status" aria-live="polite" aria-atomic="true"></div> |
| 101 |
</div> |
| 102 |
</div> |
| 103 |
|
| 104 |
<?php echo logtivity_view('_admin-footer', compact('options')); ?> |
| 105 |
|